tycono 0.1.73 → 0.1.74-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -48
- package/package.json +1 -1
- package/src/api/src/routes/execute.ts +17 -2
- package/src/api/src/routes/operations.ts +4 -1
- package/src/api/src/routes/sessions.ts +42 -14
- package/src/api/src/services/activity-stream.ts +5 -0
- package/src/api/src/services/job-manager.ts +72 -2
- package/src/api/src/services/wave-tracker.ts +217 -0
- package/src/web/dist/assets/index-0e6kn9Ne.js +108 -0
- package/src/web/dist/assets/index-BLBYHBP_.css +1 -0
- package/src/web/dist/assets/{preview-app-BT_tZB55.js → preview-app-B3kFNGV1.js} +1 -1
- package/src/web/dist/index.html +2 -2
- package/src/web/dist/assets/index-BQaKrdJG.css +0 -1
- package/src/web/dist/assets/index-DVuy5FDy.js +0 -108
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var ow=Object.defineProperty;var cw=(e,n,a)=>n in e?ow(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var k0=(e,n,a)=>cw(e,typeof n!="symbol"?n+"":n,a);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function a(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(o){if(o.ep)return;o.ep=!0;const u=a(o);fetch(o.href,u)}})();function Ng(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pf={exports:{}},bo={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var j0;function uw(){if(j0)return bo;j0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(i,o,u){var d=null;if(u!==void 0&&(d=""+u),o.key!==void 0&&(d=""+o.key),"key"in o){u={};for(var h in o)h!=="key"&&(u[h]=o[h])}else u=o;return o=u.ref,{$$typeof:e,type:i,key:d,ref:o!==void 0?o:null,props:u}}return bo.Fragment=n,bo.jsx=a,bo.jsxs=a,bo}var S0;function dw(){return S0||(S0=1,Pf.exports=uw()),Pf.exports}var l=dw(),Zf={exports:{}},ht={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react.production.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var C0;function fw(){if(C0)return ht;C0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),v=Symbol.iterator;function b(F){return F===null||typeof F!="object"?null:(F=v&&F[v]||F["@@iterator"],typeof F=="function"?F:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,N={};function C(F,q,T){this.props=F,this.context=q,this.refs=N,this.updater=T||j}C.prototype.isReactComponent={},C.prototype.setState=function(F,q){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,q,"setState")},C.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function E(){}E.prototype=C.prototype;function R(F,q,T){this.props=F,this.context=q,this.refs=N,this.updater=T||j}var M=R.prototype=new E;M.constructor=R,k(M,C.prototype),M.isPureReactComponent=!0;var I=Array.isArray;function B(){}var L={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function Q(F,q,T){var de=T.ref;return{$$typeof:e,type:F,key:q,ref:de!==void 0?de:null,props:T}}function A(F,q){return Q(F.type,q,F.props)}function $(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function U(F){var q={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(T){return q[T]})}var ee=/\/+/g;function oe(F,q){return typeof F=="object"&&F!==null&&F.key!=null?U(""+F.key):q.toString(36)}function ne(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(B,B):(F.status="pending",F.then(function(q){F.status==="pending"&&(F.status="fulfilled",F.value=q)},function(q){F.status==="pending"&&(F.status="rejected",F.reason=q)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function Y(F,q,T,de,Ne){var ye=typeof F;(ye==="undefined"||ye==="boolean")&&(F=null);var _e=!1;if(F===null)_e=!0;else switch(ye){case"bigint":case"string":case"number":_e=!0;break;case"object":switch(F.$$typeof){case e:case n:_e=!0;break;case x:return _e=F._init,Y(_e(F._payload),q,T,de,Ne)}}if(_e)return Ne=Ne(F),_e=de===""?"."+oe(F,0):de,I(Ne)?(T="",_e!=null&&(T=_e.replace(ee,"$&/")+"/"),Y(Ne,q,T,"",function(lt){return lt})):Ne!=null&&($(Ne)&&(Ne=A(Ne,T+(Ne.key==null||F&&F.key===Ne.key?"":(""+Ne.key).replace(ee,"$&/")+"/")+_e)),q.push(Ne)),1;_e=0;var Pe=de===""?".":de+":";if(I(F))for(var Ve=0;Ve<F.length;Ve++)de=F[Ve],ye=Pe+oe(de,Ve),_e+=Y(de,q,T,ye,Ne);else if(Ve=b(F),typeof Ve=="function")for(F=Ve.call(F),Ve=0;!(de=F.next()).done;)de=de.value,ye=Pe+oe(de,Ve++),_e+=Y(de,q,T,ye,Ne);else if(ye==="object"){if(typeof F.then=="function")return Y(ne(F),q,T,de,Ne);throw q=String(F),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return _e}function ue(F,q,T){if(F==null)return F;var de=[],Ne=0;return Y(F,de,"","",function(ye){return q.call(T,ye,Ne++)}),de}function J(F){if(F._status===-1){var q=F._result;q=q(),q.then(function(T){(F._status===0||F._status===-1)&&(F._status=1,F._result=T)},function(T){(F._status===0||F._status===-1)&&(F._status=2,F._result=T)}),F._status===-1&&(F._status=0,F._result=q)}if(F._status===1)return F._result.default;throw F._result}var K=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},D={map:ue,forEach:function(F,q,T){ue(F,function(){q.apply(this,arguments)},T)},count:function(F){var q=0;return ue(F,function(){q++}),q},toArray:function(F){return ue(F,function(q){return q})||[]},only:function(F){if(!$(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return ht.Activity=y,ht.Children=D,ht.Component=C,ht.Fragment=a,ht.Profiler=o,ht.PureComponent=R,ht.StrictMode=i,ht.Suspense=m,ht.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,ht.__COMPILER_RUNTIME={__proto__:null,c:function(F){return L.H.useMemoCache(F)}},ht.cache=function(F){return function(){return F.apply(null,arguments)}},ht.cacheSignal=function(){return null},ht.cloneElement=function(F,q,T){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var de=k({},F.props),Ne=F.key;if(q!=null)for(ye in q.key!==void 0&&(Ne=""+q.key),q)!H.call(q,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&q.ref===void 0||(de[ye]=q[ye]);var ye=arguments.length-2;if(ye===1)de.children=T;else if(1<ye){for(var _e=Array(ye),Pe=0;Pe<ye;Pe++)_e[Pe]=arguments[Pe+2];de.children=_e}return Q(F.type,Ne,de)},ht.createContext=function(F){return F={$$typeof:d,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:u,_context:F},F},ht.createElement=function(F,q,T){var de,Ne={},ye=null;if(q!=null)for(de in q.key!==void 0&&(ye=""+q.key),q)H.call(q,de)&&de!=="key"&&de!=="__self"&&de!=="__source"&&(Ne[de]=q[de]);var _e=arguments.length-2;if(_e===1)Ne.children=T;else if(1<_e){for(var Pe=Array(_e),Ve=0;Ve<_e;Ve++)Pe[Ve]=arguments[Ve+2];Ne.children=Pe}if(F&&F.defaultProps)for(de in _e=F.defaultProps,_e)Ne[de]===void 0&&(Ne[de]=_e[de]);return Q(F,ye,Ne)},ht.createRef=function(){return{current:null}},ht.forwardRef=function(F){return{$$typeof:h,render:F}},ht.isValidElement=$,ht.lazy=function(F){return{$$typeof:x,_payload:{_status:-1,_result:F},_init:J}},ht.memo=function(F,q){return{$$typeof:f,type:F,compare:q===void 0?null:q}},ht.startTransition=function(F){var q=L.T,T={};L.T=T;try{var de=F(),Ne=L.S;Ne!==null&&Ne(T,de),typeof de=="object"&&de!==null&&typeof de.then=="function"&&de.then(B,K)}catch(ye){K(ye)}finally{q!==null&&T.types!==null&&(q.types=T.types),L.T=q}},ht.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},ht.use=function(F){return L.H.use(F)},ht.useActionState=function(F,q,T){return L.H.useActionState(F,q,T)},ht.useCallback=function(F,q){return L.H.useCallback(F,q)},ht.useContext=function(F){return L.H.useContext(F)},ht.useDebugValue=function(){},ht.useDeferredValue=function(F,q){return L.H.useDeferredValue(F,q)},ht.useEffect=function(F,q){return L.H.useEffect(F,q)},ht.useEffectEvent=function(F){return L.H.useEffectEvent(F)},ht.useId=function(){return L.H.useId()},ht.useImperativeHandle=function(F,q,T){return L.H.useImperativeHandle(F,q,T)},ht.useInsertionEffect=function(F,q){return L.H.useInsertionEffect(F,q)},ht.useLayoutEffect=function(F,q){return L.H.useLayoutEffect(F,q)},ht.useMemo=function(F,q){return L.H.useMemo(F,q)},ht.useOptimistic=function(F,q){return L.H.useOptimistic(F,q)},ht.useReducer=function(F,q,T){return L.H.useReducer(F,q,T)},ht.useRef=function(F){return L.H.useRef(F)},ht.useState=function(F){return L.H.useState(F)},ht.useSyncExternalStore=function(F,q,T){return L.H.useSyncExternalStore(F,q,T)},ht.useTransition=function(){return L.H.useTransition()},ht.version="19.2.4",ht}var N0;function gm(){return N0||(N0=1,Zf.exports=fw()),Zf.exports}var w=gm(),Jf={exports:{}},vo={},eh={exports:{}},th={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var E0;function hw(){return E0||(E0=1,(function(e){function n(Y,ue){var J=Y.length;Y.push(ue);e:for(;0<J;){var K=J-1>>>1,D=Y[K];if(0<o(D,ue))Y[K]=ue,Y[J]=D,J=K;else break e}}function a(Y){return Y.length===0?null:Y[0]}function i(Y){if(Y.length===0)return null;var ue=Y[0],J=Y.pop();if(J!==ue){Y[0]=J;e:for(var K=0,D=Y.length,F=D>>>1;K<F;){var q=2*(K+1)-1,T=Y[q],de=q+1,Ne=Y[de];if(0>o(T,J))de<D&&0>o(Ne,T)?(Y[K]=Ne,Y[de]=J,K=de):(Y[K]=T,Y[q]=J,K=q);else if(de<D&&0>o(Ne,J))Y[K]=Ne,Y[de]=J,K=de;else break e}}return ue}function o(Y,ue){var J=Y.sortIndex-ue.sortIndex;return J!==0?J:Y.id-ue.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();e.unstable_now=function(){return d.now()-h}}var m=[],f=[],x=1,y=null,v=3,b=!1,j=!1,k=!1,N=!1,C=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function M(Y){for(var ue=a(f);ue!==null;){if(ue.callback===null)i(f);else if(ue.startTime<=Y)i(f),ue.sortIndex=ue.expirationTime,n(m,ue);else break;ue=a(f)}}function I(Y){if(k=!1,M(Y),!j)if(a(m)!==null)j=!0,B||(B=!0,U());else{var ue=a(f);ue!==null&&ne(I,ue.startTime-Y)}}var B=!1,L=-1,H=5,Q=-1;function A(){return N?!0:!(e.unstable_now()-Q<H)}function $(){if(N=!1,B){var Y=e.unstable_now();Q=Y;var ue=!0;try{e:{j=!1,k&&(k=!1,E(L),L=-1),b=!0;var J=v;try{t:{for(M(Y),y=a(m);y!==null&&!(y.expirationTime>Y&&A());){var K=y.callback;if(typeof K=="function"){y.callback=null,v=y.priorityLevel;var D=K(y.expirationTime<=Y);if(Y=e.unstable_now(),typeof D=="function"){y.callback=D,M(Y),ue=!0;break t}y===a(m)&&i(m),M(Y)}else i(m);y=a(m)}if(y!==null)ue=!0;else{var F=a(f);F!==null&&ne(I,F.startTime-Y),ue=!1}}break e}finally{y=null,v=J,b=!1}ue=void 0}}finally{ue?U():B=!1}}}var U;if(typeof R=="function")U=function(){R($)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,oe=ee.port2;ee.port1.onmessage=$,U=function(){oe.postMessage(null)}}else U=function(){C($,0)};function ne(Y,ue){L=C(function(){Y(e.unstable_now())},ue)}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(Y){Y.callback=null},e.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<Y?Math.floor(1e3/Y):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(Y){switch(v){case 1:case 2:case 3:var ue=3;break;default:ue=v}var J=v;v=ue;try{return Y()}finally{v=J}},e.unstable_requestPaint=function(){N=!0},e.unstable_runWithPriority=function(Y,ue){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var J=v;v=Y;try{return ue()}finally{v=J}},e.unstable_scheduleCallback=function(Y,ue,J){var K=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?K+J:K):J=K,Y){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=J+D,Y={id:x++,callback:ue,priorityLevel:Y,startTime:J,expirationTime:D,sortIndex:-1},J>K?(Y.sortIndex=J,n(f,Y),a(m)===null&&Y===a(f)&&(k?(E(L),L=-1):k=!0,ne(I,J-K))):(Y.sortIndex=D,n(m,Y),j||b||(j=!0,B||(B=!0,U()))),Y},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(Y){var ue=v;return function(){var J=v;v=ue;try{return Y.apply(this,arguments)}finally{v=J}}}})(th)),th}var A0;function mw(){return A0||(A0=1,eh.exports=hw()),eh.exports}var nh={exports:{}},Pn={};/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var D0;function pw(){if(D0)return Pn;D0=1;var e=gm();function n(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 a(){}var i={d:{f:a,r:function(){throw Error(n(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},o=Symbol.for("react.portal");function u(m,f,x){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:m,containerInfo:f,implementation:x}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Pn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Pn.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(n(299));return u(m,f,null,x)},Pn.flushSync=function(m){var f=d.T,x=i.p;try{if(d.T=null,i.p=2,m)return m()}finally{d.T=f,i.p=x,i.d.f()}},Pn.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))},Pn.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},Pn.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var x=f.as,y=h(x,f.crossOrigin),v=typeof f.integrity=="string"?f.integrity:void 0,b=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;x==="style"?i.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:v,fetchPriority:b}):x==="script"&&i.d.X(m,{crossOrigin:y,integrity:v,fetchPriority:b,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Pn.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var x=h(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)},Pn.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var x=f.as,y=h(x,f.crossOrigin);i.d.L(m,x,{crossOrigin:y,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})}},Pn.preloadModule=function(m,f){if(typeof m=="string")if(f){var x=h(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)},Pn.requestFormReset=function(m){i.d.r(m)},Pn.unstable_batchedUpdates=function(m,f){return m(f)},Pn.useFormState=function(m,f,x){return d.H.useFormState(m,f,x)},Pn.useFormStatus=function(){return d.H.useHostTransitionStatus()},Pn.version="19.2.4",Pn}var T0;function xw(){if(T0)return nh.exports;T0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),nh.exports=pw(),nh.exports}/**
|
|
34
|
+
* @license React
|
|
35
|
+
* react-dom-client.production.js
|
|
36
|
+
*
|
|
37
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the MIT license found in the
|
|
40
|
+
* LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/var F0;function yw(){if(F0)return vo;F0=1;var e=mw(),n=gm(),a=xw();function i(t){var r="https://react.dev/errors/"+t;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)r+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function u(t){var r=t,s=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(s=r.return),t=r.return;while(t)}return r.tag===3?s:null}function d(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function h(t){if(t.tag===31){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function m(t){if(u(t)!==t)throw Error(i(188))}function f(t){var r=t.alternate;if(!r){if(r=u(t),r===null)throw Error(i(188));return r!==t?null:t}for(var s=t,c=r;;){var p=s.return;if(p===null)break;var g=p.alternate;if(g===null){if(c=p.return,c!==null){s=c;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===s)return m(p),t;if(g===c)return m(p),r;g=g.sibling}throw Error(i(188))}if(s.return!==c.return)s=p,c=g;else{for(var S=!1,z=p.child;z;){if(z===s){S=!0,s=p,c=g;break}if(z===c){S=!0,c=p,s=g;break}z=z.sibling}if(!S){for(z=g.child;z;){if(z===s){S=!0,s=g,c=p;break}if(z===c){S=!0,c=g,s=p;break}z=z.sibling}if(!S)throw Error(i(189))}}if(s.alternate!==c)throw Error(i(190))}if(s.tag!==3)throw Error(i(188));return s.stateNode.current===s?t:r}function x(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t;for(t=t.child;t!==null;){if(r=x(t),r!==null)return r;t=t.sibling}return null}var y=Object.assign,v=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),R=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),A=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function U(t){return t===null||typeof t!="object"?null:(t=$&&t[$]||t["@@iterator"],typeof t=="function"?t:null)}var ee=Symbol.for("react.client.reference");function oe(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===ee?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case C:return"Profiler";case N:return"StrictMode";case I:return"Suspense";case B:return"SuspenseList";case Q:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case j:return"Portal";case R:return t.displayName||"Context";case E:return(t._context.displayName||"Context")+".Consumer";case M:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case L:return r=t.displayName||null,r!==null?r:oe(t.type)||"Memo";case H:r=t._payload,t=t._init;try{return oe(t(r))}catch{}}return null}var ne=Array.isArray,Y=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},K=[],D=-1;function F(t){return{current:t}}function q(t){0>D||(t.current=K[D],K[D]=null,D--)}function T(t,r){D++,K[D]=t.current,t.current=r}var de=F(null),Ne=F(null),ye=F(null),_e=F(null);function Pe(t,r){switch(T(ye,r),T(Ne,t),T(de,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?X1(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=X1(r),t=W1(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}q(de),T(de,t)}function Ve(){q(de),q(Ne),q(ye)}function lt(t){t.memoizedState!==null&&T(_e,t);var r=de.current,s=W1(r,t.type);r!==s&&(T(Ne,t),T(de,s))}function dt(t){Ne.current===t&&(q(de),q(Ne)),_e.current===t&&(q(_e),po._currentValue=J)}var Ce,We;function Te(t){if(Ce===void 0)try{throw Error()}catch(s){var r=s.stack.trim().match(/\n( *(at )?)/);Ce=r&&r[1]||"",We=-1<s.stack.indexOf(`
|
|
42
|
+
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
+
`+Ce+t+We}var xt=!1;function ut(t,r){if(!t||xt)return"";xt=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(r){var Se=function(){throw Error()};if(Object.defineProperty(Se.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Se,[])}catch(fe){var ie=fe}Reflect.construct(t,[],Se)}else{try{Se.call()}catch(fe){ie=fe}t.call(Se.prototype)}}else{try{throw Error()}catch(fe){ie=fe}(Se=t())&&typeof Se.catch=="function"&&Se.catch(function(){})}}catch(fe){if(fe&&ie&&typeof fe.stack=="string")return[fe.stack,ie.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),S=g[0],z=g[1];if(S&&z){var X=S.split(`
|
|
44
|
+
`),ae=z.split(`
|
|
45
|
+
`);for(p=c=0;c<X.length&&!X[c].includes("DetermineComponentFrameRoot");)c++;for(;p<ae.length&&!ae[p].includes("DetermineComponentFrameRoot");)p++;if(c===X.length||p===ae.length)for(c=X.length-1,p=ae.length-1;1<=c&&0<=p&&X[c]!==ae[p];)p--;for(;1<=c&&0<=p;c--,p--)if(X[c]!==ae[p]){if(c!==1||p!==1)do if(c--,p--,0>p||X[c]!==ae[p]){var me=`
|
|
46
|
+
`+X[c].replace(" at new "," at ");return t.displayName&&me.includes("<anonymous>")&&(me=me.replace("<anonymous>",t.displayName)),me}while(1<=c&&0<=p);break}}}finally{xt=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?Te(s):""}function mt(t,r){switch(t.tag){case 26:case 27:case 5:return Te(t.type);case 16:return Te("Lazy");case 13:return t.child!==r&&r!==null?Te("Suspense Fallback"):Te("Suspense");case 19:return Te("SuspenseList");case 0:case 15:return ut(t.type,!1);case 11:return ut(t.type.render,!1);case 1:return ut(t.type,!0);case 31:return Te("Activity");default:return""}}function wt(t){try{var r="",s=null;do r+=mt(t,s),s=t,t=t.return;while(t);return r}catch(c){return`
|
|
47
|
+
Error generating stack: `+c.message+`
|
|
48
|
+
`+c.stack}}var qt=Object.prototype.hasOwnProperty,$t=e.unstable_scheduleCallback,Ct=e.unstable_cancelCallback,Bn=e.unstable_shouldYield,he=e.unstable_requestPaint,ve=e.unstable_now,ce=e.unstable_getCurrentPriorityLevel,W=e.unstable_ImmediatePriority,le=e.unstable_UserBlockingPriority,we=e.unstable_NormalPriority,xe=e.unstable_LowPriority,je=e.unstable_IdlePriority,Re=e.log,$e=e.unstable_setDisableYieldValue,Oe=null,Le=null;function tt(t){if(typeof Re=="function"&&$e(t),Le&&typeof Le.setStrictMode=="function")try{Le.setStrictMode(Oe,t)}catch{}}var Ke=Math.clz32?Math.clz32:He,jt=Math.log,ze=Math.LN2;function He(t){return t>>>=0,t===0?32:31-(jt(t)/ze|0)|0}var Lt=256,Dt=262144,Rt=4194304;function sn(t){var r=t&42;if(r!==0)return r;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function pn(t,r,s){var c=t.pendingLanes;if(c===0)return 0;var p=0,g=t.suspendedLanes,S=t.pingedLanes;t=t.warmLanes;var z=c&134217727;return z!==0?(c=z&~g,c!==0?p=sn(c):(S&=z,S!==0?p=sn(S):s||(s=z&~t,s!==0&&(p=sn(s))))):(z=c&~g,z!==0?p=sn(z):S!==0?p=sn(S):s||(s=c&~t,s!==0&&(p=sn(s)))),p===0?0:r!==0&&r!==p&&(r&g)===0&&(g=p&-p,s=r&-r,g>=s||g===32&&(s&4194048)!==0)?r:p}function P(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function Be(t,r){switch(t){case 1:case 2:case 4:case 8:case 64:return r+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 r+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 nt(){var t=Rt;return Rt<<=1,(Rt&62914560)===0&&(Rt=4194304),t}function Pt(t){for(var r=[],s=0;31>s;s++)r.push(t);return r}function ge(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Z(t,r,s,c,p,g){var S=t.pendingLanes;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=s,t.entangledLanes&=s,t.errorRecoveryDisabledLanes&=s,t.shellSuspendCounter=0;var z=t.entanglements,X=t.expirationTimes,ae=t.hiddenUpdates;for(s=S&~s;0<s;){var me=31-Ke(s),Se=1<<me;z[me]=0,X[me]=-1;var ie=ae[me];if(ie!==null)for(ae[me]=null,me=0;me<ie.length;me++){var fe=ie[me];fe!==null&&(fe.lane&=-536870913)}s&=~Se}c!==0&&Me(t,c,0),g!==0&&p===0&&t.tag!==0&&(t.suspendedLanes|=g&~(S&~r))}function Me(t,r,s){t.pendingLanes|=r,t.suspendedLanes&=~r;var c=31-Ke(r);t.entangledLanes|=r,t.entanglements[c]=t.entanglements[c]|1073741824|s&261930}function Ie(t,r){var s=t.entangledLanes|=r;for(t=t.entanglements;s;){var c=31-Ke(s),p=1<<c;p&r|t[c]&r&&(t[c]|=r),s&=~p}}function St(t,r){var s=r&-r;return s=(s&42)!==0?1:Ze(s),(s&(t.suspendedLanes|r))!==0?0:s}function Ze(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=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:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Vn(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function tr(){var t=ue.p;return t!==0?t:(t=window.event,t===void 0?32:p0(t.type))}function ia(t,r){var s=ue.p;try{return ue.p=t,r()}finally{ue.p=s}}var Hn=Math.random().toString(36).slice(2),Tn="__reactFiber$"+Hn,On="__reactProps$"+Hn,sa="__reactContainer$"+Hn,nl="__reactEvents$"+Hn,Ju="__reactListeners$"+Hn,Ns="__reactHandles$"+Hn,Wo="__reactResources$"+Hn,Ea="__reactMarker$"+Hn;function Ni(t){delete t[Tn],delete t[On],delete t[nl],delete t[Ju],delete t[Ns]}function oa(t){var r=t[Tn];if(r)return r;for(var s=t.parentNode;s;){if(r=s[sa]||s[Tn]){if(s=r.alternate,r.child!==null||s!==null&&s.child!==null)for(t=J1(t);t!==null;){if(s=t[Tn])return s;t=J1(t)}return r}t=s,s=t.parentNode}return null}function Un(t){if(t=t[Tn]||t[sa]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function Ul(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function yr(t){var r=t[Wo];return r||(r=t[Wo]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function xn(t){t[Ea]=!0}var Aa=new Set,Da={};function ir(t,r){Ta(t,r),Ta(t+"Capture",r)}function Ta(t,r){for(Da[t]=r,t=0;t<r.length;t++)Aa.add(r[t])}var rl=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]*$"),Es={},As={};function Ds(t){return qt.call(As,t)?!0:qt.call(Es,t)?!1:rl.test(t)?As[t]=!0:(Es[t]=!0,!1)}function ql(t,r,s){if(Ds(r))if(s===null)t.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":t.removeAttribute(r);return;case"boolean":var c=r.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){t.removeAttribute(r);return}}t.setAttribute(r,""+s)}}function Yl(t,r,s){if(s===null)t.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttribute(r,""+s)}}function Wr(t,r,s,c){if(c===null)t.removeAttribute(s);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(s);return}t.setAttributeNS(r,s,""+c)}}function wn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Gr(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function ca(t,r,s){var c=Object.getOwnPropertyDescriptor(t.constructor.prototype,r);if(!t.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var p=c.get,g=c.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return p.call(this)},set:function(S){s=""+S,g.call(this,S)}}),Object.defineProperty(t,r,{enumerable:c.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function Vr(t){if(!t._valueTracker){var r=Gr(t)?"checked":"value";t._valueTracker=ca(t,r,""+t[r])}}function Fr(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var s=r.getValue(),c="";return t&&(c=Gr(t)?t.checked?"true":"false":t.value),t=c,t!==s?(r.setValue(t),!0):!1}function kn(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Go=/[\n"\\]/g;function sr(t){return t.replace(Go,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Xl(t,r,s,c,p,g,S,z){t.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?t.type=S:t.removeAttribute("type"),r!=null?S==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+wn(r)):t.value!==""+wn(r)&&(t.value=""+wn(r)):S!=="submit"&&S!=="reset"||t.removeAttribute("value"),r!=null?ua(t,S,wn(r)):s!=null?ua(t,S,wn(s)):c!=null&&t.removeAttribute("value"),p==null&&g!=null&&(t.defaultChecked=!!g),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),z!=null&&typeof z!="function"&&typeof z!="symbol"&&typeof z!="boolean"?t.name=""+wn(z):t.removeAttribute("name")}function gr(t,r,s,c,p,g,S,z){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(t.type=g),r!=null||s!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){Vr(t);return}s=s!=null?""+wn(s):"",r=r!=null?""+wn(r):s,z||r===t.value||(t.value=r),t.defaultValue=r}c=c??p,c=typeof c!="function"&&typeof c!="symbol"&&!!c,t.checked=z?t.checked:!!c,t.defaultChecked=!!c,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(t.name=S),Vr(t)}function ua(t,r,s){r==="number"&&kn(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function or(t,r,s,c){if(t=t.options,r){r={};for(var p=0;p<s.length;p++)r["$"+s[p]]=!0;for(s=0;s<t.length;s++)p=r.hasOwnProperty("$"+t[s].value),t[s].selected!==p&&(t[s].selected=p),p&&c&&(t[s].defaultSelected=!0)}else{for(s=""+wn(s),r=null,p=0;p<t.length;p++){if(t[p].value===s){t[p].selected=!0,c&&(t[p].defaultSelected=!0);return}r!==null||t[p].disabled||(r=t[p])}r!==null&&(r.selected=!0)}}function Vo(t,r,s){if(r!=null&&(r=""+wn(r),r!==t.value&&(t.value=r),s==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=s!=null?""+wn(s):""}function $n(t,r,s,c){if(r==null){if(c!=null){if(s!=null)throw Error(i(92));if(ne(c)){if(1<c.length)throw Error(i(93));c=c[0]}s=c}s==null&&(s=""),r=s}s=wn(r),t.defaultValue=s,c=t.textContent,c===s&&c!==""&&c!==null&&(t.value=c),Vr(t)}function on(t,r){if(r){var s=t.firstChild;if(s&&s===t.lastChild&&s.nodeType===3){s.nodeValue=r;return}}t.textContent=r}var da=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 Ln(t,r,s){var c=r.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?c?t.setProperty(r,""):r==="float"?t.cssFloat="":t[r]="":c?t.setProperty(r,s):typeof s!="number"||s===0||da.has(r)?r==="float"?t.cssFloat=s:t[r]=(""+s).trim():t[r]=s+"px"}function Kr(t,r,s){if(r!=null&&typeof r!="object")throw Error(i(62));if(t=t.style,s!=null){for(var c in s)!s.hasOwnProperty(c)||r!=null&&r.hasOwnProperty(c)||(c.indexOf("--")===0?t.setProperty(c,""):c==="float"?t.cssFloat="":t[c]="");for(var p in r)c=r[p],r.hasOwnProperty(p)&&s[p]!==c&&Ln(t,p,c)}else for(var g in r)r.hasOwnProperty(g)&&Ln(t,g,r[g])}function Wl(t){if(t.indexOf("-")===-1)return!1;switch(t){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 ed=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"]]),Ei=/^[\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 Gl(t){return Ei.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function Kn(){}var Qr=null;function Ai(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Fa=null,jn=null;function Ma(t){var r=Un(t);if(r&&(t=r.stateNode)){var s=t[On]||null;e:switch(t=r.stateNode,r.type){case"input":if(Xl(t,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),r=s.name,s.type==="radio"&&r!=null){for(s=t;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+sr(""+r)+'"][type="radio"]'),r=0;r<s.length;r++){var c=s[r];if(c!==t&&c.form===t.form){var p=c[On]||null;if(!p)throw Error(i(90));Xl(c,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(r=0;r<s.length;r++)c=s[r],c.form===t.form&&Fr(c)}break e;case"textarea":Vo(t,s.value,s.defaultValue);break e;case"select":r=s.value,r!=null&&or(t,!!s.multiple,r,!1)}}}var al=!1;function Ko(t,r,s){if(al)return t(r,s);al=!0;try{var c=t(r);return c}finally{if(al=!1,(Fa!==null||jn!==null)&&(Ic(),Fa&&(r=Fa,t=jn,jn=Fa=null,Ma(r),t)))for(r=0;r<t.length;r++)Ma(t[r])}}function Vl(t,r){var s=t.stateNode;if(s===null)return null;var c=s[On]||null;if(c===null)return null;s=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(s&&typeof s!="function")throw Error(i(231,r,typeof s));return s}var yt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ts=!1;if(yt)try{var Gt={};Object.defineProperty(Gt,"passive",{get:function(){Ts=!0}}),window.addEventListener("test",Gt,Gt),window.removeEventListener("test",Gt,Gt)}catch{Ts=!1}var Mr=null,Ra=null,Di=null;function Ti(){if(Di)return Di;var t,r=Ra,s=r.length,c,p="value"in Mr?Mr.value:Mr.textContent,g=p.length;for(t=0;t<s&&r[t]===p[t];t++);var S=s-t;for(c=1;c<=S&&r[s-c]===p[g-c];c++);return Di=p.slice(t,1<c?1-c:void 0)}function Rr(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function ll(){return!0}function Qo(){return!1}function Qn(t){function r(s,c,p,g,S){this._reactName=s,this._targetInst=p,this.type=c,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var z in t)t.hasOwnProperty(z)&&(s=t[z],this[z]=s?s(g):g[z]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?ll:Qo,this.isPropagationStopped=Qo,this}return y(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=ll)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=ll)},persist:function(){},isPersistent:ll}),r}var Pr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Fi=Qn(Pr),il=y({},Pr,{view:0,detail:0}),Po=Qn(il),Fs,Mi,sl,Kl=y({},il,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_i,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==sl&&(sl&&t.type==="mousemove"?(Fs=t.screenX-sl.screenX,Mi=t.screenY-sl.screenY):Mi=Fs=0,sl=t),Fs)},movementY:function(t){return"movementY"in t?t.movementY:Mi}}),Zr=Qn(Kl),za=y({},Kl,{dataTransfer:0}),Ms=Qn(za),td=y({},il,{relatedTarget:0}),Ri=Qn(td),Zo=y({},Pr,{animationName:0,elapsedTime:0,pseudoElement:0}),nd=Qn(Zo),Jo=y({},Pr,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Zt=Qn(Jo),zi=y({},Pr,{data:0}),Rs=Qn(zi),ec={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},tc={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"},nc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function rc(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=nc[t])?!!r[t]:!1}function _i(){return rc}var ac=y({},il,{key:function(t){if(t.key){var r=ec[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Rr(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?tc[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_i,charCode:function(t){return t.type==="keypress"?Rr(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Rr(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),_=Qn(ac),G=y({},Kl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),se=Qn(G),pe=y({},il,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_i}),Ee=Qn(pe),Ue=y({},Pr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Yt=Qn(Ue),ft=y({},Kl,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),et=Qn(ft),rt=y({},Pr,{newState:0,oldState:0}),pt=Qn(rt),Vt=[9,13,27,32],Ql=yt&&"CompositionEvent"in window,_t=null;yt&&"documentMode"in document&&(_t=document.documentMode);var Jr=yt&&"TextEvent"in window&&!_t,zs=yt&&(!Ql||_t&&8<_t&&11>=_t),_s=" ",Jm=!1;function ep(t,r){switch(t){case"keyup":return Vt.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function tp(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Bi=!1;function Mv(t,r){switch(t){case"compositionend":return tp(r);case"keypress":return r.which!==32?null:(Jm=!0,_s);case"textInput":return t=r.data,t===_s&&Jm?null:t;default:return null}}function Rv(t,r){if(Bi)return t==="compositionend"||!Ql&&ep(t,r)?(t=Ti(),Di=Ra=Mr=null,Bi=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return zs&&r.locale!=="ko"?null:r.data;default:return null}}var zv={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 np(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!zv[t.type]:r==="textarea"}function rp(t,r,s,c){Fa?jn?jn.push(c):jn=[c]:Fa=c,r=Gc(r,"onChange"),0<r.length&&(s=new Fi("onChange","change",null,s,c),t.push({event:s,listeners:r}))}var Bs=null,Os=null;function _v(t){L1(t,0)}function lc(t){var r=Ul(t);if(Fr(r))return t}function ap(t,r){if(t==="change")return r}var lp=!1;if(yt){var rd;if(yt){var ad="oninput"in document;if(!ad){var ip=document.createElement("div");ip.setAttribute("oninput","return;"),ad=typeof ip.oninput=="function"}rd=ad}else rd=!1;lp=rd&&(!document.documentMode||9<document.documentMode)}function sp(){Bs&&(Bs.detachEvent("onpropertychange",op),Os=Bs=null)}function op(t){if(t.propertyName==="value"&&lc(Os)){var r=[];rp(r,Os,t,Ai(t)),Ko(_v,r)}}function Bv(t,r,s){t==="focusin"?(sp(),Bs=r,Os=s,Bs.attachEvent("onpropertychange",op)):t==="focusout"&&sp()}function Ov(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return lc(Os)}function $v(t,r){if(t==="click")return lc(r)}function Lv(t,r){if(t==="input"||t==="change")return lc(r)}function Iv(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var br=typeof Object.is=="function"?Object.is:Iv;function $s(t,r){if(br(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var s=Object.keys(t),c=Object.keys(r);if(s.length!==c.length)return!1;for(c=0;c<s.length;c++){var p=s[c];if(!qt.call(r,p)||!br(t[p],r[p]))return!1}return!0}function cp(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function up(t,r){var s=cp(t);t=0;for(var c;s;){if(s.nodeType===3){if(c=t+s.textContent.length,t<=r&&c>=r)return{node:s,offset:r-t};t=c}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=cp(s)}}function dp(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?dp(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function fp(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=kn(t.document);r instanceof t.HTMLIFrameElement;){try{var s=typeof r.contentWindow.location.href=="string"}catch{s=!1}if(s)t=r.contentWindow;else break;r=kn(t.document)}return r}function ld(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}var Hv=yt&&"documentMode"in document&&11>=document.documentMode,Oi=null,id=null,Ls=null,sd=!1;function hp(t,r,s){var c=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;sd||Oi==null||Oi!==kn(c)||(c=Oi,"selectionStart"in c&&ld(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Ls&&$s(Ls,c)||(Ls=c,c=Gc(id,"onSelect"),0<c.length&&(r=new Fi("onSelect","select",null,r,s),t.push({event:r,listeners:c}),r.target=Oi)))}function Pl(t,r){var s={};return s[t.toLowerCase()]=r.toLowerCase(),s["Webkit"+t]="webkit"+r,s["Moz"+t]="moz"+r,s}var $i={animationend:Pl("Animation","AnimationEnd"),animationiteration:Pl("Animation","AnimationIteration"),animationstart:Pl("Animation","AnimationStart"),transitionrun:Pl("Transition","TransitionRun"),transitionstart:Pl("Transition","TransitionStart"),transitioncancel:Pl("Transition","TransitionCancel"),transitionend:Pl("Transition","TransitionEnd")},od={},mp={};yt&&(mp=document.createElement("div").style,"AnimationEvent"in window||(delete $i.animationend.animation,delete $i.animationiteration.animation,delete $i.animationstart.animation),"TransitionEvent"in window||delete $i.transitionend.transition);function Zl(t){if(od[t])return od[t];if(!$i[t])return t;var r=$i[t],s;for(s in r)if(r.hasOwnProperty(s)&&s in mp)return od[t]=r[s];return t}var pp=Zl("animationend"),xp=Zl("animationiteration"),yp=Zl("animationstart"),Uv=Zl("transitionrun"),qv=Zl("transitionstart"),Yv=Zl("transitioncancel"),gp=Zl("transitionend"),bp=new Map,cd="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(" ");cd.push("scrollEnd");function ea(t,r){bp.set(t,r),ir(r,[t])}var ic=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},zr=[],Li=0,ud=0;function sc(){for(var t=Li,r=ud=Li=0;r<t;){var s=zr[r];zr[r++]=null;var c=zr[r];zr[r++]=null;var p=zr[r];zr[r++]=null;var g=zr[r];if(zr[r++]=null,c!==null&&p!==null){var S=c.pending;S===null?p.next=p:(p.next=S.next,S.next=p),c.pending=p}g!==0&&vp(s,p,g)}}function oc(t,r,s,c){zr[Li++]=t,zr[Li++]=r,zr[Li++]=s,zr[Li++]=c,ud|=c,t.lanes|=c,t=t.alternate,t!==null&&(t.lanes|=c)}function dd(t,r,s,c){return oc(t,r,s,c),cc(t)}function Jl(t,r){return oc(t,null,null,r),cc(t)}function vp(t,r,s){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s);for(var p=!1,g=t.return;g!==null;)g.childLanes|=s,c=g.alternate,c!==null&&(c.childLanes|=s),g.tag===22&&(t=g.stateNode,t===null||t._visibility&1||(p=!0)),t=g,g=g.return;return t.tag===3?(g=t.stateNode,p&&r!==null&&(p=31-Ke(s),t=g.hiddenUpdates,c=t[p],c===null?t[p]=[r]:c.push(r),r.lane=s|536870912),g):null}function cc(t){if(50<so)throw so=0,wf=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var Ii={};function Xv(t,r,s,c){this.tag=t,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vr(t,r,s,c){return new Xv(t,r,s,c)}function fd(t){return t=t.prototype,!(!t||!t.isReactComponent)}function _a(t,r){var s=t.alternate;return s===null?(s=vr(t.tag,r,t.key,t.mode),s.elementType=t.elementType,s.type=t.type,s.stateNode=t.stateNode,s.alternate=t,t.alternate=s):(s.pendingProps=r,s.type=t.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=t.flags&65011712,s.childLanes=t.childLanes,s.lanes=t.lanes,s.child=t.child,s.memoizedProps=t.memoizedProps,s.memoizedState=t.memoizedState,s.updateQueue=t.updateQueue,r=t.dependencies,s.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},s.sibling=t.sibling,s.index=t.index,s.ref=t.ref,s.refCleanup=t.refCleanup,s}function wp(t,r){t.flags&=65011714;var s=t.alternate;return s===null?(t.childLanes=0,t.lanes=r,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=s.childLanes,t.lanes=s.lanes,t.child=s.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=s.memoizedProps,t.memoizedState=s.memoizedState,t.updateQueue=s.updateQueue,t.type=s.type,r=s.dependencies,t.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),t}function uc(t,r,s,c,p,g){var S=0;if(c=t,typeof t=="function")fd(t)&&(S=1);else if(typeof t=="string")S=Q2(t,s,de.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case Q:return t=vr(31,s,r,p),t.elementType=Q,t.lanes=g,t;case k:return ei(s.children,p,g,r);case N:S=8,p|=24;break;case C:return t=vr(12,s,r,p|2),t.elementType=C,t.lanes=g,t;case I:return t=vr(13,s,r,p),t.elementType=I,t.lanes=g,t;case B:return t=vr(19,s,r,p),t.elementType=B,t.lanes=g,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case R:S=10;break e;case E:S=9;break e;case M:S=11;break e;case L:S=14;break e;case H:S=16,c=null;break e}S=29,s=Error(i(130,t===null?"null":typeof t,"")),c=null}return r=vr(S,s,r,p),r.elementType=t,r.type=c,r.lanes=g,r}function ei(t,r,s,c){return t=vr(7,t,c,r),t.lanes=s,t}function hd(t,r,s){return t=vr(6,t,null,r),t.lanes=s,t}function kp(t){var r=vr(18,null,null,0);return r.stateNode=t,r}function md(t,r,s){return r=vr(4,t.children!==null?t.children:[],t.key,r),r.lanes=s,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var jp=new WeakMap;function _r(t,r){if(typeof t=="object"&&t!==null){var s=jp.get(t);return s!==void 0?s:(r={value:t,source:r,stack:wt(r)},jp.set(t,r),r)}return{value:t,source:r,stack:wt(r)}}var Hi=[],Ui=0,dc=null,Is=0,Br=[],Or=0,ol=null,fa=1,ha="";function Ba(t,r){Hi[Ui++]=Is,Hi[Ui++]=dc,dc=t,Is=r}function Sp(t,r,s){Br[Or++]=fa,Br[Or++]=ha,Br[Or++]=ol,ol=t;var c=fa;t=ha;var p=32-Ke(c)-1;c&=~(1<<p),s+=1;var g=32-Ke(r)+p;if(30<g){var S=p-p%5;g=(c&(1<<S)-1).toString(32),c>>=S,p-=S,fa=1<<32-Ke(r)+p|s<<p|c,ha=g+t}else fa=1<<g|s<<p|c,ha=t}function pd(t){t.return!==null&&(Ba(t,1),Sp(t,1,0))}function xd(t){for(;t===dc;)dc=Hi[--Ui],Hi[Ui]=null,Is=Hi[--Ui],Hi[Ui]=null;for(;t===ol;)ol=Br[--Or],Br[Or]=null,ha=Br[--Or],Br[Or]=null,fa=Br[--Or],Br[Or]=null}function Cp(t,r){Br[Or++]=fa,Br[Or++]=ha,Br[Or++]=ol,fa=r.id,ha=r.overflow,ol=t}var qn=null,un=null,zt=!1,cl=null,$r=!1,yd=Error(i(519));function ul(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Hs(_r(r,t)),yd}function Np(t){var r=t.stateNode,s=t.type,c=t.memoizedProps;switch(r[Tn]=t,r[On]=c,s){case"dialog":Et("cancel",r),Et("close",r);break;case"iframe":case"object":case"embed":Et("load",r);break;case"video":case"audio":for(s=0;s<co.length;s++)Et(co[s],r);break;case"source":Et("error",r);break;case"img":case"image":case"link":Et("error",r),Et("load",r);break;case"details":Et("toggle",r);break;case"input":Et("invalid",r),gr(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Et("invalid",r);break;case"textarea":Et("invalid",r),$n(r,c.value,c.defaultValue,c.children)}s=c.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||r.textContent===""+s||c.suppressHydrationWarning===!0||q1(r.textContent,s)?(c.popover!=null&&(Et("beforetoggle",r),Et("toggle",r)),c.onScroll!=null&&Et("scroll",r),c.onScrollEnd!=null&&Et("scrollend",r),c.onClick!=null&&(r.onclick=Kn),r=!0):r=!1,r||ul(t,!0)}function Ep(t){for(qn=t.return;qn;)switch(qn.tag){case 5:case 31:case 13:$r=!1;return;case 27:case 3:$r=!0;return;default:qn=qn.return}}function qi(t){if(t!==qn)return!1;if(!zt)return Ep(t),zt=!0,!1;var r=t.tag,s;if((s=r!==3&&r!==27)&&((s=r===5)&&(s=t.type,s=!(s!=="form"&&s!=="button")||Bf(t.type,t.memoizedProps)),s=!s),s&&un&&ul(t),Ep(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));un=Z1(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));un=Z1(t)}else r===27?(r=un,Sl(t.type)?(t=Hf,Hf=null,un=t):un=r):un=qn?Ir(t.stateNode.nextSibling):null;return!0}function ti(){un=qn=null,zt=!1}function gd(){var t=cl;return t!==null&&(fr===null?fr=t:fr.push.apply(fr,t),cl=null),t}function Hs(t){cl===null?cl=[t]:cl.push(t)}var bd=F(null),ni=null,Oa=null;function dl(t,r,s){T(bd,r._currentValue),r._currentValue=s}function $a(t){t._currentValue=bd.current,q(bd)}function vd(t,r,s){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===s)break;t=t.return}}function wd(t,r,s,c){var p=t.child;for(p!==null&&(p.return=t);p!==null;){var g=p.dependencies;if(g!==null){var S=p.child;g=g.firstContext;e:for(;g!==null;){var z=g;g=p;for(var X=0;X<r.length;X++)if(z.context===r[X]){g.lanes|=s,z=g.alternate,z!==null&&(z.lanes|=s),vd(g.return,s,t),c||(S=null);break e}g=z.next}}else if(p.tag===18){if(S=p.return,S===null)throw Error(i(341));S.lanes|=s,g=S.alternate,g!==null&&(g.lanes|=s),vd(S,s,t),S=null}else S=p.child;if(S!==null)S.return=p;else for(S=p;S!==null;){if(S===t){S=null;break}if(p=S.sibling,p!==null){p.return=S.return,S=p;break}S=S.return}p=S}}function Yi(t,r,s,c){t=null;for(var p=r,g=!1;p!==null;){if(!g){if((p.flags&524288)!==0)g=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var S=p.alternate;if(S===null)throw Error(i(387));if(S=S.memoizedProps,S!==null){var z=p.type;br(p.pendingProps.value,S.value)||(t!==null?t.push(z):t=[z])}}else if(p===_e.current){if(S=p.alternate,S===null)throw Error(i(387));S.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(t!==null?t.push(po):t=[po])}p=p.return}t!==null&&wd(r,t,s,c),r.flags|=262144}function fc(t){for(t=t.firstContext;t!==null;){if(!br(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function ri(t){ni=t,Oa=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Yn(t){return Ap(ni,t)}function hc(t,r){return ni===null&&ri(t),Ap(t,r)}function Ap(t,r){var s=r._currentValue;if(r={context:r,memoizedValue:s,next:null},Oa===null){if(t===null)throw Error(i(308));Oa=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else Oa=Oa.next=r;return s}var Wv=typeof AbortController<"u"?AbortController:function(){var t=[],r=this.signal={aborted:!1,addEventListener:function(s,c){t.push(c)}};this.abort=function(){r.aborted=!0,t.forEach(function(s){return s()})}},Gv=e.unstable_scheduleCallback,Vv=e.unstable_NormalPriority,Sn={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function kd(){return{controller:new Wv,data:new Map,refCount:0}}function Us(t){t.refCount--,t.refCount===0&&Gv(Vv,function(){t.controller.abort()})}var qs=null,jd=0,Xi=0,Wi=null;function Kv(t,r){if(qs===null){var s=qs=[];jd=0,Xi=Ef(),Wi={status:"pending",value:void 0,then:function(c){s.push(c)}}}return jd++,r.then(Dp,Dp),r}function Dp(){if(--jd===0&&qs!==null){Wi!==null&&(Wi.status="fulfilled");var t=qs;qs=null,Xi=0,Wi=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function Qv(t,r){var s=[],c={status:"pending",value:null,reason:null,then:function(p){s.push(p)}};return t.then(function(){c.status="fulfilled",c.value=r;for(var p=0;p<s.length;p++)(0,s[p])(r)},function(p){for(c.status="rejected",c.reason=p,p=0;p<s.length;p++)(0,s[p])(void 0)}),c}var Tp=Y.S;Y.S=function(t,r){h1=ve(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Kv(t,r),Tp!==null&&Tp(t,r)};var ai=F(null);function Sd(){var t=ai.current;return t!==null?t:rn.pooledCache}function mc(t,r){r===null?T(ai,ai.current):T(ai,r.pool)}function Fp(){var t=Sd();return t===null?null:{parent:Sn._currentValue,pool:t}}var Gi=Error(i(460)),Cd=Error(i(474)),pc=Error(i(542)),xc={then:function(){}};function Mp(t){return t=t.status,t==="fulfilled"||t==="rejected"}function Rp(t,r,s){switch(s=t[s],s===void 0?t.push(r):s!==r&&(r.then(Kn,Kn),r=s),r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,_p(t),t;default:if(typeof r.status=="string")r.then(Kn,Kn);else{if(t=rn,t!==null&&100<t.shellSuspendCounter)throw Error(i(482));t=r,t.status="pending",t.then(function(c){if(r.status==="pending"){var p=r;p.status="fulfilled",p.value=c}},function(c){if(r.status==="pending"){var p=r;p.status="rejected",p.reason=c}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,_p(t),t}throw ii=r,Gi}}function li(t){try{var r=t._init;return r(t._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(ii=s,Gi):s}}var ii=null;function zp(){if(ii===null)throw Error(i(459));var t=ii;return ii=null,t}function _p(t){if(t===Gi||t===pc)throw Error(i(483))}var Vi=null,Ys=0;function yc(t){var r=Ys;return Ys+=1,Vi===null&&(Vi=[]),Rp(Vi,t,r)}function Xs(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function gc(t,r){throw r.$$typeof===v?Error(i(525)):(t=Object.prototype.toString.call(r),Error(i(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t)))}function Bp(t){function r(te,V){if(t){var re=te.deletions;re===null?(te.deletions=[V],te.flags|=16):re.push(V)}}function s(te,V){if(!t)return null;for(;V!==null;)r(te,V),V=V.sibling;return null}function c(te){for(var V=new Map;te!==null;)te.key!==null?V.set(te.key,te):V.set(te.index,te),te=te.sibling;return V}function p(te,V){return te=_a(te,V),te.index=0,te.sibling=null,te}function g(te,V,re){return te.index=re,t?(re=te.alternate,re!==null?(re=re.index,re<V?(te.flags|=67108866,V):re):(te.flags|=67108866,V)):(te.flags|=1048576,V)}function S(te){return t&&te.alternate===null&&(te.flags|=67108866),te}function z(te,V,re,be){return V===null||V.tag!==6?(V=hd(re,te.mode,be),V.return=te,V):(V=p(V,re),V.return=te,V)}function X(te,V,re,be){var Je=re.type;return Je===k?me(te,V,re.props.children,be,re.key):V!==null&&(V.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===H&&li(Je)===V.type)?(V=p(V,re.props),Xs(V,re),V.return=te,V):(V=uc(re.type,re.key,re.props,null,te.mode,be),Xs(V,re),V.return=te,V)}function ae(te,V,re,be){return V===null||V.tag!==4||V.stateNode.containerInfo!==re.containerInfo||V.stateNode.implementation!==re.implementation?(V=md(re,te.mode,be),V.return=te,V):(V=p(V,re.children||[]),V.return=te,V)}function me(te,V,re,be,Je){return V===null||V.tag!==7?(V=ei(re,te.mode,be,Je),V.return=te,V):(V=p(V,re),V.return=te,V)}function Se(te,V,re){if(typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint")return V=hd(""+V,te.mode,re),V.return=te,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case b:return re=uc(V.type,V.key,V.props,null,te.mode,re),Xs(re,V),re.return=te,re;case j:return V=md(V,te.mode,re),V.return=te,V;case H:return V=li(V),Se(te,V,re)}if(ne(V)||U(V))return V=ei(V,te.mode,re,null),V.return=te,V;if(typeof V.then=="function")return Se(te,yc(V),re);if(V.$$typeof===R)return Se(te,hc(te,V),re);gc(te,V)}return null}function ie(te,V,re,be){var Je=V!==null?V.key:null;if(typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint")return Je!==null?null:z(te,V,""+re,be);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case b:return re.key===Je?X(te,V,re,be):null;case j:return re.key===Je?ae(te,V,re,be):null;case H:return re=li(re),ie(te,V,re,be)}if(ne(re)||U(re))return Je!==null?null:me(te,V,re,be,null);if(typeof re.then=="function")return ie(te,V,yc(re),be);if(re.$$typeof===R)return ie(te,V,hc(te,re),be);gc(te,re)}return null}function fe(te,V,re,be,Je){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return te=te.get(re)||null,z(V,te,""+be,Je);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case b:return te=te.get(be.key===null?re:be.key)||null,X(V,te,be,Je);case j:return te=te.get(be.key===null?re:be.key)||null,ae(V,te,be,Je);case H:return be=li(be),fe(te,V,re,be,Je)}if(ne(be)||U(be))return te=te.get(re)||null,me(V,te,be,Je,null);if(typeof be.then=="function")return fe(te,V,re,yc(be),Je);if(be.$$typeof===R)return fe(te,V,re,hc(V,be),Je);gc(V,be)}return null}function qe(te,V,re,be){for(var Je=null,It=null,Xe=V,bt=V=0,Ft=null;Xe!==null&&bt<re.length;bt++){Xe.index>bt?(Ft=Xe,Xe=null):Ft=Xe.sibling;var Ht=ie(te,Xe,re[bt],be);if(Ht===null){Xe===null&&(Xe=Ft);break}t&&Xe&&Ht.alternate===null&&r(te,Xe),V=g(Ht,V,bt),It===null?Je=Ht:It.sibling=Ht,It=Ht,Xe=Ft}if(bt===re.length)return s(te,Xe),zt&&Ba(te,bt),Je;if(Xe===null){for(;bt<re.length;bt++)Xe=Se(te,re[bt],be),Xe!==null&&(V=g(Xe,V,bt),It===null?Je=Xe:It.sibling=Xe,It=Xe);return zt&&Ba(te,bt),Je}for(Xe=c(Xe);bt<re.length;bt++)Ft=fe(Xe,te,bt,re[bt],be),Ft!==null&&(t&&Ft.alternate!==null&&Xe.delete(Ft.key===null?bt:Ft.key),V=g(Ft,V,bt),It===null?Je=Ft:It.sibling=Ft,It=Ft);return t&&Xe.forEach(function(Dl){return r(te,Dl)}),zt&&Ba(te,bt),Je}function it(te,V,re,be){if(re==null)throw Error(i(151));for(var Je=null,It=null,Xe=V,bt=V=0,Ft=null,Ht=re.next();Xe!==null&&!Ht.done;bt++,Ht=re.next()){Xe.index>bt?(Ft=Xe,Xe=null):Ft=Xe.sibling;var Dl=ie(te,Xe,Ht.value,be);if(Dl===null){Xe===null&&(Xe=Ft);break}t&&Xe&&Dl.alternate===null&&r(te,Xe),V=g(Dl,V,bt),It===null?Je=Dl:It.sibling=Dl,It=Dl,Xe=Ft}if(Ht.done)return s(te,Xe),zt&&Ba(te,bt),Je;if(Xe===null){for(;!Ht.done;bt++,Ht=re.next())Ht=Se(te,Ht.value,be),Ht!==null&&(V=g(Ht,V,bt),It===null?Je=Ht:It.sibling=Ht,It=Ht);return zt&&Ba(te,bt),Je}for(Xe=c(Xe);!Ht.done;bt++,Ht=re.next())Ht=fe(Xe,te,bt,Ht.value,be),Ht!==null&&(t&&Ht.alternate!==null&&Xe.delete(Ht.key===null?bt:Ht.key),V=g(Ht,V,bt),It===null?Je=Ht:It.sibling=Ht,It=Ht);return t&&Xe.forEach(function(sw){return r(te,sw)}),zt&&Ba(te,bt),Je}function tn(te,V,re,be){if(typeof re=="object"&&re!==null&&re.type===k&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case b:e:{for(var Je=re.key;V!==null;){if(V.key===Je){if(Je=re.type,Je===k){if(V.tag===7){s(te,V.sibling),be=p(V,re.props.children),be.return=te,te=be;break e}}else if(V.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===H&&li(Je)===V.type){s(te,V.sibling),be=p(V,re.props),Xs(be,re),be.return=te,te=be;break e}s(te,V);break}else r(te,V);V=V.sibling}re.type===k?(be=ei(re.props.children,te.mode,be,re.key),be.return=te,te=be):(be=uc(re.type,re.key,re.props,null,te.mode,be),Xs(be,re),be.return=te,te=be)}return S(te);case j:e:{for(Je=re.key;V!==null;){if(V.key===Je)if(V.tag===4&&V.stateNode.containerInfo===re.containerInfo&&V.stateNode.implementation===re.implementation){s(te,V.sibling),be=p(V,re.children||[]),be.return=te,te=be;break e}else{s(te,V);break}else r(te,V);V=V.sibling}be=md(re,te.mode,be),be.return=te,te=be}return S(te);case H:return re=li(re),tn(te,V,re,be)}if(ne(re))return qe(te,V,re,be);if(U(re)){if(Je=U(re),typeof Je!="function")throw Error(i(150));return re=Je.call(re),it(te,V,re,be)}if(typeof re.then=="function")return tn(te,V,yc(re),be);if(re.$$typeof===R)return tn(te,V,hc(te,re),be);gc(te,re)}return typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint"?(re=""+re,V!==null&&V.tag===6?(s(te,V.sibling),be=p(V,re),be.return=te,te=be):(s(te,V),be=hd(re,te.mode,be),be.return=te,te=be),S(te)):s(te,V)}return function(te,V,re,be){try{Ys=0;var Je=tn(te,V,re,be);return Vi=null,Je}catch(Xe){if(Xe===Gi||Xe===pc)throw Xe;var It=vr(29,Xe,null,te.mode);return It.lanes=be,It.return=te,It}finally{}}}var si=Bp(!0),Op=Bp(!1),fl=!1;function Nd(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ed(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function hl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function ml(t,r,s){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Xt&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,r=cc(t),vp(t,null,s),r}return oc(t,c,r,s),cc(t)}function Ws(t,r,s){if(r=r.updateQueue,r!==null&&(r=r.shared,(s&4194048)!==0)){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,Ie(t,s)}}function Ad(t,r){var s=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,s===c)){var p=null,g=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};g===null?p=g=S:g=g.next=S,s=s.next}while(s!==null);g===null?p=g=r:g=g.next=r}else p=g=r;s={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:c.shared,callbacks:c.callbacks},t.updateQueue=s;return}t=s.lastBaseUpdate,t===null?s.firstBaseUpdate=r:t.next=r,s.lastBaseUpdate=r}var Dd=!1;function Gs(){if(Dd){var t=Wi;if(t!==null)throw t}}function Vs(t,r,s,c){Dd=!1;var p=t.updateQueue;fl=!1;var g=p.firstBaseUpdate,S=p.lastBaseUpdate,z=p.shared.pending;if(z!==null){p.shared.pending=null;var X=z,ae=X.next;X.next=null,S===null?g=ae:S.next=ae,S=X;var me=t.alternate;me!==null&&(me=me.updateQueue,z=me.lastBaseUpdate,z!==S&&(z===null?me.firstBaseUpdate=ae:z.next=ae,me.lastBaseUpdate=X))}if(g!==null){var Se=p.baseState;S=0,me=ae=X=null,z=g;do{var ie=z.lane&-536870913,fe=ie!==z.lane;if(fe?(Tt&ie)===ie:(c&ie)===ie){ie!==0&&ie===Xi&&(Dd=!0),me!==null&&(me=me.next={lane:0,tag:z.tag,payload:z.payload,callback:null,next:null});e:{var qe=t,it=z;ie=r;var tn=s;switch(it.tag){case 1:if(qe=it.payload,typeof qe=="function"){Se=qe.call(tn,Se,ie);break e}Se=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=it.payload,ie=typeof qe=="function"?qe.call(tn,Se,ie):qe,ie==null)break e;Se=y({},Se,ie);break e;case 2:fl=!0}}ie=z.callback,ie!==null&&(t.flags|=64,fe&&(t.flags|=8192),fe=p.callbacks,fe===null?p.callbacks=[ie]:fe.push(ie))}else fe={lane:ie,tag:z.tag,payload:z.payload,callback:z.callback,next:null},me===null?(ae=me=fe,X=Se):me=me.next=fe,S|=ie;if(z=z.next,z===null){if(z=p.shared.pending,z===null)break;fe=z,z=fe.next,fe.next=null,p.lastBaseUpdate=fe,p.shared.pending=null}}while(!0);me===null&&(X=Se),p.baseState=X,p.firstBaseUpdate=ae,p.lastBaseUpdate=me,g===null&&(p.shared.lanes=0),bl|=S,t.lanes=S,t.memoizedState=Se}}function $p(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function Lp(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;t<s.length;t++)$p(s[t],r)}var Ki=F(null),bc=F(0);function Ip(t,r){t=Ga,T(bc,t),T(Ki,r),Ga=t|r.baseLanes}function Td(){T(bc,Ga),T(Ki,Ki.current)}function Fd(){Ga=bc.current,q(Ki),q(bc)}var wr=F(null),Lr=null;function pl(t){var r=t.alternate;T(bn,bn.current&1),T(wr,t),Lr===null&&(r===null||Ki.current!==null||r.memoizedState!==null)&&(Lr=t)}function Md(t){T(bn,bn.current),T(wr,t),Lr===null&&(Lr=t)}function Hp(t){t.tag===22?(T(bn,bn.current),T(wr,t),Lr===null&&(Lr=t)):xl()}function xl(){T(bn,bn.current),T(wr,wr.current)}function kr(t){q(wr),Lr===t&&(Lr=null),q(bn)}var bn=F(0);function vc(t){for(var r=t;r!==null;){if(r.tag===13){var s=r.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||Lf(s)||If(s)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var La=0,gt=null,Jt=null,Cn=null,wc=!1,Qi=!1,oi=!1,kc=0,Ks=0,Pi=null,Pv=0;function yn(){throw Error(i(321))}function Rd(t,r){if(r===null)return!1;for(var s=0;s<r.length&&s<t.length;s++)if(!br(t[s],r[s]))return!1;return!0}function zd(t,r,s,c,p,g){return La=g,gt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Y.H=t===null||t.memoizedState===null?Sx:Kd,oi=!1,g=s(c,p),oi=!1,Qi&&(g=qp(r,s,c,p)),Up(t),g}function Up(t){Y.H=Zs;var r=Jt!==null&&Jt.next!==null;if(La=0,Cn=Jt=gt=null,wc=!1,Ks=0,Pi=null,r)throw Error(i(300));t===null||Nn||(t=t.dependencies,t!==null&&fc(t)&&(Nn=!0))}function qp(t,r,s,c){gt=t;var p=0;do{if(Qi&&(Pi=null),Ks=0,Qi=!1,25<=p)throw Error(i(301));if(p+=1,Cn=Jt=null,t.updateQueue!=null){var g=t.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}Y.H=Cx,g=r(s,c)}while(Qi);return g}function Zv(){var t=Y.H,r=t.useState()[0];return r=typeof r.then=="function"?Qs(r):r,t=t.useState()[0],(Jt!==null?Jt.memoizedState:null)!==t&&(gt.flags|=1024),r}function _d(){var t=kc!==0;return kc=0,t}function Bd(t,r,s){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~s}function Od(t){if(wc){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}wc=!1}La=0,Cn=Jt=gt=null,Qi=!1,Ks=kc=0,Pi=null}function nr(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Cn===null?gt.memoizedState=Cn=t:Cn=Cn.next=t,Cn}function vn(){if(Jt===null){var t=gt.alternate;t=t!==null?t.memoizedState:null}else t=Jt.next;var r=Cn===null?gt.memoizedState:Cn.next;if(r!==null)Cn=r,Jt=t;else{if(t===null)throw gt.alternate===null?Error(i(467)):Error(i(310));Jt=t,t={memoizedState:Jt.memoizedState,baseState:Jt.baseState,baseQueue:Jt.baseQueue,queue:Jt.queue,next:null},Cn===null?gt.memoizedState=Cn=t:Cn=Cn.next=t}return Cn}function jc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Qs(t){var r=Ks;return Ks+=1,Pi===null&&(Pi=[]),t=Rp(Pi,t,r),r=gt,(Cn===null?r.memoizedState:Cn.next)===null&&(r=r.alternate,Y.H=r===null||r.memoizedState===null?Sx:Kd),t}function Sc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Qs(t);if(t.$$typeof===R)return Yn(t)}throw Error(i(438,String(t)))}function $d(t){var r=null,s=gt.updateQueue;if(s!==null&&(r=s.memoCache),r==null){var c=gt.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(r={data:c.data.map(function(p){return p.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),s===null&&(s=jc(),gt.updateQueue=s),s.memoCache=r,s=r.data[r.index],s===void 0)for(s=r.data[r.index]=Array(t),c=0;c<t;c++)s[c]=A;return r.index++,s}function Ia(t,r){return typeof r=="function"?r(t):r}function Cc(t){var r=vn();return Ld(r,Jt,t)}function Ld(t,r,s){var c=t.queue;if(c===null)throw Error(i(311));c.lastRenderedReducer=s;var p=t.baseQueue,g=c.pending;if(g!==null){if(p!==null){var S=p.next;p.next=g.next,g.next=S}r.baseQueue=p=g,c.pending=null}if(g=t.baseState,p===null)t.memoizedState=g;else{r=p.next;var z=S=null,X=null,ae=r,me=!1;do{var Se=ae.lane&-536870913;if(Se!==ae.lane?(Tt&Se)===Se:(La&Se)===Se){var ie=ae.revertLane;if(ie===0)X!==null&&(X=X.next={lane:0,revertLane:0,gesture:null,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null}),Se===Xi&&(me=!0);else if((La&ie)===ie){ae=ae.next,ie===Xi&&(me=!0);continue}else Se={lane:0,revertLane:ae.revertLane,gesture:null,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null},X===null?(z=X=Se,S=g):X=X.next=Se,gt.lanes|=ie,bl|=ie;Se=ae.action,oi&&s(g,Se),g=ae.hasEagerState?ae.eagerState:s(g,Se)}else ie={lane:Se,revertLane:ae.revertLane,gesture:ae.gesture,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null},X===null?(z=X=ie,S=g):X=X.next=ie,gt.lanes|=Se,bl|=Se;ae=ae.next}while(ae!==null&&ae!==r);if(X===null?S=g:X.next=z,!br(g,t.memoizedState)&&(Nn=!0,me&&(s=Wi,s!==null)))throw s;t.memoizedState=g,t.baseState=S,t.baseQueue=X,c.lastRenderedState=g}return p===null&&(c.lanes=0),[t.memoizedState,c.dispatch]}function Id(t){var r=vn(),s=r.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=t;var c=s.dispatch,p=s.pending,g=r.memoizedState;if(p!==null){s.pending=null;var S=p=p.next;do g=t(g,S.action),S=S.next;while(S!==p);br(g,r.memoizedState)||(Nn=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),s.lastRenderedState=g}return[g,c]}function Yp(t,r,s){var c=gt,p=vn(),g=zt;if(g){if(s===void 0)throw Error(i(407));s=s()}else s=r();var S=!br((Jt||p).memoizedState,s);if(S&&(p.memoizedState=s,Nn=!0),p=p.queue,qd(Gp.bind(null,c,p,t),[t]),p.getSnapshot!==r||S||Cn!==null&&Cn.memoizedState.tag&1){if(c.flags|=2048,Zi(9,{destroy:void 0},Wp.bind(null,c,p,s,r),null),rn===null)throw Error(i(349));g||(La&127)!==0||Xp(c,r,s)}return s}function Xp(t,r,s){t.flags|=16384,t={getSnapshot:r,value:s},r=gt.updateQueue,r===null?(r=jc(),gt.updateQueue=r,r.stores=[t]):(s=r.stores,s===null?r.stores=[t]:s.push(t))}function Wp(t,r,s,c){r.value=s,r.getSnapshot=c,Vp(r)&&Kp(t)}function Gp(t,r,s){return s(function(){Vp(r)&&Kp(t)})}function Vp(t){var r=t.getSnapshot;t=t.value;try{var s=r();return!br(t,s)}catch{return!0}}function Kp(t){var r=Jl(t,2);r!==null&&hr(r,t,2)}function Hd(t){var r=nr();if(typeof t=="function"){var s=t;if(t=s(),oi){tt(!0);try{s()}finally{tt(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:t},r}function Qp(t,r,s,c){return t.baseState=s,Ld(t,Jt,typeof c=="function"?c:Ia)}function Jv(t,r,s,c,p){if(Ac(t))throw Error(i(485));if(t=r.action,t!==null){var g={payload:p,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};Y.T!==null?s(!0):g.isTransition=!1,c(g),s=r.pending,s===null?(g.next=r.pending=g,Pp(r,g)):(g.next=s.next,r.pending=s.next=g)}}function Pp(t,r){var s=r.action,c=r.payload,p=t.state;if(r.isTransition){var g=Y.T,S={};Y.T=S;try{var z=s(p,c),X=Y.S;X!==null&&X(S,z),Zp(t,r,z)}catch(ae){Ud(t,r,ae)}finally{g!==null&&S.types!==null&&(g.types=S.types),Y.T=g}}else try{g=s(p,c),Zp(t,r,g)}catch(ae){Ud(t,r,ae)}}function Zp(t,r,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(c){Jp(t,r,c)},function(c){return Ud(t,r,c)}):Jp(t,r,s)}function Jp(t,r,s){r.status="fulfilled",r.value=s,ex(r),t.state=s,r=t.pending,r!==null&&(s=r.next,s===r?t.pending=null:(s=s.next,r.next=s,Pp(t,s)))}function Ud(t,r,s){var c=t.pending;if(t.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=s,ex(r),r=r.next;while(r!==c)}t.action=null}function ex(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function tx(t,r){return r}function nx(t,r){if(zt){var s=rn.formState;if(s!==null){e:{var c=gt;if(zt){if(un){t:{for(var p=un,g=$r;p.nodeType!==8;){if(!g){p=null;break t}if(p=Ir(p.nextSibling),p===null){p=null;break t}}g=p.data,p=g==="F!"||g==="F"?p:null}if(p){un=Ir(p.nextSibling),c=p.data==="F!";break e}}ul(c)}c=!1}c&&(r=s[0])}}return s=nr(),s.memoizedState=s.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:tx,lastRenderedState:r},s.queue=c,s=wx.bind(null,gt,c),c.dispatch=s,c=Hd(!1),g=Vd.bind(null,gt,!1,c.queue),c=nr(),p={state:r,dispatch:null,action:t,pending:null},c.queue=p,s=Jv.bind(null,gt,p,g,s),p.dispatch=s,c.memoizedState=t,[r,s,!1]}function rx(t){var r=vn();return ax(r,Jt,t)}function ax(t,r,s){if(r=Ld(t,r,tx)[0],t=Cc(Ia)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=Qs(r)}catch(S){throw S===Gi?pc:S}else c=r;r=vn();var p=r.queue,g=p.dispatch;return s!==r.memoizedState&&(gt.flags|=2048,Zi(9,{destroy:void 0},e2.bind(null,p,s),null)),[c,g,t]}function e2(t,r){t.action=r}function lx(t){var r=vn(),s=Jt;if(s!==null)return ax(r,s,t);vn(),r=r.memoizedState,s=vn();var c=s.queue.dispatch;return s.memoizedState=t,[r,c,!1]}function Zi(t,r,s,c){return t={tag:t,create:s,deps:c,inst:r,next:null},r=gt.updateQueue,r===null&&(r=jc(),gt.updateQueue=r),s=r.lastEffect,s===null?r.lastEffect=t.next=t:(c=s.next,s.next=t,t.next=c,r.lastEffect=t),t}function ix(){return vn().memoizedState}function Nc(t,r,s,c){var p=nr();gt.flags|=t,p.memoizedState=Zi(1|r,{destroy:void 0},s,c===void 0?null:c)}function Ec(t,r,s,c){var p=vn();c=c===void 0?null:c;var g=p.memoizedState.inst;Jt!==null&&c!==null&&Rd(c,Jt.memoizedState.deps)?p.memoizedState=Zi(r,g,s,c):(gt.flags|=t,p.memoizedState=Zi(1|r,g,s,c))}function sx(t,r){Nc(8390656,8,t,r)}function qd(t,r){Ec(2048,8,t,r)}function t2(t){gt.flags|=4;var r=gt.updateQueue;if(r===null)r=jc(),gt.updateQueue=r,r.events=[t];else{var s=r.events;s===null?r.events=[t]:s.push(t)}}function ox(t){var r=vn().memoizedState;return t2({ref:r,nextImpl:t}),function(){if((Xt&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function cx(t,r){return Ec(4,2,t,r)}function ux(t,r){return Ec(4,4,t,r)}function dx(t,r){if(typeof r=="function"){t=t();var s=r(t);return function(){typeof s=="function"?s():r(null)}}if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function fx(t,r,s){s=s!=null?s.concat([t]):null,Ec(4,4,dx.bind(null,r,t),s)}function Yd(){}function hx(t,r){var s=vn();r=r===void 0?null:r;var c=s.memoizedState;return r!==null&&Rd(r,c[1])?c[0]:(s.memoizedState=[t,r],t)}function mx(t,r){var s=vn();r=r===void 0?null:r;var c=s.memoizedState;if(r!==null&&Rd(r,c[1]))return c[0];if(c=t(),oi){tt(!0);try{t()}finally{tt(!1)}}return s.memoizedState=[c,r],c}function Xd(t,r,s){return s===void 0||(La&1073741824)!==0&&(Tt&261930)===0?t.memoizedState=r:(t.memoizedState=s,t=p1(),gt.lanes|=t,bl|=t,s)}function px(t,r,s,c){return br(s,r)?s:Ki.current!==null?(t=Xd(t,s,c),br(t,r)||(Nn=!0),t):(La&42)===0||(La&1073741824)!==0&&(Tt&261930)===0?(Nn=!0,t.memoizedState=s):(t=p1(),gt.lanes|=t,bl|=t,r)}function xx(t,r,s,c,p){var g=ue.p;ue.p=g!==0&&8>g?g:8;var S=Y.T,z={};Y.T=z,Vd(t,!1,r,s);try{var X=p(),ae=Y.S;if(ae!==null&&ae(z,X),X!==null&&typeof X=="object"&&typeof X.then=="function"){var me=Qv(X,c);Ps(t,r,me,Cr(t))}else Ps(t,r,c,Cr(t))}catch(Se){Ps(t,r,{then:function(){},status:"rejected",reason:Se},Cr())}finally{ue.p=g,S!==null&&z.types!==null&&(S.types=z.types),Y.T=S}}function n2(){}function Wd(t,r,s,c){if(t.tag!==5)throw Error(i(476));var p=yx(t).queue;xx(t,p,r,J,s===null?n2:function(){return gx(t),s(c)})}function yx(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:J},next:null};var s={};return r.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:s},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function gx(t){var r=yx(t);r.next===null&&(r=t.alternate.memoizedState),Ps(t,r.next.queue,{},Cr())}function Gd(){return Yn(po)}function bx(){return vn().memoizedState}function vx(){return vn().memoizedState}function r2(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=Cr();t=hl(s);var c=ml(r,t,s);c!==null&&(hr(c,r,s),Ws(c,r,s)),r={cache:kd()},t.payload=r;return}r=r.return}}function a2(t,r,s){var c=Cr();s={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Ac(t)?kx(r,s):(s=dd(t,r,s,c),s!==null&&(hr(s,t,c),jx(s,r,c)))}function wx(t,r,s){var c=Cr();Ps(t,r,s,c)}function Ps(t,r,s,c){var p={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Ac(t))kx(r,p);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var S=r.lastRenderedState,z=g(S,s);if(p.hasEagerState=!0,p.eagerState=z,br(z,S))return oc(t,r,p,0),rn===null&&sc(),!1}catch{}finally{}if(s=dd(t,r,p,c),s!==null)return hr(s,t,c),jx(s,r,c),!0}return!1}function Vd(t,r,s,c){if(c={lane:2,revertLane:Ef(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Ac(t)){if(r)throw Error(i(479))}else r=dd(t,s,c,2),r!==null&&hr(r,t,2)}function Ac(t){var r=t.alternate;return t===gt||r!==null&&r===gt}function kx(t,r){Qi=wc=!0;var s=t.pending;s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r}function jx(t,r,s){if((s&4194048)!==0){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,Ie(t,s)}}var Zs={readContext:Yn,use:Sc,useCallback:yn,useContext:yn,useEffect:yn,useImperativeHandle:yn,useLayoutEffect:yn,useInsertionEffect:yn,useMemo:yn,useReducer:yn,useRef:yn,useState:yn,useDebugValue:yn,useDeferredValue:yn,useTransition:yn,useSyncExternalStore:yn,useId:yn,useHostTransitionStatus:yn,useFormState:yn,useActionState:yn,useOptimistic:yn,useMemoCache:yn,useCacheRefresh:yn};Zs.useEffectEvent=yn;var Sx={readContext:Yn,use:Sc,useCallback:function(t,r){return nr().memoizedState=[t,r===void 0?null:r],t},useContext:Yn,useEffect:sx,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,Nc(4194308,4,dx.bind(null,r,t),s)},useLayoutEffect:function(t,r){return Nc(4194308,4,t,r)},useInsertionEffect:function(t,r){Nc(4,2,t,r)},useMemo:function(t,r){var s=nr();r=r===void 0?null:r;var c=t();if(oi){tt(!0);try{t()}finally{tt(!1)}}return s.memoizedState=[c,r],c},useReducer:function(t,r,s){var c=nr();if(s!==void 0){var p=s(r);if(oi){tt(!0);try{s(r)}finally{tt(!1)}}}else p=r;return c.memoizedState=c.baseState=p,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:p},c.queue=t,t=t.dispatch=a2.bind(null,gt,t),[c.memoizedState,t]},useRef:function(t){var r=nr();return t={current:t},r.memoizedState=t},useState:function(t){t=Hd(t);var r=t.queue,s=wx.bind(null,gt,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:Yd,useDeferredValue:function(t,r){var s=nr();return Xd(s,t,r)},useTransition:function(){var t=Hd(!1);return t=xx.bind(null,gt,t.queue,!0,!1),nr().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var c=gt,p=nr();if(zt){if(s===void 0)throw Error(i(407));s=s()}else{if(s=r(),rn===null)throw Error(i(349));(Tt&127)!==0||Xp(c,r,s)}p.memoizedState=s;var g={value:s,getSnapshot:r};return p.queue=g,sx(Gp.bind(null,c,g,t),[t]),c.flags|=2048,Zi(9,{destroy:void 0},Wp.bind(null,c,g,s,r),null),s},useId:function(){var t=nr(),r=rn.identifierPrefix;if(zt){var s=ha,c=fa;s=(c&~(1<<32-Ke(c)-1)).toString(32)+s,r="_"+r+"R_"+s,s=kc++,0<s&&(r+="H"+s.toString(32)),r+="_"}else s=Pv++,r="_"+r+"r_"+s.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Gd,useFormState:nx,useActionState:nx,useOptimistic:function(t){var r=nr();r.memoizedState=r.baseState=t;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=s,r=Vd.bind(null,gt,!0,s),s.dispatch=r,[t,r]},useMemoCache:$d,useCacheRefresh:function(){return nr().memoizedState=r2.bind(null,gt)},useEffectEvent:function(t){var r=nr(),s={impl:t};return r.memoizedState=s,function(){if((Xt&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}},Kd={readContext:Yn,use:Sc,useCallback:hx,useContext:Yn,useEffect:qd,useImperativeHandle:fx,useInsertionEffect:cx,useLayoutEffect:ux,useMemo:mx,useReducer:Cc,useRef:ix,useState:function(){return Cc(Ia)},useDebugValue:Yd,useDeferredValue:function(t,r){var s=vn();return px(s,Jt.memoizedState,t,r)},useTransition:function(){var t=Cc(Ia)[0],r=vn().memoizedState;return[typeof t=="boolean"?t:Qs(t),r]},useSyncExternalStore:Yp,useId:bx,useHostTransitionStatus:Gd,useFormState:rx,useActionState:rx,useOptimistic:function(t,r){var s=vn();return Qp(s,Jt,t,r)},useMemoCache:$d,useCacheRefresh:vx};Kd.useEffectEvent=ox;var Cx={readContext:Yn,use:Sc,useCallback:hx,useContext:Yn,useEffect:qd,useImperativeHandle:fx,useInsertionEffect:cx,useLayoutEffect:ux,useMemo:mx,useReducer:Id,useRef:ix,useState:function(){return Id(Ia)},useDebugValue:Yd,useDeferredValue:function(t,r){var s=vn();return Jt===null?Xd(s,t,r):px(s,Jt.memoizedState,t,r)},useTransition:function(){var t=Id(Ia)[0],r=vn().memoizedState;return[typeof t=="boolean"?t:Qs(t),r]},useSyncExternalStore:Yp,useId:bx,useHostTransitionStatus:Gd,useFormState:lx,useActionState:lx,useOptimistic:function(t,r){var s=vn();return Jt!==null?Qp(s,Jt,t,r):(s.baseState=t,[t,s.queue.dispatch])},useMemoCache:$d,useCacheRefresh:vx};Cx.useEffectEvent=ox;function Qd(t,r,s,c){r=t.memoizedState,s=s(c,r),s=s==null?r:y({},r,s),t.memoizedState=s,t.lanes===0&&(t.updateQueue.baseState=s)}var Pd={enqueueSetState:function(t,r,s){t=t._reactInternals;var c=Cr(),p=hl(c);p.payload=r,s!=null&&(p.callback=s),r=ml(t,p,c),r!==null&&(hr(r,t,c),Ws(r,t,c))},enqueueReplaceState:function(t,r,s){t=t._reactInternals;var c=Cr(),p=hl(c);p.tag=1,p.payload=r,s!=null&&(p.callback=s),r=ml(t,p,c),r!==null&&(hr(r,t,c),Ws(r,t,c))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var s=Cr(),c=hl(s);c.tag=2,r!=null&&(c.callback=r),r=ml(t,c,s),r!==null&&(hr(r,t,s),Ws(r,t,s))}};function Nx(t,r,s,c,p,g,S){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,g,S):r.prototype&&r.prototype.isPureReactComponent?!$s(s,c)||!$s(p,g):!0}function Ex(t,r,s,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(s,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(s,c),r.state!==t&&Pd.enqueueReplaceState(r,r.state,null)}function ci(t,r){var s=r;if("ref"in r){s={};for(var c in r)c!=="ref"&&(s[c]=r[c])}if(t=t.defaultProps){s===r&&(s=y({},s));for(var p in t)s[p]===void 0&&(s[p]=t[p])}return s}function Ax(t){ic(t)}function Dx(t){console.error(t)}function Tx(t){ic(t)}function Dc(t,r){try{var s=t.onUncaughtError;s(r.value,{componentStack:r.stack})}catch(c){setTimeout(function(){throw c})}}function Fx(t,r,s){try{var c=t.onCaughtError;c(s.value,{componentStack:s.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function Zd(t,r,s){return s=hl(s),s.tag=3,s.payload={element:null},s.callback=function(){Dc(t,r)},s}function Mx(t){return t=hl(t),t.tag=3,t}function Rx(t,r,s,c){var p=s.type.getDerivedStateFromError;if(typeof p=="function"){var g=c.value;t.payload=function(){return p(g)},t.callback=function(){Fx(r,s,c)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(t.callback=function(){Fx(r,s,c),typeof p!="function"&&(vl===null?vl=new Set([this]):vl.add(this));var z=c.stack;this.componentDidCatch(c.value,{componentStack:z!==null?z:""})})}function l2(t,r,s,c,p){if(s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=s.alternate,r!==null&&Yi(r,s,p,!0),s=wr.current,s!==null){switch(s.tag){case 31:case 13:return Lr===null?Hc():s.alternate===null&&gn===0&&(gn=3),s.flags&=-257,s.flags|=65536,s.lanes=p,c===xc?s.flags|=16384:(r=s.updateQueue,r===null?s.updateQueue=new Set([c]):r.add(c),Sf(t,c,p)),!1;case 22:return s.flags|=65536,c===xc?s.flags|=16384:(r=s.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([c])},s.updateQueue=r):(s=r.retryQueue,s===null?r.retryQueue=new Set([c]):s.add(c)),Sf(t,c,p)),!1}throw Error(i(435,s.tag))}return Sf(t,c,p),Hc(),!1}if(zt)return r=wr.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,c!==yd&&(t=Error(i(422),{cause:c}),Hs(_r(t,s)))):(c!==yd&&(r=Error(i(423),{cause:c}),Hs(_r(r,s))),t=t.current.alternate,t.flags|=65536,p&=-p,t.lanes|=p,c=_r(c,s),p=Zd(t.stateNode,c,p),Ad(t,p),gn!==4&&(gn=2)),!1;var g=Error(i(520),{cause:c});if(g=_r(g,s),io===null?io=[g]:io.push(g),gn!==4&&(gn=2),r===null)return!0;c=_r(c,s),s=r;do{switch(s.tag){case 3:return s.flags|=65536,t=p&-p,s.lanes|=t,t=Zd(s.stateNode,c,t),Ad(s,t),!1;case 1:if(r=s.type,g=s.stateNode,(s.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(vl===null||!vl.has(g))))return s.flags|=65536,p&=-p,s.lanes|=p,p=Mx(p),Rx(p,t,s,c),Ad(s,p),!1}s=s.return}while(s!==null);return!1}var Jd=Error(i(461)),Nn=!1;function Xn(t,r,s,c){r.child=t===null?Op(r,null,s,c):si(r,t.child,s,c)}function zx(t,r,s,c,p){s=s.render;var g=r.ref;if("ref"in c){var S={};for(var z in c)z!=="ref"&&(S[z]=c[z])}else S=c;return ri(r),c=zd(t,r,s,S,g,p),z=_d(),t!==null&&!Nn?(Bd(t,r,p),Ha(t,r,p)):(zt&&z&&pd(r),r.flags|=1,Xn(t,r,c,p),r.child)}function _x(t,r,s,c,p){if(t===null){var g=s.type;return typeof g=="function"&&!fd(g)&&g.defaultProps===void 0&&s.compare===null?(r.tag=15,r.type=g,Bx(t,r,g,c,p)):(t=uc(s.type,null,c,r,r.mode,p),t.ref=r.ref,t.return=r,r.child=t)}if(g=t.child,!of(t,p)){var S=g.memoizedProps;if(s=s.compare,s=s!==null?s:$s,s(S,c)&&t.ref===r.ref)return Ha(t,r,p)}return r.flags|=1,t=_a(g,c),t.ref=r.ref,t.return=r,r.child=t}function Bx(t,r,s,c,p){if(t!==null){var g=t.memoizedProps;if($s(g,c)&&t.ref===r.ref)if(Nn=!1,r.pendingProps=c=g,of(t,p))(t.flags&131072)!==0&&(Nn=!0);else return r.lanes=t.lanes,Ha(t,r,p)}return ef(t,r,s,c,p)}function Ox(t,r,s,c){var p=c.children,g=t!==null?t.memoizedState:null;if(t===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((r.flags&128)!==0){if(g=g!==null?g.baseLanes|s:s,t!==null){for(c=r.child=t.child,p=0;c!==null;)p=p|c.lanes|c.childLanes,c=c.sibling;c=p&~g}else c=0,r.child=null;return $x(t,r,g,s,c)}if((s&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&mc(r,g!==null?g.cachePool:null),g!==null?Ip(r,g):Td(),Hp(r);else return c=r.lanes=536870912,$x(t,r,g!==null?g.baseLanes|s:s,s,c)}else g!==null?(mc(r,g.cachePool),Ip(r,g),xl(),r.memoizedState=null):(t!==null&&mc(r,null),Td(),xl());return Xn(t,r,p,s),r.child}function Js(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function $x(t,r,s,c,p){var g=Sd();return g=g===null?null:{parent:Sn._currentValue,pool:g},r.memoizedState={baseLanes:s,cachePool:g},t!==null&&mc(r,null),Td(),Hp(r),t!==null&&Yi(t,r,c,!0),r.childLanes=p,null}function Tc(t,r){return r=Mc({mode:r.mode,children:r.children},t.mode),r.ref=t.ref,t.child=r,r.return=t,r}function Lx(t,r,s){return si(r,t.child,null,s),t=Tc(r,r.pendingProps),t.flags|=2,kr(r),r.memoizedState=null,t}function i2(t,r,s){var c=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,t===null){if(zt){if(c.mode==="hidden")return t=Tc(r,c),r.lanes=536870912,Js(null,t);if(Md(r),(t=un)?(t=P1(t,$r),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:ol!==null?{id:fa,overflow:ha}:null,retryLane:536870912,hydrationErrors:null},s=kp(t),s.return=r,r.child=s,qn=r,un=null)):t=null,t===null)throw ul(r);return r.lanes=536870912,null}return Tc(r,c)}var g=t.memoizedState;if(g!==null){var S=g.dehydrated;if(Md(r),p)if(r.flags&256)r.flags&=-257,r=Lx(t,r,s);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(Nn||Yi(t,r,s,!1),p=(s&t.childLanes)!==0,Nn||p){if(c=rn,c!==null&&(S=St(c,s),S!==0&&S!==g.retryLane))throw g.retryLane=S,Jl(t,S),hr(c,t,S),Jd;Hc(),r=Lx(t,r,s)}else t=g.treeContext,un=Ir(S.nextSibling),qn=r,zt=!0,cl=null,$r=!1,t!==null&&Cp(r,t),r=Tc(r,c),r.flags|=4096;return r}return t=_a(t.child,{mode:c.mode,children:c.children}),t.ref=r.ref,r.child=t,t.return=r,t}function Fc(t,r){var s=r.ref;if(s===null)t!==null&&t.ref!==null&&(r.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(i(284));(t===null||t.ref!==s)&&(r.flags|=4194816)}}function ef(t,r,s,c,p){return ri(r),s=zd(t,r,s,c,void 0,p),c=_d(),t!==null&&!Nn?(Bd(t,r,p),Ha(t,r,p)):(zt&&c&&pd(r),r.flags|=1,Xn(t,r,s,p),r.child)}function Ix(t,r,s,c,p,g){return ri(r),r.updateQueue=null,s=qp(r,c,s,p),Up(t),c=_d(),t!==null&&!Nn?(Bd(t,r,g),Ha(t,r,g)):(zt&&c&&pd(r),r.flags|=1,Xn(t,r,s,g),r.child)}function Hx(t,r,s,c,p){if(ri(r),r.stateNode===null){var g=Ii,S=s.contextType;typeof S=="object"&&S!==null&&(g=Yn(S)),g=new s(c,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Pd,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=c,g.state=r.memoizedState,g.refs={},Nd(r),S=s.contextType,g.context=typeof S=="object"&&S!==null?Yn(S):Ii,g.state=r.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(Qd(r,s,S,c),g.state=r.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(S=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),S!==g.state&&Pd.enqueueReplaceState(g,g.state,null),Vs(r,c,g,p),Gs(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(t===null){g=r.stateNode;var z=r.memoizedProps,X=ci(s,z);g.props=X;var ae=g.context,me=s.contextType;S=Ii,typeof me=="object"&&me!==null&&(S=Yn(me));var Se=s.getDerivedStateFromProps;me=typeof Se=="function"||typeof g.getSnapshotBeforeUpdate=="function",z=r.pendingProps!==z,me||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(z||ae!==S)&&Ex(r,g,c,S),fl=!1;var ie=r.memoizedState;g.state=ie,Vs(r,c,g,p),Gs(),ae=r.memoizedState,z||ie!==ae||fl?(typeof Se=="function"&&(Qd(r,s,Se,c),ae=r.memoizedState),(X=fl||Nx(r,s,X,c,ie,ae,S))?(me||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=ae),g.props=c,g.state=ae,g.context=S,c=X):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{g=r.stateNode,Ed(t,r),S=r.memoizedProps,me=ci(s,S),g.props=me,Se=r.pendingProps,ie=g.context,ae=s.contextType,X=Ii,typeof ae=="object"&&ae!==null&&(X=Yn(ae)),z=s.getDerivedStateFromProps,(ae=typeof z=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==Se||ie!==X)&&Ex(r,g,c,X),fl=!1,ie=r.memoizedState,g.state=ie,Vs(r,c,g,p),Gs();var fe=r.memoizedState;S!==Se||ie!==fe||fl||t!==null&&t.dependencies!==null&&fc(t.dependencies)?(typeof z=="function"&&(Qd(r,s,z,c),fe=r.memoizedState),(me=fl||Nx(r,s,me,c,ie,fe,X)||t!==null&&t.dependencies!==null&&fc(t.dependencies))?(ae||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,fe,X),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,fe,X)),typeof g.componentDidUpdate=="function"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===t.memoizedProps&&ie===t.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&ie===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=fe),g.props=c,g.state=fe,g.context=X,c=me):(typeof g.componentDidUpdate!="function"||S===t.memoizedProps&&ie===t.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&ie===t.memoizedState||(r.flags|=1024),c=!1)}return g=c,Fc(t,r),c=(r.flags&128)!==0,g||c?(g=r.stateNode,s=c&&typeof s.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,t!==null&&c?(r.child=si(r,t.child,null,p),r.child=si(r,null,s,p)):Xn(t,r,s,p),r.memoizedState=g.state,t=r.child):t=Ha(t,r,p),t}function Ux(t,r,s,c){return ti(),r.flags|=256,Xn(t,r,s,c),r.child}var tf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function nf(t){return{baseLanes:t,cachePool:Fp()}}function rf(t,r,s){return t=t!==null?t.childLanes&~s:0,r&&(t|=Sr),t}function qx(t,r,s){var c=r.pendingProps,p=!1,g=(r.flags&128)!==0,S;if((S=g)||(S=t!==null&&t.memoizedState===null?!1:(bn.current&2)!==0),S&&(p=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,t===null){if(zt){if(p?pl(r):xl(),(t=un)?(t=P1(t,$r),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:ol!==null?{id:fa,overflow:ha}:null,retryLane:536870912,hydrationErrors:null},s=kp(t),s.return=r,r.child=s,qn=r,un=null)):t=null,t===null)throw ul(r);return If(t)?r.lanes=32:r.lanes=536870912,null}var z=c.children;return c=c.fallback,p?(xl(),p=r.mode,z=Mc({mode:"hidden",children:z},p),c=ei(c,p,s,null),z.return=r,c.return=r,z.sibling=c,r.child=z,c=r.child,c.memoizedState=nf(s),c.childLanes=rf(t,S,s),r.memoizedState=tf,Js(null,c)):(pl(r),af(r,z))}var X=t.memoizedState;if(X!==null&&(z=X.dehydrated,z!==null)){if(g)r.flags&256?(pl(r),r.flags&=-257,r=lf(t,r,s)):r.memoizedState!==null?(xl(),r.child=t.child,r.flags|=128,r=null):(xl(),z=c.fallback,p=r.mode,c=Mc({mode:"visible",children:c.children},p),z=ei(z,p,s,null),z.flags|=2,c.return=r,z.return=r,c.sibling=z,r.child=c,si(r,t.child,null,s),c=r.child,c.memoizedState=nf(s),c.childLanes=rf(t,S,s),r.memoizedState=tf,r=Js(null,c));else if(pl(r),If(z)){if(S=z.nextSibling&&z.nextSibling.dataset,S)var ae=S.dgst;S=ae,c=Error(i(419)),c.stack="",c.digest=S,Hs({value:c,source:null,stack:null}),r=lf(t,r,s)}else if(Nn||Yi(t,r,s,!1),S=(s&t.childLanes)!==0,Nn||S){if(S=rn,S!==null&&(c=St(S,s),c!==0&&c!==X.retryLane))throw X.retryLane=c,Jl(t,c),hr(S,t,c),Jd;Lf(z)||Hc(),r=lf(t,r,s)}else Lf(z)?(r.flags|=192,r.child=t.child,r=null):(t=X.treeContext,un=Ir(z.nextSibling),qn=r,zt=!0,cl=null,$r=!1,t!==null&&Cp(r,t),r=af(r,c.children),r.flags|=4096);return r}return p?(xl(),z=c.fallback,p=r.mode,X=t.child,ae=X.sibling,c=_a(X,{mode:"hidden",children:c.children}),c.subtreeFlags=X.subtreeFlags&65011712,ae!==null?z=_a(ae,z):(z=ei(z,p,s,null),z.flags|=2),z.return=r,c.return=r,c.sibling=z,r.child=c,Js(null,c),c=r.child,z=t.child.memoizedState,z===null?z=nf(s):(p=z.cachePool,p!==null?(X=Sn._currentValue,p=p.parent!==X?{parent:X,pool:X}:p):p=Fp(),z={baseLanes:z.baseLanes|s,cachePool:p}),c.memoizedState=z,c.childLanes=rf(t,S,s),r.memoizedState=tf,Js(t.child,c)):(pl(r),s=t.child,t=s.sibling,s=_a(s,{mode:"visible",children:c.children}),s.return=r,s.sibling=null,t!==null&&(S=r.deletions,S===null?(r.deletions=[t],r.flags|=16):S.push(t)),r.child=s,r.memoizedState=null,s)}function af(t,r){return r=Mc({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function Mc(t,r){return t=vr(22,t,null,r),t.lanes=0,t}function lf(t,r,s){return si(r,t.child,null,s),t=af(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Yx(t,r,s){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),vd(t.return,r,s)}function sf(t,r,s,c,p,g){var S=t.memoizedState;S===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:s,tailMode:p,treeForkCount:g}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=c,S.tail=s,S.tailMode=p,S.treeForkCount=g)}function Xx(t,r,s){var c=r.pendingProps,p=c.revealOrder,g=c.tail;c=c.children;var S=bn.current,z=(S&2)!==0;if(z?(S=S&1|2,r.flags|=128):S&=1,T(bn,S),Xn(t,r,c,s),c=zt?Is:0,!z&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Yx(t,s,r);else if(t.tag===19)Yx(t,s,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(p){case"forwards":for(s=r.child,p=null;s!==null;)t=s.alternate,t!==null&&vc(t)===null&&(p=s),s=s.sibling;s=p,s===null?(p=r.child,r.child=null):(p=s.sibling,s.sibling=null),sf(r,!1,p,s,g,c);break;case"backwards":case"unstable_legacy-backwards":for(s=null,p=r.child,r.child=null;p!==null;){if(t=p.alternate,t!==null&&vc(t)===null){r.child=p;break}t=p.sibling,p.sibling=s,s=p,p=t}sf(r,!0,s,null,g,c);break;case"together":sf(r,!1,null,null,void 0,c);break;default:r.memoizedState=null}return r.child}function Ha(t,r,s){if(t!==null&&(r.dependencies=t.dependencies),bl|=r.lanes,(s&r.childLanes)===0)if(t!==null){if(Yi(t,r,s,!1),(s&r.childLanes)===0)return null}else return null;if(t!==null&&r.child!==t.child)throw Error(i(153));if(r.child!==null){for(t=r.child,s=_a(t,t.pendingProps),r.child=s,s.return=r;t.sibling!==null;)t=t.sibling,s=s.sibling=_a(t,t.pendingProps),s.return=r;s.sibling=null}return r.child}function of(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&fc(t)))}function s2(t,r,s){switch(r.tag){case 3:Pe(r,r.stateNode.containerInfo),dl(r,Sn,t.memoizedState.cache),ti();break;case 27:case 5:lt(r);break;case 4:Pe(r,r.stateNode.containerInfo);break;case 10:dl(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Md(r),null;break;case 13:var c=r.memoizedState;if(c!==null)return c.dehydrated!==null?(pl(r),r.flags|=128,null):(s&r.child.childLanes)!==0?qx(t,r,s):(pl(r),t=Ha(t,r,s),t!==null?t.sibling:null);pl(r);break;case 19:var p=(t.flags&128)!==0;if(c=(s&r.childLanes)!==0,c||(Yi(t,r,s,!1),c=(s&r.childLanes)!==0),p){if(c)return Xx(t,r,s);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),T(bn,bn.current),c)break;return null;case 22:return r.lanes=0,Ox(t,r,s,r.pendingProps);case 24:dl(r,Sn,t.memoizedState.cache)}return Ha(t,r,s)}function Wx(t,r,s){if(t!==null)if(t.memoizedProps!==r.pendingProps)Nn=!0;else{if(!of(t,s)&&(r.flags&128)===0)return Nn=!1,s2(t,r,s);Nn=(t.flags&131072)!==0}else Nn=!1,zt&&(r.flags&1048576)!==0&&Sp(r,Is,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(t=li(r.elementType),r.type=t,typeof t=="function")fd(t)?(c=ci(t,c),r.tag=1,r=Hx(null,r,t,c,s)):(r.tag=0,r=ef(null,r,t,c,s));else{if(t!=null){var p=t.$$typeof;if(p===M){r.tag=11,r=zx(null,r,t,c,s);break e}else if(p===L){r.tag=14,r=_x(null,r,t,c,s);break e}}throw r=oe(t)||t,Error(i(306,r,""))}}return r;case 0:return ef(t,r,r.type,r.pendingProps,s);case 1:return c=r.type,p=ci(c,r.pendingProps),Hx(t,r,c,p,s);case 3:e:{if(Pe(r,r.stateNode.containerInfo),t===null)throw Error(i(387));c=r.pendingProps;var g=r.memoizedState;p=g.element,Ed(t,r),Vs(r,c,null,s);var S=r.memoizedState;if(c=S.cache,dl(r,Sn,c),c!==g.cache&&wd(r,[Sn],s,!0),Gs(),c=S.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=Ux(t,r,c,s);break e}else if(c!==p){p=_r(Error(i(424)),r),Hs(p),r=Ux(t,r,c,s);break e}else{switch(t=r.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(un=Ir(t.firstChild),qn=r,zt=!0,cl=null,$r=!0,s=Op(r,null,c,s),r.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(ti(),c===p){r=Ha(t,r,s);break e}Xn(t,r,c,s)}r=r.child}return r;case 26:return Fc(t,r),t===null?(s=r0(r.type,null,r.pendingProps,null))?r.memoizedState=s:zt||(s=r.type,t=r.pendingProps,c=Vc(ye.current).createElement(s),c[Tn]=r,c[On]=t,Wn(c,s,t),xn(c),r.stateNode=c):r.memoizedState=r0(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return lt(r),t===null&&zt&&(c=r.stateNode=e0(r.type,r.pendingProps,ye.current),qn=r,$r=!0,p=un,Sl(r.type)?(Hf=p,un=Ir(c.firstChild)):un=p),Xn(t,r,r.pendingProps.children,s),Fc(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&zt&&((p=c=un)&&(c=O2(c,r.type,r.pendingProps,$r),c!==null?(r.stateNode=c,qn=r,un=Ir(c.firstChild),$r=!1,p=!0):p=!1),p||ul(r)),lt(r),p=r.type,g=r.pendingProps,S=t!==null?t.memoizedProps:null,c=g.children,Bf(p,g)?c=null:S!==null&&Bf(p,S)&&(r.flags|=32),r.memoizedState!==null&&(p=zd(t,r,Zv,null,null,s),po._currentValue=p),Fc(t,r),Xn(t,r,c,s),r.child;case 6:return t===null&&zt&&((t=s=un)&&(s=$2(s,r.pendingProps,$r),s!==null?(r.stateNode=s,qn=r,un=null,t=!0):t=!1),t||ul(r)),null;case 13:return qx(t,r,s);case 4:return Pe(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=si(r,null,c,s):Xn(t,r,c,s),r.child;case 11:return zx(t,r,r.type,r.pendingProps,s);case 7:return Xn(t,r,r.pendingProps,s),r.child;case 8:return Xn(t,r,r.pendingProps.children,s),r.child;case 12:return Xn(t,r,r.pendingProps.children,s),r.child;case 10:return c=r.pendingProps,dl(r,r.type,c.value),Xn(t,r,c.children,s),r.child;case 9:return p=r.type._context,c=r.pendingProps.children,ri(r),p=Yn(p),c=c(p),r.flags|=1,Xn(t,r,c,s),r.child;case 14:return _x(t,r,r.type,r.pendingProps,s);case 15:return Bx(t,r,r.type,r.pendingProps,s);case 19:return Xx(t,r,s);case 31:return i2(t,r,s);case 22:return Ox(t,r,s,r.pendingProps);case 24:return ri(r),c=Yn(Sn),t===null?(p=Sd(),p===null&&(p=rn,g=kd(),p.pooledCache=g,g.refCount++,g!==null&&(p.pooledCacheLanes|=s),p=g),r.memoizedState={parent:c,cache:p},Nd(r),dl(r,Sn,p)):((t.lanes&s)!==0&&(Ed(t,r),Vs(r,null,null,s),Gs()),p=t.memoizedState,g=r.memoizedState,p.parent!==c?(p={parent:c,cache:c},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),dl(r,Sn,c)):(c=g.cache,dl(r,Sn,c),c!==p.cache&&wd(r,[Sn],s,!0))),Xn(t,r,r.pendingProps.children,s),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Ua(t){t.flags|=4}function cf(t,r,s,c,p){if((r=(t.mode&32)!==0)&&(r=!1),r){if(t.flags|=16777216,(p&335544128)===p)if(t.stateNode.complete)t.flags|=8192;else if(b1())t.flags|=8192;else throw ii=xc,Cd}else t.flags&=-16777217}function Gx(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!o0(r))if(b1())t.flags|=8192;else throw ii=xc,Cd}function Rc(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?nt():536870912,t.lanes|=r,ns|=r)}function eo(t,r){if(!zt)switch(t.tailMode){case"hidden":r=t.tail;for(var s=null;r!==null;)r.alternate!==null&&(s=r),r=r.sibling;s===null?t.tail=null:s.sibling=null;break;case"collapsed":s=t.tail;for(var c=null;s!==null;)s.alternate!==null&&(c=s),s=s.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function dn(t){var r=t.alternate!==null&&t.alternate.child===t.child,s=0,c=0;if(r)for(var p=t.child;p!==null;)s|=p.lanes|p.childLanes,c|=p.subtreeFlags&65011712,c|=p.flags&65011712,p.return=t,p=p.sibling;else for(p=t.child;p!==null;)s|=p.lanes|p.childLanes,c|=p.subtreeFlags,c|=p.flags,p.return=t,p=p.sibling;return t.subtreeFlags|=c,t.childLanes=s,r}function o2(t,r,s){var c=r.pendingProps;switch(xd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dn(r),null;case 1:return dn(r),null;case 3:return s=r.stateNode,c=null,t!==null&&(c=t.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),$a(Sn),Ve(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(qi(r)?Ua(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,gd())),dn(r),null;case 26:var p=r.type,g=r.memoizedState;return t===null?(Ua(r),g!==null?(dn(r),Gx(r,g)):(dn(r),cf(r,p,null,c,s))):g?g!==t.memoizedState?(Ua(r),dn(r),Gx(r,g)):(dn(r),r.flags&=-16777217):(t=t.memoizedProps,t!==c&&Ua(r),dn(r),cf(r,p,t,c,s)),null;case 27:if(dt(r),s=ye.current,p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ua(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return dn(r),null}t=de.current,qi(r)?Np(r):(t=e0(p,c,s),r.stateNode=t,Ua(r))}return dn(r),null;case 5:if(dt(r),p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ua(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return dn(r),null}if(g=de.current,qi(r))Np(r);else{var S=Vc(ye.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof c.is=="string"?S.createElement("select",{is:c.is}):S.createElement("select"),c.multiple?g.multiple=!0:c.size&&(g.size=c.size);break;default:g=typeof c.is=="string"?S.createElement(p,{is:c.is}):S.createElement(p)}}g[Tn]=r,g[On]=c;e:for(S=r.child;S!==null;){if(S.tag===5||S.tag===6)g.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===r)break e;for(;S.sibling===null;){if(S.return===null||S.return===r)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}r.stateNode=g;e:switch(Wn(g,p,c),p){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&Ua(r)}}return dn(r),cf(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==c&&Ua(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(i(166));if(t=ye.current,qi(r)){if(t=r.stateNode,s=r.memoizedProps,c=null,p=qn,p!==null)switch(p.tag){case 27:case 5:c=p.memoizedProps}t[Tn]=r,t=!!(t.nodeValue===s||c!==null&&c.suppressHydrationWarning===!0||q1(t.nodeValue,s)),t||ul(r,!0)}else t=Vc(t).createTextNode(c),t[Tn]=r,r.stateNode=t}return dn(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(c=qi(r),s!==null){if(t===null){if(!c)throw Error(i(318));if(t=r.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(557));t[Tn]=r}else ti(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;dn(r),t=!1}else s=gd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return r.flags&256?(kr(r),r):(kr(r),null);if((r.flags&128)!==0)throw Error(i(558))}return dn(r),null;case 13:if(c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=qi(r),c!==null&&c.dehydrated!==null){if(t===null){if(!p)throw Error(i(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[Tn]=r}else ti(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;dn(r),p=!1}else p=gd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(kr(r),r):(kr(r),null)}return kr(r),(r.flags&128)!==0?(r.lanes=s,r):(s=c!==null,t=t!==null&&t.memoizedState!==null,s&&(c=r.child,p=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(p=c.alternate.memoizedState.cachePool.pool),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==p&&(c.flags|=2048)),s!==t&&s&&(r.child.flags|=8192),Rc(r,r.updateQueue),dn(r),null);case 4:return Ve(),t===null&&Ff(r.stateNode.containerInfo),dn(r),null;case 10:return $a(r.type),dn(r),null;case 19:if(q(bn),c=r.memoizedState,c===null)return dn(r),null;if(p=(r.flags&128)!==0,g=c.rendering,g===null)if(p)eo(c,!1);else{if(gn!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(g=vc(t),g!==null){for(r.flags|=128,eo(c,!1),t=g.updateQueue,r.updateQueue=t,Rc(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)wp(s,t),s=s.sibling;return T(bn,bn.current&1|2),zt&&Ba(r,c.treeForkCount),r.child}t=t.sibling}c.tail!==null&&ve()>$c&&(r.flags|=128,p=!0,eo(c,!1),r.lanes=4194304)}else{if(!p)if(t=vc(g),t!==null){if(r.flags|=128,p=!0,t=t.updateQueue,r.updateQueue=t,Rc(r,t),eo(c,!0),c.tail===null&&c.tailMode==="hidden"&&!g.alternate&&!zt)return dn(r),null}else 2*ve()-c.renderingStartTime>$c&&s!==536870912&&(r.flags|=128,p=!0,eo(c,!1),r.lanes=4194304);c.isBackwards?(g.sibling=r.child,r.child=g):(t=c.last,t!==null?t.sibling=g:r.child=g,c.last=g)}return c.tail!==null?(t=c.tail,c.rendering=t,c.tail=t.sibling,c.renderingStartTime=ve(),t.sibling=null,s=bn.current,T(bn,p?s&1|2:s&1),zt&&Ba(r,c.treeForkCount),t):(dn(r),null);case 22:case 23:return kr(r),Fd(),c=r.memoizedState!==null,t!==null?t.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(s&536870912)!==0&&(r.flags&128)===0&&(dn(r),r.subtreeFlags&6&&(r.flags|=8192)):dn(r),s=r.updateQueue,s!==null&&Rc(r,s.retryQueue),s=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),c=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),c!==s&&(r.flags|=2048),t!==null&&q(ai),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),$a(Sn),dn(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function c2(t,r){switch(xd(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return $a(Sn),Ve(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return dt(r),null;case 31:if(r.memoizedState!==null){if(kr(r),r.alternate===null)throw Error(i(340));ti()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(kr(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(i(340));ti()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return q(bn),null;case 4:return Ve(),null;case 10:return $a(r.type),null;case 22:case 23:return kr(r),Fd(),t!==null&&q(ai),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return $a(Sn),null;case 25:return null;default:return null}}function Vx(t,r){switch(xd(r),r.tag){case 3:$a(Sn),Ve();break;case 26:case 27:case 5:dt(r);break;case 4:Ve();break;case 31:r.memoizedState!==null&&kr(r);break;case 13:kr(r);break;case 19:q(bn);break;case 10:$a(r.type);break;case 22:case 23:kr(r),Fd(),t!==null&&q(ai);break;case 24:$a(Sn)}}function to(t,r){try{var s=r.updateQueue,c=s!==null?s.lastEffect:null;if(c!==null){var p=c.next;s=p;do{if((s.tag&t)===t){c=void 0;var g=s.create,S=s.inst;c=g(),S.destroy=c}s=s.next}while(s!==p)}}catch(z){Qt(r,r.return,z)}}function yl(t,r,s){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var g=p.next;c=g;do{if((c.tag&t)===t){var S=c.inst,z=S.destroy;if(z!==void 0){S.destroy=void 0,p=r;var X=s,ae=z;try{ae()}catch(me){Qt(p,X,me)}}}c=c.next}while(c!==g)}}catch(me){Qt(r,r.return,me)}}function Kx(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{Lp(r,s)}catch(c){Qt(t,t.return,c)}}}function Qx(t,r,s){s.props=ci(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(c){Qt(t,r,c)}}function no(t,r){try{var s=t.ref;if(s!==null){switch(t.tag){case 26:case 27:case 5:var c=t.stateNode;break;case 30:c=t.stateNode;break;default:c=t.stateNode}typeof s=="function"?t.refCleanup=s(c):s.current=c}}catch(p){Qt(t,r,p)}}function ma(t,r){var s=t.ref,c=t.refCleanup;if(s!==null)if(typeof c=="function")try{c()}catch(p){Qt(t,r,p)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(p){Qt(t,r,p)}else s.current=null}function Px(t){var r=t.type,s=t.memoizedProps,c=t.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":s.autoFocus&&c.focus();break e;case"img":s.src?c.src=s.src:s.srcSet&&(c.srcset=s.srcSet)}}catch(p){Qt(t,t.return,p)}}function uf(t,r,s){try{var c=t.stateNode;F2(c,t.type,s,r),c[On]=r}catch(p){Qt(t,t.return,p)}}function Zx(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Sl(t.type)||t.tag===4}function df(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Zx(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Sl(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function ff(t,r,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(t,r):(r=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,r.appendChild(t),s=s._reactRootContainer,s!=null||r.onclick!==null||(r.onclick=Kn));else if(c!==4&&(c===27&&Sl(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(ff(t,r,s),t=t.sibling;t!==null;)ff(t,r,s),t=t.sibling}function zc(t,r,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?s.insertBefore(t,r):s.appendChild(t);else if(c!==4&&(c===27&&Sl(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(zc(t,r,s),t=t.sibling;t!==null;)zc(t,r,s),t=t.sibling}function Jx(t){var r=t.stateNode,s=t.memoizedProps;try{for(var c=t.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);Wn(r,c,s),r[Tn]=t,r[On]=s}catch(g){Qt(t,t.return,g)}}var qa=!1,En=!1,hf=!1,e1=typeof WeakSet=="function"?WeakSet:Set,In=null;function u2(t,r){if(t=t.containerInfo,zf=tu,t=fp(t),ld(t)){if("selectionStart"in t)var s={start:t.selectionStart,end:t.selectionEnd};else e:{s=(s=t.ownerDocument)&&s.defaultView||window;var c=s.getSelection&&s.getSelection();if(c&&c.rangeCount!==0){s=c.anchorNode;var p=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{s.nodeType,g.nodeType}catch{s=null;break e}var S=0,z=-1,X=-1,ae=0,me=0,Se=t,ie=null;t:for(;;){for(var fe;Se!==s||p!==0&&Se.nodeType!==3||(z=S+p),Se!==g||c!==0&&Se.nodeType!==3||(X=S+c),Se.nodeType===3&&(S+=Se.nodeValue.length),(fe=Se.firstChild)!==null;)ie=Se,Se=fe;for(;;){if(Se===t)break t;if(ie===s&&++ae===p&&(z=S),ie===g&&++me===c&&(X=S),(fe=Se.nextSibling)!==null)break;Se=ie,ie=Se.parentNode}Se=fe}s=z===-1||X===-1?null:{start:z,end:X}}else s=null}s=s||{start:0,end:0}}else s=null;for(_f={focusedElem:t,selectionRange:s},tu=!1,In=r;In!==null;)if(r=In,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,In=t;else for(;In!==null;){switch(r=In,g=r.alternate,t=r.flags,r.tag){case 0:if((t&4)!==0&&(t=r.updateQueue,t=t!==null?t.events:null,t!==null))for(s=0;s<t.length;s++)p=t[s],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&g!==null){t=void 0,s=r,p=g.memoizedProps,g=g.memoizedState,c=s.stateNode;try{var qe=ci(s.type,p);t=c.getSnapshotBeforeUpdate(qe,g),c.__reactInternalSnapshotBeforeUpdate=t}catch(it){Qt(s,s.return,it)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,s=t.nodeType,s===9)$f(t);else if(s===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":$f(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(i(163))}if(t=r.sibling,t!==null){t.return=r.return,In=t;break}In=r.return}}function t1(t,r,s){var c=s.flags;switch(s.tag){case 0:case 11:case 15:Xa(t,s),c&4&&to(5,s);break;case 1:if(Xa(t,s),c&4)if(t=s.stateNode,r===null)try{t.componentDidMount()}catch(S){Qt(s,s.return,S)}else{var p=ci(s.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(p,r,t.__reactInternalSnapshotBeforeUpdate)}catch(S){Qt(s,s.return,S)}}c&64&&Kx(s),c&512&&no(s,s.return);break;case 3:if(Xa(t,s),c&64&&(t=s.updateQueue,t!==null)){if(r=null,s.child!==null)switch(s.child.tag){case 27:case 5:r=s.child.stateNode;break;case 1:r=s.child.stateNode}try{Lp(t,r)}catch(S){Qt(s,s.return,S)}}break;case 27:r===null&&c&4&&Jx(s);case 26:case 5:Xa(t,s),r===null&&c&4&&Px(s),c&512&&no(s,s.return);break;case 12:Xa(t,s);break;case 31:Xa(t,s),c&4&&a1(t,s);break;case 13:Xa(t,s),c&4&&l1(t,s),c&64&&(t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(s=b2.bind(null,s),L2(t,s))));break;case 22:if(c=s.memoizedState!==null||qa,!c){r=r!==null&&r.memoizedState!==null||En,p=qa;var g=En;qa=c,(En=r)&&!g?Wa(t,s,(s.subtreeFlags&8772)!==0):Xa(t,s),qa=p,En=g}break;case 30:break;default:Xa(t,s)}}function n1(t){var r=t.alternate;r!==null&&(t.alternate=null,n1(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&Ni(r)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var fn=null,cr=!1;function Ya(t,r,s){for(s=s.child;s!==null;)r1(t,r,s),s=s.sibling}function r1(t,r,s){if(Le&&typeof Le.onCommitFiberUnmount=="function")try{Le.onCommitFiberUnmount(Oe,s)}catch{}switch(s.tag){case 26:En||ma(s,r),Ya(t,r,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:En||ma(s,r);var c=fn,p=cr;Sl(s.type)&&(fn=s.stateNode,cr=!1),Ya(t,r,s),fo(s.stateNode),fn=c,cr=p;break;case 5:En||ma(s,r);case 6:if(c=fn,p=cr,fn=null,Ya(t,r,s),fn=c,cr=p,fn!==null)if(cr)try{(fn.nodeType===9?fn.body:fn.nodeName==="HTML"?fn.ownerDocument.body:fn).removeChild(s.stateNode)}catch(g){Qt(s,r,g)}else try{fn.removeChild(s.stateNode)}catch(g){Qt(s,r,g)}break;case 18:fn!==null&&(cr?(t=fn,K1(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,s.stateNode),us(t)):K1(fn,s.stateNode));break;case 4:c=fn,p=cr,fn=s.stateNode.containerInfo,cr=!0,Ya(t,r,s),fn=c,cr=p;break;case 0:case 11:case 14:case 15:yl(2,s,r),En||yl(4,s,r),Ya(t,r,s);break;case 1:En||(ma(s,r),c=s.stateNode,typeof c.componentWillUnmount=="function"&&Qx(s,r,c)),Ya(t,r,s);break;case 21:Ya(t,r,s);break;case 22:En=(c=En)||s.memoizedState!==null,Ya(t,r,s),En=c;break;default:Ya(t,r,s)}}function a1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{us(t)}catch(s){Qt(r,r.return,s)}}}function l1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{us(t)}catch(s){Qt(r,r.return,s)}}function d2(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new e1),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new e1),r;default:throw Error(i(435,t.tag))}}function _c(t,r){var s=d2(t);r.forEach(function(c){if(!s.has(c)){s.add(c);var p=v2.bind(null,t,c);c.then(p,p)}})}function ur(t,r){var s=r.deletions;if(s!==null)for(var c=0;c<s.length;c++){var p=s[c],g=t,S=r,z=S;e:for(;z!==null;){switch(z.tag){case 27:if(Sl(z.type)){fn=z.stateNode,cr=!1;break e}break;case 5:fn=z.stateNode,cr=!1;break e;case 3:case 4:fn=z.stateNode.containerInfo,cr=!0;break e}z=z.return}if(fn===null)throw Error(i(160));r1(g,S,p),fn=null,cr=!1,g=p.alternate,g!==null&&(g.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)i1(r,t),r=r.sibling}var ta=null;function i1(t,r){var s=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:ur(r,t),dr(t),c&4&&(yl(3,t,t.return),to(3,t),yl(5,t,t.return));break;case 1:ur(r,t),dr(t),c&512&&(En||s===null||ma(s,s.return)),c&64&&qa&&(t=t.updateQueue,t!==null&&(c=t.callbacks,c!==null&&(s=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=s===null?c:s.concat(c))));break;case 26:var p=ta;if(ur(r,t),dr(t),c&512&&(En||s===null||ma(s,s.return)),c&4){var g=s!==null?s.memoizedState:null;if(c=t.memoizedState,s===null)if(c===null)if(t.stateNode===null){e:{c=t.type,s=t.memoizedProps,p=p.ownerDocument||p;t:switch(c){case"title":g=p.getElementsByTagName("title")[0],(!g||g[Ea]||g[Tn]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=p.createElement(c),p.head.insertBefore(g,p.querySelector("head > title"))),Wn(g,c,s),g[Tn]=t,xn(g),c=g;break e;case"link":var S=i0("link","href",p).get(c+(s.href||""));if(S){for(var z=0;z<S.length;z++)if(g=S[z],g.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&g.getAttribute("rel")===(s.rel==null?null:s.rel)&&g.getAttribute("title")===(s.title==null?null:s.title)&&g.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(z,1);break t}}g=p.createElement(c),Wn(g,c,s),p.head.appendChild(g);break;case"meta":if(S=i0("meta","content",p).get(c+(s.content||""))){for(z=0;z<S.length;z++)if(g=S[z],g.getAttribute("content")===(s.content==null?null:""+s.content)&&g.getAttribute("name")===(s.name==null?null:s.name)&&g.getAttribute("property")===(s.property==null?null:s.property)&&g.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&g.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(z,1);break t}}g=p.createElement(c),Wn(g,c,s),p.head.appendChild(g);break;default:throw Error(i(468,c))}g[Tn]=t,xn(g),c=g}t.stateNode=c}else s0(p,t.type,t.stateNode);else t.stateNode=l0(p,c,t.memoizedProps);else g!==c?(g===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):g.count--,c===null?s0(p,t.type,t.stateNode):l0(p,c,t.memoizedProps)):c===null&&t.stateNode!==null&&uf(t,t.memoizedProps,s.memoizedProps)}break;case 27:ur(r,t),dr(t),c&512&&(En||s===null||ma(s,s.return)),s!==null&&c&4&&uf(t,t.memoizedProps,s.memoizedProps);break;case 5:if(ur(r,t),dr(t),c&512&&(En||s===null||ma(s,s.return)),t.flags&32){p=t.stateNode;try{on(p,"")}catch(qe){Qt(t,t.return,qe)}}c&4&&t.stateNode!=null&&(p=t.memoizedProps,uf(t,p,s!==null?s.memoizedProps:p)),c&1024&&(hf=!0);break;case 6:if(ur(r,t),dr(t),c&4){if(t.stateNode===null)throw Error(i(162));c=t.memoizedProps,s=t.stateNode;try{s.nodeValue=c}catch(qe){Qt(t,t.return,qe)}}break;case 3:if(Pc=null,p=ta,ta=Kc(r.containerInfo),ur(r,t),ta=p,dr(t),c&4&&s!==null&&s.memoizedState.isDehydrated)try{us(r.containerInfo)}catch(qe){Qt(t,t.return,qe)}hf&&(hf=!1,s1(t));break;case 4:c=ta,ta=Kc(t.stateNode.containerInfo),ur(r,t),dr(t),ta=c;break;case 12:ur(r,t),dr(t);break;case 31:ur(r,t),dr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,_c(t,c)));break;case 13:ur(r,t),dr(t),t.child.flags&8192&&t.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Oc=ve()),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,_c(t,c)));break;case 22:p=t.memoizedState!==null;var X=s!==null&&s.memoizedState!==null,ae=qa,me=En;if(qa=ae||p,En=me||X,ur(r,t),En=me,qa=ae,dr(t),c&8192)e:for(r=t.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(s===null||X||qa||En||ui(t)),s=null,r=t;;){if(r.tag===5||r.tag===26){if(s===null){X=s=r;try{if(g=X.stateNode,p)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{z=X.stateNode;var Se=X.memoizedProps.style,ie=Se!=null&&Se.hasOwnProperty("display")?Se.display:null;z.style.display=ie==null||typeof ie=="boolean"?"":(""+ie).trim()}}catch(qe){Qt(X,X.return,qe)}}}else if(r.tag===6){if(s===null){X=r;try{X.stateNode.nodeValue=p?"":X.memoizedProps}catch(qe){Qt(X,X.return,qe)}}}else if(r.tag===18){if(s===null){X=r;try{var fe=X.stateNode;p?Q1(fe,!0):Q1(X.stateNode,!1)}catch(qe){Qt(X,X.return,qe)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===t)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break e;for(;r.sibling===null;){if(r.return===null||r.return===t)break e;s===r&&(s=null),r=r.return}s===r&&(s=null),r.sibling.return=r.return,r=r.sibling}c&4&&(c=t.updateQueue,c!==null&&(s=c.retryQueue,s!==null&&(c.retryQueue=null,_c(t,s))));break;case 19:ur(r,t),dr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,_c(t,c)));break;case 30:break;case 21:break;default:ur(r,t),dr(t)}}function dr(t){var r=t.flags;if(r&2){try{for(var s,c=t.return;c!==null;){if(Zx(c)){s=c;break}c=c.return}if(s==null)throw Error(i(160));switch(s.tag){case 27:var p=s.stateNode,g=df(t);zc(t,g,p);break;case 5:var S=s.stateNode;s.flags&32&&(on(S,""),s.flags&=-33);var z=df(t);zc(t,z,S);break;case 3:case 4:var X=s.stateNode.containerInfo,ae=df(t);ff(t,ae,X);break;default:throw Error(i(161))}}catch(me){Qt(t,t.return,me)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function s1(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;s1(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),t=t.sibling}}function Xa(t,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)t1(t,r.alternate,r),r=r.sibling}function ui(t){for(t=t.child;t!==null;){var r=t;switch(r.tag){case 0:case 11:case 14:case 15:yl(4,r,r.return),ui(r);break;case 1:ma(r,r.return);var s=r.stateNode;typeof s.componentWillUnmount=="function"&&Qx(r,r.return,s),ui(r);break;case 27:fo(r.stateNode);case 26:case 5:ma(r,r.return),ui(r);break;case 22:r.memoizedState===null&&ui(r);break;case 30:ui(r);break;default:ui(r)}t=t.sibling}}function Wa(t,r,s){for(s=s&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var c=r.alternate,p=t,g=r,S=g.flags;switch(g.tag){case 0:case 11:case 15:Wa(p,g,s),to(4,g);break;case 1:if(Wa(p,g,s),c=g,p=c.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(ae){Qt(c,c.return,ae)}if(c=g,p=c.updateQueue,p!==null){var z=c.stateNode;try{var X=p.shared.hiddenCallbacks;if(X!==null)for(p.shared.hiddenCallbacks=null,p=0;p<X.length;p++)$p(X[p],z)}catch(ae){Qt(c,c.return,ae)}}s&&S&64&&Kx(g),no(g,g.return);break;case 27:Jx(g);case 26:case 5:Wa(p,g,s),s&&c===null&&S&4&&Px(g),no(g,g.return);break;case 12:Wa(p,g,s);break;case 31:Wa(p,g,s),s&&S&4&&a1(p,g);break;case 13:Wa(p,g,s),s&&S&4&&l1(p,g);break;case 22:g.memoizedState===null&&Wa(p,g,s),no(g,g.return);break;case 30:break;default:Wa(p,g,s)}r=r.sibling}}function mf(t,r){var s=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),t=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(t=r.memoizedState.cachePool.pool),t!==s&&(t!=null&&t.refCount++,s!=null&&Us(s))}function pf(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&Us(t))}function na(t,r,s,c){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)o1(t,r,s,c),r=r.sibling}function o1(t,r,s,c){var p=r.flags;switch(r.tag){case 0:case 11:case 15:na(t,r,s,c),p&2048&&to(9,r);break;case 1:na(t,r,s,c);break;case 3:na(t,r,s,c),p&2048&&(t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&Us(t)));break;case 12:if(p&2048){na(t,r,s,c),t=r.stateNode;try{var g=r.memoizedProps,S=g.id,z=g.onPostCommit;typeof z=="function"&&z(S,r.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(X){Qt(r,r.return,X)}}else na(t,r,s,c);break;case 31:na(t,r,s,c);break;case 13:na(t,r,s,c);break;case 23:break;case 22:g=r.stateNode,S=r.alternate,r.memoizedState!==null?g._visibility&2?na(t,r,s,c):ro(t,r):g._visibility&2?na(t,r,s,c):(g._visibility|=2,Ji(t,r,s,c,(r.subtreeFlags&10256)!==0||!1)),p&2048&&mf(S,r);break;case 24:na(t,r,s,c),p&2048&&pf(r.alternate,r);break;default:na(t,r,s,c)}}function Ji(t,r,s,c,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var g=t,S=r,z=s,X=c,ae=S.flags;switch(S.tag){case 0:case 11:case 15:Ji(g,S,z,X,p),to(8,S);break;case 23:break;case 22:var me=S.stateNode;S.memoizedState!==null?me._visibility&2?Ji(g,S,z,X,p):ro(g,S):(me._visibility|=2,Ji(g,S,z,X,p)),p&&ae&2048&&mf(S.alternate,S);break;case 24:Ji(g,S,z,X,p),p&&ae&2048&&pf(S.alternate,S);break;default:Ji(g,S,z,X,p)}r=r.sibling}}function ro(t,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var s=t,c=r,p=c.flags;switch(c.tag){case 22:ro(s,c),p&2048&&mf(c.alternate,c);break;case 24:ro(s,c),p&2048&&pf(c.alternate,c);break;default:ro(s,c)}r=r.sibling}}var ao=8192;function es(t,r,s){if(t.subtreeFlags&ao)for(t=t.child;t!==null;)c1(t,r,s),t=t.sibling}function c1(t,r,s){switch(t.tag){case 26:es(t,r,s),t.flags&ao&&t.memoizedState!==null&&P2(s,ta,t.memoizedState,t.memoizedProps);break;case 5:es(t,r,s);break;case 3:case 4:var c=ta;ta=Kc(t.stateNode.containerInfo),es(t,r,s),ta=c;break;case 22:t.memoizedState===null&&(c=t.alternate,c!==null&&c.memoizedState!==null?(c=ao,ao=16777216,es(t,r,s),ao=c):es(t,r,s));break;default:es(t,r,s)}}function u1(t){var r=t.alternate;if(r!==null&&(t=r.child,t!==null)){r.child=null;do r=t.sibling,t.sibling=null,t=r;while(t!==null)}}function lo(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var s=0;s<r.length;s++){var c=r[s];In=c,f1(c,t)}u1(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)d1(t),t=t.sibling}function d1(t){switch(t.tag){case 0:case 11:case 15:lo(t),t.flags&2048&&yl(9,t,t.return);break;case 3:lo(t);break;case 12:lo(t);break;case 22:var r=t.stateNode;t.memoizedState!==null&&r._visibility&2&&(t.return===null||t.return.tag!==13)?(r._visibility&=-3,Bc(t)):lo(t);break;default:lo(t)}}function Bc(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var s=0;s<r.length;s++){var c=r[s];In=c,f1(c,t)}u1(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:yl(8,r,r.return),Bc(r);break;case 22:s=r.stateNode,s._visibility&2&&(s._visibility&=-3,Bc(r));break;default:Bc(r)}t=t.sibling}}function f1(t,r){for(;In!==null;){var s=In;switch(s.tag){case 0:case 11:case 15:yl(8,s,r);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var c=s.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:Us(s.memoizedState.cache)}if(c=s.child,c!==null)c.return=s,In=c;else e:for(s=t;In!==null;){c=In;var p=c.sibling,g=c.return;if(n1(c),c===s){In=null;break e}if(p!==null){p.return=g,In=p;break e}In=g}}}var f2={getCacheForType:function(t){var r=Yn(Sn),s=r.data.get(t);return s===void 0&&(s=t(),r.data.set(t,s)),s},cacheSignal:function(){return Yn(Sn).controller.signal}},h2=typeof WeakMap=="function"?WeakMap:Map,Xt=0,rn=null,Nt=null,Tt=0,Kt=0,jr=null,gl=!1,ts=!1,xf=!1,Ga=0,gn=0,bl=0,di=0,yf=0,Sr=0,ns=0,io=null,fr=null,gf=!1,Oc=0,h1=0,$c=1/0,Lc=null,vl=null,Fn=0,wl=null,rs=null,Va=0,bf=0,vf=null,m1=null,so=0,wf=null;function Cr(){return(Xt&2)!==0&&Tt!==0?Tt&-Tt:Y.T!==null?Ef():tr()}function p1(){if(Sr===0)if((Tt&536870912)===0||zt){var t=Dt;Dt<<=1,(Dt&3932160)===0&&(Dt=262144),Sr=t}else Sr=536870912;return t=wr.current,t!==null&&(t.flags|=32),Sr}function hr(t,r,s){(t===rn&&(Kt===2||Kt===9)||t.cancelPendingCommit!==null)&&(as(t,0),kl(t,Tt,Sr,!1)),ge(t,s),((Xt&2)===0||t!==rn)&&(t===rn&&((Xt&2)===0&&(di|=s),gn===4&&kl(t,Tt,Sr,!1)),pa(t))}function x1(t,r,s){if((Xt&6)!==0)throw Error(i(327));var c=!s&&(r&127)===0&&(r&t.expiredLanes)===0||P(t,r),p=c?x2(t,r):jf(t,r,!0),g=c;do{if(p===0){ts&&!c&&kl(t,r,0,!1);break}else{if(s=t.current.alternate,g&&!m2(s)){p=jf(t,r,!1),g=!1;continue}if(p===2){if(g=r,t.errorRecoveryDisabledLanes&g)var S=0;else S=t.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){r=S;e:{var z=t;p=io;var X=z.current.memoizedState.isDehydrated;if(X&&(as(z,S).flags|=256),S=jf(z,S,!1),S!==2){if(xf&&!X){z.errorRecoveryDisabledLanes|=g,di|=g,p=4;break e}g=fr,fr=p,g!==null&&(fr===null?fr=g:fr.push.apply(fr,g))}p=S}if(g=!1,p!==2)continue}}if(p===1){as(t,0),kl(t,r,0,!0);break}e:{switch(c=t,g=p,g){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:kl(c,r,Sr,!gl);break e;case 2:fr=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(p=Oc+300-ve(),10<p)){if(kl(c,r,Sr,!gl),pn(c,0,!0)!==0)break e;Va=r,c.timeoutHandle=G1(y1.bind(null,c,s,fr,Lc,gf,r,Sr,di,ns,gl,g,"Throttled",-0,0),p);break e}y1(c,s,fr,Lc,gf,r,Sr,di,ns,gl,g,null,-0,0)}}break}while(!0);pa(t)}function y1(t,r,s,c,p,g,S,z,X,ae,me,Se,ie,fe){if(t.timeoutHandle=-1,Se=r.subtreeFlags,Se&8192||(Se&16785408)===16785408){Se={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Kn},c1(r,g,Se);var qe=(g&62914560)===g?Oc-ve():(g&4194048)===g?h1-ve():0;if(qe=Z2(Se,qe),qe!==null){Va=g,t.cancelPendingCommit=qe(C1.bind(null,t,r,g,s,c,p,S,z,X,me,Se,null,ie,fe)),kl(t,g,S,!ae);return}}C1(t,r,g,s,c,p,S,z,X)}function m2(t){for(var r=t;;){var s=r.tag;if((s===0||s===11||s===15)&&r.flags&16384&&(s=r.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var c=0;c<s.length;c++){var p=s[c],g=p.getSnapshot;p=p.value;try{if(!br(g(),p))return!1}catch{return!1}}if(s=r.child,r.subtreeFlags&16384&&s!==null)s.return=r,r=s;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function kl(t,r,s,c){r&=~yf,r&=~di,t.suspendedLanes|=r,t.pingedLanes&=~r,c&&(t.warmLanes|=r),c=t.expirationTimes;for(var p=r;0<p;){var g=31-Ke(p),S=1<<g;c[g]=-1,p&=~S}s!==0&&Me(t,s,r)}function Ic(){return(Xt&6)===0?(oo(0),!1):!0}function kf(){if(Nt!==null){if(Kt===0)var t=Nt.return;else t=Nt,Oa=ni=null,Od(t),Vi=null,Ys=0,t=Nt;for(;t!==null;)Vx(t.alternate,t),t=t.return;Nt=null}}function as(t,r){var s=t.timeoutHandle;s!==-1&&(t.timeoutHandle=-1,z2(s)),s=t.cancelPendingCommit,s!==null&&(t.cancelPendingCommit=null,s()),Va=0,kf(),rn=t,Nt=s=_a(t.current,null),Tt=r,Kt=0,jr=null,gl=!1,ts=P(t,r),xf=!1,ns=Sr=yf=di=bl=gn=0,fr=io=null,gf=!1,(r&8)!==0&&(r|=r&32);var c=t.entangledLanes;if(c!==0)for(t=t.entanglements,c&=r;0<c;){var p=31-Ke(c),g=1<<p;r|=t[p],c&=~g}return Ga=r,sc(),s}function g1(t,r){gt=null,Y.H=Zs,r===Gi||r===pc?(r=zp(),Kt=3):r===Cd?(r=zp(),Kt=4):Kt=r===Jd?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,jr=r,Nt===null&&(gn=1,Dc(t,_r(r,t.current)))}function b1(){var t=wr.current;return t===null?!0:(Tt&4194048)===Tt?Lr===null:(Tt&62914560)===Tt||(Tt&536870912)!==0?t===Lr:!1}function v1(){var t=Y.H;return Y.H=Zs,t===null?Zs:t}function w1(){var t=Y.A;return Y.A=f2,t}function Hc(){gn=4,gl||(Tt&4194048)!==Tt&&wr.current!==null||(ts=!0),(bl&134217727)===0&&(di&134217727)===0||rn===null||kl(rn,Tt,Sr,!1)}function jf(t,r,s){var c=Xt;Xt|=2;var p=v1(),g=w1();(rn!==t||Tt!==r)&&(Lc=null,as(t,r)),r=!1;var S=gn;e:do try{if(Kt!==0&&Nt!==null){var z=Nt,X=jr;switch(Kt){case 8:kf(),S=6;break e;case 3:case 2:case 9:case 6:wr.current===null&&(r=!0);var ae=Kt;if(Kt=0,jr=null,ls(t,z,X,ae),s&&ts){S=0;break e}break;default:ae=Kt,Kt=0,jr=null,ls(t,z,X,ae)}}p2(),S=gn;break}catch(me){g1(t,me)}while(!0);return r&&t.shellSuspendCounter++,Oa=ni=null,Xt=c,Y.H=p,Y.A=g,Nt===null&&(rn=null,Tt=0,sc()),S}function p2(){for(;Nt!==null;)k1(Nt)}function x2(t,r){var s=Xt;Xt|=2;var c=v1(),p=w1();rn!==t||Tt!==r?(Lc=null,$c=ve()+500,as(t,r)):ts=P(t,r);e:do try{if(Kt!==0&&Nt!==null){r=Nt;var g=jr;t:switch(Kt){case 1:Kt=0,jr=null,ls(t,r,g,1);break;case 2:case 9:if(Mp(g)){Kt=0,jr=null,j1(r);break}r=function(){Kt!==2&&Kt!==9||rn!==t||(Kt=7),pa(t)},g.then(r,r);break e;case 3:Kt=7;break e;case 4:Kt=5;break e;case 7:Mp(g)?(Kt=0,jr=null,j1(r)):(Kt=0,jr=null,ls(t,r,g,7));break;case 5:var S=null;switch(Nt.tag){case 26:S=Nt.memoizedState;case 5:case 27:var z=Nt;if(S?o0(S):z.stateNode.complete){Kt=0,jr=null;var X=z.sibling;if(X!==null)Nt=X;else{var ae=z.return;ae!==null?(Nt=ae,Uc(ae)):Nt=null}break t}}Kt=0,jr=null,ls(t,r,g,5);break;case 6:Kt=0,jr=null,ls(t,r,g,6);break;case 8:kf(),gn=6;break e;default:throw Error(i(462))}}y2();break}catch(me){g1(t,me)}while(!0);return Oa=ni=null,Y.H=c,Y.A=p,Xt=s,Nt!==null?0:(rn=null,Tt=0,sc(),gn)}function y2(){for(;Nt!==null&&!Bn();)k1(Nt)}function k1(t){var r=Wx(t.alternate,t,Ga);t.memoizedProps=t.pendingProps,r===null?Uc(t):Nt=r}function j1(t){var r=t,s=r.alternate;switch(r.tag){case 15:case 0:r=Ix(s,r,r.pendingProps,r.type,void 0,Tt);break;case 11:r=Ix(s,r,r.pendingProps,r.type.render,r.ref,Tt);break;case 5:Od(r);default:Vx(s,r),r=Nt=wp(r,Ga),r=Wx(s,r,Ga)}t.memoizedProps=t.pendingProps,r===null?Uc(t):Nt=r}function ls(t,r,s,c){Oa=ni=null,Od(r),Vi=null,Ys=0;var p=r.return;try{if(l2(t,p,r,s,Tt)){gn=1,Dc(t,_r(s,t.current)),Nt=null;return}}catch(g){if(p!==null)throw Nt=p,g;gn=1,Dc(t,_r(s,t.current)),Nt=null;return}r.flags&32768?(zt||c===1?t=!0:ts||(Tt&536870912)!==0?t=!1:(gl=t=!0,(c===2||c===9||c===3||c===6)&&(c=wr.current,c!==null&&c.tag===13&&(c.flags|=16384))),S1(r,t)):Uc(r)}function Uc(t){var r=t;do{if((r.flags&32768)!==0){S1(r,gl);return}t=r.return;var s=o2(r.alternate,r,Ga);if(s!==null){Nt=s;return}if(r=r.sibling,r!==null){Nt=r;return}Nt=r=t}while(r!==null);gn===0&&(gn=5)}function S1(t,r){do{var s=c2(t.alternate,t);if(s!==null){s.flags&=32767,Nt=s;return}if(s=t.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!r&&(t=t.sibling,t!==null)){Nt=t;return}Nt=t=s}while(t!==null);gn=6,Nt=null}function C1(t,r,s,c,p,g,S,z,X){t.cancelPendingCommit=null;do qc();while(Fn!==0);if((Xt&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(g=r.lanes|r.childLanes,g|=ud,Z(t,s,g,S,z,X),t===rn&&(Nt=rn=null,Tt=0),rs=r,wl=t,Va=s,bf=g,vf=p,m1=c,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,w2(we,function(){return T1(),null})):(t.callbackNode=null,t.callbackPriority=0),c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=Y.T,Y.T=null,p=ue.p,ue.p=2,S=Xt,Xt|=4;try{u2(t,r,s)}finally{Xt=S,ue.p=p,Y.T=c}}Fn=1,N1(),E1(),A1()}}function N1(){if(Fn===1){Fn=0;var t=wl,r=rs,s=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||s){s=Y.T,Y.T=null;var c=ue.p;ue.p=2;var p=Xt;Xt|=4;try{i1(r,t);var g=_f,S=fp(t.containerInfo),z=g.focusedElem,X=g.selectionRange;if(S!==z&&z&&z.ownerDocument&&dp(z.ownerDocument.documentElement,z)){if(X!==null&&ld(z)){var ae=X.start,me=X.end;if(me===void 0&&(me=ae),"selectionStart"in z)z.selectionStart=ae,z.selectionEnd=Math.min(me,z.value.length);else{var Se=z.ownerDocument||document,ie=Se&&Se.defaultView||window;if(ie.getSelection){var fe=ie.getSelection(),qe=z.textContent.length,it=Math.min(X.start,qe),tn=X.end===void 0?it:Math.min(X.end,qe);!fe.extend&&it>tn&&(S=tn,tn=it,it=S);var te=up(z,it),V=up(z,tn);if(te&&V&&(fe.rangeCount!==1||fe.anchorNode!==te.node||fe.anchorOffset!==te.offset||fe.focusNode!==V.node||fe.focusOffset!==V.offset)){var re=Se.createRange();re.setStart(te.node,te.offset),fe.removeAllRanges(),it>tn?(fe.addRange(re),fe.extend(V.node,V.offset)):(re.setEnd(V.node,V.offset),fe.addRange(re))}}}}for(Se=[],fe=z;fe=fe.parentNode;)fe.nodeType===1&&Se.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof z.focus=="function"&&z.focus(),z=0;z<Se.length;z++){var be=Se[z];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}tu=!!zf,_f=zf=null}finally{Xt=p,ue.p=c,Y.T=s}}t.current=r,Fn=2}}function E1(){if(Fn===2){Fn=0;var t=wl,r=rs,s=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||s){s=Y.T,Y.T=null;var c=ue.p;ue.p=2;var p=Xt;Xt|=4;try{t1(t,r.alternate,r)}finally{Xt=p,ue.p=c,Y.T=s}}Fn=3}}function A1(){if(Fn===4||Fn===3){Fn=0,he();var t=wl,r=rs,s=Va,c=m1;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Fn=5:(Fn=0,rs=wl=null,D1(t,t.pendingLanes));var p=t.pendingLanes;if(p===0&&(vl=null),Vn(s),r=r.stateNode,Le&&typeof Le.onCommitFiberRoot=="function")try{Le.onCommitFiberRoot(Oe,r,void 0,(r.current.flags&128)===128)}catch{}if(c!==null){r=Y.T,p=ue.p,ue.p=2,Y.T=null;try{for(var g=t.onRecoverableError,S=0;S<c.length;S++){var z=c[S];g(z.value,{componentStack:z.stack})}}finally{Y.T=r,ue.p=p}}(Va&3)!==0&&qc(),pa(t),p=t.pendingLanes,(s&261930)!==0&&(p&42)!==0?t===wf?so++:(so=0,wf=t):so=0,oo(0)}}function D1(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,Us(r)))}function qc(){return N1(),E1(),A1(),T1()}function T1(){if(Fn!==5)return!1;var t=wl,r=bf;bf=0;var s=Vn(Va),c=Y.T,p=ue.p;try{ue.p=32>s?32:s,Y.T=null,s=vf,vf=null;var g=wl,S=Va;if(Fn=0,rs=wl=null,Va=0,(Xt&6)!==0)throw Error(i(331));var z=Xt;if(Xt|=4,d1(g.current),o1(g,g.current,S,s),Xt=z,oo(0,!1),Le&&typeof Le.onPostCommitFiberRoot=="function")try{Le.onPostCommitFiberRoot(Oe,g)}catch{}return!0}finally{ue.p=p,Y.T=c,D1(t,r)}}function F1(t,r,s){r=_r(s,r),r=Zd(t.stateNode,r,2),t=ml(t,r,2),t!==null&&(ge(t,2),pa(t))}function Qt(t,r,s){if(t.tag===3)F1(t,t,s);else for(;r!==null;){if(r.tag===3){F1(r,t,s);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(vl===null||!vl.has(c))){t=_r(s,t),s=Mx(2),c=ml(r,s,2),c!==null&&(Rx(s,c,r,t),ge(c,2),pa(c));break}}r=r.return}}function Sf(t,r,s){var c=t.pingCache;if(c===null){c=t.pingCache=new h2;var p=new Set;c.set(r,p)}else p=c.get(r),p===void 0&&(p=new Set,c.set(r,p));p.has(s)||(xf=!0,p.add(s),t=g2.bind(null,t,r,s),r.then(t,t))}function g2(t,r,s){var c=t.pingCache;c!==null&&c.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,rn===t&&(Tt&s)===s&&(gn===4||gn===3&&(Tt&62914560)===Tt&&300>ve()-Oc?(Xt&2)===0&&as(t,0):yf|=s,ns===Tt&&(ns=0)),pa(t)}function M1(t,r){r===0&&(r=nt()),t=Jl(t,r),t!==null&&(ge(t,r),pa(t))}function b2(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),M1(t,s)}function v2(t,r){var s=0;switch(t.tag){case 31:case 13:var c=t.stateNode,p=t.memoizedState;p!==null&&(s=p.retryLane);break;case 19:c=t.stateNode;break;case 22:c=t.stateNode._retryCache;break;default:throw Error(i(314))}c!==null&&c.delete(r),M1(t,s)}function w2(t,r){return $t(t,r)}var Yc=null,is=null,Cf=!1,Xc=!1,Nf=!1,jl=0;function pa(t){t!==is&&t.next===null&&(is===null?Yc=is=t:is=is.next=t),Xc=!0,Cf||(Cf=!0,j2())}function oo(t,r){if(!Nf&&Xc){Nf=!0;do for(var s=!1,c=Yc;c!==null;){if(t!==0){var p=c.pendingLanes;if(p===0)var g=0;else{var S=c.suspendedLanes,z=c.pingedLanes;g=(1<<31-Ke(42|t)+1)-1,g&=p&~(S&~z),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(s=!0,B1(c,g))}else g=Tt,g=pn(c,c===rn?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||P(c,g)||(s=!0,B1(c,g));c=c.next}while(s);Nf=!1}}function k2(){R1()}function R1(){Xc=Cf=!1;var t=0;jl!==0&&R2()&&(t=jl);for(var r=ve(),s=null,c=Yc;c!==null;){var p=c.next,g=z1(c,r);g===0?(c.next=null,s===null?Yc=p:s.next=p,p===null&&(is=s)):(s=c,(t!==0||(g&3)!==0)&&(Xc=!0)),c=p}Fn!==0&&Fn!==5||oo(t),jl!==0&&(jl=0)}function z1(t,r){for(var s=t.suspendedLanes,c=t.pingedLanes,p=t.expirationTimes,g=t.pendingLanes&-62914561;0<g;){var S=31-Ke(g),z=1<<S,X=p[S];X===-1?((z&s)===0||(z&c)!==0)&&(p[S]=Be(z,r)):X<=r&&(t.expiredLanes|=z),g&=~z}if(r=rn,s=Tt,s=pn(t,t===r?s:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c=t.callbackNode,s===0||t===r&&(Kt===2||Kt===9)||t.cancelPendingCommit!==null)return c!==null&&c!==null&&Ct(c),t.callbackNode=null,t.callbackPriority=0;if((s&3)===0||P(t,s)){if(r=s&-s,r===t.callbackPriority)return r;switch(c!==null&&Ct(c),Vn(s)){case 2:case 8:s=le;break;case 32:s=we;break;case 268435456:s=je;break;default:s=we}return c=_1.bind(null,t),s=$t(s,c),t.callbackPriority=r,t.callbackNode=s,r}return c!==null&&c!==null&&Ct(c),t.callbackPriority=2,t.callbackNode=null,2}function _1(t,r){if(Fn!==0&&Fn!==5)return t.callbackNode=null,t.callbackPriority=0,null;var s=t.callbackNode;if(qc()&&t.callbackNode!==s)return null;var c=Tt;return c=pn(t,t===rn?c:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c===0?null:(x1(t,c,r),z1(t,ve()),t.callbackNode!=null&&t.callbackNode===s?_1.bind(null,t):null)}function B1(t,r){if(qc())return null;x1(t,r,!0)}function j2(){_2(function(){(Xt&6)!==0?$t(W,k2):R1()})}function Ef(){if(jl===0){var t=Xi;t===0&&(t=Lt,Lt<<=1,(Lt&261888)===0&&(Lt=256)),jl=t}return jl}function O1(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Gl(""+t)}function $1(t,r){var s=r.ownerDocument.createElement("input");return s.name=r.name,s.value=r.value,t.id&&s.setAttribute("form",t.id),r.parentNode.insertBefore(s,r),t=new FormData(t),s.parentNode.removeChild(s),t}function S2(t,r,s,c,p){if(r==="submit"&&s&&s.stateNode===p){var g=O1((p[On]||null).action),S=c.submitter;S&&(r=(r=S[On]||null)?O1(r.formAction):S.getAttribute("formAction"),r!==null&&(g=r,S=null));var z=new Fi("action","action",null,c,p);t.push({event:z,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(jl!==0){var X=S?$1(p,S):new FormData(p);Wd(s,{pending:!0,data:X,method:p.method,action:g},null,X)}}else typeof g=="function"&&(z.preventDefault(),X=S?$1(p,S):new FormData(p),Wd(s,{pending:!0,data:X,method:p.method,action:g},g,X))},currentTarget:p}]})}}for(var Af=0;Af<cd.length;Af++){var Df=cd[Af],C2=Df.toLowerCase(),N2=Df[0].toUpperCase()+Df.slice(1);ea(C2,"on"+N2)}ea(pp,"onAnimationEnd"),ea(xp,"onAnimationIteration"),ea(yp,"onAnimationStart"),ea("dblclick","onDoubleClick"),ea("focusin","onFocus"),ea("focusout","onBlur"),ea(Uv,"onTransitionRun"),ea(qv,"onTransitionStart"),ea(Yv,"onTransitionCancel"),ea(gp,"onTransitionEnd"),Ta("onMouseEnter",["mouseout","mouseover"]),Ta("onMouseLeave",["mouseout","mouseover"]),Ta("onPointerEnter",["pointerout","pointerover"]),Ta("onPointerLeave",["pointerout","pointerover"]),ir("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ir("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ir("onBeforeInput",["compositionend","keypress","textInput","paste"]),ir("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ir("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ir("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var co="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(" "),E2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(co));function L1(t,r){r=(r&4)!==0;for(var s=0;s<t.length;s++){var c=t[s],p=c.event;c=c.listeners;e:{var g=void 0;if(r)for(var S=c.length-1;0<=S;S--){var z=c[S],X=z.instance,ae=z.currentTarget;if(z=z.listener,X!==g&&p.isPropagationStopped())break e;g=z,p.currentTarget=ae;try{g(p)}catch(me){ic(me)}p.currentTarget=null,g=X}else for(S=0;S<c.length;S++){if(z=c[S],X=z.instance,ae=z.currentTarget,z=z.listener,X!==g&&p.isPropagationStopped())break e;g=z,p.currentTarget=ae;try{g(p)}catch(me){ic(me)}p.currentTarget=null,g=X}}}}function Et(t,r){var s=r[nl];s===void 0&&(s=r[nl]=new Set);var c=t+"__bubble";s.has(c)||(I1(r,t,2,!1),s.add(c))}function Tf(t,r,s){var c=0;r&&(c|=4),I1(s,t,c,r)}var Wc="_reactListening"+Math.random().toString(36).slice(2);function Ff(t){if(!t[Wc]){t[Wc]=!0,Aa.forEach(function(s){s!=="selectionchange"&&(E2.has(s)||Tf(s,!1,t),Tf(s,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[Wc]||(r[Wc]=!0,Tf("selectionchange",!1,r))}}function I1(t,r,s,c){switch(p0(r)){case 2:var p=tw;break;case 8:p=nw;break;default:p=Wf}s=p.bind(null,r,s,t),p=void 0,!Ts||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),c?p!==void 0?t.addEventListener(r,s,{capture:!0,passive:p}):t.addEventListener(r,s,!0):p!==void 0?t.addEventListener(r,s,{passive:p}):t.addEventListener(r,s,!1)}function Mf(t,r,s,c,p){var g=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var S=c.tag;if(S===3||S===4){var z=c.stateNode.containerInfo;if(z===p)break;if(S===4)for(S=c.return;S!==null;){var X=S.tag;if((X===3||X===4)&&S.stateNode.containerInfo===p)return;S=S.return}for(;z!==null;){if(S=oa(z),S===null)return;if(X=S.tag,X===5||X===6||X===26||X===27){c=g=S;continue e}z=z.parentNode}}c=c.return}Ko(function(){var ae=g,me=Ai(s),Se=[];e:{var ie=bp.get(t);if(ie!==void 0){var fe=Fi,qe=t;switch(t){case"keypress":if(Rr(s)===0)break e;case"keydown":case"keyup":fe=_;break;case"focusin":qe="focus",fe=Ri;break;case"focusout":qe="blur",fe=Ri;break;case"beforeblur":case"afterblur":fe=Ri;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=Zr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=Ms;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=Ee;break;case pp:case xp:case yp:fe=nd;break;case gp:fe=Yt;break;case"scroll":case"scrollend":fe=Po;break;case"wheel":fe=et;break;case"copy":case"cut":case"paste":fe=Zt;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=se;break;case"toggle":case"beforetoggle":fe=pt}var it=(r&4)!==0,tn=!it&&(t==="scroll"||t==="scrollend"),te=it?ie!==null?ie+"Capture":null:ie;it=[];for(var V=ae,re;V!==null;){var be=V;if(re=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||re===null||te===null||(be=Vl(V,te),be!=null&&it.push(uo(V,be,re))),tn)break;V=V.return}0<it.length&&(ie=new fe(ie,qe,null,s,me),Se.push({event:ie,listeners:it}))}}if((r&7)===0){e:{if(ie=t==="mouseover"||t==="pointerover",fe=t==="mouseout"||t==="pointerout",ie&&s!==Qr&&(qe=s.relatedTarget||s.fromElement)&&(oa(qe)||qe[sa]))break e;if((fe||ie)&&(ie=me.window===me?me:(ie=me.ownerDocument)?ie.defaultView||ie.parentWindow:window,fe?(qe=s.relatedTarget||s.toElement,fe=ae,qe=qe?oa(qe):null,qe!==null&&(tn=u(qe),it=qe.tag,qe!==tn||it!==5&&it!==27&&it!==6)&&(qe=null)):(fe=null,qe=ae),fe!==qe)){if(it=Zr,be="onMouseLeave",te="onMouseEnter",V="mouse",(t==="pointerout"||t==="pointerover")&&(it=se,be="onPointerLeave",te="onPointerEnter",V="pointer"),tn=fe==null?ie:Ul(fe),re=qe==null?ie:Ul(qe),ie=new it(be,V+"leave",fe,s,me),ie.target=tn,ie.relatedTarget=re,be=null,oa(me)===ae&&(it=new it(te,V+"enter",qe,s,me),it.target=re,it.relatedTarget=tn,be=it),tn=be,fe&&qe)t:{for(it=A2,te=fe,V=qe,re=0,be=te;be;be=it(be))re++;be=0;for(var Je=V;Je;Je=it(Je))be++;for(;0<re-be;)te=it(te),re--;for(;0<be-re;)V=it(V),be--;for(;re--;){if(te===V||V!==null&&te===V.alternate){it=te;break t}te=it(te),V=it(V)}it=null}else it=null;fe!==null&&H1(Se,ie,fe,it,!1),qe!==null&&tn!==null&&H1(Se,tn,qe,it,!0)}}e:{if(ie=ae?Ul(ae):window,fe=ie.nodeName&&ie.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ie.type==="file")var It=ap;else if(np(ie))if(lp)It=Lv;else{It=Ov;var Xe=Bv}else fe=ie.nodeName,!fe||fe.toLowerCase()!=="input"||ie.type!=="checkbox"&&ie.type!=="radio"?ae&&Wl(ae.elementType)&&(It=ap):It=$v;if(It&&(It=It(t,ae))){rp(Se,It,s,me);break e}Xe&&Xe(t,ie,ae),t==="focusout"&&ae&&ie.type==="number"&&ae.memoizedProps.value!=null&&ua(ie,"number",ie.value)}switch(Xe=ae?Ul(ae):window,t){case"focusin":(np(Xe)||Xe.contentEditable==="true")&&(Oi=Xe,id=ae,Ls=null);break;case"focusout":Ls=id=Oi=null;break;case"mousedown":sd=!0;break;case"contextmenu":case"mouseup":case"dragend":sd=!1,hp(Se,s,me);break;case"selectionchange":if(Hv)break;case"keydown":case"keyup":hp(Se,s,me)}var bt;if(Ql)e:{switch(t){case"compositionstart":var Ft="onCompositionStart";break e;case"compositionend":Ft="onCompositionEnd";break e;case"compositionupdate":Ft="onCompositionUpdate";break e}Ft=void 0}else Bi?ep(t,s)&&(Ft="onCompositionEnd"):t==="keydown"&&s.keyCode===229&&(Ft="onCompositionStart");Ft&&(zs&&s.locale!=="ko"&&(Bi||Ft!=="onCompositionStart"?Ft==="onCompositionEnd"&&Bi&&(bt=Ti()):(Mr=me,Ra="value"in Mr?Mr.value:Mr.textContent,Bi=!0)),Xe=Gc(ae,Ft),0<Xe.length&&(Ft=new Rs(Ft,t,null,s,me),Se.push({event:Ft,listeners:Xe}),bt?Ft.data=bt:(bt=tp(s),bt!==null&&(Ft.data=bt)))),(bt=Jr?Mv(t,s):Rv(t,s))&&(Ft=Gc(ae,"onBeforeInput"),0<Ft.length&&(Xe=new Rs("onBeforeInput","beforeinput",null,s,me),Se.push({event:Xe,listeners:Ft}),Xe.data=bt)),S2(Se,t,ae,s,me)}L1(Se,r)})}function uo(t,r,s){return{instance:t,listener:r,currentTarget:s}}function Gc(t,r){for(var s=r+"Capture",c=[];t!==null;){var p=t,g=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||g===null||(p=Vl(t,s),p!=null&&c.unshift(uo(t,p,g)),p=Vl(t,r),p!=null&&c.push(uo(t,p,g))),t.tag===3)return c;t=t.return}return[]}function A2(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function H1(t,r,s,c,p){for(var g=r._reactName,S=[];s!==null&&s!==c;){var z=s,X=z.alternate,ae=z.stateNode;if(z=z.tag,X!==null&&X===c)break;z!==5&&z!==26&&z!==27||ae===null||(X=ae,p?(ae=Vl(s,g),ae!=null&&S.unshift(uo(s,ae,X))):p||(ae=Vl(s,g),ae!=null&&S.push(uo(s,ae,X)))),s=s.return}S.length!==0&&t.push({event:r,listeners:S})}var D2=/\r\n?/g,T2=/\u0000|\uFFFD/g;function U1(t){return(typeof t=="string"?t:""+t).replace(D2,`
|
|
49
|
+
`).replace(T2,"")}function q1(t,r){return r=U1(r),U1(t)===r}function en(t,r,s,c,p,g){switch(s){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||on(t,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&on(t,""+c);break;case"className":Yl(t,"class",c);break;case"tabIndex":Yl(t,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":Yl(t,s,c);break;case"style":Kr(t,c,g);break;case"data":if(r!=="object"){Yl(t,"data",c);break}case"src":case"href":if(c===""&&(r!=="a"||s!=="href")){t.removeAttribute(s);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=Gl(""+c),t.setAttribute(s,c);break;case"action":case"formAction":if(typeof c=="function"){t.setAttribute(s,"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 g=="function"&&(s==="formAction"?(r!=="input"&&en(t,r,"name",p.name,p,null),en(t,r,"formEncType",p.formEncType,p,null),en(t,r,"formMethod",p.formMethod,p,null),en(t,r,"formTarget",p.formTarget,p,null)):(en(t,r,"encType",p.encType,p,null),en(t,r,"method",p.method,p,null),en(t,r,"target",p.target,p,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=Gl(""+c),t.setAttribute(s,c);break;case"onClick":c!=null&&(t.onclick=Kn);break;case"onScroll":c!=null&&Et("scroll",t);break;case"onScrollEnd":c!=null&&Et("scrollend",t);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(s=c.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"multiple":t.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":t.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){t.removeAttribute("xlink:href");break}s=Gl(""+c),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,""+c):t.removeAttribute(s);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":c&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,""):t.removeAttribute(s);break;case"capture":case"download":c===!0?t.setAttribute(s,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,c):t.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?t.setAttribute(s,c):t.removeAttribute(s);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?t.removeAttribute(s):t.setAttribute(s,c);break;case"popover":Et("beforetoggle",t),Et("toggle",t),ql(t,"popover",c);break;case"xlinkActuate":Wr(t,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Wr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Wr(t,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Wr(t,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Wr(t,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Wr(t,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Wr(t,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Wr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Wr(t,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":ql(t,"is",c);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=ed.get(s)||s,ql(t,s,c))}}function Rf(t,r,s,c,p,g){switch(s){case"style":Kr(t,c,g);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(s=c.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"children":typeof c=="string"?on(t,c):(typeof c=="number"||typeof c=="bigint")&&on(t,""+c);break;case"onScroll":c!=null&&Et("scroll",t);break;case"onScrollEnd":c!=null&&Et("scrollend",t);break;case"onClick":c!=null&&(t.onclick=Kn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Da.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(p=s.endsWith("Capture"),r=s.slice(2,p?s.length-7:void 0),g=t[On]||null,g=g!=null?g[s]:null,typeof g=="function"&&t.removeEventListener(r,g,p),typeof c=="function")){typeof g!="function"&&g!==null&&(s in t?t[s]=null:t.hasAttribute(s)&&t.removeAttribute(s)),t.addEventListener(r,c,p);break e}s in t?t[s]=c:c===!0?t.setAttribute(s,""):ql(t,s,c)}}}function Wn(t,r,s){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Et("error",t),Et("load",t);var c=!1,p=!1,g;for(g in s)if(s.hasOwnProperty(g)){var S=s[g];if(S!=null)switch(g){case"src":c=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:en(t,r,g,S,s,null)}}p&&en(t,r,"srcSet",s.srcSet,s,null),c&&en(t,r,"src",s.src,s,null);return;case"input":Et("invalid",t);var z=g=S=p=null,X=null,ae=null;for(c in s)if(s.hasOwnProperty(c)){var me=s[c];if(me!=null)switch(c){case"name":p=me;break;case"type":S=me;break;case"checked":X=me;break;case"defaultChecked":ae=me;break;case"value":g=me;break;case"defaultValue":z=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(i(137,r));break;default:en(t,r,c,me,s,null)}}gr(t,g,z,X,ae,S,p,!1);return;case"select":Et("invalid",t),c=S=g=null;for(p in s)if(s.hasOwnProperty(p)&&(z=s[p],z!=null))switch(p){case"value":g=z;break;case"defaultValue":S=z;break;case"multiple":c=z;default:en(t,r,p,z,s,null)}r=g,s=S,t.multiple=!!c,r!=null?or(t,!!c,r,!1):s!=null&&or(t,!!c,s,!0);return;case"textarea":Et("invalid",t),g=p=c=null;for(S in s)if(s.hasOwnProperty(S)&&(z=s[S],z!=null))switch(S){case"value":c=z;break;case"defaultValue":p=z;break;case"children":g=z;break;case"dangerouslySetInnerHTML":if(z!=null)throw Error(i(91));break;default:en(t,r,S,z,s,null)}$n(t,c,p,g);return;case"option":for(X in s)if(s.hasOwnProperty(X)&&(c=s[X],c!=null))switch(X){case"selected":t.selected=c&&typeof c!="function"&&typeof c!="symbol";break;default:en(t,r,X,c,s,null)}return;case"dialog":Et("beforetoggle",t),Et("toggle",t),Et("cancel",t),Et("close",t);break;case"iframe":case"object":Et("load",t);break;case"video":case"audio":for(c=0;c<co.length;c++)Et(co[c],t);break;case"image":Et("error",t),Et("load",t);break;case"details":Et("toggle",t);break;case"embed":case"source":case"link":Et("error",t),Et("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ae in s)if(s.hasOwnProperty(ae)&&(c=s[ae],c!=null))switch(ae){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:en(t,r,ae,c,s,null)}return;default:if(Wl(r)){for(me in s)s.hasOwnProperty(me)&&(c=s[me],c!==void 0&&Rf(t,r,me,c,s,void 0));return}}for(z in s)s.hasOwnProperty(z)&&(c=s[z],c!=null&&en(t,r,z,c,s,null))}function F2(t,r,s,c){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,g=null,S=null,z=null,X=null,ae=null,me=null;for(fe in s){var Se=s[fe];if(s.hasOwnProperty(fe)&&Se!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":X=Se;default:c.hasOwnProperty(fe)||en(t,r,fe,null,c,Se)}}for(var ie in c){var fe=c[ie];if(Se=s[ie],c.hasOwnProperty(ie)&&(fe!=null||Se!=null))switch(ie){case"type":g=fe;break;case"name":p=fe;break;case"checked":ae=fe;break;case"defaultChecked":me=fe;break;case"value":S=fe;break;case"defaultValue":z=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(i(137,r));break;default:fe!==Se&&en(t,r,ie,fe,c,Se)}}Xl(t,S,z,X,ae,me,g,p);return;case"select":fe=S=z=ie=null;for(g in s)if(X=s[g],s.hasOwnProperty(g)&&X!=null)switch(g){case"value":break;case"multiple":fe=X;default:c.hasOwnProperty(g)||en(t,r,g,null,c,X)}for(p in c)if(g=c[p],X=s[p],c.hasOwnProperty(p)&&(g!=null||X!=null))switch(p){case"value":ie=g;break;case"defaultValue":z=g;break;case"multiple":S=g;default:g!==X&&en(t,r,p,g,c,X)}r=z,s=S,c=fe,ie!=null?or(t,!!s,ie,!1):!!c!=!!s&&(r!=null?or(t,!!s,r,!0):or(t,!!s,s?[]:"",!1));return;case"textarea":fe=ie=null;for(z in s)if(p=s[z],s.hasOwnProperty(z)&&p!=null&&!c.hasOwnProperty(z))switch(z){case"value":break;case"children":break;default:en(t,r,z,null,c,p)}for(S in c)if(p=c[S],g=s[S],c.hasOwnProperty(S)&&(p!=null||g!=null))switch(S){case"value":ie=p;break;case"defaultValue":fe=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(i(91));break;default:p!==g&&en(t,r,S,p,c,g)}Vo(t,ie,fe);return;case"option":for(var qe in s)if(ie=s[qe],s.hasOwnProperty(qe)&&ie!=null&&!c.hasOwnProperty(qe))switch(qe){case"selected":t.selected=!1;break;default:en(t,r,qe,null,c,ie)}for(X in c)if(ie=c[X],fe=s[X],c.hasOwnProperty(X)&&ie!==fe&&(ie!=null||fe!=null))switch(X){case"selected":t.selected=ie&&typeof ie!="function"&&typeof ie!="symbol";break;default:en(t,r,X,ie,c,fe)}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 it in s)ie=s[it],s.hasOwnProperty(it)&&ie!=null&&!c.hasOwnProperty(it)&&en(t,r,it,null,c,ie);for(ae in c)if(ie=c[ae],fe=s[ae],c.hasOwnProperty(ae)&&ie!==fe&&(ie!=null||fe!=null))switch(ae){case"children":case"dangerouslySetInnerHTML":if(ie!=null)throw Error(i(137,r));break;default:en(t,r,ae,ie,c,fe)}return;default:if(Wl(r)){for(var tn in s)ie=s[tn],s.hasOwnProperty(tn)&&ie!==void 0&&!c.hasOwnProperty(tn)&&Rf(t,r,tn,void 0,c,ie);for(me in c)ie=c[me],fe=s[me],!c.hasOwnProperty(me)||ie===fe||ie===void 0&&fe===void 0||Rf(t,r,me,ie,c,fe);return}}for(var te in s)ie=s[te],s.hasOwnProperty(te)&&ie!=null&&!c.hasOwnProperty(te)&&en(t,r,te,null,c,ie);for(Se in c)ie=c[Se],fe=s[Se],!c.hasOwnProperty(Se)||ie===fe||ie==null&&fe==null||en(t,r,Se,ie,c,fe)}function Y1(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function M2(){if(typeof performance.getEntriesByType=="function"){for(var t=0,r=0,s=performance.getEntriesByType("resource"),c=0;c<s.length;c++){var p=s[c],g=p.transferSize,S=p.initiatorType,z=p.duration;if(g&&z&&Y1(S)){for(S=0,z=p.responseEnd,c+=1;c<s.length;c++){var X=s[c],ae=X.startTime;if(ae>z)break;var me=X.transferSize,Se=X.initiatorType;me&&Y1(Se)&&(X=X.responseEnd,S+=me*(X<z?1:(z-ae)/(X-ae)))}if(--c,r+=8*(g+S)/(p.duration/1e3),t++,10<t)break}}if(0<t)return r/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var zf=null,_f=null;function Vc(t){return t.nodeType===9?t:t.ownerDocument}function X1(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function W1(t,r){if(t===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&r==="foreignObject"?0:t}function Bf(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Of=null;function R2(){var t=window.event;return t&&t.type==="popstate"?t===Of?!1:(Of=t,!0):(Of=null,!1)}var G1=typeof setTimeout=="function"?setTimeout:void 0,z2=typeof clearTimeout=="function"?clearTimeout:void 0,V1=typeof Promise=="function"?Promise:void 0,_2=typeof queueMicrotask=="function"?queueMicrotask:typeof V1<"u"?function(t){return V1.resolve(null).then(t).catch(B2)}:G1;function B2(t){setTimeout(function(){throw t})}function Sl(t){return t==="head"}function K1(t,r){var s=r,c=0;do{var p=s.nextSibling;if(t.removeChild(s),p&&p.nodeType===8)if(s=p.data,s==="/$"||s==="/&"){if(c===0){t.removeChild(p),us(r);return}c--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")c++;else if(s==="html")fo(t.ownerDocument.documentElement);else if(s==="head"){s=t.ownerDocument.head,fo(s);for(var g=s.firstChild;g;){var S=g.nextSibling,z=g.nodeName;g[Ea]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&g.rel.toLowerCase()==="stylesheet"||s.removeChild(g),g=S}}else s==="body"&&fo(t.ownerDocument.body);s=p}while(s);us(r)}function Q1(t,r){var s=t;t=0;do{var c=s.nextSibling;if(s.nodeType===1?r?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(r?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),c&&c.nodeType===8)if(s=c.data,s==="/$"){if(t===0)break;t--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||t++;s=c}while(s)}function $f(t){var r=t.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var s=r;switch(r=r.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":$f(s),Ni(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}t.removeChild(s)}}function O2(t,r,s,c){for(;t.nodeType===1;){var p=s;if(t.nodeName.toLowerCase()!==r.toLowerCase()){if(!c&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(c){if(!t[Ea])switch(r){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(g=t.getAttribute("rel"),g==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(g!==p.rel||t.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||t.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||t.getAttribute("title")!==(p.title==null?null:p.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(g=t.getAttribute("src"),(g!==(p.src==null?null:p.src)||t.getAttribute("type")!==(p.type==null?null:p.type)||t.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&g&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(r==="input"&&t.type==="hidden"){var g=p.name==null?null:""+p.name;if(p.type==="hidden"&&t.getAttribute("name")===g)return t}else return t;if(t=Ir(t.nextSibling),t===null)break}return null}function $2(t,r,s){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=Ir(t.nextSibling),t===null))return null;return t}function P1(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Ir(t.nextSibling),t===null))return null;return t}function Lf(t){return t.data==="$?"||t.data==="$~"}function If(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function L2(t,r){var s=t.ownerDocument;if(t.data==="$~")t._reactRetry=r;else if(t.data!=="$?"||s.readyState!=="loading")r();else{var c=function(){r(),s.removeEventListener("DOMContentLoaded",c)};s.addEventListener("DOMContentLoaded",c),t._reactRetry=c}}function Ir(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return t}var Hf=null;function Z1(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="/$"||s==="/&"){if(r===0)return Ir(t.nextSibling);r--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||r++}t=t.nextSibling}return null}function J1(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(r===0)return t;r--}else s!=="/$"&&s!=="/&"||r++}t=t.previousSibling}return null}function e0(t,r,s){switch(r=Vc(s),t){case"html":if(t=r.documentElement,!t)throw Error(i(452));return t;case"head":if(t=r.head,!t)throw Error(i(453));return t;case"body":if(t=r.body,!t)throw Error(i(454));return t;default:throw Error(i(451))}}function fo(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Ni(t)}var Hr=new Map,t0=new Set;function Kc(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Ka=ue.d;ue.d={f:I2,r:H2,D:U2,C:q2,L:Y2,m:X2,X:G2,S:W2,M:V2};function I2(){var t=Ka.f(),r=Ic();return t||r}function H2(t){var r=Un(t);r!==null&&r.tag===5&&r.type==="form"?gx(r):Ka.r(t)}var ss=typeof document>"u"?null:document;function n0(t,r,s){var c=ss;if(c&&typeof r=="string"&&r){var p=sr(r);p='link[rel="'+t+'"][href="'+p+'"]',typeof s=="string"&&(p+='[crossorigin="'+s+'"]'),t0.has(p)||(t0.add(p),t={rel:t,crossOrigin:s,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),Wn(r,"link",t),xn(r),c.head.appendChild(r)))}}function U2(t){Ka.D(t),n0("dns-prefetch",t,null)}function q2(t,r){Ka.C(t,r),n0("preconnect",t,r)}function Y2(t,r,s){Ka.L(t,r,s);var c=ss;if(c&&t&&r){var p='link[rel="preload"][as="'+sr(r)+'"]';r==="image"&&s&&s.imageSrcSet?(p+='[imagesrcset="'+sr(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(p+='[imagesizes="'+sr(s.imageSizes)+'"]')):p+='[href="'+sr(t)+'"]';var g=p;switch(r){case"style":g=os(t);break;case"script":g=cs(t)}Hr.has(g)||(t=y({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),Hr.set(g,t),c.querySelector(p)!==null||r==="style"&&c.querySelector(ho(g))||r==="script"&&c.querySelector(mo(g))||(r=c.createElement("link"),Wn(r,"link",t),xn(r),c.head.appendChild(r)))}}function X2(t,r){Ka.m(t,r);var s=ss;if(s&&t){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+sr(c)+'"][href="'+sr(t)+'"]',g=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=cs(t)}if(!Hr.has(g)&&(t=y({rel:"modulepreload",href:t},r),Hr.set(g,t),s.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(mo(g)))return}c=s.createElement("link"),Wn(c,"link",t),xn(c),s.head.appendChild(c)}}}function W2(t,r,s){Ka.S(t,r,s);var c=ss;if(c&&t){var p=yr(c).hoistableStyles,g=os(t);r=r||"default";var S=p.get(g);if(!S){var z={loading:0,preload:null};if(S=c.querySelector(ho(g)))z.loading=5;else{t=y({rel:"stylesheet",href:t,"data-precedence":r},s),(s=Hr.get(g))&&Uf(t,s);var X=S=c.createElement("link");xn(X),Wn(X,"link",t),X._p=new Promise(function(ae,me){X.onload=ae,X.onerror=me}),X.addEventListener("load",function(){z.loading|=1}),X.addEventListener("error",function(){z.loading|=2}),z.loading|=4,Qc(S,r,c)}S={type:"stylesheet",instance:S,count:1,state:z},p.set(g,S)}}}function G2(t,r){Ka.X(t,r);var s=ss;if(s&&t){var c=yr(s).hoistableScripts,p=cs(t),g=c.get(p);g||(g=s.querySelector(mo(p)),g||(t=y({src:t,async:!0},r),(r=Hr.get(p))&&qf(t,r),g=s.createElement("script"),xn(g),Wn(g,"link",t),s.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(p,g))}}function V2(t,r){Ka.M(t,r);var s=ss;if(s&&t){var c=yr(s).hoistableScripts,p=cs(t),g=c.get(p);g||(g=s.querySelector(mo(p)),g||(t=y({src:t,async:!0,type:"module"},r),(r=Hr.get(p))&&qf(t,r),g=s.createElement("script"),xn(g),Wn(g,"link",t),s.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(p,g))}}function r0(t,r,s,c){var p=(p=ye.current)?Kc(p):null;if(!p)throw Error(i(446));switch(t){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(r=os(s.href),s=yr(p).hoistableStyles,c=s.get(r),c||(c={type:"style",instance:null,count:0,state:null},s.set(r,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){t=os(s.href);var g=yr(p).hoistableStyles,S=g.get(t);if(S||(p=p.ownerDocument||p,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(t,S),(g=p.querySelector(ho(t)))&&!g._p&&(S.instance=g,S.state.loading=5),Hr.has(t)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Hr.set(t,s),g||K2(p,t,s,S.state))),r&&c===null)throw Error(i(528,""));return S}if(r&&c!==null)throw Error(i(529,""));return null;case"script":return r=s.async,s=s.src,typeof s=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=cs(s),s=yr(p).hoistableScripts,c=s.get(r),c||(c={type:"script",instance:null,count:0,state:null},s.set(r,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,t))}}function os(t){return'href="'+sr(t)+'"'}function ho(t){return'link[rel="stylesheet"]['+t+"]"}function a0(t){return y({},t,{"data-precedence":t.precedence,precedence:null})}function K2(t,r,s,c){t.querySelector('link[rel="preload"][as="style"]['+r+"]")?c.loading=1:(r=t.createElement("link"),c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2}),Wn(r,"link",s),xn(r),t.head.appendChild(r))}function cs(t){return'[src="'+sr(t)+'"]'}function mo(t){return"script[async]"+t}function l0(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var c=t.querySelector('style[data-href~="'+sr(s.href)+'"]');if(c)return r.instance=c,xn(c),c;var p=y({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return c=(t.ownerDocument||t).createElement("style"),xn(c),Wn(c,"style",p),Qc(c,s.precedence,t),r.instance=c;case"stylesheet":p=os(s.href);var g=t.querySelector(ho(p));if(g)return r.state.loading|=4,r.instance=g,xn(g),g;c=a0(s),(p=Hr.get(p))&&Uf(c,p),g=(t.ownerDocument||t).createElement("link"),xn(g);var S=g;return S._p=new Promise(function(z,X){S.onload=z,S.onerror=X}),Wn(g,"link",c),r.state.loading|=4,Qc(g,s.precedence,t),r.instance=g;case"script":return g=cs(s.src),(p=t.querySelector(mo(g)))?(r.instance=p,xn(p),p):(c=s,(p=Hr.get(g))&&(c=y({},s),qf(c,p)),t=t.ownerDocument||t,p=t.createElement("script"),xn(p),Wn(p,"link",c),t.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(c=r.instance,r.state.loading|=4,Qc(c,s.precedence,t));return r.instance}function Qc(t,r,s){for(var c=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=c.length?c[c.length-1]:null,g=p,S=0;S<c.length;S++){var z=c[S];if(z.dataset.precedence===r)g=z;else if(g!==p)break}g?g.parentNode.insertBefore(t,g.nextSibling):(r=s.nodeType===9?s.head:s,r.insertBefore(t,r.firstChild))}function Uf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function qf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var Pc=null;function i0(t,r,s){if(Pc===null){var c=new Map,p=Pc=new Map;p.set(s,c)}else p=Pc,c=p.get(s),c||(c=new Map,p.set(s,c));if(c.has(t))return c;for(c.set(t,null),s=s.getElementsByTagName(t),p=0;p<s.length;p++){var g=s[p];if(!(g[Ea]||g[Tn]||t==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(r)||"";S=t+S;var z=c.get(S);z?z.push(g):c.set(S,[g])}}return c}function s0(t,r,s){t=t.ownerDocument||t,t.head.insertBefore(s,r==="title"?t.querySelector("head > title"):null)}function Q2(t,r,s){if(s===1||r.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return t=r.disabled,typeof r.precedence=="string"&&t==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function o0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function P2(t,r,s,c){if(s.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var p=os(c.href),g=r.querySelector(ho(p));if(g){r=g._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=Zc.bind(t),r.then(t,t)),s.state.loading|=4,s.instance=g,xn(g);return}g=r.ownerDocument||r,c=a0(c),(p=Hr.get(p))&&Uf(c,p),g=g.createElement("link"),xn(g);var S=g;S._p=new Promise(function(z,X){S.onload=z,S.onerror=X}),Wn(g,"link",c),s.instance=g}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(s,r),(r=s.state.preload)&&(s.state.loading&3)===0&&(t.count++,s=Zc.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var Yf=0;function Z2(t,r){return t.stylesheets&&t.count===0&&eu(t,t.stylesheets),0<t.count||0<t.imgCount?function(s){var c=setTimeout(function(){if(t.stylesheets&&eu(t,t.stylesheets),t.unsuspend){var g=t.unsuspend;t.unsuspend=null,g()}},6e4+r);0<t.imgBytes&&Yf===0&&(Yf=62500*M2());var p=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&eu(t,t.stylesheets),t.unsuspend)){var g=t.unsuspend;t.unsuspend=null,g()}},(t.imgBytes>Yf?50:800)+r);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(c),clearTimeout(p)}}:null}function Zc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)eu(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Jc=null;function eu(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Jc=new Map,r.forEach(J2,t),Jc=null,Zc.call(t))}function J2(t,r){if(!(r.state.loading&4)){var s=Jc.get(t);if(s)var c=s.get(null);else{s=new Map,Jc.set(t,s);for(var p=t.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<p.length;g++){var S=p[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),c=S)}c&&s.set(null,c)}p=r.instance,S=p.getAttribute("data-precedence"),g=s.get(S)||c,g===c&&s.set(null,p),s.set(S,p),this.count++,c=Zc.bind(this),p.addEventListener("load",c),p.addEventListener("error",c),g?g.parentNode.insertBefore(p,g.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(p,t.firstChild)),r.state.loading|=4}}var po={$$typeof:R,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function ew(t,r,s,c,p,g,S,z,X){this.tag=1,this.containerInfo=t,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=Pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pt(0),this.hiddenUpdates=Pt(null),this.identifierPrefix=c,this.onUncaughtError=p,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=X,this.incompleteTransitions=new Map}function c0(t,r,s,c,p,g,S,z,X,ae,me,Se){return t=new ew(t,r,s,S,X,ae,me,Se,z),r=1,g===!0&&(r|=24),g=vr(3,null,null,r),t.current=g,g.stateNode=t,r=kd(),r.refCount++,t.pooledCache=r,r.refCount++,g.memoizedState={element:c,isDehydrated:s,cache:r},Nd(g),t}function u0(t){return t?(t=Ii,t):Ii}function d0(t,r,s,c,p,g){p=u0(p),c.context===null?c.context=p:c.pendingContext=p,c=hl(r),c.payload={element:s},g=g===void 0?null:g,g!==null&&(c.callback=g),s=ml(t,c,r),s!==null&&(hr(s,t,r),Ws(s,t,r))}function f0(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var s=t.retryLane;t.retryLane=s!==0&&s<r?s:r}}function Xf(t,r){f0(t,r),(t=t.alternate)&&f0(t,r)}function h0(t){if(t.tag===13||t.tag===31){var r=Jl(t,67108864);r!==null&&hr(r,t,67108864),Xf(t,67108864)}}function m0(t){if(t.tag===13||t.tag===31){var r=Cr();r=Ze(r);var s=Jl(t,r);s!==null&&hr(s,t,r),Xf(t,r)}}var tu=!0;function tw(t,r,s,c){var p=Y.T;Y.T=null;var g=ue.p;try{ue.p=2,Wf(t,r,s,c)}finally{ue.p=g,Y.T=p}}function nw(t,r,s,c){var p=Y.T;Y.T=null;var g=ue.p;try{ue.p=8,Wf(t,r,s,c)}finally{ue.p=g,Y.T=p}}function Wf(t,r,s,c){if(tu){var p=Gf(c);if(p===null)Mf(t,r,c,nu,s),x0(t,c);else if(aw(p,t,r,s,c))c.stopPropagation();else if(x0(t,c),r&4&&-1<rw.indexOf(t)){for(;p!==null;){var g=Un(p);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=sn(g.pendingLanes);if(S!==0){var z=g;for(z.pendingLanes|=2,z.entangledLanes|=2;S;){var X=1<<31-Ke(S);z.entanglements[1]|=X,S&=~X}pa(g),(Xt&6)===0&&($c=ve()+500,oo(0))}}break;case 31:case 13:z=Jl(g,2),z!==null&&hr(z,g,2),Ic(),Xf(g,2)}if(g=Gf(c),g===null&&Mf(t,r,c,nu,s),g===p)break;p=g}p!==null&&c.stopPropagation()}else Mf(t,r,c,null,s)}}function Gf(t){return t=Ai(t),Vf(t)}var nu=null;function Vf(t){if(nu=null,t=oa(t),t!==null){var r=u(t);if(r===null)t=null;else{var s=r.tag;if(s===13){if(t=d(r),t!==null)return t;t=null}else if(s===31){if(t=h(r),t!==null)return t;t=null}else if(s===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null)}}return nu=t,null}function p0(t){switch(t){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 W:return 2;case le:return 8;case we:case xe:return 32;case je:return 268435456;default:return 32}default:return 32}}var Kf=!1,Cl=null,Nl=null,El=null,xo=new Map,yo=new Map,Al=[],rw="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 x0(t,r){switch(t){case"focusin":case"focusout":Cl=null;break;case"dragenter":case"dragleave":Nl=null;break;case"mouseover":case"mouseout":El=null;break;case"pointerover":case"pointerout":xo.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":yo.delete(r.pointerId)}}function go(t,r,s,c,p,g){return t===null||t.nativeEvent!==g?(t={blockedOn:r,domEventName:s,eventSystemFlags:c,nativeEvent:g,targetContainers:[p]},r!==null&&(r=Un(r),r!==null&&h0(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),t)}function aw(t,r,s,c,p){switch(r){case"focusin":return Cl=go(Cl,t,r,s,c,p),!0;case"dragenter":return Nl=go(Nl,t,r,s,c,p),!0;case"mouseover":return El=go(El,t,r,s,c,p),!0;case"pointerover":var g=p.pointerId;return xo.set(g,go(xo.get(g)||null,t,r,s,c,p)),!0;case"gotpointercapture":return g=p.pointerId,yo.set(g,go(yo.get(g)||null,t,r,s,c,p)),!0}return!1}function y0(t){var r=oa(t.target);if(r!==null){var s=u(r);if(s!==null){if(r=s.tag,r===13){if(r=d(s),r!==null){t.blockedOn=r,ia(t.priority,function(){m0(s)});return}}else if(r===31){if(r=h(s),r!==null){t.blockedOn=r,ia(t.priority,function(){m0(s)});return}}else if(r===3&&s.stateNode.current.memoizedState.isDehydrated){t.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ru(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var s=Gf(t.nativeEvent);if(s===null){s=t.nativeEvent;var c=new s.constructor(s.type,s);Qr=c,s.target.dispatchEvent(c),Qr=null}else return r=Un(s),r!==null&&h0(r),t.blockedOn=s,!1;r.shift()}return!0}function g0(t,r,s){ru(t)&&s.delete(r)}function lw(){Kf=!1,Cl!==null&&ru(Cl)&&(Cl=null),Nl!==null&&ru(Nl)&&(Nl=null),El!==null&&ru(El)&&(El=null),xo.forEach(g0),yo.forEach(g0)}function au(t,r){t.blockedOn===r&&(t.blockedOn=null,Kf||(Kf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,lw)))}var lu=null;function b0(t){lu!==t&&(lu=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){lu===t&&(lu=null);for(var r=0;r<t.length;r+=3){var s=t[r],c=t[r+1],p=t[r+2];if(typeof c!="function"){if(Vf(c||s)===null)continue;break}var g=Un(s);g!==null&&(t.splice(r,3),r-=3,Wd(g,{pending:!0,data:p,method:s.method,action:c},c,p))}}))}function us(t){function r(X){return au(X,t)}Cl!==null&&au(Cl,t),Nl!==null&&au(Nl,t),El!==null&&au(El,t),xo.forEach(r),yo.forEach(r);for(var s=0;s<Al.length;s++){var c=Al[s];c.blockedOn===t&&(c.blockedOn=null)}for(;0<Al.length&&(s=Al[0],s.blockedOn===null);)y0(s),s.blockedOn===null&&Al.shift();if(s=(t.ownerDocument||t).$$reactFormReplay,s!=null)for(c=0;c<s.length;c+=3){var p=s[c],g=s[c+1],S=p[On]||null;if(typeof g=="function")S||b0(s);else if(S){var z=null;if(g&&g.hasAttribute("formAction")){if(p=g,S=g[On]||null)z=S.formAction;else if(Vf(p)!==null)continue}else z=S.action;typeof z=="function"?s[c+1]=z:(s.splice(c,3),c-=3),b0(s)}}}function v0(){function t(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return p=S})},focusReset:"manual",scroll:"manual"})}function r(){p!==null&&(p(),p=null),c||setTimeout(s,20)}function s(){if(!c&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,p=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(s,100),function(){c=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),p!==null&&(p(),p=null)}}}function Qf(t){this._internalRoot=t}iu.prototype.render=Qf.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var s=r.current,c=Cr();d0(s,c,t,r,null,null)},iu.prototype.unmount=Qf.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;d0(t.current,2,null,t,null,null),Ic(),r[sa]=null}};function iu(t){this._internalRoot=t}iu.prototype.unstable_scheduleHydration=function(t){if(t){var r=tr();t={blockedOn:null,target:t,priority:r};for(var s=0;s<Al.length&&r!==0&&r<Al[s].priority;s++);Al.splice(s,0,t),s===0&&y0(t)}};var w0=n.version;if(w0!=="19.2.4")throw Error(i(527,w0,"19.2.4"));ue.findDOMNode=function(t){var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(i(188)):(t=Object.keys(t).join(","),Error(i(268,t)));return t=f(r),t=t!==null?x(t):null,t=t===null?null:t.stateNode,t};var iw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var su=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!su.isDisabled&&su.supportsFiber)try{Oe=su.inject(iw),Le=su}catch{}}return vo.createRoot=function(t,r){if(!o(t))throw Error(i(299));var s=!1,c="",p=Ax,g=Dx,S=Tx;return r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=c0(t,1,!1,null,null,s,c,null,p,g,S,v0),t[sa]=r.current,Ff(t),new Qf(r)},vo.hydrateRoot=function(t,r,s){if(!o(t))throw Error(i(299));var c=!1,p="",g=Ax,S=Dx,z=Tx,X=null;return s!=null&&(s.unstable_strictMode===!0&&(c=!0),s.identifierPrefix!==void 0&&(p=s.identifierPrefix),s.onUncaughtError!==void 0&&(g=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(z=s.onRecoverableError),s.formState!==void 0&&(X=s.formState)),r=c0(t,1,!0,r,s??null,c,p,X,g,S,z,v0),r.context=u0(null),s=r.current,c=Cr(),c=Ze(c),p=hl(c),p.callback=null,ml(s,p,c),s=c,r.current.lanes=s,ge(r,s),pa(r),t[sa]=r.current,Ff(t),new iu(r)},vo.version="19.2.4",vo}var M0;function gw(){if(M0)return Jf.exports;M0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Jf.exports=yw(),Jf.exports}var bw=gw();const vw="modulepreload",ww=function(e){return"/"+e},R0={},Eg=function(n,a,i){let o=Promise.resolve();if(a&&a.length>0){let d=function(f){return Promise.all(f.map(x=>Promise.resolve(x).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),m=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=d(a.map(f=>{if(f=ww(f),f in R0)return;R0[f]=!0;const x=f.endsWith(".css"),y=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const v=document.createElement("link");if(v.rel=x?"stylesheet":vw,x||(v.as="script"),v.crossOrigin="",v.href=f,m&&v.setAttribute("nonce",m),document.head.appendChild(v),x)return new Promise((b,j)=>{v.addEventListener("load",b),v.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${f}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return o.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return n().catch(u)})};class kw extends w.Component{constructor(){super(...arguments);k0(this,"state",{hasError:!1,error:null})}static getDerivedStateFromError(a){return{hasError:!0,error:a}}render(){var a;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:((a=this.state.error)==null?void 0:a.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 wa="/api";async function Ot(e){const n=await fetch(`${wa}${e}`);if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function an(e,n){const a=await fetch(`${wa}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function ou(e,n){const a=await fetch(`${wa}${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function jw(e,n){const a=await fetch(`${wa}${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function Qa(e,n){const a={method:"DELETE"};n!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(n));const i=await fetch(`${wa}${e}`,a);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const ke={getCompany:()=>Ot("/company"),getRoles:()=>Ot("/roles"),getRole:e=>Ot(`/roles/${e}`),getProjects:()=>Ot("/projects"),getProject:e=>Ot(`/projects/${e}`),getStandups:()=>Ot("/operations/standups"),getWaves:()=>Ot("/operations/waves"),getWaveDetail:e=>Ot(`/operations/waves/${e}`),patchWave:(e,n)=>ou(`/operations/waves/${e}`,n),getDecisions:()=>Ot("/operations/decisions"),updateDecision:(e,n)=>jw(`/operations/decisions/${e}`,{content:n}),deleteDecision:e=>Qa(`/operations/decisions/${e}`),getOrgTree:()=>Ot("/engine/org"),getSkills:()=>Ot("/skills"),exportSkills:e=>Ot(`/skills/export/${e}`),getSkillRegistry:()=>Ot("/skills/registry"),installRegistrySkill:(e,n)=>an("/skills/registry/install",{skillId:e,url:n}),createRole:e=>an("/engine/roles",e),updateRole:(e,n)=>ou(`/engine/roles/${e}`,n),deleteRole:e=>Qa(`/engine/roles/${e}`),getSessions:()=>Ot("/sessions"),getSession:e=>Ot(`/sessions/${e}`),createSession:(e,n="talk")=>an("/sessions",{roleId:e,mode:n}),deleteSession:e=>Qa(`/sessions/${e}`),deleteSessions:e=>Qa("/sessions",{ids:e}),deleteEmptySessions:()=>Qa("/sessions?empty=true"),updateSession:(e,n)=>ou(`/sessions/${e}`,n),abortSession:e=>an(`/sessions/${e}/abort`,{}),replyToSession:(e,n,a)=>an(`/sessions/${e}/reply`,{message:n,...a&&{attachments:a}}),startJob:e=>an("/jobs",e),saveWave:e=>an("/waves/save",e),getStatus:()=>Ot("/status"),detectEngine:()=>an("/setup/detect-engine",{}),validatePath:e=>an("/setup/validate-path",{path:e}),scaffold:e=>an("/setup/scaffold",e),getTeams:()=>Ot("/setup/teams"),browse:e=>an("/setup/browse",{path:e}),mkdir:(e,n)=>an("/setup/mkdir",{path:e,name:n}),connectAkb:e=>an("/setup/connect-akb",{path:e}),getRequiredTools:e=>an("/setup/required-tools",{team:e}),installTools:(e,n)=>fetch(`${wa}/setup/install-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({team:e})}).then(a=>{var h;const i=(h=a.body)==null?void 0:h.getReader();if(!i)return;const o=new TextDecoder;let u="";const d=()=>i.read().then(({done:m,value:f})=>{if(m)return;u+=o.decode(f,{stream:!0});const x=u.split(`
|
|
50
|
+
`);u=x.pop()||"";let y="";for(const v of x)if(v.startsWith("event: "))y=v.slice(7);else if(v.startsWith("data: ")&&y){try{n(y,JSON.parse(v.slice(6)))}catch{}y=""}return d()});return d()}),getKnowledge:()=>Ot("/knowledge"),getKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return Ot(`/knowledge/${n}`)},createKnowledgeDoc:e=>an("/knowledge",e),updateKnowledgeDoc:(e,n)=>{const a=e.split("/").map(encodeURIComponent).join("/");return fetch(`${wa}/knowledge/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})}).then(i=>{if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()})},deleteKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return Qa(`/knowledge/${n}`)},getPreferences:()=>Ot("/preferences"),updatePreferences:e=>ou("/preferences",e),chatInChannel:e=>an("/speech/chat",e),getSaveStatus:(e="akb")=>Ot(`/save/status?repo=${e}`),save:(e,n="akb")=>an(`/save?repo=${n}`,{message:e}),getSaveHistory:(e=20,n="akb")=>Ot(`/save/history?limit=${e}&repo=${n}`),restoreSave:(e,n,a="akb")=>an(`/save/restore?repo=${a}`,{sha:e,paths:n}),initGit:()=>an("/save/init",{}),getSyncStatus:(e="akb")=>Ot(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${wa}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>Ot(`/save/github-status?repo=${e}`),githubCreateRepo:(e,n="private",a="akb")=>an(`/save/github-create-repo?repo=${a}`,{name:e,visibility:n}),addRemote:(e,n="akb")=>an(`/save/remote?repo=${n}`,{url:e}),setCodeRoot:async e=>{const n=await fetch(`${wa}/setup/code-root`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({codeRoot:e})}),a=await n.json();if(!n.ok)throw new Error(a.error||`API error: ${n.status}`);return a},getCodeRoot:()=>Ot("/setup/code-root"),getCostSummary:()=>Ot("/cost/summary"),getSyncRoles:()=>Ot("/sync/roles"),applySyncUpdate:e=>an("/sync/apply",e),getCompanyStats:()=>Ot("/sync/stats"),getCoins:()=>Ot("/coins"),earnCoins:(e,n,a)=>an("/coins/earn",{amount:e,reason:n,ref:a}),spendCoins:(e,n,a)=>an("/coins/spend",{amount:e,reason:n,ref:a}),migrateCoins:e=>an("/coins/migrate",{completedQuests:e}),getQuestProgress:()=>Ot("/quests/progress"),saveQuestProgress:e=>fetch(`${wa}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>n.json()),getActiveSessions:()=>Ot("/active-sessions"),getActiveSession:e=>Ot(`/active-sessions/${e}`),registerActiveSession:e=>an("/active-sessions/register",e),deleteActiveSession:e=>Qa(`/active-sessions/${e}`),cleanupActiveSessions:()=>an("/active-sessions/cleanup",{}),getGitStatus:()=>Ot("/git/status"),deleteWorktree:e=>Qa(`/git/worktrees/${encodeURIComponent(e)}`),deleteBranch:e=>Qa(`/git/branches/${encodeURIComponent(e)}`)},Sw=Object.freeze(Object.defineProperty({__proto__:null,api:ke},Symbol.toStringTag,{value:"Module"}));function Ag(e){const[n,a]=w.useState([]),[i,o]=w.useState("idle"),[u,d]=w.useState(""),[h,m]=w.useState([]),f=w.useRef(-1),x=w.useRef(null),y=w.useRef(0),v=w.useCallback(()=>{var C;if(!e)return;(C=x.current)==null||C.abort();const j=new AbortController;x.current=j,o("connecting");const k=f.current+1,N=`/api/sessions/${e}/stream?from=${k}`;fetch(N,{signal:j.signal}).then(async E=>{if(!E.ok||!E.body){o("error");return}o("streaming");const R=E.body.getReader(),M=new TextDecoder;let I="";for(;;){const{done:B,value:L}=await R.read();if(B)break;I+=M.decode(L,{stream:!0});const H=I.split(`
|
|
51
|
+
`);I=H.pop()??"";let Q="";for(const A of H)if(A.startsWith("event: "))Q=A.slice(7).trim();else if(A.startsWith("data: ")){try{const $=JSON.parse(A.slice(6));if(Q==="activity"){const U=$;U.seq>f.current&&(f.current=U.seq),a(ee=>ee.some(oe=>oe.seq===U.seq)?ee:[...ee,U]),U.type==="text"&&d(ee=>ee+(U.data.text??"")),U.type==="dispatch:start"&&U.data.childJobId&&m(ee=>[...ee,U.data.childJobId]),U.type==="job:done"?o("done"):U.type==="job:error"&&o("error")}else if(Q==="stream:end"){const U=$.reason;o(U==="done"?"done":U==="error"?"error":"done")}}catch{}Q=""}}i==="streaming"&&o("done")}).catch(E=>{E.name!=="AbortError"&&(o("error"),y.current<3&&(y.current++,setTimeout(v,1e3*y.current)))})},[e]),b=w.useCallback(()=>{y.current=0,v()},[v]);return w.useEffect(()=>{if(!e){a([]),o("idle"),d(""),m([]),f.current=-1;return}return a([]),d(""),m([]),f.current=-1,y.current=0,v(),()=>{var j;(j=x.current)==null||j.abort()}},[e,v]),{events:n,status:i,textOutput:u,childJobIds:h,reconnect:b}}function Cw(e,n){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const Nw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ew=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Aw={};function z0(e,n){return(Aw.jsx?Ew:Nw).test(e)}const Dw=/[ \t\n\f\r]/g;function Tw(e){return typeof e=="object"?e.type==="text"?_0(e.value):!1:_0(e)}function _0(e){return e.replace(Dw,"")===""}class Uo{constructor(n,a,i){this.normal=a,this.property=n,i&&(this.space=i)}}Uo.prototype.normal={};Uo.prototype.property={};Uo.prototype.space=void 0;function Dg(e,n){const a={},i={};for(const o of e)Object.assign(a,o.property),Object.assign(i,o.normal);return new Uo(a,i,n)}function Yh(e){return e.toLowerCase()}class xr{constructor(n,a){this.attribute=a,this.property=n}}xr.prototype.attribute="";xr.prototype.booleanish=!1;xr.prototype.boolean=!1;xr.prototype.commaOrSpaceSeparated=!1;xr.prototype.commaSeparated=!1;xr.prototype.defined=!1;xr.prototype.mustUseProperty=!1;xr.prototype.number=!1;xr.prototype.overloadedBoolean=!1;xr.prototype.property="";xr.prototype.spaceSeparated=!1;xr.prototype.space=void 0;let Fw=0;const vt=Ci(),An=Ci(),Xh=Ci(),Fe=Ci(),cn=Ci(),ps=Ci(),Nr=Ci();function Ci(){return 2**++Fw}const Wh=Object.freeze(Object.defineProperty({__proto__:null,boolean:vt,booleanish:An,commaOrSpaceSeparated:Nr,commaSeparated:ps,number:Fe,overloadedBoolean:Xh,spaceSeparated:cn},Symbol.toStringTag,{value:"Module"})),rh=Object.keys(Wh);class bm extends xr{constructor(n,a,i,o){let u=-1;if(super(n,a),B0(this,"space",o),typeof i=="number")for(;++u<rh.length;){const d=rh[u];B0(this,rh[u],(i&Wh[d])===Wh[d])}}}bm.prototype.defined=!0;function B0(e,n,a){a&&(e[n]=a)}function ws(e){const n={},a={};for(const[i,o]of Object.entries(e.properties)){const u=new bm(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(u.mustUseProperty=!0),n[i]=u,a[Yh(i)]=i,a[Yh(u.attribute)]=i}return new Uo(n,a,e.space)}const Tg=ws({properties:{ariaActiveDescendant:null,ariaAtomic:An,ariaAutoComplete:null,ariaBusy:An,ariaChecked:An,ariaColCount:Fe,ariaColIndex:Fe,ariaColSpan:Fe,ariaControls:cn,ariaCurrent:null,ariaDescribedBy:cn,ariaDetails:null,ariaDisabled:An,ariaDropEffect:cn,ariaErrorMessage:null,ariaExpanded:An,ariaFlowTo:cn,ariaGrabbed:An,ariaHasPopup:null,ariaHidden:An,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:cn,ariaLevel:Fe,ariaLive:null,ariaModal:An,ariaMultiLine:An,ariaMultiSelectable:An,ariaOrientation:null,ariaOwns:cn,ariaPlaceholder:null,ariaPosInSet:Fe,ariaPressed:An,ariaReadOnly:An,ariaRelevant:null,ariaRequired:An,ariaRoleDescription:cn,ariaRowCount:Fe,ariaRowIndex:Fe,ariaRowSpan:Fe,ariaSelected:An,ariaSetSize:Fe,ariaSort:null,ariaValueMax:Fe,ariaValueMin:Fe,ariaValueNow:Fe,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function Fg(e,n){return n in e?e[n]:n}function Mg(e,n){return Fg(e,n.toLowerCase())}const Mw=ws({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ps,acceptCharset:cn,accessKey:cn,action:null,allow:null,allowFullScreen:vt,allowPaymentRequest:vt,allowUserMedia:vt,alt:null,as:null,async:vt,autoCapitalize:null,autoComplete:cn,autoFocus:vt,autoPlay:vt,blocking:cn,capture:null,charSet:null,checked:vt,cite:null,className:cn,cols:Fe,colSpan:null,content:null,contentEditable:An,controls:vt,controlsList:cn,coords:Fe|ps,crossOrigin:null,data:null,dateTime:null,decoding:null,default:vt,defer:vt,dir:null,dirName:null,disabled:vt,download:Xh,draggable:An,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:vt,formTarget:null,headers:cn,height:Fe,hidden:Xh,high:Fe,href:null,hrefLang:null,htmlFor:cn,httpEquiv:cn,id:null,imageSizes:null,imageSrcSet:null,inert:vt,inputMode:null,integrity:null,is:null,isMap:vt,itemId:null,itemProp:cn,itemRef:cn,itemScope:vt,itemType:cn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:vt,low:Fe,manifest:null,max:null,maxLength:Fe,media:null,method:null,min:null,minLength:Fe,multiple:vt,muted:vt,name:null,nonce:null,noModule:vt,noValidate:vt,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:vt,optimum:Fe,pattern:null,ping:cn,placeholder:null,playsInline:vt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:vt,referrerPolicy:null,rel:cn,required:vt,reversed:vt,rows:Fe,rowSpan:Fe,sandbox:cn,scope:null,scoped:vt,seamless:vt,selected:vt,shadowRootClonable:vt,shadowRootDelegatesFocus:vt,shadowRootMode:null,shape:null,size:Fe,sizes:null,slot:null,span:Fe,spellCheck:An,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Fe,step:null,style:null,tabIndex:Fe,target:null,title:null,translate:null,type:null,typeMustMatch:vt,useMap:null,value:An,width:Fe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:cn,axis:null,background:null,bgColor:null,border:Fe,borderColor:null,bottomMargin:Fe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:vt,declare:vt,event:null,face:null,frame:null,frameBorder:null,hSpace:Fe,leftMargin:Fe,link:null,longDesc:null,lowSrc:null,marginHeight:Fe,marginWidth:Fe,noResize:vt,noHref:vt,noShade:vt,noWrap:vt,object:null,profile:null,prompt:null,rev:null,rightMargin:Fe,rules:null,scheme:null,scrolling:An,standby:null,summary:null,text:null,topMargin:Fe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Fe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:vt,disableRemotePlayback:vt,prefix:null,property:null,results:Fe,security:null,unselectable:null},space:"html",transform:Mg}),Rw=ws({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:Nr,accentHeight:Fe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Fe,amplitude:Fe,arabicForm:null,ascent:Fe,attributeName:null,attributeType:null,azimuth:Fe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Fe,by:null,calcMode:null,capHeight:Fe,className:cn,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:Fe,diffuseConstant:Fe,direction:null,display:null,dur:null,divisor:Fe,dominantBaseline:null,download:vt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Fe,enableBackground:null,end:null,event:null,exponent:Fe,externalResourcesRequired:null,fill:null,fillOpacity:Fe,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:ps,g2:ps,glyphName:ps,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Fe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Fe,horizOriginX:Fe,horizOriginY:Fe,id:null,ideographic:Fe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Fe,k:Fe,k1:Fe,k2:Fe,k3:Fe,k4:Fe,kernelMatrix:Nr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Fe,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:Fe,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:Fe,overlineThickness:Fe,paintOrder:null,panose1:null,path:null,pathLength:Fe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:cn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Fe,pointsAtY:Fe,pointsAtZ:Fe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Nr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Nr,rev:Nr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Nr,requiredFeatures:Nr,requiredFonts:Nr,requiredFormats:Nr,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:Fe,specularExponent:Fe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Fe,strikethroughThickness:Fe,string:null,stroke:null,strokeDashArray:Nr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Fe,strokeOpacity:Fe,strokeWidth:null,style:null,surfaceScale:Fe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Nr,tabIndex:Fe,tableValues:null,target:null,targetX:Fe,targetY:Fe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Nr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Fe,underlineThickness:Fe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Fe,values:null,vAlphabetic:Fe,vMathematical:Fe,vectorEffect:null,vHanging:Fe,vIdeographic:Fe,version:null,vertAdvY:Fe,vertOriginX:Fe,vertOriginY:Fe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Fe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Fg}),Rg=ws({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),zg=ws({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Mg}),_g=ws({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),zw={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"},_w=/[A-Z]/g,O0=/-[a-z]/g,Bw=/^data[-\w.:]+$/i;function Ow(e,n){const a=Yh(n);let i=n,o=xr;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&Bw.test(n)){if(n.charAt(4)==="-"){const u=n.slice(5).replace(O0,Lw);i="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=n.slice(4);if(!O0.test(u)){let d=u.replace(_w,$w);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}o=bm}return new o(i,n)}function $w(e){return"-"+e.toLowerCase()}function Lw(e){return e.charAt(1).toUpperCase()}const Iw=Dg([Tg,Mw,Rg,zg,_g],"html"),vm=Dg([Tg,Rw,Rg,zg,_g],"svg");function Hw(e){return e.join(" ").trim()}var ds={},ah,$0;function Uw(){if($0)return ah;$0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,h=/^\s+|\s+$/g,m=`
|
|
52
|
+
`,f="/",x="*",y="",v="comment",b="declaration";function j(N,C){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];C=C||{};var E=1,R=1;function M(oe){var ne=oe.match(n);ne&&(E+=ne.length);var Y=oe.lastIndexOf(m);R=~Y?oe.length-Y:R+oe.length}function I(){var oe={line:E,column:R};return function(ne){return ne.position=new B(oe),Q(),ne}}function B(oe){this.start=oe,this.end={line:E,column:R},this.source=C.source}B.prototype.content=N;function L(oe){var ne=new Error(C.source+":"+E+":"+R+": "+oe);if(ne.reason=oe,ne.filename=C.source,ne.line=E,ne.column=R,ne.source=N,!C.silent)throw ne}function H(oe){var ne=oe.exec(N);if(ne){var Y=ne[0];return M(Y),N=N.slice(Y.length),ne}}function Q(){H(a)}function A(oe){var ne;for(oe=oe||[];ne=$();)ne!==!1&&oe.push(ne);return oe}function $(){var oe=I();if(!(f!=N.charAt(0)||x!=N.charAt(1))){for(var ne=2;y!=N.charAt(ne)&&(x!=N.charAt(ne)||f!=N.charAt(ne+1));)++ne;if(ne+=2,y===N.charAt(ne-1))return L("End of comment missing");var Y=N.slice(2,ne-2);return R+=2,M(Y),N=N.slice(ne),R+=2,oe({type:v,comment:Y})}}function U(){var oe=I(),ne=H(i);if(ne){if($(),!H(o))return L("property missing ':'");var Y=H(u),ue=oe({type:b,property:k(ne[0].replace(e,y)),value:Y?k(Y[0].replace(e,y)):y});return H(d),ue}}function ee(){var oe=[];A(oe);for(var ne;ne=U();)ne!==!1&&(oe.push(ne),A(oe));return oe}return Q(),ee()}function k(N){return N?N.replace(h,y):y}return ah=j,ah}var L0;function qw(){if(L0)return ds;L0=1;var e=ds&&ds.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(ds,"__esModule",{value:!0}),ds.default=a;const n=e(Uw());function a(i,o){let u=null;if(!i||typeof i!="string")return u;const d=(0,n.default)(i),h=typeof o=="function";return d.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:x}=m;h?o(f,x,m):x&&(u=u||{},u[f]=x)}),u}return ds}var wo={},I0;function Yw(){if(I0)return wo;I0=1,Object.defineProperty(wo,"__esModule",{value:!0}),wo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,u=function(f){return!f||a.test(f)||e.test(f)},d=function(f,x){return x.toUpperCase()},h=function(f,x){return"".concat(x,"-")},m=function(f,x){return x===void 0&&(x={}),u(f)?f:(f=f.toLowerCase(),x.reactCompat?f=f.replace(o,h):f=f.replace(i,h),f.replace(n,d))};return wo.camelCase=m,wo}var ko,H0;function Xw(){if(H0)return ko;H0=1;var e=ko&&ko.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(qw()),a=Yw();function i(o,u){var d={};return!o||typeof o!="string"||(0,n.default)(o,function(h,m){h&&m&&(d[(0,a.camelCase)(h,u)]=m)}),d}return i.default=i,ko=i,ko}var Ww=Xw();const Gw=Ng(Ww),Bg=Og("end"),wm=Og("start");function Og(e){return n;function n(a){const i=a&&a.position&&a.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 Vw(e){const n=wm(e),a=Bg(e);if(n&&a)return{start:n,end:a}}function zo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?U0(e.position):"start"in e||"end"in e?U0(e):"line"in e||"column"in e?Gh(e):""}function Gh(e){return q0(e&&e.line)+":"+q0(e&&e.column)}function U0(e){return Gh(e&&e.start)+"-"+Gh(e&&e.end)}function q0(e){return e&&typeof e=="number"?e:1}class er extends Error{constructor(n,a,i){super(),typeof a=="string"&&(i=a,a=void 0);let o="",u={},d=!1;if(a&&("line"in a&&"column"in a?u={place:a}:"start"in a&&"end"in a?u={place:a}:"type"in a?u={ancestors:[a],place:a.position}:u={...a}),typeof n=="string"?o=n:!u.cause&&n&&(d=!0,o=n.message,u.cause=n),!u.ruleId&&!u.source&&typeof i=="string"){const m=i.indexOf(":");m===-1?u.ruleId=i:(u.source=i.slice(0,m),u.ruleId=i.slice(m+1))}if(!u.place&&u.ancestors&&u.ancestors){const m=u.ancestors[u.ancestors.length-1];m&&(u.place=m.position)}const h=u.place&&"start"in u.place?u.place.start:u.place;this.ancestors=u.ancestors||void 0,this.cause=u.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=h?h.line:void 0,this.name=zo(u.place)||"1:1",this.place=u.place||void 0,this.reason=this.message,this.ruleId=u.ruleId||void 0,this.source=u.source||void 0,this.stack=d&&u.cause&&typeof u.cause.stack=="string"?u.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}er.prototype.file="";er.prototype.name="";er.prototype.reason="";er.prototype.message="";er.prototype.stack="";er.prototype.column=void 0;er.prototype.line=void 0;er.prototype.ancestors=void 0;er.prototype.cause=void 0;er.prototype.fatal=void 0;er.prototype.place=void 0;er.prototype.ruleId=void 0;er.prototype.source=void 0;const km={}.hasOwnProperty,Kw=new Map,Qw=/[A-Z]/g,Pw=new Set(["table","tbody","thead","tfoot","tr"]),Zw=new Set(["td","th"]),$g="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Jw(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=n.filePath||void 0;let i;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=s5(a,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=i5(a,n.jsx,n.jsxs)}const o={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?vm:Iw,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},u=Lg(o,e,void 0);return u&&typeof u!="string"?u:o.create(e,o.Fragment,{children:u||void 0},void 0)}function Lg(e,n,a){if(n.type==="element")return e5(e,n,a);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return t5(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return r5(e,n,a);if(n.type==="mdxjsEsm")return n5(e,n);if(n.type==="root")return a5(e,n,a);if(n.type==="text")return l5(e,n)}function e5(e,n,a){const i=e.schema;let o=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=vm,e.schema=o),e.ancestors.push(n);const u=Hg(e,n.tagName,!1),d=o5(e,n);let h=Sm(e,n);return Pw.has(n.tagName)&&(h=h.filter(function(m){return typeof m=="string"?!Tw(m):!0})),Ig(e,d,u,n),jm(d,h),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function t5(e,n){if(n.data&&n.data.estree&&e.evaluater){const i=n.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Oo(e,n.position)}function n5(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Oo(e,n.position)}function r5(e,n,a){const i=e.schema;let o=i;n.name==="svg"&&i.space==="html"&&(o=vm,e.schema=o),e.ancestors.push(n);const u=n.name===null?e.Fragment:Hg(e,n.name,!0),d=c5(e,n),h=Sm(e,n);return Ig(e,d,u,n),jm(d,h),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function a5(e,n,a){const i={};return jm(i,Sm(e,n)),e.create(n,e.Fragment,i,a)}function l5(e,n){return n.value}function Ig(e,n,a,i){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(n.node=i)}function jm(e,n){if(n.length>0){const a=n.length>1?n:n[0];a&&(e.children=a)}}function i5(e,n,a){return i;function i(o,u,d,h){const f=Array.isArray(d.children)?a:n;return h?f(u,d,h):f(u,d)}}function s5(e,n){return a;function a(i,o,u,d){const h=Array.isArray(u.children),m=wm(i);return n(o,u,d,h,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function o5(e,n){const a={};let i,o;for(o in n.properties)if(o!=="children"&&km.call(n.properties,o)){const u=u5(e,o,n.properties[o]);if(u){const[d,h]=u;e.tableCellAlignToStyle&&d==="align"&&typeof h=="string"&&Zw.has(n.tagName)?i=h:a[d]=h}}if(i){const u=a.style||(a.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return a}function c5(e,n){const a={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const u=i.data.estree.body[0];u.type;const d=u.expression;d.type;const h=d.properties[0];h.type,Object.assign(a,e.evaluater.evaluateExpression(h.argument))}else Oo(e,n.position);else{const o=i.name;let u;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const h=i.value.data.estree.body[0];h.type,u=e.evaluater.evaluateExpression(h.expression)}else Oo(e,n.position);else u=i.value===null?!0:i.value;a[o]=u}return a}function Sm(e,n){const a=[];let i=-1;const o=e.passKeys?new Map:Kw;for(;++i<n.children.length;){const u=n.children[i];let d;if(e.passKeys){const m=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(m){const f=o.get(m)||0;d=m+"-"+f,o.set(m,f+1)}}const h=Lg(e,u,d);h!==void 0&&a.push(h)}return a}function u5(e,n,a){const i=Ow(e.schema,n);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=i.commaSeparated?Cw(a):Hw(a)),i.property==="style"){let o=typeof a=="object"?a:d5(e,String(a));return e.stylePropertyNameCase==="css"&&(o=f5(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?zw[i.property]||i.property:i.attribute,a]}}function d5(e,n){try{return Gw(n,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const i=a,o=new er("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=$g+"#cannot-parse-style-attribute",o}}function Hg(e,n,a){let i;if(!a)i={type:"Literal",value:n};else if(n.includes(".")){const o=n.split(".");let u=-1,d;for(;++u<o.length;){const h=z0(o[u])?{type:"Identifier",name:o[u]}:{type:"Literal",value:o[u]};d=d?{type:"MemberExpression",object:d,property:h,computed:!!(u&&h.type==="Literal"),optional:!1}:h}i=d}else i=z0(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const o=i.value;return km.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);Oo(e)}function Oo(e,n){const a=new er("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=$g+"#cannot-handle-mdx-estrees-without-createevaluater",a}function f5(e){const n={};let a;for(a in e)km.call(e,a)&&(n[h5(a)]=e[a]);return n}function h5(e){let n=e.replace(Qw,m5);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function m5(e){return"-"+e.toLowerCase()}const lh={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"]},p5={};function Cm(e,n){const a=p5,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Ug(e,i,o)}function Ug(e,n,a){if(x5(e)){if("value"in e)return e.type==="html"&&!a?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Y0(e.children,n,a)}return Array.isArray(e)?Y0(e,n,a):""}function Y0(e,n,a){const i=[];let o=-1;for(;++o<e.length;)i[o]=Ug(e[o],n,a);return i.join("")}function x5(e){return!!(e&&typeof e=="object")}const X0=document.createElement("i");function Nm(e){const n="&"+e+";";X0.innerHTML=n;const a=X0.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===n?!1:a}function Tr(e,n,a,i){const o=e.length;let u=0,d;if(n<0?n=-n>o?0:o+n:n=n>o?o:n,a=a>0?a:0,i.length<1e4)d=Array.from(i),d.unshift(n,a),e.splice(...d);else for(a&&e.splice(n,a);u<i.length;)d=i.slice(u,u+1e4),d.unshift(n,0),e.splice(...d),u+=1e4,n+=1e4}function qr(e,n){return e.length>0?(Tr(e,e.length,0,n),e):n}const W0={}.hasOwnProperty;function qg(e){const n={};let a=-1;for(;++a<e.length;)y5(n,e[a]);return n}function y5(e,n){let a;for(a in n){const o=(W0.call(e,a)?e[a]:void 0)||(e[a]={}),u=n[a];let d;if(u)for(d in u){W0.call(o,d)||(o[d]=[]);const h=u[d];g5(o[d],Array.isArray(h)?h:h?[h]:[])}}}function g5(e,n){let a=-1;const i=[];for(;++a<n.length;)(n[a].add==="after"?e:i).push(n[a]);Tr(e,0,0,i)}function Yg(e,n){const a=Number.parseInt(e,n);return a<9||a===11||a>13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function la(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const rr=Ll(/[A-Za-z]/),Jn=Ll(/[\dA-Za-z]/),b5=Ll(/[#-'*+\--9=?A-Z^-~]/);function Mu(e){return e!==null&&(e<32||e===127)}const Vh=Ll(/\d/),v5=Ll(/[\dA-Fa-f]/),w5=Ll(/[!-/:-@[-`{-~]/);function at(e){return e!==null&&e<-2}function ln(e){return e!==null&&(e<0||e===32)}function At(e){return e===-2||e===-1||e===32}const Xu=Ll(new RegExp("\\p{P}|\\p{S}","u")),ki=Ll(/\s/);function Ll(e){return n;function n(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function ks(e){const n=[];let a=-1,i=0,o=0;for(;++a<e.length;){const u=e.charCodeAt(a);let d="";if(u===37&&Jn(e.charCodeAt(a+1))&&Jn(e.charCodeAt(a+2)))o=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(d=String.fromCharCode(u));else if(u>55295&&u<57344){const h=e.charCodeAt(a+1);u<56320&&h>56319&&h<57344?(d=String.fromCharCode(u,h),o=1):d="�"}else d=String.fromCharCode(u);d&&(n.push(e.slice(i,a),encodeURIComponent(d)),i=a+o+1,d=""),o&&(a+=o,o=0)}return n.join("")+e.slice(i)}function Bt(e,n,a,i){const o=i?i-1:Number.POSITIVE_INFINITY;let u=0;return d;function d(m){return At(m)?(e.enter(a),h(m)):n(m)}function h(m){return At(m)&&u++<o?(e.consume(m),h):(e.exit(a),n(m))}}const k5={tokenize:j5};function j5(e){const n=e.attempt(this.parser.constructs.contentInitial,i,o);let a;return n;function i(h){if(h===null){e.consume(h);return}return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Bt(e,n,"linePrefix")}function o(h){return e.enter("paragraph"),u(h)}function u(h){const m=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=m),a=m,d(h)}function d(h){if(h===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(h);return}return at(h)?(e.consume(h),e.exit("chunkText"),u):(e.consume(h),d)}}const S5={tokenize:C5},G0={tokenize:N5};function C5(e){const n=this,a=[];let i=0,o,u,d;return h;function h(R){if(i<a.length){const M=a[i];return n.containerState=M[1],e.attempt(M[0].continuation,m,f)(R)}return f(R)}function m(R){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&E();const M=n.events.length;let I=M,B;for(;I--;)if(n.events[I][0]==="exit"&&n.events[I][1].type==="chunkFlow"){B=n.events[I][1].end;break}C(i);let L=M;for(;L<n.events.length;)n.events[L][1].end={...B},L++;return Tr(n.events,I+1,0,n.events.slice(M)),n.events.length=L,f(R)}return h(R)}function f(R){if(i===a.length){if(!o)return v(R);if(o.currentConstruct&&o.currentConstruct.concrete)return j(R);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(G0,x,y)(R)}function x(R){return o&&E(),C(i),v(R)}function y(R){return n.parser.lazy[n.now().line]=i!==a.length,d=n.now().offset,j(R)}function v(R){return n.containerState={},e.attempt(G0,b,j)(R)}function b(R){return i++,a.push([n.currentConstruct,n.containerState]),v(R)}function j(R){if(R===null){o&&E(),C(0),e.consume(R);return}return o=o||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:u}),k(R)}function k(R){if(R===null){N(e.exit("chunkFlow"),!0),C(0),e.consume(R);return}return at(R)?(e.consume(R),N(e.exit("chunkFlow")),i=0,n.interrupt=void 0,h):(e.consume(R),k)}function N(R,M){const I=n.sliceStream(R);if(M&&I.push(null),R.previous=u,u&&(u.next=R),u=R,o.defineSkip(R.start),o.write(I),n.parser.lazy[R.start.line]){let B=o.events.length;for(;B--;)if(o.events[B][1].start.offset<d&&(!o.events[B][1].end||o.events[B][1].end.offset>d))return;const L=n.events.length;let H=L,Q,A;for(;H--;)if(n.events[H][0]==="exit"&&n.events[H][1].type==="chunkFlow"){if(Q){A=n.events[H][1].end;break}Q=!0}for(C(i),B=L;B<n.events.length;)n.events[B][1].end={...A},B++;Tr(n.events,H+1,0,n.events.slice(L)),n.events.length=B}}function C(R){let M=a.length;for(;M-- >R;){const I=a[M];n.containerState=I[1],I[0].exit.call(n,e)}a.length=R}function E(){o.write([null]),u=void 0,o=void 0,n.containerState._closeFlow=void 0}}function N5(e,n,a){return Bt(e,e.attempt(this.parser.constructs.document,n,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ys(e){if(e===null||ln(e)||ki(e))return 1;if(Xu(e))return 2}function Wu(e,n,a){const i=[];let o=-1;for(;++o<e.length;){const u=e[o].resolveAll;u&&!i.includes(u)&&(n=u(n,a),i.push(u))}return n}const Kh={name:"attention",resolveAll:E5,tokenize:A5};function E5(e,n){let a=-1,i,o,u,d,h,m,f,x;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(i=a;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[i][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;m=e[i][1].end.offset-e[i][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const y={...e[i][1].end},v={...e[a][1].start};V0(y,-m),V0(v,m),d={type:m>1?"strongSequence":"emphasisSequence",start:y,end:{...e[i][1].end}},h={type:m>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:v},u={type:m>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[a][1].start}},o={type:m>1?"strong":"emphasis",start:{...d.start},end:{...h.end}},e[i][1].end={...d.start},e[a][1].start={...h.end},f=[],e[i][1].end.offset-e[i][1].start.offset&&(f=qr(f,[["enter",e[i][1],n],["exit",e[i][1],n]])),f=qr(f,[["enter",o,n],["enter",d,n],["exit",d,n],["enter",u,n]]),f=qr(f,Wu(n.parser.constructs.insideSpan.null,e.slice(i+1,a),n)),f=qr(f,[["exit",u,n],["enter",h,n],["exit",h,n],["exit",o,n]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,f=qr(f,[["enter",e[a][1],n],["exit",e[a][1],n]])):x=0,Tr(e,i-1,a-i+3,f),a=i+f.length-x-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function A5(e,n){const a=this.parser.constructs.attentionMarkers.null,i=this.previous,o=ys(i);let u;return d;function d(m){return u=m,e.enter("attentionSequence"),h(m)}function h(m){if(m===u)return e.consume(m),h;const f=e.exit("attentionSequence"),x=ys(m),y=!x||x===2&&o||a.includes(m),v=!o||o===2&&x||a.includes(i);return f._open=!!(u===42?y:y&&(o||!v)),f._close=!!(u===42?v:v&&(x||!y)),n(m)}}function V0(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const D5={name:"autolink",tokenize:T5};function T5(e,n,a){let i=0;return o;function o(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),u}function u(b){return rr(b)?(e.consume(b),d):b===64?a(b):f(b)}function d(b){return b===43||b===45||b===46||Jn(b)?(i=1,h(b)):f(b)}function h(b){return b===58?(e.consume(b),i=0,m):(b===43||b===45||b===46||Jn(b))&&i++<32?(e.consume(b),h):(i=0,f(b))}function m(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):b===null||b===32||b===60||Mu(b)?a(b):(e.consume(b),m)}function f(b){return b===64?(e.consume(b),x):b5(b)?(e.consume(b),f):a(b)}function x(b){return Jn(b)?y(b):a(b)}function y(b){return b===46?(e.consume(b),i=0,x):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):v(b)}function v(b){if((b===45||Jn(b))&&i++<63){const j=b===45?v:y;return e.consume(b),j}return a(b)}}const qo={partial:!0,tokenize:F5};function F5(e,n,a){return i;function i(u){return At(u)?Bt(e,o,"linePrefix")(u):o(u)}function o(u){return u===null||at(u)?n(u):a(u)}}const Xg={continuation:{tokenize:R5},exit:z5,name:"blockQuote",tokenize:M5};function M5(e,n,a){const i=this;return o;function o(d){if(d===62){const h=i.containerState;return h.open||(e.enter("blockQuote",{_container:!0}),h.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),u}return a(d)}function u(d){return At(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(d))}}function R5(e,n,a){const i=this;return o;function o(d){return At(d)?Bt(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):u(d)}function u(d){return e.attempt(Xg,n,a)(d)}}function z5(e){e.exit("blockQuote")}const Wg={name:"characterEscape",tokenize:_5};function _5(e,n,a){return i;function i(u){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(u),e.exit("escapeMarker"),o}function o(u){return w5(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):a(u)}}const Gg={name:"characterReference",tokenize:B5};function B5(e,n,a){const i=this;let o=0,u,d;return h;function h(y){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(y),e.exit("characterReferenceMarker"),m}function m(y){return y===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(y),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),u=31,d=Jn,x(y))}function f(y){return y===88||y===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(y),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,d=v5,x):(e.enter("characterReferenceValue"),u=7,d=Vh,x(y))}function x(y){if(y===59&&o){const v=e.exit("characterReferenceValue");return d===Jn&&!Nm(i.sliceSerialize(v))?a(y):(e.enter("characterReferenceMarker"),e.consume(y),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(y)&&o++<u?(e.consume(y),x):a(y)}}const K0={partial:!0,tokenize:$5},Q0={concrete:!0,name:"codeFenced",tokenize:O5};function O5(e,n,a){const i=this,o={partial:!0,tokenize:I};let u=0,d=0,h;return m;function m(B){return f(B)}function f(B){const L=i.events[i.events.length-1];return u=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,h=B,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(B)}function x(B){return B===h?(d++,e.consume(B),x):d<3?a(B):(e.exit("codeFencedFenceSequence"),At(B)?Bt(e,y,"whitespace")(B):y(B))}function y(B){return B===null||at(B)?(e.exit("codeFencedFence"),i.interrupt?n(B):e.check(K0,k,M)(B)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(B))}function v(B){return B===null||at(B)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),y(B)):At(B)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Bt(e,b,"whitespace")(B)):B===96&&B===h?a(B):(e.consume(B),v)}function b(B){return B===null||at(B)?y(B):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(B))}function j(B){return B===null||at(B)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),y(B)):B===96&&B===h?a(B):(e.consume(B),j)}function k(B){return e.attempt(o,M,N)(B)}function N(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),C}function C(B){return u>0&&At(B)?Bt(e,E,"linePrefix",u+1)(B):E(B)}function E(B){return B===null||at(B)?e.check(K0,k,M)(B):(e.enter("codeFlowValue"),R(B))}function R(B){return B===null||at(B)?(e.exit("codeFlowValue"),E(B)):(e.consume(B),R)}function M(B){return e.exit("codeFenced"),n(B)}function I(B,L,H){let Q=0;return A;function A(ne){return B.enter("lineEnding"),B.consume(ne),B.exit("lineEnding"),$}function $(ne){return B.enter("codeFencedFence"),At(ne)?Bt(B,U,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ne):U(ne)}function U(ne){return ne===h?(B.enter("codeFencedFenceSequence"),ee(ne)):H(ne)}function ee(ne){return ne===h?(Q++,B.consume(ne),ee):Q>=d?(B.exit("codeFencedFenceSequence"),At(ne)?Bt(B,oe,"whitespace")(ne):oe(ne)):H(ne)}function oe(ne){return ne===null||at(ne)?(B.exit("codeFencedFence"),L(ne)):H(ne)}}}function $5(e,n,a){const i=this;return o;function o(d){return d===null?a(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u)}function u(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}const ih={name:"codeIndented",tokenize:I5},L5={partial:!0,tokenize:H5};function I5(e,n,a){const i=this;return o;function o(f){return e.enter("codeIndented"),Bt(e,u,"linePrefix",5)(f)}function u(f){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(f):a(f)}function d(f){return f===null?m(f):at(f)?e.attempt(L5,d,m)(f):(e.enter("codeFlowValue"),h(f))}function h(f){return f===null||at(f)?(e.exit("codeFlowValue"),d(f)):(e.consume(f),h)}function m(f){return e.exit("codeIndented"),n(f)}}function H5(e,n,a){const i=this;return o;function o(d){return i.parser.lazy[i.now().line]?a(d):at(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):Bt(e,u,"linePrefix",5)(d)}function u(d){const h=i.events[i.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(d):at(d)?o(d):a(d)}}const U5={name:"codeText",previous:Y5,resolve:q5,tokenize:X5};function q5(e){let n=e.length-4,a=3,i,o;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=a;++i<n;)if(e[i][1].type==="codeTextData"){e[a][1].type="codeTextPadding",e[n][1].type="codeTextPadding",a+=2,n-=2;break}}for(i=a-1,n++;++i<=n;)o===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(o=i):(i===n||e[i][1].type==="lineEnding")&&(e[o][1].type="codeTextData",i!==o+2&&(e[o][1].end=e[i-1][1].end,e.splice(o+2,i-o-2),n-=i-o-2,i=o+2),o=void 0);return e}function Y5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function X5(e,n,a){let i=0,o,u;return d;function d(y){return e.enter("codeText"),e.enter("codeTextSequence"),h(y)}function h(y){return y===96?(e.consume(y),i++,h):(e.exit("codeTextSequence"),m(y))}function m(y){return y===null?a(y):y===32?(e.enter("space"),e.consume(y),e.exit("space"),m):y===96?(u=e.enter("codeTextSequence"),o=0,x(y)):at(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(y))}function f(y){return y===null||y===32||y===96||at(y)?(e.exit("codeTextData"),m(y)):(e.consume(y),f)}function x(y){return y===96?(e.consume(y),o++,x):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(y)):(u.type="codeTextData",f(y))}}class W5{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,a){const i=a??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(n,i):n>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(n,a,i){const o=a||0;this.setCursor(Math.trunc(n));const u=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return i&&jo(this.left,i),u.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),jo(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),jo(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){const a=this.left.splice(n,Number.POSITIVE_INFINITY);jo(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);jo(this.left,a.reverse())}}}function jo(e,n){let a=0;if(n.length<1e4)e.push(...n);else for(;a<n.length;)e.push(...n.slice(a,a+1e4)),a+=1e4}function Vg(e){const n={};let a=-1,i,o,u,d,h,m,f;const x=new W5(e);for(;++a<x.length;){for(;a in n;)a=n[a];if(i=x.get(a),a&&i[1].type==="chunkFlow"&&x.get(a-1)[1].type==="listItemPrefix"&&(m=i[1]._tokenizer.events,u=0,u<m.length&&m[u][1].type==="lineEndingBlank"&&(u+=2),u<m.length&&m[u][1].type==="content"))for(;++u<m.length&&m[u][1].type!=="content";)m[u][1].type==="chunkText"&&(m[u][1]._isInFirstContentOfListItem=!0,u++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,G5(x,a)),a=n[a],f=!0);else if(i[1]._container){for(u=a,o=void 0;u--;)if(d=x.get(u),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),d[1].type="lineEnding",o=u);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;o&&(i[1].end={...x.get(o)[1].start},h=x.slice(o,a),h.unshift(i),x.splice(o,a-o+1,h))}}return Tr(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function G5(e,n){const a=e.get(n)[1],i=e.get(n)[2];let o=n-1;const u=[];let d=a._tokenizer;d||(d=i.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const h=d.events,m=[],f={};let x,y,v=-1,b=a,j=0,k=0;const N=[k];for(;b;){for(;e.get(++o)[1]!==b;);u.push(o),b._tokenizer||(x=i.sliceStream(b),b.next||x.push(null),y&&d.defineSkip(b.start),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),y=b,b=b.next}for(b=a;++v<h.length;)h[v][0]==="exit"&&h[v-1][0]==="enter"&&h[v][1].type===h[v-1][1].type&&h[v][1].start.line!==h[v][1].end.line&&(k=v+1,N.push(k),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(d.events=[],b?(b._tokenizer=void 0,b.previous=void 0):N.pop(),v=N.length;v--;){const C=h.slice(N[v],N[v+1]),E=u.pop();m.push([E,E+C.length-1]),e.splice(E,2,C)}for(m.reverse(),v=-1;++v<m.length;)f[j+m[v][0]]=j+m[v][1],j+=m[v][1]-m[v][0]-1;return f}const V5={resolve:Q5,tokenize:P5},K5={partial:!0,tokenize:Z5};function Q5(e){return Vg(e),e}function P5(e,n){let a;return i;function i(h){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),o(h)}function o(h){return h===null?u(h):at(h)?e.check(K5,d,u)(h):(e.consume(h),o)}function u(h){return e.exit("chunkContent"),e.exit("content"),n(h)}function d(h){return e.consume(h),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,o}}function Z5(e,n,a){const i=this;return o;function o(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Bt(e,u,"linePrefix")}function u(d){if(d===null||at(d))return a(d);const h=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(d):e.interrupt(i.parser.constructs.flow,a,n)(d)}}function Kg(e,n,a,i,o,u,d,h,m){const f=m||Number.POSITIVE_INFINITY;let x=0;return y;function y(C){return C===60?(e.enter(i),e.enter(o),e.enter(u),e.consume(C),e.exit(u),v):C===null||C===32||C===41||Mu(C)?a(C):(e.enter(i),e.enter(d),e.enter(h),e.enter("chunkString",{contentType:"string"}),k(C))}function v(C){return C===62?(e.enter(u),e.consume(C),e.exit(u),e.exit(o),e.exit(i),n):(e.enter(h),e.enter("chunkString",{contentType:"string"}),b(C))}function b(C){return C===62?(e.exit("chunkString"),e.exit(h),v(C)):C===null||C===60||at(C)?a(C):(e.consume(C),C===92?j:b)}function j(C){return C===60||C===62||C===92?(e.consume(C),b):b(C)}function k(C){return!x&&(C===null||C===41||ln(C))?(e.exit("chunkString"),e.exit(h),e.exit(d),e.exit(i),n(C)):x<f&&C===40?(e.consume(C),x++,k):C===41?(e.consume(C),x--,k):C===null||C===32||C===40||Mu(C)?a(C):(e.consume(C),C===92?N:k)}function N(C){return C===40||C===41||C===92?(e.consume(C),k):k(C)}}function Qg(e,n,a,i,o,u){const d=this;let h=0,m;return f;function f(b){return e.enter(i),e.enter(o),e.consume(b),e.exit(o),e.enter(u),x}function x(b){return h>999||b===null||b===91||b===93&&!m||b===94&&!h&&"_hiddenFootnoteSupport"in d.parser.constructs?a(b):b===93?(e.exit(u),e.enter(o),e.consume(b),e.exit(o),e.exit(i),n):at(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),y(b))}function y(b){return b===null||b===91||b===93||at(b)||h++>999?(e.exit("chunkString"),x(b)):(e.consume(b),m||(m=!At(b)),b===92?v:y)}function v(b){return b===91||b===92||b===93?(e.consume(b),h++,y):y(b)}}function Pg(e,n,a,i,o,u){let d;return h;function h(v){return v===34||v===39||v===40?(e.enter(i),e.enter(o),e.consume(v),e.exit(o),d=v===40?41:v,m):a(v)}function m(v){return v===d?(e.enter(o),e.consume(v),e.exit(o),e.exit(i),n):(e.enter(u),f(v))}function f(v){return v===d?(e.exit(u),m(d)):v===null?a(v):at(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),Bt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(v))}function x(v){return v===d||v===null||at(v)?(e.exit("chunkString"),f(v)):(e.consume(v),v===92?y:x)}function y(v){return v===d||v===92?(e.consume(v),x):x(v)}}function _o(e,n){let a;return i;function i(o){return at(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,i):At(o)?Bt(e,i,a?"linePrefix":"lineSuffix")(o):n(o)}}const J5={name:"definition",tokenize:tk},ek={partial:!0,tokenize:nk};function tk(e,n,a){const i=this;let o;return u;function u(b){return e.enter("definition"),d(b)}function d(b){return Qg.call(i,e,h,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function h(b){return o=la(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),m):a(b)}function m(b){return ln(b)?_o(e,f)(b):f(b)}function f(b){return Kg(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(ek,y,y)(b)}function y(b){return At(b)?Bt(e,v,"whitespace")(b):v(b)}function v(b){return b===null||at(b)?(e.exit("definition"),i.parser.defined.push(o),n(b)):a(b)}}function nk(e,n,a){return i;function i(h){return ln(h)?_o(e,o)(h):a(h)}function o(h){return Pg(e,u,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function u(h){return At(h)?Bt(e,d,"whitespace")(h):d(h)}function d(h){return h===null||at(h)?n(h):a(h)}}const rk={name:"hardBreakEscape",tokenize:ak};function ak(e,n,a){return i;function i(u){return e.enter("hardBreakEscape"),e.consume(u),o}function o(u){return at(u)?(e.exit("hardBreakEscape"),n(u)):a(u)}}const lk={name:"headingAtx",resolve:ik,tokenize:sk};function ik(e,n){let a=e.length-2,i=3,o,u;return e[i][1].type==="whitespace"&&(i+=2),a-2>i&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(i===a-1||a-4>i&&e[a-2][1].type==="whitespace")&&(a-=i+1===a?2:4),a>i&&(o={type:"atxHeadingText",start:e[i][1].start,end:e[a][1].end},u={type:"chunkText",start:e[i][1].start,end:e[a][1].end,contentType:"text"},Tr(e,i,a-i+1,[["enter",o,n],["enter",u,n],["exit",u,n],["exit",o,n]])),e}function sk(e,n,a){let i=0;return o;function o(x){return e.enter("atxHeading"),u(x)}function u(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&i++<6?(e.consume(x),d):x===null||ln(x)?(e.exit("atxHeadingSequence"),h(x)):a(x)}function h(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||at(x)?(e.exit("atxHeading"),n(x)):At(x)?Bt(e,h,"whitespace")(x):(e.enter("atxHeadingText"),f(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),h(x))}function f(x){return x===null||x===35||ln(x)?(e.exit("atxHeadingText"),h(x)):(e.consume(x),f)}}const ok=["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"],P0=["pre","script","style","textarea"],ck={concrete:!0,name:"htmlFlow",resolveTo:fk,tokenize:hk},uk={partial:!0,tokenize:pk},dk={partial:!0,tokenize:mk};function fk(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function hk(e,n,a){const i=this;let o,u,d,h,m;return f;function f(T){return x(T)}function x(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),y}function y(T){return T===33?(e.consume(T),v):T===47?(e.consume(T),u=!0,k):T===63?(e.consume(T),o=3,i.interrupt?n:D):rr(T)?(e.consume(T),d=String.fromCharCode(T),N):a(T)}function v(T){return T===45?(e.consume(T),o=2,b):T===91?(e.consume(T),o=5,h=0,j):rr(T)?(e.consume(T),o=4,i.interrupt?n:D):a(T)}function b(T){return T===45?(e.consume(T),i.interrupt?n:D):a(T)}function j(T){const de="CDATA[";return T===de.charCodeAt(h++)?(e.consume(T),h===de.length?i.interrupt?n:U:j):a(T)}function k(T){return rr(T)?(e.consume(T),d=String.fromCharCode(T),N):a(T)}function N(T){if(T===null||T===47||T===62||ln(T)){const de=T===47,Ne=d.toLowerCase();return!de&&!u&&P0.includes(Ne)?(o=1,i.interrupt?n(T):U(T)):ok.includes(d.toLowerCase())?(o=6,de?(e.consume(T),C):i.interrupt?n(T):U(T)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(T):u?E(T):R(T))}return T===45||Jn(T)?(e.consume(T),d+=String.fromCharCode(T),N):a(T)}function C(T){return T===62?(e.consume(T),i.interrupt?n:U):a(T)}function E(T){return At(T)?(e.consume(T),E):A(T)}function R(T){return T===47?(e.consume(T),A):T===58||T===95||rr(T)?(e.consume(T),M):At(T)?(e.consume(T),R):A(T)}function M(T){return T===45||T===46||T===58||T===95||Jn(T)?(e.consume(T),M):I(T)}function I(T){return T===61?(e.consume(T),B):At(T)?(e.consume(T),I):R(T)}function B(T){return T===null||T===60||T===61||T===62||T===96?a(T):T===34||T===39?(e.consume(T),m=T,L):At(T)?(e.consume(T),B):H(T)}function L(T){return T===m?(e.consume(T),m=null,Q):T===null||at(T)?a(T):(e.consume(T),L)}function H(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||ln(T)?I(T):(e.consume(T),H)}function Q(T){return T===47||T===62||At(T)?R(T):a(T)}function A(T){return T===62?(e.consume(T),$):a(T)}function $(T){return T===null||at(T)?U(T):At(T)?(e.consume(T),$):a(T)}function U(T){return T===45&&o===2?(e.consume(T),Y):T===60&&o===1?(e.consume(T),ue):T===62&&o===4?(e.consume(T),F):T===63&&o===3?(e.consume(T),D):T===93&&o===5?(e.consume(T),K):at(T)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(uk,q,ee)(T)):T===null||at(T)?(e.exit("htmlFlowData"),ee(T)):(e.consume(T),U)}function ee(T){return e.check(dk,oe,q)(T)}function oe(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),ne}function ne(T){return T===null||at(T)?ee(T):(e.enter("htmlFlowData"),U(T))}function Y(T){return T===45?(e.consume(T),D):U(T)}function ue(T){return T===47?(e.consume(T),d="",J):U(T)}function J(T){if(T===62){const de=d.toLowerCase();return P0.includes(de)?(e.consume(T),F):U(T)}return rr(T)&&d.length<8?(e.consume(T),d+=String.fromCharCode(T),J):U(T)}function K(T){return T===93?(e.consume(T),D):U(T)}function D(T){return T===62?(e.consume(T),F):T===45&&o===2?(e.consume(T),D):U(T)}function F(T){return T===null||at(T)?(e.exit("htmlFlowData"),q(T)):(e.consume(T),F)}function q(T){return e.exit("htmlFlow"),n(T)}}function mk(e,n,a){const i=this;return o;function o(d){return at(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):a(d)}function u(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}function pk(e,n,a){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(qo,n,a)}}const xk={name:"htmlText",tokenize:yk};function yk(e,n,a){const i=this;let o,u,d;return h;function h(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),m}function m(D){return D===33?(e.consume(D),f):D===47?(e.consume(D),I):D===63?(e.consume(D),R):rr(D)?(e.consume(D),H):a(D)}function f(D){return D===45?(e.consume(D),x):D===91?(e.consume(D),u=0,j):rr(D)?(e.consume(D),E):a(D)}function x(D){return D===45?(e.consume(D),b):a(D)}function y(D){return D===null?a(D):D===45?(e.consume(D),v):at(D)?(d=y,ue(D)):(e.consume(D),y)}function v(D){return D===45?(e.consume(D),b):y(D)}function b(D){return D===62?Y(D):D===45?v(D):y(D)}function j(D){const F="CDATA[";return D===F.charCodeAt(u++)?(e.consume(D),u===F.length?k:j):a(D)}function k(D){return D===null?a(D):D===93?(e.consume(D),N):at(D)?(d=k,ue(D)):(e.consume(D),k)}function N(D){return D===93?(e.consume(D),C):k(D)}function C(D){return D===62?Y(D):D===93?(e.consume(D),C):k(D)}function E(D){return D===null||D===62?Y(D):at(D)?(d=E,ue(D)):(e.consume(D),E)}function R(D){return D===null?a(D):D===63?(e.consume(D),M):at(D)?(d=R,ue(D)):(e.consume(D),R)}function M(D){return D===62?Y(D):R(D)}function I(D){return rr(D)?(e.consume(D),B):a(D)}function B(D){return D===45||Jn(D)?(e.consume(D),B):L(D)}function L(D){return at(D)?(d=L,ue(D)):At(D)?(e.consume(D),L):Y(D)}function H(D){return D===45||Jn(D)?(e.consume(D),H):D===47||D===62||ln(D)?Q(D):a(D)}function Q(D){return D===47?(e.consume(D),Y):D===58||D===95||rr(D)?(e.consume(D),A):at(D)?(d=Q,ue(D)):At(D)?(e.consume(D),Q):Y(D)}function A(D){return D===45||D===46||D===58||D===95||Jn(D)?(e.consume(D),A):$(D)}function $(D){return D===61?(e.consume(D),U):at(D)?(d=$,ue(D)):At(D)?(e.consume(D),$):Q(D)}function U(D){return D===null||D===60||D===61||D===62||D===96?a(D):D===34||D===39?(e.consume(D),o=D,ee):at(D)?(d=U,ue(D)):At(D)?(e.consume(D),U):(e.consume(D),oe)}function ee(D){return D===o?(e.consume(D),o=void 0,ne):D===null?a(D):at(D)?(d=ee,ue(D)):(e.consume(D),ee)}function oe(D){return D===null||D===34||D===39||D===60||D===61||D===96?a(D):D===47||D===62||ln(D)?Q(D):(e.consume(D),oe)}function ne(D){return D===47||D===62||ln(D)?Q(D):a(D)}function Y(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),n):a(D)}function ue(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),J}function J(D){return At(D)?Bt(e,K,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):K(D)}function K(D){return e.enter("htmlTextData"),d(D)}}const Em={name:"labelEnd",resolveAll:wk,resolveTo:kk,tokenize:jk},gk={tokenize:Sk},bk={tokenize:Ck},vk={tokenize:Nk};function wk(e){let n=-1;const a=[];for(;++n<e.length;){const i=e[n][1];if(a.push(e[n]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const o=i.type==="labelImage"?4:2;i.type="data",n+=o}}return e.length!==a.length&&Tr(e,0,e.length,a),e}function kk(e,n){let a=e.length,i=0,o,u,d,h;for(;a--;)if(o=e[a][1],u){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[a][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(d){if(e[a][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(u=a,o.type!=="labelLink")){i=2;break}}else o.type==="labelEnd"&&(d=a);const m={type:e[u][1].type==="labelLink"?"link":"image",start:{...e[u][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[u][1].start},end:{...e[d][1].end}},x={type:"labelText",start:{...e[u+i+2][1].end},end:{...e[d-2][1].start}};return h=[["enter",m,n],["enter",f,n]],h=qr(h,e.slice(u+1,u+i+3)),h=qr(h,[["enter",x,n]]),h=qr(h,Wu(n.parser.constructs.insideSpan.null,e.slice(u+i+4,d-3),n)),h=qr(h,[["exit",x,n],e[d-2],e[d-1],["exit",f,n]]),h=qr(h,e.slice(d+1)),h=qr(h,[["exit",m,n]]),Tr(e,u,e.length,h),e}function jk(e,n,a){const i=this;let o=i.events.length,u,d;for(;o--;)if((i.events[o][1].type==="labelImage"||i.events[o][1].type==="labelLink")&&!i.events[o][1]._balanced){u=i.events[o][1];break}return h;function h(v){return u?u._inactive?y(v):(d=i.parser.defined.includes(la(i.sliceSerialize({start:u.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(v),e.exit("labelMarker"),e.exit("labelEnd"),m):a(v)}function m(v){return v===40?e.attempt(gk,x,d?x:y)(v):v===91?e.attempt(bk,x,d?f:y)(v):d?x(v):y(v)}function f(v){return e.attempt(vk,x,y)(v)}function x(v){return n(v)}function y(v){return u._balanced=!0,a(v)}}function Sk(e,n,a){return i;function i(y){return e.enter("resource"),e.enter("resourceMarker"),e.consume(y),e.exit("resourceMarker"),o}function o(y){return ln(y)?_o(e,u)(y):u(y)}function u(y){return y===41?x(y):Kg(e,d,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(y)}function d(y){return ln(y)?_o(e,m)(y):x(y)}function h(y){return a(y)}function m(y){return y===34||y===39||y===40?Pg(e,f,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(y):x(y)}function f(y){return ln(y)?_o(e,x)(y):x(y)}function x(y){return y===41?(e.enter("resourceMarker"),e.consume(y),e.exit("resourceMarker"),e.exit("resource"),n):a(y)}}function Ck(e,n,a){const i=this;return o;function o(h){return Qg.call(i,e,u,d,"reference","referenceMarker","referenceString")(h)}function u(h){return i.parser.defined.includes(la(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(h):a(h)}function d(h){return a(h)}}function Nk(e,n,a){return i;function i(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),o}function o(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),n):a(u)}}const Ek={name:"labelStartImage",resolveAll:Em.resolveAll,tokenize:Ak};function Ak(e,n,a){const i=this;return o;function o(h){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(h),e.exit("labelImageMarker"),u}function u(h){return h===91?(e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelImage"),d):a(h)}function d(h){return h===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(h):n(h)}}const Dk={name:"labelStartLink",resolveAll:Em.resolveAll,tokenize:Tk};function Tk(e,n,a){const i=this;return o;function o(d){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelLink"),u}function u(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(d):n(d)}}const sh={name:"lineEnding",tokenize:Fk};function Fk(e,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Bt(e,n,"linePrefix")}}const Nu={name:"thematicBreak",tokenize:Mk};function Mk(e,n,a){let i=0,o;return u;function u(f){return e.enter("thematicBreak"),d(f)}function d(f){return o=f,h(f)}function h(f){return f===o?(e.enter("thematicBreakSequence"),m(f)):i>=3&&(f===null||at(f))?(e.exit("thematicBreak"),n(f)):a(f)}function m(f){return f===o?(e.consume(f),i++,m):(e.exit("thematicBreakSequence"),At(f)?Bt(e,h,"whitespace")(f):h(f))}}const mr={continuation:{tokenize:Bk},exit:$k,name:"list",tokenize:_k},Rk={partial:!0,tokenize:Lk},zk={partial:!0,tokenize:Ok};function _k(e,n,a){const i=this,o=i.events[i.events.length-1];let u=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,d=0;return h;function h(b){const j=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:Vh(b)){if(i.containerState.type||(i.containerState.type=j,e.enter(j,{_container:!0})),j==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(Nu,a,f)(b):f(b);if(!i.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(b)}return a(b)}function m(b){return Vh(b)&&++d<10?(e.consume(b),m):(!i.interrupt||d<2)&&(i.containerState.marker?b===i.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),f(b)):a(b)}function f(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||b,e.check(qo,i.interrupt?a:x,e.attempt(Rk,v,y))}function x(b){return i.containerState.initialBlankLine=!0,u++,v(b)}function y(b){return At(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),v):a(b)}function v(b){return i.containerState.size=u+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(b)}}function Bk(e,n,a){const i=this;return i.containerState._closeFlow=void 0,e.check(qo,o,u);function o(h){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Bt(e,n,"listItemIndent",i.containerState.size+1)(h)}function u(h){return i.containerState.furtherBlankLines||!At(h)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,d(h)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(zk,n,d)(h))}function d(h){return i.containerState._closeFlow=!0,i.interrupt=void 0,Bt(e,e.attempt(mr,n,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function Ok(e,n,a){const i=this;return Bt(e,o,"listItemIndent",i.containerState.size+1);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===i.containerState.size?n(u):a(u)}}function $k(e){e.exit(this.containerState.type)}function Lk(e,n,a){const i=this;return Bt(e,o,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(u){const d=i.events[i.events.length-1];return!At(u)&&d&&d[1].type==="listItemPrefixWhitespace"?n(u):a(u)}}const Z0={name:"setextUnderline",resolveTo:Ik,tokenize:Hk};function Ik(e,n){let a=e.length,i,o,u;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){i=a;break}e[a][1].type==="paragraph"&&(o=a)}else e[a][1].type==="content"&&e.splice(a,1),!u&&e[a][1].type==="definition"&&(u=a);const d={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",u?(e.splice(o,0,["enter",d,n]),e.splice(u+1,0,["exit",e[i][1],n]),e[i][1].end={...e[u][1].end}):e[i][1]=d,e.push(["exit",d,n]),e}function Hk(e,n,a){const i=this;let o;return u;function u(f){let x=i.events.length,y;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){y=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||y)?(e.enter("setextHeadingLine"),o=f,d(f)):a(f)}function d(f){return e.enter("setextHeadingLineSequence"),h(f)}function h(f){return f===o?(e.consume(f),h):(e.exit("setextHeadingLineSequence"),At(f)?Bt(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||at(f)?(e.exit("setextHeadingLine"),n(f)):a(f)}}const Uk={tokenize:qk};function qk(e){const n=this,a=e.attempt(qo,i,e.attempt(this.parser.constructs.flowInitial,o,Bt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(V5,o)),"linePrefix")));return a;function i(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),n.currentConstruct=void 0,a}function o(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),n.currentConstruct=void 0,a}}const Yk={resolveAll:Jg()},Xk=Zg("string"),Wk=Zg("text");function Zg(e){return{resolveAll:Jg(e==="text"?Gk:void 0),tokenize:n};function n(a){const i=this,o=this.parser.constructs[e],u=a.attempt(o,d,h);return d;function d(x){return f(x)?u(x):h(x)}function h(x){if(x===null){a.consume(x);return}return a.enter("data"),a.consume(x),m}function m(x){return f(x)?(a.exit("data"),u(x)):(a.consume(x),m)}function f(x){if(x===null)return!0;const y=o[x];let v=-1;if(y)for(;++v<y.length;){const b=y[v];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function Jg(e){return n;function n(a,i){let o=-1,u;for(;++o<=a.length;)u===void 0?a[o]&&a[o][1].type==="data"&&(u=o,o++):(!a[o]||a[o][1].type!=="data")&&(o!==u+2&&(a[u][1].end=a[o-1][1].end,a.splice(u+2,o-u-2),o=u+2),u=void 0);return e?e(a,i):a}}function Gk(e,n){let a=0;for(;++a<=e.length;)if((a===e.length||e[a][1].type==="lineEnding")&&e[a-1][1].type==="data"){const i=e[a-1][1],o=n.sliceStream(i);let u=o.length,d=-1,h=0,m;for(;u--;){const f=o[u];if(typeof f=="string"){for(d=f.length;f.charCodeAt(d-1)===32;)h++,d--;if(d)break;d=-1}else if(f===-2)m=!0,h++;else if(f!==-1){u++;break}}if(n._contentTypeTextTrailing&&a===e.length&&(h=0),h){const f={type:a===e.length||m||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?d:i.start._bufferIndex+d,_index:i.start._index+u,line:i.end.line,column:i.end.column-h,offset:i.end.offset-h},end:{...i.end}};i.end={...f.start},i.start.offset===i.end.offset?Object.assign(i,f):(e.splice(a,0,["enter",f,n],["exit",f,n]),a+=2)}a++}return e}const Vk={42:mr,43:mr,45:mr,48:mr,49:mr,50:mr,51:mr,52:mr,53:mr,54:mr,55:mr,56:mr,57:mr,62:Xg},Kk={91:J5},Qk={[-2]:ih,[-1]:ih,32:ih},Pk={35:lk,42:Nu,45:[Z0,Nu],60:ck,61:Z0,95:Nu,96:Q0,126:Q0},Zk={38:Gg,92:Wg},Jk={[-5]:sh,[-4]:sh,[-3]:sh,33:Ek,38:Gg,42:Kh,60:[D5,xk],91:Dk,92:[rk,Wg],93:Em,95:Kh,96:U5},e3={null:[Kh,Yk]},t3={null:[42,95]},n3={null:[]},r3=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:t3,contentInitial:Kk,disable:n3,document:Vk,flow:Pk,flowInitial:Qk,insideSpan:e3,string:Zk,text:Jk},Symbol.toStringTag,{value:"Module"}));function a3(e,n,a){let i={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const o={},u=[];let d=[],h=[];const m={attempt:L(I),check:L(B),consume:E,enter:R,exit:M,interrupt:L(B,{interrupt:!0})},f={code:null,containerState:{},defineSkip:k,events:[],now:j,parser:e,previous:null,sliceSerialize:v,sliceStream:b,write:y};let x=n.tokenize.call(f,m);return n.resolveAll&&u.push(n),f;function y($){return d=qr(d,$),N(),d[d.length-1]!==null?[]:(H(n,0),f.events=Wu(u,f.events,f),f.events)}function v($,U){return i3(b($),U)}function b($){return l3(d,$)}function j(){const{_bufferIndex:$,_index:U,line:ee,column:oe,offset:ne}=i;return{_bufferIndex:$,_index:U,line:ee,column:oe,offset:ne}}function k($){o[$.line]=$.column,A()}function N(){let $;for(;i._index<d.length;){const U=d[i._index];if(typeof U=="string")for($=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===$&&i._bufferIndex<U.length;)C(U.charCodeAt(i._bufferIndex));else C(U)}}function C($){x=x($)}function E($){at($)?(i.line++,i.column=1,i.offset+=$===-3?2:1,A()):$!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===d[i._index].length&&(i._bufferIndex=-1,i._index++)),f.previous=$}function R($,U){const ee=U||{};return ee.type=$,ee.start=j(),f.events.push(["enter",ee,f]),h.push(ee),ee}function M($){const U=h.pop();return U.end=j(),f.events.push(["exit",U,f]),U}function I($,U){H($,U.from)}function B($,U){U.restore()}function L($,U){return ee;function ee(oe,ne,Y){let ue,J,K,D;return Array.isArray(oe)?q(oe):"tokenize"in oe?q([oe]):F(oe);function F(ye){return _e;function _e(Pe){const Ve=Pe!==null&&ye[Pe],lt=Pe!==null&&ye.null,dt=[...Array.isArray(Ve)?Ve:Ve?[Ve]:[],...Array.isArray(lt)?lt:lt?[lt]:[]];return q(dt)(Pe)}}function q(ye){return ue=ye,J=0,ye.length===0?Y:T(ye[J])}function T(ye){return _e;function _e(Pe){return D=Q(),K=ye,ye.partial||(f.currentConstruct=ye),ye.name&&f.parser.constructs.disable.null.includes(ye.name)?Ne():ye.tokenize.call(U?Object.assign(Object.create(f),U):f,m,de,Ne)(Pe)}}function de(ye){return $(K,D),ne}function Ne(ye){return D.restore(),++J<ue.length?T(ue[J]):Y}}}function H($,U){$.resolveAll&&!u.includes($)&&u.push($),$.resolve&&Tr(f.events,U,f.events.length-U,$.resolve(f.events.slice(U),f)),$.resolveTo&&(f.events=$.resolveTo(f.events,f))}function Q(){const $=j(),U=f.previous,ee=f.currentConstruct,oe=f.events.length,ne=Array.from(h);return{from:oe,restore:Y};function Y(){i=$,f.previous=U,f.currentConstruct=ee,f.events.length=oe,h=ne,A()}}function A(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function l3(e,n){const a=n.start._index,i=n.start._bufferIndex,o=n.end._index,u=n.end._bufferIndex;let d;if(a===o)d=[e[a].slice(i,u)];else{if(d=e.slice(a,o),i>-1){const h=d[0];typeof h=="string"?d[0]=h.slice(i):d.shift()}u>0&&d.push(e[o].slice(0,u))}return d}function i3(e,n){let a=-1;const i=[];let o;for(;++a<e.length;){const u=e[a];let d;if(typeof u=="string")d=u;else switch(u){case-5:{d="\r";break}case-4:{d=`
|
|
53
|
+
`;break}case-3:{d=`\r
|
|
54
|
+
`;break}case-2:{d=n?" ":" ";break}case-1:{if(!n&&o)continue;d=" ";break}default:d=String.fromCharCode(u)}o=u===-2,i.push(d)}return i.join("")}function s3(e){const i={constructs:qg([r3,...(e||{}).extensions||[]]),content:o(k5),defined:[],document:o(S5),flow:o(Uk),lazy:{},string:o(Xk),text:o(Wk)};return i;function o(u){return d;function d(h){return a3(i,u,h)}}}function o3(e){for(;!Vg(e););return e}const J0=/[\0\t\n\r]/g;function c3(){let e=1,n="",a=!0,i;return o;function o(u,d,h){const m=[];let f,x,y,v,b;for(u=n+(typeof u=="string"?u.toString():new TextDecoder(d||void 0).decode(u)),y=0,n="",a&&(u.charCodeAt(0)===65279&&y++,a=void 0);y<u.length;){if(J0.lastIndex=y,f=J0.exec(u),v=f&&f.index!==void 0?f.index:u.length,b=u.charCodeAt(v),!f){n=u.slice(y);break}if(b===10&&y===v&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),y<v&&(m.push(u.slice(y,v)),e+=v-y),b){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}y=v+1}return h&&(i&&m.push(-5),n&&m.push(n),m.push(null)),m}}const u3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function d3(e){return e.replace(u3,f3)}function f3(e,n,a){if(n)return n;if(a.charCodeAt(0)===35){const o=a.charCodeAt(1),u=o===120||o===88;return Yg(a.slice(u?2:1),u?16:10)}return Nm(a)||e}const eb={}.hasOwnProperty;function h3(e,n,a){return n&&typeof n=="object"&&(a=n,n=void 0),m3(a)(o3(s3(a).document().write(c3()(e,n,!0))))}function m3(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(qt),autolinkProtocol:Q,autolinkEmail:Q,atxHeading:u(xt),blockQuote:u(lt),characterEscape:Q,characterReference:Q,codeFenced:u(dt),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:u(dt,d),codeText:u(Ce,d),codeTextData:Q,data:Q,codeFlowValue:Q,definition:u(We),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:u(Te),hardBreakEscape:u(ut),hardBreakTrailing:u(ut),htmlFlow:u(mt,d),htmlFlowData:Q,htmlText:u(mt,d),htmlTextData:Q,image:u(wt),label:d,link:u(qt),listItem:u(Ct),listItemValue:v,listOrdered:u($t,y),listUnordered:u($t),paragraph:u(Bn),reference:T,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:u(xt),strong:u(he),thematicBreak:u(ce)},exit:{atxHeading:m(),atxHeadingSequence:I,autolink:m(),autolinkEmail:Ve,autolinkProtocol:Pe,blockQuote:m(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:Ne,characterReferenceMarkerNumeric:Ne,characterReferenceValue:ye,characterReference:_e,codeFenced:m(N),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:j,codeFlowValue:A,codeIndented:m(C),codeText:m(ne),codeTextData:A,data:A,definition:m(),definitionDestinationString:M,definitionLabelString:E,definitionTitleString:R,emphasis:m(),hardBreakEscape:m(U),hardBreakTrailing:m(U),htmlFlow:m(ee),htmlFlowData:A,htmlText:m(oe),htmlTextData:A,image:m(ue),label:K,labelText:J,lineEnding:$,link:m(Y),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:de,resourceDestinationString:D,resourceTitleString:F,resource:q,setextHeading:m(H),setextHeadingLineSequence:L,setextHeadingText:B,strong:m(),thematicBreak:m()}};tb(n,(e||{}).mdastExtensions||[]);const a={};return i;function i(W){let le={type:"root",children:[]};const we={stack:[le],tokenStack:[],config:n,enter:h,exit:f,buffer:d,resume:x,data:a},xe=[];let je=-1;for(;++je<W.length;)if(W[je][1].type==="listOrdered"||W[je][1].type==="listUnordered")if(W[je][0]==="enter")xe.push(je);else{const Re=xe.pop();je=o(W,Re,je)}for(je=-1;++je<W.length;){const Re=n[W[je][0]];eb.call(Re,W[je][1].type)&&Re[W[je][1].type].call(Object.assign({sliceSerialize:W[je][2].sliceSerialize},we),W[je][1])}if(we.tokenStack.length>0){const Re=we.tokenStack[we.tokenStack.length-1];(Re[1]||ey).call(we,void 0,Re[0])}for(le.position={start:Tl(W.length>0?W[0][1].start:{line:1,column:1,offset:0}),end:Tl(W.length>0?W[W.length-2][1].end:{line:1,column:1,offset:0})},je=-1;++je<n.transforms.length;)le=n.transforms[je](le)||le;return le}function o(W,le,we){let xe=le-1,je=-1,Re=!1,$e,Oe,Le,tt;for(;++xe<=we;){const Ke=W[xe];switch(Ke[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ke[0]==="enter"?je++:je--,tt=void 0;break}case"lineEndingBlank":{Ke[0]==="enter"&&($e&&!tt&&!je&&!Le&&(Le=xe),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!je&&Ke[0]==="enter"&&Ke[1].type==="listItemPrefix"||je===-1&&Ke[0]==="exit"&&(Ke[1].type==="listUnordered"||Ke[1].type==="listOrdered")){if($e){let jt=xe;for(Oe=void 0;jt--;){const ze=W[jt];if(ze[1].type==="lineEnding"||ze[1].type==="lineEndingBlank"){if(ze[0]==="exit")continue;Oe&&(W[Oe][1].type="lineEndingBlank",Re=!0),ze[1].type="lineEnding",Oe=jt}else if(!(ze[1].type==="linePrefix"||ze[1].type==="blockQuotePrefix"||ze[1].type==="blockQuotePrefixWhitespace"||ze[1].type==="blockQuoteMarker"||ze[1].type==="listItemIndent"))break}Le&&(!Oe||Le<Oe)&&($e._spread=!0),$e.end=Object.assign({},Oe?W[Oe][1].start:Ke[1].end),W.splice(Oe||xe,0,["exit",$e,Ke[2]]),xe++,we++}if(Ke[1].type==="listItemPrefix"){const jt={type:"listItem",_spread:!1,start:Object.assign({},Ke[1].start),end:void 0};$e=jt,W.splice(xe,0,["enter",jt,Ke[2]]),xe++,we++,Le=void 0,tt=!0}}}return W[le][1]._spread=Re,we}function u(W,le){return we;function we(xe){h.call(this,W(xe),xe),le&&le.call(this,xe)}}function d(){this.stack.push({type:"fragment",children:[]})}function h(W,le,we){this.stack[this.stack.length-1].children.push(W),this.stack.push(W),this.tokenStack.push([le,we||void 0]),W.position={start:Tl(le.start),end:void 0}}function m(W){return le;function le(we){W&&W.call(this,we),f.call(this,we)}}function f(W,le){const we=this.stack.pop(),xe=this.tokenStack.pop();if(xe)xe[0].type!==W.type&&(le?le.call(this,W,xe[0]):(xe[1]||ey).call(this,W,xe[0]));else throw new Error("Cannot close `"+W.type+"` ("+zo({start:W.start,end:W.end})+"): it’s not open");we.position.end=Tl(W.end)}function x(){return Cm(this.stack.pop())}function y(){this.data.expectingFirstListItemValue=!0}function v(W){if(this.data.expectingFirstListItemValue){const le=this.stack[this.stack.length-2];le.start=Number.parseInt(this.sliceSerialize(W),10),this.data.expectingFirstListItemValue=void 0}}function b(){const W=this.resume(),le=this.stack[this.stack.length-1];le.lang=W}function j(){const W=this.resume(),le=this.stack[this.stack.length-1];le.meta=W}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const W=this.resume(),le=this.stack[this.stack.length-1];le.value=W.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function C(){const W=this.resume(),le=this.stack[this.stack.length-1];le.value=W.replace(/(\r?\n|\r)$/g,"")}function E(W){const le=this.resume(),we=this.stack[this.stack.length-1];we.label=le,we.identifier=la(this.sliceSerialize(W)).toLowerCase()}function R(){const W=this.resume(),le=this.stack[this.stack.length-1];le.title=W}function M(){const W=this.resume(),le=this.stack[this.stack.length-1];le.url=W}function I(W){const le=this.stack[this.stack.length-1];if(!le.depth){const we=this.sliceSerialize(W).length;le.depth=we}}function B(){this.data.setextHeadingSlurpLineEnding=!0}function L(W){const le=this.stack[this.stack.length-1];le.depth=this.sliceSerialize(W).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function Q(W){const we=this.stack[this.stack.length-1].children;let xe=we[we.length-1];(!xe||xe.type!=="text")&&(xe=ve(),xe.position={start:Tl(W.start),end:void 0},we.push(xe)),this.stack.push(xe)}function A(W){const le=this.stack.pop();le.value+=this.sliceSerialize(W),le.position.end=Tl(W.end)}function $(W){const le=this.stack[this.stack.length-1];if(this.data.atHardBreak){const we=le.children[le.children.length-1];we.position.end=Tl(W.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(le.type)&&(Q.call(this,W),A.call(this,W))}function U(){this.data.atHardBreak=!0}function ee(){const W=this.resume(),le=this.stack[this.stack.length-1];le.value=W}function oe(){const W=this.resume(),le=this.stack[this.stack.length-1];le.value=W}function ne(){const W=this.resume(),le=this.stack[this.stack.length-1];le.value=W}function Y(){const W=this.stack[this.stack.length-1];if(this.data.inReference){const le=this.data.referenceType||"shortcut";W.type+="Reference",W.referenceType=le,delete W.url,delete W.title}else delete W.identifier,delete W.label;this.data.referenceType=void 0}function ue(){const W=this.stack[this.stack.length-1];if(this.data.inReference){const le=this.data.referenceType||"shortcut";W.type+="Reference",W.referenceType=le,delete W.url,delete W.title}else delete W.identifier,delete W.label;this.data.referenceType=void 0}function J(W){const le=this.sliceSerialize(W),we=this.stack[this.stack.length-2];we.label=d3(le),we.identifier=la(le).toLowerCase()}function K(){const W=this.stack[this.stack.length-1],le=this.resume(),we=this.stack[this.stack.length-1];if(this.data.inReference=!0,we.type==="link"){const xe=W.children;we.children=xe}else we.alt=le}function D(){const W=this.resume(),le=this.stack[this.stack.length-1];le.url=W}function F(){const W=this.resume(),le=this.stack[this.stack.length-1];le.title=W}function q(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function de(W){const le=this.resume(),we=this.stack[this.stack.length-1];we.label=le,we.identifier=la(this.sliceSerialize(W)).toLowerCase(),this.data.referenceType="full"}function Ne(W){this.data.characterReferenceType=W.type}function ye(W){const le=this.sliceSerialize(W),we=this.data.characterReferenceType;let xe;we?(xe=Yg(le,we==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):xe=Nm(le);const je=this.stack[this.stack.length-1];je.value+=xe}function _e(W){const le=this.stack.pop();le.position.end=Tl(W.end)}function Pe(W){A.call(this,W);const le=this.stack[this.stack.length-1];le.url=this.sliceSerialize(W)}function Ve(W){A.call(this,W);const le=this.stack[this.stack.length-1];le.url="mailto:"+this.sliceSerialize(W)}function lt(){return{type:"blockquote",children:[]}}function dt(){return{type:"code",lang:null,meta:null,value:""}}function Ce(){return{type:"inlineCode",value:""}}function We(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Te(){return{type:"emphasis",children:[]}}function xt(){return{type:"heading",depth:0,children:[]}}function ut(){return{type:"break"}}function mt(){return{type:"html",value:""}}function wt(){return{type:"image",title:null,url:"",alt:null}}function qt(){return{type:"link",title:null,url:"",children:[]}}function $t(W){return{type:"list",ordered:W.type==="listOrdered",start:null,spread:W._spread,children:[]}}function Ct(W){return{type:"listItem",spread:W._spread,checked:null,children:[]}}function Bn(){return{type:"paragraph",children:[]}}function he(){return{type:"strong",children:[]}}function ve(){return{type:"text",value:""}}function ce(){return{type:"thematicBreak"}}}function Tl(e){return{line:e.line,column:e.column,offset:e.offset}}function tb(e,n){let a=-1;for(;++a<n.length;){const i=n[a];Array.isArray(i)?tb(e,i):p3(e,i)}}function p3(e,n){let a;for(a in n)if(eb.call(n,a))switch(a){case"canContainEols":{const i=n[a];i&&e[a].push(...i);break}case"transforms":{const i=n[a];i&&e[a].push(...i);break}case"enter":case"exit":{const i=n[a];i&&Object.assign(e[a],i);break}}}function ey(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+zo({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+zo({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+zo({start:n.start,end:n.end})+") is still open")}function x3(e){const n=this;n.parser=a;function a(i){return h3(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function y3(e,n){const a={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,a),e.applyData(n,a)}function g3(e,n){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,a),[e.applyData(n,a),{type:"text",value:`
|
|
55
|
+
`}]}function b3(e,n){const a=n.value?n.value+`
|
|
56
|
+
`:"",i={},o=n.lang?n.lang.split(/\s+/):[];o.length>0&&(i.className=["language-"+o[0]]);let u={type:"element",tagName:"code",properties:i,children:[{type:"text",value:a}]};return n.meta&&(u.data={meta:n.meta}),e.patch(n,u),u=e.applyData(n,u),u={type:"element",tagName:"pre",properties:{},children:[u]},e.patch(n,u),u}function v3(e,n){const a={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function w3(e,n){const a={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function k3(e,n){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),o=ks(i.toLowerCase()),u=e.footnoteOrder.indexOf(i);let d,h=e.footnoteCounts.get(i);h===void 0?(h=0,e.footnoteOrder.push(i),d=e.footnoteOrder.length):d=u+1,h+=1,e.footnoteCounts.set(i,h);const m={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(n,m);const f={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(n,f),e.applyData(n,f)}function j3(e,n){const a={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function S3(e,n){if(e.options.allowDangerousHtml){const a={type:"raw",value:n.value};return e.patch(n,a),e.applyData(n,a)}}function nb(e,n){const a=n.referenceType;let i="]";if(a==="collapsed"?i+="[]":a==="full"&&(i+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+i}];const o=e.all(n),u=o[0];u&&u.type==="text"?u.value="["+u.value:o.unshift({type:"text",value:"["});const d=o[o.length-1];return d&&d.type==="text"?d.value+=i:o.push({type:"text",value:i}),o}function C3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return nb(e,n);const o={src:ks(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(o.title=i.title);const u={type:"element",tagName:"img",properties:o,children:[]};return e.patch(n,u),e.applyData(n,u)}function N3(e,n){const a={src:ks(n.url)};n.alt!==null&&n.alt!==void 0&&(a.alt=n.alt),n.title!==null&&n.title!==void 0&&(a.title=n.title);const i={type:"element",tagName:"img",properties:a,children:[]};return e.patch(n,i),e.applyData(n,i)}function E3(e,n){const a={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,a);const i={type:"element",tagName:"code",properties:{},children:[a]};return e.patch(n,i),e.applyData(n,i)}function A3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return nb(e,n);const o={href:ks(i.url||"")};i.title!==null&&i.title!==void 0&&(o.title=i.title);const u={type:"element",tagName:"a",properties:o,children:e.all(n)};return e.patch(n,u),e.applyData(n,u)}function D3(e,n){const a={href:ks(n.url)};n.title!==null&&n.title!==void 0&&(a.title=n.title);const i={type:"element",tagName:"a",properties:a,children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function T3(e,n,a){const i=e.all(n),o=a?F3(a):rb(n),u={},d=[];if(typeof n.checked=="boolean"){const x=i[0];let y;x&&x.type==="element"&&x.tagName==="p"?y=x:(y={type:"element",tagName:"p",properties:{},children:[]},i.unshift(y)),y.children.length>0&&y.children.unshift({type:"text",value:" "}),y.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),u.className=["task-list-item"]}let h=-1;for(;++h<i.length;){const x=i[h];(o||h!==0||x.type!=="element"||x.tagName!=="p")&&d.push({type:"text",value:`
|
|
57
|
+
`}),x.type==="element"&&x.tagName==="p"&&!o?d.push(...x.children):d.push(x)}const m=i[i.length-1];m&&(o||m.type!=="element"||m.tagName!=="p")&&d.push({type:"text",value:`
|
|
58
|
+
`});const f={type:"element",tagName:"li",properties:u,children:d};return e.patch(n,f),e.applyData(n,f)}function F3(e){let n=!1;if(e.type==="list"){n=e.spread||!1;const a=e.children;let i=-1;for(;!n&&++i<a.length;)n=rb(a[i])}return n}function rb(e){const n=e.spread;return n??e.children.length>1}function M3(e,n){const a={},i=e.all(n);let o=-1;for(typeof n.start=="number"&&n.start!==1&&(a.start=n.start);++o<i.length;){const d=i[o];if(d.type==="element"&&d.tagName==="li"&&d.properties&&Array.isArray(d.properties.className)&&d.properties.className.includes("task-list-item")){a.className=["contains-task-list"];break}}const u={type:"element",tagName:n.ordered?"ol":"ul",properties:a,children:e.wrap(i,!0)};return e.patch(n,u),e.applyData(n,u)}function R3(e,n){const a={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function z3(e,n){const a={type:"root",children:e.wrap(e.all(n))};return e.patch(n,a),e.applyData(n,a)}function _3(e,n){const a={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function B3(e,n){const a=e.all(n),i=a.shift(),o=[];if(i){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(n.children[0],d),o.push(d)}if(a.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},h=wm(n.children[1]),m=Bg(n.children[n.children.length-1]);h&&m&&(d.position={start:h,end:m}),o.push(d)}const u={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(n,u),e.applyData(n,u)}function O3(e,n,a){const i=a?a.children:void 0,u=(i?i.indexOf(n):1)===0?"th":"td",d=a&&a.type==="table"?a.align:void 0,h=d?d.length:n.children.length;let m=-1;const f=[];for(;++m<h;){const y=n.children[m],v={},b=d?d[m]:void 0;b&&(v.align=b);let j={type:"element",tagName:u,properties:v,children:[]};y&&(j.children=e.all(y),e.patch(y,j),j=e.applyData(y,j)),f.push(j)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(n,x),e.applyData(n,x)}function $3(e,n){const a={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}const ty=9,ny=32;function L3(e){const n=String(e),a=/\r?\n|\r/g;let i=a.exec(n),o=0;const u=[];for(;i;)u.push(ry(n.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=a.exec(n);return u.push(ry(n.slice(o),o>0,!1)),u.join("")}function ry(e,n,a){let i=0,o=e.length;if(n){let u=e.codePointAt(i);for(;u===ty||u===ny;)i++,u=e.codePointAt(i)}if(a){let u=e.codePointAt(o-1);for(;u===ty||u===ny;)o--,u=e.codePointAt(o-1)}return o>i?e.slice(i,o):""}function I3(e,n){const a={type:"text",value:L3(String(n.value))};return e.patch(n,a),e.applyData(n,a)}function H3(e,n){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,a),e.applyData(n,a)}const U3={blockquote:y3,break:g3,code:b3,delete:v3,emphasis:w3,footnoteReference:k3,heading:j3,html:S3,imageReference:C3,image:N3,inlineCode:E3,linkReference:A3,link:D3,listItem:T3,list:M3,paragraph:R3,root:z3,strong:_3,table:B3,tableCell:$3,tableRow:O3,text:I3,thematicBreak:H3,toml:cu,yaml:cu,definition:cu,footnoteDefinition:cu};function cu(){}const ab=-1,Gu=0,Bo=1,Ru=2,Am=3,Dm=4,Tm=5,Fm=6,lb=7,ib=8,ay=typeof self=="object"?self:globalThis,q3=(e,n)=>{const a=(o,u)=>(e.set(u,o),o),i=o=>{if(e.has(o))return e.get(o);const[u,d]=n[o];switch(u){case Gu:case ab:return a(d,o);case Bo:{const h=a([],o);for(const m of d)h.push(i(m));return h}case Ru:{const h=a({},o);for(const[m,f]of d)h[i(m)]=i(f);return h}case Am:return a(new Date(d),o);case Dm:{const{source:h,flags:m}=d;return a(new RegExp(h,m),o)}case Tm:{const h=a(new Map,o);for(const[m,f]of d)h.set(i(m),i(f));return h}case Fm:{const h=a(new Set,o);for(const m of d)h.add(i(m));return h}case lb:{const{name:h,message:m}=d;return a(new ay[h](m),o)}case ib:return a(BigInt(d),o);case"BigInt":return a(Object(BigInt(d)),o);case"ArrayBuffer":return a(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:h}=new Uint8Array(d);return a(new DataView(h),d)}}return a(new ay[u](d),o)};return i},ly=e=>q3(new Map,e)(0),fs="",{toString:Y3}={},{keys:X3}=Object,So=e=>{const n=typeof e;if(n!=="object"||!e)return[Gu,n];const a=Y3.call(e).slice(8,-1);switch(a){case"Array":return[Bo,fs];case"Object":return[Ru,fs];case"Date":return[Am,fs];case"RegExp":return[Dm,fs];case"Map":return[Tm,fs];case"Set":return[Fm,fs];case"DataView":return[Bo,a]}return a.includes("Array")?[Bo,a]:a.includes("Error")?[lb,a]:[Ru,a]},uu=([e,n])=>e===Gu&&(n==="function"||n==="symbol"),W3=(e,n,a,i)=>{const o=(d,h)=>{const m=i.push(d)-1;return a.set(h,m),m},u=d=>{if(a.has(d))return a.get(d);let[h,m]=So(d);switch(h){case Gu:{let x=d;switch(m){case"bigint":h=ib,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([ab],d)}return o([h,x],d)}case Bo:{if(m){let v=d;return m==="DataView"?v=new Uint8Array(d.buffer):m==="ArrayBuffer"&&(v=new Uint8Array(d)),o([m,[...v]],d)}const x=[],y=o([h,x],d);for(const v of d)x.push(u(v));return y}case Ru:{if(m)switch(m){case"BigInt":return o([m,d.toString()],d);case"Boolean":case"Number":case"String":return o([m,d.valueOf()],d)}if(n&&"toJSON"in d)return u(d.toJSON());const x=[],y=o([h,x],d);for(const v of X3(d))(e||!uu(So(d[v])))&&x.push([u(v),u(d[v])]);return y}case Am:return o([h,d.toISOString()],d);case Dm:{const{source:x,flags:y}=d;return o([h,{source:x,flags:y}],d)}case Tm:{const x=[],y=o([h,x],d);for(const[v,b]of d)(e||!(uu(So(v))||uu(So(b))))&&x.push([u(v),u(b)]);return y}case Fm:{const x=[],y=o([h,x],d);for(const v of d)(e||!uu(So(v)))&&x.push(u(v));return y}}const{message:f}=d;return o([h,{name:m,message:f}],d)};return u},iy=(e,{json:n,lossy:a}={})=>{const i=[];return W3(!(n||a),!!n,new Map,i)(e),i},zu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?ly(iy(e,n)):structuredClone(e):(e,n)=>ly(iy(e,n));function G3(e,n){const a=[{type:"text",value:"↩"}];return n>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(n)}]}),a}function V3(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function K3(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||G3,i=e.options.footnoteBackLabel||V3,o=e.options.footnoteLabel||"Footnotes",u=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let m=-1;for(;++m<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[m]);if(!f)continue;const x=e.all(f),y=String(f.identifier).toUpperCase(),v=ks(y.toLowerCase());let b=0;const j=[],k=e.footnoteCounts.get(y);for(;k!==void 0&&++b<=k;){j.length>0&&j.push({type:"text",value:" "});let E=typeof a=="string"?a:a(m,b);typeof E=="string"&&(E={type:"text",value:E}),j.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+v+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(m,b),className:["data-footnote-backref"]},children:Array.isArray(E)?E:[E]})}const N=x[x.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const E=N.children[N.children.length-1];E&&E.type==="text"?E.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...j)}else x.push(...j);const C={type:"element",tagName:"li",properties:{id:n+"fn-"+v},children:e.wrap(x,!0)};e.patch(f,C),h.push(C)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:u,properties:{...zu(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
59
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(h,!0)},{type:"text",value:`
|
|
60
|
+
`}]}}const Vu=(function(e){if(e==null)return J3;if(typeof e=="function")return Ku(e);if(typeof e=="object")return Array.isArray(e)?Q3(e):P3(e);if(typeof e=="string")return Z3(e);throw new Error("Expected function, string, or object as test")});function Q3(e){const n=[];let a=-1;for(;++a<e.length;)n[a]=Vu(e[a]);return Ku(i);function i(...o){let u=-1;for(;++u<n.length;)if(n[u].apply(this,o))return!0;return!1}}function P3(e){const n=e;return Ku(a);function a(i){const o=i;let u;for(u in e)if(o[u]!==n[u])return!1;return!0}}function Z3(e){return Ku(n);function n(a){return a&&a.type===e}}function Ku(e){return n;function n(a,i,o){return!!(e4(a)&&e.call(this,a,typeof i=="number"?i:void 0,o||void 0))}}function J3(){return!0}function e4(e){return e!==null&&typeof e=="object"&&"type"in e}const sb=[],t4=!0,Qh=!1,n4="skip";function ob(e,n,a,i){let o;typeof n=="function"&&typeof a!="function"?(i=a,a=n):o=n;const u=Vu(o),d=i?-1:1;h(e,void 0,[])();function h(m,f,x){const y=m&&typeof m=="object"?m:{};if(typeof y.type=="string"){const b=typeof y.tagName=="string"?y.tagName:typeof y.name=="string"?y.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(m.type+(b?"<"+b+">":""))+")"})}return v;function v(){let b=sb,j,k,N;if((!n||u(m,f,x[x.length-1]||void 0))&&(b=r4(a(m,x)),b[0]===Qh))return b;if("children"in m&&m.children){const C=m;if(C.children&&b[0]!==n4)for(k=(i?C.children.length:-1)+d,N=x.concat(C);k>-1&&k<C.children.length;){const E=C.children[k];if(j=h(E,k,N)(),j[0]===Qh)return j;k=typeof j[1]=="number"?j[1]:k+d}}return b}}}function r4(e){return Array.isArray(e)?e:typeof e=="number"?[t4,e]:e==null?sb:[e]}function Mm(e,n,a,i){let o,u,d;typeof n=="function"&&typeof a!="function"?(u=void 0,d=n,o=a):(u=n,d=a,o=i),ob(e,u,h,o);function h(m,f){const x=f[f.length-1],y=x?x.children.indexOf(m):void 0;return d(m,y,x)}}const Ph={}.hasOwnProperty,a4={};function l4(e,n){const a=n||a4,i=new Map,o=new Map,u=new Map,d={...U3,...a.handlers},h={all:f,applyData:s4,definitionById:i,footnoteById:o,footnoteCounts:u,footnoteOrder:[],handlers:d,one:m,options:a,patch:i4,wrap:c4};return Mm(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const y=x.type==="definition"?i:o,v=String(x.identifier).toUpperCase();y.has(v)||y.set(v,x)}}),h;function m(x,y){const v=x.type,b=h.handlers[v];if(Ph.call(h.handlers,v)&&b)return b(h,x,y);if(h.options.passThrough&&h.options.passThrough.includes(v)){if("children"in x){const{children:k,...N}=x,C=zu(N);return C.children=h.all(x),C}return zu(x)}return(h.options.unknownHandler||o4)(h,x,y)}function f(x){const y=[];if("children"in x){const v=x.children;let b=-1;for(;++b<v.length;){const j=h.one(v[b],x);if(j){if(b&&v[b-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=sy(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=sy(k.value))}Array.isArray(j)?y.push(...j):y.push(j)}}}return y}}function i4(e,n){e.position&&(n.position=Vw(e))}function s4(e,n){let a=n;if(e&&e.data){const i=e.data.hName,o=e.data.hChildren,u=e.data.hProperties;if(typeof i=="string")if(a.type==="element")a.tagName=i;else{const d="children"in a?a.children:[a];a={type:"element",tagName:i,properties:{},children:d}}a.type==="element"&&u&&Object.assign(a.properties,zu(u)),"children"in a&&a.children&&o!==null&&o!==void 0&&(a.children=o)}return a}function o4(e,n){const a=n.data||{},i="value"in n&&!(Ph.call(a,"hProperties")||Ph.call(a,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function c4(e,n){const a=[];let i=-1;for(n&&a.push({type:"text",value:`
|
|
61
|
+
`});++i<e.length;)i&&a.push({type:"text",value:`
|
|
62
|
+
`}),a.push(e[i]);return n&&e.length>0&&a.push({type:"text",value:`
|
|
63
|
+
`}),a}function sy(e){let n=0,a=e.charCodeAt(n);for(;a===9||a===32;)n++,a=e.charCodeAt(n);return e.slice(n)}function oy(e,n){const a=l4(e,n),i=a.one(e,void 0),o=K3(a),u=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return o&&u.children.push({type:"text",value:`
|
|
64
|
+
`},o),u}function u4(e,n){return e&&"run"in e?async function(a,i){const o=oy(a,{file:i,...n});await e.run(o,i)}:function(a,i){return oy(a,{file:i,...e||n})}}function cy(e){if(e)throw e}var oh,uy;function d4(){if(uy)return oh;uy=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):n.call(f)==="[object Array]"},u=function(f){if(!f||n.call(f)!=="[object Object]")return!1;var x=e.call(f,"constructor"),y=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!x&&!y)return!1;var v;for(v in f);return typeof v>"u"||e.call(f,v)},d=function(f,x){a&&x.name==="__proto__"?a(f,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):f[x.name]=x.newValue},h=function(f,x){if(x==="__proto__")if(e.call(f,x)){if(i)return i(f,x).value}else return;return f[x]};return oh=function m(){var f,x,y,v,b,j,k=arguments[0],N=1,C=arguments.length,E=!1;for(typeof k=="boolean"&&(E=k,k=arguments[1]||{},N=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});N<C;++N)if(f=arguments[N],f!=null)for(x in f)y=h(k,x),v=h(f,x),k!==v&&(E&&v&&(u(v)||(b=o(v)))?(b?(b=!1,j=y&&o(y)?y:[]):j=y&&u(y)?y:{},d(k,{name:x,newValue:m(E,j,v)})):typeof v<"u"&&d(k,{name:x,newValue:v}));return k},oh}var f4=d4();const ch=Ng(f4);function Zh(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function h4(){const e=[],n={run:a,use:i};return n;function a(...o){let u=-1;const d=o.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);h(null,...o);function h(m,...f){const x=e[++u];let y=-1;if(m){d(m);return}for(;++y<o.length;)(f[y]===null||f[y]===void 0)&&(f[y]=o[y]);o=f,x?m4(x,h)(...f):d(null,...f)}}function i(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),n}}function m4(e,n){let a;return i;function i(...d){const h=e.length>d.length;let m;h&&d.push(o);try{m=e.apply(this,d)}catch(f){const x=f;if(h&&a)throw x;return o(x)}h||(m&&m.then&&typeof m.then=="function"?m.then(u,o):m instanceof Error?o(m):u(m))}function o(d,...h){a||(a=!0,n(d,...h))}function u(d){o(null,d)}}const ba={basename:p4,dirname:x4,extname:y4,join:g4,sep:"/"};function p4(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Yo(e);let a=0,i=-1,o=e.length,u;if(n===void 0||n.length===0||n.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else i<0&&(u=!0,i=o+1);return i<0?"":e.slice(a,i)}if(n===e)return"";let d=-1,h=n.length-1;for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else d<0&&(u=!0,d=o+1),h>-1&&(e.codePointAt(o)===n.codePointAt(h--)?h<0&&(i=o):(h=-1,i=d));return a===i?i=d:i<0&&(i=e.length),e.slice(a,i)}function x4(e){if(Yo(e),e.length===0)return".";let n=-1,a=e.length,i;for(;--a;)if(e.codePointAt(a)===47){if(i){n=a;break}}else i||(i=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function y4(e){Yo(e);let n=e.length,a=-1,i=0,o=-1,u=0,d;for(;n--;){const h=e.codePointAt(n);if(h===47){if(d){i=n+1;break}continue}a<0&&(d=!0,a=n+1),h===46?o<0?o=n:u!==1&&(u=1):o>-1&&(u=-1)}return o<0||a<0||u===0||u===1&&o===a-1&&o===i+1?"":e.slice(o,a)}function g4(...e){let n=-1,a;for(;++n<e.length;)Yo(e[n]),e[n]&&(a=a===void 0?e[n]:a+"/"+e[n]);return a===void 0?".":b4(a)}function b4(e){Yo(e);const n=e.codePointAt(0)===47;let a=v4(e,!n);return a.length===0&&!n&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),n?"/"+a:a}function v4(e,n){let a="",i=0,o=-1,u=0,d=-1,h,m;for(;++d<=e.length;){if(d<e.length)h=e.codePointAt(d);else{if(h===47)break;h=47}if(h===47){if(!(o===d-1||u===1))if(o!==d-1&&u===2){if(a.length<2||i!==2||a.codePointAt(a.length-1)!==46||a.codePointAt(a.length-2)!==46){if(a.length>2){if(m=a.lastIndexOf("/"),m!==a.length-1){m<0?(a="",i=0):(a=a.slice(0,m),i=a.length-1-a.lastIndexOf("/")),o=d,u=0;continue}}else if(a.length>0){a="",i=0,o=d,u=0;continue}}n&&(a=a.length>0?a+"/..":"..",i=2)}else a.length>0?a+="/"+e.slice(o+1,d):a=e.slice(o+1,d),i=d-o-1;o=d,u=0}else h===46&&u>-1?u++:u=-1}return a}function Yo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const w4={cwd:k4};function k4(){return"/"}function Jh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function j4(e){if(typeof e=="string")e=new URL(e);else if(!Jh(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return S4(e)}function S4(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=e.pathname;let a=-1;for(;++a<n.length;)if(n.codePointAt(a)===37&&n.codePointAt(a+1)===50){const i=n.codePointAt(a+2);if(i===70||i===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(n)}const uh=["history","path","basename","stem","extname","dirname"];class cb{constructor(n){let a;n?Jh(n)?a={path:n}:typeof n=="string"||C4(n)?a={value:n}:a=n:a={},this.cwd="cwd"in a?"":w4.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<uh.length;){const u=uh[i];u in a&&a[u]!==void 0&&a[u]!==null&&(this[u]=u==="history"?[...a[u]]:a[u])}let o;for(o in a)uh.includes(o)||(this[o]=a[o])}get basename(){return typeof this.path=="string"?ba.basename(this.path):void 0}set basename(n){fh(n,"basename"),dh(n,"basename"),this.path=ba.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?ba.dirname(this.path):void 0}set dirname(n){dy(this.basename,"dirname"),this.path=ba.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?ba.extname(this.path):void 0}set extname(n){if(dh(n,"extname"),dy(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ba.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){Jh(n)&&(n=j4(n)),fh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?ba.basename(this.path,this.extname):void 0}set stem(n){fh(n,"stem"),dh(n,"stem"),this.path=ba.join(this.dirname||"",n+(this.extname||""))}fail(n,a,i){const o=this.message(n,a,i);throw o.fatal=!0,o}info(n,a,i){const o=this.message(n,a,i);return o.fatal=void 0,o}message(n,a,i){const o=new er(n,a,i);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function dh(e,n){if(e&&e.includes(ba.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+ba.sep+"`")}function fh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function dy(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function C4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const N4=(function(e){const i=this.constructor.prototype,o=i[e],u=function(){return o.apply(u,arguments)};return Object.setPrototypeOf(u,i),u}),E4={}.hasOwnProperty;class Rm extends N4{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=h4()}copy(){const n=new Rm;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];n.use(...i)}return n.data(ch(!0,{},this.namespace)),n}data(n,a){return typeof n=="string"?arguments.length===2?(ph("data",this.frozen),this.namespace[n]=a,this):E4.call(this.namespace,n)&&this.namespace[n]||void 0:n?(ph("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[a,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const o=a.call(n,...i);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const a=du(n),i=this.parser||this.Parser;return hh("parse",i),i(String(a),a)}process(n,a){const i=this;return this.freeze(),hh("process",this.parser||this.Parser),mh("process",this.compiler||this.Compiler),a?o(void 0,a):new Promise(o);function o(u,d){const h=du(n),m=i.parse(h);i.run(m,h,function(x,y,v){if(x||!y||!v)return f(x);const b=y,j=i.stringify(b,v);T4(j)?v.value=j:v.result=j,f(x,v)});function f(x,y){x||!y?d(x):u?u(y):a(void 0,y)}}}processSync(n){let a=!1,i;return this.freeze(),hh("processSync",this.parser||this.Parser),mh("processSync",this.compiler||this.Compiler),this.process(n,o),hy("processSync","process",a),i;function o(u,d){a=!0,cy(u),i=d}}run(n,a,i){fy(n),this.freeze();const o=this.transformers;return!i&&typeof a=="function"&&(i=a,a=void 0),i?u(void 0,i):new Promise(u);function u(d,h){const m=du(a);o.run(n,m,f);function f(x,y,v){const b=y||n;x?h(x):d?d(b):i(void 0,b,v)}}}runSync(n,a){let i=!1,o;return this.run(n,a,u),hy("runSync","run",i),o;function u(d,h){cy(d),o=h,i=!0}}stringify(n,a){this.freeze();const i=du(a),o=this.compiler||this.Compiler;return mh("stringify",o),fy(n),o(n,i)}use(n,...a){const i=this.attachers,o=this.namespace;if(ph("use",this.frozen),n!=null)if(typeof n=="function")m(n,a);else if(typeof n=="object")Array.isArray(n)?h(n):d(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function u(f){if(typeof f=="function")m(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[x,...y]=f;m(x,y)}else d(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function d(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(f.plugins),f.settings&&(o.settings=ch(!0,o.settings,f.settings))}function h(f){let x=-1;if(f!=null)if(Array.isArray(f))for(;++x<f.length;){const y=f[x];u(y)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,x){let y=-1,v=-1;for(;++y<i.length;)if(i[y][0]===f){v=y;break}if(v===-1)i.push([f,...x]);else if(x.length>0){let[b,...j]=x;const k=i[v][1];Zh(k)&&Zh(b)&&(b=ch(!0,k,b)),i[v]=[f,b,...j]}}}}const A4=new Rm().freeze();function hh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function mh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ph(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function fy(e){if(!Zh(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function hy(e,n,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function du(e){return D4(e)?e:new cb(e)}function D4(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function T4(e){return typeof e=="string"||F4(e)}function F4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const M4="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",my=[],py={allowDangerousHtml:!0},R4=/^(https?|ircs?|mailto|xmpp)$/i,z4=[{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 zm(e){const n=_4(e),a=B4(e);return O4(n.runSync(n.parse(a),a),e)}function _4(e){const n=e.rehypePlugins||my,a=e.remarkPlugins||my,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...py}:py;return A4().use(x3).use(a).use(u4,i).use(n)}function B4(e){const n=e.children||"",a=new cb;return typeof n=="string"&&(a.value=n),a}function O4(e,n){const a=n.allowedElements,i=n.allowElement,o=n.components,u=n.disallowedElements,d=n.skipHtml,h=n.unwrapDisallowed,m=n.urlTransform||$4;for(const x of z4)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+M4+x.id,void 0);return Mm(e,f),Jw(e,{Fragment:l.Fragment,components:o,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function f(x,y,v){if(x.type==="raw"&&v&&typeof y=="number")return d?v.children.splice(y,1):v.children[y]={type:"text",value:x.value},y;if(x.type==="element"){let b;for(b in lh)if(Object.hasOwn(lh,b)&&Object.hasOwn(x.properties,b)){const j=x.properties[b],k=lh[b];(k===null||k.includes(x.tagName))&&(x.properties[b]=m(String(j||""),b,x))}}if(x.type==="element"){let b=a?!a.includes(x.tagName):u?u.includes(x.tagName):!1;if(!b&&i&&typeof y=="number"&&(b=!i(x,y,v)),b&&v&&typeof y=="number")return h&&x.children?v.children.splice(y,1,...x.children):v.children.splice(y,1),y}}}function $4(e){const n=e.indexOf(":"),a=e.indexOf("?"),i=e.indexOf("#"),o=e.indexOf("/");return n===-1||o!==-1&&n>o||a!==-1&&n>a||i!==-1&&n>i||R4.test(e.slice(0,n))?e:""}function xy(e,n){const a=String(e);if(typeof n!="string")throw new TypeError("Expected character");let i=0,o=a.indexOf(n);for(;o!==-1;)i++,o=a.indexOf(n,o+n.length);return i}function L4(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function I4(e,n,a){const o=Vu((a||{}).ignore||[]),u=H4(n);let d=-1;for(;++d<u.length;)ob(e,"text",h);function h(f,x){let y=-1,v;for(;++y<x.length;){const b=x[y],j=v?v.children:void 0;if(o(b,j?j.indexOf(b):void 0,v))return;v=b}if(v)return m(f,x)}function m(f,x){const y=x[x.length-1],v=u[d][0],b=u[d][1];let j=0;const N=y.children.indexOf(f);let C=!1,E=[];v.lastIndex=0;let R=v.exec(f.value);for(;R;){const M=R.index,I={index:R.index,input:R.input,stack:[...x,f]};let B=b(...R,I);if(typeof B=="string"&&(B=B.length>0?{type:"text",value:B}:void 0),B===!1?v.lastIndex=M+1:(j!==M&&E.push({type:"text",value:f.value.slice(j,M)}),Array.isArray(B)?E.push(...B):B&&E.push(B),j=M+R[0].length,C=!0),!v.global)break;R=v.exec(f.value)}return C?(j<f.value.length&&E.push({type:"text",value:f.value.slice(j)}),y.children.splice(N,1,...E)):E=[f],N+E.length}}function H4(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const a=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<a.length;){const o=a[i];n.push([U4(o[0]),q4(o[1])])}return n}function U4(e){return typeof e=="string"?new RegExp(L4(e),"g"):e}function q4(e){return typeof e=="function"?e:function(){return e}}const xh="phrasing",yh=["autolink","link","image","label"];function Y4(){return{transforms:[P4],enter:{literalAutolink:W4,literalAutolinkEmail:gh,literalAutolinkHttp:gh,literalAutolinkWww:gh},exit:{literalAutolink:Q4,literalAutolinkEmail:K4,literalAutolinkHttp:G4,literalAutolinkWww:V4}}}function X4(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:xh,notInConstruct:yh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:xh,notInConstruct:yh},{character:":",before:"[ps]",after:"\\/",inConstruct:xh,notInConstruct:yh}]}}function W4(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function gh(e){this.config.enter.autolinkProtocol.call(this,e)}function G4(e){this.config.exit.autolinkProtocol.call(this,e)}function V4(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(e)}function K4(e){this.config.exit.autolinkEmail.call(this,e)}function Q4(e){this.exit(e)}function P4(e){I4(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Z4],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),J4]],{ignore:["link","linkReference"]})}function Z4(e,n,a,i,o){let u="";if(!ub(o)||(/^w/i.test(n)&&(a=n+a,n="",u="http://"),!ej(a)))return!1;const d=tj(a+i);if(!d[0])return!1;const h={type:"link",title:null,url:u+n+d[0],children:[{type:"text",value:n+d[0]}]};return d[1]?[h,{type:"text",value:d[1]}]:h}function J4(e,n,a,i){return!ub(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+a,children:[{type:"text",value:n+"@"+a}]}}function ej(e){const n=e.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function tj(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let a=n[0],i=a.indexOf(")");const o=xy(e,"(");let u=xy(e,")");for(;i!==-1&&o>u;)e+=a.slice(0,i+1),a=a.slice(i+1),i=a.indexOf(")"),u++;return[e,a]}function ub(e,n){const a=e.input.charCodeAt(e.index-1);return(e.index===0||ki(a)||Xu(a))&&(!n||a!==47)}db.peek=uj;function nj(){this.buffer()}function rj(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function aj(){this.buffer()}function lj(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ij(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=la(this.sliceSerialize(e)).toLowerCase(),a.label=n}function sj(e){this.exit(e)}function oj(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=la(this.sliceSerialize(e)).toLowerCase(),a.label=n}function cj(e){this.exit(e)}function uj(){return"["}function db(e,n,a,i){const o=a.createTracker(i);let u=o.move("[^");const d=a.enter("footnoteReference"),h=a.enter("reference");return u+=o.move(a.safe(a.associationId(e),{after:"]",before:u})),h(),d(),u+=o.move("]"),u}function dj(){return{enter:{gfmFootnoteCallString:nj,gfmFootnoteCall:rj,gfmFootnoteDefinitionLabelString:aj,gfmFootnoteDefinition:lj},exit:{gfmFootnoteCallString:ij,gfmFootnoteCall:sj,gfmFootnoteDefinitionLabelString:oj,gfmFootnoteDefinition:cj}}}function fj(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:a,footnoteReference:db},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,o,u,d){const h=u.createTracker(d);let m=h.move("[^");const f=u.enter("footnoteDefinition"),x=u.enter("label");return m+=h.move(u.safe(u.associationId(i),{before:m,after:"]"})),x(),m+=h.move("]:"),i.children&&i.children.length>0&&(h.shift(4),m+=h.move((n?`
|
|
65
|
+
`:" ")+u.indentLines(u.containerFlow(i,h.current()),n?fb:hj))),f(),m}}function hj(e,n,a){return n===0?e:fb(e,n,a)}function fb(e,n,a){return(a?"":" ")+e}const mj=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];hb.peek=bj;function pj(){return{canContainEols:["delete"],enter:{strikethrough:yj},exit:{strikethrough:gj}}}function xj(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:mj}],handlers:{delete:hb}}}function yj(e){this.enter({type:"delete",children:[]},e)}function gj(e){this.exit(e)}function hb(e,n,a,i){const o=a.createTracker(i),u=a.enter("strikethrough");let d=o.move("~~");return d+=a.containerPhrasing(e,{...o.current(),before:d,after:"~"}),d+=o.move("~~"),u(),d}function bj(){return"~"}function vj(e){return e.length}function wj(e,n){const a=n||{},i=(a.align||[]).concat(),o=a.stringLength||vj,u=[],d=[],h=[],m=[];let f=0,x=-1;for(;++x<e.length;){const k=[],N=[];let C=-1;for(e[x].length>f&&(f=e[x].length);++C<e[x].length;){const E=kj(e[x][C]);if(a.alignDelimiters!==!1){const R=o(E);N[C]=R,(m[C]===void 0||R>m[C])&&(m[C]=R)}k.push(E)}d[x]=k,h[x]=N}let y=-1;if(typeof i=="object"&&"length"in i)for(;++y<f;)u[y]=yy(i[y]);else{const k=yy(i);for(;++y<f;)u[y]=k}y=-1;const v=[],b=[];for(;++y<f;){const k=u[y];let N="",C="";k===99?(N=":",C=":"):k===108?N=":":k===114&&(C=":");let E=a.alignDelimiters===!1?1:Math.max(1,m[y]-N.length-C.length);const R=N+"-".repeat(E)+C;a.alignDelimiters!==!1&&(E=N.length+E+C.length,E>m[y]&&(m[y]=E),b[y]=E),v[y]=R}d.splice(1,0,v),h.splice(1,0,b),x=-1;const j=[];for(;++x<d.length;){const k=d[x],N=h[x];y=-1;const C=[];for(;++y<f;){const E=k[y]||"";let R="",M="";if(a.alignDelimiters!==!1){const I=m[y]-(N[y]||0),B=u[y];B===114?R=" ".repeat(I):B===99?I%2?(R=" ".repeat(I/2+.5),M=" ".repeat(I/2-.5)):(R=" ".repeat(I/2),M=R):M=" ".repeat(I)}a.delimiterStart!==!1&&!y&&C.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&E==="")&&(a.delimiterStart!==!1||y)&&C.push(" "),a.alignDelimiters!==!1&&C.push(R),C.push(E),a.alignDelimiters!==!1&&C.push(M),a.padding!==!1&&C.push(" "),(a.delimiterEnd!==!1||y!==f-1)&&C.push("|")}j.push(a.delimiterEnd===!1?C.join("").replace(/ +$/,""):C.join(""))}return j.join(`
|
|
66
|
+
`)}function kj(e){return e==null?"":String(e)}function yy(e){const n=typeof e=="string"?e.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function jj(e,n,a,i){const o=a.enter("blockquote"),u=a.createTracker(i);u.move("> "),u.shift(2);const d=a.indentLines(a.containerFlow(e,u.current()),Sj);return o(),d}function Sj(e,n,a){return">"+(a?"":" ")+e}function Cj(e,n){return gy(e,n.inConstruct,!0)&&!gy(e,n.notInConstruct,!1)}function gy(e,n,a){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return a;let i=-1;for(;++i<n.length;)if(e.includes(n[i]))return!0;return!1}function by(e,n,a,i){let o=-1;for(;++o<a.unsafe.length;)if(a.unsafe[o].character===`
|
|
67
|
+
`&&Cj(a.stack,a.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
68
|
+
`}function Nj(e,n){const a=String(e);let i=a.indexOf(n),o=i,u=0,d=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===o?++u>d&&(d=u):u=1,o=i+n.length,i=a.indexOf(n,o);return d}function Ej(e,n){return!!(n.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Aj(e){const n=e.options.fence||"`";if(n!=="`"&&n!=="~")throw new Error("Cannot serialize code with `"+n+"` for `options.fence`, expected `` ` `` or `~`");return n}function Dj(e,n,a,i){const o=Aj(a),u=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(Ej(e,a)){const y=a.enter("codeIndented"),v=a.indentLines(u,Tj);return y(),v}const h=a.createTracker(i),m=o.repeat(Math.max(Nj(u,o)+1,3)),f=a.enter("codeFenced");let x=h.move(m);if(e.lang){const y=a.enter(`codeFencedLang${d}`);x+=h.move(a.safe(e.lang,{before:x,after:" ",encode:["`"],...h.current()})),y()}if(e.lang&&e.meta){const y=a.enter(`codeFencedMeta${d}`);x+=h.move(" "),x+=h.move(a.safe(e.meta,{before:x,after:`
|
|
69
|
+
`,encode:["`"],...h.current()})),y()}return x+=h.move(`
|
|
70
|
+
`),u&&(x+=h.move(u+`
|
|
71
|
+
`)),x+=h.move(m),f(),x}function Tj(e,n,a){return(a?"":" ")+e}function _m(e){const n=e.options.quote||'"';if(n!=='"'&&n!=="'")throw new Error("Cannot serialize title with `"+n+"` for `options.quote`, expected `\"`, or `'`");return n}function Fj(e,n,a,i){const o=_m(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("definition");let h=a.enter("label");const m=a.createTracker(i);let f=m.move("[");return f+=m.move(a.safe(a.associationId(e),{before:f,after:"]",...m.current()})),f+=m.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=a.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(a.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=a.enter("destinationRaw"),f+=m.move(a.safe(e.url,{before:f,after:e.title?" ":`
|
|
72
|
+
`,...m.current()}))),h(),e.title&&(h=a.enter(`title${u}`),f+=m.move(" "+o),f+=m.move(a.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),d(),f}function Mj(e){const n=e.options.emphasis||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize emphasis with `"+n+"` for `options.emphasis`, expected `*`, or `_`");return n}function $o(e){return"&#x"+e.toString(16).toUpperCase()+";"}function _u(e,n,a){const i=ys(e),o=ys(n);return i===void 0?o===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}mb.peek=Rj;function mb(e,n,a,i){const o=Mj(a),u=a.enter("emphasis"),d=a.createTracker(i),h=d.move(o);let m=d.move(a.containerPhrasing(e,{after:o,before:h,...d.current()}));const f=m.charCodeAt(0),x=_u(i.before.charCodeAt(i.before.length-1),f,o);x.inside&&(m=$o(f)+m.slice(1));const y=m.charCodeAt(m.length-1),v=_u(i.after.charCodeAt(0),y,o);v.inside&&(m=m.slice(0,-1)+$o(y));const b=d.move(o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},h+m+b}function Rj(e,n,a){return a.options.emphasis||"*"}function zj(e,n){let a=!1;return Mm(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,Qh}),!!((!e.depth||e.depth<3)&&Cm(e)&&(n.options.setext||a))}function _j(e,n,a,i){const o=Math.max(Math.min(6,e.depth||1),1),u=a.createTracker(i);if(zj(e,a)){const x=a.enter("headingSetext"),y=a.enter("phrasing"),v=a.containerPhrasing(e,{...u.current(),before:`
|
|
73
|
+
`,after:`
|
|
74
|
+
`});return y(),x(),v+`
|
|
75
|
+
`+(o===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
|
|
76
|
+
`))+1))}const d="#".repeat(o),h=a.enter("headingAtx"),m=a.enter("phrasing");u.move(d+" ");let f=a.containerPhrasing(e,{before:"# ",after:`
|
|
77
|
+
`,...u.current()});return/^[\t ]/.test(f)&&(f=$o(f.charCodeAt(0))+f.slice(1)),f=f?d+" "+f:d,a.options.closeAtx&&(f+=" "+d),m(),h(),f}pb.peek=Bj;function pb(e){return e.value||""}function Bj(){return"<"}xb.peek=Oj;function xb(e,n,a,i){const o=_m(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let h=a.enter("label");const m=a.createTracker(i);let f=m.move("![");return f+=m.move(a.safe(e.alt,{before:f,after:"]",...m.current()})),f+=m.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=a.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(a.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=a.enter("destinationRaw"),f+=m.move(a.safe(e.url,{before:f,after:e.title?" ":")",...m.current()}))),h(),e.title&&(h=a.enter(`title${u}`),f+=m.move(" "+o),f+=m.move(a.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),f+=m.move(")"),d(),f}function Oj(){return"!"}yb.peek=$j;function yb(e,n,a,i){const o=e.referenceType,u=a.enter("imageReference");let d=a.enter("label");const h=a.createTracker(i);let m=h.move("![");const f=a.safe(e.alt,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const y=a.safe(a.associationId(e),{before:m,after:"]",...h.current()});return d(),a.stack=x,u(),o==="full"||!f||f!==y?m+=h.move(y+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function $j(){return"!"}gb.peek=Lj;function gb(e,n,a){let i=e.value||"",o="`",u=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(i);)o+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++u<a.unsafe.length;){const d=a.unsafe[u],h=a.compilePattern(d);let m;if(d.atBreak)for(;m=h.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 o+i+o}function Lj(){return"`"}function bb(e,n){const a=Cm(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(a===e.url||"mailto:"+a===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}vb.peek=Ij;function vb(e,n,a,i){const o=_m(a),u=o==='"'?"Quote":"Apostrophe",d=a.createTracker(i);let h,m;if(bb(e,a)){const x=a.stack;a.stack=[],h=a.enter("autolink");let y=d.move("<");return y+=d.move(a.containerPhrasing(e,{before:y,after:">",...d.current()})),y+=d.move(">"),h(),a.stack=x,y}h=a.enter("link"),m=a.enter("label");let f=d.move("[");return f+=d.move(a.containerPhrasing(e,{before:f,after:"](",...d.current()})),f+=d.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(a.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(m=a.enter("destinationRaw"),f+=d.move(a.safe(e.url,{before:f,after:e.title?" ":")",...d.current()}))),m(),e.title&&(m=a.enter(`title${u}`),f+=d.move(" "+o),f+=d.move(a.safe(e.title,{before:f,after:o,...d.current()})),f+=d.move(o),m()),f+=d.move(")"),h(),f}function Ij(e,n,a){return bb(e,a)?"<":"["}wb.peek=Hj;function wb(e,n,a,i){const o=e.referenceType,u=a.enter("linkReference");let d=a.enter("label");const h=a.createTracker(i);let m=h.move("[");const f=a.containerPhrasing(e,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const y=a.safe(a.associationId(e),{before:m,after:"]",...h.current()});return d(),a.stack=x,u(),o==="full"||!f||f!==y?m+=h.move(y+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function Hj(){return"["}function Bm(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function Uj(e){const n=Bm(e),a=e.options.bulletOther;if(!a)return n==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+a+"`) to be different");return a}function qj(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function kb(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function Yj(e,n,a,i){const o=a.enter("list"),u=a.bulletCurrent;let d=e.ordered?qj(a):Bm(a);const h=e.ordered?d==="."?")":".":Uj(a);let m=n&&a.bulletLastUsed?d===a.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((d==="*"||d==="-")&&x&&(!x.children||!x.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(m=!0),kb(a)===d&&x){let y=-1;for(;++y<e.children.length;){const v=e.children[y];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(d=h),a.bulletCurrent=d;const f=a.containerFlow(e,i);return a.bulletLastUsed=d,a.bulletCurrent=u,o(),f}function Xj(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function Wj(e,n,a,i){const o=Xj(a);let u=a.bulletCurrent||Bm(a);n&&n.type==="list"&&n.ordered&&(u=(typeof n.start=="number"&&n.start>-1?n.start:1)+(a.options.incrementListMarker===!1?0:n.children.indexOf(e))+u);let d=u.length+1;(o==="tab"||o==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(d=Math.ceil(d/4)*4);const h=a.createTracker(i);h.move(u+" ".repeat(d-u.length)),h.shift(d);const m=a.enter("listItem"),f=a.indentLines(a.containerFlow(e,h.current()),x);return m(),f;function x(y,v,b){return v?(b?"":" ".repeat(d))+y:(b?u:u+" ".repeat(d-u.length))+y}}function Gj(e,n,a,i){const o=a.enter("paragraph"),u=a.enter("phrasing"),d=a.containerPhrasing(e,i);return u(),o(),d}const Vj=Vu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Kj(e,n,a,i){return(e.children.some(function(d){return Vj(d)})?a.containerPhrasing:a.containerFlow).call(a,e,i)}function Qj(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}jb.peek=Pj;function jb(e,n,a,i){const o=Qj(a),u=a.enter("strong"),d=a.createTracker(i),h=d.move(o+o);let m=d.move(a.containerPhrasing(e,{after:o,before:h,...d.current()}));const f=m.charCodeAt(0),x=_u(i.before.charCodeAt(i.before.length-1),f,o);x.inside&&(m=$o(f)+m.slice(1));const y=m.charCodeAt(m.length-1),v=_u(i.after.charCodeAt(0),y,o);v.inside&&(m=m.slice(0,-1)+$o(y));const b=d.move(o+o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},h+m+b}function Pj(e,n,a){return a.options.strong||"*"}function Zj(e,n,a,i){return a.safe(e.value,i)}function Jj(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function eS(e,n,a){const i=(kb(a)+(a.options.ruleSpaces?" ":"")).repeat(Jj(a));return a.options.ruleSpaces?i.slice(0,-1):i}const Sb={blockquote:jj,break:by,code:Dj,definition:Fj,emphasis:mb,hardBreak:by,heading:_j,html:pb,image:xb,imageReference:yb,inlineCode:gb,link:vb,linkReference:wb,list:Yj,listItem:Wj,paragraph:Gj,root:Kj,strong:jb,text:Zj,thematicBreak:eS};function tS(){return{enter:{table:nS,tableData:vy,tableHeader:vy,tableRow:aS},exit:{codeText:lS,table:rS,tableData:bh,tableHeader:bh,tableRow:bh}}}function nS(e){const n=e._align;this.enter({type:"table",align:n.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function rS(e){this.exit(e),this.data.inTable=void 0}function aS(e){this.enter({type:"tableRow",children:[]},e)}function bh(e){this.exit(e)}function vy(e){this.enter({type:"tableCell",children:[]},e)}function lS(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,iS));const a=this.stack[this.stack.length-1];a.type,a.value=n,this.exit(e)}function iS(e,n){return n==="|"?n:e}function sS(e){const n=e||{},a=n.tableCellPadding,i=n.tablePipeAlign,o=n.stringLength,u=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
78
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:d,tableCell:m,tableRow:h}};function d(b,j,k,N){return f(x(b,k,N),b.align)}function h(b,j,k,N){const C=y(b,k,N),E=f([C]);return E.slice(0,E.indexOf(`
|
|
79
|
+
`))}function m(b,j,k,N){const C=k.enter("tableCell"),E=k.enter("phrasing"),R=k.containerPhrasing(b,{...N,before:u,after:u});return E(),C(),R}function f(b,j){return wj(b,{align:j,alignDelimiters:i,padding:a,stringLength:o})}function x(b,j,k){const N=b.children;let C=-1;const E=[],R=j.enter("table");for(;++C<N.length;)E[C]=y(N[C],j,k);return R(),E}function y(b,j,k){const N=b.children;let C=-1;const E=[],R=j.enter("tableRow");for(;++C<N.length;)E[C]=m(N[C],b,j,k);return R(),E}function v(b,j,k){let N=Sb.inlineCode(b,j,k);return k.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function oS(){return{exit:{taskListCheckValueChecked:wy,taskListCheckValueUnchecked:wy,paragraph:uS}}}function cS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dS}}}function wy(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function uS(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const o=n.children;let u=-1,d;for(;++u<o.length;){const h=o[u];if(h.type==="paragraph"){d=h;break}}d===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function dS(e,n,a,i){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",h=a.createTracker(i);u&&h.move(d);let m=Sb.listItem(e,n,a,{...i,...h.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),m;function f(x){return x+d}}function fS(){return[Y4(),dj(),pj(),tS(),oS()]}function hS(e){return{extensions:[X4(),fj(e),xj(),sS(e),cS()]}}const mS={tokenize:vS,partial:!0},Cb={tokenize:wS,partial:!0},Nb={tokenize:kS,partial:!0},Eb={tokenize:jS,partial:!0},pS={tokenize:SS,partial:!0},Ab={name:"wwwAutolink",tokenize:gS,previous:Tb},Db={name:"protocolAutolink",tokenize:bS,previous:Fb},tl={name:"emailAutolink",tokenize:yS,previous:Mb},Ca={};function xS(){return{text:Ca}}let fi=48;for(;fi<123;)Ca[fi]=tl,fi++,fi===58?fi=65:fi===91&&(fi=97);Ca[43]=tl;Ca[45]=tl;Ca[46]=tl;Ca[95]=tl;Ca[72]=[tl,Db];Ca[104]=[tl,Db];Ca[87]=[tl,Ab];Ca[119]=[tl,Ab];function yS(e,n,a){const i=this;let o,u;return d;function d(y){return!em(y)||!Mb.call(i,i.previous)||Om(i.events)?a(y):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(y))}function h(y){return em(y)?(e.consume(y),h):y===64?(e.consume(y),m):a(y)}function m(y){return y===46?e.check(pS,x,f)(y):y===45||y===95||Jn(y)?(u=!0,e.consume(y),m):x(y)}function f(y){return e.consume(y),o=!0,m}function x(y){return u&&o&&rr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(y)):a(y)}}function gS(e,n,a){const i=this;return o;function o(d){return d!==87&&d!==119||!Tb.call(i,i.previous)||Om(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mS,e.attempt(Cb,e.attempt(Nb,u),a),a)(d))}function u(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(d)}}function bS(e,n,a){const i=this;let o="",u=!1;return d;function d(y){return(y===72||y===104)&&Fb.call(i,i.previous)&&!Om(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(y),e.consume(y),h):a(y)}function h(y){if(rr(y)&&o.length<5)return o+=String.fromCodePoint(y),e.consume(y),h;if(y===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(y),m}return a(y)}function m(y){return y===47?(e.consume(y),u?f:(u=!0,m)):a(y)}function f(y){return y===null||Mu(y)||ln(y)||ki(y)||Xu(y)?a(y):e.attempt(Cb,e.attempt(Nb,x),a)(y)}function x(y){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(y)}}function vS(e,n,a){let i=0;return o;function o(d){return(d===87||d===119)&&i<3?(i++,e.consume(d),o):d===46&&i===3?(e.consume(d),u):a(d)}function u(d){return d===null?a(d):n(d)}}function wS(e,n,a){let i,o,u;return d;function d(f){return f===46||f===95?e.check(Eb,m,h)(f):f===null||ln(f)||ki(f)||f!==45&&Xu(f)?m(f):(u=!0,e.consume(f),d)}function h(f){return f===95?i=!0:(o=i,i=void 0),e.consume(f),d}function m(f){return o||i||!u?a(f):n(f)}}function kS(e,n){let a=0,i=0;return o;function o(d){return d===40?(a++,e.consume(d),o):d===41&&i<a?u(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?e.check(Eb,n,u)(d):d===null||ln(d)||ki(d)?n(d):(e.consume(d),o)}function u(d){return d===41&&i++,e.consume(d),o}}function jS(e,n,a){return i;function i(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(e.consume(h),i):h===38?(e.consume(h),u):h===93?(e.consume(h),o):h===60||h===null||ln(h)||ki(h)?n(h):a(h)}function o(h){return h===null||h===40||h===91||ln(h)||ki(h)?n(h):i(h)}function u(h){return rr(h)?d(h):a(h)}function d(h){return h===59?(e.consume(h),i):rr(h)?(e.consume(h),d):a(h)}}function SS(e,n,a){return i;function i(u){return e.consume(u),o}function o(u){return Jn(u)?a(u):n(u)}}function Tb(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ln(e)}function Fb(e){return!rr(e)}function Mb(e){return!(e===47||em(e))}function em(e){return e===43||e===45||e===46||e===95||Jn(e)}function Om(e){let n=e.length,a=!1;for(;n--;){const i=e[n][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){a=!0;break}if(i._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const CS={tokenize:RS,partial:!0};function NS(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:TS,continuation:{tokenize:FS},exit:MS}},text:{91:{name:"gfmFootnoteCall",tokenize:DS},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ES,resolveTo:AS}}}}function ES(e,n,a){const i=this;let o=i.events.length;const u=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d;for(;o--;){const m=i.events[o][1];if(m.type==="labelImage"){d=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return h;function h(m){if(!d||!d._balanced)return a(m);const f=la(i.sliceSerialize({start:d.end,end:i.now()}));return f.codePointAt(0)!==94||!u.includes(f.slice(1))?a(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function AS(e,n){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},h=[e[a+1],e[a+2],["enter",i,n],e[a+3],e[a+4],["enter",o,n],["exit",o,n],["enter",u,n],["enter",d,n],["exit",d,n],["exit",u,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(a,e.length-a+1,...h),e}function DS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return h;function h(y){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(y),e.exit("gfmFootnoteCallLabelMarker"),m}function m(y){return y!==94?a(y):(e.enter("gfmFootnoteCallMarker"),e.consume(y),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(y){if(u>999||y===93&&!d||y===null||y===91||ln(y))return a(y);if(y===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(la(i.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(y),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):a(y)}return ln(y)||(d=!0),u++,e.consume(y),y===92?x:f}function x(y){return y===91||y===92||y===93?(e.consume(y),u++,f):f(y)}}function TS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,h;return m;function m(j){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(j){return j===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):a(j)}function x(j){if(d>999||j===93&&!h||j===null||j===91||ln(j))return a(j);if(j===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return u=la(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return ln(j)||(h=!0),d++,e.consume(j),j===92?y:x}function y(j){return j===91||j===92||j===93?(e.consume(j),d++,x):x(j)}function v(j){return j===58?(e.enter("definitionMarker"),e.consume(j),e.exit("definitionMarker"),o.includes(u)||o.push(u),Bt(e,b,"gfmFootnoteDefinitionWhitespace")):a(j)}function b(j){return n(j)}}function FS(e,n,a){return e.check(qo,n,e.attempt(CS,n,a))}function MS(e){e.exit("gfmFootnoteDefinition")}function RS(e,n,a){const i=this;return Bt(e,o,"gfmFootnoteDefinitionIndent",5);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?n(u):a(u)}}function zS(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:u,resolveAll:o};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(d,h){let m=-1;for(;++m<d.length;)if(d[m][0]==="enter"&&d[m][1].type==="strikethroughSequenceTemporary"&&d[m][1]._close){let f=m;for(;f--;)if(d[f][0]==="exit"&&d[f][1].type==="strikethroughSequenceTemporary"&&d[f][1]._open&&d[m][1].end.offset-d[m][1].start.offset===d[f][1].end.offset-d[f][1].start.offset){d[m][1].type="strikethroughSequence",d[f][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},d[f][1].start),end:Object.assign({},d[m][1].end)},y={type:"strikethroughText",start:Object.assign({},d[f][1].end),end:Object.assign({},d[m][1].start)},v=[["enter",x,h],["enter",d[f][1],h],["exit",d[f][1],h],["enter",y,h]],b=h.parser.constructs.insideSpan.null;b&&Tr(v,v.length,0,Wu(b,d.slice(f+1,m),h)),Tr(v,v.length,0,[["exit",y,h],["enter",d[m][1],h],["exit",d[m][1],h],["exit",x,h]]),Tr(d,f-1,m-f+3,v),m=f+v.length-2;break}}for(m=-1;++m<d.length;)d[m][1].type==="strikethroughSequenceTemporary"&&(d[m][1].type="data");return d}function u(d,h,m){const f=this.previous,x=this.events;let y=0;return v;function v(j){return f===126&&x[x.length-1][1].type!=="characterEscape"?m(j):(d.enter("strikethroughSequenceTemporary"),b(j))}function b(j){const k=ys(f);if(j===126)return y>1?m(j):(d.consume(j),y++,b);if(y<2&&!a)return m(j);const N=d.exit("strikethroughSequenceTemporary"),C=ys(j);return N._open=!C||C===2&&!!k,N._close=!k||k===2&&!!C,h(j)}}}class _S{constructor(){this.map=[]}add(n,a,i){BS(this,n,a,i)}consume(n){if(this.map.sort(function(u,d){return u[0]-d[0]}),this.map.length===0)return;let a=this.map.length;const i=[];for(;a>0;)a-=1,i.push(n.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),n.length=this.map[a][0];i.push(n.slice()),n.length=0;let o=i.pop();for(;o;){for(const u of o)n.push(u);o=i.pop()}this.map.length=0}}function BS(e,n,a,i){let o=0;if(!(a===0&&i.length===0)){for(;o<e.map.length;){if(e.map[o][0]===n){e.map[o][1]+=a,e.map[o][2].push(...i);return}o+=1}e.map.push([n,a,i])}}function OS(e,n){let a=!1;const i=[];for(;n<e.length;){const o=e[n];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&i.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const u=i.length-1;i[u]=i[u]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);n+=1}return i}function $S(){return{flow:{null:{name:"table",tokenize:LS,resolveAll:IS}}}}function LS(e,n,a){const i=this;let o=0,u=0,d;return h;function h(A){let $=i.events.length-1;for(;$>-1;){const oe=i.events[$][1].type;if(oe==="lineEnding"||oe==="linePrefix")$--;else break}const U=$>-1?i.events[$][1].type:null,ee=U==="tableHead"||U==="tableRow"?B:m;return ee===B&&i.parser.lazy[i.now().line]?a(A):ee(A)}function m(A){return e.enter("tableHead"),e.enter("tableRow"),f(A)}function f(A){return A===124||(d=!0,u+=1),x(A)}function x(A){return A===null?a(A):at(A)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),b):a(A):At(A)?Bt(e,x,"whitespace")(A):(u+=1,d&&(d=!1,o+=1),A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),y(A)))}function y(A){return A===null||A===124||ln(A)?(e.exit("data"),x(A)):(e.consume(A),A===92?v:y)}function v(A){return A===92||A===124?(e.consume(A),y):y(A)}function b(A){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(A):(e.enter("tableDelimiterRow"),d=!1,At(A)?Bt(e,j,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):j(A))}function j(A){return A===45||A===58?N(A):A===124?(d=!0,e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),k):I(A)}function k(A){return At(A)?Bt(e,N,"whitespace")(A):N(A)}function N(A){return A===58?(u+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),C):A===45?(u+=1,C(A)):A===null||at(A)?M(A):I(A)}function C(A){return A===45?(e.enter("tableDelimiterFiller"),E(A)):I(A)}function E(A){return A===45?(e.consume(A),E):A===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),R):(e.exit("tableDelimiterFiller"),R(A))}function R(A){return At(A)?Bt(e,M,"whitespace")(A):M(A)}function M(A){return A===124?j(A):A===null||at(A)?!d||o!==u?I(A):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(A)):I(A)}function I(A){return a(A)}function B(A){return e.enter("tableRow"),L(A)}function L(A){return A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),L):A===null||at(A)?(e.exit("tableRow"),n(A)):At(A)?Bt(e,L,"whitespace")(A):(e.enter("data"),H(A))}function H(A){return A===null||A===124||ln(A)?(e.exit("data"),L(A)):(e.consume(A),A===92?Q:H)}function Q(A){return A===92||A===124?(e.consume(A),H):H(A)}}function IS(e,n){let a=-1,i=!0,o=0,u=[0,0,0,0],d=[0,0,0,0],h=!1,m=0,f,x,y;const v=new _S;for(;++a<e.length;){const b=e[a],j=b[1];b[0]==="enter"?j.type==="tableHead"?(h=!1,m!==0&&(ky(v,n,m,f,x),x=void 0,m=0),f={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(a,0,[["enter",f,n]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(i=!0,y=void 0,u=[0,0,0,0],d=[0,a+1,0,0],h&&(h=!1,x={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(a,0,[["enter",x,n]])),o=j.type==="tableDelimiterRow"?2:x?3:1):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(i=!1,d[2]===0&&(u[1]!==0&&(d[0]=d[1],y=fu(v,n,u,o,void 0,y),u=[0,0,0,0]),d[2]=a)):j.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],y=fu(v,n,u,o,void 0,y)),u=d,d=[u[1],a,0,0])):j.type==="tableHead"?(h=!0,m=a):j.type==="tableRow"||j.type==="tableDelimiterRow"?(m=a,u[1]!==0?(d[0]=d[1],y=fu(v,n,u,o,a,y)):d[1]!==0&&(y=fu(v,n,d,o,a,y)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(d[3]=a)}for(m!==0&&ky(v,n,m,f,x),v.consume(n.events),a=-1;++a<n.events.length;){const b=n.events[a];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=OS(n.events,a))}return e}function fu(e,n,a,i,o,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",h="tableContent";a[0]!==0&&(u.end=Object.assign({},hs(n.events,a[0])),e.add(a[0],0,[["exit",u,n]]));const m=hs(n.events,a[1]);if(u={type:d,start:Object.assign({},m),end:Object.assign({},m)},e.add(a[1],0,[["enter",u,n]]),a[2]!==0){const f=hs(n.events,a[2]),x=hs(n.events,a[3]),y={type:h,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(a[2],0,[["enter",y,n]]),i!==2){const v=n.events[a[2]],b=n.events[a[3]];if(v[1].end=Object.assign({},b[1].end),v[1].type="chunkText",v[1].contentType="text",a[3]>a[2]+1){const j=a[2]+1,k=a[3]-a[2]-1;e.add(j,k,[])}}e.add(a[3]+1,0,[["exit",y,n]])}return o!==void 0&&(u.end=Object.assign({},hs(n.events,o)),e.add(o,0,[["exit",u,n]]),u=void 0),u}function ky(e,n,a,i,o){const u=[],d=hs(n.events,a);o&&(o.end=Object.assign({},d),u.push(["exit",o,n])),i.end=Object.assign({},d),u.push(["exit",i,n]),e.add(a+1,0,u)}function hs(e,n){const a=e[n],i=a[0]==="enter"?"start":"end";return a[1][i]}const HS={name:"tasklistCheck",tokenize:qS};function US(){return{text:{91:HS}}}function qS(e,n,a){const i=this;return o;function o(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?a(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),u)}function u(m){return ln(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),d):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),d):a(m)}function d(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),h):a(m)}function h(m){return at(m)?n(m):At(m)?e.check({tokenize:YS},n,a)(m):a(m)}}function YS(e,n,a){return Bt(e,i,"whitespace");function i(o){return o===null?a(o):n(o)}}function XS(e){return qg([xS(),NS(),zS(e),$S(),US()])}const WS={};function $m(e){const n=this,a=e||WS,i=n.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(XS(a)),u.push(fS()),d.push(hS(a))}function js({content:e,className:n=""}){return l.jsx("div",{className:`office-markdown ${n}`,children:l.jsx(zm,{remarkPlugins:[$m],components:{code:GS,table:({children:a})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:a})})},children:e})})}function GS({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
80
|
+
`)?l.jsx(VS,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"bg-gray-100 text-gray-700 px-1 py-0.5 rounded text-[0.9em] font-mono",...a,children:n})}function VS({children:e,language:n}){const[a,i]=w.useState(!1),o=String(e).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"office-code-block group relative my-2",children:[n&&l.jsx("div",{className:"text-[10px] text-gray-400 px-3 pt-1.5",children:n}),l.jsx("button",{onClick:u,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:a?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:o})})]})}const jy={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},KS=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function QS(e,n){const a=parseInt(e.replace("#",""),16),i=Math.max(0,(a>>16&255)-n),o=Math.max(0,(a>>8&255)-n),u=Math.max(0,(a&255)-n);return`#${(i<<16|o<<8|u).toString(16).padStart(6,"0")}`}function PS(e,n){const a=parseInt(e.replace("#",""),16),i=Math.min(255,(a>>16&255)+n),o=Math.min(255,(a>>8&255)+n),u=Math.min(255,(a&255)+n);return`#${(i<<16|o<<8|u).toString(16).padStart(6,"0")}`}function Rb(e,n){const a=jy[e];if(a&&n)return n[a];const i=KS.exec(e);if(i){const[,o,u,d]=i,h=jy[u],m=h&&n?n[h]:u,f=parseInt(d,10);return o==="darken"?QS(m,f):PS(m,f)}return e}function tm(e,n=12){return e.map(a=>({...a,x:n-a.x-a.w}))}function ZS(e,n){return n==="down"?e.down:n==="up"&&e.up?e.up:n==="left"&&e.left?e.left:n==="right"&&e.right?e.right:n==="right"&&e.left?{name:e.left.name,pixels:tm(e.left.pixels)}:n==="left"&&e.right?{name:e.right.name,pixels:tm(e.right.pixels)}:e.down}function JS(e,n){return nm(e,"hair",n,1)}function nm(e,n,a,i){const o=e.layers.findIndex(d=>d.name===n),u=[...e.layers];if(o>=0)u[o]={...a,name:n};else{const d=i??u.length;u.splice(d,0,{...a,name:n})}return{...e,layers:u}}const Lm=new Map,Im=new Map;function zb(e,n){Lm.set(e,n)}function Qu(e,n){Im.set(e,n)}function rm(e){return Lm.get(e)}function E8(e){return Im.get(e)}function A8(){return Array.from(Lm.keys())}function D8(){return Array.from(Im.keys())}function eC(e,n,a,i,o=2){e.clearRect(0,0,n.width*o,n.height*o);for(const u of n.layers)_b(e,u.pixels,o,a,i)}function Bl(e,n,a,i,o){for(const u of n){const d=Rb(u.c,o);u.a!==void 0&&u.a!==1&&(e.globalAlpha=u.a),e.fillStyle=d,e.fillRect(a+u.x,i+u.y,u.w,u.h),u.a!==void 0&&u.a!==1&&(e.globalAlpha=1)}}function T8(e,n){const a=n.scale;e.clearRect(0,0,n.canvasWidth,n.canvasHeight),_b(e,n.pixels,a,0)}function _b(e,n,a,i,o){for(const u of n){const d=Rb(u.c,o);u.a!==void 0&&u.a!==1&&(e.globalAlpha=u.a),e.fillStyle=d,e.fillRect(u.x*a,(u.y+i)*a,u.w*a,u.h*a),u.a!==void 0&&u.a!==1&&(e.globalAlpha=1)}}const Bu=new Map;function Il(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Bu.set(e,{id:e,name:n,layer:{...o.down,name:"hair"},directions:{down:{...o.down,name:"hair"},up:o.up?{...o.up,name:"hair"}:void 0,left:o.left?{...o.left,name:"hair"}:void 0,right:o.right?{...o.right,name:"hair"}:void 0}})}else{const o=a;Bu.set(e,{id:e,name:n,layer:{...o,name:"hair"}})}}function tC(e){return Bu.get(e)}function Bb(){return Array.from(Bu.values())}Il("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}]}});Il("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}]}});Il("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}]}});Il("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}]}});Il("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"}]}});Il("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}]}});Il("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}]}});Il("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}]}});const Ou=new Map;function Na(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Ou.set(e,{id:e,name:n,layer:{...o.down,name:"torso"},directions:{down:{...o.down,name:"torso"},up:o.up?{...o.up,name:"torso"}:void 0,left:o.left?{...o.left,name:"torso"}:void 0,right:o.right?{...o.right,name:"torso"}:void 0}})}else{const o=a;Ou.set(e,{id:e,name:n,layer:{...o,name:"torso"}})}}function nC(e){return Ou.get(e)}function Ob(){return Array.from(Ou.values())}Na("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"}]}});Na("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"}]}});Na("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"}]}});Na("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)"}]}});Na("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)"}]}});Na("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"}]}});Na("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"}]}});Na("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"}]}});Na("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"}]}});Na("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"}]}});const Lo=new Map;function Wt(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Lo.set(e,{id:e,name:n,layer:{...o.down,name:"accessory"},directions:{down:{...o.down,name:"accessory"},up:o.up?{...o.up,name:"accessory"}:void 0,left:o.left?{...o.left,name:"accessory"}:void 0,right:o.right?{...o.right,name:"accessory"}:void 0}})}else{const o=a;Lo.set(e,{id:e,name:n,layer:{...o,name:"accessory"}})}}function rC(e){return Lo.get(e)}function aC(e,n){const a=Lo.get(e);if(!a)return;if(a.directions)return ZS(a.directions,n);if(n==="down")return a.layer;const i=a.layer.pixels.filter(u=>u.y<2);if(i.length===0)return;const o=n==="right"?1:n==="left"?-1:0;return{name:a.layer.name,pixels:o?i.map(u=>({...u,x:u.x+o})):i}}function $b(){return Array.from(Lo.values())}Wt("none","None",{name:"accessory",pixels:[]});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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"}]}});Wt("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}]}});Wt("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}]}});Wt("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"}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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"}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});Wt("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"}]}});Wt("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"}]}});Wt("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}]}});Wt("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}]}});Wt("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}]}});const lC={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 Lb(e){return lC[e]??1}function Ib(e,n){return n>=Lb(e)}Wt("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 Co({r:e,g:n,b:a}){return`#${(e<<16|n<<8|a).toString(16).padStart(6,"0")}`}function Eu(e,n){const a=e.r-n.r,i=e.g-n.g,o=e.b-n.b;return a*a+i*i+o*o}function iC(e,n){const a=[];a.push(e[Math.floor(Math.random()*e.length)]);for(let i=1;i<n;i++){const o=e.map(h=>{let m=1/0;for(const f of a)m=Math.min(m,Eu(h,f));return m}),u=o.reduce((h,m)=>h+m,0);let d=Math.random()*u;for(let h=0;h<e.length;h++)if(d-=o[h],d<=0){a.push(e[h]);break}a.length<=i&&a.push(e[Math.floor(Math.random()*e.length)])}return a}function sC(e,n,a=20){if(e.length===0)return[];const i=iC(e,n);for(let u=0;u<a;u++){const d=Array.from({length:n},()=>[]);for(const m of e){let f=1/0,x=0;for(let y=0;y<n;y++){const v=Eu(m,i[y]);v<f&&(f=v,x=y)}d[x].push(m)}let h=!0;for(let m=0;m<n;m++){if(d[m].length===0)continue;const f={r:0,g:0,b:0};for(const v of d[m])f.r+=v.r,f.g+=v.g,f.b+=v.b;const x=d[m].length,y={r:Math.round(f.r/x),g:Math.round(f.g/x),b:Math.round(f.b/x)};Eu(y,i[m])>1&&(h=!1),i[m]=y}if(h)break}const o=new Array(n).fill(0);for(const u of e){let d=1/0,h=0;for(let m=0;m<n;m++){const f=Eu(u,i[m]);f<d&&(d=f,h=m)}o[h]++}return i.map((u,d)=>({c:u,count:o[d]})).sort((u,d)=>d.count-u.count).map(u=>u.c)}function oC(e,n=1e4){const a=document.createElement("canvas"),i=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height;a.width=i,a.height=o;const u=a.getContext("2d");u.drawImage(e,0,0);const d=u.getImageData(0,0,i,o).data,h=i*o,m=Math.max(1,Math.floor(h/n)),f=[];for(let x=0;x<h;x+=m){const y=x*4;d[y+3]<128||f.push({r:d[y],g:d[y+1],b:d[y+2]})}return f}function Sy(e){return .299*e.r+.587*e.g+.114*e.b}function Cy(e){const n=Math.max(e.r,e.g,e.b),a=Math.min(e.r,e.g,e.b);return n===0?0:(n-a)/n*255}function cC(e,n=8){const a=oC(e),i=sC(a,n);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const o=[...i].sort((y,v)=>Sy(v)-Sy(y)),u=[...i].sort((y,v)=>Cy(v)-Cy(y)),d=o[0],h=o[o.length-1],m=u[0],f=o[o.length-2],x=o[o.length-1];return{skinColor:Co(d),hairColor:Co(h),shirtColor:Co(m),pantsColor:Co(f),shoeColor:Co(x)}}const uC=[{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}],dC=[{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"}],fC=[{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"}],hC=[{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 mC(){return{width:12,height:22,layers:[{name:"lower",pixels:uC},{name:"torso",pixels:dC},{name:"head",pixels:fC},{name:"hair",pixels:hC},{name:"accessory",pixels:[]}]}}const pC=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const e of pC)zb(`mini:${e}`,mC());const xC=[{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"}],yC=[{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"}],gC=[{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 bC(){return{width:12,height:22,layers:[{name:"torso",pixels:xC},{name:"head",pixels:yC},{name:"hair",pixels:gC},{name:"accessory",pixels:[]}]}}zb("mini-seated:default",bC());const vC={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"}]},wC={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"}]},kC={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"}]},jC={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"}]};Qu("meeting",vC);Qu("bulletin",wC);Qu("decision",jC);Qu("knowledge",kC);const vh=16,wh=24,SC=60,CC={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function Hb(e,n){if(!e)return e;let a=e;if(n!=null&&n.hairStyle){const i=tC(n.hairStyle);i&&(a=JS(a,i.layer))}if(n!=null&&n.outfitStyle){const i=nC(n.outfitStyle);i&&(a=nm(a,"torso",i.layer,1))}if(n!=null&&n.accessory&&n.accessory!=="none"){const i=rC(n.accessory);i&&(a=nm(a,"accessory",i.layer))}return a}function $l({roleId:e,className:n,appearance:a,scale:i}){const o=w.useRef(null),u=w.useRef(0),d=w.useRef(0),h=w.useRef(a);h.current=a;const m=i??4,f=vh*m,x=wh*m,y=w.useMemo(()=>{const v=rm(`mini:${e}`)??rm("mini:default");return Hb(v,a)},[e,a==null?void 0:a.hairStyle,a==null?void 0:a.outfitStyle,a==null?void 0:a.accessory]);return w.useEffect(()=>{const v=o.current;if(!v)return;const b=v.getContext("2d");if(!b)return;const j=CC[e]??0,k=()=>{d.current++;const N=h.current;if(!N||!y){u.current=requestAnimationFrame(k);return}const E=(d.current+j)%SC<30?1:0;b.clearRect(0,0,vh,wh),b.save(),b.translate(2,1),eC(b,y,E,N,1),b.restore(),u.current=requestAnimationFrame(k)};return u.current=requestAnimationFrame(k),()=>cancelAnimationFrame(u.current)},[e,y]),l.jsx("canvas",{ref:o,width:vh,height:wh,className:n,style:{imageRendering:"pixelated",display:"block",width:f,height:x}})}const NC="https://api.tycono.ai",Hm=NC;async function No(e){const n=await fetch(`${Hm}${e}`);if(!n.ok)throw new Error(`Cloud API error: ${n.status}`);return n.json()}async function hi(e,n){const a=await fetch(`${Hm}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Cloud API error: ${a.status}`);return a.json()}const pr={health:()=>No("/api/health"),getMyName:e=>No(`/api/auth/my-name?instance_id=${encodeURIComponent(e)}`),getCharacters:e=>{const n=new URLSearchParams;e!=null&&e.sort&&n.set("sort",e.sort),e!=null&&e.instanceId&&n.set("instance_id",e.instanceId);const a=n.toString();return No(`/api/store/characters${a?`?${a}`:""}`)},getCharacter:e=>No(`/api/store/characters/${e}`),getCharacterVersion:e=>No(`/api/store/characters/${e}/version`),voteCharacter:(e,n,a)=>hi(`/api/store/characters/${e}/vote`,{instanceId:n,vote:a}),trackInstall:e=>hi(`/api/store/characters/${e}/install`,{}),syncCheck:e=>hi("/api/sync/check",{roles:e}),syncPull:e=>hi("/api/sync/pull",{sourceId:e}),publishCharacter:e=>hi("/api/store/publish",e),deleteCharacter:(e,n)=>{const a=n?`?publisher_id=${encodeURIComponent(n)}`:"";return fetch(`${Hm}/api/store/characters/${e}${a}`,{method:"DELETE"}).then(i=>i.json())},uploadTelemetry:e=>hi("/api/telemetry",e),syncStats:e=>hi("/api/stats/sync",e)},EC={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},kh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},AC={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},DC=500,Ny=360,Ey=700,TC=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function Ay({role:e,allRoles:n,recentActivity:a,onClose:i,onFireRole:o,terminalWidth:u=0,activeJobId:d,activeSessionId:h,activeTask:m,isWorking:f,jobStartedAt:x,onStopJob:y,sessions:v,streamingSessionId:b,onCreateSessionSilent:j,onSendMessage:k,onFocusTerminal:N,onCustomize:C,onUpdateRole:E,appearance:R,relationships:M,roleLevel:I,onMaximize:B}){var Ke,jt;const[L,H]=w.useState(DC),[Q,A]=w.useState(!1),$=w.useRef(0),U=w.useRef(0),[ee,oe]=w.useState(!1),[ne,Y]=w.useState(!1),[ue,J]=w.useState(!1),[K,D]=w.useState(!1),[F,q]=w.useState("talk"),[T,de]=w.useState(!1),[Ne,ye]=w.useState(""),[_e,Pe]=w.useState(!1),Ve=w.useRef(null),[lt,dt]=w.useState(!1),[Ce,We]=w.useState(""),[Te,xt]=w.useState(!1),{events:ut,status:mt}=Ag(h??null),[wt,qt]=w.useState(0);w.useEffect(()=>{if(!f||!x){qt(0);return}const ze=new Date(x).getTime(),He=()=>qt(Math.floor((Date.now()-ze)/1e3));He();const Lt=setInterval(He,1e3);return()=>clearInterval(Lt)},[f,x]);const $t=u>0,Ct=$t?u:0,Bn=$t?Math.max(Ny,window.innerWidth-u-100):Ey,he=Math.min(L,Bn),ve=w.useCallback(ze=>{ze.preventDefault(),$.current=ze.clientX,U.current=he,A(!0);const He=B,Lt=()=>{A(!1),document.removeEventListener("mousemove",Dt),document.removeEventListener("mouseup",Lt)},Dt=Rt=>{const sn=$.current-Rt.clientX,pn=U.current+sn;if(pn>=window.innerWidth*.6&&He){Lt(),He();return}const P=Math.min(Ey,Math.max(Ny,pn));H(P)};document.addEventListener("mousemove",Dt),document.addEventListener("mouseup",Lt)},[he,B]),ce=w.useRef(null),W=e?v.find(ze=>ze.roleId===e.id):null,le=ze=>{if(!e)return;const He=f?"talk":F;W?(k(W.id,ze,He),N(e.id)):(ce.current={content:ze,mode:He},j(e.id))};w.useEffect(()=>{if(W&&ce.current){const{content:ze,mode:He}=ce.current;ce.current=null,k(W.id,ze,He),e&&N(e.id)}},[W==null?void 0:W.id]);const we=(()=>{if(!ut.length)return null;const ze=[];let He=0,Lt=0,Dt=0;for(const Rt of ut)if(Rt.type==="thinking")He++;else if(Rt.type==="text")Lt++;else if(Rt.type==="tool:start"){const sn=String(Rt.data.name??"");ze.includes(sn)||ze.push(sn)}else Rt.type==="dispatch:start"&&Dt++;return{tools:ze,thinkCount:He,textCount:Lt,dispatchCount:Dt,total:ut.length}})(),xe=m||(()=>{if(!W)return null;const ze=W.messages;for(let He=ze.length-1;He>=0;He--)if(ze[He].from==="ceo")return ze[He].content;return null})(),je=(()=>{if(!W)return null;const ze=W.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:Ct},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:Ct,width:he,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 Re=kh[e.id]??"#666",$e=EC[e.id]??"👤",Oe=n.filter(ze=>ze.reportsTo===e.id),Le=W&&b===W.id,tt=e.name||AC[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:Ct},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:Re,right:Ct,width:he,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:ve}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Re}ee, ${Re}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:"🎨"}),B&&l.jsx("button",{onClick:B,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($l,{roleId:e.id,appearance:R,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:[$e," ",e.id.toUpperCase(),f&&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"})]}),T?l.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async ze=>{ze.preventDefault();const He=Ne.trim();if(!He||He===tt||!E){de(!1);return}Pe(!0);try{await E(e.id,{name:He})}catch{}Pe(!1),de(!1)},children:[l.jsx("input",{ref:Ve,value:Ne,onChange:ze=>ye(ze.target.value),onKeyDown:ze=>{ze.key==="Escape"&&de(!1)},disabled:_e,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:_e,className:"text-white/80 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✓"}),l.jsx("button",{type:"button",onClick:()=>de(!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:()=>{E&&(ye(tt),de(!0))},title:E?"Click to edit name":void 0,children:[tt,E&&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.",I??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:f?"var(--idle-amber)":"var(--active-green)"}}),f?"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:[f&&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",wt>0?` · ${TC(wt)}`:""]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>N(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"}),d&&y&&l.jsx("button",{onClick:()=>y(d),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"})]})]}),xe&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:xe})]}),f&&d&&we&&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:()=>N(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:[we.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 ×",we.thinkCount]}),we.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)),we.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 ×",we.dispatchCount]}),we.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 ×",we.textCount]}),(mt==="streaming"||mt==="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:[we.total," events"]})]}),f&&je&&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:()=>N(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:[je.slice(0,200),je.length>200&&"..."]})]}),f&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(Dy,{onSend:le,disabled:!!Le,placeholder:"Ask something...",color:Re})}),!f&&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(MC,{icon:$e,roleId:e.id,roleName:tt,color:Re,text:a})]}),!f&&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:[je&&l.jsxs("div",{className:"px-3 pt-2.5 pb-2 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--terminal-border)"},onClick:()=>N(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:[je.slice(0,150),je.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:()=>q("talk"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:F==="talk"?"var(--accent)":"transparent",color:F==="talk"?"#fff":"var(--terminal-text-secondary)"},children:"Talk"}),l.jsx("button",{onClick:()=>q("do"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:F==="do"?"var(--idle-amber)":"transparent",color:F==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),l.jsx(Dy,{onSend:le,disabled:!!Le,placeholder:F==="talk"?"Ask something...":"Give a directive...",color:Re})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(hu,{title:`Profile${e.persona?"":" (empty)"}`,open:ee,onToggle:()=>oe(ze=>!ze),children:[lt?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:Ce,onChange:ze=>We(ze.target.value),onKeyDown:ze=>{ze.key==="Escape"&&dt(!1)},disabled:Te,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:()=>dt(!1),disabled:Te,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(E){xt(!0);try{await E(e.id,{persona:Ce.trim()})}catch{}xt(!1),dt(!1)}},disabled:Te,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold",style:{background:"var(--active-green)",color:"#000"},children:Te?"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:()=>{E&&(We(e.persona||""),dt(!0))},title:E?"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."}),E&&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(jh,{label:"Level",value:e.level}),l.jsx(jh,{label:"Reports to",value:e.reportsTo}),l.jsx(jh,{label:"Status",value:e.status})]}),Oe.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:Oe.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:kh[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(hu,{title:"Authority",open:ne,onToggle:()=>Y(ze=>!ze),children:[((Ke=e.authority.autonomous)==null?void 0:Ke.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))]}),((jt=e.authority.needsApproval)==null?void 0:jt.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&&M&&(()=>{const ze=M.filter(He=>He.roleA===e.id||He.roleB===e.id).filter(He=>He.familiarity>0).sort((He,Lt)=>Lt.familiarity-He.familiarity);return ze.length===0?null:l.jsx(hu,{title:`Relationships (${ze.length})`,open:ue,onToggle:()=>J(He=>!He),children:l.jsx("div",{className:"space-y-1.5",children:ze.map((He,Lt)=>{const Dt=He.roleA===e.id?He.roleB:He.roleA,Rt=n.find(P=>P.id===Dt),sn=He.familiarity>=80?"Best Partner":He.familiarity>=50?"Friend":He.familiarity>=20?"Colleague":"Acquaintance",pn=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:kh[Dt]??"var(--terminal-text-secondary)"},children:(Rt==null?void 0:Rt.name)??Dt}),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:pn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:sn})]},Lt)})})})})(),e.journal&&l.jsx(hu,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:K,onToggle:()=>D(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(js,{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(FC,{role:e,appearance:R}),o&&l.jsx("div",{className:"px-4 pb-4 mt-auto shrink-0",children:l.jsx("button",{onClick:()=>{o(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 FC({role:e,appearance:n}){const[a,i]=w.useState("idle"),[o,u]=w.useState(""),[d,h]=w.useState(!1),[m,f]=w.useState(null),[x,y]=w.useState(!1),[v,b]=w.useState(!1),[j,k]=w.useState(null);w.useEffect(()=>{pr.getCharacterVersion(e.id).then(E=>f((E==null?void 0:E.version)??null)).catch(()=>f(null)),ke.getPreferences().then(E=>k(E.instanceId??null)).catch(()=>{})},[e.id]);const N=async()=>{var E,R;if(!d){h(!0);return}i("publishing");try{let M=null;try{M=await ke.exportSkills(e.id)}catch{}const I={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:M??[],resume:{summary:((R=e.persona)==null?void 0:R.split(`
|
|
81
|
+
`)[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:""};n&&(I.appearance=n);let B="1.0.0";try{const L=await pr.getCharacterVersion(e.id);if(L!=null&&L.version){const H=L.version.split(".").map(Number);H[2]=(H[2]??0)+1,B=H.join(".")}}catch{}await pr.publishCharacter({id:e.id,name:e.name||e.id,version:B,data:I,publisherId:j??void 0}),i("done"),u(`Published v${B}`),f(B),h(!1)}catch(M){i("error"),u(M instanceof Error?M.message:"Failed"),h(!1)}},C=async()=>{b(!0);try{await pr.deleteCharacter(e.id,j??void 0),f(null),i("idle"),u(""),y(!1)}catch{u("Delete failed")}b(!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("span",{className:"text-[11px] font-bold uppercase tracking-wider shrink-0",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Cloud Store"}),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:[a==="done"?l.jsxs(l.Fragment,{children:[l.jsx("a",{href:"https://tycono.ai/store.html",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] hover:underline",style:{color:"var(--terminal-text-muted)"},onClick:E=>E.stopPropagation(),children:"View on Store ↗"}),l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--active-green)"},children:o})]}):a==="error"?l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#ef4444"},children:o}):l.jsx("button",{onClick:N,disabled:a==="publishing",className:"text-[10px] px-2.5 py-1 rounded font-semibold cursor-pointer transition-colors disabled:opacity-50",style:{background:d?"rgba(59,130,246,0.3)":"rgba(59,130,246,0.15)",color:"#60a5fa",border:d?"1px solid rgba(59,130,246,0.5)":"1px solid transparent"},children:a==="publishing"?"Publishing...":d?"Confirm?":m?"Update":"Publish"}),m&&!x&&l.jsx("button",{onClick:()=>y(!0),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer transition-colors",style:{color:"rgba(239,68,68,0.4)"},title:"Remove from store",children:"✕"}),x&&l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:C,disabled:v,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:v?"...":"Delete"}),l.jsx("button",{onClick:()=>y(!1),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)"},children:"No"})]})]})]})})})}function MC({icon:e,roleId:n,roleName:a,color:i,text:o}){const u=!!o;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:n})]}),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:a}),u?l.jsx("div",{className:"text-sm leading-relaxed",style:{color:"var(--terminal-text)"},children:l.jsx(js,{content:o})}):l.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function hu({title:e,open:n,onToggle:a,children:i}){return l.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[l.jsxs("button",{onClick:a,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:n?"rotate(0deg)":"rotate(-90deg)"},children:"▼"})]}),n&&l.jsx("div",{className:"px-3 pb-3 pt-2",style:{borderTop:"1px solid var(--terminal-border)"},children:i})]})}function Dy({onSend:e,disabled:n,placeholder:a,color:i}){const[o,u]=w.useState(""),d=w.useRef(!1),h=()=>{const m=o.trim();!m||n||(e(m),u(""))};return l.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[l.jsx("input",{type:"text",value:o,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!d.current&&(m.preventDefault(),h())},onCompositionStart:()=>{d.current=!0},onCompositionEnd:()=>{d.current=!1},placeholder:n?"Waiting...":a,disabled:n,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:h,disabled:n||!o.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:n||!o.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 jh({label:e,value:n}){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:n})]})}function RC(e,n){var a,i=1;e==null&&(e=0),n==null&&(n=0);function o(){var u,d=a.length,h,m=0,f=0;for(u=0;u<d;++u)h=a[u],m+=h.x,f+=h.y;for(m=(m/d-e)*i,f=(f/d-n)*i,u=0;u<d;++u)h=a[u],h.x-=m,h.y-=f}return o.initialize=function(u){a=u},o.x=function(u){return arguments.length?(e=+u,o):e},o.y=function(u){return arguments.length?(n=+u,o):n},o.strength=function(u){return arguments.length?(i=+u,o):i},o}function zC(e){const n=+this._x.call(null,e),a=+this._y.call(null,e);return Ub(this.cover(n,a),n,a,e)}function Ub(e,n,a,i){if(isNaN(n)||isNaN(a))return e;var o,u=e._root,d={data:i},h=e._x0,m=e._y0,f=e._x1,x=e._y1,y,v,b,j,k,N,C,E;if(!u)return e._root=d,e;for(;u.length;)if((k=n>=(y=(h+f)/2))?h=y:f=y,(N=a>=(v=(m+x)/2))?m=v:x=v,o=u,!(u=u[C=N<<1|k]))return o[C]=d,e;if(b=+e._x.call(null,u.data),j=+e._y.call(null,u.data),n===b&&a===j)return d.next=u,o?o[C]=d:e._root=d,e;do o=o?o[C]=new Array(4):e._root=new Array(4),(k=n>=(y=(h+f)/2))?h=y:f=y,(N=a>=(v=(m+x)/2))?m=v:x=v;while((C=N<<1|k)===(E=(j>=v)<<1|b>=y));return o[E]=u,o[C]=d,e}function _C(e){var n,a,i=e.length,o,u,d=new Array(i),h=new Array(i),m=1/0,f=1/0,x=-1/0,y=-1/0;for(a=0;a<i;++a)isNaN(o=+this._x.call(null,n=e[a]))||isNaN(u=+this._y.call(null,n))||(d[a]=o,h[a]=u,o<m&&(m=o),o>x&&(x=o),u<f&&(f=u),u>y&&(y=u));if(m>x||f>y)return this;for(this.cover(m,f).cover(x,y),a=0;a<i;++a)Ub(this,d[a],h[a],e[a]);return this}function BC(e,n){if(isNaN(e=+e)||isNaN(n=+n))return this;var a=this._x0,i=this._y0,o=this._x1,u=this._y1;if(isNaN(a))o=(a=Math.floor(e))+1,u=(i=Math.floor(n))+1;else{for(var d=o-a||1,h=this._root,m,f;a>e||e>=o||i>n||n>=u;)switch(f=(n<i)<<1|e<a,m=new Array(4),m[f]=h,h=m,d*=2,f){case 0:o=a+d,u=i+d;break;case 1:a=o-d,u=i+d;break;case 2:o=a+d,i=u-d;break;case 3:a=o-d,i=u-d;break}this._root&&this._root.length&&(this._root=h)}return this._x0=a,this._y0=i,this._x1=o,this._y1=u,this}function OC(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function $C(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 ar(e,n,a,i,o){this.node=e,this.x0=n,this.y0=a,this.x1=i,this.y1=o}function LC(e,n,a){var i,o=this._x0,u=this._y0,d,h,m,f,x=this._x1,y=this._y1,v=[],b=this._root,j,k;for(b&&v.push(new ar(b,o,u,x,y)),a==null?a=1/0:(o=e-a,u=n-a,x=e+a,y=n+a,a*=a);j=v.pop();)if(!(!(b=j.node)||(d=j.x0)>x||(h=j.y0)>y||(m=j.x1)<o||(f=j.y1)<u))if(b.length){var N=(d+m)/2,C=(h+f)/2;v.push(new ar(b[3],N,C,m,f),new ar(b[2],d,C,N,f),new ar(b[1],N,h,m,C),new ar(b[0],d,h,N,C)),(k=(n>=C)<<1|e>=N)&&(j=v[v.length-1],v[v.length-1]=v[v.length-1-k],v[v.length-1-k]=j)}else{var E=e-+this._x.call(null,b.data),R=n-+this._y.call(null,b.data),M=E*E+R*R;if(M<a){var I=Math.sqrt(a=M);o=e-I,u=n-I,x=e+I,y=n+I,i=b.data}}return i}function IC(e){if(isNaN(x=+this._x.call(null,e))||isNaN(y=+this._y.call(null,e)))return this;var n,a=this._root,i,o,u,d=this._x0,h=this._y0,m=this._x1,f=this._y1,x,y,v,b,j,k,N,C;if(!a)return this;if(a.length)for(;;){if((j=x>=(v=(d+m)/2))?d=v:m=v,(k=y>=(b=(h+f)/2))?h=b:f=b,n=a,!(a=a[N=k<<1|j]))return this;if(!a.length)break;(n[N+1&3]||n[N+2&3]||n[N+3&3])&&(i=n,C=N)}for(;a.data!==e;)if(o=a,!(a=a.next))return this;return(u=a.next)&&delete a.next,o?(u?o.next=u:delete o.next,this):n?(u?n[N]=u:delete n[N],(a=n[0]||n[1]||n[2]||n[3])&&a===(n[3]||n[2]||n[1]||n[0])&&!a.length&&(i?i[C]=a:this._root=a),this):(this._root=u,this)}function HC(e){for(var n=0,a=e.length;n<a;++n)this.remove(e[n]);return this}function UC(){return this._root}function qC(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function YC(e){var n=[],a,i=this._root,o,u,d,h,m;for(i&&n.push(new ar(i,this._x0,this._y0,this._x1,this._y1));a=n.pop();)if(!e(i=a.node,u=a.x0,d=a.y0,h=a.x1,m=a.y1)&&i.length){var f=(u+h)/2,x=(d+m)/2;(o=i[3])&&n.push(new ar(o,f,x,h,m)),(o=i[2])&&n.push(new ar(o,u,x,f,m)),(o=i[1])&&n.push(new ar(o,f,d,h,x)),(o=i[0])&&n.push(new ar(o,u,d,f,x))}return this}function XC(e){var n=[],a=[],i;for(this._root&&n.push(new ar(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var o=i.node;if(o.length){var u,d=i.x0,h=i.y0,m=i.x1,f=i.y1,x=(d+m)/2,y=(h+f)/2;(u=o[0])&&n.push(new ar(u,d,h,x,y)),(u=o[1])&&n.push(new ar(u,x,h,m,y)),(u=o[2])&&n.push(new ar(u,d,y,x,f)),(u=o[3])&&n.push(new ar(u,x,y,m,f))}a.push(i)}for(;i=a.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function WC(e){return e[0]}function GC(e){return arguments.length?(this._x=e,this):this._x}function VC(e){return e[1]}function KC(e){return arguments.length?(this._y=e,this):this._y}function Um(e,n,a){var i=new qm(n??WC,a??VC,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function qm(e,n,a,i,o,u){this._x=e,this._y=n,this._x0=a,this._y0=i,this._x1=o,this._y1=u,this._root=void 0}function Ty(e){for(var n={data:e.data},a=n;e=e.next;)a=a.next={data:e.data};return n}var lr=Um.prototype=qm.prototype;lr.copy=function(){var e=new qm(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,a,i;if(!n)return e;if(!n.length)return e._root=Ty(n),e;for(a=[{source:n,target:e._root=new Array(4)}];n=a.pop();)for(var o=0;o<4;++o)(i=n.source[o])&&(i.length?a.push({source:i,target:n.target[o]=new Array(4)}):n.target[o]=Ty(i));return e};lr.add=zC;lr.addAll=_C;lr.cover=BC;lr.data=OC;lr.extent=$C;lr.find=LC;lr.remove=IC;lr.removeAll=HC;lr.root=UC;lr.size=qC;lr.visit=YC;lr.visitAfter=XC;lr.x=GC;lr.y=KC;function bi(e){return function(){return e}}function Ol(e){return(e()-.5)*1e-6}function QC(e){return e.x+e.vx}function PC(e){return e.y+e.vy}function ZC(e){var n,a,i,o=1,u=1;typeof e!="function"&&(e=bi(e==null?1:+e));function d(){for(var f,x=n.length,y,v,b,j,k,N,C=0;C<u;++C)for(y=Um(n,QC,PC).visitAfter(h),f=0;f<x;++f)v=n[f],k=a[v.index],N=k*k,b=v.x+v.vx,j=v.y+v.vy,y.visit(E);function E(R,M,I,B,L){var H=R.data,Q=R.r,A=k+Q;if(H){if(H.index>v.index){var $=b-H.x-H.vx,U=j-H.y-H.vy,ee=$*$+U*U;ee<A*A&&($===0&&($=Ol(i),ee+=$*$),U===0&&(U=Ol(i),ee+=U*U),ee=(A-(ee=Math.sqrt(ee)))/ee*o,v.vx+=($*=ee)*(A=(Q*=Q)/(N+Q)),v.vy+=(U*=ee)*A,H.vx-=$*(A=1-A),H.vy-=U*A)}return}return M>b+A||B<b-A||I>j+A||L<j-A}}function h(f){if(f.data)return f.r=a[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(n){var f,x=n.length,y;for(a=new Array(x),f=0;f<x;++f)y=n[f],a[y.index]=+e(y,f,n)}}return d.initialize=function(f,x){n=f,i=x,m()},d.iterations=function(f){return arguments.length?(u=+f,d):u},d.strength=function(f){return arguments.length?(o=+f,d):o},d.radius=function(f){return arguments.length?(e=typeof f=="function"?f:bi(+f),m(),d):e},d}function JC(e){return e.index}function Fy(e,n){var a=e.get(n);if(!a)throw new Error("node not found: "+n);return a}function eN(e){var n=JC,a=y,i,o=bi(30),u,d,h,m,f,x=1;e==null&&(e=[]);function y(N){return 1/Math.min(h[N.source.index],h[N.target.index])}function v(N){for(var C=0,E=e.length;C<x;++C)for(var R=0,M,I,B,L,H,Q,A;R<E;++R)M=e[R],I=M.source,B=M.target,L=B.x+B.vx-I.x-I.vx||Ol(f),H=B.y+B.vy-I.y-I.vy||Ol(f),Q=Math.sqrt(L*L+H*H),Q=(Q-u[R])/Q*N*i[R],L*=Q,H*=Q,B.vx-=L*(A=m[R]),B.vy-=H*A,I.vx+=L*(A=1-A),I.vy+=H*A}function b(){if(d){var N,C=d.length,E=e.length,R=new Map(d.map((I,B)=>[n(I,B,d),I])),M;for(N=0,h=new Array(C);N<E;++N)M=e[N],M.index=N,typeof M.source!="object"&&(M.source=Fy(R,M.source)),typeof M.target!="object"&&(M.target=Fy(R,M.target)),h[M.source.index]=(h[M.source.index]||0)+1,h[M.target.index]=(h[M.target.index]||0)+1;for(N=0,m=new Array(E);N<E;++N)M=e[N],m[N]=h[M.source.index]/(h[M.source.index]+h[M.target.index]);i=new Array(E),j(),u=new Array(E),k()}}function j(){if(d)for(var N=0,C=e.length;N<C;++N)i[N]=+a(e[N],N,e)}function k(){if(d)for(var N=0,C=e.length;N<C;++N)u[N]=+o(e[N],N,e)}return v.initialize=function(N,C){d=N,f=C,b()},v.links=function(N){return arguments.length?(e=N,b(),v):e},v.id=function(N){return arguments.length?(n=N,v):n},v.iterations=function(N){return arguments.length?(x=+N,v):x},v.strength=function(N){return arguments.length?(a=typeof N=="function"?N:bi(+N),j(),v):a},v.distance=function(N){return arguments.length?(o=typeof N=="function"?N:bi(+N),k(),v):o},v}var tN={value:()=>{}};function qb(){for(var e=0,n=arguments.length,a={},i;e<n;++e){if(!(i=arguments[e]+"")||i in a||/[\s.]/.test(i))throw new Error("illegal type: "+i);a[i]=[]}return new Au(a)}function Au(e){this._=e}function nN(e,n){return e.trim().split(/^|\s+/).map(function(a){var i="",o=a.indexOf(".");if(o>=0&&(i=a.slice(o+1),a=a.slice(0,o)),a&&!n.hasOwnProperty(a))throw new Error("unknown type: "+a);return{type:a,name:i}})}Au.prototype=qb.prototype={constructor:Au,on:function(e,n){var a=this._,i=nN(e+"",a),o,u=-1,d=i.length;if(arguments.length<2){for(;++u<d;)if((o=(e=i[u]).type)&&(o=rN(a[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++u<d;)if(o=(e=i[u]).type)a[o]=My(a[o],e.name,n);else if(n==null)for(o in a)a[o]=My(a[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var a in n)e[a]=n[a].slice();return new Au(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var a=new Array(o),i=0,o,u;i<o;++i)a[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(u=this._[e],i=0,o=u.length;i<o;++i)u[i].value.apply(n,a)},apply:function(e,n,a){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],o=0,u=i.length;o<u;++o)i[o].value.apply(n,a)}};function rN(e,n){for(var a=0,i=e.length,o;a<i;++a)if((o=e[a]).name===n)return o.value}function My(e,n,a){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=tN,e=e.slice(0,i).concat(e.slice(i+1));break}return a!=null&&e.push({name:n,value:a}),e}var gs=0,Fo=0,Eo=0,Yb=1e3,$u,Mo,Lu=0,ji=0,Pu=0,Io=typeof performance=="object"&&performance.now?performance:Date,Xb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Wb(){return ji||(Xb(aN),ji=Io.now()+Pu)}function aN(){ji=0}function am(){this._call=this._time=this._next=null}am.prototype=Gb.prototype={constructor:am,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?Wb():+a)+(n==null?0:+n),!this._next&&Mo!==this&&(Mo?Mo._next=this:$u=this,Mo=this),this._call=e,this._time=a,lm()},stop:function(){this._call&&(this._call=null,this._time=1/0,lm())}};function Gb(e,n,a){var i=new am;return i.restart(e,n,a),i}function lN(){Wb(),++gs;for(var e=$u,n;e;)(n=ji-e._time)>=0&&e._call.call(void 0,n),e=e._next;--gs}function Ry(){ji=(Lu=Io.now())+Pu,gs=Fo=0;try{lN()}finally{gs=0,sN(),ji=0}}function iN(){var e=Io.now(),n=e-Lu;n>Yb&&(Pu-=n,Lu=e)}function sN(){for(var e,n=$u,a,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(a=n._next,n._next=null,n=e?e._next=a:$u=a);Mo=e,lm(i)}function lm(e){if(!gs){Fo&&(Fo=clearTimeout(Fo));var n=e-ji;n>24?(e<1/0&&(Fo=setTimeout(Ry,e-Io.now()-Pu)),Eo&&(Eo=clearInterval(Eo))):(Eo||(Lu=Io.now(),Eo=setInterval(iN,Yb)),gs=1,Xb(Ry))}}const oN=1664525,cN=1013904223,zy=4294967296;function uN(){let e=1;return()=>(e=(oN*e+cN)%zy)/zy}function dN(e){return e.x}function fN(e){return e.y}var hN=10,mN=Math.PI*(3-Math.sqrt(5));function pN(e){var n,a=1,i=.001,o=1-Math.pow(i,1/300),u=0,d=.6,h=new Map,m=Gb(y),f=qb("tick","end"),x=uN();e==null&&(e=[]);function y(){v(),f.call("tick",n),a<i&&(m.stop(),f.call("end",n))}function v(k){var N,C=e.length,E;k===void 0&&(k=1);for(var R=0;R<k;++R)for(a+=(u-a)*o,h.forEach(function(M){M(a)}),N=0;N<C;++N)E=e[N],E.fx==null?E.x+=E.vx*=d:(E.x=E.fx,E.vx=0),E.fy==null?E.y+=E.vy*=d:(E.y=E.fy,E.vy=0);return n}function b(){for(var k=0,N=e.length,C;k<N;++k){if(C=e[k],C.index=k,C.fx!=null&&(C.x=C.fx),C.fy!=null&&(C.y=C.fy),isNaN(C.x)||isNaN(C.y)){var E=hN*Math.sqrt(.5+k),R=k*mN;C.x=E*Math.cos(R),C.y=E*Math.sin(R)}(isNaN(C.vx)||isNaN(C.vy))&&(C.vx=C.vy=0)}}function j(k){return k.initialize&&k.initialize(e,x),k}return b(),n={tick:v,restart:function(){return m.restart(y),n},stop:function(){return m.stop(),n},nodes:function(k){return arguments.length?(e=k,b(),h.forEach(j),n):e},alpha:function(k){return arguments.length?(a=+k,n):a},alphaMin:function(k){return arguments.length?(i=+k,n):i},alphaDecay:function(k){return arguments.length?(o=+k,n):+o},alphaTarget:function(k){return arguments.length?(u=+k,n):u},velocityDecay:function(k){return arguments.length?(d=1-k,n):1-d},randomSource:function(k){return arguments.length?(x=k,h.forEach(j),n):x},force:function(k,N){return arguments.length>1?(N==null?h.delete(k):h.set(k,j(N)),n):h.get(k)},find:function(k,N,C){var E=0,R=e.length,M,I,B,L,H;for(C==null?C=1/0:C*=C,E=0;E<R;++E)L=e[E],M=k-L.x,I=N-L.y,B=M*M+I*I,B<C&&(H=L,C=B);return H},on:function(k,N){return arguments.length>1?(f.on(k,N),n):f.on(k)}}}function xN(){var e,n,a,i,o=bi(-30),u,d=1,h=1/0,m=.81;function f(b){var j,k=e.length,N=Um(e,dN,fN).visitAfter(y);for(i=b,j=0;j<k;++j)n=e[j],N.visit(v)}function x(){if(e){var b,j=e.length,k;for(u=new Array(j),b=0;b<j;++b)k=e[b],u[k.index]=+o(k,b,e)}}function y(b){var j=0,k,N,C=0,E,R,M;if(b.length){for(E=R=M=0;M<4;++M)(k=b[M])&&(N=Math.abs(k.value))&&(j+=k.value,C+=N,E+=N*k.x,R+=N*k.y);b.x=E/C,b.y=R/C}else{k=b,k.x=k.data.x,k.y=k.data.y;do j+=u[k.data.index];while(k=k.next)}b.value=j}function v(b,j,k,N){if(!b.value)return!0;var C=b.x-n.x,E=b.y-n.y,R=N-j,M=C*C+E*E;if(R*R/m<M)return M<h&&(C===0&&(C=Ol(a),M+=C*C),E===0&&(E=Ol(a),M+=E*E),M<d&&(M=Math.sqrt(d*M)),n.vx+=C*b.value*i/M,n.vy+=E*b.value*i/M),!0;if(b.length||M>=h)return;(b.data!==n||b.next)&&(C===0&&(C=Ol(a),M+=C*C),E===0&&(E=Ol(a),M+=E*E),M<d&&(M=Math.sqrt(d*M)));do b.data!==n&&(R=u[b.data.index]*i/M,n.vx+=C*R,n.vy+=E*R);while(b=b.next)}return f.initialize=function(b,j){e=b,a=j,x()},f.strength=function(b){return arguments.length?(o=typeof b=="function"?b:bi(+b),x(),f):o},f.distanceMin=function(b){return arguments.length?(d=b*b,f):Math.sqrt(d)},f.distanceMax=function(b){return arguments.length?(h=b*b,f):Math.sqrt(h)},f.theta=function(b){return arguments.length?(m=b*b,f):Math.sqrt(m)},f}function Ja(e){return Array.isArray?Array.isArray(e):Qb(e)==="[object Array]"}function yN(e){if(typeof e=="string")return e;let n=e+"";return n=="0"&&1/e==-1/0?"-0":n}function gN(e){return e==null?"":yN(e)}function ka(e){return typeof e=="string"}function Vb(e){return typeof e=="number"}function bN(e){return e===!0||e===!1||vN(e)&&Qb(e)=="[object Boolean]"}function Kb(e){return typeof e=="object"}function vN(e){return Kb(e)&&e!==null}function Ar(e){return e!=null}function Sh(e){return!e.trim().length}function Qb(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const wN="Incorrect 'index' type",kN=e=>`Invalid value for key ${e}`,jN=e=>`Pattern length exceeds max of ${e}.`,SN=e=>`Missing ${e} property in key`,CN=e=>`Property 'weight' in key '${e}' must be a positive integer`,_y=Object.prototype.hasOwnProperty;class NN{constructor(n){this._keys=[],this._keyMap={};let a=0;n.forEach(i=>{let o=Pb(i);this._keys.push(o),this._keyMap[o.id]=o,a+=o.weight}),this._keys.forEach(i=>{i.weight/=a})}get(n){return this._keyMap[n]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Pb(e){let n=null,a=null,i=null,o=1,u=null;if(ka(e)||Ja(e))i=e,n=By(e),a=im(e);else{if(!_y.call(e,"name"))throw new Error(SN("name"));const d=e.name;if(i=d,_y.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(CN(d));n=By(d),a=im(d),u=e.getFn}return{path:n,id:a,weight:o,src:i,getFn:u}}function By(e){return Ja(e)?e:e.split(".")}function im(e){return Ja(e)?e.join("."):e}function EN(e,n){let a=[],i=!1;const o=(u,d,h)=>{if(Ar(u))if(!d[h])a.push(u);else{let m=d[h];const f=u[m];if(!Ar(f))return;if(h===d.length-1&&(ka(f)||Vb(f)||bN(f)))a.push(gN(f));else if(Ja(f)){i=!0;for(let x=0,y=f.length;x<y;x+=1)o(f[x],d,h+1)}else d.length&&o(f,d,h+1)}};return o(e,ka(n)?n.split("."):n,0),i?a:a[0]}const AN={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},DN={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,n)=>e.score===n.score?e.idx<n.idx?-1:1:e.score<n.score?-1:1},TN={location:0,threshold:.6,distance:100},FN={useExtendedSearch:!1,getFn:EN,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var ct={...DN,...AN,...TN,...FN};const MN=/[^ ]+/g;function RN(e=1,n=3){const a=new Map,i=Math.pow(10,n);return{get(o){const u=o.match(MN).length;if(a.has(u))return a.get(u);const d=1/Math.pow(u,.5*e),h=parseFloat(Math.round(d*i)/i);return a.set(u,h),h},clear(){a.clear()}}}class Ym{constructor({getFn:n=ct.getFn,fieldNormWeight:a=ct.fieldNormWeight}={}){this.norm=RN(a,3),this.getFn=n,this.isCreated=!1,this.setIndexRecords()}setSources(n=[]){this.docs=n}setIndexRecords(n=[]){this.records=n}setKeys(n=[]){this.keys=n,this._keysMap={},n.forEach((a,i)=>{this._keysMap[a.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,ka(this.docs[0])?this.docs.forEach((n,a)=>{this._addString(n,a)}):this.docs.forEach((n,a)=>{this._addObject(n,a)}),this.norm.clear())}add(n){const a=this.size();ka(n)?this._addString(n,a):this._addObject(n,a)}removeAt(n){this.records.splice(n,1);for(let a=n,i=this.size();a<i;a+=1)this.records[a].i-=1}getValueForItemAtKeyId(n,a){return n[this._keysMap[a]]}size(){return this.records.length}_addString(n,a){if(!Ar(n)||Sh(n))return;let i={v:n,i:a,n:this.norm.get(n)};this.records.push(i)}_addObject(n,a){let i={i:a,$:{}};this.keys.forEach((o,u)=>{let d=o.getFn?o.getFn(n):this.getFn(n,o.path);if(Ar(d)){if(Ja(d)){let h=[];const m=[{nestedArrIndex:-1,value:d}];for(;m.length;){const{nestedArrIndex:f,value:x}=m.pop();if(Ar(x))if(ka(x)&&!Sh(x)){let y={v:x,i:f,n:this.norm.get(x)};h.push(y)}else Ja(x)&&x.forEach((y,v)=>{m.push({nestedArrIndex:v,value:y})})}i.$[u]=h}else if(ka(d)&&!Sh(d)){let h={v:d,n:this.norm.get(d)};i.$[u]=h}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function Zb(e,n,{getFn:a=ct.getFn,fieldNormWeight:i=ct.fieldNormWeight}={}){const o=new Ym({getFn:a,fieldNormWeight:i});return o.setKeys(e.map(Pb)),o.setSources(n),o.create(),o}function zN(e,{getFn:n=ct.getFn,fieldNormWeight:a=ct.fieldNormWeight}={}){const{keys:i,records:o}=e,u=new Ym({getFn:n,fieldNormWeight:a});return u.setKeys(i),u.setIndexRecords(o),u}function mu(e,{errors:n=0,currentLocation:a=0,expectedLocation:i=0,distance:o=ct.distance,ignoreLocation:u=ct.ignoreLocation}={}){const d=n/e.length;if(u)return d;const h=Math.abs(i-a);return o?d+h/o:h?1:d}function _N(e=[],n=ct.minMatchCharLength){let a=[],i=-1,o=-1,u=0;for(let d=e.length;u<d;u+=1){let h=e[u];h&&i===-1?i=u:!h&&i!==-1&&(o=u-1,o-i+1>=n&&a.push([i,o]),i=-1)}return e[u-1]&&u-i>=n&&a.push([i,u-1]),a}const gi=32;function BN(e,n,a,{location:i=ct.location,distance:o=ct.distance,threshold:u=ct.threshold,findAllMatches:d=ct.findAllMatches,minMatchCharLength:h=ct.minMatchCharLength,includeMatches:m=ct.includeMatches,ignoreLocation:f=ct.ignoreLocation}={}){if(n.length>gi)throw new Error(jN(gi));const x=n.length,y=e.length,v=Math.max(0,Math.min(i,y));let b=u,j=v;const k=h>1||m,N=k?Array(y):[];let C;for(;(C=e.indexOf(n,j))>-1;){let L=mu(n,{currentLocation:C,expectedLocation:v,distance:o,ignoreLocation:f});if(b=Math.min(L,b),j=C+x,k){let H=0;for(;H<x;)N[C+H]=1,H+=1}}j=-1;let E=[],R=1,M=x+y;const I=1<<x-1;for(let L=0;L<x;L+=1){let H=0,Q=M;for(;H<Q;)mu(n,{errors:L,currentLocation:v+Q,expectedLocation:v,distance:o,ignoreLocation:f})<=b?H=Q:M=Q,Q=Math.floor((M-H)/2+H);M=Q;let A=Math.max(1,v-Q+1),$=d?y:Math.min(v+Q,y)+x,U=Array($+2);U[$+1]=(1<<L)-1;for(let oe=$;oe>=A;oe-=1){let ne=oe-1,Y=a[e.charAt(ne)];if(k&&(N[ne]=+!!Y),U[oe]=(U[oe+1]<<1|1)&Y,L&&(U[oe]|=(E[oe+1]|E[oe])<<1|1|E[oe+1]),U[oe]&I&&(R=mu(n,{errors:L,currentLocation:ne,expectedLocation:v,distance:o,ignoreLocation:f}),R<=b)){if(b=R,j=ne,j<=v)break;A=Math.max(1,2*v-j)}}if(mu(n,{errors:L+1,currentLocation:v,expectedLocation:v,distance:o,ignoreLocation:f})>b)break;E=U}const B={isMatch:j>=0,score:Math.max(.001,R)};if(k){const L=_N(N,h);L.length?m&&(B.indices=L):B.isMatch=!1}return B}function ON(e){let n={};for(let a=0,i=e.length;a<i;a+=1){const o=e.charAt(a);n[o]=(n[o]||0)|1<<i-a-1}return n}const Iu=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 Jb{constructor(n,{location:a=ct.location,threshold:i=ct.threshold,distance:o=ct.distance,includeMatches:u=ct.includeMatches,findAllMatches:d=ct.findAllMatches,minMatchCharLength:h=ct.minMatchCharLength,isCaseSensitive:m=ct.isCaseSensitive,ignoreDiacritics:f=ct.ignoreDiacritics,ignoreLocation:x=ct.ignoreLocation}={}){if(this.options={location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:h,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x},n=m?n:n.toLowerCase(),n=f?Iu(n):n,this.pattern=n,this.chunks=[],!this.pattern.length)return;const y=(b,j)=>{this.chunks.push({pattern:b,alphabet:ON(b),startIndex:j})},v=this.pattern.length;if(v>gi){let b=0;const j=v%gi,k=v-j;for(;b<k;)y(this.pattern.substr(b,gi),b),b+=gi;if(j){const N=v-gi;y(this.pattern.substr(N),N)}}else y(this.pattern,0)}searchIn(n){const{isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o}=this.options;if(n=a?n:n.toLowerCase(),n=i?Iu(n):n,this.pattern===n){let k={isMatch:!0,score:0};return o&&(k.indices=[[0,n.length-1]]),k}const{location:u,distance:d,threshold:h,findAllMatches:m,minMatchCharLength:f,ignoreLocation:x}=this.options;let y=[],v=0,b=!1;this.chunks.forEach(({pattern:k,alphabet:N,startIndex:C})=>{const{isMatch:E,score:R,indices:M}=BN(n,k,N,{location:u+C,distance:d,threshold:h,findAllMatches:m,minMatchCharLength:f,includeMatches:o,ignoreLocation:x});E&&(b=!0),v+=R,E&&M&&(y=[...y,...M])});let j={isMatch:b,score:b?v/this.chunks.length:1};return b&&o&&(j.indices=y),j}}class Hl{constructor(n){this.pattern=n}static isMultiMatch(n){return Oy(n,this.multiRegex)}static isSingleMatch(n){return Oy(n,this.singleRegex)}search(){}}function Oy(e,n){const a=e.match(n);return a?a[1]:null}class $N extends Hl{constructor(n){super(n)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(n){const a=n===this.pattern;return{isMatch:a,score:a?0:1,indices:[0,this.pattern.length-1]}}}class LN extends Hl{constructor(n){super(n)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(n){const i=n.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,n.length-1]}}}class IN extends Hl{constructor(n){super(n)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(n){const a=n.startsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,this.pattern.length-1]}}}class HN extends Hl{constructor(n){super(n)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(n){const a=!n.startsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,n.length-1]}}}class UN extends Hl{constructor(n){super(n)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(n){const a=n.endsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[n.length-this.pattern.length,n.length-1]}}}class qN extends Hl{constructor(n){super(n)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(n){const a=!n.endsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,n.length-1]}}}class ev extends Hl{constructor(n,{location:a=ct.location,threshold:i=ct.threshold,distance:o=ct.distance,includeMatches:u=ct.includeMatches,findAllMatches:d=ct.findAllMatches,minMatchCharLength:h=ct.minMatchCharLength,isCaseSensitive:m=ct.isCaseSensitive,ignoreDiacritics:f=ct.ignoreDiacritics,ignoreLocation:x=ct.ignoreLocation}={}){super(n),this._bitapSearch=new Jb(n,{location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:h,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(n){return this._bitapSearch.searchIn(n)}}class tv extends Hl{constructor(n){super(n)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(n){let a=0,i;const o=[],u=this.pattern.length;for(;(i=n.indexOf(this.pattern,a))>-1;)a=i+u,o.push([i,a-1]);const d=!!o.length;return{isMatch:d,score:d?0:1,indices:o}}}const sm=[$N,tv,IN,HN,qN,UN,LN,ev],$y=sm.length,YN=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,XN="|";function WN(e,n={}){return e.split(XN).map(a=>{let i=a.trim().split(YN).filter(u=>u&&!!u.trim()),o=[];for(let u=0,d=i.length;u<d;u+=1){const h=i[u];let m=!1,f=-1;for(;!m&&++f<$y;){const x=sm[f];let y=x.isMultiMatch(h);y&&(o.push(new x(y,n)),m=!0)}if(!m)for(f=-1;++f<$y;){const x=sm[f];let y=x.isSingleMatch(h);if(y){o.push(new x(y,n));break}}}return o})}const GN=new Set([ev.type,tv.type]);class VN{constructor(n,{isCaseSensitive:a=ct.isCaseSensitive,ignoreDiacritics:i=ct.ignoreDiacritics,includeMatches:o=ct.includeMatches,minMatchCharLength:u=ct.minMatchCharLength,ignoreLocation:d=ct.ignoreLocation,findAllMatches:h=ct.findAllMatches,location:m=ct.location,threshold:f=ct.threshold,distance:x=ct.distance}={}){this.query=null,this.options={isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o,minMatchCharLength:u,findAllMatches:h,ignoreLocation:d,location:m,threshold:f,distance:x},n=a?n:n.toLowerCase(),n=i?Iu(n):n,this.pattern=n,this.query=WN(this.pattern,this.options)}static condition(n,a){return a.useExtendedSearch}searchIn(n){const a=this.query;if(!a)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:o,ignoreDiacritics:u}=this.options;n=o?n:n.toLowerCase(),n=u?Iu(n):n;let d=0,h=[],m=0;for(let f=0,x=a.length;f<x;f+=1){const y=a[f];h.length=0,d=0;for(let v=0,b=y.length;v<b;v+=1){const j=y[v],{isMatch:k,indices:N,score:C}=j.search(n);if(k){if(d+=1,m+=C,i){const E=j.constructor.type;GN.has(E)?h=[...h,...N]:h.push(N)}}else{m=0,d=0,h.length=0;break}}if(d){let v={isMatch:!0,score:m/d};return i&&(v.indices=h),v}}return{isMatch:!1,score:1}}}const om=[];function KN(...e){om.push(...e)}function cm(e,n){for(let a=0,i=om.length;a<i;a+=1){let o=om[a];if(o.condition(e,n))return new o(e,n)}return new Jb(e,n)}const Hu={AND:"$and",OR:"$or"},um={PATH:"$path",PATTERN:"$val"},dm=e=>!!(e[Hu.AND]||e[Hu.OR]),QN=e=>!!e[um.PATH],PN=e=>!Ja(e)&&Kb(e)&&!dm(e),Ly=e=>({[Hu.AND]:Object.keys(e).map(n=>({[n]:e[n]}))});function nv(e,n,{auto:a=!0}={}){const i=o=>{let u=Object.keys(o);const d=QN(o);if(!d&&u.length>1&&!dm(o))return i(Ly(o));if(PN(o)){const m=d?o[um.PATH]:u[0],f=d?o[um.PATTERN]:o[m];if(!ka(f))throw new Error(kN(m));const x={keyId:im(m),pattern:f};return a&&(x.searcher=cm(f,n)),x}let h={children:[],operator:u[0]};return u.forEach(m=>{const f=o[m];Ja(f)&&f.forEach(x=>{h.children.push(i(x))})}),h};return dm(e)||(e=Ly(e)),i(e)}function ZN(e,{ignoreFieldNorm:n=ct.ignoreFieldNorm}){e.forEach(a=>{let i=1;a.matches.forEach(({key:o,norm:u,score:d})=>{const h=o?o.weight:null;i*=Math.pow(d===0&&h?Number.EPSILON:d,(h||1)*(n?1:u))}),a.score=i})}function JN(e,n){const a=e.matches;n.matches=[],Ar(a)&&a.forEach(i=>{if(!Ar(i.indices)||!i.indices.length)return;const{indices:o,value:u}=i;let d={indices:o,value:u};i.key&&(d.key=i.key.src),i.idx>-1&&(d.refIndex=i.idx),n.matches.push(d)})}function eE(e,n){n.score=e.score}function tE(e,n,{includeMatches:a=ct.includeMatches,includeScore:i=ct.includeScore}={}){const o=[];return a&&o.push(JN),i&&o.push(eE),e.map(u=>{const{idx:d}=u,h={item:n[d],refIndex:d};return o.length&&o.forEach(m=>{m(u,h)}),h})}class Ss{constructor(n,a={},i){this.options={...ct,...a},this.options.useExtendedSearch,this._keyStore=new NN(this.options.keys),this.setCollection(n,i)}setCollection(n,a){if(this._docs=n,a&&!(a instanceof Ym))throw new Error(wN);this._myIndex=a||Zb(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(n){Ar(n)&&(this._docs.push(n),this._myIndex.add(n))}remove(n=()=>!1){const a=[];for(let i=0,o=this._docs.length;i<o;i+=1){const u=this._docs[i];n(u,i)&&(this.removeAt(i),i-=1,o-=1,a.push(u))}return a}removeAt(n){this._docs.splice(n,1),this._myIndex.removeAt(n)}getIndex(){return this._myIndex}search(n,{limit:a=-1}={}){const{includeMatches:i,includeScore:o,shouldSort:u,sortFn:d,ignoreFieldNorm:h}=this.options;let m=ka(n)?ka(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return ZN(m,{ignoreFieldNorm:h}),u&&m.sort(d),Vb(a)&&a>-1&&(m=m.slice(0,a)),tE(m,this._docs,{includeMatches:i,includeScore:o})}_searchStringList(n){const a=cm(n,this.options),{records:i}=this._myIndex,o=[];return i.forEach(({v:u,i:d,n:h})=>{if(!Ar(u))return;const{isMatch:m,score:f,indices:x}=a.searchIn(u);m&&o.push({item:u,idx:d,matches:[{score:f,value:u,norm:h,indices:x}]})}),o}_searchLogical(n){const a=nv(n,this.options),i=(h,m,f)=>{if(!h.children){const{keyId:y,searcher:v}=h,b=this._findMatches({key:this._keyStore.get(y),value:this._myIndex.getValueForItemAtKeyId(m,y),searcher:v});return b&&b.length?[{idx:f,item:m,matches:b}]:[]}const x=[];for(let y=0,v=h.children.length;y<v;y+=1){const b=h.children[y],j=i(b,m,f);if(j.length)x.push(...j);else if(h.operator===Hu.AND)return[]}return x},o=this._myIndex.records,u={},d=[];return o.forEach(({$:h,i:m})=>{if(Ar(h)){let f=i(a,h,m);f.length&&(u[m]||(u[m]={idx:m,item:h,matches:[]},d.push(u[m])),f.forEach(({matches:x})=>{u[m].matches.push(...x)}))}}),d}_searchObjectList(n){const a=cm(n,this.options),{keys:i,records:o}=this._myIndex,u=[];return o.forEach(({$:d,i:h})=>{if(!Ar(d))return;let m=[];i.forEach((f,x)=>{m.push(...this._findMatches({key:f,value:d[x],searcher:a}))}),m.length&&u.push({idx:h,item:d,matches:m})}),u}_findMatches({key:n,value:a,searcher:i}){if(!Ar(a))return[];let o=[];if(Ja(a))a.forEach(({v:u,i:d,n:h})=>{if(!Ar(u))return;const{isMatch:m,score:f,indices:x}=i.searchIn(u);m&&o.push({score:f,key:n,value:u,idx:d,norm:h,indices:x})});else{const{v:u,n:d}=a,{isMatch:h,score:m,indices:f}=i.searchIn(u);h&&o.push({score:m,key:n,value:u,norm:d,indices:f})}return o}}Ss.version="7.1.0";Ss.createIndex=Zb;Ss.parseIndex=zN;Ss.config=ct;Ss.parseQuery=nv;KN(VN);const ra={tech:{bg:"rgba(59,130,246,0.15)",border:"#3b82f6",text:"#60a5fa"},market:{bg:"rgba(245,158,11,0.15)",border:"#f59e0b",text:"#fbbf24"},strategy:{bg:"rgba(139,92,246,0.15)",border:"#8b5cf6",text:"#a78bfa"},financial:{bg:"rgba(34,197,94,0.15)",border:"#22c55e",text:"#4ade80"},process:{bg:"rgba(236,72,153,0.15)",border:"#ec4899",text:"#f472b6"},competitor:{bg:"rgba(239,68,68,0.15)",border:"#ef4444",text:"#f87171"},domain:{bg:"rgba(14,165,233,0.15)",border:"#0ea5e9",text:"#38bdf8"},general:{bg:"rgba(148,163,184,0.12)",border:"#64748b",text:"#94a3b8"}};function nE(e){return ra[e]??ra.general}function rE(e){return e>1600?"macro":e<800?"micro":"standard"}function aE(e){const n=new Map;for(const i of e){const o=i.category||"general";n.has(o)||n.set(o,[]),n.get(o).push(i)}const a=[];for(const[i,o]of n){let u=0,d=0;for(const m of o)u+=m.x??0,d+=m.y??0;const h=o.length;a.push({domain:i,count:h,centerX:u/h,centerY:d/h,nodes:o})}return a}function lE(e,n=60){if(!e)return"";const a=e.match(/^[^.!?]+[.!?]/),i=a?a[0]:e;return i.length>n?i.slice(0,n-2)+"..":i}function iE(e,n,a){const i=[...new Set(a.map(m=>m.category||"general"))],o=new Map,u=e/2,d=n/2,h=Math.min(e,n)*.3;return i.forEach((m,f)=>{const x=2*Math.PI*f/i.length-Math.PI/2;o.set(m,{x:u+h*Math.cos(x),y:d+h*Math.sin(x)})}),o}function sE(e,n=.12){let a;function i(o){for(const u of a){const d=e.get(u.category)||e.get("general");d&&u.x!==void 0&&u.y!==void 0&&(u.vx=(u.vx||0)+(d.x-u.x)*o*n,u.vy=(u.vy||0)+(d.y-u.y)*o*n)}}return i.initialize=function(o){a=o},i}function oE(e){return e.map(n=>{let a=0;for(const o of n.nodes){const u=(o.x??0)-n.centerX,d=(o.y??0)-n.centerY,h=Math.sqrt(u*u+d*d);h>a&&(a=h)}const i=Math.max(40,n.count*8);return{...n,radius:a+i}})}function cE(e,n,a,i){if(!e)return a;const o=new Set([e]),u=new Set;let d=new Set([e]);for(let h=0;h<i;h++){const m=new Set;for(const f of d)if(!u.has(f)){u.add(f);for(const x of n){const y=typeof x.source=="string"?x.source:x.source.id,v=typeof x.target=="string"?x.target:x.target.id;y===f&&!o.has(v)&&(o.add(v),m.add(v)),v===f&&!o.has(y)&&(o.add(y),m.add(y))}}d=m}return o}function uE({docs:e,onNodeClick:n,selectedDocId:a,matchedIds:i,localGraphMode:o,onLocalModeChange:u}){var J;const d=w.useRef(null),h=w.useRef(null),[m,f]=w.useState({width:600,height:400}),[x,y]=w.useState({nodes:[],links:[]}),[v,b]=w.useState(null),[j,k]=w.useState(null),[N,C]=w.useState({x:0,y:0}),[E,R]=w.useState({x:0,y:0,w:600,h:400}),M=w.useRef(!1),I=w.useRef({x:0,y:0,vx:0,vy:0}),B=w.useRef(null),L=w.useRef(null),H=w.useMemo(()=>rE(E.w),[E.w]),Q=w.useMemo(()=>aE(x.nodes),[x.nodes]),A=w.useMemo(()=>oE(Q),[Q]),$=w.useMemo(()=>{if(o==="global"||!a)return null;const K=new Set(x.nodes.map(F=>F.id)),D=o==="1-hop"?1:2;return cE(a,x.links,K,D)},[o,a,x.nodes,x.links]);w.useEffect(()=>{const K=d.current;if(!K)return;const D=new ResizeObserver(F=>{const{width:q,height:T}=F[0].contentRect;q>0&&T>0&&(f({width:q,height:T}),R(de=>({...de,w:q,h:T})))});return D.observe(K),()=>D.disconnect()},[]),w.useEffect(()=>{if(e.length===0)return;const K=new Set(e.map(Te=>Te.id)),D=e.map(Te=>({id:Te.id,title:Te.title,category:Te.category,akb_type:Te.akb_type,tldr:Te.tldr,tags:Te.tags})),F=(Te,xt)=>{if(!xt.startsWith(".")&&!xt.startsWith("/"))return xt;const ut=Te.split("/");ut.pop();const mt=xt.split("/");for(const wt of mt)wt===".."?ut.pop():wt!=="."&&wt!==""&&ut.push(wt);return ut.join("/")},q=[];for(const Te of e)for(const xt of Te.links){const ut=F(Te.id,xt.href);K.has(ut)&&ut!==Te.id&&(q.some(mt=>mt.source===Te.id&&mt.target===ut||mt.source===ut&&mt.target===Te.id)||q.push({source:Te.id,target:ut,label:xt.text}))}const{width:T,height:de}=m,Ne=D.length,ye=Ne>100?-600:Ne>50?-500:-400,_e=Ne>100?180:Ne>50?160:140,Pe=Ne>100?60:50,Ve=Math.max(T,Ne*12),lt=Math.max(de,Ne*10),dt=iE(Ve,lt,D),Ce=pN(D).force("link",eN(q).id(Te=>Te.id).distance(_e)).force("charge",xN().strength(ye)).force("center",RC(Ve/2,lt/2)).force("collide",ZC(Pe)).force("cluster",sE(dt,.15));L.current=Ce,Ce.on("tick",()=>{y({nodes:[...D],links:[...q]})}),Ce.alpha(1).restart();const We=Ne>100?300:150;for(let Te=0;Te<We;Te++)Ce.tick();if(Ce.stop(),y({nodes:[...D],links:[...q]}),D.length>0){let Te=1/0,xt=1/0,ut=-1/0,mt=-1/0;for(const qt of D){const $t=qt.x??0,Ct=qt.y??0;$t<Te&&(Te=$t),Ct<xt&&(xt=Ct),$t>ut&&(ut=$t),Ct>mt&&(mt=Ct)}const wt=100;R({x:Te-wt,y:xt-wt,w:Math.max(T,ut-Te+wt*2),h:Math.max(de,mt-xt+wt*2)})}return()=>{Ce.stop()}},[e,m]);const U=K=>{if(typeof K=="string"){const D=x.nodes.find(F=>F.id===K);return{x:(D==null?void 0:D.x)??0,y:(D==null?void 0:D.y)??0}}return{x:K.x??0,y:K.y??0}},ee=w.useCallback(K=>{K.preventDefault();const D=K.deltaY>0?1.1:.9;R(F=>{const q=Math.max(200,Math.min(m.width*3,F.w*D)),T=Math.max(150,Math.min(m.height*3,F.h*D)),de=(q-F.w)/2,Ne=(T-F.h)/2;return{x:F.x-de,y:F.y-Ne,w:q,h:T}})},[m]),oe=w.useCallback(K=>{K.button===0&&(M.current=!0,I.current={x:K.clientX,y:K.clientY,vx:E.x,vy:E.y})},[E]),ne=w.useCallback(K=>{var D;if(B.current){const F=h.current;if(!F)return;const q=F.getBoundingClientRect(),T=E.w/q.width,de=E.h/q.height,Ne=E.x+(K.clientX-q.left)*T,ye=E.y+(K.clientY-q.top)*de;B.current.fx=Ne,B.current.fy=ye,(D=L.current)==null||D.alpha(.3).restart();return}if(M.current){const F=(K.clientX-I.current.x)*(E.w/m.width),q=(K.clientY-I.current.y)*(E.h/m.height);R(T=>({...T,x:I.current.vx-F,y:I.current.vy-q}))}},[E,m]),Y=w.useCallback(()=>{M.current=!1,B.current&&(B.current.fx=null,B.current.fy=null,B.current=null)},[]),ue=w.useCallback((K,D)=>{var F;K.stopPropagation(),B.current=D,(F=L.current)==null||F.alpha(.3).restart()},[]);return l.jsxs("div",{ref:d,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[l.jsxs("svg",{ref:h,width:m.width,height:m.height,viewBox:`${E.x} ${E.y} ${E.w} ${E.h}`,style:{display:"block",cursor:M.current?"grabbing":"grab"},onWheel:ee,onMouseDown:oe,onMouseMove:ne,onMouseUp:Y,onMouseLeave:Y,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:E.x-100,y:E.y-100,width:E.w+200,height:E.h+200,fill:"url(#grid)",pointerEvents:"none"}),H==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:Q.map(K=>{const D=ra[K.domain]??ra.general,F=Math.max(40,Math.sqrt(K.count)*25),T=i===null||K.nodes.some(de=>i.has(de.id))?1:.4;return l.jsxs("g",{transform:`translate(${K.centerX}, ${K.centerY})`,style:{cursor:"pointer",opacity:T,transition:"opacity 0.3s ease"},onMouseEnter:de=>{var ye;const Ne=(ye=d.current)==null?void 0:ye.getBoundingClientRect();Ne&&C({x:de.clientX-Ne.left,y:de.clientY-Ne.top}),b({id:`cluster-${K.domain}`,title:`${K.domain} (${K.count})`,category:K.domain,akb_type:"hub"})},onMouseLeave:()=>b(null),children:[l.jsx("circle",{r:F,fill:D.bg,stroke:D.border,strokeWidth:3,opacity:.8}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:16,fontFamily:"monospace",fontWeight:"bold",style:{pointerEvents:"none"},children:K.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",K.count,")"]})]},K.domain)})}),H!=="macro"&&l.jsxs(l.Fragment,{children:[H==="standard"&&A.map(K=>{const D=ra[K.domain]??ra.general;if(K.count<2)return null;const F=i===null||K.nodes.some(T=>i.has(T.id)),q=F?.08:.04;return l.jsxs("g",{children:[l.jsx("circle",{cx:K.centerX,cy:K.centerY,r:K.radius,fill:D.bg,stroke:D.border,strokeWidth:1,strokeDasharray:"6 4",opacity:q,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:K.centerX,y:K.centerY-K.radius-8,textAnchor:"middle",fill:D.text,fontSize:10,fontFamily:"monospace",fontWeight:"600",opacity:F?.6:.2,style:{pointerEvents:"none",transition:"opacity 0.3s ease"},children:[K.domain," (",K.count,")"]})]},`cluster-bg-${K.domain}`)}),x.links.map((K,D)=>{const F=U(K.source),q=U(K.target),T=j===D,de=(F.x+q.x)/2,Ne=(F.y+q.y)/2,ye=typeof K.source=="string"?K.source:K.source.id,_e=typeof K.target=="string"?K.target:K.target.id,Ve=$===null||$.has(ye)&&$.has(_e)?1:.25;return l.jsxs("g",{style:{opacity:Ve,transition:"opacity 0.3s ease"},children:[l.jsx("line",{x1:F.x,y1:F.y,x2:q.x,y2:q.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>k(D),onMouseLeave:()=>k(null)}),l.jsx("line",{x1:F.x,y1:F.y,x2:q.x,y2:q.y,stroke:T?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.3)",strokeWidth:T?2:1.5,strokeDasharray:"4 3",pointerEvents:"none"}),T&&K.label&&l.jsx("text",{x:de,y:Ne-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:K.label.length>30?K.label.slice(0,28)+"..":K.label})})]},D)}),x.nodes.map(K=>{const D=ra[K.category]??ra.general,F=K.akb_type==="hub",q=F?24:16,T=H==="micro"?q*1.5:q,de=(v==null?void 0:v.id)===K.id,Ne=a===K.id,ye=de?1.1:Ne?1.05:1,_e=i===null||i.has(K.id),Pe=$===null||$.has(K.id),Ve=_e&&Pe?1:.35,lt=H==="micro"?lE(K.tldr,50):"",dt=H==="micro"&&K.tags?K.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${K.x??0}, ${K.y??0}) scale(${ye})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:Ve},onClick:Ce=>{Ce.stopPropagation();const We=e.find(Te=>Te.id===K.id);We&&n(We)},onMouseDown:Ce=>ue(Ce,K),onMouseEnter:Ce=>{var Te;b(K);const We=(Te=d.current)==null?void 0:Te.getBoundingClientRect();We&&C({x:Ce.clientX-We.left,y:Ce.clientY-We.top})},onMouseLeave:()=>b(null),children:[Ne&&l.jsx("rect",{x:-T/2-4,y:-T/2-4,width:T+8,height:T+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:F?5:2,opacity:.6}),l.jsx("rect",{x:-T/2,y:-T/2,width:T,height:T,fill:D.border,rx:F?4:2,opacity:de?1:.9}),l.jsx("rect",{x:-T/2+3,y:-T/2+3,width:Math.max(0,T-6),height:Math.max(0,T-6),fill:D.bg,rx:F?3:1}),l.jsx("text",{y:T/2+14,textAnchor:"middle",fill:Ne?"#e2e8f0":"#94a3b8",fontSize:H==="micro"?10:11,fontFamily:"monospace",fontWeight:Ne?"bold":"normal",style:{pointerEvents:"none"},children:K.title.length>24?K.title.slice(0,22)+"..":K.title}),H==="micro"&<&&l.jsx("text",{y:T/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:8,fontFamily:"system-ui, sans-serif",opacity:.7,style:{pointerEvents:"none"},children:lt}),H==="micro"&&dt.length>0&&l.jsx("g",{transform:`translate(0, ${T/2+(lt?42:28)})`,children:dt.map((Ce,We)=>{const Te=Ce.length*5+8;let ut=-dt.reduce((mt,wt)=>mt+wt.length*5+10,0)/2;for(let mt=0;mt<We;mt++)ut+=dt[mt].length*5+10;return l.jsxs("g",{transform:`translate(${ut+Te/2}, 0)`,children:[l.jsx("rect",{x:-Te/2,y:-6,width:Te,height:12,fill:D.bg,stroke:D.border,strokeWidth:.5,rx:3}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:7,fontFamily:"monospace",style:{pointerEvents:"none"},children:Ce})]},Ce)})})]},K.id)})]})]}),v&&!B.current&&l.jsxs("div",{className:"absolute z-10 pointer-events-none p-2.5 rounded text-xs max-w-[240px]",style:{left:Math.min(N.x+16,m.width-250),top:Math.max(N.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:v.title}),l.jsxs("div",{className:"text-[10px] opacity-60 mb-1",children:[v.akb_type.toUpperCase()," / ",v.category]}),v.id.startsWith("cluster-")?l.jsx("div",{className:"text-[10px] text-green-400",children:"Zoom in to see documents"}):l.jsxs(l.Fragment,{children:[((J=e.find(K=>K.id===v.id))==null?void 0:J.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(K=>K.id===v.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:H==="macro"?"#f59e0b":H==="micro"?"#22c55e":"#94a3b8",transition:"color 0.3s ease"},children:[H==="macro"&&"📍 Overview",H==="standard"&&"📍 Standard",H==="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(K=>{const D=o===K,F=K!=="global"&&!a,q=K==="global"?"🌐 All":K==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!F&&u(K),disabled:F,className:"px-2 py-1 text-[10px] font-medium cursor-pointer transition-all",style:{background:D?"rgba(22,163,106,0.3)":"transparent",color:F?"var(--terminal-text-muted)":D?"#4ade80":"var(--terminal-text-secondary)",opacity:F?.4:1,cursor:F?"not-allowed":"pointer"},title:F?"Select a node first":`Show ${K==="global"?"all nodes":`nodes within ${K}`}`,children:q},K)})}),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 dE(e){const n=[],a=new Map;return[...e].sort((o,u)=>o.id.localeCompare(u.id)).forEach(o=>{const u=o.id.split("/");let d=n,h="";for(let m=0;m<u.length-1;m++)if(h=h?`${h}/${u[m]}`:u[m],a.has(h))d=a.get(h).children;else{const f={type:"folder",name:u[m],path:h,children:[]};a.set(h,f),d.push(f),d=f.children}d.push({type:"file",name:u[u.length-1],path:o.id,doc:o})}),n}function fE({docs:e,onDocumentClick:n,selectedDocId:a,matchedIds:i}){const[o,u]=w.useState(new Set(["knowledge","projects","architecture","operations","company"])),[d,h]=w.useState(null),[m,f]=w.useState([]),[x,y]=w.useState(-1),v=w.useMemo(()=>dE(e),[e]),b=I=>{u(B=>{const L=new Set(B);return L.has(I)?L.delete(I):L.add(I),L})},j=I=>{h(I),n(I);const B=m.slice(0,x+1);B.push(I),B.length>10&&B.shift(),f(B),y(B.length-1)},k=()=>{h(null),n(null)},N=()=>{if(x>0){const I=x-1;y(I),h(m[I]),n(m[I])}},C=()=>{if(x<m.length-1){const I=x+1;y(I),h(m[I]),n(m[I])}},E=I=>{const B=m.indexOf(I);B!==-1&&(y(B),h(I),n(I))},R=I=>{I==="hub"&&k()},M=d?e.find(I=>I.id===d):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"}),v.map(I=>l.jsx(rv,{node:I,level:0,expandedFolders:o,selectedDocId:a,viewingDocId:d,onToggleFolder:b,onFileClick:j,matchedIds:i},I.path))]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:M?l.jsx(mE,{doc:M,onClose:k,onBreadcrumbClick:R,history:m,historyIndex:x,onHistoryBack:N,onHistoryForward:C,onHistoryJump:E,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 rv({node:e,level:n,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:h}){var b,j,k;const m=a.has(e.path),f=e.type==="file"&&e.path===i,x=e.type==="file"&&e.path===o,y=((b=e.doc)==null?void 0:b.akb_type)==="hub",v=e.type==="folder"||h===null||h.has(e.path);if(e.type==="folder"){const N=h===null||(((j=e.children)==null?void 0:j.some(C=>{if(C.type==="file")return h.has(C.path);const E=R=>{var M;return R.type==="file"?h.has(R.path):((M=R.children)==null?void 0:M.some(E))??!1};return E(C)}))??!1);return l.jsxs("div",{style:{opacity:N?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:n*12+4},onClick:()=>u(e.path),children:[l.jsx("span",{className:"text-[10px]",children:m?"📂":"📁"}),l.jsx("span",{className:"text-[11px]",style:{color:"var(--terminal-text)"},children:e.name})]}),m&&((k=e.children)==null?void 0:k.map(C=>l.jsx(rv,{node:C,level:n+1,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:h},C.path)))]})}return l.jsxs("div",{className:`flex items-center gap-1 py-0.5 px-1 rounded cursor-pointer transition-colors ${x?"bg-green-500/20":f?"bg-white/10":"hover:bg-white/5"}`,style:{paddingLeft:n*12+4,opacity:v?1:.45,transition:"opacity 0.2s ease"},onClick:()=>d(e.path),children:[l.jsx("span",{className:"text-[10px]",children:y?"📘":"📄"}),l.jsx("span",{className:`text-[11px] truncate ${y?"font-semibold":""}`,style:{color:y?"#16a34a":"var(--terminal-text)"},children:e.name})]})}function hE(e){const n=e.split(`
|
|
82
|
+
`),a=[],i=new Map;for(const o of n){const u=o.match(/^(#{2,3})\s+(.+)$/);if(!u)continue;const d=u[1].length,h=u[2].trim();let m=h.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;a.push({id:x,text:h,level:d})}return a}function mE({doc:e,onClose:n,onBreadcrumbClick:a,history:i,historyIndex:o,onHistoryBack:u,onHistoryForward:d,onHistoryJump:h,allDocs:m}){const[f,x]=w.useState(null),[y,v]=w.useState(!1),[b,j]=w.useState(null),k=w.useRef(null),[N,C]=w.useState(null);w.useEffect(()=>{if("content"in e&&e.content){x(e);return}v(!0),j(null),ke.getKnowledgeDoc(e.id).then(x).catch(A=>j(A instanceof Error?A.message:"Failed to load")).finally(()=>v(!1))},[e]);const E=w.useMemo(()=>!f||e.format==="html"?[]:hE(f.content),[f,e.format]),R=A=>{if(!k.current)return;const $=k.current.querySelectorAll("h2, h3");for(const U of $){const oe=(U.textContent||"").toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(A.startsWith(oe)){U.scrollIntoView({behavior:"smooth",block:"start"}),C(A);break}}},M=nE(e.category),I=e.akb_type==="hub",B=E.length>0&&!y&&!b,L=i.slice(0,o).reverse().filter(A=>A!==e.id).slice(0,3).map(A=>m.find($=>$.id===A)).filter(A=>A!==void 0),H=o>0,Q=o<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:u,disabled:!H,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:d,disabled:!Q,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(A=>l.jsxs("button",{onClick:()=>h(A.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:A.title,children:["📄 ",A.title.length>15?A.title.slice(0,15)+"...":A.title]},A.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:()=>a("hub"),className:"hover:underline cursor-pointer",style:{color:"var(--active-green)"},children:"Knowledge Hub"}),l.jsx("span",{children:"›"}),l.jsx("span",{style:{color:M.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:n,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:I?"📘":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(A=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium",style:{background:M.bg,color:M.text,border:`1px solid ${M.border}`},children:A},A))})]})]}),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:k,className:"flex-1 overflow-y-auto p-4",children:[y&&l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"Loading..."}),b&&l.jsx("div",{className:"text-xs p-2 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:b}),f&&l.jsx(js,{content:f.content})]}),B&&l.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:180,background:"var(--hud-bg-alt)",borderLeft:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase mb-2",style:{color:"var(--terminal-text-muted)"},children:"Contents"}),l.jsx("div",{className:"space-y-1",children:E.map(A=>l.jsx("button",{onClick:()=>R(A.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(A.level-2)*8+8,color:N===A.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:N===A.id?"bold":"normal"},children:A.text.length>30?A.text.slice(0,28)+"..":A.text},A.id))})]})]})]})}const pE=500,Iy=360,xE=700;function Xo(e,n,a){const i=n??pE,[o,u]=w.useState(i),[d,h]=w.useState(!1),m=w.useRef(0),f=w.useRef(0),x=w.useRef(a);x.current=a;const y=e>0,v=y?e:0,b=Math.max(xE,i),j=y?Math.max(Iy,window.innerWidth-e-100):b,k=Math.min(o,j),N=w.useCallback(C=>{C.preventDefault(),m.current=C.clientX,f.current=k,h(!0);const E=()=>{h(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",E)},R=M=>{const I=m.current-M.clientX,B=f.current+I;if(B>=window.innerWidth*.6&&x.current){E(),x.current();return}const L=Math.min(b,Math.max(Iy,B));u(L)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",E)},[k]);return{panelRight:v,panelWidth:k,isResizing:d,handleResizeStart:N}}function Hy({docs:e,onClose:n,onRefresh:a,terminalWidth:i=0,initialDocId:o,onMaximize:u}){const[d,h]=w.useState(()=>{const A=localStorage.getItem("kb-view-mode");return A==="graph"||A==="tree"||A==="list"?A:"graph"}),[m,f]=w.useState(null),[x,y]=w.useState("global"),[v,b]=w.useState(""),[j,k]=w.useState(()=>new Set(Object.keys(ra)));w.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const N=w.useMemo(()=>new Ss(e,{keys:["title","tldr","tags"],threshold:.3,includeScore:!0}),[e]),C=w.useMemo(()=>{let A=new Set(e.map($=>$.id));if(v.trim()){const $=N.search(v);A=new Set($.map(U=>U.item.id))}return A=new Set(Array.from(A).filter($=>{const U=e.find(ee=>ee.id===$);return U&&j.has(U.category)})),A.size===e.length?null:A},[e,v,N,j]),E=w.useMemo(()=>C===null?e:e.filter(A=>C.has(A.id)),[e,C]),R=A=>{k($=>{const U=new Set($);return U.has(A)?U.delete(A):U.add(A),U})},{panelRight:M,panelWidth:I,isResizing:B,handleResizeStart:L}=Xo(i,void 0,u),H=A=>{f(A.id)},Q=m?e.find(A=>A.id===m):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:M},onClick:n}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${B?"resizing":""}`,style:{right:M,width:I,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 ${B?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:L}),l.jsxs("div",{className:"p-5 text-white relative",style:{background:"#16a34a"},children:[l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1",children:[u&&l.jsx("button",{onClick:u,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:n,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:["📚"," Knowledge Base"]}),l.jsxs("div",{className:"text-xs opacity-80 mt-0.5",children:[e.length," documents"]})]}),l.jsxs("div",{className:"flex gap-1 p-2",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx(Ch,{icon:"🕸️",label:"Graph",active:d==="graph",onClick:()=>h("graph")}),l.jsx(Ch,{icon:"🌲",label:"Tree",active:d==="tree",onClick:()=>{h("tree"),f(null)}}),l.jsx(Ch,{icon:"📋",label:"List",active:d==="list",onClick:()=>{h("list"),f(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:v,onChange:A=>b(A.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)"}}),v&&l.jsx("button",{onClick:()=>b(""),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:Object.entries(ra).map(([A,$])=>{const U=j.has(A);return l.jsx("button",{onClick:()=>R(A),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:U?$.bg:"transparent",color:U?$.text:"var(--terminal-text-muted)",border:`1px solid ${U?$.border:"var(--terminal-border)"}`,opacity:U?1:.5},children:A},A)})}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:E.length===e.length?`${e.length} documents`:`${E.length} of ${e.length} documents`})]}),d==="graph"&&l.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col animate-fadeIn",children:[l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx(uE,{docs:e,onNodeClick:H,selectedDocId:m,matchedIds:C,localGraphMode:x,onLocalModeChange:y}),Q&&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((A,$)=>l.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",A.text]},$))]})]})]}),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:Object.entries(ra).map(([A,$])=>l.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[l.jsx("div",{className:"w-2 h-2",style:{background:$.border}}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:A})]},A))})})]}),d==="tree"&&l.jsx(fE,{docs:e,onDocumentClick:A=>f(A),selectedDocId:m,matchedIds:C}),d==="list"&&l.jsx(yE,{icon:"📋",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"})]})]})}function Ch({icon:e,label:n,active:a,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:a?"rgba(22,163,106,0.2)":"transparent",color:a?"#4ade80":"var(--terminal-text-muted)",border:a?"1px solid rgba(22,163,106,0.4)":"1px solid transparent"},children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{children:n})]})}function yE({icon:e,title:n,message:a,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:n}),l.jsx("div",{className:"text-sm mb-3",style:{color:"#4ade80"},children:a}),l.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:i})]})})}function Uy({waves:e,decisions:n,mode:a,onClose:i,onOpenWaveCenter:o,onUpdateDecision:u,onDeleteDecision:d,terminalWidth:h=0,onMaximize:m}){const[f,x]=w.useState("decisions"),{panelRight:y,panelWidth:v,isResizing:b,handleResizeStart:j}=Xo(h,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:y},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)] ${b?"resizing":""}`,style:{right:y,width:v,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 ${b?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:j}),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(Nh,{label:`Decisions (${n.length})`,active:f==="decisions",onClick:()=>x("decisions")}),o?l.jsx(Nh,{label:"Waves →",active:!1,onClick:o}):l.jsx(Nh,{label:`Waves (${e.length})`,active:f==="waves",onClick:()=>x("waves")})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[f==="decisions"&&(n.length>0?n.map(k=>l.jsx(gE,{decision:k,onSave:u,onDelete:d},k.id)):l.jsx("div",{className:"text-center py-10 text-sm",style:{color:"var(--terminal-text-muted)"},children:"No decisions yet"})),f==="waves"&&e.map((k,N)=>l.jsx(bE,{title:`Wave ${k.id}`,subtitle:k.startedAt,content:k.directive},N))]})]})]})}function gE({decision:e,onSave:n,onDelete:a}){const[i,o]=w.useState(!1),[u,d]=w.useState(!1),[h,m]=w.useState(e.content),[f,x]=w.useState(!1),y=av(e.content).slice(0,160),v=e.content.length>100,b=w.useCallback(async()=>{if(!n||h===e.content){d(!1);return}x(!0);try{await n(e.id,h),d(!1)}finally{x(!1)}},[n,h,e.id,e.content]),j=w.useCallback(async()=>{if(a){x(!0);try{await a(e.id)}finally{x(!1)}}},[a,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:()=>{u||o(!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&&!u&&n&&l.jsx("button",{onClick:k=>{k.stopPropagation(),m(e.content),d(!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&&u?l.jsxs("div",{className:"px-3 pb-3 pt-2",style:{borderTop:"1px solid var(--terminal-border)"},children:[l.jsx("textarea",{value:h,onChange:k=>m(k.target.value),className:"w-full rounded-lg p-3 text-xs leading-relaxed resize-none font-mono terminal-scrollbar focus:outline-none",style:{background:"var(--terminal-inline-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",minHeight:200},rows:12}),l.jsxs("div",{className:"flex items-center justify-between mt-2",children:[l.jsx("div",{children:a&&l.jsx("button",{onClick:j,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:()=>d(!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:b,disabled:f||h===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(js,{content:e.content})}):null,!i&&v&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:y})]})}function Nh({label:e,active:n,onClick:a}){return l.jsx("button",{onClick:a,className:"px-4 py-2.5 text-sm font-medium cursor-pointer",style:{color:n?"var(--accent)":"var(--terminal-text-muted)",borderBottom:n?"2px solid var(--accent)":"2px solid transparent"},children:e})}function av(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 bE({title:e,subtitle:n,content:a}){const[i,o]=w.useState(!1),u=a.length>100,d=av(a).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:()=>o(!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?"▲":"▼"})]}),n&&l.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:n})]}),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(js,{content:a})}),!i&&u&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:d})]})}const Si=[{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"}}],Uu=[{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"]}],vE={completedQuests:[],activeChapter:1,sideQuestsCompleted:[]};function qy(){return{...vE}}function qu(e,n){return n.completedQuests.includes(e.id)?"completed":e.chapter<n.activeChapter?"skipped":"active"}function wE(e){return Si.filter(n=>{const a=qu(n,e);return a==="active"||a==="skipped"})}function kE(e){const n=Uu.find(a=>a.num===e.activeChapter);return n?Si.find(a=>n.questIds.includes(a.id)&&qu(a,e)==="active")??null:null}function jE(e,n){const a=Si.find(o=>o.id===n);return a?e.completedQuests.includes(n)?{progress:e,quest:null}:{progress:{...e,completedQuests:[...e.completedQuests,n],firstCompletedAt:e.firstCompletedAt??new Date().toISOString()},quest:a}:{progress:e,quest:null}}function Yy(e){let n=1;for(const a of Uu)if(a.questIds.every(i=>e.completedQuests.includes(i))){const i=Uu.find(o=>o.num===a.num+1);i&&(n=i.num)}return n!==e.activeChapter?{...e,activeChapter:n}:e}function SE(e){const n=Si.filter(i=>i.type==="main").length;return{completed:e.completedQuests.filter(i=>{var o;return((o=Si.find(u=>u.id===i))==null?void 0:o.type)==="main"}).length,total:n}}function CE(e,n){if(e.trigger.type!==n.type)return!1;if(e.trigger.condition&&n.condition){for(const[a,i]of Object.entries(e.trigger.condition))if(a==="minRoles"){if(n.condition.roleCount<i)return!1}else if(n.condition[a]!==i)return!1}return!0}function NE({progress:e,onQuestAction:n,onClose:a,terminalWidth:i=0}){const{completed:o,total:u}=SE(e),d=u>0?Math.round(o/u*100):0,{panelRight:h,panelWidth:m,isResizing:f,handleResizeStart:x}=Xo(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:h},onClick:a}),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:h,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:a,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:[o,"/",u," quests completed · ",d,"%"]})]})]}),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:`${d}%`,background:"#F4D03F"}})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-5 flex flex-col gap-3",children:Uu.map(y=>{const v=Si.filter(k=>y.questIds.includes(k.id)),b=v.every(k=>e.completedQuests.includes(k.id)),j=v.some(k=>qu(k,e)==="active");return l.jsxs("div",{className:"rounded-lg",style:{background:j?"var(--hud-bg-alt)":"transparent",border:j?"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:b?"✅":"🟡"}),l.jsxs("span",{className:"text-sm font-medium",style:{color:j?"var(--accent)":"var(--terminal-text)"},children:["Chapter ",y.num,": ",y.title]})]}),l.jsx("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:v.map(k=>{const N=qu(k,e),C=N==="completed",E=N==="skipped";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?"☑":E?"◻":"☐"}),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||E?"var(--terminal-text-muted)":"var(--terminal-text)",textDecoration:C?"line-through":"none",opacity:E?.5:1},children:k.title}),N==="active"&&k.hint&&n&&l.jsx("button",{onClick:()=>n(k.id),className:"shrink-0 text-[10px] px-2 py-0.5 rounded cursor-pointer hover:brightness-125 transition-all",style:{background:"var(--accent)",color:"#000",fontWeight:600},children:"GO →"})]}),N==="active"&&l.jsx("div",{className:"text-[10px] mt-1 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:k.description}),N==="active"&&k.hint&&l.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:"var(--accent)"},children:["💡 ",k.hint.message]})]})]},k.id)})})]},y.num)})})]})]})}function EE({projectId:e,onClose:n,terminalWidth:a=0}){const[i,o]=w.useState(null),{panelRight:u,panelWidth:d,isResizing:h,handleResizeStart:m}=Xo(a);if(w.useEffect(()=>{ke.getProject(e).then(o).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:u},onClick:n}),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:u,width:d,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(v=>v.status==="done").length,x=i.tasks.length,y=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:u},onClick:n}),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)] ${h?"resizing":""}`,style:{right:u,width:d,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 ${h?"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:n,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: ",y,"%"]})]}),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:`${y}%`}})})]}),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(js,{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(v=>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:v.title}),l.jsx(AE,{status:v.status})]}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-muted)"},children:v.role}),v.description&&l.jsx("div",{className:"text-xs mt-1.5 line-clamp-2",style:{color:"var(--terminal-text-secondary)"},children:v.description})]},v.id))})]})]})]})]})}function AE({status:e}){const n={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)"}},a=n[e]??n.todo;return l.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:a.bg,color:a.color},children:e})}const DE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function TE({roleId:e,roleName:n,mode:a="assign",onClose:i,onExecutionStart:o}){const[u,d]=w.useState(""),h=w.useRef(null);w.useEffect(()=>{var y;(y=h.current)==null||y.focus()},[]);const m=()=>{u.trim()&&(o(e,u.trim()),i())},f=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&m(),y.key==="Escape"&&i()},x=DE[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:a==="ask"?"Ask":"Assign Task"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:a==="ask"?`to ${n}`:`to ${n} (${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:h,value:u,onChange:y=>d(y.target.value),onKeyDown:f,placeholder:a==="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:!u.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:a==="ask"?"Ask":"Assign"})]})]})]})}const Xy={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function Xm({event:e,isThinkingCollapsed:n,onToggleThinking:a,onNavigateToJob:i,onOpenKnowledgeDoc:o,compact:u}){var h;const d=Xy[e.roleId]??"#888";switch(e.type){case"text":{const m=e.data.text??"",f=u?m.slice(0,300):m;return/[#*|`\[\]_~>-]/.test(f)?l.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:l.jsx(zm,{remarkPlugins:[$m],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:a,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:n?"▶":"▼"}),l.jsx("span",{className:"italic",children:"thinking..."})]}),!n&&l.jsxs("div",{className:`ml-3 text-[var(--terminal-text-muted)] italic whitespace-pre-wrap opacity-60 text-[11px] overflow-hidden ${u?"max-h-[60px]":"max-h-[120px]"}`,children:[m.slice(0,u?200:500),m.length>(u?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):"",y=typeof(f==null?void 0:f.file_path)=="string"?String(f.file_path):typeof(f==null?void 0:f.path)=="string"?String(f.path):"",v=y?y.split("/").pop()??"":"",b=/^(write_file|Write|edit_file|Edit)$/i.test(m),j=(h=y.match(/(?:^|\/)knowledge\/(.+\.md)$/))==null?void 0:h[1],k=b&&j&&o;return l.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[l.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${k?"text-green-400/80 bg-green-400/10":"text-blue-400/80 bg-blue-400/10"}`,children:k?b&&m.toLowerCase().includes("edit")?"Edit":"Write":m}),k?l.jsx("button",{onClick:()=>o(j),className:"text-[10px] text-green-400 hover:text-green-300 underline underline-offset-2 cursor-pointer truncate",style:{maxWidth:u?200:400},children:v}):l.jsxs(l.Fragment,{children:[x&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:x}),v&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:v})]})]})}case"dispatch:start":{const m=e.data.targetRoleId??e.data.roleId??"",f=e.data.task??"",x=e.data.childJobId,y=Xy[m]??"#888";return l.jsx("div",{className:"my-1 p-2 rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",style:{borderColor:`${y}44`,background:`${y}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:y},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,u?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"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"job:start":return l.jsxs("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pb-1",children:[l.jsx("span",{style:{color:d},className:"font-bold",children:e.roleId.toUpperCase()})," ","started: ",(e.data.task??"").slice(0,u?50:80)]});case"job: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"job: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"job: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"job: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 FE({sessionId:e,title:n,color:a,variant:i,style:o,onClose:u,onMinimize:d,onDone:h,onNavigateToJob:m,onOpenKnowledgeDoc:f}){const{events:x,status:y,textOutput:v,childJobIds:b}=Ag(e),[j,k]=w.useState(0),[N,C]=w.useState(new Set),E=w.useRef(null),R=w.useRef(Date.now()),M=w.useRef(!1);w.useEffect(()=>{const $=setInterval(()=>{k(Math.floor((Date.now()-R.current)/1e3))},1e3);return()=>clearInterval($)},[]),w.useEffect(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[x]),w.useEffect(()=>{(y==="done"||y==="error")&&!M.current&&(M.current=!0,h==null||h())},[y,h]);const I=$=>{C(U=>{const ee=new Set(U);return ee.has($)?ee.delete($):ee.add($),ee})},B={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[y],L={idle:"#888",connecting:"#888",streaming:a,done:"#2E7D32",error:"#C62828"}[y],H=$=>`${Math.floor($/60)}:${String($%60).padStart(2,"0")}`,Q=y==="done"||y==="error",A=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:o,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:L}}),l.jsx("div",{children:l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:n})})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:H(j)}),l.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${L}22`,color:L},children:B}),d&&i==="modal"&&l.jsx("button",{onClick:d,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),Q&&l.jsx("button",{onClick:u,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&&y==="connecting"&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:"Connecting to activity stream..."}),x.map($=>l.jsx(Xm,{event:$,isThinkingCollapsed:N.has($.seq),onToggleThinking:()=>I($.seq),onNavigateToJob:m,onOpenKnowledgeDoc:f},$.seq)),y==="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`,v.length>0&&` · ${v.length} chars`,b.length>0&&` · ${b.length} dispatches`]}),Q&&l.jsx("button",{onClick:u,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer",style:{background:a},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:Q?u:void 0}),A]}):A}const ME={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function RE({orgNodes:e,rootId:n,activeRoles:a,onToggleRole:i}){const o=e[n];if(!o)return null;const u=!!a&&!!i,h=o.children.map(b=>e[b]).filter(Boolean),m=new Map,f=[];for(const b of h){const j=[];for(const k of b.children){const N=e[k];N&&(j.push(N),f.push(N))}m.set(b.id,j)}const x=b=>!a||a.has(b),y=u?h.filter(b=>a.has(b.id)).length+f.filter(b=>a.has(b.id)).length:h.length+f.length,v=h.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:u?"Select Target Roles":"Propagation Preview"}),u&&l.jsxs("span",{className:"text-[10px] text-white/50",children:[y,"/",v," 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"})}),h.length>0&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-3 bg-white/15"})}),h.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(h.length*80,320)}px`}})}),l.jsx("div",{className:"flex justify-center gap-3 mb-2 flex-wrap",children:h.map(b=>{const j=x(b.id),k=ME[b.id]??"#888";return l.jsx(zE,{node:b,active:j,color:k,interactive:u,onToggle:i,subRoles:m.get(b.id)??[],activeRoles:a},b.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(b=>{var E;const j=x(b.id),k=(E=h.find(R=>R.children.includes(b.id)))==null?void 0:E.id,N=k?x(k):!0,C=u&&N;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${C?"cursor-pointer select-none":u?"cursor-not-allowed":""} ${j&&N?"border-white/15 text-white/40":"border-white/5 text-white/15 opacity-50"}`,onClick:C?()=>i(b.id,!j):void 0,title:u?N?j?"Click to exclude":"Click to include":`Enable ${k==null?void 0:k.toUpperCase()} first`:void 0,children:b.id},b.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:u?`${y} role${y!==1?"s":""} will receive this wave`:`${v} role${v!==1?"s":""} will receive this wave`})]})}function zE({node:e,active:n,color:a,interactive:i,onToggle:o,subRoles:u,activeRoles:d}){const h=w.useCallback(m=>{if(!(!i||!o)){if(n){o(e.id,!1);for(const f of u)d!=null&&d.has(f.id)&&o(f.id,!1)}else if(o(e.id,!0),m.shiftKey)for(const f of u)d!=null&&d.has(f.id)||o(f.id,!0)}},[i,o,n,e.id,u,d]);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:n?a:`${a}44`,color:n?a:`${a}44`,background:n?`${a}22`:"transparent",opacity:n?1:.4},onClick:h,title:i?n?"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?n?"active":"off":"direct"})]})}function _E({cLevelRoles:e,orgNodes:n,rootId:a,onClose:i,onDispatch:o}){const[u,d]=w.useState(""),h=w.useRef(null),[m,f]=w.useState(()=>{const k=new Set,N=n[a];if(N)for(const C of N.children){k.add(C);const E=n[C];if(E)for(const R of E.children)k.add(R)}return k});w.useEffect(()=>{var k;(k=h.current)==null||k.focus()},[]);const x=w.useCallback((k,N)=>{f(C=>{const E=new Set(C);return N?E.add(k):E.delete(k),E})},[]),y=e.filter(k=>m.has(k.id)).length,v=()=>{if(!u.trim()||y===0)return;const k=n[a];let N=0;if(k)for(const R of k.children){N++;const M=n[R];M&&(N+=M.children.length)}const E=m.size>=N?void 0:Array.from(m);o(u.trim(),E),i()},b=k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&v(),k.key==="Escape"&&i()},j=a&&Object.keys(n).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:j?"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:[j&&l.jsx(RE,{orgNodes:n,rootId:a,activeRoles:m,onToggleRole:x}),!j&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Dispatching to"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:e.length>0?e.map(k=>l.jsxs("span",{className:"px-3 py-1.5 text-xs font-semibold rounded-lg border-2 border-red-200 bg-red-50 text-red-800",children:[k.id.toUpperCase()," · ",k.name]},k.id)):l.jsx("span",{className:"text-xs text-gray-400 italic",children:"No C-Level roles found"})}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Each C-Level receives the directive and delegates to their reports"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Directive"}),l.jsx("textarea",{ref:h,value:u,onChange:k=>d(k.target.value),onKeyDown:b,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:v,disabled:!u.trim()||y===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 ",y," Role",y!==1?"s":""]})]})]})]})}function lv(e,n,a){const[i,o]=w.useState(new Map),[u,d]=w.useState(null),[h,m]=w.useState(new Set),f=w.useRef(new Map),x=w.useRef(i);x.current=i;const y=w.useRef(!1),v=w.useCallback(()=>{if(!a||Object.keys(n).length===0)return null;const R=new Map,M=new Set,I=L=>{const H=n[L];H&&(M.add(L),R.set(L,{sessionId:"",roleId:L,roleName:H.name,children:H.children,status:"waiting",events:[],streamStatus:"idle"}),H.children.forEach(I))},B=n[a];return B&&(R.set(a,{sessionId:"",roleId:a,roleName:"CEO",children:B.children,status:"not-dispatched",events:[],streamStatus:"idle"}),B.children.forEach(I)),{initial:R,allRoles:M}},[n,a]);w.useEffect(()=>{if(y.current)if(e.length>0)y.current=!1;else return;const R=v();if(!R)return;const{initial:M,allRoles:I}=R;for(const B of e){const L=M.get(B.roleId);L&&(L.sessionId=B.sessionId,L.status="running",L.streamStatus="connecting")}o(M),m(B=>{if(B.size===0){const L=new Set(I);return L.delete(a),L}return B}),e.length>0&&d(B=>B??e[0].roleId)},[e,n,a,v]);const b=w.useCallback(R=>{m(M=>{const I=new Set(M);return I.has(R)?I.delete(R):I.add(R),I})},[]),j=w.useCallback(R=>{for(const[,M]of f.current)M.controller.abort();f.current.clear(),y.current=!0,o(R);for(const[M,I]of R)if(M!==a&&I.events.length>0){d(M);break}},[a]),k=w.useCallback((R,M)=>{const I=f.current.get(R);if(I&&!I.controller.signal.aborted){console.log(`[WaveTree] connectStream SKIP (already connected) → role=${M} session=${R}`);return}I&&I.controller.abort(),console.log(`[WaveTree] connectStream → role=${M} session=${R}`),o(Q=>{const A=new Map(Q),$=A.get(M);return $&&A.set(M,{...$,sessionId:R,status:"running",streamStatus:"connecting",events:[]}),A});const B=new AbortController,L={controller:B,lastSeq:-1};f.current.set(R,L);const H=`/api/sessions/${R}/stream?from=0`;fetch(H,{signal:B.signal}).then(async Q=>{if(!Q.ok||!Q.body){o(oe=>{const ne=new Map(oe),Y=ne.get(M);return Y&&ne.set(M,{...Y,streamStatus:"error"}),ne});return}console.log(`[WaveTree SSE] connected → role=${M} status=${Q.status}`),o(oe=>{const ne=new Map(oe),Y=ne.get(M);return Y&&ne.set(M,{...Y,streamStatus:"streaming",status:"running"}),ne});const A=Q.body.getReader(),$=new TextDecoder;let U="",ee="";for(;;){const{done:oe,value:ne}=await A.read();if(oe)break;U+=$.decode(ne,{stream:!0});const Y=U.split(`
|
|
83
|
+
`);U=Y.pop()??"";for(const ue of Y)if(ue.startsWith("event: "))ee=ue.slice(7).trim();else if(ue.startsWith("data: ")){try{const J=JSON.parse(ue.slice(6));if(console.log(`[WaveTree SSE] role=${M} event=${ee} type=${(J==null?void 0:J.type)??"?"} seq=${(J==null?void 0:J.seq)??"?"}`),ee==="activity"){const K=J;K.seq>L.lastSeq&&(L.lastSeq=K.seq),o(D=>{const F=new Map(D),q=F.get(M);if(!q||q.events.some(de=>de.seq===K.seq))return D;const T={...q,events:[...q.events,K]};if(K.type==="dispatch:start"&&K.data.childJobId){const de=K.data.targetRoleId??K.data.roleId,Ne=K.data.childSessionId;if(console.log(`[WaveTree] dispatch:start → target=${de} childSession=${Ne??"none"} from=${M}`),de&&Ne){const ye=F.get(de);ye&&(F.set(de,{...ye,sessionId:Ne,status:"running",streamStatus:"connecting"}),setTimeout(()=>k(Ne,de),0))}}return K.type==="job:done"?(T.status="done",T.streamStatus="done"):K.type==="job:error"?(T.status="error",T.streamStatus="error"):K.type==="job:awaiting_input"?(T.status="awaiting_input",T.streamStatus="done"):K.type==="job:reply"&&(T.status="running",T.streamStatus="streaming"),F.set(M,T),F})}else if(ee==="stream:end"){const K=J.reason;K!=="replied"&&o(D=>{const F=new Map(D),q=F.get(M);if(!q)return D;const T=K==="error"?"error":K==="awaiting_input"?"awaiting_input":"done";return F.set(M,{...q,status:q.status==="running"?T:q.status,streamStatus:T==="error"?"error":"done"}),F})}}catch{}ee=""}}}).catch(Q=>{Q.name!=="AbortError"&&o(A=>{const $=new Map(A),U=$.get(M);return U&&$.set(M,{...U,streamStatus:"error"}),$})})},[]),N=w.useRef(new Set);w.useEffect(()=>{if(e.length===0)return;const R=new Set;for(const M of e)R.add(M.sessionId),k(M.sessionId,M.roleId);return N.current=R,()=>{for(const M of N.current){const I=f.current.get(M);I&&(I.controller.abort(),f.current.delete(M))}N.current.clear()}},[e,k]);const C=(()=>{let R=0,M=0,I=0,B=0;for(const[L,H]of i)L!==a&&(B++,H.status==="done"?R++:H.status==="running"?M++:H.status==="awaiting_input"&&I++);return{done:R,total:B,running:M,awaitingInput:I}})(),E=C.total>0&&C.running===0&&C.awaitingInput===0&&Array.from(i.values()).every(R=>R.status!=="running"&&R.status!=="awaiting_input"&&R.streamStatus!=="streaming"&&R.streamStatus!=="connecting");return w.useEffect(()=>{E&&o(R=>{const M=new Map(R);let I=!1;for(const[B,L]of M)L.status==="waiting"&&(M.set(B,{...L,status:"not-dispatched"}),I=!0);return I?M:R})},[E]),{nodes:i,selectedRoleId:u,selectNode:d,checkedRoles:h,toggleCheck:b,setCheckedRoles:m,progress:C,allDone:E,connectStream:k,injectStaticNodes:j}}const Wy={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},va=130,Ur=44,Gy=80;function BE(e,n){if(!e.get(n))return{layout:[],width:300,height:200};const i=[],o=[],u=[{id:n,depth:0,parentId:null}],d=new Set;for(;u.length>0;){const{id:x,depth:y,parentId:v}=u.shift();if(d.has(x))continue;for(d.add(x);o.length<=y;)o.push([]);o[y].push(x),i.push({roleId:x,x:0,y:y*Gy+20,parentId:v});const b=e.get(x);if(b)for(const j of b.children)e.has(j)&&!d.has(j)&&u.push({id:j,depth:y+1,parentId:x})}const h=Math.max(...o.map(x=>x.length))*(va+16),m=Math.max(h,280);for(const x of o){const y=x.length*(va+16)-16,v=(m-y)/2;x.forEach((b,j)=>{const k=i.find(N=>N.roleId===b);k&&(k.x=v+j*(va+16))})}const f=o.length*Gy+40;return{layout:i,width:m,height:f}}function iv({nodes:e,rootId:n,selectedRoleId:a,onSelectNode:i,checkedRoles:o,onToggleCheck:u,eligibleRoles:d}){const{layout:h,width:m,height:f}=BE(e,n),x=!!u,y=b=>{const j=h.find(k=>k.roleId===b);return j?{cx:j.x+va/2,cy:j.y+Ur/2}:{cx:0,cy:0}},v=b=>{switch(b.status){case"running":return Wy[b.roleId]??"#FBBF24";case"awaiting_input":return"#F59E0B";case"done":return"#2E7D32";case"error":return"#C62828";case"not-dispatched":return"#666";default:return"#888"}};return l.jsxs("svg",{viewBox:`0 0 ${m} ${f}`,width:Math.max(m,280),height:f,className:"block",style:{minWidth:m},children:[l.jsx("defs",{children:l.jsxs("filter",{id:"glow",children:[l.jsx("feGaussianBlur",{stdDeviation:"2",result:"blur"}),l.jsxs("feMerge",{children:[l.jsx("feMergeNode",{in:"blur"}),l.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),h.filter(b=>b.parentId).map(b=>{const j=y(b.parentId),k=y(b.roleId),N=e.get(b.roleId),C=e.get(b.parentId);let E="rgba(180,200,240,0.15)",R="4 4",M="";return(N==null?void 0:N.status)==="done"||(C==null?void 0:C.status)==="done"?(E="#2E7D3266",R=""):(N==null?void 0:N.status)==="awaiting_input"?(E="#F59E0B",R="6 4",M="wave-edge-flow"):(N==null?void 0:N.status)==="running"&&(E=Wy[b.roleId]??"#FBBF24",R="6 4",M="wave-edge-flow"),l.jsx("line",{x1:j.cx,y1:j.cy+Ur/2-4,x2:k.cx,y2:k.cy-Ur/2+4,stroke:E,strokeWidth:1.5,strokeDasharray:R,className:M},`${b.parentId}-${b.roleId}`)}),h.map(b=>{const j=e.get(b.roleId);if(!j)return null;const k=v(j),N=a===b.roleId,C=b.roleId===n,E=(o==null?void 0:o.has(b.roleId))??!1,R=C?N?.7:.5:j.status==="not-dispatched"&&!E?.35:1;return l.jsxs("g",{transform:`translate(${b.x}, ${b.y})`,style:{cursor:"pointer",opacity:R},onClick:()=>i(b.roleId),children:[l.jsx("rect",{x:0,y:0,width:va,height:Ur,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:N?"#fff":E?"#EF5350":k,strokeWidth:N||E?2:1.5,strokeDasharray:j.status==="not-dispatched"&&!E?"4 3":""}),l.jsx("circle",{cx:14,cy:Ur/2,r:4,fill:k,filter:j.status==="running"||j.status==="awaiting_input"?"url(#glow)":void 0,children:(j.status==="running"||j.status==="awaiting_input")&&l.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),l.jsx("text",{x:26,y:Ur/2-4,fill:"var(--terminal-text, #fff)",fontSize:10,fontWeight:700,fontFamily:"var(--pixel-font)",children:j.roleId.toUpperCase()}),l.jsx("text",{x:26,y:Ur/2+10,fill:"var(--terminal-text-muted, #888)",fontSize:8,fontFamily:"var(--pixel-font)",children:j.status==="running"?"Working...":j.status==="awaiting_input"?"Awaiting Reply":j.status==="done"?"Complete":j.status==="error"?"Error":j.status==="waiting"?"Waiting":""}),j.status==="done"&&!x&&l.jsx("text",{x:va-18,y:Ur/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),j.status==="error"&&!x&&l.jsx("text",{x:va-18,y:Ur/2+4,fontSize:14,fill:"#C62828",children:"✗"}),x&&!C&&(()=>{const M=!d||d.has(b.roleId);return l.jsxs("g",{onClick:I=>{I.stopPropagation(),M&&(u==null||u(b.roleId))},style:{cursor:M?"pointer":"default",opacity:M?1:.2},children:[l.jsx("rect",{x:va-24,y:Ur/2-10,width:20,height:20,fill:"transparent"}),l.jsx("rect",{x:va-20,y:Ur/2-6,width:12,height:12,rx:2,ry:2,fill:E?"#EF5350":"transparent",stroke:E?"#EF5350":"#666",strokeWidth:1.5}),E&&l.jsx("text",{x:va-18,y:Ur/2+4,fontSize:10,fontWeight:700,fill:"#fff",children:"✓"})]})})()]},b.roleId)})]})}const OE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function $E({directive:e,rootJobs:n,orgNodes:a,rootRoleId:i,onClose:o,onMinimize:u,onDone:d,onOpenKnowledgeDoc:h,onSave:m}){const{nodes:f,selectedRoleId:x,selectNode:y,progress:v,allDone:b,connectStream:j}=lv(n,a,i),[k,N]=w.useState(0),[C,E]=w.useState(new Set),[R,M]=w.useState(""),[I,B]=w.useState(!1),[L,H]=w.useState(!1),Q=w.useRef(null),A=w.useRef(Date.now()),$=w.useRef(!1),U=w.useCallback(async()=>{if(m){H(!0);try{const F=n.map(q=>q.jobId).filter(q=>!!q);await m(F)}catch(F){console.error("Save failed:",F)}finally{H(!1),o()}}},[m,n,o]),ee=w.useCallback(async()=>{if(!x||!R.trim())return;const F=f.get(x);if(!(!(F!=null&&F.sessionId)||F.status!=="awaiting_input"&&F.status!=="done")){B(!0);try{await ke.replyToSession(F.sessionId,R.trim()),M(""),j(F.sessionId,x)}catch(q){console.error("Reply failed:",q)}finally{B(!1)}}},[x,R,f,j]),oe=w.useCallback(async F=>{const q=f.get(F);if(q!=null&&q.sessionId)try{await ke.abortSession(q.sessionId)}catch(T){console.error("Abort failed:",T)}},[f]),ne=w.useCallback(async()=>{for(const[,F]of f)if((F.status==="running"||F.status==="awaiting_input")&&F.sessionId)try{await ke.abortSession(F.sessionId)}catch{}},[f]);w.useEffect(()=>{const F=setInterval(()=>{N(Math.floor((Date.now()-A.current)/1e3))},1e3);return()=>clearInterval(F)},[]);const Y=w.useRef(!1);w.useEffect(()=>{const F=Q.current;if(!F)return;const q=()=>{const T=F.scrollHeight-F.scrollTop-F.clientHeight<60;Y.current=!T};return F.addEventListener("scroll",q),()=>F.removeEventListener("scroll",q)},[]),w.useEffect(()=>{Y.current=!1,Q.current&&(Q.current.scrollTop=Q.current.scrollHeight)},[x]),w.useEffect(()=>{Q.current&&!Y.current&&(Q.current.scrollTop=Q.current.scrollHeight)},[f]),w.useEffect(()=>{b&&!$.current&&($.current=!0,d==null||d()),!b&&$.current&&($.current=!1)},[b,d]);const ue=F=>`${Math.floor(F/60)}:${String(F%60).padStart(2,"0")}`,J=x?f.get(x):null,K=x?OE[x]??"#888":"#888",D=F=>{E(q=>{const T=new Set(q);return T.has(F)?T.delete(F):T.add(F),T})};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:b?"#2E7D32":"#B71C1C",animation:b?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:b?"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:ue(k)}),v.awaitingInput>0&&l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[v.awaitingInput," awaiting reply"]}),l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:b?"#2E7D3222":"#B71C1C22",color:b?"#2E7D32":"#B71C1C"},children:[v.done,"/",v.total," done"]}),!b&&(v.running>0||v.awaitingInput>0)&&l.jsx("button",{onClick:ne,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:u,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:b?"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:"running",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(F=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:F.color,animation:F.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:F.label})]},F.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"35vh"},children:l.jsx(iv,{nodes:f,rootId:i,selectedRoleId:x,onSelectNode:y})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[J&&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:K}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:J.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:J.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:J.status==="awaiting_input"?"#F59E0B22":`${K}22`,color:J.status==="awaiting_input"?"#F59E0B":K},children:J.status==="running"?"Working":J.status==="done"?"Complete":J.status==="error"?"Error":J.status==="waiting"?"Waiting":J.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(J.status==="running"||J.status==="awaiting_input")&&J.sessionId&&l.jsx("button",{onClick:()=>oe(J.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 job",children:"Stop"})]}),l.jsxs("div",{ref:Q,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[J&&J.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:J.status==="waiting"?"Waiting for dispatch...":J.status==="running"?"Connecting to activity stream...":J.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),J==null?void 0:J.events.map(F=>l.jsx(Xm,{event:F,isThinkingCollapsed:C.has(F.seq),onToggleThinking:()=>D(F.seq),onNavigateToJob:q=>{const T=J==null?void 0:J.events.find(Ne=>Ne.type==="dispatch:start"&&Ne.data.childJobId===q),de=T==null?void 0:T.data.targetRoleId;de&&f.has(de)&&y(de)},onOpenKnowledgeDoc:h},F.seq)),(J==null?void 0:J.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(J==null?void 0:J.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:[J.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:R,onChange:F=>M(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),ee())},placeholder:"Type your response...",disabled:I,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:ee,disabled:I||!R.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:I?"...":"Reply"})]})]}),(J==null?void 0:J.status)==="done"&&J.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 ",J.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:R,onChange:F=>M(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),ee())},placeholder:"e.g., 좋아 KB-3 진행해, Engineer에게 시켜...",disabled:I,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:ee,disabled:I||!R.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:I?"...":"Send"})]})]}),!J&&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:J&&J.events.length>0&&`${J.events.length} events`}),b&&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"}),m&&l.jsx("button",{onClick:U,disabled:L,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:L?"Saving...":"Save Wave"})]})]})]})]})]})]})}const LE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function Vy({orgNodes:e,rootRoleId:n,cLevelRoles:a,pastWaves:i,activeWaves:o,onDispatch:u,onClose:d,onDone:h,onSave:m,onOpenKnowledgeDoc:f,onRefreshWaves:x,terminalWidth:y=0,onMaximize:v,inline:b=!1,onOpenSaveModal:j}){const[k,N]=w.useState(""),[C,E]=w.useState(null),[R,M]=w.useState(!1),[I,B]=w.useState(o.length>0?0:-1),L=w.useRef(null),H=I>=0?o[I]??null:null,Q=w.useMemo(()=>[],[]),A=(H==null?void 0:H.rootJobs)??Q,$=lv(A,e,n);w.useEffect(()=>{if(C){const Z=IE(e,n,C.roles);$.injectStaticNodes(Z);for(const Me of C.roles??[])if(Me.status==="running"&&Me.jobId){const Ie=Z.get(Me.roleId);Ie!=null&&Ie.sessionId&&setTimeout(()=>$.connectStream(Ie.sessionId,Me.roleId),100)}}},[C,e,n]),w.useEffect(()=>{!$.selectedRoleId&&n&&$.selectNode(n)},[n]),w.useEffect(()=>{o.length>0&&I<0&&(B(0),E(null))},[o.length,I]);const[U,ee]=w.useState(null),oe=w.useMemo(()=>{if(!U)return null;const Z=U.modified.length+U.untracked.length;return{branch:U.branch,dirty:Z>0,count:Z}},[U]),ne=w.useCallback(()=>{ke.getSaveStatus("code").then(Z=>{ee({dirty:Z.modified.length+Z.untracked.length>0,modified:Z.modified,untracked:Z.untracked,lastCommit:Z.lastCommit,branch:Z.branch})}).catch(()=>{})},[]);w.useEffect(()=>{ne()},[ne]);const[Y,ue]=w.useState(0);w.useEffect(()=>{if(!H)return;const Z=setInterval(()=>{ue(Math.floor((Date.now()-H.startedAt)/1e3))},1e3);return()=>clearInterval(Z)},[H]);const[J,K]=w.useState(""),[D,F]=w.useState(!1),[q,T]=w.useState([]),[de,Ne]=w.useState(!1),[ye,_e]=w.useState(null),Pe=w.useRef(null);w.useEffect(()=>{if(ye){const Z=setTimeout(()=>_e(null),3e3);return()=>clearTimeout(Z)}},[ye]);const Ve=w.useCallback(async Z=>["image/png","image/jpeg","image/gif","image/webp"].includes(Z.type)?Z.size>5*1024*1024?(_e(`Too large: ${(Z.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(Ie=>{const St=new FileReader;St.onload=()=>{const Ze=St.result.split(",")[1];Ie({type:"image",data:Ze,name:Z.name,mediaType:Z.type})},St.onerror=()=>{_e("Failed to read file"),Ie(null)},St.readAsDataURL(Z)}):(_e(`Unsupported: ${Z.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),lt=w.useCallback(async Z=>{const Me=[];for(const Ie of Array.from(Z)){const St=await Ve(Ie);St&&Me.push(St)}Me.length>0&&T(Ie=>[...Ie,...Me])},[Ve]),dt=w.useCallback(Z=>{Z.preventDefault(),Z.stopPropagation(),Ne(!0)},[]),Ce=w.useCallback(Z=>{Z.preventDefault(),Z.stopPropagation(),Ne(!1)},[]),We=w.useCallback(Z=>{Z.preventDefault(),Z.stopPropagation(),Ne(!1),Z.dataTransfer.files.length>0&<(Z.dataTransfer.files)},[lt]),Te=w.useCallback(Z=>{const Me=[];for(let Ie=0;Ie<Z.clipboardData.items.length;Ie++){const St=Z.clipboardData.items[Ie];if(St.type.startsWith("image/")){const Ze=St.getAsFile();Ze&&Me.push(Ze)}}Me.length>0&&(Z.preventDefault(),lt(Me))},[lt]),[xt,ut]=w.useState(320),mt=w.useRef(!1),wt=w.useRef(0),qt=w.useRef(0),$t=w.useCallback(Z=>{Z.preventDefault(),mt.current=!0,wt.current=Z.clientX,qt.current=xt;const Me=St=>{if(!mt.current)return;const Ze=wt.current-St.clientX;ut(Math.max(200,Math.min(500,qt.current+Ze)))},Ie=()=>{mt.current=!1,window.removeEventListener("mousemove",Me),window.removeEventListener("mouseup",Ie)};window.addEventListener("mousemove",Me),window.addEventListener("mouseup",Ie)},[xt]),[Ct,Bn]=w.useState(new Set),he=w.useRef(null),ve=w.useRef(!1);w.useEffect(()=>{const Z=he.current;if(!Z)return;const Me=()=>{const Ie=Z.scrollHeight-Z.scrollTop-Z.clientHeight<60;ve.current=!Ie};return Z.addEventListener("scroll",Me),()=>Z.removeEventListener("scroll",Me)},[]),w.useEffect(()=>{!ve.current&&he.current&&(he.current.scrollTop=he.current.scrollHeight)},[$.nodes,$.selectedRoleId]);const ce=$.selectedRoleId?$.nodes.get($.selectedRoleId)??null:null,W=ce?LE[ce.roleId]??"#888":"#888",le=$.progress.running>0||$.progress.awaitingInput>0,we=$.selectedRoleId===n,xe=!!C&&!H,je=(H==null?void 0:H.directive)??(C==null?void 0:C.directive)??"",Re=w.useCallback(Z=>{const Me=new Set,Ie=[Z];for(;Ie.length>0;){const St=Ie.shift();if(Me.has(St))continue;Me.add(St);const Ze=e[St];Ze&&Ie.push(...Ze.children)}return Me},[e]),$e=w.useMemo(()=>{if(!$.selectedRoleId)return new Set;const Z=Re($.selectedRoleId);return Z.delete(n),Z},[$.selectedRoleId,Re,n]),Oe=w.useRef(null);w.useEffect(()=>{if($.selectedRoleId===Oe.current||(Oe.current=$.selectedRoleId,!$.selectedRoleId))return;const Z=Re($.selectedRoleId);Z.delete(n),$.setCheckedRoles(Z)},[$.selectedRoleId,Re,n]);const Le=$.checkedRoles.size,tt=()=>{if(!k.trim()&&q.length===0||Le===0)return;const Me=Array.from($.nodes.keys()).filter(St=>St!==n).every(St=>$.checkedRoles.has(St)),Ie=q.length>0?q:void 0;u(k.trim(),Me?void 0:Array.from($.checkedRoles),Ie),N(""),T([])},Ke=Z=>{Z.key==="Enter"&&(Z.metaKey||Z.ctrlKey)&&(Z.preventDefault(),tt()),Z.key==="Escape"&&d()},jt=w.useCallback(async()=>{if(!$.selectedRoleId||!J.trim()&&q.length===0)return;const Z=$.nodes.get($.selectedRoleId);if(!Z)return;const Me=q.length>0?q:void 0;F(!0);try{if(Z.status==="awaiting_input"&&Z.sessionId){const Ie=await ke.replyToSession(Z.sessionId,J.trim(),Me);K(""),T([]),$.connectStream(Ie.sessionId||Z.sessionId,$.selectedRoleId)}else{const Ie=(H==null?void 0:H.id)??(C==null?void 0:C.waveId)??(C==null?void 0:C.id),St=await ke.startJob({type:"assign",roleId:$.selectedRoleId,task:J.trim(),...Ie&&{waveId:Ie},...Me&&{attachments:Me}});K(""),T([]),St.sessionId&&$.connectStream(St.sessionId,$.selectedRoleId)}}catch(Ie){console.error("Reply failed:",Ie)}finally{F(!1)}},[$,J,q,H,C]),ze=w.useCallback(async Z=>{const Me=$.nodes.get(Z);if(Me!=null&&Me.sessionId)try{await ke.abortSession(Me.sessionId)}catch{}},[$.nodes]),He=w.useCallback(async()=>{for(const[,Z]of $.nodes)if((Z.status==="running"||Z.status==="awaiting_input")&&Z.sessionId)try{await ke.abortSession(Z.sessionId)}catch{}},[$.nodes]),Lt=w.useCallback(async Z=>{M(!0),E(null),B(-1);try{const Me=await ke.getWaveDetail(Z);Me.replay&&E(Me.replay)}catch(Me){console.error("Failed to load wave:",Me)}finally{M(!1)}},[]),Dt=w.useRef(!1);w.useEffect(()=>{$.allDone&&!Dt.current&&H&&(Dt.current=!0,ne(),h==null||h())},[$.allDone,H,h,ne]);const Rt=w.useCallback(async()=>{if(!m||!H)return;const Z=H.rootJobs.map(Me=>Me.jobId).filter(Me=>!!Me);await m(H.directive,Z,{waveId:H.id,sessionIds:H.sessionIds})},[m,H]),sn=Z=>{Bn(Me=>{const Ie=new Set(Me);return Ie.has(Z)?Ie.delete(Z):Ie.add(Z),Ie})},pn=Z=>{const Me=Math.floor(Z/60),Ie=Z%60;return`${Me}:${Ie.toString().padStart(2,"0")}`},{panelRight:P,panelWidth:Be,isResizing:nt,handleResizeStart:Pt}=Xo(y,700,v),ge=l.jsxs(l.Fragment,{children:[!b&&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:[$.progress.running," running"]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[v&&l.jsx("button",{onClick:v,className:"text-white/50 hover:text-white text-xs cursor-pointer",children:"Maximize"}),l.jsx("button",{onClick:d,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:H?`${o.length} active wave${o.length!==1?"s":""}`:xe?"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:[(H||xe)&&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":$.allDone||xe?"#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:["“",je,"”"]}),H&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:pn(Y)}),xe&&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"}),xe&&(C==null?void 0:C.startedAt)&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:new Date(C.startedAt).toLocaleString()}),$.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:[$.progress.awaitingInput," awaiting"]}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:$.allDone||xe&&!le?"#2E7D3222":"#B71C1C22",color:$.allDone||xe&&!le?"#2E7D32":"#B71C1C"},children:[$.progress.done,"/",$.progress.total]}),le&&l.jsx("button",{onClick:He,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:H||xe?"Org Propagation":"Select Target Roles"}),l.jsxs("span",{className:"ml-auto text-[10px] text-[var(--terminal-text-muted)]",children:[$.checkedRoles.size,"/",$.progress.total," selected"]}),(H||xe)&&l.jsx("div",{className:"flex gap-x-3",children:[{label:"running",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(Z=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:Z.color,animation:Z.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:Z.label})]},Z.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(iv,{nodes:$.nodes,rootId:n,selectedRoleId:$.selectedRoleId,onSelectNode:$.selectNode,checkedRoles:$.checkedRoles,onToggleCheck:$.toggleCheck,eligibleRoles:$e})})]}),R?l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"Loading wave data..."}):we?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:[Le," target role",Le!==1?"s":""," selected"]})]}),l.jsxs("div",{ref:he,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-2 text-xs font-mono select-text",children:[je&&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:je}),H&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",children:["dispatched ",pn(Y)," ago to ",H.rootJobs.length," role",H.rootJobs.length!==1?"s":""]})]})]}),!je&&!H&&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:[q.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:q.map((Z,Me)=>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:${Z.mediaType};base64,${Z.data}`,alt:Z.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>T(Ie=>Ie.filter((St,Ze)=>Ze!==Me)),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:Z.name})]},Me))}),ye&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:ye}),l.jsxs("div",{className:"flex gap-2 items-end",children:[l.jsx("button",{onClick:()=>{var Z;return(Z=Pe.current)==null?void 0:Z.click()},className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:text-[var(--terminal-text-secondary)] transition-colors",title:"Attach image",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("textarea",{ref:L,value:k,onChange:Z=>N(Z.target.value),onKeyDown:Ke,onPaste:Te,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:tt,disabled:!k.trim()&&q.length===0||Le===0,className:"px-4 py-2 text-xs font-bold rounded-lg cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed shrink-0",style:{background:k.trim()&&Le>0?"#B71C1C":"#333",color:"#fff",minWidth:140},children:["Dispatch to ",Le," Role",Le!==1?"s":""]})]}),l.jsx("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",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:W}}),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==="running"?"#FBBF2422":`${W}22`,color:ce.status==="awaiting_input"?"#F59E0B":ce.status==="running"?"#FBBF24":W},children:ce.status==="running"?"Working...":ce.status==="done"?"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"]}),(ce.status==="running"||ce.status==="awaiting_input")&&ce.sessionId&&l.jsx("button",{onClick:()=>ze(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"})]}),l.jsx("input",{ref:Pe,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:Z=>{var Me;(Me=Z.target.files)!=null&&Me.length&<(Z.target.files),Z.target.value=""},className:"hidden"}),l.jsxs("div",{ref:he,className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text transition-colors ${de?"bg-amber-500/5 ring-1 ring-inset ring-amber-500/30":""}`,onDragOver:dt,onDragLeave:Ce,onDrop:We,children:[ce&&je&&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:je})]}),ce&&ce.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:ce.status==="waiting"?"Waiting for dispatch...":ce.status==="running"?"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((Z,Me)=>{const Ie=ce.events,St=Z.type==="job:start"&&Me>0,Ze=Ie[Me+1];if((Z.type==="job:done"||Z.type==="job:error"||Z.type==="job:awaiting_input")&&(Ze==null?void 0:Ze.type)==="job:start")return null;if(St){const tr=Z.data.task??"",ia=tr.match(/\[CEO Follow-up\]\n([\s\S]+)$/),Hn=ia?ia[1].trim():tr;return l.jsx(w.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:Hn})]})},`followup-${Z.seq}`)}return l.jsx(Xm,{event:Z,isThinkingCollapsed:Ct.has(Z.seq),onToggleThinking:()=>sn(Z.seq),onNavigateToJob:tr=>{for(const[,ia]of $.nodes)if(ia.events.some(Hn=>Hn.data.childJobId===tr)){$.selectNode(ia.roleId);return}},onOpenKnowledgeDoc:f},Z.seq)}),(ce==null?void 0:ce.status)==="running"&&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")&&(q.length>0||ye||de)&&l.jsxs("div",{className:"px-4 pt-2 border-t shrink-0",style:{borderColor:"var(--terminal-border)"},children:[ye&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:ye}),de&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-1",children:"Drop image here"}),q.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-1",children:q.map((Z,Me)=>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:${Z.mediaType};base64,${Z.data}`,alt:Z.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>T(Ie=>Ie.filter((St,Ze)=>Ze!==Me)),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:Z.name})]},Me))})]}),(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 Z;return(Z=Pe.current)==null?void 0:Z.click()},disabled:D,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:J,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),jt())},onPaste:Te,placeholder:"Type your response...",disabled:D,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none",style:{borderColor:"var(--terminal-border)"},autoFocus:!0}),l.jsx("button",{onClick:jt,disabled:D||!J.trim()&&q.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:D?"...":"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 Z;return(Z=Pe.current)==null?void 0:Z.click()},disabled:D,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:J,onChange:Z=>K(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),jt())},onPaste:Te,placeholder:"Send a follow-up directive...",disabled:D,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:jt,disabled:D||!J.trim()&&q.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:D?"...":"Send"})]})]}),$.allDone&&H&&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:Rt,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:xt,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:$t}),o.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:o.map((Z,Me)=>l.jsxs("button",{onClick:()=>{B(Me),E(null)},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:I===Me&&!C?"var(--terminal-bg)":"transparent",border:I===Me&&!C?"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:[Z.directive.slice(0,40),Z.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[Z.rootJobs.length," role",Z.rootJobs.length!==1?"s":""]})]},Z.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(Z=>l.jsx(HE,{wave:Z,active:(C==null?void 0:C.id)===Z.id,onLoad:()=>Lt(Z.id)},Z.id))})]}),oe&&l.jsxs("button",{onClick:j,disabled:!j,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:oe.dirty?"var(--idle-amber)":"#2E7D32"}}),l.jsx("span",{className:"text-[10px] font-mono text-[var(--terminal-text-muted)] truncate",children:oe.branch}),oe.dirty&&l.jsxs("span",{className:"text-[9px] ml-auto shrink-0",style:{color:"var(--idle-amber)"},children:[oe.count," unsaved"]}),!oe.dirty&&l.jsx("span",{className:"text-[9px] text-green-400 ml-auto shrink-0",children:"clean"})]})]})]})]});return b?l.jsx("div",{className:"flex flex-col h-full w-full",style:{background:"var(--terminal-bg)"},children:ge}):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:d}),l.jsxs("div",{className:"fixed top-0 bottom-0 z-50 flex flex-col",style:{right:P,width:Be,background:"var(--terminal-bg)",borderLeft:"1px solid var(--terminal-border)",transition:nt?"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:Pt}),ge]})]})}function IE(e,n,a){const i=new Map,o=d=>{const h=e[d];!h||i.has(d)||(i.set(d,{sessionId:"",roleId:d,roleName:h.name,children:h.children,status:"not-dispatched",events:[],streamStatus:"idle"}),h.children.forEach(o))},u=e[n];u&&(i.set(n,{sessionId:"",roleId:n,roleName:"CEO",children:u.children,status:"not-dispatched",events:[],streamStatus:"idle"}),u.children.forEach(o));for(const d of a){const h=i.get(d.roleId);if(h){const m=d.status==="running";i.set(d.roleId,{...h,sessionId:d.sessionId??d.jobId??"",status:d.status||"done",events:d.events,streamStatus:m?"connecting":"done"})}for(const m of d.childJobs){const f=i.get(m.roleId);f&&i.set(m.roleId,{...f,sessionId:m.jobId??"",status:m.status||"done",events:m.events,streamStatus:"done"})}}return i}function HE({wave:e,active:n,onLoad:a}){const i=e.id.match(/^(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})/),o=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:n?"1px solid var(--accent)":"1px solid var(--terminal-border)",background:n?"var(--terminal-bg)":void 0},onClick:a,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:o}),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 UE={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 Wm(e){return UE[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const sv=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],ov=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],cv=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],uv=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],dv=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],el={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 qE({color:e,selected:n,onClick:a}){return l.jsx("button",{onClick:a,className:"customize-swatch",style:{background:e,outline:n?"2px solid #fff":"2px solid transparent",boxShadow:n?`0 0 0 1px ${e}, 0 0 6px ${e}88`:"none"}})}function Ao({label:e,presets:n,value:a,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:a}})]}),l.jsx("div",{className:"customize-swatches",children:n.map(o=>l.jsx(qE,{color:o,selected:o===a,onClick:()=>i(o)},o))})]})}function Eh({label:e,items:n,value:a,onChange:i,lockInfo:o}){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:n.map(u=>{const d=o?o.getLockLevel(u.id):1,h=u.id===a,m=o?d>o.roleLevel&&!h:!1,f=o?h&&d>o.roleLevel:!1;return l.jsxs("button",{onClick:()=>{m||i(u.id===a?void 0:u.id)},className:"customize-swatch",style:{width:"auto",height:"auto",padding:m?"2px 6px 10px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:h?"rgba(255,255,255,0.15)":m?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",outline:h?f?"2px solid #F59E0B":"2px solid #fff":"2px solid transparent",color:m?"rgba(255,255,255,0.25)":h?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:m?"not-allowed":"pointer",opacity:m?.35:1,position:"relative"},children:[u.name,m&&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.",d]}),f&&l.jsxs("span",{style:{position:"absolute",bottom:-8,left:"50%",transform:"translateX(-50%)",fontSize:7,color:"#F59E0B",whiteSpace:"nowrap"},children:["⚠"," Lv.",d]})]},u.id)})})]})}function Ah({label:e,active:n,onClick:a}){return l.jsx("button",{onClick:a,style:{flex:1,padding:"6px 0",fontSize:10,fontFamily:"var(--font-pixel, monospace)",fontWeight:"bold",letterSpacing:1,background:n?"rgba(255,255,255,0.08)":"transparent",color:n?"#fff":"rgba(255,255,255,0.35)",border:"none",borderBottom:n?"2px solid #3B82F6":"2px solid transparent",cursor:"pointer",transition:"all 0.15s"},children:e})}function Fl(e){return e[Math.floor(Math.random()*e.length)]}function ms(e){var o,u,d;const n=Bb(),a=Ob(),i=$b().filter(h=>!e||Ib(h.id,e));return{skinColor:Fl(sv),hairColor:Fl(ov),shirtColor:Fl(cv),pantsColor:Fl(uv),shoeColor:Fl(dv),hairStyle:(o=Fl(n))==null?void 0:o.id,outfitStyle:(u=Fl(a))==null?void 0:u.id,accessory:(d=Fl(i))==null?void 0:d.id}}function fv({roleId:e,appearance:n,onChange:a,onRandomize:i,onReset:o,label:u,roleLevel:d}){const[h,m]=w.useState("look"),f=w.useCallback((N,C)=>{a({...n,[N]:C})},[n,a]),x=w.useRef(null),y=w.useCallback(N=>{var R;const C=(R=N.target.files)==null?void 0:R[0];if(!C)return;const E=new Image;E.onload=()=>{const M=cC(E);a({...M,hairStyle:n.hairStyle,outfitStyle:n.outfitStyle,accessory:n.accessory}),URL.revokeObjectURL(E.src)},E.src=URL.createObjectURL(C),N.target.value=""},[n.hairStyle,n.outfitStyle,n.accessory,a]),v=Bb(),b=Ob(),j=$b(),k=d!==void 0?j.filter(N=>Ib(N.id,d)).length:j.length;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"customize-preview",children:[l.jsx("div",{className:"customize-preview-bg",children:l.jsx($l,{roleId:e,appearance:n,scale:12})}),u&&l.jsx("div",{className:"customize-preview-name",children:u}),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:o,children:"RESET"}),l.jsx("button",{className:"customize-btn",onClick:()=>{var N;return(N=x.current)==null?void 0:N.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),l.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:y,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(Ah,{label:"LOOK",active:h==="look",onClick:()=>m("look")}),l.jsx(Ah,{label:"OUTFIT",active:h==="outfit",onClick:()=>m("outfit")}),l.jsx(Ah,{label:"ACCESSORY",active:h==="accessory",onClick:()=>m("accessory")})]}),h==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(Ao,{label:"SKIN",presets:sv,value:n.skinColor,onChange:N=>f("skinColor",N)}),l.jsx(Ao,{label:"HAIR COLOR",presets:ov,value:n.hairColor,onChange:N=>f("hairColor",N)}),l.jsx(Eh,{label:"HAIR STYLE",items:v,value:n.hairStyle,onChange:N=>f("hairStyle",N)})]}),h==="outfit"&&l.jsxs(l.Fragment,{children:[l.jsx(Eh,{label:"STYLE",items:b,value:n.outfitStyle,onChange:N=>f("outfitStyle",N)}),l.jsx(Ao,{label:"TOP",presets:cv,value:n.shirtColor,onChange:N=>f("shirtColor",N)}),l.jsx(Ao,{label:"PANTS",presets:uv,value:n.pantsColor,onChange:N=>f("pantsColor",N)}),l.jsx(Ao,{label:"SHOES",presets:dv,value:n.shoeColor,onChange:N=>f("shoeColor",N)})]}),h==="accessory"&&l.jsxs(l.Fragment,{children:[d!==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.",d]}),l.jsxs("span",{children:[k,"/",j.length," unlocked"]})]}),l.jsx(Eh,{label:"ACCESSORY",items:j,value:n.accessory,onChange:N=>f("accessory",N),lockInfo:d!==void 0?{roleLevel:d,getLockLevel:Lb}:void 0}),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:d!==void 0&&d<10?"Level up to unlock more accessories":"More accessories coming soon"})]})]})]})}const YE=[{value:"c-level",label:"C-Level"},{value:"member",label:"Member"}];function fm(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Dh(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 XE={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 zl=null;async function WE(){if(zl)return zl;try{const a=await ke.getPreferences();if(a.instanceId)return zl=a.instanceId,localStorage.setItem("tycono_instance_id",zl),zl}catch{}const e="tycono_instance_id";let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),zl=n,n}const Do=4;function GE(e,n,a){const i=e.trim();if(!i||i.startsWith("#"))return null;const o=i.split(",").map(y=>y.trim()),u=o[0];if(!u)return null;const d=fm(u),m=(o[1]||"member").toLowerCase()==="c-level"?"c-level":"member",f=o[2]||"ceo";let x;return n.has(d)?x="ID already exists":a.has(d)&&(x="Duplicate ID in batch"),a.add(d),{name:u,id:d,level:m,reportsTo:f,error:x}}function VE({existingRoles:e,onClose:n,onHire:a,onStoreVisit:i,questHint:o}){const[u,d]=w.useState("single"),[h,m]=w.useState([]),[f,x]=w.useState(!1),[y,v]=w.useState("popular"),[b,j]=w.useState(""),[k,N]=w.useState(null),[C,E]=w.useState(!1),[R,M]=w.useState(""),[I,B]=w.useState("browse"),[L,H]=w.useState(""),[Q,A]=w.useState(""),[$,U]=w.useState("ceo"),[ee,oe]=w.useState(null),[ne,Y]=w.useState(1),[ue,J]=w.useState(""),[K,D]=w.useState(""),[F,q]=w.useState(!1),[T,de]=w.useState("member"),[Ne,ye]=w.useState(()=>{const P=e.find(Be=>Be.level==="c-level");return(P==null?void 0:P.id)??"ceo"}),[_e,Pe]=w.useState(""),[Ve,lt]=w.useState(ms),[dt,Ce]=w.useState(!1),[We,Te]=w.useState(""),[xt,ut]=w.useState([]),[mt,wt]=w.useState(new Set),[qt,$t]=w.useState(""),[Ct,Bn]=w.useState("input"),[he,ve]=w.useState({done:0,total:0}),ce=w.useRef(null),W=w.useRef(null),le=w.useRef(null);w.useEffect(()=>{ke.getSkills().then(P=>ut(P.filter(Be=>Be.installed))).catch(()=>{}),WE().then(P=>oe(P)).catch(()=>{})},[]),w.useEffect(()=>{var P,Be,nt;u==="single"?(ne===1&&((P=ce.current)==null||P.focus()),ne===2&&((Be=W.current)==null||Be.focus())):u==="bulk"&&Ct==="input"&&((nt=le.current)==null||nt.focus())},[ne,u,Ct]),w.useEffect(()=>{u==="store"&&I==="browse"&&h.length===0&&we()},[u,I]);const we=async()=>{x(!0);try{const P=await pr.getCharacters({sort:y,instanceId:ee??void 0});m(P.characters)}catch{M("Failed to load job board")}x(!1)};w.useEffect(()=>{u==="store"&&I==="browse"&&we()},[y,ee]);const xe=w.useMemo(()=>{if(!b.trim())return h;const P=b.toLowerCase();return h.filter(Be=>Be.name.toLowerCase().includes(P)||Be.id.toLowerCase().includes(P)||(Be.tagline??"").toLowerCase().includes(P))},[h,b]),je=w.useMemo(()=>new Set(e.map(P=>P.id)),[e]),Re=w.useMemo(()=>{const P=qt.split(`
|
|
84
|
+
`),Be=new Set;return P.map(nt=>GE(nt,je,Be)).filter(nt=>nt!==null)},[qt,je]),$e=Re.length>0&&Re.every(P=>!P.error),Oe=P=>{J(P),F||D(fm(P))},Le=ue.trim().length>0&&K.trim().length>0&&!e.some(P=>P.id===K),tt=_e.trim().length>0,Ke=async()=>{Ce(!0),Te("");const P=Dh(T);try{await a({id:K,name:ue.trim(),level:T,reportsTo:Ne,persona:_e.trim(),...P,skills:mt.size>0?[...mt]:void 0},Ve),n()}catch(Be){Te(Be instanceof Error?Be.message:"Failed to create role"),Ce(!1)}},jt=P=>P===1?Le:P===2?tt:!0,ze=async()=>{Ce(!0),Te(""),ve({done:0,total:Re.length});try{for(let P=0;P<Re.length;P++){const Be=Re[P],nt=Dh(Be.level),Pt=ms(),ge=`${Be.name}. A ${Be.level} role reporting to ${Be.reportsTo}.`;await a({id:Be.id,name:Be.name,level:Be.level,reportsTo:Be.reportsTo,persona:ge,...nt},Pt),ve({done:P+1,total:Re.length})}n()}catch(P){Te(P instanceof Error?P.message:"Failed to create roles"),Ce(!1)}},He=async P=>{E(!0),M("");try{const Be=await pr.getCharacter(P);N(Be),H(Be.name||""),A(fm(Be.name||P)),B("review")}catch{M("Failed to load character details")}finally{E(!1)}},Lt=async(P,Be)=>{if(!ee)return;const nt=h.find(ge=>ge.id===P);if(!nt)return;const Pt=nt.my_vote===Be?0:Be;try{const ge=await pr.voteCharacter(P,ee,Pt);m(Z=>Z.map(Me=>Me.id===P?{...Me,upvotes:ge.upvotes,downvotes:ge.downvotes,vote_score:ge.upvotes-ge.downvotes,my_vote:Pt===0?null:Pt}:Me))}catch{}},Dt=async()=>{if(!k)return;Ce(!0),Te("");const P=k,Be=P.level==="c-level"?"c-level":"member",nt=Dh(Be),Pt=P.skills!=null&&typeof P.skills=="object"&&!Array.isArray(P.skills)&&"primary"in P.skills;try{await a({id:Q,name:L.trim(),level:Be,reportsTo:$,persona:P.persona||`${L}. Imported from Job Board.`,authority:P.authority||nt.authority,knowledge:nt.knowledge,reports:nt.reports,source:{id:`tycono/${P.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:Pt?P.skills:void 0},P.appearance?P.appearance:ms()),pr.trackInstall(P.id).catch(()=>{}),n()}catch(ge){Te(ge instanceof Error?ge.message:"Failed to hire"),Ce(!1)}},Rt=async P=>{if(ee)try{await pr.deleteCharacter(P,ee),m(Be=>Be.filter(nt=>nt.id!==P))}catch{}},sn=P=>{P.key==="Escape"&&n(),P.key==="Enter"&&(P.metaKey||P.ctrlKey)&&(u==="single"?ne<Do&&jt(ne)?Y(ne+1):ne===Do&&Ke():u==="bulk"?Ct==="input"&&$e?Bn("review"):Ct==="review"&&ze():u==="store"&&I==="review"&&Dt())},pn=e.some(P=>P.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:n}),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:sn,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:()=>{d("single"),Te("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="single"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Single"}),l.jsx("button",{onClick:()=>{d("bulk"),Te("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="bulk"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Bulk"}),l.jsx("button",{onClick:()=>{d("store"),Te(""),i==null||i()},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="store"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Job Board"})]})]}),o&&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:o.message}),o.roleId&&u==="single"&&ne===1&&!ue&&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 P=XE[o.roleId];P&&(J(P.name),D(P.id),q(!0),de(P.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:u==="single"?`Step ${ne} of ${Do}`:u==="bulk"?Ct==="input"?"Enter roles, one per line":`Review ${Re.length} roles`:I==="browse"?`${h.length} roles available`:"Review & customize"}),u==="store"&&I==="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:P=>P.stopPropagation(),children:"Open in browser ↗"})]})]}),u==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:Do},(P,Be)=>Be+1).map(P=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:P<=ne?"#2E7D32":"rgba(255,255,255,0.1)"}},P))}),l.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:u==="store"?l.jsxs(l.Fragment,{children:[I==="browse"&&l.jsxs("div",{className:"space-y-3",children:[ee?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:[ee.slice(0,8),"..."]})]}),l.jsx("button",{onClick:()=>{zl=null,localStorage.removeItem("tycono_instance_id"),oe(null)},className:"text-white/30 hover:text-white/60 cursor-pointer",children:"Sign out"})]}):l.jsx(KE,{onLogin:P=>{zl=P,localStorage.setItem("tycono_instance_id",P),oe(P)}}),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:P=>{if(P.key==="Enter"){const nt=P.target.value.trim().replace(/^tycono:/,"");nt&&(He(nt),P.target.value="")}}}),l.jsx("button",{onClick:()=>{const P=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(P){const nt=P.value.trim().replace(/^tycono:/,"");nt&&(He(nt),P.value="")}},disabled:C,className:"px-3 py-2 rounded-lg bg-accent/10 border border-accent/25 text-accent text-xs font-medium hover:bg-accent/20 transition-colors shrink-0 cursor-pointer disabled:opacity-50",children:C?"Loading...":"Fetch"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex-1 h-px bg-white/10"}),l.jsx("span",{className:"text-[10px] text-white/30",children:"or browse"}),l.jsx("div",{className:"flex-1 h-px bg-white/10"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:b,onChange:P=>j(P.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:y,onChange:P=>v(P.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..."}):R?l.jsxs("div",{className:"text-center py-8",children:[l.jsx("div",{className:"text-xs text-red-400 mb-2",children:R}),l.jsx("button",{onClick:we,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):xe.length===0?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:b?"No matches found":"No characters in store yet"}):l.jsx("div",{className:"space-y-2 max-h-[380px] overflow-y-auto pr-1",children:xe.map(P=>l.jsx(QE,{char:P,isHired:je.has(P.id),onSelect:()=>He(P.id),onVote:Be=>Lt(P.id,Be),onDelete:()=>Rt(P.id),fetching:C,token:ee},P.id))})]}),I==="review"&&k&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"bg-white/5 rounded-xl p-4 border border-white/10",children:[l.jsxs("div",{className:"flex gap-4",children:[k.appearance&&l.jsx("div",{className:"flex-shrink-0 rounded-lg overflow-hidden",style:{background:"#0d1117",padding:8},children:l.jsx($l,{roleId:"store-preview",appearance:k.appearance,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Name"}),l.jsx("input",{value:L,onChange:P=>H(P.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:Q,onChange:P=>A(P.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(P=>P.id===Q)&&Q.length>0&&l.jsx("div",{className:"text-xs text-red-500 mt-1",children:"ID already exists"})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Level"}),l.jsx("div",{className:"text-sm text-white/70 p-2 rounded-lg bg-white/5 border border-white/10",children:k.level==="c-level"?"C-Level":"Member"})]}),l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Reports To"}),l.jsxs("select",{value:$,onChange:P=>U(P.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(P=>l.jsxs("option",{value:P.id,className:"bg-[var(--wall)] text-white",children:[P.name," (",P.id,")"]},P.id))]})]})]})]})]}),k.persona&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),l.jsx("div",{className:"text-xs text-white/60 leading-relaxed line-clamp-3",children:k.persona})]}),k.skills&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Skills"}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:(()=>{var Pt,ge;const P=k.skills;if(P&&typeof P=="object"&&!Array.isArray(P)&&"primary"in P){const Z=[];return(ge=(Pt=P.primary)==null?void 0:Pt.frontmatter)!=null&&ge.name&&Z.push(P.primary.frontmatter.name),P.shared&&P.shared.forEach(Me=>{var Ie;return Z.push(((Ie=Me.frontmatter)==null?void 0:Ie.name)||Me.id)}),Z.map(Me=>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:Me},Me))}return(Array.isArray(P)?P:[]).map((Z,Me)=>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 Z=="string"?Z:Z.name},Me))})()})]})]}),We&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:We})]})]}):u==="single"?l.jsxs(l.Fragment,{children:[ne===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:ue,onChange:P=>Oe(P.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:P=>{D(P.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),q(!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 ${pn?"border-red-400":"border-white/10 focus:border-white/25"}`}),pn&&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:YE.map(P=>l.jsx("button",{onClick:()=>{if(de(P.value),P.value==="c-level")ye("ceo");else{const Be=e.find(nt=>nt.level==="c-level");ye((Be==null?void 0:Be.id)??"ceo")}},className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${T===P.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:P.label},P.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"}),T==="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:Ne,onChange:P=>ye(P.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(P=>P.level==="c-level").map(P=>l.jsxs("option",{value:P.id,className:"bg-[var(--wall)] text-white",children:[P.name," (",P.id,")"]},P.id))})]})]}),ne===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:W,value:_e,onChange:P=>Pe(P.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"})]}),xt.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:xt.map(P=>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:mt.has(P.id),onChange:()=>wt(Be=>{const nt=new Set(Be);return nt.has(P.id)?nt.delete(P.id):nt.add(P.id),nt}),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:P.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:P.description})]})]},P.id))})]})]}),ne===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx(fv,{roleId:"default",appearance:Ve,onChange:lt,onRandomize:()=>lt(ms()),onReset:()=>lt(ms()),label:l.jsxs("span",{children:[K||"new-role"," — ",ue||"New Role"]})})}),ne===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($l,{roleId:"default",appearance:Ve,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(To,{label:"Name",value:ue}),l.jsx(To,{label:"ID",value:K,mono:!0}),l.jsx(To,{label:"Level",value:T}),l.jsx(To,{label:"Reports To",value:Ne}),mt.size>0&&l.jsx(To,{label:"Skills",value:[...mt].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:_e})]})]}),We&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:We})]})]}):l.jsxs(l.Fragment,{children:[Ct==="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:le,value:qt,onChange:P=>$t(P.target.value),placeholder:`Name, Level, ReportsTo
|
|
85
|
+
e.g.
|
|
86
|
+
Data Analyst
|
|
87
|
+
DevOps Engineer, member, cto
|
|
88
|
+
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."})]}),Re.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 (",Re.length," role",Re.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:Re.map((P,Be)=>l.jsxs("tr",{className:`border-b border-white/5 ${P.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:P.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:P.id}),l.jsx("td",{className:"p-2 text-white/60",children:P.level}),l.jsx("td",{className:"p-2 text-white/60",children:P.reportsTo}),P.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:P.error})]},Be))})]})})]})]}),Ct==="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 — ",Re.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:Re.map((P,Be)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:Be+1}),l.jsx("td",{className:"p-2 text-white/80",children:P.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:P.id}),l.jsx("td",{className:"p-2 text-white/60",children:P.level}),l.jsx("td",{className:"p-2 text-white/60",children:P.reportsTo})]},Be))})]})}),dt&&he.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:[he.done,"/",he.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:`${he.done/he.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."}),We&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:We})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[u==="single"&&ne>1&&l.jsx("button",{onClick:()=>Y(ne-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"}),u==="bulk"&&Ct==="review"&&l.jsx("button",{onClick:()=>Bn("input"),disabled:dt,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"}),u==="store"&&I==="review"&&l.jsx("button",{onClick:()=>{B("browse"),N(null),Te("")},disabled:dt,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:n,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),u==="single"?ne<Do?l.jsx("button",{onClick:()=>Y(ne+1),disabled:!jt(ne),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:Ke,disabled:dt,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:dt?"Hiring...":"HIRE"}):u==="bulk"?Ct==="input"?l.jsxs("button",{onClick:()=>Bn("review"),disabled:!$e,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 (",Re.length,")"]}):l.jsx("button",{onClick:ze,disabled:dt,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:dt?`Hiring ${he.done}/${he.total}...`:`HIRE ALL (${Re.length})`}):I==="review"?l.jsx("button",{onClick:Dt,disabled:dt||!L.trim()||!Q.trim()||e.some(P=>P.id===Q),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:dt?"Hiring...":"HIRE"}):null]})]})]})]})}function KE({onLogin:e}){const[n,a]=w.useState(""),[i,o]=w.useState(!1),[u,d]=w.useState(""),h=()=>{const m=n.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)){d("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:n,onChange:m=>{a(m.target.value),d("")},onKeyDown:m=>{m.key==="Enter"&&h()},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:h,disabled:!n.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"})]}),u&&l.jsx("div",{className:"text-[10px] text-red-400",children:u}),l.jsx("button",{onClick:o.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:o.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 QE({char:e,isHired:n,onSelect:a,onVote:i,onDelete:o,fetching:u,token:d}){const[h,m]=w.useState(!1),f=d&&e.publisher_id===d,x=!!d;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:y=>{y.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:y=>{y.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:a,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}),n&&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:a,disabled:u,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&&(h?l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:y=>{y.stopPropagation(),o(),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:y=>{y.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:y=>{y.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 To({label:e,value:n,mono:a}){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 ${a?"font-mono":""}`,children:n})]})}function PE({roleId:e,roleName:n,onClose:a,onConfirm:i}){const[o,u]=w.useState(!1),d=async()=>{u(!0);try{await i(e)}finally{u(!1)}};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:a}),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 ",n," (",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:n}),"?"]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:a,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:d,disabled:o,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:o?"Removing...":"Confirm Fire"})]})]})]})}const ZE={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function JE({roleId:e,title:n,roleColor:a,active:i,isWave:o,isWaveStreaming:u,onClick:d,onClose:h,"data-session-id":m}){const f=o?"#F59E0B":a;return l.jsxs("button",{onClick:d,"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:[o&&u&&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:ZE[e]??"👤"}),l.jsx("span",{className:`truncate ${o?"text-amber-400/90":""}`,children:n}),l.jsx("span",{onClick:h,className:"ml-auto text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none",children:"×"})]})}function e6({content:e,streaming:n}){let a=e;return n&&(e.match(/```/g)??[]).length%2!==0&&(a+="\n```"),l.jsx("div",{className:"terminal-markdown",children:l.jsx(zm,{remarkPlugins:[$m],components:{code:t6,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:a})})}function t6({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
89
|
+
`)?l.jsx(n6,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"terminal-inline-code",...a,children:n})}function n6({children:e,language:n}){const[a,i]=w.useState(!1),o=String(e).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"terminal-code-block group relative my-2",children:[n&&l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] px-3 pt-1.5",children:n}),l.jsx("button",{onClick:u,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:a?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:o})})]})}const r6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function a6({attachments:e}){const[n,a]=w.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,o)=>l.jsxs("button",{onClick:()=>a(o),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})]},o))}),n!==null&&l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/80 flex items-center justify-center",onClick:()=>a(null),children:l.jsxs("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[l.jsx("img",{src:`data:${e[n].mediaType};base64,${e[n].data}`,alt:e[n].name,className:"max-w-full max-h-[90vh] object-contain rounded-lg"}),l.jsx("button",{onClick:()=>a(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[n].name})]})})]})}function Th(e,n){return n?n.file_path?String(n.file_path).replace(/^.*\/(?=[^/]+\/)/,""):n.path?String(n.path).replace(/^.*\/(?=[^/]+\/)/,""):n.pattern?String(n.pattern):n.command?String(n.command).slice(0,60):n.query?String(n.query).slice(0,60):n.url?String(n.url).slice(0,60):"":""}function l6(e){const n=[];let a="";for(const i of e)if(i.type==="thinking")i.text&&(a=i.text),n.length===0||n[n.length-1].type!=="thinking"?n.push({type:"thinking",text:i.text}):n[n.length-1].text=i.text;else if(i.type==="tool")n.push({type:"tool",toolName:i.toolName,toolSummary:Th(i.toolName??"",i.toolInput),toolInput:i.toolInput});else if(i.type==="dispatch")n.push({type:"dispatch",roleId:i.roleId,task:i.task});else if(i.type==="dispatch:progress"){const o=n.length>0?n[n.length-1]:null;(o==null?void 0:o.type)==="dispatch:progress"&&o.roleId===i.roleId?i.progressType==="tool"?(o.toolName=i.toolName,o.toolSummary=Th(i.toolName??"",i.toolInput),o.progressType="tool"):i.progressType==="thinking"?(o.text=i.text,o.progressType="thinking"):i.progressType==="text"?(o.text=i.text,o.progressType="text"):(i.progressType==="done"||i.progressType==="error")&&(o.progressType=i.progressType):n.push({type:"dispatch:progress",roleId:i.roleId,progressType:i.progressType,text:i.text,toolName:i.toolName,toolSummary:i.toolName?Th(i.toolName,i.toolInput):void 0})}if(a){const i=n.filter(o=>o.type==="thinking");i.length>0&&(i[i.length-1].text=a)}return n}function i6({event:e,isStreaming:n}){var o,u,d;const[a,i]=w.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(!a),children:[l.jsx("span",{className:"stream-event-thinking-icon"}),l.jsxs("span",{className:"stream-event-thinking-label",children:["thinking",n?"...":""]}),e.text&&!n&&l.jsx("span",{className:"stream-event-thinking-toggle",children:a?"▾":"▸"})]}),(n||a)&&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(!a),children:a?"▾":"▸"}),a&&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:["→"," ",(o=e.roleId)==null?void 0:o.toUpperCase()]}),l.jsx("span",{className:"stream-event-dispatch-task",children:(u=e.task)==null?void 0:u.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:(d=e.roleId)==null?void 0:d.toUpperCase()}),e.progressType==="thinking"&&l.jsxs("span",{className:"stream-event-dispatch-progress-status",children:["thinking",n?"...":""]}),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 s6({events:e,isStreaming:n}){const[a,i]=w.useState(!1);if(e.length===0)return null;const o=l6(e);if(o.length===0)return null;const u=e.filter(v=>v.type==="thinking").length,d=e.filter(v=>v.type==="tool"),h=e.filter(v=>v.type==="dispatch"||v.type==="dispatch:progress"),m=e.filter(v=>v.type==="turn").reduce((v,b)=>Math.max(v,b.turn??0),0),f=[];if(u>0&&f.push("thinking"),d.length>0){const v=[...new Set(d.map(b=>b.toolName))];v.length<=3?f.push(v.join(", ")):f.push(`${d.length} tool calls`)}h.length>0&&f.push(`${h.length} dispatch`),m>1&&f.push(`${m} turns`);const x=f.join(" · "),y=!a;return l.jsxs("div",{className:"stream-activity-log",children:[l.jsxs("div",{className:"stream-activity-header",onClick:()=>i(!a),children:[n&&l.jsx("span",{className:"stream-activity-pulse"}),l.jsxs("span",{className:"stream-activity-summary",children:[a?"▸":"▾"," ",x,n?"...":""]})]}),y&&l.jsx("div",{className:"stream-activity-events",children:o.map((v,b)=>l.jsx(i6,{event:v,isStreaming:n&&b===o.length-1},b))})]})}function o6(e){return e.map(n=>({type:n.type==="tool:start"?"tool":n.type==="dispatch:start"?"dispatch":n.type,timestamp:new Date(n.ts).getTime(),text:n.data.text,toolName:n.data.name,toolInput:n.data.input,roleId:n.data.roleId,task:n.data.task}))}function c6({message:e,roleId:n,roleColor:a}){const i=e.from==="ceo",o=e.type==="system",u=e.status==="streaming";if(o)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(a6,{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 d=e.streamEvents??(e.events?o6(e.events):void 0),h=((d==null?void 0:d.length)??0)>0,m=!!e.thinking,f=m&&!e.content&&u&&!h;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:`${a}33`},children:r6[n]??"👤"}),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:n.toUpperCase()}),h&&l.jsx(s6,{events:d,isStreaming:u}),m&&!h&&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 ${a}`,background:"var(--terminal-surface)"},children:[e.content?l.jsx(e6,{content:e.content,streaming:u}):u&&!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"})]}):u&&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,u&&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,y)=>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})`:""]})]},y))]})]})]})}function hv({messages:e,roleId:n,roleColor:a}){var o;const i=w.useRef(null);return w.useEffect(()=>{var u;(u=i.current)==null||u.scrollIntoView({behavior:"smooth"})},[e,(o=e[e.length-1])==null?void 0:o.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 ",n.toUpperCase()]}):l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 terminal-scrollbar",children:[e.map(u=>l.jsx(c6,{message:u,roleId:n,roleColor:a},u.id)),l.jsx("div",{ref:i})]})}const u6=5*1024*1024,d6=["image/png","image/jpeg","image/gif","image/webp"];function Gm({mode:e,onModeChange:n,onSend:a,disabled:i,disabledReason:o}){const[u,d]=w.useState(""),[h,m]=w.useState([]),[f,x]=w.useState(!1),[y,v]=w.useState(null),b=w.useRef(null),j=w.useRef(null),k=w.useRef(!1);w.useEffect(()=>{const A=b.current;A&&(A.style.height="0",A.style.height=Math.min(A.scrollHeight,120)+"px")},[u]),w.useEffect(()=>{if(y){const A=setTimeout(()=>v(null),3e3);return()=>clearTimeout(A)}},[y]);const N=w.useCallback(async A=>d6.includes(A.type)?A.size>u6?(v(`File too large: ${(A.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise($=>{const U=new FileReader;U.onload=()=>{const oe=U.result.split(",")[1];$({type:"image",data:oe,name:A.name,mediaType:A.type})},U.onerror=()=>{v("Failed to read file"),$(null)},U.readAsDataURL(A)}):(v(`Unsupported format: ${A.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),C=w.useCallback(async A=>{const $=Array.from(A),U=[];for(const ee of $){const oe=await N(ee);oe&&U.push(oe)}U.length>0&&m(ee=>[...ee,...U])},[N]),E=w.useCallback(A=>{A.preventDefault(),A.stopPropagation(),x(!0)},[]),R=w.useCallback(A=>{A.preventDefault(),A.stopPropagation(),x(!1)},[]),M=w.useCallback(A=>{A.preventDefault(),A.stopPropagation(),x(!1);const $=A.dataTransfer.files;$.length>0&&C($)},[C]),I=w.useCallback(A=>{const $=A.clipboardData.items,U=[];for(let ee=0;ee<$.length;ee++){const oe=$[ee];if(oe.type.startsWith("image/")){const ne=oe.getAsFile();ne&&U.push(ne)}}U.length>0&&(A.preventDefault(),C(U))},[C]),B=w.useCallback(A=>{const $=A.target.files;$&&$.length>0&&C($),A.target.value=""},[C]),L=w.useCallback(A=>{m($=>$.filter((U,ee)=>ee!==A))},[]),H=()=>{const A=u.trim();!A&&h.length===0||i||(a(A,h.length>0?h:void 0),d(""),m([]))},Q=A=>{if(A.key==="Enter"&&!A.shiftKey){if(k.current)return;A.preventDefault(),H()}};return l.jsxs("div",{className:`border-t border-[var(--terminal-border)] p-3 shrink-0 transition-colors ${f?"bg-[var(--terminal-surface-light)] border-amber-500/50":""}`,onDragOver:E,onDragLeave:R,onDrop:M,children:[y&&l.jsx("div",{className:"text-[10px] text-red-400 mb-2 text-center",children:y}),o&&l.jsx("div",{className:"text-[10px] text-amber-400/70 mb-2 text-center",children:o}),h.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:h.map((A,$)=>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:${A.mediaType};base64,${A.data}`,alt:A.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>L($),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:A.name})]},$))}),f&&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:()=>n("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:()=>n("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 A;return(A=j.current)==null?void 0:A.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:j,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:B,className:"hidden"}),l.jsx("textarea",{ref:b,value:u,onChange:A=>d(A.target.value),onKeyDown:Q,onCompositionStart:()=>{k.current=!0},onCompositionEnd:()=>{k.current=!1},onPaste:I,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"}),l.jsx("button",{onClick:H,disabled:i||!u.trim()&&h.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 f6={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},mv={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function Ky(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function h6({msg:e}){const n=f6[e.roleId]??"#888",a=mv[e.roleId]??e.roleId;if(e.type==="dispatch"){const i=e.text.includes("WAVE"),o=e.text.includes("completed")||e.text.includes("완료"),u=i?"📡":o?"✓":"→",d=o?"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:Ky(e.ts)}),l.jsx("span",{className:"text-[10px] shrink-0 mt-0.5",children:u}),l.jsx("span",{className:`text-[11px] ${d}`,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:Ky(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:n},children:a}),l.jsx("span",{className:"text-xs text-[var(--terminal-text-secondary)]",children:e.text})]})]})}function m6({channel:e,allRoles:n,onUpdateMembers:a,onUpdateTopic:i,onSendMessage:o}){const u=w.useRef(null),d=w.useRef(null),[h,m]=w.useState("");w.useEffect(()=>{var R;const C=d.current;if(!C)return;C.scrollHeight-C.scrollTop-C.clientHeight<80&&((R=u.current)==null||R.scrollIntoView({behavior:"smooth"}))},[e.messages.length]);const[f,x]=w.useState(!1),[y,v]=w.useState(!1),[b,j]=w.useState(""),k=o&&e.id!=="general",N=()=>{!h.trim()||!o||(o(e.id,h.trim()),m(""),setTimeout(()=>{var C;return(C=u.current)==null?void 0:C.scrollIntoView({behavior:"smooth"})},50))};return l.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[l.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto terminal-scrollbar py-2 min-h-0",children:[l.jsxs("div",{className:"px-3 py-2 mb-2 border-b border-[var(--terminal-border)] flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-[var(--terminal-text)]",children:e.name}),e.members.length>0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.members.map(C=>mv[C]??C).join(", ")}),e.members.length===0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.isDefault?"system logs":"no members"}),!e.isDefault&&n&&a&&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:y?l.jsx("input",{autoFocus:!0,value:b,onChange:C=>j(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(i(e.id,b.trim()),v(!1)),C.key==="Escape"&&v(!1)},onBlur:()=>{i(e.id,b.trim()),v(!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:()=>{j(e.topic??""),v(!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&&n&&a&&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:n.map(C=>{const E=e.members.includes(C.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 R=E?e.members.filter(M=>M!==C.id):[...e.members,C.id];a(e.id,R)},children:[E?"✓ ":"",C.name]},C.id)})})}),e.messages.length===0&&l.jsx("div",{className:"flex-1 flex flex-col items-center justify-center text-[var(--terminal-text-muted)] text-xs gap-1 py-8",children:l.jsx("span",{children:e.isDefault?"No dispatch events yet":"No messages yet — invite roles to start chatting"})}),e.messages.map(C=>l.jsx(h6,{msg:C},C.id)),l.jsx("div",{ref:u})]}),k&&l.jsx("div",{className:"shrink-0 px-3 py-2 border-t border-[var(--terminal-border)]",children:l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("span",{className:"text-[10px] font-semibold shrink-0",style:{color:"#FFB300"},children:"CEO"}),l.jsx("input",{type:"text",value:h,onChange:C=>m(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),N())},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 Fh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},p6=400,x6=800;function Qy({sessions:e,activeSessionId:n,roles:a,streamingSessionId:i,width:o,onWidthChange:u,onSwitchSession:d,onCloseSession:h,onCreateSession:m,onClearEmpty:f,onCloseAll:x,onSendMessage:y,onModeChange:v,onCloseTerminal:b,onMaximize:j,chatChannels:k,activeChatChannelId:N,onSwitchChatChannel:C,onCreateChatChannel:E,onDeleteChatChannel:R,onUpdateChatMembers:M,onUpdateChatTopic:I,onSendChatMessage:B,unreadChannels:L}){const[H,Q]=w.useState(!1),[A,$]=w.useState(!1),[U,ee]=w.useState(!1),[oe,ne]=w.useState(""),Y=N!=null,ue=k==null?void 0:k.find(Ce=>Ce.id===N),[J,K]=w.useState(!1),[D,F]=w.useState(!1),[q,T]=w.useState(!1),de=w.useRef(0),Ne=w.useRef(0),ye=w.useRef(null),_e=e.find(Ce=>Ce.id===n),Pe=i===n,Ve=e.filter(Ce=>Ce.messages.length===0).length,lt=w.useCallback(()=>{const Ce=ye.current;Ce&&(F(Ce.scrollLeft>0),T(Ce.scrollLeft+Ce.clientWidth<Ce.scrollWidth-1))},[]);w.useEffect(()=>{if(!n||!ye.current)return;const Ce=ye.current.querySelector(`[data-session-id="${n}"]`);Ce&&Ce.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),lt()},[n,e.length,lt]),w.useEffect(()=>{const Ce=ye.current;if(!Ce)return;lt(),Ce.addEventListener("scroll",lt);const We=new ResizeObserver(lt);return We.observe(Ce),()=>{Ce.removeEventListener("scroll",lt),We.disconnect()}},[lt]);const dt=w.useCallback(Ce=>{Ce.preventDefault(),de.current=Ce.clientX,Ne.current=o,K(!0);const We=j,Te=()=>{K(!1),document.removeEventListener("mousemove",xt),document.removeEventListener("mouseup",Te)},xt=ut=>{const mt=de.current-ut.clientX,wt=Ne.current+mt;if(wt>=window.innerWidth*.6&&We){Te(),We();return}const qt=Math.min(x6,Math.max(p6,wt));u==null||u(qt)};document.addEventListener("mousemove",xt),document.addEventListener("mouseup",Te)},[o,u,j]);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:o},children:[u&&l.jsx("div",{className:`terminal-resize-handle absolute top-0 left-0 w-1 h-full cursor-col-resize z-10 transition-colors ${J?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:dt}),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:[D&&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:ye,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[k==null?void 0:k.map(Ce=>l.jsxs("button",{onClick:()=>{C==null||C(Ce.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 ${N===Ce.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:N===Ce.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),l.jsx("span",{className:"truncate",children:Ce.name}),(L==null?void 0:L.has(Ce.id))&&N!==Ce.id&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!Ce.isDefault&&l.jsx("span",{onClick:We=>{We.stopPropagation(),R==null||R(Ce.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:"×"})]},Ce.id)),k&&k.length>0&&e.length>0&&l.jsx("div",{className:"w-px h-4 bg-[var(--terminal-border)] shrink-0 mx-1"}),e.map(Ce=>l.jsx(JE,{roleId:Ce.roleId,title:Ce.title,roleColor:Fh[Ce.roleId]??"#666",active:!Y&&Ce.id===n,isWave:Ce.source==="wave",isWaveStreaming:Ce.source==="wave"&&Ce.status==="active",onClick:()=>{C==null||C(null),d(Ce.id)},onClose:We=>{We.stopPropagation(),h(Ce.id)},"data-session-id":Ce.id},Ce.id))]}),q&&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:()=>{Q(!H),$(!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:"+"}),H&&l.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[E&&l.jsxs(l.Fragment,{children:[U?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:oe,onChange:Ce=>ne(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&oe.trim()&&(E(oe.trim(),[]),ne(""),ee(!1),Q(!1)),Ce.key==="Escape"&&(ee(!1),ne(""))},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:()=>ee(!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"})]}),a.map(Ce=>l.jsxs("button",{onClick:()=>{m(Ce.id),C==null||C(null),Q(!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:Fh[Ce.id]??"#666"}}),Ce.id.toUpperCase()," — ",Ce.name]},Ce.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{$(!A),Q(!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:"···"}),A&&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":""]}),Ve>0&&f&&l.jsxs("button",{onClick:()=>{f(),$(!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 (",Ve,")"]}),e.length>0&&x&&l.jsx("button",{onClick:()=>{x(),$(!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"})]})]}),j&&l.jsx("button",{onClick:j,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:b,className:"px-2 py-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",children:"×"})]}),Y&&ue?l.jsx(m6,{channel:ue,allRoles:a,onUpdateMembers:M,onUpdateTopic:I,onSendMessage:B}):_e?l.jsxs(l.Fragment,{children:[l.jsx(hv,{messages:_e.messages,roleId:_e.roleId,roleColor:Fh[_e.roleId]??"#666"}),_e.source==="wave"?l.jsxs("div",{className:"shrink-0 px-4 py-2 border-t border-[var(--terminal-border)] bg-[var(--terminal-bg-deeper)] flex items-center gap-2",children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",style:_e.status==="active"?{animation:"pulse 2s infinite"}:void 0}),l.jsx("span",{className:"text-[11px] text-amber-400/80",children:"Wave execution · read-only"}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] ml-auto",children:"Interact via Wave Command Center"})]}):l.jsx(Gm,{mode:_e.mode,onModeChange:Ce=>v(_e.id,Ce),onSend:(Ce,We)=>y(_e.id,Ce,_e.mode,We),disabled:Pe,disabledReason:Pe?`${_e.roleId.toUpperCase()} is responding...`: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 y6(){const e=w.useRef(null),n=w.useCallback(()=>{var i;(i=e.current)==null||i.abort(),e.current=null},[]);return{sendMessage:w.useCallback((i,o,u,d,h)=>{n();const m=new AbortController;return e.current=m,fetch(`/api/exec/session/${i}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o,mode:u,attachments:h}),signal:m.signal}).then(async f=>{var N,C,E,R,M;if(!f.ok||!f.body){d.onError("Failed to connect");return}const x=f.body.getReader(),y=new TextDecoder;let v="",b=Date.now();const j=6e4,k=setInterval(()=>{Date.now()-b>j&&(clearInterval(k),m.abort(),d.onError("Connection stale — no data received for 60s"))},1e4);try{for(;;){const{done:I,value:B}=await x.read();if(I)break;b=Date.now(),v+=y.decode(B,{stream:!0});const L=v.split(`
|
|
90
|
+
`);v=L.pop()??"";let H="";for(let Q=0;Q<L.length;Q++){const A=L[Q];if(A.startsWith("event: ")){H=A.slice(7).trim();continue}if(A.startsWith("data: ")){let $;try{$=JSON.parse(A.slice(6))}catch{H="";continue}switch(H){case"thinking":$.text&&((N=d.onThinking)==null||N.call(d,$.text));break;case"output":$.text&&d.onText($.text);break;case"tool":(C=d.onToolUse)==null||C.call(d,$.name,$.input);break;case"dispatch":(E=d.onDispatch)==null||E.call(d,$.roleId,$.task);break;case"dispatch:progress":(R=d.onDispatchProgress)==null||R.call(d,$.roleId,$.type,$);break;case"turn":(M=d.onTurn)==null||M.call(d,$.turn);break;case"done":d.onDone($);break;case"error":d.onError($.message??"Unknown error");break;default:$.text&&d.onText($.text);break}H=""}}}}finally{clearInterval(k)}}).catch(f=>{f.name!=="AbortError"&&d.onError(f.message)}),{abort:n}},[n]),abort:n}}const pv="tycono-appearances",hm="tycono-theme";function Py(){try{const e=localStorage.getItem(pv);return e?JSON.parse(e):{}}catch{return{}}}function Mh(e){localStorage.setItem(pv,JSON.stringify(e))}function Zy(){try{const e=localStorage.getItem(hm);if(e&&e in el)return e}catch{}return"default"}const xv=new Set;for(const e of Object.values(el))for(const n of Object.keys(e.vars))xv.add(n);function g6(e){var i;const n=(i=el[e])==null?void 0:i.vars;if(!n)return;const a=document.documentElement;for(const o of xv)o in n||a.style.removeProperty(o);for(const[o,u]of Object.entries(n))a.style.setProperty(o,u)}const Rh={mode:"auto",intervalSec:18,dailyBudgetUsd:1},mm="tycono-speech-settings",zh="tycono-language";function b6(){try{const e=localStorage.getItem(mm);return e?{...Rh,...JSON.parse(e)}:Rh}catch{return Rh}}function v6(){const[e,n]=w.useState(Py),[a,i]=w.useState(Zy),[o,u]=w.useState(b6),[d,h]=w.useState(()=>{try{return localStorage.getItem(zh)??"auto"}catch{return"auto"}}),m=w.useRef(!1);w.useEffect(()=>{m.current||(m.current=!0,ke.getPreferences().then(k=>{const N=Object.keys(k.appearances??{}).length>0||k.theme!=="default";if(k.speech&&(u(C=>({...C,...k.speech})),localStorage.setItem(mm,JSON.stringify(k.speech))),k.language&&(h(k.language),localStorage.setItem(zh,k.language)),N){const C=k.appearances;n(C),Mh(C),k.theme&&k.theme in el&&(i(k.theme),localStorage.setItem(hm,k.theme))}else{const C=Py(),E=Zy();(Object.keys(C).length>0||E!=="default")&&ke.updatePreferences({appearances:C,theme:E}).catch(()=>{})}}).catch(()=>{}))},[]),w.useEffect(()=>{g6(a)},[a]);const f=w.useCallback(k=>e[k]??Wm(k),[e]),x=w.useCallback((k,N)=>{n(C=>{const E={...C,[k]:N};return Mh(E),ke.updatePreferences({appearances:E}).catch(()=>{}),E})},[]),y=w.useCallback(k=>{n(N=>{const C={...N};return delete C[k],Mh(C),ke.updatePreferences({appearances:C}).catch(()=>{}),C})},[]),v=w.useCallback(k=>{i(k),localStorage.setItem(hm,k),ke.updatePreferences({theme:k}).catch(()=>{})},[]),b=w.useCallback(k=>{u(N=>{const C={...N,...k};return localStorage.setItem(mm,JSON.stringify(C)),ke.updatePreferences({speech:C}).catch(()=>{}),C})},[]),j=w.useCallback(k=>{h(k),localStorage.setItem(zh,k),ke.updatePreferences({language:k}).catch(()=>{})},[]);return{appearances:e,getAppearance:f,setAppearance:x,resetAppearance:y,theme:a,setTheme:v,speechSettings:o,setSpeechSettings:b,language:d,setLanguage:j}}const w6=3e4,k6=3e5;function j6(){var $;const[e,n]=w.useState("akb"),[a,i]=w.useState(null),[o,u]=w.useState("synced"),[d,h]=w.useState([]),[m,f]=w.useState(null),[x,y]=w.useState(!1),v=w.useRef(null),b=w.useRef(null),j=w.useRef(e);j.current=e;const k=w.useCallback(async()=>{try{const U=await ke.getSaveStatus(j.current);i(U),U.noGit?u("no-git"):u(ee=>ee==="saving"?ee:U.dirty?"dirty":"synced")}catch{u("error")}},[]),N=w.useCallback(async()=>{try{const U=await ke.getSyncStatus(j.current);f({ahead:U.ahead,behind:U.behind,branch:U.branch,hasRemote:U.hasRemote})}catch{}},[]),C=w.useCallback(()=>{v.current&&clearInterval(v.current),k(),v.current=setInterval(k,w6),b.current&&clearInterval(b.current),N(),b.current=setInterval(N,k6)},[k,N]);w.useEffect(()=>()=>{v.current&&clearInterval(v.current),b.current&&clearInterval(b.current)},[]);const E=w.useCallback(U=>{n(U),j.current=U,i(null),f(null),h([]),setTimeout(()=>{k(),N()},0)},[k,N]),R=w.useCallback(async U=>{u("saving");try{const ee=await ke.save(U,j.current);return await k(),ee}catch(ee){throw u("error"),ee}},[k]),M=w.useCallback(async()=>{try{const U=await ke.getSaveHistory(20,j.current);h(U)}catch{}},[]),I=w.useCallback(async U=>{u("saving");try{await ke.restoreSave(U,void 0,j.current),await k()}catch(ee){throw u("error"),ee}},[k]),B=w.useCallback(async()=>{y(!0);try{const U=await ke.pull(j.current);return await k(),await N(),U}catch(U){throw U}finally{y(!1)}},[k,N]),L=w.useCallback(async()=>{try{await ke.initGit(),await k()}catch{u("error")}},[k]),H=a?a.modified.length+a.untracked.length:0,Q=(($=a==null?void 0:a.lastCommit)==null?void 0:$.date)??null,A=w.useCallback(async()=>{C()},[C]);return{state:o,dirtyCount:H,lastSaved:Q,status:a,save:R,history:d,loadHistory:M,restore:I,refresh:A,initGit:L,repo:e,setRepo:E,syncInfo:m,fetchSyncStatus:N,pull:B,pulling:x}}const Jy={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."]},eg={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."]},S6=[{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."}]}],C6=18e3,tg=6e3,N6=2500,E6=30*6e4,yv="tycono:relationships";function A6(){try{const e=localStorage.getItem(yv);return e?JSON.parse(e):[]}catch{return[]}}function D6(e){localStorage.setItem(yv,JSON.stringify(e))}function pu(e,n,a){const[i,o]=n<a?[n,a]:[a,n];let u=e.find(d=>d.roleA===i&&d.roleB===o);return u||(u={roleA:i,roleB:o,dispatches:0,wavesTogether:0,conversations:0,familiarity:0,lastInteraction:new Date().toISOString()},e.push(u)),u}function xu(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function yu(e){return e[Math.floor(Math.random()*e.length)]}function T6(e,n,a){const i=a.find(h=>h.id===e),o=a.find(h=>h.id===n);if(!i||!o)return null;const u=i.level==="c-level",d=o.level==="c-level";return u&&d?"c-level":i.reportsTo===n||o.reportsTo===e?"superior-subordinate":(i.reportsTo===o.reportsTo,"peer")}function F6(e,n){return e.relation==="any"?!0:e.relation===n}function M6({roles:e,roleStatuses:n,activeExecs:a,getStandupSpeech:i}){const[o,u]=w.useState(new Map),[d,h]=w.useState(A6),m=w.useRef({}),f=w.useRef(null),x=w.useRef(e),y=w.useRef(n),v=w.useRef(a),b=w.useRef(i),j=w.useRef(d);x.current=e,y.current=n,v.current=a,b.current=i,j.current=d,w.useEffect(()=>{const M=Date.now();for(const[I,B]of Object.entries(n))B==="working"&&(m.current[I]=M)},[n]),w.useEffect(()=>{D6(d)},[d]);const k=w.useCallback(M=>{const I=y.current[M],B=v.current.find($=>$.roleId===M);if(I==="working"&&(B!=null&&B.task))return null;const L=b.current(M);if(L&&Math.random()<.3)return{text:L,type:"work",ts:Date.now()};const H=Date.now(),Q=m.current[M]??0;if(H-Q>E6&&Math.random()<.5){const $=eg[M]??eg.engineer;return{text:yu($),type:"guilt",ts:H}}const A=Jy[M]??Jy.engineer;return{text:yu(A),type:"personality",ts:H}},[]),N=w.useCallback(M=>{if(f.current)return!1;const I=M.filter(ue=>y.current[ue.id]!=="working");if(I.length<2)return!1;const B=[...I].sort(()=>Math.random()-.5),L=B[0],H=B[1],Q=T6(L.id,H.id,M);if(!Q)return!1;const A=pu(j.current,L.id,H.id),$=xu(A),U=S6.filter(ue=>F6(ue,Q)&&$>=ue.minFamiliarity);if(U.length===0)return!1;const ee=yu(U);let oe=L.id,ne=H.id;ee.relation==="superior-subordinate"&&(H.reportsTo===L.id||L.level==="c-level"?(oe=L.id,ne=H.id):(oe=H.id,ne=L.id)),f.current={templateId:ee.id,roleA:oe,roleB:ne,turnIdx:0,timer:null};const Y=ue=>{if(!f.current||ue>=ee.turns.length){f.current=null,h(F=>{const q=[...F],T=pu(q,oe,ne);return T.conversations++,T.familiarity=xu(T),T.lastInteraction=new Date().toISOString(),q}),setTimeout(()=>{u(F=>{const q=new Map(F);return q.delete(oe),q.delete(ne),q})},tg);return}const J=ee.turns[ue],K=J.speaker==="A"?oe:ne,D=J.speaker==="A"?ne:oe;u(F=>{const q=new Map(F);if(q.set(K,{text:J.text,type:"social",partnerId:D,ts:Date.now()}),ue>0){const T=ee.turns[ue-1].speaker==="A"?oe:ne;T!==K&&q.delete(T)}return q}),f.current.turnIdx=ue,f.current.timer=setTimeout(()=>Y(ue+1),N6)};return Y(0),!0},[]);w.useEffect(()=>{const M=setInterval(()=>{const I=x.current;if(I.length===0||f.current||Math.random()<.35&&N(I))return;const B=I.filter(Q=>y.current[Q.id]!=="working");if(B.length===0)return;const L=yu(B),H=k(L.id);H&&(u(Q=>{const A=new Map(Q);return A.set(L.id,H),A}),setTimeout(()=>{u(Q=>{const A=new Map(Q),$=A.get(L.id);return $&&$.ts===H.ts&&A.delete(L.id),A})},tg))},C6);return()=>{var I;clearInterval(M),(I=f.current)!=null&&I.timer&&clearTimeout(f.current.timer)}},[k,N]);const C=w.useCallback(M=>{const I=o.get(M);return(I==null?void 0:I.text)??""},[o]),E=w.useCallback((M,I)=>{h(B=>{const L=[...B],H=pu(L,M,I);return H.dispatches++,H.familiarity=xu(H),H.lastInteraction=new Date().toISOString(),L})},[]),R=w.useCallback(M=>{M.length<2||h(I=>{const B=[...I];for(let L=0;L<M.length;L++)for(let H=L+1;H<M.length;H++){const Q=pu(B,M[L],M[H]);Q.wavesTogether++,Q.familiarity=xu(Q),Q.lastInteraction=new Date().toISOString()}return B})},[]);return{speeches:o,getSpeech:C,relationships:d,notifyDispatch:E,notifyWave:R}}const gv="tycono:office-chat";let R6=0;function z6(){return`chat-${Date.now()}-${++R6}`}function _h(){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 _6(){try{const e=localStorage.getItem(gv);if(e){const n=JSON.parse(e);if(n.find(i=>i.id==="office")&&!n.find(i=>i.id==="general")){const i=n.filter(o=>o.id!=="office");return[..._h(),...i]}const a=_h();for(const i of a)n.find(o=>o.id===i.id)||n.unshift(i);return n}}catch{}return _h()}function B6(e){const n=e.map(a=>({...a,messages:a.messages.slice(-200)}));localStorage.setItem(gv,JSON.stringify(n))}function O6(){const[e,n]=w.useState(_6),[a,i]=w.useState(null),[o,u]=w.useState(new Set);w.useEffect(()=>{B6(e)},[e]);const d=w.useCallback(b=>{i(b),b&&u(j=>{const k=new Set(j);return k.delete(b),k})},[]),h=w.useCallback(b=>{const j={...b,id:z6()};n(k=>{const N=k.map(C=>C.id==="general"?b.type==="dispatch"?{...C,messages:[...C.messages,j].slice(-200)}:C:b.channelId?C.id===b.channelId?{...C,messages:[...C.messages,j].slice(-200)}:C:C.members.length>0&&C.members.includes(b.roleId)?{...C,messages:[...C.messages,j].slice(-200)}:C);return u(C=>{const E=new Set(C);for(const R of N){const M=k.find(I=>I.id===R.id);M&&R.messages.length>M.messages.length&&E.add(R.id)}return E}),N})},[]),m=w.useCallback((b,j,k)=>{const N=`ch-${Date.now()}`,C={id:N,name:b.startsWith("#")?b:`#${b}`,members:j,isDefault:!1,messages:[],topic:k};n(E=>[...E,C]),i(N)},[]),f=w.useCallback(b=>{n(j=>j.filter(k=>k.id!==b||k.isDefault)),i(j=>j===b?"general":j)},[]),x=w.useCallback((b,j)=>{n(k=>k.map(N=>N.id===b&&!N.isDefault?{...N,members:j}:N))},[]),y=w.useCallback((b,j)=>{n(k=>k.map(N=>N.id===b&&!N.isDefault?{...N,topic:j||void 0}:N))},[]),v=w.useCallback(b=>{n(j=>j.map(k=>{if(k.id==="watercooler"){const N=b.filter(C=>C.level!=="c-level").map(C=>C.id);if(k.members.length!==N.length||!N.every(C=>k.members.includes(C)))return{...k,members:N}}return k}))},[]);return{channels:e,activeChannelId:a,setActiveChannelId:d,pushMessage:h,createChannel:m,deleteChannel:f,updateMembers:x,updateTopic:y,unreadChannels:o,syncDefaultMembers:v}}const $6=45e3,ng=5e3,L6=4,I6=20;function H6({roles:e,roleStatuses:n,activeExecs:a,channels:i,relationships:o,pushMessage:u,speechSettings:d,engineType:h,hasApiKey:m}){const x=((d==null?void 0:d.mode)==="auto"?h==="claude-cli"||h==="local"?"llm":"template":(d==null?void 0:d.mode)??"template")==="llm"&&(m!==!1||h==="claude-cli"),y=((d==null?void 0:d.intervalSec)??$6/1e3)*1e3,v=w.useRef(e),b=w.useRef(n),j=w.useRef(a),k=w.useRef(i),N=w.useRef(o),C=w.useRef(u),E=w.useRef(0),R=w.useRef(!1);v.current=e,b.current=n,j.current=a,k.current=i,N.current=o,C.current=u;const M=w.useCallback(async(L,H)=>{if(R.current)return!1;R.current=!0;try{if(!v.current.find(Y=>Y.id===L))return!1;const A=H.messages.slice(-I6).map(Y=>({roleId:Y.roleId,text:Y.text,ts:Y.ts})),$=v.current.filter(Y=>H.members.includes(Y.id)),U=N.current.filter(Y=>Y.roleA===L||Y.roleB===L).map(Y=>({partnerId:Y.roleA===L?Y.roleB:Y.roleA,familiarity:Y.familiarity})),ee=j.current.find(Y=>Y.roleId===L),oe=ee?{currentTask:ee.task,taskProgress:null}:{currentTask:null,taskProgress:null},ne=await ke.chatInChannel({channelId:H.name.replace("#",""),channelTopic:H.topic,roleId:L,history:A,members:$.map(Y=>({id:Y.id,name:Y.name,level:Y.level})),relationships:U,workContext:oe});return ne.message?(C.current({ts:Date.now(),roleId:L,text:ne.message,type:"chat",channelId:H.id}),!0):!1}catch{return!1}finally{R.current=!1}},[]),I=w.useCallback(async(L,H)=>{if(E.current>=L6){E.current=0;return}const Q=L.members.filter(ee=>ee!==H&&b.current[ee]!=="working");if(Q.length===0){E.current=0;return}const A=Q[Math.floor(Math.random()*Q.length)];if(Math.random()>.7){E.current=0;return}const $=E.current*2e3,U=Math.random()*5e3;setTimeout(async()=>{E.current++;const ee=k.current.find(ne=>ne.id===L.id);if(!ee)return;if(await M(A,ee)){const ne=.6-E.current*.1;Math.random()<ne?I(ee,A):E.current=0}else E.current=0},ng+$+U)},[M]);return w.useEffect(()=>{if(!x)return;const L=setInterval(async()=>{const H=v.current;if(H.length===0||R.current)return;const Q=H.filter(oe=>b.current[oe.id]!=="working");if(Q.length===0)return;const A=Q[Math.floor(Math.random()*Q.length)],$=k.current.filter(oe=>oe.members.length===0?!0:oe.members.includes(A.id));if($.length===0)return;const U=$[Math.floor(Math.random()*$.length)];E.current=0,await M(A.id,U)&&I(U,A.id)},y);return()=>clearInterval(L)},[x,y,M,I]),{triggerCeoReaction:w.useCallback(L=>{if(!x)return;const H=k.current.find(Q=>Q.id===L);H&&(E.current=0,setTimeout(()=>{I(H,"ceo")},ng))},[x,I])}}const bv=[[1,8],[3,5],[8,1],[5,3]],U6=[[1,4],[2,3],[4,1],[3,2]];function gu(e){const n=e===1||e===3?-1:0,a=bv[e],i=e<2?[0,1]:[1,0],o=n;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:a[0],y:13,w:3,h:4,c:"$pants"},{x:a[1],y:13,w:3,h:4,c:"$pants"},{x:a[0]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:a[1]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:a[0],y:16,w:3,h:2,c:"$shoes"},{x:a[1],y:16,w:3,h:2,c:"$shoes"},{x:a[0],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:a[1],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:1,y:o+8,w:10,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.35},{x:1,y:o+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:10,y:o+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:-1,y:o+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:o+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:-1,y:o+12,w:2,h:1,c:"$skin"},{x:11,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:1,y:o+0,w:10,h:7,c:"$skin"},{x:3,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:o+3,w:1,h:1,c:"#FFF",a:.4},{x:7,y:o+3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:o+6,w:2,h:1,c:"darken($skin, 25)",a:.35},{x:0,y:o+3,w:1,h:1,c:"$skin"},{x:11,y:o+3,w:1,h:1,c:"$skin"},{x:1,y:o+0,w:10,h:3,c:"$hair"},{x:0,y:o+1,w:2,h:3,c:"$hair"},{x:10,y:o+1,w:2,h:3,c:"$hair"},{x:2,y:o+0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]}function bu(e){const n=e===1||e===3?-1:0,a=bv[e],i=e<2?[0,1]:[1,0],o=n;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:a[0],y:13,w:3,h:4,c:"$pants"},{x:a[1],y:13,w:3,h:4,c:"$pants"},{x:a[0],y:16,w:3,h:2,c:"$shoes"},{x:a[1],y:16,w:3,h:2,c:"$shoes"},{x:1,y:o+8,w:10,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:5,y:o+10,w:2,h:3,c:"darken($shirt, 30)",a:.12},{x:-1,y:o+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:o+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:1,y:o+0,w:10,h:7,c:"$skin"},{x:1,y:o+0,w:10,h:6,c:"$hair"},{x:0,y:o+1,w:2,h:5,c:"$hair"},{x:10,y:o+1,w:2,h:5,c:"$hair"},{x:2,y:o+0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:0,y:o+4,w:1,h:1,c:"$skin",a:.6},{x:11,y:o+4,w:1,h:1,c:"$skin",a:.6}]}function Ml(e,n){const a=e===1||e===3?-1:0,i=U6[e],o=a,u=e%2===0?1:0;return n?[{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:o+8,w:8,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:8,y:o+9+u,w:3,h:4-u,c:"$shirt"},{x:9,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:2,y:o+0,w:8,h:7,c:"$skin"},{x:7,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:o+3,w:1,h:1,c:"#FFF",a:.3},{x:9,y:o+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:o+0,w:8,h:3,c:"$hair"},{x:1,y:o+1,w:2,h:4,c:"$hair"},{x:9,y:o+1,w:2,h:3,c:"$hair"},{x:3,y:o+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:o+8,w:8,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:0,y:o+9+u,w:3,h:4-u,c:"$shirt"},{x:-1,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:2,y:o+0,w:8,h:7,c:"$skin"},{x:3,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:o+3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:o+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:o+0,w:8,h:3,c:"$hair"},{x:1,y:o+1,w:2,h:3,c:"$hair"},{x:9,y:o+1,w:2,h:4,c:"$hair"},{x:3,y:o+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]}const rg={down:[gu(0),gu(1),gu(2),gu(3)],up:[bu(0),bu(1),bu(2),bu(3)],right:[Ml(0,!0),Ml(1,!0),Ml(2,!0),Ml(3,!0)],left:[Ml(0,!1),Ml(1,!1),Ml(2,!1),Ml(3,!1)]},De="#FAFAF7",_n="#FFFFFF",Ae="#EDE8E2",Qe="#DDD6CC",Ho="#1A1A2E",Zu="#2A2A2A",Vm="#FFB0B0",ag=[{x:2,y:0,w:1,h:1,c:Ae},{x:3,y:0,w:1,h:1,c:De},{x:4,y:0,w:1,h:1,c:_n},{x:5,y:0,w:1,h:1,c:De},{x:6,y:0,w:1,h:1,c:Ae},{x:1,y:1,w:1,h:1,c:Qe},{x:2,y:1,w:1,h:1,c:De},{x:3,y:1,w:1,h:1,c:_n},{x:4,y:1,w:1,h:1,c:De},{x:5,y:1,w:1,h:1,c:_n},{x:6,y:1,w:1,h:1,c:De},{x:7,y:1,w:1,h:1,c:Qe},{x:0,y:2,w:1,h:1,c:Qe},{x:1,y:2,w:1,h:1,c:Ae},{x:2,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:De},{x:4,y:2,w:1,h:1,c:_n},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:De},{x:7,y:2,w:1,h:1,c:Ae},{x:8,y:2,w:1,h:1,c:Qe},{x:1,y:3,w:1,h:1,c:Ae},{x:2,y:3,w:1,h:1,c:De},{x:3,y:3,w:1,h:1,c:Ho},{x:4,y:3,w:1,h:1,c:De},{x:5,y:3,w:1,h:1,c:Ho},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:Ae},{x:2,y:4,w:1,h:1,c:Ae},{x:3,y:4,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:Zu},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:Ae},{x:3,y:5,w:1,h:1,c:Qe},{x:4,y:5,w:1,h:1,c:Ae},{x:5,y:5,w:1,h:1,c:Qe},{x:2,y:6,w:1,h:1,c:Ae},{x:3,y:6,w:1,h:1,c:De},{x:4,y:6,w:1,h:1,c:_n},{x:5,y:6,w:1,h:1,c:De},{x:6,y:6,w:1,h:1,c:Ae},{x:2,y:7,w:1,h:1,c:Qe},{x:3,y:7,w:1,h:1,c:Ae},{x:4,y:7,w:1,h:1,c:De},{x:5,y:7,w:1,h:1,c:Ae},{x:6,y:7,w:1,h:1,c:Qe}],q6=[{x:3,y:8,w:1,h:1,c:Ae},{x:5,y:8,w:1,h:1,c:Ae},{x:3,y:9,w:1,h:1,c:Qe},{x:5,y:9,w:1,h:1,c:Qe}],Y6=[{x:2,y:8,w:1,h:1,c:Ae},{x:6,y:8,w:1,h:1,c:Ae},{x:2,y:9,w:1,h:1,c:Qe},{x:6,y:9,w:1,h:1,c:Qe}],lg=[{x:2,y:0,w:1,h:1,c:Ae},{x:3,y:0,w:1,h:1,c:De},{x:4,y:0,w:1,h:1,c:_n},{x:5,y:0,w:1,h:1,c:De},{x:6,y:0,w:1,h:1,c:Ae},{x:1,y:1,w:1,h:1,c:Qe},{x:2,y:1,w:1,h:1,c:Ae},{x:3,y:1,w:1,h:1,c:De},{x:4,y:1,w:1,h:1,c:_n},{x:5,y:1,w:1,h:1,c:De},{x:6,y:1,w:1,h:1,c:Ae},{x:7,y:1,w:1,h:1,c:Qe},{x:0,y:2,w:1,h:1,c:Qe},{x:1,y:2,w:1,h:1,c:Ae},{x:2,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:De},{x:4,y:2,w:1,h:1,c:De},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:De},{x:7,y:2,w:1,h:1,c:Ae},{x:8,y:2,w:1,h:1,c:Qe},{x:1,y:3,w:1,h:1,c:Qe},{x:2,y:3,w:1,h:1,c:Ae},{x:3,y:3,w:1,h:1,c:De},{x:4,y:3,w:1,h:1,c:De},{x:5,y:3,w:1,h:1,c:De},{x:6,y:3,w:1,h:1,c:Ae},{x:7,y:3,w:1,h:1,c:Qe},{x:2,y:4,w:1,h:1,c:Qe},{x:3,y:4,w:1,h:1,c:Ae},{x:4,y:4,w:1,h:1,c:De},{x:5,y:4,w:1,h:1,c:Ae},{x:6,y:4,w:1,h:1,c:Qe},{x:3,y:5,w:1,h:1,c:Qe},{x:4,y:5,w:1,h:1,c:Ae},{x:5,y:5,w:1,h:1,c:Qe},{x:2,y:6,w:1,h:1,c:Ae},{x:3,y:6,w:1,h:1,c:De},{x:4,y:6,w:1,h:1,c:De},{x:5,y:6,w:1,h:1,c:De},{x:6,y:6,w:1,h:1,c:Ae},{x:2,y:7,w:1,h:1,c:Qe},{x:3,y:7,w:1,h:1,c:Ae},{x:4,y:7,w:1,h:1,c:De},{x:5,y:7,w:1,h:1,c:Ae},{x:6,y:7,w:1,h:1,c:Qe},{x:4,y:5,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:_n}],X6=[{x:3,y:8,w:1,h:1,c:Ae},{x:5,y:8,w:1,h:1,c:Ae},{x:3,y:9,w:1,h:1,c:Qe},{x:5,y:9,w:1,h:1,c:Qe}],W6=[{x:2,y:8,w:1,h:1,c:Ae},{x:6,y:8,w:1,h:1,c:Ae},{x:2,y:9,w:1,h:1,c:Qe},{x:6,y:9,w:1,h:1,c:Qe}],pm=[{x:8,y:0,w:1,h:1,c:Ae},{x:9,y:0,w:1,h:1,c:De},{x:10,y:0,w:1,h:1,c:_n},{x:11,y:0,w:1,h:1,c:De},{x:7,y:1,w:1,h:1,c:Qe},{x:8,y:1,w:1,h:1,c:De},{x:9,y:1,w:1,h:1,c:_n},{x:10,y:1,w:1,h:1,c:De},{x:11,y:1,w:1,h:1,c:De},{x:12,y:1,w:1,h:1,c:Ae},{x:0,y:2,w:1,h:1,c:_n},{x:1,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:Ae},{x:4,y:2,w:1,h:1,c:De},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:De},{x:7,y:2,w:1,h:1,c:Ae},{x:8,y:2,w:1,h:1,c:De},{x:9,y:2,w:1,h:1,c:De},{x:10,y:2,w:1,h:1,c:De},{x:11,y:2,w:1,h:1,c:De},{x:12,y:2,w:1,h:1,c:Ae},{x:0,y:3,w:1,h:1,c:Ae},{x:1,y:3,w:1,h:1,c:Qe},{x:3,y:3,w:1,h:1,c:Qe},{x:4,y:3,w:1,h:1,c:Ae},{x:5,y:3,w:1,h:1,c:De},{x:6,y:3,w:1,h:1,c:Ae},{x:7,y:3,w:1,h:1,c:Qe},{x:8,y:3,w:1,h:1,c:De},{x:9,y:3,w:1,h:1,c:Ho},{x:10,y:3,w:1,h:1,c:De},{x:11,y:3,w:1,h:1,c:Ae},{x:3,y:4,w:1,h:1,c:Qe},{x:4,y:4,w:1,h:1,c:Ae},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:Ae},{x:8,y:4,w:1,h:1,c:Ae},{x:9,y:4,w:1,h:1,c:De},{x:10,y:4,w:1,h:1,c:Zu}],vv=[{x:4,y:5,w:1,h:1,c:Ae},{x:6,y:5,w:1,h:1,c:Ae},{x:8,y:5,w:1,h:1,c:Ae},{x:10,y:5,w:1,h:1,c:Ae},{x:4,y:6,w:1,h:1,c:Qe},{x:6,y:6,w:1,h:1,c:Qe},{x:8,y:6,w:1,h:1,c:Qe},{x:10,y:6,w:1,h:1,c:Qe}],wv=[{x:3,y:5,w:1,h:1,c:Ae},{x:5,y:5,w:1,h:1,c:Ae},{x:9,y:5,w:1,h:1,c:Ae},{x:11,y:5,w:1,h:1,c:Ae},{x:3,y:6,w:1,h:1,c:Qe},{x:5,y:6,w:1,h:1,c:Qe},{x:9,y:6,w:1,h:1,c:Qe},{x:11,y:6,w:1,h:1,c:Qe}];function Km(e,n=13){return e.map(a=>({...a,x:n-1-a.x}))}const ig=Km(pm),G6=Km(vv),V6=Km(wv),K6={down:[[...ag,...q6],[...ag,...Y6]],up:[[...lg,...X6],[...lg,...W6]],right:[[...pm,...vv],[...pm,...wv]],left:[[...ig,...G6],[...ig,...V6]]},Q6=[{x:4,y:5,w:1,h:1,c:Vm}],Dn="#FFD4D4",Yr="#FFCCD5",P6=[{x:2,y:0,w:1,h:1,c:Qe},{x:3,y:0,w:1,h:1,c:Ae},{x:4,y:0,w:1,h:1,c:De},{x:5,y:0,w:1,h:1,c:_n},{x:6,y:0,w:1,h:1,c:Ae},{x:7,y:0,w:1,h:1,c:Qe},{x:1,y:1,w:1,h:1,c:Qe},{x:2,y:1,w:1,h:1,c:Ae},{x:3,y:1,w:1,h:1,c:De},{x:4,y:1,w:1,h:1,c:_n},{x:5,y:1,w:1,h:1,c:De},{x:6,y:1,w:1,h:1,c:_n},{x:7,y:1,w:1,h:1,c:Ae},{x:8,y:1,w:1,h:1,c:Qe},{x:1,y:2,w:1,h:1,c:Ae},{x:2,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:Ho},{x:4,y:2,w:1,h:1,c:De},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:Ho},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:Ae},{x:2,y:3,w:1,h:1,c:Ae},{x:3,y:3,w:1,h:1,c:De},{x:4,y:3,w:1,h:1,c:Zu},{x:5,y:3,w:1,h:1,c:Vm},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:Ae},{x:2,y:4,w:1,h:1,c:Qe},{x:3,y:4,w:1,h:1,c:Ae},{x:4,y:4,w:1,h:1,c:De},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:Ae},{x:7,y:4,w:1,h:1,c:Qe},{x:0,y:5,w:1,h:1,c:Ae},{x:1,y:5,w:1,h:1,c:Yr},{x:2,y:5,w:1,h:1,c:De},{x:3,y:5,w:1,h:1,c:Dn},{x:4,y:5,w:1,h:1,c:Dn},{x:5,y:5,w:1,h:1,c:Dn},{x:6,y:5,w:1,h:1,c:Dn},{x:7,y:5,w:1,h:1,c:De},{x:8,y:5,w:1,h:1,c:Yr},{x:9,y:5,w:1,h:1,c:Ae},{x:1,y:6,w:1,h:1,c:Ae},{x:2,y:6,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:Dn},{x:4,y:6,w:1,h:1,c:Yr},{x:5,y:6,w:1,h:1,c:Yr},{x:6,y:6,w:1,h:1,c:Dn},{x:7,y:6,w:1,h:1,c:De},{x:8,y:6,w:1,h:1,c:Ae},{x:2,y:7,w:1,h:1,c:De},{x:3,y:7,w:1,h:1,c:Dn},{x:4,y:7,w:1,h:1,c:Dn},{x:5,y:7,w:1,h:1,c:Dn},{x:6,y:7,w:1,h:1,c:Dn},{x:7,y:7,w:1,h:1,c:De},{x:0,y:8,w:1,h:1,c:Ae},{x:1,y:8,w:1,h:1,c:Yr},{x:2,y:8,w:1,h:1,c:Qe},{x:3,y:8,w:1,h:1,c:Ae},{x:4,y:8,w:1,h:1,c:De},{x:5,y:8,w:1,h:1,c:De},{x:6,y:8,w:1,h:1,c:Ae},{x:7,y:8,w:1,h:1,c:Qe},{x:8,y:8,w:1,h:1,c:Yr},{x:9,y:8,w:1,h:1,c:Ae},{x:4,y:9,w:1,h:1,c:De},{x:5,y:9,w:1,h:1,c:_n}],Z6=[{x:2,y:0,w:1,h:1,c:Qe},{x:3,y:0,w:1,h:1,c:Ae},{x:4,y:0,w:1,h:1,c:De},{x:5,y:0,w:1,h:1,c:_n},{x:6,y:0,w:1,h:1,c:Ae},{x:7,y:0,w:1,h:1,c:Qe},{x:1,y:1,w:1,h:1,c:Qe},{x:2,y:1,w:1,h:1,c:Ae},{x:3,y:1,w:1,h:1,c:De},{x:4,y:1,w:1,h:1,c:_n},{x:5,y:1,w:1,h:1,c:De},{x:6,y:1,w:1,h:1,c:_n},{x:7,y:1,w:1,h:1,c:Ae},{x:8,y:1,w:1,h:1,c:Qe},{x:1,y:2,w:1,h:1,c:Ae},{x:2,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:Ae},{x:4,y:2,w:1,h:1,c:De},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:Ae},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:Ae},{x:2,y:3,w:1,h:1,c:Ae},{x:3,y:3,w:1,h:1,c:De},{x:4,y:3,w:1,h:1,c:Zu},{x:5,y:3,w:1,h:1,c:Vm},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:Ae},{x:2,y:4,w:1,h:1,c:Qe},{x:3,y:4,w:1,h:1,c:Ae},{x:4,y:4,w:1,h:1,c:De},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:Ae},{x:7,y:4,w:1,h:1,c:Qe},{x:0,y:5,w:1,h:1,c:Ae},{x:1,y:5,w:1,h:1,c:Yr},{x:2,y:5,w:1,h:1,c:De},{x:3,y:5,w:1,h:1,c:Dn},{x:4,y:5,w:1,h:1,c:Dn},{x:5,y:5,w:1,h:1,c:Dn},{x:6,y:5,w:1,h:1,c:Dn},{x:7,y:5,w:1,h:1,c:De},{x:8,y:5,w:1,h:1,c:Yr},{x:9,y:5,w:1,h:1,c:Ae},{x:1,y:6,w:1,h:1,c:Ae},{x:2,y:6,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:Dn},{x:4,y:6,w:1,h:1,c:Yr},{x:5,y:6,w:1,h:1,c:Yr},{x:6,y:6,w:1,h:1,c:Dn},{x:7,y:6,w:1,h:1,c:De},{x:8,y:6,w:1,h:1,c:Ae},{x:2,y:7,w:1,h:1,c:De},{x:3,y:7,w:1,h:1,c:Dn},{x:4,y:7,w:1,h:1,c:Dn},{x:5,y:7,w:1,h:1,c:Dn},{x:6,y:7,w:1,h:1,c:Dn},{x:7,y:7,w:1,h:1,c:De},{x:0,y:8,w:1,h:1,c:Ae},{x:1,y:8,w:1,h:1,c:Yr},{x:2,y:8,w:1,h:1,c:Qe},{x:3,y:8,w:1,h:1,c:Ae},{x:4,y:8,w:1,h:1,c:De},{x:5,y:8,w:1,h:1,c:De},{x:6,y:8,w:1,h:1,c:Ae},{x:7,y:8,w:1,h:1,c:Qe},{x:8,y:8,w:1,h:1,c:Yr},{x:9,y:8,w:1,h:1,c:Ae},{x:5,y:9,w:1,h:1,c:De},{x:6,y:9,w:1,h:1,c:_n}],J6=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],eA=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],tA=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],ot=4,nn=28,zn=2,Mt=4,kt=4,Za=[{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 Qm(e,n,a){const u=e.fy+Math.max(10,Math.floor(e.fh*.18)),d=Math.min(n,a),h=Math.ceil(n/d),m=[],f=d*28,x=e.fx+Math.max(8,Math.floor((e.fw-f)/2));for(let y=0;y<h&&m.length<n;y++){const v=Math.min(d,n-y*d);for(let b=0;b<v;b++)m.push({dx:x+b*28,dy:u+y*28,room:e.id})}return m}function nA(e){const i=Za[0],o={id:"main",wx:ot+kt,wy:ot,ww:160-2*(ot+kt),wh:nn,fx:ot+kt,fy:ot+nn+zn,fw:160-2*(ot+kt),fh:120-ot-nn-zn-ot,...i},u=Qm(o,Math.min(e,6),3),d=[{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*(ot+kt))/2),offsetY:10}],h=[{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:o},desks:u,doors:{},adjacency:{main:[]},corridorY:{main:o.fy+o.fh-12},waypoints:{main:[{x:o.fx+10,y:o.fy+o.fh-14},{x:o.fx+o.fw/2,y:o.fy+o.fh-14},{x:o.fx+o.fw-10,y:o.fy+o.fh-14}]},wallDecorations:d,furniture:h}}function rA(e){const o={id:"exec",wx:ot+kt,wy:ot,ww:144-ot-kt-Mt/2,wh:nn,fx:ot+kt,fy:ot+nn+zn,fw:144-ot-kt-Mt/2,fh:66,...Za[0]},u={id:"work",wx:144+Mt/2+kt,wy:ot,ww:144-Mt/2-kt-ot,wh:nn,fx:144+Mt/2+kt,fy:ot+nn+zn,fw:144-Mt/2-kt-ot,fh:66,...Za[1]},d={id:"meet",wx:ot+kt,wy:ot+nn+zn+66+Mt,ww:144-ot-kt-Mt/2,wh:nn,fx:ot+kt,fy:ot+nn+zn+66+Mt+nn+zn,fw:144-ot-kt-Mt/2,fh:70,...Za[2]},h={id:"comm",wx:144+Mt/2+kt,wy:ot+nn+zn+66+Mt,ww:144-Mt/2-kt-ot,wh:nn,fx:144+Mt/2+kt,fy:ot+nn+zn+66+Mt+nn+zn,fw:144-Mt/2-kt-ot,fh:70,...Za[3]},m={exec:o,work:u,meet:d,comm:h},f=[];let x=e;const y=[[o,Math.min(3,x)],[u,0]];y[1][1]=Math.min(3,x-y[0][1]);const v=[[d,0],[h,0]];let b=x-y[0][1]-y[1][1];b>0&&(v[0][1]=Math.min(2,b),b-=v[0][1]),b>0&&(v[1][1]=Math.min(2,b));for(const[B,L]of[...y,...v])L>0&&f.push(...Qm(B,L,3));const j=ot+nn+zn+66,k=144-Mt/2,N={exec_work:{id:"exec_work",type:"v",doorY:ot+nn+zn+20+12,xA:k-2,xB:u.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:ot+nn+zn+66+Mt+nn+zn+20+12,xA:k-2,xB:h.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:ot+kt+40+14,yA:j-2,yB:d.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+Mt/2+kt+40+14,yA:j-2,yB:h.fy+2}},C={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},E={exec:o.fy+52,work:u.fy+48,meet:d.fy+56,comm:h.fy+54},R={exec:[{x:o.fx+6,y:o.fy+52},{x:o.fx+60,y:o.fy+54},{x:o.fx+112,y:o.fy+50},{x:o.fx+50,y:o.fy+52}],work:[{x:u.fx+14,y:u.fy+48},{x:u.fx+44,y:u.fy+48},{x:u.fx+70,y:u.fy+48},{x:u.fx+100,y:u.fy+48}],meet:[{x:d.fx+60,y:d.fy+56},{x:d.fx+30,y:d.fy+54},{x:d.fx+110,y:d.fy+50},{x:d.fx+80,y:d.fy+56}],comm:[{x:h.fx+96,y:h.fy+8},{x:h.fx+60,y:h.fy+54},{x:h.fx+40,y:h.fy+54},{x:h.fx+20,y:h.fy+54}]},M=[{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}],I=[{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(o.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:N,adjacency:C,corridorY:E,waypoints:R,wallDecorations:M,furniture:I}}function aA(e){const d={id:"exec",wx:ot+kt,wy:ot,ww:180-ot-kt-Mt/2,wh:nn,fx:ot+kt,fy:ot+nn+zn,fw:180-ot-kt-Mt/2,fh:82,...Za[0]},h={id:"work",wx:180+Mt/2+kt,wy:ot,ww:180-Mt/2-kt-ot,wh:nn,fx:180+Mt/2+kt,fy:ot+nn+zn,fw:180-Mt/2-kt-ot,fh:82,...Za[1]},m=ot+nn+zn+82,f={id:"meet",wx:ot+kt,wy:m+Mt,ww:180-ot-kt-Mt/2,wh:nn,fx:ot+kt,fy:m+Mt+nn+zn,fw:180-ot-kt-Mt/2,fh:86,...Za[2]},x={id:"comm",wx:180+Mt/2+kt,wy:m+Mt,ww:180-Mt/2-kt-ot,wh:nn,fx:180+Mt/2+kt,fy:m+Mt+nn+zn,fw:180-Mt/2-kt-ot,fh:86,...Za[3]},y={exec:d,work:h,meet:f,comm:x},v=[];let b=e;const j=[[d,Math.min(5,b)],[h,0]];j[1][1]=Math.min(5,b-j[0][1]);const k=[[f,0],[x,0]];let N=b-j[0][1]-j[1][1];N>0&&(k[0][1]=Math.min(3,N),N-=k[0][1]),N>0&&(k[1][1]=Math.min(3,N));for(const[H,Q]of[...j,...k])Q>0&&v.push(...Qm(H,Q,4));const C=180-Mt/2,E={exec_work:{id:"exec_work",type:"v",doorY:d.fy+82/2,xA:C-2,xB:h.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:f.fy+86/2,xA:C-2,xB:x.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:d.fx+54,yA:m-2,yB:f.fy+2},work_comm:{id:"work_comm",type:"h",doorX:h.fx+54,yA:m-2,yB:x.fy+2}},R={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"}]},M={exec:d.fy+82-12,work:h.fy+82-12,meet:f.fy+86-12,comm:x.fy+86-12},I={exec:[{x:d.fx+10,y:M.exec},{x:d.fx+d.fw/2,y:M.exec},{x:d.fx+d.fw-10,y:M.exec}],work:[{x:h.fx+10,y:M.work},{x:h.fx+h.fw/2,y:M.work},{x:h.fx+h.fw-10,y:M.work}],meet:[{x:f.fx+10,y:M.meet},{x:f.fx+f.fw/2,y:M.meet},{x:f.fx+f.fw-10,y:M.meet}],comm:[{x:x.fx+10,y:M.comm},{x:x.fx+x.fw/2,y:M.comm},{x:x.fx+x.fw-10,y:M.comm}]},B=[{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}],L=[{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(d.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:y,desks:v,doors:E,adjacency:R,corridorY:M,waypoints:I,wallDecorations:B,furniture:L}}const lA=2;function kv(e,n,a){return a||(n?n==="L"&&e<=12-lA?"M":n==="M"&&e>12?"L":n:e<=12?"M":"L")}function jv(e,n){switch(n??kv(e)){case"S":return nA(e);case"M":return rA(e);case"L":return aA(e)}}function iA(e,n){if(!n||Object.keys(n).length===0)return e;const a=i=>i.map(o=>{const u=n[o.id];return u?{...o,offsetX:u.offsetX,offsetY:u.offsetY}:o});return{...e,wallDecorations:a(e.wallDecorations),furniture:a(e.furniture)}}function sA(e,n){if(n)for(const[a,i]of Object.entries(n))e[a]&&(e[a]={...e[a],dx:i.dx,dy:i.dy})}function sg(e,n){if(!n||n.length===0)return e;const a=new Set(n);return{...e,wallDecorations:e.wallDecorations.filter(i=>!a.has(i.id)),furniture:e.furniture.filter(i=>!a.has(i.id))}}function oA(e,n){if(!n||n.length===0)return e;const a=[],i=[];for(const o of n)o.zone==="wall"?a.push(o):i.push(o);return{...e,wallDecorations:[...e.wallDecorations,...a],furniture:[...e.furniture,...i]}}let Ro;function cA(e){Ro=e}function O(e,n,a,i,o,u){e=Math.round(e),n=Math.round(n),!(u!==void 0&&u<.01)&&(u!==void 0&&u!==1&&(Ro.globalAlpha=u),Ro.fillStyle=o,Ro.fillRect(e,n,a,i),u!==void 0&&u!==1&&(Ro.globalAlpha=1))}function st(e,n,a,i){O(e,n,1,1,a,i)}let Du=1;function Cs(e){Du=e}function ja(){return Du=Du*16807%2147483647,(Du&65535)/65535}function Sv(e){const n=parseInt(e.slice(1,3),16)/255,a=parseInt(e.slice(3,5),16)/255,i=parseInt(e.slice(5,7),16)/255,o=Math.max(n,a,i),u=Math.min(n,a,i);let d=0,h=0;const m=(o+u)/2;if(o!==u){const f=o-u;h=m>.5?f/(2-o-u):f/(o+u),o===n?d=((a-i)/f+(a<i?6:0))/6:o===a?d=((i-n)/f+2)/6:d=((n-a)/f+4)/6}return[d*360,h*100,m*100]}function Cv(e,n,a){e=(e%360+360)%360,n=Math.max(0,Math.min(100,n))/100,a=Math.max(0,Math.min(100,a))/100;const i=n*Math.min(a,1-a),o=d=>{const h=(d+e/30)%12;return a-i*Math.max(-1,Math.min(h-3,9-h,1))},u=d=>Math.round(d*255).toString(16).padStart(2,"0");return"#"+u(o(0))+u(o(8))+u(o(4))}function Sa(e,n=1){const[a,i,o]=Sv(e);return Cv(a+15*n,Math.min(100,i+8),o-12*n)}function hn(e,n=1){const[a,i,o]=Sv(e);return Cv(a-10*n,i-3,o+10*n)}const Rn={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},Dr={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},xa={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},Xr="#100A06";function uA(e,n,a=14,i=12){O(e,n,a,i,"#4A3828"),O(e+1,n+1,a-2,i-2,"#5A4838"),O(e+2,n+2,a-4,i-4,"#4A7098"),O(e+2,n+2,a-4,Math.floor((i-4)/2),"#6A90B8",.35);const o=Math.floor(a/2);O(e+o,n+1,1,i-2,"#4A3828"),O(e+1,n+Math.floor(i/2),a-2,1,"#4A3828",.5),st(e+3,n+3,"#8AB8E8",.35),st(e+o+2,n+3,"#8AB8E8",.25),O(e-1,n+i,a+2,2,"#5A4838"),O(e-1,n+i,a+2,1,hn("#5A4838",.5),.35)}function dA(e,n,a){O(e,n,10,8,"#3A2818"),O(e+1,n+1,8,6,a),O(e+2,n+2,4,3,hn(a,1.2),.3),st(e+3,n+2,hn(a,2),.25)}function fA(e,n){O(e,n,7,7,"#3A2818"),O(e+1,n+1,5,5,"#F0EDE5"),st(e+3,n+1,"#AAA"),st(e+3,n+5,"#AAA"),st(e+1,n+3,"#AAA"),st(e+5,n+3,"#AAA"),st(e+3,n+3,"#222"),O(e+3,n+1,1,2,"#333"),st(e+4,n+3,"#D32F2F")}function hA(e,n){O(e,n,26,16,"#586878"),O(e+1,n+1,24,13,"#ECEFF1"),O(e+1,n+1,24,1,"#F5F5F5",.4),O(e+3,n+3,14,1,"#1565C0",.6),O(e+3,n+5,18,1,"#333",.2),O(e+3,n+7,12,1,"#D32F2F",.35),O(e+3,n+9,16,1,"#333",.15),O(e+1,n+14,24,2,"#708898"),O(e+3,n+14,3,1,"#D32F2F"),O(e+7,n+14,3,1,"#1565C0"),O(e+11,n+14,3,1,"#2E7D32")}function mA(e,n){O(e,n,22,16,"#6A5030"),O(e+1,n+1,20,14,"#C4A66A"),Cs(88);for(let a=0;a<14;a++)for(let i=0;i<20;i++)ja()>.5&&st(e+1+i,n+1+a,ja()>.5?"#B89858":"#D4B87A",.18);O(e+2,n+2,5,4,"#FFF176"),O(e+8,n+2,5,4,"#90CAF9"),O(e+14,n+3,5,4,"#CE93D8"),O(e+3,n+8,7,4,"#C8E6C9"),O(e+11,n+8,8,4,"#F8BBD0"),st(e+4,n+2,"#E53935"),st(e+10,n+2,"#1E88E5"),st(e+16,n+3,"#FF9800")}function pA(e,n){O(e,n,20,3,"#5A4030"),O(e,n,20,1,hn("#5A4030",.5),.35),O(e,n+2,20,1,Sa("#5A4030",.5),.3),O(e+2,n-4,3,4,"#E53935"),O(e+2,n-4,3,1,hn("#E53935",1),.3),O(e+6,n-3,2,3,"#1E88E5"),O(e+9,n-5,4,5,"#43A047"),O(e+14,n-3,3,3,"#FFD54F"),st(e+15,n-3,"#FFF176",.4)}function xA(e,n){O(e,n,16,12,"#1E1E28"),O(e+1,n+1,14,9,"#0C1420"),O(e+2,n+2,12,1,"#EF4444",.6),st(e+2,n+4,"#4CAF50"),O(e+4,n+4,7,1,"#8b949e",.4),st(e+2,n+6,"#FF9800"),O(e+4,n+6,5,1,"#8b949e",.3),st(e+2,n+8,"#42A5F5"),O(e+4,n+8,8,1,"#8b949e",.25),O(e+7,n+10,2,2,"#1E1E28"),O(e+5,n+11,6,1,"#586878")}function yA(e,n,a){O(e+2,n+20,22,2,Xr,.15),O(e,n,22,20,Dr.deep),O(e+1,n+1,20,18,Dr.base),O(e,n,22,1,Dr.hi,.35),O(e,n,1,20,Dr.hi,.2);for(const u of[6,12])O(e+1,n+u,20,2,Dr.sh),O(e+1,n+u,20,1,Dr.hi,.2);const i=["#E53935","#1E88E5","#43A047","#8E24AA","#FB8C00","#00897B","#5C6BC0"];let o=e+2;for(let u=0;u<5;u++){const d=2+u%2;O(o,n+1,d,5,i[u]),O(o,n+1,d,1,hn(i[u],1),.35),o+=d+1}o=e+2;for(let u=0;u<4;u++)O(o,n+7,4,5,i[u+3]),O(o,n+7,4,1,hn(i[u+3],1),.25),o+=5;O(e+2,n+14,4,4,"#FFD54F"),O(e+8,n+14,7,4,"#90CAF9"),a&&O(e,n-1,22,1,a,.7)}function gA(e,n){O(e+2,n+11,6,2,Xr,.1),O(e+2,n+8,6,4,"#8B5E3C"),O(e+1,n+7,8,2,Sa("#A06E48",.3)),O(e+2,n+7,6,1,hn("#A06E48",.5),.4),O(e+1,n+3,3,4,"#2E7D32"),O(e+5,n+2,3,4,"#2E7D32"),O(e+2,n+1,4,4,"#43A047"),O(e+3,n+0,3,3,"#66BB6A"),st(e+4,n,"#81C784"),st(e+3,n+1,"#A5D6A7",.4)}function bA(e,n){pi(e+4,n-4,"down"),pi(e+16,n-4,"down"),pi(e+28,n-4,"down"),O(e+3,n+24,34,3,Xr,.15),O(e,n+2,36,18,Rn.deep),O(e+1,n+3,34,16,Rn.base),O(e+1,n+3,34,1,Rn.hi,.35);for(let a=0;a<14;a+=3)O(e+1,n+4+a,34,1,Sa(Rn.base,.2),.08);O(e,n+20,36,4,Rn.deep),O(e+1,n+21,34,2,Rn.sh),O(e+6,n+7,10,6,"#1A1A24"),O(e+7,n+8,8,4,"#0C1420"),O(e+8,n+9,4,1,"#2A6898",.4),O(e+20,n+8,6,4,"#F0F0F0"),O(e+15,n+7,3,3,"#ECEFF1"),st(e+16,n+8,"#795548"),pi(e+4,n+24,"up"),pi(e+16,n+24,"up"),pi(e+28,n+24,"up")}function vA(e,n){O(e+2,n+16,36,3,Xr,.15),O(e,n,36,5,"#5D4037"),O(e+1,n+1,34,3,"#6D4C41"),O(e+1,n+1,34,1,hn("#6D4C41",.5),.3),O(e,n+5,36,8,"#5D4037"),O(e+2,n+6,15,6,"#6D4C41"),O(e+3,n+6,13,1,hn("#6D4C41",.5),.35),O(e+19,n+6,15,6,"#6D4C41"),O(e+20,n+6,13,1,hn("#6D4C41",.5),.35),O(e+17,n+6,2,6,"#5D4037"),O(e,n+13,36,3,Sa("#5D4037",1)),O(e-2,n+2,3,12,"#5D4037"),O(e+35,n+2,3,12,"#5D4037"),O(e+4,n+7,6,4,"#FF8A65"),O(e+5,n+7,4,1,hn("#FF8A65",1),.35)}function wA(e,n){O(e+2,n+10,22,2,Xr,.12),O(e,n,22,8,Dr.deep),O(e+1,n+1,20,6,Dr.base),O(e+1,n+1,20,1,Dr.hi,.3),O(e,n+8,22,2,Dr.sh),O(e+3,n+2,6,4,"#F0F0F0"),O(e+13,n+3,3,3,"#ECEFF1"),st(e+14,n+4,"#795548")}function kA(e,n){O(e+1,n+14,10,2,Xr,.12),O(e,n,10,14,"#546E7A"),O(e,n,10,1,hn("#546E7A",1),.35),O(e+1,n+1,8,3,"#78909C"),O(e+1,n+5,8,4,"#37474F"),st(e+2,n+6,"#EF5350"),st(e+4,n+6,"#66BB6A"),O(e+2,n+11,4,2,"#ECEFF1")}function jA(e,n){O(e+2,n+18,28,3,Xr,.12),O(e,n,28,18,"#37474F"),O(e+1,n+1,26,15,"#0D47A1"),O(e+2,n+2,24,13,"#1565C0"),O(e+2,n+2,24,4,"#1976D2",.4),O(e+2,n+12,24,3,"#F9A825",.35),O(e+4,n+8,2,5,"#2E7D32"),O(e+6,n+9,2,4,"#43A047"),O(e+20,n+7,2,6,"#2E7D32"),O(e+22,n+8,2,5,"#388E3C"),O(e+9,n+5,4,2,"#FF8A65"),st(e+12,n+5,"#FF5722"),O(e+16,n+8,3,2,"#FFD54F"),st(e+15,n+8,"#FFC107"),st(e+13,n+3,"#90CAF9",.5),st(e+14,n+4,"#BBDEFB",.35),st(e+8,n+3,"#BBDEFB",.3),O(e,n+16,28,2,"#455A64"),O(e+1,n+16,26,1,hn("#455A64",.5),.3)}function SA(e,n){O(e,n,24,10,"#1A1A2E"),O(e+2,n+1,20,8,"#E040FB",.15),O(e+3,n+2,4,6,"#E040FB",.7),O(e+4,n+3,2,4,"#1A1A2E"),O(e+8,n+2,1,6,"#00E5FF",.7),O(e+8,n+2,4,1,"#00E5FF",.7),O(e+8,n+4,4,1,"#00E5FF",.7),O(e+11,n+2,1,3,"#00E5FF",.7),O(e+13,n+2,1,6,"#E040FB",.7),O(e+13,n+2,4,1,"#E040FB",.7),O(e+13,n+4,3,1,"#E040FB",.7),O(e+13,n+7,4,1,"#E040FB",.7),O(e+18,n+2,1,6,"#00E5FF",.7),O(e+21,n+2,1,6,"#00E5FF",.7),O(e+19,n+3,1,2,"#00E5FF",.5),O(e+20,n+5,1,2,"#00E5FF",.5)}function CA(e,n){O(e+2,n+28,16,3,Xr,.15),O(e,n,16,28,"#1A237E"),O(e+1,n+1,14,3,"#283593"),O(e+2,n+4,12,10,"#0D1117"),O(e+3,n+5,10,8,"#1B5E20"),O(e+5,n+6,2,2,"#4CAF50"),O(e+9,n+8,2,2,"#FF5722"),O(e+7,n+10,3,1,"#FFD54F"),st(e+6,n+7,"#81C784"),O(e+1,n+14,14,6,"#1A237E"),O(e+2,n+15,4,4,"#212121"),st(e+4,n+16,"#F44336"),st(e+9,n+16,"#F44336"),st(e+11,n+16,"#2196F3"),st(e+10,n+18,"#FFEB3B"),O(e,n+20,16,8,"#0D47A1"),O(e+1,n+21,14,6,"#1565C0"),O(e,n+4,1,14,"#FF4081",.4),O(e+15,n+4,1,14,"#FF4081",.4)}function NA(e,n){O(e+2,n+24,20,3,Xr,.15),O(e,n,20,24,"#4E342E"),O(e+1,n+1,18,22,"#5D4037"),O(e+2,n+1,16,4,"#FF6F00"),O(e+3,n+2,14,2,"#FF8F00",.6),O(e+2,n+5,16,10,"#1A1A2E"),O(e+3,n+6,14,8,"#212121"),O(e+4,n+7,4,4,"#333"),O(e+5,n+8,2,2,"#E53935"),O(e+10,n+7,4,4,"#333"),O(e+11,n+8,2,2,"#1E88E5"),O(e+3,n+16,14,6,"#3E2723");for(let a=0;a<7;a++)O(e+4+a*2,n+17,1,4,"#5D4037",.5);O(e+1,n+5,18,1,"#FFD54F",.5),O(e+1,n+15,18,1,"#FFD54F",.5)}function EA(e,n){O(e+2,n+22,22,2,Xr,.12),O(e,n,22,22,Dr.deep),O(e+1,n+1,20,20,"#37474F"),O(e+2,n+2,18,18,"#546E7A",.3),O(e+1,n+10,20,1,Dr.base),O(e+1,n+10,20,1,Dr.hi,.2),O(e+4,n+3,4,5,"#FFD54F"),O(e+5,n+4,2,3,"#FFC107"),O(e+4,n+7,4,1,"#FFA000"),st(e+5,n+3,"#FFF176",.5),O(e+13,n+4,4,4,"#B0BEC5"),O(e+14,n+3,2,1,"#CFD8DC"),st(e+14,n+5,"#ECEFF1",.6),O(e+5,n+12,3,3,"#A1887F"),O(e+6,n+11,1,1,"#D7CCC8"),O(e+12,n+12,6,4,"#5D4037"),O(e+13,n+13,4,2,"#FFD54F",.6),O(e+2,n+2,2,18,"#fff",.08)}function AA(e,n){O(e+2,n+16,26,3,Xr,.18),O(e,n,26,10,Rn.deep),O(e+1,n+1,24,8,Rn.base),O(e+1,n+2,24,1,Rn.hi,.2),O(e+1,n+4,24,1,Sa(Rn.base,.2),.1),O(e+1,n+6,24,1,Rn.hi,.15),O(e+1,n+1,24,1,Rn.hi,.4),O(e+1,n+1,1,8,Rn.hi,.2),O(e,n+10,26,5,Rn.deep),O(e+1,n+11,24,3,Rn.sh),O(e+1,n+10,24,1,Sa(Rn.base,1.5),.4),O(e+1,n+14,24,1,Rn.base,.15),O(e+2,n+12,10,1,Rn.deep,.4),O(e+14,n+12,10,1,Rn.deep,.4),st(e+7,n+11,"#C8D0D8",.6),st(e+19,n+11,"#C8D0D8",.6),O(e+6,n-5,14,7,"#1E1E28"),O(e+7,n-4,12,5,"#0C1420"),O(e+8,n-3,5,1,"#2A6898",.6),O(e+8,n-2,8,1,"#1A3858",.4),O(e+8,n-1,3,1,"#2A6898",.35),st(e+7,n-4,"#4A98D8",.25),st(e+12,n+1,"#4CAF50",.4),O(e+12,n+2,2,3,"#586878"),O(e+10,n+4,6,1,"#8898A8"),O(e+6,n+4,12,4,"#222228"),O(e+6,n+4,12,1,"#333338",.4);for(let a=0;a<5;a++)st(e+7+a*2,n+5,"#444",.6),st(e+7+a*2,n+6,"#3A3A3E",.4);O(e+20,n+5,3,4,"#333338"),O(e+20,n+5,3,1,"#444448"),O(e+1,n+3,4,4,"#F0EDE8"),O(e+1,n+3,4,1,"#F8F6F2"),st(e+2,n+5,"#6D4C41")}function pi(e,n,a){O(e+1,n+9,10,2,Xr,.1),st(e+5,n+9,"#1E1E22"),st(e+1,n+10,"#1A1A1E"),st(e+9,n+10,"#1A1A1E"),st(e+3,n+11,"#1A1A1E"),st(e+7,n+11,"#1A1A1E"),O(e+1,n+2,8,6,xa.base),O(e+2,n+3,6,4,xa.hi,.35),O(e+2,n+3,6,1,hn(xa.hi,.5),.25),O(e+1,n+7,8,1,xa.deep),a==="up"?(O(e,n+7,10,3,xa.deep),O(e+1,n+8,8,1,xa.sh)):(O(e,n-1,10,3,xa.deep),O(e+1,n,8,1,xa.sh)),O(e,n+3,1,4,xa.sh),O(e+9,n+3,1,4,xa.sh)}const Nv={bookshelf:(e,n,a)=>yA(e,n,a.accent),plant:(e,n)=>gA(e,n),"meeting-table":(e,n)=>bA(e,n),sofa:(e,n)=>vA(e,n),"coffee-table":(e,n)=>wA(e,n),"coffee-machine":(e,n)=>kA(e,n),window:(e,n,a)=>uA(e,n,a.windowW??16,a.windowH??14),picture:(e,n,a)=>dA(e,n,a.pictureColor??"#1565C0"),clock:(e,n)=>fA(e,n),whiteboard:(e,n)=>hA(e,n),"bulletin-board":(e,n)=>mA(e,n),shelf:(e,n)=>pA(e,n),screen:(e,n)=>xA(e,n),aquarium:(e,n)=>jA(e,n),"neon-sign":(e,n)=>SA(e,n),arcade:(e,n)=>CA(e,n),jukebox:(e,n)=>NA(e,n),"trophy-case":(e,n)=>EA(e,n)};function bs(e,n){const a=e.zone==="wall"?n.wx:n.fx,i=e.zone==="wall"?n.wy:n.fy;return{x:e.anchorX==="right"?(e.zone==="wall"?n.wx+n.ww:n.fx+n.fw)+e.offsetX:a+e.offsetX,y:i+e.offsetY}}function DA(e){for(const n of e.wallDecorations){const a=e.rooms[n.room];if(!a)continue;const{x:i,y:o}=bs(n,a),u=Nv[n.type];u&&u(i,o,n)}}function TA(e,n,a){for(const i of e.furniture){const o=e.rooms[i.room];if(!o||i.condition==="no-desks"&&a.has(i.room))continue;const{x:u,y:d}=bs(i,o),h=Nv[i.type];h&&n.push({y:d,draw:()=>h(u,d,i)})}}function xi(e){const n=[],a=[...e.wallDecorations,...e.furniture];for(const i of a){if(!i.facility)continue;const o=e.rooms[i.room];if(!o)continue;const{x:u,y:d}=bs(i,o);n.push({id:i.facility.id,label:i.facility.label,icon:i.facility.icon,color:i.facility.color,dx:u,dy:d,pw:i.facility.hitW,ph:i.facility.hitH})}return n}const FA={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 xm(e){return FA[e]??{w:16,h:16}}function Bh(e,n,a,i){for(let o=e.furniture.length-1;o>=0;o--){const u=e.furniture[o],d=e.rooms[u.room];if(!d||u.condition==="no-desks"&&i.has(u.room))continue;const{x:h,y:m}=bs(u,d),f=xm(u.type);if(n>=h&&n<=h+f.w&&a>=m&&a<=m+f.h)return u.id}for(let o=e.wallDecorations.length-1;o>=0;o--){const u=e.wallDecorations[o],d=e.rooms[u.room];if(!d)continue;const{x:h,y:m}=bs(u,d),f=xm(u.type);if(n>=h&&n<=h+f.w&&a>=m&&a<=m+f.h)return u.id}return null}function og(e,n,a,i,o){const d=[...n.wallDecorations,...n.furniture].find(y=>y.id===a);if(!d||d.condition==="no-desks"&&o.has(d.room))return;const h=n.rooms[d.room];if(!h)return;const{x:m,y:f}=bs(d,h),x=xm(d.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 cg(e,n,a,i){e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(n-1,a-1,28,42),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(n-.5,a-.5,27,41),e.restore()}function ug(e,n,a){for(const[i,o]of Object.entries(e))if(n>=o.dx&&n<=o.dx+26&&a>=o.dy&&a<=o.dy+40)return i;return null}const dg=[{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}],vu=16,MA=4,mi=4,Tu=2,Ut=4,_l=4;let Ge=jv(7);const Yu={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},fg={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 RA(e,n){const a=fg[e]||fg.default;return a[n]||a.en||a.default||[]}let ga=xi(Ge);function Ev(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function Av(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let mn={};function zA(e){const n={};for(let a=0;a<e.length&&a<Ge.desks.length;a++)n[e[a]]=Ge.desks[a];return n}let Ye,Gn=null,yi=null,Pa=!1,aa=null,Er=null,Dv=0,Zn=null,Mn=null,Rl=null,ya=null,Oh=900;function _A(e,n){const{wx:a,wy:i,ww:o,wh:u,wallColor:d,baseboardColor:h}=e,m=Sa(d,.5),f=hn(d,.5),x=[];if(n){const y=n.x-a,v=n.w;y>0&&x.push({sx:a,sw:y}),y+v<o&&x.push({sx:n.x+v,sw:o-y-v})}else x.push({sx:a,sw:o});for(const y of x){O(y.sx,i,y.sw,u,d);for(let v=0;v<u;v+=4)O(y.sx,i+v,y.sw,1,f,.08),O(y.sx,i+v+2,y.sw,1,m,.05);Cs(Math.round(y.sx*7+i*13));for(let v=0;v<y.sw;v+=3)ja()>.4&&O(y.sx+v,i,1,u,f,.04);O(y.sx,i,y.sw,2,f,.3),O(y.sx,i,y.sw,1,hn(d,1),.2),O(y.sx,i+u-2,y.sw,2,m,.3),O(y.sx,i+u,y.sw,Tu,h),O(y.sx,i+u,y.sw,1,hn(h,.5),.4)}n&&(O(n.x-1,i,1,u+Tu,"#4A3828"),O(n.x+n.w,i,1,u+Tu,"#4A3828"),O(n.x,i,n.w,1,"#0A0808",.12)),O(e.fx,e.fy,e.fw,3,"#0A0808",.12),O(e.fx,e.fy+3,e.fw,2,"#0A0808",.06)}function BA(e){const n="#504038",a=Sa(n,.5),i=hn(n,.5),o=e.wx-_l,u=e.wy,d=e.wh+Tu+e.fh;O(o,u,_l,d,n),O(o,u,1,d,i,.3),O(o+_l-1,u,1,d,a,.4);for(let m=0;m<d;m+=6)O(o+1,u+m,_l-2,1,i,.06);const h=e.wx+e.ww;O(h,u,_l,d,n),O(h,u,1,d,i,.2),O(h+_l-1,u,1,d,a,.3)}function $h(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#B08040",d="#C89848",h="#8A6030",m="#6A4820";O(n,a,i,o,u),Cs(42);for(let f=0;f<o;f+=5){const x=Math.floor(f/5)%2*10;for(let y=-10;y<i+10;y+=20){const v=n+y+x,b=Math.max(n,v),j=Math.min(v+19,n+i)-b;if(j<=0)continue;const k=ja()>.5?d:u;O(b,a+f,j,4,k,.25),O(b,a+f,j,1,d,.3),O(b,a+f+4,j,1,m,.35),v>=n&&v<n+i&&O(v,a+f,1,4,m,.2),O(b,a+f+2,j,1,h,.1)}}O(n,a,i,2,"#0A0808",.08),O(n,a,2,o,"#0A0808",.06)}function hg(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#1C2A38",d="#101820";Cs(99),O(n,a,i,o,u);for(let h=0;h<o;h+=vu)for(let m=0;m<i;m+=vu){const f=Math.min(vu,i-m),x=Math.min(vu,o-h);ja()>.5&&O(n+m,a+h,f,x,hn(u,.2),.15),O(n+m+2,a+h+2,f-4,x-4,hn(u,.3),.08),O(n+m,a+h,f,1,d,.5),O(n+m,a+h,1,x,d,.5),O(n+m+1,a+h+1,1,x-1,hn(u,.4),.1),ja()>.85&&st(n+m+4+Math.floor(ja()*8),a+h+4+Math.floor(ja()*8),"#3A6A9A",.08)}}function OA(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#387848",d="#4A9058",h="#285E38";O(n,a,i,o,u),Cs(77);for(let f=0;f<o;f+=2)for(let x=0;x<i;x+=2)ja()>.5&&st(n+x,a+f,d,.1),ja()>.8&&st(n+x+1,a+f+1,h,.12);const m=5;O(n+m,a+m,i-m*2,1,d,.45),O(n+m,a+o-m-1,i-m*2,1,h,.45),O(n+m,a+m,1,o-m*2,d,.35),O(n+i-m-1,a+m,1,o-m*2,h,.35)}function $A(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#D8C490",d="#B09060",h="#907848";Cs(55);for(let m=0;m<o;m+=8)for(let f=0;f<i;f+=8){const x=Math.min(8,i-f),y=Math.min(8,o-m),v=(f/8+m/8)%2===0?d:u;O(n+f,a+m,x,y,v),O(n+f+1,a+m+1,x-2,1,hn(v,.4),.2),O(n+f+1,a+m+1,1,y-2,hn(v,.4),.15),O(n+f+x-2,a+m+2,1,y-3,Sa(v,.4),.15),O(n+f+2,a+m+y-2,x-3,1,Sa(v,.4),.15),O(n+f,a+m,x,1,h,.3),O(n+f,a+m,1,y,h,.3)}}function LA(){const{canvasW:e,canvasH:n,rooms:a,doors:i}=Ge,o="#2A1E14",u="#3A2E24";if(O(0,0,e,mi,o),O(0,n-mi,e,mi,o),O(0,0,mi,n,o),O(e-mi,0,mi,n,o),O(0,0,e,1,u,.3),O(0,0,1,n,u,.2),!a.exec||!a.work||!a.meet||!a.comm)return;const d=a.exec,h=a.meet,m=e/2,f=m-Ut/2,x=d.fy+d.fh,y=i.exec_work,v=i.meet_comm,b=i.exec_meet,j=i.work_comm,k=24,N=28,C=((y==null?void 0:y.doorY)??d.fy+20)-k/2,E=((b==null?void 0:b.doorX)??mi+_l+54)-N/2,R=((j==null?void 0:j.doorX)??m+Ut/2+_l+54)-N/2,M=((v==null?void 0:v.doorY)??h.fy+20)-k/2;O(0,x,E,Ut,o),O(E+N,x,f-E-N,Ut,o),O(f+Ut,x,R-f-Ut,Ut,o),O(R+N,x,e-R-N,Ut,o),O(0,x,E,1,u,.3),O(E+N,x,f-E-N,1,u,.3),O(f+Ut,x,R-f-Ut,1,u,.3),O(R+N,x,e-R-N,1,u,.3),O(f,0,Ut,C,o),O(f,C+k,Ut,x-C-k,o),O(f,x+Ut,Ut,M-x-Ut,o),O(f,M+k,Ut,n-M-k,o),O(f,0,1,C,u,.2),O(f,C+k,1,x-C-k,u,.2),O(f,x+Ut,1,M-x-Ut,u,.2),O(f,M+k,1,n-M-k,u,.2),O(f,C,Ut,k,"#C4A070"),O(f+Ut/2,C,Ut/2,k,"#3A4858"),O(f,M,Ut,k,"#7AA880"),O(f+Ut/2,M,Ut/2,k,"#C8B890");const I="#4A3828";O(f,C-1,Ut,1,I),O(f,C+k,Ut,1,I),O(E-1,x,1,Ut,I),O(E+N,x,1,Ut,I),O(R-1,x,1,Ut,I),O(R+N,x,1,Ut,I),O(f,M-1,Ut,1,I),O(f,M+k,Ut,1,I)}const mg=new Map;function IA(e,n="right"){const a=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${n}`;let i=mg.get(a);if(!i){const o=rm("mini-seated:default"),u=Hb(o,e);let d=u?u.layers.flatMap(h=>h.pixels):[];n==="left"&&d.length>0&&(d=tm(d,12)),i=d,mg.set(a,i)}return i}function HA(e,n,a,i="right"){Bl(Ye,IA(a,i),e,n,a)}function UA(e,n,a,i,o,u="right"){pi(e+8,n+20,"up"),o||HA(e+8,n+0+i,a,u),AA(e,n+14)}function qA(e,n,a,i,o){const u=i in rg?i:"down",d=o%4,h=rg[u][d];Bl(Ye,h,e,n,a);const m=d===1||d===3?-1:0;if(a.accessory&&a.accessory!=="none"){const f=aC(a.accessory,u);f&&f.pixels.length>0&&Bl(Ye,f.pixels,e,n+m,a)}Ye.globalAlpha=1}let Fu=[],vi=!1,vs=0;function YA(){const e=Object.keys(Ge.rooms),n=e[Math.floor(Math.random()*e.length)],a=Ge.rooms[n];return{x:a.fx+a.fw/2,y:a.fy+a.fh/2,dir:"down",walkFrame:0,walkTimer:0,path:[],room:n,state:"walking",stateTimer:0,tongueTimer:0,idleTime:0}}function XA(e){if(e.stateTimer--,vi){vs++,e.dir="down",e.walkFrame=0,e.tongueTimer++,e.idleTime=0;return}else vs=0;if(e.state==="idle"){if(e.tongueTimer++,e.idleTime++,e.stateTimer<=0){e.state="walking",e.tongueTimer=0;const n=Object.keys(Ge.rooms);if(Math.random()<.35&&n.length>1){const a=n.filter(d=>d!==e.room),i=a[Math.floor(Math.random()*a.length)],o=Pm(e,i),u=Ge.waypoints[i];if(u&&u.length>0){const d=u[Math.floor(Math.random()*u.length)],h=o[o.length-1]??{x:e.x,y:e.y},m=wi(h.x,h.y,d.x,d.y,i);e.path=[...o,...m]}else e.path=o}else{const a=Ge.waypoints[e.room];if(a&&a.length>0){const i=a[Math.floor(Math.random()*a.length)];e.path=wi(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 n=e.path[0],a=n.x-e.x,i=n.y-e.y,o=Math.sqrt(a*a+i*i);if(o<1.5){e.x=n.x,e.y=n.y,e.path.shift();for(const[u,d]of Object.entries(Ge.rooms))if(e.x>=d.fx&&e.x<=d.fx+d.fw&&e.y>=d.fy&&e.y<=d.fy+d.fh){e.room=u;break}}else e.x+=a/o*.15,e.y+=i/o*.15,Math.abs(a)>Math.abs(i)?e.dir=a>0?"right":"left":e.dir=i>0?"down":"up",e.walkTimer++,e.walkFrame=Math.floor(e.walkTimer/15)%2}}function WA(e){const n=Math.round(e.x),a=Math.round(e.y);if(vi&&vs>90){const d=Math.floor(vs/12)%2===0?P6:Z6;Bl(Ye,tA,n,a),Bl(Ye,d,n,a);return}const i=e.state==="walking"?e.walkFrame:0,o=K6[e.dir][i],u=e.dir==="left"||e.dir==="right";Bl(Ye,u?eA:J6,n,a),Bl(Ye,o,n,a),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&Bl(Ye,Q6,n,a)}function GA(e){const n={};let a=0;for(const i of e){const o=mn[i];o&&(n[i]={state:"sitting",homeX:o.dx+8,homeY:o.dy+34,homeRoom:o.room,x:o.dx+8,y:o.dy+34,path:[],room:o.room,dir:"down",walkFrame:0,walkTimer:0,bobY:0,bobOff:a*17,stateTimer:1200+Math.floor(Math.random()*1800),sittingTime:0,lookDir:"right",isStretching:!1,stretchTimer:0},a++)}return n}function wi(e,n,a,i,o){const u=Ge.corridorY[o]??n,d=[];return n<u-4&&d.push({x:e,y:u}),Math.abs(e-a)>4&&d.push({x:a,y:u}),d.push({x:a,y:i}),d}function Lh(e,n,a,i){const o=Ge.adjacency[a];if(!o)return[];const u=o.find(x=>x.room===i);if(!u)return[];const d=Ge.doors[u.door];if(!d)return[];const h=[],m=Ge.corridorY[a]??n,f=Ge.corridorY[i]??n;if(Math.abs(n-m)>4&&h.push({x:e,y:m}),d.type==="v"){const x=u.side==="A"?d.xA:d.xB,y=u.side==="A"?d.xB:d.xA;h.push({x,y:m}),h.push({x,y:d.doorY}),h.push({x:y,y:d.doorY}),h.push({x:y,y:f})}else{const x=u.side==="A"?d.yA:d.yB,y=u.side==="A"?d.yB:d.yA;h.push({x:d.doorX,y:m}),h.push({x:d.doorX,y:x}),h.push({x:d.doorX,y}),h.push({x:d.doorX,y:f})}return h}function Pm(e,n){const a=Ge.adjacency[e.room];if(!a)return[];if(!a.find(o=>o.room===n)){for(const o of a){const u=Ge.adjacency[o.room];if(u!=null&&u.find(d=>d.room===n)){const d=Lh(e.x,e.y,e.room,o.room),h=d[d.length-1],m=Lh((h==null?void 0:h.x)??e.x,(h==null?void 0:h.y)??e.y,o.room,n);return[...d,...m]}}return[]}return Lh(e.x,e.y,e.room,n)}function VA(e){if(e.room!==e.homeRoom){const n=Pm({...e},e.homeRoom),a=n[n.length-1],i=wi((a==null?void 0:a.x)??e.x,(a==null?void 0:a.y)??e.y,e.homeX,e.homeY,e.homeRoom);return[...n,...i]}return wi(e.x,e.y,e.homeX,e.homeY,e.room)}function KA(e,n){if(Oh--,Oh<=0){const a=Object.entries(e).filter(([,i])=>i.state==="sitting"&&!i.isStretching);if(a.length>0){const[,i]=a[Math.floor(Math.random()*a.length)];i.isStretching=!0,i.stretchTimer=120}Oh=900}for(const[a,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++,Gn===a){i.sittingTime=0,i.bobY=-3;const u=mn[a];if(u){const d=u.dx+13;i.lookDir=Dv<d?"left":"right"}}else i.bobY=(n+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 u=Object.keys(Ge.rooms);if(Math.random()<.15&&u.length>1){const d=u.filter(x=>x!==i.room),h=d[Math.floor(Math.random()*d.length)],m=Pm(i,h),f=Ge.waypoints[h];if(f&&f.length>0){const x=f[Math.floor(Math.random()*f.length)],y=m[m.length-1]??{x:i.x,y:i.y},v=wi(y.x,y.y,x.x,x.y,h);i.path=[...m,...v]}else i.path=m;i.walkTimer=0}else{const d=Ge.waypoints[i.room];if(d&&d.length>0){const h=d[Math.floor(Math.random()*d.length)];i.path=wi(i.x,i.y,h.x,h.y,i.room)}i.walkTimer=0}}}else if(i.state==="walking"||i.state==="returning"){if(i.sittingTime=0,Gn===a){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 u=i.path[0],d=u.x-i.x,h=u.y-i.y,m=Math.sqrt(d*d+h*h);if(m<1.5){i.x=u.x,i.y=u.y,i.path.shift();for(const[f,x]of Object.entries(Ge.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+=d/m*.2,i.y+=h/m*.2,Math.abs(d)>Math.abs(h)?i.dir=d>0?"right":"left":i.dir=h>0?"down":"up",i.walkTimer++,i.walkFrame=Math.floor(i.walkTimer/12)%4}else if(i.state==="idle"){if(Gn===a){i.dir="down";continue}if(i.stateTimer<=0)if(Math.random()<.15){i.state="walking";const o=Ge.waypoints[i.room];if(o&&o.length>0){const u=o[Math.floor(Math.random()*o.length)];i.path=wi(i.x,i.y,u.x,u.y,i.room)}i.walkTimer=0}else i.state="returning",i.path=VA(i),i.walkTimer=0}}function QA(e,n,a,i){const{canvasW:o,canvasH:u,rooms:d}=Ge;Ye.clearRect(0,0,o,u),O(0,0,o,u,"#2A1E14");const h={wood:$h,dark:hg,carpet:OA,tile:$A};for(const b of Object.values(d))(h[b.floorType]??$h)(b);const m=Object.keys(d);if(m.length>=4){const b=d.exec,j=d.meet,{doors:k}=Ge;if(b&&j&&k.exec_meet&&k.work_comm){const C=(k.exec_meet.doorX??0)-14,E=(k.work_comm.doorX??0)-28/2,R=b.fy+b.fh,M=j.fy;$h({fx:C,fy:R,fw:28,fh:M-R}),hg({fx:E,fy:R,fw:28,fh:M-R})}}const f={};if(m.length>=4){const{doors:b}=Ge,j=28,k=b.exec_meet,N=b.work_comm;k!=null&&k.doorX&&(f.meet={x:k.doorX-j/2,w:j}),N!=null&&N.doorX&&(f.comm={x:N.doorX-j/2,w:j})}for(const b of Object.values(d))_A(b,f[b.id]),BA(b);LA(),DA(Ge);const x=[],y=new Set(Object.values(mn).map(b=>b.room));TA(Ge,x,y);for(const[b,j]of Object.entries(mn)){const k=e[b];if(!k)continue;const N=k.state==="sitting",C=n(b),E=a[b]==="working",R=k.isStretching&&k.stretchTimer>0?Math.sin(k.stretchTimer*.15)*1:0;x.push({y:j.dy+14,draw:()=>{const M=N?k.bobY+R:0;if(UA(j.dx,j.dy,C,M,!N,k.lookDir),N&&E){const I=Yu[b]??"#388bfd";O(j.dx+7,j.dy+14-4,12,5,I,.15),st(j.dx+12,j.dy+14+1,"#4CAF50",.8)}}})}for(const[b,j]of Object.entries(e))if(j.state!=="sitting"){const k=n(b);x.push({y:j.y+14,draw:()=>qA(Math.round(j.x),Math.round(j.y),k,j.dir,j.walkFrame)})}i&&x.push({y:i.y+10,draw:()=>WA(i)}),x.sort((b,j)=>b.y-j.y);for(const b of x)b.draw();for(const b of ga){const j=yi===b.id,k=Av(b);if(Ye.save(),Ye.globalAlpha=j?.9:.5,Ye.fillStyle=b.color,Ye.fillRect(k.cx-1,k.botY-2,3,3),j){const N=Ev(b);Ye.globalAlpha=.3,Ye.strokeStyle=b.color,Ye.lineWidth=1,Ye.strokeRect(N.x-1,N.y-1,N.w+2,N.h+2)}Ye.restore()}if(Pa){const b=new Set(Object.values(mn).map(j=>j.room));if(aa&&aa!==Er)if(aa.startsWith("desk:")){const j=aa.slice(5),k=mn[j];k&&cg(Ye,k.dx,k.dy,"#FBBF24")}else og(Ye,Ge,aa,"#FBBF24",b);if(Er)if(Er.startsWith("desk:")){const j=Er.slice(5),k=mn[j];k&&cg(Ye,k.dx,k.dy,"#3B82F6")}else og(Ye,Ge,Er,"#3B82F6",b)}if(Gn){const b=mn[Gn],j=e[Gn];if(b&&j){Ye.save(),Ye.globalAlpha=.25,Ye.fillStyle=Yu[Gn]??"#fff",j.state==="sitting"?Ye.fillRect(b.dx-1,b.dy+6,28,30):Ye.fillRect(Math.round(j.x)-1,Math.round(j.y)-1,14,24),Ye.globalAlpha=.95,Ye.fillStyle="#FBBF24",Ye.font="bold 8px monospace",Ye.textAlign="center";const k=j.state==="sitting"?b.dx+13:Math.round(j.x)+6,N=j.state==="sitting"?b.dy-1:Math.round(j.y)-5;Ye.fillText("!",k,N),Ye.restore()}}const v=3600;for(const[,b]of Object.entries(e))if(b.state==="sitting"&&b.sittingTime>v&&!b.isStretching){const j=Object.values(mn).find(M=>M.dx+8===b.homeX&&M.dy+34===b.homeY);if(!j)continue;const k=j.dx+13,N=j.dy,C=Math.floor(b.sittingTime/40)%3;Ye.save(),Ye.font="5px monospace",Ye.textAlign="center";const E=[.7,.5,.3],R=[{x:3,y:-2-C},{x:6,y:-5-(C+1)%3},{x:4,y:-8-(C+2)%3}];for(let M=0;M<3;M++)Ye.globalAlpha=E[M],Ye.fillStyle="#93C5FD",Ye.font=`${4+M}px monospace`,Ye.fillText("z",k+R[M].x,N+R[M].y);Ye.restore()}Fu=Fu.filter(b=>b.life>0);for(const b of Fu)b.x+=b.vx,b.y+=b.vy,b.life--,Ye.save(),Ye.globalAlpha=Math.min(1,b.life/(b.maxLife*.3)),Ye.fillStyle=b.color??"#FF6B8A",Ye.font="8px serif",Ye.fillText(b.char,Math.round(b.x),Math.round(b.y)),Ye.restore();if(vi&&i&&vs<=90){const b=Math.round(i.x),j=Math.round(i.y);Ye.save(),Ye.globalAlpha=.9,Ye.fillStyle="#FBBF24",Ye.font="bold 5px monospace",Ye.textAlign="center",Ye.fillText("!",b+4,j-2),Ye.restore()}if(i&&!vi&&i.state==="idle"&&i.idleTime>600){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(i.idleTime/40)%3;Ye.save();const N=[{x:3,y:-2-k},{x:5,y:-5-(k+1)%3},{x:4,y:-8-(k+2)%3}];for(let C=0;C<3;C++)Ye.globalAlpha=[.7,.5,.3][C],Ye.fillStyle="#93C5FD",Ye.font=`${3+C}px monospace`,Ye.textAlign="center",Ye.fillText("z",b+N[C].x,j+N[C].y);Ye.restore()}if(vi&&i&&vs<=90){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(Date.now()/150)%2===0?-1:1;i.dir==="down"&&(Ye.fillStyle="#FAFAF7",Ye.fillRect(b+4+k,j-1,2,2))}}function pg(e,n){for(let a=0;a<4;a++)Fu.push({x:e+(Math.random()-.5)*8,y:n,vx:(Math.random()-.5)*.3,vy:-.3-Math.random()*.2,life:60+Math.floor(Math.random()*30),maxLife:80,char:a%2===0?"♥":"♡",color:"#FF6B8A"})}function PA({roles:e,projects:n,roleStatuses:a,activeExecs:i,onRoleClick:o,onProjectClick:u,onBulletinClick:d,onDecisionsClick:h,onKnowledgeClick:m,onSettingsClick:f,onThemeClick:x,onStatsClick:y,getRoleSpeech:v,getAppearance:b,onHireClick:j,onMascotClick:k,roleLevels:N,coinBalance:C=0,onCoinsSpent:E,onFurniturePlaced:R,purchasedPreset:M,language:I="en"}){const B=w.useRef(null),L=w.useRef(null),H=w.useRef(null),Q=w.useRef({}),A=w.useRef(null),$=w.useRef(0),U=w.useRef(MA),[ee,oe]=w.useState(!1),[ne,Y]=w.useState(null),[ue,J]=w.useState(null),K=w.useRef({}),D=w.useRef({}),F=w.useRef([]),q=w.useRef([]);w.useEffect(()=>{Pa=ee},[ee]),w.useEffect(()=>{Rl=ne,ya=ue},[ne,ue]);const[T,de]=w.useState(!1);w.useEffect(()=>{ke.getPreferences().then(he=>{const ve=he.furnitureOverrides;ve&&Object.keys(ve).length>0&&(K.current=ve);const ce=he.deskOverrides;ce&&Object.keys(ce).length>0&&(D.current=ce);const W=he.removedFurniture;W&&W.length>0&&(F.current=W);const le=he.addedFurniture;le&&le.length>0&&(q.current=le),de(!0)}).catch(()=>{de(!0)})},[]);const Ne=w.useRef({roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b});Ne.current={roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b};const ye=w.useRef({}),_e=w.useMemo(()=>e.map(he=>he.id),[e]),Pe=w.useRef(Ge);w.useEffect(()=>{if(!T)return;const he=_e.length,ve=kv(he,Pe.current.preset,M),ce=Pe.current.preset!==ve;let W=jv(he,ve);F.current.length>0&&(W=sg(W,F.current)),q.current.length>0&&(W=oA(W,q.current)),Object.keys(K.current).length>0&&(W=iA(W,K.current)),Ge=W,Pe.current=W,mn=zA(_e),Object.keys(D.current).length>0&&sA(mn,D.current),ga=xi(W),Q.current=GA(_e),A.current=YA();const le=B.current;le&&(le.width=W.canvasW,le.height=W.canvasH,ce&&(le.style.opacity="0",le.style.transition="opacity 0.3s",setTimeout(()=>{le.style.opacity="1"},50))),lt()},[_e,M,T]);const Ve=w.useCallback(he=>{var ve,ce;return((ce=(ve=Ne.current).getAppearance)==null?void 0:ce.call(ve,he))??Wm(he)},[]),lt=w.useCallback(()=>{const he=L.current,ve=B.current;if(!he||!ve)return;const ce=he.parentElement;if(!ce)return;const W=ce.clientWidth,le=ce.clientHeight;if(W===0||le===0)return;const{canvasW:we,canvasH:xe}=Ge;let je=Math.min(W/we,le/xe);je=Math.round(je*2)/2,je=Math.max(2,Math.min(je,5)),U.current=je,ve.style.width=we*je+"px",ve.style.height=xe*je+"px",he.style.width=we*je+"px",he.style.height=xe*je+"px"},[]);w.useEffect(()=>{var xe;const he=B.current;if(!he)return;const ve=he.getContext("2d");if(!ve)return;Ye=ve,cA(ve),lt();const ce=new ResizeObserver(()=>lt()),W=(xe=L.current)==null?void 0:xe.parentElement;W&&ce.observe(W);let le;const we=()=>{$.current++,KA(Q.current,$.current),A.current&&XA(A.current),QA(Q.current,Ve,Ne.current.roleStatuses,A.current),dt(),le=requestAnimationFrame(we)};return le=requestAnimationFrame(we),()=>{cancelAnimationFrame(le),ce.disconnect()}},[Ve,lt]),w.useEffect(()=>{var we;const he=H.current;if(!he)return;he.innerHTML="";const ve={};for(const xe of e)ve[xe.id]=xe.name;for(const xe of _e){const je=Yu[xe]??"#8b949e",Re=ve[xe],$e=Re&&Re.toLowerCase()!==xe.toLowerCase()?`${xe.toUpperCase()} · ${Re}`:xe.toUpperCase(),Oe=document.createElement("div");Oe.className="td-nametag",Oe.dataset.role=xe;const Le=document.createElement("span");Le.className="td-dot",Le.style.background=je,Oe.appendChild(Le),Oe.appendChild(document.createTextNode($e));const tt=((we=N==null?void 0:N[xe])==null?void 0:we.level)??1;if(tt>1){const jt=document.createElement("span");jt.className="td-lvl",jt.textContent=`Lv.${tt}`,Oe.appendChild(jt)}he.appendChild(Oe);const Ke=document.createElement("div");Ke.className="td-bubble",Ke.dataset.role=xe,Ke.dataset.type="bubble",he.appendChild(Ke)}const ce={meeting:()=>{const xe=n[0];xe?u(xe.id):d()},bulletin:d,decisions:h,knowledge:m,settings:f,theme:x,stats:y};for(const xe of ga){const je=document.createElement("div");je.className="td-facility-label",je.dataset.facility=xe.id,xe.id==="meeting"&&(je.dataset.questTarget="meeting-room"),xe.id==="knowledge"&&(je.dataset.questTarget="knowledge-hub"),xe.id==="bulletin"&&(je.dataset.questTarget="bulletin-board"),xe.id==="stats"&&(je.dataset.questTarget="stats-btn"),xe.id==="settings"&&(je.dataset.questTarget="settings-btn"),xe.id==="theme"&&(je.dataset.questTarget="theme-btn"),je.textContent=`${xe.icon} ${xe.label}`,je.style.borderColor=`${xe.color}44`;const Re=ce[xe.id];Re&&je.addEventListener("click",Re),je.addEventListener("mouseenter",()=>{yi=xe.id}),je.addEventListener("mouseleave",()=>{yi=null}),he.appendChild(je)}const W=document.createElement("div");W.className="td-nametag td-nametag-mascot",W.dataset.role="mascot";const le=document.createElement("span");le.className="td-dot",le.style.background="#ffd700",W.appendChild(le),W.appendChild(document.createTextNode("Pupu")),W.addEventListener("click",()=>k==null?void 0:k()),he.appendChild(W)},[_e,e,n,u,d,h,m,f,x,y,k,N]);const dt=w.useCallback(()=>{var Re;const he=H.current;if(!he)return;const ve=U.current,ce=Q.current,{getRoleSpeech:W,roleStatuses:le,activeExecs:we}=Ne.current;for(const $e of Object.keys(ce)){const Oe=ce[$e],Le=mn[$e];if(!Le)continue;let tt,Ke,jt;Oe.state==="sitting"?(tt=Le.dx+13,jt=Le.dy+2,Ke=Le.dy+37):(tt=Math.round(Oe.x)+6,jt=Math.round(Oe.y)-2,Ke=Math.round(Oe.y)+18);const ze=tt/Ge.canvasW*100,He=he.querySelector(`.td-nametag[data-role="${$e}"]`);if(He){He.style.left=ze+"%",He.style.top=Ke*ve+2+"px";const Dt=He.querySelector(".td-dot");if(Dt){const Rt=le[$e]==="working";Dt.style.background=Rt?"#FBBF24":Yu[$e]??"#8b949e",Rt?Dt.style.animation="td-pulse 1s ease-in-out infinite":Dt.style.animation=""}}const Lt=he.querySelector(`.td-bubble[data-role="${$e}"]`);if(Lt){const Dt=Date.now(),Rt=le[$e]==="working",sn=(Re=we.find(Pt=>Pt.roleId===$e))==null?void 0:Re.task,pn=W($e);let P="";const Be=ye.current[$e];if(Be){if(Be.speechDismissTime&&Dt>=Be.speechDismissTime&&(Be.currentSpeech=null,Be.speechDismissTime=null),Be.hoverStartTime&&!Be.currentSpeech){const Pt=Dt-Be.hoverStartTime,ge=!Be.lastSpeechTime||Dt-Be.lastSpeechTime>=5e3;if(Pt>=2e3&&ge){const Z=RA($e,I),Me=Z[Math.floor(Math.random()*Z.length)];Be.currentSpeech=Me,Be.lastSpeechTime=Dt,Be.speechDismissTime=Dt+3e3}}P=Be.currentSpeech||""}const nt=Rt&&sn?sn.slice(0,60):P?P.slice(0,60):pn?pn.slice(0,60):"";nt&&Oe.state==="sitting"?(Lt.style.display="",Lt.style.left=ze+"%",Lt.style.top=(jt-10)*ve+"px",Lt.textContent=nt):Lt.style.display="none"}}const xe=he.querySelector(".td-nametag-mascot"),je=A.current;if(xe&&je){const $e=je.dir==="left"||je.dir==="right",Oe=Math.round(je.x)+($e?6:4),Le=Math.round(je.y)+($e?7:10);xe.style.left=Oe/Ge.canvasW*100+"%",xe.style.top=Le*ve+2+"px"}for(const $e of ga){const Oe=he.querySelector(`.td-facility-label[data-facility="${$e.id}"]`);if(Oe){const Le=Av($e);Oe.style.left=Le.cx/Ge.canvasW*100+"%",Oe.style.top=Le.botY*ve-4+"px",Oe.classList.toggle("td-facility-label--hover",yi===$e.id)}}},[]),Ce=w.useCallback(he=>{const ve=B.current;if(!ve)return null;const ce=ve.getBoundingClientRect(),W=U.current,le=(he.clientX-ce.left)/W,we=(he.clientY-ce.top)/W,xe=Q.current;for(const[Re,$e]of Object.entries(mn)){if(!xe[Re])continue;const Oe=xe[Re];if(Oe.state==="sitting"){if(le>=$e.dx&&le<=$e.dx+26&&we>=$e.dy&&we<=$e.dy+40)return{type:"role",id:Re}}else if(le>=Oe.x-2&&le<=Oe.x+14&&we>=Oe.y-2&&we<=Oe.y+20)return{type:"role",id:Re}}const je=A.current;if(je){const Re=je.dir==="left"||je.dir==="right",$e=Re?13:9,Oe=Re?7:10;if(le>=je.x&&le<=je.x+$e&&we>=je.y&&we<=je.y+Oe)return{type:"mascot",id:"mascot"}}for(const Re of ga){const $e=Ev(Re);if(le>=$e.x&&le<=$e.x+$e.w&&we>=$e.y&&we<=$e.y+$e.h)return{type:"facility",id:Re.id}}return null},[]),We=w.useCallback(he=>{const ve=B.current;if(!ve)return{mx:0,my:0};const ce=ve.getBoundingClientRect(),W=U.current;return{mx:(he.clientX-ce.left)/W,my:(he.clientY-ce.top)/W}},[]),Te=w.useCallback(he=>{ke.updatePreferences(he).catch(()=>{})},[]),xt=w.useCallback(he=>{const ve=[...F.current,he];F.current=ve,Ge=sg(Ge,[he]),ga=xi(Ge),Er=null,aa=null,Te({removedFurniture:ve})},[Te]),ut=w.useCallback((he,ve)=>{if(!Rl||!ya)return;const ce=dg.find(Oe=>Oe.type===Rl),W=(ce==null?void 0:ce.price)??0;if(W>0&&C<W)return;let le=null;for(const[Oe,Le]of Object.entries(Ge.rooms)){const tt=ya==="wall"?Le.wx:Le.fx,Ke=ya==="wall"?Le.wy:Le.fy,jt=ya==="wall"?Le.ww:Le.fw,ze=ya==="wall"?Le.wh:Le.fh;if(he>=tt&&he<=tt+jt&&ve>=Ke&&ve<=Ke+ze){le=Oe;break}}if(!le)return;const we=Ge.rooms[le],xe=ya==="wall"?we.wx:we.fx,je=ya==="wall"?we.wy:we.fy,Re={id:`user-${Rl}-${Date.now()}`,type:Rl,room:le,zone:ya,offsetX:Math.round(he-xe),offsetY:Math.round(ve-je)},$e=[...q.current,Re];if(q.current=$e,ya==="wall"?Ge.wallDecorations.push(Re):Ge.furniture.push(Re),ga=xi(Ge),Te({addedFurniture:$e}),R==null||R(Rl,W),W>0){const Oe=Re.type;Eg(async()=>{const{api:Le}=await Promise.resolve().then(()=>Sw);return{api:Le}},void 0).then(({api:Le})=>{Le.spendCoins(W,`furniture: ${Oe}`,Re.id).then(tt=>E==null?void 0:E(tt.balance)).catch(()=>{})})}Y(null),J(null)},[Te,C,E,R]),mt=w.useCallback(he=>{const ve=B.current;if(Pa&&Zn){const{mx:xe,my:je}=We(he),$e=[...Ge.furniture,...Ge.wallDecorations].find(tt=>tt.id===Zn.defId);if(!$e)return;const Oe=xe-Zn.startMx,Le=je-Zn.startMy;$e.offsetX=Math.round(Zn.origOffX+Oe),$e.offsetY=Math.round(Zn.origOffY+Le),ga=xi(Ge),ve&&(ve.style.cursor="grabbing");return}if(Pa&&Mn){const{mx:xe,my:je}=We(he),Re=mn[Mn.roleId];if(!Re)return;Re.dx=Math.round(Mn.origDx+(xe-Mn.startMx)),Re.dy=Math.round(Mn.origDy+(je-Mn.startMy));const $e=Q.current[Mn.roleId];$e&&($e.homeX=Re.dx+8,$e.homeY=Re.dy+34),ve&&(ve.style.cursor="grabbing");return}if(Pa){const{mx:xe,my:je}=We(he);if(Rl){ve&&(ve.style.cursor="crosshair");return}const Re=new Set(Object.values(mn).map(Oe=>Oe.room)),$e=Bh(Ge,xe,je,Re);if($e)aa=$e;else{const Oe=ug(mn,xe,je);aa=Oe?`desk:${Oe}`:null}Gn=null,yi=null,ve&&(ve.style.cursor=aa?"grab":"default");return}const ce=Ce(he),W=Gn;Gn=(ce==null?void 0:ce.type)==="role"?ce.id:null,yi=(ce==null?void 0:ce.type)==="facility"?ce.id:null,vi=(ce==null?void 0:ce.type)==="mascot",aa=null,ve&&(ve.style.cursor=ce?"pointer":"default");const{mx:le}=We(he);Dv=le;const we=Date.now();if(Gn&&Gn!==W){ye.current[Gn]||(ye.current[Gn]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const xe=ye.current[Gn];xe.hoverStartTime=we}else if(!Gn&&W){const xe=ye.current[W];xe&&(xe.hoverStartTime=null)}},[Ce,We]),wt=w.useCallback(he=>{if(!Pa)return;const{mx:ve,my:ce}=We(he);if(Rl){ut(ve,ce),he.preventDefault();return}const W=new Set(Object.values(mn).map(xe=>xe.room)),le=Bh(Ge,ve,ce,W);if(le){const je=[...Ge.furniture,...Ge.wallDecorations].find(Re=>Re.id===le);je&&(Er=le,Zn={defId:le,startMx:ve,startMy:ce,origOffX:je.offsetX,origOffY:je.offsetY},he.preventDefault());return}const we=ug(mn,ve,ce);if(we){const xe=mn[we];Er=`desk:${we}`,Mn={roleId:we,startMx:ve,startMy:ce,origDx:xe.dx,origDy:xe.dy},he.preventDefault();return}Er=null},[We,ut]),qt=w.useCallback(he=>{if(Zn){const ce=[...Ge.furniture,...Ge.wallDecorations].find(W=>W.id===Zn.defId);if(ce){const W={...K.current,[ce.id]:{offsetX:ce.offsetX,offsetY:ce.offsetY}};K.current=W,Te({furnitureOverrides:W}),ga=xi(Ge)}Zn=null,B.current&&(B.current.style.cursor="grab");return}if(Mn){const ve=mn[Mn.roleId];if(ve){const ce={...D.current,[Mn.roleId]:{dx:ve.dx,dy:ve.dy}};D.current=ce,Te({deskOverrides:ce})}Mn=null,B.current&&(B.current.style.cursor="grab")}},[Te]),$t=w.useCallback(he=>{if(!Pa)return;he.preventDefault();const{mx:ve,my:ce}=We(he),W=new Set(Object.values(mn).map(we=>we.room)),le=Bh(Ge,ve,ce,W);le&&xt(le)},[We,xt]);w.useEffect(()=>{const he=ve=>{!Pa||!Er||(ve.key==="Delete"||ve.key==="Backspace")&&(Er.startsWith("desk:")||xt(Er))};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[xt]);const Ct=w.useCallback(()=>{if(Zn){const ve=[...Ge.furniture,...Ge.wallDecorations].find(ce=>ce.id===Zn.defId);ve&&(ve.offsetX=Zn.origOffX,ve.offsetY=Zn.origOffY,ga=xi(Ge)),Zn=null}if(Mn){const he=mn[Mn.roleId];he&&(he.dx=Mn.origDx,he.dy=Mn.origDy);const ve=Q.current[Mn.roleId];ve&&(ve.homeX=he.dx+8,ve.homeY=he.dy+34),Mn=null}Gn=null,yi=null,vi=!1,aa=null,B.current&&(B.current.style.cursor="default")},[]),Bn=w.useCallback(he=>{if(Pa)return;const ve=Ce(he);if(ve){if(ve.type==="role"){const ce=Q.current[ve.id],W=mn[ve.id];if(ce&&W){const le=ce.state==="sitting"?W.dx+13:Math.round(ce.x)+6,we=ce.state==="sitting"?W.dy+2:Math.round(ce.y)-2;pg(le,we)}o(ve.id);return}if(ve.type==="mascot"){const ce=A.current;ce&&pg(Math.round(ce.x)+4,Math.round(ce.y)-2),k==null||k();return}switch(ve.id){case"meeting":{const ce=n[0];ce?u(ce.id):d();break}case"bulletin":d();break;case"decisions":h();break;case"knowledge":m();break;case"settings":f==null||f();break;case"theme":x==null||x();break;case"stats":y==null||y();break}}},[Ce,o,u,d,h,m,f,x,y]);return l.jsxs("div",{className:`td-scene${ee?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:L,className:"td-wrap",children:[l.jsx("canvas",{ref:B,width:Ge.canvasW,height:Ge.canvasH,className:"td-canvas",onClick:Bn,onMouseDown:wt,onMouseUp:qt,onMouseMove:mt,onMouseLeave:Ct,onContextMenu:$t}),l.jsx("div",{ref:H,className:"td-overlay"})]}),ee&&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${ee?" td-edit-btn--active":""}`,"data-quest-target":"edit-btn",onClick:()=>{oe(he=>{const ve=!he;return ve||(Y(null),J(null)),ve}),Er=null,Zn=null,Mn=null},title:ee?"Exit Edit Mode":"Edit Furniture Layout",children:[l.jsx("span",{className:"td-edit-btn__icon",children:ee?"✓":"✎"}),l.jsx("span",{className:"td-edit-btn__label",children:ee?"DONE":"EDIT"})]}),ee&&l.jsx("div",{className:"td-palette",children:dg.map(he=>{const ve=he.price===0||C>=he.price,ce=he.price===0?"Free":`${he.price>=1e3?`${(he.price/1e3).toFixed(he.price%1e3===0?0:1)}K`:he.price}`;return l.jsxs("button",{className:`td-palette__item${ne===he.type?" td-palette__item--active":""}${ve?"":" td-palette__item--locked"}`,onClick:()=>{ve&&(ne===he.type?(Y(null),J(null)):(Y(he.type),J(he.zone)))},title:`${he.label} — ${ce}`,style:ve?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:he.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:he.price===0?"#4CAF50":ve?"#FFD54F":"#EF5350"},children:ce})]},he.type)})}),j&&l.jsxs("button",{className:"td-hire-btn","data-quest-target":"hire-btn",onClick:j,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 ZA({role:e,appearance:n,onSave:a,onReset:i,onClose:o,theme:u,onThemeChange:d,onUpdateName:h,initialTab:m,characterOnly:f,speechSettings:x,onSpeechSettingsChange:y,language:v,onLanguageChange:b,roleLevel:j}){var $;const[k,N]=w.useState(m??"character"),[C,E]=w.useState({...n}),[R,M]=w.useState(e.name),[I,B]=w.useState(!1),L=w.useCallback(()=>E(ms(j)),[j]),H=w.useCallback(()=>{const U=Wm(e.id);E({...U}),i()},[e.id,i]),Q=w.useCallback(async()=>{a(C);const U=R.trim();if(h&&U&&U!==e.name){B(!0);try{await h(e.id,U)}catch{}B(!1)}o()},[C,a,o,R,e.name,e.id,h]),A=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," –"]}),h?l.jsx("input",{value:R,onChange:U=>M(U.target.value),disabled:I,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:o,children:l.jsxs("div",{className:"customize-modal",onClick:U=>U.stopPropagation(),children:[l.jsxs("div",{className:"customize-header",children:[l.jsxs("div",{className:"customize-tabs",children:[l.jsx("button",{className:`customize-tab ${k==="character"?"active":""}`,onClick:()=>N("character"),children:"CHARACTER"}),!f&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${k==="office"?"active":""}`,onClick:()=>N("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${k==="settings"?"active":""}`,onClick:()=>N("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:o,children:"X"})]}),k==="character"?l.jsx("div",{className:"customize-body",children:l.jsx(fv,{roleId:e.id,appearance:C,onChange:E,onRandomize:L,onReset:H,label:A,roleLevel:j})}):k==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(el).map(([U,ee])=>l.jsxs("button",{className:`customize-theme-card ${u===U?"active":""}`,onClick:()=>d(U),children:[l.jsxs("div",{className:"customize-theme-preview",style:{background:ee.vars["--floor-light"],borderColor:ee.vars["--pixel-border"]},children:[l.jsx("div",{style:{background:ee.vars["--hud-bg"],height:8,borderBottom:`2px solid ${ee.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:ee.vars["--accent"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:ee.vars["--active-green"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:ee.vars["--idle-amber"],borderRadius:1}})]}),l.jsx("div",{style:{background:ee.vars["--hud-bg"],height:6,borderTop:`2px solid ${ee.vars["--pixel-border"]}`}})]}),l.jsxs("div",{className:"customize-theme-name",children:[ee.icon," ",ee.name]})]},U))})}):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(U=>l.jsxs("button",{onClick:()=>y==null?void 0:y({mode:U}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(x==null?void 0:x.mode)===U?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(x==null?void 0:x.mode)===U?"rgba(255,255,255,0.08)":"transparent",color:(x==null?void 0:x.mode)===U?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:U==="template"?"TEMPLATE":U==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:U==="template"?"Static pool ($0)":U==="llm"?"LLM generated":"Detect engine"})]},U))}),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:U=>y==null?void 0:y({intervalSec:Number(U.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: $",(($=x==null?void 0:x.dailyBudgetUsd)==null?void 0:$.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(x==null?void 0:x.dailyBudgetUsd)??1,onChange:U=>y==null?void 0:y({dailyBudgetUsd:Number(U.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:U,label:ee})=>l.jsx("button",{onClick:()=>b==null?void 0:b(U),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(v??"auto")===U?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(v??"auto")===U?"rgba(255,255,255,0.08)":"transparent",color:(v??"auto")===U?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:ee},U))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]})]})}),k==="character"&&l.jsxs("div",{className:"customize-footer",children:[l.jsx("button",{className:"customize-btn customize-btn--cancel",onClick:o,children:"CANCEL"}),l.jsx("button",{className:"customize-btn customize-btn--save",onClick:Q,children:"SAVE"})]})]})})}function xg(e){if(e.length===0)return"";const n={};for(const{file:h}of e){const m=h.split("/"),f=m[0]==="."?m[1]??"root":m[0];(n[f]??(n[f]=[])).push(h)}const a={roles:"roles",projects:"projects",operations:"operations",knowledge:"knowledge",architecture:"architecture",company:"company",".tycono":"config",".claude":"skills"},i=[];for(const[h,m]of Object.entries(n)){const f=a[h]??h;if(m.length===1){const x=m[0].split("/").pop()??m[0];i.push(`${f}/${x}`)}else i.push(`${f} (${m.length} files)`)}const o=e.some(h=>h.status==="A"),u=e.some(h=>h.status==="M");return`${o&&!u?"add":"update"}: ${i.join(", ")}`}function yg(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 i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function JA({onInitGit:e,onDelegate:n,delegateRoleName:a}){const[i,o]=w.useState(!1),[u,d]=w.useState(null),h=async()=>{o(!0),d(null);try{await e(),d({ok:!0,message:"Git repository initialized!"})}catch(f){const x=f instanceof Error?f.message:"Failed";x.includes("not installed")||x.includes("noGitBinary")?d({ok:!1,message:"git is not installed on this system"}):d({ok:!1,message:x})}finally{o(!1)}},m=u&&!u.ok&&u.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"}),!u&&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:h,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"}),n&&l.jsxs("button",{onClick:n,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["🤖"," ",(a==null?void 0:a.toUpperCase())??"AI"," FIX"]})]})]}),u&&u.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:u.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:()=>{d(null)},className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),n&&l.jsxs("button",{onClick:n,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:["🤖"," ",(a==null?void 0:a.toUpperCase())??"AI"," FIX"]})]})]}),u&&!u.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:u.message})]})}function e8({repo:e,onConnected:n,onDelegate:a,delegateRoleName:i}){const[o,u]=w.useState("idle"),[d,h]=w.useState(null),[m,f]=w.useState(""),[x,y]=w.useState("private"),[v,b]=w.useState(""),[j,k]=w.useState(null),[N,C]=w.useState(!1),E=async()=>{u("checking"),k(null);try{const B=await ke.getGithubStatus(e);h(B),B.hasRemote?n():B.ghInstalled&&B.authenticated?u("ready"):u("idle")}catch{u("idle")}},R=async()=>{if(m.trim()){C(!0),k(null);try{const B=await ke.githubCreateRepo(m.trim(),x,e);k(B),B.ok&&setTimeout(n,1500)}catch(B){k({ok:!1,message:B instanceof Error?B.message:"Failed"})}finally{C(!1)}}},M=async()=>{if(v.trim()){C(!0),k(null);try{const B=await ke.addRemote(v.trim(),e);k(B),B.ok&&setTimeout(n,1500)}catch(B){k({ok:!1,message:B instanceof Error?B.message:"Failed"})}finally{C(!1)}}},I=a?l.jsxs("button",{onClick:a,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"}),o==="idle"&&!d&&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:()=>u("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"}),I]}),o==="checking"&&l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"Checking GitHub CLI..."}),o==="idle"&&d&&!d.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:()=>u("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"}),I]})]}),o==="idle"&&d&&d.ghInstalled&&!d.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:()=>u("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"}),I]})]}),o==="ready"&&d&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--active-green)"},children:["Logged in as ",d.username||"GitHub user"]}),l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("input",{type:"text",value:m,onChange:B=>f(B.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:B=>y(B.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:R,disabled:N||!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:N?"CREATING...":"CREATE & PUSH"}),l.jsx("button",{onClick:()=>u("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"})]})]}),o==="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:v,onChange:B=>b(B.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:M,disabled:N||!v.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:N?"ADDING...":"ADD REMOTE & PUSH"}),l.jsx("button",{onClick:()=>{u("idle"),h(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"})]})]}),j&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:j.ok?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${j.ok?"var(--active-green)":"#D32F2F"}`,color:j.ok?"var(--active-green)":"#EF5350"},children:j.message})]})}function t8({status:e,history:n,onClose:a,onSave:i,onLoadHistory:o,onRestore:u,saving:d,onDelegate:h,delegateRoleName:m,repo:f,onRepoChange:x,syncInfo:y,onPull:v,pulling:b,onRefresh:j,onInitGit:k}){const[N,C]=w.useState("save"),[E,R]=w.useState(""),[M,I]=w.useState(null),[B,L]=w.useState(!1),[H,Q]=w.useState(null),[A,$]=w.useState(null),U=w.useRef(null);w.useEffect(()=>{N==="history"&&o()},[N,o]),w.useEffect(()=>{var D;(D=U.current)==null||D.focus()},[]);const ee=[...((e==null?void 0:e.modified)??[]).map(D=>({status:"M",file:D})),...((e==null?void 0:e.untracked)??[]).map(D=>({status:"A",file:D}))],oe=w.useRef(!1);w.useEffect(()=>{!oe.current&&ee.length>0&&!E&&(R(xg(ee)),oe.current=!0)},[ee.length]),w.useEffect(()=>{oe.current=!1,R(""),$(null),Q(null),I(null)},[f]);const ne=w.useCallback(()=>{R(xg(ee))},[ee]),Y=async()=>{I(null),Q(null);try{const D=await i(E||void 0);Q(D),R("")}catch(D){I(D instanceof Error?D.message:"Save failed")}},ue=async()=>{$(null),I(null);try{const D=await v();$(D)}catch(D){I(D instanceof Error?D.message:"Pull failed")}},J=async D=>{if(confirm(`Restore from commit ${D.slice(0,7)}? This creates a new commit with those files.`)){L(!0);try{await u(D),L(!1)}catch(F){I(F instanceof Error?F.message:"Restore failed"),L(!1)}}};w.useEffect(()=>{const D=F=>{F.key==="Escape"&&a()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[a]);const K=D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&Y()};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:a}),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 GAME"}),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:[y&&y.hasRemote&&(y.behind>0||y.ahead>0)&&l.jsxs("span",{className:"text-[10px] font-bold",style:{color:y.behind>0?"var(--idle-amber)":"var(--active-green)"},children:[y.behind>0&&`↓${y.behind}`,y.behind>0&&y.ahead>0&&" ",y.ahead>0&&`↑${y.ahead}`]}),l.jsx("button",{onClick:a,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(D=>l.jsx("button",{onClick:()=>x(D),className:"flex-1 py-1.5 text-[10px] font-bold uppercase tracking-wider cursor-pointer",style:{background:f===D?"var(--hud-bg-alt)":"transparent",color:f===D?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:f===D?"2px solid var(--accent)":"2px solid transparent"},children:D==="akb"?"AKB":"CODE"},D))}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["save","history"].map(D=>l.jsx("button",{onClick:()=>C(D),className:"flex-1 py-2 text-[11px] font-bold uppercase tracking-wider cursor-pointer",style:{background:N===D?"var(--hud-bg-alt)":"transparent",color:N===D?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:N===D?"2px solid var(--accent)":"2px solid transparent"},children:D==="save"?"SAVE":"HISTORY"},D))}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[N==="save"&&l.jsxs(l.Fragment,{children:[(e==null?void 0:e.noGit)&&l.jsx(JA,{onInitGit:async()=>{await(k==null?void 0:k()),j==null||j()},onDelegate:h?()=>{h(`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}),y&&y.hasRemote&&y.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:[y.behind," commit",y.behind>1?"s":""," behind remote"]}),l.jsx("button",{onClick:ue,disabled:b,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--idle-amber)",color:"#000",border:"none",opacity:b?.5:1},children:b?"PULLING...":"↓ PULL"})]}),A&&l.jsx("div",{className:"text-[11px] p-2",style:{background:A.status==="ok"||A.status==="up-to-date"?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${A.status==="ok"||A.status==="up-to-date"?"var(--active-green)":"#D32F2F"}`,color:A.status==="ok"||A.status==="up-to-date"?"var(--active-green)":"#EF5350"},children:A.message}),l.jsx("div",{className:"text-[11px]",style:{color:"var(--terminal-text-secondary)"},children:ee.length>0?l.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",ee.length," unsaved change",ee.length>1?"s":""]}):l.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),ee.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:ee.map(({status:D,file:F})=>l.jsxs("div",{className:"flex gap-2",children:[l.jsx("span",{style:{color:D==="A"?"var(--active-green)":"var(--idle-amber)",width:"14px"},children:D}),l.jsx("span",{style:{color:"var(--terminal-text-secondary)"},children:F})]},F))})]}),ee.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:ne,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:U,type:"text",value:E,onChange:D=>R(D.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)"}})]}),ee.length>0&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:Y,disabled:d,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:d?"SAVING...":e!=null&&e.hasRemote?"SAVE & PUSH":"SAVE"}),h&&l.jsxs("button",{onClick:()=>{const D=ee.map(F=>`${F.status} ${F.file}`).join(`
|
|
91
|
+
`);h(D)},disabled:d,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(e8,{repo:f,onConnected:()=>j==null?void 0:j(),onDelegate:h?()=>{h(`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}),H&&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! ",H.filesChanged," file",H.filesChanged>1?"s":""," committed",H.pushed?" & pushed":"",H.pushError?` (push error: ${H.pushError})`:""]}),M&&l.jsx("div",{className:"text-[11px] p-2",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:M}),(e==null?void 0:e.lastCommit)&&l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:["Last save: ",e.lastCommit.message," (",yg(e.lastCommit.date),")"]})]}),N==="history"&&l.jsxs(l.Fragment,{children:[n.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:n.map(D=>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:D.shortSha}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:D.message})]}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:yg(D.date)})]}),l.jsx("button",{onClick:()=>J(D.sha),disabled:B,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"})]},D.sha))})]})]})]})]})}function n8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[,h]=w.useState(!1);return w.useEffect(()=>{Promise.all([ke.getCompanyStats(),ke.getPreferences()]).then(async([m,f])=>{a(m);const x=f;if(x.instanceId)try{await pr.syncStats({instanceId:x.instanceId,roleCount:m.company.roleCount,totalTokens:m.company.totalTokens,rolesData:m.roles.map(y=>({roleId:y.roleId,name:y.name,tokens:y.totalTokens}))}),h(!0)}catch{}}).catch(m=>d(m.message)).finally(()=>o(!1))},[]),i?l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading stats..."}):u||!n?l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u||"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(wu,{label:"Roles",value:String(n.company.roleCount)}),l.jsx(wu,{label:"Avg Level",value:`Lv.${n.company.avgLevel}`}),l.jsx(wu,{label:"Total Tokens",value:n.company.formattedTokens}),l.jsx(wu,{label:"Total Cost",value:`$${n.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:[n.roles.map((m,f)=>l.jsx(r8,{role:m,rank:f+1},m.roleId)),n.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(n.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(n.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:a8(m)}),l.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",f.costUsd.toFixed(2)]})]},m))})]})]})}function wu({label:e,value:n}){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:n})]})}function r8({role:e,rank:n}){const a=["🥇","🥈","🥉"],i=n<=3?a[n-1]:`#${n}`;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:gg(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:gg(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 gg(e){return e>=20?"#FFD700":e>=10?"#C0A0FF":e>=5?"#4FC3F7":e>=3?"#81C784":"rgba(255,255,255,0.4)"}function a8(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.split("-").slice(0,2).join(" ")}function l8({onClose:e,onSyncComplete:n}){const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,h]=w.useState(!0),[m,f]=w.useState(null),[x,y]=w.useState(new Set),[v,b]=w.useState(null),[j,k]=w.useState(null),N=w.useCallback(async()=>{h(!0),b(null);try{const{roles:E}=await ke.getSyncRoles();i(E);const R=E.filter(M=>M.source.sync!=="off");if(R.length===0){u([]),k(null);return}try{const M=await pr.syncCheck(R.map(B=>({roleId:B.roleId,sourceId:B.source.id,currentVersion:B.source.upstream_version??B.source.forked_at??"0.0.0"})));k(!0);const I=[];for(const B of M.updates){if(!B.hasUpdate)continue;const L=R.find(U=>U.roleId===B.roleId);if(!L)continue;const{character:H}=await pr.syncPull(B.sourceId),Q=[];L.persona.trim()!==H.persona.trim()&&Q.push({field:"persona",local:L.persona.slice(0,120)+(L.persona.length>120?"...":""),upstream:H.persona.slice(0,120)+(H.persona.length>120?"...":"")});const A=JSON.stringify(L.authority),$=JSON.stringify(H.authority);A!==$&&Q.push({field:"authority",local:`${L.authority.autonomous.length} autonomous, ${L.authority.needsApproval.length} approval`,upstream:`${H.authority.autonomous.length} autonomous, ${H.authority.needsApproval.length} approval`}),Q.length>0&&I.push({roleId:B.roleId,roleName:L.name,sourceId:B.sourceId,currentVersion:B.currentVersion,latestVersion:B.latestVersion,fields:Q})}u(I)}catch{k(!1),u([])}}catch(E){b(E instanceof Error?E.message:"Failed to check for updates")}finally{h(!1)}},[]);w.useEffect(()=>{N()},[N]);const C=async E=>{f(E.roleId);try{const{character:R,version:M}=await pr.syncPull(E.sourceId);await ke.applySyncUpdate({roleId:E.roleId,changes:{persona:R.persona,authority:R.authority},upstreamVersion:M}),y(I=>new Set(I).add(E.roleId)),n==null||n()}catch(R){b(R instanceof Error?R.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:N,disabled:d,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:d?"wait":"pointer"},children:d?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),j===!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."}),v&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:v}),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:a.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:o.length>0?"#4FC3F7":"rgba(255,255,255,0.7)"},children:o.filter(E=>!x.has(E.roleId)).length}),j===!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"})]})]}),o.length===0&&!d&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:a.length===0?"No roles with source tracking. Hire from the Store to enable sync.":"All roles are up to date!"}),o.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:()=>C(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(R=>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:R.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",{}),R.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",{}),R.upstream]})]})]},R.field))]},E.roleId)),a.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 i8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[h,m]=w.useState(null),f=w.useCallback(async()=>{o(!0),d(null);try{const E=await ke.getGitStatus();a(E)}catch(E){d(E instanceof Error?E.message:"Failed to load git status")}finally{o(!1)}},[]);w.useEffect(()=>{f()},[f]);const x=async E=>{m(E.path);try{await ke.deleteWorktree(E.path),await f()}catch(R){d(R instanceof Error?R.message:"Failed to remove worktree")}finally{m(null)}},y=async E=>{m(E);try{await ke.deleteBranch(E),await f()}catch(R){d(R instanceof Error?R.message:"Failed to delete branch")}finally{m(null)}};if(i&&!n)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading git status..."});if(u&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const v=n.worktrees.filter(E=>E.status==="active"),b=n.worktrees.filter(E=>E.status==="pending-merge"),j=n.worktrees.filter(E=>E.status==="stale");function k(E){const R=E.split("/");if(R.length>1){const M=R[R.length-1],I=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const B of I)if(M.toLowerCase().includes(B))return B}return null}function N(E,R=40){return E.length<=R?E:"..."+E.slice(E.length-R+3)}function C(E){const R=Date.now()-new Date(E).getTime(),M=Math.floor(R/6e4);if(M<1)return"just now";if(M<60)return`${M}m ago`;const I=Math.floor(M/60);return I<24?`${I}h ago`:`${Math.floor(I/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:"×"})]})]}),u&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),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:n.currentBranch})]}),l.jsx("div",{children:n.unsavedCount>0&&l.jsxs("span",{style:{color:"#FFB74D",fontSize:12},children:[n.unsavedCount," unsaved"]})})]}),n.lastCommit&&l.jsxs("div",{style:{marginTop:6,fontSize:11,color:"rgba(255,255,255,0.4)"},children:["Last commit: ",n.lastCommit.message.slice(0,60),n.lastCommit.message.length>60?"...":""," · ",C(n.lastCommit.date)]})]}),v.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ku,{label:"Active Worktrees",count:v.length}),v.map(E=>l.jsx(Ih,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:N,timeAgo:C,removing:h===E.path,onRemove:()=>x(E),statusColor:"#4FC3F7",statusIcon:"📂"},E.path))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ku,{label:"Pending Merge",count:b.length}),b.map(E=>l.jsx(Ih,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:N,timeAgo:C,removing:h===E.path,onRemove:()=>x(E),statusColor:"#FFB74D",statusIcon:"⚠️"},E.path))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ku,{label:"Stale",count:j.length}),j.map(E=>l.jsx(Ih,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:N,timeAgo:C,removing:h===E.path,onRemove:()=>x(E),statusColor:"#ff6b6b",statusIcon:"🔴"},E.path))]}),n.staleBranches.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ku,{label:"Unmerged Branches",count:n.staleBranches.length}),n.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:()=>y(E),disabled:h===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:h===E?"wait":"pointer",opacity:h===E?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:h===E?"...":"DELETE"})]},E))]}),v.length===0&&b.length===0&&j.length===0&&n.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."]}),n.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:n.lastMerge.branch})," · ",n.lastMerge.roleId," · ",C(n.lastMerge.mergedAt)]})]})}function ku({label:e,count:n}){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," (",n,")"]})}function Ih({wt:e,roleFromBranch:n,truncatePath:a,timeAgo:i,removing:o,onRemove:u,statusColor:d,statusIcon:h}){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:h}),e.branch,n&&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:n})]}),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:[a(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:u,disabled:o,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:d,borderRadius:4,padding:"3px 8px",fontSize:10,cursor:o?"wait":"pointer",opacity:o?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:o?"...":"REMOVE"})]})})}function s8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[h,m]=w.useState(null),f=w.useCallback(async()=>{o(!0),d(null);try{const k=await ke.getActiveSessions();a(k)}catch(k){d(k instanceof Error?k.message:"Failed to load sessions")}finally{o(!1)}},[]);w.useEffect(()=>{f();const k=setInterval(f,1e4);return()=>clearInterval(k)},[f]);const x=async k=>{m(k);try{await ke.deleteActiveSession(k),await f()}catch(N){d(N instanceof Error?N.message:"Failed to remove session")}finally{m(null)}},y=async()=>{try{await ke.cleanupActiveSessions(),await f()}catch(k){d(k instanceof Error?k.message:"Failed to cleanup sessions")}};if(i&&!n)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading sessions..."});if(u&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const v=n.sessions.filter(k=>k.status==="active"),b=n.sessions.filter(k=>k.status==="idle"),j=n.sessions.filter(k=>k.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:[j.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: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:"×"})]})]}),u&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13,display:"flex",justifyContent:"space-between"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Sessions: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.active})]}),l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Ports in use: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.totalPorts})]})]}),v.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Hh,{label:"Active",count:v.length}),v.map(k=>l.jsx(Uh,{session:k,removing:h===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#4FC3F7"},k.sessionId))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Hh,{label:"Idle",count:b.length}),b.map(k=>l.jsx(Uh,{session:k,removing:h===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#FFB74D"},k.sessionId))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Hh,{label:"Dead",count:j.length}),j.map(k=>l.jsx(Uh,{session:k,removing:h===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#ff6b6b"},k.sessionId))]}),n.sessions.length===0&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:"No active sessions. Sessions appear when jobs run with port allocation."})]})}function Hh({label:e,count:n}){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," (",n,")"]})}function o8(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 i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Uh({session:e,removing:n,onRemove:a,statusColor:i}){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.jobStatus&&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.jobStatus})]}),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:[" · ",c8(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" · ","PID:",e.pid]})," · ",o8(e.startedAt)]})]}),l.jsx("button",{onClick:a,disabled:n,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:"#ff6b6b",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:n?"wait":"pointer",opacity:n?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:n?"...":"STOP"})]})})}function c8(e,n=35){return e.length<=n?e:"..."+e.slice(e.length-n+3)}function u8({onClose:e,speechSettings:n,onSpeechSettingsChange:a,language:i,onLanguageChange:o,onOpenSync:u,onOpenGitStatus:d,onOpenSessions:h,onOpenStats:m}){var ue;const[f,x]=w.useState(null),[y,v]=w.useState(null),[b,j]=w.useState(!1),[k,N]=w.useState(!1),[C,E]=w.useState(!1),[R,M]=w.useState(null),[I,B]=w.useState(""),[L,H]=w.useState(!1),[Q,A]=w.useState(!1),[$,U]=w.useState(null),[ee,oe]=w.useState(!1);w.useEffect(()=>{ke.getPreferences().then(async J=>{const K=J;if(x(K.instanceId??null),K.instanceId)try{const{name:D}=await pr.getMyName(K.instanceId);v(D)}catch{}}).catch(()=>{}),ke.getCodeRoot().then(({codeRoot:J})=>{M(J),J&&B(J)}).catch(()=>{})},[]);const ne=async()=>{E(!0);try{const K=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();K.ok&&(x(K.newInstanceId),N(!1))}catch{}E(!1)},Y=()=>{f&&navigator.clipboard.writeText(f).then(()=>{j(!0),setTimeout(()=>j(!1),2e3)})};return l.jsx("div",{className:"customize-overlay",onClick:e,children:l.jsxs("div",{className:"customize-modal",onClick:J=>J.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(J=>l.jsxs("button",{onClick:()=>a==null?void 0:a({mode:J}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(n==null?void 0:n.mode)===J?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(n==null?void 0:n.mode)===J?"rgba(255,255,255,0.08)":"transparent",color:(n==null?void 0:n.mode)===J?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:J==="template"?"TEMPLATE":J==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:J==="template"?"Static pool ($0)":J==="llm"?"LLM generated":"Detect engine"})]},J))}),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: ",(n==null?void 0:n.intervalSec)??18,"s"]}),l.jsx("input",{type:"range",min:5,max:120,step:5,value:(n==null?void 0:n.intervalSec)??18,onChange:J=>a==null?void 0:a({intervalSec:Number(J.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)"})]})]}),(n==null?void 0:n.mode)!=="template"&&l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["DAILY LLM BUDGET: $",((ue=n==null?void 0:n.dailyBudgetUsd)==null?void 0:ue.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(n==null?void 0:n.dailyBudgetUsd)??1,onChange:J=>a==null?void 0:a({dailyBudgetUsd:Number(J.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:J,label:K})=>l.jsx("button",{onClick:()=>o==null?void 0:o(J),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(i??"auto")===J?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(i??"auto")===J?"rgba(255,255,255,0.08)":"transparent",color:(i??"auto")===J?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:K},J))}),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"}),L?l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:I,onChange:J=>{B(J.target.value),U(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(I.trim()){A(!0),U(null);try{const J=await ke.setCodeRoot(I.trim());M(J.codeRoot),B(J.codeRoot),H(!1),oe(!0),setTimeout(()=>oe(!1),3e3)}catch(J){U(J instanceof Error?J.message:"Failed to set code root")}finally{A(!1)}}},disabled:Q||!I.trim(),style:{padding:"8px 12px",fontSize:10,fontWeight:600,background:"var(--accent)",border:"none",color:"#fff",borderRadius:6,cursor:"pointer",opacity:Q||!I.trim()?.5:1},children:Q?"...":"Save"}),l.jsx("button",{onClick:()=>{H(!1),B(R||""),U(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:R?"var(--terminal-text)":"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R||"Not configured"}),l.jsx("button",{onClick:()=>{H(!0),U(null),oe(!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"})]}),ee&&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)"})]}),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:Y,style:{padding:"8px 12px",fontSize:10,fontWeight:600,border:"2px solid rgba(255,255,255,0.1)",background:"transparent",color:b?"#4ade80":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",whiteSpace:"nowrap"},children:b?"Copied!":"Copy"})]}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Use this token to sign in on the web Store. Keep it secret — anyone with this token can act as you."}),l.jsx("div",{style:{marginTop:6},children:k?l.jsxs("div",{style:{background:"rgba(255,50,50,0.08)",border:"1px solid rgba(255,50,50,0.2)",borderRadius:6,padding:"8px 10px"},children:[l.jsx("div",{style:{fontSize:9,color:"rgba(255,100,100,0.8)",marginBottom:6},children:"This will invalidate your current token. Published characters will lose ownership. No migration."}),l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("button",{onClick:ne,disabled:C,style:{padding:"4px 12px",fontSize:9,fontWeight:700,border:"1px solid rgba(255,50,50,0.4)",background:"rgba(255,50,50,0.15)",color:"#ff6464",borderRadius:4,cursor:"pointer"},children:C?"...":"Confirm Regenerate"}),l.jsx("button",{onClick:()=>N(!1),style:{padding:"4px 12px",fontSize:9,border:"none",background:"transparent",color:"var(--terminal-text-muted)",cursor:"pointer"},children:"Cancel"})]})]}):l.jsx("button",{onClick:()=>N(!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:[u&&l.jsx("button",{onClick:()=>{e(),u()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🔄 ROLE SYNC"}),d&&l.jsx("button",{onClick:()=>{e(),d()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"📂 GIT STATUS"}),h&&l.jsx("button",{onClick:()=>{e(),h()},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"})]}),y&&l.jsx("div",{style:{textAlign:"center",marginTop:-8},children:l.jsx("a",{href:`https://tycono.ai/profile.html?u=${encodeURIComponent(y)}`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:10,color:"var(--terminal-text-muted)",textDecoration:"none"},onMouseEnter:J=>J.currentTarget.style.color="var(--accent)",onMouseLeave:J=>J.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile →"})})]})})]})})}function d8({theme:e,onThemeChange:n,onClose:a}){const i=w.useRef(null);return w.useEffect(()=>{const o=u=>{i.current&&!i.current.contains(u.target)&&a()};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[a]),l.jsx("div",{ref:i,className:"theme-dropup",children:Object.entries(el).map(([o,u])=>l.jsxs("button",{className:`theme-dropup__item${e===o?" theme-dropup__item--active":""}`,onClick:()=>{n(o),a()},title:u.name,children:[l.jsxs("span",{className:"theme-dropup__swatch",style:{background:u.vars["--hud-bg"],borderColor:u.vars["--pixel-border"]},children:[l.jsx("span",{style:{background:u.vars["--accent"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:u.vars["--active-green"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:u.vars["--idle-amber"],width:5,height:5,borderRadius:1}})]}),l.jsx("span",{className:"theme-dropup__name",children:u.icon})]},o))})}const xs={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function f8({roles:e,roleStatuses:n,activeExecs:a,sessions:i,knowledgeDocs:o,roleLevels:u,companyName:d,getAppearance:h,waveCenterWaves:m,renderProfile:f,channel:x,onChannelChange:y,onClose:v,children:b}){const[j,k]=w.useState(!1),N=m.filter(L=>L.rootJobs.some(H=>{const Q=n[H.roleId];return Q==="working"||Q==="thinking"})),C=[...e].sort((L,H)=>L.level==="c-level"&&H.level!=="c-level"?-1:L.level!=="c-level"&&H.level==="c-level"?1:L.name.localeCompare(H.name)),E=e.filter(L=>n[L.id]==="working").length,R=i.filter(L=>L.status==="active").length,M=x.type==="role"?e.find(L=>L.id===x.roleId):null,I=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"?(M==null?void 0:M.name)??x.roleId:"Dashboard",B=x.type==="terminal"?`${R} active sessions`:x.type==="wave"?`${N.length} running`:x.type==="knowledge"?`${o.length} documents`:x.type==="role"?(M==null?void 0:M.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:d}),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"]})]}),N.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:()=>y({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:["⚡"," ",N[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:[N[0].rootJobs.filter(L=>{const H=n[L.roleId];return H==="working"||H==="thinking"}).length,"/",N[0].rootJobs.length," roles working"]})]}),l.jsxs("div",{className:"mx-3 mt-3 grid grid-cols-2 gap-1.5",children:[l.jsx(ju,{icon:"💬",label:"Chats",badge:R||void 0,active:x.type==="terminal",onClick:()=>y({type:"terminal"})}),l.jsx(ju,{icon:"⚡",label:"Waves",live:N.length>0,active:x.type==="wave",onClick:()=>y({type:"wave"})}),l.jsx(ju,{icon:"📋",label:"Decisions",active:x.type==="operations",onClick:()=>y({type:"operations"})}),l.jsx(ju,{icon:"📚",label:"Knowledge",badge:o.length||void 0,active:x.type==="knowledge",onClick:()=>y({type:"knowledge"})})]}),l.jsxs("div",{className:"mt-4",children:[l.jsx("div",{className:"px-4 py-1 text-[9px] font-bold tracking-widest",style:{color:"var(--terminal-text-muted)"},children:"TEAM"}),C.map(L=>{var ee;const H=n[L.id],Q=a.find(oe=>oe.roleId===L.id),A=xs[L.id]??"#666",$=(ee=u[L.id])==null?void 0:ee.level,U=x.type==="role"&&x.roleId===L.id;return l.jsxs("button",{onClick:()=>y({type:"role",roleId:L.id}),className:"flex items-center gap-2.5 w-full px-4 py-1.5 text-left hover:opacity-80 transition-all",style:{background:U?`${A}18`:"transparent",borderLeft:U?`2px solid ${A}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx($l,{roleId:L.id,appearance:h(L.id),scale:1.3}),l.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full",style:{background:H==="working"?"#4CAF50":H==="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:[L.name,$!=null&&l.jsxs("span",{className:"ml-1 opacity-40 text-[8px]",children:["Lv.",$]})]}),Q?l.jsx("div",{className:"text-[9px] truncate",style:{color:A},children:Q.task.slice(0,28)}):l.jsx("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted, #887766)"},children:L.level==="c-level"?L.id.toUpperCase():L.id})]}),H==="working"&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:A}})]},L.id)})]}),l.jsx("div",{className:"flex-1"}),a.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 (",a.length,")"]}),l.jsx("div",{className:"space-y-0.5 max-h-[140px] overflow-y-auto",children:a.map(L=>{const H=e.find($=>$.id===L.roleId),Q=xs[L.roleId]??"#666",A=x.type==="role"&&x.roleId===L.roleId;return l.jsxs("button",{onClick:()=>y({type:"role",roleId:L.roleId}),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded text-left hover:opacity-80 transition-all",style:{background:A?`${Q}18`:"transparent"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:Q}}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text, #fff5eb)"},children:(H==null?void 0:H.name)??L.roleId}),l.jsx("div",{className:"text-[8px] truncate",style:{color:"var(--terminal-text-muted)"},children:L.task.slice(0,40)})]})]},L.jobId??L.roleId)})})]}),l.jsx("div",{className:"px-3 py-3 shrink-0",style:{borderTop:"1px solid var(--terminal-border, #2E261F)"},children:l.jsxs("button",{onClick:v,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"&&M&&l.jsxs("button",{onClick:()=>k(L=>!L),className:"relative shrink-0 rounded-lg overflow-hidden hover:opacity-80 transition-opacity cursor-pointer",style:{width:28,height:28,background:`${xs[M.id]??"#666"}30`},title:"View profile",children:[l.jsx($l,{roleId:M.id,appearance:h(M.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:n[M.id]==="working"?"#4CAF50":n[M.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:I}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted, #887766)"},children:B}),l.jsx("span",{className:"flex-1"}),x.type==="role"&&l.jsx("button",{onClick:()=>k(L=>!L),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:j?"var(--terminal-text)":"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)",background:j?"var(--terminal-border)":"transparent"},children:"Profile"}),x.type!=="dashboard"&&l.jsx("button",{onClick:()=>y({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:b}),j&&x.type==="role"&&f&&l.jsx("div",{className:"shrink-0 overflow-hidden pro-panel-inline",style:{width:420,borderLeft:"1px solid var(--terminal-border, #2E261F)"},children:f(()=>k(!1))})]})]})]})}function h8({role:e,messages:n,isStreaming:a,mode:i,onModeChange:o,onSend:u,isWave:d}){const h=xs[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsx(hv,{messages:n,roleId:e.id,roleColor:h}),d?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(Gm,{mode:i,onModeChange:o,onSend:(m,f)=>u(m,i,f),disabled:a,disabledReason:a?`${e.id.toUpperCase()} is responding...`:void 0})]})}function m8({role:e,onSend:n,getAppearance:a,onOpenProfile:i}){const[o,u]=w.useState("talk"),d=xs[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:`${d}20`},children:l.jsx($l,{roleId:e.id,appearance:a(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(Gm,{mode:o,onModeChange:u,onSend:h=>n(h,o),disabled:!1})]})}function ju({icon:e,label:n,active:a,badge:i,live:o,onClick:u}){return l.jsxs("button",{onClick:u,className:"flex flex-col items-center gap-1 py-3 rounded-lg transition-all hover:opacity-90",style:{background:a?"var(--desk-wood, #5C3D2E)":"var(--terminal-border, #2E261F)",border:a?"1px solid var(--desk-wood, #5C3D2E)":"1px solid transparent"},children:[l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"text-[16px]",children:e}),o&&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&&!o&&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:a?"#fff":"var(--terminal-text, #fff5eb)"},children:n})]})}function p8({roles:e,roleStatuses:n,activeExecs:a,waves:i,knowledgeDocs:o,roleLevels:u,getAppearance:d,onRoleClick:h,onWaveClick:m,onKnowledgeClick:f}){const x=e.filter(y=>n[y.id]==="working");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(bg,{label:"New Wave",icon:"⚡",color:"#EF4444",onClick:m}),l.jsx(bg,{label:"Knowledge",icon:"📚",color:"#0D9488",onClick:f})]}),x.length>0&&l.jsx(Su,{title:"Currently Working",count:x.length,children:a.map(y=>{const v=e.find(j=>j.id===y.roleId),b=xs[y.roleId]??"#666";return l.jsxs("button",{onClick:()=>h(y.roleId),className:"flex items-center gap-3 px-4 py-2.5 rounded hover:opacity-80 w-full text-left",style:{background:`${b}10`},children:[l.jsx("div",{className:"shrink-0",style:{width:24,height:24},children:l.jsx($l,{roleId:y.roleId,appearance:d(y.roleId),scale:1.2})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-[12px] font-medium",style:{color:b},children:v==null?void 0:v.name}),l.jsx("span",{className:"text-[11px] ml-2 truncate",style:{color:"var(--terminal-text-muted)"},children:y.task.slice(0,60)})]}),l.jsx("span",{className:"text-[10px] animate-pulse",style:{color:b},children:"●"})]},y.roleId)})}),l.jsx(Su,{title:"Team",count:e.length,children:l.jsx("div",{className:"grid grid-cols-3 gap-1 px-2",children:e.map(y=>{var j;const v=n[y.id]??"offline",b=(j=u[y.id])==null?void 0:j.level;return l.jsxs("button",{onClick:()=>h(y.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:v==="working"?"#4CAF50":v==="idle"?"#FFC107":"#9E9E9E"}}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:y.name}),b!=null&&l.jsxs("span",{className:"text-[9px] opacity-40",children:["Lv.",b]})]},y.id)})})}),i.length>0&&l.jsx(Su,{title:"Recent Waves",count:i.length,children:i.slice(0,5).map(y=>{var v;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 ",y.id]})," — ",(v=y.directive)==null?void 0:v.slice(0,80)]},y.id)})}),l.jsx(Su,{title:"Knowledge Base",count:o.length,children:l.jsxs("button",{onClick:f,className:"px-4 py-3 text-[11px] hover:opacity-80",style:{color:"var(--terminal-text-muted)"},children:[o.length," documents · Click to explore ","→"]})})]})})}function bg({label:e,icon:n,color:a,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:`${a}15`,border:`1px solid ${a}30`},children:[l.jsx("span",{className:"text-sm",children:n}),l.jsx("span",{className:"text-[12px] font-medium",style:{color:a},children:e})]})}function Su({title:e,count:n,children:a}){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()}),n!==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:n})]}),l.jsx("div",{className:"py-1",children:a})]})}const ym=5e4;function Tv(e){return e<ym?1:Math.max(1,Math.floor(Math.sqrt(e/ym)))}function vg(e){return ym*e*e}function x8(e){const n=Tv(e),a=vg(n),i=vg(n+1);return Math.min(1,(e-a)/(i-a))}function qh(e){const n={};for(const[a,i]of Object.entries(e)){const o=i.inputTokens+i.outputTokens;n[a]={level:Tv(o),totalTokens:o,progress:x8(o)}}return n}const y8=[{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(n=>n.level>=3)},{id:"senior-staff",name:"Senior Staff",icon:"🌟",description:"Any role reached Lv.5",check:e=>e.roles.some(n=>n.level>=5)},{id:"master-class",name:"Master Class",icon:"👑",description:"Any role reached Lv.10",check:e=>e.roles.some(n=>n.level>=10)},{id:"full-house",name:"Full House",icon:"🏠",description:"All roles Lv.5+",check:e=>e.roleCount>=3&&e.roles.every(n=>n.level>=5)},{id:"first-launch",name:"First Launch",icon:"🚀",description:"Completed Chapter 2 — gave your first order",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch2-q2"))??!1}},{id:"team-builder",name:"Team Builder",icon:"🏗️",description:"Completed Chapter 4 — dispatched your first wave",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch4-q2"))??!1}},{id:"explorer",name:"Explorer",icon:"🔍",description:"Completed Chapter 5 — customized a character",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch5-q2"))??!1}},{id:"interior-designer",name:"Interior Designer",icon:"🎨",description:"Completed Chapter 7 — bought premium furniture",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch7-q2"))??!1}},{id:"tycoon-master",name:"Tycoon Master",icon:"🎯",description:"Completed all 10 chapters",check:e=>{var n;return((n=e.completedQuests)==null?void 0:n.includes("ch10-q3"))??!1}}];function wg(e){return y8.filter(n=>n.check(e))}const kg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function g8({importJob:e,onImportDone:n}){var tc,nc,rc,_i,ac;const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,h]=w.useState([]),[m,f]=w.useState([]),[x,y]=w.useState([]),[v,b]=w.useState([]),[j,k]=w.useState("TYCONO"),[N,C]=w.useState(!0),[E,R]=w.useState(null),[M,I]=w.useState({type:"none"}),[B,L]=w.useState(null),[H,Q]=w.useState(null),[A,$]=w.useState([]),[U,ee]=w.useState(!1),[oe,ne]=w.useState(!1),[Y,ue]=w.useState([]),[J,K]=w.useState([]),[D,F]=w.useState(0),[q,T]=w.useState(!1),[de,Ne]=w.useState({}),[ye,_e]=w.useState("ceo"),[Pe,Ve]=w.useState(null),[lt,dt]=w.useState(!1),[Ce,We]=w.useState(!1),[Te,xt]=w.useState({}),ut=w.useRef({}),[mt,wt]=w.useState(!1),[qt,$t]=w.useState(null),[Ct,Bn]=w.useState({}),[he,ve]=w.useState([]),ce=w.useMemo(()=>{const _={};for(const G of he)_[G.roleId]=G;return _},[he]),[W,le]=w.useState([]),[we,xe]=w.useState(0),[je,Re]=w.useState(qy()),$e=w.useRef(qy()),Oe=w.useRef(!1),Le=w.useRef(-1),[tt,Ke]=w.useState(null),jt=w.useRef(null),[ze,He]=w.useState(void 0),[Lt,Dt]=w.useState(!1);w.useEffect(()=>{ke.getStatus().then(_=>{He(_.engine),Dt(!!_.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:Rt,setAppearance:sn,resetAppearance:pn,theme:P,setTheme:Be,speechSettings:nt,setSpeechSettings:Pt,language:ge,setLanguage:Z}=v6(),[Me,Ie]=w.useState(null),[,St]=w.useState("character"),Ze=j6(),[Vn,tr]=w.useState(!1),[ia,Hn]=w.useState(!1),[Tn,On]=w.useState(!1),[sa,nl]=w.useState(!1),[Ju,Ns]=w.useState(!1),[Wo,Ea]=w.useState(!1),[Ni,oa]=w.useState(!1),[Un,Ul]=w.useState(null);w.useEffect(()=>{Ze.refresh()},[]),w.useEffect(()=>{const _=G=>{(G.metaKey||G.ctrlKey)&&G.key==="s"&&(G.preventDefault(),tr(!0))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[]),w.useEffect(()=>{if(!sa)return;let _=!1;const G=async()=>{try{const pe=await ke.getGitStatus();_||Ul(pe)}catch{}};G();const se=setInterval(G,1e4);return()=>{_=!0,clearInterval(se)}},[sa]);const[yr,xn]=w.useState(null),[Aa,Da]=w.useState(null),[ir,Ta]=w.useState([]),[rl,Es]=w.useState(!1),As=w.useRef(!1),Ds=w.useRef(null);let ql=w.useRef(0);const Yl=w.useRef(new Set),Wr=w.useRef(Date.now()),wn=(_,G,se)=>{const pe={id:ql.current++,type:_,text:G,detail:se};Ta(Ee=>[...Ee,pe])};w.useEffect(()=>{var _;rl&&((_=Ds.current)==null||_.scrollIntoView({behavior:"smooth"}))},[ir,rl]),w.useEffect(()=>{e&&(As.current||(As.current=!0,Da("Scanning knowledge sources..."),Ta([{id:0,type:"scan",text:"Starting knowledge import..."}]),ql.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 _=>{var Ee;const G=(Ee=_.body)==null?void 0:Ee.getReader();if(!G)return;const se=new TextDecoder;let pe="";for(;;){const{done:Ue,value:Yt}=await G.read();if(Ue)break;pe+=se.decode(Yt,{stream:!0});const ft=pe.split(`
|
|
92
|
+
`);pe=ft.pop()||"";let et="";for(const rt of ft)if(rt.startsWith("event: "))et=rt.slice(7).trim();else if(rt.startsWith("data: ")&&et){try{const pt=JSON.parse(rt.slice(6));switch(et){case"scanning":Da(`Scanning: ${pt.path} (${pt.fileCount} files)`),wn("scan",`Found ${pt.fileCount} files`,pt.path);break;case"processing":xn({index:pt.index,total:pt.total}),Da(`Importing knowledge... (${pt.index}/${pt.total})`),wn("process",`Processing: ${pt.file}`,`${pt.index} / ${pt.total}`);break;case"created":wn("created",pt.title,pt.summary);break;case"skipped":wn("process",`Skipped: ${pt.file}`,pt.reason);break;case"done":Da(null),xn(null),wn("done",`Import complete! ${pt.created} created, ${pt.skipped} skipped.`),yt(`Knowledge import complete! ${pt.created} documents imported.`,"#2E7D32"),n==null||n();break;case"error":Da(null),xn(null),wn("error",pt.message),yt(`Import failed: ${pt.message}`,"#B71C1C"),n==null||n();break}}catch{}et=""}}}).catch(_=>{Da(null),wn("error",_.message),yt(`Import error: ${_.message}`,"#B71C1C"),n==null||n()})))},[e]);const[Gr,ca]=w.useState("iso"),Vr=w.useRef("iso"),[Fr,kn]=w.useState({type:"dashboard"}),[Go,sr]=w.useState(typeof window<"u"?window.innerWidth:1200);w.useEffect(()=>{const _=()=>sr(window.innerWidth);return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const Xl=Go<1024,[gr,ua]=w.useState(!1),[or,Vo]=w.useState(560),[$n,on]=w.useState([]),[da,Ln]=w.useState(null),[Kr,Wl]=w.useState(null),{sendMessage:ed}=y6(),Ei=w.useRef(new Map);w.useEffect(()=>{Promise.all([ke.getCompany().then(_=>{k(_.name),i(_.roles)}),ke.getOrgTree().then(_=>{Ne(_.nodes),_e(_.root)}).catch(()=>{}),ke.getCostSummary().then(_=>Mr(qh(_.byRole))).catch(()=>{})]).catch(_=>R(`Failed to load: ${_.message}`)).finally(()=>C(!1)),ke.getProjects().then(u).catch(()=>{}),ke.getStandups().then(h).catch(()=>{}),ke.getWaves().then(f).catch(()=>{}),ke.getDecisions().then(y).catch(()=>{}),ke.getKnowledge().then(b).catch(()=>{}),ke.getQuestProgress().then(_=>{const G=Yy(_);G.activeChapter!==_.activeChapter&&ke.saveQuestProgress(G).catch(()=>{}),Re(G),$e.current=G,Oe.current=!0,ke.getCoins().then(se=>{var pe;se.totalEarned===0?ke.migrateCoins(((pe=G.completedQuests)==null?void 0:pe.length)??0).then(Ee=>xe(Ee.balance)).catch(()=>{}):xe(se.balance)}).catch(()=>{})}).catch(()=>{Oe.current=!0})},[]),w.useEffect(()=>{if(Le.current===-1){Le.current=o.length;return}o.length>Le.current&&Gt({type:"project_created"}),Le.current=o.length},[o.length]);const Gl=w.useRef(!1);w.useEffect(()=>{if(!(!Oe.current||a.length===0||Gl.current)){Gl.current=!0;for(const _ of a)Gt({type:"role_hired",condition:{roleId:_.id,roleCount:a.length}})}},[a.length]),w.useEffect(()=>{ke.getSessions().then(_=>{if(_.length>0){const G=_.map(pe=>({...pe,messages:[]}));on(G);const se=G.find(pe=>pe.status==="active")??G[0];Ln(se.id),Ma()}}).catch(_=>{console.error("Failed to load sessions",_)})},[]),w.useEffect(()=>{const _=()=>{fetch("/api/exec/status").then(se=>se.json()).then(se=>{Bn(se.statuses??{}),ve(se.activeExecutions??[])}).catch(()=>{})};_();const G=setInterval(_,3e3);return()=>clearInterval(G)},[]);const Kn=w.useMemo(()=>{const _={...Ct};if(Kr){const G=$n.find(se=>se.id===Kr);G&&(_[G.roleId]="working")}return _},[Ct,Kr,$n]);w.useEffect(()=>{M.type==="role"?ke.getRole(M.roleId).then(L).catch(console.error):L(null)},[M]);const Qr=()=>I({type:"none"}),Ai=async(_,G)=>{const se=await ke.updateDecision(_,G);y(pe=>pe.map(Ee=>Ee.id===_?se:Ee))},Fa=async _=>{await ke.deleteDecision(_),y(G=>G.filter(se=>se.id!==_))},jn=_=>{I(_),ua(!1),ne(!1)},Ma=()=>{ua(!0),I({type:"none"}),ne(!1)},al=()=>{ne(!0),ua(!1),I({type:"none"})},Ko=async(_,G)=>{const se=a.find(Ee=>Ee.id===_),pe=(H==null?void 0:H.mode)==="ask";Q(null);try{const Ee=await ke.startJob({type:"assign",roleId:_,task:G,readOnly:pe}),Ue=Ee.jobId,Yt=Ee.sessionId??`job-${Ue}`,ft=kg[_]??"#666",et=`${_.toUpperCase()} · ${(se==null?void 0:se.name)??_}`;T(!1),$([{sessionId:Yt,jobId:Ue,title:et,color:ft}]),Gt({type:"task_executed",condition:{roleId:_}}),Zt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(se==null?void 0:se.name)??_}] ${pe?"Ask":"Assign"}: ${G}`,type:"dispatch",targetRoleId:_})}catch(Ee){yt(`Failed to start job: ${Ee instanceof Error?Ee.message:"unknown"}`,"#C62828")}},Vl=w.useRef(0),yt=(_,G)=>{const se=++Vl.current;le(pe=>[...pe,{id:se,message:_,color:G}]),setTimeout(()=>le(pe=>pe.filter(Ee=>Ee.id!==se)),4e3)},Ts=_=>{jt.current&&clearTimeout(jt.current),Ke(_),jt.current=setTimeout(()=>Ke(null),8e3)},Gt=_=>{if(!Oe.current)return;let G=$e.current;const se=wE(G);let pe=0;const Ee=[];for(const Yt of se){if(!CE(Yt,_))continue;const{progress:ft,quest:et}=jE(G,Yt.id);et&&(G=ft,pe+=et.rewards.coins??0,Ee.push(et.title))}if(Ee.length===0)return;G=Yy(G),$e.current=G,Re(G);const Ue=pe>0?` 💰 +${pe.toLocaleString()}`:"";Ee.length===1?yt(`📋 Quest complete: ${Ee[0]}${Ue}`,"#7C3AED"):yt(`📋 ${Ee.length} quests complete!${Ue}`,"#7C3AED"),Ke(null),ke.saveQuestProgress(G).catch(()=>{}),pe>0&&ke.earnCoins(pe,`quests: ${Ee.length}`,Ee.join(",")).then(Yt=>xe(Yt.balance)).catch(()=>{})};w.useEffect(()=>{if(!tt)return;const _=document.querySelector(`[data-quest-target="${tt}"]`);if(!_)return;_.classList.add("quest-spotlight");const G=()=>{_.classList.remove("quest-spotlight"),Ke(null),jt.current&&clearTimeout(jt.current)};return _.addEventListener("click",G,{once:!0}),()=>{_.classList.remove("quest-spotlight"),_.removeEventListener("click",G)}},[tt]);const Mr=_=>{var se,pe;const G=ut.current;for(const[Ee,Ue]of Object.entries(_)){const Yt=((se=G[Ee])==null?void 0:se.level)??0;if(Yt>0&&Ue.level>Yt){const ft=((pe=a.find(et=>et.id===Ee))==null?void 0:pe.name)??Ee.toUpperCase();yt(`${ft} leveled up to Lv.${Ue.level}!`,"#7C3AED")}}ut.current=_,xt(_)};w.useEffect(()=>{const _={roles:Object.entries(Te).map(([Ee,Ue])=>({id:Ee,level:Ue.level,totalTokens:Ue.totalTokens})),totalTokens:Object.values(Te).reduce((Ee,Ue)=>Ee+Ue.totalTokens,0),roleCount:a.length,completedQuests:je.completedQuests},G=wg(_),se=new Set(G.map(Ee=>Ee.id));if(Date.now()-Wr.current>5e3){const Ee=Yl.current;for(const Ue of G)Ee.has(Ue.id)||yt(`${Ue.icon} Badge earned: ${Ue.name}!`,"#D4A017")}Yl.current=se},[Te,a.length,je.completedQuests]);const Ra=w.useMemo(()=>kE(je),[je]),Di=()=>{var G;const _=A[A.length-1];_&&(yt(`${_.title} completed`,_.color),Zt.pushMessage({ts:Date.now(),roleId:((G=_.title.split(" · ")[0])==null?void 0:G.toLowerCase())??"unknown",text:`[${_.title}] Job completed`,type:"dispatch"})),ke.getStandups().then(h).catch(console.error),ke.getCompany().then(se=>i(se.roles)).catch(console.error),ke.getCostSummary().then(se=>Mr(qh(se.byRole))).catch(()=>{})},Ti=async(_,G,se)=>{ee(!1);try{const pe=await ke.startJob({type:"wave",directive:_,targetRoles:G,...se&&{attachments:se}});Gt({type:"wave_dispatched"});const Ee=pe.jobIds??(pe.jobId?[pe.jobId]:[]),Ue=ye&&de[ye]?de[ye].children.map(_t=>a.find(Jr=>Jr.id===_t)).filter(_t=>!!_t):a.filter(_t=>_t.level==="c-level"),Yt=G?Ue.filter(_t=>G.includes(_t.id)):Ue,ft=pe.waveId??`wave-${Date.now()}`,et=pe.sessionIds??[],rt=Ee.map((_t,Jr)=>{var zs,_s;return{jobId:_t,roleId:((zs=Yt[Jr])==null?void 0:zs.id)??`role-${Jr}`,roleName:((_s=Yt[Jr])==null?void 0:_s.name)??`C-Level ${Jr+1}`,sessionId:et[Jr]??`wave-${_t}`}});Zt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${_}" → ${rt.map(_t=>_t.roleName).join(", ")}`,type:"dispatch"});const pt={id:ft,directive:_,rootJobs:rt,startedAt:Date.now(),sessionIds:et};ue(_t=>[pt,..._t]),al();const Vt=new Date().toISOString(),Ql=et.length>0?rt.map((_t,Jr)=>({id:et[Jr]??`wave-${_t.jobId}`,roleId:_t.roleId,title:`WAVE: ${_t.roleName}`,mode:"do",source:"wave",jobId:_t.jobId,messages:[{id:`msg-wave-${_t.jobId}-ceo`,from:"ceo",content:_,type:"directive",status:"done",timestamp:Vt}],status:"active",createdAt:Vt,updatedAt:Vt})):rt.map(_t=>({id:`wave-${_t.jobId}`,roleId:_t.roleId,title:`WAVE: ${_t.roleName}`,mode:"do",source:"wave",jobId:_t.jobId,messages:[{id:`msg-wave-${_t.jobId}-ceo`,from:"ceo",content:_,type:"directive",status:"done",timestamp:Vt}],status:"active",createdAt:Vt,updatedAt:Vt}));on(_t=>[...Ql,..._t]),Ql.length>0&&(Ln(Ql[0].id),Ma())}catch(pe){yt(`Failed to start wave: ${pe instanceof Error?pe.message:"unknown"}`,"#C62828")}},Rr=()=>{ke.getWaves().then(f).catch(console.error),ke.getStandups().then(h).catch(console.error)},ll=()=>{ke.getCompany().then(_=>i(_.roles)).catch(console.error),ke.getOrgTree().then(_=>{Ne(_.nodes),_e(_.root)}).catch(console.error),ke.getCostSummary().then(_=>Mr(qh(_.byRole))).catch(()=>{})},Qo=async(_,G)=>{await ke.createRole(_),sn(_.id,G),ll(),yt(`${_.name} hired!`,"#2E7D32"),Gt({type:"role_hired",condition:{roleId:_.id,roleCount:a.length+1}})},Qn=async _=>{var G;await ke.deleteRole(_),ll(),on(se=>se.filter(pe=>pe.roleId!==_)),da&&((G=$n.find(se=>se.id===da))==null?void 0:G.roleId)===_&&Ln(null),$t(null),yt(`${_.toUpperCase()} removed`,"#B71C1C")},Pr=async(_,G)=>{await ke.updateRole(_,G),ll(),M.type==="role"&&M.roleId===_&&ke.getRole(_).then(L).catch(console.error),G.name&&yt(`${_.toUpperCase()} renamed to "${G.name}"`,"#1565C0"),G.persona!==void 0&&(yt(`${_.toUpperCase()} persona updated`,"#2E7D32"),Gt({type:"persona_updated"}))},Fi=_=>{Ma(),Gt({type:"terminal_opened"})},il=async _=>{try{const G=await ke.createSession(_,"talk");on(se=>[G,...se]),Ln(G.id),Ma()}catch(G){console.error("Failed to create session",G),yt(`Failed to create session: ${G instanceof Error?G.message:"API unreachable"}`,"#B71C1C")}},Po=async _=>{try{const G=await ke.createSession(_,"talk");on(se=>[G,...se]),Ln(G.id)}catch(G){console.error("Failed to create session",G),yt(`Failed to create session: ${G instanceof Error?G.message:"API unreachable"}`,"#B71C1C")}},Fs=async _=>{const G=ce[_],se=(G==null?void 0:G.jobId)??(G==null?void 0:G.id);if(se&&Kn[_]==="working"){const Ee=a.find(rt=>rt.id===_),Ue=kg[_]??"#666",Yt=`${_.toUpperCase()} · ${(Ee==null?void 0:Ee.name)??_}`,ft=$n.find(rt=>rt.roleId===_&&rt.status==="active"),et=(ft==null?void 0:ft.id)??`job-${se}`;$([{sessionId:et,jobId:se,title:Yt,color:Ue}]),T(!1);return}const pe=$n.find(Ee=>Ee.roleId===_);if(pe)Ln(pe.id),Zt.setActiveChannelId(null);else try{const Ee=await ke.createSession(_,"talk");on(Ue=>[Ee,...Ue]),Ln(Ee.id),Zt.setActiveChannelId(null)}catch(Ee){console.error("Failed to create session",Ee)}Ma()},Mi=async _=>{const G=$n.find(se=>se.id===_);if((G==null?void 0:G.source)==="wave"){if(G.jobId){const se=Ei.current.get(G.jobId);se&&(se.abort(),Ei.current.delete(G.jobId))}on(se=>{var Ee;const pe=se.filter(Ue=>Ue.id!==_);return da===_&&Ln(((Ee=pe[0])==null?void 0:Ee.id)??null),pe});return}try{await ke.deleteSession(_),on(se=>{var Ee;const pe=se.filter(Ue=>Ue.id!==_);return da===_&&Ln(((Ee=pe[0])==null?void 0:Ee.id)??null),pe})}catch(se){console.error("Failed to delete session",se),yt(`Failed to close session: ${se instanceof Error?se.message:"API error"}`,"#B71C1C")}},sl=async()=>{try{const{ids:_}=await ke.deleteEmptySessions();if(_.length===0)return;on(G=>{var pe;const se=G.filter(Ee=>!_.includes(Ee.id));return da&&_.includes(da)&&Ln(((pe=se[0])==null?void 0:pe.id)??null),se}),yt(`Cleared ${_.length} empty session${_.length!==1?"s":""}`,"#2E7D32")}catch(_){yt(`Failed to clear empty sessions: ${_ instanceof Error?_.message:"API error"}`,"#B71C1C")}},Kl=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const _=$n.filter(G=>G.source!=="wave").map(G=>G.id);for(const G of $n)if(G.source==="wave"&&G.jobId){const se=Ei.current.get(G.jobId);se&&(se.abort(),Ei.current.delete(G.jobId))}try{_.length>0&&await ke.deleteSessions(_),on([]),Ln(null),yt("All sessions closed","#2E7D32")}catch(G){yt(`Failed to close sessions: ${G instanceof Error?G.message:"API error"}`,"#B71C1C")}},Zr=(_,G)=>{on(se=>se.map(pe=>{if(pe.id!==_)return pe;const Ee=[...pe.messages],Ue=Ee[Ee.length-1];if(Ue&&Ue.from==="role"&&Ue.status==="streaming"){const Yt=[...Ue.streamEvents??[],G];Ee[Ee.length-1]={...Ue,streamEvents:Yt}}return{...pe,messages:Ee}}))},za=(_,G,se,pe)=>{const Ee={id:`msg-${Date.now()}-ceo`,from:"ceo",content:G,type:se==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:pe},Ue={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};on(ft=>ft.map(et=>et.id===_?{...et,messages:[...et.messages,Ee,Ue],updatedAt:new Date().toISOString()}:et));const Yt=$n.find(ft=>ft.id===_);se==="talk"?Gt({type:"talk_mode_used"}):se==="do"&&(Gt({type:"do_mode_used"}),Yt&&Gt({type:"task_executed",condition:{roleId:Yt.roleId}})),Wl(_),ed(_,G,se,{onThinking:ft=>{on(et=>et.map(rt=>{if(rt.id!==_)return rt;const pt=[...rt.messages],Vt=pt[pt.length-1];return Vt&&Vt.from==="role"&&Vt.status==="streaming"&&(pt[pt.length-1]={...Vt,thinking:(Vt.thinking??"")+ft}),{...rt,messages:pt}})),Zr(_,{type:"thinking",timestamp:Date.now(),text:ft})},onText:ft=>{on(et=>et.map(rt=>{if(rt.id!==_)return rt;const pt=[...rt.messages],Vt=pt[pt.length-1];return Vt&&Vt.from==="role"&&Vt.status==="streaming"&&(pt[pt.length-1]={...Vt,content:Vt.content+ft}),{...rt,messages:pt}}))},onToolUse:(ft,et)=>{Zr(_,{type:"tool",timestamp:Date.now(),toolName:ft,toolInput:et})},onDispatch:(ft,et)=>{Zr(_,{type:"dispatch",timestamp:Date.now(),roleId:ft,task:et})},onDispatchProgress:(ft,et,rt)=>{var pt;et==="tool"?Zr(_,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"tool",toolName:rt.name,toolInput:rt.input}):et==="thinking"?Zr(_,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"thinking",text:rt.text}):et==="text"?Zr(_,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"text",text:(pt=rt.text)==null?void 0:pt.slice(-200)}):(et==="done"||et==="error")&&Zr(_,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:et})},onTurn:ft=>{Zr(_,{type:"turn",timestamp:Date.now(),turn:ft})},onDone:()=>{on(ft=>ft.map(et=>{if(et.id!==_)return et;const rt=et.messages.map(Vt=>Vt.status==="streaming"?{...Vt,status:"done"}:Vt),pt=et.messages.length<=2?G.slice(0,40).replace(/\n/g," "):et.title;return{...et,messages:rt,title:pt}})),Wl(null)},onError:ft=>{on(et=>et.map(rt=>{if(rt.id!==_)return rt;const pt=rt.messages.map(Vt=>Vt.status==="streaming"?{...Vt,status:"error",content:Vt.content||ft}:Vt);return{...rt,messages:pt}})),Wl(null)}},pe)},Ms=(_,G)=>{on(se=>se.map(pe=>pe.id===_?{...pe,mode:G}:pe)),ke.updateSession(_,{mode:G}).catch(console.error)},td=new Date().toISOString().slice(0,10),Ri=o[0],Zo={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},nd=_=>{const G=Zo[_];if(!G)return"";for(const se of d){const pe=se.content,Ee=pe.indexOf(`## ${G}`);if(Ee===-1)continue;const Ue=pe.indexOf(`
|
|
93
|
+
## `,Ee+10),ft=(Ue===-1?pe.slice(Ee):pe.slice(Ee,Ue)).split(`
|
|
94
|
+
`).filter(et=>et.trim().length>0);for(const et of ft){const rt=et.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(rt.startsWith("|")||rt.startsWith("{")||rt.startsWith("[")||rt.startsWith("```")||rt.startsWith("---")||rt.includes("Journal")||rt.includes("(c-level)")||rt.includes("(team-lead)")||rt.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(rt))&&rt.length>15&&rt.length<120)return rt}}return""},Jo=_=>{const G=Zo[_];if(!G)return"";for(const se of d){const pe=se.content,Ee=pe.indexOf(`## ${G}`);if(Ee===-1)continue;const Ue=pe.indexOf(`
|
|
95
|
+
## `,Ee+10),ft=(Ue===-1?pe.slice(Ee):pe.slice(Ee,Ue)).replace(/^## .+\n/,"").trim();if(ft)return ft.slice(0,1500)}return""},Zt=O6();w.useEffect(()=>{a.length>0&&Zt.syncDefaultMembers(a)},[a]);const zi=M6({roles:a,roleStatuses:Ct,activeExecs:he,getStandupSpeech:nd}),Rs=H6({roles:a,roleStatuses:Ct,activeExecs:he,channels:Zt.channels,relationships:zi.relationships,pushMessage:Zt.pushMessage,speechSettings:nt,engineType:ze,hasApiKey:Lt}),ec=w.useCallback((_,G)=>{Zt.pushMessage({ts:Date.now(),roleId:"ceo",text:G,type:"chat",channelId:_}),Rs.triggerCeoReaction(_)},[Zt,Rs]);return N?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(Aa||ir.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:()=>Es(_=>!_),children:[Aa?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:Aa||"Knowledge import finished"}),yr&&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:`${yr.index/yr.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:rl?"▲":"▼"})]}),rl&&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:[ir.map(_=>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:[_.type==="scan"&&"🔍",_.type==="process"&&"⚙️",_.type==="created"&&"✅",_.type==="done"&&"🎉",_.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:_.type==="error"?"#EF4444":_.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:_.text}),_.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:_.detail})]})]},_.id)),l.jsx("div",{ref:Ds})]})]}),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:j})]}),l.jsxs("div",{className:"flex gap-4 text-[11px] items-center",style:{color:"var(--bar-text, var(--terminal-text-secondary))"},children:[(()=>{const _=we>=1e6?`${(we/1e6).toFixed(1)}M`:we>=1e3?`${(we/1e3).toFixed(1)}K`:String(we),G=he.length,se=a.length>0?Math.round(G/a.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:_})]}),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:`${se}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:se})]})]})})(),l.jsxs("span",{className:"hidden sm:inline",children:["Roles: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:a.length})]}),l.jsxs("span",{className:"hidden sm:inline",children:["Projects: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:o.length})]}),he.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:he.length})]}),(()=>{const _={roles:Object.entries(Te).map(([se,pe])=>({id:se,level:pe.level,totalTokens:pe.totalTokens})),totalTokens:Object.values(Te).reduce((se,pe)=>se+pe.totalTokens,0),roleCount:a.length},G=wg(_);return G.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:G.map(se=>l.jsx("span",{title:`${se.name}: ${se.description}`,style:{fontSize:12,cursor:"default"},children:se.icon},se.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:td})]})]}),(Aa||ir.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:()=>Es(_=>!_),children:[Aa?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:Aa||"Knowledge import finished"}),yr&&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:`${yr.index/yr.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:rl?"▲":"▼"})]}),rl&&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:[ir.map(_=>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:[_.type==="scan"&&"🔍",_.type==="process"&&"⚙️",_.type==="created"&&"✅",_.type==="done"&&"🎉",_.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:_.type==="error"?"#EF4444":_.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:_.text}),_.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:_.detail})]})]},_.id)),l.jsx("div",{ref:Ds}),ir.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(PA,{roles:a,projects:o,waves:m,standups:d,decisions:x,roleStatuses:Kn,activeExecs:he,onRoleClick:_=>jn({type:"role",roleId:_}),onProjectClick:_=>jn({type:"project",projectId:_}),onBulletinClick:()=>{jn({type:"bulletin"}),Gt({type:"bulletin_visited"})},onDecisionsClick:()=>jn({type:"decisions"}),onKnowledgeClick:()=>{jn({type:"knowledge"}),Gt({type:"knowledge_visited"})},onSettingsClick:()=>{Ea(!0),Gt({type:"settings_visited"})},onThemeClick:()=>oa(_=>!_),onStatsClick:()=>{Hn(!0),Gt({type:"stats_visited"})},knowledgeDocsCount:v.length,getRoleSpeech:zi.getSpeech,getAppearance:Rt,onHireClick:()=>wt(!0),onMascotClick:()=>jn({type:"quest"}),roleLevels:Te,language:ge,coinBalance:we,onCoinsSpent:_=>xe(_),onFurniturePlaced:(_,G)=>{Gt({type:"furniture_placed"}),G>0&&Gt({type:"furniture_purchased"})}})}),gr&&l.jsx("div",{className:Xl?"absolute inset-0 z-50":"contents",children:l.jsx(Qy,{sessions:$n,activeSessionId:da,roles:a,streamingSessionId:Kr,width:Xl?Go:or,onWidthChange:Xl?void 0:Vo,onSwitchSession:Ln,onCloseSession:Mi,onCreateSession:il,onClearEmpty:sl,onCloseAll:Kl,onSendMessage:za,onModeChange:Ms,onCloseTerminal:()=>ua(!1),onMaximize:()=>{Vr.current="iso",kn({type:"terminal"}),ca("pro")},chatChannels:Zt.channels,activeChatChannelId:Zt.activeChannelId,onSwitchChatChannel:Zt.setActiveChannelId,onCreateChatChannel:(..._)=>{const G=Zt.createChannel(..._);return Gt({type:"chat_channel_created"}),G},onDeleteChatChannel:Zt.deleteChannel,onUpdateChatMembers:Zt.updateMembers,onUpdateChatTopic:Zt.updateTopic,onSendChatMessage:ec,unreadChannels:Zt.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:()=>ca("iso"),className:`view-toggle-btn ${Gr==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{Vr.current="iso",ca("pro")},className:`view-toggle-btn ${Gr==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${Ni?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>oa(_=>!_),title:"Office Theme",children:[((tc=el[P])==null?void 0:tc.icon)??"","▾"]}),Ni&&l.jsx(d8,{theme:P,onThemeChange:_=>{Be(_),Gt({type:"theme_changed"})},onClose:()=>oa(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>Ea(!0),title:"Settings",children:"⚙"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("button",{"data-quest-target":"save-btn",onClick:()=>{Ze.state==="no-git"||Ze.state==="dirty"?tr(!0):nl(!0)},title:Ze.state==="dirty"?`${Ze.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:Ze.state==="no-git"?"var(--terminal-text-muted)":Ze.state==="saving"||Ze.state==="dirty"?"var(--idle-amber)":Ze.state==="error"?"#EF5350":"var(--active-green)",animation:Ze.state==="saving"?"pulse 1s infinite":void 0}}),l.jsx("span",{style:{color:Ze.state==="dirty"?"var(--idle-amber)":"var(--bar-text, var(--terminal-text-muted))"},children:Ze.state==="no-git"?"No git":Ze.state==="saving"?"Saving...":Ze.state==="dirty"?`${Ze.dirtyCount} unsaved`:"Saved"}),Un&&(Un.worktrees.length>0||Un.staleBranches.length>0)&&l.jsxs("span",{style:{color:Un.worktrees.some(_=>_.status==="stale")?"#ff6b6b":Un.worktrees.some(_=>_.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["·"," ","📂"," ",Un.worktrees.length," worktree",Un.worktrees.length!==1?"s":"",Un.staleBranches.length>0&&` · ⚠ ${Un.staleBranches.length} branch${Un.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[Y.length>0&&!oe&&l.jsx("button",{onClick:()=>al(),className:`px-3 py-1 font-black text-white cursor-pointer ${Ce?"":"animate-pulse"}`,style:{background:Ce?"#2E7D32":"#B71C1C",border:`2px solid ${Ce?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Ce?"WAVE DONE":`WAVE (${Y.length})`}),Pe&<&&Y.length===0&&l.jsx("button",{onClick:()=>dt(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${Ce?"":"animate-pulse"}`,style:{background:Ce?"#2E7D32":"#B71C1C",border:`2px solid ${Ce?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Ce?"WAVE DONE":"WAVE"}),A.length>0&&q&&l.jsxs("button",{onClick:()=>T(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:A[A.length-1].color,border:`2px solid ${A[A.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[A[A.length-1].title.slice(0,20),A[A.length-1].title.length>20?"..":""]}),l.jsxs("button",{onClick:()=>al(),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:()=>gr?ua(!1):Fi(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:gr?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${gr?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),Gr!=="pro"&&M.type==="role"&&B&&(()=>{var G,se;const _=ce[B.id];return l.jsx(Ay,{role:B,allRoles:a,recentActivity:Jo(B.id),onClose:Qr,onFireRole:(pe,Ee)=>{$t({roleId:pe,roleName:Ee}),Qr()},terminalWidth:gr?or:0,activeJobId:_==null?void 0:_.id,activeSessionId:(G=A.find(pe=>pe.jobId===(_==null?void 0:_.jobId)))==null?void 0:G.sessionId,activeTask:_==null?void 0:_.task,isWorking:Kn[B.id]==="working",jobStartedAt:_==null?void 0:_.startedAt,onStopJob:pe=>{const Ee=A.find(Ue=>Ue.jobId===pe);Ee&&ke.abortSession(Ee.sessionId)},sessions:$n,streamingSessionId:Kr,onCreateSessionSilent:Po,onSendMessage:za,onFocusTerminal:Fs,onCustomize:pe=>{const Ee=a.find(Ue=>Ue.id===pe);Ee&&(St("character"),Ie(Ee))},onUpdateRole:Pr,appearance:Rt(B.id),relationships:zi.relationships,roleLevel:(se=Te[B.id])==null?void 0:se.level,onMaximize:()=>{Vr.current="iso",kn({type:"role",roleId:B.id}),ca("pro")}})})(),Gr!=="pro"&&M.type==="project"&&Ri&&l.jsx(EE,{projectId:Ri.id,onClose:Qr,terminalWidth:gr?or:0}),Gr!=="pro"&&(M.type==="bulletin"||M.type==="decisions")&&l.jsx(Uy,{standups:d,waves:m,decisions:x,mode:M.type==="bulletin"?"bulletin":"decisions",onClose:Qr,onOpenWaveCenter:()=>al(),onUpdateDecision:Ai,onDeleteDecision:Fa,terminalWidth:gr?or:0,onMaximize:()=>{Vr.current="iso",kn({type:"operations"}),ca("pro")}}),Gr!=="pro"&&M.type==="quest"&&l.jsx(NE,{progress:je,onClose:Qr,terminalWidth:gr?or:0,onQuestAction:_=>{var se;Qr();const G=Si.find(pe=>pe.id===_);(se=G==null?void 0:G.hint)!=null&&se.target&&Ts(G.hint.target)}}),Gr!=="pro"&&M.type==="knowledge"&&l.jsx(Hy,{docs:v,onClose:Qr,onRefresh:()=>ke.getKnowledge().then(b).catch(()=>{}),terminalWidth:gr?or:0,initialDocId:M.docId,onMaximize:()=>{Vr.current="iso",kn({type:"knowledge"}),ca("pro")}}),Gr==="pro"&&l.jsxs(f8,{roles:a,roleStatuses:Kn,activeExecs:he,waves:m,knowledgeDocs:v,sessions:$n,roleLevels:Te,companyName:j,getAppearance:Rt,waveCenterWaves:Y,renderProfile:Fr.type==="role"&&B?_=>{var se,pe;const G=ce[B.id];return l.jsx(Ay,{role:B,allRoles:a,recentActivity:Jo(B.id),onClose:_,onFireRole:(Ee,Ue)=>{$t({roleId:Ee,roleName:Ue})},terminalWidth:0,activeJobId:G==null?void 0:G.id,activeSessionId:(se=A.find(Ee=>Ee.jobId===(G==null?void 0:G.jobId)))==null?void 0:se.sessionId,activeTask:G==null?void 0:G.task,isWorking:Kn[B.id]==="working",jobStartedAt:G==null?void 0:G.startedAt,onStopJob:Ee=>{const Ue=A.find(Yt=>Yt.jobId===Ee);Ue&&ke.abortSession(Ue.sessionId)},sessions:$n,streamingSessionId:Kr,onCreateSessionSilent:Po,onSendMessage:za,onFocusTerminal:()=>{},onCustomize:Ee=>{const Ue=a.find(Yt=>Yt.id===Ee);Ue&&(St("character"),Ie(Ue))},onUpdateRole:Pr,appearance:Rt(B.id),relationships:zi.relationships,roleLevel:(pe=Te[B.id])==null?void 0:pe.level})}:void 0,channel:Fr,onChannelChange:_=>{kn(_),_.type==="role"?jn({type:"role",roleId:_.roleId}):_.type==="knowledge"?jn({type:"knowledge"}):_.type==="operations"?jn({type:"bulletin"}):_.type==="wave"?ne(!0):_.type==="terminal"?ua(!0):(I({type:"none"}),ne(!1))},onClose:()=>{ca(Vr.current),I({type:"none"}),ne(!1)},children:[Fr.type==="dashboard"&&l.jsx(p8,{roles:a,roleStatuses:Kn,activeExecs:he,waves:m,knowledgeDocs:v,roleLevels:Te,getAppearance:Rt,onRoleClick:_=>kn({type:"role",roleId:_}),onWaveClick:()=>kn({type:"wave"}),onKnowledgeClick:()=>kn({type:"knowledge"})}),Fr.type==="terminal"&&l.jsx(Qy,{sessions:$n,activeSessionId:da,roles:a,streamingSessionId:Kr,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:Ln,onCloseSession:Mi,onCreateSession:il,onClearEmpty:sl,onCloseAll:Kl,onSendMessage:za,onModeChange:Ms,onCloseTerminal:()=>kn({type:"dashboard"}),chatChannels:Zt.channels,activeChatChannelId:Zt.activeChannelId,onSwitchChatChannel:Zt.setActiveChannelId,onCreateChatChannel:(..._)=>{const G=Zt.createChannel(..._);return Gt({type:"chat_channel_created"}),G},onDeleteChatChannel:Zt.deleteChannel,onUpdateChatMembers:Zt.updateMembers,onUpdateChatTopic:Zt.updateTopic,onSendChatMessage:ec,unreadChannels:Zt.unreadChannels}),Fr.type==="wave"&&l.jsx(Vy,{orgNodes:de,rootRoleId:ye,cLevelRoles:ye&&de[ye]?de[ye].children.map(_=>a.find(G=>G.id===_)).filter(_=>!!_):a.filter(_=>_.level==="c-level"),pastWaves:m,activeWaves:Y,onDispatch:(_,G)=>Ti(_,G),onClose:()=>kn({type:"dashboard"}),onDone:()=>{Rr(),We(!0),yt("Wave complete","#2E7D32")},onSave:async(_,G,se)=>{try{await ke.saveWave({directive:_,jobIds:G,waveId:se==null?void 0:se.waveId,sessionIds:se==null?void 0:se.sessionIds}),Rr(),yt("Wave saved","#2E7D32")}catch(pe){yt(`Save failed: ${pe instanceof Error?pe.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:_=>{kn({type:"knowledge"}),jn({type:"knowledge",docId:_}),ke.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ke.getWaves().then(f).catch(()=>{}),terminalWidth:0,inline:!0,onOpenSaveModal:()=>tr(!0)}),Fr.type==="knowledge"&&l.jsx(Hy,{docs:v,onClose:()=>kn({type:"dashboard"}),onRefresh:()=>ke.getKnowledge().then(b).catch(()=>{}),terminalWidth:0}),Fr.type==="operations"&&l.jsx(Uy,{standups:d,waves:m,decisions:x,mode:"bulletin",onClose:()=>kn({type:"dashboard"}),onOpenWaveCenter:()=>kn({type:"wave"}),onUpdateDecision:Ai,onDeleteDecision:Fa,terminalWidth:0}),Fr.type==="role"&&(()=>{const _=Fr.roleId,G=a.find(pe=>pe.id===_);if(!G)return null;const se=$n.find(pe=>pe.roleId===_);return se?l.jsx(h8,{role:G,messages:se.messages,isStreaming:Kr===se.id,mode:se.mode,onModeChange:pe=>Ms(se.id,pe),onSend:(pe,Ee,Ue)=>za(se.id,pe,Ee,Ue),isWave:se.source==="wave"}):l.jsx(m8,{role:G,getAppearance:Rt,onSend:async(pe,Ee)=>{try{const Ue=await ke.createSession(_,"talk");on(Yt=>[Ue,...Yt]),Ln(Ue.id),za(Ue.id,pe,Ee)}catch(Ue){yt(`Failed to create session: ${Ue instanceof Error?Ue.message:"API unreachable"}`,"#B71C1C")}}})})()]}),H&&l.jsx(TE,{roleId:H.roleId,roleName:H.roleName,mode:H.mode,onClose:()=>Q(null),onExecutionStart:Ko}),Pe&&!lt&&l.jsx($E,{directive:Pe.directive,rootJobs:Pe.rootJobs,orgNodes:de,rootRoleId:ye,onClose:()=>{Ve(null),dt(!1),We(!1)},onMinimize:()=>dt(!0),onDone:()=>{Rr(),We(!0),yt("Wave complete","#2E7D32")},onSave:async _=>{try{await ke.saveWave({directive:Pe.directive,jobIds:_}),Rr(),yt("Wave saved to bulletin","#2E7D32")}catch(G){yt(`Save failed: ${G instanceof Error?G.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:_=>{Ve(null),dt(!1),We(!1),jn({type:"knowledge",docId:_}),ke.getKnowledge().then(b).catch(()=>{})}}),oe&&l.jsx(Vy,{orgNodes:de,rootRoleId:ye,cLevelRoles:ye&&de[ye]?de[ye].children.map(_=>a.find(G=>G.id===_)).filter(_=>!!_):a.filter(_=>_.level==="c-level"),pastWaves:m,activeWaves:Y,onDispatch:(_,G)=>Ti(_,G),onClose:()=>ne(!1),onMaximize:()=>{Vr.current="iso",kn({type:"wave"}),ca("pro")},onDone:()=>{Rr(),We(!0),yt("Wave complete","#2E7D32")},onSave:async(_,G,se)=>{try{await ke.saveWave({directive:_,jobIds:G,waveId:se==null?void 0:se.waveId,sessionIds:se==null?void 0:se.sessionIds}),Rr(),yt("Wave saved","#2E7D32")}catch(pe){yt(`Save failed: ${pe instanceof Error?pe.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:_=>{ne(!1),jn({type:"knowledge",docId:_}),ke.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ke.getWaves().then(f).catch(()=>{}),terminalWidth:gr?or:0,onOpenSaveModal:()=>tr(!0)}),A.length>0&&!q&&(()=>{var se;const _=A[A.length-1],G=J.length>1;return l.jsxs(l.Fragment,{children:[G&&A.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:J.map((pe,Ee)=>l.jsx("button",{onClick:()=>{F(Ee),$([{sessionId:pe.sessionId,jobId:pe.jobId??"",title:`CEO WAVE · ${pe.roleId.toUpperCase()}`,color:"#B71C1C"}])},className:"px-3 py-1.5 text-xs font-bold rounded-t-lg cursor-pointer transition-colors",style:{background:D===Ee?"#B71C1C":"var(--terminal-bg)",color:D===Ee?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${D===Ee?"#B71C1C":"var(--terminal-border)"}`,borderBottom:"none"},children:pe.roleId.toUpperCase()},pe.sessionId))}),l.jsx(FE,{sessionId:_.sessionId,title:A.length>1?_.title:G?`CEO WAVE · ${((se=J[D])==null?void 0:se.roleName)??""}`:_.title,color:_.color,variant:"modal",style:G&&A.length===1?{marginTop:28}:void 0,onClose:()=>{$([]),K([]),F(0),T(!1)},onMinimize:()=>T(!0),onDone:()=>{Di(),Rr()},onNavigateToJob:()=>{},onOpenKnowledgeDoc:pe=>{$([]),K([]),F(0),T(!1),jn({type:"knowledge",docId:pe}),ke.getKnowledge().then(b).catch(()=>{})}},_.sessionId)]})})(),A.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:()=>$(_=>_.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 ",(nc=A[A.length-2])==null?void 0:nc.title]})})}),U&&l.jsx(_E,{cLevelRoles:ye&&de[ye]?de[ye].children.map(_=>a.find(G=>G.id===_)).filter(_=>!!_):a.filter(_=>_.level==="c-level"),orgNodes:de,rootId:ye,onClose:()=>ee(!1),onDispatch:(_,G)=>Ti(_,G)}),mt&&l.jsx(VE,{existingRoles:a,onClose:()=>wt(!1),onHire:Qo,onStoreVisit:()=>Gt({type:"store_visited"}),questHint:((rc=Ra==null?void 0:Ra.hint)==null?void 0:rc.target)==="hire-btn"?{message:Ra.description,roleId:((_i=Ra.trigger.condition)==null?void 0:_i.roleId)??void 0}:void 0}),qt&&l.jsx(PE,{roleId:qt.roleId,roleName:qt.roleName,onClose:()=>$t(null),onConfirm:Qn}),Me&&l.jsx(ZA,{role:Me,appearance:Rt(Me.id),onSave:_=>{sn(Me.id,_),Gt({type:"accessory_changed"})},onReset:()=>pn(Me.id),onClose:()=>{Ie(null),St("character")},theme:P,onThemeChange:_=>{Be(_),Gt({type:"theme_changed"})},onUpdateName:async(_,G)=>{await Pr(_,{name:G})},initialTab:"character",characterOnly:!0,speechSettings:nt,onSpeechSettingsChange:Pt,language:ge,onLanguageChange:Z,roleLevel:(ac=Te[Me.id])==null?void 0:ac.level}),Vn&&(()=>{const _=a.find(G=>G.id==="cto")??a.find(G=>G.level==="c-level")??a[0];return l.jsx(t8,{status:Ze.status,history:Ze.history,onClose:()=>tr(!1),onSave:async G=>{const se=await Ze.save(G);return se!=null&&se.ok&&Gt({type:"save_committed"}),se},onLoadHistory:Ze.loadHistory,onRestore:Ze.restore,saving:Ze.state==="saving",repo:Ze.repo,onRepoChange:Ze.setRepo,syncInfo:Ze.syncInfo,onPull:Ze.pull,pulling:Ze.pulling,onRefresh:Ze.refresh,onInitGit:Ze.initGit,delegateRoleName:(_==null?void 0:_.name)??(_==null?void 0:_.id),onDelegate:_?async G=>{tr(!1);try{const se=await ke.createSession(_.id,"do");on(Ee=>[se,...Ee]),Ln(se.id),Ma();const pe=`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.
|
|
96
|
+
|
|
97
|
+
Changed files:
|
|
98
|
+
${G}`;za(se.id,pe,"do")}catch(se){yt(`Failed to delegate: ${se instanceof Error?se.message:"error"}`,"#B71C1C")}}:void 0})})(),ia&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Hn(!1),children:l.jsx("div",{style:{width:420,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8},onClick:_=>_.stopPropagation(),children:l.jsx(n8,{onClose:()=>Hn(!1)})})}),Tn&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>On(!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:_=>_.stopPropagation(),children:l.jsx(l8,{onClose:()=>On(!1),onSyncComplete:()=>{}})})}),Wo&&l.jsx(u8,{onClose:()=>Ea(!1),speechSettings:nt,onSpeechSettingsChange:Pt,language:ge,onLanguageChange:Z,onOpenSync:()=>On(!0),onOpenGitStatus:()=>nl(!0),onOpenSessions:()=>Ns(!0),onOpenStats:()=>Hn(!0)}),sa&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>nl(!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:_=>_.stopPropagation(),children:l.jsx(i8,{onClose:()=>nl(!1)})})}),Ju&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ns(!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:_=>_.stopPropagation(),children:l.jsx(s8,{onClose:()=>Ns(!1)})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:W.map(_=>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:_.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"}),_.message]},_.id))})]})}function Cu({onSelect:e,onClose:n}){const[a,i]=w.useState(null),[o,u]=w.useState(!0),[d,h]=w.useState(""),[m,f]=w.useState(!1),[x,y]=w.useState(!1),v=w.useRef(null),b=w.useCallback(async k=>{u(!0);try{const N=await ke.browse(k);i(N)}catch{}finally{u(!1)}},[]);w.useEffect(()=>{b()},[b]),w.useEffect(()=>{var k;m&&((k=v.current)==null||k.focus())},[m]);const j=async()=>{if(!(!a||!d.trim())){y(!0);try{const k=await ke.mkdir(a.current,d.trim());k.ok&&(h(""),f(!1),await b(k.path))}catch{}finally{y(!1)}}};return o&&!a?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..."}):a?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:a.current}),l.jsx("button",{onClick:()=>{f(!m),h("")},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(a.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:n,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:v,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:d,onChange:k=>h(k.target.value),onKeyDown:k=>{k.key==="Enter"&&j(),k.key==="Escape"&&f(!1)}}),l.jsx("button",{onClick:j,disabled:x||!d.trim(),className:"px-2 py-1 rounded text-[10px] font-medium shrink-0 cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:x||!d.trim()?.5:1},children:x?"...":"Create"})]}),a.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:()=>b(a.parent),children:[l.jsx("span",{children:"⬆️"}),l.jsx("span",{children:".."})]}),a.dirs.map(k=>l.jsxs("div",{className:"px-3 py-1.5 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)]",style:{color:"var(--terminal-text)"},onClick:()=>b(k.path),children:[l.jsx("span",{children:"📁"}),l.jsx("span",{children:k.name})]},k.path)),a.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 b8={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function jg(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function v8({onComplete:e}){const[n,a]=w.useState(0),[i,o]=w.useState(null),[u,d]=w.useState("none"),[h,m]=w.useState(""),[f,x]=w.useState(!0),[y,v]=w.useState(""),[b,j]=w.useState(""),[k,N]=w.useState("en"),C=w.useRef(null),[E,R]=w.useState("new"),[M,I]=w.useState(""),[B,L]=w.useState(""),[H,Q]=w.useState(!1),[A,$]=w.useState(!1),[U,ee]=w.useState(!1),[oe,ne]=w.useState(""),[Y,ue]=w.useState(!1),[J,K]=w.useState(!1),[D,F]=w.useState([]),[q,T]=w.useState(""),[de,Ne]=w.useState(!1),[ye,_e]=w.useState(""),[Pe,Ve]=w.useState(null),[lt,dt]=w.useState(!1),[Ce,We]=w.useState(!1),[Te,xt]=w.useState([]),[ut,mt]=w.useState("startup"),[wt,qt]=w.useState(!1),[$t,Ct]=w.useState(!1),[Bn,he]=w.useState(null),[ve,ce]=w.useState([]),[W,le]=w.useState(""),[we,xe]=w.useState(!1),[je,Re]=w.useState(!1),[$e,Oe]=w.useState([]),Le=w.useMemo(()=>jg(E),[E]),tt=Le[n]??"engine";w.useEffect(()=>{ke.detectEngine().then(ge=>{o(ge),d(ge.recommended),x(!1)}).catch(()=>x(!1)),ke.getTeams().then(xt).catch(()=>{}),ke.getStatus().then(ge=>{L(ge.companyRoot||"")}).catch(()=>{})},[]),w.useEffect(()=>{var ge;tt==="company"&&((ge=C.current)==null||ge.focus())},[tt]),w.useEffect(()=>{if(H||!B)return;const ge=y.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");I(ge?`${B}/${ge}`:B)},[y,B,H]);const Ke=()=>{switch(tt){case"engine":return u!=="none"||h.length>10;case"company":return y.trim().length>0;case"workspace":return E==="existing-akb"?Pe===!0:!0;case"team":return!0;case"create":return!$t;default:return!1}},jt=()=>{n<Le.length-1&&Ke()&&a(n+1),tt==="create"&&!wt&&!we&&(E==="existing-akb"?pn():sn())},ze=()=>{n>0&&a(n-1)},He=w.useRef(E);w.useEffect(()=>{if(He.current===E)return;He.current=E;const Z=jg(E).indexOf("workspace");Z>=0&&a(Z)},[E]);const Lt=async()=>{if(ye.trim()){dt(!0);try{const ge=await ke.validatePath(ye.trim());Ve(ge.valid&&ge.hasClaudeMd===!0)}catch{Ve(!1)}finally{dt(!1)}}},Dt=()=>{const ge=q.trim();ge&&!D.includes(ge)&&(F([...D,ge]),T(""))},Rt=async ge=>{Re(!0),Oe([]);try{const{tools:Z}=await ke.getRequiredTools(ge);if(Z.filter(Ie=>!Ie.installed).length===0){Re(!1);return}await ke.installTools(ge,(Ie,St)=>{const Ze=St.tool||"";Ie==="checking"?Oe(Vn=>[...Vn,{event:Ie,tool:Ze,detail:"checking..."}]):Ie==="installing"?Oe(Vn=>[...Vn,{event:Ie,tool:Ze,detail:"installing..."}]):Ie==="installed"?Oe(Vn=>[...Vn,{event:Ie,tool:Ze,detail:"installed"}]):Ie==="skipped"?Oe(Vn=>[...Vn,{event:Ie,tool:Ze,detail:St.reason||"skipped"}]):Ie==="error"&&Oe(Vn=>[...Vn,{event:Ie,tool:Ze,detail:St.error||"failed"}])})}catch{}finally{Re(!1)}},sn=async()=>{qt(!0),he(null);try{const ge={companyName:y.trim(),description:b.trim()||"An AI-powered organization",team:ut,knowledgePaths:D.length>0?D:void 0,language:k!=="auto"?k:void 0,location:M.trim()||void 0,codeRoot:oe.trim()||void 0};(u==="direct-api"||h)&&(ge.apiKey=h||void 0);const Z=await ke.scaffold(ge);ce(Z.created),le(Z.projectRoot),Ct(!0),qt(!1),ut!=="custom"&&Rt(ut)}catch(ge){he(ge instanceof Error?ge.message:"Scaffold failed"),qt(!1)}},pn=async()=>{xe(!0),he(null);try{const ge=await ke.connectAkb(ye.trim());ge.ok?(Ct(!0),ce([`Connected to: ${ge.companyRoot}`])):he(ge.error||"Failed to connect")}catch(ge){he(ge instanceof Error?ge.message:"Connect failed")}finally{xe(!1)}},P=()=>{D.length>0?e({paths:D,companyRoot:""}):e()},Be=ge=>{ge.key==="Enter"&&Ke()&&(ge.preventDefault(),jt())},nt=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
|
|
99
|
+
bg-[var(--terminal-bg)] text-[var(--terminal-text)]
|
|
100
|
+
border border-[var(--terminal-border)]
|
|
101
|
+
focus:border-[var(--terminal-border-hover)]
|
|
102
|
+
placeholder:text-[var(--terminal-text-muted)]`,Pt=ge=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ge?"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:Be,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:Le.map((ge,Z)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Z<=n?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Z===n?"var(--terminal-text)":"var(--terminal-text-muted)"},children:b8[ge]})]},ge))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[tt==="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:Pt(u==="claude-cli"),onClick:()=>(i==null?void 0:i.claudeCli)&&d("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:Pt(u==="direct-api"),onClick:()=>d("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"})]})]}),u==="direct-api"&&!(i!=null&&i.apiKey)&&l.jsx("input",{type:"password",className:`${nt} mt-3`,placeholder:"sk-ant-...",value:h,onChange:ge=>m(ge.target.value),autoFocus:!0})]})]})]}),tt==="company"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company"}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),l.jsx("input",{ref:C,className:nt,placeholder:"e.g. Acme Corp",value:y,onChange:ge=>v(ge.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:`${nt} resize-none`,rows:3,placeholder:"What does your AI company do?",value:b,onChange:ge=>j(ge.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:nt,value:k,onChange:ge=>N(ge.target.value),children:[l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"한국어"}),l.jsx("option",{value:"ja",children:"日本語"})]})]})]}),tt==="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(Zm,{text:`"New Company" creates a fresh workspace with roles, knowledge base, and project structure.
|
|
103
|
+
|
|
104
|
+
"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:()=>R("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:()=>R("existing-akb"),children:"Connect Existing"})]}),E==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Sg,{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:`${nt} flex-1`,placeholder:"/path/to/your-company",value:M,onChange:ge=>{I(ge.target.value),Q(!0)}}),l.jsx("button",{onClick:()=>$(!A),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:"📁"})]}),A&&l.jsx(Cu,{onSelect:ge=>{I(ge),Q(!0),$(!1)},onClose:()=>$(!1)})]}),l.jsxs(Cg,{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.
|
|
105
|
+
|
|
106
|
+
Skip this if you don't have a codebase yet — you can connect one later from Settings.`,tag:"optional",open:U,onToggle:()=>ee(!U),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${nt} flex-1`,placeholder:"/path/to/code/repo",value:oe,onChange:ge=>ne(ge.target.value)}),l.jsx("button",{onClick:()=>ue(!Y),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:"📁"})]}),Y&&l.jsx(Cu,{onSelect:ge=>{ne(ge),ue(!1)},onClose:()=>ue(!1)})]}),l.jsxs(Cg,{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.
|
|
107
|
+
|
|
108
|
+
Skip this to start with an empty knowledge base. You can import documents anytime from the office.`,tag:"optional",open:J,onToggle:()=>K(!J),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${nt} flex-1`,placeholder:"/path/to/docs",value:q,onChange:ge=>T(ge.target.value),onKeyDown:ge=>{ge.key==="Enter"&&(ge.preventDefault(),Dt())}}),l.jsx("button",{onClick:()=>Ne(!de),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:Dt,disabled:!q.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:q.trim()?1:.5},children:"Add"})]}),de&&l.jsx(Cu,{onSelect:ge=>{D.includes(ge)||F([...D,ge]),Ne(!1)},onClose:()=>Ne(!1)}),D.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:D.map((ge,Z)=>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:ge}),l.jsx("button",{onClick:()=>F(D.filter((Me,Ie)=>Ie!==Z)),className:"opacity-50 hover:opacity-100",children:"✕"})]},Z))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(Sg,{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:`${nt} flex-1`,placeholder:"/path/to/your/akb",value:ye,onChange:ge=>{_e(ge.target.value),Ve(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>We(!Ce),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:Lt,disabled:lt||!ye.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:lt||!ye.trim()?.5:1},children:lt?"...":"Verify"})]}),Pe===!0&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found"]}),Pe===!1&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),Ce&&l.jsx(Cu,{onSelect:ge=>{_e(ge),Ve(null),We(!1)},onClose:()=>We(!1)})]})})]}),tt==="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."}),Te.map(ge=>l.jsxs("div",{className:Pt(ut===ge.id),onClick:()=>mt(ge.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:ge.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ge.roles.map(Z=>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:Z.name},Z.id))})]},ge.id)),l.jsxs("div",{className:Pt(ut==="custom"),onClick:()=>mt("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."})]})]}),tt==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:$t?E==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!$t&&!wt&&!we&&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:"})," ",ye]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Company:"})," ",y]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Location:"})," ",M||"(default)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]}),oe.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Code Repo:"})," ",oe]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",D.length>0?`Import ${D.length} source(s)`:"Fresh (empty)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Team:"})," ",ut]}),D.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."})]})}),Bn&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:Bn})]}),(wt||we)&&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:we?"Connecting to AKB...":"Scaffolding your company..."})]}),$t&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),W&&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:"})," ",W]}),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((ge,Z)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ge]},Z))}),(je||$e.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:je?"Installing skill tools...":"Skill tools"}),$e.map((ge,Z)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:ge.event==="installed"||ge.event==="skipped"?"var(--active-green)":ge.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:ge.event==="installed"||ge.event==="skipped"?"✓":ge.event==="error"?"✗":"…"}),l.jsx("span",{children:ge.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:ge.detail})]},Z)),je&&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..."})]})]}),D.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:n>0&&!$t&&l.jsx("button",{onClick:ze,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:[n+1," / ",Le.length]}),l.jsx("div",{children:$t?l.jsx("button",{onClick:P,disabled:je,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:je?.5:1},children:je?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:jt,disabled:!Ke()||wt||we,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Ke()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Ke()&&!wt&&!we?1:.5},children:tt==="create"?wt||we?we?"Connecting...":"Creating...":E==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function Zm({text:e}){const[n,a]=w.useState(!1),[i,o]=w.useState({top:0,left:0}),u=w.useRef(null),d=()=>{if(u.current){const h=u.current.getBoundingClientRect();o({top:h.bottom+6,left:h.left})}a(!0)};return l.jsxs("span",{className:"inline-flex",ref:u,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:d,onMouseLeave:()=>a(!1),onClick:h=>{h.stopPropagation(),n?a(!1):d()},children:"?"}),n&&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 Sg({icon:e,title:n,hint:a,help:i,children:o}){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:n}),i&&l.jsx(Zm,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:a})]}),o]})}function Cg({icon:e,title:n,hint:a,help:i,tag:o,open:u,onToggle:d,children:h}){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:d,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:n}),i&&l.jsx(Zm,{text:i}),o&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded",style:{background:"var(--terminal-surface)",color:"var(--terminal-text-muted)"},children:o}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:u?"▲":"▼"})]}),!u&&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:a})}),u&&l.jsx("div",{className:"px-3 pb-3 space-y-2",children:h})]})}function w8(){const[e,n]=w.useState(null),[a,i]=w.useState(!0),[o,u]=w.useState(null),d=w.useCallback(async()=>{i(!0),u(null);try{const h=await ke.getStatus();n(h)}catch(h){u(h instanceof Error?h.message:"Failed to fetch status")}finally{i(!1)}},[]);return w.useEffect(()=>{d()},[d]),{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:a,error:o,refetch:d}}const k8=w.lazy(()=>Eg(()=>import("./preview-app-B3kFNGV1.js"),[]));function Fv(){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 j8(){var e;try{const n=localStorage.getItem("tycono-theme"),a=n&&n in el?n:"default",i=(e=el[a])==null?void 0:e.vars;if(!i)return;const o=document.documentElement;for(const[u,d]of Object.entries(i))o.style.setProperty(u,d)}catch{}}function S8(){const{initialized:e,loading:n,refetch:a}=w8(),[i,o]=w.useState(null);w.useEffect(()=>{j8()},[]);const u=d=>{d&&o(d),a()};return n?l.jsx(Fv,{}):e?l.jsx(g8,{importJob:i,onImportDone:()=>o(null)}):l.jsx(v8,{onComplete:u})}function C8(){const e=new URLSearchParams(window.location.search).has("sprite-preview");return l.jsx(kw,{children:e?l.jsx(w.Suspense,{fallback:l.jsx(Fv,{}),children:l.jsx(k8,{})}):l.jsx(S8,{})})}bw.createRoot(document.getElementById("root")).render(l.jsx(w.StrictMode,{children:l.jsx(C8,{})}));export{ov as H,uv as P,dv as S,D8 as a,cv as b,sv as c,rm as d,eC as e,E8 as f,A8 as g,T8 as h,l as j,w as r};
|