tycono 0.1.89-beta.0 → 0.1.89
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/package.json +1 -1
- package/src/api/src/create-server.ts +2 -1
- package/src/api/src/engine/agent-loop.ts +5 -0
- package/src/api/src/engine/context-assembler.ts +3 -2
- package/src/api/src/engine/runners/claude-cli.ts +3 -0
- package/src/api/src/engine/runners/direct-api.ts +1 -0
- package/src/api/src/engine/runners/types.ts +4 -1
- package/src/api/src/routes/execute.ts +59 -21
- package/src/api/src/routes/operations.ts +133 -1
- package/src/api/src/routes/sessions.ts +4 -7
- package/src/api/src/services/activity-stream.ts +9 -21
- package/src/api/src/services/activity-tracker.ts +11 -1
- package/src/api/src/services/job-manager.ts +44 -26
- package/src/api/src/services/scaffold.ts +2 -2
- package/src/api/src/services/session-store.ts +4 -7
- package/src/api/src/services/wave-multiplexer.ts +5 -2
- package/src/api/src/services/wave-tracker.ts +4 -5
- package/src/web/dist/assets/index--pQ-Ce3E.js +110 -0
- package/src/web/dist/assets/{preview-app-DogEuj8S.js → preview-app-B2p8z-M8.js} +1 -1
- package/src/web/dist/index.html +1 -1
- package/src/web/dist/assets/index-oa99cszw.js +0 -110
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
var pw=Object.defineProperty;var xw=(e,n,a)=>n in e?pw(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var C0=(e,n,a)=>xw(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 Ay(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var th={exports:{}},ko={};/**
|
|
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 E0;function gw(){if(E0)return ko;E0=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 f in o)f!=="key"&&(u[f]=o[f])}else u=o;return o=u.ref,{$$typeof:e,type:i,key:d,ref:o!==void 0?o:null,props:u}}return ko.Fragment=n,ko.jsx=a,ko.jsxs=a,ko}var N0;function yw(){return N0||(N0=1,th.exports=gw()),th.exports}var l=yw(),nh={exports:{}},pt={};/**
|
|
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 A0;function bw(){if(A0)return pt;A0=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"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function b($){return $===null||typeof $!="object"?null:($=v&&$[v]||$["@@iterator"],typeof $=="function"?$:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,N={};function E($,U,T){this.props=$,this.context=U,this.refs=N,this.updater=T||j}E.prototype.isReactComponent={},E.prototype.setState=function($,U){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,U,"setState")},E.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function C(){}C.prototype=E.prototype;function _($,U,T){this.props=$,this.context=U,this.refs=N,this.updater=T||j}var M=_.prototype=new C;M.constructor=_,k(M,E.prototype),M.isPureReactComponent=!0;var H=Array.isArray;function R(){}var I={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function Y($,U,T){var se=T.ref;return{$$typeof:e,type:$,key:U,ref:se!==void 0?se:null,props:T}}function D($,U){return Y($.type,U,$.props)}function O($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function B($){var U={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(T){return U[T]})}var ee=/\/+/g;function re($,U){return typeof $=="object"&&$!==null&&$.key!=null?B(""+$.key):U.toString(36)}function K($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(R,R):($.status="pending",$.then(function(U){$.status==="pending"&&($.status="fulfilled",$.value=U)},function(U){$.status==="pending"&&($.status="rejected",$.reason=U)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function q($,U,T,se,ke){var he=typeof $;(he==="undefined"||he==="boolean")&&($=null);var _e=!1;if($===null)_e=!0;else switch(he){case"bigint":case"string":case"number":_e=!0;break;case"object":switch($.$$typeof){case e:case n:_e=!0;break;case x:return _e=$._init,q(_e($._payload),U,T,se,ke)}}if(_e)return ke=ke($),_e=se===""?"."+re($,0):se,H(ke)?(T="",_e!=null&&(T=_e.replace(ee,"$&/")+"/"),q(ke,U,T,"",function(et){return et})):ke!=null&&(O(ke)&&(ke=D(ke,T+(ke.key==null||$&&$.key===ke.key?"":(""+ke.key).replace(ee,"$&/")+"/")+_e)),U.push(ke)),1;_e=0;var Le=se===""?".":se+":";if(H($))for(var Ue=0;Ue<$.length;Ue++)se=$[Ue],he=Le+re(se,Ue),_e+=q(se,U,T,he,ke);else if(Ue=b($),typeof Ue=="function")for($=Ue.call($),Ue=0;!(se=$.next()).done;)se=se.value,he=Le+re(se,Ue++),_e+=q(se,U,T,he,ke);else if(he==="object"){if(typeof $.then=="function")return q(K($),U,T,se,ke);throw U=String($),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return _e}function ce($,U,T){if($==null)return $;var se=[],ke=0;return q($,se,"","",function(he){return U.call(T,he,ke++)}),se}function ue($){if($._status===-1){var U=$._result;U=U(),U.then(function(T){($._status===0||$._status===-1)&&($._status=1,$._result=T)},function(T){($._status===0||$._status===-1)&&($._status=2,$._result=T)}),$._status===-1&&($._status=0,$._result=U)}if($._status===1)return $._result.default;throw $._result}var V=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},A={map:ce,forEach:function($,U,T){ce($,function(){U.apply(this,arguments)},T)},count:function($){var U=0;return ce($,function(){U++}),U},toArray:function($){return ce($,function(U){return U})||[]},only:function($){if(!O($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return pt.Activity=g,pt.Children=A,pt.Component=E,pt.Fragment=a,pt.Profiler=o,pt.PureComponent=_,pt.StrictMode=i,pt.Suspense=m,pt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,pt.__COMPILER_RUNTIME={__proto__:null,c:function($){return I.H.useMemoCache($)}},pt.cache=function($){return function(){return $.apply(null,arguments)}},pt.cacheSignal=function(){return null},pt.cloneElement=function($,U,T){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var se=k({},$.props),ke=$.key;if(U!=null)for(he in U.key!==void 0&&(ke=""+U.key),U)!W.call(U,he)||he==="key"||he==="__self"||he==="__source"||he==="ref"&&U.ref===void 0||(se[he]=U[he]);var he=arguments.length-2;if(he===1)se.children=T;else if(1<he){for(var _e=Array(he),Le=0;Le<he;Le++)_e[Le]=arguments[Le+2];se.children=_e}return Y($.type,ke,se)},pt.createContext=function($){return $={$$typeof:d,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:u,_context:$},$},pt.createElement=function($,U,T){var se,ke={},he=null;if(U!=null)for(se in U.key!==void 0&&(he=""+U.key),U)W.call(U,se)&&se!=="key"&&se!=="__self"&&se!=="__source"&&(ke[se]=U[se]);var _e=arguments.length-2;if(_e===1)ke.children=T;else if(1<_e){for(var Le=Array(_e),Ue=0;Ue<_e;Ue++)Le[Ue]=arguments[Ue+2];ke.children=Le}if($&&$.defaultProps)for(se in _e=$.defaultProps,_e)ke[se]===void 0&&(ke[se]=_e[se]);return Y($,he,ke)},pt.createRef=function(){return{current:null}},pt.forwardRef=function($){return{$$typeof:f,render:$}},pt.isValidElement=O,pt.lazy=function($){return{$$typeof:x,_payload:{_status:-1,_result:$},_init:ue}},pt.memo=function($,U){return{$$typeof:h,type:$,compare:U===void 0?null:U}},pt.startTransition=function($){var U=I.T,T={};I.T=T;try{var se=$(),ke=I.S;ke!==null&&ke(T,se),typeof se=="object"&&se!==null&&typeof se.then=="function"&&se.then(R,V)}catch(he){V(he)}finally{U!==null&&T.types!==null&&(U.types=T.types),I.T=U}},pt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},pt.use=function($){return I.H.use($)},pt.useActionState=function($,U,T){return I.H.useActionState($,U,T)},pt.useCallback=function($,U){return I.H.useCallback($,U)},pt.useContext=function($){return I.H.useContext($)},pt.useDebugValue=function(){},pt.useDeferredValue=function($,U){return I.H.useDeferredValue($,U)},pt.useEffect=function($,U){return I.H.useEffect($,U)},pt.useEffectEvent=function($){return I.H.useEffectEvent($)},pt.useId=function(){return I.H.useId()},pt.useImperativeHandle=function($,U,T){return I.H.useImperativeHandle($,U,T)},pt.useInsertionEffect=function($,U){return I.H.useInsertionEffect($,U)},pt.useLayoutEffect=function($,U){return I.H.useLayoutEffect($,U)},pt.useMemo=function($,U){return I.H.useMemo($,U)},pt.useOptimistic=function($,U){return I.H.useOptimistic($,U)},pt.useReducer=function($,U,T){return I.H.useReducer($,U,T)},pt.useRef=function($){return I.H.useRef($)},pt.useState=function($){return I.H.useState($)},pt.useSyncExternalStore=function($,U,T){return I.H.useSyncExternalStore($,U,T)},pt.useTransition=function(){return I.H.useTransition()},pt.version="19.2.4",pt}var D0;function Sm(){return D0||(D0=1,nh.exports=bw()),nh.exports}var w=Sm(),rh={exports:{}},jo={},ah={exports:{}},lh={};/**
|
|
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 T0;function vw(){return T0||(T0=1,(function(e){function n(q,ce){var ue=q.length;q.push(ce);e:for(;0<ue;){var V=ue-1>>>1,A=q[V];if(0<o(A,ce))q[V]=ce,q[ue]=A,ue=V;else break e}}function a(q){return q.length===0?null:q[0]}function i(q){if(q.length===0)return null;var ce=q[0],ue=q.pop();if(ue!==ce){q[0]=ue;e:for(var V=0,A=q.length,$=A>>>1;V<$;){var U=2*(V+1)-1,T=q[U],se=U+1,ke=q[se];if(0>o(T,ue))se<A&&0>o(ke,T)?(q[V]=ke,q[se]=ue,V=se):(q[V]=T,q[U]=ue,V=U);else if(se<A&&0>o(ke,ue))q[V]=ke,q[se]=ue,V=se;else break e}}return ce}function o(q,ce){var ue=q.sortIndex-ce.sortIndex;return ue!==0?ue:q.id-ce.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,f=d.now();e.unstable_now=function(){return d.now()-f}}var m=[],h=[],x=1,g=null,v=3,b=!1,j=!1,k=!1,N=!1,E=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function M(q){for(var ce=a(h);ce!==null;){if(ce.callback===null)i(h);else if(ce.startTime<=q)i(h),ce.sortIndex=ce.expirationTime,n(m,ce);else break;ce=a(h)}}function H(q){if(k=!1,M(q),!j)if(a(m)!==null)j=!0,R||(R=!0,B());else{var ce=a(h);ce!==null&&K(H,ce.startTime-q)}}var R=!1,I=-1,W=5,Y=-1;function D(){return N?!0:!(e.unstable_now()-Y<W)}function O(){if(N=!1,R){var q=e.unstable_now();Y=q;var ce=!0;try{e:{j=!1,k&&(k=!1,C(I),I=-1),b=!0;var ue=v;try{t:{for(M(q),g=a(m);g!==null&&!(g.expirationTime>q&&D());){var V=g.callback;if(typeof V=="function"){g.callback=null,v=g.priorityLevel;var A=V(g.expirationTime<=q);if(q=e.unstable_now(),typeof A=="function"){g.callback=A,M(q),ce=!0;break t}g===a(m)&&i(m),M(q)}else i(m);g=a(m)}if(g!==null)ce=!0;else{var $=a(h);$!==null&&K(H,$.startTime-q),ce=!1}}break e}finally{g=null,v=ue,b=!1}ce=void 0}}finally{ce?B():R=!1}}}var B;if(typeof _=="function")B=function(){_(O)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,re=ee.port2;ee.port1.onmessage=O,B=function(){re.postMessage(null)}}else B=function(){E(O,0)};function K(q,ce){I=E(function(){q(e.unstable_now())},ce)}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(q){q.callback=null},e.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<q?Math.floor(1e3/q):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(q){switch(v){case 1:case 2:case 3:var ce=3;break;default:ce=v}var ue=v;v=ce;try{return q()}finally{v=ue}},e.unstable_requestPaint=function(){N=!0},e.unstable_runWithPriority=function(q,ce){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var ue=v;v=q;try{return ce()}finally{v=ue}},e.unstable_scheduleCallback=function(q,ce,ue){var V=e.unstable_now();switch(typeof ue=="object"&&ue!==null?(ue=ue.delay,ue=typeof ue=="number"&&0<ue?V+ue:V):ue=V,q){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=ue+A,q={id:x++,callback:ce,priorityLevel:q,startTime:ue,expirationTime:A,sortIndex:-1},ue>V?(q.sortIndex=ue,n(h,q),a(m)===null&&q===a(h)&&(k?(C(I),I=-1):k=!0,K(H,ue-V))):(q.sortIndex=A,n(m,q),j||b||(j=!0,R||(R=!0,B()))),q},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(q){var ce=v;return function(){var ue=v;v=ce;try{return q.apply(this,arguments)}finally{v=ue}}}})(lh)),lh}var F0;function ww(){return F0||(F0=1,ah.exports=vw()),ah.exports}var ih={exports:{}},nr={};/**
|
|
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 R0;function kw(){if(R0)return nr;R0=1;var e=Sm();function n(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)h+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+h+" 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,h,x){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:h,implementation:x}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return nr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,nr.createPortal=function(m,h){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(n(299));return u(m,h,null,x)},nr.flushSync=function(m){var h=d.T,x=i.p;try{if(d.T=null,i.p=2,m)return m()}finally{d.T=h,i.p=x,i.d.f()}},nr.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,i.d.C(m,h))},nr.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},nr.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin),v=typeof h.integrity=="string"?h.integrity:void 0,b=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;x==="style"?i.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:v,fetchPriority:b}):x==="script"&&i.d.X(m,{crossOrigin:g,integrity:v,fetchPriority:b,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},nr.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var x=f(h.as,h.crossOrigin);i.d.M(m,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&i.d.M(m)},nr.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin);i.d.L(m,x,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},nr.preloadModule=function(m,h){if(typeof m=="string")if(h){var x=f(h.as,h.crossOrigin);i.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else i.d.m(m)},nr.requestFormReset=function(m){i.d.r(m)},nr.unstable_batchedUpdates=function(m,h){return m(h)},nr.useFormState=function(m,h,x){return d.H.useFormState(m,h,x)},nr.useFormStatus=function(){return d.H.useHostTransitionStatus()},nr.version="19.2.4",nr}var M0;function jw(){if(M0)return ih.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(),ih.exports=kw(),ih.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 z0;function Sw(){if(z0)return jo;z0=1;var e=ww(),n=Sm(),a=jw();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 f(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 h(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 y=p.alternate;if(y===null){if(c=p.return,c!==null){s=c;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===s)return m(p),t;if(y===c)return m(p),r;y=y.sibling}throw Error(i(188))}if(s.return!==c.return)s=p,c=y;else{for(var S=!1,z=p.child;z;){if(z===s){S=!0,s=p,c=y;break}if(z===c){S=!0,c=p,s=y;break}z=z.sibling}if(!S){for(z=y.child;z;){if(z===s){S=!0,s=y,c=p;break}if(z===c){S=!0,c=y,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 g=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"),E=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),_=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),O=Symbol.iterator;function B(t){return t===null||typeof t!="object"?null:(t=O&&t[O]||t["@@iterator"],typeof t=="function"?t:null)}var ee=Symbol.for("react.client.reference");function re(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 E:return"Profiler";case N:return"StrictMode";case H:return"Suspense";case R:return"SuspenseList";case Y:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case j:return"Portal";case _:return t.displayName||"Context";case C: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 I:return r=t.displayName||null,r!==null?r:re(t.type)||"Memo";case W:r=t._payload,t=t._init;try{return re(t(r))}catch{}}return null}var K=Array.isArray,q=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},V=[],A=-1;function $(t){return{current:t}}function U(t){0>A||(t.current=V[A],V[A]=null,A--)}function T(t,r){A++,V[A]=t.current,t.current=r}var se=$(null),ke=$(null),he=$(null),_e=$(null);function Le(t,r){switch(T(he,r),T(ke,t),T(se,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?G1(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=G1(r),t=K1(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}U(se),T(se,t)}function Ue(){U(se),U(ke),U(he)}function et(t){t.memoizedState!==null&&T(_e,t);var r=se.current,s=K1(r,t.type);r!==s&&(T(ke,t),T(se,s))}function Pe(t){ke.current===t&&(U(se),U(ke)),_e.current===t&&(U(_e),yo._currentValue=ue)}var Ge,Ce;function Ae(t){if(Ge===void 0)try{throw Error()}catch(s){var r=s.stack.trim().match(/\n( *(at )?)/);Ge=r&&r[1]||"",Ce=-1<s.stack.indexOf(`
|
|
42
|
+
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
+
`+Ge+t+Ce}var yt=!1;function ct(t,r){if(!t||yt)return"";yt=!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(de){var oe=de}Reflect.construct(t,[],Se)}else{try{Se.call()}catch(de){oe=de}t.call(Se.prototype)}}else{try{throw Error()}catch(de){oe=de}(Se=t())&&typeof Se.catch=="function"&&Se.catch(function(){})}}catch(de){if(de&&oe&&typeof de.stack=="string")return[de.stack,oe.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 y=c.DetermineComponentFrameRoot(),S=y[0],z=y[1];if(S&&z){var X=S.split(`
|
|
44
|
+
`),ie=z.split(`
|
|
45
|
+
`);for(p=c=0;c<X.length&&!X[c].includes("DetermineComponentFrameRoot");)c++;for(;p<ie.length&&!ie[p].includes("DetermineComponentFrameRoot");)p++;if(c===X.length||p===ie.length)for(c=X.length-1,p=ie.length-1;1<=c&&0<=p&&X[c]!==ie[p];)p--;for(;1<=c&&0<=p;c--,p--)if(X[c]!==ie[p]){if(c!==1||p!==1)do if(c--,p--,0>p||X[c]!==ie[p]){var xe=`
|
|
46
|
+
`+X[c].replace(" at new "," at ");return t.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",t.displayName)),xe}while(1<=c&&0<=p);break}}}finally{yt=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?Ae(s):""}function xt(t,r){switch(t.tag){case 26:case 27:case 5:return Ae(t.type);case 16:return Ae("Lazy");case 13:return t.child!==r&&r!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return ct(t.type,!1);case 11:return ct(t.type.render,!1);case 1:return ct(t.type,!0);case 31:return Ae("Activity");default:return""}}function Ct(t){try{var r="",s=null;do r+=xt(t,s),s=t,t=t.return;while(t);return r}catch(c){return`
|
|
47
|
+
Error generating stack: `+c.message+`
|
|
48
|
+
`+c.stack}}var Ht=Object.prototype.hasOwnProperty,zt=e.unstable_scheduleCallback,jt=e.unstable_cancelCallback,Hn=e.unstable_shouldYield,me=e.unstable_requestPaint,je=e.unstable_now,Ne=e.unstable_getCurrentPriorityLevel,G=e.unstable_ImmediatePriority,Z=e.unstable_UserBlockingPriority,ye=e.unstable_NormalPriority,ge=e.unstable_LowPriority,Ee=e.unstable_IdlePriority,Fe=e.log,Be=e.unstable_setDisableYieldValue,Oe=null,qe=null;function at(t){if(typeof Fe=="function"&&Be(t),qe&&typeof qe.setStrictMode=="function")try{qe.setStrictMode(Oe,t)}catch{}}var We=Math.clz32?Math.clz32:He,Dt=Math.log,ze=Math.LN2;function He(t){return t>>>=0,t===0?32:31-(Dt(t)/ze|0)|0}var qt=256,_t=262144,Bt=4194304;function Jt(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 kn(t,r,s){var c=t.pendingLanes;if(c===0)return 0;var p=0,y=t.suspendedLanes,S=t.pingedLanes;t=t.warmLanes;var z=c&134217727;return z!==0?(c=z&~y,c!==0?p=Jt(c):(S&=z,S!==0?p=Jt(S):s||(s=z&~t,s!==0&&(p=Jt(s))))):(z=c&~y,z!==0?p=Jt(z):S!==0?p=Jt(S):s||(s=c&~t,s!==0&&(p=Jt(s)))),p===0?0:r!==0&&r!==p&&(r&y)===0&&(y=p&-p,s=r&-r,y>=s||y===32&&(s&4194048)!==0)?r:p}function J(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function $e(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 lt(){var t=Bt;return Bt<<=1,(Bt&62914560)===0&&(Bt=4194304),t}function Kt(t){for(var r=[],s=0;31>s;s++)r.push(t);return r}function ve(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function wt(t,r,s,c,p,y){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,ie=t.hiddenUpdates;for(s=S&~s;0<s;){var xe=31-We(s),Se=1<<xe;z[xe]=0,X[xe]=-1;var oe=ie[xe];if(oe!==null)for(ie[xe]=null,xe=0;xe<oe.length;xe++){var de=oe[xe];de!==null&&(de.lane&=-536870913)}s&=~Se}c!==0&&jn(t,c,0),y!==0&&p===0&&t.tag!==0&&(t.suspendedLanes|=y&~(S&~r))}function jn(t,r,s){t.pendingLanes|=r,t.suspendedLanes&=~r;var c=31-We(r);t.entangledLanes|=r,t.entanglements[c]=t.entanglements[c]|1073741824|s&261930}function hn(t,r){var s=t.entangledLanes|=r;for(t=t.entanglements;s;){var c=31-We(s),p=1<<c;p&r|t[c]&r&&(t[c]|=r),s&=~p}}function ne(t,r){var s=r&-r;return s=(s&42)!==0?1:Me(s),(s&(t.suspendedLanes|r))!==0?0:s}function Me(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 Ve(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Ze(){var t=ce.p;return t!==0?t:(t=window.event,t===void 0?32:y0(t.type))}function Sn(t,r){var s=ce.p;try{return ce.p=t,r()}finally{ce.p=s}}var Vn=Math.random().toString(36).slice(2),yn="__reactFiber$"+Vn,mn="__reactProps$"+Vn,Lr="__reactContainer$"+Vn,Jl="__reactEvents$"+Vn,Fs="__reactListeners$"+Vn,Mi="__reactHandles$"+Vn,Po="__reactResources$"+Vn,Ra="__reactMarker$"+Vn;function Rs(t){delete t[yn],delete t[mn],delete t[Jl],delete t[Fs],delete t[Mi]}function ua(t){var r=t[yn];if(r)return r;for(var s=t.parentNode;s;){if(r=s[Lr]||s[yn]){if(s=r.alternate,r.child!==null||s!==null&&s.child!==null)for(t=n0(t);t!==null;){if(s=t[yn])return s;t=n0(t)}return r}t=s,s=t.parentNode}return null}function Ma(t){if(t=t[yn]||t[Lr]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function za(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function Gn(t){var r=t[Po];return r||(r=t[Po]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function Dn(t){t[Ra]=!0}var _a=new Set,zi={};function hr(t,r){Sr(t,r),Sr(t+"Capture",r)}function Sr(t,r){for(zi[t]=r,t=0;t<r.length;t++)_a.add(r[t])}var ul=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]*$"),Ms={},Ba={};function Qo(t){return Ht.call(Ba,t)?!0:Ht.call(Ms,t)?!1:ul.test(t)?Ba[t]=!0:(Ms[t]=!0,!1)}function ei(t,r,s){if(Qo(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 dl(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 Ir(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 ir(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Zo(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Oa(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,y=c.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return p.call(this)},set:function(S){s=""+S,y.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 Cr(t){if(!t._valueTracker){var r=Zo(t)?"checked":"value";t._valueTracker=Oa(t,r,""+t[r])}}function Hr(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var s=r.getValue(),c="";return t&&(c=Zo(t)?t.checked?"true":"false":t.value),t=c,t!==s?(r.setValue(t),!0):!1}function Er(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 ta=/[\n"\\]/g;function Pt(t){return t.replace(ta,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function _i(t,r,s,c,p,y,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=""+ir(r)):t.value!==""+ir(r)&&(t.value=""+ir(r)):S!=="submit"&&S!=="reset"||t.removeAttribute("value"),r!=null?ti(t,S,ir(r)):s!=null?ti(t,S,ir(s)):c!=null&&t.removeAttribute("value"),p==null&&y!=null&&(t.defaultChecked=!!y),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),z!=null&&typeof z!="function"&&typeof z!="symbol"&&typeof z!="boolean"?t.name=""+ir(z):t.removeAttribute("name")}function Jo(t,r,s,c,p,y,S,z){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(t.type=y),r!=null||s!=null){if(!(y!=="submit"&&y!=="reset"||r!=null)){Cr(t);return}s=s!=null?""+ir(s):"",r=r!=null?""+ir(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),Cr(t)}function ti(t,r,s){r==="number"&&Er(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function Kn(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=""+ir(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 $a(t,r,s){if(r!=null&&(r=""+ir(r),r!==t.value&&(t.value=r),s==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=s!=null?""+ir(s):""}function da(t,r,s,c){if(r==null){if(c!=null){if(s!=null)throw Error(i(92));if(K(c)){if(1<c.length)throw Error(i(93));c=c[0]}s=c}s==null&&(s=""),r=s}s=ir(r),t.defaultValue=s,c=t.textContent,c===s&&c!==""&&c!==null&&(t.value=c),Cr(t)}function fl(t,r){if(r){var s=t.firstChild;if(s&&s===t.lastChild&&s.nodeType===3){s.nodeValue=r;return}}t.textContent=r}var Un=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 sn(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||Un.has(r)?r==="float"?t.cssFloat=s:t[r]=(""+s).trim():t[r]=s+"px"}function na(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&&sn(t,p,c)}else for(var y in r)r.hasOwnProperty(y)&&sn(t,y,r[y])}function qn(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 fa=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"]]),La=/^[\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 Bi(t){return La.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function mr(){}var Oi=null;function ha(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var pr=null,Ia=null;function zs(t){var r=Ma(t);if(r&&(t=r.stateNode)){var s=t[mn]||null;e:switch(t=r.stateNode,r.type){case"input":if(_i(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="'+Pt(""+r)+'"][type="radio"]'),r=0;r<s.length;r++){var c=s[r];if(c!==t&&c.form===t.form){var p=c[mn]||null;if(!p)throw Error(i(90));_i(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&&Hr(c)}break e;case"textarea":$a(t,s.value,s.defaultValue);break e;case"select":r=s.value,r!=null&&Kn(t,!!s.multiple,r,!1)}}}var Pn=!1;function hl(t,r,s){if(Pn)return t(r,s);Pn=!0;try{var c=t(r);return c}finally{if(Pn=!1,(pr!==null||Ia!==null)&&(Kc(),pr&&(r=pr,t=Ia,Ia=pr=null,zs(r),t)))for(r=0;r<t.length;r++)zs(t[r])}}function ma(t,r){var s=t.stateNode;if(s===null)return null;var c=s[mn]||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 ra=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_s=!1;if(ra)try{var St={};Object.defineProperty(St,"passive",{get:function(){_s=!0}}),window.addEventListener("test",St,St),window.removeEventListener("test",St,St)}catch{_s=!1}var pa=null,on=null,ml=null;function pl(){if(ml)return ml;var t,r=on,s=r.length,c,p="value"in pa?pa.value:pa.textContent,y=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[y-c];c++);return ml=p.slice(t,1<c?1-c:void 0)}function $i(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 xa(){return!0}function ec(){return!1}function Yn(t){function r(s,c,p,y,S){this._reactName=s,this._targetInst=p,this.type=c,this.nativeEvent=y,this.target=S,this.currentTarget=null;for(var z in t)t.hasOwnProperty(z)&&(s=t[z],this[z]=s?s(y):y[z]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?xa:ec,this.isPropagationStopped=ec,this}return g(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=xa)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=xa)},persist:function(){},isPersistent:xa}),r}var sr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xl=Yn(sr),ni=g({},sr,{view:0,detail:0}),ld=Yn(ni),ri,Bs,gl,ai=g({},ni,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ii,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!==gl&&(gl&&t.type==="mousemove"?(ri=t.screenX-gl.screenX,Bs=t.screenY-gl.screenY):Bs=ri=0,gl=t),ri)},movementY:function(t){return"movementY"in t?t.movementY:Bs}}),tc=Yn(ai),nc=g({},ai,{dataTransfer:0}),rc=Yn(nc),ac=g({},ni,{relatedTarget:0}),Ur=Yn(ac),Ha=g({},sr,{animationName:0,elapsedTime:0,pseudoElement:0}),Os=Yn(Ha),id=g({},sr,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),lc=Yn(id),ic=g({},sr,{data:0}),sc=Yn(ic),oc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},en={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"},Li={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function cc(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=Li[t])?!!r[t]:!1}function Ii(){return cc}var uc=g({},ni,{key:function(t){if(t.key){var r=oc[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=$i(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?en[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ii,charCode:function(t){return t.type==="keypress"?$i(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?$i(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),dc=Yn(uc),fc=g({},ai,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$s=Yn(fc),hc=g({},ni,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ii}),F=Yn(hc),P=g({},sr,{propertyName:0,elapsedTime:0,pseudoElement:0}),ae=Yn(P),fe=g({},ai,{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}),we=Yn(fe),Ie=g({},sr,{newState:0,oldState:0}),Lt=Yn(Ie),ft=[9,13,27,32],tt=ra&&"CompositionEvent"in window,Qe=null;ra&&"documentMode"in document&&(Qe=document.documentMode);var mt=ra&&"TextEvent"in window&&!Qe,Tt=ra&&(!tt||Qe&&8<Qe&&11>=Qe),yl=" ",or=!1;function ut(t,r){switch(t){case"keyup":return ft.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ot(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var pn=!1;function dn(t,r){switch(t){case"compositionend":return Ot(r);case"keypress":return r.which!==32?null:(or=!0,yl);case"textInput":return t=r.data,t===yl&&or?null:t;default:return null}}function Iv(t,r){if(pn)return t==="compositionend"||!tt&&ut(t,r)?(t=pl(),ml=on=pa=null,pn=!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 Tt&&r.locale!=="ko"?null:r.data;default:return null}}var Hv={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 lp(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!Hv[t.type]:r==="textarea"}function ip(t,r,s,c){pr?Ia?Ia.push(c):Ia=[c]:pr=c,r=nu(r,"onChange"),0<r.length&&(s=new xl("onChange","change",null,s,c),t.push({event:s,listeners:r}))}var Ls=null,Is=null;function Uv(t){U1(t,0)}function mc(t){var r=za(t);if(Hr(r))return t}function sp(t,r){if(t==="change")return r}var op=!1;if(ra){var sd;if(ra){var od="oninput"in document;if(!od){var cp=document.createElement("div");cp.setAttribute("oninput","return;"),od=typeof cp.oninput=="function"}sd=od}else sd=!1;op=sd&&(!document.documentMode||9<document.documentMode)}function up(){Ls&&(Ls.detachEvent("onpropertychange",dp),Is=Ls=null)}function dp(t){if(t.propertyName==="value"&&mc(Is)){var r=[];ip(r,Is,t,ha(t)),hl(Uv,r)}}function qv(t,r,s){t==="focusin"?(up(),Ls=r,Is=s,Ls.attachEvent("onpropertychange",dp)):t==="focusout"&&up()}function Yv(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return mc(Is)}function Xv(t,r){if(t==="click")return mc(r)}function Wv(t,r){if(t==="input"||t==="change")return mc(r)}function Vv(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var Nr=typeof Object.is=="function"?Object.is:Vv;function Hs(t,r){if(Nr(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(!Ht.call(r,p)||!Nr(t[p],r[p]))return!1}return!0}function fp(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function hp(t,r){var s=fp(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=fp(s)}}function mp(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?mp(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function pp(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=Er(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=Er(t.document)}return r}function cd(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 Gv=ra&&"documentMode"in document&&11>=document.documentMode,Hi=null,ud=null,Us=null,dd=!1;function xp(t,r,s){var c=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;dd||Hi==null||Hi!==Er(c)||(c=Hi,"selectionStart"in c&&cd(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}),Us&&Hs(Us,c)||(Us=c,c=nu(ud,"onSelect"),0<c.length&&(r=new xl("onSelect","select",null,r,s),t.push({event:r,listeners:c}),r.target=Hi)))}function li(t,r){var s={};return s[t.toLowerCase()]=r.toLowerCase(),s["Webkit"+t]="webkit"+r,s["Moz"+t]="moz"+r,s}var Ui={animationend:li("Animation","AnimationEnd"),animationiteration:li("Animation","AnimationIteration"),animationstart:li("Animation","AnimationStart"),transitionrun:li("Transition","TransitionRun"),transitionstart:li("Transition","TransitionStart"),transitioncancel:li("Transition","TransitionCancel"),transitionend:li("Transition","TransitionEnd")},fd={},gp={};ra&&(gp=document.createElement("div").style,"AnimationEvent"in window||(delete Ui.animationend.animation,delete Ui.animationiteration.animation,delete Ui.animationstart.animation),"TransitionEvent"in window||delete Ui.transitionend.transition);function ii(t){if(fd[t])return fd[t];if(!Ui[t])return t;var r=Ui[t],s;for(s in r)if(r.hasOwnProperty(s)&&s in gp)return fd[t]=r[s];return t}var yp=ii("animationend"),bp=ii("animationiteration"),vp=ii("animationstart"),Kv=ii("transitionrun"),Pv=ii("transitionstart"),Qv=ii("transitioncancel"),wp=ii("transitionend"),kp=new Map,hd="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(" ");hd.push("scrollEnd");function aa(t,r){kp.set(t,r),hr(r,[t])}var pc=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)},qr=[],qi=0,md=0;function xc(){for(var t=qi,r=md=qi=0;r<t;){var s=qr[r];qr[r++]=null;var c=qr[r];qr[r++]=null;var p=qr[r];qr[r++]=null;var y=qr[r];if(qr[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}y!==0&&jp(s,p,y)}}function gc(t,r,s,c){qr[qi++]=t,qr[qi++]=r,qr[qi++]=s,qr[qi++]=c,md|=c,t.lanes|=c,t=t.alternate,t!==null&&(t.lanes|=c)}function pd(t,r,s,c){return gc(t,r,s,c),yc(t)}function si(t,r){return gc(t,null,null,r),yc(t)}function jp(t,r,s){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s);for(var p=!1,y=t.return;y!==null;)y.childLanes|=s,c=y.alternate,c!==null&&(c.childLanes|=s),y.tag===22&&(t=y.stateNode,t===null||t._visibility&1||(p=!0)),t=y,y=y.return;return t.tag===3?(y=t.stateNode,p&&r!==null&&(p=31-We(s),t=y.hiddenUpdates,c=t[p],c===null?t[p]=[r]:c.push(r),r.lane=s|536870912),y):null}function yc(t){if(50<uo)throw uo=0,Cf=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var Yi={};function Zv(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 Ar(t,r,s,c){return new Zv(t,r,s,c)}function xd(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ua(t,r){var s=t.alternate;return s===null?(s=Ar(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 Sp(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 bc(t,r,s,c,p,y){var S=0;if(c=t,typeof t=="function")xd(t)&&(S=1);else if(typeof t=="string")S=rw(t,s,se.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case Y:return t=Ar(31,s,r,p),t.elementType=Y,t.lanes=y,t;case k:return oi(s.children,p,y,r);case N:S=8,p|=24;break;case E:return t=Ar(12,s,r,p|2),t.elementType=E,t.lanes=y,t;case H:return t=Ar(13,s,r,p),t.elementType=H,t.lanes=y,t;case R:return t=Ar(19,s,r,p),t.elementType=R,t.lanes=y,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:S=10;break e;case C:S=9;break e;case M:S=11;break e;case I:S=14;break e;case W:S=16,c=null;break e}S=29,s=Error(i(130,t===null?"null":typeof t,"")),c=null}return r=Ar(S,s,r,p),r.elementType=t,r.type=c,r.lanes=y,r}function oi(t,r,s,c){return t=Ar(7,t,c,r),t.lanes=s,t}function gd(t,r,s){return t=Ar(6,t,null,r),t.lanes=s,t}function Cp(t){var r=Ar(18,null,null,0);return r.stateNode=t,r}function yd(t,r,s){return r=Ar(4,t.children!==null?t.children:[],t.key,r),r.lanes=s,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var Ep=new WeakMap;function Yr(t,r){if(typeof t=="object"&&t!==null){var s=Ep.get(t);return s!==void 0?s:(r={value:t,source:r,stack:Ct(r)},Ep.set(t,r),r)}return{value:t,source:r,stack:Ct(r)}}var Xi=[],Wi=0,vc=null,qs=0,Xr=[],Wr=0,bl=null,ga=1,ya="";function qa(t,r){Xi[Wi++]=qs,Xi[Wi++]=vc,vc=t,qs=r}function Np(t,r,s){Xr[Wr++]=ga,Xr[Wr++]=ya,Xr[Wr++]=bl,bl=t;var c=ga;t=ya;var p=32-We(c)-1;c&=~(1<<p),s+=1;var y=32-We(r)+p;if(30<y){var S=p-p%5;y=(c&(1<<S)-1).toString(32),c>>=S,p-=S,ga=1<<32-We(r)+p|s<<p|c,ya=y+t}else ga=1<<y|s<<p|c,ya=t}function bd(t){t.return!==null&&(qa(t,1),Np(t,1,0))}function vd(t){for(;t===vc;)vc=Xi[--Wi],Xi[Wi]=null,qs=Xi[--Wi],Xi[Wi]=null;for(;t===bl;)bl=Xr[--Wr],Xr[Wr]=null,ya=Xr[--Wr],Xr[Wr]=null,ga=Xr[--Wr],Xr[Wr]=null}function Ap(t,r){Xr[Wr++]=ga,Xr[Wr++]=ya,Xr[Wr++]=bl,ga=r.id,ya=r.overflow,bl=t}var Qn=null,xn=null,$t=!1,vl=null,Vr=!1,wd=Error(i(519));function wl(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ys(Yr(r,t)),wd}function Dp(t){var r=t.stateNode,s=t.type,c=t.memoizedProps;switch(r[yn]=t,r[mn]=c,s){case"dialog":Nt("cancel",r),Nt("close",r);break;case"iframe":case"object":case"embed":Nt("load",r);break;case"video":case"audio":for(s=0;s<ho.length;s++)Nt(ho[s],r);break;case"source":Nt("error",r);break;case"img":case"image":case"link":Nt("error",r),Nt("load",r);break;case"details":Nt("toggle",r);break;case"input":Nt("invalid",r),Jo(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Nt("invalid",r);break;case"textarea":Nt("invalid",r),da(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||W1(r.textContent,s)?(c.popover!=null&&(Nt("beforetoggle",r),Nt("toggle",r)),c.onScroll!=null&&Nt("scroll",r),c.onScrollEnd!=null&&Nt("scrollend",r),c.onClick!=null&&(r.onclick=mr),r=!0):r=!1,r||wl(t,!0)}function Tp(t){for(Qn=t.return;Qn;)switch(Qn.tag){case 5:case 31:case 13:Vr=!1;return;case 27:case 3:Vr=!0;return;default:Qn=Qn.return}}function Vi(t){if(t!==Qn)return!1;if(!$t)return Tp(t),$t=!0,!1;var r=t.tag,s;if((s=r!==3&&r!==27)&&((s=r===5)&&(s=t.type,s=!(s!=="form"&&s!=="button")||If(t.type,t.memoizedProps)),s=!s),s&&xn&&wl(t),Tp(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));xn=t0(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));xn=t0(t)}else r===27?(r=xn,_l(t.type)?(t=Xf,Xf=null,xn=t):xn=r):xn=Qn?Kr(t.stateNode.nextSibling):null;return!0}function ci(){xn=Qn=null,$t=!1}function kd(){var t=vl;return t!==null&&(br===null?br=t:br.push.apply(br,t),vl=null),t}function Ys(t){vl===null?vl=[t]:vl.push(t)}var jd=$(null),ui=null,Ya=null;function kl(t,r,s){T(jd,r._currentValue),r._currentValue=s}function Xa(t){t._currentValue=jd.current,U(jd)}function Sd(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 Cd(t,r,s,c){var p=t.child;for(p!==null&&(p.return=t);p!==null;){var y=p.dependencies;if(y!==null){var S=p.child;y=y.firstContext;e:for(;y!==null;){var z=y;y=p;for(var X=0;X<r.length;X++)if(z.context===r[X]){y.lanes|=s,z=y.alternate,z!==null&&(z.lanes|=s),Sd(y.return,s,t),c||(S=null);break e}y=z.next}}else if(p.tag===18){if(S=p.return,S===null)throw Error(i(341));S.lanes|=s,y=S.alternate,y!==null&&(y.lanes|=s),Sd(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 Gi(t,r,s,c){t=null;for(var p=r,y=!1;p!==null;){if(!y){if((p.flags&524288)!==0)y=!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;Nr(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(yo):t=[yo])}p=p.return}t!==null&&Cd(r,t,s,c),r.flags|=262144}function wc(t){for(t=t.firstContext;t!==null;){if(!Nr(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function di(t){ui=t,Ya=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Zn(t){return Fp(ui,t)}function kc(t,r){return ui===null&&di(t),Fp(t,r)}function Fp(t,r){var s=r._currentValue;if(r={context:r,memoizedValue:s,next:null},Ya===null){if(t===null)throw Error(i(308));Ya=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else Ya=Ya.next=r;return s}var Jv=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()})}},e2=e.unstable_scheduleCallback,t2=e.unstable_NormalPriority,Tn={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ed(){return{controller:new Jv,data:new Map,refCount:0}}function Xs(t){t.refCount--,t.refCount===0&&e2(t2,function(){t.controller.abort()})}var Ws=null,Nd=0,Ki=0,Pi=null;function n2(t,r){if(Ws===null){var s=Ws=[];Nd=0,Ki=Ff(),Pi={status:"pending",value:void 0,then:function(c){s.push(c)}}}return Nd++,r.then(Rp,Rp),r}function Rp(){if(--Nd===0&&Ws!==null){Pi!==null&&(Pi.status="fulfilled");var t=Ws;Ws=null,Ki=0,Pi=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function r2(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 Mp=q.S;q.S=function(t,r){x1=je(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&n2(t,r),Mp!==null&&Mp(t,r)};var fi=$(null);function Ad(){var t=fi.current;return t!==null?t:cn.pooledCache}function jc(t,r){r===null?T(fi,fi.current):T(fi,r.pool)}function zp(){var t=Ad();return t===null?null:{parent:Tn._currentValue,pool:t}}var Qi=Error(i(460)),Dd=Error(i(474)),Sc=Error(i(542)),Cc={then:function(){}};function _p(t){return t=t.status,t==="fulfilled"||t==="rejected"}function Bp(t,r,s){switch(s=t[s],s===void 0?t.push(r):s!==r&&(r.then(mr,mr),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(mr,mr);else{if(t=cn,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 mi=r,Qi}}function hi(t){try{var r=t._init;return r(t._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(mi=s,Qi):s}}var mi=null;function Op(){if(mi===null)throw Error(i(459));var t=mi;return mi=null,t}function $p(t){if(t===Qi||t===Sc)throw Error(i(483))}var Zi=null,Vs=0;function Ec(t){var r=Vs;return Vs+=1,Zi===null&&(Zi=[]),Bp(Zi,t,r)}function Gs(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function Nc(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 Lp(t){function r(te,Q){if(t){var le=te.deletions;le===null?(te.deletions=[Q],te.flags|=16):le.push(Q)}}function s(te,Q){if(!t)return null;for(;Q!==null;)r(te,Q),Q=Q.sibling;return null}function c(te){for(var Q=new Map;te!==null;)te.key!==null?Q.set(te.key,te):Q.set(te.index,te),te=te.sibling;return Q}function p(te,Q){return te=Ua(te,Q),te.index=0,te.sibling=null,te}function y(te,Q,le){return te.index=le,t?(le=te.alternate,le!==null?(le=le.index,le<Q?(te.flags|=67108866,Q):le):(te.flags|=67108866,Q)):(te.flags|=1048576,Q)}function S(te){return t&&te.alternate===null&&(te.flags|=67108866),te}function z(te,Q,le,be){return Q===null||Q.tag!==6?(Q=gd(le,te.mode,be),Q.return=te,Q):(Q=p(Q,le),Q.return=te,Q)}function X(te,Q,le,be){var rt=le.type;return rt===k?xe(te,Q,le.props.children,be,le.key):Q!==null&&(Q.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===W&&hi(rt)===Q.type)?(Q=p(Q,le.props),Gs(Q,le),Q.return=te,Q):(Q=bc(le.type,le.key,le.props,null,te.mode,be),Gs(Q,le),Q.return=te,Q)}function ie(te,Q,le,be){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==le.containerInfo||Q.stateNode.implementation!==le.implementation?(Q=yd(le,te.mode,be),Q.return=te,Q):(Q=p(Q,le.children||[]),Q.return=te,Q)}function xe(te,Q,le,be,rt){return Q===null||Q.tag!==7?(Q=oi(le,te.mode,be,rt),Q.return=te,Q):(Q=p(Q,le),Q.return=te,Q)}function Se(te,Q,le){if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return Q=gd(""+Q,te.mode,le),Q.return=te,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case b:return le=bc(Q.type,Q.key,Q.props,null,te.mode,le),Gs(le,Q),le.return=te,le;case j:return Q=yd(Q,te.mode,le),Q.return=te,Q;case W:return Q=hi(Q),Se(te,Q,le)}if(K(Q)||B(Q))return Q=oi(Q,te.mode,le,null),Q.return=te,Q;if(typeof Q.then=="function")return Se(te,Ec(Q),le);if(Q.$$typeof===_)return Se(te,kc(te,Q),le);Nc(te,Q)}return null}function oe(te,Q,le,be){var rt=Q!==null?Q.key:null;if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return rt!==null?null:z(te,Q,""+le,be);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case b:return le.key===rt?X(te,Q,le,be):null;case j:return le.key===rt?ie(te,Q,le,be):null;case W:return le=hi(le),oe(te,Q,le,be)}if(K(le)||B(le))return rt!==null?null:xe(te,Q,le,be,null);if(typeof le.then=="function")return oe(te,Q,Ec(le),be);if(le.$$typeof===_)return oe(te,Q,kc(te,le),be);Nc(te,le)}return null}function de(te,Q,le,be,rt){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return te=te.get(le)||null,z(Q,te,""+be,rt);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case b:return te=te.get(be.key===null?le:be.key)||null,X(Q,te,be,rt);case j:return te=te.get(be.key===null?le:be.key)||null,ie(Q,te,be,rt);case W:return be=hi(be),de(te,Q,le,be,rt)}if(K(be)||B(be))return te=te.get(le)||null,xe(Q,te,be,rt,null);if(typeof be.then=="function")return de(te,Q,le,Ec(be),rt);if(be.$$typeof===_)return de(te,Q,le,kc(Q,be),rt);Nc(Q,be)}return null}function Ye(te,Q,le,be){for(var rt=null,Yt=null,Ke=Q,bt=Q=0,Rt=null;Ke!==null&&bt<le.length;bt++){Ke.index>bt?(Rt=Ke,Ke=null):Rt=Ke.sibling;var Xt=oe(te,Ke,le[bt],be);if(Xt===null){Ke===null&&(Ke=Rt);break}t&&Ke&&Xt.alternate===null&&r(te,Ke),Q=y(Xt,Q,bt),Yt===null?rt=Xt:Yt.sibling=Xt,Yt=Xt,Ke=Rt}if(bt===le.length)return s(te,Ke),$t&&qa(te,bt),rt;if(Ke===null){for(;bt<le.length;bt++)Ke=Se(te,le[bt],be),Ke!==null&&(Q=y(Ke,Q,bt),Yt===null?rt=Ke:Yt.sibling=Ke,Yt=Ke);return $t&&qa(te,bt),rt}for(Ke=c(Ke);bt<le.length;bt++)Rt=de(Ke,te,bt,le[bt],be),Rt!==null&&(t&&Rt.alternate!==null&&Ke.delete(Rt.key===null?bt:Rt.key),Q=y(Rt,Q,bt),Yt===null?rt=Rt:Yt.sibling=Rt,Yt=Rt);return t&&Ke.forEach(function(Il){return r(te,Il)}),$t&&qa(te,bt),rt}function st(te,Q,le,be){if(le==null)throw Error(i(151));for(var rt=null,Yt=null,Ke=Q,bt=Q=0,Rt=null,Xt=le.next();Ke!==null&&!Xt.done;bt++,Xt=le.next()){Ke.index>bt?(Rt=Ke,Ke=null):Rt=Ke.sibling;var Il=oe(te,Ke,Xt.value,be);if(Il===null){Ke===null&&(Ke=Rt);break}t&&Ke&&Il.alternate===null&&r(te,Ke),Q=y(Il,Q,bt),Yt===null?rt=Il:Yt.sibling=Il,Yt=Il,Ke=Rt}if(Xt.done)return s(te,Ke),$t&&qa(te,bt),rt;if(Ke===null){for(;!Xt.done;bt++,Xt=le.next())Xt=Se(te,Xt.value,be),Xt!==null&&(Q=y(Xt,Q,bt),Yt===null?rt=Xt:Yt.sibling=Xt,Yt=Xt);return $t&&qa(te,bt),rt}for(Ke=c(Ke);!Xt.done;bt++,Xt=le.next())Xt=de(Ke,te,bt,Xt.value,be),Xt!==null&&(t&&Xt.alternate!==null&&Ke.delete(Xt.key===null?bt:Xt.key),Q=y(Xt,Q,bt),Yt===null?rt=Xt:Yt.sibling=Xt,Yt=Xt);return t&&Ke.forEach(function(mw){return r(te,mw)}),$t&&qa(te,bt),rt}function rn(te,Q,le,be){if(typeof le=="object"&&le!==null&&le.type===k&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case b:e:{for(var rt=le.key;Q!==null;){if(Q.key===rt){if(rt=le.type,rt===k){if(Q.tag===7){s(te,Q.sibling),be=p(Q,le.props.children),be.return=te,te=be;break e}}else if(Q.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===W&&hi(rt)===Q.type){s(te,Q.sibling),be=p(Q,le.props),Gs(be,le),be.return=te,te=be;break e}s(te,Q);break}else r(te,Q);Q=Q.sibling}le.type===k?(be=oi(le.props.children,te.mode,be,le.key),be.return=te,te=be):(be=bc(le.type,le.key,le.props,null,te.mode,be),Gs(be,le),be.return=te,te=be)}return S(te);case j:e:{for(rt=le.key;Q!==null;){if(Q.key===rt)if(Q.tag===4&&Q.stateNode.containerInfo===le.containerInfo&&Q.stateNode.implementation===le.implementation){s(te,Q.sibling),be=p(Q,le.children||[]),be.return=te,te=be;break e}else{s(te,Q);break}else r(te,Q);Q=Q.sibling}be=yd(le,te.mode,be),be.return=te,te=be}return S(te);case W:return le=hi(le),rn(te,Q,le,be)}if(K(le))return Ye(te,Q,le,be);if(B(le)){if(rt=B(le),typeof rt!="function")throw Error(i(150));return le=rt.call(le),st(te,Q,le,be)}if(typeof le.then=="function")return rn(te,Q,Ec(le),be);if(le.$$typeof===_)return rn(te,Q,kc(te,le),be);Nc(te,le)}return typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint"?(le=""+le,Q!==null&&Q.tag===6?(s(te,Q.sibling),be=p(Q,le),be.return=te,te=be):(s(te,Q),be=gd(le,te.mode,be),be.return=te,te=be),S(te)):s(te,Q)}return function(te,Q,le,be){try{Vs=0;var rt=rn(te,Q,le,be);return Zi=null,rt}catch(Ke){if(Ke===Qi||Ke===Sc)throw Ke;var Yt=Ar(29,Ke,null,te.mode);return Yt.lanes=be,Yt.return=te,Yt}finally{}}}var pi=Lp(!0),Ip=Lp(!1),jl=!1;function Td(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Fd(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 Sl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Cl(t,r,s){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Vt&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,r=yc(t),jp(t,null,s),r}return gc(t,c,r,s),yc(t)}function Ks(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,hn(t,s)}}function Rd(t,r){var s=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,s===c)){var p=null,y=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};y===null?p=y=S:y=y.next=S,s=s.next}while(s!==null);y===null?p=y=r:y=y.next=r}else p=y=r;s={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:y,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 Md=!1;function Ps(){if(Md){var t=Pi;if(t!==null)throw t}}function Qs(t,r,s,c){Md=!1;var p=t.updateQueue;jl=!1;var y=p.firstBaseUpdate,S=p.lastBaseUpdate,z=p.shared.pending;if(z!==null){p.shared.pending=null;var X=z,ie=X.next;X.next=null,S===null?y=ie:S.next=ie,S=X;var xe=t.alternate;xe!==null&&(xe=xe.updateQueue,z=xe.lastBaseUpdate,z!==S&&(z===null?xe.firstBaseUpdate=ie:z.next=ie,xe.lastBaseUpdate=X))}if(y!==null){var Se=p.baseState;S=0,xe=ie=X=null,z=y;do{var oe=z.lane&-536870913,de=oe!==z.lane;if(de?(Ft&oe)===oe:(c&oe)===oe){oe!==0&&oe===Ki&&(Md=!0),xe!==null&&(xe=xe.next={lane:0,tag:z.tag,payload:z.payload,callback:null,next:null});e:{var Ye=t,st=z;oe=r;var rn=s;switch(st.tag){case 1:if(Ye=st.payload,typeof Ye=="function"){Se=Ye.call(rn,Se,oe);break e}Se=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=st.payload,oe=typeof Ye=="function"?Ye.call(rn,Se,oe):Ye,oe==null)break e;Se=g({},Se,oe);break e;case 2:jl=!0}}oe=z.callback,oe!==null&&(t.flags|=64,de&&(t.flags|=8192),de=p.callbacks,de===null?p.callbacks=[oe]:de.push(oe))}else de={lane:oe,tag:z.tag,payload:z.payload,callback:z.callback,next:null},xe===null?(ie=xe=de,X=Se):xe=xe.next=de,S|=oe;if(z=z.next,z===null){if(z=p.shared.pending,z===null)break;de=z,z=de.next,de.next=null,p.lastBaseUpdate=de,p.shared.pending=null}}while(!0);xe===null&&(X=Se),p.baseState=X,p.firstBaseUpdate=ie,p.lastBaseUpdate=xe,y===null&&(p.shared.lanes=0),Tl|=S,t.lanes=S,t.memoizedState=Se}}function Hp(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function Up(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;t<s.length;t++)Hp(s[t],r)}var Ji=$(null),Ac=$(0);function qp(t,r){t=el,T(Ac,t),T(Ji,r),el=t|r.baseLanes}function zd(){T(Ac,el),T(Ji,Ji.current)}function _d(){el=Ac.current,U(Ji),U(Ac)}var Dr=$(null),Gr=null;function El(t){var r=t.alternate;T(Nn,Nn.current&1),T(Dr,t),Gr===null&&(r===null||Ji.current!==null||r.memoizedState!==null)&&(Gr=t)}function Bd(t){T(Nn,Nn.current),T(Dr,t),Gr===null&&(Gr=t)}function Yp(t){t.tag===22?(T(Nn,Nn.current),T(Dr,t),Gr===null&&(Gr=t)):Nl()}function Nl(){T(Nn,Nn.current),T(Dr,Dr.current)}function Tr(t){U(Dr),Gr===t&&(Gr=null),U(Nn)}var Nn=$(0);function Dc(t){for(var r=t;r!==null;){if(r.tag===13){var s=r.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||qf(s)||Yf(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 Wa=0,gt=null,tn=null,Fn=null,Tc=!1,es=!1,xi=!1,Fc=0,Zs=0,ts=null,a2=0;function Cn(){throw Error(i(321))}function Od(t,r){if(r===null)return!1;for(var s=0;s<r.length&&s<t.length;s++)if(!Nr(t[s],r[s]))return!1;return!0}function $d(t,r,s,c,p,y){return Wa=y,gt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,q.H=t===null||t.memoizedState===null?Nx:Jd,xi=!1,y=s(c,p),xi=!1,es&&(y=Wp(r,s,c,p)),Xp(t),y}function Xp(t){q.H=to;var r=tn!==null&&tn.next!==null;if(Wa=0,Fn=tn=gt=null,Tc=!1,Zs=0,ts=null,r)throw Error(i(300));t===null||Rn||(t=t.dependencies,t!==null&&wc(t)&&(Rn=!0))}function Wp(t,r,s,c){gt=t;var p=0;do{if(es&&(ts=null),Zs=0,es=!1,25<=p)throw Error(i(301));if(p+=1,Fn=tn=null,t.updateQueue!=null){var y=t.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}q.H=Ax,y=r(s,c)}while(es);return y}function l2(){var t=q.H,r=t.useState()[0];return r=typeof r.then=="function"?Js(r):r,t=t.useState()[0],(tn!==null?tn.memoizedState:null)!==t&&(gt.flags|=1024),r}function Ld(){var t=Fc!==0;return Fc=0,t}function Id(t,r,s){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~s}function Hd(t){if(Tc){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}Tc=!1}Wa=0,Fn=tn=gt=null,es=!1,Zs=Fc=0,ts=null}function cr(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fn===null?gt.memoizedState=Fn=t:Fn=Fn.next=t,Fn}function An(){if(tn===null){var t=gt.alternate;t=t!==null?t.memoizedState:null}else t=tn.next;var r=Fn===null?gt.memoizedState:Fn.next;if(r!==null)Fn=r,tn=t;else{if(t===null)throw gt.alternate===null?Error(i(467)):Error(i(310));tn=t,t={memoizedState:tn.memoizedState,baseState:tn.baseState,baseQueue:tn.baseQueue,queue:tn.queue,next:null},Fn===null?gt.memoizedState=Fn=t:Fn=Fn.next=t}return Fn}function Rc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Js(t){var r=Zs;return Zs+=1,ts===null&&(ts=[]),t=Bp(ts,t,r),r=gt,(Fn===null?r.memoizedState:Fn.next)===null&&(r=r.alternate,q.H=r===null||r.memoizedState===null?Nx:Jd),t}function Mc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Js(t);if(t.$$typeof===_)return Zn(t)}throw Error(i(438,String(t)))}function Ud(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=Rc(),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]=D;return r.index++,s}function Va(t,r){return typeof r=="function"?r(t):r}function zc(t){var r=An();return qd(r,tn,t)}function qd(t,r,s){var c=t.queue;if(c===null)throw Error(i(311));c.lastRenderedReducer=s;var p=t.baseQueue,y=c.pending;if(y!==null){if(p!==null){var S=p.next;p.next=y.next,y.next=S}r.baseQueue=p=y,c.pending=null}if(y=t.baseState,p===null)t.memoizedState=y;else{r=p.next;var z=S=null,X=null,ie=r,xe=!1;do{var Se=ie.lane&-536870913;if(Se!==ie.lane?(Ft&Se)===Se:(Wa&Se)===Se){var oe=ie.revertLane;if(oe===0)X!==null&&(X=X.next={lane:0,revertLane:0,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),Se===Ki&&(xe=!0);else if((Wa&oe)===oe){ie=ie.next,oe===Ki&&(xe=!0);continue}else Se={lane:0,revertLane:ie.revertLane,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},X===null?(z=X=Se,S=y):X=X.next=Se,gt.lanes|=oe,Tl|=oe;Se=ie.action,xi&&s(y,Se),y=ie.hasEagerState?ie.eagerState:s(y,Se)}else oe={lane:Se,revertLane:ie.revertLane,gesture:ie.gesture,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},X===null?(z=X=oe,S=y):X=X.next=oe,gt.lanes|=Se,Tl|=Se;ie=ie.next}while(ie!==null&&ie!==r);if(X===null?S=y:X.next=z,!Nr(y,t.memoizedState)&&(Rn=!0,xe&&(s=Pi,s!==null)))throw s;t.memoizedState=y,t.baseState=S,t.baseQueue=X,c.lastRenderedState=y}return p===null&&(c.lanes=0),[t.memoizedState,c.dispatch]}function Yd(t){var r=An(),s=r.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=t;var c=s.dispatch,p=s.pending,y=r.memoizedState;if(p!==null){s.pending=null;var S=p=p.next;do y=t(y,S.action),S=S.next;while(S!==p);Nr(y,r.memoizedState)||(Rn=!0),r.memoizedState=y,r.baseQueue===null&&(r.baseState=y),s.lastRenderedState=y}return[y,c]}function Vp(t,r,s){var c=gt,p=An(),y=$t;if(y){if(s===void 0)throw Error(i(407));s=s()}else s=r();var S=!Nr((tn||p).memoizedState,s);if(S&&(p.memoizedState=s,Rn=!0),p=p.queue,Vd(Pp.bind(null,c,p,t),[t]),p.getSnapshot!==r||S||Fn!==null&&Fn.memoizedState.tag&1){if(c.flags|=2048,ns(9,{destroy:void 0},Kp.bind(null,c,p,s,r),null),cn===null)throw Error(i(349));y||(Wa&127)!==0||Gp(c,r,s)}return s}function Gp(t,r,s){t.flags|=16384,t={getSnapshot:r,value:s},r=gt.updateQueue,r===null?(r=Rc(),gt.updateQueue=r,r.stores=[t]):(s=r.stores,s===null?r.stores=[t]:s.push(t))}function Kp(t,r,s,c){r.value=s,r.getSnapshot=c,Qp(r)&&Zp(t)}function Pp(t,r,s){return s(function(){Qp(r)&&Zp(t)})}function Qp(t){var r=t.getSnapshot;t=t.value;try{var s=r();return!Nr(t,s)}catch{return!0}}function Zp(t){var r=si(t,2);r!==null&&vr(r,t,2)}function Xd(t){var r=cr();if(typeof t=="function"){var s=t;if(t=s(),xi){at(!0);try{s()}finally{at(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Va,lastRenderedState:t},r}function Jp(t,r,s,c){return t.baseState=s,qd(t,tn,typeof c=="function"?c:Va)}function i2(t,r,s,c,p){if(Oc(t))throw Error(i(485));if(t=r.action,t!==null){var y={payload:p,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){y.listeners.push(S)}};q.T!==null?s(!0):y.isTransition=!1,c(y),s=r.pending,s===null?(y.next=r.pending=y,ex(r,y)):(y.next=s.next,r.pending=s.next=y)}}function ex(t,r){var s=r.action,c=r.payload,p=t.state;if(r.isTransition){var y=q.T,S={};q.T=S;try{var z=s(p,c),X=q.S;X!==null&&X(S,z),tx(t,r,z)}catch(ie){Wd(t,r,ie)}finally{y!==null&&S.types!==null&&(y.types=S.types),q.T=y}}else try{y=s(p,c),tx(t,r,y)}catch(ie){Wd(t,r,ie)}}function tx(t,r,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(c){nx(t,r,c)},function(c){return Wd(t,r,c)}):nx(t,r,s)}function nx(t,r,s){r.status="fulfilled",r.value=s,rx(r),t.state=s,r=t.pending,r!==null&&(s=r.next,s===r?t.pending=null:(s=s.next,r.next=s,ex(t,s)))}function Wd(t,r,s){var c=t.pending;if(t.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=s,rx(r),r=r.next;while(r!==c)}t.action=null}function rx(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function ax(t,r){return r}function lx(t,r){if($t){var s=cn.formState;if(s!==null){e:{var c=gt;if($t){if(xn){t:{for(var p=xn,y=Vr;p.nodeType!==8;){if(!y){p=null;break t}if(p=Kr(p.nextSibling),p===null){p=null;break t}}y=p.data,p=y==="F!"||y==="F"?p:null}if(p){xn=Kr(p.nextSibling),c=p.data==="F!";break e}}wl(c)}c=!1}c&&(r=s[0])}}return s=cr(),s.memoizedState=s.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ax,lastRenderedState:r},s.queue=c,s=Sx.bind(null,gt,c),c.dispatch=s,c=Xd(!1),y=Zd.bind(null,gt,!1,c.queue),c=cr(),p={state:r,dispatch:null,action:t,pending:null},c.queue=p,s=i2.bind(null,gt,p,y,s),p.dispatch=s,c.memoizedState=t,[r,s,!1]}function ix(t){var r=An();return sx(r,tn,t)}function sx(t,r,s){if(r=qd(t,r,ax)[0],t=zc(Va)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=Js(r)}catch(S){throw S===Qi?Sc:S}else c=r;r=An();var p=r.queue,y=p.dispatch;return s!==r.memoizedState&&(gt.flags|=2048,ns(9,{destroy:void 0},s2.bind(null,p,s),null)),[c,y,t]}function s2(t,r){t.action=r}function ox(t){var r=An(),s=tn;if(s!==null)return sx(r,s,t);An(),r=r.memoizedState,s=An();var c=s.queue.dispatch;return s.memoizedState=t,[r,c,!1]}function ns(t,r,s,c){return t={tag:t,create:s,deps:c,inst:r,next:null},r=gt.updateQueue,r===null&&(r=Rc(),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 cx(){return An().memoizedState}function _c(t,r,s,c){var p=cr();gt.flags|=t,p.memoizedState=ns(1|r,{destroy:void 0},s,c===void 0?null:c)}function Bc(t,r,s,c){var p=An();c=c===void 0?null:c;var y=p.memoizedState.inst;tn!==null&&c!==null&&Od(c,tn.memoizedState.deps)?p.memoizedState=ns(r,y,s,c):(gt.flags|=t,p.memoizedState=ns(1|r,y,s,c))}function ux(t,r){_c(8390656,8,t,r)}function Vd(t,r){Bc(2048,8,t,r)}function o2(t){gt.flags|=4;var r=gt.updateQueue;if(r===null)r=Rc(),gt.updateQueue=r,r.events=[t];else{var s=r.events;s===null?r.events=[t]:s.push(t)}}function dx(t){var r=An().memoizedState;return o2({ref:r,nextImpl:t}),function(){if((Vt&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function fx(t,r){return Bc(4,2,t,r)}function hx(t,r){return Bc(4,4,t,r)}function mx(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 px(t,r,s){s=s!=null?s.concat([t]):null,Bc(4,4,mx.bind(null,r,t),s)}function Gd(){}function xx(t,r){var s=An();r=r===void 0?null:r;var c=s.memoizedState;return r!==null&&Od(r,c[1])?c[0]:(s.memoizedState=[t,r],t)}function gx(t,r){var s=An();r=r===void 0?null:r;var c=s.memoizedState;if(r!==null&&Od(r,c[1]))return c[0];if(c=t(),xi){at(!0);try{t()}finally{at(!1)}}return s.memoizedState=[c,r],c}function Kd(t,r,s){return s===void 0||(Wa&1073741824)!==0&&(Ft&261930)===0?t.memoizedState=r:(t.memoizedState=s,t=y1(),gt.lanes|=t,Tl|=t,s)}function yx(t,r,s,c){return Nr(s,r)?s:Ji.current!==null?(t=Kd(t,s,c),Nr(t,r)||(Rn=!0),t):(Wa&42)===0||(Wa&1073741824)!==0&&(Ft&261930)===0?(Rn=!0,t.memoizedState=s):(t=y1(),gt.lanes|=t,Tl|=t,r)}function bx(t,r,s,c,p){var y=ce.p;ce.p=y!==0&&8>y?y:8;var S=q.T,z={};q.T=z,Zd(t,!1,r,s);try{var X=p(),ie=q.S;if(ie!==null&&ie(z,X),X!==null&&typeof X=="object"&&typeof X.then=="function"){var xe=r2(X,c);eo(t,r,xe,Mr(t))}else eo(t,r,c,Mr(t))}catch(Se){eo(t,r,{then:function(){},status:"rejected",reason:Se},Mr())}finally{ce.p=y,S!==null&&z.types!==null&&(S.types=z.types),q.T=S}}function c2(){}function Pd(t,r,s,c){if(t.tag!==5)throw Error(i(476));var p=vx(t).queue;bx(t,p,r,ue,s===null?c2:function(){return wx(t),s(c)})}function vx(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:ue,baseState:ue,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Va,lastRenderedState:ue},next:null};var s={};return r.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Va,lastRenderedState:s},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function wx(t){var r=vx(t);r.next===null&&(r=t.alternate.memoizedState),eo(t,r.next.queue,{},Mr())}function Qd(){return Zn(yo)}function kx(){return An().memoizedState}function jx(){return An().memoizedState}function u2(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=Mr();t=Sl(s);var c=Cl(r,t,s);c!==null&&(vr(c,r,s),Ks(c,r,s)),r={cache:Ed()},t.payload=r;return}r=r.return}}function d2(t,r,s){var c=Mr();s={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Oc(t)?Cx(r,s):(s=pd(t,r,s,c),s!==null&&(vr(s,t,c),Ex(s,r,c)))}function Sx(t,r,s){var c=Mr();eo(t,r,s,c)}function eo(t,r,s,c){var p={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Oc(t))Cx(r,p);else{var y=t.alternate;if(t.lanes===0&&(y===null||y.lanes===0)&&(y=r.lastRenderedReducer,y!==null))try{var S=r.lastRenderedState,z=y(S,s);if(p.hasEagerState=!0,p.eagerState=z,Nr(z,S))return gc(t,r,p,0),cn===null&&xc(),!1}catch{}finally{}if(s=pd(t,r,p,c),s!==null)return vr(s,t,c),Ex(s,r,c),!0}return!1}function Zd(t,r,s,c){if(c={lane:2,revertLane:Ff(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Oc(t)){if(r)throw Error(i(479))}else r=pd(t,s,c,2),r!==null&&vr(r,t,2)}function Oc(t){var r=t.alternate;return t===gt||r!==null&&r===gt}function Cx(t,r){es=Tc=!0;var s=t.pending;s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r}function Ex(t,r,s){if((s&4194048)!==0){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,hn(t,s)}}var to={readContext:Zn,use:Mc,useCallback:Cn,useContext:Cn,useEffect:Cn,useImperativeHandle:Cn,useLayoutEffect:Cn,useInsertionEffect:Cn,useMemo:Cn,useReducer:Cn,useRef:Cn,useState:Cn,useDebugValue:Cn,useDeferredValue:Cn,useTransition:Cn,useSyncExternalStore:Cn,useId:Cn,useHostTransitionStatus:Cn,useFormState:Cn,useActionState:Cn,useOptimistic:Cn,useMemoCache:Cn,useCacheRefresh:Cn};to.useEffectEvent=Cn;var Nx={readContext:Zn,use:Mc,useCallback:function(t,r){return cr().memoizedState=[t,r===void 0?null:r],t},useContext:Zn,useEffect:ux,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,_c(4194308,4,mx.bind(null,r,t),s)},useLayoutEffect:function(t,r){return _c(4194308,4,t,r)},useInsertionEffect:function(t,r){_c(4,2,t,r)},useMemo:function(t,r){var s=cr();r=r===void 0?null:r;var c=t();if(xi){at(!0);try{t()}finally{at(!1)}}return s.memoizedState=[c,r],c},useReducer:function(t,r,s){var c=cr();if(s!==void 0){var p=s(r);if(xi){at(!0);try{s(r)}finally{at(!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=d2.bind(null,gt,t),[c.memoizedState,t]},useRef:function(t){var r=cr();return t={current:t},r.memoizedState=t},useState:function(t){t=Xd(t);var r=t.queue,s=Sx.bind(null,gt,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:Gd,useDeferredValue:function(t,r){var s=cr();return Kd(s,t,r)},useTransition:function(){var t=Xd(!1);return t=bx.bind(null,gt,t.queue,!0,!1),cr().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var c=gt,p=cr();if($t){if(s===void 0)throw Error(i(407));s=s()}else{if(s=r(),cn===null)throw Error(i(349));(Ft&127)!==0||Gp(c,r,s)}p.memoizedState=s;var y={value:s,getSnapshot:r};return p.queue=y,ux(Pp.bind(null,c,y,t),[t]),c.flags|=2048,ns(9,{destroy:void 0},Kp.bind(null,c,y,s,r),null),s},useId:function(){var t=cr(),r=cn.identifierPrefix;if($t){var s=ya,c=ga;s=(c&~(1<<32-We(c)-1)).toString(32)+s,r="_"+r+"R_"+s,s=Fc++,0<s&&(r+="H"+s.toString(32)),r+="_"}else s=a2++,r="_"+r+"r_"+s.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Qd,useFormState:lx,useActionState:lx,useOptimistic:function(t){var r=cr();r.memoizedState=r.baseState=t;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=s,r=Zd.bind(null,gt,!0,s),s.dispatch=r,[t,r]},useMemoCache:Ud,useCacheRefresh:function(){return cr().memoizedState=u2.bind(null,gt)},useEffectEvent:function(t){var r=cr(),s={impl:t};return r.memoizedState=s,function(){if((Vt&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}},Jd={readContext:Zn,use:Mc,useCallback:xx,useContext:Zn,useEffect:Vd,useImperativeHandle:px,useInsertionEffect:fx,useLayoutEffect:hx,useMemo:gx,useReducer:zc,useRef:cx,useState:function(){return zc(Va)},useDebugValue:Gd,useDeferredValue:function(t,r){var s=An();return yx(s,tn.memoizedState,t,r)},useTransition:function(){var t=zc(Va)[0],r=An().memoizedState;return[typeof t=="boolean"?t:Js(t),r]},useSyncExternalStore:Vp,useId:kx,useHostTransitionStatus:Qd,useFormState:ix,useActionState:ix,useOptimistic:function(t,r){var s=An();return Jp(s,tn,t,r)},useMemoCache:Ud,useCacheRefresh:jx};Jd.useEffectEvent=dx;var Ax={readContext:Zn,use:Mc,useCallback:xx,useContext:Zn,useEffect:Vd,useImperativeHandle:px,useInsertionEffect:fx,useLayoutEffect:hx,useMemo:gx,useReducer:Yd,useRef:cx,useState:function(){return Yd(Va)},useDebugValue:Gd,useDeferredValue:function(t,r){var s=An();return tn===null?Kd(s,t,r):yx(s,tn.memoizedState,t,r)},useTransition:function(){var t=Yd(Va)[0],r=An().memoizedState;return[typeof t=="boolean"?t:Js(t),r]},useSyncExternalStore:Vp,useId:kx,useHostTransitionStatus:Qd,useFormState:ox,useActionState:ox,useOptimistic:function(t,r){var s=An();return tn!==null?Jp(s,tn,t,r):(s.baseState=t,[t,s.queue.dispatch])},useMemoCache:Ud,useCacheRefresh:jx};Ax.useEffectEvent=dx;function ef(t,r,s,c){r=t.memoizedState,s=s(c,r),s=s==null?r:g({},r,s),t.memoizedState=s,t.lanes===0&&(t.updateQueue.baseState=s)}var tf={enqueueSetState:function(t,r,s){t=t._reactInternals;var c=Mr(),p=Sl(c);p.payload=r,s!=null&&(p.callback=s),r=Cl(t,p,c),r!==null&&(vr(r,t,c),Ks(r,t,c))},enqueueReplaceState:function(t,r,s){t=t._reactInternals;var c=Mr(),p=Sl(c);p.tag=1,p.payload=r,s!=null&&(p.callback=s),r=Cl(t,p,c),r!==null&&(vr(r,t,c),Ks(r,t,c))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var s=Mr(),c=Sl(s);c.tag=2,r!=null&&(c.callback=r),r=Cl(t,c,s),r!==null&&(vr(r,t,s),Ks(r,t,s))}};function Dx(t,r,s,c,p,y,S){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,y,S):r.prototype&&r.prototype.isPureReactComponent?!Hs(s,c)||!Hs(p,y):!0}function Tx(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&&tf.enqueueReplaceState(r,r.state,null)}function gi(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=g({},s));for(var p in t)s[p]===void 0&&(s[p]=t[p])}return s}function Fx(t){pc(t)}function Rx(t){console.error(t)}function Mx(t){pc(t)}function $c(t,r){try{var s=t.onUncaughtError;s(r.value,{componentStack:r.stack})}catch(c){setTimeout(function(){throw c})}}function zx(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 nf(t,r,s){return s=Sl(s),s.tag=3,s.payload={element:null},s.callback=function(){$c(t,r)},s}function _x(t){return t=Sl(t),t.tag=3,t}function Bx(t,r,s,c){var p=s.type.getDerivedStateFromError;if(typeof p=="function"){var y=c.value;t.payload=function(){return p(y)},t.callback=function(){zx(r,s,c)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(t.callback=function(){zx(r,s,c),typeof p!="function"&&(Fl===null?Fl=new Set([this]):Fl.add(this));var z=c.stack;this.componentDidCatch(c.value,{componentStack:z!==null?z:""})})}function f2(t,r,s,c,p){if(s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=s.alternate,r!==null&&Gi(r,s,p,!0),s=Dr.current,s!==null){switch(s.tag){case 31:case 13:return Gr===null?Pc():s.alternate===null&&En===0&&(En=3),s.flags&=-257,s.flags|=65536,s.lanes=p,c===Cc?s.flags|=16384:(r=s.updateQueue,r===null?s.updateQueue=new Set([c]):r.add(c),Af(t,c,p)),!1;case 22:return s.flags|=65536,c===Cc?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)),Af(t,c,p)),!1}throw Error(i(435,s.tag))}return Af(t,c,p),Pc(),!1}if($t)return r=Dr.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,c!==wd&&(t=Error(i(422),{cause:c}),Ys(Yr(t,s)))):(c!==wd&&(r=Error(i(423),{cause:c}),Ys(Yr(r,s))),t=t.current.alternate,t.flags|=65536,p&=-p,t.lanes|=p,c=Yr(c,s),p=nf(t.stateNode,c,p),Rd(t,p),En!==4&&(En=2)),!1;var y=Error(i(520),{cause:c});if(y=Yr(y,s),co===null?co=[y]:co.push(y),En!==4&&(En=2),r===null)return!0;c=Yr(c,s),s=r;do{switch(s.tag){case 3:return s.flags|=65536,t=p&-p,s.lanes|=t,t=nf(s.stateNode,c,t),Rd(s,t),!1;case 1:if(r=s.type,y=s.stateNode,(s.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Fl===null||!Fl.has(y))))return s.flags|=65536,p&=-p,s.lanes|=p,p=_x(p),Bx(p,t,s,c),Rd(s,p),!1}s=s.return}while(s!==null);return!1}var rf=Error(i(461)),Rn=!1;function Jn(t,r,s,c){r.child=t===null?Ip(r,null,s,c):pi(r,t.child,s,c)}function Ox(t,r,s,c,p){s=s.render;var y=r.ref;if("ref"in c){var S={};for(var z in c)z!=="ref"&&(S[z]=c[z])}else S=c;return di(r),c=$d(t,r,s,S,y,p),z=Ld(),t!==null&&!Rn?(Id(t,r,p),Ga(t,r,p)):($t&&z&&bd(r),r.flags|=1,Jn(t,r,c,p),r.child)}function $x(t,r,s,c,p){if(t===null){var y=s.type;return typeof y=="function"&&!xd(y)&&y.defaultProps===void 0&&s.compare===null?(r.tag=15,r.type=y,Lx(t,r,y,c,p)):(t=bc(s.type,null,c,r,r.mode,p),t.ref=r.ref,t.return=r,r.child=t)}if(y=t.child,!ff(t,p)){var S=y.memoizedProps;if(s=s.compare,s=s!==null?s:Hs,s(S,c)&&t.ref===r.ref)return Ga(t,r,p)}return r.flags|=1,t=Ua(y,c),t.ref=r.ref,t.return=r,r.child=t}function Lx(t,r,s,c,p){if(t!==null){var y=t.memoizedProps;if(Hs(y,c)&&t.ref===r.ref)if(Rn=!1,r.pendingProps=c=y,ff(t,p))(t.flags&131072)!==0&&(Rn=!0);else return r.lanes=t.lanes,Ga(t,r,p)}return af(t,r,s,c,p)}function Ix(t,r,s,c){var p=c.children,y=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(y=y!==null?y.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&~y}else c=0,r.child=null;return Hx(t,r,y,s,c)}if((s&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&jc(r,y!==null?y.cachePool:null),y!==null?qp(r,y):zd(),Yp(r);else return c=r.lanes=536870912,Hx(t,r,y!==null?y.baseLanes|s:s,s,c)}else y!==null?(jc(r,y.cachePool),qp(r,y),Nl(),r.memoizedState=null):(t!==null&&jc(r,null),zd(),Nl());return Jn(t,r,p,s),r.child}function no(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Hx(t,r,s,c,p){var y=Ad();return y=y===null?null:{parent:Tn._currentValue,pool:y},r.memoizedState={baseLanes:s,cachePool:y},t!==null&&jc(r,null),zd(),Yp(r),t!==null&&Gi(t,r,c,!0),r.childLanes=p,null}function Lc(t,r){return r=Hc({mode:r.mode,children:r.children},t.mode),r.ref=t.ref,t.child=r,r.return=t,r}function Ux(t,r,s){return pi(r,t.child,null,s),t=Lc(r,r.pendingProps),t.flags|=2,Tr(r),r.memoizedState=null,t}function h2(t,r,s){var c=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,t===null){if($t){if(c.mode==="hidden")return t=Lc(r,c),r.lanes=536870912,no(null,t);if(Bd(r),(t=xn)?(t=e0(t,Vr),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:bl!==null?{id:ga,overflow:ya}:null,retryLane:536870912,hydrationErrors:null},s=Cp(t),s.return=r,r.child=s,Qn=r,xn=null)):t=null,t===null)throw wl(r);return r.lanes=536870912,null}return Lc(r,c)}var y=t.memoizedState;if(y!==null){var S=y.dehydrated;if(Bd(r),p)if(r.flags&256)r.flags&=-257,r=Ux(t,r,s);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(Rn||Gi(t,r,s,!1),p=(s&t.childLanes)!==0,Rn||p){if(c=cn,c!==null&&(S=ne(c,s),S!==0&&S!==y.retryLane))throw y.retryLane=S,si(t,S),vr(c,t,S),rf;Pc(),r=Ux(t,r,s)}else t=y.treeContext,xn=Kr(S.nextSibling),Qn=r,$t=!0,vl=null,Vr=!1,t!==null&&Ap(r,t),r=Lc(r,c),r.flags|=4096;return r}return t=Ua(t.child,{mode:c.mode,children:c.children}),t.ref=r.ref,r.child=t,t.return=r,t}function Ic(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 af(t,r,s,c,p){return di(r),s=$d(t,r,s,c,void 0,p),c=Ld(),t!==null&&!Rn?(Id(t,r,p),Ga(t,r,p)):($t&&c&&bd(r),r.flags|=1,Jn(t,r,s,p),r.child)}function qx(t,r,s,c,p,y){return di(r),r.updateQueue=null,s=Wp(r,c,s,p),Xp(t),c=Ld(),t!==null&&!Rn?(Id(t,r,y),Ga(t,r,y)):($t&&c&&bd(r),r.flags|=1,Jn(t,r,s,y),r.child)}function Yx(t,r,s,c,p){if(di(r),r.stateNode===null){var y=Yi,S=s.contextType;typeof S=="object"&&S!==null&&(y=Zn(S)),y=new s(c,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=tf,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=c,y.state=r.memoizedState,y.refs={},Td(r),S=s.contextType,y.context=typeof S=="object"&&S!==null?Zn(S):Yi,y.state=r.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(ef(r,s,S,c),y.state=r.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(S=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),S!==y.state&&tf.enqueueReplaceState(y,y.state,null),Qs(r,c,y,p),Ps(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(t===null){y=r.stateNode;var z=r.memoizedProps,X=gi(s,z);y.props=X;var ie=y.context,xe=s.contextType;S=Yi,typeof xe=="object"&&xe!==null&&(S=Zn(xe));var Se=s.getDerivedStateFromProps;xe=typeof Se=="function"||typeof y.getSnapshotBeforeUpdate=="function",z=r.pendingProps!==z,xe||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(z||ie!==S)&&Tx(r,y,c,S),jl=!1;var oe=r.memoizedState;y.state=oe,Qs(r,c,y,p),Ps(),ie=r.memoizedState,z||oe!==ie||jl?(typeof Se=="function"&&(ef(r,s,Se,c),ie=r.memoizedState),(X=jl||Dx(r,s,X,c,oe,ie,S))?(xe||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(r.flags|=4194308)):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=ie),y.props=c,y.state=ie,y.context=S,c=X):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{y=r.stateNode,Fd(t,r),S=r.memoizedProps,xe=gi(s,S),y.props=xe,Se=r.pendingProps,oe=y.context,ie=s.contextType,X=Yi,typeof ie=="object"&&ie!==null&&(X=Zn(ie)),z=s.getDerivedStateFromProps,(ie=typeof z=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==Se||oe!==X)&&Tx(r,y,c,X),jl=!1,oe=r.memoizedState,y.state=oe,Qs(r,c,y,p),Ps();var de=r.memoizedState;S!==Se||oe!==de||jl||t!==null&&t.dependencies!==null&&wc(t.dependencies)?(typeof z=="function"&&(ef(r,s,z,c),de=r.memoizedState),(xe=jl||Dx(r,s,xe,c,oe,de,X)||t!==null&&t.dependencies!==null&&wc(t.dependencies))?(ie||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(c,de,X),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(c,de,X)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===t.memoizedProps&&oe===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&oe===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=de),y.props=c,y.state=de,y.context=X,c=xe):(typeof y.componentDidUpdate!="function"||S===t.memoizedProps&&oe===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&oe===t.memoizedState||(r.flags|=1024),c=!1)}return y=c,Ic(t,r),c=(r.flags&128)!==0,y||c?(y=r.stateNode,s=c&&typeof s.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,t!==null&&c?(r.child=pi(r,t.child,null,p),r.child=pi(r,null,s,p)):Jn(t,r,s,p),r.memoizedState=y.state,t=r.child):t=Ga(t,r,p),t}function Xx(t,r,s,c){return ci(),r.flags|=256,Jn(t,r,s,c),r.child}var lf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function sf(t){return{baseLanes:t,cachePool:zp()}}function of(t,r,s){return t=t!==null?t.childLanes&~s:0,r&&(t|=Rr),t}function Wx(t,r,s){var c=r.pendingProps,p=!1,y=(r.flags&128)!==0,S;if((S=y)||(S=t!==null&&t.memoizedState===null?!1:(Nn.current&2)!==0),S&&(p=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,t===null){if($t){if(p?El(r):Nl(),(t=xn)?(t=e0(t,Vr),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:bl!==null?{id:ga,overflow:ya}:null,retryLane:536870912,hydrationErrors:null},s=Cp(t),s.return=r,r.child=s,Qn=r,xn=null)):t=null,t===null)throw wl(r);return Yf(t)?r.lanes=32:r.lanes=536870912,null}var z=c.children;return c=c.fallback,p?(Nl(),p=r.mode,z=Hc({mode:"hidden",children:z},p),c=oi(c,p,s,null),z.return=r,c.return=r,z.sibling=c,r.child=z,c=r.child,c.memoizedState=sf(s),c.childLanes=of(t,S,s),r.memoizedState=lf,no(null,c)):(El(r),cf(r,z))}var X=t.memoizedState;if(X!==null&&(z=X.dehydrated,z!==null)){if(y)r.flags&256?(El(r),r.flags&=-257,r=uf(t,r,s)):r.memoizedState!==null?(Nl(),r.child=t.child,r.flags|=128,r=null):(Nl(),z=c.fallback,p=r.mode,c=Hc({mode:"visible",children:c.children},p),z=oi(z,p,s,null),z.flags|=2,c.return=r,z.return=r,c.sibling=z,r.child=c,pi(r,t.child,null,s),c=r.child,c.memoizedState=sf(s),c.childLanes=of(t,S,s),r.memoizedState=lf,r=no(null,c));else if(El(r),Yf(z)){if(S=z.nextSibling&&z.nextSibling.dataset,S)var ie=S.dgst;S=ie,c=Error(i(419)),c.stack="",c.digest=S,Ys({value:c,source:null,stack:null}),r=uf(t,r,s)}else if(Rn||Gi(t,r,s,!1),S=(s&t.childLanes)!==0,Rn||S){if(S=cn,S!==null&&(c=ne(S,s),c!==0&&c!==X.retryLane))throw X.retryLane=c,si(t,c),vr(S,t,c),rf;qf(z)||Pc(),r=uf(t,r,s)}else qf(z)?(r.flags|=192,r.child=t.child,r=null):(t=X.treeContext,xn=Kr(z.nextSibling),Qn=r,$t=!0,vl=null,Vr=!1,t!==null&&Ap(r,t),r=cf(r,c.children),r.flags|=4096);return r}return p?(Nl(),z=c.fallback,p=r.mode,X=t.child,ie=X.sibling,c=Ua(X,{mode:"hidden",children:c.children}),c.subtreeFlags=X.subtreeFlags&65011712,ie!==null?z=Ua(ie,z):(z=oi(z,p,s,null),z.flags|=2),z.return=r,c.return=r,c.sibling=z,r.child=c,no(null,c),c=r.child,z=t.child.memoizedState,z===null?z=sf(s):(p=z.cachePool,p!==null?(X=Tn._currentValue,p=p.parent!==X?{parent:X,pool:X}:p):p=zp(),z={baseLanes:z.baseLanes|s,cachePool:p}),c.memoizedState=z,c.childLanes=of(t,S,s),r.memoizedState=lf,no(t.child,c)):(El(r),s=t.child,t=s.sibling,s=Ua(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 cf(t,r){return r=Hc({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function Hc(t,r){return t=Ar(22,t,null,r),t.lanes=0,t}function uf(t,r,s){return pi(r,t.child,null,s),t=cf(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Vx(t,r,s){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Sd(t.return,r,s)}function df(t,r,s,c,p,y){var S=t.memoizedState;S===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:s,tailMode:p,treeForkCount:y}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=c,S.tail=s,S.tailMode=p,S.treeForkCount=y)}function Gx(t,r,s){var c=r.pendingProps,p=c.revealOrder,y=c.tail;c=c.children;var S=Nn.current,z=(S&2)!==0;if(z?(S=S&1|2,r.flags|=128):S&=1,T(Nn,S),Jn(t,r,c,s),c=$t?qs:0,!z&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Vx(t,s,r);else if(t.tag===19)Vx(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&&Dc(t)===null&&(p=s),s=s.sibling;s=p,s===null?(p=r.child,r.child=null):(p=s.sibling,s.sibling=null),df(r,!1,p,s,y,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&&Dc(t)===null){r.child=p;break}t=p.sibling,p.sibling=s,s=p,p=t}df(r,!0,s,null,y,c);break;case"together":df(r,!1,null,null,void 0,c);break;default:r.memoizedState=null}return r.child}function Ga(t,r,s){if(t!==null&&(r.dependencies=t.dependencies),Tl|=r.lanes,(s&r.childLanes)===0)if(t!==null){if(Gi(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=Ua(t,t.pendingProps),r.child=s,s.return=r;t.sibling!==null;)t=t.sibling,s=s.sibling=Ua(t,t.pendingProps),s.return=r;s.sibling=null}return r.child}function ff(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&wc(t)))}function m2(t,r,s){switch(r.tag){case 3:Le(r,r.stateNode.containerInfo),kl(r,Tn,t.memoizedState.cache),ci();break;case 27:case 5:et(r);break;case 4:Le(r,r.stateNode.containerInfo);break;case 10:kl(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Bd(r),null;break;case 13:var c=r.memoizedState;if(c!==null)return c.dehydrated!==null?(El(r),r.flags|=128,null):(s&r.child.childLanes)!==0?Wx(t,r,s):(El(r),t=Ga(t,r,s),t!==null?t.sibling:null);El(r);break;case 19:var p=(t.flags&128)!==0;if(c=(s&r.childLanes)!==0,c||(Gi(t,r,s,!1),c=(s&r.childLanes)!==0),p){if(c)return Gx(t,r,s);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),T(Nn,Nn.current),c)break;return null;case 22:return r.lanes=0,Ix(t,r,s,r.pendingProps);case 24:kl(r,Tn,t.memoizedState.cache)}return Ga(t,r,s)}function Kx(t,r,s){if(t!==null)if(t.memoizedProps!==r.pendingProps)Rn=!0;else{if(!ff(t,s)&&(r.flags&128)===0)return Rn=!1,m2(t,r,s);Rn=(t.flags&131072)!==0}else Rn=!1,$t&&(r.flags&1048576)!==0&&Np(r,qs,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(t=hi(r.elementType),r.type=t,typeof t=="function")xd(t)?(c=gi(t,c),r.tag=1,r=Yx(null,r,t,c,s)):(r.tag=0,r=af(null,r,t,c,s));else{if(t!=null){var p=t.$$typeof;if(p===M){r.tag=11,r=Ox(null,r,t,c,s);break e}else if(p===I){r.tag=14,r=$x(null,r,t,c,s);break e}}throw r=re(t)||t,Error(i(306,r,""))}}return r;case 0:return af(t,r,r.type,r.pendingProps,s);case 1:return c=r.type,p=gi(c,r.pendingProps),Yx(t,r,c,p,s);case 3:e:{if(Le(r,r.stateNode.containerInfo),t===null)throw Error(i(387));c=r.pendingProps;var y=r.memoizedState;p=y.element,Fd(t,r),Qs(r,c,null,s);var S=r.memoizedState;if(c=S.cache,kl(r,Tn,c),c!==y.cache&&Cd(r,[Tn],s,!0),Ps(),c=S.element,y.isDehydrated)if(y={element:c,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=Xx(t,r,c,s);break e}else if(c!==p){p=Yr(Error(i(424)),r),Ys(p),r=Xx(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(xn=Kr(t.firstChild),Qn=r,$t=!0,vl=null,Vr=!0,s=Ip(r,null,c,s),r.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(ci(),c===p){r=Ga(t,r,s);break e}Jn(t,r,c,s)}r=r.child}return r;case 26:return Ic(t,r),t===null?(s=i0(r.type,null,r.pendingProps,null))?r.memoizedState=s:$t||(s=r.type,t=r.pendingProps,c=ru(he.current).createElement(s),c[yn]=r,c[mn]=t,er(c,s,t),Dn(c),r.stateNode=c):r.memoizedState=i0(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return et(r),t===null&&$t&&(c=r.stateNode=r0(r.type,r.pendingProps,he.current),Qn=r,Vr=!0,p=xn,_l(r.type)?(Xf=p,xn=Kr(c.firstChild)):xn=p),Jn(t,r,r.pendingProps.children,s),Ic(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&$t&&((p=c=xn)&&(c=Y2(c,r.type,r.pendingProps,Vr),c!==null?(r.stateNode=c,Qn=r,xn=Kr(c.firstChild),Vr=!1,p=!0):p=!1),p||wl(r)),et(r),p=r.type,y=r.pendingProps,S=t!==null?t.memoizedProps:null,c=y.children,If(p,y)?c=null:S!==null&&If(p,S)&&(r.flags|=32),r.memoizedState!==null&&(p=$d(t,r,l2,null,null,s),yo._currentValue=p),Ic(t,r),Jn(t,r,c,s),r.child;case 6:return t===null&&$t&&((t=s=xn)&&(s=X2(s,r.pendingProps,Vr),s!==null?(r.stateNode=s,Qn=r,xn=null,t=!0):t=!1),t||wl(r)),null;case 13:return Wx(t,r,s);case 4:return Le(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=pi(r,null,c,s):Jn(t,r,c,s),r.child;case 11:return Ox(t,r,r.type,r.pendingProps,s);case 7:return Jn(t,r,r.pendingProps,s),r.child;case 8:return Jn(t,r,r.pendingProps.children,s),r.child;case 12:return Jn(t,r,r.pendingProps.children,s),r.child;case 10:return c=r.pendingProps,kl(r,r.type,c.value),Jn(t,r,c.children,s),r.child;case 9:return p=r.type._context,c=r.pendingProps.children,di(r),p=Zn(p),c=c(p),r.flags|=1,Jn(t,r,c,s),r.child;case 14:return $x(t,r,r.type,r.pendingProps,s);case 15:return Lx(t,r,r.type,r.pendingProps,s);case 19:return Gx(t,r,s);case 31:return h2(t,r,s);case 22:return Ix(t,r,s,r.pendingProps);case 24:return di(r),c=Zn(Tn),t===null?(p=Ad(),p===null&&(p=cn,y=Ed(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=s),p=y),r.memoizedState={parent:c,cache:p},Td(r),kl(r,Tn,p)):((t.lanes&s)!==0&&(Fd(t,r),Qs(r,null,null,s),Ps()),p=t.memoizedState,y=r.memoizedState,p.parent!==c?(p={parent:c,cache:c},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),kl(r,Tn,c)):(c=y.cache,kl(r,Tn,c),c!==p.cache&&Cd(r,[Tn],s,!0))),Jn(t,r,r.pendingProps.children,s),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Ka(t){t.flags|=4}function hf(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(k1())t.flags|=8192;else throw mi=Cc,Dd}else t.flags&=-16777217}function Px(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!d0(r))if(k1())t.flags|=8192;else throw mi=Cc,Dd}function Uc(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?lt():536870912,t.lanes|=r,is|=r)}function ro(t,r){if(!$t)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 gn(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 p2(t,r,s){var c=r.pendingProps;switch(vd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gn(r),null;case 1:return gn(r),null;case 3:return s=r.stateNode,c=null,t!==null&&(c=t.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),Xa(Tn),Ue(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(Vi(r)?Ka(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,kd())),gn(r),null;case 26:var p=r.type,y=r.memoizedState;return t===null?(Ka(r),y!==null?(gn(r),Px(r,y)):(gn(r),hf(r,p,null,c,s))):y?y!==t.memoizedState?(Ka(r),gn(r),Px(r,y)):(gn(r),r.flags&=-16777217):(t=t.memoizedProps,t!==c&&Ka(r),gn(r),hf(r,p,t,c,s)),null;case 27:if(Pe(r),s=he.current,p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ka(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return gn(r),null}t=se.current,Vi(r)?Dp(r):(t=r0(p,c,s),r.stateNode=t,Ka(r))}return gn(r),null;case 5:if(Pe(r),p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ka(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return gn(r),null}if(y=se.current,Vi(r))Dp(r);else{var S=ru(he.current);switch(y){case 1:y=S.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:y=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":y=S.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":y=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":y=S.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof c.is=="string"?S.createElement("select",{is:c.is}):S.createElement("select"),c.multiple?y.multiple=!0:c.size&&(y.size=c.size);break;default:y=typeof c.is=="string"?S.createElement(p,{is:c.is}):S.createElement(p)}}y[yn]=r,y[mn]=c;e:for(S=r.child;S!==null;){if(S.tag===5||S.tag===6)y.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=y;e:switch(er(y,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&&Ka(r)}}return gn(r),hf(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==c&&Ka(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(i(166));if(t=he.current,Vi(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[yn]=r,t=!!(t.nodeValue===s||c!==null&&c.suppressHydrationWarning===!0||W1(t.nodeValue,s)),t||wl(r,!0)}else t=ru(t).createTextNode(c),t[yn]=r,r.stateNode=t}return gn(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(c=Vi(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[yn]=r}else ci(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;gn(r),t=!1}else s=kd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return r.flags&256?(Tr(r),r):(Tr(r),null);if((r.flags&128)!==0)throw Error(i(558))}return gn(r),null;case 13:if(c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=Vi(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[yn]=r}else ci(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;gn(r),p=!1}else p=kd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(Tr(r),r):(Tr(r),null)}return Tr(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),y=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(y=c.memoizedState.cachePool.pool),y!==p&&(c.flags|=2048)),s!==t&&s&&(r.child.flags|=8192),Uc(r,r.updateQueue),gn(r),null);case 4:return Ue(),t===null&&_f(r.stateNode.containerInfo),gn(r),null;case 10:return Xa(r.type),gn(r),null;case 19:if(U(Nn),c=r.memoizedState,c===null)return gn(r),null;if(p=(r.flags&128)!==0,y=c.rendering,y===null)if(p)ro(c,!1);else{if(En!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(y=Dc(t),y!==null){for(r.flags|=128,ro(c,!1),t=y.updateQueue,r.updateQueue=t,Uc(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)Sp(s,t),s=s.sibling;return T(Nn,Nn.current&1|2),$t&&qa(r,c.treeForkCount),r.child}t=t.sibling}c.tail!==null&&je()>Vc&&(r.flags|=128,p=!0,ro(c,!1),r.lanes=4194304)}else{if(!p)if(t=Dc(y),t!==null){if(r.flags|=128,p=!0,t=t.updateQueue,r.updateQueue=t,Uc(r,t),ro(c,!0),c.tail===null&&c.tailMode==="hidden"&&!y.alternate&&!$t)return gn(r),null}else 2*je()-c.renderingStartTime>Vc&&s!==536870912&&(r.flags|=128,p=!0,ro(c,!1),r.lanes=4194304);c.isBackwards?(y.sibling=r.child,r.child=y):(t=c.last,t!==null?t.sibling=y:r.child=y,c.last=y)}return c.tail!==null?(t=c.tail,c.rendering=t,c.tail=t.sibling,c.renderingStartTime=je(),t.sibling=null,s=Nn.current,T(Nn,p?s&1|2:s&1),$t&&qa(r,c.treeForkCount),t):(gn(r),null);case 22:case 23:return Tr(r),_d(),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&&(gn(r),r.subtreeFlags&6&&(r.flags|=8192)):gn(r),s=r.updateQueue,s!==null&&Uc(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&&U(fi),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),Xa(Tn),gn(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function x2(t,r){switch(vd(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return Xa(Tn),Ue(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return Pe(r),null;case 31:if(r.memoizedState!==null){if(Tr(r),r.alternate===null)throw Error(i(340));ci()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(Tr(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(i(340));ci()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return U(Nn),null;case 4:return Ue(),null;case 10:return Xa(r.type),null;case 22:case 23:return Tr(r),_d(),t!==null&&U(fi),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return Xa(Tn),null;case 25:return null;default:return null}}function Qx(t,r){switch(vd(r),r.tag){case 3:Xa(Tn),Ue();break;case 26:case 27:case 5:Pe(r);break;case 4:Ue();break;case 31:r.memoizedState!==null&&Tr(r);break;case 13:Tr(r);break;case 19:U(Nn);break;case 10:Xa(r.type);break;case 22:case 23:Tr(r),_d(),t!==null&&U(fi);break;case 24:Xa(Tn)}}function ao(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 y=s.create,S=s.inst;c=y(),S.destroy=c}s=s.next}while(s!==p)}}catch(z){Zt(r,r.return,z)}}function Al(t,r,s){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var y=p.next;c=y;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,ie=z;try{ie()}catch(xe){Zt(p,X,xe)}}}c=c.next}while(c!==y)}}catch(xe){Zt(r,r.return,xe)}}function Zx(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{Up(r,s)}catch(c){Zt(t,t.return,c)}}}function Jx(t,r,s){s.props=gi(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(c){Zt(t,r,c)}}function lo(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){Zt(t,r,p)}}function ba(t,r){var s=t.ref,c=t.refCleanup;if(s!==null)if(typeof c=="function")try{c()}catch(p){Zt(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){Zt(t,r,p)}else s.current=null}function e1(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){Zt(t,t.return,p)}}function mf(t,r,s){try{var c=t.stateNode;$2(c,t.type,s,r),c[mn]=r}catch(p){Zt(t,t.return,p)}}function t1(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&_l(t.type)||t.tag===4}function pf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||t1(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&&_l(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 xf(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=mr));else if(c!==4&&(c===27&&_l(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(xf(t,r,s),t=t.sibling;t!==null;)xf(t,r,s),t=t.sibling}function qc(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&&_l(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(qc(t,r,s),t=t.sibling;t!==null;)qc(t,r,s),t=t.sibling}function n1(t){var r=t.stateNode,s=t.memoizedProps;try{for(var c=t.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);er(r,c,s),r[yn]=t,r[mn]=s}catch(y){Zt(t,t.return,y)}}var Pa=!1,Mn=!1,gf=!1,r1=typeof WeakSet=="function"?WeakSet:Set,Xn=null;function g2(t,r){if(t=t.containerInfo,$f=uu,t=pp(t),cd(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,y=c.focusNode;c=c.focusOffset;try{s.nodeType,y.nodeType}catch{s=null;break e}var S=0,z=-1,X=-1,ie=0,xe=0,Se=t,oe=null;t:for(;;){for(var de;Se!==s||p!==0&&Se.nodeType!==3||(z=S+p),Se!==y||c!==0&&Se.nodeType!==3||(X=S+c),Se.nodeType===3&&(S+=Se.nodeValue.length),(de=Se.firstChild)!==null;)oe=Se,Se=de;for(;;){if(Se===t)break t;if(oe===s&&++ie===p&&(z=S),oe===y&&++xe===c&&(X=S),(de=Se.nextSibling)!==null)break;Se=oe,oe=Se.parentNode}Se=de}s=z===-1||X===-1?null:{start:z,end:X}}else s=null}s=s||{start:0,end:0}}else s=null;for(Lf={focusedElem:t,selectionRange:s},uu=!1,Xn=r;Xn!==null;)if(r=Xn,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,Xn=t;else for(;Xn!==null;){switch(r=Xn,y=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&&y!==null){t=void 0,s=r,p=y.memoizedProps,y=y.memoizedState,c=s.stateNode;try{var Ye=gi(s.type,p);t=c.getSnapshotBeforeUpdate(Ye,y),c.__reactInternalSnapshotBeforeUpdate=t}catch(st){Zt(s,s.return,st)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,s=t.nodeType,s===9)Uf(t);else if(s===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Uf(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,Xn=t;break}Xn=r.return}}function a1(t,r,s){var c=s.flags;switch(s.tag){case 0:case 11:case 15:Za(t,s),c&4&&ao(5,s);break;case 1:if(Za(t,s),c&4)if(t=s.stateNode,r===null)try{t.componentDidMount()}catch(S){Zt(s,s.return,S)}else{var p=gi(s.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(p,r,t.__reactInternalSnapshotBeforeUpdate)}catch(S){Zt(s,s.return,S)}}c&64&&Zx(s),c&512&&lo(s,s.return);break;case 3:if(Za(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{Up(t,r)}catch(S){Zt(s,s.return,S)}}break;case 27:r===null&&c&4&&n1(s);case 26:case 5:Za(t,s),r===null&&c&4&&e1(s),c&512&&lo(s,s.return);break;case 12:Za(t,s);break;case 31:Za(t,s),c&4&&s1(t,s);break;case 13:Za(t,s),c&4&&o1(t,s),c&64&&(t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(s=E2.bind(null,s),W2(t,s))));break;case 22:if(c=s.memoizedState!==null||Pa,!c){r=r!==null&&r.memoizedState!==null||Mn,p=Pa;var y=Mn;Pa=c,(Mn=r)&&!y?Ja(t,s,(s.subtreeFlags&8772)!==0):Za(t,s),Pa=p,Mn=y}break;case 30:break;default:Za(t,s)}}function l1(t){var r=t.alternate;r!==null&&(t.alternate=null,l1(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&Rs(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 bn=null,xr=!1;function Qa(t,r,s){for(s=s.child;s!==null;)i1(t,r,s),s=s.sibling}function i1(t,r,s){if(qe&&typeof qe.onCommitFiberUnmount=="function")try{qe.onCommitFiberUnmount(Oe,s)}catch{}switch(s.tag){case 26:Mn||ba(s,r),Qa(t,r,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:Mn||ba(s,r);var c=bn,p=xr;_l(s.type)&&(bn=s.stateNode,xr=!1),Qa(t,r,s),po(s.stateNode),bn=c,xr=p;break;case 5:Mn||ba(s,r);case 6:if(c=bn,p=xr,bn=null,Qa(t,r,s),bn=c,xr=p,bn!==null)if(xr)try{(bn.nodeType===9?bn.body:bn.nodeName==="HTML"?bn.ownerDocument.body:bn).removeChild(s.stateNode)}catch(y){Zt(s,r,y)}else try{bn.removeChild(s.stateNode)}catch(y){Zt(s,r,y)}break;case 18:bn!==null&&(xr?(t=bn,Z1(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,s.stateNode),ms(t)):Z1(bn,s.stateNode));break;case 4:c=bn,p=xr,bn=s.stateNode.containerInfo,xr=!0,Qa(t,r,s),bn=c,xr=p;break;case 0:case 11:case 14:case 15:Al(2,s,r),Mn||Al(4,s,r),Qa(t,r,s);break;case 1:Mn||(ba(s,r),c=s.stateNode,typeof c.componentWillUnmount=="function"&&Jx(s,r,c)),Qa(t,r,s);break;case 21:Qa(t,r,s);break;case 22:Mn=(c=Mn)||s.memoizedState!==null,Qa(t,r,s),Mn=c;break;default:Qa(t,r,s)}}function s1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{ms(t)}catch(s){Zt(r,r.return,s)}}}function o1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{ms(t)}catch(s){Zt(r,r.return,s)}}function y2(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new r1),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new r1),r;default:throw Error(i(435,t.tag))}}function Yc(t,r){var s=y2(t);r.forEach(function(c){if(!s.has(c)){s.add(c);var p=N2.bind(null,t,c);c.then(p,p)}})}function gr(t,r){var s=r.deletions;if(s!==null)for(var c=0;c<s.length;c++){var p=s[c],y=t,S=r,z=S;e:for(;z!==null;){switch(z.tag){case 27:if(_l(z.type)){bn=z.stateNode,xr=!1;break e}break;case 5:bn=z.stateNode,xr=!1;break e;case 3:case 4:bn=z.stateNode.containerInfo,xr=!0;break e}z=z.return}if(bn===null)throw Error(i(160));i1(y,S,p),bn=null,xr=!1,y=p.alternate,y!==null&&(y.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)c1(r,t),r=r.sibling}var la=null;function c1(t,r){var s=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:gr(r,t),yr(t),c&4&&(Al(3,t,t.return),ao(3,t),Al(5,t,t.return));break;case 1:gr(r,t),yr(t),c&512&&(Mn||s===null||ba(s,s.return)),c&64&&Pa&&(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=la;if(gr(r,t),yr(t),c&512&&(Mn||s===null||ba(s,s.return)),c&4){var y=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":y=p.getElementsByTagName("title")[0],(!y||y[Ra]||y[yn]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=p.createElement(c),p.head.insertBefore(y,p.querySelector("head > title"))),er(y,c,s),y[yn]=t,Dn(y),c=y;break e;case"link":var S=c0("link","href",p).get(c+(s.href||""));if(S){for(var z=0;z<S.length;z++)if(y=S[z],y.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&y.getAttribute("rel")===(s.rel==null?null:s.rel)&&y.getAttribute("title")===(s.title==null?null:s.title)&&y.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(z,1);break t}}y=p.createElement(c),er(y,c,s),p.head.appendChild(y);break;case"meta":if(S=c0("meta","content",p).get(c+(s.content||""))){for(z=0;z<S.length;z++)if(y=S[z],y.getAttribute("content")===(s.content==null?null:""+s.content)&&y.getAttribute("name")===(s.name==null?null:s.name)&&y.getAttribute("property")===(s.property==null?null:s.property)&&y.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&y.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(z,1);break t}}y=p.createElement(c),er(y,c,s),p.head.appendChild(y);break;default:throw Error(i(468,c))}y[yn]=t,Dn(y),c=y}t.stateNode=c}else u0(p,t.type,t.stateNode);else t.stateNode=o0(p,c,t.memoizedProps);else y!==c?(y===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):y.count--,c===null?u0(p,t.type,t.stateNode):o0(p,c,t.memoizedProps)):c===null&&t.stateNode!==null&&mf(t,t.memoizedProps,s.memoizedProps)}break;case 27:gr(r,t),yr(t),c&512&&(Mn||s===null||ba(s,s.return)),s!==null&&c&4&&mf(t,t.memoizedProps,s.memoizedProps);break;case 5:if(gr(r,t),yr(t),c&512&&(Mn||s===null||ba(s,s.return)),t.flags&32){p=t.stateNode;try{fl(p,"")}catch(Ye){Zt(t,t.return,Ye)}}c&4&&t.stateNode!=null&&(p=t.memoizedProps,mf(t,p,s!==null?s.memoizedProps:p)),c&1024&&(gf=!0);break;case 6:if(gr(r,t),yr(t),c&4){if(t.stateNode===null)throw Error(i(162));c=t.memoizedProps,s=t.stateNode;try{s.nodeValue=c}catch(Ye){Zt(t,t.return,Ye)}}break;case 3:if(iu=null,p=la,la=au(r.containerInfo),gr(r,t),la=p,yr(t),c&4&&s!==null&&s.memoizedState.isDehydrated)try{ms(r.containerInfo)}catch(Ye){Zt(t,t.return,Ye)}gf&&(gf=!1,u1(t));break;case 4:c=la,la=au(t.stateNode.containerInfo),gr(r,t),yr(t),la=c;break;case 12:gr(r,t),yr(t);break;case 31:gr(r,t),yr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Yc(t,c)));break;case 13:gr(r,t),yr(t),t.child.flags&8192&&t.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Wc=je()),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Yc(t,c)));break;case 22:p=t.memoizedState!==null;var X=s!==null&&s.memoizedState!==null,ie=Pa,xe=Mn;if(Pa=ie||p,Mn=xe||X,gr(r,t),Mn=xe,Pa=ie,yr(t),c&8192)e:for(r=t.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(s===null||X||Pa||Mn||yi(t)),s=null,r=t;;){if(r.tag===5||r.tag===26){if(s===null){X=s=r;try{if(y=X.stateNode,p)S=y.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{z=X.stateNode;var Se=X.memoizedProps.style,oe=Se!=null&&Se.hasOwnProperty("display")?Se.display:null;z.style.display=oe==null||typeof oe=="boolean"?"":(""+oe).trim()}}catch(Ye){Zt(X,X.return,Ye)}}}else if(r.tag===6){if(s===null){X=r;try{X.stateNode.nodeValue=p?"":X.memoizedProps}catch(Ye){Zt(X,X.return,Ye)}}}else if(r.tag===18){if(s===null){X=r;try{var de=X.stateNode;p?J1(de,!0):J1(X.stateNode,!1)}catch(Ye){Zt(X,X.return,Ye)}}}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,Yc(t,s))));break;case 19:gr(r,t),yr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,Yc(t,c)));break;case 30:break;case 21:break;default:gr(r,t),yr(t)}}function yr(t){var r=t.flags;if(r&2){try{for(var s,c=t.return;c!==null;){if(t1(c)){s=c;break}c=c.return}if(s==null)throw Error(i(160));switch(s.tag){case 27:var p=s.stateNode,y=pf(t);qc(t,y,p);break;case 5:var S=s.stateNode;s.flags&32&&(fl(S,""),s.flags&=-33);var z=pf(t);qc(t,z,S);break;case 3:case 4:var X=s.stateNode.containerInfo,ie=pf(t);xf(t,ie,X);break;default:throw Error(i(161))}}catch(xe){Zt(t,t.return,xe)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function u1(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;u1(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),t=t.sibling}}function Za(t,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)a1(t,r.alternate,r),r=r.sibling}function yi(t){for(t=t.child;t!==null;){var r=t;switch(r.tag){case 0:case 11:case 14:case 15:Al(4,r,r.return),yi(r);break;case 1:ba(r,r.return);var s=r.stateNode;typeof s.componentWillUnmount=="function"&&Jx(r,r.return,s),yi(r);break;case 27:po(r.stateNode);case 26:case 5:ba(r,r.return),yi(r);break;case 22:r.memoizedState===null&&yi(r);break;case 30:yi(r);break;default:yi(r)}t=t.sibling}}function Ja(t,r,s){for(s=s&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var c=r.alternate,p=t,y=r,S=y.flags;switch(y.tag){case 0:case 11:case 15:Ja(p,y,s),ao(4,y);break;case 1:if(Ja(p,y,s),c=y,p=c.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(ie){Zt(c,c.return,ie)}if(c=y,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++)Hp(X[p],z)}catch(ie){Zt(c,c.return,ie)}}s&&S&64&&Zx(y),lo(y,y.return);break;case 27:n1(y);case 26:case 5:Ja(p,y,s),s&&c===null&&S&4&&e1(y),lo(y,y.return);break;case 12:Ja(p,y,s);break;case 31:Ja(p,y,s),s&&S&4&&s1(p,y);break;case 13:Ja(p,y,s),s&&S&4&&o1(p,y);break;case 22:y.memoizedState===null&&Ja(p,y,s),lo(y,y.return);break;case 30:break;default:Ja(p,y,s)}r=r.sibling}}function yf(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&&Xs(s))}function bf(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&Xs(t))}function ia(t,r,s,c){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)d1(t,r,s,c),r=r.sibling}function d1(t,r,s,c){var p=r.flags;switch(r.tag){case 0:case 11:case 15:ia(t,r,s,c),p&2048&&ao(9,r);break;case 1:ia(t,r,s,c);break;case 3:ia(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&&Xs(t)));break;case 12:if(p&2048){ia(t,r,s,c),t=r.stateNode;try{var y=r.memoizedProps,S=y.id,z=y.onPostCommit;typeof z=="function"&&z(S,r.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(X){Zt(r,r.return,X)}}else ia(t,r,s,c);break;case 31:ia(t,r,s,c);break;case 13:ia(t,r,s,c);break;case 23:break;case 22:y=r.stateNode,S=r.alternate,r.memoizedState!==null?y._visibility&2?ia(t,r,s,c):io(t,r):y._visibility&2?ia(t,r,s,c):(y._visibility|=2,rs(t,r,s,c,(r.subtreeFlags&10256)!==0||!1)),p&2048&&yf(S,r);break;case 24:ia(t,r,s,c),p&2048&&bf(r.alternate,r);break;default:ia(t,r,s,c)}}function rs(t,r,s,c,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var y=t,S=r,z=s,X=c,ie=S.flags;switch(S.tag){case 0:case 11:case 15:rs(y,S,z,X,p),ao(8,S);break;case 23:break;case 22:var xe=S.stateNode;S.memoizedState!==null?xe._visibility&2?rs(y,S,z,X,p):io(y,S):(xe._visibility|=2,rs(y,S,z,X,p)),p&&ie&2048&&yf(S.alternate,S);break;case 24:rs(y,S,z,X,p),p&&ie&2048&&bf(S.alternate,S);break;default:rs(y,S,z,X,p)}r=r.sibling}}function io(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:io(s,c),p&2048&&yf(c.alternate,c);break;case 24:io(s,c),p&2048&&bf(c.alternate,c);break;default:io(s,c)}r=r.sibling}}var so=8192;function as(t,r,s){if(t.subtreeFlags&so)for(t=t.child;t!==null;)f1(t,r,s),t=t.sibling}function f1(t,r,s){switch(t.tag){case 26:as(t,r,s),t.flags&so&&t.memoizedState!==null&&aw(s,la,t.memoizedState,t.memoizedProps);break;case 5:as(t,r,s);break;case 3:case 4:var c=la;la=au(t.stateNode.containerInfo),as(t,r,s),la=c;break;case 22:t.memoizedState===null&&(c=t.alternate,c!==null&&c.memoizedState!==null?(c=so,so=16777216,as(t,r,s),so=c):as(t,r,s));break;default:as(t,r,s)}}function h1(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 oo(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];Xn=c,p1(c,t)}h1(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)m1(t),t=t.sibling}function m1(t){switch(t.tag){case 0:case 11:case 15:oo(t),t.flags&2048&&Al(9,t,t.return);break;case 3:oo(t);break;case 12:oo(t);break;case 22:var r=t.stateNode;t.memoizedState!==null&&r._visibility&2&&(t.return===null||t.return.tag!==13)?(r._visibility&=-3,Xc(t)):oo(t);break;default:oo(t)}}function Xc(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];Xn=c,p1(c,t)}h1(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:Al(8,r,r.return),Xc(r);break;case 22:s=r.stateNode,s._visibility&2&&(s._visibility&=-3,Xc(r));break;default:Xc(r)}t=t.sibling}}function p1(t,r){for(;Xn!==null;){var s=Xn;switch(s.tag){case 0:case 11:case 15:Al(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:Xs(s.memoizedState.cache)}if(c=s.child,c!==null)c.return=s,Xn=c;else e:for(s=t;Xn!==null;){c=Xn;var p=c.sibling,y=c.return;if(l1(c),c===s){Xn=null;break e}if(p!==null){p.return=y,Xn=p;break e}Xn=y}}}var b2={getCacheForType:function(t){var r=Zn(Tn),s=r.data.get(t);return s===void 0&&(s=t(),r.data.set(t,s)),s},cacheSignal:function(){return Zn(Tn).controller.signal}},v2=typeof WeakMap=="function"?WeakMap:Map,Vt=0,cn=null,Et=null,Ft=0,Qt=0,Fr=null,Dl=!1,ls=!1,vf=!1,el=0,En=0,Tl=0,bi=0,wf=0,Rr=0,is=0,co=null,br=null,kf=!1,Wc=0,x1=0,Vc=1/0,Gc=null,Fl=null,Bn=0,Rl=null,ss=null,tl=0,jf=0,Sf=null,g1=null,uo=0,Cf=null;function Mr(){return(Vt&2)!==0&&Ft!==0?Ft&-Ft:q.T!==null?Ff():Ze()}function y1(){if(Rr===0)if((Ft&536870912)===0||$t){var t=_t;_t<<=1,(_t&3932160)===0&&(_t=262144),Rr=t}else Rr=536870912;return t=Dr.current,t!==null&&(t.flags|=32),Rr}function vr(t,r,s){(t===cn&&(Qt===2||Qt===9)||t.cancelPendingCommit!==null)&&(os(t,0),Ml(t,Ft,Rr,!1)),ve(t,s),((Vt&2)===0||t!==cn)&&(t===cn&&((Vt&2)===0&&(bi|=s),En===4&&Ml(t,Ft,Rr,!1)),va(t))}function b1(t,r,s){if((Vt&6)!==0)throw Error(i(327));var c=!s&&(r&127)===0&&(r&t.expiredLanes)===0||J(t,r),p=c?j2(t,r):Nf(t,r,!0),y=c;do{if(p===0){ls&&!c&&Ml(t,r,0,!1);break}else{if(s=t.current.alternate,y&&!w2(s)){p=Nf(t,r,!1),y=!1;continue}if(p===2){if(y=r,t.errorRecoveryDisabledLanes&y)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=co;var X=z.current.memoizedState.isDehydrated;if(X&&(os(z,S).flags|=256),S=Nf(z,S,!1),S!==2){if(vf&&!X){z.errorRecoveryDisabledLanes|=y,bi|=y,p=4;break e}y=br,br=p,y!==null&&(br===null?br=y:br.push.apply(br,y))}p=S}if(y=!1,p!==2)continue}}if(p===1){os(t,0),Ml(t,r,0,!0);break}e:{switch(c=t,y=p,y){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:Ml(c,r,Rr,!Dl);break e;case 2:br=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(p=Wc+300-je(),10<p)){if(Ml(c,r,Rr,!Dl),kn(c,0,!0)!==0)break e;tl=r,c.timeoutHandle=P1(v1.bind(null,c,s,br,Gc,kf,r,Rr,bi,is,Dl,y,"Throttled",-0,0),p);break e}v1(c,s,br,Gc,kf,r,Rr,bi,is,Dl,y,null,-0,0)}}break}while(!0);va(t)}function v1(t,r,s,c,p,y,S,z,X,ie,xe,Se,oe,de){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:mr},f1(r,y,Se);var Ye=(y&62914560)===y?Wc-je():(y&4194048)===y?x1-je():0;if(Ye=lw(Se,Ye),Ye!==null){tl=y,t.cancelPendingCommit=Ye(A1.bind(null,t,r,y,s,c,p,S,z,X,xe,Se,null,oe,de)),Ml(t,y,S,!ie);return}}A1(t,r,y,s,c,p,S,z,X)}function w2(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],y=p.getSnapshot;p=p.value;try{if(!Nr(y(),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 Ml(t,r,s,c){r&=~wf,r&=~bi,t.suspendedLanes|=r,t.pingedLanes&=~r,c&&(t.warmLanes|=r),c=t.expirationTimes;for(var p=r;0<p;){var y=31-We(p),S=1<<y;c[y]=-1,p&=~S}s!==0&&jn(t,s,r)}function Kc(){return(Vt&6)===0?(fo(0),!1):!0}function Ef(){if(Et!==null){if(Qt===0)var t=Et.return;else t=Et,Ya=ui=null,Hd(t),Zi=null,Vs=0,t=Et;for(;t!==null;)Qx(t.alternate,t),t=t.return;Et=null}}function os(t,r){var s=t.timeoutHandle;s!==-1&&(t.timeoutHandle=-1,H2(s)),s=t.cancelPendingCommit,s!==null&&(t.cancelPendingCommit=null,s()),tl=0,Ef(),cn=t,Et=s=Ua(t.current,null),Ft=r,Qt=0,Fr=null,Dl=!1,ls=J(t,r),vf=!1,is=Rr=wf=bi=Tl=En=0,br=co=null,kf=!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-We(c),y=1<<p;r|=t[p],c&=~y}return el=r,xc(),s}function w1(t,r){gt=null,q.H=to,r===Qi||r===Sc?(r=Op(),Qt=3):r===Dd?(r=Op(),Qt=4):Qt=r===rf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Fr=r,Et===null&&(En=1,$c(t,Yr(r,t.current)))}function k1(){var t=Dr.current;return t===null?!0:(Ft&4194048)===Ft?Gr===null:(Ft&62914560)===Ft||(Ft&536870912)!==0?t===Gr:!1}function j1(){var t=q.H;return q.H=to,t===null?to:t}function S1(){var t=q.A;return q.A=b2,t}function Pc(){En=4,Dl||(Ft&4194048)!==Ft&&Dr.current!==null||(ls=!0),(Tl&134217727)===0&&(bi&134217727)===0||cn===null||Ml(cn,Ft,Rr,!1)}function Nf(t,r,s){var c=Vt;Vt|=2;var p=j1(),y=S1();(cn!==t||Ft!==r)&&(Gc=null,os(t,r)),r=!1;var S=En;e:do try{if(Qt!==0&&Et!==null){var z=Et,X=Fr;switch(Qt){case 8:Ef(),S=6;break e;case 3:case 2:case 9:case 6:Dr.current===null&&(r=!0);var ie=Qt;if(Qt=0,Fr=null,cs(t,z,X,ie),s&&ls){S=0;break e}break;default:ie=Qt,Qt=0,Fr=null,cs(t,z,X,ie)}}k2(),S=En;break}catch(xe){w1(t,xe)}while(!0);return r&&t.shellSuspendCounter++,Ya=ui=null,Vt=c,q.H=p,q.A=y,Et===null&&(cn=null,Ft=0,xc()),S}function k2(){for(;Et!==null;)C1(Et)}function j2(t,r){var s=Vt;Vt|=2;var c=j1(),p=S1();cn!==t||Ft!==r?(Gc=null,Vc=je()+500,os(t,r)):ls=J(t,r);e:do try{if(Qt!==0&&Et!==null){r=Et;var y=Fr;t:switch(Qt){case 1:Qt=0,Fr=null,cs(t,r,y,1);break;case 2:case 9:if(_p(y)){Qt=0,Fr=null,E1(r);break}r=function(){Qt!==2&&Qt!==9||cn!==t||(Qt=7),va(t)},y.then(r,r);break e;case 3:Qt=7;break e;case 4:Qt=5;break e;case 7:_p(y)?(Qt=0,Fr=null,E1(r)):(Qt=0,Fr=null,cs(t,r,y,7));break;case 5:var S=null;switch(Et.tag){case 26:S=Et.memoizedState;case 5:case 27:var z=Et;if(S?d0(S):z.stateNode.complete){Qt=0,Fr=null;var X=z.sibling;if(X!==null)Et=X;else{var ie=z.return;ie!==null?(Et=ie,Qc(ie)):Et=null}break t}}Qt=0,Fr=null,cs(t,r,y,5);break;case 6:Qt=0,Fr=null,cs(t,r,y,6);break;case 8:Ef(),En=6;break e;default:throw Error(i(462))}}S2();break}catch(xe){w1(t,xe)}while(!0);return Ya=ui=null,q.H=c,q.A=p,Vt=s,Et!==null?0:(cn=null,Ft=0,xc(),En)}function S2(){for(;Et!==null&&!Hn();)C1(Et)}function C1(t){var r=Kx(t.alternate,t,el);t.memoizedProps=t.pendingProps,r===null?Qc(t):Et=r}function E1(t){var r=t,s=r.alternate;switch(r.tag){case 15:case 0:r=qx(s,r,r.pendingProps,r.type,void 0,Ft);break;case 11:r=qx(s,r,r.pendingProps,r.type.render,r.ref,Ft);break;case 5:Hd(r);default:Qx(s,r),r=Et=Sp(r,el),r=Kx(s,r,el)}t.memoizedProps=t.pendingProps,r===null?Qc(t):Et=r}function cs(t,r,s,c){Ya=ui=null,Hd(r),Zi=null,Vs=0;var p=r.return;try{if(f2(t,p,r,s,Ft)){En=1,$c(t,Yr(s,t.current)),Et=null;return}}catch(y){if(p!==null)throw Et=p,y;En=1,$c(t,Yr(s,t.current)),Et=null;return}r.flags&32768?($t||c===1?t=!0:ls||(Ft&536870912)!==0?t=!1:(Dl=t=!0,(c===2||c===9||c===3||c===6)&&(c=Dr.current,c!==null&&c.tag===13&&(c.flags|=16384))),N1(r,t)):Qc(r)}function Qc(t){var r=t;do{if((r.flags&32768)!==0){N1(r,Dl);return}t=r.return;var s=p2(r.alternate,r,el);if(s!==null){Et=s;return}if(r=r.sibling,r!==null){Et=r;return}Et=r=t}while(r!==null);En===0&&(En=5)}function N1(t,r){do{var s=x2(t.alternate,t);if(s!==null){s.flags&=32767,Et=s;return}if(s=t.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!r&&(t=t.sibling,t!==null)){Et=t;return}Et=t=s}while(t!==null);En=6,Et=null}function A1(t,r,s,c,p,y,S,z,X){t.cancelPendingCommit=null;do Zc();while(Bn!==0);if((Vt&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(y=r.lanes|r.childLanes,y|=md,wt(t,s,y,S,z,X),t===cn&&(Et=cn=null,Ft=0),ss=r,Rl=t,tl=s,jf=y,Sf=p,g1=c,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,A2(ye,function(){return M1(),null})):(t.callbackNode=null,t.callbackPriority=0),c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=q.T,q.T=null,p=ce.p,ce.p=2,S=Vt,Vt|=4;try{g2(t,r,s)}finally{Vt=S,ce.p=p,q.T=c}}Bn=1,D1(),T1(),F1()}}function D1(){if(Bn===1){Bn=0;var t=Rl,r=ss,s=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||s){s=q.T,q.T=null;var c=ce.p;ce.p=2;var p=Vt;Vt|=4;try{c1(r,t);var y=Lf,S=pp(t.containerInfo),z=y.focusedElem,X=y.selectionRange;if(S!==z&&z&&z.ownerDocument&&mp(z.ownerDocument.documentElement,z)){if(X!==null&&cd(z)){var ie=X.start,xe=X.end;if(xe===void 0&&(xe=ie),"selectionStart"in z)z.selectionStart=ie,z.selectionEnd=Math.min(xe,z.value.length);else{var Se=z.ownerDocument||document,oe=Se&&Se.defaultView||window;if(oe.getSelection){var de=oe.getSelection(),Ye=z.textContent.length,st=Math.min(X.start,Ye),rn=X.end===void 0?st:Math.min(X.end,Ye);!de.extend&&st>rn&&(S=rn,rn=st,st=S);var te=hp(z,st),Q=hp(z,rn);if(te&&Q&&(de.rangeCount!==1||de.anchorNode!==te.node||de.anchorOffset!==te.offset||de.focusNode!==Q.node||de.focusOffset!==Q.offset)){var le=Se.createRange();le.setStart(te.node,te.offset),de.removeAllRanges(),st>rn?(de.addRange(le),de.extend(Q.node,Q.offset)):(le.setEnd(Q.node,Q.offset),de.addRange(le))}}}}for(Se=[],de=z;de=de.parentNode;)de.nodeType===1&&Se.push({element:de,left:de.scrollLeft,top:de.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}}uu=!!$f,Lf=$f=null}finally{Vt=p,ce.p=c,q.T=s}}t.current=r,Bn=2}}function T1(){if(Bn===2){Bn=0;var t=Rl,r=ss,s=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||s){s=q.T,q.T=null;var c=ce.p;ce.p=2;var p=Vt;Vt|=4;try{a1(t,r.alternate,r)}finally{Vt=p,ce.p=c,q.T=s}}Bn=3}}function F1(){if(Bn===4||Bn===3){Bn=0,me();var t=Rl,r=ss,s=tl,c=g1;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Bn=5:(Bn=0,ss=Rl=null,R1(t,t.pendingLanes));var p=t.pendingLanes;if(p===0&&(Fl=null),Ve(s),r=r.stateNode,qe&&typeof qe.onCommitFiberRoot=="function")try{qe.onCommitFiberRoot(Oe,r,void 0,(r.current.flags&128)===128)}catch{}if(c!==null){r=q.T,p=ce.p,ce.p=2,q.T=null;try{for(var y=t.onRecoverableError,S=0;S<c.length;S++){var z=c[S];y(z.value,{componentStack:z.stack})}}finally{q.T=r,ce.p=p}}(tl&3)!==0&&Zc(),va(t),p=t.pendingLanes,(s&261930)!==0&&(p&42)!==0?t===Cf?uo++:(uo=0,Cf=t):uo=0,fo(0)}}function R1(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,Xs(r)))}function Zc(){return D1(),T1(),F1(),M1()}function M1(){if(Bn!==5)return!1;var t=Rl,r=jf;jf=0;var s=Ve(tl),c=q.T,p=ce.p;try{ce.p=32>s?32:s,q.T=null,s=Sf,Sf=null;var y=Rl,S=tl;if(Bn=0,ss=Rl=null,tl=0,(Vt&6)!==0)throw Error(i(331));var z=Vt;if(Vt|=4,m1(y.current),d1(y,y.current,S,s),Vt=z,fo(0,!1),qe&&typeof qe.onPostCommitFiberRoot=="function")try{qe.onPostCommitFiberRoot(Oe,y)}catch{}return!0}finally{ce.p=p,q.T=c,R1(t,r)}}function z1(t,r,s){r=Yr(s,r),r=nf(t.stateNode,r,2),t=Cl(t,r,2),t!==null&&(ve(t,2),va(t))}function Zt(t,r,s){if(t.tag===3)z1(t,t,s);else for(;r!==null;){if(r.tag===3){z1(r,t,s);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Fl===null||!Fl.has(c))){t=Yr(s,t),s=_x(2),c=Cl(r,s,2),c!==null&&(Bx(s,c,r,t),ve(c,2),va(c));break}}r=r.return}}function Af(t,r,s){var c=t.pingCache;if(c===null){c=t.pingCache=new v2;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)||(vf=!0,p.add(s),t=C2.bind(null,t,r,s),r.then(t,t))}function C2(t,r,s){var c=t.pingCache;c!==null&&c.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,cn===t&&(Ft&s)===s&&(En===4||En===3&&(Ft&62914560)===Ft&&300>je()-Wc?(Vt&2)===0&&os(t,0):wf|=s,is===Ft&&(is=0)),va(t)}function _1(t,r){r===0&&(r=lt()),t=si(t,r),t!==null&&(ve(t,r),va(t))}function E2(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),_1(t,s)}function N2(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),_1(t,s)}function A2(t,r){return zt(t,r)}var Jc=null,us=null,Df=!1,eu=!1,Tf=!1,zl=0;function va(t){t!==us&&t.next===null&&(us===null?Jc=us=t:us=us.next=t),eu=!0,Df||(Df=!0,T2())}function fo(t,r){if(!Tf&&eu){Tf=!0;do for(var s=!1,c=Jc;c!==null;){if(t!==0){var p=c.pendingLanes;if(p===0)var y=0;else{var S=c.suspendedLanes,z=c.pingedLanes;y=(1<<31-We(42|t)+1)-1,y&=p&~(S&~z),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(s=!0,L1(c,y))}else y=Ft,y=kn(c,c===cn?y:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(y&3)===0||J(c,y)||(s=!0,L1(c,y));c=c.next}while(s);Tf=!1}}function D2(){B1()}function B1(){eu=Df=!1;var t=0;zl!==0&&I2()&&(t=zl);for(var r=je(),s=null,c=Jc;c!==null;){var p=c.next,y=O1(c,r);y===0?(c.next=null,s===null?Jc=p:s.next=p,p===null&&(us=s)):(s=c,(t!==0||(y&3)!==0)&&(eu=!0)),c=p}Bn!==0&&Bn!==5||fo(t),zl!==0&&(zl=0)}function O1(t,r){for(var s=t.suspendedLanes,c=t.pingedLanes,p=t.expirationTimes,y=t.pendingLanes&-62914561;0<y;){var S=31-We(y),z=1<<S,X=p[S];X===-1?((z&s)===0||(z&c)!==0)&&(p[S]=$e(z,r)):X<=r&&(t.expiredLanes|=z),y&=~z}if(r=cn,s=Ft,s=kn(t,t===r?s:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c=t.callbackNode,s===0||t===r&&(Qt===2||Qt===9)||t.cancelPendingCommit!==null)return c!==null&&c!==null&&jt(c),t.callbackNode=null,t.callbackPriority=0;if((s&3)===0||J(t,s)){if(r=s&-s,r===t.callbackPriority)return r;switch(c!==null&&jt(c),Ve(s)){case 2:case 8:s=Z;break;case 32:s=ye;break;case 268435456:s=Ee;break;default:s=ye}return c=$1.bind(null,t),s=zt(s,c),t.callbackPriority=r,t.callbackNode=s,r}return c!==null&&c!==null&&jt(c),t.callbackPriority=2,t.callbackNode=null,2}function $1(t,r){if(Bn!==0&&Bn!==5)return t.callbackNode=null,t.callbackPriority=0,null;var s=t.callbackNode;if(Zc()&&t.callbackNode!==s)return null;var c=Ft;return c=kn(t,t===cn?c:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c===0?null:(b1(t,c,r),O1(t,je()),t.callbackNode!=null&&t.callbackNode===s?$1.bind(null,t):null)}function L1(t,r){if(Zc())return null;b1(t,r,!0)}function T2(){U2(function(){(Vt&6)!==0?zt(G,D2):B1()})}function Ff(){if(zl===0){var t=Ki;t===0&&(t=qt,qt<<=1,(qt&261888)===0&&(qt=256)),zl=t}return zl}function I1(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Bi(""+t)}function H1(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 F2(t,r,s,c,p){if(r==="submit"&&s&&s.stateNode===p){var y=I1((p[mn]||null).action),S=c.submitter;S&&(r=(r=S[mn]||null)?I1(r.formAction):S.getAttribute("formAction"),r!==null&&(y=r,S=null));var z=new xl("action","action",null,c,p);t.push({event:z,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(zl!==0){var X=S?H1(p,S):new FormData(p);Pd(s,{pending:!0,data:X,method:p.method,action:y},null,X)}}else typeof y=="function"&&(z.preventDefault(),X=S?H1(p,S):new FormData(p),Pd(s,{pending:!0,data:X,method:p.method,action:y},y,X))},currentTarget:p}]})}}for(var Rf=0;Rf<hd.length;Rf++){var Mf=hd[Rf],R2=Mf.toLowerCase(),M2=Mf[0].toUpperCase()+Mf.slice(1);aa(R2,"on"+M2)}aa(yp,"onAnimationEnd"),aa(bp,"onAnimationIteration"),aa(vp,"onAnimationStart"),aa("dblclick","onDoubleClick"),aa("focusin","onFocus"),aa("focusout","onBlur"),aa(Kv,"onTransitionRun"),aa(Pv,"onTransitionStart"),aa(Qv,"onTransitionCancel"),aa(wp,"onTransitionEnd"),Sr("onMouseEnter",["mouseout","mouseover"]),Sr("onMouseLeave",["mouseout","mouseover"]),Sr("onPointerEnter",["pointerout","pointerover"]),Sr("onPointerLeave",["pointerout","pointerover"]),hr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),hr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),hr("onBeforeInput",["compositionend","keypress","textInput","paste"]),hr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),hr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),hr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ho="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(" "),z2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ho));function U1(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 y=void 0;if(r)for(var S=c.length-1;0<=S;S--){var z=c[S],X=z.instance,ie=z.currentTarget;if(z=z.listener,X!==y&&p.isPropagationStopped())break e;y=z,p.currentTarget=ie;try{y(p)}catch(xe){pc(xe)}p.currentTarget=null,y=X}else for(S=0;S<c.length;S++){if(z=c[S],X=z.instance,ie=z.currentTarget,z=z.listener,X!==y&&p.isPropagationStopped())break e;y=z,p.currentTarget=ie;try{y(p)}catch(xe){pc(xe)}p.currentTarget=null,y=X}}}}function Nt(t,r){var s=r[Jl];s===void 0&&(s=r[Jl]=new Set);var c=t+"__bubble";s.has(c)||(q1(r,t,2,!1),s.add(c))}function zf(t,r,s){var c=0;r&&(c|=4),q1(s,t,c,r)}var tu="_reactListening"+Math.random().toString(36).slice(2);function _f(t){if(!t[tu]){t[tu]=!0,_a.forEach(function(s){s!=="selectionchange"&&(z2.has(s)||zf(s,!1,t),zf(s,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[tu]||(r[tu]=!0,zf("selectionchange",!1,r))}}function q1(t,r,s,c){switch(y0(r)){case 2:var p=ow;break;case 8:p=cw;break;default:p=Pf}s=p.bind(null,r,s,t),p=void 0,!_s||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 Bf(t,r,s,c,p){var y=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=ua(z),S===null)return;if(X=S.tag,X===5||X===6||X===26||X===27){c=y=S;continue e}z=z.parentNode}}c=c.return}hl(function(){var ie=y,xe=ha(s),Se=[];e:{var oe=kp.get(t);if(oe!==void 0){var de=xl,Ye=t;switch(t){case"keypress":if($i(s)===0)break e;case"keydown":case"keyup":de=dc;break;case"focusin":Ye="focus",de=Ur;break;case"focusout":Ye="blur",de=Ur;break;case"beforeblur":case"afterblur":de=Ur;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":de=tc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":de=rc;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":de=F;break;case yp:case bp:case vp:de=Os;break;case wp:de=ae;break;case"scroll":case"scrollend":de=ld;break;case"wheel":de=we;break;case"copy":case"cut":case"paste":de=lc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":de=$s;break;case"toggle":case"beforetoggle":de=Lt}var st=(r&4)!==0,rn=!st&&(t==="scroll"||t==="scrollend"),te=st?oe!==null?oe+"Capture":null:oe;st=[];for(var Q=ie,le;Q!==null;){var be=Q;if(le=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||le===null||te===null||(be=ma(Q,te),be!=null&&st.push(mo(Q,be,le))),rn)break;Q=Q.return}0<st.length&&(oe=new de(oe,Ye,null,s,xe),Se.push({event:oe,listeners:st}))}}if((r&7)===0){e:{if(oe=t==="mouseover"||t==="pointerover",de=t==="mouseout"||t==="pointerout",oe&&s!==Oi&&(Ye=s.relatedTarget||s.fromElement)&&(ua(Ye)||Ye[Lr]))break e;if((de||oe)&&(oe=xe.window===xe?xe:(oe=xe.ownerDocument)?oe.defaultView||oe.parentWindow:window,de?(Ye=s.relatedTarget||s.toElement,de=ie,Ye=Ye?ua(Ye):null,Ye!==null&&(rn=u(Ye),st=Ye.tag,Ye!==rn||st!==5&&st!==27&&st!==6)&&(Ye=null)):(de=null,Ye=ie),de!==Ye)){if(st=tc,be="onMouseLeave",te="onMouseEnter",Q="mouse",(t==="pointerout"||t==="pointerover")&&(st=$s,be="onPointerLeave",te="onPointerEnter",Q="pointer"),rn=de==null?oe:za(de),le=Ye==null?oe:za(Ye),oe=new st(be,Q+"leave",de,s,xe),oe.target=rn,oe.relatedTarget=le,be=null,ua(xe)===ie&&(st=new st(te,Q+"enter",Ye,s,xe),st.target=le,st.relatedTarget=rn,be=st),rn=be,de&&Ye)t:{for(st=_2,te=de,Q=Ye,le=0,be=te;be;be=st(be))le++;be=0;for(var rt=Q;rt;rt=st(rt))be++;for(;0<le-be;)te=st(te),le--;for(;0<be-le;)Q=st(Q),be--;for(;le--;){if(te===Q||Q!==null&&te===Q.alternate){st=te;break t}te=st(te),Q=st(Q)}st=null}else st=null;de!==null&&Y1(Se,oe,de,st,!1),Ye!==null&&rn!==null&&Y1(Se,rn,Ye,st,!0)}}e:{if(oe=ie?za(ie):window,de=oe.nodeName&&oe.nodeName.toLowerCase(),de==="select"||de==="input"&&oe.type==="file")var Yt=sp;else if(lp(oe))if(op)Yt=Wv;else{Yt=Yv;var Ke=qv}else de=oe.nodeName,!de||de.toLowerCase()!=="input"||oe.type!=="checkbox"&&oe.type!=="radio"?ie&&qn(ie.elementType)&&(Yt=sp):Yt=Xv;if(Yt&&(Yt=Yt(t,ie))){ip(Se,Yt,s,xe);break e}Ke&&Ke(t,oe,ie),t==="focusout"&&ie&&oe.type==="number"&&ie.memoizedProps.value!=null&&ti(oe,"number",oe.value)}switch(Ke=ie?za(ie):window,t){case"focusin":(lp(Ke)||Ke.contentEditable==="true")&&(Hi=Ke,ud=ie,Us=null);break;case"focusout":Us=ud=Hi=null;break;case"mousedown":dd=!0;break;case"contextmenu":case"mouseup":case"dragend":dd=!1,xp(Se,s,xe);break;case"selectionchange":if(Gv)break;case"keydown":case"keyup":xp(Se,s,xe)}var bt;if(tt)e:{switch(t){case"compositionstart":var Rt="onCompositionStart";break e;case"compositionend":Rt="onCompositionEnd";break e;case"compositionupdate":Rt="onCompositionUpdate";break e}Rt=void 0}else pn?ut(t,s)&&(Rt="onCompositionEnd"):t==="keydown"&&s.keyCode===229&&(Rt="onCompositionStart");Rt&&(Tt&&s.locale!=="ko"&&(pn||Rt!=="onCompositionStart"?Rt==="onCompositionEnd"&&pn&&(bt=pl()):(pa=xe,on="value"in pa?pa.value:pa.textContent,pn=!0)),Ke=nu(ie,Rt),0<Ke.length&&(Rt=new sc(Rt,t,null,s,xe),Se.push({event:Rt,listeners:Ke}),bt?Rt.data=bt:(bt=Ot(s),bt!==null&&(Rt.data=bt)))),(bt=mt?dn(t,s):Iv(t,s))&&(Rt=nu(ie,"onBeforeInput"),0<Rt.length&&(Ke=new sc("onBeforeInput","beforeinput",null,s,xe),Se.push({event:Ke,listeners:Rt}),Ke.data=bt)),F2(Se,t,ie,s,xe)}U1(Se,r)})}function mo(t,r,s){return{instance:t,listener:r,currentTarget:s}}function nu(t,r){for(var s=r+"Capture",c=[];t!==null;){var p=t,y=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||y===null||(p=ma(t,s),p!=null&&c.unshift(mo(t,p,y)),p=ma(t,r),p!=null&&c.push(mo(t,p,y))),t.tag===3)return c;t=t.return}return[]}function _2(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function Y1(t,r,s,c,p){for(var y=r._reactName,S=[];s!==null&&s!==c;){var z=s,X=z.alternate,ie=z.stateNode;if(z=z.tag,X!==null&&X===c)break;z!==5&&z!==26&&z!==27||ie===null||(X=ie,p?(ie=ma(s,y),ie!=null&&S.unshift(mo(s,ie,X))):p||(ie=ma(s,y),ie!=null&&S.push(mo(s,ie,X)))),s=s.return}S.length!==0&&t.push({event:r,listeners:S})}var B2=/\r\n?/g,O2=/\u0000|\uFFFD/g;function X1(t){return(typeof t=="string"?t:""+t).replace(B2,`
|
|
49
|
+
`).replace(O2,"")}function W1(t,r){return r=X1(r),X1(t)===r}function nn(t,r,s,c,p,y){switch(s){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||fl(t,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&fl(t,""+c);break;case"className":dl(t,"class",c);break;case"tabIndex":dl(t,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":dl(t,s,c);break;case"style":na(t,c,y);break;case"data":if(r!=="object"){dl(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=Bi(""+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 y=="function"&&(s==="formAction"?(r!=="input"&&nn(t,r,"name",p.name,p,null),nn(t,r,"formEncType",p.formEncType,p,null),nn(t,r,"formMethod",p.formMethod,p,null),nn(t,r,"formTarget",p.formTarget,p,null)):(nn(t,r,"encType",p.encType,p,null),nn(t,r,"method",p.method,p,null),nn(t,r,"target",p.target,p,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=Bi(""+c),t.setAttribute(s,c);break;case"onClick":c!=null&&(t.onclick=mr);break;case"onScroll":c!=null&&Nt("scroll",t);break;case"onScrollEnd":c!=null&&Nt("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=Bi(""+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":Nt("beforetoggle",t),Nt("toggle",t),ei(t,"popover",c);break;case"xlinkActuate":Ir(t,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Ir(t,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Ir(t,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Ir(t,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Ir(t,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Ir(t,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Ir(t,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Ir(t,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Ir(t,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":ei(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=fa.get(s)||s,ei(t,s,c))}}function Of(t,r,s,c,p,y){switch(s){case"style":na(t,c,y);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"?fl(t,c):(typeof c=="number"||typeof c=="bigint")&&fl(t,""+c);break;case"onScroll":c!=null&&Nt("scroll",t);break;case"onScrollEnd":c!=null&&Nt("scrollend",t);break;case"onClick":c!=null&&(t.onclick=mr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!zi.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(p=s.endsWith("Capture"),r=s.slice(2,p?s.length-7:void 0),y=t[mn]||null,y=y!=null?y[s]:null,typeof y=="function"&&t.removeEventListener(r,y,p),typeof c=="function")){typeof y!="function"&&y!==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,""):ei(t,s,c)}}}function er(t,r,s){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Nt("error",t),Nt("load",t);var c=!1,p=!1,y;for(y in s)if(s.hasOwnProperty(y)){var S=s[y];if(S!=null)switch(y){case"src":c=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:nn(t,r,y,S,s,null)}}p&&nn(t,r,"srcSet",s.srcSet,s,null),c&&nn(t,r,"src",s.src,s,null);return;case"input":Nt("invalid",t);var z=y=S=p=null,X=null,ie=null;for(c in s)if(s.hasOwnProperty(c)){var xe=s[c];if(xe!=null)switch(c){case"name":p=xe;break;case"type":S=xe;break;case"checked":X=xe;break;case"defaultChecked":ie=xe;break;case"value":y=xe;break;case"defaultValue":z=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(i(137,r));break;default:nn(t,r,c,xe,s,null)}}Jo(t,y,z,X,ie,S,p,!1);return;case"select":Nt("invalid",t),c=S=y=null;for(p in s)if(s.hasOwnProperty(p)&&(z=s[p],z!=null))switch(p){case"value":y=z;break;case"defaultValue":S=z;break;case"multiple":c=z;default:nn(t,r,p,z,s,null)}r=y,s=S,t.multiple=!!c,r!=null?Kn(t,!!c,r,!1):s!=null&&Kn(t,!!c,s,!0);return;case"textarea":Nt("invalid",t),y=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":y=z;break;case"dangerouslySetInnerHTML":if(z!=null)throw Error(i(91));break;default:nn(t,r,S,z,s,null)}da(t,c,p,y);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:nn(t,r,X,c,s,null)}return;case"dialog":Nt("beforetoggle",t),Nt("toggle",t),Nt("cancel",t),Nt("close",t);break;case"iframe":case"object":Nt("load",t);break;case"video":case"audio":for(c=0;c<ho.length;c++)Nt(ho[c],t);break;case"image":Nt("error",t),Nt("load",t);break;case"details":Nt("toggle",t);break;case"embed":case"source":case"link":Nt("error",t),Nt("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(ie in s)if(s.hasOwnProperty(ie)&&(c=s[ie],c!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:nn(t,r,ie,c,s,null)}return;default:if(qn(r)){for(xe in s)s.hasOwnProperty(xe)&&(c=s[xe],c!==void 0&&Of(t,r,xe,c,s,void 0));return}}for(z in s)s.hasOwnProperty(z)&&(c=s[z],c!=null&&nn(t,r,z,c,s,null))}function $2(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,y=null,S=null,z=null,X=null,ie=null,xe=null;for(de in s){var Se=s[de];if(s.hasOwnProperty(de)&&Se!=null)switch(de){case"checked":break;case"value":break;case"defaultValue":X=Se;default:c.hasOwnProperty(de)||nn(t,r,de,null,c,Se)}}for(var oe in c){var de=c[oe];if(Se=s[oe],c.hasOwnProperty(oe)&&(de!=null||Se!=null))switch(oe){case"type":y=de;break;case"name":p=de;break;case"checked":ie=de;break;case"defaultChecked":xe=de;break;case"value":S=de;break;case"defaultValue":z=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(i(137,r));break;default:de!==Se&&nn(t,r,oe,de,c,Se)}}_i(t,S,z,X,ie,xe,y,p);return;case"select":de=S=z=oe=null;for(y in s)if(X=s[y],s.hasOwnProperty(y)&&X!=null)switch(y){case"value":break;case"multiple":de=X;default:c.hasOwnProperty(y)||nn(t,r,y,null,c,X)}for(p in c)if(y=c[p],X=s[p],c.hasOwnProperty(p)&&(y!=null||X!=null))switch(p){case"value":oe=y;break;case"defaultValue":z=y;break;case"multiple":S=y;default:y!==X&&nn(t,r,p,y,c,X)}r=z,s=S,c=de,oe!=null?Kn(t,!!s,oe,!1):!!c!=!!s&&(r!=null?Kn(t,!!s,r,!0):Kn(t,!!s,s?[]:"",!1));return;case"textarea":de=oe=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:nn(t,r,z,null,c,p)}for(S in c)if(p=c[S],y=s[S],c.hasOwnProperty(S)&&(p!=null||y!=null))switch(S){case"value":oe=p;break;case"defaultValue":de=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(i(91));break;default:p!==y&&nn(t,r,S,p,c,y)}$a(t,oe,de);return;case"option":for(var Ye in s)if(oe=s[Ye],s.hasOwnProperty(Ye)&&oe!=null&&!c.hasOwnProperty(Ye))switch(Ye){case"selected":t.selected=!1;break;default:nn(t,r,Ye,null,c,oe)}for(X in c)if(oe=c[X],de=s[X],c.hasOwnProperty(X)&&oe!==de&&(oe!=null||de!=null))switch(X){case"selected":t.selected=oe&&typeof oe!="function"&&typeof oe!="symbol";break;default:nn(t,r,X,oe,c,de)}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 st in s)oe=s[st],s.hasOwnProperty(st)&&oe!=null&&!c.hasOwnProperty(st)&&nn(t,r,st,null,c,oe);for(ie in c)if(oe=c[ie],de=s[ie],c.hasOwnProperty(ie)&&oe!==de&&(oe!=null||de!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(i(137,r));break;default:nn(t,r,ie,oe,c,de)}return;default:if(qn(r)){for(var rn in s)oe=s[rn],s.hasOwnProperty(rn)&&oe!==void 0&&!c.hasOwnProperty(rn)&&Of(t,r,rn,void 0,c,oe);for(xe in c)oe=c[xe],de=s[xe],!c.hasOwnProperty(xe)||oe===de||oe===void 0&&de===void 0||Of(t,r,xe,oe,c,de);return}}for(var te in s)oe=s[te],s.hasOwnProperty(te)&&oe!=null&&!c.hasOwnProperty(te)&&nn(t,r,te,null,c,oe);for(Se in c)oe=c[Se],de=s[Se],!c.hasOwnProperty(Se)||oe===de||oe==null&&de==null||nn(t,r,Se,oe,c,de)}function V1(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function L2(){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],y=p.transferSize,S=p.initiatorType,z=p.duration;if(y&&z&&V1(S)){for(S=0,z=p.responseEnd,c+=1;c<s.length;c++){var X=s[c],ie=X.startTime;if(ie>z)break;var xe=X.transferSize,Se=X.initiatorType;xe&&V1(Se)&&(X=X.responseEnd,S+=xe*(X<z?1:(z-ie)/(X-ie)))}if(--c,r+=8*(y+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 $f=null,Lf=null;function ru(t){return t.nodeType===9?t:t.ownerDocument}function G1(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 K1(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 If(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 Hf=null;function I2(){var t=window.event;return t&&t.type==="popstate"?t===Hf?!1:(Hf=t,!0):(Hf=null,!1)}var P1=typeof setTimeout=="function"?setTimeout:void 0,H2=typeof clearTimeout=="function"?clearTimeout:void 0,Q1=typeof Promise=="function"?Promise:void 0,U2=typeof queueMicrotask=="function"?queueMicrotask:typeof Q1<"u"?function(t){return Q1.resolve(null).then(t).catch(q2)}:P1;function q2(t){setTimeout(function(){throw t})}function _l(t){return t==="head"}function Z1(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),ms(r);return}c--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")c++;else if(s==="html")po(t.ownerDocument.documentElement);else if(s==="head"){s=t.ownerDocument.head,po(s);for(var y=s.firstChild;y;){var S=y.nextSibling,z=y.nodeName;y[Ra]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&y.rel.toLowerCase()==="stylesheet"||s.removeChild(y),y=S}}else s==="body"&&po(t.ownerDocument.body);s=p}while(s);ms(r)}function J1(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 Uf(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":Uf(s),Rs(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}t.removeChild(s)}}function Y2(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[Ra])switch(r){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(y=t.getAttribute("rel"),y==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(y!==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(y=t.getAttribute("src"),(y!==(p.src==null?null:p.src)||t.getAttribute("type")!==(p.type==null?null:p.type)||t.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&y&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(r==="input"&&t.type==="hidden"){var y=p.name==null?null:""+p.name;if(p.type==="hidden"&&t.getAttribute("name")===y)return t}else return t;if(t=Kr(t.nextSibling),t===null)break}return null}function X2(t,r,s){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=Kr(t.nextSibling),t===null))return null;return t}function e0(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Kr(t.nextSibling),t===null))return null;return t}function qf(t){return t.data==="$?"||t.data==="$~"}function Yf(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function W2(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 Kr(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 Xf=null;function t0(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="/$"||s==="/&"){if(r===0)return Kr(t.nextSibling);r--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||r++}t=t.nextSibling}return null}function n0(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 r0(t,r,s){switch(r=ru(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 po(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Rs(t)}var Pr=new Map,a0=new Set;function au(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var nl=ce.d;ce.d={f:V2,r:G2,D:K2,C:P2,L:Q2,m:Z2,X:ew,S:J2,M:tw};function V2(){var t=nl.f(),r=Kc();return t||r}function G2(t){var r=Ma(t);r!==null&&r.tag===5&&r.type==="form"?wx(r):nl.r(t)}var ds=typeof document>"u"?null:document;function l0(t,r,s){var c=ds;if(c&&typeof r=="string"&&r){var p=Pt(r);p='link[rel="'+t+'"][href="'+p+'"]',typeof s=="string"&&(p+='[crossorigin="'+s+'"]'),a0.has(p)||(a0.add(p),t={rel:t,crossOrigin:s,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),er(r,"link",t),Dn(r),c.head.appendChild(r)))}}function K2(t){nl.D(t),l0("dns-prefetch",t,null)}function P2(t,r){nl.C(t,r),l0("preconnect",t,r)}function Q2(t,r,s){nl.L(t,r,s);var c=ds;if(c&&t&&r){var p='link[rel="preload"][as="'+Pt(r)+'"]';r==="image"&&s&&s.imageSrcSet?(p+='[imagesrcset="'+Pt(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(p+='[imagesizes="'+Pt(s.imageSizes)+'"]')):p+='[href="'+Pt(t)+'"]';var y=p;switch(r){case"style":y=fs(t);break;case"script":y=hs(t)}Pr.has(y)||(t=g({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),Pr.set(y,t),c.querySelector(p)!==null||r==="style"&&c.querySelector(xo(y))||r==="script"&&c.querySelector(go(y))||(r=c.createElement("link"),er(r,"link",t),Dn(r),c.head.appendChild(r)))}}function Z2(t,r){nl.m(t,r);var s=ds;if(s&&t){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+Pt(c)+'"][href="'+Pt(t)+'"]',y=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=hs(t)}if(!Pr.has(y)&&(t=g({rel:"modulepreload",href:t},r),Pr.set(y,t),s.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(go(y)))return}c=s.createElement("link"),er(c,"link",t),Dn(c),s.head.appendChild(c)}}}function J2(t,r,s){nl.S(t,r,s);var c=ds;if(c&&t){var p=Gn(c).hoistableStyles,y=fs(t);r=r||"default";var S=p.get(y);if(!S){var z={loading:0,preload:null};if(S=c.querySelector(xo(y)))z.loading=5;else{t=g({rel:"stylesheet",href:t,"data-precedence":r},s),(s=Pr.get(y))&&Wf(t,s);var X=S=c.createElement("link");Dn(X),er(X,"link",t),X._p=new Promise(function(ie,xe){X.onload=ie,X.onerror=xe}),X.addEventListener("load",function(){z.loading|=1}),X.addEventListener("error",function(){z.loading|=2}),z.loading|=4,lu(S,r,c)}S={type:"stylesheet",instance:S,count:1,state:z},p.set(y,S)}}}function ew(t,r){nl.X(t,r);var s=ds;if(s&&t){var c=Gn(s).hoistableScripts,p=hs(t),y=c.get(p);y||(y=s.querySelector(go(p)),y||(t=g({src:t,async:!0},r),(r=Pr.get(p))&&Vf(t,r),y=s.createElement("script"),Dn(y),er(y,"link",t),s.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},c.set(p,y))}}function tw(t,r){nl.M(t,r);var s=ds;if(s&&t){var c=Gn(s).hoistableScripts,p=hs(t),y=c.get(p);y||(y=s.querySelector(go(p)),y||(t=g({src:t,async:!0,type:"module"},r),(r=Pr.get(p))&&Vf(t,r),y=s.createElement("script"),Dn(y),er(y,"link",t),s.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},c.set(p,y))}}function i0(t,r,s,c){var p=(p=he.current)?au(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=fs(s.href),s=Gn(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=fs(s.href);var y=Gn(p).hoistableStyles,S=y.get(t);if(S||(p=p.ownerDocument||p,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(t,S),(y=p.querySelector(xo(t)))&&!y._p&&(S.instance=y,S.state.loading=5),Pr.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},Pr.set(t,s),y||nw(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=hs(s),s=Gn(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 fs(t){return'href="'+Pt(t)+'"'}function xo(t){return'link[rel="stylesheet"]['+t+"]"}function s0(t){return g({},t,{"data-precedence":t.precedence,precedence:null})}function nw(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}),er(r,"link",s),Dn(r),t.head.appendChild(r))}function hs(t){return'[src="'+Pt(t)+'"]'}function go(t){return"script[async]"+t}function o0(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var c=t.querySelector('style[data-href~="'+Pt(s.href)+'"]');if(c)return r.instance=c,Dn(c),c;var p=g({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return c=(t.ownerDocument||t).createElement("style"),Dn(c),er(c,"style",p),lu(c,s.precedence,t),r.instance=c;case"stylesheet":p=fs(s.href);var y=t.querySelector(xo(p));if(y)return r.state.loading|=4,r.instance=y,Dn(y),y;c=s0(s),(p=Pr.get(p))&&Wf(c,p),y=(t.ownerDocument||t).createElement("link"),Dn(y);var S=y;return S._p=new Promise(function(z,X){S.onload=z,S.onerror=X}),er(y,"link",c),r.state.loading|=4,lu(y,s.precedence,t),r.instance=y;case"script":return y=hs(s.src),(p=t.querySelector(go(y)))?(r.instance=p,Dn(p),p):(c=s,(p=Pr.get(y))&&(c=g({},s),Vf(c,p)),t=t.ownerDocument||t,p=t.createElement("script"),Dn(p),er(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,lu(c,s.precedence,t));return r.instance}function lu(t,r,s){for(var c=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=c.length?c[c.length-1]:null,y=p,S=0;S<c.length;S++){var z=c[S];if(z.dataset.precedence===r)y=z;else if(y!==p)break}y?y.parentNode.insertBefore(t,y.nextSibling):(r=s.nodeType===9?s.head:s,r.insertBefore(t,r.firstChild))}function Wf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function Vf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var iu=null;function c0(t,r,s){if(iu===null){var c=new Map,p=iu=new Map;p.set(s,c)}else p=iu,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 y=s[p];if(!(y[Ra]||y[yn]||t==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var S=y.getAttribute(r)||"";S=t+S;var z=c.get(S);z?z.push(y):c.set(S,[y])}}return c}function u0(t,r,s){t=t.ownerDocument||t,t.head.insertBefore(s,r==="title"?t.querySelector("head > title"):null)}function rw(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 d0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function aw(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=fs(c.href),y=r.querySelector(xo(p));if(y){r=y._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=su.bind(t),r.then(t,t)),s.state.loading|=4,s.instance=y,Dn(y);return}y=r.ownerDocument||r,c=s0(c),(p=Pr.get(p))&&Wf(c,p),y=y.createElement("link"),Dn(y);var S=y;S._p=new Promise(function(z,X){S.onload=z,S.onerror=X}),er(y,"link",c),s.instance=y}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(s,r),(r=s.state.preload)&&(s.state.loading&3)===0&&(t.count++,s=su.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var Gf=0;function lw(t,r){return t.stylesheets&&t.count===0&&cu(t,t.stylesheets),0<t.count||0<t.imgCount?function(s){var c=setTimeout(function(){if(t.stylesheets&&cu(t,t.stylesheets),t.unsuspend){var y=t.unsuspend;t.unsuspend=null,y()}},6e4+r);0<t.imgBytes&&Gf===0&&(Gf=62500*L2());var p=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&cu(t,t.stylesheets),t.unsuspend)){var y=t.unsuspend;t.unsuspend=null,y()}},(t.imgBytes>Gf?50:800)+r);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(c),clearTimeout(p)}}:null}function su(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cu(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var ou=null;function cu(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,ou=new Map,r.forEach(iw,t),ou=null,su.call(t))}function iw(t,r){if(!(r.state.loading&4)){var s=ou.get(t);if(s)var c=s.get(null);else{s=new Map,ou.set(t,s);for(var p=t.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<p.length;y++){var S=p[y];(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"),y=s.get(S)||c,y===c&&s.set(null,p),s.set(S,p),this.count++,c=su.bind(this),p.addEventListener("load",c),p.addEventListener("error",c),y?y.parentNode.insertBefore(p,y.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(p,t.firstChild)),r.state.loading|=4}}var yo={$$typeof:_,Provider:null,Consumer:null,_currentValue:ue,_currentValue2:ue,_threadCount:0};function sw(t,r,s,c,p,y,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=Kt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kt(0),this.hiddenUpdates=Kt(null),this.identifierPrefix=c,this.onUncaughtError=p,this.onCaughtError=y,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=X,this.incompleteTransitions=new Map}function f0(t,r,s,c,p,y,S,z,X,ie,xe,Se){return t=new sw(t,r,s,S,X,ie,xe,Se,z),r=1,y===!0&&(r|=24),y=Ar(3,null,null,r),t.current=y,y.stateNode=t,r=Ed(),r.refCount++,t.pooledCache=r,r.refCount++,y.memoizedState={element:c,isDehydrated:s,cache:r},Td(y),t}function h0(t){return t?(t=Yi,t):Yi}function m0(t,r,s,c,p,y){p=h0(p),c.context===null?c.context=p:c.pendingContext=p,c=Sl(r),c.payload={element:s},y=y===void 0?null:y,y!==null&&(c.callback=y),s=Cl(t,c,r),s!==null&&(vr(s,t,r),Ks(s,t,r))}function p0(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var s=t.retryLane;t.retryLane=s!==0&&s<r?s:r}}function Kf(t,r){p0(t,r),(t=t.alternate)&&p0(t,r)}function x0(t){if(t.tag===13||t.tag===31){var r=si(t,67108864);r!==null&&vr(r,t,67108864),Kf(t,67108864)}}function g0(t){if(t.tag===13||t.tag===31){var r=Mr();r=Me(r);var s=si(t,r);s!==null&&vr(s,t,r),Kf(t,r)}}var uu=!0;function ow(t,r,s,c){var p=q.T;q.T=null;var y=ce.p;try{ce.p=2,Pf(t,r,s,c)}finally{ce.p=y,q.T=p}}function cw(t,r,s,c){var p=q.T;q.T=null;var y=ce.p;try{ce.p=8,Pf(t,r,s,c)}finally{ce.p=y,q.T=p}}function Pf(t,r,s,c){if(uu){var p=Qf(c);if(p===null)Bf(t,r,c,du,s),b0(t,c);else if(dw(p,t,r,s,c))c.stopPropagation();else if(b0(t,c),r&4&&-1<uw.indexOf(t)){for(;p!==null;){var y=Ma(p);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var S=Jt(y.pendingLanes);if(S!==0){var z=y;for(z.pendingLanes|=2,z.entangledLanes|=2;S;){var X=1<<31-We(S);z.entanglements[1]|=X,S&=~X}va(y),(Vt&6)===0&&(Vc=je()+500,fo(0))}}break;case 31:case 13:z=si(y,2),z!==null&&vr(z,y,2),Kc(),Kf(y,2)}if(y=Qf(c),y===null&&Bf(t,r,c,du,s),y===p)break;p=y}p!==null&&c.stopPropagation()}else Bf(t,r,c,null,s)}}function Qf(t){return t=ha(t),Zf(t)}var du=null;function Zf(t){if(du=null,t=ua(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=f(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 du=t,null}function y0(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(Ne()){case G:return 2;case Z:return 8;case ye:case ge:return 32;case Ee:return 268435456;default:return 32}default:return 32}}var Jf=!1,Bl=null,Ol=null,$l=null,bo=new Map,vo=new Map,Ll=[],uw="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 b0(t,r){switch(t){case"focusin":case"focusout":Bl=null;break;case"dragenter":case"dragleave":Ol=null;break;case"mouseover":case"mouseout":$l=null;break;case"pointerover":case"pointerout":bo.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":vo.delete(r.pointerId)}}function wo(t,r,s,c,p,y){return t===null||t.nativeEvent!==y?(t={blockedOn:r,domEventName:s,eventSystemFlags:c,nativeEvent:y,targetContainers:[p]},r!==null&&(r=Ma(r),r!==null&&x0(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),t)}function dw(t,r,s,c,p){switch(r){case"focusin":return Bl=wo(Bl,t,r,s,c,p),!0;case"dragenter":return Ol=wo(Ol,t,r,s,c,p),!0;case"mouseover":return $l=wo($l,t,r,s,c,p),!0;case"pointerover":var y=p.pointerId;return bo.set(y,wo(bo.get(y)||null,t,r,s,c,p)),!0;case"gotpointercapture":return y=p.pointerId,vo.set(y,wo(vo.get(y)||null,t,r,s,c,p)),!0}return!1}function v0(t){var r=ua(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,Sn(t.priority,function(){g0(s)});return}}else if(r===31){if(r=f(s),r!==null){t.blockedOn=r,Sn(t.priority,function(){g0(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 fu(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var s=Qf(t.nativeEvent);if(s===null){s=t.nativeEvent;var c=new s.constructor(s.type,s);Oi=c,s.target.dispatchEvent(c),Oi=null}else return r=Ma(s),r!==null&&x0(r),t.blockedOn=s,!1;r.shift()}return!0}function w0(t,r,s){fu(t)&&s.delete(r)}function fw(){Jf=!1,Bl!==null&&fu(Bl)&&(Bl=null),Ol!==null&&fu(Ol)&&(Ol=null),$l!==null&&fu($l)&&($l=null),bo.forEach(w0),vo.forEach(w0)}function hu(t,r){t.blockedOn===r&&(t.blockedOn=null,Jf||(Jf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,fw)))}var mu=null;function k0(t){mu!==t&&(mu=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){mu===t&&(mu=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(Zf(c||s)===null)continue;break}var y=Ma(s);y!==null&&(t.splice(r,3),r-=3,Pd(y,{pending:!0,data:p,method:s.method,action:c},c,p))}}))}function ms(t){function r(X){return hu(X,t)}Bl!==null&&hu(Bl,t),Ol!==null&&hu(Ol,t),$l!==null&&hu($l,t),bo.forEach(r),vo.forEach(r);for(var s=0;s<Ll.length;s++){var c=Ll[s];c.blockedOn===t&&(c.blockedOn=null)}for(;0<Ll.length&&(s=Ll[0],s.blockedOn===null);)v0(s),s.blockedOn===null&&Ll.shift();if(s=(t.ownerDocument||t).$$reactFormReplay,s!=null)for(c=0;c<s.length;c+=3){var p=s[c],y=s[c+1],S=p[mn]||null;if(typeof y=="function")S||k0(s);else if(S){var z=null;if(y&&y.hasAttribute("formAction")){if(p=y,S=y[mn]||null)z=S.formAction;else if(Zf(p)!==null)continue}else z=S.action;typeof z=="function"?s[c+1]=z:(s.splice(c,3),c-=3),k0(s)}}}function j0(){function t(y){y.canIntercept&&y.info==="react-transition"&&y.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 y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.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 eh(t){this._internalRoot=t}pu.prototype.render=eh.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var s=r.current,c=Mr();m0(s,c,t,r,null,null)},pu.prototype.unmount=eh.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;m0(t.current,2,null,t,null,null),Kc(),r[Lr]=null}};function pu(t){this._internalRoot=t}pu.prototype.unstable_scheduleHydration=function(t){if(t){var r=Ze();t={blockedOn:null,target:t,priority:r};for(var s=0;s<Ll.length&&r!==0&&r<Ll[s].priority;s++);Ll.splice(s,0,t),s===0&&v0(t)}};var S0=n.version;if(S0!=="19.2.4")throw Error(i(527,S0,"19.2.4"));ce.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=h(r),t=t!==null?x(t):null,t=t===null?null:t.stateNode,t};var hw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var xu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xu.isDisabled&&xu.supportsFiber)try{Oe=xu.inject(hw),qe=xu}catch{}}return jo.createRoot=function(t,r){if(!o(t))throw Error(i(299));var s=!1,c="",p=Fx,y=Rx,S=Mx;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&&(y=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=f0(t,1,!1,null,null,s,c,null,p,y,S,j0),t[Lr]=r.current,_f(t),new eh(r)},jo.hydrateRoot=function(t,r,s){if(!o(t))throw Error(i(299));var c=!1,p="",y=Fx,S=Rx,z=Mx,X=null;return s!=null&&(s.unstable_strictMode===!0&&(c=!0),s.identifierPrefix!==void 0&&(p=s.identifierPrefix),s.onUncaughtError!==void 0&&(y=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(z=s.onRecoverableError),s.formState!==void 0&&(X=s.formState)),r=f0(t,1,!0,r,s??null,c,p,X,y,S,z,j0),r.context=h0(null),s=r.current,c=Mr(),c=Me(c),p=Sl(c),p.callback=null,Cl(s,p,c),s=c,r.current.lanes=s,ve(r,s),va(r),t[Lr]=r.current,_f(t),new pu(r)},jo.version="19.2.4",jo}var _0;function Cw(){if(_0)return rh.exports;_0=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(),rh.exports=Sw(),rh.exports}var Ew=Cw();const Nw="modulepreload",Aw=function(e){return"/"+e},B0={},Dy=function(n,a,i){let o=Promise.resolve();if(a&&a.length>0){let d=function(h){return Promise.all(h.map(x=>Promise.resolve(x).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));o=d(a.map(h=>{if(h=Aw(h),h in B0)return;B0[h]=!0;const x=h.endsWith(".css"),g=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const v=document.createElement("link");if(v.rel=x?"stylesheet":Nw,x||(v.as="script"),v.crossOrigin="",v.href=h,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 ${h}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return o.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return n().catch(u)})};class Dw extends w.Component{constructor(){super(...arguments);C0(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 Ea="/api";async function Ut(e){const n=await fetch(`${Ea}${e}`);if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function an(e,n){const a=await fetch(`${Ea}${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 gu(e,n){const a=await fetch(`${Ea}${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 Tw(e,n){const a=await fetch(`${Ea}${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 rl(e,n){const a={method:"DELETE"};n!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(n));const i=await fetch(`${Ea}${e}`,a);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const pe={getCompany:()=>Ut("/company"),getRoles:()=>Ut("/roles"),getRole:e=>Ut(`/roles/${e}`),getProjects:()=>Ut("/projects"),getProject:e=>Ut(`/projects/${e}`),getStandups:()=>Ut("/operations/standups"),getWaves:()=>Ut("/operations/waves"),getWaveDetail:e=>Ut(`/operations/waves/${e}`),patchWave:(e,n)=>gu(`/operations/waves/${e}`,n),getDecisions:()=>Ut("/operations/decisions"),updateDecision:(e,n)=>Tw(`/operations/decisions/${e}`,{content:n}),deleteDecision:e=>rl(`/operations/decisions/${e}`),getOrgTree:()=>Ut("/engine/org"),getSkills:()=>Ut("/skills"),exportSkills:e=>Ut(`/skills/export/${e}`),getSkillRegistry:()=>Ut("/skills/registry"),installRegistrySkill:(e,n)=>an("/skills/registry/install",{skillId:e,url:n}),createRole:e=>an("/engine/roles",e),updateRole:(e,n)=>gu(`/engine/roles/${e}`,n),deleteRole:e=>rl(`/engine/roles/${e}`),getSessions:()=>Ut("/sessions"),getSession:e=>Ut(`/sessions/${e}`),createSession:(e,n="talk")=>an("/sessions",{roleId:e,mode:n}),deleteSession:e=>rl(`/sessions/${e}`),deleteSessions:e=>rl("/sessions",{ids:e}),deleteEmptySessions:()=>rl("/sessions?empty=true"),updateSession:(e,n)=>gu(`/sessions/${e}`,n),abortSession:e=>an(`/sessions/${e}/abort`,{}),abortJob:e=>an(`/jobs/${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:()=>Ut("/status"),detectEngine:()=>an("/setup/detect-engine",{}),validatePath:e=>an("/setup/validate-path",{path:e}),scaffold:e=>an("/setup/scaffold",e),getTeams:()=>Ut("/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(`${Ea}/setup/install-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({team:e})}).then(a=>{var f;const i=(f=a.body)==null?void 0:f.getReader();if(!i)return;const o=new TextDecoder;let u="";const d=()=>i.read().then(({done:m,value:h})=>{if(m)return;u+=o.decode(h,{stream:!0});const x=u.split(`
|
|
50
|
+
`);u=x.pop()||"";let g="";for(const v of x)if(v.startsWith("event: "))g=v.slice(7);else if(v.startsWith("data: ")&&g){try{n(g,JSON.parse(v.slice(6)))}catch{}g=""}return d()});return d()}),getKnowledge:()=>Ut("/knowledge"),getKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return Ut(`/knowledge/${n}`)},createKnowledgeDoc:e=>an("/knowledge",e),updateKnowledgeDoc:(e,n)=>{const a=e.split("/").map(encodeURIComponent).join("/");return fetch(`${Ea}/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 rl(`/knowledge/${n}`)},getPreferences:()=>Ut("/preferences"),updatePreferences:e=>gu("/preferences",e),chatInChannel:e=>an("/speech/chat",e),getSaveStatus:(e="akb")=>Ut(`/save/status?repo=${e}`),save:(e,n="akb")=>an(`/save?repo=${n}`,{message:e}),getSaveHistory:(e=20,n="akb")=>Ut(`/save/history?limit=${e}&repo=${n}`),restoreSave:(e,n,a="akb")=>an(`/save/restore?repo=${a}`,{sha:e,paths:n}),initGit:(e="akb")=>an(`/save/init?repo=${e}`,{}),getSyncStatus:(e="akb")=>Ut(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${Ea}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>Ut(`/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(`${Ea}/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:()=>Ut("/setup/code-root"),getCostSummary:()=>Ut("/cost/summary"),getSyncRoles:()=>Ut("/sync/roles"),applySyncUpdate:e=>an("/sync/apply",e),getCompanyStats:()=>Ut("/sync/stats"),getCoins:()=>Ut("/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:()=>Ut("/quests/progress"),saveQuestProgress:e=>fetch(`${Ea}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>n.json()),getActiveSessions:()=>Ut("/active-sessions"),getActiveSession:e=>Ut(`/active-sessions/${e}`),registerActiveSession:e=>an("/active-sessions/register",e),deleteActiveSession:e=>rl(`/active-sessions/${e}`),cleanupActiveSessions:()=>an("/active-sessions/cleanup",{}),getGitStatus:()=>Ut("/git/status"),deleteWorktree:e=>rl(`/git/worktrees/${encodeURIComponent(e)}`),deleteBranch:e=>rl(`/git/branches/${encodeURIComponent(e)}`)},Fw=Object.freeze(Object.defineProperty({__proto__:null,api:pe},Symbol.toStringTag,{value:"Module"}));function Wn(e){return e==="working"||e==="awaiting_input"}function Ty(e){return e==="running"||e==="awaiting_input"}function il(e){return e==="running"||e==="awaiting_input"}function Fy(e){const[n,a]=w.useState([]),[i,o]=w.useState("idle"),[u,d]=w.useState(""),[f,m]=w.useState([]),h=w.useRef(-1),x=w.useRef(null),g=w.useRef(0),v=w.useCallback(()=>{var E;if(!e)return;(E=x.current)==null||E.abort();const j=new AbortController;x.current=j,o("connecting");const k=h.current+1,N=`/api/sessions/${e}/stream?from=${k}`;fetch(N,{signal:j.signal}).then(async C=>{if(!C.ok||!C.body){o("error");return}o("streaming");const _=C.body.getReader(),M=new TextDecoder;let H="";for(;;){const{done:R,value:I}=await _.read();if(R)break;H+=M.decode(I,{stream:!0});const W=H.split(`
|
|
51
|
+
`);H=W.pop()??"";let Y="";for(const D of W)if(D.startsWith("event: "))Y=D.slice(7).trim();else if(D.startsWith("data: ")){try{const O=JSON.parse(D.slice(6));if(Y==="activity"){const B=O;B.seq>h.current&&(h.current=B.seq),a(ee=>ee.some(re=>re.seq===B.seq)?ee:[...ee,B]),B.type==="text"&&d(ee=>ee+(B.data.text??"")),B.type==="dispatch:start"&&B.data.childJobId&&m(ee=>[...ee,B.data.childJobId]),B.type==="job:done"?o("done"):B.type==="job:error"&&o("error")}else if(Y==="stream:end"){const B=O.reason;o(B==="done"?"done":B==="error"?"error":"done")}}catch{}Y=""}}i==="streaming"&&o("done")}).catch(C=>{C.name!=="AbortError"&&(o("error"),g.current<3&&(g.current++,setTimeout(v,1e3*g.current)))})},[e]),b=w.useCallback(()=>{g.current=0,v()},[v]);return w.useEffect(()=>{if(!e){a([]),o("idle"),d(""),m([]),h.current=-1;return}return a([]),d(""),m([]),h.current=-1,g.current=0,v(),()=>{var j;(j=x.current)==null||j.abort()}},[e,v]),{events:n,status:i,textOutput:u,childJobIds:f,reconnect:b}}function Rw(e,n){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const Mw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_w={};function O0(e,n){return(_w.jsx?zw:Mw).test(e)}const Bw=/[ \t\n\f\r]/g;function Ow(e){return typeof e=="object"?e.type==="text"?$0(e.value):!1:$0(e)}function $0(e){return e.replace(Bw,"")===""}class Wo{constructor(n,a,i){this.normal=a,this.property=n,i&&(this.space=i)}}Wo.prototype.normal={};Wo.prototype.property={};Wo.prototype.space=void 0;function Ry(e,n){const a={},i={};for(const o of e)Object.assign(a,o.property),Object.assign(i,o.normal);return new Wo(a,i,n)}function Gh(e){return e.toLowerCase()}class jr{constructor(n,a){this.attribute=a,this.property=n}}jr.prototype.attribute="";jr.prototype.booleanish=!1;jr.prototype.boolean=!1;jr.prototype.commaOrSpaceSeparated=!1;jr.prototype.commaSeparated=!1;jr.prototype.defined=!1;jr.prototype.mustUseProperty=!1;jr.prototype.number=!1;jr.prototype.overloadedBoolean=!1;jr.prototype.property="";jr.prototype.spaceSeparated=!1;jr.prototype.space=void 0;let $w=0;const vt=Ri(),zn=Ri(),Kh=Ri(),Re=Ri(),fn=Ri(),bs=Ri(),zr=Ri();function Ri(){return 2**++$w}const Ph=Object.freeze(Object.defineProperty({__proto__:null,boolean:vt,booleanish:zn,commaOrSpaceSeparated:zr,commaSeparated:bs,number:Re,overloadedBoolean:Kh,spaceSeparated:fn},Symbol.toStringTag,{value:"Module"})),sh=Object.keys(Ph);class Cm extends jr{constructor(n,a,i,o){let u=-1;if(super(n,a),L0(this,"space",o),typeof i=="number")for(;++u<sh.length;){const d=sh[u];L0(this,sh[u],(i&Ph[d])===Ph[d])}}}Cm.prototype.defined=!0;function L0(e,n,a){a&&(e[n]=a)}function Es(e){const n={},a={};for(const[i,o]of Object.entries(e.properties)){const u=new Cm(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(u.mustUseProperty=!0),n[i]=u,a[Gh(i)]=i,a[Gh(u.attribute)]=i}return new Wo(n,a,e.space)}const My=Es({properties:{ariaActiveDescendant:null,ariaAtomic:zn,ariaAutoComplete:null,ariaBusy:zn,ariaChecked:zn,ariaColCount:Re,ariaColIndex:Re,ariaColSpan:Re,ariaControls:fn,ariaCurrent:null,ariaDescribedBy:fn,ariaDetails:null,ariaDisabled:zn,ariaDropEffect:fn,ariaErrorMessage:null,ariaExpanded:zn,ariaFlowTo:fn,ariaGrabbed:zn,ariaHasPopup:null,ariaHidden:zn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:fn,ariaLevel:Re,ariaLive:null,ariaModal:zn,ariaMultiLine:zn,ariaMultiSelectable:zn,ariaOrientation:null,ariaOwns:fn,ariaPlaceholder:null,ariaPosInSet:Re,ariaPressed:zn,ariaReadOnly:zn,ariaRelevant:null,ariaRequired:zn,ariaRoleDescription:fn,ariaRowCount:Re,ariaRowIndex:Re,ariaRowSpan:Re,ariaSelected:zn,ariaSetSize:Re,ariaSort:null,ariaValueMax:Re,ariaValueMin:Re,ariaValueNow:Re,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function zy(e,n){return n in e?e[n]:n}function _y(e,n){return zy(e,n.toLowerCase())}const Lw=Es({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:bs,acceptCharset:fn,accessKey:fn,action:null,allow:null,allowFullScreen:vt,allowPaymentRequest:vt,allowUserMedia:vt,alt:null,as:null,async:vt,autoCapitalize:null,autoComplete:fn,autoFocus:vt,autoPlay:vt,blocking:fn,capture:null,charSet:null,checked:vt,cite:null,className:fn,cols:Re,colSpan:null,content:null,contentEditable:zn,controls:vt,controlsList:fn,coords:Re|bs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:vt,defer:vt,dir:null,dirName:null,disabled:vt,download:Kh,draggable:zn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:vt,formTarget:null,headers:fn,height:Re,hidden:Kh,high:Re,href:null,hrefLang:null,htmlFor:fn,httpEquiv:fn,id:null,imageSizes:null,imageSrcSet:null,inert:vt,inputMode:null,integrity:null,is:null,isMap:vt,itemId:null,itemProp:fn,itemRef:fn,itemScope:vt,itemType:fn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:vt,low:Re,manifest:null,max:null,maxLength:Re,media:null,method:null,min:null,minLength:Re,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:Re,pattern:null,ping:fn,placeholder:null,playsInline:vt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:vt,referrerPolicy:null,rel:fn,required:vt,reversed:vt,rows:Re,rowSpan:Re,sandbox:fn,scope:null,scoped:vt,seamless:vt,selected:vt,shadowRootClonable:vt,shadowRootDelegatesFocus:vt,shadowRootMode:null,shape:null,size:Re,sizes:null,slot:null,span:Re,spellCheck:zn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Re,step:null,style:null,tabIndex:Re,target:null,title:null,translate:null,type:null,typeMustMatch:vt,useMap:null,value:zn,width:Re,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:fn,axis:null,background:null,bgColor:null,border:Re,borderColor:null,bottomMargin:Re,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:Re,leftMargin:Re,link:null,longDesc:null,lowSrc:null,marginHeight:Re,marginWidth:Re,noResize:vt,noHref:vt,noShade:vt,noWrap:vt,object:null,profile:null,prompt:null,rev:null,rightMargin:Re,rules:null,scheme:null,scrolling:zn,standby:null,summary:null,text:null,topMargin:Re,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Re,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:vt,disableRemotePlayback:vt,prefix:null,property:null,results:Re,security:null,unselectable:null},space:"html",transform:_y}),Iw=Es({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:zr,accentHeight:Re,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Re,amplitude:Re,arabicForm:null,ascent:Re,attributeName:null,attributeType:null,azimuth:Re,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Re,by:null,calcMode:null,capHeight:Re,className:fn,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:Re,diffuseConstant:Re,direction:null,display:null,dur:null,divisor:Re,dominantBaseline:null,download:vt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Re,enableBackground:null,end:null,event:null,exponent:Re,externalResourcesRequired:null,fill:null,fillOpacity:Re,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:bs,g2:bs,glyphName:bs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Re,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Re,horizOriginX:Re,horizOriginY:Re,id:null,ideographic:Re,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Re,k:Re,k1:Re,k2:Re,k3:Re,k4:Re,kernelMatrix:zr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Re,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:Re,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:Re,overlineThickness:Re,paintOrder:null,panose1:null,path:null,pathLength:Re,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:fn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Re,pointsAtY:Re,pointsAtZ:Re,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:zr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:zr,rev:zr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:zr,requiredFeatures:zr,requiredFonts:zr,requiredFormats:zr,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:Re,specularExponent:Re,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Re,strikethroughThickness:Re,string:null,stroke:null,strokeDashArray:zr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Re,strokeOpacity:Re,strokeWidth:null,style:null,surfaceScale:Re,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:zr,tabIndex:Re,tableValues:null,target:null,targetX:Re,targetY:Re,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:zr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Re,underlineThickness:Re,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Re,values:null,vAlphabetic:Re,vMathematical:Re,vectorEffect:null,vHanging:Re,vIdeographic:Re,version:null,vertAdvY:Re,vertOriginX:Re,vertOriginY:Re,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Re,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:zy}),By=Es({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()}}),Oy=Es({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:_y}),$y=Es({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),Hw={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"},Uw=/[A-Z]/g,I0=/-[a-z]/g,qw=/^data[-\w.:]+$/i;function Yw(e,n){const a=Gh(n);let i=n,o=jr;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&qw.test(n)){if(n.charAt(4)==="-"){const u=n.slice(5).replace(I0,Ww);i="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=n.slice(4);if(!I0.test(u)){let d=u.replace(Uw,Xw);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}o=Cm}return new o(i,n)}function Xw(e){return"-"+e.toLowerCase()}function Ww(e){return e.charAt(1).toUpperCase()}const Vw=Ry([My,Lw,By,Oy,$y],"html"),Em=Ry([My,Iw,By,Oy,$y],"svg");function Gw(e){return e.join(" ").trim()}var ps={},oh,H0;function Kw(){if(H0)return oh;H0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
|
|
52
|
+
`,h="/",x="*",g="",v="comment",b="declaration";function j(N,E){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];E=E||{};var C=1,_=1;function M(re){var K=re.match(n);K&&(C+=K.length);var q=re.lastIndexOf(m);_=~q?re.length-q:_+re.length}function H(){var re={line:C,column:_};return function(K){return K.position=new R(re),Y(),K}}function R(re){this.start=re,this.end={line:C,column:_},this.source=E.source}R.prototype.content=N;function I(re){var K=new Error(E.source+":"+C+":"+_+": "+re);if(K.reason=re,K.filename=E.source,K.line=C,K.column=_,K.source=N,!E.silent)throw K}function W(re){var K=re.exec(N);if(K){var q=K[0];return M(q),N=N.slice(q.length),K}}function Y(){W(a)}function D(re){var K;for(re=re||[];K=O();)K!==!1&&re.push(K);return re}function O(){var re=H();if(!(h!=N.charAt(0)||x!=N.charAt(1))){for(var K=2;g!=N.charAt(K)&&(x!=N.charAt(K)||h!=N.charAt(K+1));)++K;if(K+=2,g===N.charAt(K-1))return I("End of comment missing");var q=N.slice(2,K-2);return _+=2,M(q),N=N.slice(K),_+=2,re({type:v,comment:q})}}function B(){var re=H(),K=W(i);if(K){if(O(),!W(o))return I("property missing ':'");var q=W(u),ce=re({type:b,property:k(K[0].replace(e,g)),value:q?k(q[0].replace(e,g)):g});return W(d),ce}}function ee(){var re=[];D(re);for(var K;K=B();)K!==!1&&(re.push(K),D(re));return re}return Y(),ee()}function k(N){return N?N.replace(f,g):g}return oh=j,oh}var U0;function Pw(){if(U0)return ps;U0=1;var e=ps&&ps.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(ps,"__esModule",{value:!0}),ps.default=a;const n=e(Kw());function a(i,o){let u=null;if(!i||typeof i!="string")return u;const d=(0,n.default)(i),f=typeof o=="function";return d.forEach(m=>{if(m.type!=="declaration")return;const{property:h,value:x}=m;f?o(h,x,m):x&&(u=u||{},u[h]=x)}),u}return ps}var So={},q0;function Qw(){if(q0)return So;q0=1,Object.defineProperty(So,"__esModule",{value:!0}),So.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,u=function(h){return!h||a.test(h)||e.test(h)},d=function(h,x){return x.toUpperCase()},f=function(h,x){return"".concat(x,"-")},m=function(h,x){return x===void 0&&(x={}),u(h)?h:(h=h.toLowerCase(),x.reactCompat?h=h.replace(o,f):h=h.replace(i,f),h.replace(n,d))};return So.camelCase=m,So}var Co,Y0;function Zw(){if(Y0)return Co;Y0=1;var e=Co&&Co.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(Pw()),a=Qw();function i(o,u){var d={};return!o||typeof o!="string"||(0,n.default)(o,function(f,m){f&&m&&(d[(0,a.camelCase)(f,u)]=m)}),d}return i.default=i,Co=i,Co}var Jw=Zw();const e5=Ay(Jw),Ly=Iy("end"),Nm=Iy("start");function Iy(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 t5(e){const n=Nm(e),a=Ly(e);if(n&&a)return{start:n,end:a}}function Oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?X0(e.position):"start"in e||"end"in e?X0(e):"line"in e||"column"in e?Qh(e):""}function Qh(e){return W0(e&&e.line)+":"+W0(e&&e.column)}function X0(e){return Qh(e&&e.start)+"-"+Qh(e&&e.end)}function W0(e){return e&&typeof e=="number"?e:1}class lr 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 f=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=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=Oo(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}}lr.prototype.file="";lr.prototype.name="";lr.prototype.reason="";lr.prototype.message="";lr.prototype.stack="";lr.prototype.column=void 0;lr.prototype.line=void 0;lr.prototype.ancestors=void 0;lr.prototype.cause=void 0;lr.prototype.fatal=void 0;lr.prototype.place=void 0;lr.prototype.ruleId=void 0;lr.prototype.source=void 0;const Am={}.hasOwnProperty,n5=new Map,r5=/[A-Z]/g,a5=new Set(["table","tbody","thead","tfoot","tr"]),l5=new Set(["td","th"]),Hy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function i5(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=m5(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=h5(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"?Em:Vw,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},u=Uy(o,e,void 0);return u&&typeof u!="string"?u:o.create(e,o.Fragment,{children:u||void 0},void 0)}function Uy(e,n,a){if(n.type==="element")return s5(e,n,a);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return o5(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return u5(e,n,a);if(n.type==="mdxjsEsm")return c5(e,n);if(n.type==="root")return d5(e,n,a);if(n.type==="text")return f5(e,n)}function s5(e,n,a){const i=e.schema;let o=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=Em,e.schema=o),e.ancestors.push(n);const u=Yy(e,n.tagName,!1),d=p5(e,n);let f=Tm(e,n);return a5.has(n.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!Ow(m):!0})),qy(e,d,u,n),Dm(d,f),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function o5(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)}Ho(e,n.position)}function c5(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Ho(e,n.position)}function u5(e,n,a){const i=e.schema;let o=i;n.name==="svg"&&i.space==="html"&&(o=Em,e.schema=o),e.ancestors.push(n);const u=n.name===null?e.Fragment:Yy(e,n.name,!0),d=x5(e,n),f=Tm(e,n);return qy(e,d,u,n),Dm(d,f),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function d5(e,n,a){const i={};return Dm(i,Tm(e,n)),e.create(n,e.Fragment,i,a)}function f5(e,n){return n.value}function qy(e,n,a,i){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(n.node=i)}function Dm(e,n){if(n.length>0){const a=n.length>1?n:n[0];a&&(e.children=a)}}function h5(e,n,a){return i;function i(o,u,d,f){const h=Array.isArray(d.children)?a:n;return f?h(u,d,f):h(u,d)}}function m5(e,n){return a;function a(i,o,u,d){const f=Array.isArray(u.children),m=Nm(i);return n(o,u,d,f,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function p5(e,n){const a={};let i,o;for(o in n.properties)if(o!=="children"&&Am.call(n.properties,o)){const u=g5(e,o,n.properties[o]);if(u){const[d,f]=u;e.tableCellAlignToStyle&&d==="align"&&typeof f=="string"&&l5.has(n.tagName)?i=f:a[d]=f}}if(i){const u=a.style||(a.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return a}function x5(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 f=d.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else Ho(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 f=i.value.data.estree.body[0];f.type,u=e.evaluater.evaluateExpression(f.expression)}else Ho(e,n.position);else u=i.value===null?!0:i.value;a[o]=u}return a}function Tm(e,n){const a=[];let i=-1;const o=e.passKeys?new Map:n5;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 h=o.get(m)||0;d=m+"-"+h,o.set(m,h+1)}}const f=Uy(e,u,d);f!==void 0&&a.push(f)}return a}function g5(e,n,a){const i=Yw(e.schema,n);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=i.commaSeparated?Rw(a):Gw(a)),i.property==="style"){let o=typeof a=="object"?a:y5(e,String(a));return e.stylePropertyNameCase==="css"&&(o=b5(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?Hw[i.property]||i.property:i.attribute,a]}}function y5(e,n){try{return e5(n,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const i=a,o=new lr("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=Hy+"#cannot-parse-style-attribute",o}}function Yy(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 f=O0(o[u])?{type:"Identifier",name:o[u]}:{type:"Literal",value:o[u]};d=d?{type:"MemberExpression",object:d,property:f,computed:!!(u&&f.type==="Literal"),optional:!1}:f}i=d}else i=O0(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const o=i.value;return Am.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);Ho(e)}function Ho(e,n){const a=new lr("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=Hy+"#cannot-handle-mdx-estrees-without-createevaluater",a}function b5(e){const n={};let a;for(a in e)Am.call(e,a)&&(n[v5(a)]=e[a]);return n}function v5(e){let n=e.replace(r5,w5);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function w5(e){return"-"+e.toLowerCase()}const ch={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"]},k5={};function Fm(e,n){const a=k5,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Xy(e,i,o)}function Xy(e,n,a){if(j5(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 V0(e.children,n,a)}return Array.isArray(e)?V0(e,n,a):""}function V0(e,n,a){const i=[];let o=-1;for(;++o<e.length;)i[o]=Xy(e[o],n,a);return i.join("")}function j5(e){return!!(e&&typeof e=="object")}const G0=document.createElement("i");function Rm(e){const n="&"+e+";";G0.innerHTML=n;const a=G0.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===n?!1:a}function $r(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 Zr(e,n){return e.length>0?($r(e,e.length,0,n),e):n}const K0={}.hasOwnProperty;function Wy(e){const n={};let a=-1;for(;++a<e.length;)S5(n,e[a]);return n}function S5(e,n){let a;for(a in n){const o=(K0.call(e,a)?e[a]:void 0)||(e[a]={}),u=n[a];let d;if(u)for(d in u){K0.call(o,d)||(o[d]=[]);const f=u[d];C5(o[d],Array.isArray(f)?f:f?[f]:[])}}}function C5(e,n){let a=-1;const i=[];for(;++a<n.length;)(n[a].add==="after"?e:i).push(n[a]);$r(e,0,0,i)}function Vy(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 ca(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ur=Pl(/[A-Za-z]/),ar=Pl(/[\dA-Za-z]/),E5=Pl(/[#-'*+\--9=?A-Z^-~]/);function Iu(e){return e!==null&&(e<32||e===127)}const Zh=Pl(/\d/),N5=Pl(/[\dA-Fa-f]/),A5=Pl(/[!-/:-@[-`{-~]/);function it(e){return e!==null&&e<-2}function un(e){return e!==null&&(e<0||e===32)}function At(e){return e===-2||e===-1||e===32}const Qu=Pl(new RegExp("\\p{P}|\\p{S}","u")),Ti=Pl(/\s/);function Pl(e){return n;function n(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function Ns(e){const n=[];let a=-1,i=0,o=0;for(;++a<e.length;){const u=e.charCodeAt(a);let d="";if(u===37&&ar(e.charCodeAt(a+1))&&ar(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 f=e.charCodeAt(a+1);u<56320&&f>56319&&f<57344?(d=String.fromCharCode(u,f),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 It(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),f(m)):n(m)}function f(m){return At(m)&&u++<o?(e.consume(m),f):(e.exit(a),n(m))}}const D5={tokenize:T5};function T5(e){const n=e.attempt(this.parser.constructs.contentInitial,i,o);let a;return n;function i(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),It(e,n,"linePrefix")}function o(f){return e.enter("paragraph"),u(f)}function u(f){const m=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=m),a=m,d(f)}function d(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return it(f)?(e.consume(f),e.exit("chunkText"),u):(e.consume(f),d)}}const F5={tokenize:R5},P0={tokenize:M5};function R5(e){const n=this,a=[];let i=0,o,u,d;return f;function f(_){if(i<a.length){const M=a[i];return n.containerState=M[1],e.attempt(M[0].continuation,m,h)(_)}return h(_)}function m(_){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&C();const M=n.events.length;let H=M,R;for(;H--;)if(n.events[H][0]==="exit"&&n.events[H][1].type==="chunkFlow"){R=n.events[H][1].end;break}E(i);let I=M;for(;I<n.events.length;)n.events[I][1].end={...R},I++;return $r(n.events,H+1,0,n.events.slice(M)),n.events.length=I,h(_)}return f(_)}function h(_){if(i===a.length){if(!o)return v(_);if(o.currentConstruct&&o.currentConstruct.concrete)return j(_);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(P0,x,g)(_)}function x(_){return o&&C(),E(i),v(_)}function g(_){return n.parser.lazy[n.now().line]=i!==a.length,d=n.now().offset,j(_)}function v(_){return n.containerState={},e.attempt(P0,b,j)(_)}function b(_){return i++,a.push([n.currentConstruct,n.containerState]),v(_)}function j(_){if(_===null){o&&C(),E(0),e.consume(_);return}return o=o||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:u}),k(_)}function k(_){if(_===null){N(e.exit("chunkFlow"),!0),E(0),e.consume(_);return}return it(_)?(e.consume(_),N(e.exit("chunkFlow")),i=0,n.interrupt=void 0,f):(e.consume(_),k)}function N(_,M){const H=n.sliceStream(_);if(M&&H.push(null),_.previous=u,u&&(u.next=_),u=_,o.defineSkip(_.start),o.write(H),n.parser.lazy[_.start.line]){let R=o.events.length;for(;R--;)if(o.events[R][1].start.offset<d&&(!o.events[R][1].end||o.events[R][1].end.offset>d))return;const I=n.events.length;let W=I,Y,D;for(;W--;)if(n.events[W][0]==="exit"&&n.events[W][1].type==="chunkFlow"){if(Y){D=n.events[W][1].end;break}Y=!0}for(E(i),R=I;R<n.events.length;)n.events[R][1].end={...D},R++;$r(n.events,W+1,0,n.events.slice(I)),n.events.length=R}}function E(_){let M=a.length;for(;M-- >_;){const H=a[M];n.containerState=H[1],H[0].exit.call(n,e)}a.length=_}function C(){o.write([null]),u=void 0,o=void 0,n.containerState._closeFlow=void 0}}function M5(e,n,a){return It(e,e.attempt(this.parser.constructs.document,n,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ws(e){if(e===null||un(e)||Ti(e))return 1;if(Qu(e))return 2}function Zu(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 Jh={name:"attention",resolveAll:z5,tokenize:_5};function z5(e,n){let a=-1,i,o,u,d,f,m,h,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 g={...e[i][1].end},v={...e[a][1].start};Q0(g,-m),Q0(v,m),d={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[i][1].end}},f={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:{...f.end}},e[i][1].end={...d.start},e[a][1].start={...f.end},h=[],e[i][1].end.offset-e[i][1].start.offset&&(h=Zr(h,[["enter",e[i][1],n],["exit",e[i][1],n]])),h=Zr(h,[["enter",o,n],["enter",d,n],["exit",d,n],["enter",u,n]]),h=Zr(h,Zu(n.parser.constructs.insideSpan.null,e.slice(i+1,a),n)),h=Zr(h,[["exit",u,n],["enter",f,n],["exit",f,n],["exit",o,n]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,h=Zr(h,[["enter",e[a][1],n],["exit",e[a][1],n]])):x=0,$r(e,i-1,a-i+3,h),a=i+h.length-x-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function _5(e,n){const a=this.parser.constructs.attentionMarkers.null,i=this.previous,o=ws(i);let u;return d;function d(m){return u=m,e.enter("attentionSequence"),f(m)}function f(m){if(m===u)return e.consume(m),f;const h=e.exit("attentionSequence"),x=ws(m),g=!x||x===2&&o||a.includes(m),v=!o||o===2&&x||a.includes(i);return h._open=!!(u===42?g:g&&(o||!v)),h._close=!!(u===42?v:v&&(x||!g)),n(m)}}function Q0(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const B5={name:"autolink",tokenize:O5};function O5(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 ur(b)?(e.consume(b),d):b===64?a(b):h(b)}function d(b){return b===43||b===45||b===46||ar(b)?(i=1,f(b)):h(b)}function f(b){return b===58?(e.consume(b),i=0,m):(b===43||b===45||b===46||ar(b))&&i++<32?(e.consume(b),f):(i=0,h(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||Iu(b)?a(b):(e.consume(b),m)}function h(b){return b===64?(e.consume(b),x):E5(b)?(e.consume(b),h):a(b)}function x(b){return ar(b)?g(b):a(b)}function g(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||ar(b))&&i++<63){const j=b===45?v:g;return e.consume(b),j}return a(b)}}const Vo={partial:!0,tokenize:$5};function $5(e,n,a){return i;function i(u){return At(u)?It(e,o,"linePrefix")(u):o(u)}function o(u){return u===null||it(u)?n(u):a(u)}}const Gy={continuation:{tokenize:I5},exit:H5,name:"blockQuote",tokenize:L5};function L5(e,n,a){const i=this;return o;function o(d){if(d===62){const f=i.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.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 I5(e,n,a){const i=this;return o;function o(d){return At(d)?It(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):u(d)}function u(d){return e.attempt(Gy,n,a)(d)}}function H5(e){e.exit("blockQuote")}const Ky={name:"characterEscape",tokenize:U5};function U5(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 A5(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):a(u)}}const Py={name:"characterReference",tokenize:q5};function q5(e,n,a){const i=this;let o=0,u,d;return f;function f(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),u=31,d=ar,x(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,d=N5,x):(e.enter("characterReferenceValue"),u=7,d=Zh,x(g))}function x(g){if(g===59&&o){const v=e.exit("characterReferenceValue");return d===ar&&!Rm(i.sliceSerialize(v))?a(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(g)&&o++<u?(e.consume(g),x):a(g)}}const Z0={partial:!0,tokenize:X5},J0={concrete:!0,name:"codeFenced",tokenize:Y5};function Y5(e,n,a){const i=this,o={partial:!0,tokenize:H};let u=0,d=0,f;return m;function m(R){return h(R)}function h(R){const I=i.events[i.events.length-1];return u=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,f=R,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(R)}function x(R){return R===f?(d++,e.consume(R),x):d<3?a(R):(e.exit("codeFencedFenceSequence"),At(R)?It(e,g,"whitespace")(R):g(R))}function g(R){return R===null||it(R)?(e.exit("codeFencedFence"),i.interrupt?n(R):e.check(Z0,k,M)(R)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(R))}function v(R){return R===null||it(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(R)):At(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),It(e,b,"whitespace")(R)):R===96&&R===f?a(R):(e.consume(R),v)}function b(R){return R===null||it(R)?g(R):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(R))}function j(R){return R===null||it(R)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(R)):R===96&&R===f?a(R):(e.consume(R),j)}function k(R){return e.attempt(o,M,N)(R)}function N(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),E}function E(R){return u>0&&At(R)?It(e,C,"linePrefix",u+1)(R):C(R)}function C(R){return R===null||it(R)?e.check(Z0,k,M)(R):(e.enter("codeFlowValue"),_(R))}function _(R){return R===null||it(R)?(e.exit("codeFlowValue"),C(R)):(e.consume(R),_)}function M(R){return e.exit("codeFenced"),n(R)}function H(R,I,W){let Y=0;return D;function D(K){return R.enter("lineEnding"),R.consume(K),R.exit("lineEnding"),O}function O(K){return R.enter("codeFencedFence"),At(K)?It(R,B,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):B(K)}function B(K){return K===f?(R.enter("codeFencedFenceSequence"),ee(K)):W(K)}function ee(K){return K===f?(Y++,R.consume(K),ee):Y>=d?(R.exit("codeFencedFenceSequence"),At(K)?It(R,re,"whitespace")(K):re(K)):W(K)}function re(K){return K===null||it(K)?(R.exit("codeFencedFence"),I(K)):W(K)}}}function X5(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 uh={name:"codeIndented",tokenize:V5},W5={partial:!0,tokenize:G5};function V5(e,n,a){const i=this;return o;function o(h){return e.enter("codeIndented"),It(e,u,"linePrefix",5)(h)}function u(h){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(h):a(h)}function d(h){return h===null?m(h):it(h)?e.attempt(W5,d,m)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||it(h)?(e.exit("codeFlowValue"),d(h)):(e.consume(h),f)}function m(h){return e.exit("codeIndented"),n(h)}}function G5(e,n,a){const i=this;return o;function o(d){return i.parser.lazy[i.now().line]?a(d):it(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):It(e,u,"linePrefix",5)(d)}function u(d){const f=i.events[i.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?n(d):it(d)?o(d):a(d)}}const K5={name:"codeText",previous:Q5,resolve:P5,tokenize:Z5};function P5(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 Q5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Z5(e,n,a){let i=0,o,u;return d;function d(g){return e.enter("codeText"),e.enter("codeTextSequence"),f(g)}function f(g){return g===96?(e.consume(g),i++,f):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?a(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(u=e.enter("codeTextSequence"),o=0,x(g)):it(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||it(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),h)}function x(g){return g===96?(e.consume(g),o++,x):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(g)):(u.type="codeTextData",h(g))}}class J5{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&&Eo(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),Eo(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Eo(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);Eo(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);Eo(this.left,a.reverse())}}}function Eo(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 Qy(e){const n={};let a=-1,i,o,u,d,f,m,h;const x=new J5(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,ek(x,a)),a=n[a],h=!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},f=x.slice(o,a),f.unshift(i),x.splice(o,a-o+1,f))}}return $r(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!h}function ek(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 f=d.events,m=[],h={};let x,g,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),g&&d.defineSkip(b.start),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),g=b,b=b.next}for(b=a;++v<f.length;)f[v][0]==="exit"&&f[v-1][0]==="enter"&&f[v][1].type===f[v-1][1].type&&f[v][1].start.line!==f[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 E=f.slice(N[v],N[v+1]),C=u.pop();m.push([C,C+E.length-1]),e.splice(C,2,E)}for(m.reverse(),v=-1;++v<m.length;)h[j+m[v][0]]=j+m[v][1],j+=m[v][1]-m[v][0]-1;return h}const tk={resolve:rk,tokenize:ak},nk={partial:!0,tokenize:lk};function rk(e){return Qy(e),e}function ak(e,n){let a;return i;function i(f){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),o(f)}function o(f){return f===null?u(f):it(f)?e.check(nk,d,u)(f):(e.consume(f),o)}function u(f){return e.exit("chunkContent"),e.exit("content"),n(f)}function d(f){return e.consume(f),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,o}}function lk(e,n,a){const i=this;return o;function o(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),It(e,u,"linePrefix")}function u(d){if(d===null||it(d))return a(d);const f=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?n(d):e.interrupt(i.parser.constructs.flow,a,n)(d)}}function Zy(e,n,a,i,o,u,d,f,m){const h=m||Number.POSITIVE_INFINITY;let x=0;return g;function g(E){return E===60?(e.enter(i),e.enter(o),e.enter(u),e.consume(E),e.exit(u),v):E===null||E===32||E===41||Iu(E)?a(E):(e.enter(i),e.enter(d),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(E))}function v(E){return E===62?(e.enter(u),e.consume(E),e.exit(u),e.exit(o),e.exit(i),n):(e.enter(f),e.enter("chunkString",{contentType:"string"}),b(E))}function b(E){return E===62?(e.exit("chunkString"),e.exit(f),v(E)):E===null||E===60||it(E)?a(E):(e.consume(E),E===92?j:b)}function j(E){return E===60||E===62||E===92?(e.consume(E),b):b(E)}function k(E){return!x&&(E===null||E===41||un(E))?(e.exit("chunkString"),e.exit(f),e.exit(d),e.exit(i),n(E)):x<h&&E===40?(e.consume(E),x++,k):E===41?(e.consume(E),x--,k):E===null||E===32||E===40||Iu(E)?a(E):(e.consume(E),E===92?N:k)}function N(E){return E===40||E===41||E===92?(e.consume(E),k):k(E)}}function Jy(e,n,a,i,o,u){const d=this;let f=0,m;return h;function h(b){return e.enter(i),e.enter(o),e.consume(b),e.exit(o),e.enter(u),x}function x(b){return f>999||b===null||b===91||b===93&&!m||b===94&&!f&&"_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):it(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===null||b===91||b===93||it(b)||f++>999?(e.exit("chunkString"),x(b)):(e.consume(b),m||(m=!At(b)),b===92?v:g)}function v(b){return b===91||b===92||b===93?(e.consume(b),f++,g):g(b)}}function eb(e,n,a,i,o,u){let d;return f;function f(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),h(v))}function h(v){return v===d?(e.exit(u),m(d)):v===null?a(v):it(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),It(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(v))}function x(v){return v===d||v===null||it(v)?(e.exit("chunkString"),h(v)):(e.consume(v),v===92?g:x)}function g(v){return v===d||v===92?(e.consume(v),x):x(v)}}function $o(e,n){let a;return i;function i(o){return it(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,i):At(o)?It(e,i,a?"linePrefix":"lineSuffix")(o):n(o)}}const ik={name:"definition",tokenize:ok},sk={partial:!0,tokenize:ck};function ok(e,n,a){const i=this;let o;return u;function u(b){return e.enter("definition"),d(b)}function d(b){return Jy.call(i,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function f(b){return o=ca(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 un(b)?$o(e,h)(b):h(b)}function h(b){return Zy(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(sk,g,g)(b)}function g(b){return At(b)?It(e,v,"whitespace")(b):v(b)}function v(b){return b===null||it(b)?(e.exit("definition"),i.parser.defined.push(o),n(b)):a(b)}}function ck(e,n,a){return i;function i(f){return un(f)?$o(e,o)(f):a(f)}function o(f){return eb(e,u,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function u(f){return At(f)?It(e,d,"whitespace")(f):d(f)}function d(f){return f===null||it(f)?n(f):a(f)}}const uk={name:"hardBreakEscape",tokenize:dk};function dk(e,n,a){return i;function i(u){return e.enter("hardBreakEscape"),e.consume(u),o}function o(u){return it(u)?(e.exit("hardBreakEscape"),n(u)):a(u)}}const fk={name:"headingAtx",resolve:hk,tokenize:mk};function hk(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"},$r(e,i,a-i+1,[["enter",o,n],["enter",u,n],["exit",u,n],["exit",o,n]])),e}function mk(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||un(x)?(e.exit("atxHeadingSequence"),f(x)):a(x)}function f(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||it(x)?(e.exit("atxHeading"),n(x)):At(x)?It(e,f,"whitespace")(x):(e.enter("atxHeadingText"),h(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),f(x))}function h(x){return x===null||x===35||un(x)?(e.exit("atxHeadingText"),f(x)):(e.consume(x),h)}}const pk=["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"],eg=["pre","script","style","textarea"],xk={concrete:!0,name:"htmlFlow",resolveTo:bk,tokenize:vk},gk={partial:!0,tokenize:kk},yk={partial:!0,tokenize:wk};function bk(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 vk(e,n,a){const i=this;let o,u,d,f,m;return h;function h(T){return x(T)}function x(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),g}function g(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:A):ur(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,f=0,j):ur(T)?(e.consume(T),o=4,i.interrupt?n:A):a(T)}function b(T){return T===45?(e.consume(T),i.interrupt?n:A):a(T)}function j(T){const se="CDATA[";return T===se.charCodeAt(f++)?(e.consume(T),f===se.length?i.interrupt?n:B:j):a(T)}function k(T){return ur(T)?(e.consume(T),d=String.fromCharCode(T),N):a(T)}function N(T){if(T===null||T===47||T===62||un(T)){const se=T===47,ke=d.toLowerCase();return!se&&!u&&eg.includes(ke)?(o=1,i.interrupt?n(T):B(T)):pk.includes(d.toLowerCase())?(o=6,se?(e.consume(T),E):i.interrupt?n(T):B(T)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(T):u?C(T):_(T))}return T===45||ar(T)?(e.consume(T),d+=String.fromCharCode(T),N):a(T)}function E(T){return T===62?(e.consume(T),i.interrupt?n:B):a(T)}function C(T){return At(T)?(e.consume(T),C):D(T)}function _(T){return T===47?(e.consume(T),D):T===58||T===95||ur(T)?(e.consume(T),M):At(T)?(e.consume(T),_):D(T)}function M(T){return T===45||T===46||T===58||T===95||ar(T)?(e.consume(T),M):H(T)}function H(T){return T===61?(e.consume(T),R):At(T)?(e.consume(T),H):_(T)}function R(T){return T===null||T===60||T===61||T===62||T===96?a(T):T===34||T===39?(e.consume(T),m=T,I):At(T)?(e.consume(T),R):W(T)}function I(T){return T===m?(e.consume(T),m=null,Y):T===null||it(T)?a(T):(e.consume(T),I)}function W(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||un(T)?H(T):(e.consume(T),W)}function Y(T){return T===47||T===62||At(T)?_(T):a(T)}function D(T){return T===62?(e.consume(T),O):a(T)}function O(T){return T===null||it(T)?B(T):At(T)?(e.consume(T),O):a(T)}function B(T){return T===45&&o===2?(e.consume(T),q):T===60&&o===1?(e.consume(T),ce):T===62&&o===4?(e.consume(T),$):T===63&&o===3?(e.consume(T),A):T===93&&o===5?(e.consume(T),V):it(T)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(gk,U,ee)(T)):T===null||it(T)?(e.exit("htmlFlowData"),ee(T)):(e.consume(T),B)}function ee(T){return e.check(yk,re,U)(T)}function re(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),K}function K(T){return T===null||it(T)?ee(T):(e.enter("htmlFlowData"),B(T))}function q(T){return T===45?(e.consume(T),A):B(T)}function ce(T){return T===47?(e.consume(T),d="",ue):B(T)}function ue(T){if(T===62){const se=d.toLowerCase();return eg.includes(se)?(e.consume(T),$):B(T)}return ur(T)&&d.length<8?(e.consume(T),d+=String.fromCharCode(T),ue):B(T)}function V(T){return T===93?(e.consume(T),A):B(T)}function A(T){return T===62?(e.consume(T),$):T===45&&o===2?(e.consume(T),A):B(T)}function $(T){return T===null||it(T)?(e.exit("htmlFlowData"),U(T)):(e.consume(T),$)}function U(T){return e.exit("htmlFlow"),n(T)}}function wk(e,n,a){const i=this;return o;function o(d){return it(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 kk(e,n,a){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Vo,n,a)}}const jk={name:"htmlText",tokenize:Sk};function Sk(e,n,a){const i=this;let o,u,d;return f;function f(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),m}function m(A){return A===33?(e.consume(A),h):A===47?(e.consume(A),H):A===63?(e.consume(A),_):ur(A)?(e.consume(A),W):a(A)}function h(A){return A===45?(e.consume(A),x):A===91?(e.consume(A),u=0,j):ur(A)?(e.consume(A),C):a(A)}function x(A){return A===45?(e.consume(A),b):a(A)}function g(A){return A===null?a(A):A===45?(e.consume(A),v):it(A)?(d=g,ce(A)):(e.consume(A),g)}function v(A){return A===45?(e.consume(A),b):g(A)}function b(A){return A===62?q(A):A===45?v(A):g(A)}function j(A){const $="CDATA[";return A===$.charCodeAt(u++)?(e.consume(A),u===$.length?k:j):a(A)}function k(A){return A===null?a(A):A===93?(e.consume(A),N):it(A)?(d=k,ce(A)):(e.consume(A),k)}function N(A){return A===93?(e.consume(A),E):k(A)}function E(A){return A===62?q(A):A===93?(e.consume(A),E):k(A)}function C(A){return A===null||A===62?q(A):it(A)?(d=C,ce(A)):(e.consume(A),C)}function _(A){return A===null?a(A):A===63?(e.consume(A),M):it(A)?(d=_,ce(A)):(e.consume(A),_)}function M(A){return A===62?q(A):_(A)}function H(A){return ur(A)?(e.consume(A),R):a(A)}function R(A){return A===45||ar(A)?(e.consume(A),R):I(A)}function I(A){return it(A)?(d=I,ce(A)):At(A)?(e.consume(A),I):q(A)}function W(A){return A===45||ar(A)?(e.consume(A),W):A===47||A===62||un(A)?Y(A):a(A)}function Y(A){return A===47?(e.consume(A),q):A===58||A===95||ur(A)?(e.consume(A),D):it(A)?(d=Y,ce(A)):At(A)?(e.consume(A),Y):q(A)}function D(A){return A===45||A===46||A===58||A===95||ar(A)?(e.consume(A),D):O(A)}function O(A){return A===61?(e.consume(A),B):it(A)?(d=O,ce(A)):At(A)?(e.consume(A),O):Y(A)}function B(A){return A===null||A===60||A===61||A===62||A===96?a(A):A===34||A===39?(e.consume(A),o=A,ee):it(A)?(d=B,ce(A)):At(A)?(e.consume(A),B):(e.consume(A),re)}function ee(A){return A===o?(e.consume(A),o=void 0,K):A===null?a(A):it(A)?(d=ee,ce(A)):(e.consume(A),ee)}function re(A){return A===null||A===34||A===39||A===60||A===61||A===96?a(A):A===47||A===62||un(A)?Y(A):(e.consume(A),re)}function K(A){return A===47||A===62||un(A)?Y(A):a(A)}function q(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),n):a(A)}function ce(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),ue}function ue(A){return At(A)?It(e,V,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):V(A)}function V(A){return e.enter("htmlTextData"),d(A)}}const Mm={name:"labelEnd",resolveAll:Ak,resolveTo:Dk,tokenize:Tk},Ck={tokenize:Fk},Ek={tokenize:Rk},Nk={tokenize:Mk};function Ak(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&&$r(e,0,e.length,a),e}function Dk(e,n){let a=e.length,i=0,o,u,d,f;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}},h={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 f=[["enter",m,n],["enter",h,n]],f=Zr(f,e.slice(u+1,u+i+3)),f=Zr(f,[["enter",x,n]]),f=Zr(f,Zu(n.parser.constructs.insideSpan.null,e.slice(u+i+4,d-3),n)),f=Zr(f,[["exit",x,n],e[d-2],e[d-1],["exit",h,n]]),f=Zr(f,e.slice(d+1)),f=Zr(f,[["exit",m,n]]),$r(e,u,e.length,f),e}function Tk(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 f;function f(v){return u?u._inactive?g(v):(d=i.parser.defined.includes(ca(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(Ck,x,d?x:g)(v):v===91?e.attempt(Ek,x,d?h:g)(v):d?x(v):g(v)}function h(v){return e.attempt(Nk,x,g)(v)}function x(v){return n(v)}function g(v){return u._balanced=!0,a(v)}}function Fk(e,n,a){return i;function i(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return un(g)?$o(e,u)(g):u(g)}function u(g){return g===41?x(g):Zy(e,d,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function d(g){return un(g)?$o(e,m)(g):x(g)}function f(g){return a(g)}function m(g){return g===34||g===39||g===40?eb(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):x(g)}function h(g){return un(g)?$o(e,x)(g):x(g)}function x(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),n):a(g)}}function Rk(e,n,a){const i=this;return o;function o(f){return Jy.call(i,e,u,d,"reference","referenceMarker","referenceString")(f)}function u(f){return i.parser.defined.includes(ca(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(f):a(f)}function d(f){return a(f)}}function Mk(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 zk={name:"labelStartImage",resolveAll:Mm.resolveAll,tokenize:_k};function _k(e,n,a){const i=this;return o;function o(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),u}function u(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),d):a(f)}function d(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(f):n(f)}}const Bk={name:"labelStartLink",resolveAll:Mm.resolveAll,tokenize:Ok};function Ok(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 dh={name:"lineEnding",tokenize:$k};function $k(e,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),It(e,n,"linePrefix")}}const _u={name:"thematicBreak",tokenize:Lk};function Lk(e,n,a){let i=0,o;return u;function u(h){return e.enter("thematicBreak"),d(h)}function d(h){return o=h,f(h)}function f(h){return h===o?(e.enter("thematicBreakSequence"),m(h)):i>=3&&(h===null||it(h))?(e.exit("thematicBreak"),n(h)):a(h)}function m(h){return h===o?(e.consume(h),i++,m):(e.exit("thematicBreakSequence"),At(h)?It(e,f,"whitespace")(h):f(h))}}const wr={continuation:{tokenize:qk},exit:Xk,name:"list",tokenize:Uk},Ik={partial:!0,tokenize:Wk},Hk={partial:!0,tokenize:Yk};function Uk(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 f;function f(b){const j=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:Zh(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(_u,a,h)(b):h(b);if(!i.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(b)}return a(b)}function m(b){return Zh(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"),h(b)):a(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||b,e.check(Vo,i.interrupt?a:x,e.attempt(Ik,v,g))}function x(b){return i.containerState.initialBlankLine=!0,u++,v(b)}function g(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 qk(e,n,a){const i=this;return i.containerState._closeFlow=void 0,e.check(Vo,o,u);function o(f){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,It(e,n,"listItemIndent",i.containerState.size+1)(f)}function u(f){return i.containerState.furtherBlankLines||!At(f)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,d(f)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(Hk,n,d)(f))}function d(f){return i.containerState._closeFlow=!0,i.interrupt=void 0,It(e,e.attempt(wr,n,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function Yk(e,n,a){const i=this;return It(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 Xk(e){e.exit(this.containerState.type)}function Wk(e,n,a){const i=this;return It(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 tg={name:"setextUnderline",resolveTo:Vk,tokenize:Gk};function Vk(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 Gk(e,n,a){const i=this;let o;return u;function u(h){let x=i.events.length,g;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){g=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||g)?(e.enter("setextHeadingLine"),o=h,d(h)):a(h)}function d(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===o?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),At(h)?It(e,m,"lineSuffix")(h):m(h))}function m(h){return h===null||it(h)?(e.exit("setextHeadingLine"),n(h)):a(h)}}const Kk={tokenize:Pk};function Pk(e){const n=this,a=e.attempt(Vo,i,e.attempt(this.parser.constructs.flowInitial,o,It(e,e.attempt(this.parser.constructs.flow,o,e.attempt(tk,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 Qk={resolveAll:nb()},Zk=tb("string"),Jk=tb("text");function tb(e){return{resolveAll:nb(e==="text"?e3:void 0),tokenize:n};function n(a){const i=this,o=this.parser.constructs[e],u=a.attempt(o,d,f);return d;function d(x){return h(x)?u(x):f(x)}function f(x){if(x===null){a.consume(x);return}return a.enter("data"),a.consume(x),m}function m(x){return h(x)?(a.exit("data"),u(x)):(a.consume(x),m)}function h(x){if(x===null)return!0;const g=o[x];let v=-1;if(g)for(;++v<g.length;){const b=g[v];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function nb(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 e3(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,f=0,m;for(;u--;){const h=o[u];if(typeof h=="string"){for(d=h.length;h.charCodeAt(d-1)===32;)f++,d--;if(d)break;d=-1}else if(h===-2)m=!0,f++;else if(h!==-1){u++;break}}if(n._contentTypeTextTrailing&&a===e.length&&(f=0),f){const h={type:a===e.length||m||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?d:i.start._bufferIndex+d,_index:i.start._index+u,line:i.end.line,column:i.end.column-f,offset:i.end.offset-f},end:{...i.end}};i.end={...h.start},i.start.offset===i.end.offset?Object.assign(i,h):(e.splice(a,0,["enter",h,n],["exit",h,n]),a+=2)}a++}return e}const t3={42:wr,43:wr,45:wr,48:wr,49:wr,50:wr,51:wr,52:wr,53:wr,54:wr,55:wr,56:wr,57:wr,62:Gy},n3={91:ik},r3={[-2]:uh,[-1]:uh,32:uh},a3={35:fk,42:_u,45:[tg,_u],60:xk,61:tg,95:_u,96:J0,126:J0},l3={38:Py,92:Ky},i3={[-5]:dh,[-4]:dh,[-3]:dh,33:zk,38:Py,42:Jh,60:[B5,jk],91:Bk,92:[uk,Ky],93:Mm,95:Jh,96:K5},s3={null:[Jh,Qk]},o3={null:[42,95]},c3={null:[]},u3=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:o3,contentInitial:n3,disable:c3,document:t3,flow:a3,flowInitial:r3,insideSpan:s3,string:l3,text:i3},Symbol.toStringTag,{value:"Module"}));function d3(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=[],f=[];const m={attempt:I(H),check:I(R),consume:C,enter:_,exit:M,interrupt:I(R,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:j,parser:e,previous:null,sliceSerialize:v,sliceStream:b,write:g};let x=n.tokenize.call(h,m);return n.resolveAll&&u.push(n),h;function g(O){return d=Zr(d,O),N(),d[d.length-1]!==null?[]:(W(n,0),h.events=Zu(u,h.events,h),h.events)}function v(O,B){return h3(b(O),B)}function b(O){return f3(d,O)}function j(){const{_bufferIndex:O,_index:B,line:ee,column:re,offset:K}=i;return{_bufferIndex:O,_index:B,line:ee,column:re,offset:K}}function k(O){o[O.line]=O.column,D()}function N(){let O;for(;i._index<d.length;){const B=d[i._index];if(typeof B=="string")for(O=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===O&&i._bufferIndex<B.length;)E(B.charCodeAt(i._bufferIndex));else E(B)}}function E(O){x=x(O)}function C(O){it(O)?(i.line++,i.column=1,i.offset+=O===-3?2:1,D()):O!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===d[i._index].length&&(i._bufferIndex=-1,i._index++)),h.previous=O}function _(O,B){const ee=B||{};return ee.type=O,ee.start=j(),h.events.push(["enter",ee,h]),f.push(ee),ee}function M(O){const B=f.pop();return B.end=j(),h.events.push(["exit",B,h]),B}function H(O,B){W(O,B.from)}function R(O,B){B.restore()}function I(O,B){return ee;function ee(re,K,q){let ce,ue,V,A;return Array.isArray(re)?U(re):"tokenize"in re?U([re]):$(re);function $(he){return _e;function _e(Le){const Ue=Le!==null&&he[Le],et=Le!==null&&he.null,Pe=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(et)?et:et?[et]:[]];return U(Pe)(Le)}}function U(he){return ce=he,ue=0,he.length===0?q:T(he[ue])}function T(he){return _e;function _e(Le){return A=Y(),V=he,he.partial||(h.currentConstruct=he),he.name&&h.parser.constructs.disable.null.includes(he.name)?ke():he.tokenize.call(B?Object.assign(Object.create(h),B):h,m,se,ke)(Le)}}function se(he){return O(V,A),K}function ke(he){return A.restore(),++ue<ce.length?T(ce[ue]):q}}}function W(O,B){O.resolveAll&&!u.includes(O)&&u.push(O),O.resolve&&$r(h.events,B,h.events.length-B,O.resolve(h.events.slice(B),h)),O.resolveTo&&(h.events=O.resolveTo(h.events,h))}function Y(){const O=j(),B=h.previous,ee=h.currentConstruct,re=h.events.length,K=Array.from(f);return{from:re,restore:q};function q(){i=O,h.previous=B,h.currentConstruct=ee,h.events.length=re,f=K,D()}}function D(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function f3(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 f=d[0];typeof f=="string"?d[0]=f.slice(i):d.shift()}u>0&&d.push(e[o].slice(0,u))}return d}function h3(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 m3(e){const i={constructs:Wy([u3,...(e||{}).extensions||[]]),content:o(D5),defined:[],document:o(F5),flow:o(Kk),lazy:{},string:o(Zk),text:o(Jk)};return i;function o(u){return d;function d(f){return d3(i,u,f)}}}function p3(e){for(;!Qy(e););return e}const ng=/[\0\t\n\r]/g;function x3(){let e=1,n="",a=!0,i;return o;function o(u,d,f){const m=[];let h,x,g,v,b;for(u=n+(typeof u=="string"?u.toString():new TextDecoder(d||void 0).decode(u)),g=0,n="",a&&(u.charCodeAt(0)===65279&&g++,a=void 0);g<u.length;){if(ng.lastIndex=g,h=ng.exec(u),v=h&&h.index!==void 0?h.index:u.length,b=u.charCodeAt(v),!h){n=u.slice(g);break}if(b===10&&g===v&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),g<v&&(m.push(u.slice(g,v)),e+=v-g),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}g=v+1}return f&&(i&&m.push(-5),n&&m.push(n),m.push(null)),m}}const g3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function y3(e){return e.replace(g3,b3)}function b3(e,n,a){if(n)return n;if(a.charCodeAt(0)===35){const o=a.charCodeAt(1),u=o===120||o===88;return Vy(a.slice(u?2:1),u?16:10)}return Rm(a)||e}const rb={}.hasOwnProperty;function v3(e,n,a){return n&&typeof n=="object"&&(a=n,n=void 0),w3(a)(p3(m3(a).document().write(x3()(e,n,!0))))}function w3(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(Ht),autolinkProtocol:Y,autolinkEmail:Y,atxHeading:u(yt),blockQuote:u(et),characterEscape:Y,characterReference:Y,codeFenced:u(Pe),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:u(Pe,d),codeText:u(Ge,d),codeTextData:Y,data:Y,codeFlowValue:Y,definition:u(Ce),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:u(Ae),hardBreakEscape:u(ct),hardBreakTrailing:u(ct),htmlFlow:u(xt,d),htmlFlowData:Y,htmlText:u(xt,d),htmlTextData:Y,image:u(Ct),label:d,link:u(Ht),listItem:u(jt),listItemValue:v,listOrdered:u(zt,g),listUnordered:u(zt),paragraph:u(Hn),reference:T,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:u(yt),strong:u(me),thematicBreak:u(Ne)},exit:{atxHeading:m(),atxHeadingSequence:H,autolink:m(),autolinkEmail:Ue,autolinkProtocol:Le,blockQuote:m(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:ke,characterReferenceMarkerNumeric:ke,characterReferenceValue:he,characterReference:_e,codeFenced:m(N),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:j,codeFlowValue:D,codeIndented:m(E),codeText:m(K),codeTextData:D,data:D,definition:m(),definitionDestinationString:M,definitionLabelString:C,definitionTitleString:_,emphasis:m(),hardBreakEscape:m(B),hardBreakTrailing:m(B),htmlFlow:m(ee),htmlFlowData:D,htmlText:m(re),htmlTextData:D,image:m(ce),label:V,labelText:ue,lineEnding:O,link:m(q),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:se,resourceDestinationString:A,resourceTitleString:$,resource:U,setextHeading:m(W),setextHeadingLineSequence:I,setextHeadingText:R,strong:m(),thematicBreak:m()}};ab(n,(e||{}).mdastExtensions||[]);const a={};return i;function i(G){let Z={type:"root",children:[]};const ye={stack:[Z],tokenStack:[],config:n,enter:f,exit:h,buffer:d,resume:x,data:a},ge=[];let Ee=-1;for(;++Ee<G.length;)if(G[Ee][1].type==="listOrdered"||G[Ee][1].type==="listUnordered")if(G[Ee][0]==="enter")ge.push(Ee);else{const Fe=ge.pop();Ee=o(G,Fe,Ee)}for(Ee=-1;++Ee<G.length;){const Fe=n[G[Ee][0]];rb.call(Fe,G[Ee][1].type)&&Fe[G[Ee][1].type].call(Object.assign({sliceSerialize:G[Ee][2].sliceSerialize},ye),G[Ee][1])}if(ye.tokenStack.length>0){const Fe=ye.tokenStack[ye.tokenStack.length-1];(Fe[1]||rg).call(ye,void 0,Fe[0])}for(Z.position={start:Hl(G.length>0?G[0][1].start:{line:1,column:1,offset:0}),end:Hl(G.length>0?G[G.length-2][1].end:{line:1,column:1,offset:0})},Ee=-1;++Ee<n.transforms.length;)Z=n.transforms[Ee](Z)||Z;return Z}function o(G,Z,ye){let ge=Z-1,Ee=-1,Fe=!1,Be,Oe,qe,at;for(;++ge<=ye;){const We=G[ge];switch(We[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{We[0]==="enter"?Ee++:Ee--,at=void 0;break}case"lineEndingBlank":{We[0]==="enter"&&(Be&&!at&&!Ee&&!qe&&(qe=ge),at=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:at=void 0}if(!Ee&&We[0]==="enter"&&We[1].type==="listItemPrefix"||Ee===-1&&We[0]==="exit"&&(We[1].type==="listUnordered"||We[1].type==="listOrdered")){if(Be){let Dt=ge;for(Oe=void 0;Dt--;){const ze=G[Dt];if(ze[1].type==="lineEnding"||ze[1].type==="lineEndingBlank"){if(ze[0]==="exit")continue;Oe&&(G[Oe][1].type="lineEndingBlank",Fe=!0),ze[1].type="lineEnding",Oe=Dt}else if(!(ze[1].type==="linePrefix"||ze[1].type==="blockQuotePrefix"||ze[1].type==="blockQuotePrefixWhitespace"||ze[1].type==="blockQuoteMarker"||ze[1].type==="listItemIndent"))break}qe&&(!Oe||qe<Oe)&&(Be._spread=!0),Be.end=Object.assign({},Oe?G[Oe][1].start:We[1].end),G.splice(Oe||ge,0,["exit",Be,We[2]]),ge++,ye++}if(We[1].type==="listItemPrefix"){const Dt={type:"listItem",_spread:!1,start:Object.assign({},We[1].start),end:void 0};Be=Dt,G.splice(ge,0,["enter",Dt,We[2]]),ge++,ye++,qe=void 0,at=!0}}}return G[Z][1]._spread=Fe,ye}function u(G,Z){return ye;function ye(ge){f.call(this,G(ge),ge),Z&&Z.call(this,ge)}}function d(){this.stack.push({type:"fragment",children:[]})}function f(G,Z,ye){this.stack[this.stack.length-1].children.push(G),this.stack.push(G),this.tokenStack.push([Z,ye||void 0]),G.position={start:Hl(Z.start),end:void 0}}function m(G){return Z;function Z(ye){G&&G.call(this,ye),h.call(this,ye)}}function h(G,Z){const ye=this.stack.pop(),ge=this.tokenStack.pop();if(ge)ge[0].type!==G.type&&(Z?Z.call(this,G,ge[0]):(ge[1]||rg).call(this,G,ge[0]));else throw new Error("Cannot close `"+G.type+"` ("+Oo({start:G.start,end:G.end})+"): it’s not open");ye.position.end=Hl(G.end)}function x(){return Fm(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function v(G){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(G),10),this.data.expectingFirstListItemValue=void 0}}function b(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=G}function j(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=G}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.value=G.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.value=G.replace(/(\r?\n|\r)$/g,"")}function C(G){const Z=this.resume(),ye=this.stack[this.stack.length-1];ye.label=Z,ye.identifier=ca(this.sliceSerialize(G)).toLowerCase()}function _(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.title=G}function M(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.url=G}function H(G){const Z=this.stack[this.stack.length-1];if(!Z.depth){const ye=this.sliceSerialize(G).length;Z.depth=ye}}function R(){this.data.setextHeadingSlurpLineEnding=!0}function I(G){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(G).codePointAt(0)===61?1:2}function W(){this.data.setextHeadingSlurpLineEnding=void 0}function Y(G){const ye=this.stack[this.stack.length-1].children;let ge=ye[ye.length-1];(!ge||ge.type!=="text")&&(ge=je(),ge.position={start:Hl(G.start),end:void 0},ye.push(ge)),this.stack.push(ge)}function D(G){const Z=this.stack.pop();Z.value+=this.sliceSerialize(G),Z.position.end=Hl(G.end)}function O(G){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=Z.children[Z.children.length-1];ye.position.end=Hl(G.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(Z.type)&&(Y.call(this,G),D.call(this,G))}function B(){this.data.atHardBreak=!0}function ee(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.value=G}function re(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.value=G}function K(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.value=G}function q(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=Z,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function ce(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=Z,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function ue(G){const Z=this.sliceSerialize(G),ye=this.stack[this.stack.length-2];ye.label=y3(Z),ye.identifier=ca(Z).toLowerCase()}function V(){const G=this.stack[this.stack.length-1],Z=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const ge=G.children;ye.children=ge}else ye.alt=Z}function A(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.url=G}function $(){const G=this.resume(),Z=this.stack[this.stack.length-1];Z.title=G}function U(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function se(G){const Z=this.resume(),ye=this.stack[this.stack.length-1];ye.label=Z,ye.identifier=ca(this.sliceSerialize(G)).toLowerCase(),this.data.referenceType="full"}function ke(G){this.data.characterReferenceType=G.type}function he(G){const Z=this.sliceSerialize(G),ye=this.data.characterReferenceType;let ge;ye?(ge=Vy(Z,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ge=Rm(Z);const Ee=this.stack[this.stack.length-1];Ee.value+=ge}function _e(G){const Z=this.stack.pop();Z.position.end=Hl(G.end)}function Le(G){D.call(this,G);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(G)}function Ue(G){D.call(this,G);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(G)}function et(){return{type:"blockquote",children:[]}}function Pe(){return{type:"code",lang:null,meta:null,value:""}}function Ge(){return{type:"inlineCode",value:""}}function Ce(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ae(){return{type:"emphasis",children:[]}}function yt(){return{type:"heading",depth:0,children:[]}}function ct(){return{type:"break"}}function xt(){return{type:"html",value:""}}function Ct(){return{type:"image",title:null,url:"",alt:null}}function Ht(){return{type:"link",title:null,url:"",children:[]}}function zt(G){return{type:"list",ordered:G.type==="listOrdered",start:null,spread:G._spread,children:[]}}function jt(G){return{type:"listItem",spread:G._spread,checked:null,children:[]}}function Hn(){return{type:"paragraph",children:[]}}function me(){return{type:"strong",children:[]}}function je(){return{type:"text",value:""}}function Ne(){return{type:"thematicBreak"}}}function Hl(e){return{line:e.line,column:e.column,offset:e.offset}}function ab(e,n){let a=-1;for(;++a<n.length;){const i=n[a];Array.isArray(i)?ab(e,i):k3(e,i)}}function k3(e,n){let a;for(a in n)if(rb.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 rg(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+Oo({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+Oo({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Oo({start:n.start,end:n.end})+") is still open")}function j3(e){const n=this;n.parser=a;function a(i){return v3(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function S3(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 C3(e,n){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,a),[e.applyData(n,a),{type:"text",value:`
|
|
55
|
+
`}]}function E3(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 N3(e,n){const a={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function A3(e,n){const a={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function D3(e,n){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),o=Ns(i.toLowerCase()),u=e.footnoteOrder.indexOf(i);let d,f=e.footnoteCounts.get(i);f===void 0?(f=0,e.footnoteOrder.push(i),d=e.footnoteOrder.length):d=u+1,f+=1,e.footnoteCounts.set(i,f);const m={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(n,m);const h={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(n,h),e.applyData(n,h)}function T3(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 F3(e,n){if(e.options.allowDangerousHtml){const a={type:"raw",value:n.value};return e.patch(n,a),e.applyData(n,a)}}function lb(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 R3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return lb(e,n);const o={src:Ns(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 M3(e,n){const a={src:Ns(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 z3(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 _3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return lb(e,n);const o={href:Ns(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 B3(e,n){const a={href:Ns(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 O3(e,n,a){const i=e.all(n),o=a?$3(a):ib(n),u={},d=[];if(typeof n.checked=="boolean"){const x=i[0];let g;x&&x.type==="element"&&x.tagName==="p"?g=x:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),u.className=["task-list-item"]}let f=-1;for(;++f<i.length;){const x=i[f];(o||f!==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 h={type:"element",tagName:"li",properties:u,children:d};return e.patch(n,h),e.applyData(n,h)}function $3(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=ib(a[i])}return n}function ib(e){const n=e.spread;return n??e.children.length>1}function L3(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 I3(e,n){const a={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function H3(e,n){const a={type:"root",children:e.wrap(e.all(n))};return e.patch(n,a),e.applyData(n,a)}function U3(e,n){const a={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function q3(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)},f=Nm(n.children[1]),m=Ly(n.children[n.children.length-1]);f&&m&&(d.position={start:f,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 Y3(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,f=d?d.length:n.children.length;let m=-1;const h=[];for(;++m<f;){const g=n.children[m],v={},b=d?d[m]:void 0;b&&(v.align=b);let j={type:"element",tagName:u,properties:v,children:[]};g&&(j.children=e.all(g),e.patch(g,j),j=e.applyData(g,j)),h.push(j)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(n,x),e.applyData(n,x)}function X3(e,n){const a={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}const ag=9,lg=32;function W3(e){const n=String(e),a=/\r?\n|\r/g;let i=a.exec(n),o=0;const u=[];for(;i;)u.push(ig(n.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=a.exec(n);return u.push(ig(n.slice(o),o>0,!1)),u.join("")}function ig(e,n,a){let i=0,o=e.length;if(n){let u=e.codePointAt(i);for(;u===ag||u===lg;)i++,u=e.codePointAt(i)}if(a){let u=e.codePointAt(o-1);for(;u===ag||u===lg;)o--,u=e.codePointAt(o-1)}return o>i?e.slice(i,o):""}function V3(e,n){const a={type:"text",value:W3(String(n.value))};return e.patch(n,a),e.applyData(n,a)}function G3(e,n){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,a),e.applyData(n,a)}const K3={blockquote:S3,break:C3,code:E3,delete:N3,emphasis:A3,footnoteReference:D3,heading:T3,html:F3,imageReference:R3,image:M3,inlineCode:z3,linkReference:_3,link:B3,listItem:O3,list:L3,paragraph:I3,root:H3,strong:U3,table:q3,tableCell:X3,tableRow:Y3,text:V3,thematicBreak:G3,toml:yu,yaml:yu,definition:yu,footnoteDefinition:yu};function yu(){}const sb=-1,Ju=0,Lo=1,Hu=2,zm=3,_m=4,Bm=5,Om=6,ob=7,cb=8,sg=typeof self=="object"?self:globalThis,P3=(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 Ju:case sb:return a(d,o);case Lo:{const f=a([],o);for(const m of d)f.push(i(m));return f}case Hu:{const f=a({},o);for(const[m,h]of d)f[i(m)]=i(h);return f}case zm:return a(new Date(d),o);case _m:{const{source:f,flags:m}=d;return a(new RegExp(f,m),o)}case Bm:{const f=a(new Map,o);for(const[m,h]of d)f.set(i(m),i(h));return f}case Om:{const f=a(new Set,o);for(const m of d)f.add(i(m));return f}case ob:{const{name:f,message:m}=d;return a(new sg[f](m),o)}case cb: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:f}=new Uint8Array(d);return a(new DataView(f),d)}}return a(new sg[u](d),o)};return i},og=e=>P3(new Map,e)(0),xs="",{toString:Q3}={},{keys:Z3}=Object,No=e=>{const n=typeof e;if(n!=="object"||!e)return[Ju,n];const a=Q3.call(e).slice(8,-1);switch(a){case"Array":return[Lo,xs];case"Object":return[Hu,xs];case"Date":return[zm,xs];case"RegExp":return[_m,xs];case"Map":return[Bm,xs];case"Set":return[Om,xs];case"DataView":return[Lo,a]}return a.includes("Array")?[Lo,a]:a.includes("Error")?[ob,a]:[Hu,a]},bu=([e,n])=>e===Ju&&(n==="function"||n==="symbol"),J3=(e,n,a,i)=>{const o=(d,f)=>{const m=i.push(d)-1;return a.set(f,m),m},u=d=>{if(a.has(d))return a.get(d);let[f,m]=No(d);switch(f){case Ju:{let x=d;switch(m){case"bigint":f=cb,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([sb],d)}return o([f,x],d)}case Lo:{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=[],g=o([f,x],d);for(const v of d)x.push(u(v));return g}case Hu:{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=[],g=o([f,x],d);for(const v of Z3(d))(e||!bu(No(d[v])))&&x.push([u(v),u(d[v])]);return g}case zm:return o([f,d.toISOString()],d);case _m:{const{source:x,flags:g}=d;return o([f,{source:x,flags:g}],d)}case Bm:{const x=[],g=o([f,x],d);for(const[v,b]of d)(e||!(bu(No(v))||bu(No(b))))&&x.push([u(v),u(b)]);return g}case Om:{const x=[],g=o([f,x],d);for(const v of d)(e||!bu(No(v)))&&x.push(u(v));return g}}const{message:h}=d;return o([f,{name:m,message:h}],d)};return u},cg=(e,{json:n,lossy:a}={})=>{const i=[];return J3(!(n||a),!!n,new Map,i)(e),i},Uu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?og(cg(e,n)):structuredClone(e):(e,n)=>og(cg(e,n));function e4(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 t4(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function n4(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||e4,i=e.options.footnoteBackLabel||t4,o=e.options.footnoteLabel||"Footnotes",u=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let m=-1;for(;++m<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[m]);if(!h)continue;const x=e.all(h),g=String(h.identifier).toUpperCase(),v=Ns(g.toLowerCase());let b=0;const j=[],k=e.footnoteCounts.get(g);for(;k!==void 0&&++b<=k;){j.length>0&&j.push({type:"text",value:" "});let C=typeof a=="string"?a:a(m,b);typeof C=="string"&&(C={type:"text",value:C}),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(C)?C:[C]})}const N=x[x.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const C=N.children[N.children.length-1];C&&C.type==="text"?C.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...j)}else x.push(...j);const E={type:"element",tagName:"li",properties:{id:n+"fn-"+v},children:e.wrap(x,!0)};e.patch(h,E),f.push(E)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:u,properties:{...Uu(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
59
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:`
|
|
60
|
+
`}]}}const ed=(function(e){if(e==null)return i4;if(typeof e=="function")return td(e);if(typeof e=="object")return Array.isArray(e)?r4(e):a4(e);if(typeof e=="string")return l4(e);throw new Error("Expected function, string, or object as test")});function r4(e){const n=[];let a=-1;for(;++a<e.length;)n[a]=ed(e[a]);return td(i);function i(...o){let u=-1;for(;++u<n.length;)if(n[u].apply(this,o))return!0;return!1}}function a4(e){const n=e;return td(a);function a(i){const o=i;let u;for(u in e)if(o[u]!==n[u])return!1;return!0}}function l4(e){return td(n);function n(a){return a&&a.type===e}}function td(e){return n;function n(a,i,o){return!!(s4(a)&&e.call(this,a,typeof i=="number"?i:void 0,o||void 0))}}function i4(){return!0}function s4(e){return e!==null&&typeof e=="object"&&"type"in e}const ub=[],o4=!0,em=!1,c4="skip";function db(e,n,a,i){let o;typeof n=="function"&&typeof a!="function"?(i=a,a=n):o=n;const u=ed(o),d=i?-1:1;f(e,void 0,[])();function f(m,h,x){const g=m&&typeof m=="object"?m:{};if(typeof g.type=="string"){const b=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(m.type+(b?"<"+b+">":""))+")"})}return v;function v(){let b=ub,j,k,N;if((!n||u(m,h,x[x.length-1]||void 0))&&(b=u4(a(m,x)),b[0]===em))return b;if("children"in m&&m.children){const E=m;if(E.children&&b[0]!==c4)for(k=(i?E.children.length:-1)+d,N=x.concat(E);k>-1&&k<E.children.length;){const C=E.children[k];if(j=f(C,k,N)(),j[0]===em)return j;k=typeof j[1]=="number"?j[1]:k+d}}return b}}}function u4(e){return Array.isArray(e)?e:typeof e=="number"?[o4,e]:e==null?ub:[e]}function $m(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),db(e,u,f,o);function f(m,h){const x=h[h.length-1],g=x?x.children.indexOf(m):void 0;return d(m,g,x)}}const tm={}.hasOwnProperty,d4={};function f4(e,n){const a=n||d4,i=new Map,o=new Map,u=new Map,d={...K3,...a.handlers},f={all:h,applyData:m4,definitionById:i,footnoteById:o,footnoteCounts:u,footnoteOrder:[],handlers:d,one:m,options:a,patch:h4,wrap:x4};return $m(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const g=x.type==="definition"?i:o,v=String(x.identifier).toUpperCase();g.has(v)||g.set(v,x)}}),f;function m(x,g){const v=x.type,b=f.handlers[v];if(tm.call(f.handlers,v)&&b)return b(f,x,g);if(f.options.passThrough&&f.options.passThrough.includes(v)){if("children"in x){const{children:k,...N}=x,E=Uu(N);return E.children=f.all(x),E}return Uu(x)}return(f.options.unknownHandler||p4)(f,x,g)}function h(x){const g=[];if("children"in x){const v=x.children;let b=-1;for(;++b<v.length;){const j=f.one(v[b],x);if(j){if(b&&v[b-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=ug(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=ug(k.value))}Array.isArray(j)?g.push(...j):g.push(j)}}}return g}}function h4(e,n){e.position&&(n.position=t5(e))}function m4(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,Uu(u)),"children"in a&&a.children&&o!==null&&o!==void 0&&(a.children=o)}return a}function p4(e,n){const a=n.data||{},i="value"in n&&!(tm.call(a,"hProperties")||tm.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 x4(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 ug(e){let n=0,a=e.charCodeAt(n);for(;a===9||a===32;)n++,a=e.charCodeAt(n);return e.slice(n)}function dg(e,n){const a=f4(e,n),i=a.one(e,void 0),o=n4(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 g4(e,n){return e&&"run"in e?async function(a,i){const o=dg(a,{file:i,...n});await e.run(o,i)}:function(a,i){return dg(a,{file:i,...e||n})}}function fg(e){if(e)throw e}var fh,hg;function y4(){if(hg)return fh;hg=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(h){return typeof Array.isArray=="function"?Array.isArray(h):n.call(h)==="[object Array]"},u=function(h){if(!h||n.call(h)!=="[object Object]")return!1;var x=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!x&&!g)return!1;var v;for(v in h);return typeof v>"u"||e.call(h,v)},d=function(h,x){a&&x.name==="__proto__"?a(h,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):h[x.name]=x.newValue},f=function(h,x){if(x==="__proto__")if(e.call(h,x)){if(i)return i(h,x).value}else return;return h[x]};return fh=function m(){var h,x,g,v,b,j,k=arguments[0],N=1,E=arguments.length,C=!1;for(typeof k=="boolean"&&(C=k,k=arguments[1]||{},N=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});N<E;++N)if(h=arguments[N],h!=null)for(x in h)g=f(k,x),v=f(h,x),k!==v&&(C&&v&&(u(v)||(b=o(v)))?(b?(b=!1,j=g&&o(g)?g:[]):j=g&&u(g)?g:{},d(k,{name:x,newValue:m(C,j,v)})):typeof v<"u"&&d(k,{name:x,newValue:v}));return k},fh}var b4=y4();const hh=Ay(b4);function nm(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 v4(){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);f(null,...o);function f(m,...h){const x=e[++u];let g=-1;if(m){d(m);return}for(;++g<o.length;)(h[g]===null||h[g]===void 0)&&(h[g]=o[g]);o=h,x?w4(x,f)(...h):d(null,...h)}}function i(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),n}}function w4(e,n){let a;return i;function i(...d){const f=e.length>d.length;let m;f&&d.push(o);try{m=e.apply(this,d)}catch(h){const x=h;if(f&&a)throw x;return o(x)}f||(m&&m.then&&typeof m.then=="function"?m.then(u,o):m instanceof Error?o(m):u(m))}function o(d,...f){a||(a=!0,n(d,...f))}function u(d){o(null,d)}}const Sa={basename:k4,dirname:j4,extname:S4,join:C4,sep:"/"};function k4(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Go(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,f=n.length-1;for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else d<0&&(u=!0,d=o+1),f>-1&&(e.codePointAt(o)===n.codePointAt(f--)?f<0&&(i=o):(f=-1,i=d));return a===i?i=d:i<0&&(i=e.length),e.slice(a,i)}function j4(e){if(Go(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 S4(e){Go(e);let n=e.length,a=-1,i=0,o=-1,u=0,d;for(;n--;){const f=e.codePointAt(n);if(f===47){if(d){i=n+1;break}continue}a<0&&(d=!0,a=n+1),f===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 C4(...e){let n=-1,a;for(;++n<e.length;)Go(e[n]),e[n]&&(a=a===void 0?e[n]:a+"/"+e[n]);return a===void 0?".":E4(a)}function E4(e){Go(e);const n=e.codePointAt(0)===47;let a=N4(e,!n);return a.length===0&&!n&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),n?"/"+a:a}function N4(e,n){let a="",i=0,o=-1,u=0,d=-1,f,m;for(;++d<=e.length;){if(d<e.length)f=e.codePointAt(d);else{if(f===47)break;f=47}if(f===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 f===46&&u>-1?u++:u=-1}return a}function Go(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const A4={cwd:D4};function D4(){return"/"}function rm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function T4(e){if(typeof e=="string")e=new URL(e);else if(!rm(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 F4(e)}function F4(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 mh=["history","path","basename","stem","extname","dirname"];class fb{constructor(n){let a;n?rm(n)?a={path:n}:typeof n=="string"||R4(n)?a={value:n}:a=n:a={},this.cwd="cwd"in a?"":A4.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<mh.length;){const u=mh[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)mh.includes(o)||(this[o]=a[o])}get basename(){return typeof this.path=="string"?Sa.basename(this.path):void 0}set basename(n){xh(n,"basename"),ph(n,"basename"),this.path=Sa.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?Sa.dirname(this.path):void 0}set dirname(n){mg(this.basename,"dirname"),this.path=Sa.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?Sa.extname(this.path):void 0}set extname(n){if(ph(n,"extname"),mg(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=Sa.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){rm(n)&&(n=T4(n)),xh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?Sa.basename(this.path,this.extname):void 0}set stem(n){xh(n,"stem"),ph(n,"stem"),this.path=Sa.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 lr(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 ph(e,n){if(e&&e.includes(Sa.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+Sa.sep+"`")}function xh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function mg(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function R4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const M4=(function(e){const i=this.constructor.prototype,o=i[e],u=function(){return o.apply(u,arguments)};return Object.setPrototypeOf(u,i),u}),z4={}.hasOwnProperty;class Lm extends M4{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=v4()}copy(){const n=new Lm;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];n.use(...i)}return n.data(hh(!0,{},this.namespace)),n}data(n,a){return typeof n=="string"?arguments.length===2?(bh("data",this.frozen),this.namespace[n]=a,this):z4.call(this.namespace,n)&&this.namespace[n]||void 0:n?(bh("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=vu(n),i=this.parser||this.Parser;return gh("parse",i),i(String(a),a)}process(n,a){const i=this;return this.freeze(),gh("process",this.parser||this.Parser),yh("process",this.compiler||this.Compiler),a?o(void 0,a):new Promise(o);function o(u,d){const f=vu(n),m=i.parse(f);i.run(m,f,function(x,g,v){if(x||!g||!v)return h(x);const b=g,j=i.stringify(b,v);O4(j)?v.value=j:v.result=j,h(x,v)});function h(x,g){x||!g?d(x):u?u(g):a(void 0,g)}}}processSync(n){let a=!1,i;return this.freeze(),gh("processSync",this.parser||this.Parser),yh("processSync",this.compiler||this.Compiler),this.process(n,o),xg("processSync","process",a),i;function o(u,d){a=!0,fg(u),i=d}}run(n,a,i){pg(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,f){const m=vu(a);o.run(n,m,h);function h(x,g,v){const b=g||n;x?f(x):d?d(b):i(void 0,b,v)}}}runSync(n,a){let i=!1,o;return this.run(n,a,u),xg("runSync","run",i),o;function u(d,f){fg(d),o=f,i=!0}}stringify(n,a){this.freeze();const i=vu(a),o=this.compiler||this.Compiler;return yh("stringify",o),pg(n),o(n,i)}use(n,...a){const i=this.attachers,o=this.namespace;if(bh("use",this.frozen),n!=null)if(typeof n=="function")m(n,a);else if(typeof n=="object")Array.isArray(n)?f(n):d(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function u(h){if(typeof h=="function")m(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[x,...g]=h;m(x,g)}else d(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function d(h){if(!("plugins"in h)&&!("settings"in h))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");f(h.plugins),h.settings&&(o.settings=hh(!0,o.settings,h.settings))}function f(h){let x=-1;if(h!=null)if(Array.isArray(h))for(;++x<h.length;){const g=h[x];u(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function m(h,x){let g=-1,v=-1;for(;++g<i.length;)if(i[g][0]===h){v=g;break}if(v===-1)i.push([h,...x]);else if(x.length>0){let[b,...j]=x;const k=i[v][1];nm(k)&&nm(b)&&(b=hh(!0,k,b)),i[v]=[h,b,...j]}}}}const _4=new Lm().freeze();function gh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function bh(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 pg(e){if(!nm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function xg(e,n,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function vu(e){return B4(e)?e:new fb(e)}function B4(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function O4(e){return typeof e=="string"||$4(e)}function $4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const L4="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",gg=[],yg={allowDangerousHtml:!0},I4=/^(https?|ircs?|mailto|xmpp)$/i,H4=[{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 Im(e){const n=U4(e),a=q4(e);return Y4(n.runSync(n.parse(a),a),e)}function U4(e){const n=e.rehypePlugins||gg,a=e.remarkPlugins||gg,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...yg}:yg;return _4().use(j3).use(a).use(g4,i).use(n)}function q4(e){const n=e.children||"",a=new fb;return typeof n=="string"&&(a.value=n),a}function Y4(e,n){const a=n.allowedElements,i=n.allowElement,o=n.components,u=n.disallowedElements,d=n.skipHtml,f=n.unwrapDisallowed,m=n.urlTransform||X4;for(const x of H4)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+L4+x.id,void 0);return $m(e,h),i5(e,{Fragment:l.Fragment,components:o,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function h(x,g,v){if(x.type==="raw"&&v&&typeof g=="number")return d?v.children.splice(g,1):v.children[g]={type:"text",value:x.value},g;if(x.type==="element"){let b;for(b in ch)if(Object.hasOwn(ch,b)&&Object.hasOwn(x.properties,b)){const j=x.properties[b],k=ch[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 g=="number"&&(b=!i(x,g,v)),b&&v&&typeof g=="number")return f&&x.children?v.children.splice(g,1,...x.children):v.children.splice(g,1),g}}}function X4(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||I4.test(e.slice(0,n))?e:""}function bg(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 W4(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function V4(e,n,a){const o=ed((a||{}).ignore||[]),u=G4(n);let d=-1;for(;++d<u.length;)db(e,"text",f);function f(h,x){let g=-1,v;for(;++g<x.length;){const b=x[g],j=v?v.children:void 0;if(o(b,j?j.indexOf(b):void 0,v))return;v=b}if(v)return m(h,x)}function m(h,x){const g=x[x.length-1],v=u[d][0],b=u[d][1];let j=0;const N=g.children.indexOf(h);let E=!1,C=[];v.lastIndex=0;let _=v.exec(h.value);for(;_;){const M=_.index,H={index:_.index,input:_.input,stack:[...x,h]};let R=b(..._,H);if(typeof R=="string"&&(R=R.length>0?{type:"text",value:R}:void 0),R===!1?v.lastIndex=M+1:(j!==M&&C.push({type:"text",value:h.value.slice(j,M)}),Array.isArray(R)?C.push(...R):R&&C.push(R),j=M+_[0].length,E=!0),!v.global)break;_=v.exec(h.value)}return E?(j<h.value.length&&C.push({type:"text",value:h.value.slice(j)}),g.children.splice(N,1,...C)):C=[h],N+C.length}}function G4(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([K4(o[0]),P4(o[1])])}return n}function K4(e){return typeof e=="string"?new RegExp(W4(e),"g"):e}function P4(e){return typeof e=="function"?e:function(){return e}}const vh="phrasing",wh=["autolink","link","image","label"];function Q4(){return{transforms:[aj],enter:{literalAutolink:J4,literalAutolinkEmail:kh,literalAutolinkHttp:kh,literalAutolinkWww:kh},exit:{literalAutolink:rj,literalAutolinkEmail:nj,literalAutolinkHttp:ej,literalAutolinkWww:tj}}}function Z4(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:vh,notInConstruct:wh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:vh,notInConstruct:wh},{character:":",before:"[ps]",after:"\\/",inConstruct:vh,notInConstruct:wh}]}}function J4(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function kh(e){this.config.enter.autolinkProtocol.call(this,e)}function ej(e){this.config.exit.autolinkProtocol.call(this,e)}function tj(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 nj(e){this.config.exit.autolinkEmail.call(this,e)}function rj(e){this.exit(e)}function aj(e){V4(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,lj],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),ij]],{ignore:["link","linkReference"]})}function lj(e,n,a,i,o){let u="";if(!hb(o)||(/^w/i.test(n)&&(a=n+a,n="",u="http://"),!sj(a)))return!1;const d=oj(a+i);if(!d[0])return!1;const f={type:"link",title:null,url:u+n+d[0],children:[{type:"text",value:n+d[0]}]};return d[1]?[f,{type:"text",value:d[1]}]:f}function ij(e,n,a,i){return!hb(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+a,children:[{type:"text",value:n+"@"+a}]}}function sj(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 oj(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=bg(e,"(");let u=bg(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 hb(e,n){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Ti(a)||Qu(a))&&(!n||a!==47)}mb.peek=gj;function cj(){this.buffer()}function uj(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function dj(){this.buffer()}function fj(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function hj(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=ca(this.sliceSerialize(e)).toLowerCase(),a.label=n}function mj(e){this.exit(e)}function pj(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=ca(this.sliceSerialize(e)).toLowerCase(),a.label=n}function xj(e){this.exit(e)}function gj(){return"["}function mb(e,n,a,i){const o=a.createTracker(i);let u=o.move("[^");const d=a.enter("footnoteReference"),f=a.enter("reference");return u+=o.move(a.safe(a.associationId(e),{after:"]",before:u})),f(),d(),u+=o.move("]"),u}function yj(){return{enter:{gfmFootnoteCallString:cj,gfmFootnoteCall:uj,gfmFootnoteDefinitionLabelString:dj,gfmFootnoteDefinition:fj},exit:{gfmFootnoteCallString:hj,gfmFootnoteCall:mj,gfmFootnoteDefinitionLabelString:pj,gfmFootnoteDefinition:xj}}}function bj(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:a,footnoteReference:mb},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,o,u,d){const f=u.createTracker(d);let m=f.move("[^");const h=u.enter("footnoteDefinition"),x=u.enter("label");return m+=f.move(u.safe(u.associationId(i),{before:m,after:"]"})),x(),m+=f.move("]:"),i.children&&i.children.length>0&&(f.shift(4),m+=f.move((n?`
|
|
65
|
+
`:" ")+u.indentLines(u.containerFlow(i,f.current()),n?pb:vj))),h(),m}}function vj(e,n,a){return n===0?e:pb(e,n,a)}function pb(e,n,a){return(a?"":" ")+e}const wj=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];xb.peek=Ej;function kj(){return{canContainEols:["delete"],enter:{strikethrough:Sj},exit:{strikethrough:Cj}}}function jj(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:wj}],handlers:{delete:xb}}}function Sj(e){this.enter({type:"delete",children:[]},e)}function Cj(e){this.exit(e)}function xb(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 Ej(){return"~"}function Nj(e){return e.length}function Aj(e,n){const a=n||{},i=(a.align||[]).concat(),o=a.stringLength||Nj,u=[],d=[],f=[],m=[];let h=0,x=-1;for(;++x<e.length;){const k=[],N=[];let E=-1;for(e[x].length>h&&(h=e[x].length);++E<e[x].length;){const C=Dj(e[x][E]);if(a.alignDelimiters!==!1){const _=o(C);N[E]=_,(m[E]===void 0||_>m[E])&&(m[E]=_)}k.push(C)}d[x]=k,f[x]=N}let g=-1;if(typeof i=="object"&&"length"in i)for(;++g<h;)u[g]=vg(i[g]);else{const k=vg(i);for(;++g<h;)u[g]=k}g=-1;const v=[],b=[];for(;++g<h;){const k=u[g];let N="",E="";k===99?(N=":",E=":"):k===108?N=":":k===114&&(E=":");let C=a.alignDelimiters===!1?1:Math.max(1,m[g]-N.length-E.length);const _=N+"-".repeat(C)+E;a.alignDelimiters!==!1&&(C=N.length+C+E.length,C>m[g]&&(m[g]=C),b[g]=C),v[g]=_}d.splice(1,0,v),f.splice(1,0,b),x=-1;const j=[];for(;++x<d.length;){const k=d[x],N=f[x];g=-1;const E=[];for(;++g<h;){const C=k[g]||"";let _="",M="";if(a.alignDelimiters!==!1){const H=m[g]-(N[g]||0),R=u[g];R===114?_=" ".repeat(H):R===99?H%2?(_=" ".repeat(H/2+.5),M=" ".repeat(H/2-.5)):(_=" ".repeat(H/2),M=_):M=" ".repeat(H)}a.delimiterStart!==!1&&!g&&E.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&C==="")&&(a.delimiterStart!==!1||g)&&E.push(" "),a.alignDelimiters!==!1&&E.push(_),E.push(C),a.alignDelimiters!==!1&&E.push(M),a.padding!==!1&&E.push(" "),(a.delimiterEnd!==!1||g!==h-1)&&E.push("|")}j.push(a.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return j.join(`
|
|
66
|
+
`)}function Dj(e){return e==null?"":String(e)}function vg(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 Tj(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()),Fj);return o(),d}function Fj(e,n,a){return">"+(a?"":" ")+e}function Rj(e,n){return wg(e,n.inConstruct,!0)&&!wg(e,n.notInConstruct,!1)}function wg(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 kg(e,n,a,i){let o=-1;for(;++o<a.unsafe.length;)if(a.unsafe[o].character===`
|
|
67
|
+
`&&Rj(a.stack,a.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
68
|
+
`}function Mj(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 zj(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 _j(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 Bj(e,n,a,i){const o=_j(a),u=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(zj(e,a)){const g=a.enter("codeIndented"),v=a.indentLines(u,Oj);return g(),v}const f=a.createTracker(i),m=o.repeat(Math.max(Mj(u,o)+1,3)),h=a.enter("codeFenced");let x=f.move(m);if(e.lang){const g=a.enter(`codeFencedLang${d}`);x+=f.move(a.safe(e.lang,{before:x,after:" ",encode:["`"],...f.current()})),g()}if(e.lang&&e.meta){const g=a.enter(`codeFencedMeta${d}`);x+=f.move(" "),x+=f.move(a.safe(e.meta,{before:x,after:`
|
|
69
|
+
`,encode:["`"],...f.current()})),g()}return x+=f.move(`
|
|
70
|
+
`),u&&(x+=f.move(u+`
|
|
71
|
+
`)),x+=f.move(m),h(),x}function Oj(e,n,a){return(a?"":" ")+e}function Hm(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 $j(e,n,a,i){const o=Hm(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("definition");let f=a.enter("label");const m=a.createTracker(i);let h=m.move("[");return h+=m.move(a.safe(a.associationId(e),{before:h,after:"]",...m.current()})),h+=m.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(a.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=a.enter("destinationRaw"),h+=m.move(a.safe(e.url,{before:h,after:e.title?" ":`
|
|
72
|
+
`,...m.current()}))),f(),e.title&&(f=a.enter(`title${u}`),h+=m.move(" "+o),h+=m.move(a.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),d(),h}function Lj(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 Uo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function qu(e,n,a){const i=ws(e),o=ws(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}}gb.peek=Ij;function gb(e,n,a,i){const o=Lj(a),u=a.enter("emphasis"),d=a.createTracker(i),f=d.move(o);let m=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const h=m.charCodeAt(0),x=qu(i.before.charCodeAt(i.before.length-1),h,o);x.inside&&(m=Uo(h)+m.slice(1));const g=m.charCodeAt(m.length-1),v=qu(i.after.charCodeAt(0),g,o);v.inside&&(m=m.slice(0,-1)+Uo(g));const b=d.move(o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},f+m+b}function Ij(e,n,a){return a.options.emphasis||"*"}function Hj(e,n){let a=!1;return $m(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,em}),!!((!e.depth||e.depth<3)&&Fm(e)&&(n.options.setext||a))}function Uj(e,n,a,i){const o=Math.max(Math.min(6,e.depth||1),1),u=a.createTracker(i);if(Hj(e,a)){const x=a.enter("headingSetext"),g=a.enter("phrasing"),v=a.containerPhrasing(e,{...u.current(),before:`
|
|
73
|
+
`,after:`
|
|
74
|
+
`});return g(),x(),v+`
|
|
75
|
+
`+(o===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
|
|
76
|
+
`))+1))}const d="#".repeat(o),f=a.enter("headingAtx"),m=a.enter("phrasing");u.move(d+" ");let h=a.containerPhrasing(e,{before:"# ",after:`
|
|
77
|
+
`,...u.current()});return/^[\t ]/.test(h)&&(h=Uo(h.charCodeAt(0))+h.slice(1)),h=h?d+" "+h:d,a.options.closeAtx&&(h+=" "+d),m(),f(),h}yb.peek=qj;function yb(e){return e.value||""}function qj(){return"<"}bb.peek=Yj;function bb(e,n,a,i){const o=Hm(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let f=a.enter("label");const m=a.createTracker(i);let h=m.move("![");return h+=m.move(a.safe(e.alt,{before:h,after:"]",...m.current()})),h+=m.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(a.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=a.enter("destinationRaw"),h+=m.move(a.safe(e.url,{before:h,after:e.title?" ":")",...m.current()}))),f(),e.title&&(f=a.enter(`title${u}`),h+=m.move(" "+o),h+=m.move(a.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),h+=m.move(")"),d(),h}function Yj(){return"!"}vb.peek=Xj;function vb(e,n,a,i){const o=e.referenceType,u=a.enter("imageReference");let d=a.enter("label");const f=a.createTracker(i);let m=f.move("![");const h=a.safe(e.alt,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const g=a.safe(a.associationId(e),{before:m,after:"]",...f.current()});return d(),a.stack=x,u(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function Xj(){return"!"}wb.peek=Wj;function wb(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],f=a.compilePattern(d);let m;if(d.atBreak)for(;m=f.exec(i);){let h=m.index;i.charCodeAt(h)===10&&i.charCodeAt(h-1)===13&&h--,i=i.slice(0,h)+" "+i.slice(m.index+1)}}return o+i+o}function Wj(){return"`"}function kb(e,n){const a=Fm(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))}jb.peek=Vj;function jb(e,n,a,i){const o=Hm(a),u=o==='"'?"Quote":"Apostrophe",d=a.createTracker(i);let f,m;if(kb(e,a)){const x=a.stack;a.stack=[],f=a.enter("autolink");let g=d.move("<");return g+=d.move(a.containerPhrasing(e,{before:g,after:">",...d.current()})),g+=d.move(">"),f(),a.stack=x,g}f=a.enter("link"),m=a.enter("label");let h=d.move("[");return h+=d.move(a.containerPhrasing(e,{before:h,after:"](",...d.current()})),h+=d.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(a.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(m=a.enter("destinationRaw"),h+=d.move(a.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),m(),e.title&&(m=a.enter(`title${u}`),h+=d.move(" "+o),h+=d.move(a.safe(e.title,{before:h,after:o,...d.current()})),h+=d.move(o),m()),h+=d.move(")"),f(),h}function Vj(e,n,a){return kb(e,a)?"<":"["}Sb.peek=Gj;function Sb(e,n,a,i){const o=e.referenceType,u=a.enter("linkReference");let d=a.enter("label");const f=a.createTracker(i);let m=f.move("[");const h=a.containerPhrasing(e,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const g=a.safe(a.associationId(e),{before:m,after:"]",...f.current()});return d(),a.stack=x,u(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function Gj(){return"["}function Um(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 Kj(e){const n=Um(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 Pj(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 Cb(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 Qj(e,n,a,i){const o=a.enter("list"),u=a.bulletCurrent;let d=e.ordered?Pj(a):Um(a);const f=e.ordered?d==="."?")":".":Kj(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),Cb(a)===d&&x){let g=-1;for(;++g<e.children.length;){const v=e.children[g];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(d=f),a.bulletCurrent=d;const h=a.containerFlow(e,i);return a.bulletLastUsed=d,a.bulletCurrent=u,o(),h}function Zj(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 Jj(e,n,a,i){const o=Zj(a);let u=a.bulletCurrent||Um(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 f=a.createTracker(i);f.move(u+" ".repeat(d-u.length)),f.shift(d);const m=a.enter("listItem"),h=a.indentLines(a.containerFlow(e,f.current()),x);return m(),h;function x(g,v,b){return v?(b?"":" ".repeat(d))+g:(b?u:u+" ".repeat(d-u.length))+g}}function eS(e,n,a,i){const o=a.enter("paragraph"),u=a.enter("phrasing"),d=a.containerPhrasing(e,i);return u(),o(),d}const tS=ed(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function nS(e,n,a,i){return(e.children.some(function(d){return tS(d)})?a.containerPhrasing:a.containerFlow).call(a,e,i)}function rS(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}Eb.peek=aS;function Eb(e,n,a,i){const o=rS(a),u=a.enter("strong"),d=a.createTracker(i),f=d.move(o+o);let m=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const h=m.charCodeAt(0),x=qu(i.before.charCodeAt(i.before.length-1),h,o);x.inside&&(m=Uo(h)+m.slice(1));const g=m.charCodeAt(m.length-1),v=qu(i.after.charCodeAt(0),g,o);v.inside&&(m=m.slice(0,-1)+Uo(g));const b=d.move(o+o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},f+m+b}function aS(e,n,a){return a.options.strong||"*"}function lS(e,n,a,i){return a.safe(e.value,i)}function iS(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 sS(e,n,a){const i=(Cb(a)+(a.options.ruleSpaces?" ":"")).repeat(iS(a));return a.options.ruleSpaces?i.slice(0,-1):i}const Nb={blockquote:Tj,break:kg,code:Bj,definition:$j,emphasis:gb,hardBreak:kg,heading:Uj,html:yb,image:bb,imageReference:vb,inlineCode:wb,link:jb,linkReference:Sb,list:Qj,listItem:Jj,paragraph:eS,root:nS,strong:Eb,text:lS,thematicBreak:sS};function oS(){return{enter:{table:cS,tableData:jg,tableHeader:jg,tableRow:dS},exit:{codeText:fS,table:uS,tableData:jh,tableHeader:jh,tableRow:jh}}}function cS(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 uS(e){this.exit(e),this.data.inTable=void 0}function dS(e){this.enter({type:"tableRow",children:[]},e)}function jh(e){this.exit(e)}function jg(e){this.enter({type:"tableCell",children:[]},e)}function fS(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,hS));const a=this.stack[this.stack.length-1];a.type,a.value=n,this.exit(e)}function hS(e,n){return n==="|"?n:e}function mS(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:f}};function d(b,j,k,N){return h(x(b,k,N),b.align)}function f(b,j,k,N){const E=g(b,k,N),C=h([E]);return C.slice(0,C.indexOf(`
|
|
79
|
+
`))}function m(b,j,k,N){const E=k.enter("tableCell"),C=k.enter("phrasing"),_=k.containerPhrasing(b,{...N,before:u,after:u});return C(),E(),_}function h(b,j){return Aj(b,{align:j,alignDelimiters:i,padding:a,stringLength:o})}function x(b,j,k){const N=b.children;let E=-1;const C=[],_=j.enter("table");for(;++E<N.length;)C[E]=g(N[E],j,k);return _(),C}function g(b,j,k){const N=b.children;let E=-1;const C=[],_=j.enter("tableRow");for(;++E<N.length;)C[E]=m(N[E],b,j,k);return _(),C}function v(b,j,k){let N=Nb.inlineCode(b,j,k);return k.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function pS(){return{exit:{taskListCheckValueChecked:Sg,taskListCheckValueUnchecked:Sg,paragraph:gS}}}function xS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:yS}}}function Sg(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function gS(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 f=o[u];if(f.type==="paragraph"){d=f;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 yS(e,n,a,i){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",f=a.createTracker(i);u&&f.move(d);let m=Nb.listItem(e,n,a,{...i,...f.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),m;function h(x){return x+d}}function bS(){return[Q4(),yj(),kj(),oS(),pS()]}function vS(e){return{extensions:[Z4(),bj(e),jj(),mS(e),xS()]}}const wS={tokenize:NS,partial:!0},Ab={tokenize:AS,partial:!0},Db={tokenize:DS,partial:!0},Tb={tokenize:TS,partial:!0},kS={tokenize:FS,partial:!0},Fb={name:"wwwAutolink",tokenize:CS,previous:Mb},Rb={name:"protocolAutolink",tokenize:ES,previous:zb},cl={name:"emailAutolink",tokenize:SS,previous:_b},Ta={};function jS(){return{text:Ta}}let vi=48;for(;vi<123;)Ta[vi]=cl,vi++,vi===58?vi=65:vi===91&&(vi=97);Ta[43]=cl;Ta[45]=cl;Ta[46]=cl;Ta[95]=cl;Ta[72]=[cl,Rb];Ta[104]=[cl,Rb];Ta[87]=[cl,Fb];Ta[119]=[cl,Fb];function SS(e,n,a){const i=this;let o,u;return d;function d(g){return!am(g)||!_b.call(i,i.previous)||qm(i.events)?a(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return am(g)?(e.consume(g),f):g===64?(e.consume(g),m):a(g)}function m(g){return g===46?e.check(kS,x,h)(g):g===45||g===95||ar(g)?(u=!0,e.consume(g),m):x(g)}function h(g){return e.consume(g),o=!0,m}function x(g){return u&&o&&ur(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(g)):a(g)}}function CS(e,n,a){const i=this;return o;function o(d){return d!==87&&d!==119||!Mb.call(i,i.previous)||qm(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(wS,e.attempt(Ab,e.attempt(Db,u),a),a)(d))}function u(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(d)}}function ES(e,n,a){const i=this;let o="",u=!1;return d;function d(g){return(g===72||g===104)&&zb.call(i,i.previous)&&!qm(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):a(g)}function f(g){if(ur(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(g),m}return a(g)}function m(g){return g===47?(e.consume(g),u?h:(u=!0,m)):a(g)}function h(g){return g===null||Iu(g)||un(g)||Ti(g)||Qu(g)?a(g):e.attempt(Ab,e.attempt(Db,x),a)(g)}function x(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(g)}}function NS(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 AS(e,n,a){let i,o,u;return d;function d(h){return h===46||h===95?e.check(Tb,m,f)(h):h===null||un(h)||Ti(h)||h!==45&&Qu(h)?m(h):(u=!0,e.consume(h),d)}function f(h){return h===95?i=!0:(o=i,i=void 0),e.consume(h),d}function m(h){return o||i||!u?a(h):n(h)}}function DS(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(Tb,n,u)(d):d===null||un(d)||Ti(d)?n(d):(e.consume(d),o)}function u(d){return d===41&&i++,e.consume(d),o}}function TS(e,n,a){return i;function i(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),i):f===38?(e.consume(f),u):f===93?(e.consume(f),o):f===60||f===null||un(f)||Ti(f)?n(f):a(f)}function o(f){return f===null||f===40||f===91||un(f)||Ti(f)?n(f):i(f)}function u(f){return ur(f)?d(f):a(f)}function d(f){return f===59?(e.consume(f),i):ur(f)?(e.consume(f),d):a(f)}}function FS(e,n,a){return i;function i(u){return e.consume(u),o}function o(u){return ar(u)?a(u):n(u)}}function Mb(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||un(e)}function zb(e){return!ur(e)}function _b(e){return!(e===47||am(e))}function am(e){return e===43||e===45||e===46||e===95||ar(e)}function qm(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 RS={tokenize:IS,partial:!0};function MS(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:OS,continuation:{tokenize:$S},exit:LS}},text:{91:{name:"gfmFootnoteCall",tokenize:BS},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:zS,resolveTo:_S}}}}function zS(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 f;function f(m){if(!d||!d._balanced)return a(m);const h=ca(i.sliceSerialize({start:d.end,end:i.now()}));return h.codePointAt(0)!==94||!u.includes(h.slice(1))?a(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function _S(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)},f=[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,...f),e}function BS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?a(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(u>999||g===93&&!d||g===null||g===91||un(g))return a(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(ca(i.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):a(g)}return un(g)||(d=!0),u++,e.consume(g),g===92?x:h}function x(g){return g===91||g===92||g===93?(e.consume(g),u++,h):h(g)}}function OS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,f;return m;function m(j){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(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&&!f||j===null||j===91||un(j))return a(j);if(j===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return u=ca(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return un(j)||(f=!0),d++,e.consume(j),j===92?g:x}function g(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),It(e,b,"gfmFootnoteDefinitionWhitespace")):a(j)}function b(j){return n(j)}}function $S(e,n,a){return e.check(Vo,n,e.attempt(RS,n,a))}function LS(e){e.exit("gfmFootnoteDefinition")}function IS(e,n,a){const i=this;return It(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 HS(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,f){let m=-1;for(;++m<d.length;)if(d[m][0]==="enter"&&d[m][1].type==="strikethroughSequenceTemporary"&&d[m][1]._close){let h=m;for(;h--;)if(d[h][0]==="exit"&&d[h][1].type==="strikethroughSequenceTemporary"&&d[h][1]._open&&d[m][1].end.offset-d[m][1].start.offset===d[h][1].end.offset-d[h][1].start.offset){d[m][1].type="strikethroughSequence",d[h][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},d[h][1].start),end:Object.assign({},d[m][1].end)},g={type:"strikethroughText",start:Object.assign({},d[h][1].end),end:Object.assign({},d[m][1].start)},v=[["enter",x,f],["enter",d[h][1],f],["exit",d[h][1],f],["enter",g,f]],b=f.parser.constructs.insideSpan.null;b&&$r(v,v.length,0,Zu(b,d.slice(h+1,m),f)),$r(v,v.length,0,[["exit",g,f],["enter",d[m][1],f],["exit",d[m][1],f],["exit",x,f]]),$r(d,h-1,m-h+3,v),m=h+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,f,m){const h=this.previous,x=this.events;let g=0;return v;function v(j){return h===126&&x[x.length-1][1].type!=="characterEscape"?m(j):(d.enter("strikethroughSequenceTemporary"),b(j))}function b(j){const k=ws(h);if(j===126)return g>1?m(j):(d.consume(j),g++,b);if(g<2&&!a)return m(j);const N=d.exit("strikethroughSequenceTemporary"),E=ws(j);return N._open=!E||E===2&&!!k,N._close=!k||k===2&&!!E,f(j)}}}class US{constructor(){this.map=[]}add(n,a,i){qS(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 qS(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 YS(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 XS(){return{flow:{null:{name:"table",tokenize:WS,resolveAll:VS}}}}function WS(e,n,a){const i=this;let o=0,u=0,d;return f;function f(D){let O=i.events.length-1;for(;O>-1;){const re=i.events[O][1].type;if(re==="lineEnding"||re==="linePrefix")O--;else break}const B=O>-1?i.events[O][1].type:null,ee=B==="tableHead"||B==="tableRow"?R:m;return ee===R&&i.parser.lazy[i.now().line]?a(D):ee(D)}function m(D){return e.enter("tableHead"),e.enter("tableRow"),h(D)}function h(D){return D===124||(d=!0,u+=1),x(D)}function x(D){return D===null?a(D):it(D)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),b):a(D):At(D)?It(e,x,"whitespace")(D):(u+=1,d&&(d=!1,o+=1),D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),g(D)))}function g(D){return D===null||D===124||un(D)?(e.exit("data"),x(D)):(e.consume(D),D===92?v:g)}function v(D){return D===92||D===124?(e.consume(D),g):g(D)}function b(D){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(D):(e.enter("tableDelimiterRow"),d=!1,At(D)?It(e,j,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):j(D))}function j(D){return D===45||D===58?N(D):D===124?(d=!0,e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),k):H(D)}function k(D){return At(D)?It(e,N,"whitespace")(D):N(D)}function N(D){return D===58?(u+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),E):D===45?(u+=1,E(D)):D===null||it(D)?M(D):H(D)}function E(D){return D===45?(e.enter("tableDelimiterFiller"),C(D)):H(D)}function C(D){return D===45?(e.consume(D),C):D===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),_):(e.exit("tableDelimiterFiller"),_(D))}function _(D){return At(D)?It(e,M,"whitespace")(D):M(D)}function M(D){return D===124?j(D):D===null||it(D)?!d||o!==u?H(D):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(D)):H(D)}function H(D){return a(D)}function R(D){return e.enter("tableRow"),I(D)}function I(D){return D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),I):D===null||it(D)?(e.exit("tableRow"),n(D)):At(D)?It(e,I,"whitespace")(D):(e.enter("data"),W(D))}function W(D){return D===null||D===124||un(D)?(e.exit("data"),I(D)):(e.consume(D),D===92?Y:W)}function Y(D){return D===92||D===124?(e.consume(D),W):W(D)}}function VS(e,n){let a=-1,i=!0,o=0,u=[0,0,0,0],d=[0,0,0,0],f=!1,m=0,h,x,g;const v=new US;for(;++a<e.length;){const b=e[a],j=b[1];b[0]==="enter"?j.type==="tableHead"?(f=!1,m!==0&&(Cg(v,n,m,h,x),x=void 0,m=0),h={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(a,0,[["enter",h,n]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(i=!0,g=void 0,u=[0,0,0,0],d=[0,a+1,0,0],f&&(f=!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],g=wu(v,n,u,o,void 0,g),u=[0,0,0,0]),d[2]=a)):j.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],g=wu(v,n,u,o,void 0,g)),u=d,d=[u[1],a,0,0])):j.type==="tableHead"?(f=!0,m=a):j.type==="tableRow"||j.type==="tableDelimiterRow"?(m=a,u[1]!==0?(d[0]=d[1],g=wu(v,n,u,o,a,g)):d[1]!==0&&(g=wu(v,n,d,o,a,g)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(d[3]=a)}for(m!==0&&Cg(v,n,m,h,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=YS(n.events,a))}return e}function wu(e,n,a,i,o,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(u.end=Object.assign({},gs(n.events,a[0])),e.add(a[0],0,[["exit",u,n]]));const m=gs(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 h=gs(n.events,a[2]),x=gs(n.events,a[3]),g={type:f,start:Object.assign({},h),end:Object.assign({},x)};if(e.add(a[2],0,[["enter",g,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",g,n]])}return o!==void 0&&(u.end=Object.assign({},gs(n.events,o)),e.add(o,0,[["exit",u,n]]),u=void 0),u}function Cg(e,n,a,i,o){const u=[],d=gs(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 gs(e,n){const a=e[n],i=a[0]==="enter"?"start":"end";return a[1][i]}const GS={name:"tasklistCheck",tokenize:PS};function KS(){return{text:{91:GS}}}function PS(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 un(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"),f):a(m)}function f(m){return it(m)?n(m):At(m)?e.check({tokenize:QS},n,a)(m):a(m)}}function QS(e,n,a){return It(e,i,"whitespace");function i(o){return o===null?a(o):n(o)}}function ZS(e){return Wy([jS(),MS(),HS(e),XS(),KS()])}const JS={};function Ym(e){const n=this,a=e||JS,i=n.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(ZS(a)),u.push(bS()),d.push(vS(a))}function As({content:e,className:n=""}){return l.jsx("div",{className:`office-markdown ${n}`,children:l.jsx(Im,{remarkPlugins:[Ym],components:{code:eC,table:({children:a})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:a})})},children:e})})}function eC({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
80
|
+
`)?l.jsx(tC,{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 tC({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 Eg={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},nC=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function rC(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 aC(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 Bb(e,n){const a=Eg[e];if(a&&n)return n[a];const i=nC.exec(e);if(i){const[,o,u,d]=i,f=Eg[u],m=f&&n?n[f]:u,h=parseInt(d,10);return o==="darken"?rC(m,h):aC(m,h)}return e}function lm(e,n=12){return e.map(a=>({...a,x:n-a.x-a.w}))}function lC(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:lm(e.left.pixels)}:n==="left"&&e.right?{name:e.right.name,pixels:lm(e.right.pixels)}:e.down}function iC(e,n){return im(e,"hair",n,1)}function im(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 Xm=new Map,Wm=new Map;function Ob(e,n){Xm.set(e,n)}function nd(e,n){Wm.set(e,n)}function sm(e){return Xm.get(e)}function K8(e){return Wm.get(e)}function P8(){return Array.from(Xm.keys())}function Q8(){return Array.from(Wm.keys())}function sC(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 Vl(e,n,a,i,o){for(const u of n){const d=Bb(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 Z8(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=Bb(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 Yu=new Map;function Ql(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Yu.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;Yu.set(e,{id:e,name:n,layer:{...o,name:"hair"}})}}function oC(e){return Yu.get(e)}function Lb(){return Array.from(Yu.values())}Ql("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}]}});Ql("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}]}});Ql("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}]}});Ql("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}]}});Ql("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"}]}});Ql("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}]}});Ql("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}]}});Ql("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 cC={short:1,messy:1,bun:2,long:2,mohawk:3,slicked:3,bob:4,curly:4},uC={short:0,messy:0,bun:500,long:500,mohawk:2e3,slicked:2e3,bob:5e3,curly:5e3};function Ib(e){return cC[e]??1}function Hb(e,n){return n>=Ib(e)}function dC(e){return uC[e]??0}const Xu=new Map;function Fa(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Xu.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;Xu.set(e,{id:e,name:n,layer:{...o,name:"torso"}})}}function fC(e){return Xu.get(e)}function Ub(){return Array.from(Xu.values())}Fa("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"}]}});Fa("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"}]}});Fa("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"}]}});Fa("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)"}]}});Fa("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)"}]}});Fa("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"}]}});Fa("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"}]}});Fa("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"}]}});Fa("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"}]}});Fa("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 hC={tshirt:1,polo:1,hoodie:2,vest:2,suit:3,tank:3,overalls:4,turtleneck:4,labcoat:5,robe:5},mC={tshirt:0,polo:0,hoodie:500,vest:500,suit:3e3,tank:1e3,overalls:5e3,turtleneck:5e3,labcoat:1e4,robe:1e4};function qb(e){return hC[e]??1}function Yb(e,n){return n>=qb(e)}function pC(e){return mC[e]??0}const qo=new Map;function Gt(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;qo.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;qo.set(e,{id:e,name:n,layer:{...o,name:"accessory"}})}}function xC(e){return qo.get(e)}function gC(e,n){const a=qo.get(e);if(!a)return;if(a.directions)return lC(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 Xb(){return Array.from(qo.values())}Gt("none","None",{name:"accessory",pixels:[]});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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"}]}});Gt("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}]}});Gt("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}]}});Gt("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"}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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"}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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}]}});Gt("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"}]}});Gt("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"}]}});Gt("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}]}});Gt("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}]}});Gt("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 yC={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 Wb(e){return yC[e]??1}function Vb(e,n){return n>=Wb(e)}const bC={none:0,glasses:0,beret:0,cap:0,badge:0,blush:0,lapels:0,"round-glasses":500,headphones:800,scarf:1500,tie:1500,bowtie:1500,sunglasses:3e3,bandana:3e3,eyepatch:3e3,crown:8e3,halo:8e3,horns:5e3,mask:5e3,"cat-ears":8e3,"bear-ears":8e3,"bunny-ears":8e3,"dog-nose":5e3,"fox-mask":8e3,"cat-face":15e3,"bear-face":15e3,"panda-face":15e3,"frog-face":25e3,"rabbit-face":25e3,"dog-face":25e3,"star-glasses":5e4};function vC(e){return bC[e]??0}Gt("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 Ao({r:e,g:n,b:a}){return`#${(e<<16|n<<8|a).toString(16).padStart(6,"0")}`}function Bu(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 wC(e,n){const a=[];a.push(e[Math.floor(Math.random()*e.length)]);for(let i=1;i<n;i++){const o=e.map(f=>{let m=1/0;for(const h of a)m=Math.min(m,Bu(f,h));return m}),u=o.reduce((f,m)=>f+m,0);let d=Math.random()*u;for(let f=0;f<e.length;f++)if(d-=o[f],d<=0){a.push(e[f]);break}a.length<=i&&a.push(e[Math.floor(Math.random()*e.length)])}return a}function kC(e,n,a=20){if(e.length===0)return[];const i=wC(e,n);for(let u=0;u<a;u++){const d=Array.from({length:n},()=>[]);for(const m of e){let h=1/0,x=0;for(let g=0;g<n;g++){const v=Bu(m,i[g]);v<h&&(h=v,x=g)}d[x].push(m)}let f=!0;for(let m=0;m<n;m++){if(d[m].length===0)continue;const h={r:0,g:0,b:0};for(const v of d[m])h.r+=v.r,h.g+=v.g,h.b+=v.b;const x=d[m].length,g={r:Math.round(h.r/x),g:Math.round(h.g/x),b:Math.round(h.b/x)};Bu(g,i[m])>1&&(f=!1),i[m]=g}if(f)break}const o=new Array(n).fill(0);for(const u of e){let d=1/0,f=0;for(let m=0;m<n;m++){const h=Bu(u,i[m]);h<d&&(d=h,f=m)}o[f]++}return i.map((u,d)=>({c:u,count:o[d]})).sort((u,d)=>d.count-u.count).map(u=>u.c)}function jC(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,f=i*o,m=Math.max(1,Math.floor(f/n)),h=[];for(let x=0;x<f;x+=m){const g=x*4;d[g+3]<128||h.push({r:d[g],g:d[g+1],b:d[g+2]})}return h}function Ng(e){return .299*e.r+.587*e.g+.114*e.b}function Ag(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 SC(e,n=8){const a=jC(e),i=kC(a,n);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const o=[...i].sort((g,v)=>Ng(v)-Ng(g)),u=[...i].sort((g,v)=>Ag(v)-Ag(g)),d=o[0],f=o[o.length-1],m=u[0],h=o[o.length-2],x=o[o.length-1];return{skinColor:Ao(d),hairColor:Ao(f),shirtColor:Ao(m),pantsColor:Ao(h),shoeColor:Ao(x)}}const CC=[{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}],EC=[{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"}],NC=[{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"}],AC=[{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 DC(){return{width:12,height:22,layers:[{name:"lower",pixels:CC},{name:"torso",pixels:EC},{name:"head",pixels:NC},{name:"hair",pixels:AC},{name:"accessory",pixels:[]}]}}const TC=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const e of TC)Ob(`mini:${e}`,DC());const FC=[{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"}],RC=[{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"}],MC=[{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 zC(){return{width:12,height:22,layers:[{name:"torso",pixels:FC},{name:"head",pixels:RC},{name:"hair",pixels:MC},{name:"accessory",pixels:[]}]}}Ob("mini-seated:default",zC());const _C={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"}]},BC={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"}]},OC={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"}]},$C={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"}]};nd("meeting",_C);nd("bulletin",BC);nd("decision",$C);nd("knowledge",OC);const Sh=16,Ch=24,LC=60,IC={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function Gb(e,n){if(!e)return e;let a=e;if(n!=null&&n.hairStyle){const i=oC(n.hairStyle);i&&(a=iC(a,i.layer))}if(n!=null&&n.outfitStyle){const i=fC(n.outfitStyle);i&&(a=im(a,"torso",i.layer,1))}if(n!=null&&n.accessory&&n.accessory!=="none"){const i=xC(n.accessory);i&&(a=im(a,"accessory",i.layer))}return a}function Kl({roleId:e,className:n,appearance:a,scale:i}){const o=w.useRef(null),u=w.useRef(0),d=w.useRef(0),f=w.useRef(a);f.current=a;const m=i??4,h=Sh*m,x=Ch*m,g=w.useMemo(()=>{const v=sm(`mini:${e}`)??sm("mini:default");return Gb(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=IC[e]??0,k=()=>{d.current++;const N=f.current;if(!N||!g){u.current=requestAnimationFrame(k);return}const C=(d.current+j)%LC<30?1:0;b.clearRect(0,0,Sh,Ch),b.save(),b.translate(2,1),sC(b,g,C,N,1),b.restore(),u.current=requestAnimationFrame(k)};return u.current=requestAnimationFrame(k),()=>cancelAnimationFrame(u.current)},[e,g]),l.jsx("canvas",{ref:o,width:Sh,height:Ch,className:n,style:{imageRendering:"pixelated",display:"block",width:h,height:x}})}const HC="https://api.tycono.ai",Vm=HC;async function Do(e){const n=await fetch(`${Vm}${e}`);if(!n.ok)throw new Error(`Cloud API error: ${n.status}`);return n.json()}async function wi(e,n){const a=await fetch(`${Vm}${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 kr={health:()=>Do("/api/health"),getMyName:e=>Do(`/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 Do(`/api/store/characters${a?`?${a}`:""}`)},getCharacter:e=>Do(`/api/store/characters/${e}`),getCharacterVersion:e=>Do(`/api/store/characters/${e}/version`),voteCharacter:(e,n,a)=>wi(`/api/store/characters/${e}/vote`,{instanceId:n,vote:a}),trackInstall:e=>wi(`/api/store/characters/${e}/install`,{}),syncCheck:e=>wi("/api/sync/check",{roles:e}),syncPull:e=>wi("/api/sync/pull",{sourceId:e}),publishCharacter:e=>wi("/api/store/publish",e),deleteCharacter:(e,n)=>{const a=n?`?publisher_id=${encodeURIComponent(n)}`:"";return fetch(`${Vm}/api/store/characters/${e}${a}`,{method:"DELETE"}).then(i=>i.json())},uploadTelemetry:e=>wi("/api/telemetry",e),syncStats:e=>wi("/api/stats/sync",e)},UC={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},Eh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},qC={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},YC=500,Dg=360,Tg=700,XC=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function Fg({role:e,allRoles:n,recentActivity:a,onClose:i,onFireRole:o,terminalWidth:u=0,activeJobId:d,activeSessionId:f,activeTask:m,isWorking:h,jobStartedAt:x,onStopJob:g,sessions:v,streamingSessionId:b,onCreateSessionSilent:j,onSendMessage:k,onFocusTerminal:N,onCustomize:E,onUpdateRole:C,appearance:_,relationships:M,roleLevel:H,onMaximize:R}){var We,Dt;const[I,W]=w.useState(YC),[Y,D]=w.useState(!1),O=w.useRef(0),B=w.useRef(0),[ee,re]=w.useState(!1),[K,q]=w.useState(!1),[ce,ue]=w.useState(!1),[V,A]=w.useState(!1),[$,U]=w.useState("talk"),[T,se]=w.useState(!1),[ke,he]=w.useState(""),[_e,Le]=w.useState(!1),Ue=w.useRef(null),[et,Pe]=w.useState(!1),[Ge,Ce]=w.useState(""),[Ae,yt]=w.useState(!1),{events:ct,status:xt}=Fy(f??null),[Ct,Ht]=w.useState(0);w.useEffect(()=>{if(!h||!x){Ht(0);return}const ze=new Date(x).getTime(),He=()=>Ht(Math.floor((Date.now()-ze)/1e3));He();const qt=setInterval(He,1e3);return()=>clearInterval(qt)},[h,x]);const zt=u>0,jt=zt?u:0,Hn=zt?Math.max(Dg,window.innerWidth-u-100):Tg,me=Math.min(I,Hn),je=w.useCallback(ze=>{ze.preventDefault(),O.current=ze.clientX,B.current=me,D(!0);const He=R,qt=()=>{D(!1),document.removeEventListener("mousemove",_t),document.removeEventListener("mouseup",qt)},_t=Bt=>{const Jt=O.current-Bt.clientX,kn=B.current+Jt;if(kn>=window.innerWidth*.6&&He){qt(),He();return}const J=Math.min(Tg,Math.max(Dg,kn));W(J)};document.addEventListener("mousemove",_t),document.addEventListener("mouseup",qt)},[me,R]),Ne=w.useRef(null),G=e?v.find(ze=>ze.roleId===e.id):null,Z=ze=>{if(!e)return;const He=h?"talk":$;G?(k(G.id,ze,He),N(e.id)):(Ne.current={content:ze,mode:He},j(e.id))};w.useEffect(()=>{if(G&&Ne.current){const{content:ze,mode:He}=Ne.current;Ne.current=null,k(G.id,ze,He),e&&N(e.id)}},[G==null?void 0:G.id]);const ye=(()=>{if(!ct.length)return null;const ze=[];let He=0,qt=0,_t=0;for(const Bt of ct)if(Bt.type==="thinking")He++;else if(Bt.type==="text")qt++;else if(Bt.type==="tool:start"){const Jt=String(Bt.data.name??"");ze.includes(Jt)||ze.push(Jt)}else Bt.type==="dispatch:start"&&_t++;return{tools:ze,thinkCount:He,textCount:qt,dispatchCount:_t,total:ct.length}})(),ge=m||(()=>{if(!G)return null;const ze=G.messages;for(let He=ze.length-1;He>=0;He--)if(ze[He].from==="ceo")return ze[He].content;return null})(),Ee=(()=>{if(!G)return null;const ze=G.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:jt},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:jt,width:me,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 Fe=Eh[e.id]??"#666",Be=UC[e.id]??"👤",Oe=n.filter(ze=>ze.reportsTo===e.id),qe=G&&b===G.id,at=e.name||qC[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:jt},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)] ${Y?"resizing":""}`,style:{borderLeftColor:Fe,right:jt,width:me,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 ${Y?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:je}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Fe}ee, ${Fe}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:[E&&l.jsx("button",{onClick:()=>E(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:"🎨"}),R&&l.jsx("button",{onClick:R,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(Kl,{roleId:e.id,appearance:_,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:[Be," ",e.id.toUpperCase(),h&&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=ke.trim();if(!He||He===at||!C){se(!1);return}Le(!0);try{await C(e.id,{name:He})}catch{}Le(!1),se(!1)},children:[l.jsx("input",{ref:Ue,value:ke,onChange:ze=>he(ze.target.value),onKeyDown:ze=>{ze.key==="Escape"&&se(!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:()=>se(!1),className:"text-white/60 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✕"})]}):l.jsxs("div",{className:"text-xs opacity-75 mt-0.5 group/name flex items-center gap-1 cursor-pointer hover:opacity-100 transition-opacity",onClick:()=>{C&&(he(at),se(!0))},title:C?"Click to edit name":void 0,children:[at,C&&l.jsx("span",{className:"opacity-0 group-hover/name:opacity-60 text-[10px]",children:"✎"})]})]})]}),l.jsxs("div",{className:"relative flex items-center gap-3 px-4 py-2 text-[10px] font-bold text-white/80",style:{background:"rgba(0,0,0,0.2)",fontFamily:"var(--pixel-font)"},children:[l.jsxs("span",{children:["Lv.",H??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:h?"var(--idle-amber)":"var(--active-green)"}}),h?"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:[h&&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",Ct>0?` · ${XC(Ct)}`:""]})]}),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&&g&&l.jsx("button",{onClick:()=>g(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"})]})]}),ge&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:ge})]}),h&&d&&ye&&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:[ye.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 ×",ye.thinkCount]}),ye.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)),ye.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 ×",ye.dispatchCount]}),ye.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 ×",ye.textCount]}),(xt==="streaming"||xt==="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:[ye.total," events"]})]}),h&&Ee&&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:[Ee.slice(0,200),Ee.length>200&&"..."]})]}),h&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(Rg,{onSend:Z,disabled:!!qe,placeholder:"Ask something...",color:Fe})}),!h&&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(VC,{icon:Be,roleId:e.id,roleName:at,color:Fe,text:a})]}),!h&&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:[Ee&&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:[Ee.slice(0,150),Ee.length>150&&"..."]})]}),l.jsx("div",{className:"p-2",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex rounded-lg overflow-hidden shrink-0",style:{border:"1px solid var(--pixel-border)"},children:[l.jsx("button",{onClick:()=>U("talk"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:$==="talk"?"var(--accent)":"transparent",color:$==="talk"?"#fff":"var(--terminal-text-secondary)"},children:"Talk"}),l.jsx("button",{onClick:()=>U("do"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:$==="do"?"var(--idle-amber)":"transparent",color:$==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),l.jsx(Rg,{onSend:Z,disabled:!!qe,placeholder:$==="talk"?"Ask something...":"Give a directive...",color:Fe})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(ku,{title:`Profile${e.persona?"":" (empty)"}`,open:ee,onToggle:()=>re(ze=>!ze),children:[et?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:Ge,onChange:ze=>Ce(ze.target.value),onKeyDown:ze=>{ze.key==="Escape"&&Pe(!1)},disabled:Ae,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:()=>Pe(!1),disabled:Ae,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Cancel"}),l.jsx("button",{onClick:async()=>{if(C){yt(!0);try{await C(e.id,{persona:Ge.trim()})}catch{}yt(!1),Pe(!1)}},disabled:Ae,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold",style:{background:"var(--active-green)",color:"#000"},children:Ae?"Saving...":"Save"})]})]}):l.jsxs("div",{className:"text-xs leading-relaxed rounded-lg p-3 group/persona cursor-pointer hover:opacity-90 transition-opacity",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},onClick:()=>{C&&(Ce(e.persona||""),Pe(!0))},title:C?"Click to edit persona":void 0,children:[e.persona||l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:"No persona set. Click to add one."}),C&&l.jsx("span",{className:"opacity-0 group-hover/persona:opacity-60 text-[10px] ml-1",children:"✎"})]}),l.jsxs("div",{className:"space-y-0 mt-2",children:[l.jsx(Nh,{label:"Level",value:e.level}),l.jsx(Nh,{label:"Reports to",value:e.reportsTo}),l.jsx(Nh,{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:Eh[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(ku,{title:"Authority",open:K,onToggle:()=>q(ze=>!ze),children:[((We=e.authority.autonomous)==null?void 0:We.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))]}),((Dt=e.authority.needsApproval)==null?void 0:Dt.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,qt)=>qt.familiarity-He.familiarity);return ze.length===0?null:l.jsx(ku,{title:`Relationships (${ze.length})`,open:ce,onToggle:()=>ue(He=>!He),children:l.jsx("div",{className:"space-y-1.5",children:ze.map((He,qt)=>{const _t=He.roleA===e.id?He.roleB:He.roleA,Bt=n.find(J=>J.id===_t),Jt=He.familiarity>=80?"Best Partner":He.familiarity>=50?"Friend":He.familiarity>=20?"Colleague":"Acquaintance",kn=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:Eh[_t]??"var(--terminal-text-secondary)"},children:(Bt==null?void 0:Bt.name)??_t}),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:kn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:Jt})]},qt)})})})})(),e.journal&&l.jsx(ku,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:V,onToggle:()=>A(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(As,{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(WC,{role:e,appearance:_}),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 WC({role:e,appearance:n}){const[a,i]=w.useState("idle"),[o,u]=w.useState(""),[d,f]=w.useState(!1),[m,h]=w.useState(null),[x,g]=w.useState(!1),[v,b]=w.useState(!1),[j,k]=w.useState(null);w.useEffect(()=>{kr.getCharacterVersion(e.id).then(C=>h((C==null?void 0:C.version)??null)).catch(()=>h(null)),pe.getPreferences().then(C=>k(C.instanceId??null)).catch(()=>{})},[e.id]);const N=async()=>{var C,_;if(!d){f(!0);return}i("publishing");try{let M=null;try{M=await pe.exportSkills(e.id)}catch{}const H={roleId:e.id,persona:e.persona??"",authority:e.authority??{autonomous:[],needsApproval:[]},level:e.level,tagline:((C=(e.persona??"").split(/[.\n]/)[0])==null?void 0:C.trim().slice(0,80))||e.name,chatStyle:"Professional and focused",skills:M??[],resume:{summary:((_=e.persona)==null?void 0:_.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&&(H.appearance=n);let R="1.0.0";try{const I=await kr.getCharacterVersion(e.id);if(I!=null&&I.version){const W=I.version.split(".").map(Number);W[2]=(W[2]??0)+1,R=W.join(".")}}catch{}await kr.publishCharacter({id:e.id,name:e.name||e.id,version:R,data:H,publisherId:j??void 0}),i("done"),u(`Published v${R}`),h(R),f(!1)}catch(M){i("error"),u(M instanceof Error?M.message:"Failed"),f(!1)}},E=async()=>{b(!0);try{await kr.deleteCharacter(e.id,j??void 0),h(null),i("idle"),u(""),g(!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("a",{href:"https://tycono.ai/store.html",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-bold uppercase tracking-wider shrink-0 hover:underline cursor-pointer",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)",textDecoration:"none"},onClick:C=>C.stopPropagation(),children:"Job Board ↗"}),m&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded shrink-0",style:{background:"rgba(34,197,94,0.1)",color:"rgba(34,197,94,0.6)",border:"1px solid rgba(34,197,94,0.2)"},children:["v",m]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a==="done"?l.jsx(l.Fragment,{children: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:()=>g(!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:E,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:()=>g(!1),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)"},children:"No"})]})]})]})})})}function VC({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(As,{content:o})}):l.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function ku({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 Rg({onSend:e,disabled:n,placeholder:a,color:i}){const[o,u]=w.useState(""),d=w.useRef(!1),f=()=>{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(),f())},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:f,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 Nh({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 GC(e,n){var a,i=1;e==null&&(e=0),n==null&&(n=0);function o(){var u,d=a.length,f,m=0,h=0;for(u=0;u<d;++u)f=a[u],m+=f.x,h+=f.y;for(m=(m/d-e)*i,h=(h/d-n)*i,u=0;u<d;++u)f=a[u],f.x-=m,f.y-=h}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 KC(e){const n=+this._x.call(null,e),a=+this._y.call(null,e);return Kb(this.cover(n,a),n,a,e)}function Kb(e,n,a,i){if(isNaN(n)||isNaN(a))return e;var o,u=e._root,d={data:i},f=e._x0,m=e._y0,h=e._x1,x=e._y1,g,v,b,j,k,N,E,C;if(!u)return e._root=d,e;for(;u.length;)if((k=n>=(g=(f+h)/2))?f=g:h=g,(N=a>=(v=(m+x)/2))?m=v:x=v,o=u,!(u=u[E=N<<1|k]))return o[E]=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[E]=d:e._root=d,e;do o=o?o[E]=new Array(4):e._root=new Array(4),(k=n>=(g=(f+h)/2))?f=g:h=g,(N=a>=(v=(m+x)/2))?m=v:x=v;while((E=N<<1|k)===(C=(j>=v)<<1|b>=g));return o[C]=u,o[E]=d,e}function PC(e){var n,a,i=e.length,o,u,d=new Array(i),f=new Array(i),m=1/0,h=1/0,x=-1/0,g=-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,f[a]=u,o<m&&(m=o),o>x&&(x=o),u<h&&(h=u),u>g&&(g=u));if(m>x||h>g)return this;for(this.cover(m,h).cover(x,g),a=0;a<i;++a)Kb(this,d[a],f[a],e[a]);return this}function QC(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,f=this._root,m,h;a>e||e>=o||i>n||n>=u;)switch(h=(n<i)<<1|e<a,m=new Array(4),m[h]=f,f=m,d*=2,h){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=f)}return this._x0=a,this._y0=i,this._x1=o,this._y1=u,this}function ZC(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function JC(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 dr(e,n,a,i,o){this.node=e,this.x0=n,this.y0=a,this.x1=i,this.y1=o}function eE(e,n,a){var i,o=this._x0,u=this._y0,d,f,m,h,x=this._x1,g=this._y1,v=[],b=this._root,j,k;for(b&&v.push(new dr(b,o,u,x,g)),a==null?a=1/0:(o=e-a,u=n-a,x=e+a,g=n+a,a*=a);j=v.pop();)if(!(!(b=j.node)||(d=j.x0)>x||(f=j.y0)>g||(m=j.x1)<o||(h=j.y1)<u))if(b.length){var N=(d+m)/2,E=(f+h)/2;v.push(new dr(b[3],N,E,m,h),new dr(b[2],d,E,N,h),new dr(b[1],N,f,m,E),new dr(b[0],d,f,N,E)),(k=(n>=E)<<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 C=e-+this._x.call(null,b.data),_=n-+this._y.call(null,b.data),M=C*C+_*_;if(M<a){var H=Math.sqrt(a=M);o=e-H,u=n-H,x=e+H,g=n+H,i=b.data}}return i}function tE(e){if(isNaN(x=+this._x.call(null,e))||isNaN(g=+this._y.call(null,e)))return this;var n,a=this._root,i,o,u,d=this._x0,f=this._y0,m=this._x1,h=this._y1,x,g,v,b,j,k,N,E;if(!a)return this;if(a.length)for(;;){if((j=x>=(v=(d+m)/2))?d=v:m=v,(k=g>=(b=(f+h)/2))?f=b:h=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,E=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[E]=a:this._root=a),this):(this._root=u,this)}function nE(e){for(var n=0,a=e.length;n<a;++n)this.remove(e[n]);return this}function rE(){return this._root}function aE(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function lE(e){var n=[],a,i=this._root,o,u,d,f,m;for(i&&n.push(new dr(i,this._x0,this._y0,this._x1,this._y1));a=n.pop();)if(!e(i=a.node,u=a.x0,d=a.y0,f=a.x1,m=a.y1)&&i.length){var h=(u+f)/2,x=(d+m)/2;(o=i[3])&&n.push(new dr(o,h,x,f,m)),(o=i[2])&&n.push(new dr(o,u,x,h,m)),(o=i[1])&&n.push(new dr(o,h,d,f,x)),(o=i[0])&&n.push(new dr(o,u,d,h,x))}return this}function iE(e){var n=[],a=[],i;for(this._root&&n.push(new dr(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,f=i.y0,m=i.x1,h=i.y1,x=(d+m)/2,g=(f+h)/2;(u=o[0])&&n.push(new dr(u,d,f,x,g)),(u=o[1])&&n.push(new dr(u,x,f,m,g)),(u=o[2])&&n.push(new dr(u,d,g,x,h)),(u=o[3])&&n.push(new dr(u,x,g,m,h))}a.push(i)}for(;i=a.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function sE(e){return e[0]}function oE(e){return arguments.length?(this._x=e,this):this._x}function cE(e){return e[1]}function uE(e){return arguments.length?(this._y=e,this):this._y}function Gm(e,n,a){var i=new Km(n??sE,a??cE,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function Km(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 Mg(e){for(var n={data:e.data},a=n;e=e.next;)a=a.next={data:e.data};return n}var fr=Gm.prototype=Km.prototype;fr.copy=function(){var e=new Km(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=Mg(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]=Mg(i));return e};fr.add=KC;fr.addAll=PC;fr.cover=QC;fr.data=ZC;fr.extent=JC;fr.find=eE;fr.remove=tE;fr.removeAll=nE;fr.root=rE;fr.size=aE;fr.visit=lE;fr.visitAfter=iE;fr.x=oE;fr.y=uE;function Ni(e){return function(){return e}}function Gl(e){return(e()-.5)*1e-6}function dE(e){return e.x+e.vx}function fE(e){return e.y+e.vy}function hE(e){var n,a,i,o=1,u=1;typeof e!="function"&&(e=Ni(e==null?1:+e));function d(){for(var h,x=n.length,g,v,b,j,k,N,E=0;E<u;++E)for(g=Gm(n,dE,fE).visitAfter(f),h=0;h<x;++h)v=n[h],k=a[v.index],N=k*k,b=v.x+v.vx,j=v.y+v.vy,g.visit(C);function C(_,M,H,R,I){var W=_.data,Y=_.r,D=k+Y;if(W){if(W.index>v.index){var O=b-W.x-W.vx,B=j-W.y-W.vy,ee=O*O+B*B;ee<D*D&&(O===0&&(O=Gl(i),ee+=O*O),B===0&&(B=Gl(i),ee+=B*B),ee=(D-(ee=Math.sqrt(ee)))/ee*o,v.vx+=(O*=ee)*(D=(Y*=Y)/(N+Y)),v.vy+=(B*=ee)*D,W.vx-=O*(D=1-D),W.vy-=B*D)}return}return M>b+D||R<b-D||H>j+D||I<j-D}}function f(h){if(h.data)return h.r=a[h.data.index];for(var x=h.r=0;x<4;++x)h[x]&&h[x].r>h.r&&(h.r=h[x].r)}function m(){if(n){var h,x=n.length,g;for(a=new Array(x),h=0;h<x;++h)g=n[h],a[g.index]=+e(g,h,n)}}return d.initialize=function(h,x){n=h,i=x,m()},d.iterations=function(h){return arguments.length?(u=+h,d):u},d.strength=function(h){return arguments.length?(o=+h,d):o},d.radius=function(h){return arguments.length?(e=typeof h=="function"?h:Ni(+h),m(),d):e},d}function mE(e){return e.index}function zg(e,n){var a=e.get(n);if(!a)throw new Error("node not found: "+n);return a}function pE(e){var n=mE,a=g,i,o=Ni(30),u,d,f,m,h,x=1;e==null&&(e=[]);function g(N){return 1/Math.min(f[N.source.index],f[N.target.index])}function v(N){for(var E=0,C=e.length;E<x;++E)for(var _=0,M,H,R,I,W,Y,D;_<C;++_)M=e[_],H=M.source,R=M.target,I=R.x+R.vx-H.x-H.vx||Gl(h),W=R.y+R.vy-H.y-H.vy||Gl(h),Y=Math.sqrt(I*I+W*W),Y=(Y-u[_])/Y*N*i[_],I*=Y,W*=Y,R.vx-=I*(D=m[_]),R.vy-=W*D,H.vx+=I*(D=1-D),H.vy+=W*D}function b(){if(d){var N,E=d.length,C=e.length,_=new Map(d.map((H,R)=>[n(H,R,d),H])),M;for(N=0,f=new Array(E);N<C;++N)M=e[N],M.index=N,typeof M.source!="object"&&(M.source=zg(_,M.source)),typeof M.target!="object"&&(M.target=zg(_,M.target)),f[M.source.index]=(f[M.source.index]||0)+1,f[M.target.index]=(f[M.target.index]||0)+1;for(N=0,m=new Array(C);N<C;++N)M=e[N],m[N]=f[M.source.index]/(f[M.source.index]+f[M.target.index]);i=new Array(C),j(),u=new Array(C),k()}}function j(){if(d)for(var N=0,E=e.length;N<E;++N)i[N]=+a(e[N],N,e)}function k(){if(d)for(var N=0,E=e.length;N<E;++N)u[N]=+o(e[N],N,e)}return v.initialize=function(N,E){d=N,h=E,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:Ni(+N),j(),v):a},v.distance=function(N){return arguments.length?(o=typeof N=="function"?N:Ni(+N),k(),v):o},v}var xE={value:()=>{}};function Pb(){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 Ou(a)}function Ou(e){this._=e}function gE(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}})}Ou.prototype=Pb.prototype={constructor:Ou,on:function(e,n){var a=this._,i=gE(e+"",a),o,u=-1,d=i.length;if(arguments.length<2){for(;++u<d;)if((o=(e=i[u]).type)&&(o=yE(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]=_g(a[o],e.name,n);else if(n==null)for(o in a)a[o]=_g(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 Ou(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 yE(e,n){for(var a=0,i=e.length,o;a<i;++a)if((o=e[a]).name===n)return o.value}function _g(e,n,a){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=xE,e=e.slice(0,i).concat(e.slice(i+1));break}return a!=null&&e.push({name:n,value:a}),e}var ks=0,zo=0,To=0,Qb=1e3,Wu,_o,Vu=0,Fi=0,rd=0,Yo=typeof performance=="object"&&performance.now?performance:Date,Zb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Jb(){return Fi||(Zb(bE),Fi=Yo.now()+rd)}function bE(){Fi=0}function om(){this._call=this._time=this._next=null}om.prototype=ev.prototype={constructor:om,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?Jb():+a)+(n==null?0:+n),!this._next&&_o!==this&&(_o?_o._next=this:Wu=this,_o=this),this._call=e,this._time=a,cm()},stop:function(){this._call&&(this._call=null,this._time=1/0,cm())}};function ev(e,n,a){var i=new om;return i.restart(e,n,a),i}function vE(){Jb(),++ks;for(var e=Wu,n;e;)(n=Fi-e._time)>=0&&e._call.call(void 0,n),e=e._next;--ks}function Bg(){Fi=(Vu=Yo.now())+rd,ks=zo=0;try{vE()}finally{ks=0,kE(),Fi=0}}function wE(){var e=Yo.now(),n=e-Vu;n>Qb&&(rd-=n,Vu=e)}function kE(){for(var e,n=Wu,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:Wu=a);_o=e,cm(i)}function cm(e){if(!ks){zo&&(zo=clearTimeout(zo));var n=e-Fi;n>24?(e<1/0&&(zo=setTimeout(Bg,e-Yo.now()-rd)),To&&(To=clearInterval(To))):(To||(Vu=Yo.now(),To=setInterval(wE,Qb)),ks=1,Zb(Bg))}}const jE=1664525,SE=1013904223,Og=4294967296;function CE(){let e=1;return()=>(e=(jE*e+SE)%Og)/Og}function EE(e){return e.x}function NE(e){return e.y}var AE=10,DE=Math.PI*(3-Math.sqrt(5));function TE(e){var n,a=1,i=.001,o=1-Math.pow(i,1/300),u=0,d=.6,f=new Map,m=ev(g),h=Pb("tick","end"),x=CE();e==null&&(e=[]);function g(){v(),h.call("tick",n),a<i&&(m.stop(),h.call("end",n))}function v(k){var N,E=e.length,C;k===void 0&&(k=1);for(var _=0;_<k;++_)for(a+=(u-a)*o,f.forEach(function(M){M(a)}),N=0;N<E;++N)C=e[N],C.fx==null?C.x+=C.vx*=d:(C.x=C.fx,C.vx=0),C.fy==null?C.y+=C.vy*=d:(C.y=C.fy,C.vy=0);return n}function b(){for(var k=0,N=e.length,E;k<N;++k){if(E=e[k],E.index=k,E.fx!=null&&(E.x=E.fx),E.fy!=null&&(E.y=E.fy),isNaN(E.x)||isNaN(E.y)){var C=AE*Math.sqrt(.5+k),_=k*DE;E.x=C*Math.cos(_),E.y=C*Math.sin(_)}(isNaN(E.vx)||isNaN(E.vy))&&(E.vx=E.vy=0)}}function j(k){return k.initialize&&k.initialize(e,x),k}return b(),n={tick:v,restart:function(){return m.restart(g),n},stop:function(){return m.stop(),n},nodes:function(k){return arguments.length?(e=k,b(),f.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,f.forEach(j),n):x},force:function(k,N){return arguments.length>1?(N==null?f.delete(k):f.set(k,j(N)),n):f.get(k)},find:function(k,N,E){var C=0,_=e.length,M,H,R,I,W;for(E==null?E=1/0:E*=E,C=0;C<_;++C)I=e[C],M=k-I.x,H=N-I.y,R=M*M+H*H,R<E&&(W=I,E=R);return W},on:function(k,N){return arguments.length>1?(h.on(k,N),n):h.on(k)}}}function FE(){var e,n,a,i,o=Ni(-30),u,d=1,f=1/0,m=.81;function h(b){var j,k=e.length,N=Gm(e,EE,NE).visitAfter(g);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 g(b){var j=0,k,N,E=0,C,_,M;if(b.length){for(C=_=M=0;M<4;++M)(k=b[M])&&(N=Math.abs(k.value))&&(j+=k.value,E+=N,C+=N*k.x,_+=N*k.y);b.x=C/E,b.y=_/E}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 E=b.x-n.x,C=b.y-n.y,_=N-j,M=E*E+C*C;if(_*_/m<M)return M<f&&(E===0&&(E=Gl(a),M+=E*E),C===0&&(C=Gl(a),M+=C*C),M<d&&(M=Math.sqrt(d*M)),n.vx+=E*b.value*i/M,n.vy+=C*b.value*i/M),!0;if(b.length||M>=f)return;(b.data!==n||b.next)&&(E===0&&(E=Gl(a),M+=E*E),C===0&&(C=Gl(a),M+=C*C),M<d&&(M=Math.sqrt(d*M)));do b.data!==n&&(_=u[b.data.index]*i/M,n.vx+=E*_,n.vy+=C*_);while(b=b.next)}return h.initialize=function(b,j){e=b,a=j,x()},h.strength=function(b){return arguments.length?(o=typeof b=="function"?b:Ni(+b),x(),h):o},h.distanceMin=function(b){return arguments.length?(d=b*b,h):Math.sqrt(d)},h.distanceMax=function(b){return arguments.length?(f=b*b,h):Math.sqrt(f)},h.theta=function(b){return arguments.length?(m=b*b,h):Math.sqrt(m)},h}function sl(e){return Array.isArray?Array.isArray(e):rv(e)==="[object Array]"}function RE(e){if(typeof e=="string")return e;let n=e+"";return n=="0"&&1/e==-1/0?"-0":n}function ME(e){return e==null?"":RE(e)}function Na(e){return typeof e=="string"}function tv(e){return typeof e=="number"}function zE(e){return e===!0||e===!1||_E(e)&&rv(e)=="[object Boolean]"}function nv(e){return typeof e=="object"}function _E(e){return nv(e)&&e!==null}function Br(e){return e!=null}function Ah(e){return!e.trim().length}function rv(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const BE="Incorrect 'index' type",OE=e=>`Invalid value for key ${e}`,$E=e=>`Pattern length exceeds max of ${e}.`,LE=e=>`Missing ${e} property in key`,IE=e=>`Property 'weight' in key '${e}' must be a positive integer`,$g=Object.prototype.hasOwnProperty;class HE{constructor(n){this._keys=[],this._keyMap={};let a=0;n.forEach(i=>{let o=av(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 av(e){let n=null,a=null,i=null,o=1,u=null;if(Na(e)||sl(e))i=e,n=Lg(e),a=um(e);else{if(!$g.call(e,"name"))throw new Error(LE("name"));const d=e.name;if(i=d,$g.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(IE(d));n=Lg(d),a=um(d),u=e.getFn}return{path:n,id:a,weight:o,src:i,getFn:u}}function Lg(e){return sl(e)?e:e.split(".")}function um(e){return sl(e)?e.join("."):e}function UE(e,n){let a=[],i=!1;const o=(u,d,f)=>{if(Br(u))if(!d[f])a.push(u);else{let m=d[f];const h=u[m];if(!Br(h))return;if(f===d.length-1&&(Na(h)||tv(h)||zE(h)))a.push(ME(h));else if(sl(h)){i=!0;for(let x=0,g=h.length;x<g;x+=1)o(h[x],d,f+1)}else d.length&&o(h,d,f+1)}};return o(e,Na(n)?n.split("."):n,0),i?a:a[0]}const qE={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},YE={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},XE={location:0,threshold:.6,distance:100},WE={useExtendedSearch:!1,getFn:UE,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var ht={...YE,...qE,...XE,...WE};const VE=/[^ ]+/g;function GE(e=1,n=3){const a=new Map,i=Math.pow(10,n);return{get(o){const u=o.match(VE).length;if(a.has(u))return a.get(u);const d=1/Math.pow(u,.5*e),f=parseFloat(Math.round(d*i)/i);return a.set(u,f),f},clear(){a.clear()}}}class Pm{constructor({getFn:n=ht.getFn,fieldNormWeight:a=ht.fieldNormWeight}={}){this.norm=GE(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,Na(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();Na(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(!Br(n)||Ah(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(Br(d)){if(sl(d)){let f=[];const m=[{nestedArrIndex:-1,value:d}];for(;m.length;){const{nestedArrIndex:h,value:x}=m.pop();if(Br(x))if(Na(x)&&!Ah(x)){let g={v:x,i:h,n:this.norm.get(x)};f.push(g)}else sl(x)&&x.forEach((g,v)=>{m.push({nestedArrIndex:v,value:g})})}i.$[u]=f}else if(Na(d)&&!Ah(d)){let f={v:d,n:this.norm.get(d)};i.$[u]=f}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function lv(e,n,{getFn:a=ht.getFn,fieldNormWeight:i=ht.fieldNormWeight}={}){const o=new Pm({getFn:a,fieldNormWeight:i});return o.setKeys(e.map(av)),o.setSources(n),o.create(),o}function KE(e,{getFn:n=ht.getFn,fieldNormWeight:a=ht.fieldNormWeight}={}){const{keys:i,records:o}=e,u=new Pm({getFn:n,fieldNormWeight:a});return u.setKeys(i),u.setIndexRecords(o),u}function ju(e,{errors:n=0,currentLocation:a=0,expectedLocation:i=0,distance:o=ht.distance,ignoreLocation:u=ht.ignoreLocation}={}){const d=n/e.length;if(u)return d;const f=Math.abs(i-a);return o?d+f/o:f?1:d}function PE(e=[],n=ht.minMatchCharLength){let a=[],i=-1,o=-1,u=0;for(let d=e.length;u<d;u+=1){let f=e[u];f&&i===-1?i=u:!f&&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 Ei=32;function QE(e,n,a,{location:i=ht.location,distance:o=ht.distance,threshold:u=ht.threshold,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,includeMatches:m=ht.includeMatches,ignoreLocation:h=ht.ignoreLocation}={}){if(n.length>Ei)throw new Error($E(Ei));const x=n.length,g=e.length,v=Math.max(0,Math.min(i,g));let b=u,j=v;const k=f>1||m,N=k?Array(g):[];let E;for(;(E=e.indexOf(n,j))>-1;){let I=ju(n,{currentLocation:E,expectedLocation:v,distance:o,ignoreLocation:h});if(b=Math.min(I,b),j=E+x,k){let W=0;for(;W<x;)N[E+W]=1,W+=1}}j=-1;let C=[],_=1,M=x+g;const H=1<<x-1;for(let I=0;I<x;I+=1){let W=0,Y=M;for(;W<Y;)ju(n,{errors:I,currentLocation:v+Y,expectedLocation:v,distance:o,ignoreLocation:h})<=b?W=Y:M=Y,Y=Math.floor((M-W)/2+W);M=Y;let D=Math.max(1,v-Y+1),O=d?g:Math.min(v+Y,g)+x,B=Array(O+2);B[O+1]=(1<<I)-1;for(let re=O;re>=D;re-=1){let K=re-1,q=a[e.charAt(K)];if(k&&(N[K]=+!!q),B[re]=(B[re+1]<<1|1)&q,I&&(B[re]|=(C[re+1]|C[re])<<1|1|C[re+1]),B[re]&H&&(_=ju(n,{errors:I,currentLocation:K,expectedLocation:v,distance:o,ignoreLocation:h}),_<=b)){if(b=_,j=K,j<=v)break;D=Math.max(1,2*v-j)}}if(ju(n,{errors:I+1,currentLocation:v,expectedLocation:v,distance:o,ignoreLocation:h})>b)break;C=B}const R={isMatch:j>=0,score:Math.max(.001,_)};if(k){const I=PE(N,f);I.length?m&&(R.indices=I):R.isMatch=!1}return R}function ZE(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 Gu=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 iv{constructor(n,{location:a=ht.location,threshold:i=ht.threshold,distance:o=ht.distance,includeMatches:u=ht.includeMatches,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,isCaseSensitive:m=ht.isCaseSensitive,ignoreDiacritics:h=ht.ignoreDiacritics,ignoreLocation:x=ht.ignoreLocation}={}){if(this.options={location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:f,isCaseSensitive:m,ignoreDiacritics:h,ignoreLocation:x},n=m?n:n.toLowerCase(),n=h?Gu(n):n,this.pattern=n,this.chunks=[],!this.pattern.length)return;const g=(b,j)=>{this.chunks.push({pattern:b,alphabet:ZE(b),startIndex:j})},v=this.pattern.length;if(v>Ei){let b=0;const j=v%Ei,k=v-j;for(;b<k;)g(this.pattern.substr(b,Ei),b),b+=Ei;if(j){const N=v-Ei;g(this.pattern.substr(N),N)}}else g(this.pattern,0)}searchIn(n){const{isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o}=this.options;if(n=a?n:n.toLowerCase(),n=i?Gu(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:f,findAllMatches:m,minMatchCharLength:h,ignoreLocation:x}=this.options;let g=[],v=0,b=!1;this.chunks.forEach(({pattern:k,alphabet:N,startIndex:E})=>{const{isMatch:C,score:_,indices:M}=QE(n,k,N,{location:u+E,distance:d,threshold:f,findAllMatches:m,minMatchCharLength:h,includeMatches:o,ignoreLocation:x});C&&(b=!0),v+=_,C&&M&&(g=[...g,...M])});let j={isMatch:b,score:b?v/this.chunks.length:1};return b&&o&&(j.indices=g),j}}class Zl{constructor(n){this.pattern=n}static isMultiMatch(n){return Ig(n,this.multiRegex)}static isSingleMatch(n){return Ig(n,this.singleRegex)}search(){}}function Ig(e,n){const a=e.match(n);return a?a[1]:null}class JE extends Zl{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 eN extends Zl{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 tN extends Zl{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 nN extends Zl{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 rN extends Zl{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 aN extends Zl{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 sv extends Zl{constructor(n,{location:a=ht.location,threshold:i=ht.threshold,distance:o=ht.distance,includeMatches:u=ht.includeMatches,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,isCaseSensitive:m=ht.isCaseSensitive,ignoreDiacritics:h=ht.ignoreDiacritics,ignoreLocation:x=ht.ignoreLocation}={}){super(n),this._bitapSearch=new iv(n,{location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:f,isCaseSensitive:m,ignoreDiacritics:h,ignoreLocation:x})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(n){return this._bitapSearch.searchIn(n)}}class ov extends Zl{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 dm=[JE,ov,tN,nN,aN,rN,eN,sv],Hg=dm.length,lN=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,iN="|";function sN(e,n={}){return e.split(iN).map(a=>{let i=a.trim().split(lN).filter(u=>u&&!!u.trim()),o=[];for(let u=0,d=i.length;u<d;u+=1){const f=i[u];let m=!1,h=-1;for(;!m&&++h<Hg;){const x=dm[h];let g=x.isMultiMatch(f);g&&(o.push(new x(g,n)),m=!0)}if(!m)for(h=-1;++h<Hg;){const x=dm[h];let g=x.isSingleMatch(f);if(g){o.push(new x(g,n));break}}}return o})}const oN=new Set([sv.type,ov.type]);class cN{constructor(n,{isCaseSensitive:a=ht.isCaseSensitive,ignoreDiacritics:i=ht.ignoreDiacritics,includeMatches:o=ht.includeMatches,minMatchCharLength:u=ht.minMatchCharLength,ignoreLocation:d=ht.ignoreLocation,findAllMatches:f=ht.findAllMatches,location:m=ht.location,threshold:h=ht.threshold,distance:x=ht.distance}={}){this.query=null,this.options={isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o,minMatchCharLength:u,findAllMatches:f,ignoreLocation:d,location:m,threshold:h,distance:x},n=a?n:n.toLowerCase(),n=i?Gu(n):n,this.pattern=n,this.query=sN(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?Gu(n):n;let d=0,f=[],m=0;for(let h=0,x=a.length;h<x;h+=1){const g=a[h];f.length=0,d=0;for(let v=0,b=g.length;v<b;v+=1){const j=g[v],{isMatch:k,indices:N,score:E}=j.search(n);if(k){if(d+=1,m+=E,i){const C=j.constructor.type;oN.has(C)?f=[...f,...N]:f.push(N)}}else{m=0,d=0,f.length=0;break}}if(d){let v={isMatch:!0,score:m/d};return i&&(v.indices=f),v}}return{isMatch:!1,score:1}}}const fm=[];function uN(...e){fm.push(...e)}function hm(e,n){for(let a=0,i=fm.length;a<i;a+=1){let o=fm[a];if(o.condition(e,n))return new o(e,n)}return new iv(e,n)}const Ku={AND:"$and",OR:"$or"},mm={PATH:"$path",PATTERN:"$val"},pm=e=>!!(e[Ku.AND]||e[Ku.OR]),dN=e=>!!e[mm.PATH],fN=e=>!sl(e)&&nv(e)&&!pm(e),Ug=e=>({[Ku.AND]:Object.keys(e).map(n=>({[n]:e[n]}))});function cv(e,n,{auto:a=!0}={}){const i=o=>{let u=Object.keys(o);const d=dN(o);if(!d&&u.length>1&&!pm(o))return i(Ug(o));if(fN(o)){const m=d?o[mm.PATH]:u[0],h=d?o[mm.PATTERN]:o[m];if(!Na(h))throw new Error(OE(m));const x={keyId:um(m),pattern:h};return a&&(x.searcher=hm(h,n)),x}let f={children:[],operator:u[0]};return u.forEach(m=>{const h=o[m];sl(h)&&h.forEach(x=>{f.children.push(i(x))})}),f};return pm(e)||(e=Ug(e)),i(e)}function hN(e,{ignoreFieldNorm:n=ht.ignoreFieldNorm}){e.forEach(a=>{let i=1;a.matches.forEach(({key:o,norm:u,score:d})=>{const f=o?o.weight:null;i*=Math.pow(d===0&&f?Number.EPSILON:d,(f||1)*(n?1:u))}),a.score=i})}function mN(e,n){const a=e.matches;n.matches=[],Br(a)&&a.forEach(i=>{if(!Br(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 pN(e,n){n.score=e.score}function xN(e,n,{includeMatches:a=ht.includeMatches,includeScore:i=ht.includeScore}={}){const o=[];return a&&o.push(mN),i&&o.push(pN),e.map(u=>{const{idx:d}=u,f={item:n[d],refIndex:d};return o.length&&o.forEach(m=>{m(u,f)}),f})}class Ds{constructor(n,a={},i){this.options={...ht,...a},this.options.useExtendedSearch,this._keyStore=new HE(this.options.keys),this.setCollection(n,i)}setCollection(n,a){if(this._docs=n,a&&!(a instanceof Pm))throw new Error(BE);this._myIndex=a||lv(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(n){Br(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:f}=this.options;let m=Na(n)?Na(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return hN(m,{ignoreFieldNorm:f}),u&&m.sort(d),tv(a)&&a>-1&&(m=m.slice(0,a)),xN(m,this._docs,{includeMatches:i,includeScore:o})}_searchStringList(n){const a=hm(n,this.options),{records:i}=this._myIndex,o=[];return i.forEach(({v:u,i:d,n:f})=>{if(!Br(u))return;const{isMatch:m,score:h,indices:x}=a.searchIn(u);m&&o.push({item:u,idx:d,matches:[{score:h,value:u,norm:f,indices:x}]})}),o}_searchLogical(n){const a=cv(n,this.options),i=(f,m,h)=>{if(!f.children){const{keyId:g,searcher:v}=f,b=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(m,g),searcher:v});return b&&b.length?[{idx:h,item:m,matches:b}]:[]}const x=[];for(let g=0,v=f.children.length;g<v;g+=1){const b=f.children[g],j=i(b,m,h);if(j.length)x.push(...j);else if(f.operator===Ku.AND)return[]}return x},o=this._myIndex.records,u={},d=[];return o.forEach(({$:f,i:m})=>{if(Br(f)){let h=i(a,f,m);h.length&&(u[m]||(u[m]={idx:m,item:f,matches:[]},d.push(u[m])),h.forEach(({matches:x})=>{u[m].matches.push(...x)}))}}),d}_searchObjectList(n){const a=hm(n,this.options),{keys:i,records:o}=this._myIndex,u=[];return o.forEach(({$:d,i:f})=>{if(!Br(d))return;let m=[];i.forEach((h,x)=>{m.push(...this._findMatches({key:h,value:d[x],searcher:a}))}),m.length&&u.push({idx:f,item:d,matches:m})}),u}_findMatches({key:n,value:a,searcher:i}){if(!Br(a))return[];let o=[];if(sl(a))a.forEach(({v:u,i:d,n:f})=>{if(!Br(u))return;const{isMatch:m,score:h,indices:x}=i.searchIn(u);m&&o.push({score:h,key:n,value:u,idx:d,norm:f,indices:x})});else{const{v:u,n:d}=a,{isMatch:f,score:m,indices:h}=i.searchIn(u);f&&o.push({score:m,key:n,value:u,norm:d,indices:h})}return o}}Ds.version="7.1.0";Ds.createIndex=lv;Ds.parseIndex=KE;Ds.config=ht;Ds.parseQuery=cv;uN(cN);const sa={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 gN(e){return sa[e]??sa.general}function yN(e){return e>1600?"macro":e<800?"micro":"standard"}function bN(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 f=o.length;a.push({domain:i,count:f,centerX:u/f,centerY:d/f,nodes:o})}return a}function vN(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 wN(e,n,a){const i=[...new Set(a.map(m=>m.category||"general"))],o=new Map,u=e/2,d=n/2,f=Math.min(e,n)*.3;return i.forEach((m,h)=>{const x=2*Math.PI*h/i.length-Math.PI/2;o.set(m,{x:u+f*Math.cos(x),y:d+f*Math.sin(x)})}),o}function kN(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 jN(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,f=Math.sqrt(u*u+d*d);f>a&&(a=f)}const i=Math.max(40,n.count*8);return{...n,radius:a+i}})}function SN(e,n,a,i){if(!e)return a;const o=new Set([e]),u=new Set;let d=new Set([e]);for(let f=0;f<i;f++){const m=new Set;for(const h of d)if(!u.has(h)){u.add(h);for(const x of n){const g=typeof x.source=="string"?x.source:x.source.id,v=typeof x.target=="string"?x.target:x.target.id;g===h&&!o.has(v)&&(o.add(v),m.add(v)),v===h&&!o.has(g)&&(o.add(g),m.add(g))}}d=m}return o}function CN({docs:e,onNodeClick:n,selectedDocId:a,matchedIds:i,localGraphMode:o,onLocalModeChange:u}){var ue;const d=w.useRef(null),f=w.useRef(null),[m,h]=w.useState({width:600,height:400}),[x,g]=w.useState({nodes:[],links:[]}),[v,b]=w.useState(null),[j,k]=w.useState(null),[N,E]=w.useState({x:0,y:0}),[C,_]=w.useState({x:0,y:0,w:600,h:400}),M=w.useRef(!1),H=w.useRef({x:0,y:0,vx:0,vy:0}),R=w.useRef(null),I=w.useRef(null),W=w.useMemo(()=>yN(C.w),[C.w]),Y=w.useMemo(()=>bN(x.nodes),[x.nodes]),D=w.useMemo(()=>jN(Y),[Y]),O=w.useMemo(()=>{if(o==="global"||!a)return null;const V=new Set(x.nodes.map($=>$.id)),A=o==="1-hop"?1:2;return SN(a,x.links,V,A)},[o,a,x.nodes,x.links]);w.useEffect(()=>{const V=d.current;if(!V)return;const A=new ResizeObserver($=>{const{width:U,height:T}=$[0].contentRect;U>0&&T>0&&(h({width:U,height:T}),_(se=>({...se,w:U,h:T})))});return A.observe(V),()=>A.disconnect()},[]),w.useEffect(()=>{if(e.length===0)return;const V=new Set(e.map(Ae=>Ae.id)),A=e.map(Ae=>({id:Ae.id,title:Ae.title,category:Ae.category,akb_type:Ae.akb_type,tldr:Ae.tldr,tags:Ae.tags})),$=(Ae,yt)=>{if(!yt.startsWith(".")&&!yt.startsWith("/"))return yt;const ct=Ae.split("/");ct.pop();const xt=yt.split("/");for(const Ct of xt)Ct===".."?ct.pop():Ct!=="."&&Ct!==""&&ct.push(Ct);return ct.join("/")},U=[];for(const Ae of e)for(const yt of Ae.links){const ct=$(Ae.id,yt.href);V.has(ct)&&ct!==Ae.id&&(U.some(xt=>xt.source===Ae.id&&xt.target===ct||xt.source===ct&&xt.target===Ae.id)||U.push({source:Ae.id,target:ct,label:yt.text}))}const{width:T,height:se}=m,ke=A.length,he=ke>100?-600:ke>50?-500:-400,_e=ke>100?180:ke>50?160:140,Le=ke>100?60:50,Ue=Math.max(T,ke*12),et=Math.max(se,ke*10),Pe=wN(Ue,et,A),Ge=TE(A).force("link",pE(U).id(Ae=>Ae.id).distance(_e)).force("charge",FE().strength(he)).force("center",GC(Ue/2,et/2)).force("collide",hE(Le)).force("cluster",kN(Pe,.15));I.current=Ge,Ge.on("tick",()=>{g({nodes:[...A],links:[...U]})}),Ge.alpha(1).restart();const Ce=ke>100?300:150;for(let Ae=0;Ae<Ce;Ae++)Ge.tick();if(Ge.stop(),g({nodes:[...A],links:[...U]}),A.length>0){let Ae=1/0,yt=1/0,ct=-1/0,xt=-1/0;for(const Ht of A){const zt=Ht.x??0,jt=Ht.y??0;zt<Ae&&(Ae=zt),jt<yt&&(yt=jt),zt>ct&&(ct=zt),jt>xt&&(xt=jt)}const Ct=100;_({x:Ae-Ct,y:yt-Ct,w:Math.max(T,ct-Ae+Ct*2),h:Math.max(se,xt-yt+Ct*2)})}return()=>{Ge.stop()}},[e,m]);const B=V=>{if(typeof V=="string"){const A=x.nodes.find($=>$.id===V);return{x:(A==null?void 0:A.x)??0,y:(A==null?void 0:A.y)??0}}return{x:V.x??0,y:V.y??0}},ee=w.useCallback(V=>{V.preventDefault();const A=V.deltaY>0?1.1:.9;_($=>{const U=Math.max(200,Math.min(m.width*3,$.w*A)),T=Math.max(150,Math.min(m.height*3,$.h*A)),se=(U-$.w)/2,ke=(T-$.h)/2;return{x:$.x-se,y:$.y-ke,w:U,h:T}})},[m]),re=w.useCallback(V=>{V.button===0&&(M.current=!0,H.current={x:V.clientX,y:V.clientY,vx:C.x,vy:C.y})},[C]),K=w.useCallback(V=>{var A;if(R.current){const $=f.current;if(!$)return;const U=$.getBoundingClientRect(),T=C.w/U.width,se=C.h/U.height,ke=C.x+(V.clientX-U.left)*T,he=C.y+(V.clientY-U.top)*se;R.current.fx=ke,R.current.fy=he,(A=I.current)==null||A.alpha(.3).restart();return}if(M.current){const $=(V.clientX-H.current.x)*(C.w/m.width),U=(V.clientY-H.current.y)*(C.h/m.height);_(T=>({...T,x:H.current.vx-$,y:H.current.vy-U}))}},[C,m]),q=w.useCallback(()=>{M.current=!1,R.current&&(R.current.fx=null,R.current.fy=null,R.current=null)},[]),ce=w.useCallback((V,A)=>{var $;V.stopPropagation(),R.current=A,($=I.current)==null||$.alpha(.3).restart()},[]);return l.jsxs("div",{ref:d,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[l.jsxs("svg",{ref:f,width:m.width,height:m.height,viewBox:`${C.x} ${C.y} ${C.w} ${C.h}`,style:{display:"block",cursor:M.current?"grabbing":"grab"},onWheel:ee,onMouseDown:re,onMouseMove:K,onMouseUp:q,onMouseLeave:q,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:C.x-100,y:C.y-100,width:C.w+200,height:C.h+200,fill:"url(#grid)",pointerEvents:"none"}),W==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:Y.map(V=>{const A=sa[V.domain]??sa.general,$=Math.max(40,Math.sqrt(V.count)*25),T=i===null||V.nodes.some(se=>i.has(se.id))?1:.4;return l.jsxs("g",{transform:`translate(${V.centerX}, ${V.centerY})`,style:{cursor:"pointer",opacity:T,transition:"opacity 0.3s ease"},onMouseEnter:se=>{var he;const ke=(he=d.current)==null?void 0:he.getBoundingClientRect();ke&&E({x:se.clientX-ke.left,y:se.clientY-ke.top}),b({id:`cluster-${V.domain}`,title:`${V.domain} (${V.count})`,category:V.domain,akb_type:"hub"})},onMouseLeave:()=>b(null),children:[l.jsx("circle",{r:$,fill:A.bg,stroke:A.border,strokeWidth:3,opacity:.8}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:A.text,fontSize:16,fontFamily:"monospace",fontWeight:"bold",style:{pointerEvents:"none"},children:V.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:A.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",V.count,")"]})]},V.domain)})}),W!=="macro"&&l.jsxs(l.Fragment,{children:[W==="standard"&&D.map(V=>{const A=sa[V.domain]??sa.general;if(V.count<2)return null;const $=i===null||V.nodes.some(T=>i.has(T.id)),U=$?.08:.04;return l.jsxs("g",{children:[l.jsx("circle",{cx:V.centerX,cy:V.centerY,r:V.radius,fill:A.bg,stroke:A.border,strokeWidth:1,opacity:U,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:V.centerX,y:V.centerY-V.radius-8,textAnchor:"middle",fill:A.text,fontSize:12,fontFamily:"monospace",fontWeight:"600",opacity:$?.85:.5,style:{pointerEvents:"none",transition:"opacity 0.3s ease"},children:[V.domain," (",V.count,")"]})]},`cluster-bg-${V.domain}`)}),x.links.map((V,A)=>{const $=B(V.source),U=B(V.target),T=j===A,se=($.x+U.x)/2,ke=($.y+U.y)/2,he=typeof V.source=="string"?V.source:V.source.id,_e=typeof V.target=="string"?V.target:V.target.id,Ue=O===null||O.has(he)&&O.has(_e)?1:.4;return l.jsxs("g",{style:{opacity:Ue,transition:"opacity 0.3s ease"},children:[l.jsx("line",{x1:$.x,y1:$.y,x2:U.x,y2:U.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>k(A),onMouseLeave:()=>k(null)}),l.jsx("line",{x1:$.x,y1:$.y,x2:U.x,y2:U.y,stroke:T?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.6)",strokeWidth:T?2:1.5,pointerEvents:"none"}),T&&V.label&&l.jsx("text",{x:se,y:ke-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:V.label.length>30?V.label.slice(0,28)+"..":V.label})})]},A)}),x.nodes.map(V=>{const A=sa[V.category]??sa.general,$=V.akb_type==="hub",U=$?24:16,T=W==="micro"?U*1.5:U,se=(v==null?void 0:v.id)===V.id,ke=a===V.id,he=se?1.1:ke?1.05:1,_e=i===null||i.has(V.id),Le=O===null||O.has(V.id),Ue=_e&&Le?1:.35,et=W==="micro"?vN(V.tldr,60):"",Pe=W==="micro"&&V.tags?V.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${V.x??0}, ${V.y??0}) scale(${he})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:Ue},onClick:Ge=>{Ge.stopPropagation();const Ce=e.find(Ae=>Ae.id===V.id);Ce&&n(Ce)},onMouseDown:Ge=>ce(Ge,V),onMouseEnter:Ge=>{var Ae;b(V);const Ce=(Ae=d.current)==null?void 0:Ae.getBoundingClientRect();Ce&&E({x:Ge.clientX-Ce.left,y:Ge.clientY-Ce.top})},onMouseLeave:()=>b(null),children:[ke&&l.jsx("rect",{x:-T/2-4,y:-T/2-4,width:T+8,height:T+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:$?5:2,opacity:.6}),l.jsx("rect",{x:-T/2,y:-T/2,width:T,height:T,fill:A.border,rx:$?4:2,opacity:se?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:A.bg,rx:$?3:1}),l.jsx("text",{y:T/2+14,textAnchor:"middle",fill:ke?"#e2e8f0":"#cbd5e1",fontSize:W==="micro"?13:12,fontFamily:"monospace",fontWeight:ke?"bold":"normal",style:{pointerEvents:"none"},children:V.title.length>36?V.title.slice(0,34)+"..":V.title}),W==="micro"&&et&&l.jsx("text",{y:T/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:10,fontFamily:"system-ui, sans-serif",opacity:.85,style:{pointerEvents:"none"},children:et}),W==="micro"&&Pe.length>0&&l.jsx("g",{transform:`translate(0, ${T/2+(et?42:28)})`,children:Pe.map((Ge,Ce)=>{const Ae=Ge.length*5+8;let ct=-Pe.reduce((xt,Ct)=>xt+Ct.length*5+10,0)/2;for(let xt=0;xt<Ce;xt++)ct+=Pe[xt].length*5+10;return l.jsxs("g",{transform:`translate(${ct+Ae/2}, 0)`,children:[l.jsx("rect",{x:-Ae/2,y:-6,width:Ae,height:12,fill:A.bg,stroke:A.border,strokeWidth:.5,rx:3}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:A.text,fontSize:9,fontFamily:"monospace",style:{pointerEvents:"none"},children:Ge})]},Ge)})})]},V.id)})]})]}),v&&!R.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:[((ue=e.find(V=>V.id===v.id))==null?void 0:ue.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(V=>V.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:W==="macro"?"#f59e0b":W==="micro"?"#22c55e":"#94a3b8",transition:"color 0.3s ease"},children:[W==="macro"&&"📍 Overview",W==="standard"&&"📍 Standard",W==="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(V=>{const A=o===V,$=V!=="global"&&!a,U=V==="global"?"🌐 All":V==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!$&&u(V),disabled:$,className:"px-2 py-1 text-[10px] font-medium cursor-pointer transition-all",style:{background:A?"rgba(22,163,106,0.3)":"transparent",color:$?"var(--terminal-text-muted)":A?"#4ade80":"var(--terminal-text-secondary)",opacity:$?.4:1,cursor:$?"not-allowed":"pointer"},title:$?"Select a node first":`Show ${V==="global"?"all nodes":`nodes within ${V}`}`,children:U},V)})}),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 EN(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,f="";for(let m=0;m<u.length-1;m++)if(f=f?`${f}/${u[m]}`:u[m],a.has(f))d=a.get(f).children;else{const h={type:"folder",name:u[m],path:f,children:[]};a.set(f,h),d.push(h),d=h.children}d.push({type:"file",name:u[u.length-1],path:o.id,doc:o})}),n}function NN({docs:e,onDocumentClick:n,selectedDocId:a,matchedIds:i}){const[o,u]=w.useState(new Set(["knowledge","projects","architecture","operations","company"])),[d,f]=w.useState(null),[m,h]=w.useState([]),[x,g]=w.useState(-1),v=w.useMemo(()=>EN(e),[e]),b=H=>{u(R=>{const I=new Set(R);return I.has(H)?I.delete(H):I.add(H),I})},j=H=>{f(H),n(H);const R=m.slice(0,x+1);R.push(H),R.length>10&&R.shift(),h(R),g(R.length-1)},k=()=>{f(null),n(null)},N=()=>{if(x>0){const H=x-1;g(H),f(m[H]),n(m[H])}},E=()=>{if(x<m.length-1){const H=x+1;g(H),f(m[H]),n(m[H])}},C=H=>{const R=m.indexOf(H);R!==-1&&(g(R),f(H),n(H))},_=H=>{H==="hub"&&k()},M=d?e.find(H=>H.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(H=>l.jsx(uv,{node:H,level:0,expandedFolders:o,selectedDocId:a,viewingDocId:d,onToggleFolder:b,onFileClick:j,matchedIds:i},H.path))]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:M?l.jsx(DN,{doc:M,onClose:k,onBreadcrumbClick:_,history:m,historyIndex:x,onHistoryBack:N,onHistoryForward:E,onHistoryJump:C,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 uv({node:e,level:n,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:f}){var b,j,k;const m=a.has(e.path),h=e.type==="file"&&e.path===i,x=e.type==="file"&&e.path===o,g=((b=e.doc)==null?void 0:b.akb_type)==="hub",v=e.type==="folder"||f===null||f.has(e.path);if(e.type==="folder"){const N=f===null||(((j=e.children)==null?void 0:j.some(E=>{if(E.type==="file")return f.has(E.path);const C=_=>{var M;return _.type==="file"?f.has(_.path):((M=_.children)==null?void 0:M.some(C))??!1};return C(E)}))??!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(E=>l.jsx(uv,{node:E,level:n+1,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:f},E.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":h?"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:g?"📘":"📄"}),l.jsx("span",{className:`text-[11px] truncate ${g?"font-semibold":""}`,style:{color:g?"#16a34a":"var(--terminal-text)"},children:e.name})]})}function AN(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,f=u[2].trim();let m=f.toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);const h=i.get(m)||0;i.set(m,h+1);const x=h>0?`${m}-${h}`:m;a.push({id:x,text:f,level:d})}return a}function DN({doc:e,onClose:n,onBreadcrumbClick:a,history:i,historyIndex:o,onHistoryBack:u,onHistoryForward:d,onHistoryJump:f,allDocs:m}){const[h,x]=w.useState(null),[g,v]=w.useState(!1),[b,j]=w.useState(null),k=w.useRef(null),[N,E]=w.useState(null);w.useEffect(()=>{if("content"in e&&e.content){x(e);return}v(!0),j(null),pe.getKnowledgeDoc(e.id).then(x).catch(D=>j(D instanceof Error?D.message:"Failed to load")).finally(()=>v(!1))},[e]);const C=w.useMemo(()=>!h||e.format==="html"?[]:AN(h.content),[h,e.format]),_=D=>{if(!k.current)return;const O=k.current.querySelectorAll("h2, h3");for(const B of O){const re=(B.textContent||"").toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(D.startsWith(re)){B.scrollIntoView({behavior:"smooth",block:"start"}),E(D);break}}},M=gN(e.category),H=e.akb_type==="hub",R=C.length>0&&!g&&!b,I=i.slice(0,o).reverse().filter(D=>D!==e.id).slice(0,3).map(D=>m.find(O=>O.id===D)).filter(D=>D!==void 0),W=o>0,Y=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:!W,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:!Y,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:I.map(D=>l.jsxs("button",{onClick:()=>f(D.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:D.title,children:["📄 ",D.title.length>15?D.title.slice(0,15)+"...":D.title]},D.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:H?"📘":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(D=>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:D},D))})]})]}),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:[g&&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}),h&&l.jsx(As,{content:h.content})]}),R&&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:C.map(D=>l.jsx("button",{onClick:()=>_(D.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(D.level-2)*8+8,color:N===D.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:N===D.id?"bold":"normal"},children:D.text.length>30?D.text.slice(0,28)+"..":D.text},D.id))})]})]})]})}const TN=500,qg=360,FN=700;function Ko(e,n,a){const i=n??TN,[o,u]=w.useState(i),[d,f]=w.useState(!1),m=w.useRef(0),h=w.useRef(0),x=w.useRef(a);x.current=a;const g=e>0,v=g?e:0,b=Math.max(FN,i),j=g?Math.max(qg,window.innerWidth-e-100):b,k=Math.min(o,j),N=w.useCallback(E=>{E.preventDefault(),m.current=E.clientX,h.current=k,f(!0);const C=()=>{f(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",C)},_=M=>{const H=m.current-M.clientX,R=h.current+H;if(R>=window.innerWidth*.6&&x.current){C(),x.current();return}const I=Math.min(b,Math.max(qg,R));u(I)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",C)},[k]);return{panelRight:v,panelWidth:k,isResizing:d,handleResizeStart:N}}function Yg({docs:e,onClose:n,onRefresh:a,terminalWidth:i=0,initialDocId:o,onMaximize:u}){const[d,f]=w.useState(()=>{const D=localStorage.getItem("kb-view-mode");return D==="graph"||D==="tree"||D==="list"?D:"graph"}),[m,h]=w.useState(null),[x,g]=w.useState("global"),[v,b]=w.useState(""),[j,k]=w.useState(()=>new Set(Object.keys(sa)));w.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const N=w.useMemo(()=>new Ds(e,{keys:["title","tldr","tags"],threshold:.3,includeScore:!0}),[e]),E=w.useMemo(()=>{let D=new Set(e.map(O=>O.id));if(v.trim()){const O=N.search(v);D=new Set(O.map(B=>B.item.id))}return D=new Set(Array.from(D).filter(O=>{const B=e.find(ee=>ee.id===O);return B&&j.has(B.category)})),D.size===e.length?null:D},[e,v,N,j]),C=w.useMemo(()=>E===null?e:e.filter(D=>E.has(D.id)),[e,E]),_=D=>{k(O=>{const B=new Set(O);return B.has(D)?B.delete(D):B.add(D),B})},{panelRight:M,panelWidth:H,isResizing:R,handleResizeStart:I}=Ko(i,void 0,u),W=D=>{h(D.id)},Y=m?e.find(D=>D.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)] ${R?"resizing":""}`,style:{right:M,width:H,background:"var(--terminal-bg)",borderLeftColor:"#16a34a"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${R?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:I}),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(Dh,{icon:"🕸️",label:"Graph",active:d==="graph",onClick:()=>f("graph")}),l.jsx(Dh,{icon:"🌲",label:"Tree",active:d==="tree",onClick:()=>{f("tree"),h(null)}}),l.jsx(Dh,{icon:"📋",label:"List",active:d==="list",onClick:()=>{f("list"),h(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:D=>b(D.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(sa).map(([D,O])=>{const B=j.has(D);return l.jsx("button",{onClick:()=>_(D),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:B?O.bg:"transparent",color:B?O.text:"var(--terminal-text-muted)",border:`1px solid ${B?O.border:"var(--terminal-border)"}`,opacity:B?1:.5},children:D},D)})}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:C.length===e.length?`${e.length} documents`:`${C.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(CN,{docs:e,onNodeClick:W,selectedDocId:m,matchedIds:E,localGraphMode:x,onLocalModeChange:g}),Y&&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:Y.title}),l.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:Y.status==="active"?"#16a34a":Y.status==="draft"?"#f59e0b":"#94a3b8"}}),Y.tldr&&l.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:Y.tldr}),Y.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"}),Y.links.slice(0,5).map((D,O)=>l.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",D.text]},O))]})]})]}),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(sa).map(([D,O])=>l.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[l.jsx("div",{className:"w-2 h-2",style:{background:O.border}}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:D})]},D))})})]}),d==="tree"&&l.jsx(NN,{docs:e,onDocumentClick:D=>h(D),selectedDocId:m,matchedIds:E}),d==="list"&&l.jsx(RN,{icon:"📋",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"})]})]})}function Dh({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 RN({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 Xg({waves:e,decisions:n,mode:a,onClose:i,onOpenWaveCenter:o,onUpdateDecision:u,onDeleteDecision:d,terminalWidth:f=0,onMaximize:m}){const[h,x]=w.useState("decisions"),{panelRight:g,panelWidth:v,isResizing:b,handleResizeStart:j}=Ko(f,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:g},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:g,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(Th,{label:`Decisions (${n.length})`,active:h==="decisions",onClick:()=>x("decisions")}),o?l.jsx(Th,{label:"Waves →",active:!1,onClick:o}):l.jsx(Th,{label:`Waves (${e.length})`,active:h==="waves",onClick:()=>x("waves")})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[h==="decisions"&&(n.length>0?n.map(k=>l.jsx(MN,{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"})),h==="waves"&&e.map((k,N)=>l.jsx(zN,{title:`Wave ${k.id}`,subtitle:k.startedAt,content:k.directive},N))]})]})]})}function MN({decision:e,onSave:n,onDelete:a}){const[i,o]=w.useState(!1),[u,d]=w.useState(!1),[f,m]=w.useState(e.content),[h,x]=w.useState(!1),g=dv(e.content).slice(0,160),v=e.content.length>100,b=w.useCallback(async()=>{if(!n||f===e.content){d(!1);return}x(!0);try{await n(e.id,f),d(!1)}finally{x(!1)}},[n,f,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:f,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:h,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:h,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:h||f===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:h?"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(As,{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:g})]})}function Th({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 dv(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 zN({title:e,subtitle:n,content:a}){const[i,o]=w.useState(!1),u=a.length>100,d=dv(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(As,{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 js=[{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"}}],xm=[{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"]}],_N={completedQuests:[],activeChapter:1,sideQuestsCompleted:[]};function Wg(){return{..._N}}function gm(e,n){return n.completedQuests.includes(e.id)?"completed":"active"}function fv(e){return js.filter(n=>gm(n,e)==="active")}function BN(e){const n=fv(e);return n.find(i=>i.chapter===e.activeChapter)??n[0]??null}function ON(e,n){const a=js.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 Vg(e){let n=1;for(const a of xm)if(a.questIds.every(i=>e.completedQuests.includes(i))){const i=xm.find(o=>o.num===a.num+1);i&&(n=i.num)}return n!==e.activeChapter?{...e,activeChapter:n}:e}function $N(e){const n=js.filter(i=>i.type==="main").length;return{completed:e.completedQuests.filter(i=>{var o;return((o=js.find(u=>u.id===i))==null?void 0:o.type)==="main"}).length,total:n}}function LN(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 IN({progress:e,onQuestAction:n,onClose:a,terminalWidth:i=0}){const{completed:o,total:u}=$N(e),d=u>0?Math.round(o/u*100):0,{panelRight:f,panelWidth:m,isResizing:h,handleResizeStart:x}=Ko(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:f},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)] ${h?"resizing":""}`,style:{right:f,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 ${h?"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:xm.map(g=>{const v=js.filter(k=>g.questIds.includes(k.id)),b=v.every(k=>e.completedQuests.includes(k.id)),j=v.some(k=>gm(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 ",g.num,": ",g.title]})]}),l.jsx("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:v.map(k=>{const N=gm(k,e);return l.jsxs("div",{className:"flex items-start gap-2 pl-2",children:[l.jsx("span",{className:"text-xs mt-0.5 shrink-0",children:N==="completed"?"☑":"☐"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs",style:{color:N==="completed"?"var(--terminal-text-muted)":"var(--terminal-text)",textDecoration:N==="completed"?"line-through":"none"},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)})})]},g.num)})})]})]})}function HN({projectId:e,onClose:n,terminalWidth:a=0}){const[i,o]=w.useState(null),{panelRight:u,panelWidth:d,isResizing:f,handleResizeStart:m}=Ko(a);if(w.useEffect(()=>{pe.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 h=i.tasks.filter(v=>v.status==="done").length,x=i.tasks.length,g=x>0?Math.round(h/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)] ${f?"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 ${f?"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: ",h]}),l.jsxs("span",{children:["Progress: ",g,"%"]})]}),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:`${g}%`}})})]}),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(As,{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(UN,{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 UN({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 qN={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function YN({roleId:e,roleName:n,mode:a="assign",onClose:i,onExecutionStart:o}){const[u,d]=w.useState(""),f=w.useRef(null);w.useEffect(()=>{var g;(g=f.current)==null||g.focus()},[]);const m=()=>{u.trim()&&(o(e,u.trim()),i())},h=g=>{g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&m(),g.key==="Escape"&&i()},x=qN[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:f,value:u,onChange:g=>d(g.target.value),onKeyDown:h,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 Gg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function Qm({event:e,isThinkingCollapsed:n,onToggleThinking:a,onNavigateToJob:i,onOpenKnowledgeDoc:o,compact:u}){var f;const d=Gg[e.roleId]??"#888";switch(e.type){case"text":{const m=e.data.text??"",h=u?m.slice(0,300):m;return/[#*|`\[\]_~>-]/.test(h)?l.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:l.jsx(Im,{remarkPlugins:[Ym],children:h})}):l.jsx("div",{className:"text-green-300/90 whitespace-pre-wrap leading-relaxed",children:h})}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??""),h=e.data.input,x=typeof(h==null?void 0:h.command)=="string"?h.command.slice(0,80):"",g=typeof(h==null?void 0:h.file_path)=="string"?String(h.file_path):typeof(h==null?void 0:h.path)=="string"?String(h.path):"",v=g?g.split("/").pop()??"":"",b=/^(write_file|Write|edit_file|Edit)$/i.test(m),j=(f=g.match(/(?:^|\/)knowledge\/(.+\.md)$/))==null?void 0:f[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??"",h=e.data.task??"",x=e.data.childJobId,g=Gg[m]??"#888";return l.jsx("div",{className:"my-1 p-2 rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",style:{borderColor:`${g}44`,background:`${g}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:g},className:"font-bold text-[11px]",children:["→"," ",m.toUpperCase()]}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] text-[10px] truncate flex-1",children:h.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,h=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 · ",h," 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 XN({sessionId:e,title:n,color:a,variant:i,style:o,onClose:u,onMinimize:d,onDone:f,onNavigateToJob:m,onOpenKnowledgeDoc:h}){const{events:x,status:g,textOutput:v,childJobIds:b}=Fy(e),[j,k]=w.useState(0),[N,E]=w.useState(new Set),C=w.useRef(null),_=w.useRef(Date.now()),M=w.useRef(!1);w.useEffect(()=>{const O=setInterval(()=>{k(Math.floor((Date.now()-_.current)/1e3))},1e3);return()=>clearInterval(O)},[]),w.useEffect(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[x]),w.useEffect(()=>{(g==="done"||g==="error")&&!M.current&&(M.current=!0,f==null||f())},[g,f]);const H=O=>{E(B=>{const ee=new Set(B);return ee.has(O)?ee.delete(O):ee.add(O),ee})},R={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[g],I={idle:"#888",connecting:"#888",streaming:a,done:"#2E7D32",error:"#C62828"}[g],W=O=>`${Math.floor(O/60)}:${String(O%60).padStart(2,"0")}`,Y=g==="done"||g==="error",D=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:I}}),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:W(j)}),l.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${I}22`,color:I},children:R}),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:"–"}),Y&&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:C,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono",children:[x.length===0&&g==="connecting"&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:"Connecting to activity stream..."}),x.map(O=>l.jsx(Qm,{event:O,isThinkingCollapsed:N.has(O.seq),onToggleThinking:()=>H(O.seq),onNavigateToJob:m,onOpenKnowledgeDoc:h},O.seq)),g==="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`]}),Y&&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:Y?u:void 0}),D]}):D}const WN={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function VN({orgNodes:e,rootId:n,activeRoles:a,onToggleRole:i}){const o=e[n];if(!o)return null;const u=!!a&&!!i,f=o.children.map(b=>e[b]).filter(Boolean),m=new Map,h=[];for(const b of f){const j=[];for(const k of b.children){const N=e[k];N&&(j.push(N),h.push(N))}m.set(b.id,j)}const x=b=>!a||a.has(b),g=u?f.filter(b=>a.has(b.id)).length+h.filter(b=>a.has(b.id)).length:f.length+h.length,v=f.length+h.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:[g,"/",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"})}),f.length>0&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-3 bg-white/15"})}),f.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(f.length*80,320)}px`}})}),l.jsx("div",{className:"flex justify-center gap-3 mb-2 flex-wrap",children:f.map(b=>{const j=x(b.id),k=WN[b.id]??"#888";return l.jsx(GN,{node:b,active:j,color:k,interactive:u,onToggle:i,subRoles:m.get(b.id)??[],activeRoles:a},b.id)})}),h.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:h.map(b=>{var C;const j=x(b.id),k=(C=f.find(_=>_.children.includes(b.id)))==null?void 0:C.id,N=k?x(k):!0,E=u&&N;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${E?"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:E?()=>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?`${g} role${g!==1?"s":""} will receive this wave`:`${v} role${v!==1?"s":""} will receive this wave`})]})}function GN({node:e,active:n,color:a,interactive:i,onToggle:o,subRoles:u,activeRoles:d}){const f=w.useCallback(m=>{if(!(!i||!o)){if(n){o(e.id,!1);for(const h of u)d!=null&&d.has(h.id)&&o(h.id,!1)}else if(o(e.id,!0),m.shiftKey)for(const h of u)d!=null&&d.has(h.id)||o(h.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:f,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 KN({cLevelRoles:e,orgNodes:n,rootId:a,onClose:i,onDispatch:o}){const[u,d]=w.useState(""),f=w.useRef(null),[m,h]=w.useState(()=>{const k=new Set,N=n[a];if(N)for(const E of N.children){k.add(E);const C=n[E];if(C)for(const _ of C.children)k.add(_)}return k});w.useEffect(()=>{var k;(k=f.current)==null||k.focus()},[]);const x=w.useCallback((k,N)=>{h(E=>{const C=new Set(E);return N?C.add(k):C.delete(k),C})},[]),g=e.filter(k=>m.has(k.id)).length,v=()=>{if(!u.trim()||g===0)return;const k=n[a];let N=0;if(k)for(const _ of k.children){N++;const M=n[_];M&&(N+=M.children.length)}const C=m.size>=N?void 0:Array.from(m);o(u.trim(),C),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(VN,{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:f,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()||g===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 ",g," Role",g!==1?"s":""]})]})]})]})}function PN(){const e=w.useRef(null),n=w.useRef(0),a=w.useCallback((o,u,d)=>{e.current&&e.current.abort();const f=new AbortController;e.current=f,n.current=0;const h=`/api/waves/${o}/stream?from=0`;fetch(h,{signal:f.signal}).then(async x=>{if(!x.ok||!x.body){console.error(`[WaveStream] Failed to connect: ${x.status}`);return}console.log(`[WaveStream] Connected to wave=${o}`);const g=x.body.getReader(),v=new TextDecoder;let b="",j="",k=Date.now();const N=6e4,E=setInterval(()=>{Date.now()-k>N&&(console.warn("[WaveStream] Stale connection — no data for 60s"),f.abort(),clearInterval(E))},1e4);try{for(;;){const{done:C,value:_}=await g.read();if(C)break;k=Date.now(),b+=v.decode(_,{stream:!0});const M=b.split(`
|
|
83
|
+
`);b=M.pop()??"";for(const H of M)if(H.startsWith("event: "))j=H.slice(7).trim();else if(H.startsWith("data: ")){try{const R=JSON.parse(H.slice(6));QN(j,R,u,d)}catch{}j=""}}}finally{clearInterval(E)}}).catch(x=>{x.name!=="AbortError"&&console.error("[WaveStream] Connection error:",x)})},[]),i=w.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{connectWaveStream:a,disconnectWaveStream:i}}function QN(e,n,a,i){switch(e){case"wave:event":ZN(n,a);break;case"wave:role-attached":JN(n,a,i);break;case"wave:role-detached":e6(n,a);break;case"wave:done":t6(a);break}}function ZN(e,n){const{event:a,sessionId:i}=e,{roleId:o}=a;n(u=>{const d=new Map(u),f=d.get(o);if(!f||f.events.some(h=>h.seq===a.seq&&h.roleId===a.roleId))return u;const m={...f,sessionId:i||f.sessionId,events:[...f.events,a]};return a.type==="job:start"?(m.status="running",m.streamStatus="streaming"):a.type==="job:done"?(m.status="done",m.streamStatus="done"):a.type==="job:error"?(m.status="error",m.streamStatus="error"):a.type==="job:awaiting_input"?(m.status="awaiting_input",m.streamStatus="done"):a.type==="job:reply"&&(m.status="running",m.streamStatus="streaming"),d.set(o,m),d})}function JN(e,n,a){const{sessionId:i,roleId:o,jobId:u}=e;n(d=>{const f=new Map(d),m=f.get(o);if(m)f.set(o,{...m,sessionId:i,jobId:u||m.jobId,status:"running",streamStatus:"streaming"});else{const h=a[o];f.set(o,{sessionId:i,jobId:u,roleId:o,roleName:(h==null?void 0:h.name)??o,children:(h==null?void 0:h.children)??[],status:"running",events:[],streamStatus:"streaming"})}return f})}function e6(e,n){const{roleId:a,reason:i}=e,o=i==="error"?"error":"done";n(u=>{const d=new Map(u),f=d.get(a);return!f||f.status==="done"||f.status==="error"?u:(d.set(a,{...f,status:o,streamStatus:o==="error"?"error":"done"}),d)})}function t6(e){e(n=>{const a=new Map(n);let i=!1;for(const[o,u]of a)u.status==="waiting"&&(a.set(o,{...u,status:"not-dispatched"}),i=!0);return i?a:n})}function hv(e,n,a,i){const[o,u]=w.useState(new Map),[d,f]=w.useState(null),[m,h]=w.useState(new Set),x=w.useRef(new Map),g=w.useRef(o);g.current=o;const v=w.useRef(!1),{connectWaveStream:b,disconnectWaveStream:j}=PN(),k=w.useCallback(()=>{if(!a||Object.keys(n).length===0)return null;const D=new Map,O=new Set,B=re=>{const K=n[re];K&&(O.add(re),D.set(re,{sessionId:"",roleId:re,roleName:K.name,children:K.children,status:"waiting",events:[],streamStatus:"idle"}),K.children.forEach(B))},ee=n[a];return ee&&(D.set(a,{sessionId:"",roleId:a,roleName:"CEO",children:ee.children,status:"not-dispatched",events:[],streamStatus:"idle"}),ee.children.forEach(B)),{initial:D,allRoles:O}},[n,a]);w.useEffect(()=>{if(v.current)if(e.length>0)v.current=!1;else return;const D=k();if(!D)return;const{initial:O,allRoles:B}=D;for(const ee of e){const re=O.get(ee.roleId);re&&(re.sessionId=ee.sessionId,re.jobId=ee.jobId,re.status="running",re.streamStatus="connecting")}u(O),h(ee=>{if(ee.size===0){const re=new Set(B);return re.delete(a),re}return ee}),e.length>0&&f(ee=>ee??e[0].roleId)},[e,n,a,k]);const N=w.useCallback(D=>{h(O=>{const B=new Set(O);return B.has(D)?B.delete(D):B.add(D),B})},[]),E=w.useCallback(D=>{for(const[,O]of x.current)O.controller.abort();x.current.clear(),v.current=!0,u(D);for(const[O,B]of D)if(O!==a&&B.events.length>0){f(O);break}},[a]),C=w.useCallback((D,O)=>{const B=x.current.get(D);if(B&&!B.controller.signal.aborted){console.log(`[WaveTree] connectStream SKIP (already connected) → role=${O} session=${D}`);return}B&&B.controller.abort(),console.log(`[WaveTree] connectStream → role=${O} session=${D}`),u(q=>{const ce=new Map(q),ue=ce.get(O);return ue&&ce.set(O,{...ue,sessionId:D,status:"running",streamStatus:"connecting",events:[]}),ce});const ee=new AbortController,re={controller:ee,lastSeq:-1};x.current.set(D,re);const K=`/api/sessions/${D}/stream?from=0`;fetch(K,{signal:ee.signal}).then(async q=>{if(!q.ok||!q.body){u($=>{const U=new Map($),T=U.get(O);return T&&U.set(O,{...T,streamStatus:"error"}),U});return}console.log(`[WaveTree SSE] connected → role=${O} status=${q.status}`),u($=>{const U=new Map($),T=U.get(O);return T&&U.set(O,{...T,streamStatus:"streaming",status:"running"}),U});const ce=q.body.getReader(),ue=new TextDecoder;let V="",A="";for(;;){const{done:$,value:U}=await ce.read();if($)break;V+=ue.decode(U,{stream:!0});const T=V.split(`
|
|
84
|
+
`);V=T.pop()??"";for(const se of T)if(se.startsWith("event: "))A=se.slice(7).trim();else if(se.startsWith("data: ")){try{const ke=JSON.parse(se.slice(6));if(console.log(`[WaveTree SSE] role=${O} event=${A} type=${(ke==null?void 0:ke.type)??"?"} seq=${(ke==null?void 0:ke.seq)??"?"}`),A==="activity"){const he=ke;he.seq>re.lastSeq&&(re.lastSeq=he.seq),u(_e=>{const Le=new Map(_e),Ue=Le.get(O);if(!Ue||Ue.events.some(Pe=>Pe.seq===he.seq))return _e;const et={...Ue,events:[...Ue.events,he]};if(he.type==="dispatch:start"&&he.data.childJobId){const Pe=he.data.targetRoleId??he.data.roleId,Ge=he.data.childSessionId;if(console.log(`[WaveTree] dispatch:start → target=${Pe} childSession=${Ge??"none"} from=${O}`),Pe&&Ge){const Ce=Le.get(Pe);Ce&&(Le.set(Pe,{...Ce,sessionId:Ge,status:"running",streamStatus:"connecting"}),setTimeout(()=>C(Ge,Pe),0))}}return he.type==="job:done"?(et.status="done",et.streamStatus="done"):he.type==="job:error"?(et.status="error",et.streamStatus="error"):he.type==="job:awaiting_input"?(et.status="awaiting_input",et.streamStatus="done"):he.type==="job:reply"&&(et.status="running",et.streamStatus="streaming"),Le.set(O,et),Le})}else if(A==="stream:end"){const he=ke.reason;he!=="replied"&&u(_e=>{const Le=new Map(_e),Ue=Le.get(O);if(!Ue)return _e;const et=he==="error"?"error":he==="awaiting_input"?"awaiting_input":"done";return Le.set(O,{...Ue,status:Ue.status==="running"?et:Ue.status,streamStatus:et==="error"?"error":"done"}),Le})}}catch{}A=""}}}).catch(q=>{q.name!=="AbortError"&&u(ce=>{const ue=new Map(ce),V=ue.get(O);return V&&ue.set(O,{...V,streamStatus:"error"}),ue})})},[]),_=w.useRef(new Set),M=w.useRef(!1),H=w.useRef(n);H.current=n;const R=w.useRef(e);R.current=e,w.useEffect(()=>{if(!(!i||R.current.length===0))return M.current=!0,b(i,u,H.current),()=>{j(),M.current=!1}},[i,b,j]),w.useEffect(()=>{if(i||e.length===0)return;M.current=!1;const D=new Set;for(const O of e)D.add(O.sessionId),C(O.sessionId,O.roleId);return _.current=D,()=>{for(const O of _.current){const B=x.current.get(O);B&&(B.controller.abort(),x.current.delete(O))}_.current.clear()}},[e,C,i]);const I=(()=>{let D=0,O=0,B=0,ee=0;for(const[re,K]of o)re!==a&&(ee++,K.status==="done"?D++:K.status==="running"?O++:K.status==="awaiting_input"&&B++);return{done:D,total:ee,running:O,awaitingInput:B}})(),W=I.total>0&&I.done>0&&I.running===0&&I.awaitingInput===0&&Array.from(o.values()).every(D=>!il(D.status)&&D.streamStatus!=="streaming"&&D.streamStatus!=="connecting");w.useEffect(()=>{W&&u(D=>{const O=new Map(D);let B=!1;for(const[ee,re]of O)re.status==="waiting"&&(O.set(ee,{...re,status:"not-dispatched"}),B=!0);return B?O:D})},[W]);const Y=w.useCallback(()=>{for(const[,O]of x.current)O.controller.abort();x.current.clear(),v.current=!1;const D=k();if(D){u(D.initial);const O=new Set(D.allRoles);O.delete(a),h(O)}f(a)},[k,a]);return{nodes:o,selectedRoleId:d,selectNode:f,checkedRoles:m,toggleCheck:N,setCheckedRoles:h,progress:I,allDone:W,connectStream:C,injectStaticNodes:E,reset:Y}}const Kg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},Ca=130,Qr=44,Pg=80;function n6(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:g,parentId:v}=u.shift();if(d.has(x))continue;for(d.add(x);o.length<=g;)o.push([]);o[g].push(x),i.push({roleId:x,x:0,y:g*Pg+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:g+1,parentId:x})}const f=Math.max(...o.map(x=>x.length))*(Ca+16),m=Math.max(f,280);for(const x of o){const g=x.length*(Ca+16)-16,v=(m-g)/2;x.forEach((b,j)=>{const k=i.find(N=>N.roleId===b);k&&(k.x=v+j*(Ca+16))})}const h=o.length*Pg+40;return{layout:i,width:m,height:h}}function mv({nodes:e,rootId:n,selectedRoleId:a,onSelectNode:i,checkedRoles:o,onToggleCheck:u,eligibleRoles:d}){const{layout:f,width:m,height:h}=n6(e,n),x=!!u,g=b=>{const j=f.find(k=>k.roleId===b);return j?{cx:j.x+Ca/2,cy:j.y+Qr/2}:{cx:0,cy:0}},v=b=>{switch(b.status){case"running":return Kg[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} ${h}`,width:Math.max(m,280),height:h,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"})]})]})}),f.filter(b=>b.parentId).map(b=>{const j=g(b.parentId),k=g(b.roleId),N=e.get(b.roleId),E=e.get(b.parentId);let C="rgba(180,200,240,0.15)",_="4 4",M="";return(N==null?void 0:N.status)==="done"||(E==null?void 0:E.status)==="done"?(C="#2E7D3266",_=""):(N==null?void 0:N.status)==="awaiting_input"?(C="#F59E0B",_="6 4",M="wave-edge-flow"):(N==null?void 0:N.status)==="running"&&(C=Kg[b.roleId]??"#FBBF24",_="6 4",M="wave-edge-flow"),l.jsx("line",{x1:j.cx,y1:j.cy+Qr/2-4,x2:k.cx,y2:k.cy-Qr/2+4,stroke:C,strokeWidth:1.5,strokeDasharray:_,className:M},`${b.parentId}-${b.roleId}`)}),f.map(b=>{const j=e.get(b.roleId);if(!j)return null;const k=v(j),N=a===b.roleId,E=b.roleId===n,C=(o==null?void 0:o.has(b.roleId))??!1,_=E?N?.7:.5:j.status==="not-dispatched"&&!C?.35:1;return l.jsxs("g",{transform:`translate(${b.x}, ${b.y})`,style:{cursor:"pointer",opacity:_},onClick:()=>i(b.roleId),children:[l.jsx("rect",{x:0,y:0,width:Ca,height:Qr,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:N?"#fff":C?"#EF5350":k,strokeWidth:N||C?2:1.5,strokeDasharray:j.status==="not-dispatched"&&!C?"4 3":""}),l.jsx("circle",{cx:14,cy:Qr/2,r:4,fill:k,filter:il(j.status)?"url(#glow)":void 0,children:il(j.status)&&l.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),l.jsx("text",{x:26,y:Qr/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:Qr/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"?j.children.some(M=>{const H=e.get(M);return H&&il(H.status)})?"Supervising...":"Complete":j.status==="error"?"Error":j.status==="waiting"?"Waiting":""}),j.status==="done"&&!x&&l.jsx("text",{x:Ca-18,y:Qr/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),j.status==="error"&&!x&&l.jsx("text",{x:Ca-18,y:Qr/2+4,fontSize:14,fill:"#C62828",children:"✗"}),x&&!E&&(()=>{const M=!d||d.has(b.roleId);return l.jsxs("g",{onClick:H=>{H.stopPropagation(),M&&(u==null||u(b.roleId))},style:{cursor:M?"pointer":"default",opacity:M?1:.2},children:[l.jsx("rect",{x:Ca-24,y:Qr/2-10,width:20,height:20,fill:"transparent"}),l.jsx("rect",{x:Ca-20,y:Qr/2-6,width:12,height:12,rx:2,ry:2,fill:C?"#EF5350":"transparent",stroke:C?"#EF5350":"#666",strokeWidth:1.5}),C&&l.jsx("text",{x:Ca-18,y:Qr/2+4,fontSize:10,fontWeight:700,fill:"#fff",children:"✓"})]})})()]},b.roleId)})]})}const r6={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function a6({directive:e,rootJobs:n,orgNodes:a,rootRoleId:i,waveId:o,onClose:u,onMinimize:d,onDone:f,onOpenKnowledgeDoc:m,onSave:h}){const{nodes:x,selectedRoleId:g,selectNode:v,progress:b,allDone:j,connectStream:k}=hv(n,a,i,o),[N,E]=w.useState(0),[C,_]=w.useState(new Set),[M,H]=w.useState(""),[R,I]=w.useState(!1),[W,Y]=w.useState(!1),D=w.useRef(null),O=w.useRef(Date.now()),B=w.useRef(!1),ee=w.useCallback(async()=>{if(h){Y(!0);try{const U=n.map(T=>T.jobId).filter(T=>!!T);await h(U)}catch(U){console.error("Save failed:",U)}finally{Y(!1),u()}}},[h,n,u]),re=w.useCallback(async()=>{if(!g||!M.trim())return;const U=x.get(g);if(!(!(U!=null&&U.sessionId)||U.status!=="awaiting_input"&&U.status!=="done")){I(!0);try{await pe.replyToSession(U.sessionId,M.trim()),H(""),k(U.sessionId,g)}catch(T){console.error("Reply failed:",T)}finally{I(!1)}}},[g,M,x,k]),K=w.useCallback(async U=>{const T=x.get(U);if(T)try{T.sessionId?await pe.abortSession(T.sessionId):T.jobId&&await pe.abortJob(T.jobId)}catch{if(T.jobId)try{await pe.abortJob(T.jobId)}catch{}}},[x]),q=w.useCallback(async()=>{for(const[,U]of x)if(il(U.status))try{U.sessionId?await pe.abortSession(U.sessionId):U.jobId&&await pe.abortJob(U.jobId)}catch{if(U.jobId)try{await pe.abortJob(U.jobId)}catch{}}},[x]);w.useEffect(()=>{const U=setInterval(()=>{E(Math.floor((Date.now()-O.current)/1e3))},1e3);return()=>clearInterval(U)},[]);const ce=w.useRef(!1);w.useEffect(()=>{const U=D.current;if(!U)return;const T=()=>{const se=U.scrollHeight-U.scrollTop-U.clientHeight<60;ce.current=!se};return U.addEventListener("scroll",T),()=>U.removeEventListener("scroll",T)},[]),w.useEffect(()=>{ce.current=!1,D.current&&(D.current.scrollTop=D.current.scrollHeight)},[g]),w.useEffect(()=>{D.current&&!ce.current&&(D.current.scrollTop=D.current.scrollHeight)},[x]),w.useEffect(()=>{j&&!B.current&&(B.current=!0,f==null||f()),!j&&B.current&&(B.current=!1)},[j,f]);const ue=U=>`${Math.floor(U/60)}:${String(U%60).padStart(2,"0")}`,V=g?x.get(g):null,A=g?r6[g]??"#888":"#888",$=U=>{_(T=>{const se=new Set(T);return se.has(U)?se.delete(U):se.add(U),se})};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:j?"#2E7D32":"#B71C1C",animation:j?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:j?"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(N)}),b.awaitingInput>0&&l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[b.awaitingInput," awaiting reply"]}),l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:j?"#2E7D3222":"#B71C1C22",color:j?"#2E7D32":"#B71C1C"},children:[b.done,"/",b.total," done"]}),!j&&(b.running>0||b.awaitingInput>0)&&l.jsx("button",{onClick:q,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:d,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),l.jsx("button",{onClick:u,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",title:j?"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(U=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:U.color,animation:U.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:U.label})]},U.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"35vh"},children:l.jsx(mv,{nodes:x,rootId:i,selectedRoleId:g,onSelectNode:v})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[V&&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:A}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:V.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:V.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:V.status==="awaiting_input"?"#F59E0B22":`${A}22`,color:V.status==="awaiting_input"?"#F59E0B":A},children:V.status==="running"?"Working":V.status==="done"?"Complete":V.status==="error"?"Error":V.status==="waiting"?"Waiting":V.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),il(V.status)&&V.sessionId&&l.jsx("button",{onClick:()=>K(V.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:D,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[V&&V.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:V.status==="waiting"?"Waiting for dispatch...":V.status==="running"?"Connecting to activity stream...":V.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),V==null?void 0:V.events.map(U=>l.jsx(Qm,{event:U,isThinkingCollapsed:C.has(U.seq),onToggleThinking:()=>$(U.seq),onNavigateToJob:T=>{const se=V==null?void 0:V.events.find(he=>he.type==="dispatch:start"&&he.data.childJobId===T),ke=se==null?void 0:se.data.targetRoleId;ke&&x.has(ke)&&v(ke)},onOpenKnowledgeDoc:m},U.seq)),(V==null?void 0:V.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(V==null?void 0:V.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:[V.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:M,onChange:U=>H(U.target.value),onKeyDown:U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),re())},placeholder:"Type your response...",disabled:R,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:re,disabled:R||!M.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:R?"...":"Reply"})]})]}),(V==null?void 0:V.status)==="done"&&V.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 ",V.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:M,onChange:U=>H(U.target.value),onKeyDown:U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),re())},placeholder:"e.g., 좋아 KB-3 진행해, Engineer에게 시켜...",disabled:R,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:re,disabled:R||!M.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:R?"...":"Send"})]})]}),!V&&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:V&&V.events.length>0&&`${V.events.length} events`}),j&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:u,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"}),h&&l.jsx("button",{onClick:ee,disabled:W,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:W?"Saving...":"Save Wave"})]})]})]})]})]})]})}const l6={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function Qg({orgNodes:e,rootRoleId:n,cLevelRoles:a,pastWaves:i,activeWaves:o,onDispatch:u,onClose:d,onDone:f,onSave:m,onOpenKnowledgeDoc:h,onRefreshWaves:x,terminalWidth:g=0,onMaximize:v,inline:b=!1,onOpenSaveModal:j}){const[k,N]=w.useState(""),[E,C]=w.useState(null),[_,M]=w.useState(!1),[H,R]=w.useState(o.length>0?0:-1),[,I]=w.useState(!1),W=w.useRef(null),Y=H>=0?o[H]??null:null,D=w.useMemo(()=>[],[]),O=(Y==null?void 0:Y.rootJobs)??D,B=hv(O,e,n,(Y==null?void 0:Y.id)??null);w.useEffect(()=>{if(E){const ne=i6(e,n,E.roles);B.injectStaticNodes(ne);for(const Me of E.roles??[])if(Ty(Me.status)&&Me.jobId){const Ve=ne.get(Me.roleId);Ve!=null&&Ve.sessionId&&setTimeout(()=>B.connectStream(Ve.sessionId,Me.roleId),100)}}},[E,e,n]),w.useEffect(()=>{!B.selectedRoleId&&n&&B.selectNode(n)},[n]);const ee=w.useRef(o.length);w.useEffect(()=>{const ne=o.length>ee.current;ee.current=o.length,ne&&(R(0),C(null),I(!1))},[o.length]);const[re,K]=w.useState(null),q=w.useMemo(()=>{if(!re)return null;const ne=re.modified.length+re.untracked.length;return{branch:re.branch,dirty:ne>0,count:ne}},[re]),ce=w.useCallback(()=>{pe.getSaveStatus("code").then(ne=>{K({dirty:ne.modified.length+ne.untracked.length>0,modified:ne.modified,untracked:ne.untracked,lastCommit:ne.lastCommit,branch:ne.branch})}).catch(()=>{})},[]);w.useEffect(()=>{ce()},[ce]);const[ue,V]=w.useState(0);w.useEffect(()=>{if(!Y)return;const ne=setInterval(()=>{V(Math.floor((Date.now()-Y.startedAt)/1e3))},1e3);return()=>clearInterval(ne)},[Y]);const[A,$]=w.useState(""),[U,T]=w.useState(!1),[se,ke]=w.useState([]),[he,_e]=w.useState(!1),[Le,Ue]=w.useState(null),et=w.useRef(null);w.useEffect(()=>{if(Le){const ne=setTimeout(()=>Ue(null),3e3);return()=>clearTimeout(ne)}},[Le]);const Pe=w.useCallback(async ne=>["image/png","image/jpeg","image/gif","image/webp"].includes(ne.type)?ne.size>5*1024*1024?(Ue(`Too large: ${(ne.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(Ve=>{const Ze=new FileReader;Ze.onload=()=>{const Sn=Ze.result.split(",")[1];Ve({type:"image",data:Sn,name:ne.name,mediaType:ne.type})},Ze.onerror=()=>{Ue("Failed to read file"),Ve(null)},Ze.readAsDataURL(ne)}):(Ue(`Unsupported: ${ne.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),Ge=w.useCallback(async ne=>{const Me=[];for(const Ve of Array.from(ne)){const Ze=await Pe(Ve);Ze&&Me.push(Ze)}Me.length>0&&ke(Ve=>[...Ve,...Me])},[Pe]),Ce=w.useCallback(ne=>{ne.preventDefault(),ne.stopPropagation(),_e(!0)},[]),Ae=w.useCallback(ne=>{ne.preventDefault(),ne.stopPropagation(),_e(!1)},[]),yt=w.useCallback(ne=>{ne.preventDefault(),ne.stopPropagation(),_e(!1),ne.dataTransfer.files.length>0&&Ge(ne.dataTransfer.files)},[Ge]),ct=w.useCallback(ne=>{const Me=[];for(let Ve=0;Ve<ne.clipboardData.items.length;Ve++){const Ze=ne.clipboardData.items[Ve];if(Ze.type.startsWith("image/")){const Sn=Ze.getAsFile();Sn&&Me.push(Sn)}}Me.length>0&&(ne.preventDefault(),Ge(Me))},[Ge]),[xt,Ct]=w.useState(320),Ht=w.useRef(!1),zt=w.useRef(0),jt=w.useRef(0),Hn=w.useCallback(ne=>{ne.preventDefault(),Ht.current=!0,zt.current=ne.clientX,jt.current=xt;const Me=Ze=>{if(!Ht.current)return;const Sn=zt.current-Ze.clientX;Ct(Math.max(200,Math.min(500,jt.current+Sn)))},Ve=()=>{Ht.current=!1,window.removeEventListener("mousemove",Me),window.removeEventListener("mouseup",Ve)};window.addEventListener("mousemove",Me),window.addEventListener("mouseup",Ve)},[xt]),[me,je]=w.useState(new Set),Ne=w.useRef(null),G=w.useRef(!1);w.useEffect(()=>{const ne=Ne.current;if(!ne)return;const Me=()=>{const Ve=ne.scrollHeight-ne.scrollTop-ne.clientHeight<60;G.current=!Ve};return ne.addEventListener("scroll",Me),()=>ne.removeEventListener("scroll",Me)},[]),w.useEffect(()=>{!G.current&&Ne.current&&(Ne.current.scrollTop=Ne.current.scrollHeight)},[B.nodes,B.selectedRoleId]);const Z=B.selectedRoleId?B.nodes.get(B.selectedRoleId)??null:null,ye=Z?l6[Z.roleId]??"#888":"#888",ge=B.progress.running>0||B.progress.awaitingInput>0,Ee=B.selectedRoleId===n,Fe=!!E&&!Y,Be=(Y==null?void 0:Y.directive)??(E==null?void 0:E.directive)??"",Oe=w.useCallback(ne=>{const Me=new Set,Ve=[ne];for(;Ve.length>0;){const Ze=Ve.shift();if(Me.has(Ze))continue;Me.add(Ze);const Sn=e[Ze];Sn&&Ve.push(...Sn.children)}return Me},[e]),qe=w.useMemo(()=>{if(!B.selectedRoleId)return new Set;const ne=Oe(B.selectedRoleId);return ne.delete(n),ne},[B.selectedRoleId,Oe,n]),at=w.useRef(null);w.useEffect(()=>{if(B.selectedRoleId===at.current||(at.current=B.selectedRoleId,!B.selectedRoleId))return;const ne=Oe(B.selectedRoleId);ne.delete(n),B.setCheckedRoles(ne)},[B.selectedRoleId,Oe,n]);const We=B.checkedRoles.size,Dt=()=>{if(!k.trim()&&se.length===0||We===0)return;const Me=Array.from(B.nodes.keys()).filter(Ze=>Ze!==n).every(Ze=>B.checkedRoles.has(Ze)),Ve=se.length>0?se:void 0;u(k.trim(),Me?void 0:Array.from(B.checkedRoles),Ve),N(""),ke([])},ze=ne=>{ne.key==="Enter"&&(ne.metaKey||ne.ctrlKey)&&(ne.preventDefault(),Dt()),ne.key==="Escape"&&d()},He=w.useCallback(async()=>{if(!B.selectedRoleId||!A.trim()&&se.length===0)return;const ne=B.nodes.get(B.selectedRoleId);if(!ne)return;const Me=se.length>0?se:void 0;T(!0);try{if(ne.status==="awaiting_input"&&ne.sessionId){const Ve=await pe.replyToSession(ne.sessionId,A.trim(),Me);$(""),ke([]),B.connectStream(Ve.sessionId||ne.sessionId,B.selectedRoleId)}else{const Ve=(Y==null?void 0:Y.id)??(E==null?void 0:E.waveId)??(E==null?void 0:E.id),Ze=await pe.startJob({type:"assign",roleId:B.selectedRoleId,task:A.trim(),...Ve&&{waveId:Ve},...Me&&{attachments:Me}});$(""),ke([]),Ze.sessionId&&B.connectStream(Ze.sessionId,B.selectedRoleId)}}catch(Ve){console.error("Reply failed:",Ve)}finally{T(!1)}},[B,A,se,Y,E]),qt=w.useCallback(async ne=>{const Me=B.nodes.get(ne);if(Me)try{Me.sessionId?await pe.abortSession(Me.sessionId):Me.jobId&&await pe.abortJob(Me.jobId)}catch{if(Me.jobId)try{await pe.abortJob(Me.jobId)}catch{}}},[B.nodes]),_t=w.useCallback(async()=>{for(const[,ne]of B.nodes)if(il(ne.status))try{ne.sessionId?await pe.abortSession(ne.sessionId):ne.jobId&&await pe.abortJob(ne.jobId)}catch{if(ne.jobId)try{await pe.abortJob(ne.jobId)}catch{}}},[B.nodes]),Bt=w.useCallback(async ne=>{M(!0),C(null),R(-1);try{const Me=await pe.getWaveDetail(ne);Me.replay&&C(Me.replay)}catch(Me){console.error("Failed to load wave:",Me)}finally{M(!1)}},[]),Jt=w.useRef(!1),kn=w.useRef(null);w.useEffect(()=>{if(!(E||_)&&((Y==null?void 0:Y.id)!==kn.current&&(Jt.current=!1,kn.current=(Y==null?void 0:Y.id)??null),B.allDone&&!Jt.current&&Y&&(Jt.current=!0,ce(),f==null||f(),m))){const ne=Y.rootJobs.map(Me=>Me.jobId).filter(Me=>!!Me);m(Y.directive,ne,{waveId:Y.id,sessionIds:Y.sessionIds}).catch(()=>{})}},[B.allDone,Y,f,m,ce,E,_]);const J=w.useCallback(async()=>{if(!m||!Y)return;const ne=Y.rootJobs.map(Me=>Me.jobId).filter(Me=>!!Me);await m(Y.directive,ne,{waveId:Y.id,sessionIds:Y.sessionIds})},[m,Y]),$e=ne=>{je(Me=>{const Ve=new Set(Me);return Ve.has(ne)?Ve.delete(ne):Ve.add(ne),Ve})},lt=ne=>{const Me=Math.floor(ne/60),Ve=ne%60;return`${Me}:${Ve.toString().padStart(2,"0")}`},{panelRight:Kt,panelWidth:ve,isResizing:wt,handleResizeStart:jn}=Ko(g,700,v),hn=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"}),ge&&l.jsxs("span",{className:"text-white/60 text-xs",children:[B.progress.running+B.progress.awaitingInput," active",B.progress.awaitingInput>0&&` (${B.progress.awaitingInput} awaiting)`]}),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:Y?`${o.length} active wave${o.length!==1?"s":""}`:Fe?"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:[(Y||Fe)&&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:ge?"#FBBF24":B.allDone||Fe?"#2E7D32":"#B71C1C",animation:ge?"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:["“",Be,"”"]}),Y&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:lt(ue)}),Fe&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:ge?"#FBBF2422":"#2E7D3222",color:ge?"#FBBF24":"#2E7D32"},children:ge?"LIVE":"REPLAY"}),Fe&&(E==null?void 0:E.startedAt)&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:new Date(E.startedAt).toLocaleString()}),B.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:[B.progress.awaitingInput," awaiting"]}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:B.allDone||Fe&&!ge?"#2E7D3222":"#B71C1C22",color:B.allDone||Fe&&!ge?"#2E7D32":"#B71C1C"},children:[B.progress.done,"/",B.progress.total]}),ge&&l.jsx("button",{onClick:_t,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:Y||Fe?"Org Propagation":"Select Target Roles"}),l.jsxs("span",{className:"ml-auto text-[10px] text-[var(--terminal-text-muted)]",children:[B.checkedRoles.size,"/",B.progress.total," selected"]}),(Y||Fe)&&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(ne=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:ne.color,animation:ne.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:ne.label})]},ne.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(mv,{nodes:B.nodes,rootId:n,selectedRoleId:B.selectedRoleId,onSelectNode:B.selectNode,checkedRoles:B.checkedRoles,onToggleCheck:B.toggleCheck,eligibleRoles:qe})})]}),_?l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"Loading wave data..."}):Ee?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:[We," target role",We!==1?"s":""," selected"]})]}),l.jsxs("div",{ref:Ne,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-2 text-xs font-mono select-text",children:[Be&&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:Be}),Y&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",children:["dispatched ",lt(ue)," ago to ",Y.rootJobs.length," role",Y.rootJobs.length!==1?"s":""]})]})]}),!Be&&!Y&&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:[se.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:se.map((ne,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:${ne.mediaType};base64,${ne.data}`,alt:ne.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>ke(Ve=>Ve.filter((Ze,Sn)=>Sn!==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:ne.name})]},Me))}),Le&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:Le}),l.jsxs("div",{className:"flex gap-2 items-end",children:[l.jsx("button",{onClick:()=>{var ne;return(ne=et.current)==null?void 0:ne.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:W,value:k,onChange:ne=>N(ne.target.value),onKeyDown:ze,onPaste:ct,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:Dt,disabled:!k.trim()&&se.length===0||We===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()&&We>0?"#B71C1C":"#333",color:"#fff",minWidth:140},children:["Dispatch to ",We," Role",We!==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:[Z&&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:ye}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:Z.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:Z.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:Z.status==="awaiting_input"?"#F59E0B22":Z.status==="running"?"#FBBF2422":`${ye}22`,color:Z.status==="awaiting_input"?"#F59E0B":Z.status==="running"?"#FBBF24":ye},children:Z.status==="running"?"Working...":Z.status==="done"?Z.children.some(ne=>{const Me=B.nodes.get(ne);return Me&&il(Me.status)})?"Supervising...":"Complete":Z.status==="error"?"Error":Z.status==="waiting"?"Waiting":Z.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),l.jsxs("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[Z.events.length," events"]}),il(Z.status)&&Z.sessionId&&l.jsx("button",{onClick:()=>qt(Z.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:et,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:ne=>{var Me;(Me=ne.target.files)!=null&&Me.length&&Ge(ne.target.files),ne.target.value=""},className:"hidden"}),l.jsxs("div",{ref:Ne,className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text transition-colors ${he?"bg-amber-500/5 ring-1 ring-inset ring-amber-500/30":""}`,onDragOver:Ce,onDragLeave:Ae,onDrop:yt,children:[Z&&Be&&Z.status!=="waiting"&&Z.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:Be})]}),Z&&Z.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:Z.status==="waiting"?"Waiting for dispatch...":Z.status==="running"?"Connecting to activity stream...":Z.status==="not-dispatched"?"This role was not dispatched. Send a follow-up to activate.":""}),Z==null?void 0:Z.events.map((ne,Me)=>{const Ve=Z.events,Ze=ne.type==="job:start"&&Me>0,Sn=Ve[Me+1];if((ne.type==="job:done"||ne.type==="job:error"||ne.type==="job:awaiting_input")&&(Sn==null?void 0:Sn.type)==="job:start")return null;if(Ze){const yn=ne.data.task??"",mn=yn.match(/\[CEO Follow-up\]\n([\s\S]+)$/),Lr=mn?mn[1].trim():yn;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:Lr})]})},`followup-${ne.seq}`)}return l.jsx(Qm,{event:ne,isThinkingCollapsed:me.has(ne.seq),onToggleThinking:()=>$e(ne.seq),onNavigateToJob:yn=>{for(const[,mn]of B.nodes)if(mn.events.some(Lr=>Lr.data.childJobId===yn)){B.selectNode(mn.roleId);return}},onOpenKnowledgeDoc:h},ne.seq)}),(Z==null?void 0:Z.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"}),!Z&&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"})]}),((Z==null?void 0:Z.status)==="awaiting_input"||(Z==null?void 0:Z.status)==="done"||(Z==null?void 0:Z.status)==="not-dispatched")&&(se.length>0||Le||he)&&l.jsxs("div",{className:"px-4 pt-2 border-t shrink-0",style:{borderColor:"var(--terminal-border)"},children:[Le&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:Le}),he&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-1",children:"Drop image here"}),se.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-1",children:se.map((ne,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:${ne.mediaType};base64,${ne.data}`,alt:ne.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>ke(Ve=>Ve.filter((Ze,Sn)=>Sn!==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:ne.name})]},Me))})]}),(Z==null?void 0:Z.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:[Z.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var ne;return(ne=et.current)==null?void 0:ne.click()},disabled:U,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:A,onChange:ne=>$(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),He())},onPaste:ct,placeholder:"Type your response...",disabled:U,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:He,disabled:U||!A.trim()&&se.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:U?"...":"Reply"})]})]}),Z&&(Z.status==="done"||Z.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 ",Z.roleName]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var ne;return(ne=et.current)==null?void 0:ne.click()},disabled:U,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:A,onChange:ne=>$(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),He())},onPaste:ct,placeholder:"Send a follow-up directive...",disabled:U,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:He,disabled:U||!A.trim()&&se.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:U?"...":"Send"})]})]}),B.allDone&&Y&&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:J,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:Hn}),l.jsx("div",{className:"p-3 pb-0",children:l.jsx("button",{onClick:()=>{C(null),R(-1),I(!0),B.reset()},className:"w-full px-3 py-1.5 text-[11px] font-bold rounded-lg cursor-pointer transition-colors",style:{background:!E&&H<0?"#B71C1C":"var(--terminal-inline-bg)",color:!E&&H<0?"#fff":"var(--terminal-text-secondary)",border:"1px solid",borderColor:!E&&H<0?"#B71C1C":"var(--terminal-border)"},children:"+ New Wave"})}),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((ne,Me)=>l.jsxs("button",{onClick:()=>{R(Me),C(null),I(!1),B.reset()},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:H===Me&&!E?"var(--terminal-bg)":"transparent",border:H===Me&&!E?"1px solid var(--accent)":"1px solid transparent"},children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 shrink-0 animate-pulse"}),l.jsxs("span",{className:"text-[11px] text-[var(--terminal-text)] truncate font-medium",children:[ne.directive.slice(0,40),ne.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[ne.rootJobs.length," role",ne.rootJobs.length!==1?"s":""]})]},ne.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(ne=>l.jsx(s6,{wave:ne,active:(E==null?void 0:E.id)===ne.id,onLoad:()=>Bt(ne.id)},ne.id))})]}),q&&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:q.dirty?"var(--idle-amber)":"#2E7D32"}}),l.jsx("span",{className:"text-[10px] font-mono text-[var(--terminal-text-muted)] truncate",children:q.branch}),q.dirty&&l.jsxs("span",{className:"text-[9px] ml-auto shrink-0",style:{color:"var(--idle-amber)"},children:[q.count," unsaved"]}),!q.dirty&&l.jsx("span",{className:"text-[9px] text-green-400 ml-auto shrink-0",children:"clean"})]})]})]})]});return b?l.jsx("div",{className:"flex flex-col h-full w-full",style:{background:"var(--terminal-bg)"},children:hn}):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:Kt},onClick:d}),l.jsxs("div",{className:"fixed top-0 bottom-0 z-50 flex flex-col",style:{right:Kt,width:ve,background:"var(--terminal-bg)",borderLeft:"1px solid var(--terminal-border)",transition:wt?"none":"width 0.2s ease"},children:[l.jsx("div",{className:"absolute top-0 bottom-0 w-1 cursor-col-resize hover:bg-[var(--accent)] z-50",style:{left:0},onMouseDown:jn}),hn]})]})}function i6(e,n,a){const i=new Map,o=d=>{const f=e[d];!f||i.has(d)||(i.set(d,{sessionId:"",roleId:d,roleName:f.name,children:f.children,status:"not-dispatched",events:[],streamStatus:"idle"}),f.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 f=i.get(d.roleId);if(f){const m=Ty(d.status);i.set(d.roleId,{...f,sessionId:d.sessionId??d.jobId??"",status:d.status||"done",events:d.events,streamStatus:m?"connecting":"done"})}for(const m of d.childJobs){const h=i.get(m.roleId);h&&i.set(m.roleId,{...h,sessionId:m.jobId??"",status:m.status||"done",events:m.events,streamStatus:"done"})}}return i}function s6({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 o6={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 Zm(e){return o6[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const pv=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],xv=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],gv=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],yv=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],bv=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],ol={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 c6({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 Fo({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(c6,{color:o,selected:o===a,onClick:()=>i(o)},o))})]})}function Fh({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,f=o!=null&&o.getCost?o.getCost(u.id):0,m=u.id===a,h=o?d>o.roleLevel&&!m:!1,x=f>0&&(o==null?void 0:o.purchased)&&!o.purchased.has(u.id)&&!m,g=(o==null?void 0:o.coinBalance)!==void 0?o.coinBalance>=f:!0,v=h||!1,b=o?m&&d>o.roleLevel:!1;return l.jsxs("button",{onClick:()=>{if(!v){if(x&&!h){g&&(o!=null&&o.onPurchase)&&o.onPurchase(u.id,f);return}i(u.id===a?void 0:u.id)}},className:"customize-swatch",style:{width:"auto",height:"auto",padding:v||x?"2px 6px 12px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:m?"rgba(255,255,255,0.15)":v?"rgba(255,255,255,0.02)":x?"rgba(255,200,0,0.04)":"rgba(255,255,255,0.04)",outline:m?b?"2px solid #F59E0B":"2px solid #fff":x&&!v?"2px solid rgba(255,200,0,0.3)":"2px solid transparent",color:v?"rgba(255,255,255,0.25)":x?"rgba(255,255,255,0.45)":m?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:v?"not-allowed":x?g?"pointer":"not-allowed":"pointer",opacity:v?.35:1,position:"relative"},children:[u.name,v&&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]}),!v&&x&&l.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:g?"#FFD700":"#F87171",whiteSpace:"nowrap"},children:["🪙"," ",f]}),b&&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 Rh({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 Ul(e){return e[Math.floor(Math.random()*e.length)]}function ys(e){var o,u,d;const n=Lb().filter(f=>!e||Hb(f.id,e)),a=Ub().filter(f=>!e||Yb(f.id,e)),i=Xb().filter(f=>!e||Vb(f.id,e));return{skinColor:Ul(pv),hairColor:Ul(xv),shirtColor:Ul(gv),pantsColor:Ul(yv),shoeColor:Ul(bv),hairStyle:(o=Ul(n))==null?void 0:o.id,outfitStyle:(u=Ul(a))==null?void 0:u.id,accessory:(d=Ul(i))==null?void 0:d.id}}function vv({roleId:e,appearance:n,onChange:a,onRandomize:i,onReset:o,label:u,roleLevel:d,coinBalance:f,purchased:m,onPurchase:h}){const[x,g]=w.useState("look"),v=w.useCallback((R,I)=>{a({...n,[R]:I})},[n,a]),b=w.useRef(null),j=w.useCallback(R=>{var Y;const I=(Y=R.target.files)==null?void 0:Y[0];if(!I)return;const W=new Image;W.onload=()=>{const D=SC(W);a({...D,hairStyle:n.hairStyle,outfitStyle:n.outfitStyle,accessory:n.accessory}),URL.revokeObjectURL(W.src)},W.src=URL.createObjectURL(I),R.target.value=""},[n.hairStyle,n.outfitStyle,n.accessory,a]),k=Lb(),N=Ub(),E=Xb(),C=d!==void 0?k.filter(R=>Hb(R.id,d)).length:k.length,_=d!==void 0?N.filter(R=>Yb(R.id,d)).length:N.length,M=d!==void 0?E.filter(R=>Vb(R.id,d)).length:E.length,H=(R,I)=>d!==void 0?{roleLevel:d,getLockLevel:R,getCost:I,purchased:m,onPurchase:h,coinBalance:f}:void 0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"customize-preview",children:[l.jsx("div",{className:"customize-preview-bg",children:l.jsx(Kl,{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 R;return(R=b.current)==null?void 0:R.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),l.jsx("input",{ref:b,type:"file",accept:"image/*",onChange:j,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(Rh,{label:"LOOK",active:x==="look",onClick:()=>g("look")}),l.jsx(Rh,{label:"OUTFIT",active:x==="outfit",onClick:()=>g("outfit")}),l.jsx(Rh,{label:"ACCESSORY",active:x==="accessory",onClick:()=>g("accessory")})]}),x==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(Fo,{label:"SKIN",presets:pv,value:n.skinColor,onChange:R=>v("skinColor",R)}),l.jsx(Fo,{label:"HAIR COLOR",presets:xv,value:n.hairColor,onChange:R=>v("hairColor",R)}),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:[C,"/",k.length," unlocked"]})]}),l.jsx(Fh,{label:"HAIR STYLE",items:k,value:n.hairStyle,onChange:R=>v("hairStyle",R),lockInfo:H(Ib,dC)})]}),x==="outfit"&&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:[_,"/",N.length," unlocked"]})]}),l.jsx(Fh,{label:"STYLE",items:N,value:n.outfitStyle,onChange:R=>v("outfitStyle",R),lockInfo:H(qb,pC)}),l.jsx(Fo,{label:"TOP",presets:gv,value:n.shirtColor,onChange:R=>v("shirtColor",R)}),l.jsx(Fo,{label:"PANTS",presets:yv,value:n.pantsColor,onChange:R=>v("pantsColor",R)}),l.jsx(Fo,{label:"SHOES",presets:bv,value:n.shoeColor,onChange:R=>v("shoeColor",R)})]}),x==="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:[M,"/",E.length," unlocked"]})]}),l.jsx(Fh,{label:"ACCESSORY",items:E,value:n.accessory,onChange:R=>v("accessory",R),lockInfo:H(Wb,vC)}),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 u6=[{value:"c-level",label:"C-Level"},{value:"member",label:"Member"}];function ym(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Mh(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 d6={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 Xl=null;async function f6(){if(Xl)return Xl;try{const a=await pe.getPreferences();if(a.instanceId)return Xl=a.instanceId,localStorage.setItem("tycono_instance_id",Xl),Xl}catch{}const e="tycono_instance_id";let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),Xl=n,n}const Ro=4;function h6(e,n,a){const i=e.trim();if(!i||i.startsWith("#"))return null;const o=i.split(",").map(g=>g.trim()),u=o[0];if(!u)return null;const d=ym(u),m=(o[1]||"member").toLowerCase()==="c-level"?"c-level":"member",h=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:h,error:x}}function m6({existingRoles:e,onClose:n,onHire:a,onStoreVisit:i,questHint:o}){const[u,d]=w.useState("single"),[f,m]=w.useState([]),[h,x]=w.useState(!1),[g,v]=w.useState("popular"),[b,j]=w.useState(""),[k,N]=w.useState(null),[E,C]=w.useState(!1),[_,M]=w.useState(""),[H,R]=w.useState("browse"),[I,W]=w.useState(""),[Y,D]=w.useState(""),[O,B]=w.useState("ceo"),[ee,re]=w.useState(null),[K,q]=w.useState(1),[ce,ue]=w.useState(""),[V,A]=w.useState(""),[$,U]=w.useState(!1),[T,se]=w.useState("member"),[ke,he]=w.useState(()=>{const J=e.find($e=>$e.level==="c-level");return(J==null?void 0:J.id)??"ceo"}),[_e,Le]=w.useState(""),[Ue,et]=w.useState(ys),[Pe,Ge]=w.useState(!1),[Ce,Ae]=w.useState(""),[yt,ct]=w.useState([]),[xt,Ct]=w.useState(new Set),[Ht,zt]=w.useState(""),[jt,Hn]=w.useState("input"),[me,je]=w.useState({done:0,total:0}),Ne=w.useRef(null),G=w.useRef(null),Z=w.useRef(null);w.useEffect(()=>{pe.getSkills().then(J=>ct(J.filter($e=>$e.installed))).catch(()=>{}),f6().then(J=>re(J)).catch(()=>{})},[]),w.useEffect(()=>{var J,$e,lt;u==="single"?(K===1&&((J=Ne.current)==null||J.focus()),K===2&&(($e=G.current)==null||$e.focus())):u==="bulk"&&jt==="input"&&((lt=Z.current)==null||lt.focus())},[K,u,jt]),w.useEffect(()=>{u==="store"&&H==="browse"&&f.length===0&&ye()},[u,H]);const ye=async()=>{x(!0);try{const J=await kr.getCharacters({sort:g,instanceId:ee??void 0});m(J.characters)}catch{M("Failed to load job board")}x(!1)};w.useEffect(()=>{u==="store"&&H==="browse"&&ye()},[g,ee]);const ge=w.useMemo(()=>{if(!b.trim())return f;const J=b.toLowerCase();return f.filter($e=>$e.name.toLowerCase().includes(J)||$e.id.toLowerCase().includes(J)||($e.tagline??"").toLowerCase().includes(J))},[f,b]),Ee=w.useMemo(()=>new Set(e.map(J=>J.id)),[e]),Fe=w.useMemo(()=>{const J=Ht.split(`
|
|
85
|
+
`),$e=new Set;return J.map(lt=>h6(lt,Ee,$e)).filter(lt=>lt!==null)},[Ht,Ee]),Be=Fe.length>0&&Fe.every(J=>!J.error),Oe=J=>{ue(J),$||A(ym(J))},qe=ce.trim().length>0&&V.trim().length>0&&!e.some(J=>J.id===V),at=_e.trim().length>0,We=async()=>{Ge(!0),Ae("");const J=Mh(T);try{await a({id:V,name:ce.trim(),level:T,reportsTo:ke,persona:_e.trim(),...J,skills:xt.size>0?[...xt]:void 0},Ue),n()}catch($e){Ae($e instanceof Error?$e.message:"Failed to create role"),Ge(!1)}},Dt=J=>J===1?qe:J===2?at:!0,ze=async()=>{Ge(!0),Ae(""),je({done:0,total:Fe.length});try{for(let J=0;J<Fe.length;J++){const $e=Fe[J],lt=Mh($e.level),Kt=ys(),ve=`${$e.name}. A ${$e.level} role reporting to ${$e.reportsTo}.`;await a({id:$e.id,name:$e.name,level:$e.level,reportsTo:$e.reportsTo,persona:ve,...lt},Kt),je({done:J+1,total:Fe.length})}n()}catch(J){Ae(J instanceof Error?J.message:"Failed to create roles"),Ge(!1)}},He=async J=>{C(!0),M("");try{const $e=await kr.getCharacter(J);N($e),W($e.name||""),D(ym($e.name||J)),R("review")}catch{M("Failed to load character details")}finally{C(!1)}},qt=async(J,$e)=>{if(!ee)return;const lt=f.find(ve=>ve.id===J);if(!lt)return;const Kt=lt.my_vote===$e?0:$e;try{const ve=await kr.voteCharacter(J,ee,Kt);m(wt=>wt.map(jn=>jn.id===J?{...jn,upvotes:ve.upvotes,downvotes:ve.downvotes,vote_score:ve.upvotes-ve.downvotes,my_vote:Kt===0?null:Kt}:jn))}catch{}},_t=async()=>{if(!k)return;Ge(!0),Ae("");const J=k,$e=J.level==="c-level"?"c-level":"member",lt=Mh($e),Kt=J.skills!=null&&typeof J.skills=="object"&&!Array.isArray(J.skills)&&"primary"in J.skills;try{await a({id:Y,name:I.trim(),level:$e,reportsTo:O,persona:J.persona||`${I}. Imported from Job Board.`,authority:J.authority||lt.authority,knowledge:lt.knowledge,reports:lt.reports,source:{id:`tycono/${J.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:Kt?J.skills:void 0},J.appearance?J.appearance:ys()),kr.trackInstall(J.id).catch(()=>{}),n()}catch(ve){Ae(ve instanceof Error?ve.message:"Failed to hire"),Ge(!1)}},Bt=async J=>{if(ee)try{await kr.deleteCharacter(J,ee),m($e=>$e.filter(lt=>lt.id!==J))}catch{}},Jt=J=>{J.key==="Escape"&&n(),J.key==="Enter"&&(J.metaKey||J.ctrlKey)&&(u==="single"?K<Ro&&Dt(K)?q(K+1):K===Ro&&We():u==="bulk"?jt==="input"&&Be?Hn("review"):jt==="review"&&ze():u==="store"&&H==="review"&&_t())},kn=e.some(J=>J.id===V)&&V.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:Jt,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"),Ae("")},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"),Ae("")},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"),Ae(""),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"&&K===1&&!ce&&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 J=d6[o.roleId];J&&(ue(J.name),A(J.id),U(!0),se(J.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 ${K} of ${Ro}`:u==="bulk"?jt==="input"?"Enter roles, one per line":`Review ${Fe.length} roles`:H==="browse"?`${f.length} roles available`:"Review & customize"}),u==="store"&&H==="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:J=>J.stopPropagation(),children:"Open in browser ↗"})]})]}),u==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:Ro},(J,$e)=>$e+1).map(J=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:J<=K?"#2E7D32":"rgba(255,255,255,0.1)"}},J))}),l.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:u==="store"?l.jsxs(l.Fragment,{children:[H==="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:()=>{Xl=null,localStorage.removeItem("tycono_instance_id"),re(null)},className:"text-white/30 hover:text-white/60 cursor-pointer",children:"Sign out"})]}):l.jsx(p6,{onLogin:J=>{Xl=J,localStorage.setItem("tycono_instance_id",J),re(J)}}),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:J=>{if(J.key==="Enter"){const lt=J.target.value.trim().replace(/^tycono:/,"");lt&&(He(lt),J.target.value="")}}}),l.jsx("button",{onClick:()=>{const J=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(J){const lt=J.value.trim().replace(/^tycono:/,"");lt&&(He(lt),J.value="")}},disabled:E,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:E?"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:J=>j(J.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:g,onChange:J=>v(J.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"})]})]}),h?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:"Loading store..."}):_?l.jsxs("div",{className:"text-center py-8",children:[l.jsx("div",{className:"text-xs text-red-400 mb-2",children:_}),l.jsx("button",{onClick:ye,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):ge.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:ge.map(J=>l.jsx(x6,{char:J,isHired:Ee.has(J.id),onSelect:()=>He(J.id),onVote:$e=>qt(J.id,$e),onDelete:()=>Bt(J.id),fetching:E,token:ee},J.id))})]}),H==="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(Kl,{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:I,onChange:J=>W(J.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:Y,onChange:J=>D(J.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(J=>J.id===Y)&&Y.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:O,onChange:J=>B(J.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(J=>l.jsxs("option",{value:J.id,className:"bg-[var(--wall)] text-white",children:[J.name," (",J.id,")"]},J.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 Kt,ve;const J=k.skills;if(J&&typeof J=="object"&&!Array.isArray(J)&&"primary"in J){const wt=[];return(ve=(Kt=J.primary)==null?void 0:Kt.frontmatter)!=null&&ve.name&&wt.push(J.primary.frontmatter.name),J.shared&&J.shared.forEach(jn=>{var hn;return wt.push(((hn=jn.frontmatter)==null?void 0:hn.name)||jn.id)}),wt.map(jn=>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:jn},jn))}return(Array.isArray(J)?J:[]).map((wt,jn)=>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 wt=="string"?wt:wt.name},jn))})()})]})]}),Ce&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ce})]})]}):u==="single"?l.jsxs(l.Fragment,{children:[K===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:Ne,value:ce,onChange:J=>Oe(J.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:V,onChange:J=>{A(J.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),U(!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 ${kn?"border-red-400":"border-white/10 focus:border-white/25"}`}),kn&&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:u6.map(J=>l.jsx("button",{onClick:()=>{if(se(J.value),J.value==="c-level")he("ceo");else{const $e=e.find(lt=>lt.level==="c-level");he(($e==null?void 0:$e.id)??"ceo")}},className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${T===J.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:J.label},J.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:ke,onChange:J=>he(J.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(J=>J.level==="c-level").map(J=>l.jsxs("option",{value:J.id,className:"bg-[var(--wall)] text-white",children:[J.name," (",J.id,")"]},J.id))})]})]}),K===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:G,value:_e,onChange:J=>Le(J.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"})]}),yt.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:yt.map(J=>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:xt.has(J.id),onChange:()=>Ct($e=>{const lt=new Set($e);return lt.has(J.id)?lt.delete(J.id):lt.add(J.id),lt}),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:J.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:J.description})]})]},J.id))})]})]}),K===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx(vv,{roleId:"default",appearance:Ue,onChange:et,onRandomize:()=>et(ys()),onReset:()=>et(ys()),label:l.jsxs("span",{children:[V||"new-role"," — ",ce||"New Role"]})})}),K===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(Kl,{roleId:"default",appearance:Ue,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(Mo,{label:"Name",value:ce}),l.jsx(Mo,{label:"ID",value:V,mono:!0}),l.jsx(Mo,{label:"Level",value:T}),l.jsx(Mo,{label:"Reports To",value:ke}),xt.size>0&&l.jsx(Mo,{label:"Skills",value:[...xt].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})]})]}),Ce&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ce})]})]}):l.jsxs(l.Fragment,{children:[jt==="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:Z,value:Ht,onChange:J=>zt(J.target.value),placeholder:`Name, Level, ReportsTo
|
|
86
|
+
e.g.
|
|
87
|
+
Data Analyst
|
|
88
|
+
DevOps Engineer, member, cto
|
|
89
|
+
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."})]}),Fe.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 (",Fe.length," role",Fe.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:Fe.map((J,$e)=>l.jsxs("tr",{className:`border-b border-white/5 ${J.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:J.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:J.id}),l.jsx("td",{className:"p-2 text-white/60",children:J.level}),l.jsx("td",{className:"p-2 text-white/60",children:J.reportsTo}),J.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:J.error})]},$e))})]})})]})]}),jt==="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 — ",Fe.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:Fe.map((J,$e)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:$e+1}),l.jsx("td",{className:"p-2 text-white/80",children:J.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:J.id}),l.jsx("td",{className:"p-2 text-white/60",children:J.level}),l.jsx("td",{className:"p-2 text-white/60",children:J.reportsTo})]},$e))})]})}),Pe&&me.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:[me.done,"/",me.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:`${me.done/me.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."}),Ce&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ce})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[u==="single"&&K>1&&l.jsx("button",{onClick:()=>q(K-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"&&jt==="review"&&l.jsx("button",{onClick:()=>Hn("input"),disabled:Pe,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"&&H==="review"&&l.jsx("button",{onClick:()=>{R("browse"),N(null),Ae("")},disabled:Pe,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"?K<Ro?l.jsx("button",{onClick:()=>q(K+1),disabled:!Dt(K),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:We,disabled:Pe,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:Pe?"Hiring...":"HIRE"}):u==="bulk"?jt==="input"?l.jsxs("button",{onClick:()=>Hn("review"),disabled:!Be,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 (",Fe.length,")"]}):l.jsx("button",{onClick:ze,disabled:Pe,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:Pe?`Hiring ${me.done}/${me.total}...`:`HIRE ALL (${Fe.length})`}):H==="review"?l.jsx("button",{onClick:_t,disabled:Pe||!I.trim()||!Y.trim()||e.some(J=>J.id===Y),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:Pe?"Hiring...":"HIRE"}):null]})]})]})]})}function p6({onLogin:e}){const[n,a]=w.useState(""),[i,o]=w.useState(!1),[u,d]=w.useState(""),f=()=>{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"&&f()},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:f,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 x6({char:e,isHired:n,onSelect:a,onVote:i,onDelete:o,fetching:u,token:d}){const[f,m]=w.useState(!1),h=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:g=>{g.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:g=>{g.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"}),h&&(f?l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:g=>{g.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:g=>{g.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:g=>{g.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 Mo({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 g6({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 y6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function b6({roleId:e,title:n,roleColor:a,active:i,isWave:o,isWaveStreaming:u,onClick:d,onClose:f,"data-session-id":m}){const h=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 ${h}`}: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:y6[e]??"👤"}),l.jsx("span",{className:`truncate ${o?"text-amber-400/90":""}`,children:n}),l.jsx("span",{onClick:f,className:"ml-auto text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none",children:"×"})]})}function v6({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(Im,{remarkPlugins:[Ym],components:{code:w6,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:a})})}function w6({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
90
|
+
`)?l.jsx(k6,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"terminal-inline-code",...a,children:n})}function k6({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 j6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function S6({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 zh(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 C6(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:zh(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=zh(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?zh(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 E6({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 N6({events:e,isStreaming:n}){const[a,i]=w.useState(!1);if(e.length===0)return null;const o=C6(e);if(o.length===0)return null;const u=e.filter(v=>v.type==="thinking").length,d=e.filter(v=>v.type==="tool"),f=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),h=[];if(u>0&&h.push("thinking"),d.length>0){const v=[...new Set(d.map(b=>b.toolName))];v.length<=3?h.push(v.join(", ")):h.push(`${d.length} tool calls`)}f.length>0&&h.push(`${f.length} dispatch`),m>1&&h.push(`${m} turns`);const x=h.join(" · "),g=!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?"...":""]})]}),g&&l.jsx("div",{className:"stream-activity-events",children:o.map((v,b)=>l.jsx(E6,{event:v,isStreaming:n&&b===o.length-1},b))})]})}function A6(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 D6({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(S6,{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?A6(e.events):void 0),f=((d==null?void 0:d.length)??0)>0,m=!!e.thinking,h=m&&!e.content&&u&&!f;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:j6[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()}),f&&l.jsx(N6,{events:d,isStreaming:u}),m&&!f&&l.jsxs("details",{open:h,className:"mb-1",children:[l.jsxs("summary",{className:"text-[10px] text-purple-400/70 cursor-pointer select-none flex items-center gap-1",children:[h&&l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-purple-400 animate-pulse"}),"thinking",h?"...":` (${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(v6,{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,g)=>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})`:""]})]},g))]})]})]})}function wv({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(D6,{message:u,roleId:n,roleColor:a},u.id)),l.jsx("div",{ref:i})]})}const T6=5*1024*1024,F6=["image/png","image/jpeg","image/gif","image/webp"];function Jm({mode:e,onModeChange:n,onSend:a,disabled:i,disabledReason:o,onStop:u}){const[d,f]=w.useState(""),[m,h]=w.useState([]),[x,g]=w.useState(!1),[v,b]=w.useState(null),j=w.useRef(null),k=w.useRef(null),N=w.useRef(!1);w.useEffect(()=>{const O=j.current;O&&(O.style.height="0",O.style.height=Math.min(O.scrollHeight,120)+"px")},[d]),w.useEffect(()=>{if(v){const O=setTimeout(()=>b(null),3e3);return()=>clearTimeout(O)}},[v]);const E=w.useCallback(async O=>F6.includes(O.type)?O.size>T6?(b(`File too large: ${(O.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(B=>{const ee=new FileReader;ee.onload=()=>{const K=ee.result.split(",")[1];B({type:"image",data:K,name:O.name,mediaType:O.type})},ee.onerror=()=>{b("Failed to read file"),B(null)},ee.readAsDataURL(O)}):(b(`Unsupported format: ${O.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),C=w.useCallback(async O=>{const B=Array.from(O),ee=[];for(const re of B){const K=await E(re);K&&ee.push(K)}ee.length>0&&h(re=>[...re,...ee])},[E]),_=w.useCallback(O=>{O.preventDefault(),O.stopPropagation(),g(!0)},[]),M=w.useCallback(O=>{O.preventDefault(),O.stopPropagation(),g(!1)},[]),H=w.useCallback(O=>{O.preventDefault(),O.stopPropagation(),g(!1);const B=O.dataTransfer.files;B.length>0&&C(B)},[C]),R=w.useCallback(O=>{const B=O.clipboardData.items,ee=[];for(let re=0;re<B.length;re++){const K=B[re];if(K.type.startsWith("image/")){const q=K.getAsFile();q&&ee.push(q)}}ee.length>0&&(O.preventDefault(),C(ee))},[C]),I=w.useCallback(O=>{const B=O.target.files;B&&B.length>0&&C(B),O.target.value=""},[C]),W=w.useCallback(O=>{h(B=>B.filter((ee,re)=>re!==O))},[]),Y=()=>{const O=d.trim();!O&&m.length===0||i||(a(O,m.length>0?m:void 0),f(""),h([]))},D=O=>{if(O.key==="Enter"&&!O.shiftKey){if(N.current)return;O.preventDefault(),Y()}};return l.jsxs("div",{className:`border-t border-[var(--terminal-border)] p-3 shrink-0 transition-colors ${x?"bg-[var(--terminal-surface-light)] border-amber-500/50":""}`,onDragOver:_,onDragLeave:M,onDrop:H,children:[v&&l.jsx("div",{className:"text-[10px] text-red-400 mb-2 text-center",children:v}),o&&l.jsx("div",{className:"text-[10px] text-amber-400/70 mb-2 text-center",children:o}),m.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:m.map((O,B)=>l.jsxs("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${O.mediaType};base64,${O.data}`,alt:O.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>W(B),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[8px] text-white truncate px-1 py-0.5",children:O.name})]},B))}),x&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-2",children:"Drop image here"}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"flex rounded-lg overflow-hidden border border-[var(--terminal-border)] shrink-0",children:[l.jsx("button",{onClick:()=>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 O;return(O=k.current)==null?void 0:O.click()},disabled:i,className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--terminal-surface-light)] hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Attach image (PNG, JPG, GIF, WebP)",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{ref:k,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:I,className:"hidden"}),l.jsx("textarea",{ref:j,value:d,onChange:O=>f(O.target.value),onKeyDown:D,onCompositionStart:()=>{N.current=!0},onCompositionEnd:()=>{N.current=!1},onPaste:R,placeholder:i?"Waiting...":e==="talk"?"Ask something...":"Give a directive...",disabled:i,rows:1,className:"flex-1 bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] rounded-lg px-3 py-2 text-sm text-[var(--terminal-text)] placeholder:text-[var(--terminal-text-muted)] resize-none focus:outline-none focus:border-[var(--terminal-border-hover)] disabled:opacity-40 terminal-scrollbar"}),i&&u&&l.jsx("button",{onClick:u,className:"w-8 h-8 rounded-lg bg-red-900/40 text-red-400 flex items-center justify-center shrink-0 cursor-pointer hover:bg-red-900/60 hover:text-red-300 transition-colors",title:"Stop",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),l.jsx("button",{onClick:Y,disabled:i||!d.trim()&&m.length===0,className:"w-8 h-8 rounded-lg bg-[var(--terminal-surface-light)] text-[var(--terminal-text-secondary)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--desk-wood)] hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M22 2L11 13"}),l.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})]})}const R6={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},kv={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function Zg(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function M6({msg:e}){const n=R6[e.roleId]??"#888",a=kv[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:Zg(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:Zg(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 z6({channel:e,allRoles:n,onUpdateMembers:a,onUpdateTopic:i,onSendMessage:o}){const u=w.useRef(null),d=w.useRef(null),[f,m]=w.useState("");w.useEffect(()=>{var _;const E=d.current;if(!E)return;E.scrollHeight-E.scrollTop-E.clientHeight<80&&((_=u.current)==null||_.scrollIntoView({behavior:"smooth"}))},[e.messages.length]);const[h,x]=w.useState(!1),[g,v]=w.useState(!1),[b,j]=w.useState(""),k=o&&e.id!=="general",N=()=>{!f.trim()||!o||(o(e.id,f.trim()),m(""),setTimeout(()=>{var E;return(E=u.current)==null?void 0:E.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(E=>kv[E]??E).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(!h),children:h?"Done":"Invite"})]}),!e.isDefault&&i&&l.jsx("div",{className:"px-3 pb-2 mb-1",children:g?l.jsx("input",{autoFocus:!0,value:b,onChange:E=>j(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(i(e.id,b.trim()),v(!1)),E.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..."})}),h&&!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(E=>{const C=e.members.includes(E.id);return l.jsxs("button",{className:`text-[10px] px-2 py-1 rounded ${C?"bg-white/15 text-[var(--terminal-text)]":"bg-white/5 text-[var(--terminal-text-muted)]"}`,onClick:()=>{const _=C?e.members.filter(M=>M!==E.id):[...e.members,E.id];a(e.id,_)},children:[C?"✓ ":"",E.name]},E.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(E=>l.jsx(M6,{msg:E},E.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:f,onChange:E=>m(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.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 _h={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},_6=400,B6=800;function Jg({sessions:e,activeSessionId:n,roles:a,streamingSessionId:i,width:o,onWidthChange:u,onSwitchSession:d,onCloseSession:f,onCreateSession:m,onClearEmpty:h,onCloseAll:x,onSendMessage:g,onModeChange:v,onStopSession:b,onCloseTerminal:j,onMaximize:k,chatChannels:N,activeChatChannelId:E,onSwitchChatChannel:C,onCreateChatChannel:_,onDeleteChatChannel:M,onUpdateChatMembers:H,onUpdateChatTopic:R,onSendChatMessage:I,unreadChannels:W}){const[Y,D]=w.useState(!1),[O,B]=w.useState(!1),[ee,re]=w.useState(!1),[K,q]=w.useState(""),ce=E!=null,ue=N==null?void 0:N.find(Ce=>Ce.id===E),[V,A]=w.useState(!1),[$,U]=w.useState(!1),[T,se]=w.useState(!1),ke=w.useRef(0),he=w.useRef(0),_e=w.useRef(null),Le=e.find(Ce=>Ce.id===n),Ue=i===n,et=e.filter(Ce=>Ce.messages.length===0).length,Pe=w.useCallback(()=>{const Ce=_e.current;Ce&&(U(Ce.scrollLeft>0),se(Ce.scrollLeft+Ce.clientWidth<Ce.scrollWidth-1))},[]);w.useEffect(()=>{if(!n||!_e.current)return;const Ce=_e.current.querySelector(`[data-session-id="${n}"]`);Ce&&Ce.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),Pe()},[n,e.length,Pe]),w.useEffect(()=>{const Ce=_e.current;if(!Ce)return;Pe(),Ce.addEventListener("scroll",Pe);const Ae=new ResizeObserver(Pe);return Ae.observe(Ce),()=>{Ce.removeEventListener("scroll",Pe),Ae.disconnect()}},[Pe]);const Ge=w.useCallback(Ce=>{Ce.preventDefault(),ke.current=Ce.clientX,he.current=o,A(!0);const Ae=k,yt=()=>{A(!1),document.removeEventListener("mousemove",ct),document.removeEventListener("mouseup",yt)},ct=xt=>{const Ct=ke.current-xt.clientX,Ht=he.current+Ct;if(Ht>=window.innerWidth*.6&&Ae){yt(),Ae();return}const zt=Math.min(B6,Math.max(_6,Ht));u==null||u(zt)};document.addEventListener("mousemove",ct),document.addEventListener("mouseup",yt)},[o,u,k]);return l.jsxs("div",{className:"shrink-0 bg-[var(--terminal-bg)] border-l border-[var(--terminal-border)] flex flex-col h-full relative",style:{width: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 ${V?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:Ge}),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:[$&&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:_e,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[N==null?void 0:N.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 ${E===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:E===Ce.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),l.jsx("span",{className:"truncate",children:Ce.name}),(W==null?void 0:W.has(Ce.id))&&E!==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:Ae=>{Ae.stopPropagation(),M==null||M(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)),N&&N.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(b6,{roleId:Ce.roleId,title:Ce.title,roleColor:_h[Ce.roleId]??"#666",active:!ce&&Ce.id===n,isWave:Ce.source==="wave",isWaveStreaming:Ce.source==="wave"&&Ce.status==="active",onClick:()=>{C==null||C(null),d(Ce.id)},onClose:Ae=>{Ae.stopPropagation(),f(Ce.id)},"data-session-id":Ce.id},Ce.id))]}),T&&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:()=>{D(!Y),B(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-lg cursor-pointer",children:"+"}),Y&&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(l.Fragment,{children:[ee?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:K,onChange:Ce=>q(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&K.trim()&&(_(K.trim(),[]),q(""),re(!1),D(!1)),Ce.key==="Escape"&&(re(!1),q(""))},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:()=>re(!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),D(!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:_h[Ce.id]??"#666"}}),Ce.id.toUpperCase()," — ",Ce.name]},Ce.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{B(!O),D(!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:"···"}),O&&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":""]}),et>0&&h&&l.jsxs("button",{onClick:()=>{h(),B(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:["Clear empty sessions (",et,")"]}),e.length>0&&x&&l.jsx("button",{onClick:()=>{x(),B(!1)},className:"w-full text-left px-3 py-2 text-xs text-[#E57373] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:"Close all sessions"}),e.length===0&&l.jsx("div",{className:"px-3 py-2 text-xs text-[var(--terminal-text-muted)]",children:"No sessions"})]})]}),k&&l.jsx("button",{onClick:k,className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:j,className:"px-2 py-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",children:"×"})]}),ce&&ue?l.jsx(z6,{channel:ue,allRoles:a,onUpdateMembers:H,onUpdateTopic:R,onSendMessage:I}):Le?l.jsxs(l.Fragment,{children:[l.jsx(wv,{messages:Le.messages,roleId:Le.roleId,roleColor:_h[Le.roleId]??"#666"}),l.jsx(Jm,{mode:Le.mode,onModeChange:Ce=>v(Le.id,Ce),onSend:(Ce,Ae)=>g(Le.id,Ce,Le.mode,Ae),disabled:Ue,disabledReason:Ue?`${Le.roleId.toUpperCase()} is responding...`:void 0,onStop:Ue&&b?()=>b(Le.id):void 0})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"No active session. Click [+] to start."})]})}function O6(){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,f)=>{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:f}),signal:m.signal}).then(async h=>{var N,E,C,_,M;if(!h.ok||!h.body){d.onError("Failed to connect");return}const x=h.body.getReader(),g=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:H,value:R}=await x.read();if(H)break;b=Date.now(),v+=g.decode(R,{stream:!0});const I=v.split(`
|
|
91
|
+
`);v=I.pop()??"";let W="";for(let Y=0;Y<I.length;Y++){const D=I[Y];if(D.startsWith("event: ")){W=D.slice(7).trim();continue}if(D.startsWith("data: ")){let O;try{O=JSON.parse(D.slice(6))}catch{W="";continue}switch(W){case"thinking":O.text&&((N=d.onThinking)==null||N.call(d,O.text));break;case"output":O.text&&d.onText(O.text);break;case"tool":(E=d.onToolUse)==null||E.call(d,O.name,O.input);break;case"dispatch":(C=d.onDispatch)==null||C.call(d,O.roleId,O.task);break;case"dispatch:progress":(_=d.onDispatchProgress)==null||_.call(d,O.roleId,O.type,O);break;case"turn":(M=d.onTurn)==null||M.call(d,O.turn);break;case"done":d.onDone(O);break;case"error":d.onError(O.message??"Unknown error");break;default:O.text&&d.onText(O.text);break}W=""}}}}finally{clearInterval(k)}}).catch(h=>{h.name!=="AbortError"&&d.onError(h.message)}),{abort:n}},[n]),abort:n}}const jv="tycono-appearances",bm="tycono-theme";function ey(){try{const e=localStorage.getItem(jv);return e?JSON.parse(e):{}}catch{return{}}}function Bh(e){localStorage.setItem(jv,JSON.stringify(e))}function ty(){try{const e=localStorage.getItem(bm);if(e&&e in ol)return e}catch{}return"default"}const Sv=new Set;for(const e of Object.values(ol))for(const n of Object.keys(e.vars))Sv.add(n);function $6(e){var i;const n=(i=ol[e])==null?void 0:i.vars;if(!n)return;const a=document.documentElement;for(const o of Sv)o in n||a.style.removeProperty(o);for(const[o,u]of Object.entries(n))a.style.setProperty(o,u)}const Oh={mode:"auto",intervalSec:18,dailyBudgetUsd:1},vm="tycono-speech-settings",$h="tycono-language";function L6(){try{const e=localStorage.getItem(vm);return e?{...Oh,...JSON.parse(e)}:Oh}catch{return Oh}}function I6(){const[e,n]=w.useState(ey),[a,i]=w.useState(ty),[o,u]=w.useState(L6),[d,f]=w.useState(()=>{try{return localStorage.getItem($h)??"auto"}catch{return"auto"}}),[m,h]=w.useState(new Set),x=w.useRef(!1);w.useEffect(()=>{x.current||(x.current=!0,pe.getPreferences().then(C=>{const _=Object.keys(C.appearances??{}).length>0||C.theme!=="default";if(C.speech&&(u(M=>({...M,...C.speech})),localStorage.setItem(vm,JSON.stringify(C.speech))),C.language&&(f(C.language),localStorage.setItem($h,C.language)),C.purchasedItems&&h(new Set(C.purchasedItems)),_){const M=C.appearances;n(M),Bh(M),C.theme&&C.theme in ol&&(i(C.theme),localStorage.setItem(bm,C.theme))}else{const M=ey(),H=ty();(Object.keys(M).length>0||H!=="default")&&pe.updatePreferences({appearances:M,theme:H}).catch(()=>{})}}).catch(()=>{}))},[]),w.useEffect(()=>{$6(a)},[a]);const g=w.useCallback(C=>e[C]??Zm(C),[e]),v=w.useCallback((C,_)=>{n(M=>{const H={...M,[C]:_};return Bh(H),pe.updatePreferences({appearances:H}).catch(()=>{}),H})},[]),b=w.useCallback(C=>{n(_=>{const M={..._};return delete M[C],Bh(M),pe.updatePreferences({appearances:M}).catch(()=>{}),M})},[]),j=w.useCallback(C=>{i(C),localStorage.setItem(bm,C),pe.updatePreferences({theme:C}).catch(()=>{})},[]),k=w.useCallback(C=>{u(_=>{const M={..._,...C};return localStorage.setItem(vm,JSON.stringify(M)),pe.updatePreferences({speech:M}).catch(()=>{}),M})},[]),N=w.useCallback(C=>{f(C),localStorage.setItem($h,C),pe.updatePreferences({language:C}).catch(()=>{})},[]),E=w.useCallback(C=>{h(_=>{const M=new Set(_);return M.add(C),pe.updatePreferences({purchasedItems:Array.from(M)}).catch(()=>{}),M})},[]);return{appearances:e,getAppearance:g,setAppearance:v,resetAppearance:b,theme:a,setTheme:j,speechSettings:o,setSpeechSettings:k,language:d,setLanguage:N,purchasedItems:m,addPurchasedItem:E}}const H6=3e4,U6=3e5;function q6(){var O;const[e,n]=w.useState("akb"),[a,i]=w.useState(null),[o,u]=w.useState("synced"),[d,f]=w.useState([]),[m,h]=w.useState(null),[x,g]=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 B=await pe.getSaveStatus(j.current);i(B),B.noGit?u("no-git"):u(ee=>ee==="saving"?ee:B.dirty?"dirty":"synced")}catch{u("error")}},[]),N=w.useCallback(async()=>{try{const B=await pe.getSyncStatus(j.current);h({ahead:B.ahead,behind:B.behind,branch:B.branch,hasRemote:B.hasRemote})}catch{}},[]),E=w.useCallback(()=>{v.current&&clearInterval(v.current),k(),v.current=setInterval(k,H6),b.current&&clearInterval(b.current),N(),b.current=setInterval(N,U6)},[k,N]);w.useEffect(()=>()=>{v.current&&clearInterval(v.current),b.current&&clearInterval(b.current)},[]);const C=w.useCallback(B=>{n(B),j.current=B,i(null),h(null),f([]),setTimeout(()=>{k(),N()},0)},[k,N]),_=w.useCallback(async B=>{u("saving");try{const ee=await pe.save(B,j.current);return await k(),ee}catch(ee){throw u("error"),ee}},[k]),M=w.useCallback(async()=>{try{const B=await pe.getSaveHistory(20,j.current);f(B)}catch{}},[]),H=w.useCallback(async B=>{u("saving");try{await pe.restoreSave(B,void 0,j.current),await k()}catch(ee){throw u("error"),ee}},[k]),R=w.useCallback(async()=>{g(!0);try{const B=await pe.pull(j.current);return await k(),await N(),B}catch(B){throw B}finally{g(!1)}},[k,N]),I=w.useCallback(async()=>{try{await pe.initGit(j.current),await k()}catch{u("error")}},[k]),W=a?a.modified.length+a.untracked.length:0,Y=((O=a==null?void 0:a.lastCommit)==null?void 0:O.date)??null,D=w.useCallback(async()=>{E()},[E]);return{state:o,dirtyCount:W,lastSaved:Y,status:a,save:_,history:d,loadHistory:M,restore:H,refresh:D,initGit:I,repo:e,setRepo:C,syncInfo:m,fetchSyncStatus:N,pull:R,pulling:x}}const ny={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."]},ry={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."]},Y6=[{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."}]}],X6=18e3,ay=6e3,W6=2500,V6=30*6e4,Cv="tycono:relationships";function G6(){try{const e=localStorage.getItem(Cv);return e?JSON.parse(e):[]}catch{return[]}}function K6(e){localStorage.setItem(Cv,JSON.stringify(e))}function Su(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 Cu(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function Eu(e){return e[Math.floor(Math.random()*e.length)]}function P6(e,n,a){const i=a.find(f=>f.id===e),o=a.find(f=>f.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 Q6(e,n){return e.relation==="any"?!0:e.relation===n}function Z6({roles:e,roleStatuses:n,activeExecs:a,getStandupSpeech:i}){const[o,u]=w.useState(new Map),[d,f]=w.useState(G6),m=w.useRef({}),h=w.useRef(null),x=w.useRef(e),g=w.useRef(n),v=w.useRef(a),b=w.useRef(i),j=w.useRef(d);x.current=e,g.current=n,v.current=a,b.current=i,j.current=d,w.useEffect(()=>{const M=Date.now();for(const[H,R]of Object.entries(n))Wn(R)&&(m.current[H]=M)},[n]),w.useEffect(()=>{K6(d)},[d]);const k=w.useCallback(M=>{const H=g.current[M],R=v.current.find(O=>O.roleId===M);if(Wn(H)&&(R!=null&&R.task))return null;const I=b.current(M);if(I&&Math.random()<.3)return{text:I,type:"work",ts:Date.now()};const W=Date.now(),Y=m.current[M]??0;if(W-Y>V6&&Math.random()<.5){const O=ry[M]??ry.engineer;return{text:Eu(O),type:"guilt",ts:W}}const D=ny[M]??ny.engineer;return{text:Eu(D),type:"personality",ts:W}},[]),N=w.useCallback(M=>{if(h.current)return!1;const H=M.filter(ce=>!Wn(g.current[ce.id]));if(H.length<2)return!1;const R=[...H].sort(()=>Math.random()-.5),I=R[0],W=R[1],Y=P6(I.id,W.id,M);if(!Y)return!1;const D=Su(j.current,I.id,W.id),O=Cu(D),B=Y6.filter(ce=>Q6(ce,Y)&&O>=ce.minFamiliarity);if(B.length===0)return!1;const ee=Eu(B);let re=I.id,K=W.id;ee.relation==="superior-subordinate"&&(W.reportsTo===I.id||I.level==="c-level"?(re=I.id,K=W.id):(re=W.id,K=I.id)),h.current={templateId:ee.id,roleA:re,roleB:K,turnIdx:0,timer:null};const q=ce=>{if(!h.current||ce>=ee.turns.length){h.current=null,f($=>{const U=[...$],T=Su(U,re,K);return T.conversations++,T.familiarity=Cu(T),T.lastInteraction=new Date().toISOString(),U}),setTimeout(()=>{u($=>{const U=new Map($);return U.delete(re),U.delete(K),U})},ay);return}const ue=ee.turns[ce],V=ue.speaker==="A"?re:K,A=ue.speaker==="A"?K:re;u($=>{const U=new Map($);if(U.set(V,{text:ue.text,type:"social",partnerId:A,ts:Date.now()}),ce>0){const T=ee.turns[ce-1].speaker==="A"?re:K;T!==V&&U.delete(T)}return U}),h.current.turnIdx=ce,h.current.timer=setTimeout(()=>q(ce+1),W6)};return q(0),!0},[]);w.useEffect(()=>{const M=setInterval(()=>{const H=x.current;if(H.length===0||h.current||Math.random()<.35&&N(H))return;const R=H.filter(Y=>!Wn(g.current[Y.id]));if(R.length===0)return;const I=Eu(R),W=k(I.id);W&&(u(Y=>{const D=new Map(Y);return D.set(I.id,W),D}),setTimeout(()=>{u(Y=>{const D=new Map(Y),O=D.get(I.id);return O&&O.ts===W.ts&&D.delete(I.id),D})},ay))},X6);return()=>{var H;clearInterval(M),(H=h.current)!=null&&H.timer&&clearTimeout(h.current.timer)}},[k,N]);const E=w.useCallback(M=>{const H=o.get(M);return(H==null?void 0:H.text)??""},[o]),C=w.useCallback((M,H)=>{f(R=>{const I=[...R],W=Su(I,M,H);return W.dispatches++,W.familiarity=Cu(W),W.lastInteraction=new Date().toISOString(),I})},[]),_=w.useCallback(M=>{M.length<2||f(H=>{const R=[...H];for(let I=0;I<M.length;I++)for(let W=I+1;W<M.length;W++){const Y=Su(R,M[I],M[W]);Y.wavesTogether++,Y.familiarity=Cu(Y),Y.lastInteraction=new Date().toISOString()}return R})},[]);return{speeches:o,getSpeech:E,relationships:d,notifyDispatch:C,notifyWave:_}}const Ev="tycono:office-chat";let J6=0;function eA(){return`chat-${Date.now()}-${++J6}`}function Lh(){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 tA(){try{const e=localStorage.getItem(Ev);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[...Lh(),...i]}const a=Lh();for(const i of a)n.find(o=>o.id===i.id)||n.unshift(i);return n}}catch{}return Lh()}function nA(e){const n=e.map(a=>({...a,messages:a.messages.slice(-200)}));localStorage.setItem(Ev,JSON.stringify(n))}function rA(){const[e,n]=w.useState(tA),[a,i]=w.useState(null),[o,u]=w.useState(new Set);w.useEffect(()=>{nA(e)},[e]);const d=w.useCallback(b=>{i(b),b&&u(j=>{const k=new Set(j);return k.delete(b),k})},[]),f=w.useCallback(b=>{const j={...b,id:eA()};n(k=>{const N=k.map(E=>E.id==="general"?b.type==="dispatch"?{...E,messages:[...E.messages,j].slice(-200)}:E:b.channelId?E.id===b.channelId?{...E,messages:[...E.messages,j].slice(-200)}:E:E.members.length>0&&E.members.includes(b.roleId)?{...E,messages:[...E.messages,j].slice(-200)}:E);return u(E=>{const C=new Set(E);for(const _ of N){const M=k.find(H=>H.id===_.id);M&&_.messages.length>M.messages.length&&C.add(_.id)}return C}),N})},[]),m=w.useCallback((b,j,k)=>{const N=`ch-${Date.now()}`,E={id:N,name:b.startsWith("#")?b:`#${b}`,members:j,isDefault:!1,messages:[],topic:k};n(C=>[...C,E]),i(N)},[]),h=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))},[]),g=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(E=>E.level!=="c-level").map(E=>E.id);if(k.members.length!==N.length||!N.every(E=>k.members.includes(E)))return{...k,members:N}}return k}))},[]);return{channels:e,activeChannelId:a,setActiveChannelId:d,pushMessage:f,createChannel:m,deleteChannel:h,updateMembers:x,updateTopic:g,unreadChannels:o,syncDefaultMembers:v}}const aA=45e3,ly=5e3,lA=4,iA=20;function sA({roles:e,roleStatuses:n,activeExecs:a,channels:i,relationships:o,pushMessage:u,speechSettings:d,engineType:f,hasApiKey:m}){const x=((d==null?void 0:d.mode)==="auto"?f==="claude-cli"||f==="local"?"llm":"template":(d==null?void 0:d.mode)??"template")==="llm"&&(m!==!1||f==="claude-cli"),g=((d==null?void 0:d.intervalSec)??aA/1e3)*1e3,v=w.useRef(e),b=w.useRef(n),j=w.useRef(a),k=w.useRef(i),N=w.useRef(o),E=w.useRef(u),C=w.useRef(0),_=w.useRef(!1);v.current=e,b.current=n,j.current=a,k.current=i,N.current=o,E.current=u;const M=w.useCallback(async(I,W)=>{if(_.current)return!1;_.current=!0;try{if(!v.current.find(q=>q.id===I))return!1;const D=W.messages.slice(-iA).map(q=>({roleId:q.roleId,text:q.text,ts:q.ts})),O=v.current.filter(q=>W.members.includes(q.id)),B=N.current.filter(q=>q.roleA===I||q.roleB===I).map(q=>({partnerId:q.roleA===I?q.roleB:q.roleA,familiarity:q.familiarity})),ee=j.current.find(q=>q.roleId===I),re=ee?{currentTask:ee.task,taskProgress:null}:{currentTask:null,taskProgress:null},K=await pe.chatInChannel({channelId:W.name.replace("#",""),channelTopic:W.topic,roleId:I,history:D,members:O.map(q=>({id:q.id,name:q.name,level:q.level})),relationships:B,workContext:re});return K.message?(E.current({ts:Date.now(),roleId:I,text:K.message,type:"chat",channelId:W.id}),!0):!1}catch{return!1}finally{_.current=!1}},[]),H=w.useCallback(async(I,W)=>{if(C.current>=lA){C.current=0;return}const Y=I.members.filter(ee=>ee!==W&&!Wn(b.current[ee]));if(Y.length===0){C.current=0;return}const D=Y[Math.floor(Math.random()*Y.length)];if(Math.random()>.7){C.current=0;return}const O=C.current*2e3,B=Math.random()*5e3;setTimeout(async()=>{C.current++;const ee=k.current.find(K=>K.id===I.id);if(!ee)return;if(await M(D,ee)){const K=.6-C.current*.1;Math.random()<K?H(ee,D):C.current=0}else C.current=0},ly+O+B)},[M]);return w.useEffect(()=>{if(!x)return;const I=setInterval(async()=>{const W=v.current;if(W.length===0||_.current)return;const Y=W.filter(re=>!Wn(b.current[re.id]));if(Y.length===0)return;const D=Y[Math.floor(Math.random()*Y.length)],O=k.current.filter(re=>re.members.length===0?!0:re.members.includes(D.id));if(O.length===0)return;const B=O[Math.floor(Math.random()*O.length)];C.current=0,await M(D.id,B)&&H(B,D.id)},g);return()=>clearInterval(I)},[x,g,M,H]),{triggerCeoReaction:w.useCallback(I=>{if(!x)return;const W=k.current.find(Y=>Y.id===I);W&&(C.current=0,setTimeout(()=>{H(W,"ceo")},ly))},[x,H])}}const Nv=[[1,8],[3,5],[8,1],[5,3]],oA=[[1,4],[2,3],[4,1],[3,2]];function Nu(e){const n=e===1||e===3?-1:0,a=Nv[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 Au(e){const n=e===1||e===3?-1:0,a=Nv[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 ql(e,n){const a=e===1||e===3?-1:0,i=oA[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 iy={down:[Nu(0),Nu(1),Nu(2),Nu(3)],up:[Au(0),Au(1),Au(2),Au(3)],right:[ql(0,!0),ql(1,!0),ql(2,!0),ql(3,!0)],left:[ql(0,!1),ql(1,!1),ql(2,!1),ql(3,!1)]},Te="#FAFAF7",In="#FFFFFF",De="#EDE8E2",nt="#DDD6CC",Xo="#1A1A2E",ad="#2A2A2A",ep="#FFB0B0",sy=[{x:2,y:0,w:1,h:1,c:De},{x:3,y:0,w:1,h:1,c:Te},{x:4,y:0,w:1,h:1,c:In},{x:5,y:0,w:1,h:1,c:Te},{x:6,y:0,w:1,h:1,c:De},{x:1,y:1,w:1,h:1,c:nt},{x:2,y:1,w:1,h:1,c:Te},{x:3,y:1,w:1,h:1,c:In},{x:4,y:1,w:1,h:1,c:Te},{x:5,y:1,w:1,h:1,c:In},{x:6,y:1,w:1,h:1,c:Te},{x:7,y:1,w:1,h:1,c:nt},{x:0,y:2,w:1,h:1,c:nt},{x:1,y:2,w:1,h:1,c:De},{x:2,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:Te},{x:4,y:2,w:1,h:1,c:In},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:Te},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:nt},{x:1,y:3,w:1,h:1,c:De},{x:2,y:3,w:1,h:1,c:Te},{x:3,y:3,w:1,h:1,c:Xo},{x:4,y:3,w:1,h:1,c:Te},{x:5,y:3,w:1,h:1,c:Xo},{x:6,y:3,w:1,h:1,c:Te},{x:7,y:3,w:1,h:1,c:De},{x:2,y:4,w:1,h:1,c:De},{x:3,y:4,w:1,h:1,c:Te},{x:4,y:4,w:1,h:1,c:ad},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:De},{x:3,y:5,w:1,h:1,c:nt},{x:4,y:5,w:1,h:1,c:De},{x:5,y:5,w:1,h:1,c:nt},{x:2,y:6,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:Te},{x:4,y:6,w:1,h:1,c:In},{x:5,y:6,w:1,h:1,c:Te},{x:6,y:6,w:1,h:1,c:De},{x:2,y:7,w:1,h:1,c:nt},{x:3,y:7,w:1,h:1,c:De},{x:4,y:7,w:1,h:1,c:Te},{x:5,y:7,w:1,h:1,c:De},{x:6,y:7,w:1,h:1,c:nt}],cA=[{x:3,y:8,w:1,h:1,c:De},{x:5,y:8,w:1,h:1,c:De},{x:3,y:9,w:1,h:1,c:nt},{x:5,y:9,w:1,h:1,c:nt}],uA=[{x:2,y:8,w:1,h:1,c:De},{x:6,y:8,w:1,h:1,c:De},{x:2,y:9,w:1,h:1,c:nt},{x:6,y:9,w:1,h:1,c:nt}],oy=[{x:2,y:0,w:1,h:1,c:De},{x:3,y:0,w:1,h:1,c:Te},{x:4,y:0,w:1,h:1,c:In},{x:5,y:0,w:1,h:1,c:Te},{x:6,y:0,w:1,h:1,c:De},{x:1,y:1,w:1,h:1,c:nt},{x:2,y:1,w:1,h:1,c:De},{x:3,y:1,w:1,h:1,c:Te},{x:4,y:1,w:1,h:1,c:In},{x:5,y:1,w:1,h:1,c:Te},{x:6,y:1,w:1,h:1,c:De},{x:7,y:1,w:1,h:1,c:nt},{x:0,y:2,w:1,h:1,c:nt},{x:1,y:2,w:1,h:1,c:De},{x:2,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:Te},{x:4,y:2,w:1,h:1,c:Te},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:Te},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:nt},{x:1,y:3,w:1,h:1,c:nt},{x:2,y:3,w:1,h:1,c:De},{x:3,y:3,w:1,h:1,c:Te},{x:4,y:3,w:1,h:1,c:Te},{x:5,y:3,w:1,h:1,c:Te},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:nt},{x:2,y:4,w:1,h:1,c:nt},{x:3,y:4,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:Te},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:nt},{x:3,y:5,w:1,h:1,c:nt},{x:4,y:5,w:1,h:1,c:De},{x:5,y:5,w:1,h:1,c:nt},{x:2,y:6,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:Te},{x:4,y:6,w:1,h:1,c:Te},{x:5,y:6,w:1,h:1,c:Te},{x:6,y:6,w:1,h:1,c:De},{x:2,y:7,w:1,h:1,c:nt},{x:3,y:7,w:1,h:1,c:De},{x:4,y:7,w:1,h:1,c:Te},{x:5,y:7,w:1,h:1,c:De},{x:6,y:7,w:1,h:1,c:nt},{x:4,y:5,w:1,h:1,c:Te},{x:4,y:4,w:1,h:1,c:In}],dA=[{x:3,y:8,w:1,h:1,c:De},{x:5,y:8,w:1,h:1,c:De},{x:3,y:9,w:1,h:1,c:nt},{x:5,y:9,w:1,h:1,c:nt}],fA=[{x:2,y:8,w:1,h:1,c:De},{x:6,y:8,w:1,h:1,c:De},{x:2,y:9,w:1,h:1,c:nt},{x:6,y:9,w:1,h:1,c:nt}],wm=[{x:8,y:0,w:1,h:1,c:De},{x:9,y:0,w:1,h:1,c:Te},{x:10,y:0,w:1,h:1,c:In},{x:11,y:0,w:1,h:1,c:Te},{x:7,y:1,w:1,h:1,c:nt},{x:8,y:1,w:1,h:1,c:Te},{x:9,y:1,w:1,h:1,c:In},{x:10,y:1,w:1,h:1,c:Te},{x:11,y:1,w:1,h:1,c:Te},{x:12,y:1,w:1,h:1,c:De},{x:0,y:2,w:1,h:1,c:In},{x:1,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:De},{x:4,y:2,w:1,h:1,c:Te},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:Te},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:Te},{x:9,y:2,w:1,h:1,c:Te},{x:10,y:2,w:1,h:1,c:Te},{x:11,y:2,w:1,h:1,c:Te},{x:12,y:2,w:1,h:1,c:De},{x:0,y:3,w:1,h:1,c:De},{x:1,y:3,w:1,h:1,c:nt},{x:3,y:3,w:1,h:1,c:nt},{x:4,y:3,w:1,h:1,c:De},{x:5,y:3,w:1,h:1,c:Te},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:nt},{x:8,y:3,w:1,h:1,c:Te},{x:9,y:3,w:1,h:1,c:Xo},{x:10,y:3,w:1,h:1,c:Te},{x:11,y:3,w:1,h:1,c:De},{x:3,y:4,w:1,h:1,c:nt},{x:4,y:4,w:1,h:1,c:De},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:De},{x:8,y:4,w:1,h:1,c:De},{x:9,y:4,w:1,h:1,c:Te},{x:10,y:4,w:1,h:1,c:ad}],Av=[{x:4,y:5,w:1,h:1,c:De},{x:6,y:5,w:1,h:1,c:De},{x:8,y:5,w:1,h:1,c:De},{x:10,y:5,w:1,h:1,c:De},{x:4,y:6,w:1,h:1,c:nt},{x:6,y:6,w:1,h:1,c:nt},{x:8,y:6,w:1,h:1,c:nt},{x:10,y:6,w:1,h:1,c:nt}],Dv=[{x:3,y:5,w:1,h:1,c:De},{x:5,y:5,w:1,h:1,c:De},{x:9,y:5,w:1,h:1,c:De},{x:11,y:5,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:nt},{x:5,y:6,w:1,h:1,c:nt},{x:9,y:6,w:1,h:1,c:nt},{x:11,y:6,w:1,h:1,c:nt}];function tp(e,n=13){return e.map(a=>({...a,x:n-1-a.x}))}const cy=tp(wm),hA=tp(Av),mA=tp(Dv),pA={down:[[...sy,...cA],[...sy,...uA]],up:[[...oy,...dA],[...oy,...fA]],right:[[...wm,...Av],[...wm,...Dv]],left:[[...cy,...hA],[...cy,...mA]]},xA=[{x:4,y:5,w:1,h:1,c:ep}],_n="#FFD4D4",Jr="#FFCCD5",gA=[{x:2,y:0,w:1,h:1,c:nt},{x:3,y:0,w:1,h:1,c:De},{x:4,y:0,w:1,h:1,c:Te},{x:5,y:0,w:1,h:1,c:In},{x:6,y:0,w:1,h:1,c:De},{x:7,y:0,w:1,h:1,c:nt},{x:1,y:1,w:1,h:1,c:nt},{x:2,y:1,w:1,h:1,c:De},{x:3,y:1,w:1,h:1,c:Te},{x:4,y:1,w:1,h:1,c:In},{x:5,y:1,w:1,h:1,c:Te},{x:6,y:1,w:1,h:1,c:In},{x:7,y:1,w:1,h:1,c:De},{x:8,y:1,w:1,h:1,c:nt},{x:1,y:2,w:1,h:1,c:De},{x:2,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:Xo},{x:4,y:2,w:1,h:1,c:Te},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:Xo},{x:7,y:2,w:1,h:1,c:Te},{x:8,y:2,w:1,h:1,c:De},{x:2,y:3,w:1,h:1,c:De},{x:3,y:3,w:1,h:1,c:Te},{x:4,y:3,w:1,h:1,c:ad},{x:5,y:3,w:1,h:1,c:ep},{x:6,y:3,w:1,h:1,c:Te},{x:7,y:3,w:1,h:1,c:De},{x:2,y:4,w:1,h:1,c:nt},{x:3,y:4,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:Te},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:De},{x:7,y:4,w:1,h:1,c:nt},{x:0,y:5,w:1,h:1,c:De},{x:1,y:5,w:1,h:1,c:Jr},{x:2,y:5,w:1,h:1,c:Te},{x:3,y:5,w:1,h:1,c:_n},{x:4,y:5,w:1,h:1,c:_n},{x:5,y:5,w:1,h:1,c:_n},{x:6,y:5,w:1,h:1,c:_n},{x:7,y:5,w:1,h:1,c:Te},{x:8,y:5,w:1,h:1,c:Jr},{x:9,y:5,w:1,h:1,c:De},{x:1,y:6,w:1,h:1,c:De},{x:2,y:6,w:1,h:1,c:Te},{x:3,y:6,w:1,h:1,c:_n},{x:4,y:6,w:1,h:1,c:Jr},{x:5,y:6,w:1,h:1,c:Jr},{x:6,y:6,w:1,h:1,c:_n},{x:7,y:6,w:1,h:1,c:Te},{x:8,y:6,w:1,h:1,c:De},{x:2,y:7,w:1,h:1,c:Te},{x:3,y:7,w:1,h:1,c:_n},{x:4,y:7,w:1,h:1,c:_n},{x:5,y:7,w:1,h:1,c:_n},{x:6,y:7,w:1,h:1,c:_n},{x:7,y:7,w:1,h:1,c:Te},{x:0,y:8,w:1,h:1,c:De},{x:1,y:8,w:1,h:1,c:Jr},{x:2,y:8,w:1,h:1,c:nt},{x:3,y:8,w:1,h:1,c:De},{x:4,y:8,w:1,h:1,c:Te},{x:5,y:8,w:1,h:1,c:Te},{x:6,y:8,w:1,h:1,c:De},{x:7,y:8,w:1,h:1,c:nt},{x:8,y:8,w:1,h:1,c:Jr},{x:9,y:8,w:1,h:1,c:De},{x:4,y:9,w:1,h:1,c:Te},{x:5,y:9,w:1,h:1,c:In}],yA=[{x:2,y:0,w:1,h:1,c:nt},{x:3,y:0,w:1,h:1,c:De},{x:4,y:0,w:1,h:1,c:Te},{x:5,y:0,w:1,h:1,c:In},{x:6,y:0,w:1,h:1,c:De},{x:7,y:0,w:1,h:1,c:nt},{x:1,y:1,w:1,h:1,c:nt},{x:2,y:1,w:1,h:1,c:De},{x:3,y:1,w:1,h:1,c:Te},{x:4,y:1,w:1,h:1,c:In},{x:5,y:1,w:1,h:1,c:Te},{x:6,y:1,w:1,h:1,c:In},{x:7,y:1,w:1,h:1,c:De},{x:8,y:1,w:1,h:1,c:nt},{x:1,y:2,w:1,h:1,c:De},{x:2,y:2,w:1,h:1,c:Te},{x:3,y:2,w:1,h:1,c:De},{x:4,y:2,w:1,h:1,c:Te},{x:5,y:2,w:1,h:1,c:Te},{x:6,y:2,w:1,h:1,c:De},{x:7,y:2,w:1,h:1,c:Te},{x:8,y:2,w:1,h:1,c:De},{x:2,y:3,w:1,h:1,c:De},{x:3,y:3,w:1,h:1,c:Te},{x:4,y:3,w:1,h:1,c:ad},{x:5,y:3,w:1,h:1,c:ep},{x:6,y:3,w:1,h:1,c:Te},{x:7,y:3,w:1,h:1,c:De},{x:2,y:4,w:1,h:1,c:nt},{x:3,y:4,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:Te},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:De},{x:7,y:4,w:1,h:1,c:nt},{x:0,y:5,w:1,h:1,c:De},{x:1,y:5,w:1,h:1,c:Jr},{x:2,y:5,w:1,h:1,c:Te},{x:3,y:5,w:1,h:1,c:_n},{x:4,y:5,w:1,h:1,c:_n},{x:5,y:5,w:1,h:1,c:_n},{x:6,y:5,w:1,h:1,c:_n},{x:7,y:5,w:1,h:1,c:Te},{x:8,y:5,w:1,h:1,c:Jr},{x:9,y:5,w:1,h:1,c:De},{x:1,y:6,w:1,h:1,c:De},{x:2,y:6,w:1,h:1,c:Te},{x:3,y:6,w:1,h:1,c:_n},{x:4,y:6,w:1,h:1,c:Jr},{x:5,y:6,w:1,h:1,c:Jr},{x:6,y:6,w:1,h:1,c:_n},{x:7,y:6,w:1,h:1,c:Te},{x:8,y:6,w:1,h:1,c:De},{x:2,y:7,w:1,h:1,c:Te},{x:3,y:7,w:1,h:1,c:_n},{x:4,y:7,w:1,h:1,c:_n},{x:5,y:7,w:1,h:1,c:_n},{x:6,y:7,w:1,h:1,c:_n},{x:7,y:7,w:1,h:1,c:Te},{x:0,y:8,w:1,h:1,c:De},{x:1,y:8,w:1,h:1,c:Jr},{x:2,y:8,w:1,h:1,c:nt},{x:3,y:8,w:1,h:1,c:De},{x:4,y:8,w:1,h:1,c:Te},{x:5,y:8,w:1,h:1,c:Te},{x:6,y:8,w:1,h:1,c:De},{x:7,y:8,w:1,h:1,c:nt},{x:8,y:8,w:1,h:1,c:Jr},{x:9,y:8,w:1,h:1,c:De},{x:5,y:9,w:1,h:1,c:Te},{x:6,y:9,w:1,h:1,c:In}],bA=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],vA=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],wA=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],dt=4,ln=28,Ln=2,Mt=4,kt=4,ll=[{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 np(e,n,a){const u=e.fy+Math.max(10,Math.floor(e.fh*.18)),d=Math.min(n,a),f=Math.ceil(n/d),m=[],h=d*28,x=e.fx+Math.max(8,Math.floor((e.fw-h)/2));for(let g=0;g<f&&m.length<n;g++){const v=Math.min(d,n-g*d);for(let b=0;b<v;b++)m.push({dx:x+b*28,dy:u+g*28,room:e.id})}return m}function kA(e){const i=ll[0],o={id:"main",wx:dt+kt,wy:dt,ww:160-2*(dt+kt),wh:ln,fx:dt+kt,fy:dt+ln+Ln,fw:160-2*(dt+kt),fh:120-dt-ln-Ln-dt,...i},u=np(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*(dt+kt))/2),offsetY:10}],f=[{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:f}}function jA(e){const o={id:"exec",wx:dt+kt,wy:dt,ww:144-dt-kt-Mt/2,wh:ln,fx:dt+kt,fy:dt+ln+Ln,fw:144-dt-kt-Mt/2,fh:66,...ll[0]},u={id:"work",wx:144+Mt/2+kt,wy:dt,ww:144-Mt/2-kt-dt,wh:ln,fx:144+Mt/2+kt,fy:dt+ln+Ln,fw:144-Mt/2-kt-dt,fh:66,...ll[1]},d={id:"meet",wx:dt+kt,wy:dt+ln+Ln+66+Mt,ww:144-dt-kt-Mt/2,wh:ln,fx:dt+kt,fy:dt+ln+Ln+66+Mt+ln+Ln,fw:144-dt-kt-Mt/2,fh:70,...ll[2]},f={id:"comm",wx:144+Mt/2+kt,wy:dt+ln+Ln+66+Mt,ww:144-Mt/2-kt-dt,wh:ln,fx:144+Mt/2+kt,fy:dt+ln+Ln+66+Mt+ln+Ln,fw:144-Mt/2-kt-dt,fh:70,...ll[3]},m={exec:o,work:u,meet:d,comm:f},h=[];let x=e;const g=[[o,Math.min(3,x)],[u,0]];g[1][1]=Math.min(3,x-g[0][1]);const v=[[d,0],[f,0]];let b=x-g[0][1]-g[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[R,I]of[...g,...v])I>0&&h.push(...np(R,I,3));const j=dt+ln+Ln+66,k=144-Mt/2,N={exec_work:{id:"exec_work",type:"v",doorY:dt+ln+Ln+20+12,xA:k-2,xB:u.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:dt+ln+Ln+66+Mt+ln+Ln+20+12,xA:k-2,xB:f.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:dt+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:f.fy+2}},E={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},C={exec:o.fy+52,work:u.fy+48,meet:d.fy+56,comm:f.fy+54},_={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:f.fx+96,y:f.fy+8},{x:f.fx+60,y:f.fy+54},{x:f.fx+40,y:f.fy+54},{x:f.fx+20,y:f.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}],H=[{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:h,doors:N,adjacency:E,corridorY:C,waypoints:_,wallDecorations:M,furniture:H}}function SA(e){const d={id:"exec",wx:dt+kt,wy:dt,ww:180-dt-kt-Mt/2,wh:ln,fx:dt+kt,fy:dt+ln+Ln,fw:180-dt-kt-Mt/2,fh:82,...ll[0]},f={id:"work",wx:180+Mt/2+kt,wy:dt,ww:180-Mt/2-kt-dt,wh:ln,fx:180+Mt/2+kt,fy:dt+ln+Ln,fw:180-Mt/2-kt-dt,fh:82,...ll[1]},m=dt+ln+Ln+82,h={id:"meet",wx:dt+kt,wy:m+Mt,ww:180-dt-kt-Mt/2,wh:ln,fx:dt+kt,fy:m+Mt+ln+Ln,fw:180-dt-kt-Mt/2,fh:86,...ll[2]},x={id:"comm",wx:180+Mt/2+kt,wy:m+Mt,ww:180-Mt/2-kt-dt,wh:ln,fx:180+Mt/2+kt,fy:m+Mt+ln+Ln,fw:180-Mt/2-kt-dt,fh:86,...ll[3]},g={exec:d,work:f,meet:h,comm:x},v=[];let b=e;const j=[[d,Math.min(5,b)],[f,0]];j[1][1]=Math.min(5,b-j[0][1]);const k=[[h,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[W,Y]of[...j,...k])Y>0&&v.push(...np(W,Y,4));const E=180-Mt/2,C={exec_work:{id:"exec_work",type:"v",doorY:d.fy+82/2,xA:E-2,xB:f.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:h.fy+86/2,xA:E-2,xB:x.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:d.fx+54,yA:m-2,yB:h.fy+2},work_comm:{id:"work_comm",type:"h",doorX:f.fx+54,yA:m-2,yB:x.fy+2}},_={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:f.fy+82-12,meet:h.fy+86-12,comm:x.fy+86-12},H={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:f.fx+10,y:M.work},{x:f.fx+f.fw/2,y:M.work},{x:f.fx+f.fw-10,y:M.work}],meet:[{x:h.fx+10,y:M.meet},{x:h.fx+h.fw/2,y:M.meet},{x:h.fx+h.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}]},R=[{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(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:g,desks:v,doors:C,adjacency:_,corridorY:M,waypoints:H,wallDecorations:R,furniture:I}}const CA=2;function Tv(e,n,a){return a||(n?n==="L"&&e<=12-CA?"M":n==="M"&&e>12?"L":n:e<=12?"M":"L")}function Fv(e,n){switch(n??Tv(e)){case"S":return kA(e);case"M":return jA(e);case"L":return SA(e)}}function EA(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 NA(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 uy(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 AA(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 Bo;function DA(e){Bo=e}function L(e,n,a,i,o,u){e=Math.round(e),n=Math.round(n),!(u!==void 0&&u<.01)&&(u!==void 0&&u!==1&&(Bo.globalAlpha=u),Bo.fillStyle=o,Bo.fillRect(e,n,a,i),u!==void 0&&u!==1&&(Bo.globalAlpha=1))}function ot(e,n,a,i){L(e,n,1,1,a,i)}let $u=1;function Ts(e){$u=e}function Aa(){return $u=$u*16807%2147483647,($u&65535)/65535}function Rv(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,f=0;const m=(o+u)/2;if(o!==u){const h=o-u;f=m>.5?h/(2-o-u):h/(o+u),o===n?d=((a-i)/h+(a<i?6:0))/6:o===a?d=((i-n)/h+2)/6:d=((n-a)/h+4)/6}return[d*360,f*100,m*100]}function Mv(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 f=(d+e/30)%12;return a-i*Math.max(-1,Math.min(f-3,9-f,1))},u=d=>Math.round(d*255).toString(16).padStart(2,"0");return"#"+u(o(0))+u(o(8))+u(o(4))}function Da(e,n=1){const[a,i,o]=Rv(e);return Mv(a+15*n,Math.min(100,i+8),o-12*n)}function vn(e,n=1){const[a,i,o]=Rv(e);return Mv(a-10*n,i-3,o+10*n)}const $n={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},Or={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},wa={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},ea="#100A06";function TA(e,n,a=14,i=12){L(e,n,a,i,"#4A3828"),L(e+1,n+1,a-2,i-2,"#5A4838"),L(e+2,n+2,a-4,i-4,"#4A7098"),L(e+2,n+2,a-4,Math.floor((i-4)/2),"#6A90B8",.35);const o=Math.floor(a/2);L(e+o,n+1,1,i-2,"#4A3828"),L(e+1,n+Math.floor(i/2),a-2,1,"#4A3828",.5),ot(e+3,n+3,"#8AB8E8",.35),ot(e+o+2,n+3,"#8AB8E8",.25),L(e-1,n+i,a+2,2,"#5A4838"),L(e-1,n+i,a+2,1,vn("#5A4838",.5),.35)}function FA(e,n,a){L(e,n,10,8,"#3A2818"),L(e+1,n+1,8,6,a),L(e+2,n+2,4,3,vn(a,1.2),.3),ot(e+3,n+2,vn(a,2),.25)}function RA(e,n){L(e,n,7,7,"#3A2818"),L(e+1,n+1,5,5,"#F0EDE5"),ot(e+3,n+1,"#AAA"),ot(e+3,n+5,"#AAA"),ot(e+1,n+3,"#AAA"),ot(e+5,n+3,"#AAA"),ot(e+3,n+3,"#222"),L(e+3,n+1,1,2,"#333"),ot(e+4,n+3,"#D32F2F")}function MA(e,n){L(e,n,26,16,"#586878"),L(e+1,n+1,24,13,"#ECEFF1"),L(e+1,n+1,24,1,"#F5F5F5",.4),L(e+3,n+3,14,1,"#1565C0",.6),L(e+3,n+5,18,1,"#333",.2),L(e+3,n+7,12,1,"#D32F2F",.35),L(e+3,n+9,16,1,"#333",.15),L(e+1,n+14,24,2,"#708898"),L(e+3,n+14,3,1,"#D32F2F"),L(e+7,n+14,3,1,"#1565C0"),L(e+11,n+14,3,1,"#2E7D32")}function zA(e,n){L(e,n,22,16,"#6A5030"),L(e+1,n+1,20,14,"#C4A66A"),Ts(88);for(let a=0;a<14;a++)for(let i=0;i<20;i++)Aa()>.5&&ot(e+1+i,n+1+a,Aa()>.5?"#B89858":"#D4B87A",.18);L(e+2,n+2,5,4,"#FFF176"),L(e+8,n+2,5,4,"#90CAF9"),L(e+14,n+3,5,4,"#CE93D8"),L(e+3,n+8,7,4,"#C8E6C9"),L(e+11,n+8,8,4,"#F8BBD0"),ot(e+4,n+2,"#E53935"),ot(e+10,n+2,"#1E88E5"),ot(e+16,n+3,"#FF9800")}function _A(e,n){L(e,n,20,3,"#5A4030"),L(e,n,20,1,vn("#5A4030",.5),.35),L(e,n+2,20,1,Da("#5A4030",.5),.3),L(e+2,n-4,3,4,"#E53935"),L(e+2,n-4,3,1,vn("#E53935",1),.3),L(e+6,n-3,2,3,"#1E88E5"),L(e+9,n-5,4,5,"#43A047"),L(e+14,n-3,3,3,"#FFD54F"),ot(e+15,n-3,"#FFF176",.4)}function BA(e,n){L(e,n,16,12,"#1E1E28"),L(e+1,n+1,14,9,"#0C1420"),L(e+2,n+2,12,1,"#EF4444",.6),ot(e+2,n+4,"#4CAF50"),L(e+4,n+4,7,1,"#8b949e",.4),ot(e+2,n+6,"#FF9800"),L(e+4,n+6,5,1,"#8b949e",.3),ot(e+2,n+8,"#42A5F5"),L(e+4,n+8,8,1,"#8b949e",.25),L(e+7,n+10,2,2,"#1E1E28"),L(e+5,n+11,6,1,"#586878")}function OA(e,n,a){L(e+2,n+20,22,2,ea,.15),L(e,n,22,20,Or.deep),L(e+1,n+1,20,18,Or.base),L(e,n,22,1,Or.hi,.35),L(e,n,1,20,Or.hi,.2);for(const u of[6,12])L(e+1,n+u,20,2,Or.sh),L(e+1,n+u,20,1,Or.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;L(o,n+1,d,5,i[u]),L(o,n+1,d,1,vn(i[u],1),.35),o+=d+1}o=e+2;for(let u=0;u<4;u++)L(o,n+7,4,5,i[u+3]),L(o,n+7,4,1,vn(i[u+3],1),.25),o+=5;L(e+2,n+14,4,4,"#FFD54F"),L(e+8,n+14,7,4,"#90CAF9"),a&&L(e,n-1,22,1,a,.7)}function $A(e,n){L(e+2,n+11,6,2,ea,.1),L(e+2,n+8,6,4,"#8B5E3C"),L(e+1,n+7,8,2,Da("#A06E48",.3)),L(e+2,n+7,6,1,vn("#A06E48",.5),.4),L(e+1,n+3,3,4,"#2E7D32"),L(e+5,n+2,3,4,"#2E7D32"),L(e+2,n+1,4,4,"#43A047"),L(e+3,n+0,3,3,"#66BB6A"),ot(e+4,n,"#81C784"),ot(e+3,n+1,"#A5D6A7",.4)}function LA(e,n){ji(e+4,n-4,"down"),ji(e+16,n-4,"down"),ji(e+28,n-4,"down"),L(e+3,n+24,34,3,ea,.15),L(e,n+2,36,18,$n.deep),L(e+1,n+3,34,16,$n.base),L(e+1,n+3,34,1,$n.hi,.35);for(let a=0;a<14;a+=3)L(e+1,n+4+a,34,1,Da($n.base,.2),.08);L(e,n+20,36,4,$n.deep),L(e+1,n+21,34,2,$n.sh),L(e+6,n+7,10,6,"#1A1A24"),L(e+7,n+8,8,4,"#0C1420"),L(e+8,n+9,4,1,"#2A6898",.4),L(e+20,n+8,6,4,"#F0F0F0"),L(e+15,n+7,3,3,"#ECEFF1"),ot(e+16,n+8,"#795548"),ji(e+4,n+24,"up"),ji(e+16,n+24,"up"),ji(e+28,n+24,"up")}function IA(e,n){L(e+2,n+16,36,3,ea,.15),L(e,n,36,5,"#5D4037"),L(e+1,n+1,34,3,"#6D4C41"),L(e+1,n+1,34,1,vn("#6D4C41",.5),.3),L(e,n+5,36,8,"#5D4037"),L(e+2,n+6,15,6,"#6D4C41"),L(e+3,n+6,13,1,vn("#6D4C41",.5),.35),L(e+19,n+6,15,6,"#6D4C41"),L(e+20,n+6,13,1,vn("#6D4C41",.5),.35),L(e+17,n+6,2,6,"#5D4037"),L(e,n+13,36,3,Da("#5D4037",1)),L(e-2,n+2,3,12,"#5D4037"),L(e+35,n+2,3,12,"#5D4037"),L(e+4,n+7,6,4,"#FF8A65"),L(e+5,n+7,4,1,vn("#FF8A65",1),.35)}function HA(e,n){L(e+2,n+10,22,2,ea,.12),L(e,n,22,8,Or.deep),L(e+1,n+1,20,6,Or.base),L(e+1,n+1,20,1,Or.hi,.3),L(e,n+8,22,2,Or.sh),L(e+3,n+2,6,4,"#F0F0F0"),L(e+13,n+3,3,3,"#ECEFF1"),ot(e+14,n+4,"#795548")}function UA(e,n){L(e+1,n+14,10,2,ea,.12),L(e,n,10,14,"#546E7A"),L(e,n,10,1,vn("#546E7A",1),.35),L(e+1,n+1,8,3,"#78909C"),L(e+1,n+5,8,4,"#37474F"),ot(e+2,n+6,"#EF5350"),ot(e+4,n+6,"#66BB6A"),L(e+2,n+11,4,2,"#ECEFF1")}function qA(e,n){L(e+2,n+18,28,3,ea,.12),L(e,n,28,18,"#37474F"),L(e+1,n+1,26,15,"#0D47A1"),L(e+2,n+2,24,13,"#1565C0"),L(e+2,n+2,24,4,"#1976D2",.4),L(e+2,n+12,24,3,"#F9A825",.35),L(e+4,n+8,2,5,"#2E7D32"),L(e+6,n+9,2,4,"#43A047"),L(e+20,n+7,2,6,"#2E7D32"),L(e+22,n+8,2,5,"#388E3C"),L(e+9,n+5,4,2,"#FF8A65"),ot(e+12,n+5,"#FF5722"),L(e+16,n+8,3,2,"#FFD54F"),ot(e+15,n+8,"#FFC107"),ot(e+13,n+3,"#90CAF9",.5),ot(e+14,n+4,"#BBDEFB",.35),ot(e+8,n+3,"#BBDEFB",.3),L(e,n+16,28,2,"#455A64"),L(e+1,n+16,26,1,vn("#455A64",.5),.3)}function YA(e,n){L(e,n,24,10,"#1A1A2E"),L(e+2,n+1,20,8,"#E040FB",.15),L(e+3,n+2,4,6,"#E040FB",.7),L(e+4,n+3,2,4,"#1A1A2E"),L(e+8,n+2,1,6,"#00E5FF",.7),L(e+8,n+2,4,1,"#00E5FF",.7),L(e+8,n+4,4,1,"#00E5FF",.7),L(e+11,n+2,1,3,"#00E5FF",.7),L(e+13,n+2,1,6,"#E040FB",.7),L(e+13,n+2,4,1,"#E040FB",.7),L(e+13,n+4,3,1,"#E040FB",.7),L(e+13,n+7,4,1,"#E040FB",.7),L(e+18,n+2,1,6,"#00E5FF",.7),L(e+21,n+2,1,6,"#00E5FF",.7),L(e+19,n+3,1,2,"#00E5FF",.5),L(e+20,n+5,1,2,"#00E5FF",.5)}function XA(e,n){L(e+2,n+28,16,3,ea,.15),L(e,n,16,28,"#1A237E"),L(e+1,n+1,14,3,"#283593"),L(e+2,n+4,12,10,"#0D1117"),L(e+3,n+5,10,8,"#1B5E20"),L(e+5,n+6,2,2,"#4CAF50"),L(e+9,n+8,2,2,"#FF5722"),L(e+7,n+10,3,1,"#FFD54F"),ot(e+6,n+7,"#81C784"),L(e+1,n+14,14,6,"#1A237E"),L(e+2,n+15,4,4,"#212121"),ot(e+4,n+16,"#F44336"),ot(e+9,n+16,"#F44336"),ot(e+11,n+16,"#2196F3"),ot(e+10,n+18,"#FFEB3B"),L(e,n+20,16,8,"#0D47A1"),L(e+1,n+21,14,6,"#1565C0"),L(e,n+4,1,14,"#FF4081",.4),L(e+15,n+4,1,14,"#FF4081",.4)}function WA(e,n){L(e+2,n+24,20,3,ea,.15),L(e,n,20,24,"#4E342E"),L(e+1,n+1,18,22,"#5D4037"),L(e+2,n+1,16,4,"#FF6F00"),L(e+3,n+2,14,2,"#FF8F00",.6),L(e+2,n+5,16,10,"#1A1A2E"),L(e+3,n+6,14,8,"#212121"),L(e+4,n+7,4,4,"#333"),L(e+5,n+8,2,2,"#E53935"),L(e+10,n+7,4,4,"#333"),L(e+11,n+8,2,2,"#1E88E5"),L(e+3,n+16,14,6,"#3E2723");for(let a=0;a<7;a++)L(e+4+a*2,n+17,1,4,"#5D4037",.5);L(e+1,n+5,18,1,"#FFD54F",.5),L(e+1,n+15,18,1,"#FFD54F",.5)}function VA(e,n){L(e+2,n+22,22,2,ea,.12),L(e,n,22,22,Or.deep),L(e+1,n+1,20,20,"#37474F"),L(e+2,n+2,18,18,"#546E7A",.3),L(e+1,n+10,20,1,Or.base),L(e+1,n+10,20,1,Or.hi,.2),L(e+4,n+3,4,5,"#FFD54F"),L(e+5,n+4,2,3,"#FFC107"),L(e+4,n+7,4,1,"#FFA000"),ot(e+5,n+3,"#FFF176",.5),L(e+13,n+4,4,4,"#B0BEC5"),L(e+14,n+3,2,1,"#CFD8DC"),ot(e+14,n+5,"#ECEFF1",.6),L(e+5,n+12,3,3,"#A1887F"),L(e+6,n+11,1,1,"#D7CCC8"),L(e+12,n+12,6,4,"#5D4037"),L(e+13,n+13,4,2,"#FFD54F",.6),L(e+2,n+2,2,18,"#fff",.08)}function GA(e,n){L(e+2,n+16,26,3,ea,.18),L(e,n,26,10,$n.deep),L(e+1,n+1,24,8,$n.base),L(e+1,n+2,24,1,$n.hi,.2),L(e+1,n+4,24,1,Da($n.base,.2),.1),L(e+1,n+6,24,1,$n.hi,.15),L(e+1,n+1,24,1,$n.hi,.4),L(e+1,n+1,1,8,$n.hi,.2),L(e,n+10,26,5,$n.deep),L(e+1,n+11,24,3,$n.sh),L(e+1,n+10,24,1,Da($n.base,1.5),.4),L(e+1,n+14,24,1,$n.base,.15),L(e+2,n+12,10,1,$n.deep,.4),L(e+14,n+12,10,1,$n.deep,.4),ot(e+7,n+11,"#C8D0D8",.6),ot(e+19,n+11,"#C8D0D8",.6),L(e+6,n-5,14,7,"#1E1E28"),L(e+7,n-4,12,5,"#0C1420"),L(e+8,n-3,5,1,"#2A6898",.6),L(e+8,n-2,8,1,"#1A3858",.4),L(e+8,n-1,3,1,"#2A6898",.35),ot(e+7,n-4,"#4A98D8",.25),ot(e+12,n+1,"#4CAF50",.4),L(e+12,n+2,2,3,"#586878"),L(e+10,n+4,6,1,"#8898A8"),L(e+6,n+4,12,4,"#222228"),L(e+6,n+4,12,1,"#333338",.4);for(let a=0;a<5;a++)ot(e+7+a*2,n+5,"#444",.6),ot(e+7+a*2,n+6,"#3A3A3E",.4);L(e+20,n+5,3,4,"#333338"),L(e+20,n+5,3,1,"#444448"),L(e+1,n+3,4,4,"#F0EDE8"),L(e+1,n+3,4,1,"#F8F6F2"),ot(e+2,n+5,"#6D4C41")}function ji(e,n,a){L(e+1,n+9,10,2,ea,.1),ot(e+5,n+9,"#1E1E22"),ot(e+1,n+10,"#1A1A1E"),ot(e+9,n+10,"#1A1A1E"),ot(e+3,n+11,"#1A1A1E"),ot(e+7,n+11,"#1A1A1E"),L(e+1,n+2,8,6,wa.base),L(e+2,n+3,6,4,wa.hi,.35),L(e+2,n+3,6,1,vn(wa.hi,.5),.25),L(e+1,n+7,8,1,wa.deep),a==="up"?(L(e,n+7,10,3,wa.deep),L(e+1,n+8,8,1,wa.sh)):(L(e,n-1,10,3,wa.deep),L(e+1,n,8,1,wa.sh)),L(e,n+3,1,4,wa.sh),L(e+9,n+3,1,4,wa.sh)}const zv={bookshelf:(e,n,a)=>OA(e,n,a.accent),plant:(e,n)=>$A(e,n),"meeting-table":(e,n)=>LA(e,n),sofa:(e,n)=>IA(e,n),"coffee-table":(e,n)=>HA(e,n),"coffee-machine":(e,n)=>UA(e,n),window:(e,n,a)=>TA(e,n,a.windowW??16,a.windowH??14),picture:(e,n,a)=>FA(e,n,a.pictureColor??"#1565C0"),clock:(e,n)=>RA(e,n),whiteboard:(e,n)=>MA(e,n),"bulletin-board":(e,n)=>zA(e,n),shelf:(e,n)=>_A(e,n),screen:(e,n)=>BA(e,n),aquarium:(e,n)=>qA(e,n),"neon-sign":(e,n)=>YA(e,n),arcade:(e,n)=>XA(e,n),jukebox:(e,n)=>WA(e,n),"trophy-case":(e,n)=>VA(e,n)};function Ss(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 KA(e){for(const n of e.wallDecorations){const a=e.rooms[n.room];if(!a)continue;const{x:i,y:o}=Ss(n,a),u=zv[n.type];u&&u(i,o,n)}}function PA(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}=Ss(i,o),f=zv[i.type];f&&n.push({y:d,draw:()=>f(u,d,i)})}}function Si(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}=Ss(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 QA={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 km(e){return QA[e]??{w:16,h:16}}function Ih(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:f,y:m}=Ss(u,d),h=km(u.type);if(n>=f&&n<=f+h.w&&a>=m&&a<=m+h.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:f,y:m}=Ss(u,d),h=km(u.type);if(n>=f&&n<=f+h.w&&a>=m&&a<=m+h.h)return u.id}return null}function dy(e,n,a,i,o){const d=[...n.wallDecorations,...n.furniture].find(g=>g.id===a);if(!d||d.condition==="no-desks"&&o.has(d.room))return;const f=n.rooms[d.room];if(!f)return;const{x:m,y:h}=Ss(d,f),x=km(d.type);e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(m-1,h-1,x.w+2,x.h+2),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(m-.5,h-.5,x.w+1,x.h+1),e.restore()}function fy(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 hy(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 my=[{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}],Du=16,ZA=4,ki=4,Lu=2,Wt=4,Wl=4;let Je=Fv(7);const Pu={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},py={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 JA(e,n){const a=py[e]||py.default;return a[n]||a.en||a.default||[]}let ja=Si(Je);function _v(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function Bv(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let wn={};function e8(e){const n={};for(let a=0;a<e.length&&a<Je.desks.length;a++)n[e[a]]=Je.desks[a];return n}let Xe,tr=null,Ci=null,al=!1,oa=null,_r=null,Ov=0,rr=null,On=null,Yl=null,ka=null,Hh=900;function t8(e,n){const{wx:a,wy:i,ww:o,wh:u,wallColor:d,baseboardColor:f}=e,m=Da(d,.5),h=vn(d,.5),x=[];if(n){const g=n.x-a,v=n.w;g>0&&x.push({sx:a,sw:g}),g+v<o&&x.push({sx:n.x+v,sw:o-g-v})}else x.push({sx:a,sw:o});for(const g of x){L(g.sx,i,g.sw,u,d);for(let v=0;v<u;v+=4)L(g.sx,i+v,g.sw,1,h,.08),L(g.sx,i+v+2,g.sw,1,m,.05);Ts(Math.round(g.sx*7+i*13));for(let v=0;v<g.sw;v+=3)Aa()>.4&&L(g.sx+v,i,1,u,h,.04);L(g.sx,i,g.sw,2,h,.3),L(g.sx,i,g.sw,1,vn(d,1),.2),L(g.sx,i+u-2,g.sw,2,m,.3),L(g.sx,i+u,g.sw,Lu,f),L(g.sx,i+u,g.sw,1,vn(f,.5),.4)}n&&(L(n.x-1,i,1,u+Lu,"#4A3828"),L(n.x+n.w,i,1,u+Lu,"#4A3828"),L(n.x,i,n.w,1,"#0A0808",.12)),L(e.fx,e.fy,e.fw,3,"#0A0808",.12),L(e.fx,e.fy+3,e.fw,2,"#0A0808",.06)}function n8(e){const n="#504038",a=Da(n,.5),i=vn(n,.5),o=e.wx-Wl,u=e.wy,d=e.wh+Lu+e.fh;L(o,u,Wl,d,n),L(o,u,1,d,i,.3),L(o+Wl-1,u,1,d,a,.4);for(let m=0;m<d;m+=6)L(o+1,u+m,Wl-2,1,i,.06);const f=e.wx+e.ww;L(f,u,Wl,d,n),L(f,u,1,d,i,.2),L(f+Wl-1,u,1,d,a,.3)}function Uh(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#B08040",d="#C89848",f="#8A6030",m="#6A4820";L(n,a,i,o,u),Ts(42);for(let h=0;h<o;h+=5){const x=Math.floor(h/5)%2*10;for(let g=-10;g<i+10;g+=20){const v=n+g+x,b=Math.max(n,v),j=Math.min(v+19,n+i)-b;if(j<=0)continue;const k=Aa()>.5?d:u;L(b,a+h,j,4,k,.25),L(b,a+h,j,1,d,.3),L(b,a+h+4,j,1,m,.35),v>=n&&v<n+i&&L(v,a+h,1,4,m,.2),L(b,a+h+2,j,1,f,.1)}}L(n,a,i,2,"#0A0808",.08),L(n,a,2,o,"#0A0808",.06)}function xy(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#1C2A38",d="#101820";Ts(99),L(n,a,i,o,u);for(let f=0;f<o;f+=Du)for(let m=0;m<i;m+=Du){const h=Math.min(Du,i-m),x=Math.min(Du,o-f);Aa()>.5&&L(n+m,a+f,h,x,vn(u,.2),.15),L(n+m+2,a+f+2,h-4,x-4,vn(u,.3),.08),L(n+m,a+f,h,1,d,.5),L(n+m,a+f,1,x,d,.5),L(n+m+1,a+f+1,1,x-1,vn(u,.4),.1),Aa()>.85&&ot(n+m+4+Math.floor(Aa()*8),a+f+4+Math.floor(Aa()*8),"#3A6A9A",.08)}}function r8(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#387848",d="#4A9058",f="#285E38";L(n,a,i,o,u),Ts(77);for(let h=0;h<o;h+=2)for(let x=0;x<i;x+=2)Aa()>.5&&ot(n+x,a+h,d,.1),Aa()>.8&&ot(n+x+1,a+h+1,f,.12);const m=5;L(n+m,a+m,i-m*2,1,d,.45),L(n+m,a+o-m-1,i-m*2,1,f,.45),L(n+m,a+m,1,o-m*2,d,.35),L(n+i-m-1,a+m,1,o-m*2,f,.35)}function a8(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#D8C490",d="#B09060",f="#907848";Ts(55);for(let m=0;m<o;m+=8)for(let h=0;h<i;h+=8){const x=Math.min(8,i-h),g=Math.min(8,o-m),v=(h/8+m/8)%2===0?d:u;L(n+h,a+m,x,g,v),L(n+h+1,a+m+1,x-2,1,vn(v,.4),.2),L(n+h+1,a+m+1,1,g-2,vn(v,.4),.15),L(n+h+x-2,a+m+2,1,g-3,Da(v,.4),.15),L(n+h+2,a+m+g-2,x-3,1,Da(v,.4),.15),L(n+h,a+m,x,1,f,.3),L(n+h,a+m,1,g,f,.3)}}function l8(){const{canvasW:e,canvasH:n,rooms:a,doors:i}=Je,o="#2A1E14",u="#3A2E24";if(L(0,0,e,ki,o),L(0,n-ki,e,ki,o),L(0,0,ki,n,o),L(e-ki,0,ki,n,o),L(0,0,e,1,u,.3),L(0,0,1,n,u,.2),!a.exec||!a.work||!a.meet||!a.comm)return;const d=a.exec,f=a.meet,m=e/2,h=m-Wt/2,x=d.fy+d.fh,g=i.exec_work,v=i.meet_comm,b=i.exec_meet,j=i.work_comm,k=24,N=28,E=((g==null?void 0:g.doorY)??d.fy+20)-k/2,C=((b==null?void 0:b.doorX)??ki+Wl+54)-N/2,_=((j==null?void 0:j.doorX)??m+Wt/2+Wl+54)-N/2,M=((v==null?void 0:v.doorY)??f.fy+20)-k/2;L(0,x,C,Wt,o),L(C+N,x,h-C-N,Wt,o),L(h+Wt,x,_-h-Wt,Wt,o),L(_+N,x,e-_-N,Wt,o),L(0,x,C,1,u,.3),L(C+N,x,h-C-N,1,u,.3),L(h+Wt,x,_-h-Wt,1,u,.3),L(_+N,x,e-_-N,1,u,.3),L(h,0,Wt,E,o),L(h,E+k,Wt,x-E-k,o),L(h,x+Wt,Wt,M-x-Wt,o),L(h,M+k,Wt,n-M-k,o),L(h,0,1,E,u,.2),L(h,E+k,1,x-E-k,u,.2),L(h,x+Wt,1,M-x-Wt,u,.2),L(h,M+k,1,n-M-k,u,.2),L(h,E,Wt,k,"#C4A070"),L(h+Wt/2,E,Wt/2,k,"#3A4858"),L(h,M,Wt,k,"#7AA880"),L(h+Wt/2,M,Wt/2,k,"#C8B890");const H="#4A3828";L(h,E-1,Wt,1,H),L(h,E+k,Wt,1,H),L(C-1,x,1,Wt,H),L(C+N,x,1,Wt,H),L(_-1,x,1,Wt,H),L(_+N,x,1,Wt,H),L(h,M-1,Wt,1,H),L(h,M+k,Wt,1,H)}const gy=new Map;function i8(e,n="right"){const a=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${n}`;let i=gy.get(a);if(!i){const o=sm("mini-seated:default"),u=Gb(o,e);let d=u?u.layers.flatMap(f=>f.pixels):[];n==="left"&&d.length>0&&(d=lm(d,12)),i=d,gy.set(a,i)}return i}function s8(e,n,a,i="right"){Vl(Xe,i8(a,i),e,n,a)}function o8(e,n,a,i,o,u="right"){ji(e+8,n+20,"up"),o||s8(e+8,n+0+i,a,u),GA(e,n+14)}function c8(e,n,a,i,o){const u=i in iy?i:"down",d=o%4,f=iy[u][d];Vl(Xe,f,e,n,a);const m=d===1||d===3?-1:0;if(a.accessory&&a.accessory!=="none"){const h=gC(a.accessory,u);h&&h.pixels.length>0&&Vl(Xe,h.pixels,e,n+m,a)}Xe.globalAlpha=1}let Io=[],Ai=!1,Cs=0;function u8(){const e=Object.keys(Je.rooms),n=e[Math.floor(Math.random()*e.length)],a=Je.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 d8(e){if(e.stateTimer--,Ai){Cs++,e.dir="down",e.walkFrame=0,e.tongueTimer++,e.idleTime=0;return}else Cs=0;if(e.state==="idle"){if(e.tongueTimer++,e.idleTime++,e.stateTimer<=0){e.state="walking",e.tongueTimer=0;const n=Object.keys(Je.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=rp(e,i),u=Je.waypoints[i];if(u&&u.length>0){const d=u[Math.floor(Math.random()*u.length)],f=o[o.length-1]??{x:e.x,y:e.y},m=Di(f.x,f.y,d.x,d.y,i);e.path=[...o,...m]}else e.path=o}else{const a=Je.waypoints[e.room];if(a&&a.length>0){const i=a[Math.floor(Math.random()*a.length)];e.path=Di(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(Je.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 f8(e){const n=Math.round(e.x),a=Math.round(e.y);if(Ai&&Cs>90){const d=Math.floor(Cs/12)%2===0?gA:yA;Vl(Xe,wA,n,a),Vl(Xe,d,n,a);return}const i=e.state==="walking"?e.walkFrame:0,o=pA[e.dir][i],u=e.dir==="left"||e.dir==="right";Vl(Xe,u?vA:bA,n,a),Vl(Xe,o,n,a),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&Vl(Xe,xA,n,a)}function h8(e){const n={};let a=0;for(const i of e){const o=wn[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 Di(e,n,a,i,o){const u=Je.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 qh(e,n,a,i){const o=Je.adjacency[a];if(!o)return[];const u=o.find(x=>x.room===i);if(!u)return[];const d=Je.doors[u.door];if(!d)return[];const f=[],m=Je.corridorY[a]??n,h=Je.corridorY[i]??n;if(Math.abs(n-m)>4&&f.push({x:e,y:m}),d.type==="v"){const x=u.side==="A"?d.xA:d.xB,g=u.side==="A"?d.xB:d.xA;f.push({x,y:m}),f.push({x,y:d.doorY}),f.push({x:g,y:d.doorY}),f.push({x:g,y:h})}else{const x=u.side==="A"?d.yA:d.yB,g=u.side==="A"?d.yB:d.yA;f.push({x:d.doorX,y:m}),f.push({x:d.doorX,y:x}),f.push({x:d.doorX,y:g}),f.push({x:d.doorX,y:h})}return f}function rp(e,n){const a=Je.adjacency[e.room];if(!a)return[];if(!a.find(o=>o.room===n)){for(const o of a){const u=Je.adjacency[o.room];if(u!=null&&u.find(d=>d.room===n)){const d=qh(e.x,e.y,e.room,o.room),f=d[d.length-1],m=qh((f==null?void 0:f.x)??e.x,(f==null?void 0:f.y)??e.y,o.room,n);return[...d,...m]}}return[]}return qh(e.x,e.y,e.room,n)}function m8(e){if(e.room!==e.homeRoom){const n=rp({...e},e.homeRoom),a=n[n.length-1],i=Di((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 Di(e.x,e.y,e.homeX,e.homeY,e.room)}function p8(e,n){if(Hh--,Hh<=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}Hh=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++,tr===a){i.sittingTime=0,i.bobY=-3;const u=wn[a];if(u){const d=u.dx+13;i.lookDir=Ov<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(Je.rooms);if(Math.random()<.15&&u.length>1){const d=u.filter(x=>x!==i.room),f=d[Math.floor(Math.random()*d.length)],m=rp(i,f),h=Je.waypoints[f];if(h&&h.length>0){const x=h[Math.floor(Math.random()*h.length)],g=m[m.length-1]??{x:i.x,y:i.y},v=Di(g.x,g.y,x.x,x.y,f);i.path=[...m,...v]}else i.path=m;i.walkTimer=0}else{const d=Je.waypoints[i.room];if(d&&d.length>0){const f=d[Math.floor(Math.random()*d.length)];i.path=Di(i.x,i.y,f.x,f.y,i.room)}i.walkTimer=0}}}else if(i.state==="walking"||i.state==="returning"){if(i.sittingTime=0,tr===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,f=u.y-i.y,m=Math.sqrt(d*d+f*f);if(m<1.5){i.x=u.x,i.y=u.y,i.path.shift();for(const[h,x]of Object.entries(Je.rooms))if(i.x>=x.fx&&i.x<=x.fx+x.fw&&i.y>=x.fy&&i.y<=x.fy+x.fh){i.room=h;break}}else i.x+=d/m*.2,i.y+=f/m*.2,Math.abs(d)>Math.abs(f)?i.dir=d>0?"right":"left":i.dir=f>0?"down":"up",i.walkTimer++,i.walkFrame=Math.floor(i.walkTimer/12)%4}else if(i.state==="idle"){if(tr===a){i.dir="down";continue}if(i.stateTimer<=0)if(Math.random()<.15){i.state="walking";const o=Je.waypoints[i.room];if(o&&o.length>0){const u=o[Math.floor(Math.random()*o.length)];i.path=Di(i.x,i.y,u.x,u.y,i.room)}i.walkTimer=0}else i.state="returning",i.path=m8(i),i.walkTimer=0}}function x8(e,n,a,i){const{canvasW:o,canvasH:u,rooms:d}=Je;Xe.clearRect(0,0,o,u),L(0,0,o,u,"#2A1E14");const f={wood:Uh,dark:xy,carpet:r8,tile:a8};for(const b of Object.values(d))(f[b.floorType]??Uh)(b);const m=Object.keys(d);if(m.length>=4){const b=d.exec,j=d.meet,{doors:k}=Je;if(b&&j&&k.exec_meet&&k.work_comm){const E=(k.exec_meet.doorX??0)-14,C=(k.work_comm.doorX??0)-28/2,_=b.fy+b.fh,M=j.fy;Uh({fx:E,fy:_,fw:28,fh:M-_}),xy({fx:C,fy:_,fw:28,fh:M-_})}}const h={};if(m.length>=4){const{doors:b}=Je,j=28,k=b.exec_meet,N=b.work_comm;k!=null&&k.doorX&&(h.meet={x:k.doorX-j/2,w:j}),N!=null&&N.doorX&&(h.comm={x:N.doorX-j/2,w:j})}for(const b of Object.values(d))t8(b,h[b.id]),n8(b);l8(),KA(Je);const x=[],g=new Set(Object.values(wn).map(b=>b.room));PA(Je,x,g);for(const[b,j]of Object.entries(wn)){const k=e[b];if(!k)continue;const N=k.state==="sitting",E=n(b),C=Wn(a[b]),_=k.isStretching&&k.stretchTimer>0?Math.sin(k.stretchTimer*.15)*1:0;x.push({y:j.dy+14,draw:()=>{const M=N?k.bobY+_:0;if(o8(j.dx,j.dy,E,M,!N,k.lookDir),N&&C){const H=Pu[b]??"#388bfd";L(j.dx+7,j.dy+14-4,12,5,H,.15),ot(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:()=>c8(Math.round(j.x),Math.round(j.y),k,j.dir,j.walkFrame)})}i&&x.push({y:i.y+10,draw:()=>f8(i)}),x.sort((b,j)=>b.y-j.y);for(const b of x)b.draw();for(const b of ja){const j=Ci===b.id,k=Bv(b);if(Xe.save(),Xe.globalAlpha=j?.9:.5,Xe.fillStyle=b.color,Xe.fillRect(k.cx-1,k.botY-2,3,3),j){const N=_v(b);Xe.globalAlpha=.3,Xe.strokeStyle=b.color,Xe.lineWidth=1,Xe.strokeRect(N.x-1,N.y-1,N.w+2,N.h+2)}Xe.restore()}if(al){const b=new Set(Object.values(wn).map(j=>j.room));if(oa&&oa!==_r)if(oa.startsWith("desk:")){const j=oa.slice(5),k=wn[j];k&&fy(Xe,k.dx,k.dy,"#FBBF24")}else dy(Xe,Je,oa,"#FBBF24",b);if(_r)if(_r.startsWith("desk:")){const j=_r.slice(5),k=wn[j];k&&fy(Xe,k.dx,k.dy,"#3B82F6")}else dy(Xe,Je,_r,"#3B82F6",b)}if(tr){const b=wn[tr],j=e[tr];if(b&&j){Xe.save(),Xe.globalAlpha=.25,Xe.fillStyle=Pu[tr]??"#fff",j.state==="sitting"?Xe.fillRect(b.dx-1,b.dy+6,28,30):Xe.fillRect(Math.round(j.x)-1,Math.round(j.y)-1,14,24),Xe.globalAlpha=.95,Xe.fillStyle="#FBBF24",Xe.font="bold 8px monospace",Xe.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;Xe.fillText("!",k,N),Xe.restore()}}const v=3600;for(const[,b]of Object.entries(e))if(b.state==="sitting"&&b.sittingTime>v&&!b.isStretching){const j=Object.values(wn).find(M=>M.dx+8===b.homeX&&M.dy+34===b.homeY);if(!j)continue;const k=j.dx+13,N=j.dy,E=Math.floor(b.sittingTime/40)%3;Xe.save(),Xe.font="5px monospace",Xe.textAlign="center";const C=[.7,.5,.3],_=[{x:3,y:-2-E},{x:6,y:-5-(E+1)%3},{x:4,y:-8-(E+2)%3}];for(let M=0;M<3;M++)Xe.globalAlpha=C[M],Xe.fillStyle="#93C5FD",Xe.font=`${4+M}px monospace`,Xe.fillText("z",k+_[M].x,N+_[M].y);Xe.restore()}Io=Io.filter(b=>b.life>0);for(const b of Io)b.x+=b.vx,b.y+=b.vy,b.life--,Xe.save(),Xe.globalAlpha=Math.min(1,b.life/(b.maxLife*.3)),Xe.fillStyle=b.color??"#FF6B8A",Xe.font="8px serif",Xe.fillText(b.char,Math.round(b.x),Math.round(b.y)),Xe.restore();if(Ai&&i&&Cs<=90){const b=Math.round(i.x),j=Math.round(i.y);Xe.save(),Xe.globalAlpha=.9,Xe.fillStyle="#FBBF24",Xe.font="bold 5px monospace",Xe.textAlign="center",Xe.fillText("!",b+4,j-2),Xe.restore()}if(i&&!Ai&&i.state==="idle"&&i.idleTime>600){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(i.idleTime/40)%3;Xe.save();const N=[{x:3,y:-2-k},{x:5,y:-5-(k+1)%3},{x:4,y:-8-(k+2)%3}];for(let E=0;E<3;E++)Xe.globalAlpha=[.7,.5,.3][E],Xe.fillStyle="#93C5FD",Xe.font=`${3+E}px monospace`,Xe.textAlign="center",Xe.fillText("z",b+N[E].x,j+N[E].y);Xe.restore()}if(Ai&&i&&Cs<=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"&&(Xe.fillStyle="#FAFAF7",Xe.fillRect(b+4+k,j-1,2,2))}}function g8(e,n){for(let a=0;a<4;a++)Io.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 y8(e,n){for(let a=0;a<3;a++)Io.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:"💧",color:"#64B5F6"})}function b8({roles:e,projects:n,roleStatuses:a,activeExecs:i,onRoleClick:o,onProjectClick:u,onBulletinClick:d,onDecisionsClick:f,onKnowledgeClick:m,onSettingsClick:h,onThemeClick:x,onStatsClick:g,getRoleSpeech:v,getAppearance:b,onHireClick:j,onMascotClick:k,roleLevels:N,coinBalance:E=0,onCoinsSpent:C,onFurniturePlaced:_,purchasedPreset:M,language:H="en"}){const R=w.useRef(null),I=w.useRef(null),W=w.useRef(null),Y=w.useRef({}),D=w.useRef(null),O=w.useRef(0),B=w.useRef(ZA),[ee,re]=w.useState(!1),[K,q]=w.useState(null),[ce,ue]=w.useState(null),V=w.useRef({}),A=w.useRef({}),$=w.useRef([]),U=w.useRef([]);w.useEffect(()=>{al=ee},[ee]),w.useEffect(()=>{Yl=K,ka=ce},[K,ce]);const[T,se]=w.useState(!1);w.useEffect(()=>{pe.getPreferences().then(me=>{const je=me.furnitureOverrides;je&&Object.keys(je).length>0&&(V.current=je);const Ne=me.deskOverrides;Ne&&Object.keys(Ne).length>0&&(A.current=Ne);const G=me.removedFurniture;G&&G.length>0&&($.current=G);const Z=me.addedFurniture;Z&&Z.length>0&&(U.current=Z),se(!0)}).catch(()=>{se(!0)})},[]);const ke=w.useRef({roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b});ke.current={roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b};const he=w.useRef({}),_e=w.useMemo(()=>e.map(me=>me.id),[e]),Le=w.useRef(Je);w.useEffect(()=>{if(!T)return;const me=_e.length,je=Tv(me,Le.current.preset,M),Ne=Le.current.preset!==je;let G=Fv(me,je);$.current.length>0&&(G=uy(G,$.current)),U.current.length>0&&(G=AA(G,U.current)),Object.keys(V.current).length>0&&(G=EA(G,V.current)),Je=G,Le.current=G,wn=e8(_e),Object.keys(A.current).length>0&&NA(wn,A.current),ja=Si(G),Y.current=h8(_e),D.current=u8();const Z=R.current;Z&&(Z.width=G.canvasW,Z.height=G.canvasH,Ne&&(Z.style.opacity="0",Z.style.transition="opacity 0.3s",setTimeout(()=>{Z.style.opacity="1"},50))),et()},[_e,M,T]);const Ue=w.useCallback(me=>{var je,Ne;return((Ne=(je=ke.current).getAppearance)==null?void 0:Ne.call(je,me))??Zm(me)},[]),et=w.useCallback(()=>{const me=I.current,je=R.current;if(!me||!je)return;const Ne=me.parentElement;if(!Ne)return;const G=Ne.clientWidth,Z=Ne.clientHeight;if(G===0||Z===0)return;const{canvasW:ye,canvasH:ge}=Je;let Ee=Math.min(G/ye,Z/ge);Ee=Math.round(Ee*2)/2,Ee=Math.max(2,Math.min(Ee,5)),B.current=Ee,je.style.width=ye*Ee+"px",je.style.height=ge*Ee+"px",me.style.width=ye*Ee+"px",me.style.height=ge*Ee+"px"},[]);w.useEffect(()=>{var ge;const me=R.current;if(!me)return;const je=me.getContext("2d");if(!je)return;Xe=je,DA(je),et();const Ne=new ResizeObserver(()=>et()),G=(ge=I.current)==null?void 0:ge.parentElement;G&&Ne.observe(G);let Z;const ye=()=>{O.current++,p8(Y.current,O.current),D.current&&d8(D.current),x8(Y.current,Ue,ke.current.roleStatuses,D.current),Pe(),Z=requestAnimationFrame(ye)};return Z=requestAnimationFrame(ye),()=>{cancelAnimationFrame(Z),Ne.disconnect()}},[Ue,et]),w.useEffect(()=>{var ye;const me=W.current;if(!me)return;me.innerHTML="";const je={};for(const ge of e)je[ge.id]=ge.name;for(const ge of _e){const Ee=Pu[ge]??"#8b949e",Fe=je[ge],Be=Fe&&Fe.toLowerCase()!==ge.toLowerCase()?`${ge.toUpperCase()} · ${Fe}`:ge.toUpperCase(),Oe=document.createElement("div");Oe.className="td-nametag",Oe.dataset.role=ge;const qe=document.createElement("span");qe.className="td-dot",qe.style.background=Ee,Oe.appendChild(qe),Oe.appendChild(document.createTextNode(Be));const at=((ye=N==null?void 0:N[ge])==null?void 0:ye.level)??1;if(at>1){const Dt=document.createElement("span");Dt.className="td-lvl",Dt.textContent=`Lv.${at}`,Oe.appendChild(Dt)}me.appendChild(Oe);const We=document.createElement("div");We.className="td-bubble",We.dataset.role=ge,We.dataset.type="bubble",me.appendChild(We)}const Ne={meeting:()=>{const ge=n[0];ge?u(ge.id):d()},bulletin:d,decisions:f,knowledge:m,settings:h,theme:x,stats:g};for(const ge of ja){const Ee=document.createElement("div");Ee.className="td-facility-label",Ee.dataset.facility=ge.id,ge.id==="meeting"&&(Ee.dataset.questTarget="meeting-room"),ge.id==="knowledge"&&(Ee.dataset.questTarget="knowledge-hub"),ge.id==="bulletin"&&(Ee.dataset.questTarget="bulletin-board"),ge.id==="stats"&&(Ee.dataset.questTarget="stats-btn"),ge.id==="settings"&&(Ee.dataset.questTarget="settings-btn"),ge.id==="theme"&&(Ee.dataset.questTarget="theme-btn"),Ee.textContent=`${ge.icon} ${ge.label}`,Ee.style.borderColor=`${ge.color}44`;const Fe=Ne[ge.id];Fe&&Ee.addEventListener("click",Fe),Ee.addEventListener("mouseenter",()=>{Ci=ge.id}),Ee.addEventListener("mouseleave",()=>{Ci=null}),me.appendChild(Ee)}const G=document.createElement("div");G.className="td-nametag td-nametag-mascot",G.dataset.role="mascot";const Z=document.createElement("span");Z.className="td-dot",Z.style.background="#ffd700",G.appendChild(Z),G.appendChild(document.createTextNode("Pupu")),G.addEventListener("click",()=>k==null?void 0:k()),me.appendChild(G)},[_e,e,n,u,d,f,m,h,x,g,k,N]);const Pe=w.useCallback(()=>{var Fe;const me=W.current;if(!me)return;const je=B.current,Ne=Y.current,{getRoleSpeech:G,roleStatuses:Z,activeExecs:ye}=ke.current;for(const Be of Object.keys(Ne)){const Oe=Ne[Be],qe=wn[Be];if(!qe)continue;let at,We,Dt;Oe.state==="sitting"?(at=qe.dx+13,Dt=qe.dy+2,We=qe.dy+37):(at=Math.round(Oe.x)+6,Dt=Math.round(Oe.y)-2,We=Math.round(Oe.y)+18);const ze=at/Je.canvasW*100,He=me.querySelector(`.td-nametag[data-role="${Be}"]`);if(He){He.style.left=ze+"%",He.style.top=We*je+2+"px";const _t=He.querySelector(".td-dot");if(_t){const Bt=Wn(Z[Be]);_t.style.background=Bt?"#FBBF24":Pu[Be]??"#8b949e",Bt?_t.style.animation="td-pulse 1s ease-in-out infinite":_t.style.animation=""}}const qt=me.querySelector(`.td-bubble[data-role="${Be}"]`);if(qt){const _t=Date.now(),Bt=Wn(Z[Be]),Jt=(Fe=ye.find(Kt=>Kt.roleId===Be))==null?void 0:Fe.task,kn=G(Be);let J="";const $e=he.current[Be];if($e){if($e.speechDismissTime&&_t>=$e.speechDismissTime&&($e.currentSpeech=null,$e.speechDismissTime=null),$e.hoverStartTime&&!$e.currentSpeech){const Kt=_t-$e.hoverStartTime,ve=!$e.lastSpeechTime||_t-$e.lastSpeechTime>=5e3;if(Kt>=2e3&&ve){const wt=JA(Be,H),jn=wt[Math.floor(Math.random()*wt.length)];$e.currentSpeech=jn,$e.lastSpeechTime=_t,$e.speechDismissTime=_t+3e3}}J=$e.currentSpeech||""}const lt=Bt&&Jt?Jt.slice(0,60):J?J.slice(0,60):kn?kn.slice(0,60):"";lt&&Oe.state==="sitting"?(qt.style.display="",qt.style.left=ze+"%",qt.style.top=(Dt-10)*je+"px",qt.textContent=lt):qt.style.display="none"}}const ge=me.querySelector(".td-nametag-mascot"),Ee=D.current;if(ge&&Ee){const Be=Ee.dir==="left"||Ee.dir==="right",Oe=Math.round(Ee.x)+(Be?6:4),qe=Math.round(Ee.y)+(Be?7:10);ge.style.left=Oe/Je.canvasW*100+"%",ge.style.top=qe*je+2+"px"}for(const Be of ja){const Oe=me.querySelector(`.td-facility-label[data-facility="${Be.id}"]`);if(Oe){const qe=Bv(Be);Oe.style.left=qe.cx/Je.canvasW*100+"%",Oe.style.top=qe.botY*je-4+"px",Oe.classList.toggle("td-facility-label--hover",Ci===Be.id)}}},[]),Ge=w.useCallback(me=>{const je=R.current;if(!je)return null;const Ne=je.getBoundingClientRect(),G=B.current,Z=(me.clientX-Ne.left)/G,ye=(me.clientY-Ne.top)/G,ge=Y.current;for(const[Fe,Be]of Object.entries(wn)){if(!ge[Fe])continue;const Oe=ge[Fe];if(Oe.state==="sitting"){if(Z>=Be.dx&&Z<=Be.dx+26&&ye>=Be.dy&&ye<=Be.dy+40)return{type:"role",id:Fe}}else if(Z>=Oe.x-2&&Z<=Oe.x+14&&ye>=Oe.y-2&&ye<=Oe.y+20)return{type:"role",id:Fe}}const Ee=D.current;if(Ee){const Fe=Ee.dir==="left"||Ee.dir==="right",Be=Fe?13:9,Oe=Fe?7:10;if(Z>=Ee.x&&Z<=Ee.x+Be&&ye>=Ee.y&&ye<=Ee.y+Oe)return{type:"mascot",id:"mascot"}}for(const Fe of ja){const Be=_v(Fe);if(Z>=Be.x&&Z<=Be.x+Be.w&&ye>=Be.y&&ye<=Be.y+Be.h)return{type:"facility",id:Fe.id}}return null},[]),Ce=w.useCallback(me=>{const je=R.current;if(!je)return{mx:0,my:0};const Ne=je.getBoundingClientRect(),G=B.current;return{mx:(me.clientX-Ne.left)/G,my:(me.clientY-Ne.top)/G}},[]),Ae=w.useCallback(me=>{pe.updatePreferences(me).catch(()=>{})},[]),yt=w.useCallback(me=>{const je=U.current.some(G=>G.id===me),Ne={};if(je){const G=U.current.filter(Z=>Z.id!==me);U.current=G,Ne.addedFurniture=G}else{const G=[...$.current,me];$.current=G,Ne.removedFurniture=G}Je=uy(Je,[me]),ja=Si(Je),_r=null,oa=null,Ae(Ne)},[Ae]),ct=w.useCallback((me,je)=>{if(!Yl||!ka)return;const Ne=my.find(Oe=>Oe.type===Yl),G=(Ne==null?void 0:Ne.price)??0;if(G>0&&E<G)return;let Z=null;for(const[Oe,qe]of Object.entries(Je.rooms)){const at=ka==="wall"?qe.wx:qe.fx,We=ka==="wall"?qe.wy:qe.fy,Dt=ka==="wall"?qe.ww:qe.fw,ze=ka==="wall"?qe.wh:qe.fh;if(me>=at&&me<=at+Dt&&je>=We&&je<=We+ze){Z=Oe;break}}if(!Z)return;const ye=Je.rooms[Z],ge=ka==="wall"?ye.wx:ye.fx,Ee=ka==="wall"?ye.wy:ye.fy,Fe={id:`user-${Yl}-${Date.now()}`,type:Yl,room:Z,zone:ka,offsetX:Math.round(me-ge),offsetY:Math.round(je-Ee)},Be=[...U.current,Fe];if(U.current=Be,ka==="wall"?Je.wallDecorations.push(Fe):Je.furniture.push(Fe),ja=Si(Je),Ae({addedFurniture:Be}),_==null||_(Yl,G),G>0){const Oe=Fe.type;Dy(async()=>{const{api:qe}=await Promise.resolve().then(()=>Fw);return{api:qe}},void 0).then(({api:qe})=>{qe.spendCoins(G,`furniture: ${Oe}`,Fe.id).then(at=>C==null?void 0:C(at.balance)).catch(()=>{})})}q(null),ue(null)},[Ae,E,C,_]),xt=w.useCallback(me=>{const je=R.current;if(al&&rr){const{mx:ge,my:Ee}=Ce(me),Be=[...Je.furniture,...Je.wallDecorations].find(at=>at.id===rr.defId);if(!Be)return;const Oe=ge-rr.startMx,qe=Ee-rr.startMy;Be.offsetX=Math.round(rr.origOffX+Oe),Be.offsetY=Math.round(rr.origOffY+qe),ja=Si(Je),je&&(je.style.cursor="grabbing");return}if(al&&On){const{mx:ge,my:Ee}=Ce(me),Fe=wn[On.roleId];if(!Fe)return;Fe.dx=Math.round(On.origDx+(ge-On.startMx)),Fe.dy=Math.round(On.origDy+(Ee-On.startMy));const Be=Y.current[On.roleId];Be&&(Be.homeX=Fe.dx+8,Be.homeY=Fe.dy+34),je&&(je.style.cursor="grabbing");return}if(al){const{mx:ge,my:Ee}=Ce(me);if(Yl){je&&(je.style.cursor="crosshair");return}const Fe=new Set(Object.values(wn).map(Oe=>Oe.room)),Be=Ih(Je,ge,Ee,Fe);if(Be)oa=Be;else{const Oe=hy(wn,ge,Ee);oa=Oe?`desk:${Oe}`:null}tr=null,Ci=null,je&&(je.style.cursor=oa?"grab":"default");return}const Ne=Ge(me),G=tr;tr=(Ne==null?void 0:Ne.type)==="role"?Ne.id:null,Ci=(Ne==null?void 0:Ne.type)==="facility"?Ne.id:null,Ai=(Ne==null?void 0:Ne.type)==="mascot",oa=null,je&&(je.style.cursor=Ne?"pointer":"default");const{mx:Z}=Ce(me);Ov=Z;const ye=Date.now();if(tr&&tr!==G){he.current[tr]||(he.current[tr]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const ge=he.current[tr];ge.hoverStartTime=ye}else if(!tr&&G){const ge=he.current[G];ge&&(ge.hoverStartTime=null)}},[Ge,Ce]),Ct=w.useCallback(me=>{if(!al)return;const{mx:je,my:Ne}=Ce(me);if(Yl){ct(je,Ne),me.preventDefault();return}const G=new Set(Object.values(wn).map(ge=>ge.room)),Z=Ih(Je,je,Ne,G);if(Z){const Ee=[...Je.furniture,...Je.wallDecorations].find(Fe=>Fe.id===Z);Ee&&(_r=Z,rr={defId:Z,startMx:je,startMy:Ne,origOffX:Ee.offsetX,origOffY:Ee.offsetY},me.preventDefault());return}const ye=hy(wn,je,Ne);if(ye){const ge=wn[ye];_r=`desk:${ye}`,On={roleId:ye,startMx:je,startMy:Ne,origDx:ge.dx,origDy:ge.dy},me.preventDefault();return}_r=null},[Ce,ct]),Ht=w.useCallback(me=>{if(rr){const Ne=[...Je.furniture,...Je.wallDecorations].find(G=>G.id===rr.defId);if(Ne){const G={...V.current,[Ne.id]:{offsetX:Ne.offsetX,offsetY:Ne.offsetY}};V.current=G,Ae({furnitureOverrides:G}),ja=Si(Je)}rr=null,R.current&&(R.current.style.cursor="grab");return}if(On){const je=wn[On.roleId];if(je){const Ne={...A.current,[On.roleId]:{dx:je.dx,dy:je.dy}};A.current=Ne,Ae({deskOverrides:Ne})}On=null,R.current&&(R.current.style.cursor="grab")}},[Ae]),zt=w.useCallback(me=>{if(!al)return;me.preventDefault();const{mx:je,my:Ne}=Ce(me),G=new Set(Object.values(wn).map(ye=>ye.room)),Z=Ih(Je,je,Ne,G);Z&&yt(Z)},[Ce,yt]);w.useEffect(()=>{const me=je=>{!al||!_r||(je.key==="Delete"||je.key==="Backspace")&&(_r.startsWith("desk:")||yt(_r))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[yt]);const jt=w.useCallback(()=>{if(rr){const je=[...Je.furniture,...Je.wallDecorations].find(Ne=>Ne.id===rr.defId);je&&(je.offsetX=rr.origOffX,je.offsetY=rr.origOffY,ja=Si(Je)),rr=null}if(On){const me=wn[On.roleId];me&&(me.dx=On.origDx,me.dy=On.origDy);const je=Y.current[On.roleId];je&&(je.homeX=me.dx+8,je.homeY=me.dy+34),On=null}tr=null,Ci=null,Ai=!1,oa=null,R.current&&(R.current.style.cursor="default")},[]),Hn=w.useCallback(me=>{if(al)return;const je=Ge(me);if(je){if(je.type==="role"){const Ne=Y.current[je.id],G=wn[je.id];if(Ne&&G){const Z=Ne.state==="sitting"?G.dx+13:Math.round(Ne.x)+6,ye=Ne.state==="sitting"?G.dy+2:Math.round(Ne.y)-2;y8(Z,ye)}o(je.id);return}if(je.type==="mascot"){const Ne=D.current;Ne&&g8(Math.round(Ne.x)+4,Math.round(Ne.y)-2),k==null||k();return}switch(je.id){case"meeting":{const Ne=n[0];Ne?u(Ne.id):d();break}case"bulletin":d();break;case"decisions":f();break;case"knowledge":m();break;case"settings":h==null||h();break;case"theme":x==null||x();break;case"stats":g==null||g();break}}},[Ge,o,u,d,f,m,h,x,g]);return l.jsxs("div",{className:`td-scene${ee?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:I,className:"td-wrap",children:[l.jsx("canvas",{ref:R,width:Je.canvasW,height:Je.canvasH,className:"td-canvas",onClick:Hn,onMouseDown:Ct,onMouseUp:Ht,onMouseMove:xt,onMouseLeave:jt,onContextMenu:zt}),l.jsx("div",{ref:W,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:()=>{re(me=>{const je=!me;return je||(q(null),ue(null)),je}),_r=null,rr=null,On=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:my.map(me=>{const je=me.price===0||E>=me.price,Ne=me.price===0?"Free":`${me.price>=1e3?`${(me.price/1e3).toFixed(me.price%1e3===0?0:1)}K`:me.price}`;return l.jsxs("button",{className:`td-palette__item${K===me.type?" td-palette__item--active":""}${je?"":" td-palette__item--locked"}`,onClick:()=>{je&&(K===me.type?(q(null),ue(null)):(q(me.type),ue(me.zone)))},title:`${me.label} — ${Ne}`,style:je?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:me.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:me.price===0?"#4CAF50":je?"#FFD54F":"#EF5350"},children:Ne})]},me.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 v8({role:e,appearance:n,onSave:a,onReset:i,onClose:o,theme:u,onThemeChange:d,onUpdateName:f,initialTab:m,characterOnly:h,speechSettings:x,onSpeechSettingsChange:g,language:v,onLanguageChange:b,roleLevel:j,coinBalance:k,purchased:N,onPurchase:E}){var re;const[C,_]=w.useState(m??"character"),[M,H]=w.useState({...n}),[R,I]=w.useState(e.name),[W,Y]=w.useState(!1),D=w.useCallback(()=>H(ys(j)),[j]),O=w.useCallback(()=>{const K=Zm(e.id);H({...K}),i()},[e.id,i]),B=w.useCallback(async()=>{a(M);const K=R.trim();if(f&&K&&K!==e.name){Y(!0);try{await f(e.id,K)}catch{}Y(!1)}o()},[M,a,o,R,e.name,e.id,f]),ee=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," –"]}),f?l.jsx("input",{value:R,onChange:K=>I(K.target.value),disabled:W,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:K=>K.stopPropagation(),children:[l.jsxs("div",{className:"customize-header",children:[l.jsxs("div",{className:"customize-tabs",children:[l.jsx("button",{className:`customize-tab ${C==="character"?"active":""}`,onClick:()=>_("character"),children:"CHARACTER"}),!h&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${C==="office"?"active":""}`,onClick:()=>_("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${C==="settings"?"active":""}`,onClick:()=>_("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:o,children:"X"})]}),C==="character"?l.jsx("div",{className:"customize-body",children:l.jsx(vv,{roleId:e.id,appearance:M,onChange:H,onRandomize:D,onReset:O,label:ee,roleLevel:j,coinBalance:k,purchased:N,onPurchase:E})}):C==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(ol).map(([K,q])=>l.jsxs("button",{className:`customize-theme-card ${u===K?"active":""}`,onClick:()=>d(K),children:[l.jsxs("div",{className:"customize-theme-preview",style:{background:q.vars["--floor-light"],borderColor:q.vars["--pixel-border"]},children:[l.jsx("div",{style:{background:q.vars["--hud-bg"],height:8,borderBottom:`2px solid ${q.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:q.vars["--accent"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:q.vars["--active-green"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:q.vars["--idle-amber"],borderRadius:1}})]}),l.jsx("div",{style:{background:q.vars["--hud-bg"],height:6,borderTop:`2px solid ${q.vars["--pixel-border"]}`}})]}),l.jsxs("div",{className:"customize-theme-name",children:[q.icon," ",q.name]})]},K))})}):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(K=>l.jsxs("button",{onClick:()=>g==null?void 0:g({mode:K}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(x==null?void 0:x.mode)===K?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(x==null?void 0:x.mode)===K?"rgba(255,255,255,0.08)":"transparent",color:(x==null?void 0:x.mode)===K?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:K==="template"?"TEMPLATE":K==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:K==="template"?"Static pool ($0)":K==="llm"?"LLM generated":"Detect engine"})]},K))}),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:K=>g==null?void 0:g({intervalSec:Number(K.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: $",((re=x==null?void 0:x.dailyBudgetUsd)==null?void 0:re.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(x==null?void 0:x.dailyBudgetUsd)??1,onChange:K=>g==null?void 0:g({dailyBudgetUsd:Number(K.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:K,label:q})=>l.jsx("button",{onClick:()=>b==null?void 0:b(K),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(v??"auto")===K?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(v??"auto")===K?"rgba(255,255,255,0.08)":"transparent",color:(v??"auto")===K?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:q},K))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]})]})}),C==="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:B,children:"SAVE"})]})]})})}function yy(e){if(e.length===0)return"";const n={};for(const{file:f}of e){const m=f.split("/"),h=m[0]==="."?m[1]??"root":m[0];(n[h]??(n[h]=[])).push(f)}const a={roles:"roles",projects:"projects",operations:"operations",knowledge:"knowledge",architecture:"architecture",company:"company",".tycono":"config",".claude":"skills"},i=[];for(const[f,m]of Object.entries(n)){const h=a[f]??f;if(m.length===1){const x=m[0].split("/").pop()??m[0];i.push(`${h}/${x}`)}else i.push(`${h} (${m.length} files)`)}const o=e.some(f=>f.status==="A"),u=e.some(f=>f.status==="M");return`${o&&!u?"add":"update"}: ${i.join(", ")}`}function by(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 w8({onInitGit:e,onDelegate:n,delegateRoleName:a}){const[i,o]=w.useState(!1),[u,d]=w.useState(null),f=async()=>{o(!0),d(null);try{await e(),d({ok:!0,message:"Git repository initialized!"})}catch(h){const x=h instanceof Error?h.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:f,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 k8({repo:e,onConnected:n,onDelegate:a,delegateRoleName:i}){const[o,u]=w.useState("idle"),[d,f]=w.useState(null),[m,h]=w.useState(""),[x,g]=w.useState("private"),[v,b]=w.useState(""),[j,k]=w.useState(null),[N,E]=w.useState(!1),C=async()=>{u("checking"),k(null);try{const R=await pe.getGithubStatus(e);f(R),R.hasRemote?n():R.ghInstalled&&R.authenticated?u("ready"):u("idle")}catch{u("idle")}},_=async()=>{if(m.trim()){E(!0),k(null);try{const R=await pe.githubCreateRepo(m.trim(),x,e);k(R),R.ok&&setTimeout(n,1500)}catch(R){k({ok:!1,message:R instanceof Error?R.message:"Failed"})}finally{E(!1)}}},M=async()=>{if(v.trim()){E(!0),k(null);try{const R=await pe.addRemote(v.trim(),e);k(R),R.ok&&setTimeout(n,1500)}catch(R){k({ok:!1,message:R instanceof Error?R.message:"Failed"})}finally{E(!1)}}},H=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:C,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"}),H]}),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:C,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"}),H]})]}),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:C,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"}),H]})]}),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:R=>h(R.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:R=>g(R.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:_,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:R=>b(R.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"),f(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 j8({status:e,history:n,onClose:a,onSave:i,onLoadHistory:o,onRestore:u,saving:d,onDelegate:f,delegateRoleName:m,repo:h,onRepoChange:x,syncInfo:g,onPull:v,pulling:b,onRefresh:j,onInitGit:k}){const[N,E]=w.useState("save"),[C,_]=w.useState(""),[M,H]=w.useState(null),[R,I]=w.useState(!1),[W,Y]=w.useState(null),[D,O]=w.useState(null),B=w.useRef(null);w.useEffect(()=>{N==="history"&&o()},[N,o]),w.useEffect(()=>{var A;(A=B.current)==null||A.focus()},[]);const ee=[...((e==null?void 0:e.modified)??[]).map(A=>({status:"M",file:A})),...((e==null?void 0:e.untracked)??[]).map(A=>({status:"A",file:A}))],re=w.useRef(!1);w.useEffect(()=>{!re.current&&ee.length>0&&!C&&(_(yy(ee)),re.current=!0)},[ee.length]),w.useEffect(()=>{re.current=!1,_(""),O(null),Y(null),H(null)},[h]);const K=w.useCallback(()=>{_(yy(ee))},[ee]),q=async()=>{H(null),Y(null);try{const A=await i(C||void 0);Y(A),_("")}catch(A){H(A instanceof Error?A.message:"Save failed")}},ce=async()=>{O(null),H(null);try{const A=await v();O(A)}catch(A){H(A instanceof Error?A.message:"Pull failed")}},ue=async A=>{if(confirm(`Restore from commit ${A.slice(0,7)}? This creates a new commit with those files.`)){I(!0);try{await u(A),I(!1)}catch($){H($ instanceof Error?$.message:"Restore failed"),I(!1)}}};w.useEffect(()=>{const A=$=>{$.key==="Escape"&&a()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[a]);const V=A=>{A.key==="Enter"&&(A.metaKey||A.ctrlKey)&&q()};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:V,children:[l.jsxs("div",{className:"px-5 py-3 flex items-center justify-between shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-lg font-black tracking-tight",children:"SAVE COMPANY"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:(e==null?void 0:e.branch)??""})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[g&&g.hasRemote&&(g.behind>0||g.ahead>0)&&l.jsxs("span",{className:"text-[10px] font-bold",style:{color:g.behind>0?"var(--idle-amber)":"var(--active-green)"},children:[g.behind>0&&`↓${g.behind}`,g.behind>0&&g.ahead>0&&" ",g.ahead>0&&`↑${g.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(A=>l.jsx("button",{onClick:()=>x(A),className:"flex-1 py-1.5 text-[10px] font-bold uppercase tracking-wider cursor-pointer",style:{background:h===A?"var(--hud-bg-alt)":"transparent",color:h===A?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:h===A?"2px solid var(--accent)":"2px solid transparent"},children:A==="akb"?"AKB":"CODE"},A))}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["save","history"].map(A=>l.jsx("button",{onClick:()=>E(A),className:"flex-1 py-2 text-[11px] font-bold uppercase tracking-wider cursor-pointer",style:{background:N===A?"var(--hud-bg-alt)":"transparent",color:N===A?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:N===A?"2px solid var(--accent)":"2px solid transparent"},children:A==="save"?"SAVE":"HISTORY"},A))}),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(w8,{onInitGit:async()=>{await(k==null?void 0:k()),j==null||j()},onDelegate:f?()=>{f(`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}),g&&g.hasRemote&&g.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:[g.behind," commit",g.behind>1?"s":""," behind remote"]}),l.jsx("button",{onClick:ce,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"})]}),D&&l.jsx("div",{className:"text-[11px] p-2",style:{background:D.status==="ok"||D.status==="up-to-date"?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${D.status==="ok"||D.status==="up-to-date"?"var(--active-green)":"#D32F2F"}`,color:D.status==="ok"||D.status==="up-to-date"?"var(--active-green)":"#EF5350"},children:D.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:A,file:$})=>l.jsxs("div",{className:"flex gap-2",children:[l.jsx("span",{style:{color:A==="A"?"var(--active-green)":"var(--idle-amber)",width:"14px"},children:A}),l.jsx("span",{style:{color:"var(--terminal-text-secondary)"},children:$})]},$))})]}),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:K,className:"text-[9px] px-1.5 py-0.5 cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--accent)",fontFamily:"var(--pixel-font)"},title:"Auto-generate message from changes",children:["✨"," AUTO"]})]}),l.jsx("input",{ref:B,type:"text",value:C,onChange:A=>_(A.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:q,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"}),f&&l.jsxs("button",{onClick:()=>{const A=ee.map($=>`${$.status} ${$.file}`).join(`
|
|
92
|
+
`);f(A)},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(k8,{repo:h,onConnected:()=>j==null?void 0:j(),onDelegate:f?()=>{f(`Set up a GitHub remote for the ${h==="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}),W&&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! ",W.filesChanged," file",W.filesChanged>1?"s":""," committed",W.pushed?" & pushed":"",W.pushError?` (push error: ${W.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," (",by(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(A=>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:A.shortSha}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:A.message})]}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:by(A.date)})]}),l.jsx("button",{onClick:()=>ue(A.sha),disabled:R,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"})]},A.sha))})]})]})]})]})}function S8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[,f]=w.useState(!1);return w.useEffect(()=>{Promise.all([pe.getCompanyStats(),pe.getPreferences()]).then(async([m,h])=>{a(m);const x=h;if(x.instanceId)try{await kr.syncStats({instanceId:x.instanceId,roleCount:m.company.roleCount,totalTokens:m.company.totalTokens,rolesData:m.roles.map(g=>({roleId:g.roleId,name:g.name,tokens:g.totalTokens}))}),f(!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(Tu,{label:"Roles",value:String(n.company.roleCount)}),l.jsx(Tu,{label:"Avg Level",value:`Lv.${n.company.avgLevel}`}),l.jsx(Tu,{label:"Total Tokens",value:n.company.formattedTokens}),l.jsx(Tu,{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,h)=>l.jsx(C8,{role:m,rank:h+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,h])=>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:E8(m)}),l.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",h.costUsd.toFixed(2)]})]},m))})]})]})}function Tu({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 C8({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:vy(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:vy(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 vy(e){return e>=20?"#FFD700":e>=10?"#C0A0FF":e>=5?"#4FC3F7":e>=3?"#81C784":"rgba(255,255,255,0.4)"}function E8(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.split("-").slice(0,2).join(" ")}function N8({onClose:e,onSyncComplete:n}){const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,f]=w.useState(!0),[m,h]=w.useState(null),[x,g]=w.useState(new Set),[v,b]=w.useState(null),[j,k]=w.useState(null),N=w.useCallback(async()=>{f(!0),b(null);try{const{roles:C}=await pe.getSyncRoles();i(C);const _=C.filter(M=>M.source.sync!=="off");if(_.length===0){u([]),k(null);return}try{const M=await kr.syncCheck(_.map(R=>({roleId:R.roleId,sourceId:R.source.id,currentVersion:R.source.upstream_version??R.source.forked_at??"0.0.0"})));k(!0);const H=[];for(const R of M.updates){if(!R.hasUpdate)continue;const I=_.find(B=>B.roleId===R.roleId);if(!I)continue;const{character:W}=await kr.syncPull(R.sourceId),Y=[];I.persona.trim()!==W.persona.trim()&&Y.push({field:"persona",local:I.persona.slice(0,120)+(I.persona.length>120?"...":""),upstream:W.persona.slice(0,120)+(W.persona.length>120?"...":"")});const D=JSON.stringify(I.authority),O=JSON.stringify(W.authority);D!==O&&Y.push({field:"authority",local:`${I.authority.autonomous.length} autonomous, ${I.authority.needsApproval.length} approval`,upstream:`${W.authority.autonomous.length} autonomous, ${W.authority.needsApproval.length} approval`}),Y.length>0&&H.push({roleId:R.roleId,roleName:I.name,sourceId:R.sourceId,currentVersion:R.currentVersion,latestVersion:R.latestVersion,fields:Y})}u(H)}catch{k(!1),u([])}}catch(C){b(C instanceof Error?C.message:"Failed to check for updates")}finally{f(!1)}},[]);w.useEffect(()=>{N()},[N]);const E=async C=>{h(C.roleId);try{const{character:_,version:M}=await kr.syncPull(C.sourceId);await pe.applySyncUpdate({roleId:C.roleId,changes:{persona:_.persona,authority:_.authority},upstreamVersion:M}),g(H=>new Set(H).add(C.roleId)),n==null||n()}catch(_){b(_ instanceof Error?_.message:"Failed to apply update")}finally{h(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(C=>!x.has(C.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(C=>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:C.roleName}),l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[C.sourceId," · v",C.currentVersion," → v",C.latestVersion]})]}),x.has(C.roleId)?l.jsx("span",{style:{fontSize:12,color:"#81C784"},children:"Applied ✓"}):l.jsx("button",{onClick:()=>E(C),disabled:m===C.roleId,style:{background:"#1565C0",border:"none",color:"white",borderRadius:6,padding:"5px 12px",fontSize:12,cursor:m===C.roleId?"wait":"pointer",opacity:m===C.roleId?.6:1},children:m===C.roleId?"Applying...":"Apply Update"})]}),C.fields.map(_=>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:_.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",{}),_.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",{}),_.upstream]})]})]},_.field))]},C.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 A8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[f,m]=w.useState(null),h=w.useCallback(async()=>{o(!0),d(null);try{const C=await pe.getGitStatus();a(C)}catch(C){d(C instanceof Error?C.message:"Failed to load git status")}finally{o(!1)}},[]);w.useEffect(()=>{h()},[h]);const x=async C=>{m(C.path);try{await pe.deleteWorktree(C.path),await h()}catch(_){d(_ instanceof Error?_.message:"Failed to remove worktree")}finally{m(null)}},g=async C=>{m(C);try{await pe.deleteBranch(C),await h()}catch(_){d(_ instanceof Error?_.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(C=>C.status==="active"),b=n.worktrees.filter(C=>C.status==="pending-merge"),j=n.worktrees.filter(C=>C.status==="stale");function k(C){const _=C.split("/");if(_.length>1){const M=_[_.length-1],H=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const R of H)if(M.toLowerCase().includes(R))return R}return null}function N(C,_=40){return C.length<=_?C:"..."+C.slice(C.length-_+3)}function E(C){const _=Date.now()-new Date(C).getTime(),M=Math.floor(_/6e4);if(M<1)return"just now";if(M<60)return`${M}m ago`;const H=Math.floor(M/60);return H<24?`${H}h ago`:`${Math.floor(H/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:h,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?"...":""," · ",E(n.lastCommit.date)]})]}),v.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Fu,{label:"Active Worktrees",count:v.length}),v.map(C=>l.jsx(Yh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:N,timeAgo:E,removing:f===C.path,onRemove:()=>x(C),statusColor:"#4FC3F7",statusIcon:"📂"},C.path))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Fu,{label:"Pending Merge",count:b.length}),b.map(C=>l.jsx(Yh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:N,timeAgo:E,removing:f===C.path,onRemove:()=>x(C),statusColor:"#FFB74D",statusIcon:"⚠️"},C.path))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Fu,{label:"Stale",count:j.length}),j.map(C=>l.jsx(Yh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:N,timeAgo:E,removing:f===C.path,onRemove:()=>x(C),statusColor:"#ff6b6b",statusIcon:"🔴"},C.path))]}),n.staleBranches.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Fu,{label:"Unmerged Branches",count:n.staleBranches.length}),n.staleBranches.map(C=>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:C})]}),l.jsx("button",{onClick:()=>g(C),disabled:f===C,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:f===C?"wait":"pointer",opacity:f===C?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:f===C?"...":"DELETE"})]},C))]}),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," · ",E(n.lastMerge.mergedAt)]})]})}function Fu({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 Yh({wt:e,roleFromBranch:n,truncatePath:a,timeAgo:i,removing:o,onRemove:u,statusColor:d,statusIcon:f}){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:f}),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 D8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[f,m]=w.useState(null),h=w.useCallback(async()=>{o(!0),d(null);try{const k=await pe.getActiveSessions();a(k)}catch(k){d(k instanceof Error?k.message:"Failed to load sessions")}finally{o(!1)}},[]);w.useEffect(()=>{h();const k=setInterval(h,1e4);return()=>clearInterval(k)},[h]);const x=async k=>{m(k);try{await pe.deleteActiveSession(k),await h()}catch(N){d(N instanceof Error?N.message:"Failed to remove session")}finally{m(null)}},g=async()=>{try{await pe.cleanupActiveSessions(),await h()}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:g,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:h,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(Xh,{label:"Active",count:v.length}),v.map(k=>l.jsx(Wh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#4FC3F7"},k.sessionId))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Xh,{label:"Idle",count:b.length}),b.map(k=>l.jsx(Wh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#FFB74D"},k.sessionId))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Xh,{label:"Dead",count:j.length}),j.map(k=>l.jsx(Wh,{session:k,removing:f===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 Xh({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 T8(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 Wh({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:[" · ",F8(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" · ","PID:",e.pid]})," · ",T8(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 F8(e,n=35){return e.length<=n?e:"..."+e.slice(e.length-n+3)}function R8({onClose:e,speechSettings:n,onSpeechSettingsChange:a,language:i,onLanguageChange:o,onOpenSync:u,onOpenGitStatus:d,onOpenSessions:f,onOpenStats:m}){var ce;const[h,x]=w.useState(null),[g,v]=w.useState(null),[b,j]=w.useState(!1),[k,N]=w.useState(!1),[E,C]=w.useState(!1),[_,M]=w.useState(null),[H,R]=w.useState(""),[I,W]=w.useState(!1),[Y,D]=w.useState(!1),[O,B]=w.useState(null),[ee,re]=w.useState(!1);w.useEffect(()=>{pe.getPreferences().then(async ue=>{const V=ue;if(x(V.instanceId??null),V.instanceId)try{const{name:A}=await kr.getMyName(V.instanceId);v(A)}catch{}}).catch(()=>{}),pe.getCodeRoot().then(({codeRoot:ue})=>{M(ue),ue&&R(ue)}).catch(()=>{})},[]);const K=async()=>{C(!0);try{const V=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();V.ok&&(x(V.newInstanceId),N(!1))}catch{}C(!1)},q=()=>{h&&navigator.clipboard.writeText(h).then(()=>{j(!0),setTimeout(()=>j(!1),2e3)})};return l.jsx("div",{className:"customize-overlay",onClick:e,children:l.jsxs("div",{className:"customize-modal",onClick:ue=>ue.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(ue=>l.jsxs("button",{onClick:()=>a==null?void 0:a({mode:ue}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(n==null?void 0:n.mode)===ue?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(n==null?void 0:n.mode)===ue?"rgba(255,255,255,0.08)":"transparent",color:(n==null?void 0:n.mode)===ue?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:ue==="template"?"TEMPLATE":ue==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:ue==="template"?"Static pool ($0)":ue==="llm"?"LLM generated":"Detect engine"})]},ue))}),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:ue=>a==null?void 0:a({intervalSec:Number(ue.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: $",((ce=n==null?void 0:n.dailyBudgetUsd)==null?void 0:ce.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(n==null?void 0:n.dailyBudgetUsd)??1,onChange:ue=>a==null?void 0:a({dailyBudgetUsd:Number(ue.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:ue,label:V})=>l.jsx("button",{onClick:()=>o==null?void 0:o(ue),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(i??"auto")===ue?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(i??"auto")===ue?"rgba(255,255,255,0.08)":"transparent",color:(i??"auto")===ue?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:V},ue))}),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"}),I?l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:H,onChange:ue=>{R(ue.target.value),B(null)},placeholder:"/path/to/code/repo",style:{flex:1,padding:"8px 10px",fontSize:11,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:6,color:"var(--terminal-text)",fontFamily:"monospace",outline:"none"},autoFocus:!0}),l.jsx("button",{onClick:async()=>{if(H.trim()){D(!0),B(null);try{const ue=await pe.setCodeRoot(H.trim());M(ue.codeRoot),R(ue.codeRoot),W(!1),re(!0),setTimeout(()=>re(!1),3e3)}catch(ue){B(ue instanceof Error?ue.message:"Failed to set code root")}finally{D(!1)}}},disabled:Y||!H.trim(),style:{padding:"8px 12px",fontSize:10,fontWeight:600,background:"var(--accent)",border:"none",color:"#fff",borderRadius:6,cursor:"pointer",opacity:Y||!H.trim()?.5:1},children:Y?"...":"Save"}),l.jsx("button",{onClick:()=>{W(!1),R(_||""),B(null)},style:{padding:"8px 10px",fontSize:10,background:"transparent",border:"1px solid rgba(255,255,255,0.1)",color:"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer"},children:"Cancel"})]}),O&&l.jsx("div",{style:{fontSize:9,color:"#ff6b6b",marginTop:4},children:O})]}):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)":"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_||"Not configured"}),l.jsx("button",{onClick:()=>{W(!0),B(null),re(!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). If not set, auto-created as ../[company]-code/ when AI starts working."})]}),h&&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:h}),l.jsx("button",{onClick:q,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:K,disabled:E,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:E?"...":"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"}),f&&l.jsx("button",{onClick:()=>{e(),f()},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"})]}),g&&l.jsx("div",{style:{textAlign:"center",marginTop:-8},children:l.jsx("a",{href:`https://tycono.ai/profile.html?u=${encodeURIComponent(g)}`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:10,color:"var(--terminal-text-muted)",textDecoration:"none"},onMouseEnter:ue=>ue.currentTarget.style.color="var(--accent)",onMouseLeave:ue=>ue.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile →"})})]})})]})})}function M8({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(ol).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 vs={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function z8({roles:e,roleStatuses:n,activeExecs:a,sessions:i,knowledgeDocs:o,roleLevels:u,companyName:d,getAppearance:f,waveCenterWaves:m,renderProfile:h,channel:x,onChannelChange:g,onClose:v,children:b}){const[j,k]=w.useState(!1),N=m.filter(I=>I.rootJobs.some(W=>{const Y=n[W.roleId];return Y==="working"||Y==="thinking"})),E=[...e].sort((I,W)=>I.level==="c-level"&&W.level!=="c-level"?-1:I.level!=="c-level"&&W.level==="c-level"?1:I.name.localeCompare(W.name)),C=e.filter(I=>Wn(n[I.id])).length,_=i.filter(I=>I.status==="active").length,M=x.type==="role"?e.find(I=>I.id===x.roleId):null,H=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",R=x.type==="terminal"?`${_} 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":`${C} 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}),C>0&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full animate-pulse",style:{background:"#4CAF5020",color:"#4CAF50"},children:[C," 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:()=>g({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(I=>{const W=n[I.roleId];return W==="working"||W==="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(Ru,{icon:"💬",label:"Chats",badge:_||void 0,active:x.type==="terminal",onClick:()=>g({type:"terminal"})}),l.jsx(Ru,{icon:"⚡",label:"Waves",live:N.length>0,active:x.type==="wave",onClick:()=>g({type:"wave"})}),l.jsx(Ru,{icon:"📋",label:"Decisions",active:x.type==="operations",onClick:()=>g({type:"operations"})}),l.jsx(Ru,{icon:"📚",label:"Knowledge",badge:o.length||void 0,active:x.type==="knowledge",onClick:()=>g({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"}),E.map(I=>{var ee;const W=n[I.id],Y=a.find(re=>re.roleId===I.id),D=vs[I.id]??"#666",O=(ee=u[I.id])==null?void 0:ee.level,B=x.type==="role"&&x.roleId===I.id;return l.jsxs("button",{onClick:()=>g({type:"role",roleId:I.id}),className:"flex items-center gap-2.5 w-full px-4 py-1.5 text-left hover:opacity-80 transition-all",style:{background:B?`${D}18`:"transparent",borderLeft:B?`2px solid ${D}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx(Kl,{roleId:I.id,appearance:f(I.id),scale:1.3}),l.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full",style:{background:Wn(W)?"#4CAF50":W==="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:[I.name,O!=null&&l.jsxs("span",{className:"ml-1 opacity-40 text-[8px]",children:["Lv.",O]})]}),Y?l.jsx("div",{className:"text-[9px] truncate",style:{color:D},children:Y.task.slice(0,28)}):l.jsx("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted, #887766)"},children:I.level==="c-level"?I.id.toUpperCase():I.id})]}),Wn(W)&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:D}})]},I.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(I=>{const W=e.find(O=>O.id===I.roleId),Y=vs[I.roleId]??"#666",D=x.type==="role"&&x.roleId===I.roleId;return l.jsxs("button",{onClick:()=>g({type:"role",roleId:I.roleId}),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded text-left hover:opacity-80 transition-all",style:{background:D?`${Y}18`:"transparent"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:Y}}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text, #fff5eb)"},children:(W==null?void 0:W.name)??I.roleId}),l.jsx("div",{className:"text-[8px] truncate",style:{color:"var(--terminal-text-muted)"},children:I.task.slice(0,40)})]})]},I.jobId??I.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(I=>!I),className:"relative shrink-0 rounded-lg overflow-hidden hover:opacity-80 transition-opacity cursor-pointer",style:{width:28,height:28,background:`${vs[M.id]??"#666"}30`},title:"View profile",children:[l.jsx(Kl,{roleId:M.id,appearance:f(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:Wn(n[M.id])?"#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:H}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted, #887766)"},children:R}),l.jsx("span",{className:"flex-1"}),x.type==="role"&&l.jsx("button",{onClick:()=>k(I=>!I),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:()=>g({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"&&h&&l.jsx("div",{className:"shrink-0 overflow-hidden pro-panel-inline",style:{width:420,borderLeft:"1px solid var(--terminal-border, #2E261F)"},children:h(()=>k(!1))})]})]})]})}function _8({role:e,messages:n,isStreaming:a,mode:i,onModeChange:o,onSend:u,isWave:d}){const f=vs[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsx(wv,{messages:n,roleId:e.id,roleColor:f}),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(Jm,{mode:i,onModeChange:o,onSend:(m,h)=>u(m,i,h),disabled:a,disabledReason:a?`${e.id.toUpperCase()} is responding...`:void 0})]})}function B8({role:e,onSend:n,getAppearance:a,onOpenProfile:i}){const[o,u]=w.useState("talk"),d=vs[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(Kl,{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(Jm,{mode:o,onModeChange:u,onSend:f=>n(f,o),disabled:!1})]})}function Ru({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 O8({roles:e,roleStatuses:n,activeExecs:a,waves:i,knowledgeDocs:o,roleLevels:u,getAppearance:d,onRoleClick:f,onWaveClick:m,onKnowledgeClick:h}){const x=e.filter(g=>Wn(n[g.id]));return l.jsx("div",{className:"h-full overflow-y-auto px-6 py-5",children:l.jsxs("div",{className:"space-y-5 max-w-4xl",children:[l.jsxs("div",{className:"flex gap-3",children:[l.jsx(wy,{label:"New Wave",icon:"⚡",color:"#EF4444",onClick:m}),l.jsx(wy,{label:"Knowledge",icon:"📚",color:"#0D9488",onClick:h})]}),x.length>0&&l.jsx(Mu,{title:"Currently Working",count:x.length,children:a.map(g=>{const v=e.find(j=>j.id===g.roleId),b=vs[g.roleId]??"#666";return l.jsxs("button",{onClick:()=>f(g.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(Kl,{roleId:g.roleId,appearance:d(g.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:g.task.slice(0,60)})]}),l.jsx("span",{className:"text-[10px] animate-pulse",style:{color:b},children:"●"})]},g.roleId)})}),l.jsx(Mu,{title:"Team",count:e.length,children:l.jsx("div",{className:"grid grid-cols-3 gap-1 px-2",children:e.map(g=>{var j;const v=n[g.id]??"offline",b=(j=u[g.id])==null?void 0:j.level;return l.jsxs("button",{onClick:()=>f(g.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:Wn(v)?"#4CAF50":v==="idle"?"#FFC107":"#9E9E9E"}}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:g.name}),b!=null&&l.jsxs("span",{className:"text-[9px] opacity-40",children:["Lv.",b]})]},g.id)})})}),i.length>0&&l.jsx(Mu,{title:"Recent Waves",count:i.length,children:i.slice(0,5).map(g=>{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 ",g.id]})," — ",(v=g.directive)==null?void 0:v.slice(0,80)]},g.id)})}),l.jsx(Mu,{title:"Knowledge Base",count:o.length,children:l.jsxs("button",{onClick:h,className:"px-4 py-3 text-[11px] hover:opacity-80",style:{color:"var(--terminal-text-muted)"},children:[o.length," documents · Click to explore ","→"]})})]})})}function wy({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 Mu({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 jm=5e4;function $v(e){return e<jm?1:Math.max(1,Math.floor(Math.sqrt(e/jm)))}function ky(e){return jm*e*e}function $8(e){const n=$v(e),a=ky(n),i=ky(n+1);return Math.min(1,(e-a)/(i-a))}function Vh(e){const n={};for(const[a,i]of Object.entries(e)){const o=i.inputTokens+i.outputTokens;n[a]={level:$v(o),totalTokens:o,progress:$8(o)}}return n}const L8=[{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 jy(e){return L8.filter(n=>n.check(e))}const Sy={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function I8({importJob:e,onImportDone:n}){var uc,dc,fc,$s,hc;const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,f]=w.useState([]),[m,h]=w.useState([]),[x,g]=w.useState([]),[v,b]=w.useState([]),[j,k]=w.useState("TYCONO"),[N,E]=w.useState(!0),[C,_]=w.useState(null),[M,H]=w.useState({type:"none"}),[R,I]=w.useState(null),[W,Y]=w.useState(null),[D,O]=w.useState([]),[B,ee]=w.useState(!1),[re,K]=w.useState(!1),[q,ce]=w.useState([]),[ue,V]=w.useState([]),[A,$]=w.useState(0),[U,T]=w.useState(!1),[se,ke]=w.useState({}),[he,_e]=w.useState("ceo"),[Le,Ue]=w.useState(null),[et,Pe]=w.useState(!1),[Ge,Ce]=w.useState(!1),[Ae,yt]=w.useState({}),ct=w.useRef({}),[xt,Ct]=w.useState(!1),[Ht,zt]=w.useState(null),[jt,Hn]=w.useState({}),[me,je]=w.useState([]),Ne=w.useMemo(()=>{const F={};for(const P of me)F[P.roleId]=P;return F},[me]),[G,Z]=w.useState([]),[ye,ge]=w.useState(0),[Ee,Fe]=w.useState(Wg()),Be=w.useRef(Wg()),Oe=w.useRef(!1),qe=w.useRef(-1),[at,We]=w.useState(null),Dt=w.useRef(null),[ze,He]=w.useState(void 0),[qt,_t]=w.useState(!1);w.useEffect(()=>{pe.getStatus().then(F=>{He(F.engine),_t(!!F.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:Bt,setAppearance:Jt,resetAppearance:kn,theme:J,setTheme:$e,speechSettings:lt,setSpeechSettings:Kt,language:ve,setLanguage:wt,purchasedItems:jn,addPurchasedItem:hn}=I6(),[ne,Me]=w.useState(null),[,Ve]=w.useState("character"),Ze=q6(),[Sn,Vn]=w.useState(!1),[yn,mn]=w.useState(!1),[Lr,Jl]=w.useState(!1),[Fs,Mi]=w.useState(!1),[Po,Ra]=w.useState(!1),[Rs,ua]=w.useState(!1),[Ma,za]=w.useState(!1),[Gn,Dn]=w.useState(null);w.useEffect(()=>{Ze.refresh()},[]),w.useEffect(()=>{const F=P=>{(P.metaKey||P.ctrlKey)&&P.key==="s"&&(P.preventDefault(),Vn(!0))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),w.useEffect(()=>{if(!Fs)return;let F=!1;const P=async()=>{try{const fe=await pe.getGitStatus();F||Dn(fe)}catch{}};P();const ae=setInterval(P,1e4);return()=>{F=!0,clearInterval(ae)}},[Fs]);const[_a,zi]=w.useState(null),[hr,Sr]=w.useState(null),[ul,Ms]=w.useState([]),[Ba,Qo]=w.useState(!1),ei=w.useRef(!1),dl=w.useRef(null);let Ir=w.useRef(0);const ir=w.useRef(new Set),Zo=w.useRef(Date.now()),Oa=(F,P,ae)=>{const fe={id:Ir.current++,type:F,text:P,detail:ae};Ms(we=>[...we,fe])};w.useEffect(()=>{var F;Ba&&((F=dl.current)==null||F.scrollIntoView({behavior:"smooth"}))},[ul,Ba]),w.useEffect(()=>{e&&(ei.current||(ei.current=!0,Sr("Scanning knowledge sources..."),Ms([{id:0,type:"scan",text:"Starting knowledge import..."}]),Ir.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 F=>{var we;const P=(we=F.body)==null?void 0:we.getReader();if(!P)return;const ae=new TextDecoder;let fe="";for(;;){const{done:Ie,value:Lt}=await P.read();if(Ie)break;fe+=ae.decode(Lt,{stream:!0});const ft=fe.split(`
|
|
93
|
+
`);fe=ft.pop()||"";let tt="";for(const Qe of ft)if(Qe.startsWith("event: "))tt=Qe.slice(7).trim();else if(Qe.startsWith("data: ")&&tt){try{const mt=JSON.parse(Qe.slice(6));switch(tt){case"scanning":Sr(`Scanning: ${mt.path} (${mt.fileCount} files)`),Oa("scan",`Found ${mt.fileCount} files`,mt.path);break;case"processing":zi({index:mt.index,total:mt.total}),Sr(`Importing knowledge... (${mt.index}/${mt.total})`),Oa("process",`Processing: ${mt.file}`,`${mt.index} / ${mt.total}`);break;case"created":Oa("created",mt.title,mt.summary);break;case"skipped":Oa("process",`Skipped: ${mt.file}`,mt.reason);break;case"done":Sr(null),zi(null),Oa("done",`Import complete! ${mt.created} created, ${mt.skipped} skipped.`),St(`Knowledge import complete! ${mt.created} documents imported.`,"#2E7D32"),n==null||n();break;case"error":Sr(null),zi(null),Oa("error",mt.message),St(`Import failed: ${mt.message}`,"#B71C1C"),n==null||n();break}}catch{}tt=""}}}).catch(F=>{Sr(null),Oa("error",F.message),St(`Import error: ${F.message}`,"#B71C1C"),n==null||n()})))},[e]);const[Cr,Hr]=w.useState("iso"),Er=w.useRef("iso"),[ta,Pt]=w.useState({type:"dashboard"}),[_i,Jo]=w.useState(typeof window<"u"?window.innerWidth:1200);w.useEffect(()=>{const F=()=>Jo(window.innerWidth);return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]);const ti=_i<1024,[Kn,$a]=w.useState(!1),[da,fl]=w.useState(560),[Un,sn]=w.useState([]),[na,qn]=w.useState(null),[fa,La]=w.useState(null),{sendMessage:Bi}=O6(),mr=w.useRef(new Map);w.useEffect(()=>{Promise.all([pe.getCompany().then(F=>{k(F.name),i(F.roles)}),pe.getOrgTree().then(F=>{ke(F.nodes),_e(F.root)}).catch(()=>{}),pe.getCostSummary().then(F=>ml(Vh(F.byRole))).catch(()=>{})]).catch(F=>_(`Failed to load: ${F.message}`)).finally(()=>E(!1)),pe.getProjects().then(u).catch(()=>{}),pe.getStandups().then(f).catch(()=>{}),pe.getWaves().then(h).catch(()=>{}),pe.getDecisions().then(g).catch(()=>{}),pe.getKnowledge().then(b).catch(()=>{}),pe.getQuestProgress().then(F=>{const P=Vg(F);P.activeChapter!==F.activeChapter&&pe.saveQuestProgress(P).catch(()=>{}),Fe(P),Be.current=P,Oe.current=!0,pe.getCoins().then(ae=>{var fe;ae.totalEarned===0?pe.migrateCoins(((fe=P.completedQuests)==null?void 0:fe.length)??0).then(we=>ge(we.balance)).catch(()=>{}):ge(ae.balance)}).catch(()=>{})}).catch(()=>{Oe.current=!0})},[]),w.useEffect(()=>{if(qe.current===-1){qe.current=o.length;return}o.length>qe.current&&on({type:"project_created"}),qe.current=o.length},[o.length]);const Oi=w.useRef(!1);w.useEffect(()=>{if(!(!Oe.current||a.length===0||Oi.current)){Oi.current=!0;for(const F of a)on({type:"role_hired",condition:{roleId:F.id,roleCount:a.length}})}},[a.length]),w.useEffect(()=>{pe.getSessions().then(F=>{const P=F.filter(fe=>fe.source!=="wave");if(P.length>0){const fe=P.map(Ie=>({...Ie,messages:[]}));sn(fe);const we=fe.find(Ie=>Ie.status==="active")??fe[0];qn(we.id),hl()}const ae=F.filter(fe=>fe.source==="wave").map(fe=>fe.id);ae.length>0&&pe.deleteSessions(ae).catch(()=>{})}).catch(F=>{console.error("Failed to load sessions",F)})},[]),w.useEffect(()=>{const F=()=>{fetch("/api/exec/status").then(ae=>ae.json()).then(ae=>{Hn(ae.statuses??{}),je(ae.activeExecutions??[])}).catch(()=>{})};F();const P=setInterval(F,3e3);return()=>clearInterval(P)},[]);const ha=w.useMemo(()=>{const F={...jt};if(fa){const P=Un.find(ae=>ae.id===fa);P&&F[P.roleId]!=="awaiting_input"&&(F[P.roleId]="working")}return F},[jt,fa,Un]);w.useEffect(()=>{M.type==="role"?pe.getRole(M.roleId).then(I).catch(console.error):I(null)},[M]);const pr=()=>H({type:"none"}),Ia=async(F,P)=>{const ae=await pe.updateDecision(F,P);g(fe=>fe.map(we=>we.id===F?ae:we))},zs=async F=>{await pe.deleteDecision(F),g(P=>P.filter(ae=>ae.id!==F))},Pn=F=>{H(F),$a(!1),K(!1)},hl=()=>{$a(!0),H({type:"none"}),K(!1)},ma=()=>{Er.current="iso",Pt({type:"wave"}),Hr("pro"),K(!0),$a(!1),H({type:"none"})},ra=async(F,P)=>{const ae=a.find(we=>we.id===F),fe=(W==null?void 0:W.mode)==="ask";Y(null);try{const we=await pe.startJob({type:"assign",roleId:F,task:P,readOnly:fe}),Ie=we.jobId,Lt=we.sessionId??`job-${Ie}`,ft=Sy[F]??"#666",tt=`${F.toUpperCase()} · ${(ae==null?void 0:ae.name)??F}`;T(!1),O([{sessionId:Lt,jobId:Ie,title:tt,color:ft}]),on({type:"task_executed",condition:{roleId:F}}),en.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(ae==null?void 0:ae.name)??F}] ${fe?"Ask":"Assign"}: ${P}`,type:"dispatch",targetRoleId:F})}catch(we){St(`Failed to start job: ${we instanceof Error?we.message:"unknown"}`,"#C62828")}},_s=w.useRef(0),St=(F,P)=>{const ae=++_s.current;Z(fe=>[...fe,{id:ae,message:F,color:P}]),setTimeout(()=>Z(fe=>fe.filter(we=>we.id!==ae)),4e3)},pa=F=>{Dt.current&&clearTimeout(Dt.current),We(F),Dt.current=setTimeout(()=>We(null),8e3)},on=F=>{if(!Oe.current)return;let P=Be.current;const ae=fv(P);let fe=0;const we=[];for(const Lt of ae){if(!LN(Lt,F))continue;const{progress:ft,quest:tt}=ON(P,Lt.id);tt&&(P=ft,fe+=tt.rewards.coins??0,we.push(tt.title))}if(we.length===0)return;P=Vg(P),Be.current=P,Fe(P);const Ie=fe>0?` 💰 +${fe.toLocaleString()}`:"";we.length===1?St(`📋 Quest complete: ${we[0]}${Ie}`,"#7C3AED"):St(`📋 ${we.length} quests complete!${Ie}`,"#7C3AED"),We(null),pe.saveQuestProgress(P).catch(()=>{}),fe>0&&pe.earnCoins(fe,`quests: ${we.length}`,we.join(",")).then(Lt=>ge(Lt.balance)).catch(()=>{})};w.useEffect(()=>{if(!at)return;const F=document.querySelector(`[data-quest-target="${at}"]`);if(!F)return;F.classList.add("quest-spotlight");const P=()=>{F.classList.remove("quest-spotlight"),We(null),Dt.current&&clearTimeout(Dt.current)};return F.addEventListener("click",P,{once:!0}),()=>{F.classList.remove("quest-spotlight"),F.removeEventListener("click",P)}},[at]);const ml=F=>{var ae,fe;const P=ct.current;for(const[we,Ie]of Object.entries(F)){const Lt=((ae=P[we])==null?void 0:ae.level)??0;if(Lt>0&&Ie.level>Lt){const ft=((fe=a.find(tt=>tt.id===we))==null?void 0:fe.name)??we.toUpperCase();St(`${ft} leveled up to Lv.${Ie.level}!`,"#7C3AED")}}ct.current=F,yt(F)};w.useEffect(()=>{const F={roles:Object.entries(Ae).map(([we,Ie])=>({id:we,level:Ie.level,totalTokens:Ie.totalTokens})),totalTokens:Object.values(Ae).reduce((we,Ie)=>we+Ie.totalTokens,0),roleCount:a.length,completedQuests:Ee.completedQuests},P=jy(F),ae=new Set(P.map(we=>we.id));if(Date.now()-Zo.current>5e3){const we=ir.current;for(const Ie of P)we.has(Ie.id)||St(`${Ie.icon} Badge earned: ${Ie.name}!`,"#D4A017")}ir.current=ae},[Ae,a.length,Ee.completedQuests]);const pl=w.useMemo(()=>BN(Ee),[Ee]),$i=()=>{var P;const F=D[D.length-1];F&&(St(`${F.title} completed`,F.color),en.pushMessage({ts:Date.now(),roleId:((P=F.title.split(" · ")[0])==null?void 0:P.toLowerCase())??"unknown",text:`[${F.title}] Job completed`,type:"dispatch"})),pe.getStandups().then(f).catch(console.error),pe.getCompany().then(ae=>i(ae.roles)).catch(console.error),pe.getCostSummary().then(ae=>ml(Vh(ae.byRole))).catch(()=>{})},xa=w.useRef(new Map),ec=F=>{if(xa.current.has(F))return;const P=new AbortController;xa.current.set(F,P),La(ae=>ae??F),fetch(`/api/sessions/${F}/stream?from=0`,{signal:P.signal}).then(async ae=>{var Lt,ft;if(!ae.ok||!ae.body)return;const fe=ae.body.getReader(),we=new TextDecoder;let Ie="";for(;;){const{done:tt,value:Qe}=await fe.read();if(tt)break;Ie+=we.decode(Qe,{stream:!0});const mt=Ie.split(`
|
|
94
|
+
`);Ie=mt.pop()??"";let Tt="";for(const yl of mt)if(yl.startsWith("event: "))Tt=yl.slice(7).trim();else if(yl.startsWith("data: ")){try{const or=JSON.parse(yl.slice(6));Tt==="stream:end"?(sn(ut=>ut.map(Ot=>{if(Ot.id!==F)return Ot;const pn=Ot.messages.map(dn=>dn.status==="streaming"?{...dn,status:"done"}:dn);return{...Ot,messages:pn}})),La(ut=>ut===F?null:ut),xa.current.delete(F)):Tt==="activity"&&(or.type==="text"&&((Lt=or.data)!=null&&Lt.text)?sn(ut=>ut.map(Ot=>{if(Ot.id!==F)return Ot;const pn=[...Ot.messages],dn=pn[pn.length-1];return(dn==null?void 0:dn.from)==="role"&&dn.status==="streaming"&&(pn[pn.length-1]={...dn,content:dn.content+or.data.text}),{...Ot,messages:pn}})):or.type==="thinking"&&((ft=or.data)!=null&&ft.text)?sn(ut=>ut.map(Ot=>{if(Ot.id!==F)return Ot;const pn=[...Ot.messages],dn=pn[pn.length-1];return(dn==null?void 0:dn.from)==="role"&&dn.status==="streaming"&&(pn[pn.length-1]={...dn,thinking:(dn.thinking??"")+or.data.text}),{...Ot,messages:pn}})):(or.type==="job:done"||or.type==="job:error")&&(sn(ut=>ut.map(Ot=>{if(Ot.id!==F)return Ot;const pn=Ot.messages.map(dn=>dn.status==="streaming"?{...dn,status:or.type==="job:done"?"done":"error"}:dn);return{...Ot,messages:pn}})),La(ut=>ut===F?null:ut),xa.current.delete(F)))}catch{}Tt=""}}}).catch(()=>{xa.current.delete(F),La(ae=>ae===F?null:ae)})},Yn=async(F,P,ae)=>{ee(!1);try{const fe=await pe.startJob({type:"wave",directive:F,targetRoles:P,...ae&&{attachments:ae}});on({type:"wave_dispatched"});const we=fe.jobIds??(fe.jobId?[fe.jobId]:[]),Ie=he&&se[he]?se[he].children.map(ut=>a.find(Ot=>Ot.id===ut)).filter(ut=>!!ut):a.filter(ut=>ut.level==="c-level"),Lt=P?Ie.filter(ut=>P.includes(ut.id)):Ie,ft=fe.waveId??`wave-${Date.now()}`,tt=fe.sessionIds??[],Qe=we.map((ut,Ot)=>{var pn,dn;return{jobId:ut,roleId:((pn=Lt[Ot])==null?void 0:pn.id)??`role-${Ot}`,roleName:((dn=Lt[Ot])==null?void 0:dn.name)??`C-Level ${Ot+1}`,sessionId:tt[Ot]??`wave-${ut}`}});en.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${F}" → ${Qe.map(ut=>ut.roleName).join(", ")}`,type:"dispatch"});const mt={id:ft,directive:F,rootJobs:Qe,startedAt:Date.now(),sessionIds:tt};ce(ut=>[mt,...ut]),ma();const Tt=new Date().toISOString(),or=(tt.length>0?Qe.map((ut,Ot)=>({id:tt[Ot]??`wave-${ut.jobId}`,roleId:ut.roleId,title:`WAVE: ${ut.roleName}`,mode:"do",source:"wave",jobId:ut.jobId,messages:[{id:`msg-wave-${ut.jobId}-ceo`,from:"ceo",content:F,type:"directive",status:"done",timestamp:Tt}],status:"active",createdAt:Tt,updatedAt:Tt})):Qe.map(ut=>({id:`wave-${ut.jobId}`,roleId:ut.roleId,title:`WAVE: ${ut.roleName}`,mode:"do",source:"wave",jobId:ut.jobId,messages:[{id:`msg-wave-${ut.jobId}-ceo`,from:"ceo",content:F,type:"directive",status:"done",timestamp:Tt}],status:"active",createdAt:Tt,updatedAt:Tt}))).map((ut,Ot)=>({...ut,messages:[...ut.messages,{id:`msg-wave-${Qe[Ot].jobId}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:Tt,jobId:Qe[Ot].jobId}]}));sn(ut=>[...or,...ut]);for(const ut of or)ec(ut.id)}catch(fe){St(`Failed to start wave: ${fe instanceof Error?fe.message:"unknown"}`,"#C62828")}},sr=()=>{pe.getWaves().then(h).catch(console.error),pe.getStandups().then(f).catch(console.error)},xl=()=>{pe.getCompany().then(F=>i(F.roles)).catch(console.error),pe.getOrgTree().then(F=>{ke(F.nodes),_e(F.root)}).catch(console.error),pe.getCostSummary().then(F=>ml(Vh(F.byRole))).catch(()=>{})},ni=async(F,P)=>{await pe.createRole(F),Jt(F.id,P),xl(),St(`${F.name} hired!`,"#2E7D32"),on({type:"role_hired",condition:{roleId:F.id,roleCount:a.length+1}})},ld=async F=>{var P;await pe.deleteRole(F),xl(),sn(ae=>ae.filter(fe=>fe.roleId!==F)),na&&((P=Un.find(ae=>ae.id===na))==null?void 0:P.roleId)===F&&qn(null),zt(null),St(`${F.toUpperCase()} removed`,"#B71C1C")},ri=async(F,P)=>{await pe.updateRole(F,P),xl(),M.type==="role"&&M.roleId===F&&pe.getRole(F).then(I).catch(console.error),P.name&&St(`${F.toUpperCase()} renamed to "${P.name}"`,"#1565C0"),P.persona!==void 0&&(St(`${F.toUpperCase()} persona updated`,"#2E7D32"),on({type:"persona_updated"}))},Bs=F=>{hl(),on({type:"terminal_opened"})},gl=async F=>{try{const P=await pe.createSession(F,"talk");sn(ae=>[P,...ae]),qn(P.id),hl()}catch(P){console.error("Failed to create session",P),St(`Failed to create session: ${P instanceof Error?P.message:"API unreachable"}`,"#B71C1C")}},ai=async F=>{try{const P=await pe.createSession(F,"talk");sn(ae=>[P,...ae]),qn(P.id)}catch(P){console.error("Failed to create session",P),St(`Failed to create session: ${P instanceof Error?P.message:"API unreachable"}`,"#B71C1C")}},tc=async F=>{const P=Ne[F],ae=(P==null?void 0:P.jobId)??(P==null?void 0:P.id);if(ae&&Wn(ha[F])){const we=a.find(Qe=>Qe.id===F),Ie=Sy[F]??"#666",Lt=`${F.toUpperCase()} · ${(we==null?void 0:we.name)??F}`,ft=Un.find(Qe=>Qe.roleId===F&&Qe.status==="active"),tt=(ft==null?void 0:ft.id)??`job-${ae}`;O([{sessionId:tt,jobId:ae,title:Lt,color:Ie}]),T(!1);return}const fe=Un.find(we=>we.roleId===F);if(fe)qn(fe.id),en.setActiveChannelId(null);else try{const we=await pe.createSession(F,"talk");sn(Ie=>[we,...Ie]),qn(we.id),en.setActiveChannelId(null)}catch(we){console.error("Failed to create session",we)}hl()},nc=async F=>{const P=Un.find(ae=>ae.id===F);if((P==null?void 0:P.source)==="wave"){if(P.jobId){const ae=mr.current.get(P.jobId);ae&&(ae.abort(),mr.current.delete(P.jobId))}sn(ae=>{var we;const fe=ae.filter(Ie=>Ie.id!==F);return na===F&&qn(((we=fe[0])==null?void 0:we.id)??null),fe});return}try{await pe.deleteSession(F),sn(ae=>{var we;const fe=ae.filter(Ie=>Ie.id!==F);return na===F&&qn(((we=fe[0])==null?void 0:we.id)??null),fe})}catch(ae){console.error("Failed to delete session",ae),St(`Failed to close session: ${ae instanceof Error?ae.message:"API error"}`,"#B71C1C")}},rc=async()=>{try{const{ids:F}=await pe.deleteEmptySessions();if(F.length===0)return;sn(P=>{var fe;const ae=P.filter(we=>!F.includes(we.id));return na&&F.includes(na)&&qn(((fe=ae[0])==null?void 0:fe.id)??null),ae}),St(`Cleared ${F.length} empty session${F.length!==1?"s":""}`,"#2E7D32")}catch(F){St(`Failed to clear empty sessions: ${F instanceof Error?F.message:"API error"}`,"#B71C1C")}},ac=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const F=Un.filter(P=>P.source!=="wave").map(P=>P.id);for(const P of Un)if(P.source==="wave"&&P.jobId){const ae=mr.current.get(P.jobId);ae&&(ae.abort(),mr.current.delete(P.jobId))}try{F.length>0&&await pe.deleteSessions(F),sn([]),qn(null),St("All sessions closed","#2E7D32")}catch(P){St(`Failed to close sessions: ${P instanceof Error?P.message:"API error"}`,"#B71C1C")}},Ur=(F,P)=>{sn(ae=>ae.map(fe=>{if(fe.id!==F)return fe;const we=[...fe.messages],Ie=we[we.length-1];if(Ie&&Ie.from==="role"&&Ie.status==="streaming"){const Lt=[...Ie.streamEvents??[],P];we[we.length-1]={...Ie,streamEvents:Lt}}return{...fe,messages:we}}))},Ha=(F,P,ae,fe)=>{const we={id:`msg-${Date.now()}-ceo`,from:"ceo",content:P,type:ae==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:fe},Ie={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};sn(ft=>ft.map(tt=>tt.id===F?{...tt,messages:[...tt.messages,we,Ie],updatedAt:new Date().toISOString()}:tt));const Lt=Un.find(ft=>ft.id===F);ae==="talk"?on({type:"talk_mode_used"}):ae==="do"&&(on({type:"do_mode_used"}),Lt&&on({type:"task_executed",condition:{roleId:Lt.roleId}})),La(F),Bi(F,P,ae,{onThinking:ft=>{sn(tt=>tt.map(Qe=>{if(Qe.id!==F)return Qe;const mt=[...Qe.messages],Tt=mt[mt.length-1];return Tt&&Tt.from==="role"&&Tt.status==="streaming"&&(mt[mt.length-1]={...Tt,thinking:(Tt.thinking??"")+ft}),{...Qe,messages:mt}})),Ur(F,{type:"thinking",timestamp:Date.now(),text:ft})},onText:ft=>{sn(tt=>tt.map(Qe=>{if(Qe.id!==F)return Qe;const mt=[...Qe.messages],Tt=mt[mt.length-1];return Tt&&Tt.from==="role"&&Tt.status==="streaming"&&(mt[mt.length-1]={...Tt,content:Tt.content+ft}),{...Qe,messages:mt}}))},onToolUse:(ft,tt)=>{Ur(F,{type:"tool",timestamp:Date.now(),toolName:ft,toolInput:tt})},onDispatch:(ft,tt)=>{Ur(F,{type:"dispatch",timestamp:Date.now(),roleId:ft,task:tt})},onDispatchProgress:(ft,tt,Qe)=>{var mt;tt==="tool"?Ur(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"tool",toolName:Qe.name,toolInput:Qe.input}):tt==="thinking"?Ur(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"thinking",text:Qe.text}):tt==="text"?Ur(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:"text",text:(mt=Qe.text)==null?void 0:mt.slice(-200)}):(tt==="done"||tt==="error")&&Ur(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:ft,progressType:tt})},onTurn:ft=>{Ur(F,{type:"turn",timestamp:Date.now(),turn:ft})},onDone:()=>{sn(ft=>ft.map(tt=>{if(tt.id!==F)return tt;const Qe=tt.messages.map(Tt=>Tt.status==="streaming"?{...Tt,status:"done"}:Tt),mt=tt.messages.length<=2?P.slice(0,40).replace(/\n/g," "):tt.title;return{...tt,messages:Qe,title:mt}})),La(null)},onError:ft=>{sn(tt=>tt.map(Qe=>{if(Qe.id!==F)return Qe;const mt=Qe.messages.map(Tt=>Tt.status==="streaming"?{...Tt,status:"error",content:Tt.content||ft}:Tt);return{...Qe,messages:mt}})),La(null)}},fe)},Os=(F,P)=>{sn(ae=>ae.map(fe=>fe.id===F?{...fe,mode:P}:fe)),pe.updateSession(F,{mode:P}).catch(console.error)},id=new Date().toISOString().slice(0,10),lc=o[0],ic={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},sc=F=>{const P=ic[F];if(!P)return"";for(const ae of d){const fe=ae.content,we=fe.indexOf(`## ${P}`);if(we===-1)continue;const Ie=fe.indexOf(`
|
|
95
|
+
## `,we+10),ft=(Ie===-1?fe.slice(we):fe.slice(we,Ie)).split(`
|
|
96
|
+
`).filter(tt=>tt.trim().length>0);for(const tt of ft){const Qe=tt.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(Qe.startsWith("|")||Qe.startsWith("{")||Qe.startsWith("[")||Qe.startsWith("```")||Qe.startsWith("---")||Qe.includes("Journal")||Qe.includes("(c-level)")||Qe.includes("(team-lead)")||Qe.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(Qe))&&Qe.length>15&&Qe.length<120)return Qe}}return""},oc=F=>{const P=ic[F];if(!P)return"";for(const ae of d){const fe=ae.content,we=fe.indexOf(`## ${P}`);if(we===-1)continue;const Ie=fe.indexOf(`
|
|
97
|
+
## `,we+10),ft=(Ie===-1?fe.slice(we):fe.slice(we,Ie)).replace(/^## .+\n/,"").trim();if(ft)return ft.slice(0,1500)}return""},en=rA();w.useEffect(()=>{a.length>0&&en.syncDefaultMembers(a)},[a]);const Li=Z6({roles:a,roleStatuses:jt,activeExecs:me,getStandupSpeech:sc}),cc=sA({roles:a,roleStatuses:jt,activeExecs:me,channels:en.channels,relationships:Li.relationships,pushMessage:en.pushMessage,speechSettings:lt,engineType:ze,hasApiKey:qt}),Ii=w.useCallback((F,P)=>{en.pushMessage({ts:Date.now(),roleId:"ceo",text:P,type:"chat",channelId:F}),cc.triggerCeoReaction(F)},[en,cc]);return N?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(hr||ul.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:()=>Qo(F=>!F),children:[hr?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:hr||"Knowledge import finished"}),_a&&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:`${_a.index/_a.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:Ba?"▲":"▼"})]}),Ba&&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:[ul.map(F=>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:[F.type==="scan"&&"🔍",F.type==="process"&&"⚙️",F.type==="created"&&"✅",F.type==="done"&&"🎉",F.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:F.type==="error"?"#EF4444":F.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:F.text}),F.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:F.detail})]})]},F.id)),l.jsx("div",{ref:dl})]})]}),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..."})]})})]}):C?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:C}),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 F=ye>=1e6?`${(ye/1e6).toFixed(1)}M`:ye>=1e3?`${(ye/1e3).toFixed(1)}K`:String(ye),P=me.length,ae=a.length>0?Math.round(P/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:F})]}),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:`${ae}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:ae})]})]})})(),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})]}),me.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:me.length})]}),(()=>{const F={roles:Object.entries(Ae).map(([ae,fe])=>({id:ae,level:fe.level,totalTokens:fe.totalTokens})),totalTokens:Object.values(Ae).reduce((ae,fe)=>ae+fe.totalTokens,0),roleCount:a.length},P=jy(F);return P.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:P.map(ae=>l.jsx("span",{title:`${ae.name}: ${ae.description}`,style:{fontSize:12,cursor:"default"},children:ae.icon},ae.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:id})]})]}),(hr||ul.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:()=>Qo(F=>!F),children:[hr?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:hr||"Knowledge import finished"}),_a&&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:`${_a.index/_a.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:Ba?"▲":"▼"})]}),Ba&&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:[ul.map(F=>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:[F.type==="scan"&&"🔍",F.type==="process"&&"⚙️",F.type==="created"&&"✅",F.type==="done"&&"🎉",F.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:F.type==="error"?"#EF4444":F.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:F.text}),F.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:F.detail})]})]},F.id)),l.jsx("div",{ref:dl}),ul.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(b8,{roles:a,projects:o,waves:m,standups:d,decisions:x,roleStatuses:ha,activeExecs:me,onRoleClick:F=>Pn({type:"role",roleId:F}),onProjectClick:F=>Pn({type:"project",projectId:F}),onBulletinClick:()=>{Pn({type:"bulletin"}),on({type:"bulletin_visited"})},onDecisionsClick:()=>Pn({type:"decisions"}),onKnowledgeClick:()=>{Pn({type:"knowledge"}),on({type:"knowledge_visited"})},onSettingsClick:()=>{ua(!0),on({type:"settings_visited"})},onThemeClick:()=>za(F=>!F),onStatsClick:()=>{mn(!0),on({type:"stats_visited"})},knowledgeDocsCount:v.length,getRoleSpeech:Li.getSpeech,getAppearance:Bt,onHireClick:()=>Ct(!0),onMascotClick:()=>Pn({type:"quest"}),roleLevels:Ae,language:ve,coinBalance:ye,onCoinsSpent:F=>ge(F),onFurniturePlaced:(F,P)=>{on({type:"furniture_placed"}),P>0&&on({type:"furniture_purchased"})}})}),Kn&&l.jsx("div",{className:ti?"absolute inset-0 z-50":"contents",children:l.jsx(Jg,{sessions:Un,activeSessionId:na,roles:a,streamingSessionId:fa,width:ti?_i:da,onWidthChange:ti?void 0:fl,onSwitchSession:qn,onCloseSession:nc,onCreateSession:gl,onClearEmpty:rc,onCloseAll:ac,onSendMessage:Ha,onModeChange:Os,onStopSession:F=>pe.abortSession(F).catch(()=>{}),onCloseTerminal:()=>$a(!1),onMaximize:()=>{Er.current="iso",Pt({type:"terminal"}),Hr("pro")},chatChannels:en.channels,activeChatChannelId:en.activeChannelId,onSwitchChatChannel:en.setActiveChannelId,onCreateChatChannel:(...F)=>{const P=en.createChannel(...F);return on({type:"chat_channel_created"}),P},onDeleteChatChannel:en.deleteChannel,onUpdateChatMembers:en.updateMembers,onUpdateChatTopic:en.updateTopic,onSendChatMessage:Ii,unreadChannels:en.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:()=>Hr("iso"),className:`view-toggle-btn ${Cr==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{Er.current="iso",Hr("pro")},className:`view-toggle-btn ${Cr==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${Ma?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>za(F=>!F),title:"Office Theme",children:[((uc=ol[J])==null?void 0:uc.icon)??"","▾"]}),Ma&&l.jsx(M8,{theme:J,onThemeChange:F=>{$e(F),on({type:"theme_changed"})},onClose:()=>za(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>ua(!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"?Vn(!0):Mi(!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"}),Gn&&(Gn.worktrees.length>0||Gn.staleBranches.length>0)&&l.jsxs("span",{style:{color:Gn.worktrees.some(F=>F.status==="stale")?"#ff6b6b":Gn.worktrees.some(F=>F.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["·"," ","📂"," ",Gn.worktrees.length," worktree",Gn.worktrees.length!==1?"s":"",Gn.staleBranches.length>0&&` · ⚠ ${Gn.staleBranches.length} branch${Gn.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[q.length>0&&!re&&l.jsx("button",{onClick:()=>ma(),className:`px-3 py-1 font-black text-white cursor-pointer ${Ge?"":"animate-pulse"}`,style:{background:Ge?"#2E7D32":"#B71C1C",border:`2px solid ${Ge?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Ge?"WAVE DONE":`WAVE (${q.length})`}),Le&&et&&q.length===0&&l.jsx("button",{onClick:()=>Pe(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${Ge?"":"animate-pulse"}`,style:{background:Ge?"#2E7D32":"#B71C1C",border:`2px solid ${Ge?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Ge?"WAVE DONE":"WAVE"}),D.length>0&&U&&l.jsxs("button",{onClick:()=>T(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:D[D.length-1].color,border:`2px solid ${D[D.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[D[D.length-1].title.slice(0,20),D[D.length-1].title.length>20?"..":""]}),l.jsxs("button",{onClick:()=>ma(),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:()=>Kn?$a(!1):Bs(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:Kn?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${Kn?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),Cr!=="pro"&&M.type==="role"&&R&&(()=>{var P,ae;const F=Ne[R.id];return l.jsx(Fg,{role:R,allRoles:a,recentActivity:oc(R.id),onClose:pr,onFireRole:(fe,we)=>{zt({roleId:fe,roleName:we}),pr()},terminalWidth:Kn?da:0,activeJobId:F==null?void 0:F.id,activeSessionId:(P=D.find(fe=>fe.jobId===(F==null?void 0:F.jobId)))==null?void 0:P.sessionId,activeTask:F==null?void 0:F.task,isWorking:Wn(ha[R.id]),jobStartedAt:F==null?void 0:F.startedAt,onStopJob:fe=>{const we=D.find(Ie=>Ie.jobId===fe);we&&pe.abortSession(we.sessionId)},sessions:Un,streamingSessionId:fa,onCreateSessionSilent:ai,onSendMessage:Ha,onFocusTerminal:tc,onCustomize:fe=>{const we=a.find(Ie=>Ie.id===fe);we&&(Ve("character"),Me(we))},onUpdateRole:ri,appearance:Bt(R.id),relationships:Li.relationships,roleLevel:(ae=Ae[R.id])==null?void 0:ae.level,onMaximize:()=>{Er.current="iso",Pt({type:"role",roleId:R.id}),Hr("pro")}})})(),Cr!=="pro"&&M.type==="project"&&lc&&l.jsx(HN,{projectId:lc.id,onClose:pr,terminalWidth:Kn?da:0}),Cr!=="pro"&&(M.type==="bulletin"||M.type==="decisions")&&l.jsx(Xg,{standups:d,waves:m,decisions:x,mode:M.type==="bulletin"?"bulletin":"decisions",onClose:pr,onOpenWaveCenter:()=>ma(),onUpdateDecision:Ia,onDeleteDecision:zs,terminalWidth:Kn?da:0,onMaximize:()=>{Er.current="iso",Pt({type:"operations"}),Hr("pro")}}),Cr!=="pro"&&M.type==="quest"&&l.jsx(IN,{progress:Ee,onClose:pr,terminalWidth:Kn?da:0,onQuestAction:F=>{var ae;pr();const P=js.find(fe=>fe.id===F);(ae=P==null?void 0:P.hint)!=null&&ae.target&&pa(P.hint.target)}}),Cr!=="pro"&&M.type==="knowledge"&&l.jsx(Yg,{docs:v,onClose:pr,onRefresh:()=>pe.getKnowledge().then(b).catch(()=>{}),terminalWidth:Kn?da:0,initialDocId:M.docId,onMaximize:()=>{Er.current="iso",Pt({type:"knowledge"}),Hr("pro")}}),Cr==="pro"&&l.jsxs(z8,{roles:a,roleStatuses:ha,activeExecs:me,waves:m,knowledgeDocs:v,sessions:Un,roleLevels:Ae,companyName:j,getAppearance:Bt,waveCenterWaves:q,renderProfile:ta.type==="role"&&R?F=>{var ae,fe;const P=Ne[R.id];return l.jsx(Fg,{role:R,allRoles:a,recentActivity:oc(R.id),onClose:F,onFireRole:(we,Ie)=>{zt({roleId:we,roleName:Ie})},terminalWidth:0,activeJobId:P==null?void 0:P.id,activeSessionId:(ae=D.find(we=>we.jobId===(P==null?void 0:P.jobId)))==null?void 0:ae.sessionId,activeTask:P==null?void 0:P.task,isWorking:Wn(ha[R.id]),jobStartedAt:P==null?void 0:P.startedAt,onStopJob:we=>{const Ie=D.find(Lt=>Lt.jobId===we);Ie&&pe.abortSession(Ie.sessionId)},sessions:Un,streamingSessionId:fa,onCreateSessionSilent:ai,onSendMessage:Ha,onFocusTerminal:()=>{},onCustomize:we=>{const Ie=a.find(Lt=>Lt.id===we);Ie&&(Ve("character"),Me(Ie))},onUpdateRole:ri,appearance:Bt(R.id),relationships:Li.relationships,roleLevel:(fe=Ae[R.id])==null?void 0:fe.level})}:void 0,channel:ta,onChannelChange:F=>{Pt(F),F.type==="role"?Pn({type:"role",roleId:F.roleId}):F.type==="knowledge"?Pn({type:"knowledge"}):F.type==="operations"?Pn({type:"bulletin"}):F.type==="wave"?K(!0):F.type==="terminal"?$a(!0):(H({type:"none"}),K(!1))},onClose:()=>{Hr(Er.current),H({type:"none"}),K(!1)},children:[ta.type==="dashboard"&&l.jsx(O8,{roles:a,roleStatuses:ha,activeExecs:me,waves:m,knowledgeDocs:v,roleLevels:Ae,getAppearance:Bt,onRoleClick:F=>Pt({type:"role",roleId:F}),onWaveClick:()=>Pt({type:"wave"}),onKnowledgeClick:()=>Pt({type:"knowledge"})}),ta.type==="terminal"&&l.jsx(Jg,{sessions:Un,activeSessionId:na,roles:a,streamingSessionId:fa,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:qn,onCloseSession:nc,onCreateSession:gl,onClearEmpty:rc,onCloseAll:ac,onSendMessage:Ha,onModeChange:Os,onStopSession:F=>pe.abortSession(F).catch(()=>{}),onCloseTerminal:()=>Pt({type:"dashboard"}),chatChannels:en.channels,activeChatChannelId:en.activeChannelId,onSwitchChatChannel:en.setActiveChannelId,onCreateChatChannel:(...F)=>{const P=en.createChannel(...F);return on({type:"chat_channel_created"}),P},onDeleteChatChannel:en.deleteChannel,onUpdateChatMembers:en.updateMembers,onUpdateChatTopic:en.updateTopic,onSendChatMessage:Ii,unreadChannels:en.unreadChannels}),ta.type==="wave"&&l.jsx(Qg,{orgNodes:se,rootRoleId:he,cLevelRoles:he&&se[he]?se[he].children.map(F=>a.find(P=>P.id===F)).filter(F=>!!F):a.filter(F=>F.level==="c-level"),pastWaves:m,activeWaves:q,onDispatch:(F,P)=>Yn(F,P),onClose:()=>Pt({type:"dashboard"}),onDone:()=>{sr(),Ce(!0),St("Wave complete","#2E7D32")},onSave:async(F,P,ae)=>{try{await pe.saveWave({directive:F,jobIds:P,waveId:ae==null?void 0:ae.waveId,sessionIds:ae==null?void 0:ae.sessionIds}),sr(),St("Wave saved","#2E7D32")}catch(fe){St(`Save failed: ${fe instanceof Error?fe.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:F=>{Pt({type:"knowledge"}),Pn({type:"knowledge",docId:F}),pe.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>pe.getWaves().then(h).catch(()=>{}),terminalWidth:0,inline:!0,onOpenSaveModal:()=>Vn(!0)}),ta.type==="knowledge"&&l.jsx(Yg,{docs:v,onClose:()=>Pt({type:"dashboard"}),onRefresh:()=>pe.getKnowledge().then(b).catch(()=>{}),terminalWidth:0}),ta.type==="operations"&&l.jsx(Xg,{standups:d,waves:m,decisions:x,mode:"bulletin",onClose:()=>Pt({type:"dashboard"}),onOpenWaveCenter:()=>Pt({type:"wave"}),onUpdateDecision:Ia,onDeleteDecision:zs,terminalWidth:0}),ta.type==="role"&&(()=>{const F=ta.roleId,P=a.find(fe=>fe.id===F);if(!P)return null;const ae=Un.find(fe=>fe.roleId===F);return ae?l.jsx(_8,{role:P,messages:ae.messages,isStreaming:fa===ae.id,mode:ae.mode,onModeChange:fe=>Os(ae.id,fe),onSend:(fe,we,Ie)=>Ha(ae.id,fe,we,Ie),isWave:ae.source==="wave"}):l.jsx(B8,{role:P,getAppearance:Bt,onSend:async(fe,we)=>{try{const Ie=await pe.createSession(F,"talk");sn(Lt=>[Ie,...Lt]),qn(Ie.id),Ha(Ie.id,fe,we)}catch(Ie){St(`Failed to create session: ${Ie instanceof Error?Ie.message:"API unreachable"}`,"#B71C1C")}}})})()]}),W&&l.jsx(YN,{roleId:W.roleId,roleName:W.roleName,mode:W.mode,onClose:()=>Y(null),onExecutionStart:ra}),Le&&!et&&l.jsx(a6,{directive:Le.directive,rootJobs:Le.rootJobs,orgNodes:se,rootRoleId:he,onClose:()=>{Ue(null),Pe(!1),Ce(!1)},onMinimize:()=>Pe(!0),onDone:()=>{sr(),Ce(!0),St("Wave complete","#2E7D32")},onSave:async F=>{try{await pe.saveWave({directive:Le.directive,jobIds:F}),sr(),St("Wave saved to bulletin","#2E7D32")}catch(P){St(`Save failed: ${P instanceof Error?P.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:F=>{Ue(null),Pe(!1),Ce(!1),Pn({type:"knowledge",docId:F}),pe.getKnowledge().then(b).catch(()=>{})}}),re&&Cr!=="pro"&&l.jsx(Qg,{orgNodes:se,rootRoleId:he,cLevelRoles:he&&se[he]?se[he].children.map(F=>a.find(P=>P.id===F)).filter(F=>!!F):a.filter(F=>F.level==="c-level"),pastWaves:m,activeWaves:q,onDispatch:(F,P)=>Yn(F,P),onClose:()=>K(!1),onMaximize:()=>{Er.current="iso",Pt({type:"wave"}),Hr("pro")},onDone:()=>{sr(),Ce(!0),St("Wave complete","#2E7D32")},onSave:async(F,P,ae)=>{try{await pe.saveWave({directive:F,jobIds:P,waveId:ae==null?void 0:ae.waveId,sessionIds:ae==null?void 0:ae.sessionIds}),sr(),St("Wave saved","#2E7D32")}catch(fe){St(`Save failed: ${fe instanceof Error?fe.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:F=>{K(!1),Pn({type:"knowledge",docId:F}),pe.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>pe.getWaves().then(h).catch(()=>{}),terminalWidth:Kn?da:0,onOpenSaveModal:()=>Vn(!0)}),D.length>0&&!U&&(()=>{var ae;const F=D[D.length-1],P=ue.length>1;return l.jsxs(l.Fragment,{children:[P&&D.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:ue.map((fe,we)=>l.jsx("button",{onClick:()=>{$(we),O([{sessionId:fe.sessionId,jobId:fe.jobId??"",title:`CEO WAVE · ${fe.roleId.toUpperCase()}`,color:"#B71C1C"}])},className:"px-3 py-1.5 text-xs font-bold rounded-t-lg cursor-pointer transition-colors",style:{background:A===we?"#B71C1C":"var(--terminal-bg)",color:A===we?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${A===we?"#B71C1C":"var(--terminal-border)"}`,borderBottom:"none"},children:fe.roleId.toUpperCase()},fe.sessionId))}),l.jsx(XN,{sessionId:F.sessionId,title:D.length>1?F.title:P?`CEO WAVE · ${((ae=ue[A])==null?void 0:ae.roleName)??""}`:F.title,color:F.color,variant:"modal",style:P&&D.length===1?{marginTop:28}:void 0,onClose:()=>{const fe=Un.filter(we=>we.source==="wave").map(we=>we.id);fe.length>0&&(sn(we=>we.filter(Ie=>Ie.source!=="wave")),pe.deleteSessions(fe).catch(()=>{})),O([]),V([]),$(0),T(!1)},onMinimize:()=>T(!0),onDone:()=>{$i(),sr()},onNavigateToJob:()=>{},onOpenKnowledgeDoc:fe=>{O([]),V([]),$(0),T(!1),Pn({type:"knowledge",docId:fe}),pe.getKnowledge().then(b).catch(()=>{})}},F.sessionId)]})})(),D.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:()=>O(F=>F.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 ",(dc=D[D.length-2])==null?void 0:dc.title]})})}),B&&l.jsx(KN,{cLevelRoles:he&&se[he]?se[he].children.map(F=>a.find(P=>P.id===F)).filter(F=>!!F):a.filter(F=>F.level==="c-level"),orgNodes:se,rootId:he,onClose:()=>ee(!1),onDispatch:(F,P)=>Yn(F,P)}),xt&&l.jsx(m6,{existingRoles:a,onClose:()=>Ct(!1),onHire:ni,onStoreVisit:()=>on({type:"store_visited"}),questHint:((fc=pl==null?void 0:pl.hint)==null?void 0:fc.target)==="hire-btn"?{message:pl.description,roleId:(($s=pl.trigger.condition)==null?void 0:$s.roleId)??void 0}:void 0}),Ht&&l.jsx(g6,{roleId:Ht.roleId,roleName:Ht.roleName,onClose:()=>zt(null),onConfirm:ld}),ne&&l.jsx(v8,{role:ne,appearance:Bt(ne.id),onSave:F=>{Jt(ne.id,F),on({type:"accessory_changed"})},onReset:()=>kn(ne.id),onClose:()=>{Me(null),Ve("character")},theme:J,onThemeChange:F=>{$e(F),on({type:"theme_changed"})},onUpdateName:async(F,P)=>{await ri(F,{name:P})},initialTab:"character",characterOnly:!0,speechSettings:lt,onSpeechSettingsChange:Kt,language:ve,onLanguageChange:wt,roleLevel:(hc=Ae[ne.id])==null?void 0:hc.level,coinBalance:ye,purchased:jn,onPurchase:(F,P)=>{pe.spendCoins(P,`Purchased ${F}`,F).then(ae=>{ge(ae.balance),hn(F)}).catch(()=>{})}}),Sn&&(()=>{const F=a.find(P=>P.id==="cto")??a.find(P=>P.level==="c-level")??a[0];return l.jsx(j8,{status:Ze.status,history:Ze.history,onClose:()=>Vn(!1),onSave:async P=>{const ae=await Ze.save(P);return ae!=null&&ae.ok&&on({type:"save_committed"}),ae},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:(F==null?void 0:F.name)??(F==null?void 0:F.id),onDelegate:F?async P=>{Vn(!1);try{const ae=await pe.createSession(F.id,"do");sn(we=>[ae,...we]),qn(ae.id),hl();const fe=`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.
|
|
98
|
+
|
|
99
|
+
Changed files:
|
|
100
|
+
${P}`;Ha(ae.id,fe,"do")}catch(ae){St(`Failed to delegate: ${ae instanceof Error?ae.message:"error"}`,"#B71C1C")}}:void 0})})(),yn&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>mn(!1),children:l.jsx("div",{style:{width:420,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8},onClick:F=>F.stopPropagation(),children:l.jsx(S8,{onClose:()=>mn(!1)})})}),Lr&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Jl(!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:F=>F.stopPropagation(),children:l.jsx(N8,{onClose:()=>Jl(!1),onSyncComplete:()=>{}})})}),Rs&&l.jsx(R8,{onClose:()=>ua(!1),speechSettings:lt,onSpeechSettingsChange:Kt,language:ve,onLanguageChange:wt,onOpenSync:()=>Jl(!0),onOpenGitStatus:()=>Mi(!0),onOpenSessions:()=>Ra(!0),onOpenStats:()=>mn(!0)}),Fs&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Mi(!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:F=>F.stopPropagation(),children:l.jsx(A8,{onClose:()=>Mi(!1)})})}),Po&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ra(!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:F=>F.stopPropagation(),children:l.jsx(D8,{onClose:()=>Ra(!1)})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:G.map(F=>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:F.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"}),F.message]},F.id))})]})}function zu({onSelect:e,onClose:n}){const[a,i]=w.useState(null),[o,u]=w.useState(!0),[d,f]=w.useState(""),[m,h]=w.useState(!1),[x,g]=w.useState(!1),v=w.useRef(null),b=w.useCallback(async k=>{u(!0);try{const N=await pe.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())){g(!0);try{const k=await pe.mkdir(a.current,d.trim());k.ok&&(f(""),h(!1),await b(k.path))}catch{}finally{g(!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:()=>{h(!m),f("")},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=>f(k.target.value),onKeyDown:k=>{k.key==="Enter"&&j(),k.key==="Escape"&&h(!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 H8={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function Cy(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function U8({onComplete:e}){const[n,a]=w.useState(0),[i,o]=w.useState(null),[u,d]=w.useState("none"),[f,m]=w.useState(""),[h,x]=w.useState(!0),[g,v]=w.useState(""),[b,j]=w.useState(""),[k,N]=w.useState("en"),E=w.useRef(null),[C,_]=w.useState("new"),[M,H]=w.useState(""),[R,I]=w.useState(""),[W,Y]=w.useState(!1),[D,O]=w.useState(!1),[B,ee]=w.useState(!1),[re,K]=w.useState(""),[q,ce]=w.useState(!1),[ue,V]=w.useState(!1),[A,$]=w.useState([]),[U,T]=w.useState(""),[se,ke]=w.useState(!1),[he,_e]=w.useState(""),[Le,Ue]=w.useState(null),[et,Pe]=w.useState(!1),[Ge,Ce]=w.useState(!1),[Ae,yt]=w.useState([]),[ct,xt]=w.useState("startup"),[Ct,Ht]=w.useState(!1),[zt,jt]=w.useState(!1),[Hn,me]=w.useState(null),[je,Ne]=w.useState([]),[G,Z]=w.useState(""),[ye,ge]=w.useState(!1),[Ee,Fe]=w.useState(!1),[Be,Oe]=w.useState([]),qe=w.useMemo(()=>Cy(C),[C]),at=qe[n]??"engine";w.useEffect(()=>{pe.detectEngine().then(ve=>{o(ve),d(ve.recommended),x(!1)}).catch(()=>x(!1)),pe.getTeams().then(yt).catch(()=>{}),pe.getStatus().then(ve=>{I(ve.companyRoot||"")}).catch(()=>{})},[]),w.useEffect(()=>{var ve;at==="company"&&((ve=E.current)==null||ve.focus())},[at]),w.useEffect(()=>{if(W||!R)return;const ve=g.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");H(ve?`${R}/${ve}`:R)},[g,R,W]);const We=()=>{switch(at){case"engine":return u!=="none"||f.length>10;case"company":return g.trim().length>0;case"workspace":return C==="existing-akb"?Le===!0:!0;case"team":return!0;case"create":return!zt;default:return!1}},Dt=()=>{n<qe.length-1&&We()&&a(n+1),at==="create"&&!Ct&&!ye&&(C==="existing-akb"?kn():Jt())},ze=()=>{n>0&&a(n-1)},He=w.useRef(C);w.useEffect(()=>{if(He.current===C)return;He.current=C;const wt=Cy(C).indexOf("workspace");wt>=0&&a(wt)},[C]);const qt=async()=>{if(he.trim()){Pe(!0);try{const ve=await pe.validatePath(he.trim());Ue(ve.valid&&ve.hasClaudeMd===!0)}catch{Ue(!1)}finally{Pe(!1)}}},_t=()=>{const ve=U.trim();ve&&!A.includes(ve)&&($([...A,ve]),T(""))},Bt=async ve=>{Fe(!0),Oe([]);try{const{tools:wt}=await pe.getRequiredTools(ve);if(wt.filter(hn=>!hn.installed).length===0){Fe(!1);return}await pe.installTools(ve,(hn,ne)=>{const Me=ne.tool||"";hn==="checking"?Oe(Ve=>[...Ve,{event:hn,tool:Me,detail:"checking..."}]):hn==="installing"?Oe(Ve=>[...Ve,{event:hn,tool:Me,detail:"installing..."}]):hn==="installed"?Oe(Ve=>[...Ve,{event:hn,tool:Me,detail:"installed"}]):hn==="skipped"?Oe(Ve=>[...Ve,{event:hn,tool:Me,detail:ne.reason||"skipped"}]):hn==="error"&&Oe(Ve=>[...Ve,{event:hn,tool:Me,detail:ne.error||"failed"}])})}catch{}finally{Fe(!1)}},Jt=async()=>{Ht(!0),me(null);try{const ve={companyName:g.trim(),description:b.trim()||"An AI-powered organization",team:ct,knowledgePaths:A.length>0?A:void 0,language:k!=="auto"?k:void 0,location:M.trim()||void 0,codeRoot:re.trim()||void 0};(u==="direct-api"||f)&&(ve.apiKey=f||void 0);const wt=await pe.scaffold(ve);Ne(wt.created),Z(wt.projectRoot),jt(!0),Ht(!1),ct!=="custom"&&Bt(ct)}catch(ve){me(ve instanceof Error?ve.message:"Scaffold failed"),Ht(!1)}},kn=async()=>{ge(!0),me(null);try{const ve=await pe.connectAkb(he.trim());ve.ok?(jt(!0),Ne([`Connected to: ${ve.companyRoot}`])):me(ve.error||"Failed to connect")}catch(ve){me(ve instanceof Error?ve.message:"Connect failed")}finally{ge(!1)}},J=()=>{A.length>0?e({paths:A,companyRoot:""}):e()},$e=ve=>{ve.key==="Enter"&&We()&&(ve.preventDefault(),Dt())},lt=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
|
|
101
|
+
bg-[var(--terminal-bg)] text-[var(--terminal-text)]
|
|
102
|
+
border border-[var(--terminal-border)]
|
|
103
|
+
focus:border-[var(--terminal-border-hover)]
|
|
104
|
+
placeholder:text-[var(--terminal-text-muted)]`,Kt=ve=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ve?"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:$e,children:l.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"px-6 py-5",style:{background:"var(--terminal-bg)",borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-lg font-bold",style:{color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:"tycono"}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-secondary)"},children:"Build an AI company. Watch them work."}),l.jsx("div",{className:"flex gap-1.5 mt-4",children:qe.map((ve,wt)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:wt<=n?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:wt===n?"var(--terminal-text)":"var(--terminal-text-muted)"},children:H8[ve]})]},ve))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[at==="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"}),h?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:Kt(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:Kt(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:`${lt} mt-3`,placeholder:"sk-ant-...",value:f,onChange:ve=>m(ve.target.value),autoFocus:!0})]})]})]}),at==="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:E,className:lt,placeholder:"e.g. Acme Corp",value:g,onChange:ve=>v(ve.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:`${lt} resize-none`,rows:3,placeholder:"What does your AI company do?",value:b,onChange:ve=>j(ve.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:lt,value:k,onChange:ve=>N(ve.target.value),children:[l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"한국어"}),l.jsx("option",{value:"ja",children:"日本語"})]})]})]}),at==="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(ap,{text:`"New Company" creates a fresh workspace with roles, knowledge base, and project structure.
|
|
105
|
+
|
|
106
|
+
"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:C==="new"?"var(--accent)":"var(--hud-bg-alt)",color:C==="new"?"#fff":"var(--terminal-text-muted)"},onClick:()=>_("new"),children:"New Company"}),l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:C==="existing-akb"?"var(--accent)":"var(--hud-bg-alt)",color:C==="existing-akb"?"#fff":"var(--terminal-text-muted)",borderLeft:"1px solid var(--terminal-border)"},onClick:()=>_("existing-akb"),children:"Connect Existing"})]}),C==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Ey,{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:`${lt} flex-1`,placeholder:"/path/to/your-company",value:M,onChange:ve=>{H(ve.target.value),Y(!0)}}),l.jsx("button",{onClick:()=>O(!D),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:"📁"})]}),D&&l.jsx(zu,{onSelect:ve=>{H(ve),Y(!0),O(!1)},onClose:()=>O(!1)})]}),l.jsxs(Ny,{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.
|
|
107
|
+
|
|
108
|
+
Skip this if you don't have a codebase yet — you can connect one later from Settings.`,tag:"optional",open:B,onToggle:()=>ee(!B),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${lt} flex-1`,placeholder:"/path/to/code/repo",value:re,onChange:ve=>K(ve.target.value)}),l.jsx("button",{onClick:()=>ce(!q),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"})]}),q&&l.jsx(zu,{onSelect:ve=>{K(ve),ce(!1)},onClose:()=>ce(!1)})]}),l.jsxs(Ny,{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.
|
|
109
|
+
|
|
110
|
+
Skip this to start with an empty knowledge base. You can import documents anytime from the office.`,tag:"optional",open:ue,onToggle:()=>V(!ue),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${lt} flex-1`,placeholder:"/path/to/docs",value:U,onChange:ve=>T(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&(ve.preventDefault(),_t())}}),l.jsx("button",{onClick:()=>ke(!se),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:_t,disabled:!U.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:U.trim()?1:.5},children:"Add"})]}),se&&l.jsx(zu,{onSelect:ve=>{A.includes(ve)||$([...A,ve]),ke(!1)},onClose:()=>ke(!1)}),A.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:A.map((ve,wt)=>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:ve}),l.jsx("button",{onClick:()=>$(A.filter((jn,hn)=>hn!==wt)),className:"opacity-50 hover:opacity-100",children:"✕"})]},wt))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(Ey,{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:`${lt} flex-1`,placeholder:"/path/to/your/akb",value:he,onChange:ve=>{_e(ve.target.value),Ue(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>Ce(!Ge),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:qt,disabled:et||!he.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:et||!he.trim()?.5:1},children:et?"...":"Verify"})]}),Le===!0&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found"]}),Le===!1&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),Ge&&l.jsx(zu,{onSelect:ve=>{_e(ve),Ue(null),Ce(!1)},onClose:()=>Ce(!1)})]})})]}),at==="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."}),Ae.map(ve=>l.jsxs("div",{className:Kt(ct===ve.id),onClick:()=>xt(ve.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:ve.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ve.roles.map(wt=>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:wt.id.toUpperCase()},wt.id))})]},ve.id)),l.jsxs("div",{className:Kt(ct==="custom"),onClick:()=>xt("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."})]})]}),at==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:zt?C==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!zt&&!Ct&&!ye&&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:C==="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:"})," ",he]}),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:"})," ",g]}),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"]}),re.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Code Repo:"})," ",re]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",A.length>0?`Import ${A.length} source(s)`:"Fresh (empty)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Team:"})," ",ct]}),A.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."})]})}),Hn&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:Hn})]}),(Ct||ye)&&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:ye?"Connecting to AKB...":"Scaffolding your company..."})]}),zt&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),G&&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:"})," ",G]}),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:je.map((ve,wt)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ve]},wt))}),(Ee||Be.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:Ee?"Installing skill tools...":"Skill tools"}),Be.map((ve,wt)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:ve.event==="installed"||ve.event==="skipped"?"var(--active-green)":ve.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:ve.event==="installed"||ve.event==="skipped"?"✓":ve.event==="error"?"✗":"…"}),l.jsx("span",{children:ve.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:ve.detail})]},wt)),Ee&&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..."})]})]}),A.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&&!zt&&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," / ",qe.length]}),l.jsx("div",{children:zt?l.jsx("button",{onClick:J,disabled:Ee,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:Ee?.5:1},children:Ee?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:Dt,disabled:!We()||Ct||ye,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:We()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:We()&&!Ct&&!ye?1:.5},children:at==="create"?Ct||ye?ye?"Connecting...":"Creating...":C==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function ap({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 f=u.current.getBoundingClientRect();o({top:f.bottom+6,left:f.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:f=>{f.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 Ey({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(ap,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:a})]}),o]})}function Ny({icon:e,title:n,hint:a,help:i,tag:o,open:u,onToggle:d,children:f}){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(ap,{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:f})]})}function q8(){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 f=await pe.getStatus();n(f)}catch(f){u(f instanceof Error?f.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 Y8=w.lazy(()=>Dy(()=>import("./preview-app-B2p8z-M8.js"),[]));function Lv(){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 X8(){var e;try{const n=localStorage.getItem("tycono-theme"),a=n&&n in ol?n:"default",i=(e=ol[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 W8(){const{initialized:e,loading:n,refetch:a}=q8(),[i,o]=w.useState(null);w.useEffect(()=>{X8()},[]);const u=d=>{d&&o(d),a()};return n?l.jsx(Lv,{}):e?l.jsx(I8,{importJob:i,onImportDone:()=>o(null)}):l.jsx(U8,{onComplete:u})}function V8(){const e=new URLSearchParams(window.location.search).has("sprite-preview");return l.jsx(Dw,{children:e?l.jsx(w.Suspense,{fallback:l.jsx(Lv,{}),children:l.jsx(Y8,{})}):l.jsx(W8,{})})}Ew.createRoot(document.getElementById("root")).render(l.jsx(w.StrictMode,{children:l.jsx(V8,{})}));export{xv as H,yv as P,bv as S,Q8 as a,gv as b,pv as c,sm as d,sC as e,K8 as f,P8 as g,Z8 as h,l as j,w as r};
|