tycono 0.1.93-beta.2 → 0.1.93
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 -0
- package/src/api/src/engine/agent-loop.ts +52 -9
- package/src/api/src/engine/context-assembler.ts +59 -0
- package/src/api/src/engine/org-tree.ts +17 -0
- package/src/api/src/engine/runners/claude-cli.ts +157 -0
- package/src/api/src/engine/runners/direct-api.ts +2 -0
- package/src/api/src/engine/runners/types.ts +4 -0
- package/src/api/src/engine/tools/definitions.ts +55 -1
- package/src/api/src/engine/tools/executor.ts +163 -0
- package/src/api/src/routes/supervision.ts +136 -0
- package/src/api/src/services/digest-engine.ts +313 -0
- package/src/api/src/services/execution-manager.ts +6 -0
- package/src/shared/types.ts +2 -0
- package/src/web/dist/assets/index-CoIZS-E0.css +1 -0
- package/src/web/dist/assets/index-mJNkf7g0.js +115 -0
- package/src/web/dist/assets/{preview-app-CywDONM1.js → preview-app-BHNMBMSl.js} +1 -1
- package/src/web/dist/index.html +2 -2
- package/src/web/dist/assets/index-BoJAXuTo.js +0 -115
- package/src/web/dist/assets/index-rya2vj54.css +0 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var gw=Object.defineProperty;var yw=(e,n,a)=>n in e?gw(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var E0=(e,n,a)=>yw(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 c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function a(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=a(o);fetch(o.href,c)}})();function Ty(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var rh={exports:{}},Co={};/**
|
|
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 A0;function bw(){if(A0)return Co;A0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(i,o,c){var d=null;if(c!==void 0&&(d=""+c),o.key!==void 0&&(d=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:i,key:d,ref:o!==void 0?o:null,props:c}}return Co.Fragment=n,Co.jsx=a,Co.jsxs=a,Co}var D0;function vw(){return D0||(D0=1,rh.exports=bw()),rh.exports}var l=vw(),ah={exports:{}},xt={};/**
|
|
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 T0;function ww(){if(T0)return xt;T0=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"),c=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"),w=Symbol.iterator;function b(U){return U===null||typeof U!="object"?null:(U=w&&U[w]||U["@@iterator"],typeof U=="function"?U:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,E={};function N(U,Y,R){this.props=U,this.context=Y,this.refs=E,this.updater=R||j}N.prototype.isReactComponent={},N.prototype.setState=function(U,Y){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,Y,"setState")},N.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function C(){}C.prototype=N.prototype;function z(U,Y,R){this.props=U,this.context=Y,this.refs=E,this.updater=R||j}var T=z.prototype=new C;T.constructor=z,k(T,N.prototype),T.isPureReactComponent=!0;var H=Array.isArray;function F(){}var I={H:null,A:null,T:null,S:null},V=Object.prototype.hasOwnProperty;function X(U,Y,R){var O=R.ref;return{$$typeof:e,type:U,key:Y,ref:O!==void 0?O:null,props:R}}function _(U,Y){return X(U.type,Y,U.props)}function $(U){return typeof U=="object"&&U!==null&&U.$$typeof===e}function L(U){var Y={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(R){return Y[R]})}var W=/\/+/g;function ne(U,Y){return typeof U=="object"&&U!==null&&U.key!=null?L(""+U.key):Y.toString(36)}function K(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(F,F):(U.status="pending",U.then(function(Y){U.status==="pending"&&(U.status="fulfilled",U.value=Y)},function(Y){U.status==="pending"&&(U.status="rejected",U.reason=Y)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function q(U,Y,R,O,ae){var te=typeof U;(te==="undefined"||te==="boolean")&&(U=null);var Se=!1;if(U===null)Se=!0;else switch(te){case"bigint":case"string":case"number":Se=!0;break;case"object":switch(U.$$typeof){case e:case n:Se=!0;break;case x:return Se=U._init,q(Se(U._payload),Y,R,O,ae)}}if(Se)return ae=ae(U),Se=O===""?"."+ne(U,0):O,H(ae)?(R="",Se!=null&&(R=Se.replace(W,"$&/")+"/"),q(ae,Y,R,"",function(Oe){return Oe})):ae!=null&&($(ae)&&(ae=_(ae,R+(ae.key==null||U&&U.key===ae.key?"":(""+ae.key).replace(W,"$&/")+"/")+Se)),Y.push(ae)),1;Se=0;var je=O===""?".":O+":";if(H(U))for(var _e=0;_e<U.length;_e++)O=U[_e],te=je+ne(O,_e),Se+=q(O,Y,R,te,ae);else if(_e=b(U),typeof _e=="function")for(U=_e.call(U),_e=0;!(O=U.next()).done;)O=O.value,te=je+ne(O,_e++),Se+=q(O,Y,R,te,ae);else if(te==="object"){if(typeof U.then=="function")return q(K(U),Y,R,O,ae);throw Y=String(U),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return Se}function ie(U,Y,R){if(U==null)return U;var O=[],ae=0;return q(U,O,"","",function(te){return Y.call(R,te,ae++)}),O}function de(U){if(U._status===-1){var Y=U._result;Y=Y(),Y.then(function(R){(U._status===0||U._status===-1)&&(U._status=1,U._result=R)},function(R){(U._status===0||U._status===-1)&&(U._status=2,U._result=R)}),U._status===-1&&(U._status=0,U._result=Y)}if(U._status===1)return U._result.default;throw U._result}var me=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},D={map:ie,forEach:function(U,Y,R){ie(U,function(){Y.apply(this,arguments)},R)},count:function(U){var Y=0;return ie(U,function(){Y++}),Y},toArray:function(U){return ie(U,function(Y){return Y})||[]},only:function(U){if(!$(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return xt.Activity=g,xt.Children=D,xt.Component=N,xt.Fragment=a,xt.Profiler=o,xt.PureComponent=z,xt.StrictMode=i,xt.Suspense=m,xt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,xt.__COMPILER_RUNTIME={__proto__:null,c:function(U){return I.H.useMemoCache(U)}},xt.cache=function(U){return function(){return U.apply(null,arguments)}},xt.cacheSignal=function(){return null},xt.cloneElement=function(U,Y,R){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var O=k({},U.props),ae=U.key;if(Y!=null)for(te in Y.key!==void 0&&(ae=""+Y.key),Y)!V.call(Y,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&Y.ref===void 0||(O[te]=Y[te]);var te=arguments.length-2;if(te===1)O.children=R;else if(1<te){for(var Se=Array(te),je=0;je<te;je++)Se[je]=arguments[je+2];O.children=Se}return X(U.type,ae,O)},xt.createContext=function(U){return U={$$typeof:d,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:c,_context:U},U},xt.createElement=function(U,Y,R){var O,ae={},te=null;if(Y!=null)for(O in Y.key!==void 0&&(te=""+Y.key),Y)V.call(Y,O)&&O!=="key"&&O!=="__self"&&O!=="__source"&&(ae[O]=Y[O]);var Se=arguments.length-2;if(Se===1)ae.children=R;else if(1<Se){for(var je=Array(Se),_e=0;_e<Se;_e++)je[_e]=arguments[_e+2];ae.children=je}if(U&&U.defaultProps)for(O in Se=U.defaultProps,Se)ae[O]===void 0&&(ae[O]=Se[O]);return X(U,te,ae)},xt.createRef=function(){return{current:null}},xt.forwardRef=function(U){return{$$typeof:f,render:U}},xt.isValidElement=$,xt.lazy=function(U){return{$$typeof:x,_payload:{_status:-1,_result:U},_init:de}},xt.memo=function(U,Y){return{$$typeof:h,type:U,compare:Y===void 0?null:Y}},xt.startTransition=function(U){var Y=I.T,R={};I.T=R;try{var O=U(),ae=I.S;ae!==null&&ae(R,O),typeof O=="object"&&O!==null&&typeof O.then=="function"&&O.then(F,me)}catch(te){me(te)}finally{Y!==null&&R.types!==null&&(Y.types=R.types),I.T=Y}},xt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},xt.use=function(U){return I.H.use(U)},xt.useActionState=function(U,Y,R){return I.H.useActionState(U,Y,R)},xt.useCallback=function(U,Y){return I.H.useCallback(U,Y)},xt.useContext=function(U){return I.H.useContext(U)},xt.useDebugValue=function(){},xt.useDeferredValue=function(U,Y){return I.H.useDeferredValue(U,Y)},xt.useEffect=function(U,Y){return I.H.useEffect(U,Y)},xt.useEffectEvent=function(U){return I.H.useEffectEvent(U)},xt.useId=function(){return I.H.useId()},xt.useImperativeHandle=function(U,Y,R){return I.H.useImperativeHandle(U,Y,R)},xt.useInsertionEffect=function(U,Y){return I.H.useInsertionEffect(U,Y)},xt.useLayoutEffect=function(U,Y){return I.H.useLayoutEffect(U,Y)},xt.useMemo=function(U,Y){return I.H.useMemo(U,Y)},xt.useOptimistic=function(U,Y){return I.H.useOptimistic(U,Y)},xt.useReducer=function(U,Y,R){return I.H.useReducer(U,Y,R)},xt.useRef=function(U){return I.H.useRef(U)},xt.useState=function(U){return I.H.useState(U)},xt.useSyncExternalStore=function(U,Y,R){return I.H.useSyncExternalStore(U,Y,R)},xt.useTransition=function(){return I.H.useTransition()},xt.version="19.2.4",xt}var F0;function Nm(){return F0||(F0=1,ah.exports=ww()),ah.exports}var v=Nm(),lh={exports:{}},No={},ih={exports:{}},sh={};/**
|
|
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 R0;function kw(){return R0||(R0=1,(function(e){function n(q,ie){var de=q.length;q.push(ie);e:for(;0<de;){var me=de-1>>>1,D=q[me];if(0<o(D,ie))q[me]=ie,q[de]=D,de=me;else break e}}function a(q){return q.length===0?null:q[0]}function i(q){if(q.length===0)return null;var ie=q[0],de=q.pop();if(de!==ie){q[0]=de;e:for(var me=0,D=q.length,U=D>>>1;me<U;){var Y=2*(me+1)-1,R=q[Y],O=Y+1,ae=q[O];if(0>o(R,de))O<D&&0>o(ae,R)?(q[me]=ae,q[O]=de,me=O):(q[me]=R,q[Y]=de,me=Y);else if(O<D&&0>o(ae,de))q[me]=ae,q[O]=de,me=O;else break e}}return ie}function o(q,ie){var de=q.sortIndex-ie.sortIndex;return de!==0?de:q.id-ie.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var m=[],h=[],x=1,g=null,w=3,b=!1,j=!1,k=!1,E=!1,N=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;function T(q){for(var ie=a(h);ie!==null;){if(ie.callback===null)i(h);else if(ie.startTime<=q)i(h),ie.sortIndex=ie.expirationTime,n(m,ie);else break;ie=a(h)}}function H(q){if(k=!1,T(q),!j)if(a(m)!==null)j=!0,F||(F=!0,L());else{var ie=a(h);ie!==null&&K(H,ie.startTime-q)}}var F=!1,I=-1,V=5,X=-1;function _(){return E?!0:!(e.unstable_now()-X<V)}function $(){if(E=!1,F){var q=e.unstable_now();X=q;var ie=!0;try{e:{j=!1,k&&(k=!1,C(I),I=-1),b=!0;var de=w;try{t:{for(T(q),g=a(m);g!==null&&!(g.expirationTime>q&&_());){var me=g.callback;if(typeof me=="function"){g.callback=null,w=g.priorityLevel;var D=me(g.expirationTime<=q);if(q=e.unstable_now(),typeof D=="function"){g.callback=D,T(q),ie=!0;break t}g===a(m)&&i(m),T(q)}else i(m);g=a(m)}if(g!==null)ie=!0;else{var U=a(h);U!==null&&K(H,U.startTime-q),ie=!1}}break e}finally{g=null,w=de,b=!1}ie=void 0}}finally{ie?L():F=!1}}}var L;if(typeof z=="function")L=function(){z($)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,ne=W.port2;W.port1.onmessage=$,L=function(){ne.postMessage(null)}}else L=function(){N($,0)};function K(q,ie){I=N(function(){q(e.unstable_now())},ie)}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"):V=0<q?Math.floor(1e3/q):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(q){switch(w){case 1:case 2:case 3:var ie=3;break;default:ie=w}var de=w;w=ie;try{return q()}finally{w=de}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(q,ie){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var de=w;w=q;try{return ie()}finally{w=de}},e.unstable_scheduleCallback=function(q,ie,de){var me=e.unstable_now();switch(typeof de=="object"&&de!==null?(de=de.delay,de=typeof de=="number"&&0<de?me+de:me):de=me,q){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=de+D,q={id:x++,callback:ie,priorityLevel:q,startTime:de,expirationTime:D,sortIndex:-1},de>me?(q.sortIndex=de,n(h,q),a(m)===null&&q===a(h)&&(k?(C(I),I=-1):k=!0,K(H,de-me))):(q.sortIndex=D,n(m,q),j||b||(j=!0,F||(F=!0,L()))),q},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(q){var ie=w;return function(){var de=w;w=ie;try{return q.apply(this,arguments)}finally{w=de}}}})(sh)),sh}var M0;function jw(){return M0||(M0=1,ih.exports=kw()),ih.exports}var oh={exports:{}},ar={};/**
|
|
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 z0;function Sw(){if(z0)return ar;z0=1;var e=Nm();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 c(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 ar.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,ar.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 c(m,h,null,x)},ar.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()}},ar.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))},ar.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},ar.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin),w=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:w,fetchPriority:b}):x==="script"&&i.d.X(m,{crossOrigin:g,integrity:w,fetchPriority:b,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},ar.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)},ar.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})}},ar.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)},ar.requestFormReset=function(m){i.d.r(m)},ar.unstable_batchedUpdates=function(m,h){return m(h)},ar.useFormState=function(m,h,x){return d.H.useFormState(m,h,x)},ar.useFormStatus=function(){return d.H.useHostTransitionStatus()},ar.version="19.2.4",ar}var _0;function Cw(){if(_0)return oh.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(),oh.exports=Sw(),oh.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 B0;function Nw(){if(B0)return No;B0=1;var e=jw(),n=Nm(),a=Cw();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 c(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(c(t)!==t)throw Error(i(188))}function h(t){var r=t.alternate;if(!r){if(r=c(t),r===null)throw Error(i(188));return r!==t?null:t}for(var s=t,u=r;;){var p=s.return;if(p===null)break;var y=p.alternate;if(y===null){if(u=p.return,u!==null){s=u;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===s)return m(p),t;if(y===u)return m(p),r;y=y.sibling}throw Error(i(188))}if(s.return!==u.return)s=p,u=y;else{for(var S=!1,M=p.child;M;){if(M===s){S=!0,s=p,u=y;break}if(M===u){S=!0,u=p,s=y;break}M=M.sibling}if(!S){for(M=y.child;M;){if(M===s){S=!0,s=y,u=p;break}if(M===u){S=!0,u=y,s=p;break}M=M.sibling}if(!S)throw Error(i(189))}}if(s.alternate!==u)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,w=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),z=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),_=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function L(t){return t===null||typeof t!="object"?null:(t=$&&t[$]||t["@@iterator"],typeof t=="function"?t:null)}var W=Symbol.for("react.client.reference");function ne(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===W?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case N:return"Profiler";case E:return"StrictMode";case H:return"Suspense";case F:return"SuspenseList";case X:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case j:return"Portal";case z:return t.displayName||"Context";case C:return(t._context.displayName||"Context")+".Consumer";case T: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:ne(t.type)||"Memo";case V:r=t._payload,t=t._init;try{return ne(t(r))}catch{}}return null}var K=Array.isArray,q=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},me=[],D=-1;function U(t){return{current:t}}function Y(t){0>D||(t.current=me[D],me[D]=null,D--)}function R(t,r){D++,me[D]=t.current,t.current=r}var O=U(null),ae=U(null),te=U(null),Se=U(null);function je(t,r){switch(R(te,r),R(ae,t),R(O,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?P1(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=P1(r),t=Q1(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Y(O),R(O,t)}function _e(){Y(O),Y(ae),Y(te)}function Oe(t){t.memoizedState!==null&&R(Se,t);var r=O.current,s=Q1(r,t.type);r!==s&&(R(ae,t),R(O,s))}function Xe(t){ae.current===t&&(Y(O),Y(ae)),Se.current===t&&(Y(Se),wo._currentValue=de)}var rt,De;function We(t){if(rt===void 0)try{throw Error()}catch(s){var r=s.stack.trim().match(/\n( *(at )?)/);rt=r&&r[1]||"",De=-1<s.stack.indexOf(`
|
|
42
|
+
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
+
`+rt+t+De}var Ot=!1;function yt(t,r){if(!t||Ot)return"";Ot=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(r){var Ce=function(){throw Error()};if(Object.defineProperty(Ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ce,[])}catch(he){var ue=he}Reflect.construct(t,[],Ce)}else{try{Ce.call()}catch(he){ue=he}t.call(Ce.prototype)}}else{try{throw Error()}catch(he){ue=he}(Ce=t())&&typeof Ce.catch=="function"&&Ce.catch(function(){})}}catch(he){if(he&&ue&&typeof he.stack=="string")return[he.stack,ue.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=u.DetermineComponentFrameRoot(),S=y[0],M=y[1];if(S&&M){var G=S.split(`
|
|
44
|
+
`),ce=M.split(`
|
|
45
|
+
`);for(p=u=0;u<G.length&&!G[u].includes("DetermineComponentFrameRoot");)u++;for(;p<ce.length&&!ce[p].includes("DetermineComponentFrameRoot");)p++;if(u===G.length||p===ce.length)for(u=G.length-1,p=ce.length-1;1<=u&&0<=p&&G[u]!==ce[p];)p--;for(;1<=u&&0<=p;u--,p--)if(G[u]!==ce[p]){if(u!==1||p!==1)do if(u--,p--,0>p||G[u]!==ce[p]){var ge=`
|
|
46
|
+
`+G[u].replace(" at new "," at ");return t.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",t.displayName)),ge}while(1<=u&&0<=p);break}}}finally{Ot=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?We(s):""}function bt(t,r){switch(t.tag){case 26:case 27:case 5:return We(t.type);case 16:return We("Lazy");case 13:return t.child!==r&&r!==null?We("Suspense Fallback"):We("Suspense");case 19:return We("SuspenseList");case 0:case 15:return yt(t.type,!1);case 11:return yt(t.type.render,!1);case 1:return yt(t.type,!0);case 31:return We("Activity");default:return""}}function jt(t){try{var r="",s=null;do r+=bt(t,s),s=t,t=t.return;while(t);return r}catch(u){return`
|
|
47
|
+
Error generating stack: `+u.message+`
|
|
48
|
+
`+u.stack}}var qe=Object.prototype.hasOwnProperty,at=e.unstable_scheduleCallback,pt=e.unstable_cancelCallback,zt=e.unstable_shouldYield,fe=e.unstable_requestPaint,be=e.unstable_now,ve=e.unstable_getCurrentPriorityLevel,Q=e.unstable_ImmediatePriority,Z=e.unstable_UserBlockingPriority,Ee=e.unstable_NormalPriority,xe=e.unstable_LowPriority,Ae=e.unstable_IdlePriority,ze=e.log,$e=e.unstable_setDisableYieldValue,Le=null,Ye=null;function st(t){if(typeof ze=="function"&&$e(t),Ye&&typeof Ye.setStrictMode=="function")try{Ye.setStrictMode(Le,t)}catch{}}var Ke=Math.clz32?Math.clz32:Lt,Re=Math.log,Ie=Math.LN2;function Lt(t){return t>>>=0,t===0?32:31-(Re(t)/Ie|0)|0}var Vt=256,Et=262144,Gt=4194304;function dn(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 En(t,r,s){var u=t.pendingLanes;if(u===0)return 0;var p=0,y=t.suspendedLanes,S=t.pingedLanes;t=t.warmLanes;var M=u&134217727;return M!==0?(u=M&~y,u!==0?p=dn(u):(S&=M,S!==0?p=dn(S):s||(s=M&~t,s!==0&&(p=dn(s))))):(M=u&~y,M!==0?p=dn(M):S!==0?p=dn(S):s||(s=u&~t,s!==0&&(p=dn(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 ee(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function He(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=Gt;return Gt<<=1,(Gt&62914560)===0&&(Gt=4194304),t}function Kt(t){for(var r=[],s=0;31>s;s++)r.push(t);return r}function ke(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function St(t,r,s,u,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 M=t.entanglements,G=t.expirationTimes,ce=t.hiddenUpdates;for(s=S&~s;0<s;){var ge=31-Ke(s),Ce=1<<ge;M[ge]=0,G[ge]=-1;var ue=ce[ge];if(ue!==null)for(ce[ge]=null,ge=0;ge<ue.length;ge++){var he=ue[ge];he!==null&&(he.lane&=-536870913)}s&=~Ce}u!==0&&jn(t,u,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 u=31-Ke(r);t.entangledLanes|=r,t.entanglements[u]=t.entanglements[u]|1073741824|s&261930}function hn(t,r){var s=t.entangledLanes|=r;for(t=t.entanglements;s;){var u=31-Ke(s),p=1<<u;p&r|t[u]&r&&(t[u]|=r),s&=~p}}function le(t,r){var s=r&-r;return s=(s&42)!==0?1:Be(s),(s&(t.suspendedLanes|r))!==0?0:s}function Be(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 Pe(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Ze(){var t=ie.p;return t!==0?t:(t=window.event,t===void 0?32:v0(t.type))}function vn(t,r){var s=ie.p;try{return ie.p=t,r()}finally{ie.p=s}}var Gn=Math.random().toString(36).slice(2),gn="__reactFiber$"+Gn,mn="__reactProps$"+Gn,Ur="__reactContainer$"+Gn,Pl="__reactEvents$"+Gn,Ts="__reactListeners$"+Gn,Ti="__reactHandles$"+Gn,Jo="__reactResources$"+Gn,ma="__reactMarker$"+Gn;function aa(t){delete t[gn],delete t[mn],delete t[Pl],delete t[Ts],delete t[Ti]}function fl(t){var r=t[gn];if(r)return r;for(var s=t.parentNode;s;){if(r=s[Ur]||s[gn]){if(s=r.alternate,r.child!==null||s!==null&&s.child!==null)for(t=a0(t);t!==null;){if(s=t[gn])return s;t=a0(t)}return r}t=s,s=t.parentNode}return null}function hl(t){if(t=t[gn]||t[Ur]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function Ba(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function Oa(t){var r=t[Jo];return r||(r=t[Jo]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function Sn(t){t[ma]=!0}var Sr=new Set,ec={};function fr(t,r){pa(t,r),pa(t+"Capture",r)}function pa(t,r){for(ec[t]=r,t=0;t<r.length;t++)Sr.add(r[t])}var ml=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]*$"),$a={},La={};function tc(t){return qe.call(La,t)?!0:qe.call($a,t)?!1:ml.test(t)?La[t]=!0:($a[t]=!0,!1)}function la(t,r,s){if(tc(r))if(s===null)t.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":t.removeAttribute(r);return;case"boolean":var u=r.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){t.removeAttribute(r);return}}t.setAttribute(r,""+s)}}function Ql(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 qr(t,r,s,u){if(u===null)t.removeAttribute(s);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(s);return}t.setAttributeNS(r,s,""+u)}}function er(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Fs(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function nc(t,r,s){var u=Object.getOwnPropertyDescriptor(t.constructor.prototype,r);if(!t.hasOwnProperty(r)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var p=u.get,y=u.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:u.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function Rs(t){if(!t._valueTracker){var r=Fs(t)?"checked":"value";t._valueTracker=nc(t,r,""+t[r])}}function xa(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var s=r.getValue(),u="";return t&&(u=Fs(t)?t.checked?"true":"false":t.value),t=u,t!==s?(r.setValue(t),!0):!1}function hr(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 ia=/[\n"\\]/g;function An(t){return t.replace(ia,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Cr(t,r,s,u,p,y,S,M){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=""+er(r)):t.value!==""+er(r)&&(t.value=""+er(r)):S!=="submit"&&S!=="reset"||t.removeAttribute("value"),r!=null?Fi(t,S,er(r)):s!=null?Fi(t,S,er(s)):u!=null&&t.removeAttribute("value"),p==null&&y!=null&&(t.defaultChecked=!!y),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?t.name=""+er(M):t.removeAttribute("name")}function $n(t,r,s,u,p,y,S,M){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)){Rs(t);return}s=s!=null?""+er(s):"",r=r!=null?""+er(r):s,M||r===t.value||(t.value=r),t.defaultValue=r}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=M?t.checked:!!u,t.defaultChecked=!!u,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(t.name=S),Rs(t)}function Fi(t,r,s){r==="number"&&hr(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function pl(t,r,s,u){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&&u&&(t[s].defaultSelected=!0)}else{for(s=""+er(s),r=null,p=0;p<t.length;p++){if(t[p].value===s){t[p].selected=!0,u&&(t[p].defaultSelected=!0);return}r!==null||t[p].disabled||(r=t[p])}r!==null&&(r.selected=!0)}}function Ri(t,r,s){if(r!=null&&(r=""+er(r),r!==t.value&&(t.value=r),s==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=s!=null?""+er(s):""}function Nr(t,r,s,u){if(r==null){if(u!=null){if(s!=null)throw Error(i(92));if(K(u)){if(1<u.length)throw Error(i(93));u=u[0]}s=u}s==null&&(s=""),r=s}s=er(r),t.defaultValue=s,u=t.textContent,u===s&&u!==""&&u!==null&&(t.value=u),Rs(t)}function Er(t,r){if(r){var s=t.firstChild;if(s&&s===t.lastChild&&s.nodeType===3){s.nodeValue=r;return}}t.textContent=r}var Ia=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 rc(t,r,s){var u=r.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?u?t.setProperty(r,""):r==="float"?t.cssFloat="":t[r]="":u?t.setProperty(r,s):typeof s!="number"||s===0||Ia.has(r)?r==="float"?t.cssFloat=s:t[r]=(""+s).trim():t[r]=s+"px"}function Ln(t,r,s){if(r!=null&&typeof r!="object")throw Error(i(62));if(t=t.style,s!=null){for(var u in s)!s.hasOwnProperty(u)||r!=null&&r.hasOwnProperty(u)||(u.indexOf("--")===0?t.setProperty(u,""):u==="float"?t.cssFloat="":t[u]="");for(var p in r)u=r[p],r.hasOwnProperty(p)&&s[p]!==u&&rc(t,p,u)}else for(var y in r)r.hasOwnProperty(y)&&rc(t,y,r[y])}function Jt(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 ga=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"]]),tr=/^[\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 Ar(t){return tr.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function Vn(){}var Ms=null;function Mi(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Dr=null,mr=null;function zs(t){var r=hl(t);if(r&&(t=r.stateNode)){var s=t[mn]||null;e:switch(t=r.stateNode,r.type){case"input":if(Cr(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="'+An(""+r)+'"][type="radio"]'),r=0;r<s.length;r++){var u=s[r];if(u!==t&&u.form===t.form){var p=u[mn]||null;if(!p)throw Error(i(90));Cr(u,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(r=0;r<s.length;r++)u=s[r],u.form===t.form&&xa(u)}break e;case"textarea":Ri(t,s.value,s.defaultValue);break e;case"select":r=s.value,r!=null&&pl(t,!!s.multiple,r,!1)}}}var zi=!1;function nr(t,r,s){if(zi)return t(r,s);zi=!0;try{var u=t(r);return u}finally{if(zi=!1,(Dr!==null||mr!==null)&&(Vc(),Dr&&(r=Dr,t=mr,mr=Dr=null,zs(r),t)))for(r=0;r<t.length;r++)zs(t[r])}}function sa(t,r){var s=t.stateNode;if(s===null)return null;var u=s[mn]||null;if(u===null)return null;s=u[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":(u=!u.disabled)||(t=t.type,u=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!u;break e;default:t=!1}if(t)return null;if(s&&typeof s!="function")throw Error(i(231,r,typeof s));return s}var pr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_s=!1;if(pr)try{var Zl={};Object.defineProperty(Zl,"passive",{get:function(){_s=!0}}),window.addEventListener("test",Zl,Zl),window.removeEventListener("test",Zl,Zl)}catch{_s=!1}var vt=null,Bs=null,en=null;function _i(){if(en)return en;var t,r=Bs,s=r.length,u,p="value"in vt?vt.value:vt.textContent,y=p.length;for(t=0;t<s&&r[t]===p[t];t++);var S=s-t;for(u=1;u<=S&&r[s-u]===p[y-u];u++);return en=p.slice(t,1<u?1-u:void 0)}function ya(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 Bi(){return!0}function Yr(){return!1}function rr(t){function r(s,u,p,y,S){this._reactName=s,this._targetInst=p,this.type=u,this.nativeEvent=y,this.target=S,this.currentTarget=null;for(var M in t)t.hasOwnProperty(M)&&(s=t[M],this[M]=s?s(y):y[M]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?Bi:Yr,this.isPropagationStopped=Yr,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=Bi)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Bi)},persist:function(){},isPersistent:Bi}),r}var oa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xr=rr(oa),Ha=g({},oa,{view:0,detail:0}),ld=rr(Ha),Os,Jl,ei,ti=g({},Ha,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Li,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!==ei&&(ei&&t.type==="mousemove"?(Os=t.screenX-ei.screenX,Jl=t.screenY-ei.screenY):Jl=Os=0,ei=t),Os)},movementY:function(t){return"movementY"in t?t.movementY:Jl}}),$s=rr(ti),id=g({},ti,{dataTransfer:0}),ac=rr(id),lc=g({},Ha,{relatedTarget:0}),Oi=rr(lc),ba=g({},oa,{animationName:0,elapsedTime:0,pseudoElement:0}),Ua=rr(ba),Ls=g({},oa,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),sd=rr(Ls),ic=g({},oa,{data:0}),Is=rr(ic),od={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},sc={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"},tn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $i(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=tn[t])?!!r[t]:!1}function Li(){return $i}var oc=g({},Ha,{key:function(t){if(t.key){var r=od[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=ya(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?sc[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Li,charCode:function(t){return t.type==="keypress"?ya(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?ya(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),cc=rr(oc),uc=g({},ti,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hs=rr(uc),dc=g({},Ha,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Li}),fc=rr(dc),A=g({},oa,{propertyName:0,elapsedTime:0,pseudoElement:0}),P=rr(A),oe=g({},ti,{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}),pe=rr(oe),Ne=g({},oa,{newState:0,oldState:0}),Ue=rr(Ne),It=[9,13,27,32],ot=pr&&"CompositionEvent"in window,et=null;pr&&"documentMode"in document&&(et=document.documentMode);var ct=pr&&"TextEvent"in window&&!et,ft=pr&&(!ot||et&&8<et&&11>=et),Pt=" ",va=!1;function Ct(t,r){switch(t){case"keyup":return It.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function on(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Yt=!1;function Fn(t,r){switch(t){case"compositionend":return on(r);case"keypress":return r.which!==32?null:(va=!0,Pt);case"textInput":return t=r.data,t===Pt&&va?null:t;default:return null}}function wn(t,r){if(Yt)return t==="compositionend"||!ot&&Ct(t,r)?(t=_i(),en=Bs=vt=null,Yt=!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 ft&&r.locale!=="ko"?null:r.data;default:return null}}var qv={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 sp(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!qv[t.type]:r==="textarea"}function op(t,r,s,u){Dr?mr?mr.push(u):mr=[u]:Dr=u,r=tu(r,"onChange"),0<r.length&&(s=new Xr("onChange","change",null,s,u),t.push({event:s,listeners:r}))}var Us=null,qs=null;function Yv(t){Y1(t,0)}function hc(t){var r=Ba(t);if(xa(r))return t}function cp(t,r){if(t==="change")return r}var up=!1;if(pr){var cd;if(pr){var ud="oninput"in document;if(!ud){var dp=document.createElement("div");dp.setAttribute("oninput","return;"),ud=typeof dp.oninput=="function"}cd=ud}else cd=!1;up=cd&&(!document.documentMode||9<document.documentMode)}function fp(){Us&&(Us.detachEvent("onpropertychange",hp),qs=Us=null)}function hp(t){if(t.propertyName==="value"&&hc(qs)){var r=[];op(r,qs,t,Mi(t)),nr(Yv,r)}}function Xv(t,r,s){t==="focusin"?(fp(),Us=r,qs=s,Us.attachEvent("onpropertychange",hp)):t==="focusout"&&fp()}function Wv(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return hc(qs)}function Gv(t,r){if(t==="click")return hc(r)}function Vv(t,r){if(t==="input"||t==="change")return hc(r)}function Kv(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var Tr=typeof Object.is=="function"?Object.is:Kv;function Ys(t,r){if(Tr(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var s=Object.keys(t),u=Object.keys(r);if(s.length!==u.length)return!1;for(u=0;u<s.length;u++){var p=s[u];if(!qe.call(r,p)||!Tr(t[p],r[p]))return!1}return!0}function mp(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function pp(t,r){var s=mp(t);t=0;for(var u;s;){if(s.nodeType===3){if(u=t+s.textContent.length,t<=r&&u>=r)return{node:s,offset:r-t};t=u}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=mp(s)}}function xp(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?xp(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function gp(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=hr(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=hr(t.document)}return r}function dd(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 Pv=pr&&"documentMode"in document&&11>=document.documentMode,Ii=null,fd=null,Xs=null,hd=!1;function yp(t,r,s){var u=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;hd||Ii==null||Ii!==hr(u)||(u=Ii,"selectionStart"in u&&dd(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Xs&&Ys(Xs,u)||(Xs=u,u=tu(fd,"onSelect"),0<u.length&&(r=new Xr("onSelect","select",null,r,s),t.push({event:r,listeners:u}),r.target=Ii)))}function ni(t,r){var s={};return s[t.toLowerCase()]=r.toLowerCase(),s["Webkit"+t]="webkit"+r,s["Moz"+t]="moz"+r,s}var Hi={animationend:ni("Animation","AnimationEnd"),animationiteration:ni("Animation","AnimationIteration"),animationstart:ni("Animation","AnimationStart"),transitionrun:ni("Transition","TransitionRun"),transitionstart:ni("Transition","TransitionStart"),transitioncancel:ni("Transition","TransitionCancel"),transitionend:ni("Transition","TransitionEnd")},md={},bp={};pr&&(bp=document.createElement("div").style,"AnimationEvent"in window||(delete Hi.animationend.animation,delete Hi.animationiteration.animation,delete Hi.animationstart.animation),"TransitionEvent"in window||delete Hi.transitionend.transition);function ri(t){if(md[t])return md[t];if(!Hi[t])return t;var r=Hi[t],s;for(s in r)if(r.hasOwnProperty(s)&&s in bp)return md[t]=r[s];return t}var vp=ri("animationend"),wp=ri("animationiteration"),kp=ri("animationstart"),Qv=ri("transitionrun"),Zv=ri("transitionstart"),Jv=ri("transitioncancel"),jp=ri("transitionend"),Sp=new Map,pd="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(" ");pd.push("scrollEnd");function ca(t,r){Sp.set(t,r),fr(r,[t])}var mc=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)},Wr=[],Ui=0,xd=0;function pc(){for(var t=Ui,r=xd=Ui=0;r<t;){var s=Wr[r];Wr[r++]=null;var u=Wr[r];Wr[r++]=null;var p=Wr[r];Wr[r++]=null;var y=Wr[r];if(Wr[r++]=null,u!==null&&p!==null){var S=u.pending;S===null?p.next=p:(p.next=S.next,S.next=p),u.pending=p}y!==0&&Cp(s,p,y)}}function xc(t,r,s,u){Wr[Ui++]=t,Wr[Ui++]=r,Wr[Ui++]=s,Wr[Ui++]=u,xd|=u,t.lanes|=u,t=t.alternate,t!==null&&(t.lanes|=u)}function gd(t,r,s,u){return xc(t,r,s,u),gc(t)}function ai(t,r){return xc(t,null,null,r),gc(t)}function Cp(t,r,s){t.lanes|=s;var u=t.alternate;u!==null&&(u.lanes|=s);for(var p=!1,y=t.return;y!==null;)y.childLanes|=s,u=y.alternate,u!==null&&(u.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-Ke(s),t=y.hiddenUpdates,u=t[p],u===null?t[p]=[r]:u.push(r),r.lane=s|536870912),y):null}function gc(t){if(50<mo)throw mo=0,Ef=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var qi={};function e2(t,r,s,u){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=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fr(t,r,s,u){return new e2(t,r,s,u)}function yd(t){return t=t.prototype,!(!t||!t.isReactComponent)}function qa(t,r){var s=t.alternate;return s===null?(s=Fr(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 Np(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 yc(t,r,s,u,p,y){var S=0;if(u=t,typeof t=="function")yd(t)&&(S=1);else if(typeof t=="string")S=lw(t,s,O.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case X:return t=Fr(31,s,r,p),t.elementType=X,t.lanes=y,t;case k:return li(s.children,p,y,r);case E:S=8,p|=24;break;case N:return t=Fr(12,s,r,p|2),t.elementType=N,t.lanes=y,t;case H:return t=Fr(13,s,r,p),t.elementType=H,t.lanes=y,t;case F:return t=Fr(19,s,r,p),t.elementType=F,t.lanes=y,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case z:S=10;break e;case C:S=9;break e;case T:S=11;break e;case I:S=14;break e;case V:S=16,u=null;break e}S=29,s=Error(i(130,t===null?"null":typeof t,"")),u=null}return r=Fr(S,s,r,p),r.elementType=t,r.type=u,r.lanes=y,r}function li(t,r,s,u){return t=Fr(7,t,u,r),t.lanes=s,t}function bd(t,r,s){return t=Fr(6,t,null,r),t.lanes=s,t}function Ep(t){var r=Fr(18,null,null,0);return r.stateNode=t,r}function vd(t,r,s){return r=Fr(4,t.children!==null?t.children:[],t.key,r),r.lanes=s,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var Ap=new WeakMap;function Gr(t,r){if(typeof t=="object"&&t!==null){var s=Ap.get(t);return s!==void 0?s:(r={value:t,source:r,stack:jt(r)},Ap.set(t,r),r)}return{value:t,source:r,stack:jt(r)}}var Yi=[],Xi=0,bc=null,Ws=0,Vr=[],Kr=0,xl=null,wa=1,ka="";function Ya(t,r){Yi[Xi++]=Ws,Yi[Xi++]=bc,bc=t,Ws=r}function Dp(t,r,s){Vr[Kr++]=wa,Vr[Kr++]=ka,Vr[Kr++]=xl,xl=t;var u=wa;t=ka;var p=32-Ke(u)-1;u&=~(1<<p),s+=1;var y=32-Ke(r)+p;if(30<y){var S=p-p%5;y=(u&(1<<S)-1).toString(32),u>>=S,p-=S,wa=1<<32-Ke(r)+p|s<<p|u,ka=y+t}else wa=1<<y|s<<p|u,ka=t}function wd(t){t.return!==null&&(Ya(t,1),Dp(t,1,0))}function kd(t){for(;t===bc;)bc=Yi[--Xi],Yi[Xi]=null,Ws=Yi[--Xi],Yi[Xi]=null;for(;t===xl;)xl=Vr[--Kr],Vr[Kr]=null,ka=Vr[--Kr],Vr[Kr]=null,wa=Vr[--Kr],Vr[Kr]=null}function Tp(t,r){Vr[Kr++]=wa,Vr[Kr++]=ka,Vr[Kr++]=xl,wa=r.id,ka=r.overflow,xl=t}var Kn=null,pn=null,_t=!1,gl=null,Pr=!1,jd=Error(i(519));function yl(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Gs(Gr(r,t)),jd}function Fp(t){var r=t.stateNode,s=t.type,u=t.memoizedProps;switch(r[gn]=t,r[mn]=u,s){case"dialog":Dt("cancel",r),Dt("close",r);break;case"iframe":case"object":case"embed":Dt("load",r);break;case"video":case"audio":for(s=0;s<xo.length;s++)Dt(xo[s],r);break;case"source":Dt("error",r);break;case"img":case"image":case"link":Dt("error",r),Dt("load",r);break;case"details":Dt("toggle",r);break;case"input":Dt("invalid",r),$n(r,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":Dt("invalid",r);break;case"textarea":Dt("invalid",r),Nr(r,u.value,u.defaultValue,u.children)}s=u.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||r.textContent===""+s||u.suppressHydrationWarning===!0||V1(r.textContent,s)?(u.popover!=null&&(Dt("beforetoggle",r),Dt("toggle",r)),u.onScroll!=null&&Dt("scroll",r),u.onScrollEnd!=null&&Dt("scrollend",r),u.onClick!=null&&(r.onclick=Vn),r=!0):r=!1,r||yl(t,!0)}function Rp(t){for(Kn=t.return;Kn;)switch(Kn.tag){case 5:case 31:case 13:Pr=!1;return;case 27:case 3:Pr=!0;return;default:Kn=Kn.return}}function Wi(t){if(t!==Kn)return!1;if(!_t)return Rp(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")||Uf(t.type,t.memoizedProps)),s=!s),s&&pn&&yl(t),Rp(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));pn=r0(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));pn=r0(t)}else r===27?(r=pn,Rl(t.type)?(t=Gf,Gf=null,pn=t):pn=r):pn=Kn?Zr(t.stateNode.nextSibling):null;return!0}function ii(){pn=Kn=null,_t=!1}function Sd(){var t=gl;return t!==null&&(br===null?br=t:br.push.apply(br,t),gl=null),t}function Gs(t){gl===null?gl=[t]:gl.push(t)}var Cd=U(null),si=null,Xa=null;function bl(t,r,s){R(Cd,r._currentValue),r._currentValue=s}function Wa(t){t._currentValue=Cd.current,Y(Cd)}function Nd(t,r,s){for(;t!==null;){var u=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),t===s)break;t=t.return}}function Ed(t,r,s,u){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 M=y;y=p;for(var G=0;G<r.length;G++)if(M.context===r[G]){y.lanes|=s,M=y.alternate,M!==null&&(M.lanes|=s),Nd(y.return,s,t),u||(S=null);break e}y=M.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),Nd(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,u){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 M=p.type;Tr(p.pendingProps.value,S.value)||(t!==null?t.push(M):t=[M])}}else if(p===Se.current){if(S=p.alternate,S===null)throw Error(i(387));S.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(t!==null?t.push(wo):t=[wo])}p=p.return}t!==null&&Ed(r,t,s,u),r.flags|=262144}function vc(t){for(t=t.firstContext;t!==null;){if(!Tr(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function oi(t){si=t,Xa=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Pn(t){return Mp(si,t)}function wc(t,r){return si===null&&oi(t),Mp(t,r)}function Mp(t,r){var s=r._currentValue;if(r={context:r,memoizedValue:s,next:null},Xa===null){if(t===null)throw Error(i(308));Xa=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else Xa=Xa.next=r;return s}var t2=typeof AbortController<"u"?AbortController:function(){var t=[],r=this.signal={aborted:!1,addEventListener:function(s,u){t.push(u)}};this.abort=function(){r.aborted=!0,t.forEach(function(s){return s()})}},n2=e.unstable_scheduleCallback,r2=e.unstable_NormalPriority,Rn={$$typeof:z,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ad(){return{controller:new t2,data:new Map,refCount:0}}function Vs(t){t.refCount--,t.refCount===0&&n2(r2,function(){t.controller.abort()})}var Ks=null,Dd=0,Vi=0,Ki=null;function a2(t,r){if(Ks===null){var s=Ks=[];Dd=0,Vi=Mf(),Ki={status:"pending",value:void 0,then:function(u){s.push(u)}}}return Dd++,r.then(zp,zp),r}function zp(){if(--Dd===0&&Ks!==null){Ki!==null&&(Ki.status="fulfilled");var t=Ks;Ks=null,Vi=0,Ki=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function l2(t,r){var s=[],u={status:"pending",value:null,reason:null,then:function(p){s.push(p)}};return t.then(function(){u.status="fulfilled",u.value=r;for(var p=0;p<s.length;p++)(0,s[p])(r)},function(p){for(u.status="rejected",u.reason=p,p=0;p<s.length;p++)(0,s[p])(void 0)}),u}var _p=q.S;q.S=function(t,r){y1=be(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&a2(t,r),_p!==null&&_p(t,r)};var ci=U(null);function Td(){var t=ci.current;return t!==null?t:cn.pooledCache}function kc(t,r){r===null?R(ci,ci.current):R(ci,r.pool)}function Bp(){var t=Td();return t===null?null:{parent:Rn._currentValue,pool:t}}var Pi=Error(i(460)),Fd=Error(i(474)),jc=Error(i(542)),Sc={then:function(){}};function Op(t){return t=t.status,t==="fulfilled"||t==="rejected"}function $p(t,r,s){switch(s=t[s],s===void 0?t.push(r):s!==r&&(r.then(Vn,Vn),r=s),r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,Ip(t),t;default:if(typeof r.status=="string")r.then(Vn,Vn);else{if(t=cn,t!==null&&100<t.shellSuspendCounter)throw Error(i(482));t=r,t.status="pending",t.then(function(u){if(r.status==="pending"){var p=r;p.status="fulfilled",p.value=u}},function(u){if(r.status==="pending"){var p=r;p.status="rejected",p.reason=u}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,Ip(t),t}throw di=r,Pi}}function ui(t){try{var r=t._init;return r(t._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(di=s,Pi):s}}var di=null;function Lp(){if(di===null)throw Error(i(459));var t=di;return di=null,t}function Ip(t){if(t===Pi||t===jc)throw Error(i(483))}var Qi=null,Ps=0;function Cc(t){var r=Ps;return Ps+=1,Qi===null&&(Qi=[]),$p(Qi,t,r)}function Qs(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function Nc(t,r){throw r.$$typeof===w?Error(i(525)):(t=Object.prototype.toString.call(r),Error(i(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t)))}function Hp(t){function r(re,J){if(t){var se=re.deletions;se===null?(re.deletions=[J],re.flags|=16):se.push(J)}}function s(re,J){if(!t)return null;for(;J!==null;)r(re,J),J=J.sibling;return null}function u(re){for(var J=new Map;re!==null;)re.key!==null?J.set(re.key,re):J.set(re.index,re),re=re.sibling;return J}function p(re,J){return re=qa(re,J),re.index=0,re.sibling=null,re}function y(re,J,se){return re.index=se,t?(se=re.alternate,se!==null?(se=se.index,se<J?(re.flags|=67108866,J):se):(re.flags|=67108866,J)):(re.flags|=1048576,J)}function S(re){return t&&re.alternate===null&&(re.flags|=67108866),re}function M(re,J,se,we){return J===null||J.tag!==6?(J=bd(se,re.mode,we),J.return=re,J):(J=p(J,se),J.return=re,J)}function G(re,J,se,we){var nt=se.type;return nt===k?ge(re,J,se.props.children,we,se.key):J!==null&&(J.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===V&&ui(nt)===J.type)?(J=p(J,se.props),Qs(J,se),J.return=re,J):(J=yc(se.type,se.key,se.props,null,re.mode,we),Qs(J,se),J.return=re,J)}function ce(re,J,se,we){return J===null||J.tag!==4||J.stateNode.containerInfo!==se.containerInfo||J.stateNode.implementation!==se.implementation?(J=vd(se,re.mode,we),J.return=re,J):(J=p(J,se.children||[]),J.return=re,J)}function ge(re,J,se,we,nt){return J===null||J.tag!==7?(J=li(se,re.mode,we,nt),J.return=re,J):(J=p(J,se),J.return=re,J)}function Ce(re,J,se){if(typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint")return J=bd(""+J,re.mode,se),J.return=re,J;if(typeof J=="object"&&J!==null){switch(J.$$typeof){case b:return se=yc(J.type,J.key,J.props,null,re.mode,se),Qs(se,J),se.return=re,se;case j:return J=vd(J,re.mode,se),J.return=re,J;case V:return J=ui(J),Ce(re,J,se)}if(K(J)||L(J))return J=li(J,re.mode,se,null),J.return=re,J;if(typeof J.then=="function")return Ce(re,Cc(J),se);if(J.$$typeof===z)return Ce(re,wc(re,J),se);Nc(re,J)}return null}function ue(re,J,se,we){var nt=J!==null?J.key:null;if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return nt!==null?null:M(re,J,""+se,we);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case b:return se.key===nt?G(re,J,se,we):null;case j:return se.key===nt?ce(re,J,se,we):null;case V:return se=ui(se),ue(re,J,se,we)}if(K(se)||L(se))return nt!==null?null:ge(re,J,se,we,null);if(typeof se.then=="function")return ue(re,J,Cc(se),we);if(se.$$typeof===z)return ue(re,J,wc(re,se),we);Nc(re,se)}return null}function he(re,J,se,we,nt){if(typeof we=="string"&&we!==""||typeof we=="number"||typeof we=="bigint")return re=re.get(se)||null,M(J,re,""+we,nt);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case b:return re=re.get(we.key===null?se:we.key)||null,G(J,re,we,nt);case j:return re=re.get(we.key===null?se:we.key)||null,ce(J,re,we,nt);case V:return we=ui(we),he(re,J,se,we,nt)}if(K(we)||L(we))return re=re.get(se)||null,ge(J,re,we,nt,null);if(typeof we.then=="function")return he(re,J,se,Cc(we),nt);if(we.$$typeof===z)return he(re,J,se,wc(J,we),nt);Nc(J,we)}return null}function Ge(re,J,se,we){for(var nt=null,Ht=null,Qe=J,wt=J=0,Rt=null;Qe!==null&&wt<se.length;wt++){Qe.index>wt?(Rt=Qe,Qe=null):Rt=Qe.sibling;var Ut=ue(re,Qe,se[wt],we);if(Ut===null){Qe===null&&(Qe=Rt);break}t&&Qe&&Ut.alternate===null&&r(re,Qe),J=y(Ut,J,wt),Ht===null?nt=Ut:Ht.sibling=Ut,Ht=Ut,Qe=Rt}if(wt===se.length)return s(re,Qe),_t&&Ya(re,wt),nt;if(Qe===null){for(;wt<se.length;wt++)Qe=Ce(re,se[wt],we),Qe!==null&&(J=y(Qe,J,wt),Ht===null?nt=Qe:Ht.sibling=Qe,Ht=Qe);return _t&&Ya(re,wt),nt}for(Qe=u(Qe);wt<se.length;wt++)Rt=he(Qe,re,wt,se[wt],we),Rt!==null&&(t&&Rt.alternate!==null&&Qe.delete(Rt.key===null?wt:Rt.key),J=y(Rt,J,wt),Ht===null?nt=Rt:Ht.sibling=Rt,Ht=Rt);return t&&Qe.forEach(function(Ol){return r(re,Ol)}),_t&&Ya(re,wt),nt}function ut(re,J,se,we){if(se==null)throw Error(i(151));for(var nt=null,Ht=null,Qe=J,wt=J=0,Rt=null,Ut=se.next();Qe!==null&&!Ut.done;wt++,Ut=se.next()){Qe.index>wt?(Rt=Qe,Qe=null):Rt=Qe.sibling;var Ol=ue(re,Qe,Ut.value,we);if(Ol===null){Qe===null&&(Qe=Rt);break}t&&Qe&&Ol.alternate===null&&r(re,Qe),J=y(Ol,J,wt),Ht===null?nt=Ol:Ht.sibling=Ol,Ht=Ol,Qe=Rt}if(Ut.done)return s(re,Qe),_t&&Ya(re,wt),nt;if(Qe===null){for(;!Ut.done;wt++,Ut=se.next())Ut=Ce(re,Ut.value,we),Ut!==null&&(J=y(Ut,J,wt),Ht===null?nt=Ut:Ht.sibling=Ut,Ht=Ut);return _t&&Ya(re,wt),nt}for(Qe=u(Qe);!Ut.done;wt++,Ut=se.next())Ut=he(Qe,re,wt,Ut.value,we),Ut!==null&&(t&&Ut.alternate!==null&&Qe.delete(Ut.key===null?wt:Ut.key),J=y(Ut,J,wt),Ht===null?nt=Ut:Ht.sibling=Ut,Ht=Ut);return t&&Qe.forEach(function(xw){return r(re,xw)}),_t&&Ya(re,wt),nt}function an(re,J,se,we){if(typeof se=="object"&&se!==null&&se.type===k&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case b:e:{for(var nt=se.key;J!==null;){if(J.key===nt){if(nt=se.type,nt===k){if(J.tag===7){s(re,J.sibling),we=p(J,se.props.children),we.return=re,re=we;break e}}else if(J.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===V&&ui(nt)===J.type){s(re,J.sibling),we=p(J,se.props),Qs(we,se),we.return=re,re=we;break e}s(re,J);break}else r(re,J);J=J.sibling}se.type===k?(we=li(se.props.children,re.mode,we,se.key),we.return=re,re=we):(we=yc(se.type,se.key,se.props,null,re.mode,we),Qs(we,se),we.return=re,re=we)}return S(re);case j:e:{for(nt=se.key;J!==null;){if(J.key===nt)if(J.tag===4&&J.stateNode.containerInfo===se.containerInfo&&J.stateNode.implementation===se.implementation){s(re,J.sibling),we=p(J,se.children||[]),we.return=re,re=we;break e}else{s(re,J);break}else r(re,J);J=J.sibling}we=vd(se,re.mode,we),we.return=re,re=we}return S(re);case V:return se=ui(se),an(re,J,se,we)}if(K(se))return Ge(re,J,se,we);if(L(se)){if(nt=L(se),typeof nt!="function")throw Error(i(150));return se=nt.call(se),ut(re,J,se,we)}if(typeof se.then=="function")return an(re,J,Cc(se),we);if(se.$$typeof===z)return an(re,J,wc(re,se),we);Nc(re,se)}return typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint"?(se=""+se,J!==null&&J.tag===6?(s(re,J.sibling),we=p(J,se),we.return=re,re=we):(s(re,J),we=bd(se,re.mode,we),we.return=re,re=we),S(re)):s(re,J)}return function(re,J,se,we){try{Ps=0;var nt=an(re,J,se,we);return Qi=null,nt}catch(Qe){if(Qe===Pi||Qe===jc)throw Qe;var Ht=Fr(29,Qe,null,re.mode);return Ht.lanes=we,Ht.return=re,Ht}finally{}}}var fi=Hp(!0),Up=Hp(!1),vl=!1;function Rd(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Md(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 wl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function kl(t,r,s){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(Xt&2)!==0){var p=u.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),u.pending=r,r=gc(t),Cp(t,null,s),r}return xc(t,u,r,s),gc(t)}function Zs(t,r,s){if(r=r.updateQueue,r!==null&&(r=r.shared,(s&4194048)!==0)){var u=r.lanes;u&=t.pendingLanes,s|=u,r.lanes=s,hn(t,s)}}function zd(t,r){var s=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,s===u)){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:u.baseState,firstBaseUpdate:p,lastBaseUpdate:y,shared:u.shared,callbacks:u.callbacks},t.updateQueue=s;return}t=s.lastBaseUpdate,t===null?s.firstBaseUpdate=r:t.next=r,s.lastBaseUpdate=r}var _d=!1;function Js(){if(_d){var t=Ki;if(t!==null)throw t}}function eo(t,r,s,u){_d=!1;var p=t.updateQueue;vl=!1;var y=p.firstBaseUpdate,S=p.lastBaseUpdate,M=p.shared.pending;if(M!==null){p.shared.pending=null;var G=M,ce=G.next;G.next=null,S===null?y=ce:S.next=ce,S=G;var ge=t.alternate;ge!==null&&(ge=ge.updateQueue,M=ge.lastBaseUpdate,M!==S&&(M===null?ge.firstBaseUpdate=ce:M.next=ce,ge.lastBaseUpdate=G))}if(y!==null){var Ce=p.baseState;S=0,ge=ce=G=null,M=y;do{var ue=M.lane&-536870913,he=ue!==M.lane;if(he?(Ft&ue)===ue:(u&ue)===ue){ue!==0&&ue===Vi&&(_d=!0),ge!==null&&(ge=ge.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var Ge=t,ut=M;ue=r;var an=s;switch(ut.tag){case 1:if(Ge=ut.payload,typeof Ge=="function"){Ce=Ge.call(an,Ce,ue);break e}Ce=Ge;break e;case 3:Ge.flags=Ge.flags&-65537|128;case 0:if(Ge=ut.payload,ue=typeof Ge=="function"?Ge.call(an,Ce,ue):Ge,ue==null)break e;Ce=g({},Ce,ue);break e;case 2:vl=!0}}ue=M.callback,ue!==null&&(t.flags|=64,he&&(t.flags|=8192),he=p.callbacks,he===null?p.callbacks=[ue]:he.push(ue))}else he={lane:ue,tag:M.tag,payload:M.payload,callback:M.callback,next:null},ge===null?(ce=ge=he,G=Ce):ge=ge.next=he,S|=ue;if(M=M.next,M===null){if(M=p.shared.pending,M===null)break;he=M,M=he.next,he.next=null,p.lastBaseUpdate=he,p.shared.pending=null}}while(!0);ge===null&&(G=Ce),p.baseState=G,p.firstBaseUpdate=ce,p.lastBaseUpdate=ge,y===null&&(p.shared.lanes=0),El|=S,t.lanes=S,t.memoizedState=Ce}}function qp(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function Yp(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;t<s.length;t++)qp(s[t],r)}var Zi=U(null),Ec=U(0);function Xp(t,r){t=tl,R(Ec,t),R(Zi,r),tl=t|r.baseLanes}function Bd(){R(Ec,tl),R(Zi,Zi.current)}function Od(){tl=Ec.current,Y(Zi),Y(Ec)}var Rr=U(null),Qr=null;function jl(t){var r=t.alternate;R(Dn,Dn.current&1),R(Rr,t),Qr===null&&(r===null||Zi.current!==null||r.memoizedState!==null)&&(Qr=t)}function $d(t){R(Dn,Dn.current),R(Rr,t),Qr===null&&(Qr=t)}function Wp(t){t.tag===22?(R(Dn,Dn.current),R(Rr,t),Qr===null&&(Qr=t)):Sl()}function Sl(){R(Dn,Dn.current),R(Rr,Rr.current)}function Mr(t){Y(Rr),Qr===t&&(Qr=null),Y(Dn)}var Dn=U(0);function Ac(t){for(var r=t;r!==null;){if(r.tag===13){var s=r.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||Xf(s)||Wf(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 Ga=0,gt=null,nn=null,Mn=null,Dc=!1,Ji=!1,hi=!1,Tc=0,to=0,es=null,i2=0;function Cn(){throw Error(i(321))}function Ld(t,r){if(r===null)return!1;for(var s=0;s<r.length&&s<t.length;s++)if(!Tr(t[s],r[s]))return!1;return!0}function Id(t,r,s,u,p,y){return Ga=y,gt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,q.H=t===null||t.memoizedState===null?Dx:tf,hi=!1,y=s(u,p),hi=!1,Ji&&(y=Vp(r,s,u,p)),Gp(t),y}function Gp(t){q.H=ao;var r=nn!==null&&nn.next!==null;if(Ga=0,Mn=nn=gt=null,Dc=!1,to=0,es=null,r)throw Error(i(300));t===null||zn||(t=t.dependencies,t!==null&&vc(t)&&(zn=!0))}function Vp(t,r,s,u){gt=t;var p=0;do{if(Ji&&(es=null),to=0,Ji=!1,25<=p)throw Error(i(301));if(p+=1,Mn=nn=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=Tx,y=r(s,u)}while(Ji);return y}function s2(){var t=q.H,r=t.useState()[0];return r=typeof r.then=="function"?no(r):r,t=t.useState()[0],(nn!==null?nn.memoizedState:null)!==t&&(gt.flags|=1024),r}function Hd(){var t=Tc!==0;return Tc=0,t}function Ud(t,r,s){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~s}function qd(t){if(Dc){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}Dc=!1}Ga=0,Mn=nn=gt=null,Ji=!1,to=Tc=0,es=null}function or(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mn===null?gt.memoizedState=Mn=t:Mn=Mn.next=t,Mn}function Tn(){if(nn===null){var t=gt.alternate;t=t!==null?t.memoizedState:null}else t=nn.next;var r=Mn===null?gt.memoizedState:Mn.next;if(r!==null)Mn=r,nn=t;else{if(t===null)throw gt.alternate===null?Error(i(467)):Error(i(310));nn=t,t={memoizedState:nn.memoizedState,baseState:nn.baseState,baseQueue:nn.baseQueue,queue:nn.queue,next:null},Mn===null?gt.memoizedState=Mn=t:Mn=Mn.next=t}return Mn}function Fc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function no(t){var r=to;return to+=1,es===null&&(es=[]),t=$p(es,t,r),r=gt,(Mn===null?r.memoizedState:Mn.next)===null&&(r=r.alternate,q.H=r===null||r.memoizedState===null?Dx:tf),t}function Rc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return no(t);if(t.$$typeof===z)return Pn(t)}throw Error(i(438,String(t)))}function Yd(t){var r=null,s=gt.updateQueue;if(s!==null&&(r=s.memoCache),r==null){var u=gt.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(r={data:u.data.map(function(p){return p.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),s===null&&(s=Fc(),gt.updateQueue=s),s.memoCache=r,s=r.data[r.index],s===void 0)for(s=r.data[r.index]=Array(t),u=0;u<t;u++)s[u]=_;return r.index++,s}function Va(t,r){return typeof r=="function"?r(t):r}function Mc(t){var r=Tn();return Xd(r,nn,t)}function Xd(t,r,s){var u=t.queue;if(u===null)throw Error(i(311));u.lastRenderedReducer=s;var p=t.baseQueue,y=u.pending;if(y!==null){if(p!==null){var S=p.next;p.next=y.next,y.next=S}r.baseQueue=p=y,u.pending=null}if(y=t.baseState,p===null)t.memoizedState=y;else{r=p.next;var M=S=null,G=null,ce=r,ge=!1;do{var Ce=ce.lane&-536870913;if(Ce!==ce.lane?(Ft&Ce)===Ce:(Ga&Ce)===Ce){var ue=ce.revertLane;if(ue===0)G!==null&&(G=G.next={lane:0,revertLane:0,gesture:null,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),Ce===Vi&&(ge=!0);else if((Ga&ue)===ue){ce=ce.next,ue===Vi&&(ge=!0);continue}else Ce={lane:0,revertLane:ce.revertLane,gesture:null,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null},G===null?(M=G=Ce,S=y):G=G.next=Ce,gt.lanes|=ue,El|=ue;Ce=ce.action,hi&&s(y,Ce),y=ce.hasEagerState?ce.eagerState:s(y,Ce)}else ue={lane:Ce,revertLane:ce.revertLane,gesture:ce.gesture,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null},G===null?(M=G=ue,S=y):G=G.next=ue,gt.lanes|=Ce,El|=Ce;ce=ce.next}while(ce!==null&&ce!==r);if(G===null?S=y:G.next=M,!Tr(y,t.memoizedState)&&(zn=!0,ge&&(s=Ki,s!==null)))throw s;t.memoizedState=y,t.baseState=S,t.baseQueue=G,u.lastRenderedState=y}return p===null&&(u.lanes=0),[t.memoizedState,u.dispatch]}function Wd(t){var r=Tn(),s=r.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=t;var u=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);Tr(y,r.memoizedState)||(zn=!0),r.memoizedState=y,r.baseQueue===null&&(r.baseState=y),s.lastRenderedState=y}return[y,u]}function Kp(t,r,s){var u=gt,p=Tn(),y=_t;if(y){if(s===void 0)throw Error(i(407));s=s()}else s=r();var S=!Tr((nn||p).memoizedState,s);if(S&&(p.memoizedState=s,zn=!0),p=p.queue,Kd(Zp.bind(null,u,p,t),[t]),p.getSnapshot!==r||S||Mn!==null&&Mn.memoizedState.tag&1){if(u.flags|=2048,ts(9,{destroy:void 0},Qp.bind(null,u,p,s,r),null),cn===null)throw Error(i(349));y||(Ga&127)!==0||Pp(u,r,s)}return s}function Pp(t,r,s){t.flags|=16384,t={getSnapshot:r,value:s},r=gt.updateQueue,r===null?(r=Fc(),gt.updateQueue=r,r.stores=[t]):(s=r.stores,s===null?r.stores=[t]:s.push(t))}function Qp(t,r,s,u){r.value=s,r.getSnapshot=u,Jp(r)&&ex(t)}function Zp(t,r,s){return s(function(){Jp(r)&&ex(t)})}function Jp(t){var r=t.getSnapshot;t=t.value;try{var s=r();return!Tr(t,s)}catch{return!0}}function ex(t){var r=ai(t,2);r!==null&&vr(r,t,2)}function Gd(t){var r=or();if(typeof t=="function"){var s=t;if(t=s(),hi){st(!0);try{s()}finally{st(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Va,lastRenderedState:t},r}function tx(t,r,s,u){return t.baseState=s,Xd(t,nn,typeof u=="function"?u:Va)}function o2(t,r,s,u,p){if(Bc(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,u(y),s=r.pending,s===null?(y.next=r.pending=y,nx(r,y)):(y.next=s.next,r.pending=s.next=y)}}function nx(t,r){var s=r.action,u=r.payload,p=t.state;if(r.isTransition){var y=q.T,S={};q.T=S;try{var M=s(p,u),G=q.S;G!==null&&G(S,M),rx(t,r,M)}catch(ce){Vd(t,r,ce)}finally{y!==null&&S.types!==null&&(y.types=S.types),q.T=y}}else try{y=s(p,u),rx(t,r,y)}catch(ce){Vd(t,r,ce)}}function rx(t,r,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(u){ax(t,r,u)},function(u){return Vd(t,r,u)}):ax(t,r,s)}function ax(t,r,s){r.status="fulfilled",r.value=s,lx(r),t.state=s,r=t.pending,r!==null&&(s=r.next,s===r?t.pending=null:(s=s.next,r.next=s,nx(t,s)))}function Vd(t,r,s){var u=t.pending;if(t.pending=null,u!==null){u=u.next;do r.status="rejected",r.reason=s,lx(r),r=r.next;while(r!==u)}t.action=null}function lx(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function ix(t,r){return r}function sx(t,r){if(_t){var s=cn.formState;if(s!==null){e:{var u=gt;if(_t){if(pn){t:{for(var p=pn,y=Pr;p.nodeType!==8;){if(!y){p=null;break t}if(p=Zr(p.nextSibling),p===null){p=null;break t}}y=p.data,p=y==="F!"||y==="F"?p:null}if(p){pn=Zr(p.nextSibling),u=p.data==="F!";break e}}yl(u)}u=!1}u&&(r=s[0])}}return s=or(),s.memoizedState=s.baseState=r,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ix,lastRenderedState:r},s.queue=u,s=Nx.bind(null,gt,u),u.dispatch=s,u=Gd(!1),y=ef.bind(null,gt,!1,u.queue),u=or(),p={state:r,dispatch:null,action:t,pending:null},u.queue=p,s=o2.bind(null,gt,p,y,s),p.dispatch=s,u.memoizedState=t,[r,s,!1]}function ox(t){var r=Tn();return cx(r,nn,t)}function cx(t,r,s){if(r=Xd(t,r,ix)[0],t=Mc(Va)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var u=no(r)}catch(S){throw S===Pi?jc:S}else u=r;r=Tn();var p=r.queue,y=p.dispatch;return s!==r.memoizedState&&(gt.flags|=2048,ts(9,{destroy:void 0},c2.bind(null,p,s),null)),[u,y,t]}function c2(t,r){t.action=r}function ux(t){var r=Tn(),s=nn;if(s!==null)return cx(r,s,t);Tn(),r=r.memoizedState,s=Tn();var u=s.queue.dispatch;return s.memoizedState=t,[r,u,!1]}function ts(t,r,s,u){return t={tag:t,create:s,deps:u,inst:r,next:null},r=gt.updateQueue,r===null&&(r=Fc(),gt.updateQueue=r),s=r.lastEffect,s===null?r.lastEffect=t.next=t:(u=s.next,s.next=t,t.next=u,r.lastEffect=t),t}function dx(){return Tn().memoizedState}function zc(t,r,s,u){var p=or();gt.flags|=t,p.memoizedState=ts(1|r,{destroy:void 0},s,u===void 0?null:u)}function _c(t,r,s,u){var p=Tn();u=u===void 0?null:u;var y=p.memoizedState.inst;nn!==null&&u!==null&&Ld(u,nn.memoizedState.deps)?p.memoizedState=ts(r,y,s,u):(gt.flags|=t,p.memoizedState=ts(1|r,y,s,u))}function fx(t,r){zc(8390656,8,t,r)}function Kd(t,r){_c(2048,8,t,r)}function u2(t){gt.flags|=4;var r=gt.updateQueue;if(r===null)r=Fc(),gt.updateQueue=r,r.events=[t];else{var s=r.events;s===null?r.events=[t]:s.push(t)}}function hx(t){var r=Tn().memoizedState;return u2({ref:r,nextImpl:t}),function(){if((Xt&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function mx(t,r){return _c(4,2,t,r)}function px(t,r){return _c(4,4,t,r)}function xx(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 gx(t,r,s){s=s!=null?s.concat([t]):null,_c(4,4,xx.bind(null,r,t),s)}function Pd(){}function yx(t,r){var s=Tn();r=r===void 0?null:r;var u=s.memoizedState;return r!==null&&Ld(r,u[1])?u[0]:(s.memoizedState=[t,r],t)}function bx(t,r){var s=Tn();r=r===void 0?null:r;var u=s.memoizedState;if(r!==null&&Ld(r,u[1]))return u[0];if(u=t(),hi){st(!0);try{t()}finally{st(!1)}}return s.memoizedState=[u,r],u}function Qd(t,r,s){return s===void 0||(Ga&1073741824)!==0&&(Ft&261930)===0?t.memoizedState=r:(t.memoizedState=s,t=v1(),gt.lanes|=t,El|=t,s)}function vx(t,r,s,u){return Tr(s,r)?s:Zi.current!==null?(t=Qd(t,s,u),Tr(t,r)||(zn=!0),t):(Ga&42)===0||(Ga&1073741824)!==0&&(Ft&261930)===0?(zn=!0,t.memoizedState=s):(t=v1(),gt.lanes|=t,El|=t,r)}function wx(t,r,s,u,p){var y=ie.p;ie.p=y!==0&&8>y?y:8;var S=q.T,M={};q.T=M,ef(t,!1,r,s);try{var G=p(),ce=q.S;if(ce!==null&&ce(M,G),G!==null&&typeof G=="object"&&typeof G.then=="function"){var ge=l2(G,u);ro(t,r,ge,Br(t))}else ro(t,r,u,Br(t))}catch(Ce){ro(t,r,{then:function(){},status:"rejected",reason:Ce},Br())}finally{ie.p=y,S!==null&&M.types!==null&&(S.types=M.types),q.T=S}}function d2(){}function Zd(t,r,s,u){if(t.tag!==5)throw Error(i(476));var p=kx(t).queue;wx(t,p,r,de,s===null?d2:function(){return jx(t),s(u)})}function kx(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Va,lastRenderedState:de},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 jx(t){var r=kx(t);r.next===null&&(r=t.alternate.memoizedState),ro(t,r.next.queue,{},Br())}function Jd(){return Pn(wo)}function Sx(){return Tn().memoizedState}function Cx(){return Tn().memoizedState}function f2(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=Br();t=wl(s);var u=kl(r,t,s);u!==null&&(vr(u,r,s),Zs(u,r,s)),r={cache:Ad()},t.payload=r;return}r=r.return}}function h2(t,r,s){var u=Br();s={lane:u,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Bc(t)?Ex(r,s):(s=gd(t,r,s,u),s!==null&&(vr(s,t,u),Ax(s,r,u)))}function Nx(t,r,s){var u=Br();ro(t,r,s,u)}function ro(t,r,s,u){var p={lane:u,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Bc(t))Ex(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,M=y(S,s);if(p.hasEagerState=!0,p.eagerState=M,Tr(M,S))return xc(t,r,p,0),cn===null&&pc(),!1}catch{}finally{}if(s=gd(t,r,p,u),s!==null)return vr(s,t,u),Ax(s,r,u),!0}return!1}function ef(t,r,s,u){if(u={lane:2,revertLane:Mf(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Bc(t)){if(r)throw Error(i(479))}else r=gd(t,s,u,2),r!==null&&vr(r,t,2)}function Bc(t){var r=t.alternate;return t===gt||r!==null&&r===gt}function Ex(t,r){Ji=Dc=!0;var s=t.pending;s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r}function Ax(t,r,s){if((s&4194048)!==0){var u=r.lanes;u&=t.pendingLanes,s|=u,r.lanes=s,hn(t,s)}}var ao={readContext:Pn,use:Rc,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};ao.useEffectEvent=Cn;var Dx={readContext:Pn,use:Rc,useCallback:function(t,r){return or().memoizedState=[t,r===void 0?null:r],t},useContext:Pn,useEffect:fx,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,zc(4194308,4,xx.bind(null,r,t),s)},useLayoutEffect:function(t,r){return zc(4194308,4,t,r)},useInsertionEffect:function(t,r){zc(4,2,t,r)},useMemo:function(t,r){var s=or();r=r===void 0?null:r;var u=t();if(hi){st(!0);try{t()}finally{st(!1)}}return s.memoizedState=[u,r],u},useReducer:function(t,r,s){var u=or();if(s!==void 0){var p=s(r);if(hi){st(!0);try{s(r)}finally{st(!1)}}}else p=r;return u.memoizedState=u.baseState=p,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:p},u.queue=t,t=t.dispatch=h2.bind(null,gt,t),[u.memoizedState,t]},useRef:function(t){var r=or();return t={current:t},r.memoizedState=t},useState:function(t){t=Gd(t);var r=t.queue,s=Nx.bind(null,gt,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:Pd,useDeferredValue:function(t,r){var s=or();return Qd(s,t,r)},useTransition:function(){var t=Gd(!1);return t=wx.bind(null,gt,t.queue,!0,!1),or().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var u=gt,p=or();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||Pp(u,r,s)}p.memoizedState=s;var y={value:s,getSnapshot:r};return p.queue=y,fx(Zp.bind(null,u,y,t),[t]),u.flags|=2048,ts(9,{destroy:void 0},Qp.bind(null,u,y,s,r),null),s},useId:function(){var t=or(),r=cn.identifierPrefix;if(_t){var s=ka,u=wa;s=(u&~(1<<32-Ke(u)-1)).toString(32)+s,r="_"+r+"R_"+s,s=Tc++,0<s&&(r+="H"+s.toString(32)),r+="_"}else s=i2++,r="_"+r+"r_"+s.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Jd,useFormState:sx,useActionState:sx,useOptimistic:function(t){var r=or();r.memoizedState=r.baseState=t;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=s,r=ef.bind(null,gt,!0,s),s.dispatch=r,[t,r]},useMemoCache:Yd,useCacheRefresh:function(){return or().memoizedState=f2.bind(null,gt)},useEffectEvent:function(t){var r=or(),s={impl:t};return r.memoizedState=s,function(){if((Xt&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}},tf={readContext:Pn,use:Rc,useCallback:yx,useContext:Pn,useEffect:Kd,useImperativeHandle:gx,useInsertionEffect:mx,useLayoutEffect:px,useMemo:bx,useReducer:Mc,useRef:dx,useState:function(){return Mc(Va)},useDebugValue:Pd,useDeferredValue:function(t,r){var s=Tn();return vx(s,nn.memoizedState,t,r)},useTransition:function(){var t=Mc(Va)[0],r=Tn().memoizedState;return[typeof t=="boolean"?t:no(t),r]},useSyncExternalStore:Kp,useId:Sx,useHostTransitionStatus:Jd,useFormState:ox,useActionState:ox,useOptimistic:function(t,r){var s=Tn();return tx(s,nn,t,r)},useMemoCache:Yd,useCacheRefresh:Cx};tf.useEffectEvent=hx;var Tx={readContext:Pn,use:Rc,useCallback:yx,useContext:Pn,useEffect:Kd,useImperativeHandle:gx,useInsertionEffect:mx,useLayoutEffect:px,useMemo:bx,useReducer:Wd,useRef:dx,useState:function(){return Wd(Va)},useDebugValue:Pd,useDeferredValue:function(t,r){var s=Tn();return nn===null?Qd(s,t,r):vx(s,nn.memoizedState,t,r)},useTransition:function(){var t=Wd(Va)[0],r=Tn().memoizedState;return[typeof t=="boolean"?t:no(t),r]},useSyncExternalStore:Kp,useId:Sx,useHostTransitionStatus:Jd,useFormState:ux,useActionState:ux,useOptimistic:function(t,r){var s=Tn();return nn!==null?tx(s,nn,t,r):(s.baseState=t,[t,s.queue.dispatch])},useMemoCache:Yd,useCacheRefresh:Cx};Tx.useEffectEvent=hx;function nf(t,r,s,u){r=t.memoizedState,s=s(u,r),s=s==null?r:g({},r,s),t.memoizedState=s,t.lanes===0&&(t.updateQueue.baseState=s)}var rf={enqueueSetState:function(t,r,s){t=t._reactInternals;var u=Br(),p=wl(u);p.payload=r,s!=null&&(p.callback=s),r=kl(t,p,u),r!==null&&(vr(r,t,u),Zs(r,t,u))},enqueueReplaceState:function(t,r,s){t=t._reactInternals;var u=Br(),p=wl(u);p.tag=1,p.payload=r,s!=null&&(p.callback=s),r=kl(t,p,u),r!==null&&(vr(r,t,u),Zs(r,t,u))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var s=Br(),u=wl(s);u.tag=2,r!=null&&(u.callback=r),r=kl(t,u,s),r!==null&&(vr(r,t,s),Zs(r,t,s))}};function Fx(t,r,s,u,p,y,S){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(u,y,S):r.prototype&&r.prototype.isPureReactComponent?!Ys(s,u)||!Ys(p,y):!0}function Rx(t,r,s,u){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(s,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(s,u),r.state!==t&&rf.enqueueReplaceState(r,r.state,null)}function mi(t,r){var s=r;if("ref"in r){s={};for(var u in r)u!=="ref"&&(s[u]=r[u])}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 Mx(t){mc(t)}function zx(t){console.error(t)}function _x(t){mc(t)}function Oc(t,r){try{var s=t.onUncaughtError;s(r.value,{componentStack:r.stack})}catch(u){setTimeout(function(){throw u})}}function Bx(t,r,s){try{var u=t.onCaughtError;u(s.value,{componentStack:s.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function af(t,r,s){return s=wl(s),s.tag=3,s.payload={element:null},s.callback=function(){Oc(t,r)},s}function Ox(t){return t=wl(t),t.tag=3,t}function $x(t,r,s,u){var p=s.type.getDerivedStateFromError;if(typeof p=="function"){var y=u.value;t.payload=function(){return p(y)},t.callback=function(){Bx(r,s,u)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(t.callback=function(){Bx(r,s,u),typeof p!="function"&&(Al===null?Al=new Set([this]):Al.add(this));var M=u.stack;this.componentDidCatch(u.value,{componentStack:M!==null?M:""})})}function m2(t,r,s,u,p){if(s.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(r=s.alternate,r!==null&&Gi(r,s,p,!0),s=Rr.current,s!==null){switch(s.tag){case 31:case 13:return Qr===null?Kc():s.alternate===null&&Nn===0&&(Nn=3),s.flags&=-257,s.flags|=65536,s.lanes=p,u===Sc?s.flags|=16384:(r=s.updateQueue,r===null?s.updateQueue=new Set([u]):r.add(u),Tf(t,u,p)),!1;case 22:return s.flags|=65536,u===Sc?s.flags|=16384:(r=s.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([u])},s.updateQueue=r):(s=r.retryQueue,s===null?r.retryQueue=new Set([u]):s.add(u)),Tf(t,u,p)),!1}throw Error(i(435,s.tag))}return Tf(t,u,p),Kc(),!1}if(_t)return r=Rr.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,u!==jd&&(t=Error(i(422),{cause:u}),Gs(Gr(t,s)))):(u!==jd&&(r=Error(i(423),{cause:u}),Gs(Gr(r,s))),t=t.current.alternate,t.flags|=65536,p&=-p,t.lanes|=p,u=Gr(u,s),p=af(t.stateNode,u,p),zd(t,p),Nn!==4&&(Nn=2)),!1;var y=Error(i(520),{cause:u});if(y=Gr(y,s),ho===null?ho=[y]:ho.push(y),Nn!==4&&(Nn=2),r===null)return!0;u=Gr(u,s),s=r;do{switch(s.tag){case 3:return s.flags|=65536,t=p&-p,s.lanes|=t,t=af(s.stateNode,u,t),zd(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"&&(Al===null||!Al.has(y))))return s.flags|=65536,p&=-p,s.lanes|=p,p=Ox(p),$x(p,t,s,u),zd(s,p),!1}s=s.return}while(s!==null);return!1}var lf=Error(i(461)),zn=!1;function Qn(t,r,s,u){r.child=t===null?Up(r,null,s,u):fi(r,t.child,s,u)}function Lx(t,r,s,u,p){s=s.render;var y=r.ref;if("ref"in u){var S={};for(var M in u)M!=="ref"&&(S[M]=u[M])}else S=u;return oi(r),u=Id(t,r,s,S,y,p),M=Hd(),t!==null&&!zn?(Ud(t,r,p),Ka(t,r,p)):(_t&&M&&wd(r),r.flags|=1,Qn(t,r,u,p),r.child)}function Ix(t,r,s,u,p){if(t===null){var y=s.type;return typeof y=="function"&&!yd(y)&&y.defaultProps===void 0&&s.compare===null?(r.tag=15,r.type=y,Hx(t,r,y,u,p)):(t=yc(s.type,null,u,r,r.mode,p),t.ref=r.ref,t.return=r,r.child=t)}if(y=t.child,!mf(t,p)){var S=y.memoizedProps;if(s=s.compare,s=s!==null?s:Ys,s(S,u)&&t.ref===r.ref)return Ka(t,r,p)}return r.flags|=1,t=qa(y,u),t.ref=r.ref,t.return=r,r.child=t}function Hx(t,r,s,u,p){if(t!==null){var y=t.memoizedProps;if(Ys(y,u)&&t.ref===r.ref)if(zn=!1,r.pendingProps=u=y,mf(t,p))(t.flags&131072)!==0&&(zn=!0);else return r.lanes=t.lanes,Ka(t,r,p)}return sf(t,r,s,u,p)}function Ux(t,r,s,u){var p=u.children,y=t!==null?t.memoizedState:null;if(t===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((r.flags&128)!==0){if(y=y!==null?y.baseLanes|s:s,t!==null){for(u=r.child=t.child,p=0;u!==null;)p=p|u.lanes|u.childLanes,u=u.sibling;u=p&~y}else u=0,r.child=null;return qx(t,r,y,s,u)}if((s&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&kc(r,y!==null?y.cachePool:null),y!==null?Xp(r,y):Bd(),Wp(r);else return u=r.lanes=536870912,qx(t,r,y!==null?y.baseLanes|s:s,s,u)}else y!==null?(kc(r,y.cachePool),Xp(r,y),Sl(),r.memoizedState=null):(t!==null&&kc(r,null),Bd(),Sl());return Qn(t,r,p,s),r.child}function lo(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function qx(t,r,s,u,p){var y=Td();return y=y===null?null:{parent:Rn._currentValue,pool:y},r.memoizedState={baseLanes:s,cachePool:y},t!==null&&kc(r,null),Bd(),Wp(r),t!==null&&Gi(t,r,u,!0),r.childLanes=p,null}function $c(t,r){return r=Ic({mode:r.mode,children:r.children},t.mode),r.ref=t.ref,t.child=r,r.return=t,r}function Yx(t,r,s){return fi(r,t.child,null,s),t=$c(r,r.pendingProps),t.flags|=2,Mr(r),r.memoizedState=null,t}function p2(t,r,s){var u=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,t===null){if(_t){if(u.mode==="hidden")return t=$c(r,u),r.lanes=536870912,lo(null,t);if($d(r),(t=pn)?(t=n0(t,Pr),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:xl!==null?{id:wa,overflow:ka}:null,retryLane:536870912,hydrationErrors:null},s=Ep(t),s.return=r,r.child=s,Kn=r,pn=null)):t=null,t===null)throw yl(r);return r.lanes=536870912,null}return $c(r,u)}var y=t.memoizedState;if(y!==null){var S=y.dehydrated;if($d(r),p)if(r.flags&256)r.flags&=-257,r=Yx(t,r,s);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(zn||Gi(t,r,s,!1),p=(s&t.childLanes)!==0,zn||p){if(u=cn,u!==null&&(S=le(u,s),S!==0&&S!==y.retryLane))throw y.retryLane=S,ai(t,S),vr(u,t,S),lf;Kc(),r=Yx(t,r,s)}else t=y.treeContext,pn=Zr(S.nextSibling),Kn=r,_t=!0,gl=null,Pr=!1,t!==null&&Tp(r,t),r=$c(r,u),r.flags|=4096;return r}return t=qa(t.child,{mode:u.mode,children:u.children}),t.ref=r.ref,r.child=t,t.return=r,t}function Lc(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 sf(t,r,s,u,p){return oi(r),s=Id(t,r,s,u,void 0,p),u=Hd(),t!==null&&!zn?(Ud(t,r,p),Ka(t,r,p)):(_t&&u&&wd(r),r.flags|=1,Qn(t,r,s,p),r.child)}function Xx(t,r,s,u,p,y){return oi(r),r.updateQueue=null,s=Vp(r,u,s,p),Gp(t),u=Hd(),t!==null&&!zn?(Ud(t,r,y),Ka(t,r,y)):(_t&&u&&wd(r),r.flags|=1,Qn(t,r,s,y),r.child)}function Wx(t,r,s,u,p){if(oi(r),r.stateNode===null){var y=qi,S=s.contextType;typeof S=="object"&&S!==null&&(y=Pn(S)),y=new s(u,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=rf,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=u,y.state=r.memoizedState,y.refs={},Rd(r),S=s.contextType,y.context=typeof S=="object"&&S!==null?Pn(S):qi,y.state=r.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(nf(r,s,S,u),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&&rf.enqueueReplaceState(y,y.state,null),eo(r,u,y,p),Js(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),u=!0}else if(t===null){y=r.stateNode;var M=r.memoizedProps,G=mi(s,M);y.props=G;var ce=y.context,ge=s.contextType;S=qi,typeof ge=="object"&&ge!==null&&(S=Pn(ge));var Ce=s.getDerivedStateFromProps;ge=typeof Ce=="function"||typeof y.getSnapshotBeforeUpdate=="function",M=r.pendingProps!==M,ge||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(M||ce!==S)&&Rx(r,y,u,S),vl=!1;var ue=r.memoizedState;y.state=ue,eo(r,u,y,p),Js(),ce=r.memoizedState,M||ue!==ce||vl?(typeof Ce=="function"&&(nf(r,s,Ce,u),ce=r.memoizedState),(G=vl||Fx(r,s,G,u,ue,ce,S))?(ge||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=u,r.memoizedState=ce),y.props=u,y.state=ce,y.context=S,u=G):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{y=r.stateNode,Md(t,r),S=r.memoizedProps,ge=mi(s,S),y.props=ge,Ce=r.pendingProps,ue=y.context,ce=s.contextType,G=qi,typeof ce=="object"&&ce!==null&&(G=Pn(ce)),M=s.getDerivedStateFromProps,(ce=typeof M=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==Ce||ue!==G)&&Rx(r,y,u,G),vl=!1,ue=r.memoizedState,y.state=ue,eo(r,u,y,p),Js();var he=r.memoizedState;S!==Ce||ue!==he||vl||t!==null&&t.dependencies!==null&&vc(t.dependencies)?(typeof M=="function"&&(nf(r,s,M,u),he=r.memoizedState),(ge=vl||Fx(r,s,ge,u,ue,he,G)||t!==null&&t.dependencies!==null&&vc(t.dependencies))?(ce||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(u,he,G),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(u,he,G)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===t.memoizedProps&&ue===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&ue===t.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=he),y.props=u,y.state=he,y.context=G,u=ge):(typeof y.componentDidUpdate!="function"||S===t.memoizedProps&&ue===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&ue===t.memoizedState||(r.flags|=1024),u=!1)}return y=u,Lc(t,r),u=(r.flags&128)!==0,y||u?(y=r.stateNode,s=u&&typeof s.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,t!==null&&u?(r.child=fi(r,t.child,null,p),r.child=fi(r,null,s,p)):Qn(t,r,s,p),r.memoizedState=y.state,t=r.child):t=Ka(t,r,p),t}function Gx(t,r,s,u){return ii(),r.flags|=256,Qn(t,r,s,u),r.child}var of={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function cf(t){return{baseLanes:t,cachePool:Bp()}}function uf(t,r,s){return t=t!==null?t.childLanes&~s:0,r&&(t|=_r),t}function Vx(t,r,s){var u=r.pendingProps,p=!1,y=(r.flags&128)!==0,S;if((S=y)||(S=t!==null&&t.memoizedState===null?!1:(Dn.current&2)!==0),S&&(p=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,t===null){if(_t){if(p?jl(r):Sl(),(t=pn)?(t=n0(t,Pr),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:xl!==null?{id:wa,overflow:ka}:null,retryLane:536870912,hydrationErrors:null},s=Ep(t),s.return=r,r.child=s,Kn=r,pn=null)):t=null,t===null)throw yl(r);return Wf(t)?r.lanes=32:r.lanes=536870912,null}var M=u.children;return u=u.fallback,p?(Sl(),p=r.mode,M=Ic({mode:"hidden",children:M},p),u=li(u,p,s,null),M.return=r,u.return=r,M.sibling=u,r.child=M,u=r.child,u.memoizedState=cf(s),u.childLanes=uf(t,S,s),r.memoizedState=of,lo(null,u)):(jl(r),df(r,M))}var G=t.memoizedState;if(G!==null&&(M=G.dehydrated,M!==null)){if(y)r.flags&256?(jl(r),r.flags&=-257,r=ff(t,r,s)):r.memoizedState!==null?(Sl(),r.child=t.child,r.flags|=128,r=null):(Sl(),M=u.fallback,p=r.mode,u=Ic({mode:"visible",children:u.children},p),M=li(M,p,s,null),M.flags|=2,u.return=r,M.return=r,u.sibling=M,r.child=u,fi(r,t.child,null,s),u=r.child,u.memoizedState=cf(s),u.childLanes=uf(t,S,s),r.memoizedState=of,r=lo(null,u));else if(jl(r),Wf(M)){if(S=M.nextSibling&&M.nextSibling.dataset,S)var ce=S.dgst;S=ce,u=Error(i(419)),u.stack="",u.digest=S,Gs({value:u,source:null,stack:null}),r=ff(t,r,s)}else if(zn||Gi(t,r,s,!1),S=(s&t.childLanes)!==0,zn||S){if(S=cn,S!==null&&(u=le(S,s),u!==0&&u!==G.retryLane))throw G.retryLane=u,ai(t,u),vr(S,t,u),lf;Xf(M)||Kc(),r=ff(t,r,s)}else Xf(M)?(r.flags|=192,r.child=t.child,r=null):(t=G.treeContext,pn=Zr(M.nextSibling),Kn=r,_t=!0,gl=null,Pr=!1,t!==null&&Tp(r,t),r=df(r,u.children),r.flags|=4096);return r}return p?(Sl(),M=u.fallback,p=r.mode,G=t.child,ce=G.sibling,u=qa(G,{mode:"hidden",children:u.children}),u.subtreeFlags=G.subtreeFlags&65011712,ce!==null?M=qa(ce,M):(M=li(M,p,s,null),M.flags|=2),M.return=r,u.return=r,u.sibling=M,r.child=u,lo(null,u),u=r.child,M=t.child.memoizedState,M===null?M=cf(s):(p=M.cachePool,p!==null?(G=Rn._currentValue,p=p.parent!==G?{parent:G,pool:G}:p):p=Bp(),M={baseLanes:M.baseLanes|s,cachePool:p}),u.memoizedState=M,u.childLanes=uf(t,S,s),r.memoizedState=of,lo(t.child,u)):(jl(r),s=t.child,t=s.sibling,s=qa(s,{mode:"visible",children:u.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 df(t,r){return r=Ic({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function Ic(t,r){return t=Fr(22,t,null,r),t.lanes=0,t}function ff(t,r,s){return fi(r,t.child,null,s),t=df(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Kx(t,r,s){t.lanes|=r;var u=t.alternate;u!==null&&(u.lanes|=r),Nd(t.return,r,s)}function hf(t,r,s,u,p,y){var S=t.memoizedState;S===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:s,tailMode:p,treeForkCount:y}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=u,S.tail=s,S.tailMode=p,S.treeForkCount=y)}function Px(t,r,s){var u=r.pendingProps,p=u.revealOrder,y=u.tail;u=u.children;var S=Dn.current,M=(S&2)!==0;if(M?(S=S&1|2,r.flags|=128):S&=1,R(Dn,S),Qn(t,r,u,s),u=_t?Ws:0,!M&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Kx(t,s,r);else if(t.tag===19)Kx(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&&Ac(t)===null&&(p=s),s=s.sibling;s=p,s===null?(p=r.child,r.child=null):(p=s.sibling,s.sibling=null),hf(r,!1,p,s,y,u);break;case"backwards":case"unstable_legacy-backwards":for(s=null,p=r.child,r.child=null;p!==null;){if(t=p.alternate,t!==null&&Ac(t)===null){r.child=p;break}t=p.sibling,p.sibling=s,s=p,p=t}hf(r,!0,s,null,y,u);break;case"together":hf(r,!1,null,null,void 0,u);break;default:r.memoizedState=null}return r.child}function Ka(t,r,s){if(t!==null&&(r.dependencies=t.dependencies),El|=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=qa(t,t.pendingProps),r.child=s,s.return=r;t.sibling!==null;)t=t.sibling,s=s.sibling=qa(t,t.pendingProps),s.return=r;s.sibling=null}return r.child}function mf(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&vc(t)))}function x2(t,r,s){switch(r.tag){case 3:je(r,r.stateNode.containerInfo),bl(r,Rn,t.memoizedState.cache),ii();break;case 27:case 5:Oe(r);break;case 4:je(r,r.stateNode.containerInfo);break;case 10:bl(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,$d(r),null;break;case 13:var u=r.memoizedState;if(u!==null)return u.dehydrated!==null?(jl(r),r.flags|=128,null):(s&r.child.childLanes)!==0?Vx(t,r,s):(jl(r),t=Ka(t,r,s),t!==null?t.sibling:null);jl(r);break;case 19:var p=(t.flags&128)!==0;if(u=(s&r.childLanes)!==0,u||(Gi(t,r,s,!1),u=(s&r.childLanes)!==0),p){if(u)return Px(t,r,s);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),R(Dn,Dn.current),u)break;return null;case 22:return r.lanes=0,Ux(t,r,s,r.pendingProps);case 24:bl(r,Rn,t.memoizedState.cache)}return Ka(t,r,s)}function Qx(t,r,s){if(t!==null)if(t.memoizedProps!==r.pendingProps)zn=!0;else{if(!mf(t,s)&&(r.flags&128)===0)return zn=!1,x2(t,r,s);zn=(t.flags&131072)!==0}else zn=!1,_t&&(r.flags&1048576)!==0&&Dp(r,Ws,r.index);switch(r.lanes=0,r.tag){case 16:e:{var u=r.pendingProps;if(t=ui(r.elementType),r.type=t,typeof t=="function")yd(t)?(u=mi(t,u),r.tag=1,r=Wx(null,r,t,u,s)):(r.tag=0,r=sf(null,r,t,u,s));else{if(t!=null){var p=t.$$typeof;if(p===T){r.tag=11,r=Lx(null,r,t,u,s);break e}else if(p===I){r.tag=14,r=Ix(null,r,t,u,s);break e}}throw r=ne(t)||t,Error(i(306,r,""))}}return r;case 0:return sf(t,r,r.type,r.pendingProps,s);case 1:return u=r.type,p=mi(u,r.pendingProps),Wx(t,r,u,p,s);case 3:e:{if(je(r,r.stateNode.containerInfo),t===null)throw Error(i(387));u=r.pendingProps;var y=r.memoizedState;p=y.element,Md(t,r),eo(r,u,null,s);var S=r.memoizedState;if(u=S.cache,bl(r,Rn,u),u!==y.cache&&Ed(r,[Rn],s,!0),Js(),u=S.element,y.isDehydrated)if(y={element:u,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=Gx(t,r,u,s);break e}else if(u!==p){p=Gr(Error(i(424)),r),Gs(p),r=Gx(t,r,u,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(pn=Zr(t.firstChild),Kn=r,_t=!0,gl=null,Pr=!0,s=Up(r,null,u,s),r.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(ii(),u===p){r=Ka(t,r,s);break e}Qn(t,r,u,s)}r=r.child}return r;case 26:return Lc(t,r),t===null?(s=o0(r.type,null,r.pendingProps,null))?r.memoizedState=s:_t||(s=r.type,t=r.pendingProps,u=nu(te.current).createElement(s),u[gn]=r,u[mn]=t,Zn(u,s,t),Sn(u),r.stateNode=u):r.memoizedState=o0(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return Oe(r),t===null&&_t&&(u=r.stateNode=l0(r.type,r.pendingProps,te.current),Kn=r,Pr=!0,p=pn,Rl(r.type)?(Gf=p,pn=Zr(u.firstChild)):pn=p),Qn(t,r,r.pendingProps.children,s),Lc(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&_t&&((p=u=pn)&&(u=W2(u,r.type,r.pendingProps,Pr),u!==null?(r.stateNode=u,Kn=r,pn=Zr(u.firstChild),Pr=!1,p=!0):p=!1),p||yl(r)),Oe(r),p=r.type,y=r.pendingProps,S=t!==null?t.memoizedProps:null,u=y.children,Uf(p,y)?u=null:S!==null&&Uf(p,S)&&(r.flags|=32),r.memoizedState!==null&&(p=Id(t,r,s2,null,null,s),wo._currentValue=p),Lc(t,r),Qn(t,r,u,s),r.child;case 6:return t===null&&_t&&((t=s=pn)&&(s=G2(s,r.pendingProps,Pr),s!==null?(r.stateNode=s,Kn=r,pn=null,t=!0):t=!1),t||yl(r)),null;case 13:return Vx(t,r,s);case 4:return je(r,r.stateNode.containerInfo),u=r.pendingProps,t===null?r.child=fi(r,null,u,s):Qn(t,r,u,s),r.child;case 11:return Lx(t,r,r.type,r.pendingProps,s);case 7:return Qn(t,r,r.pendingProps,s),r.child;case 8:return Qn(t,r,r.pendingProps.children,s),r.child;case 12:return Qn(t,r,r.pendingProps.children,s),r.child;case 10:return u=r.pendingProps,bl(r,r.type,u.value),Qn(t,r,u.children,s),r.child;case 9:return p=r.type._context,u=r.pendingProps.children,oi(r),p=Pn(p),u=u(p),r.flags|=1,Qn(t,r,u,s),r.child;case 14:return Ix(t,r,r.type,r.pendingProps,s);case 15:return Hx(t,r,r.type,r.pendingProps,s);case 19:return Px(t,r,s);case 31:return p2(t,r,s);case 22:return Ux(t,r,s,r.pendingProps);case 24:return oi(r),u=Pn(Rn),t===null?(p=Td(),p===null&&(p=cn,y=Ad(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=s),p=y),r.memoizedState={parent:u,cache:p},Rd(r),bl(r,Rn,p)):((t.lanes&s)!==0&&(Md(t,r),eo(r,null,null,s),Js()),p=t.memoizedState,y=r.memoizedState,p.parent!==u?(p={parent:u,cache:u},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),bl(r,Rn,u)):(u=y.cache,bl(r,Rn,u),u!==p.cache&&Ed(r,[Rn],s,!0))),Qn(t,r,r.pendingProps.children,s),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Pa(t){t.flags|=4}function pf(t,r,s,u,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(S1())t.flags|=8192;else throw di=Sc,Fd}else t.flags&=-16777217}function Zx(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!h0(r))if(S1())t.flags|=8192;else throw di=Sc,Fd}function Hc(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?lt():536870912,t.lanes|=r,ls|=r)}function io(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 u=null;s!==null;)s.alternate!==null&&(u=s),s=s.sibling;u===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:u.sibling=null}}function xn(t){var r=t.alternate!==null&&t.alternate.child===t.child,s=0,u=0;if(r)for(var p=t.child;p!==null;)s|=p.lanes|p.childLanes,u|=p.subtreeFlags&65011712,u|=p.flags&65011712,p.return=t,p=p.sibling;else for(p=t.child;p!==null;)s|=p.lanes|p.childLanes,u|=p.subtreeFlags,u|=p.flags,p.return=t,p=p.sibling;return t.subtreeFlags|=u,t.childLanes=s,r}function g2(t,r,s){var u=r.pendingProps;switch(kd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xn(r),null;case 1:return xn(r),null;case 3:return s=r.stateNode,u=null,t!==null&&(u=t.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),Wa(Rn),_e(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(Wi(r)?Pa(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Sd())),xn(r),null;case 26:var p=r.type,y=r.memoizedState;return t===null?(Pa(r),y!==null?(xn(r),Zx(r,y)):(xn(r),pf(r,p,null,u,s))):y?y!==t.memoizedState?(Pa(r),xn(r),Zx(r,y)):(xn(r),r.flags&=-16777217):(t=t.memoizedProps,t!==u&&Pa(r),xn(r),pf(r,p,t,u,s)),null;case 27:if(Xe(r),s=te.current,p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==u&&Pa(r);else{if(!u){if(r.stateNode===null)throw Error(i(166));return xn(r),null}t=O.current,Wi(r)?Fp(r):(t=l0(p,u,s),r.stateNode=t,Pa(r))}return xn(r),null;case 5:if(Xe(r),p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==u&&Pa(r);else{if(!u){if(r.stateNode===null)throw Error(i(166));return xn(r),null}if(y=O.current,Wi(r))Fp(r);else{var S=nu(te.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 u.is=="string"?S.createElement("select",{is:u.is}):S.createElement("select"),u.multiple?y.multiple=!0:u.size&&(y.size=u.size);break;default:y=typeof u.is=="string"?S.createElement(p,{is:u.is}):S.createElement(p)}}y[gn]=r,y[mn]=u;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(Zn(y,p,u),p){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Pa(r)}}return xn(r),pf(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==u&&Pa(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(i(166));if(t=te.current,Wi(r)){if(t=r.stateNode,s=r.memoizedProps,u=null,p=Kn,p!==null)switch(p.tag){case 27:case 5:u=p.memoizedProps}t[gn]=r,t=!!(t.nodeValue===s||u!==null&&u.suppressHydrationWarning===!0||V1(t.nodeValue,s)),t||yl(r,!0)}else t=nu(t).createTextNode(u),t[gn]=r,r.stateNode=t}return xn(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(u=Wi(r),s!==null){if(t===null){if(!u)throw Error(i(318));if(t=r.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(557));t[gn]=r}else ii(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;xn(r),t=!1}else s=Sd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return r.flags&256?(Mr(r),r):(Mr(r),null);if((r.flags&128)!==0)throw Error(i(558))}return xn(r),null;case 13:if(u=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=Wi(r),u!==null&&u.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[gn]=r}else ii(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;xn(r),p=!1}else p=Sd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(Mr(r),r):(Mr(r),null)}return Mr(r),(r.flags&128)!==0?(r.lanes=s,r):(s=u!==null,t=t!==null&&t.memoizedState!==null,s&&(u=r.child,p=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(p=u.alternate.memoizedState.cachePool.pool),y=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(y=u.memoizedState.cachePool.pool),y!==p&&(u.flags|=2048)),s!==t&&s&&(r.child.flags|=8192),Hc(r,r.updateQueue),xn(r),null);case 4:return _e(),t===null&&Of(r.stateNode.containerInfo),xn(r),null;case 10:return Wa(r.type),xn(r),null;case 19:if(Y(Dn),u=r.memoizedState,u===null)return xn(r),null;if(p=(r.flags&128)!==0,y=u.rendering,y===null)if(p)io(u,!1);else{if(Nn!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(y=Ac(t),y!==null){for(r.flags|=128,io(u,!1),t=y.updateQueue,r.updateQueue=t,Hc(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)Np(s,t),s=s.sibling;return R(Dn,Dn.current&1|2),_t&&Ya(r,u.treeForkCount),r.child}t=t.sibling}u.tail!==null&&be()>Wc&&(r.flags|=128,p=!0,io(u,!1),r.lanes=4194304)}else{if(!p)if(t=Ac(y),t!==null){if(r.flags|=128,p=!0,t=t.updateQueue,r.updateQueue=t,Hc(r,t),io(u,!0),u.tail===null&&u.tailMode==="hidden"&&!y.alternate&&!_t)return xn(r),null}else 2*be()-u.renderingStartTime>Wc&&s!==536870912&&(r.flags|=128,p=!0,io(u,!1),r.lanes=4194304);u.isBackwards?(y.sibling=r.child,r.child=y):(t=u.last,t!==null?t.sibling=y:r.child=y,u.last=y)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=be(),t.sibling=null,s=Dn.current,R(Dn,p?s&1|2:s&1),_t&&Ya(r,u.treeForkCount),t):(xn(r),null);case 22:case 23:return Mr(r),Od(),u=r.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(s&536870912)!==0&&(r.flags&128)===0&&(xn(r),r.subtreeFlags&6&&(r.flags|=8192)):xn(r),s=r.updateQueue,s!==null&&Hc(r,s.retryQueue),s=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==s&&(r.flags|=2048),t!==null&&Y(ci),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),Wa(Rn),xn(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function y2(t,r){switch(kd(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return Wa(Rn),_e(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return Xe(r),null;case 31:if(r.memoizedState!==null){if(Mr(r),r.alternate===null)throw Error(i(340));ii()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(Mr(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(i(340));ii()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return Y(Dn),null;case 4:return _e(),null;case 10:return Wa(r.type),null;case 22:case 23:return Mr(r),Od(),t!==null&&Y(ci),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return Wa(Rn),null;case 25:return null;default:return null}}function Jx(t,r){switch(kd(r),r.tag){case 3:Wa(Rn),_e();break;case 26:case 27:case 5:Xe(r);break;case 4:_e();break;case 31:r.memoizedState!==null&&Mr(r);break;case 13:Mr(r);break;case 19:Y(Dn);break;case 10:Wa(r.type);break;case 22:case 23:Mr(r),Od(),t!==null&&Y(ci);break;case 24:Wa(Rn)}}function so(t,r){try{var s=r.updateQueue,u=s!==null?s.lastEffect:null;if(u!==null){var p=u.next;s=p;do{if((s.tag&t)===t){u=void 0;var y=s.create,S=s.inst;u=y(),S.destroy=u}s=s.next}while(s!==p)}}catch(M){Zt(r,r.return,M)}}function Cl(t,r,s){try{var u=r.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var y=p.next;u=y;do{if((u.tag&t)===t){var S=u.inst,M=S.destroy;if(M!==void 0){S.destroy=void 0,p=r;var G=s,ce=M;try{ce()}catch(ge){Zt(p,G,ge)}}}u=u.next}while(u!==y)}}catch(ge){Zt(r,r.return,ge)}}function e1(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{Yp(r,s)}catch(u){Zt(t,t.return,u)}}}function t1(t,r,s){s.props=mi(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(u){Zt(t,r,u)}}function oo(t,r){try{var s=t.ref;if(s!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:u=t.stateNode;break;default:u=t.stateNode}typeof s=="function"?t.refCleanup=s(u):s.current=u}}catch(p){Zt(t,r,p)}}function ja(t,r){var s=t.ref,u=t.refCleanup;if(s!==null)if(typeof u=="function")try{u()}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 n1(t){var r=t.type,s=t.memoizedProps,u=t.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":s.autoFocus&&u.focus();break e;case"img":s.src?u.src=s.src:s.srcSet&&(u.srcset=s.srcSet)}}catch(p){Zt(t,t.return,p)}}function xf(t,r,s){try{var u=t.stateNode;I2(u,t.type,s,r),u[mn]=r}catch(p){Zt(t,t.return,p)}}function r1(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Rl(t.type)||t.tag===4}function gf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||r1(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&&Rl(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 yf(t,r,s){var u=t.tag;if(u===5||u===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=Vn));else if(u!==4&&(u===27&&Rl(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(yf(t,r,s),t=t.sibling;t!==null;)yf(t,r,s),t=t.sibling}function Uc(t,r,s){var u=t.tag;if(u===5||u===6)t=t.stateNode,r?s.insertBefore(t,r):s.appendChild(t);else if(u!==4&&(u===27&&Rl(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(Uc(t,r,s),t=t.sibling;t!==null;)Uc(t,r,s),t=t.sibling}function a1(t){var r=t.stateNode,s=t.memoizedProps;try{for(var u=t.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);Zn(r,u,s),r[gn]=t,r[mn]=s}catch(y){Zt(t,t.return,y)}}var Qa=!1,_n=!1,bf=!1,l1=typeof WeakSet=="function"?WeakSet:Set,Xn=null;function b2(t,r){if(t=t.containerInfo,If=cu,t=gp(t),dd(t)){if("selectionStart"in t)var s={start:t.selectionStart,end:t.selectionEnd};else e:{s=(s=t.ownerDocument)&&s.defaultView||window;var u=s.getSelection&&s.getSelection();if(u&&u.rangeCount!==0){s=u.anchorNode;var p=u.anchorOffset,y=u.focusNode;u=u.focusOffset;try{s.nodeType,y.nodeType}catch{s=null;break e}var S=0,M=-1,G=-1,ce=0,ge=0,Ce=t,ue=null;t:for(;;){for(var he;Ce!==s||p!==0&&Ce.nodeType!==3||(M=S+p),Ce!==y||u!==0&&Ce.nodeType!==3||(G=S+u),Ce.nodeType===3&&(S+=Ce.nodeValue.length),(he=Ce.firstChild)!==null;)ue=Ce,Ce=he;for(;;){if(Ce===t)break t;if(ue===s&&++ce===p&&(M=S),ue===y&&++ge===u&&(G=S),(he=Ce.nextSibling)!==null)break;Ce=ue,ue=Ce.parentNode}Ce=he}s=M===-1||G===-1?null:{start:M,end:G}}else s=null}s=s||{start:0,end:0}}else s=null;for(Hf={focusedElem:t,selectionRange:s},cu=!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,u=s.stateNode;try{var Ge=mi(s.type,p);t=u.getSnapshotBeforeUpdate(Ge,y),u.__reactInternalSnapshotBeforeUpdate=t}catch(ut){Zt(s,s.return,ut)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,s=t.nodeType,s===9)Yf(t);else if(s===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Yf(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 i1(t,r,s){var u=s.flags;switch(s.tag){case 0:case 11:case 15:Ja(t,s),u&4&&so(5,s);break;case 1:if(Ja(t,s),u&4)if(t=s.stateNode,r===null)try{t.componentDidMount()}catch(S){Zt(s,s.return,S)}else{var p=mi(s.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(p,r,t.__reactInternalSnapshotBeforeUpdate)}catch(S){Zt(s,s.return,S)}}u&64&&e1(s),u&512&&oo(s,s.return);break;case 3:if(Ja(t,s),u&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{Yp(t,r)}catch(S){Zt(s,s.return,S)}}break;case 27:r===null&&u&4&&a1(s);case 26:case 5:Ja(t,s),r===null&&u&4&&n1(s),u&512&&oo(s,s.return);break;case 12:Ja(t,s);break;case 31:Ja(t,s),u&4&&c1(t,s);break;case 13:Ja(t,s),u&4&&u1(t,s),u&64&&(t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(s=A2.bind(null,s),V2(t,s))));break;case 22:if(u=s.memoizedState!==null||Qa,!u){r=r!==null&&r.memoizedState!==null||_n,p=Qa;var y=_n;Qa=u,(_n=r)&&!y?el(t,s,(s.subtreeFlags&8772)!==0):Ja(t,s),Qa=p,_n=y}break;case 30:break;default:Ja(t,s)}}function s1(t){var r=t.alternate;r!==null&&(t.alternate=null,s1(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&aa(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 yn=null,xr=!1;function Za(t,r,s){for(s=s.child;s!==null;)o1(t,r,s),s=s.sibling}function o1(t,r,s){if(Ye&&typeof Ye.onCommitFiberUnmount=="function")try{Ye.onCommitFiberUnmount(Le,s)}catch{}switch(s.tag){case 26:_n||ja(s,r),Za(t,r,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:_n||ja(s,r);var u=yn,p=xr;Rl(s.type)&&(yn=s.stateNode,xr=!1),Za(t,r,s),yo(s.stateNode),yn=u,xr=p;break;case 5:_n||ja(s,r);case 6:if(u=yn,p=xr,yn=null,Za(t,r,s),yn=u,xr=p,yn!==null)if(xr)try{(yn.nodeType===9?yn.body:yn.nodeName==="HTML"?yn.ownerDocument.body:yn).removeChild(s.stateNode)}catch(y){Zt(s,r,y)}else try{yn.removeChild(s.stateNode)}catch(y){Zt(s,r,y)}break;case 18:yn!==null&&(xr?(t=yn,e0(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,s.stateNode),hs(t)):e0(yn,s.stateNode));break;case 4:u=yn,p=xr,yn=s.stateNode.containerInfo,xr=!0,Za(t,r,s),yn=u,xr=p;break;case 0:case 11:case 14:case 15:Cl(2,s,r),_n||Cl(4,s,r),Za(t,r,s);break;case 1:_n||(ja(s,r),u=s.stateNode,typeof u.componentWillUnmount=="function"&&t1(s,r,u)),Za(t,r,s);break;case 21:Za(t,r,s);break;case 22:_n=(u=_n)||s.memoizedState!==null,Za(t,r,s),_n=u;break;default:Za(t,r,s)}}function c1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{hs(t)}catch(s){Zt(r,r.return,s)}}}function u1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{hs(t)}catch(s){Zt(r,r.return,s)}}function v2(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new l1),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new l1),r;default:throw Error(i(435,t.tag))}}function qc(t,r){var s=v2(t);r.forEach(function(u){if(!s.has(u)){s.add(u);var p=D2.bind(null,t,u);u.then(p,p)}})}function gr(t,r){var s=r.deletions;if(s!==null)for(var u=0;u<s.length;u++){var p=s[u],y=t,S=r,M=S;e:for(;M!==null;){switch(M.tag){case 27:if(Rl(M.type)){yn=M.stateNode,xr=!1;break e}break;case 5:yn=M.stateNode,xr=!1;break e;case 3:case 4:yn=M.stateNode.containerInfo,xr=!0;break e}M=M.return}if(yn===null)throw Error(i(160));o1(y,S,p),yn=null,xr=!1,y=p.alternate,y!==null&&(y.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)d1(r,t),r=r.sibling}var ua=null;function d1(t,r){var s=t.alternate,u=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:gr(r,t),yr(t),u&4&&(Cl(3,t,t.return),so(3,t),Cl(5,t,t.return));break;case 1:gr(r,t),yr(t),u&512&&(_n||s===null||ja(s,s.return)),u&64&&Qa&&(t=t.updateQueue,t!==null&&(u=t.callbacks,u!==null&&(s=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=s===null?u:s.concat(u))));break;case 26:var p=ua;if(gr(r,t),yr(t),u&512&&(_n||s===null||ja(s,s.return)),u&4){var y=s!==null?s.memoizedState:null;if(u=t.memoizedState,s===null)if(u===null)if(t.stateNode===null){e:{u=t.type,s=t.memoizedProps,p=p.ownerDocument||p;t:switch(u){case"title":y=p.getElementsByTagName("title")[0],(!y||y[ma]||y[gn]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=p.createElement(u),p.head.insertBefore(y,p.querySelector("head > title"))),Zn(y,u,s),y[gn]=t,Sn(y),u=y;break e;case"link":var S=d0("link","href",p).get(u+(s.href||""));if(S){for(var M=0;M<S.length;M++)if(y=S[M],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(M,1);break t}}y=p.createElement(u),Zn(y,u,s),p.head.appendChild(y);break;case"meta":if(S=d0("meta","content",p).get(u+(s.content||""))){for(M=0;M<S.length;M++)if(y=S[M],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(M,1);break t}}y=p.createElement(u),Zn(y,u,s),p.head.appendChild(y);break;default:throw Error(i(468,u))}y[gn]=t,Sn(y),u=y}t.stateNode=u}else f0(p,t.type,t.stateNode);else t.stateNode=u0(p,u,t.memoizedProps);else y!==u?(y===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):y.count--,u===null?f0(p,t.type,t.stateNode):u0(p,u,t.memoizedProps)):u===null&&t.stateNode!==null&&xf(t,t.memoizedProps,s.memoizedProps)}break;case 27:gr(r,t),yr(t),u&512&&(_n||s===null||ja(s,s.return)),s!==null&&u&4&&xf(t,t.memoizedProps,s.memoizedProps);break;case 5:if(gr(r,t),yr(t),u&512&&(_n||s===null||ja(s,s.return)),t.flags&32){p=t.stateNode;try{Er(p,"")}catch(Ge){Zt(t,t.return,Ge)}}u&4&&t.stateNode!=null&&(p=t.memoizedProps,xf(t,p,s!==null?s.memoizedProps:p)),u&1024&&(bf=!0);break;case 6:if(gr(r,t),yr(t),u&4){if(t.stateNode===null)throw Error(i(162));u=t.memoizedProps,s=t.stateNode;try{s.nodeValue=u}catch(Ge){Zt(t,t.return,Ge)}}break;case 3:if(lu=null,p=ua,ua=ru(r.containerInfo),gr(r,t),ua=p,yr(t),u&4&&s!==null&&s.memoizedState.isDehydrated)try{hs(r.containerInfo)}catch(Ge){Zt(t,t.return,Ge)}bf&&(bf=!1,f1(t));break;case 4:u=ua,ua=ru(t.stateNode.containerInfo),gr(r,t),yr(t),ua=u;break;case 12:gr(r,t),yr(t);break;case 31:gr(r,t),yr(t),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,qc(t,u)));break;case 13:gr(r,t),yr(t),t.child.flags&8192&&t.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Xc=be()),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,qc(t,u)));break;case 22:p=t.memoizedState!==null;var G=s!==null&&s.memoizedState!==null,ce=Qa,ge=_n;if(Qa=ce||p,_n=ge||G,gr(r,t),_n=ge,Qa=ce,yr(t),u&8192)e:for(r=t.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(s===null||G||Qa||_n||pi(t)),s=null,r=t;;){if(r.tag===5||r.tag===26){if(s===null){G=s=r;try{if(y=G.stateNode,p)S=y.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{M=G.stateNode;var Ce=G.memoizedProps.style,ue=Ce!=null&&Ce.hasOwnProperty("display")?Ce.display:null;M.style.display=ue==null||typeof ue=="boolean"?"":(""+ue).trim()}}catch(Ge){Zt(G,G.return,Ge)}}}else if(r.tag===6){if(s===null){G=r;try{G.stateNode.nodeValue=p?"":G.memoizedProps}catch(Ge){Zt(G,G.return,Ge)}}}else if(r.tag===18){if(s===null){G=r;try{var he=G.stateNode;p?t0(he,!0):t0(G.stateNode,!1)}catch(Ge){Zt(G,G.return,Ge)}}}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}u&4&&(u=t.updateQueue,u!==null&&(s=u.retryQueue,s!==null&&(u.retryQueue=null,qc(t,s))));break;case 19:gr(r,t),yr(t),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,qc(t,u)));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,u=t.return;u!==null;){if(r1(u)){s=u;break}u=u.return}if(s==null)throw Error(i(160));switch(s.tag){case 27:var p=s.stateNode,y=gf(t);Uc(t,y,p);break;case 5:var S=s.stateNode;s.flags&32&&(Er(S,""),s.flags&=-33);var M=gf(t);Uc(t,M,S);break;case 3:case 4:var G=s.stateNode.containerInfo,ce=gf(t);yf(t,ce,G);break;default:throw Error(i(161))}}catch(ge){Zt(t,t.return,ge)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function f1(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;f1(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),t=t.sibling}}function Ja(t,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)i1(t,r.alternate,r),r=r.sibling}function pi(t){for(t=t.child;t!==null;){var r=t;switch(r.tag){case 0:case 11:case 14:case 15:Cl(4,r,r.return),pi(r);break;case 1:ja(r,r.return);var s=r.stateNode;typeof s.componentWillUnmount=="function"&&t1(r,r.return,s),pi(r);break;case 27:yo(r.stateNode);case 26:case 5:ja(r,r.return),pi(r);break;case 22:r.memoizedState===null&&pi(r);break;case 30:pi(r);break;default:pi(r)}t=t.sibling}}function el(t,r,s){for(s=s&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var u=r.alternate,p=t,y=r,S=y.flags;switch(y.tag){case 0:case 11:case 15:el(p,y,s),so(4,y);break;case 1:if(el(p,y,s),u=y,p=u.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(ce){Zt(u,u.return,ce)}if(u=y,p=u.updateQueue,p!==null){var M=u.stateNode;try{var G=p.shared.hiddenCallbacks;if(G!==null)for(p.shared.hiddenCallbacks=null,p=0;p<G.length;p++)qp(G[p],M)}catch(ce){Zt(u,u.return,ce)}}s&&S&64&&e1(y),oo(y,y.return);break;case 27:a1(y);case 26:case 5:el(p,y,s),s&&u===null&&S&4&&n1(y),oo(y,y.return);break;case 12:el(p,y,s);break;case 31:el(p,y,s),s&&S&4&&c1(p,y);break;case 13:el(p,y,s),s&&S&4&&u1(p,y);break;case 22:y.memoizedState===null&&el(p,y,s),oo(y,y.return);break;case 30:break;default:el(p,y,s)}r=r.sibling}}function vf(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&&Vs(s))}function wf(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&Vs(t))}function da(t,r,s,u){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)h1(t,r,s,u),r=r.sibling}function h1(t,r,s,u){var p=r.flags;switch(r.tag){case 0:case 11:case 15:da(t,r,s,u),p&2048&&so(9,r);break;case 1:da(t,r,s,u);break;case 3:da(t,r,s,u),p&2048&&(t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&Vs(t)));break;case 12:if(p&2048){da(t,r,s,u),t=r.stateNode;try{var y=r.memoizedProps,S=y.id,M=y.onPostCommit;typeof M=="function"&&M(S,r.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(G){Zt(r,r.return,G)}}else da(t,r,s,u);break;case 31:da(t,r,s,u);break;case 13:da(t,r,s,u);break;case 23:break;case 22:y=r.stateNode,S=r.alternate,r.memoizedState!==null?y._visibility&2?da(t,r,s,u):co(t,r):y._visibility&2?da(t,r,s,u):(y._visibility|=2,ns(t,r,s,u,(r.subtreeFlags&10256)!==0||!1)),p&2048&&vf(S,r);break;case 24:da(t,r,s,u),p&2048&&wf(r.alternate,r);break;default:da(t,r,s,u)}}function ns(t,r,s,u,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var y=t,S=r,M=s,G=u,ce=S.flags;switch(S.tag){case 0:case 11:case 15:ns(y,S,M,G,p),so(8,S);break;case 23:break;case 22:var ge=S.stateNode;S.memoizedState!==null?ge._visibility&2?ns(y,S,M,G,p):co(y,S):(ge._visibility|=2,ns(y,S,M,G,p)),p&&ce&2048&&vf(S.alternate,S);break;case 24:ns(y,S,M,G,p),p&&ce&2048&&wf(S.alternate,S);break;default:ns(y,S,M,G,p)}r=r.sibling}}function co(t,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var s=t,u=r,p=u.flags;switch(u.tag){case 22:co(s,u),p&2048&&vf(u.alternate,u);break;case 24:co(s,u),p&2048&&wf(u.alternate,u);break;default:co(s,u)}r=r.sibling}}var uo=8192;function rs(t,r,s){if(t.subtreeFlags&uo)for(t=t.child;t!==null;)m1(t,r,s),t=t.sibling}function m1(t,r,s){switch(t.tag){case 26:rs(t,r,s),t.flags&uo&&t.memoizedState!==null&&iw(s,ua,t.memoizedState,t.memoizedProps);break;case 5:rs(t,r,s);break;case 3:case 4:var u=ua;ua=ru(t.stateNode.containerInfo),rs(t,r,s),ua=u;break;case 22:t.memoizedState===null&&(u=t.alternate,u!==null&&u.memoizedState!==null?(u=uo,uo=16777216,rs(t,r,s),uo=u):rs(t,r,s));break;default:rs(t,r,s)}}function p1(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 fo(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var s=0;s<r.length;s++){var u=r[s];Xn=u,g1(u,t)}p1(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)x1(t),t=t.sibling}function x1(t){switch(t.tag){case 0:case 11:case 15:fo(t),t.flags&2048&&Cl(9,t,t.return);break;case 3:fo(t);break;case 12:fo(t);break;case 22:var r=t.stateNode;t.memoizedState!==null&&r._visibility&2&&(t.return===null||t.return.tag!==13)?(r._visibility&=-3,Yc(t)):fo(t);break;default:fo(t)}}function Yc(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var s=0;s<r.length;s++){var u=r[s];Xn=u,g1(u,t)}p1(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:Cl(8,r,r.return),Yc(r);break;case 22:s=r.stateNode,s._visibility&2&&(s._visibility&=-3,Yc(r));break;default:Yc(r)}t=t.sibling}}function g1(t,r){for(;Xn!==null;){var s=Xn;switch(s.tag){case 0:case 11:case 15:Cl(8,s,r);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var u=s.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Vs(s.memoizedState.cache)}if(u=s.child,u!==null)u.return=s,Xn=u;else e:for(s=t;Xn!==null;){u=Xn;var p=u.sibling,y=u.return;if(s1(u),u===s){Xn=null;break e}if(p!==null){p.return=y,Xn=p;break e}Xn=y}}}var w2={getCacheForType:function(t){var r=Pn(Rn),s=r.data.get(t);return s===void 0&&(s=t(),r.data.set(t,s)),s},cacheSignal:function(){return Pn(Rn).controller.signal}},k2=typeof WeakMap=="function"?WeakMap:Map,Xt=0,cn=null,At=null,Ft=0,Qt=0,zr=null,Nl=!1,as=!1,kf=!1,tl=0,Nn=0,El=0,xi=0,jf=0,_r=0,ls=0,ho=null,br=null,Sf=!1,Xc=0,y1=0,Wc=1/0,Gc=null,Al=null,In=0,Dl=null,is=null,nl=0,Cf=0,Nf=null,b1=null,mo=0,Ef=null;function Br(){return(Xt&2)!==0&&Ft!==0?Ft&-Ft:q.T!==null?Mf():Ze()}function v1(){if(_r===0)if((Ft&536870912)===0||_t){var t=Et;Et<<=1,(Et&3932160)===0&&(Et=262144),_r=t}else _r=536870912;return t=Rr.current,t!==null&&(t.flags|=32),_r}function vr(t,r,s){(t===cn&&(Qt===2||Qt===9)||t.cancelPendingCommit!==null)&&(ss(t,0),Tl(t,Ft,_r,!1)),ke(t,s),((Xt&2)===0||t!==cn)&&(t===cn&&((Xt&2)===0&&(xi|=s),Nn===4&&Tl(t,Ft,_r,!1)),Sa(t))}function w1(t,r,s){if((Xt&6)!==0)throw Error(i(327));var u=!s&&(r&127)===0&&(r&t.expiredLanes)===0||ee(t,r),p=u?C2(t,r):Df(t,r,!0),y=u;do{if(p===0){as&&!u&&Tl(t,r,0,!1);break}else{if(s=t.current.alternate,y&&!j2(s)){p=Df(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 M=t;p=ho;var G=M.current.memoizedState.isDehydrated;if(G&&(ss(M,S).flags|=256),S=Df(M,S,!1),S!==2){if(kf&&!G){M.errorRecoveryDisabledLanes|=y,xi|=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){ss(t,0),Tl(t,r,0,!0);break}e:{switch(u=t,y=p,y){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:Tl(u,r,_r,!Nl);break e;case 2:br=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(p=Xc+300-be(),10<p)){if(Tl(u,r,_r,!Nl),En(u,0,!0)!==0)break e;nl=r,u.timeoutHandle=Z1(k1.bind(null,u,s,br,Gc,Sf,r,_r,xi,ls,Nl,y,"Throttled",-0,0),p);break e}k1(u,s,br,Gc,Sf,r,_r,xi,ls,Nl,y,null,-0,0)}}break}while(!0);Sa(t)}function k1(t,r,s,u,p,y,S,M,G,ce,ge,Ce,ue,he){if(t.timeoutHandle=-1,Ce=r.subtreeFlags,Ce&8192||(Ce&16785408)===16785408){Ce={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Vn},m1(r,y,Ce);var Ge=(y&62914560)===y?Xc-be():(y&4194048)===y?y1-be():0;if(Ge=sw(Ce,Ge),Ge!==null){nl=y,t.cancelPendingCommit=Ge(T1.bind(null,t,r,y,s,u,p,S,M,G,ge,Ce,null,ue,he)),Tl(t,y,S,!ce);return}}T1(t,r,y,s,u,p,S,M,G)}function j2(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 u=0;u<s.length;u++){var p=s[u],y=p.getSnapshot;p=p.value;try{if(!Tr(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 Tl(t,r,s,u){r&=~jf,r&=~xi,t.suspendedLanes|=r,t.pingedLanes&=~r,u&&(t.warmLanes|=r),u=t.expirationTimes;for(var p=r;0<p;){var y=31-Ke(p),S=1<<y;u[y]=-1,p&=~S}s!==0&&jn(t,s,r)}function Vc(){return(Xt&6)===0?(po(0),!1):!0}function Af(){if(At!==null){if(Qt===0)var t=At.return;else t=At,Xa=si=null,qd(t),Qi=null,Ps=0,t=At;for(;t!==null;)Jx(t.alternate,t),t=t.return;At=null}}function ss(t,r){var s=t.timeoutHandle;s!==-1&&(t.timeoutHandle=-1,q2(s)),s=t.cancelPendingCommit,s!==null&&(t.cancelPendingCommit=null,s()),nl=0,Af(),cn=t,At=s=qa(t.current,null),Ft=r,Qt=0,zr=null,Nl=!1,as=ee(t,r),kf=!1,ls=_r=jf=xi=El=Nn=0,br=ho=null,Sf=!1,(r&8)!==0&&(r|=r&32);var u=t.entangledLanes;if(u!==0)for(t=t.entanglements,u&=r;0<u;){var p=31-Ke(u),y=1<<p;r|=t[p],u&=~y}return tl=r,pc(),s}function j1(t,r){gt=null,q.H=ao,r===Pi||r===jc?(r=Lp(),Qt=3):r===Fd?(r=Lp(),Qt=4):Qt=r===lf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,zr=r,At===null&&(Nn=1,Oc(t,Gr(r,t.current)))}function S1(){var t=Rr.current;return t===null?!0:(Ft&4194048)===Ft?Qr===null:(Ft&62914560)===Ft||(Ft&536870912)!==0?t===Qr:!1}function C1(){var t=q.H;return q.H=ao,t===null?ao:t}function N1(){var t=q.A;return q.A=w2,t}function Kc(){Nn=4,Nl||(Ft&4194048)!==Ft&&Rr.current!==null||(as=!0),(El&134217727)===0&&(xi&134217727)===0||cn===null||Tl(cn,Ft,_r,!1)}function Df(t,r,s){var u=Xt;Xt|=2;var p=C1(),y=N1();(cn!==t||Ft!==r)&&(Gc=null,ss(t,r)),r=!1;var S=Nn;e:do try{if(Qt!==0&&At!==null){var M=At,G=zr;switch(Qt){case 8:Af(),S=6;break e;case 3:case 2:case 9:case 6:Rr.current===null&&(r=!0);var ce=Qt;if(Qt=0,zr=null,os(t,M,G,ce),s&&as){S=0;break e}break;default:ce=Qt,Qt=0,zr=null,os(t,M,G,ce)}}S2(),S=Nn;break}catch(ge){j1(t,ge)}while(!0);return r&&t.shellSuspendCounter++,Xa=si=null,Xt=u,q.H=p,q.A=y,At===null&&(cn=null,Ft=0,pc()),S}function S2(){for(;At!==null;)E1(At)}function C2(t,r){var s=Xt;Xt|=2;var u=C1(),p=N1();cn!==t||Ft!==r?(Gc=null,Wc=be()+500,ss(t,r)):as=ee(t,r);e:do try{if(Qt!==0&&At!==null){r=At;var y=zr;t:switch(Qt){case 1:Qt=0,zr=null,os(t,r,y,1);break;case 2:case 9:if(Op(y)){Qt=0,zr=null,A1(r);break}r=function(){Qt!==2&&Qt!==9||cn!==t||(Qt=7),Sa(t)},y.then(r,r);break e;case 3:Qt=7;break e;case 4:Qt=5;break e;case 7:Op(y)?(Qt=0,zr=null,A1(r)):(Qt=0,zr=null,os(t,r,y,7));break;case 5:var S=null;switch(At.tag){case 26:S=At.memoizedState;case 5:case 27:var M=At;if(S?h0(S):M.stateNode.complete){Qt=0,zr=null;var G=M.sibling;if(G!==null)At=G;else{var ce=M.return;ce!==null?(At=ce,Pc(ce)):At=null}break t}}Qt=0,zr=null,os(t,r,y,5);break;case 6:Qt=0,zr=null,os(t,r,y,6);break;case 8:Af(),Nn=6;break e;default:throw Error(i(462))}}N2();break}catch(ge){j1(t,ge)}while(!0);return Xa=si=null,q.H=u,q.A=p,Xt=s,At!==null?0:(cn=null,Ft=0,pc(),Nn)}function N2(){for(;At!==null&&!zt();)E1(At)}function E1(t){var r=Qx(t.alternate,t,tl);t.memoizedProps=t.pendingProps,r===null?Pc(t):At=r}function A1(t){var r=t,s=r.alternate;switch(r.tag){case 15:case 0:r=Xx(s,r,r.pendingProps,r.type,void 0,Ft);break;case 11:r=Xx(s,r,r.pendingProps,r.type.render,r.ref,Ft);break;case 5:qd(r);default:Jx(s,r),r=At=Np(r,tl),r=Qx(s,r,tl)}t.memoizedProps=t.pendingProps,r===null?Pc(t):At=r}function os(t,r,s,u){Xa=si=null,qd(r),Qi=null,Ps=0;var p=r.return;try{if(m2(t,p,r,s,Ft)){Nn=1,Oc(t,Gr(s,t.current)),At=null;return}}catch(y){if(p!==null)throw At=p,y;Nn=1,Oc(t,Gr(s,t.current)),At=null;return}r.flags&32768?(_t||u===1?t=!0:as||(Ft&536870912)!==0?t=!1:(Nl=t=!0,(u===2||u===9||u===3||u===6)&&(u=Rr.current,u!==null&&u.tag===13&&(u.flags|=16384))),D1(r,t)):Pc(r)}function Pc(t){var r=t;do{if((r.flags&32768)!==0){D1(r,Nl);return}t=r.return;var s=g2(r.alternate,r,tl);if(s!==null){At=s;return}if(r=r.sibling,r!==null){At=r;return}At=r=t}while(r!==null);Nn===0&&(Nn=5)}function D1(t,r){do{var s=y2(t.alternate,t);if(s!==null){s.flags&=32767,At=s;return}if(s=t.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!r&&(t=t.sibling,t!==null)){At=t;return}At=t=s}while(t!==null);Nn=6,At=null}function T1(t,r,s,u,p,y,S,M,G){t.cancelPendingCommit=null;do Qc();while(In!==0);if((Xt&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(y=r.lanes|r.childLanes,y|=xd,St(t,s,y,S,M,G),t===cn&&(At=cn=null,Ft=0),is=r,Dl=t,nl=s,Cf=y,Nf=p,b1=u,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,T2(Ee,function(){return _1(),null})):(t.callbackNode=null,t.callbackPriority=0),u=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||u){u=q.T,q.T=null,p=ie.p,ie.p=2,S=Xt,Xt|=4;try{b2(t,r,s)}finally{Xt=S,ie.p=p,q.T=u}}In=1,F1(),R1(),M1()}}function F1(){if(In===1){In=0;var t=Dl,r=is,s=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||s){s=q.T,q.T=null;var u=ie.p;ie.p=2;var p=Xt;Xt|=4;try{d1(r,t);var y=Hf,S=gp(t.containerInfo),M=y.focusedElem,G=y.selectionRange;if(S!==M&&M&&M.ownerDocument&&xp(M.ownerDocument.documentElement,M)){if(G!==null&&dd(M)){var ce=G.start,ge=G.end;if(ge===void 0&&(ge=ce),"selectionStart"in M)M.selectionStart=ce,M.selectionEnd=Math.min(ge,M.value.length);else{var Ce=M.ownerDocument||document,ue=Ce&&Ce.defaultView||window;if(ue.getSelection){var he=ue.getSelection(),Ge=M.textContent.length,ut=Math.min(G.start,Ge),an=G.end===void 0?ut:Math.min(G.end,Ge);!he.extend&&ut>an&&(S=an,an=ut,ut=S);var re=pp(M,ut),J=pp(M,an);if(re&&J&&(he.rangeCount!==1||he.anchorNode!==re.node||he.anchorOffset!==re.offset||he.focusNode!==J.node||he.focusOffset!==J.offset)){var se=Ce.createRange();se.setStart(re.node,re.offset),he.removeAllRanges(),ut>an?(he.addRange(se),he.extend(J.node,J.offset)):(se.setEnd(J.node,J.offset),he.addRange(se))}}}}for(Ce=[],he=M;he=he.parentNode;)he.nodeType===1&&Ce.push({element:he,left:he.scrollLeft,top:he.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;M<Ce.length;M++){var we=Ce[M];we.element.scrollLeft=we.left,we.element.scrollTop=we.top}}cu=!!If,Hf=If=null}finally{Xt=p,ie.p=u,q.T=s}}t.current=r,In=2}}function R1(){if(In===2){In=0;var t=Dl,r=is,s=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||s){s=q.T,q.T=null;var u=ie.p;ie.p=2;var p=Xt;Xt|=4;try{i1(t,r.alternate,r)}finally{Xt=p,ie.p=u,q.T=s}}In=3}}function M1(){if(In===4||In===3){In=0,fe();var t=Dl,r=is,s=nl,u=b1;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?In=5:(In=0,is=Dl=null,z1(t,t.pendingLanes));var p=t.pendingLanes;if(p===0&&(Al=null),Pe(s),r=r.stateNode,Ye&&typeof Ye.onCommitFiberRoot=="function")try{Ye.onCommitFiberRoot(Le,r,void 0,(r.current.flags&128)===128)}catch{}if(u!==null){r=q.T,p=ie.p,ie.p=2,q.T=null;try{for(var y=t.onRecoverableError,S=0;S<u.length;S++){var M=u[S];y(M.value,{componentStack:M.stack})}}finally{q.T=r,ie.p=p}}(nl&3)!==0&&Qc(),Sa(t),p=t.pendingLanes,(s&261930)!==0&&(p&42)!==0?t===Ef?mo++:(mo=0,Ef=t):mo=0,po(0)}}function z1(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,Vs(r)))}function Qc(){return F1(),R1(),M1(),_1()}function _1(){if(In!==5)return!1;var t=Dl,r=Cf;Cf=0;var s=Pe(nl),u=q.T,p=ie.p;try{ie.p=32>s?32:s,q.T=null,s=Nf,Nf=null;var y=Dl,S=nl;if(In=0,is=Dl=null,nl=0,(Xt&6)!==0)throw Error(i(331));var M=Xt;if(Xt|=4,x1(y.current),h1(y,y.current,S,s),Xt=M,po(0,!1),Ye&&typeof Ye.onPostCommitFiberRoot=="function")try{Ye.onPostCommitFiberRoot(Le,y)}catch{}return!0}finally{ie.p=p,q.T=u,z1(t,r)}}function B1(t,r,s){r=Gr(s,r),r=af(t.stateNode,r,2),t=kl(t,r,2),t!==null&&(ke(t,2),Sa(t))}function Zt(t,r,s){if(t.tag===3)B1(t,t,s);else for(;r!==null;){if(r.tag===3){B1(r,t,s);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Al===null||!Al.has(u))){t=Gr(s,t),s=Ox(2),u=kl(r,s,2),u!==null&&($x(s,u,r,t),ke(u,2),Sa(u));break}}r=r.return}}function Tf(t,r,s){var u=t.pingCache;if(u===null){u=t.pingCache=new k2;var p=new Set;u.set(r,p)}else p=u.get(r),p===void 0&&(p=new Set,u.set(r,p));p.has(s)||(kf=!0,p.add(s),t=E2.bind(null,t,r,s),r.then(t,t))}function E2(t,r,s){var u=t.pingCache;u!==null&&u.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,cn===t&&(Ft&s)===s&&(Nn===4||Nn===3&&(Ft&62914560)===Ft&&300>be()-Xc?(Xt&2)===0&&ss(t,0):jf|=s,ls===Ft&&(ls=0)),Sa(t)}function O1(t,r){r===0&&(r=lt()),t=ai(t,r),t!==null&&(ke(t,r),Sa(t))}function A2(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),O1(t,s)}function D2(t,r){var s=0;switch(t.tag){case 31:case 13:var u=t.stateNode,p=t.memoizedState;p!==null&&(s=p.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(i(314))}u!==null&&u.delete(r),O1(t,s)}function T2(t,r){return at(t,r)}var Zc=null,cs=null,Ff=!1,Jc=!1,Rf=!1,Fl=0;function Sa(t){t!==cs&&t.next===null&&(cs===null?Zc=cs=t:cs=cs.next=t),Jc=!0,Ff||(Ff=!0,R2())}function po(t,r){if(!Rf&&Jc){Rf=!0;do for(var s=!1,u=Zc;u!==null;){if(t!==0){var p=u.pendingLanes;if(p===0)var y=0;else{var S=u.suspendedLanes,M=u.pingedLanes;y=(1<<31-Ke(42|t)+1)-1,y&=p&~(S&~M),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(s=!0,H1(u,y))}else y=Ft,y=En(u,u===cn?y:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(y&3)===0||ee(u,y)||(s=!0,H1(u,y));u=u.next}while(s);Rf=!1}}function F2(){$1()}function $1(){Jc=Ff=!1;var t=0;Fl!==0&&U2()&&(t=Fl);for(var r=be(),s=null,u=Zc;u!==null;){var p=u.next,y=L1(u,r);y===0?(u.next=null,s===null?Zc=p:s.next=p,p===null&&(cs=s)):(s=u,(t!==0||(y&3)!==0)&&(Jc=!0)),u=p}In!==0&&In!==5||po(t),Fl!==0&&(Fl=0)}function L1(t,r){for(var s=t.suspendedLanes,u=t.pingedLanes,p=t.expirationTimes,y=t.pendingLanes&-62914561;0<y;){var S=31-Ke(y),M=1<<S,G=p[S];G===-1?((M&s)===0||(M&u)!==0)&&(p[S]=He(M,r)):G<=r&&(t.expiredLanes|=M),y&=~M}if(r=cn,s=Ft,s=En(t,t===r?s:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),u=t.callbackNode,s===0||t===r&&(Qt===2||Qt===9)||t.cancelPendingCommit!==null)return u!==null&&u!==null&&pt(u),t.callbackNode=null,t.callbackPriority=0;if((s&3)===0||ee(t,s)){if(r=s&-s,r===t.callbackPriority)return r;switch(u!==null&&pt(u),Pe(s)){case 2:case 8:s=Z;break;case 32:s=Ee;break;case 268435456:s=Ae;break;default:s=Ee}return u=I1.bind(null,t),s=at(s,u),t.callbackPriority=r,t.callbackNode=s,r}return u!==null&&u!==null&&pt(u),t.callbackPriority=2,t.callbackNode=null,2}function I1(t,r){if(In!==0&&In!==5)return t.callbackNode=null,t.callbackPriority=0,null;var s=t.callbackNode;if(Qc()&&t.callbackNode!==s)return null;var u=Ft;return u=En(t,t===cn?u:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),u===0?null:(w1(t,u,r),L1(t,be()),t.callbackNode!=null&&t.callbackNode===s?I1.bind(null,t):null)}function H1(t,r){if(Qc())return null;w1(t,r,!0)}function R2(){Y2(function(){(Xt&6)!==0?at(Q,F2):$1()})}function Mf(){if(Fl===0){var t=Vi;t===0&&(t=Vt,Vt<<=1,(Vt&261888)===0&&(Vt=256)),Fl=t}return Fl}function U1(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Ar(""+t)}function q1(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 M2(t,r,s,u,p){if(r==="submit"&&s&&s.stateNode===p){var y=U1((p[mn]||null).action),S=u.submitter;S&&(r=(r=S[mn]||null)?U1(r.formAction):S.getAttribute("formAction"),r!==null&&(y=r,S=null));var M=new Xr("action","action",null,u,p);t.push({event:M,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Fl!==0){var G=S?q1(p,S):new FormData(p);Zd(s,{pending:!0,data:G,method:p.method,action:y},null,G)}}else typeof y=="function"&&(M.preventDefault(),G=S?q1(p,S):new FormData(p),Zd(s,{pending:!0,data:G,method:p.method,action:y},y,G))},currentTarget:p}]})}}for(var zf=0;zf<pd.length;zf++){var _f=pd[zf],z2=_f.toLowerCase(),_2=_f[0].toUpperCase()+_f.slice(1);ca(z2,"on"+_2)}ca(vp,"onAnimationEnd"),ca(wp,"onAnimationIteration"),ca(kp,"onAnimationStart"),ca("dblclick","onDoubleClick"),ca("focusin","onFocus"),ca("focusout","onBlur"),ca(Qv,"onTransitionRun"),ca(Zv,"onTransitionStart"),ca(Jv,"onTransitionCancel"),ca(jp,"onTransitionEnd"),pa("onMouseEnter",["mouseout","mouseover"]),pa("onMouseLeave",["mouseout","mouseover"]),pa("onPointerEnter",["pointerout","pointerover"]),pa("onPointerLeave",["pointerout","pointerover"]),fr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),fr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),fr("onBeforeInput",["compositionend","keypress","textInput","paste"]),fr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xo="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(" "),B2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(xo));function Y1(t,r){r=(r&4)!==0;for(var s=0;s<t.length;s++){var u=t[s],p=u.event;u=u.listeners;e:{var y=void 0;if(r)for(var S=u.length-1;0<=S;S--){var M=u[S],G=M.instance,ce=M.currentTarget;if(M=M.listener,G!==y&&p.isPropagationStopped())break e;y=M,p.currentTarget=ce;try{y(p)}catch(ge){mc(ge)}p.currentTarget=null,y=G}else for(S=0;S<u.length;S++){if(M=u[S],G=M.instance,ce=M.currentTarget,M=M.listener,G!==y&&p.isPropagationStopped())break e;y=M,p.currentTarget=ce;try{y(p)}catch(ge){mc(ge)}p.currentTarget=null,y=G}}}}function Dt(t,r){var s=r[Pl];s===void 0&&(s=r[Pl]=new Set);var u=t+"__bubble";s.has(u)||(X1(r,t,2,!1),s.add(u))}function Bf(t,r,s){var u=0;r&&(u|=4),X1(s,t,u,r)}var eu="_reactListening"+Math.random().toString(36).slice(2);function Of(t){if(!t[eu]){t[eu]=!0,Sr.forEach(function(s){s!=="selectionchange"&&(B2.has(s)||Bf(s,!1,t),Bf(s,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[eu]||(r[eu]=!0,Bf("selectionchange",!1,r))}}function X1(t,r,s,u){switch(v0(r)){case 2:var p=uw;break;case 8:p=dw;break;default:p=Zf}s=p.bind(null,r,s,t),p=void 0,!_s||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),u?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 $f(t,r,s,u,p){var y=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var S=u.tag;if(S===3||S===4){var M=u.stateNode.containerInfo;if(M===p)break;if(S===4)for(S=u.return;S!==null;){var G=S.tag;if((G===3||G===4)&&S.stateNode.containerInfo===p)return;S=S.return}for(;M!==null;){if(S=fl(M),S===null)return;if(G=S.tag,G===5||G===6||G===26||G===27){u=y=S;continue e}M=M.parentNode}}u=u.return}nr(function(){var ce=y,ge=Mi(s),Ce=[];e:{var ue=Sp.get(t);if(ue!==void 0){var he=Xr,Ge=t;switch(t){case"keypress":if(ya(s)===0)break e;case"keydown":case"keyup":he=cc;break;case"focusin":Ge="focus",he=Oi;break;case"focusout":Ge="blur",he=Oi;break;case"beforeblur":case"afterblur":he=Oi;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":he=$s;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":he=ac;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":he=fc;break;case vp:case wp:case kp:he=Ua;break;case jp:he=P;break;case"scroll":case"scrollend":he=ld;break;case"wheel":he=pe;break;case"copy":case"cut":case"paste":he=sd;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":he=Hs;break;case"toggle":case"beforetoggle":he=Ue}var ut=(r&4)!==0,an=!ut&&(t==="scroll"||t==="scrollend"),re=ut?ue!==null?ue+"Capture":null:ue;ut=[];for(var J=ce,se;J!==null;){var we=J;if(se=we.stateNode,we=we.tag,we!==5&&we!==26&&we!==27||se===null||re===null||(we=sa(J,re),we!=null&&ut.push(go(J,we,se))),an)break;J=J.return}0<ut.length&&(ue=new he(ue,Ge,null,s,ge),Ce.push({event:ue,listeners:ut}))}}if((r&7)===0){e:{if(ue=t==="mouseover"||t==="pointerover",he=t==="mouseout"||t==="pointerout",ue&&s!==Ms&&(Ge=s.relatedTarget||s.fromElement)&&(fl(Ge)||Ge[Ur]))break e;if((he||ue)&&(ue=ge.window===ge?ge:(ue=ge.ownerDocument)?ue.defaultView||ue.parentWindow:window,he?(Ge=s.relatedTarget||s.toElement,he=ce,Ge=Ge?fl(Ge):null,Ge!==null&&(an=c(Ge),ut=Ge.tag,Ge!==an||ut!==5&&ut!==27&&ut!==6)&&(Ge=null)):(he=null,Ge=ce),he!==Ge)){if(ut=$s,we="onMouseLeave",re="onMouseEnter",J="mouse",(t==="pointerout"||t==="pointerover")&&(ut=Hs,we="onPointerLeave",re="onPointerEnter",J="pointer"),an=he==null?ue:Ba(he),se=Ge==null?ue:Ba(Ge),ue=new ut(we,J+"leave",he,s,ge),ue.target=an,ue.relatedTarget=se,we=null,fl(ge)===ce&&(ut=new ut(re,J+"enter",Ge,s,ge),ut.target=se,ut.relatedTarget=an,we=ut),an=we,he&&Ge)t:{for(ut=O2,re=he,J=Ge,se=0,we=re;we;we=ut(we))se++;we=0;for(var nt=J;nt;nt=ut(nt))we++;for(;0<se-we;)re=ut(re),se--;for(;0<we-se;)J=ut(J),we--;for(;se--;){if(re===J||J!==null&&re===J.alternate){ut=re;break t}re=ut(re),J=ut(J)}ut=null}else ut=null;he!==null&&W1(Ce,ue,he,ut,!1),Ge!==null&&an!==null&&W1(Ce,an,Ge,ut,!0)}}e:{if(ue=ce?Ba(ce):window,he=ue.nodeName&&ue.nodeName.toLowerCase(),he==="select"||he==="input"&&ue.type==="file")var Ht=cp;else if(sp(ue))if(up)Ht=Vv;else{Ht=Wv;var Qe=Xv}else he=ue.nodeName,!he||he.toLowerCase()!=="input"||ue.type!=="checkbox"&&ue.type!=="radio"?ce&&Jt(ce.elementType)&&(Ht=cp):Ht=Gv;if(Ht&&(Ht=Ht(t,ce))){op(Ce,Ht,s,ge);break e}Qe&&Qe(t,ue,ce),t==="focusout"&&ce&&ue.type==="number"&&ce.memoizedProps.value!=null&&Fi(ue,"number",ue.value)}switch(Qe=ce?Ba(ce):window,t){case"focusin":(sp(Qe)||Qe.contentEditable==="true")&&(Ii=Qe,fd=ce,Xs=null);break;case"focusout":Xs=fd=Ii=null;break;case"mousedown":hd=!0;break;case"contextmenu":case"mouseup":case"dragend":hd=!1,yp(Ce,s,ge);break;case"selectionchange":if(Pv)break;case"keydown":case"keyup":yp(Ce,s,ge)}var wt;if(ot)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 Yt?Ct(t,s)&&(Rt="onCompositionEnd"):t==="keydown"&&s.keyCode===229&&(Rt="onCompositionStart");Rt&&(ft&&s.locale!=="ko"&&(Yt||Rt!=="onCompositionStart"?Rt==="onCompositionEnd"&&Yt&&(wt=_i()):(vt=ge,Bs="value"in vt?vt.value:vt.textContent,Yt=!0)),Qe=tu(ce,Rt),0<Qe.length&&(Rt=new Is(Rt,t,null,s,ge),Ce.push({event:Rt,listeners:Qe}),wt?Rt.data=wt:(wt=on(s),wt!==null&&(Rt.data=wt)))),(wt=ct?Fn(t,s):wn(t,s))&&(Rt=tu(ce,"onBeforeInput"),0<Rt.length&&(Qe=new Is("onBeforeInput","beforeinput",null,s,ge),Ce.push({event:Qe,listeners:Rt}),Qe.data=wt)),M2(Ce,t,ce,s,ge)}Y1(Ce,r)})}function go(t,r,s){return{instance:t,listener:r,currentTarget:s}}function tu(t,r){for(var s=r+"Capture",u=[];t!==null;){var p=t,y=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||y===null||(p=sa(t,s),p!=null&&u.unshift(go(t,p,y)),p=sa(t,r),p!=null&&u.push(go(t,p,y))),t.tag===3)return u;t=t.return}return[]}function O2(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function W1(t,r,s,u,p){for(var y=r._reactName,S=[];s!==null&&s!==u;){var M=s,G=M.alternate,ce=M.stateNode;if(M=M.tag,G!==null&&G===u)break;M!==5&&M!==26&&M!==27||ce===null||(G=ce,p?(ce=sa(s,y),ce!=null&&S.unshift(go(s,ce,G))):p||(ce=sa(s,y),ce!=null&&S.push(go(s,ce,G)))),s=s.return}S.length!==0&&t.push({event:r,listeners:S})}var $2=/\r\n?/g,L2=/\u0000|\uFFFD/g;function G1(t){return(typeof t=="string"?t:""+t).replace($2,`
|
|
49
|
+
`).replace(L2,"")}function V1(t,r){return r=G1(r),G1(t)===r}function rn(t,r,s,u,p,y){switch(s){case"children":typeof u=="string"?r==="body"||r==="textarea"&&u===""||Er(t,u):(typeof u=="number"||typeof u=="bigint")&&r!=="body"&&Er(t,""+u);break;case"className":Ql(t,"class",u);break;case"tabIndex":Ql(t,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Ql(t,s,u);break;case"style":Ln(t,u,y);break;case"data":if(r!=="object"){Ql(t,"data",u);break}case"src":case"href":if(u===""&&(r!=="a"||s!=="href")){t.removeAttribute(s);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){t.removeAttribute(s);break}u=Ar(""+u),t.setAttribute(s,u);break;case"action":case"formAction":if(typeof u=="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"&&rn(t,r,"name",p.name,p,null),rn(t,r,"formEncType",p.formEncType,p,null),rn(t,r,"formMethod",p.formMethod,p,null),rn(t,r,"formTarget",p.formTarget,p,null)):(rn(t,r,"encType",p.encType,p,null),rn(t,r,"method",p.method,p,null),rn(t,r,"target",p.target,p,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){t.removeAttribute(s);break}u=Ar(""+u),t.setAttribute(s,u);break;case"onClick":u!=null&&(t.onclick=Vn);break;case"onScroll":u!=null&&Dt("scroll",t);break;case"onScrollEnd":u!=null&&Dt("scrollend",t);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(i(61));if(s=u.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"multiple":t.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":t.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){t.removeAttribute("xlink:href");break}s=Ar(""+u),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":u!=null&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(s,""+u):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":u&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(s,""):t.removeAttribute(s);break;case"capture":case"download":u===!0?t.setAttribute(s,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(s,u):t.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?t.setAttribute(s,u):t.removeAttribute(s);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?t.removeAttribute(s):t.setAttribute(s,u);break;case"popover":Dt("beforetoggle",t),Dt("toggle",t),la(t,"popover",u);break;case"xlinkActuate":qr(t,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":qr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":qr(t,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":qr(t,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":qr(t,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":qr(t,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":qr(t,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":qr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":qr(t,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":la(t,"is",u);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=ga.get(s)||s,la(t,s,u))}}function Lf(t,r,s,u,p,y){switch(s){case"style":Ln(t,u,y);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(i(61));if(s=u.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"children":typeof u=="string"?Er(t,u):(typeof u=="number"||typeof u=="bigint")&&Er(t,""+u);break;case"onScroll":u!=null&&Dt("scroll",t);break;case"onScrollEnd":u!=null&&Dt("scrollend",t);break;case"onClick":u!=null&&(t.onclick=Vn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ec.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 u=="function")){typeof y!="function"&&y!==null&&(s in t?t[s]=null:t.hasAttribute(s)&&t.removeAttribute(s)),t.addEventListener(r,u,p);break e}s in t?t[s]=u:u===!0?t.setAttribute(s,""):la(t,s,u)}}}function Zn(t,r,s){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Dt("error",t),Dt("load",t);var u=!1,p=!1,y;for(y in s)if(s.hasOwnProperty(y)){var S=s[y];if(S!=null)switch(y){case"src":u=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:rn(t,r,y,S,s,null)}}p&&rn(t,r,"srcSet",s.srcSet,s,null),u&&rn(t,r,"src",s.src,s,null);return;case"input":Dt("invalid",t);var M=y=S=p=null,G=null,ce=null;for(u in s)if(s.hasOwnProperty(u)){var ge=s[u];if(ge!=null)switch(u){case"name":p=ge;break;case"type":S=ge;break;case"checked":G=ge;break;case"defaultChecked":ce=ge;break;case"value":y=ge;break;case"defaultValue":M=ge;break;case"children":case"dangerouslySetInnerHTML":if(ge!=null)throw Error(i(137,r));break;default:rn(t,r,u,ge,s,null)}}$n(t,y,M,G,ce,S,p,!1);return;case"select":Dt("invalid",t),u=S=y=null;for(p in s)if(s.hasOwnProperty(p)&&(M=s[p],M!=null))switch(p){case"value":y=M;break;case"defaultValue":S=M;break;case"multiple":u=M;default:rn(t,r,p,M,s,null)}r=y,s=S,t.multiple=!!u,r!=null?pl(t,!!u,r,!1):s!=null&&pl(t,!!u,s,!0);return;case"textarea":Dt("invalid",t),y=p=u=null;for(S in s)if(s.hasOwnProperty(S)&&(M=s[S],M!=null))switch(S){case"value":u=M;break;case"defaultValue":p=M;break;case"children":y=M;break;case"dangerouslySetInnerHTML":if(M!=null)throw Error(i(91));break;default:rn(t,r,S,M,s,null)}Nr(t,u,p,y);return;case"option":for(G in s)if(s.hasOwnProperty(G)&&(u=s[G],u!=null))switch(G){case"selected":t.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:rn(t,r,G,u,s,null)}return;case"dialog":Dt("beforetoggle",t),Dt("toggle",t),Dt("cancel",t),Dt("close",t);break;case"iframe":case"object":Dt("load",t);break;case"video":case"audio":for(u=0;u<xo.length;u++)Dt(xo[u],t);break;case"image":Dt("error",t),Dt("load",t);break;case"details":Dt("toggle",t);break;case"embed":case"source":case"link":Dt("error",t),Dt("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(ce in s)if(s.hasOwnProperty(ce)&&(u=s[ce],u!=null))switch(ce){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:rn(t,r,ce,u,s,null)}return;default:if(Jt(r)){for(ge in s)s.hasOwnProperty(ge)&&(u=s[ge],u!==void 0&&Lf(t,r,ge,u,s,void 0));return}}for(M in s)s.hasOwnProperty(M)&&(u=s[M],u!=null&&rn(t,r,M,u,s,null))}function I2(t,r,s,u){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,M=null,G=null,ce=null,ge=null;for(he in s){var Ce=s[he];if(s.hasOwnProperty(he)&&Ce!=null)switch(he){case"checked":break;case"value":break;case"defaultValue":G=Ce;default:u.hasOwnProperty(he)||rn(t,r,he,null,u,Ce)}}for(var ue in u){var he=u[ue];if(Ce=s[ue],u.hasOwnProperty(ue)&&(he!=null||Ce!=null))switch(ue){case"type":y=he;break;case"name":p=he;break;case"checked":ce=he;break;case"defaultChecked":ge=he;break;case"value":S=he;break;case"defaultValue":M=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(i(137,r));break;default:he!==Ce&&rn(t,r,ue,he,u,Ce)}}Cr(t,S,M,G,ce,ge,y,p);return;case"select":he=S=M=ue=null;for(y in s)if(G=s[y],s.hasOwnProperty(y)&&G!=null)switch(y){case"value":break;case"multiple":he=G;default:u.hasOwnProperty(y)||rn(t,r,y,null,u,G)}for(p in u)if(y=u[p],G=s[p],u.hasOwnProperty(p)&&(y!=null||G!=null))switch(p){case"value":ue=y;break;case"defaultValue":M=y;break;case"multiple":S=y;default:y!==G&&rn(t,r,p,y,u,G)}r=M,s=S,u=he,ue!=null?pl(t,!!s,ue,!1):!!u!=!!s&&(r!=null?pl(t,!!s,r,!0):pl(t,!!s,s?[]:"",!1));return;case"textarea":he=ue=null;for(M in s)if(p=s[M],s.hasOwnProperty(M)&&p!=null&&!u.hasOwnProperty(M))switch(M){case"value":break;case"children":break;default:rn(t,r,M,null,u,p)}for(S in u)if(p=u[S],y=s[S],u.hasOwnProperty(S)&&(p!=null||y!=null))switch(S){case"value":ue=p;break;case"defaultValue":he=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(i(91));break;default:p!==y&&rn(t,r,S,p,u,y)}Ri(t,ue,he);return;case"option":for(var Ge in s)if(ue=s[Ge],s.hasOwnProperty(Ge)&&ue!=null&&!u.hasOwnProperty(Ge))switch(Ge){case"selected":t.selected=!1;break;default:rn(t,r,Ge,null,u,ue)}for(G in u)if(ue=u[G],he=s[G],u.hasOwnProperty(G)&&ue!==he&&(ue!=null||he!=null))switch(G){case"selected":t.selected=ue&&typeof ue!="function"&&typeof ue!="symbol";break;default:rn(t,r,G,ue,u,he)}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 ut in s)ue=s[ut],s.hasOwnProperty(ut)&&ue!=null&&!u.hasOwnProperty(ut)&&rn(t,r,ut,null,u,ue);for(ce in u)if(ue=u[ce],he=s[ce],u.hasOwnProperty(ce)&&ue!==he&&(ue!=null||he!=null))switch(ce){case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(i(137,r));break;default:rn(t,r,ce,ue,u,he)}return;default:if(Jt(r)){for(var an in s)ue=s[an],s.hasOwnProperty(an)&&ue!==void 0&&!u.hasOwnProperty(an)&&Lf(t,r,an,void 0,u,ue);for(ge in u)ue=u[ge],he=s[ge],!u.hasOwnProperty(ge)||ue===he||ue===void 0&&he===void 0||Lf(t,r,ge,ue,u,he);return}}for(var re in s)ue=s[re],s.hasOwnProperty(re)&&ue!=null&&!u.hasOwnProperty(re)&&rn(t,r,re,null,u,ue);for(Ce in u)ue=u[Ce],he=s[Ce],!u.hasOwnProperty(Ce)||ue===he||ue==null&&he==null||rn(t,r,Ce,ue,u,he)}function K1(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function H2(){if(typeof performance.getEntriesByType=="function"){for(var t=0,r=0,s=performance.getEntriesByType("resource"),u=0;u<s.length;u++){var p=s[u],y=p.transferSize,S=p.initiatorType,M=p.duration;if(y&&M&&K1(S)){for(S=0,M=p.responseEnd,u+=1;u<s.length;u++){var G=s[u],ce=G.startTime;if(ce>M)break;var ge=G.transferSize,Ce=G.initiatorType;ge&&K1(Ce)&&(G=G.responseEnd,S+=ge*(G<M?1:(M-ce)/(G-ce)))}if(--u,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 If=null,Hf=null;function nu(t){return t.nodeType===9?t:t.ownerDocument}function P1(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 Q1(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 Uf(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 qf=null;function U2(){var t=window.event;return t&&t.type==="popstate"?t===qf?!1:(qf=t,!0):(qf=null,!1)}var Z1=typeof setTimeout=="function"?setTimeout:void 0,q2=typeof clearTimeout=="function"?clearTimeout:void 0,J1=typeof Promise=="function"?Promise:void 0,Y2=typeof queueMicrotask=="function"?queueMicrotask:typeof J1<"u"?function(t){return J1.resolve(null).then(t).catch(X2)}:Z1;function X2(t){setTimeout(function(){throw t})}function Rl(t){return t==="head"}function e0(t,r){var s=r,u=0;do{var p=s.nextSibling;if(t.removeChild(s),p&&p.nodeType===8)if(s=p.data,s==="/$"||s==="/&"){if(u===0){t.removeChild(p),hs(r);return}u--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")u++;else if(s==="html")yo(t.ownerDocument.documentElement);else if(s==="head"){s=t.ownerDocument.head,yo(s);for(var y=s.firstChild;y;){var S=y.nextSibling,M=y.nodeName;y[ma]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&y.rel.toLowerCase()==="stylesheet"||s.removeChild(y),y=S}}else s==="body"&&yo(t.ownerDocument.body);s=p}while(s);hs(r)}function t0(t,r){var s=t;t=0;do{var u=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||""),u&&u.nodeType===8)if(s=u.data,s==="/$"){if(t===0)break;t--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||t++;s=u}while(s)}function Yf(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":Yf(s),aa(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}t.removeChild(s)}}function W2(t,r,s,u){for(;t.nodeType===1;){var p=s;if(t.nodeName.toLowerCase()!==r.toLowerCase()){if(!u&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(u){if(!t[ma])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=Zr(t.nextSibling),t===null)break}return null}function G2(t,r,s){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=Zr(t.nextSibling),t===null))return null;return t}function n0(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Zr(t.nextSibling),t===null))return null;return t}function Xf(t){return t.data==="$?"||t.data==="$~"}function Wf(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function V2(t,r){var s=t.ownerDocument;if(t.data==="$~")t._reactRetry=r;else if(t.data!=="$?"||s.readyState!=="loading")r();else{var u=function(){r(),s.removeEventListener("DOMContentLoaded",u)};s.addEventListener("DOMContentLoaded",u),t._reactRetry=u}}function Zr(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 Gf=null;function r0(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="/$"||s==="/&"){if(r===0)return Zr(t.nextSibling);r--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||r++}t=t.nextSibling}return null}function a0(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 l0(t,r,s){switch(r=nu(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 yo(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);aa(t)}var Jr=new Map,i0=new Set;function ru(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var rl=ie.d;ie.d={f:K2,r:P2,D:Q2,C:Z2,L:J2,m:ew,X:nw,S:tw,M:rw};function K2(){var t=rl.f(),r=Vc();return t||r}function P2(t){var r=hl(t);r!==null&&r.tag===5&&r.type==="form"?jx(r):rl.r(t)}var us=typeof document>"u"?null:document;function s0(t,r,s){var u=us;if(u&&typeof r=="string"&&r){var p=An(r);p='link[rel="'+t+'"][href="'+p+'"]',typeof s=="string"&&(p+='[crossorigin="'+s+'"]'),i0.has(p)||(i0.add(p),t={rel:t,crossOrigin:s,href:r},u.querySelector(p)===null&&(r=u.createElement("link"),Zn(r,"link",t),Sn(r),u.head.appendChild(r)))}}function Q2(t){rl.D(t),s0("dns-prefetch",t,null)}function Z2(t,r){rl.C(t,r),s0("preconnect",t,r)}function J2(t,r,s){rl.L(t,r,s);var u=us;if(u&&t&&r){var p='link[rel="preload"][as="'+An(r)+'"]';r==="image"&&s&&s.imageSrcSet?(p+='[imagesrcset="'+An(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(p+='[imagesizes="'+An(s.imageSizes)+'"]')):p+='[href="'+An(t)+'"]';var y=p;switch(r){case"style":y=ds(t);break;case"script":y=fs(t)}Jr.has(y)||(t=g({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),Jr.set(y,t),u.querySelector(p)!==null||r==="style"&&u.querySelector(bo(y))||r==="script"&&u.querySelector(vo(y))||(r=u.createElement("link"),Zn(r,"link",t),Sn(r),u.head.appendChild(r)))}}function ew(t,r){rl.m(t,r);var s=us;if(s&&t){var u=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+An(u)+'"][href="'+An(t)+'"]',y=p;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=fs(t)}if(!Jr.has(y)&&(t=g({rel:"modulepreload",href:t},r),Jr.set(y,t),s.querySelector(p)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(vo(y)))return}u=s.createElement("link"),Zn(u,"link",t),Sn(u),s.head.appendChild(u)}}}function tw(t,r,s){rl.S(t,r,s);var u=us;if(u&&t){var p=Oa(u).hoistableStyles,y=ds(t);r=r||"default";var S=p.get(y);if(!S){var M={loading:0,preload:null};if(S=u.querySelector(bo(y)))M.loading=5;else{t=g({rel:"stylesheet",href:t,"data-precedence":r},s),(s=Jr.get(y))&&Vf(t,s);var G=S=u.createElement("link");Sn(G),Zn(G,"link",t),G._p=new Promise(function(ce,ge){G.onload=ce,G.onerror=ge}),G.addEventListener("load",function(){M.loading|=1}),G.addEventListener("error",function(){M.loading|=2}),M.loading|=4,au(S,r,u)}S={type:"stylesheet",instance:S,count:1,state:M},p.set(y,S)}}}function nw(t,r){rl.X(t,r);var s=us;if(s&&t){var u=Oa(s).hoistableScripts,p=fs(t),y=u.get(p);y||(y=s.querySelector(vo(p)),y||(t=g({src:t,async:!0},r),(r=Jr.get(p))&&Kf(t,r),y=s.createElement("script"),Sn(y),Zn(y,"link",t),s.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(p,y))}}function rw(t,r){rl.M(t,r);var s=us;if(s&&t){var u=Oa(s).hoistableScripts,p=fs(t),y=u.get(p);y||(y=s.querySelector(vo(p)),y||(t=g({src:t,async:!0,type:"module"},r),(r=Jr.get(p))&&Kf(t,r),y=s.createElement("script"),Sn(y),Zn(y,"link",t),s.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(p,y))}}function o0(t,r,s,u){var p=(p=te.current)?ru(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=ds(s.href),s=Oa(p).hoistableStyles,u=s.get(r),u||(u={type:"style",instance:null,count:0,state:null},s.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){t=ds(s.href);var y=Oa(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(bo(t)))&&!y._p&&(S.instance=y,S.state.loading=5),Jr.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},Jr.set(t,s),y||aw(p,t,s,S.state))),r&&u===null)throw Error(i(528,""));return S}if(r&&u!==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=fs(s),s=Oa(p).hoistableScripts,u=s.get(r),u||(u={type:"script",instance:null,count:0,state:null},s.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,t))}}function ds(t){return'href="'+An(t)+'"'}function bo(t){return'link[rel="stylesheet"]['+t+"]"}function c0(t){return g({},t,{"data-precedence":t.precedence,precedence:null})}function aw(t,r,s,u){t.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=t.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Zn(r,"link",s),Sn(r),t.head.appendChild(r))}function fs(t){return'[src="'+An(t)+'"]'}function vo(t){return"script[async]"+t}function u0(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var u=t.querySelector('style[data-href~="'+An(s.href)+'"]');if(u)return r.instance=u,Sn(u),u;var p=g({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),Sn(u),Zn(u,"style",p),au(u,s.precedence,t),r.instance=u;case"stylesheet":p=ds(s.href);var y=t.querySelector(bo(p));if(y)return r.state.loading|=4,r.instance=y,Sn(y),y;u=c0(s),(p=Jr.get(p))&&Vf(u,p),y=(t.ownerDocument||t).createElement("link"),Sn(y);var S=y;return S._p=new Promise(function(M,G){S.onload=M,S.onerror=G}),Zn(y,"link",u),r.state.loading|=4,au(y,s.precedence,t),r.instance=y;case"script":return y=fs(s.src),(p=t.querySelector(vo(y)))?(r.instance=p,Sn(p),p):(u=s,(p=Jr.get(y))&&(u=g({},s),Kf(u,p)),t=t.ownerDocument||t,p=t.createElement("script"),Sn(p),Zn(p,"link",u),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&&(u=r.instance,r.state.loading|=4,au(u,s.precedence,t));return r.instance}function au(t,r,s){for(var u=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=u.length?u[u.length-1]:null,y=p,S=0;S<u.length;S++){var M=u[S];if(M.dataset.precedence===r)y=M;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 Vf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function Kf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var lu=null;function d0(t,r,s){if(lu===null){var u=new Map,p=lu=new Map;p.set(s,u)}else p=lu,u=p.get(s),u||(u=new Map,p.set(s,u));if(u.has(t))return u;for(u.set(t,null),s=s.getElementsByTagName(t),p=0;p<s.length;p++){var y=s[p];if(!(y[ma]||y[gn]||t==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var S=y.getAttribute(r)||"";S=t+S;var M=u.get(S);M?M.push(y):u.set(S,[y])}}return u}function f0(t,r,s){t=t.ownerDocument||t,t.head.insertBefore(s,r==="title"?t.querySelector("head > title"):null)}function lw(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 h0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function iw(t,r,s,u){if(s.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var p=ds(u.href),y=r.querySelector(bo(p));if(y){r=y._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=iu.bind(t),r.then(t,t)),s.state.loading|=4,s.instance=y,Sn(y);return}y=r.ownerDocument||r,u=c0(u),(p=Jr.get(p))&&Vf(u,p),y=y.createElement("link"),Sn(y);var S=y;S._p=new Promise(function(M,G){S.onload=M,S.onerror=G}),Zn(y,"link",u),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=iu.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var Pf=0;function sw(t,r){return t.stylesheets&&t.count===0&&ou(t,t.stylesheets),0<t.count||0<t.imgCount?function(s){var u=setTimeout(function(){if(t.stylesheets&&ou(t,t.stylesheets),t.unsuspend){var y=t.unsuspend;t.unsuspend=null,y()}},6e4+r);0<t.imgBytes&&Pf===0&&(Pf=62500*H2());var p=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&ou(t,t.stylesheets),t.unsuspend)){var y=t.unsuspend;t.unsuspend=null,y()}},(t.imgBytes>Pf?50:800)+r);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(p)}}:null}function iu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ou(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var su=null;function ou(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,su=new Map,r.forEach(ow,t),su=null,iu.call(t))}function ow(t,r){if(!(r.state.loading&4)){var s=su.get(t);if(s)var u=s.get(null);else{s=new Map,su.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),u=S)}u&&s.set(null,u)}p=r.instance,S=p.getAttribute("data-precedence"),y=s.get(S)||u,y===u&&s.set(null,p),s.set(S,p),this.count++,u=iu.bind(this),p.addEventListener("load",u),p.addEventListener("error",u),y?y.parentNode.insertBefore(p,y.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(p,t.firstChild)),r.state.loading|=4}}var wo={$$typeof:z,Provider:null,Consumer:null,_currentValue:de,_currentValue2:de,_threadCount:0};function cw(t,r,s,u,p,y,S,M,G){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=u,this.onUncaughtError=p,this.onCaughtError=y,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=G,this.incompleteTransitions=new Map}function m0(t,r,s,u,p,y,S,M,G,ce,ge,Ce){return t=new cw(t,r,s,S,G,ce,ge,Ce,M),r=1,y===!0&&(r|=24),y=Fr(3,null,null,r),t.current=y,y.stateNode=t,r=Ad(),r.refCount++,t.pooledCache=r,r.refCount++,y.memoizedState={element:u,isDehydrated:s,cache:r},Rd(y),t}function p0(t){return t?(t=qi,t):qi}function x0(t,r,s,u,p,y){p=p0(p),u.context===null?u.context=p:u.pendingContext=p,u=wl(r),u.payload={element:s},y=y===void 0?null:y,y!==null&&(u.callback=y),s=kl(t,u,r),s!==null&&(vr(s,t,r),Zs(s,t,r))}function g0(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var s=t.retryLane;t.retryLane=s!==0&&s<r?s:r}}function Qf(t,r){g0(t,r),(t=t.alternate)&&g0(t,r)}function y0(t){if(t.tag===13||t.tag===31){var r=ai(t,67108864);r!==null&&vr(r,t,67108864),Qf(t,67108864)}}function b0(t){if(t.tag===13||t.tag===31){var r=Br();r=Be(r);var s=ai(t,r);s!==null&&vr(s,t,r),Qf(t,r)}}var cu=!0;function uw(t,r,s,u){var p=q.T;q.T=null;var y=ie.p;try{ie.p=2,Zf(t,r,s,u)}finally{ie.p=y,q.T=p}}function dw(t,r,s,u){var p=q.T;q.T=null;var y=ie.p;try{ie.p=8,Zf(t,r,s,u)}finally{ie.p=y,q.T=p}}function Zf(t,r,s,u){if(cu){var p=Jf(u);if(p===null)$f(t,r,u,uu,s),w0(t,u);else if(hw(p,t,r,s,u))u.stopPropagation();else if(w0(t,u),r&4&&-1<fw.indexOf(t)){for(;p!==null;){var y=hl(p);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var S=dn(y.pendingLanes);if(S!==0){var M=y;for(M.pendingLanes|=2,M.entangledLanes|=2;S;){var G=1<<31-Ke(S);M.entanglements[1]|=G,S&=~G}Sa(y),(Xt&6)===0&&(Wc=be()+500,po(0))}}break;case 31:case 13:M=ai(y,2),M!==null&&vr(M,y,2),Vc(),Qf(y,2)}if(y=Jf(u),y===null&&$f(t,r,u,uu,s),y===p)break;p=y}p!==null&&u.stopPropagation()}else $f(t,r,u,null,s)}}function Jf(t){return t=Mi(t),eh(t)}var uu=null;function eh(t){if(uu=null,t=fl(t),t!==null){var r=c(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 uu=t,null}function v0(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(ve()){case Q:return 2;case Z:return 8;case Ee:case xe:return 32;case Ae:return 268435456;default:return 32}default:return 32}}var th=!1,Ml=null,zl=null,_l=null,ko=new Map,jo=new Map,Bl=[],fw="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 w0(t,r){switch(t){case"focusin":case"focusout":Ml=null;break;case"dragenter":case"dragleave":zl=null;break;case"mouseover":case"mouseout":_l=null;break;case"pointerover":case"pointerout":ko.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":jo.delete(r.pointerId)}}function So(t,r,s,u,p,y){return t===null||t.nativeEvent!==y?(t={blockedOn:r,domEventName:s,eventSystemFlags:u,nativeEvent:y,targetContainers:[p]},r!==null&&(r=hl(r),r!==null&&y0(r)),t):(t.eventSystemFlags|=u,r=t.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),t)}function hw(t,r,s,u,p){switch(r){case"focusin":return Ml=So(Ml,t,r,s,u,p),!0;case"dragenter":return zl=So(zl,t,r,s,u,p),!0;case"mouseover":return _l=So(_l,t,r,s,u,p),!0;case"pointerover":var y=p.pointerId;return ko.set(y,So(ko.get(y)||null,t,r,s,u,p)),!0;case"gotpointercapture":return y=p.pointerId,jo.set(y,So(jo.get(y)||null,t,r,s,u,p)),!0}return!1}function k0(t){var r=fl(t.target);if(r!==null){var s=c(r);if(s!==null){if(r=s.tag,r===13){if(r=d(s),r!==null){t.blockedOn=r,vn(t.priority,function(){b0(s)});return}}else if(r===31){if(r=f(s),r!==null){t.blockedOn=r,vn(t.priority,function(){b0(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 du(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var s=Jf(t.nativeEvent);if(s===null){s=t.nativeEvent;var u=new s.constructor(s.type,s);Ms=u,s.target.dispatchEvent(u),Ms=null}else return r=hl(s),r!==null&&y0(r),t.blockedOn=s,!1;r.shift()}return!0}function j0(t,r,s){du(t)&&s.delete(r)}function mw(){th=!1,Ml!==null&&du(Ml)&&(Ml=null),zl!==null&&du(zl)&&(zl=null),_l!==null&&du(_l)&&(_l=null),ko.forEach(j0),jo.forEach(j0)}function fu(t,r){t.blockedOn===r&&(t.blockedOn=null,th||(th=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,mw)))}var hu=null;function S0(t){hu!==t&&(hu=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){hu===t&&(hu=null);for(var r=0;r<t.length;r+=3){var s=t[r],u=t[r+1],p=t[r+2];if(typeof u!="function"){if(eh(u||s)===null)continue;break}var y=hl(s);y!==null&&(t.splice(r,3),r-=3,Zd(y,{pending:!0,data:p,method:s.method,action:u},u,p))}}))}function hs(t){function r(G){return fu(G,t)}Ml!==null&&fu(Ml,t),zl!==null&&fu(zl,t),_l!==null&&fu(_l,t),ko.forEach(r),jo.forEach(r);for(var s=0;s<Bl.length;s++){var u=Bl[s];u.blockedOn===t&&(u.blockedOn=null)}for(;0<Bl.length&&(s=Bl[0],s.blockedOn===null);)k0(s),s.blockedOn===null&&Bl.shift();if(s=(t.ownerDocument||t).$$reactFormReplay,s!=null)for(u=0;u<s.length;u+=3){var p=s[u],y=s[u+1],S=p[mn]||null;if(typeof y=="function")S||S0(s);else if(S){var M=null;if(y&&y.hasAttribute("formAction")){if(p=y,S=y[mn]||null)M=S.formAction;else if(eh(p)!==null)continue}else M=S.action;typeof M=="function"?s[u+1]=M:(s.splice(u,3),u-=3),S0(s)}}}function C0(){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),u||setTimeout(s,20)}function s(){if(!u&&!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 u=!1,p=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(s,100),function(){u=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),p!==null&&(p(),p=null)}}}function nh(t){this._internalRoot=t}mu.prototype.render=nh.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var s=r.current,u=Br();x0(s,u,t,r,null,null)},mu.prototype.unmount=nh.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;x0(t.current,2,null,t,null,null),Vc(),r[Ur]=null}};function mu(t){this._internalRoot=t}mu.prototype.unstable_scheduleHydration=function(t){if(t){var r=Ze();t={blockedOn:null,target:t,priority:r};for(var s=0;s<Bl.length&&r!==0&&r<Bl[s].priority;s++);Bl.splice(s,0,t),s===0&&k0(t)}};var N0=n.version;if(N0!=="19.2.4")throw Error(i(527,N0,"19.2.4"));ie.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 pw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var pu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!pu.isDisabled&&pu.supportsFiber)try{Le=pu.inject(pw),Ye=pu}catch{}}return No.createRoot=function(t,r){if(!o(t))throw Error(i(299));var s=!1,u="",p=Mx,y=zx,S=_x;return r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(y=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=m0(t,1,!1,null,null,s,u,null,p,y,S,C0),t[Ur]=r.current,Of(t),new nh(r)},No.hydrateRoot=function(t,r,s){if(!o(t))throw Error(i(299));var u=!1,p="",y=Mx,S=zx,M=_x,G=null;return s!=null&&(s.unstable_strictMode===!0&&(u=!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&&(M=s.onRecoverableError),s.formState!==void 0&&(G=s.formState)),r=m0(t,1,!0,r,s??null,u,p,G,y,S,M,C0),r.context=p0(null),s=r.current,u=Br(),u=Be(u),p=wl(u),p.callback=null,kl(s,p,u),s=u,r.current.lanes=s,ke(r,s),Sa(r),t[Ur]=r.current,Of(t),new mu(r)},No.version="19.2.4",No}var O0;function Ew(){if(O0)return lh.exports;O0=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(),lh.exports=Nw(),lh.exports}var Aw=Ew();const Dw="modulepreload",Tw=function(e){return"/"+e},$0={},Fy=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=Tw(h),h in $0)return;$0[h]=!0;const x=h.endsWith(".css"),g=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const w=document.createElement("link");if(w.rel=x?"stylesheet":Dw,x||(w.as="script"),w.crossOrigin="",w.href=h,m&&w.setAttribute("nonce",m),document.head.appendChild(w),x)return new Promise((b,j)=>{w.addEventListener("load",b),w.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function c(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"&&c(f.reason);return n().catch(c)})};class Fw extends v.Component{constructor(){super(...arguments);E0(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 Ta="/api";async function Bt(e){const n=await fetch(`${Ta}${e}`);if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function ln(e,n){const a=await fetch(`${Ta}${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 xu(e,n){const a=await fetch(`${Ta}${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 Rw(e,n){const a=await fetch(`${Ta}${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 al(e,n){const a={method:"DELETE"};n!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(n));const i=await fetch(`${Ta}${e}`,a);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const ye={getCompany:()=>Bt("/company"),getRoles:()=>Bt("/roles"),getRole:e=>Bt(`/roles/${e}`),getProjects:()=>Bt("/projects"),getProject:e=>Bt(`/projects/${e}`),getStandups:()=>Bt("/operations/standups"),getWaves:()=>Bt("/operations/waves"),getActiveWaves:()=>Bt("/waves/active"),getWaveDetail:e=>Bt(`/operations/waves/${e}`),patchWave:(e,n)=>xu(`/operations/waves/${e}`,n),getDecisions:()=>Bt("/operations/decisions"),updateDecision:(e,n)=>Rw(`/operations/decisions/${e}`,{content:n}),deleteDecision:e=>al(`/operations/decisions/${e}`),getOrgTree:()=>Bt("/engine/org"),getSkills:()=>Bt("/skills"),exportSkills:e=>Bt(`/skills/export/${e}`),getSkillRegistry:()=>Bt("/skills/registry"),installRegistrySkill:(e,n)=>ln("/skills/registry/install",{skillId:e,url:n}),createRole:e=>ln("/engine/roles",e),updateRole:(e,n)=>xu(`/engine/roles/${e}`,n),deleteRole:e=>al(`/engine/roles/${e}`),getSessions:()=>Bt("/sessions"),getSession:e=>Bt(`/sessions/${e}`),createSession:(e,n="talk")=>ln("/sessions",{roleId:e,mode:n}),deleteSession:e=>al(`/sessions/${e}`),deleteSessions:e=>al("/sessions",{ids:e}),deleteEmptySessions:()=>al("/sessions?empty=true"),updateSession:(e,n)=>xu(`/sessions/${e}`,n),abortSession:e=>ln(`/sessions/${e}/abort`,{}),abortExec:e=>ln(`/jobs/${e}/abort`,{}),replyToSession:(e,n,a)=>ln(`/sessions/${e}/reply`,{message:n,...a&&{attachments:a}}),execute:e=>ln("/jobs",e),saveWave:e=>ln("/waves/save",e),getStatus:()=>Bt("/status"),detectEngine:()=>ln("/setup/detect-engine",{}),validatePath:e=>ln("/setup/validate-path",{path:e}),scaffold:e=>ln("/setup/scaffold",e),getTeams:()=>Bt("/setup/teams"),browse:e=>ln("/setup/browse",{path:e}),mkdir:(e,n)=>ln("/setup/mkdir",{path:e,name:n}),connectAkb:e=>ln("/setup/connect-akb",{path:e}),getRequiredTools:e=>ln("/setup/required-tools",{team:e}),installTools:(e,n)=>fetch(`${Ta}/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 c="";const d=()=>i.read().then(({done:m,value:h})=>{if(m)return;c+=o.decode(h,{stream:!0});const x=c.split(`
|
|
50
|
+
`);c=x.pop()||"";let g="";for(const w of x)if(w.startsWith("event: "))g=w.slice(7);else if(w.startsWith("data: ")&&g){try{n(g,JSON.parse(w.slice(6)))}catch{}g=""}return d()});return d()}),getKnowledge:()=>Bt("/knowledge"),getKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return Bt(`/knowledge/${n}`)},createKnowledgeDoc:e=>ln("/knowledge",e),updateKnowledgeDoc:(e,n)=>{const a=e.split("/").map(encodeURIComponent).join("/");return fetch(`${Ta}/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 al(`/knowledge/${n}`)},getKnowledgeHealth:()=>Bt("/knowledge/health"),getPreferences:()=>Bt("/preferences"),updatePreferences:e=>xu("/preferences",e),chatInChannel:e=>ln("/speech/chat",e),getSaveStatus:(e="akb")=>Bt(`/save/status?repo=${e}`),save:(e,n="akb")=>ln(`/save?repo=${n}`,{message:e}),getSaveHistory:(e=20,n="akb")=>Bt(`/save/history?limit=${e}&repo=${n}`),restoreSave:(e,n,a="akb")=>ln(`/save/restore?repo=${a}`,{sha:e,paths:n}),initGit:(e="akb")=>ln(`/save/init?repo=${e}`,{}),getSyncStatus:(e="akb")=>Bt(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${Ta}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>Bt(`/save/github-status?repo=${e}`),githubCreateRepo:(e,n="private",a="akb")=>ln(`/save/github-create-repo?repo=${a}`,{name:e,visibility:n}),addRemote:(e,n="akb")=>ln(`/save/remote?repo=${n}`,{url:e}),setCodeRoot:async e=>{const n=await fetch(`${Ta}/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:()=>Bt("/setup/code-root"),getCostSummary:()=>Bt("/cost/summary"),getSyncRoles:()=>Bt("/sync/roles"),applySyncUpdate:e=>ln("/sync/apply",e),getCompanyStats:()=>Bt("/sync/stats"),getCoins:()=>Bt("/coins"),earnCoins:(e,n,a)=>ln("/coins/earn",{amount:e,reason:n,ref:a}),spendCoins:(e,n,a)=>ln("/coins/spend",{amount:e,reason:n,ref:a}),migrateCoins:e=>ln("/coins/migrate",{completedQuests:e}),getQuestProgress:()=>Bt("/quests/progress"),saveQuestProgress:e=>fetch(`${Ta}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>n.json()),getActiveSessions:()=>Bt("/active-sessions"),getActiveSession:e=>Bt(`/active-sessions/${e}`),registerActiveSession:e=>ln("/active-sessions/register",e),deleteActiveSession:e=>al(`/active-sessions/${e}`),cleanupActiveSessions:()=>ln("/active-sessions/cleanup",{}),getGitStatus:(e="akb")=>Bt(`/git/status?repo=${e}`),deleteWorktree:(e,n="akb")=>al(`/git/worktrees/${encodeURIComponent(e)}?repo=${n}`),deleteBranch:(e,n="akb")=>al(`/git/branches/${encodeURIComponent(e)}?repo=${n}`)},Mw=Object.freeze(Object.defineProperty({__proto__:null,api:ye},Symbol.toStringTag,{value:"Module"}));function Wn(e){return e==="working"||e==="awaiting_input"}function Ry(e){return e==="streaming"||e==="awaiting_input"}function ol(e){return e==="streaming"||e==="awaiting_input"}function My(e){const[n,a]=v.useState([]),[i,o]=v.useState("idle"),[c,d]=v.useState(""),[f,m]=v.useState([]),h=v.useRef(-1),x=v.useRef(null),g=v.useRef(0),w=v.useCallback(()=>{var N;if(!e)return;(N=x.current)==null||N.abort();const j=new AbortController;x.current=j,o("connecting");const k=h.current+1,E=`/api/sessions/${e}/stream?from=${k}`;fetch(E,{signal:j.signal}).then(async C=>{if(!C.ok||!C.body){o("error");return}o("streaming");const z=C.body.getReader(),T=new TextDecoder;let H="";for(;;){const{done:F,value:I}=await z.read();if(F)break;H+=T.decode(I,{stream:!0});const V=H.split(`
|
|
51
|
+
`);H=V.pop()??"";let X="";for(const _ of V)if(_.startsWith("event: "))X=_.slice(7).trim();else if(_.startsWith("data: ")){try{const $=JSON.parse(_.slice(6));if(X==="activity"){const L=$;L.seq>h.current&&(h.current=L.seq),a(W=>W.some(ne=>ne.seq===L.seq)?W:[...W,L]),L.type==="text"&&d(W=>W+(L.data.text??"")),L.type==="dispatch:start"&&L.data.childSessionId&&m(W=>[...W,L.data.childSessionId]),L.type==="msg:done"?o("done"):L.type==="msg:error"&&o("error")}else if(X==="stream:end"){const L=$.reason;o(L==="done"?"done":L==="error"?"error":"done")}}catch{}X=""}}i==="streaming"&&o("done")}).catch(C=>{C.name!=="AbortError"&&(o("error"),g.current<3&&(g.current++,setTimeout(w,1e3*g.current)))})},[e]),b=v.useCallback(()=>{g.current=0,w()},[w]);return v.useEffect(()=>{if(!e){a([]),o("idle"),d(""),m([]),h.current=-1;return}return a([]),d(""),m([]),h.current=-1,g.current=0,w(),()=>{var j;(j=x.current)==null||j.abort()}},[e,w]),{events:n,status:i,textOutput:c,childSessionIds:f,reconnect:b}}function zw(e,n){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const _w=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Bw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ow={};function L0(e,n){return(Ow.jsx?Bw:_w).test(e)}const $w=/[ \t\n\f\r]/g;function Lw(e){return typeof e=="object"?e.type==="text"?I0(e.value):!1:I0(e)}function I0(e){return e.replace($w,"")===""}class Ko{constructor(n,a,i){this.normal=a,this.property=n,i&&(this.space=i)}}Ko.prototype.normal={};Ko.prototype.property={};Ko.prototype.space=void 0;function zy(e,n){const a={},i={};for(const o of e)Object.assign(a,o.property),Object.assign(i,o.normal);return new Ko(a,i,n)}function Kh(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 Iw=0;const kt=Di(),Bn=Di(),Ph=Di(),Me=Di(),fn=Di(),ys=Di(),Or=Di();function Di(){return 2**++Iw}const Qh=Object.freeze(Object.defineProperty({__proto__:null,boolean:kt,booleanish:Bn,commaOrSpaceSeparated:Or,commaSeparated:ys,number:Me,overloadedBoolean:Ph,spaceSeparated:fn},Symbol.toStringTag,{value:"Module"})),ch=Object.keys(Qh);class Em extends jr{constructor(n,a,i,o){let c=-1;if(super(n,a),H0(this,"space",o),typeof i=="number")for(;++c<ch.length;){const d=ch[c];H0(this,ch[c],(i&Qh[d])===Qh[d])}}}Em.prototype.defined=!0;function H0(e,n,a){a&&(e[n]=a)}function Cs(e){const n={},a={};for(const[i,o]of Object.entries(e.properties)){const c=new Em(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(c.mustUseProperty=!0),n[i]=c,a[Kh(i)]=i,a[Kh(c.attribute)]=i}return new Ko(n,a,e.space)}const _y=Cs({properties:{ariaActiveDescendant:null,ariaAtomic:Bn,ariaAutoComplete:null,ariaBusy:Bn,ariaChecked:Bn,ariaColCount:Me,ariaColIndex:Me,ariaColSpan:Me,ariaControls:fn,ariaCurrent:null,ariaDescribedBy:fn,ariaDetails:null,ariaDisabled:Bn,ariaDropEffect:fn,ariaErrorMessage:null,ariaExpanded:Bn,ariaFlowTo:fn,ariaGrabbed:Bn,ariaHasPopup:null,ariaHidden:Bn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:fn,ariaLevel:Me,ariaLive:null,ariaModal:Bn,ariaMultiLine:Bn,ariaMultiSelectable:Bn,ariaOrientation:null,ariaOwns:fn,ariaPlaceholder:null,ariaPosInSet:Me,ariaPressed:Bn,ariaReadOnly:Bn,ariaRelevant:null,ariaRequired:Bn,ariaRoleDescription:fn,ariaRowCount:Me,ariaRowIndex:Me,ariaRowSpan:Me,ariaSelected:Bn,ariaSetSize:Me,ariaSort:null,ariaValueMax:Me,ariaValueMin:Me,ariaValueNow:Me,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function By(e,n){return n in e?e[n]:n}function Oy(e,n){return By(e,n.toLowerCase())}const Hw=Cs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ys,acceptCharset:fn,accessKey:fn,action:null,allow:null,allowFullScreen:kt,allowPaymentRequest:kt,allowUserMedia:kt,alt:null,as:null,async:kt,autoCapitalize:null,autoComplete:fn,autoFocus:kt,autoPlay:kt,blocking:fn,capture:null,charSet:null,checked:kt,cite:null,className:fn,cols:Me,colSpan:null,content:null,contentEditable:Bn,controls:kt,controlsList:fn,coords:Me|ys,crossOrigin:null,data:null,dateTime:null,decoding:null,default:kt,defer:kt,dir:null,dirName:null,disabled:kt,download:Ph,draggable:Bn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:kt,formTarget:null,headers:fn,height:Me,hidden:Ph,high:Me,href:null,hrefLang:null,htmlFor:fn,httpEquiv:fn,id:null,imageSizes:null,imageSrcSet:null,inert:kt,inputMode:null,integrity:null,is:null,isMap:kt,itemId:null,itemProp:fn,itemRef:fn,itemScope:kt,itemType:fn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:kt,low:Me,manifest:null,max:null,maxLength:Me,media:null,method:null,min:null,minLength:Me,multiple:kt,muted:kt,name:null,nonce:null,noModule:kt,noValidate:kt,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:kt,optimum:Me,pattern:null,ping:fn,placeholder:null,playsInline:kt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:kt,referrerPolicy:null,rel:fn,required:kt,reversed:kt,rows:Me,rowSpan:Me,sandbox:fn,scope:null,scoped:kt,seamless:kt,selected:kt,shadowRootClonable:kt,shadowRootDelegatesFocus:kt,shadowRootMode:null,shape:null,size:Me,sizes:null,slot:null,span:Me,spellCheck:Bn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Me,step:null,style:null,tabIndex:Me,target:null,title:null,translate:null,type:null,typeMustMatch:kt,useMap:null,value:Bn,width:Me,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:fn,axis:null,background:null,bgColor:null,border:Me,borderColor:null,bottomMargin:Me,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:kt,declare:kt,event:null,face:null,frame:null,frameBorder:null,hSpace:Me,leftMargin:Me,link:null,longDesc:null,lowSrc:null,marginHeight:Me,marginWidth:Me,noResize:kt,noHref:kt,noShade:kt,noWrap:kt,object:null,profile:null,prompt:null,rev:null,rightMargin:Me,rules:null,scheme:null,scrolling:Bn,standby:null,summary:null,text:null,topMargin:Me,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Me,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:kt,disableRemotePlayback:kt,prefix:null,property:null,results:Me,security:null,unselectable:null},space:"html",transform:Oy}),Uw=Cs({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:Or,accentHeight:Me,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Me,amplitude:Me,arabicForm:null,ascent:Me,attributeName:null,attributeType:null,azimuth:Me,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Me,by:null,calcMode:null,capHeight:Me,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:Me,diffuseConstant:Me,direction:null,display:null,dur:null,divisor:Me,dominantBaseline:null,download:kt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Me,enableBackground:null,end:null,event:null,exponent:Me,externalResourcesRequired:null,fill:null,fillOpacity:Me,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:ys,g2:ys,glyphName:ys,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Me,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Me,horizOriginX:Me,horizOriginY:Me,id:null,ideographic:Me,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Me,k:Me,k1:Me,k2:Me,k3:Me,k4:Me,kernelMatrix:Or,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Me,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:Me,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:Me,overlineThickness:Me,paintOrder:null,panose1:null,path:null,pathLength:Me,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:fn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Me,pointsAtY:Me,pointsAtZ:Me,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Or,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Or,rev:Or,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Or,requiredFeatures:Or,requiredFonts:Or,requiredFormats:Or,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:Me,specularExponent:Me,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Me,strikethroughThickness:Me,string:null,stroke:null,strokeDashArray:Or,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Me,strokeOpacity:Me,strokeWidth:null,style:null,surfaceScale:Me,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Or,tabIndex:Me,tableValues:null,target:null,targetX:Me,targetY:Me,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Or,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Me,underlineThickness:Me,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Me,values:null,vAlphabetic:Me,vMathematical:Me,vectorEffect:null,vHanging:Me,vIdeographic:Me,version:null,vertAdvY:Me,vertOriginX:Me,vertOriginY:Me,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Me,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:By}),$y=Cs({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()}}),Ly=Cs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Oy}),Iy=Cs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),qw={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"},Yw=/[A-Z]/g,U0=/-[a-z]/g,Xw=/^data[-\w.:]+$/i;function Ww(e,n){const a=Kh(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"&&Xw.test(n)){if(n.charAt(4)==="-"){const c=n.slice(5).replace(U0,Vw);i="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=n.slice(4);if(!U0.test(c)){let d=c.replace(Yw,Gw);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}o=Em}return new o(i,n)}function Gw(e){return"-"+e.toLowerCase()}function Vw(e){return e.charAt(1).toUpperCase()}const Kw=zy([_y,Hw,$y,Ly,Iy],"html"),Am=zy([_y,Uw,$y,Ly,Iy],"svg");function Pw(e){return e.join(" ").trim()}var ms={},uh,q0;function Qw(){if(q0)return uh;q0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
|
|
52
|
+
`,h="/",x="*",g="",w="comment",b="declaration";function j(E,N){if(typeof E!="string")throw new TypeError("First argument must be a string");if(!E)return[];N=N||{};var C=1,z=1;function T(ne){var K=ne.match(n);K&&(C+=K.length);var q=ne.lastIndexOf(m);z=~q?ne.length-q:z+ne.length}function H(){var ne={line:C,column:z};return function(K){return K.position=new F(ne),X(),K}}function F(ne){this.start=ne,this.end={line:C,column:z},this.source=N.source}F.prototype.content=E;function I(ne){var K=new Error(N.source+":"+C+":"+z+": "+ne);if(K.reason=ne,K.filename=N.source,K.line=C,K.column=z,K.source=E,!N.silent)throw K}function V(ne){var K=ne.exec(E);if(K){var q=K[0];return T(q),E=E.slice(q.length),K}}function X(){V(a)}function _(ne){var K;for(ne=ne||[];K=$();)K!==!1&&ne.push(K);return ne}function $(){var ne=H();if(!(h!=E.charAt(0)||x!=E.charAt(1))){for(var K=2;g!=E.charAt(K)&&(x!=E.charAt(K)||h!=E.charAt(K+1));)++K;if(K+=2,g===E.charAt(K-1))return I("End of comment missing");var q=E.slice(2,K-2);return z+=2,T(q),E=E.slice(K),z+=2,ne({type:w,comment:q})}}function L(){var ne=H(),K=V(i);if(K){if($(),!V(o))return I("property missing ':'");var q=V(c),ie=ne({type:b,property:k(K[0].replace(e,g)),value:q?k(q[0].replace(e,g)):g});return V(d),ie}}function W(){var ne=[];_(ne);for(var K;K=L();)K!==!1&&(ne.push(K),_(ne));return ne}return X(),W()}function k(E){return E?E.replace(f,g):g}return uh=j,uh}var Y0;function Zw(){if(Y0)return ms;Y0=1;var e=ms&&ms.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(ms,"__esModule",{value:!0}),ms.default=a;const n=e(Qw());function a(i,o){let c=null;if(!i||typeof i!="string")return c;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&&(c=c||{},c[h]=x)}),c}return ms}var Eo={},X0;function Jw(){if(X0)return Eo;X0=1,Object.defineProperty(Eo,"__esModule",{value:!0}),Eo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,c=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={}),c(h)?h:(h=h.toLowerCase(),x.reactCompat?h=h.replace(o,f):h=h.replace(i,f),h.replace(n,d))};return Eo.camelCase=m,Eo}var Ao,W0;function e5(){if(W0)return Ao;W0=1;var e=Ao&&Ao.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(Zw()),a=Jw();function i(o,c){var d={};return!o||typeof o!="string"||(0,n.default)(o,function(f,m){f&&m&&(d[(0,a.camelCase)(f,c)]=m)}),d}return i.default=i,Ao=i,Ao}var t5=e5();const n5=Ty(t5),Hy=Uy("end"),Dm=Uy("start");function Uy(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 r5(e){const n=Dm(e),a=Hy(e);if(n&&a)return{start:n,end:a}}function Io(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?G0(e.position):"start"in e||"end"in e?G0(e):"line"in e||"column"in e?Zh(e):""}function Zh(e){return V0(e&&e.line)+":"+V0(e&&e.column)}function G0(e){return Zh(e&&e.start)+"-"+Zh(e&&e.end)}function V0(e){return e&&typeof e=="number"?e:1}class sr extends Error{constructor(n,a,i){super(),typeof a=="string"&&(i=a,a=void 0);let o="",c={},d=!1;if(a&&("line"in a&&"column"in a?c={place:a}:"start"in a&&"end"in a?c={place:a}:"type"in a?c={ancestors:[a],place:a.position}:c={...a}),typeof n=="string"?o=n:!c.cause&&n&&(d=!0,o=n.message,c.cause=n),!c.ruleId&&!c.source&&typeof i=="string"){const m=i.indexOf(":");m===-1?c.ruleId=i:(c.source=i.slice(0,m),c.ruleId=i.slice(m+1))}if(!c.place&&c.ancestors&&c.ancestors){const m=c.ancestors[c.ancestors.length-1];m&&(c.place=m.position)}const f=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=Io(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=d&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}sr.prototype.file="";sr.prototype.name="";sr.prototype.reason="";sr.prototype.message="";sr.prototype.stack="";sr.prototype.column=void 0;sr.prototype.line=void 0;sr.prototype.ancestors=void 0;sr.prototype.cause=void 0;sr.prototype.fatal=void 0;sr.prototype.place=void 0;sr.prototype.ruleId=void 0;sr.prototype.source=void 0;const Tm={}.hasOwnProperty,a5=new Map,l5=/[A-Z]/g,i5=new Set(["table","tbody","thead","tfoot","tr"]),s5=new Set(["td","th"]),qy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function o5(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=x5(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=p5(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"?Am:Kw,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},c=Yy(o,e,void 0);return c&&typeof c!="string"?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}function Yy(e,n,a){if(n.type==="element")return c5(e,n,a);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return u5(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return f5(e,n,a);if(n.type==="mdxjsEsm")return d5(e,n);if(n.type==="root")return h5(e,n,a);if(n.type==="text")return m5(e,n)}function c5(e,n,a){const i=e.schema;let o=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=Am,e.schema=o),e.ancestors.push(n);const c=Wy(e,n.tagName,!1),d=g5(e,n);let f=Rm(e,n);return i5.has(n.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!Lw(m):!0})),Xy(e,d,c,n),Fm(d,f),e.ancestors.pop(),e.schema=i,e.create(n,c,d,a)}function u5(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)}Yo(e,n.position)}function d5(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Yo(e,n.position)}function f5(e,n,a){const i=e.schema;let o=i;n.name==="svg"&&i.space==="html"&&(o=Am,e.schema=o),e.ancestors.push(n);const c=n.name===null?e.Fragment:Wy(e,n.name,!0),d=y5(e,n),f=Rm(e,n);return Xy(e,d,c,n),Fm(d,f),e.ancestors.pop(),e.schema=i,e.create(n,c,d,a)}function h5(e,n,a){const i={};return Fm(i,Rm(e,n)),e.create(n,e.Fragment,i,a)}function m5(e,n){return n.value}function Xy(e,n,a,i){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(n.node=i)}function Fm(e,n){if(n.length>0){const a=n.length>1?n:n[0];a&&(e.children=a)}}function p5(e,n,a){return i;function i(o,c,d,f){const h=Array.isArray(d.children)?a:n;return f?h(c,d,f):h(c,d)}}function x5(e,n){return a;function a(i,o,c,d){const f=Array.isArray(c.children),m=Dm(i);return n(o,c,d,f,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function g5(e,n){const a={};let i,o;for(o in n.properties)if(o!=="children"&&Tm.call(n.properties,o)){const c=b5(e,o,n.properties[o]);if(c){const[d,f]=c;e.tableCellAlignToStyle&&d==="align"&&typeof f=="string"&&s5.has(n.tagName)?i=f:a[d]=f}}if(i){const c=a.style||(a.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return a}function y5(e,n){const a={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const c=i.data.estree.body[0];c.type;const d=c.expression;d.type;const f=d.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else Yo(e,n.position);else{const o=i.name;let c;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,c=e.evaluater.evaluateExpression(f.expression)}else Yo(e,n.position);else c=i.value===null?!0:i.value;a[o]=c}return a}function Rm(e,n){const a=[];let i=-1;const o=e.passKeys?new Map:a5;for(;++i<n.children.length;){const c=n.children[i];let d;if(e.passKeys){const m=c.type==="element"?c.tagName:c.type==="mdxJsxFlowElement"||c.type==="mdxJsxTextElement"?c.name:void 0;if(m){const h=o.get(m)||0;d=m+"-"+h,o.set(m,h+1)}}const f=Yy(e,c,d);f!==void 0&&a.push(f)}return a}function b5(e,n,a){const i=Ww(e.schema,n);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=i.commaSeparated?zw(a):Pw(a)),i.property==="style"){let o=typeof a=="object"?a:v5(e,String(a));return e.stylePropertyNameCase==="css"&&(o=w5(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?qw[i.property]||i.property:i.attribute,a]}}function v5(e,n){try{return n5(n,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const i=a,o=new sr("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=qy+"#cannot-parse-style-attribute",o}}function Wy(e,n,a){let i;if(!a)i={type:"Literal",value:n};else if(n.includes(".")){const o=n.split(".");let c=-1,d;for(;++c<o.length;){const f=L0(o[c])?{type:"Identifier",name:o[c]}:{type:"Literal",value:o[c]};d=d?{type:"MemberExpression",object:d,property:f,computed:!!(c&&f.type==="Literal"),optional:!1}:f}i=d}else i=L0(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const o=i.value;return Tm.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);Yo(e)}function Yo(e,n){const a=new sr("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=qy+"#cannot-handle-mdx-estrees-without-createevaluater",a}function w5(e){const n={};let a;for(a in e)Tm.call(e,a)&&(n[k5(a)]=e[a]);return n}function k5(e){let n=e.replace(l5,j5);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function j5(e){return"-"+e.toLowerCase()}const dh={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"]},S5={};function Mm(e,n){const a=S5,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Gy(e,i,o)}function Gy(e,n,a){if(C5(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 K0(e.children,n,a)}return Array.isArray(e)?K0(e,n,a):""}function K0(e,n,a){const i=[];let o=-1;for(;++o<e.length;)i[o]=Gy(e[o],n,a);return i.join("")}function C5(e){return!!(e&&typeof e=="object")}const P0=document.createElement("i");function zm(e){const n="&"+e+";";P0.innerHTML=n;const a=P0.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===n?!1:a}function Hr(e,n,a,i){const o=e.length;let c=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);c<i.length;)d=i.slice(c,c+1e4),d.unshift(n,0),e.splice(...d),c+=1e4,n+=1e4}function ta(e,n){return e.length>0?(Hr(e,e.length,0,n),e):n}const Q0={}.hasOwnProperty;function Vy(e){const n={};let a=-1;for(;++a<e.length;)N5(n,e[a]);return n}function N5(e,n){let a;for(a in n){const o=(Q0.call(e,a)?e[a]:void 0)||(e[a]={}),c=n[a];let d;if(c)for(d in c){Q0.call(o,d)||(o[d]=[]);const f=c[d];E5(o[d],Array.isArray(f)?f:f?[f]:[])}}}function E5(e,n){let a=-1;const i=[];for(;++a<n.length;)(n[a].add==="after"?e:i).push(n[a]);Hr(e,0,0,i)}function Ky(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 ha(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const cr=Gl(/[A-Za-z]/),ir=Gl(/[\dA-Za-z]/),A5=Gl(/[#-'*+\--9=?A-Z^-~]/);function Iu(e){return e!==null&&(e<32||e===127)}const Jh=Gl(/\d/),D5=Gl(/[\dA-Fa-f]/),T5=Gl(/[!-/:-@[-`{-~]/);function it(e){return e!==null&&e<-2}function un(e){return e!==null&&(e<0||e===32)}function Tt(e){return e===-2||e===-1||e===32}const Qu=Gl(new RegExp("\\p{P}|\\p{S}","u")),Ei=Gl(/\s/);function Gl(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 c=e.charCodeAt(a);let d="";if(c===37&&ir(e.charCodeAt(a+1))&&ir(e.charCodeAt(a+2)))o=2;else if(c<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(c))||(d=String.fromCharCode(c));else if(c>55295&&c<57344){const f=e.charCodeAt(a+1);c<56320&&f>56319&&f<57344?(d=String.fromCharCode(c,f),o=1):d="�"}else d=String.fromCharCode(c);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 $t(e,n,a,i){const o=i?i-1:Number.POSITIVE_INFINITY;let c=0;return d;function d(m){return Tt(m)?(e.enter(a),f(m)):n(m)}function f(m){return Tt(m)&&c++<o?(e.consume(m),f):(e.exit(a),n(m))}}const F5={tokenize:R5};function R5(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"),$t(e,n,"linePrefix")}function o(f){return e.enter("paragraph"),c(f)}function c(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"),c):(e.consume(f),d)}}const M5={tokenize:z5},Z0={tokenize:_5};function z5(e){const n=this,a=[];let i=0,o,c,d;return f;function f(z){if(i<a.length){const T=a[i];return n.containerState=T[1],e.attempt(T[0].continuation,m,h)(z)}return h(z)}function m(z){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&C();const T=n.events.length;let H=T,F;for(;H--;)if(n.events[H][0]==="exit"&&n.events[H][1].type==="chunkFlow"){F=n.events[H][1].end;break}N(i);let I=T;for(;I<n.events.length;)n.events[I][1].end={...F},I++;return Hr(n.events,H+1,0,n.events.slice(T)),n.events.length=I,h(z)}return f(z)}function h(z){if(i===a.length){if(!o)return w(z);if(o.currentConstruct&&o.currentConstruct.concrete)return j(z);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(Z0,x,g)(z)}function x(z){return o&&C(),N(i),w(z)}function g(z){return n.parser.lazy[n.now().line]=i!==a.length,d=n.now().offset,j(z)}function w(z){return n.containerState={},e.attempt(Z0,b,j)(z)}function b(z){return i++,a.push([n.currentConstruct,n.containerState]),w(z)}function j(z){if(z===null){o&&C(),N(0),e.consume(z);return}return o=o||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:c}),k(z)}function k(z){if(z===null){E(e.exit("chunkFlow"),!0),N(0),e.consume(z);return}return it(z)?(e.consume(z),E(e.exit("chunkFlow")),i=0,n.interrupt=void 0,f):(e.consume(z),k)}function E(z,T){const H=n.sliceStream(z);if(T&&H.push(null),z.previous=c,c&&(c.next=z),c=z,o.defineSkip(z.start),o.write(H),n.parser.lazy[z.start.line]){let F=o.events.length;for(;F--;)if(o.events[F][1].start.offset<d&&(!o.events[F][1].end||o.events[F][1].end.offset>d))return;const I=n.events.length;let V=I,X,_;for(;V--;)if(n.events[V][0]==="exit"&&n.events[V][1].type==="chunkFlow"){if(X){_=n.events[V][1].end;break}X=!0}for(N(i),F=I;F<n.events.length;)n.events[F][1].end={..._},F++;Hr(n.events,V+1,0,n.events.slice(I)),n.events.length=F}}function N(z){let T=a.length;for(;T-- >z;){const H=a[T];n.containerState=H[1],H[0].exit.call(n,e)}a.length=z}function C(){o.write([null]),c=void 0,o=void 0,n.containerState._closeFlow=void 0}}function _5(e,n,a){return $t(e,e.attempt(this.parser.constructs.document,n,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function vs(e){if(e===null||un(e)||Ei(e))return 1;if(Qu(e))return 2}function Zu(e,n,a){const i=[];let o=-1;for(;++o<e.length;){const c=e[o].resolveAll;c&&!i.includes(c)&&(n=c(n,a),i.push(c))}return n}const em={name:"attention",resolveAll:B5,tokenize:O5};function B5(e,n){let a=-1,i,o,c,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},w={...e[a][1].start};J0(g,-m),J0(w,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:w},c={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=ta(h,[["enter",e[i][1],n],["exit",e[i][1],n]])),h=ta(h,[["enter",o,n],["enter",d,n],["exit",d,n],["enter",c,n]]),h=ta(h,Zu(n.parser.constructs.insideSpan.null,e.slice(i+1,a),n)),h=ta(h,[["exit",c,n],["enter",f,n],["exit",f,n],["exit",o,n]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,h=ta(h,[["enter",e[a][1],n],["exit",e[a][1],n]])):x=0,Hr(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 O5(e,n){const a=this.parser.constructs.attentionMarkers.null,i=this.previous,o=vs(i);let c;return d;function d(m){return c=m,e.enter("attentionSequence"),f(m)}function f(m){if(m===c)return e.consume(m),f;const h=e.exit("attentionSequence"),x=vs(m),g=!x||x===2&&o||a.includes(m),w=!o||o===2&&x||a.includes(i);return h._open=!!(c===42?g:g&&(o||!w)),h._close=!!(c===42?w:w&&(x||!g)),n(m)}}function J0(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const $5={name:"autolink",tokenize:L5};function L5(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"),c}function c(b){return cr(b)?(e.consume(b),d):b===64?a(b):h(b)}function d(b){return b===43||b===45||b===46||ir(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||ir(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):A5(b)?(e.consume(b),h):a(b)}function x(b){return ir(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):w(b)}function w(b){if((b===45||ir(b))&&i++<63){const j=b===45?w:g;return e.consume(b),j}return a(b)}}const Po={partial:!0,tokenize:I5};function I5(e,n,a){return i;function i(c){return Tt(c)?$t(e,o,"linePrefix")(c):o(c)}function o(c){return c===null||it(c)?n(c):a(c)}}const Py={continuation:{tokenize:U5},exit:q5,name:"blockQuote",tokenize:H5};function H5(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"),c}return a(d)}function c(d){return Tt(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(d))}}function U5(e,n,a){const i=this;return o;function o(d){return Tt(d)?$t(e,c,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):c(d)}function c(d){return e.attempt(Py,n,a)(d)}}function q5(e){e.exit("blockQuote")}const Qy={name:"characterEscape",tokenize:Y5};function Y5(e,n,a){return i;function i(c){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(c),e.exit("escapeMarker"),o}function o(c){return T5(c)?(e.enter("characterEscapeValue"),e.consume(c),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):a(c)}}const Zy={name:"characterReference",tokenize:X5};function X5(e,n,a){const i=this;let o=0,c,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"),c=31,d=ir,x(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),c=6,d=D5,x):(e.enter("characterReferenceValue"),c=7,d=Jh,x(g))}function x(g){if(g===59&&o){const w=e.exit("characterReferenceValue");return d===ir&&!zm(i.sliceSerialize(w))?a(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(g)&&o++<c?(e.consume(g),x):a(g)}}const eg={partial:!0,tokenize:G5},tg={concrete:!0,name:"codeFenced",tokenize:W5};function W5(e,n,a){const i=this,o={partial:!0,tokenize:H};let c=0,d=0,f;return m;function m(F){return h(F)}function h(F){const I=i.events[i.events.length-1];return c=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,f=F,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(F)}function x(F){return F===f?(d++,e.consume(F),x):d<3?a(F):(e.exit("codeFencedFenceSequence"),Tt(F)?$t(e,g,"whitespace")(F):g(F))}function g(F){return F===null||it(F)?(e.exit("codeFencedFence"),i.interrupt?n(F):e.check(eg,k,T)(F)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),w(F))}function w(F){return F===null||it(F)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(F)):Tt(F)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),$t(e,b,"whitespace")(F)):F===96&&F===f?a(F):(e.consume(F),w)}function b(F){return F===null||it(F)?g(F):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(F))}function j(F){return F===null||it(F)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(F)):F===96&&F===f?a(F):(e.consume(F),j)}function k(F){return e.attempt(o,T,E)(F)}function E(F){return e.enter("lineEnding"),e.consume(F),e.exit("lineEnding"),N}function N(F){return c>0&&Tt(F)?$t(e,C,"linePrefix",c+1)(F):C(F)}function C(F){return F===null||it(F)?e.check(eg,k,T)(F):(e.enter("codeFlowValue"),z(F))}function z(F){return F===null||it(F)?(e.exit("codeFlowValue"),C(F)):(e.consume(F),z)}function T(F){return e.exit("codeFenced"),n(F)}function H(F,I,V){let X=0;return _;function _(K){return F.enter("lineEnding"),F.consume(K),F.exit("lineEnding"),$}function $(K){return F.enter("codeFencedFence"),Tt(K)?$t(F,L,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):L(K)}function L(K){return K===f?(F.enter("codeFencedFenceSequence"),W(K)):V(K)}function W(K){return K===f?(X++,F.consume(K),W):X>=d?(F.exit("codeFencedFenceSequence"),Tt(K)?$t(F,ne,"whitespace")(K):ne(K)):V(K)}function ne(K){return K===null||it(K)?(F.exit("codeFencedFence"),I(K)):V(K)}}}function G5(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"),c)}function c(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}const fh={name:"codeIndented",tokenize:K5},V5={partial:!0,tokenize:P5};function K5(e,n,a){const i=this;return o;function o(h){return e.enter("codeIndented"),$t(e,c,"linePrefix",5)(h)}function c(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(V5,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 P5(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):$t(e,c,"linePrefix",5)(d)}function c(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 Q5={name:"codeText",previous:J5,resolve:Z5,tokenize:ek};function Z5(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 J5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ek(e,n,a){let i=0,o,c;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?(c=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)):(c.type="codeTextData",h(g))}}class tk{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 c=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return i&&Do(this.left,i),c.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),Do(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Do(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);Do(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);Do(this.left,a.reverse())}}}function Do(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 Jy(e){const n={};let a=-1,i,o,c,d,f,m,h;const x=new tk(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,c=0,c<m.length&&m[c][1].type==="lineEndingBlank"&&(c+=2),c<m.length&&m[c][1].type==="content"))for(;++c<m.length&&m[c][1].type!=="content";)m[c][1].type==="chunkText"&&(m[c][1]._isInFirstContentOfListItem=!0,c++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,nk(x,a)),a=n[a],h=!0);else if(i[1]._container){for(c=a,o=void 0;c--;)if(d=x.get(c),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),d[1].type="lineEnding",o=c);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 Hr(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!h}function nk(e,n){const a=e.get(n)[1],i=e.get(n)[2];let o=n-1;const c=[];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,w=-1,b=a,j=0,k=0;const E=[k];for(;b;){for(;e.get(++o)[1]!==b;);c.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;++w<f.length;)f[w][0]==="exit"&&f[w-1][0]==="enter"&&f[w][1].type===f[w-1][1].type&&f[w][1].start.line!==f[w][1].end.line&&(k=w+1,E.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):E.pop(),w=E.length;w--;){const N=f.slice(E[w],E[w+1]),C=c.pop();m.push([C,C+N.length-1]),e.splice(C,2,N)}for(m.reverse(),w=-1;++w<m.length;)h[j+m[w][0]]=j+m[w][1],j+=m[w][1]-m[w][0]-1;return h}const rk={resolve:lk,tokenize:ik},ak={partial:!0,tokenize:sk};function lk(e){return Jy(e),e}function ik(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?c(f):it(f)?e.check(ak,d,c)(f):(e.consume(f),o)}function c(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 sk(e,n,a){const i=this;return o;function o(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),$t(e,c,"linePrefix")}function c(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 eb(e,n,a,i,o,c,d,f,m){const h=m||Number.POSITIVE_INFINITY;let x=0;return g;function g(N){return N===60?(e.enter(i),e.enter(o),e.enter(c),e.consume(N),e.exit(c),w):N===null||N===32||N===41||Iu(N)?a(N):(e.enter(i),e.enter(d),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(N))}function w(N){return N===62?(e.enter(c),e.consume(N),e.exit(c),e.exit(o),e.exit(i),n):(e.enter(f),e.enter("chunkString",{contentType:"string"}),b(N))}function b(N){return N===62?(e.exit("chunkString"),e.exit(f),w(N)):N===null||N===60||it(N)?a(N):(e.consume(N),N===92?j:b)}function j(N){return N===60||N===62||N===92?(e.consume(N),b):b(N)}function k(N){return!x&&(N===null||N===41||un(N))?(e.exit("chunkString"),e.exit(f),e.exit(d),e.exit(i),n(N)):x<h&&N===40?(e.consume(N),x++,k):N===41?(e.consume(N),x--,k):N===null||N===32||N===40||Iu(N)?a(N):(e.consume(N),N===92?E:k)}function E(N){return N===40||N===41||N===92?(e.consume(N),k):k(N)}}function tb(e,n,a,i,o,c){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(c),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(c),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=!Tt(b)),b===92?w:g)}function w(b){return b===91||b===92||b===93?(e.consume(b),f++,g):g(b)}}function nb(e,n,a,i,o,c){let d;return f;function f(w){return w===34||w===39||w===40?(e.enter(i),e.enter(o),e.consume(w),e.exit(o),d=w===40?41:w,m):a(w)}function m(w){return w===d?(e.enter(o),e.consume(w),e.exit(o),e.exit(i),n):(e.enter(c),h(w))}function h(w){return w===d?(e.exit(c),m(d)):w===null?a(w):it(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),$t(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(w))}function x(w){return w===d||w===null||it(w)?(e.exit("chunkString"),h(w)):(e.consume(w),w===92?g:x)}function g(w){return w===d||w===92?(e.consume(w),x):x(w)}}function Ho(e,n){let a;return i;function i(o){return it(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,i):Tt(o)?$t(e,i,a?"linePrefix":"lineSuffix")(o):n(o)}}const ok={name:"definition",tokenize:uk},ck={partial:!0,tokenize:dk};function uk(e,n,a){const i=this;let o;return c;function c(b){return e.enter("definition"),d(b)}function d(b){return tb.call(i,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function f(b){return o=ha(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)?Ho(e,h)(b):h(b)}function h(b){return eb(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(ck,g,g)(b)}function g(b){return Tt(b)?$t(e,w,"whitespace")(b):w(b)}function w(b){return b===null||it(b)?(e.exit("definition"),i.parser.defined.push(o),n(b)):a(b)}}function dk(e,n,a){return i;function i(f){return un(f)?Ho(e,o)(f):a(f)}function o(f){return nb(e,c,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function c(f){return Tt(f)?$t(e,d,"whitespace")(f):d(f)}function d(f){return f===null||it(f)?n(f):a(f)}}const fk={name:"hardBreakEscape",tokenize:hk};function hk(e,n,a){return i;function i(c){return e.enter("hardBreakEscape"),e.consume(c),o}function o(c){return it(c)?(e.exit("hardBreakEscape"),n(c)):a(c)}}const mk={name:"headingAtx",resolve:pk,tokenize:xk};function pk(e,n){let a=e.length-2,i=3,o,c;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},c={type:"chunkText",start:e[i][1].start,end:e[a][1].end,contentType:"text"},Hr(e,i,a-i+1,[["enter",o,n],["enter",c,n],["exit",c,n],["exit",o,n]])),e}function xk(e,n,a){let i=0;return o;function o(x){return e.enter("atxHeading"),c(x)}function c(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&i++<6?(e.consume(x),d):x===null||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)):Tt(x)?$t(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 gk=["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"],ng=["pre","script","style","textarea"],yk={concrete:!0,name:"htmlFlow",resolveTo:wk,tokenize:kk},bk={partial:!0,tokenize:Sk},vk={partial:!0,tokenize:jk};function wk(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 kk(e,n,a){const i=this;let o,c,d,f,m;return h;function h(R){return x(R)}function x(R){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(R),g}function g(R){return R===33?(e.consume(R),w):R===47?(e.consume(R),c=!0,k):R===63?(e.consume(R),o=3,i.interrupt?n:D):cr(R)?(e.consume(R),d=String.fromCharCode(R),E):a(R)}function w(R){return R===45?(e.consume(R),o=2,b):R===91?(e.consume(R),o=5,f=0,j):cr(R)?(e.consume(R),o=4,i.interrupt?n:D):a(R)}function b(R){return R===45?(e.consume(R),i.interrupt?n:D):a(R)}function j(R){const O="CDATA[";return R===O.charCodeAt(f++)?(e.consume(R),f===O.length?i.interrupt?n:L:j):a(R)}function k(R){return cr(R)?(e.consume(R),d=String.fromCharCode(R),E):a(R)}function E(R){if(R===null||R===47||R===62||un(R)){const O=R===47,ae=d.toLowerCase();return!O&&!c&&ng.includes(ae)?(o=1,i.interrupt?n(R):L(R)):gk.includes(d.toLowerCase())?(o=6,O?(e.consume(R),N):i.interrupt?n(R):L(R)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(R):c?C(R):z(R))}return R===45||ir(R)?(e.consume(R),d+=String.fromCharCode(R),E):a(R)}function N(R){return R===62?(e.consume(R),i.interrupt?n:L):a(R)}function C(R){return Tt(R)?(e.consume(R),C):_(R)}function z(R){return R===47?(e.consume(R),_):R===58||R===95||cr(R)?(e.consume(R),T):Tt(R)?(e.consume(R),z):_(R)}function T(R){return R===45||R===46||R===58||R===95||ir(R)?(e.consume(R),T):H(R)}function H(R){return R===61?(e.consume(R),F):Tt(R)?(e.consume(R),H):z(R)}function F(R){return R===null||R===60||R===61||R===62||R===96?a(R):R===34||R===39?(e.consume(R),m=R,I):Tt(R)?(e.consume(R),F):V(R)}function I(R){return R===m?(e.consume(R),m=null,X):R===null||it(R)?a(R):(e.consume(R),I)}function V(R){return R===null||R===34||R===39||R===47||R===60||R===61||R===62||R===96||un(R)?H(R):(e.consume(R),V)}function X(R){return R===47||R===62||Tt(R)?z(R):a(R)}function _(R){return R===62?(e.consume(R),$):a(R)}function $(R){return R===null||it(R)?L(R):Tt(R)?(e.consume(R),$):a(R)}function L(R){return R===45&&o===2?(e.consume(R),q):R===60&&o===1?(e.consume(R),ie):R===62&&o===4?(e.consume(R),U):R===63&&o===3?(e.consume(R),D):R===93&&o===5?(e.consume(R),me):it(R)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(bk,Y,W)(R)):R===null||it(R)?(e.exit("htmlFlowData"),W(R)):(e.consume(R),L)}function W(R){return e.check(vk,ne,Y)(R)}function ne(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),K}function K(R){return R===null||it(R)?W(R):(e.enter("htmlFlowData"),L(R))}function q(R){return R===45?(e.consume(R),D):L(R)}function ie(R){return R===47?(e.consume(R),d="",de):L(R)}function de(R){if(R===62){const O=d.toLowerCase();return ng.includes(O)?(e.consume(R),U):L(R)}return cr(R)&&d.length<8?(e.consume(R),d+=String.fromCharCode(R),de):L(R)}function me(R){return R===93?(e.consume(R),D):L(R)}function D(R){return R===62?(e.consume(R),U):R===45&&o===2?(e.consume(R),D):L(R)}function U(R){return R===null||it(R)?(e.exit("htmlFlowData"),Y(R)):(e.consume(R),U)}function Y(R){return e.exit("htmlFlow"),n(R)}}function jk(e,n,a){const i=this;return o;function o(d){return it(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):a(d)}function c(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}function Sk(e,n,a){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Po,n,a)}}const Ck={name:"htmlText",tokenize:Nk};function Nk(e,n,a){const i=this;let o,c,d;return f;function f(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),m}function m(D){return D===33?(e.consume(D),h):D===47?(e.consume(D),H):D===63?(e.consume(D),z):cr(D)?(e.consume(D),V):a(D)}function h(D){return D===45?(e.consume(D),x):D===91?(e.consume(D),c=0,j):cr(D)?(e.consume(D),C):a(D)}function x(D){return D===45?(e.consume(D),b):a(D)}function g(D){return D===null?a(D):D===45?(e.consume(D),w):it(D)?(d=g,ie(D)):(e.consume(D),g)}function w(D){return D===45?(e.consume(D),b):g(D)}function b(D){return D===62?q(D):D===45?w(D):g(D)}function j(D){const U="CDATA[";return D===U.charCodeAt(c++)?(e.consume(D),c===U.length?k:j):a(D)}function k(D){return D===null?a(D):D===93?(e.consume(D),E):it(D)?(d=k,ie(D)):(e.consume(D),k)}function E(D){return D===93?(e.consume(D),N):k(D)}function N(D){return D===62?q(D):D===93?(e.consume(D),N):k(D)}function C(D){return D===null||D===62?q(D):it(D)?(d=C,ie(D)):(e.consume(D),C)}function z(D){return D===null?a(D):D===63?(e.consume(D),T):it(D)?(d=z,ie(D)):(e.consume(D),z)}function T(D){return D===62?q(D):z(D)}function H(D){return cr(D)?(e.consume(D),F):a(D)}function F(D){return D===45||ir(D)?(e.consume(D),F):I(D)}function I(D){return it(D)?(d=I,ie(D)):Tt(D)?(e.consume(D),I):q(D)}function V(D){return D===45||ir(D)?(e.consume(D),V):D===47||D===62||un(D)?X(D):a(D)}function X(D){return D===47?(e.consume(D),q):D===58||D===95||cr(D)?(e.consume(D),_):it(D)?(d=X,ie(D)):Tt(D)?(e.consume(D),X):q(D)}function _(D){return D===45||D===46||D===58||D===95||ir(D)?(e.consume(D),_):$(D)}function $(D){return D===61?(e.consume(D),L):it(D)?(d=$,ie(D)):Tt(D)?(e.consume(D),$):X(D)}function L(D){return D===null||D===60||D===61||D===62||D===96?a(D):D===34||D===39?(e.consume(D),o=D,W):it(D)?(d=L,ie(D)):Tt(D)?(e.consume(D),L):(e.consume(D),ne)}function W(D){return D===o?(e.consume(D),o=void 0,K):D===null?a(D):it(D)?(d=W,ie(D)):(e.consume(D),W)}function ne(D){return D===null||D===34||D===39||D===60||D===61||D===96?a(D):D===47||D===62||un(D)?X(D):(e.consume(D),ne)}function K(D){return D===47||D===62||un(D)?X(D):a(D)}function q(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),n):a(D)}function ie(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),de}function de(D){return Tt(D)?$t(e,me,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):me(D)}function me(D){return e.enter("htmlTextData"),d(D)}}const _m={name:"labelEnd",resolveAll:Tk,resolveTo:Fk,tokenize:Rk},Ek={tokenize:Mk},Ak={tokenize:zk},Dk={tokenize:_k};function Tk(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&&Hr(e,0,e.length,a),e}function Fk(e,n){let a=e.length,i=0,o,c,d,f;for(;a--;)if(o=e[a][1],c){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&&(c=a,o.type!=="labelLink")){i=2;break}}else o.type==="labelEnd"&&(d=a);const m={type:e[c][1].type==="labelLink"?"link":"image",start:{...e[c][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[c][1].start},end:{...e[d][1].end}},x={type:"labelText",start:{...e[c+i+2][1].end},end:{...e[d-2][1].start}};return f=[["enter",m,n],["enter",h,n]],f=ta(f,e.slice(c+1,c+i+3)),f=ta(f,[["enter",x,n]]),f=ta(f,Zu(n.parser.constructs.insideSpan.null,e.slice(c+i+4,d-3),n)),f=ta(f,[["exit",x,n],e[d-2],e[d-1],["exit",h,n]]),f=ta(f,e.slice(d+1)),f=ta(f,[["exit",m,n]]),Hr(e,c,e.length,f),e}function Rk(e,n,a){const i=this;let o=i.events.length,c,d;for(;o--;)if((i.events[o][1].type==="labelImage"||i.events[o][1].type==="labelLink")&&!i.events[o][1]._balanced){c=i.events[o][1];break}return f;function f(w){return c?c._inactive?g(w):(d=i.parser.defined.includes(ha(i.sliceSerialize({start:c.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(w),e.exit("labelMarker"),e.exit("labelEnd"),m):a(w)}function m(w){return w===40?e.attempt(Ek,x,d?x:g)(w):w===91?e.attempt(Ak,x,d?h:g)(w):d?x(w):g(w)}function h(w){return e.attempt(Dk,x,g)(w)}function x(w){return n(w)}function g(w){return c._balanced=!0,a(w)}}function Mk(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)?Ho(e,c)(g):c(g)}function c(g){return g===41?x(g):eb(e,d,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function d(g){return un(g)?Ho(e,m)(g):x(g)}function f(g){return a(g)}function m(g){return g===34||g===39||g===40?nb(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):x(g)}function h(g){return un(g)?Ho(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 zk(e,n,a){const i=this;return o;function o(f){return tb.call(i,e,c,d,"reference","referenceMarker","referenceString")(f)}function c(f){return i.parser.defined.includes(ha(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(f):a(f)}function d(f){return a(f)}}function _k(e,n,a){return i;function i(c){return e.enter("reference"),e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),o}function o(c){return c===93?(e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),e.exit("reference"),n):a(c)}}const Bk={name:"labelStartImage",resolveAll:_m.resolveAll,tokenize:Ok};function Ok(e,n,a){const i=this;return o;function o(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),c}function c(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 $k={name:"labelStartLink",resolveAll:_m.resolveAll,tokenize:Lk};function Lk(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"),c}function c(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(d):n(d)}}const hh={name:"lineEnding",tokenize:Ik};function Ik(e,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),$t(e,n,"linePrefix")}}const _u={name:"thematicBreak",tokenize:Hk};function Hk(e,n,a){let i=0,o;return c;function c(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"),Tt(h)?$t(e,f,"whitespace")(h):f(h))}}const wr={continuation:{tokenize:Xk},exit:Gk,name:"list",tokenize:Yk},Uk={partial:!0,tokenize:Vk},qk={partial:!0,tokenize:Wk};function Yk(e,n,a){const i=this,o=i.events[i.events.length-1];let c=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:Jh(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 Jh(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(Po,i.interrupt?a:x,e.attempt(Uk,w,g))}function x(b){return i.containerState.initialBlankLine=!0,c++,w(b)}function g(b){return Tt(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),w):a(b)}function w(b){return i.containerState.size=c+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(b)}}function Xk(e,n,a){const i=this;return i.containerState._closeFlow=void 0,e.check(Po,o,c);function o(f){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,$t(e,n,"listItemIndent",i.containerState.size+1)(f)}function c(f){return i.containerState.furtherBlankLines||!Tt(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(qk,n,d)(f))}function d(f){return i.containerState._closeFlow=!0,i.interrupt=void 0,$t(e,e.attempt(wr,n,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function Wk(e,n,a){const i=this;return $t(e,o,"listItemIndent",i.containerState.size+1);function o(c){const d=i.events[i.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===i.containerState.size?n(c):a(c)}}function Gk(e){e.exit(this.containerState.type)}function Vk(e,n,a){const i=this;return $t(e,o,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(c){const d=i.events[i.events.length-1];return!Tt(c)&&d&&d[1].type==="listItemPrefixWhitespace"?n(c):a(c)}}const rg={name:"setextUnderline",resolveTo:Kk,tokenize:Pk};function Kk(e,n){let a=e.length,i,o,c;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),!c&&e[a][1].type==="definition"&&(c=a);const d={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",c?(e.splice(o,0,["enter",d,n]),e.splice(c+1,0,["exit",e[i][1],n]),e[i][1].end={...e[c][1].end}):e[i][1]=d,e.push(["exit",d,n]),e}function Pk(e,n,a){const i=this;let o;return c;function c(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"),Tt(h)?$t(e,m,"lineSuffix")(h):m(h))}function m(h){return h===null||it(h)?(e.exit("setextHeadingLine"),n(h)):a(h)}}const Qk={tokenize:Zk};function Zk(e){const n=this,a=e.attempt(Po,i,e.attempt(this.parser.constructs.flowInitial,o,$t(e,e.attempt(this.parser.constructs.flow,o,e.attempt(rk,o)),"linePrefix")));return a;function i(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),n.currentConstruct=void 0,a}function o(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),n.currentConstruct=void 0,a}}const Jk={resolveAll:ab()},e3=rb("string"),t3=rb("text");function rb(e){return{resolveAll:ab(e==="text"?n3:void 0),tokenize:n};function n(a){const i=this,o=this.parser.constructs[e],c=a.attempt(o,d,f);return d;function d(x){return h(x)?c(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"),c(x)):(a.consume(x),m)}function h(x){if(x===null)return!0;const g=o[x];let w=-1;if(g)for(;++w<g.length;){const b=g[w];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function ab(e){return n;function n(a,i){let o=-1,c;for(;++o<=a.length;)c===void 0?a[o]&&a[o][1].type==="data"&&(c=o,o++):(!a[o]||a[o][1].type!=="data")&&(o!==c+2&&(a[c][1].end=a[o-1][1].end,a.splice(c+2,o-c-2),o=c+2),c=void 0);return e?e(a,i):a}}function n3(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 c=o.length,d=-1,f=0,m;for(;c--;){const h=o[c];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){c++;break}}if(n._contentTypeTextTrailing&&a===e.length&&(f=0),f){const h={type:a===e.length||m||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:c?d:i.start._bufferIndex+d,_index:i.start._index+c,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 r3={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:Py},a3={91:ok},l3={[-2]:fh,[-1]:fh,32:fh},i3={35:mk,42:_u,45:[rg,_u],60:yk,61:rg,95:_u,96:tg,126:tg},s3={38:Zy,92:Qy},o3={[-5]:hh,[-4]:hh,[-3]:hh,33:Bk,38:Zy,42:em,60:[$5,Ck],91:$k,92:[fk,Qy],93:_m,95:em,96:Q5},c3={null:[em,Jk]},u3={null:[42,95]},d3={null:[]},f3=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:u3,contentInitial:a3,disable:d3,document:r3,flow:i3,flowInitial:l3,insideSpan:c3,string:s3,text:o3},Symbol.toStringTag,{value:"Module"}));function h3(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={},c=[];let d=[],f=[];const m={attempt:I(H),check:I(F),consume:C,enter:z,exit:T,interrupt:I(F,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:j,parser:e,previous:null,sliceSerialize:w,sliceStream:b,write:g};let x=n.tokenize.call(h,m);return n.resolveAll&&c.push(n),h;function g($){return d=ta(d,$),E(),d[d.length-1]!==null?[]:(V(n,0),h.events=Zu(c,h.events,h),h.events)}function w($,L){return p3(b($),L)}function b($){return m3(d,$)}function j(){const{_bufferIndex:$,_index:L,line:W,column:ne,offset:K}=i;return{_bufferIndex:$,_index:L,line:W,column:ne,offset:K}}function k($){o[$.line]=$.column,_()}function E(){let $;for(;i._index<d.length;){const L=d[i._index];if(typeof L=="string")for($=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===$&&i._bufferIndex<L.length;)N(L.charCodeAt(i._bufferIndex));else N(L)}}function N($){x=x($)}function C($){it($)?(i.line++,i.column=1,i.offset+=$===-3?2:1,_()):$!==-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=$}function z($,L){const W=L||{};return W.type=$,W.start=j(),h.events.push(["enter",W,h]),f.push(W),W}function T($){const L=f.pop();return L.end=j(),h.events.push(["exit",L,h]),L}function H($,L){V($,L.from)}function F($,L){L.restore()}function I($,L){return W;function W(ne,K,q){let ie,de,me,D;return Array.isArray(ne)?Y(ne):"tokenize"in ne?Y([ne]):U(ne);function U(te){return Se;function Se(je){const _e=je!==null&&te[je],Oe=je!==null&&te.null,Xe=[...Array.isArray(_e)?_e:_e?[_e]:[],...Array.isArray(Oe)?Oe:Oe?[Oe]:[]];return Y(Xe)(je)}}function Y(te){return ie=te,de=0,te.length===0?q:R(te[de])}function R(te){return Se;function Se(je){return D=X(),me=te,te.partial||(h.currentConstruct=te),te.name&&h.parser.constructs.disable.null.includes(te.name)?ae():te.tokenize.call(L?Object.assign(Object.create(h),L):h,m,O,ae)(je)}}function O(te){return $(me,D),K}function ae(te){return D.restore(),++de<ie.length?R(ie[de]):q}}}function V($,L){$.resolveAll&&!c.includes($)&&c.push($),$.resolve&&Hr(h.events,L,h.events.length-L,$.resolve(h.events.slice(L),h)),$.resolveTo&&(h.events=$.resolveTo(h.events,h))}function X(){const $=j(),L=h.previous,W=h.currentConstruct,ne=h.events.length,K=Array.from(f);return{from:ne,restore:q};function q(){i=$,h.previous=L,h.currentConstruct=W,h.events.length=ne,f=K,_()}}function _(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function m3(e,n){const a=n.start._index,i=n.start._bufferIndex,o=n.end._index,c=n.end._bufferIndex;let d;if(a===o)d=[e[a].slice(i,c)];else{if(d=e.slice(a,o),i>-1){const f=d[0];typeof f=="string"?d[0]=f.slice(i):d.shift()}c>0&&d.push(e[o].slice(0,c))}return d}function p3(e,n){let a=-1;const i=[];let o;for(;++a<e.length;){const c=e[a];let d;if(typeof c=="string")d=c;else switch(c){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(c)}o=c===-2,i.push(d)}return i.join("")}function x3(e){const i={constructs:Vy([f3,...(e||{}).extensions||[]]),content:o(F5),defined:[],document:o(M5),flow:o(Qk),lazy:{},string:o(e3),text:o(t3)};return i;function o(c){return d;function d(f){return h3(i,c,f)}}}function g3(e){for(;!Jy(e););return e}const ag=/[\0\t\n\r]/g;function y3(){let e=1,n="",a=!0,i;return o;function o(c,d,f){const m=[];let h,x,g,w,b;for(c=n+(typeof c=="string"?c.toString():new TextDecoder(d||void 0).decode(c)),g=0,n="",a&&(c.charCodeAt(0)===65279&&g++,a=void 0);g<c.length;){if(ag.lastIndex=g,h=ag.exec(c),w=h&&h.index!==void 0?h.index:c.length,b=c.charCodeAt(w),!h){n=c.slice(g);break}if(b===10&&g===w&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),g<w&&(m.push(c.slice(g,w)),e+=w-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=w+1}return f&&(i&&m.push(-5),n&&m.push(n),m.push(null)),m}}const b3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function v3(e){return e.replace(b3,w3)}function w3(e,n,a){if(n)return n;if(a.charCodeAt(0)===35){const o=a.charCodeAt(1),c=o===120||o===88;return Ky(a.slice(c?2:1),c?16:10)}return zm(a)||e}const lb={}.hasOwnProperty;function k3(e,n,a){return n&&typeof n=="object"&&(a=n,n=void 0),j3(a)(g3(x3(a).document().write(y3()(e,n,!0))))}function j3(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(qe),autolinkProtocol:X,autolinkEmail:X,atxHeading:c(Ot),blockQuote:c(Oe),characterEscape:X,characterReference:X,codeFenced:c(Xe),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:c(Xe,d),codeText:c(rt,d),codeTextData:X,data:X,codeFlowValue:X,definition:c(De),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:c(We),hardBreakEscape:c(yt),hardBreakTrailing:c(yt),htmlFlow:c(bt,d),htmlFlowData:X,htmlText:c(bt,d),htmlTextData:X,image:c(jt),label:d,link:c(qe),listItem:c(pt),listItemValue:w,listOrdered:c(at,g),listUnordered:c(at),paragraph:c(zt),reference:R,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:c(Ot),strong:c(fe),thematicBreak:c(ve)},exit:{atxHeading:m(),atxHeadingSequence:H,autolink:m(),autolinkEmail:_e,autolinkProtocol:je,blockQuote:m(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:te,characterReference:Se,codeFenced:m(E),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:j,codeFlowValue:_,codeIndented:m(N),codeText:m(K),codeTextData:_,data:_,definition:m(),definitionDestinationString:T,definitionLabelString:C,definitionTitleString:z,emphasis:m(),hardBreakEscape:m(L),hardBreakTrailing:m(L),htmlFlow:m(W),htmlFlowData:_,htmlText:m(ne),htmlTextData:_,image:m(ie),label:me,labelText:de,lineEnding:$,link:m(q),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:O,resourceDestinationString:D,resourceTitleString:U,resource:Y,setextHeading:m(V),setextHeadingLineSequence:I,setextHeadingText:F,strong:m(),thematicBreak:m()}};ib(n,(e||{}).mdastExtensions||[]);const a={};return i;function i(Q){let Z={type:"root",children:[]};const Ee={stack:[Z],tokenStack:[],config:n,enter:f,exit:h,buffer:d,resume:x,data:a},xe=[];let Ae=-1;for(;++Ae<Q.length;)if(Q[Ae][1].type==="listOrdered"||Q[Ae][1].type==="listUnordered")if(Q[Ae][0]==="enter")xe.push(Ae);else{const ze=xe.pop();Ae=o(Q,ze,Ae)}for(Ae=-1;++Ae<Q.length;){const ze=n[Q[Ae][0]];lb.call(ze,Q[Ae][1].type)&&ze[Q[Ae][1].type].call(Object.assign({sliceSerialize:Q[Ae][2].sliceSerialize},Ee),Q[Ae][1])}if(Ee.tokenStack.length>0){const ze=Ee.tokenStack[Ee.tokenStack.length-1];(ze[1]||lg).call(Ee,void 0,ze[0])}for(Z.position={start:$l(Q.length>0?Q[0][1].start:{line:1,column:1,offset:0}),end:$l(Q.length>0?Q[Q.length-2][1].end:{line:1,column:1,offset:0})},Ae=-1;++Ae<n.transforms.length;)Z=n.transforms[Ae](Z)||Z;return Z}function o(Q,Z,Ee){let xe=Z-1,Ae=-1,ze=!1,$e,Le,Ye,st;for(;++xe<=Ee;){const Ke=Q[xe];switch(Ke[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ke[0]==="enter"?Ae++:Ae--,st=void 0;break}case"lineEndingBlank":{Ke[0]==="enter"&&($e&&!st&&!Ae&&!Ye&&(Ye=xe),st=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:st=void 0}if(!Ae&&Ke[0]==="enter"&&Ke[1].type==="listItemPrefix"||Ae===-1&&Ke[0]==="exit"&&(Ke[1].type==="listUnordered"||Ke[1].type==="listOrdered")){if($e){let Re=xe;for(Le=void 0;Re--;){const Ie=Q[Re];if(Ie[1].type==="lineEnding"||Ie[1].type==="lineEndingBlank"){if(Ie[0]==="exit")continue;Le&&(Q[Le][1].type="lineEndingBlank",ze=!0),Ie[1].type="lineEnding",Le=Re}else if(!(Ie[1].type==="linePrefix"||Ie[1].type==="blockQuotePrefix"||Ie[1].type==="blockQuotePrefixWhitespace"||Ie[1].type==="blockQuoteMarker"||Ie[1].type==="listItemIndent"))break}Ye&&(!Le||Ye<Le)&&($e._spread=!0),$e.end=Object.assign({},Le?Q[Le][1].start:Ke[1].end),Q.splice(Le||xe,0,["exit",$e,Ke[2]]),xe++,Ee++}if(Ke[1].type==="listItemPrefix"){const Re={type:"listItem",_spread:!1,start:Object.assign({},Ke[1].start),end:void 0};$e=Re,Q.splice(xe,0,["enter",Re,Ke[2]]),xe++,Ee++,Ye=void 0,st=!0}}}return Q[Z][1]._spread=ze,Ee}function c(Q,Z){return Ee;function Ee(xe){f.call(this,Q(xe),xe),Z&&Z.call(this,xe)}}function d(){this.stack.push({type:"fragment",children:[]})}function f(Q,Z,Ee){this.stack[this.stack.length-1].children.push(Q),this.stack.push(Q),this.tokenStack.push([Z,Ee||void 0]),Q.position={start:$l(Z.start),end:void 0}}function m(Q){return Z;function Z(Ee){Q&&Q.call(this,Ee),h.call(this,Ee)}}function h(Q,Z){const Ee=this.stack.pop(),xe=this.tokenStack.pop();if(xe)xe[0].type!==Q.type&&(Z?Z.call(this,Q,xe[0]):(xe[1]||lg).call(this,Q,xe[0]));else throw new Error("Cannot close `"+Q.type+"` ("+Io({start:Q.start,end:Q.end})+"): it’s not open");Ee.position.end=$l(Q.end)}function x(){return Mm(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function w(Q){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(Q),10),this.data.expectingFirstListItemValue=void 0}}function b(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=Q}function j(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=Q}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function E(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=Q.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function N(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=Q.replace(/(\r?\n|\r)$/g,"")}function C(Q){const Z=this.resume(),Ee=this.stack[this.stack.length-1];Ee.label=Z,Ee.identifier=ha(this.sliceSerialize(Q)).toLowerCase()}function z(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.title=Q}function T(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.url=Q}function H(Q){const Z=this.stack[this.stack.length-1];if(!Z.depth){const Ee=this.sliceSerialize(Q).length;Z.depth=Ee}}function F(){this.data.setextHeadingSlurpLineEnding=!0}function I(Q){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(Q).codePointAt(0)===61?1:2}function V(){this.data.setextHeadingSlurpLineEnding=void 0}function X(Q){const Ee=this.stack[this.stack.length-1].children;let xe=Ee[Ee.length-1];(!xe||xe.type!=="text")&&(xe=be(),xe.position={start:$l(Q.start),end:void 0},Ee.push(xe)),this.stack.push(xe)}function _(Q){const Z=this.stack.pop();Z.value+=this.sliceSerialize(Q),Z.position.end=$l(Q.end)}function $(Q){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ee=Z.children[Z.children.length-1];Ee.position.end=$l(Q.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(Z.type)&&(X.call(this,Q),_.call(this,Q))}function L(){this.data.atHardBreak=!0}function W(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=Q}function ne(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=Q}function K(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=Q}function q(){const Q=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";Q.type+="Reference",Q.referenceType=Z,delete Q.url,delete Q.title}else delete Q.identifier,delete Q.label;this.data.referenceType=void 0}function ie(){const Q=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";Q.type+="Reference",Q.referenceType=Z,delete Q.url,delete Q.title}else delete Q.identifier,delete Q.label;this.data.referenceType=void 0}function de(Q){const Z=this.sliceSerialize(Q),Ee=this.stack[this.stack.length-2];Ee.label=v3(Z),Ee.identifier=ha(Z).toLowerCase()}function me(){const Q=this.stack[this.stack.length-1],Z=this.resume(),Ee=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ee.type==="link"){const xe=Q.children;Ee.children=xe}else Ee.alt=Z}function D(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.url=Q}function U(){const Q=this.resume(),Z=this.stack[this.stack.length-1];Z.title=Q}function Y(){this.data.inReference=void 0}function R(){this.data.referenceType="collapsed"}function O(Q){const Z=this.resume(),Ee=this.stack[this.stack.length-1];Ee.label=Z,Ee.identifier=ha(this.sliceSerialize(Q)).toLowerCase(),this.data.referenceType="full"}function ae(Q){this.data.characterReferenceType=Q.type}function te(Q){const Z=this.sliceSerialize(Q),Ee=this.data.characterReferenceType;let xe;Ee?(xe=Ky(Z,Ee==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):xe=zm(Z);const Ae=this.stack[this.stack.length-1];Ae.value+=xe}function Se(Q){const Z=this.stack.pop();Z.position.end=$l(Q.end)}function je(Q){_.call(this,Q);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(Q)}function _e(Q){_.call(this,Q);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(Q)}function Oe(){return{type:"blockquote",children:[]}}function Xe(){return{type:"code",lang:null,meta:null,value:""}}function rt(){return{type:"inlineCode",value:""}}function De(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function We(){return{type:"emphasis",children:[]}}function Ot(){return{type:"heading",depth:0,children:[]}}function yt(){return{type:"break"}}function bt(){return{type:"html",value:""}}function jt(){return{type:"image",title:null,url:"",alt:null}}function qe(){return{type:"link",title:null,url:"",children:[]}}function at(Q){return{type:"list",ordered:Q.type==="listOrdered",start:null,spread:Q._spread,children:[]}}function pt(Q){return{type:"listItem",spread:Q._spread,checked:null,children:[]}}function zt(){return{type:"paragraph",children:[]}}function fe(){return{type:"strong",children:[]}}function be(){return{type:"text",value:""}}function ve(){return{type:"thematicBreak"}}}function $l(e){return{line:e.line,column:e.column,offset:e.offset}}function ib(e,n){let a=-1;for(;++a<n.length;){const i=n[a];Array.isArray(i)?ib(e,i):S3(e,i)}}function S3(e,n){let a;for(a in n)if(lb.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 lg(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+Io({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+Io({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Io({start:n.start,end:n.end})+") is still open")}function C3(e){const n=this;n.parser=a;function a(i){return k3(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function N3(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 E3(e,n){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,a),[e.applyData(n,a),{type:"text",value:`
|
|
55
|
+
`}]}function A3(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 c={type:"element",tagName:"code",properties:i,children:[{type:"text",value:a}]};return n.meta&&(c.data={meta:n.meta}),e.patch(n,c),c=e.applyData(n,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(n,c),c}function D3(e,n){const a={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function T3(e,n){const a={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function F3(e,n){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),o=Ns(i.toLowerCase()),c=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=c+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 R3(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 M3(e,n){if(e.options.allowDangerousHtml){const a={type:"raw",value:n.value};return e.patch(n,a),e.applyData(n,a)}}function sb(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),c=o[0];c&&c.type==="text"?c.value="["+c.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 z3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return sb(e,n);const o={src:Ns(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(o.title=i.title);const c={type:"element",tagName:"img",properties:o,children:[]};return e.patch(n,c),e.applyData(n,c)}function _3(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 B3(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 O3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return sb(e,n);const o={href:Ns(i.url||"")};i.title!==null&&i.title!==void 0&&(o.title=i.title);const c={type:"element",tagName:"a",properties:o,children:e.all(n)};return e.patch(n,c),e.applyData(n,c)}function $3(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 L3(e,n,a){const i=e.all(n),o=a?I3(a):ob(n),c={},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:[]}),c.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:c,children:d};return e.patch(n,h),e.applyData(n,h)}function I3(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=ob(a[i])}return n}function ob(e){const n=e.spread;return n??e.children.length>1}function H3(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 c={type:"element",tagName:n.ordered?"ol":"ul",properties:a,children:e.wrap(i,!0)};return e.patch(n,c),e.applyData(n,c)}function U3(e,n){const a={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function q3(e,n){const a={type:"root",children:e.wrap(e.all(n))};return e.patch(n,a),e.applyData(n,a)}function Y3(e,n){const a={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function X3(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=Dm(n.children[1]),m=Hy(n.children[n.children.length-1]);f&&m&&(d.position={start:f,end:m}),o.push(d)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(n,c),e.applyData(n,c)}function W3(e,n,a){const i=a?a.children:void 0,c=(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],w={},b=d?d[m]:void 0;b&&(w.align=b);let j={type:"element",tagName:c,properties:w,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 G3(e,n){const a={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}const ig=9,sg=32;function V3(e){const n=String(e),a=/\r?\n|\r/g;let i=a.exec(n),o=0;const c=[];for(;i;)c.push(og(n.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=a.exec(n);return c.push(og(n.slice(o),o>0,!1)),c.join("")}function og(e,n,a){let i=0,o=e.length;if(n){let c=e.codePointAt(i);for(;c===ig||c===sg;)i++,c=e.codePointAt(i)}if(a){let c=e.codePointAt(o-1);for(;c===ig||c===sg;)o--,c=e.codePointAt(o-1)}return o>i?e.slice(i,o):""}function K3(e,n){const a={type:"text",value:V3(String(n.value))};return e.patch(n,a),e.applyData(n,a)}function P3(e,n){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,a),e.applyData(n,a)}const Q3={blockquote:N3,break:E3,code:A3,delete:D3,emphasis:T3,footnoteReference:F3,heading:R3,html:M3,imageReference:z3,image:_3,inlineCode:B3,linkReference:O3,link:$3,listItem:L3,list:H3,paragraph:U3,root:q3,strong:Y3,table:X3,tableCell:G3,tableRow:W3,text:K3,thematicBreak:P3,toml:gu,yaml:gu,definition:gu,footnoteDefinition:gu};function gu(){}const cb=-1,Ju=0,Uo=1,Hu=2,Bm=3,Om=4,$m=5,Lm=6,ub=7,db=8,cg=typeof self=="object"?self:globalThis,Z3=(e,n)=>{const a=(o,c)=>(e.set(c,o),o),i=o=>{if(e.has(o))return e.get(o);const[c,d]=n[o];switch(c){case Ju:case cb:return a(d,o);case Uo:{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 Bm:return a(new Date(d),o);case Om:{const{source:f,flags:m}=d;return a(new RegExp(f,m),o)}case $m:{const f=a(new Map,o);for(const[m,h]of d)f.set(i(m),i(h));return f}case Lm:{const f=a(new Set,o);for(const m of d)f.add(i(m));return f}case ub:{const{name:f,message:m}=d;return a(new cg[f](m),o)}case db: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 cg[c](d),o)};return i},ug=e=>Z3(new Map,e)(0),ps="",{toString:J3}={},{keys:e4}=Object,To=e=>{const n=typeof e;if(n!=="object"||!e)return[Ju,n];const a=J3.call(e).slice(8,-1);switch(a){case"Array":return[Uo,ps];case"Object":return[Hu,ps];case"Date":return[Bm,ps];case"RegExp":return[Om,ps];case"Map":return[$m,ps];case"Set":return[Lm,ps];case"DataView":return[Uo,a]}return a.includes("Array")?[Uo,a]:a.includes("Error")?[ub,a]:[Hu,a]},yu=([e,n])=>e===Ju&&(n==="function"||n==="symbol"),t4=(e,n,a,i)=>{const o=(d,f)=>{const m=i.push(d)-1;return a.set(f,m),m},c=d=>{if(a.has(d))return a.get(d);let[f,m]=To(d);switch(f){case Ju:{let x=d;switch(m){case"bigint":f=db,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([cb],d)}return o([f,x],d)}case Uo:{if(m){let w=d;return m==="DataView"?w=new Uint8Array(d.buffer):m==="ArrayBuffer"&&(w=new Uint8Array(d)),o([m,[...w]],d)}const x=[],g=o([f,x],d);for(const w of d)x.push(c(w));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 c(d.toJSON());const x=[],g=o([f,x],d);for(const w of e4(d))(e||!yu(To(d[w])))&&x.push([c(w),c(d[w])]);return g}case Bm:return o([f,d.toISOString()],d);case Om:{const{source:x,flags:g}=d;return o([f,{source:x,flags:g}],d)}case $m:{const x=[],g=o([f,x],d);for(const[w,b]of d)(e||!(yu(To(w))||yu(To(b))))&&x.push([c(w),c(b)]);return g}case Lm:{const x=[],g=o([f,x],d);for(const w of d)(e||!yu(To(w)))&&x.push(c(w));return g}}const{message:h}=d;return o([f,{name:m,message:h}],d)};return c},dg=(e,{json:n,lossy:a}={})=>{const i=[];return t4(!(n||a),!!n,new Map,i)(e),i},Uu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?ug(dg(e,n)):structuredClone(e):(e,n)=>ug(dg(e,n));function n4(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 r4(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function a4(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||n4,i=e.options.footnoteBackLabel||r4,o=e.options.footnoteLabel||"Footnotes",c=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(),w=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-"+w+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(m,b),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const E=x[x.length-1];if(E&&E.type==="element"&&E.tagName==="p"){const C=E.children[E.children.length-1];C&&C.type==="text"?C.value+=" ":E.children.push({type:"text",value:" "}),E.children.push(...j)}else x.push(...j);const N={type:"element",tagName:"li",properties:{id:n+"fn-"+w},children:e.wrap(x,!0)};e.patch(h,N),f.push(N)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,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 o4;if(typeof e=="function")return td(e);if(typeof e=="object")return Array.isArray(e)?l4(e):i4(e);if(typeof e=="string")return s4(e);throw new Error("Expected function, string, or object as test")});function l4(e){const n=[];let a=-1;for(;++a<e.length;)n[a]=ed(e[a]);return td(i);function i(...o){let c=-1;for(;++c<n.length;)if(n[c].apply(this,o))return!0;return!1}}function i4(e){const n=e;return td(a);function a(i){const o=i;let c;for(c in e)if(o[c]!==n[c])return!1;return!0}}function s4(e){return td(n);function n(a){return a&&a.type===e}}function td(e){return n;function n(a,i,o){return!!(c4(a)&&e.call(this,a,typeof i=="number"?i:void 0,o||void 0))}}function o4(){return!0}function c4(e){return e!==null&&typeof e=="object"&&"type"in e}const fb=[],u4=!0,tm=!1,d4="skip";function hb(e,n,a,i){let o;typeof n=="function"&&typeof a!="function"?(i=a,a=n):o=n;const c=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(w,"name",{value:"node ("+(m.type+(b?"<"+b+">":""))+")"})}return w;function w(){let b=fb,j,k,E;if((!n||c(m,h,x[x.length-1]||void 0))&&(b=f4(a(m,x)),b[0]===tm))return b;if("children"in m&&m.children){const N=m;if(N.children&&b[0]!==d4)for(k=(i?N.children.length:-1)+d,E=x.concat(N);k>-1&&k<N.children.length;){const C=N.children[k];if(j=f(C,k,E)(),j[0]===tm)return j;k=typeof j[1]=="number"?j[1]:k+d}}return b}}}function f4(e){return Array.isArray(e)?e:typeof e=="number"?[u4,e]:e==null?fb:[e]}function Im(e,n,a,i){let o,c,d;typeof n=="function"&&typeof a!="function"?(c=void 0,d=n,o=a):(c=n,d=a,o=i),hb(e,c,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 nm={}.hasOwnProperty,h4={};function m4(e,n){const a=n||h4,i=new Map,o=new Map,c=new Map,d={...Q3,...a.handlers},f={all:h,applyData:x4,definitionById:i,footnoteById:o,footnoteCounts:c,footnoteOrder:[],handlers:d,one:m,options:a,patch:p4,wrap:y4};return Im(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const g=x.type==="definition"?i:o,w=String(x.identifier).toUpperCase();g.has(w)||g.set(w,x)}}),f;function m(x,g){const w=x.type,b=f.handlers[w];if(nm.call(f.handlers,w)&&b)return b(f,x,g);if(f.options.passThrough&&f.options.passThrough.includes(w)){if("children"in x){const{children:k,...E}=x,N=Uu(E);return N.children=f.all(x),N}return Uu(x)}return(f.options.unknownHandler||g4)(f,x,g)}function h(x){const g=[];if("children"in x){const w=x.children;let b=-1;for(;++b<w.length;){const j=f.one(w[b],x);if(j){if(b&&w[b-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=fg(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=fg(k.value))}Array.isArray(j)?g.push(...j):g.push(j)}}}return g}}function p4(e,n){e.position&&(n.position=r5(e))}function x4(e,n){let a=n;if(e&&e.data){const i=e.data.hName,o=e.data.hChildren,c=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"&&c&&Object.assign(a.properties,Uu(c)),"children"in a&&a.children&&o!==null&&o!==void 0&&(a.children=o)}return a}function g4(e,n){const a=n.data||{},i="value"in n&&!(nm.call(a,"hProperties")||nm.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 y4(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 fg(e){let n=0,a=e.charCodeAt(n);for(;a===9||a===32;)n++,a=e.charCodeAt(n);return e.slice(n)}function hg(e,n){const a=m4(e,n),i=a.one(e,void 0),o=a4(a),c=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return o&&c.children.push({type:"text",value:`
|
|
64
|
+
`},o),c}function b4(e,n){return e&&"run"in e?async function(a,i){const o=hg(a,{file:i,...n});await e.run(o,i)}:function(a,i){return hg(a,{file:i,...e||n})}}function mg(e){if(e)throw e}var mh,pg;function v4(){if(pg)return mh;pg=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]"},c=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 w;for(w in h);return typeof w>"u"||e.call(h,w)},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 mh=function m(){var h,x,g,w,b,j,k=arguments[0],E=1,N=arguments.length,C=!1;for(typeof k=="boolean"&&(C=k,k=arguments[1]||{},E=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});E<N;++E)if(h=arguments[E],h!=null)for(x in h)g=f(k,x),w=f(h,x),k!==w&&(C&&w&&(c(w)||(b=o(w)))?(b?(b=!1,j=g&&o(g)?g:[]):j=g&&c(g)?g:{},d(k,{name:x,newValue:m(C,j,w)})):typeof w<"u"&&d(k,{name:x,newValue:w}));return k},mh}var w4=v4();const ph=Ty(w4);function rm(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 k4(){const e=[],n={run:a,use:i};return n;function a(...o){let c=-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[++c];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?j4(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 j4(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(c,o):m instanceof Error?o(m):c(m))}function o(d,...f){a||(a=!0,n(d,...f))}function c(d){o(null,d)}}const Aa={basename:S4,dirname:C4,extname:N4,join:E4,sep:"/"};function S4(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Qo(e);let a=0,i=-1,o=e.length,c;if(n===void 0||n.length===0||n.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){a=o+1;break}}else i<0&&(c=!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(c){a=o+1;break}}else d<0&&(c=!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 C4(e){if(Qo(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 N4(e){Qo(e);let n=e.length,a=-1,i=0,o=-1,c=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:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||a<0||c===0||c===1&&o===a-1&&o===i+1?"":e.slice(o,a)}function E4(...e){let n=-1,a;for(;++n<e.length;)Qo(e[n]),e[n]&&(a=a===void 0?e[n]:a+"/"+e[n]);return a===void 0?".":A4(a)}function A4(e){Qo(e);const n=e.codePointAt(0)===47;let a=D4(e,!n);return a.length===0&&!n&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),n?"/"+a:a}function D4(e,n){let a="",i=0,o=-1,c=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||c===1))if(o!==d-1&&c===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,c=0;continue}}else if(a.length>0){a="",i=0,o=d,c=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,c=0}else f===46&&c>-1?c++:c=-1}return a}function Qo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const T4={cwd:F4};function F4(){return"/"}function am(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function R4(e){if(typeof e=="string")e=new URL(e);else if(!am(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 M4(e)}function M4(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 xh=["history","path","basename","stem","extname","dirname"];class mb{constructor(n){let a;n?am(n)?a={path:n}:typeof n=="string"||z4(n)?a={value:n}:a=n:a={},this.cwd="cwd"in a?"":T4.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<xh.length;){const c=xh[i];c in a&&a[c]!==void 0&&a[c]!==null&&(this[c]=c==="history"?[...a[c]]:a[c])}let o;for(o in a)xh.includes(o)||(this[o]=a[o])}get basename(){return typeof this.path=="string"?Aa.basename(this.path):void 0}set basename(n){yh(n,"basename"),gh(n,"basename"),this.path=Aa.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?Aa.dirname(this.path):void 0}set dirname(n){xg(this.basename,"dirname"),this.path=Aa.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?Aa.extname(this.path):void 0}set extname(n){if(gh(n,"extname"),xg(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=Aa.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){am(n)&&(n=R4(n)),yh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?Aa.basename(this.path,this.extname):void 0}set stem(n){yh(n,"stem"),gh(n,"stem"),this.path=Aa.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 sr(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 gh(e,n){if(e&&e.includes(Aa.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+Aa.sep+"`")}function yh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function xg(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function z4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const _4=(function(e){const i=this.constructor.prototype,o=i[e],c=function(){return o.apply(c,arguments)};return Object.setPrototypeOf(c,i),c}),B4={}.hasOwnProperty;class Hm extends _4{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=k4()}copy(){const n=new Hm;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];n.use(...i)}return n.data(ph(!0,{},this.namespace)),n}data(n,a){return typeof n=="string"?arguments.length===2?(wh("data",this.frozen),this.namespace[n]=a,this):B4.call(this.namespace,n)&&this.namespace[n]||void 0:n?(wh("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=bu(n),i=this.parser||this.Parser;return bh("parse",i),i(String(a),a)}process(n,a){const i=this;return this.freeze(),bh("process",this.parser||this.Parser),vh("process",this.compiler||this.Compiler),a?o(void 0,a):new Promise(o);function o(c,d){const f=bu(n),m=i.parse(f);i.run(m,f,function(x,g,w){if(x||!g||!w)return h(x);const b=g,j=i.stringify(b,w);L4(j)?w.value=j:w.result=j,h(x,w)});function h(x,g){x||!g?d(x):c?c(g):a(void 0,g)}}}processSync(n){let a=!1,i;return this.freeze(),bh("processSync",this.parser||this.Parser),vh("processSync",this.compiler||this.Compiler),this.process(n,o),yg("processSync","process",a),i;function o(c,d){a=!0,mg(c),i=d}}run(n,a,i){gg(n),this.freeze();const o=this.transformers;return!i&&typeof a=="function"&&(i=a,a=void 0),i?c(void 0,i):new Promise(c);function c(d,f){const m=bu(a);o.run(n,m,h);function h(x,g,w){const b=g||n;x?f(x):d?d(b):i(void 0,b,w)}}}runSync(n,a){let i=!1,o;return this.run(n,a,c),yg("runSync","run",i),o;function c(d,f){mg(d),o=f,i=!0}}stringify(n,a){this.freeze();const i=bu(a),o=this.compiler||this.Compiler;return vh("stringify",o),gg(n),o(n,i)}use(n,...a){const i=this.attachers,o=this.namespace;if(wh("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 c(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=ph(!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];c(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function m(h,x){let g=-1,w=-1;for(;++g<i.length;)if(i[g][0]===h){w=g;break}if(w===-1)i.push([h,...x]);else if(x.length>0){let[b,...j]=x;const k=i[w][1];rm(k)&&rm(b)&&(b=ph(!0,k,b)),i[w]=[h,b,...j]}}}}const O4=new Hm().freeze();function bh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function vh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function wh(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 gg(e){if(!rm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function yg(e,n,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function bu(e){return $4(e)?e:new mb(e)}function $4(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function L4(e){return typeof e=="string"||I4(e)}function I4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const H4="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",bg=[],vg={allowDangerousHtml:!0},U4=/^(https?|ircs?|mailto|xmpp)$/i,q4=[{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 Um(e){const n=Y4(e),a=X4(e);return W4(n.runSync(n.parse(a),a),e)}function Y4(e){const n=e.rehypePlugins||bg,a=e.remarkPlugins||bg,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...vg}:vg;return O4().use(C3).use(a).use(b4,i).use(n)}function X4(e){const n=e.children||"",a=new mb;return typeof n=="string"&&(a.value=n),a}function W4(e,n){const a=n.allowedElements,i=n.allowElement,o=n.components,c=n.disallowedElements,d=n.skipHtml,f=n.unwrapDisallowed,m=n.urlTransform||G4;for(const x of q4)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+H4+x.id,void 0);return Im(e,h),o5(e,{Fragment:l.Fragment,components:o,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function h(x,g,w){if(x.type==="raw"&&w&&typeof g=="number")return d?w.children.splice(g,1):w.children[g]={type:"text",value:x.value},g;if(x.type==="element"){let b;for(b in dh)if(Object.hasOwn(dh,b)&&Object.hasOwn(x.properties,b)){const j=x.properties[b],k=dh[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):c?c.includes(x.tagName):!1;if(!b&&i&&typeof g=="number"&&(b=!i(x,g,w)),b&&w&&typeof g=="number")return f&&x.children?w.children.splice(g,1,...x.children):w.children.splice(g,1),g}}}function G4(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||U4.test(e.slice(0,n))?e:""}function wg(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 V4(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function K4(e,n,a){const o=ed((a||{}).ignore||[]),c=P4(n);let d=-1;for(;++d<c.length;)hb(e,"text",f);function f(h,x){let g=-1,w;for(;++g<x.length;){const b=x[g],j=w?w.children:void 0;if(o(b,j?j.indexOf(b):void 0,w))return;w=b}if(w)return m(h,x)}function m(h,x){const g=x[x.length-1],w=c[d][0],b=c[d][1];let j=0;const E=g.children.indexOf(h);let N=!1,C=[];w.lastIndex=0;let z=w.exec(h.value);for(;z;){const T=z.index,H={index:z.index,input:z.input,stack:[...x,h]};let F=b(...z,H);if(typeof F=="string"&&(F=F.length>0?{type:"text",value:F}:void 0),F===!1?w.lastIndex=T+1:(j!==T&&C.push({type:"text",value:h.value.slice(j,T)}),Array.isArray(F)?C.push(...F):F&&C.push(F),j=T+z[0].length,N=!0),!w.global)break;z=w.exec(h.value)}return N?(j<h.value.length&&C.push({type:"text",value:h.value.slice(j)}),g.children.splice(E,1,...C)):C=[h],E+C.length}}function P4(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([Q4(o[0]),Z4(o[1])])}return n}function Q4(e){return typeof e=="string"?new RegExp(V4(e),"g"):e}function Z4(e){return typeof e=="function"?e:function(){return e}}const kh="phrasing",jh=["autolink","link","image","label"];function J4(){return{transforms:[ij],enter:{literalAutolink:tj,literalAutolinkEmail:Sh,literalAutolinkHttp:Sh,literalAutolinkWww:Sh},exit:{literalAutolink:lj,literalAutolinkEmail:aj,literalAutolinkHttp:nj,literalAutolinkWww:rj}}}function ej(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:kh,notInConstruct:jh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:kh,notInConstruct:jh},{character:":",before:"[ps]",after:"\\/",inConstruct:kh,notInConstruct:jh}]}}function tj(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Sh(e){this.config.enter.autolinkProtocol.call(this,e)}function nj(e){this.config.exit.autolinkProtocol.call(this,e)}function rj(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 aj(e){this.config.exit.autolinkEmail.call(this,e)}function lj(e){this.exit(e)}function ij(e){K4(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,sj],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),oj]],{ignore:["link","linkReference"]})}function sj(e,n,a,i,o){let c="";if(!pb(o)||(/^w/i.test(n)&&(a=n+a,n="",c="http://"),!cj(a)))return!1;const d=uj(a+i);if(!d[0])return!1;const f={type:"link",title:null,url:c+n+d[0],children:[{type:"text",value:n+d[0]}]};return d[1]?[f,{type:"text",value:d[1]}]:f}function oj(e,n,a,i){return!pb(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+a,children:[{type:"text",value:n+"@"+a}]}}function cj(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 uj(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=wg(e,"(");let c=wg(e,")");for(;i!==-1&&o>c;)e+=a.slice(0,i+1),a=a.slice(i+1),i=a.indexOf(")"),c++;return[e,a]}function pb(e,n){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Ei(a)||Qu(a))&&(!n||a!==47)}xb.peek=bj;function dj(){this.buffer()}function fj(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function hj(){this.buffer()}function mj(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function pj(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=ha(this.sliceSerialize(e)).toLowerCase(),a.label=n}function xj(e){this.exit(e)}function gj(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=ha(this.sliceSerialize(e)).toLowerCase(),a.label=n}function yj(e){this.exit(e)}function bj(){return"["}function xb(e,n,a,i){const o=a.createTracker(i);let c=o.move("[^");const d=a.enter("footnoteReference"),f=a.enter("reference");return c+=o.move(a.safe(a.associationId(e),{after:"]",before:c})),f(),d(),c+=o.move("]"),c}function vj(){return{enter:{gfmFootnoteCallString:dj,gfmFootnoteCall:fj,gfmFootnoteDefinitionLabelString:hj,gfmFootnoteDefinition:mj},exit:{gfmFootnoteCallString:pj,gfmFootnoteCall:xj,gfmFootnoteDefinitionLabelString:gj,gfmFootnoteDefinition:yj}}}function wj(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:a,footnoteReference:xb},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,o,c,d){const f=c.createTracker(d);let m=f.move("[^");const h=c.enter("footnoteDefinition"),x=c.enter("label");return m+=f.move(c.safe(c.associationId(i),{before:m,after:"]"})),x(),m+=f.move("]:"),i.children&&i.children.length>0&&(f.shift(4),m+=f.move((n?`
|
|
65
|
+
`:" ")+c.indentLines(c.containerFlow(i,f.current()),n?gb:kj))),h(),m}}function kj(e,n,a){return n===0?e:gb(e,n,a)}function gb(e,n,a){return(a?"":" ")+e}const jj=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];yb.peek=Aj;function Sj(){return{canContainEols:["delete"],enter:{strikethrough:Nj},exit:{strikethrough:Ej}}}function Cj(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:jj}],handlers:{delete:yb}}}function Nj(e){this.enter({type:"delete",children:[]},e)}function Ej(e){this.exit(e)}function yb(e,n,a,i){const o=a.createTracker(i),c=a.enter("strikethrough");let d=o.move("~~");return d+=a.containerPhrasing(e,{...o.current(),before:d,after:"~"}),d+=o.move("~~"),c(),d}function Aj(){return"~"}function Dj(e){return e.length}function Tj(e,n){const a=n||{},i=(a.align||[]).concat(),o=a.stringLength||Dj,c=[],d=[],f=[],m=[];let h=0,x=-1;for(;++x<e.length;){const k=[],E=[];let N=-1;for(e[x].length>h&&(h=e[x].length);++N<e[x].length;){const C=Fj(e[x][N]);if(a.alignDelimiters!==!1){const z=o(C);E[N]=z,(m[N]===void 0||z>m[N])&&(m[N]=z)}k.push(C)}d[x]=k,f[x]=E}let g=-1;if(typeof i=="object"&&"length"in i)for(;++g<h;)c[g]=kg(i[g]);else{const k=kg(i);for(;++g<h;)c[g]=k}g=-1;const w=[],b=[];for(;++g<h;){const k=c[g];let E="",N="";k===99?(E=":",N=":"):k===108?E=":":k===114&&(N=":");let C=a.alignDelimiters===!1?1:Math.max(1,m[g]-E.length-N.length);const z=E+"-".repeat(C)+N;a.alignDelimiters!==!1&&(C=E.length+C+N.length,C>m[g]&&(m[g]=C),b[g]=C),w[g]=z}d.splice(1,0,w),f.splice(1,0,b),x=-1;const j=[];for(;++x<d.length;){const k=d[x],E=f[x];g=-1;const N=[];for(;++g<h;){const C=k[g]||"";let z="",T="";if(a.alignDelimiters!==!1){const H=m[g]-(E[g]||0),F=c[g];F===114?z=" ".repeat(H):F===99?H%2?(z=" ".repeat(H/2+.5),T=" ".repeat(H/2-.5)):(z=" ".repeat(H/2),T=z):T=" ".repeat(H)}a.delimiterStart!==!1&&!g&&N.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&C==="")&&(a.delimiterStart!==!1||g)&&N.push(" "),a.alignDelimiters!==!1&&N.push(z),N.push(C),a.alignDelimiters!==!1&&N.push(T),a.padding!==!1&&N.push(" "),(a.delimiterEnd!==!1||g!==h-1)&&N.push("|")}j.push(a.delimiterEnd===!1?N.join("").replace(/ +$/,""):N.join(""))}return j.join(`
|
|
66
|
+
`)}function Fj(e){return e==null?"":String(e)}function kg(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 Rj(e,n,a,i){const o=a.enter("blockquote"),c=a.createTracker(i);c.move("> "),c.shift(2);const d=a.indentLines(a.containerFlow(e,c.current()),Mj);return o(),d}function Mj(e,n,a){return">"+(a?"":" ")+e}function zj(e,n){return jg(e,n.inConstruct,!0)&&!jg(e,n.notInConstruct,!1)}function jg(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 Sg(e,n,a,i){let o=-1;for(;++o<a.unsafe.length;)if(a.unsafe[o].character===`
|
|
67
|
+
`&&zj(a.stack,a.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
68
|
+
`}function _j(e,n){const a=String(e);let i=a.indexOf(n),o=i,c=0,d=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===o?++c>d&&(d=c):c=1,o=i+n.length,i=a.indexOf(n,o);return d}function Bj(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 Oj(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 $j(e,n,a,i){const o=Oj(a),c=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(Bj(e,a)){const g=a.enter("codeIndented"),w=a.indentLines(c,Lj);return g(),w}const f=a.createTracker(i),m=o.repeat(Math.max(_j(c,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
|
+
`),c&&(x+=f.move(c+`
|
|
71
|
+
`)),x+=f.move(m),h(),x}function Lj(e,n,a){return(a?"":" ")+e}function qm(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 Ij(e,n,a,i){const o=qm(a),c=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${c}`),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 Hj(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 Xo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function qu(e,n,a){const i=vs(e),o=vs(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}}bb.peek=Uj;function bb(e,n,a,i){const o=Hj(a),c=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=Xo(h)+m.slice(1));const g=m.charCodeAt(m.length-1),w=qu(i.after.charCodeAt(0),g,o);w.inside&&(m=m.slice(0,-1)+Xo(g));const b=d.move(o);return c(),a.attentionEncodeSurroundingInfo={after:w.outside,before:x.outside},f+m+b}function Uj(e,n,a){return a.options.emphasis||"*"}function qj(e,n){let a=!1;return Im(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,tm}),!!((!e.depth||e.depth<3)&&Mm(e)&&(n.options.setext||a))}function Yj(e,n,a,i){const o=Math.max(Math.min(6,e.depth||1),1),c=a.createTracker(i);if(qj(e,a)){const x=a.enter("headingSetext"),g=a.enter("phrasing"),w=a.containerPhrasing(e,{...c.current(),before:`
|
|
73
|
+
`,after:`
|
|
74
|
+
`});return g(),x(),w+`
|
|
75
|
+
`+(o===1?"=":"-").repeat(w.length-(Math.max(w.lastIndexOf("\r"),w.lastIndexOf(`
|
|
76
|
+
`))+1))}const d="#".repeat(o),f=a.enter("headingAtx"),m=a.enter("phrasing");c.move(d+" ");let h=a.containerPhrasing(e,{before:"# ",after:`
|
|
77
|
+
`,...c.current()});return/^[\t ]/.test(h)&&(h=Xo(h.charCodeAt(0))+h.slice(1)),h=h?d+" "+h:d,a.options.closeAtx&&(h+=" "+d),m(),f(),h}vb.peek=Xj;function vb(e){return e.value||""}function Xj(){return"<"}wb.peek=Wj;function wb(e,n,a,i){const o=qm(a),c=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${c}`),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 Wj(){return"!"}kb.peek=Gj;function kb(e,n,a,i){const o=e.referenceType,c=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,c(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function Gj(){return"!"}jb.peek=Vj;function jb(e,n,a){let i=e.value||"",o="`",c=-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+" ");++c<a.unsafe.length;){const d=a.unsafe[c],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 Vj(){return"`"}function Sb(e,n){const a=Mm(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))}Cb.peek=Kj;function Cb(e,n,a,i){const o=qm(a),c=o==='"'?"Quote":"Apostrophe",d=a.createTracker(i);let f,m;if(Sb(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${c}`),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 Kj(e,n,a){return Sb(e,a)?"<":"["}Nb.peek=Pj;function Nb(e,n,a,i){const o=e.referenceType,c=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,c(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function Pj(){return"["}function Ym(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 Qj(e){const n=Ym(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 Zj(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 Eb(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 Jj(e,n,a,i){const o=a.enter("list"),c=a.bulletCurrent;let d=e.ordered?Zj(a):Ym(a);const f=e.ordered?d==="."?")":".":Qj(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),Eb(a)===d&&x){let g=-1;for(;++g<e.children.length;){const w=e.children[g];if(w&&w.type==="listItem"&&w.children&&w.children[0]&&w.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=c,o(),h}function eS(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 tS(e,n,a,i){const o=eS(a);let c=a.bulletCurrent||Ym(a);n&&n.type==="list"&&n.ordered&&(c=(typeof n.start=="number"&&n.start>-1?n.start:1)+(a.options.incrementListMarker===!1?0:n.children.indexOf(e))+c);let d=c.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(c+" ".repeat(d-c.length)),f.shift(d);const m=a.enter("listItem"),h=a.indentLines(a.containerFlow(e,f.current()),x);return m(),h;function x(g,w,b){return w?(b?"":" ".repeat(d))+g:(b?c:c+" ".repeat(d-c.length))+g}}function nS(e,n,a,i){const o=a.enter("paragraph"),c=a.enter("phrasing"),d=a.containerPhrasing(e,i);return c(),o(),d}const rS=ed(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function aS(e,n,a,i){return(e.children.some(function(d){return rS(d)})?a.containerPhrasing:a.containerFlow).call(a,e,i)}function lS(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}Ab.peek=iS;function Ab(e,n,a,i){const o=lS(a),c=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=Xo(h)+m.slice(1));const g=m.charCodeAt(m.length-1),w=qu(i.after.charCodeAt(0),g,o);w.inside&&(m=m.slice(0,-1)+Xo(g));const b=d.move(o+o);return c(),a.attentionEncodeSurroundingInfo={after:w.outside,before:x.outside},f+m+b}function iS(e,n,a){return a.options.strong||"*"}function sS(e,n,a,i){return a.safe(e.value,i)}function oS(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 cS(e,n,a){const i=(Eb(a)+(a.options.ruleSpaces?" ":"")).repeat(oS(a));return a.options.ruleSpaces?i.slice(0,-1):i}const Db={blockquote:Rj,break:Sg,code:$j,definition:Ij,emphasis:bb,hardBreak:Sg,heading:Yj,html:vb,image:wb,imageReference:kb,inlineCode:jb,link:Cb,linkReference:Nb,list:Jj,listItem:tS,paragraph:nS,root:aS,strong:Ab,text:sS,thematicBreak:cS};function uS(){return{enter:{table:dS,tableData:Cg,tableHeader:Cg,tableRow:hS},exit:{codeText:mS,table:fS,tableData:Ch,tableHeader:Ch,tableRow:Ch}}}function dS(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 fS(e){this.exit(e),this.data.inTable=void 0}function hS(e){this.enter({type:"tableRow",children:[]},e)}function Ch(e){this.exit(e)}function Cg(e){this.enter({type:"tableCell",children:[]},e)}function mS(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,pS));const a=this.stack[this.stack.length-1];a.type,a.value=n,this.exit(e)}function pS(e,n){return n==="|"?n:e}function xS(e){const n=e||{},a=n.tableCellPadding,i=n.tablePipeAlign,o=n.stringLength,c=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:w,table:d,tableCell:m,tableRow:f}};function d(b,j,k,E){return h(x(b,k,E),b.align)}function f(b,j,k,E){const N=g(b,k,E),C=h([N]);return C.slice(0,C.indexOf(`
|
|
79
|
+
`))}function m(b,j,k,E){const N=k.enter("tableCell"),C=k.enter("phrasing"),z=k.containerPhrasing(b,{...E,before:c,after:c});return C(),N(),z}function h(b,j){return Tj(b,{align:j,alignDelimiters:i,padding:a,stringLength:o})}function x(b,j,k){const E=b.children;let N=-1;const C=[],z=j.enter("table");for(;++N<E.length;)C[N]=g(E[N],j,k);return z(),C}function g(b,j,k){const E=b.children;let N=-1;const C=[],z=j.enter("tableRow");for(;++N<E.length;)C[N]=m(E[N],b,j,k);return z(),C}function w(b,j,k){let E=Db.inlineCode(b,j,k);return k.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function gS(){return{exit:{taskListCheckValueChecked:Ng,taskListCheckValueUnchecked:Ng,paragraph:bS}}}function yS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:vS}}}function Ng(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function bS(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 c=-1,d;for(;++c<o.length;){const f=o[c];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 vS(e,n,a,i){const o=e.children[0],c=typeof e.checked=="boolean"&&o&&o.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",f=a.createTracker(i);c&&f.move(d);let m=Db.listItem(e,n,a,{...i,...f.current()});return c&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),m;function h(x){return x+d}}function wS(){return[J4(),vj(),Sj(),uS(),gS()]}function kS(e){return{extensions:[ej(),wj(e),Cj(),xS(e),yS()]}}const jS={tokenize:DS,partial:!0},Tb={tokenize:TS,partial:!0},Fb={tokenize:FS,partial:!0},Rb={tokenize:RS,partial:!0},SS={tokenize:MS,partial:!0},Mb={name:"wwwAutolink",tokenize:ES,previous:_b},zb={name:"protocolAutolink",tokenize:AS,previous:Bb},dl={name:"emailAutolink",tokenize:NS,previous:Ob},za={};function CS(){return{text:za}}let gi=48;for(;gi<123;)za[gi]=dl,gi++,gi===58?gi=65:gi===91&&(gi=97);za[43]=dl;za[45]=dl;za[46]=dl;za[95]=dl;za[72]=[dl,zb];za[104]=[dl,zb];za[87]=[dl,Mb];za[119]=[dl,Mb];function NS(e,n,a){const i=this;let o,c;return d;function d(g){return!lm(g)||!Ob.call(i,i.previous)||Xm(i.events)?a(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return lm(g)?(e.consume(g),f):g===64?(e.consume(g),m):a(g)}function m(g){return g===46?e.check(SS,x,h)(g):g===45||g===95||ir(g)?(c=!0,e.consume(g),m):x(g)}function h(g){return e.consume(g),o=!0,m}function x(g){return c&&o&&cr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(g)):a(g)}}function ES(e,n,a){const i=this;return o;function o(d){return d!==87&&d!==119||!_b.call(i,i.previous)||Xm(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(jS,e.attempt(Tb,e.attempt(Fb,c),a),a)(d))}function c(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(d)}}function AS(e,n,a){const i=this;let o="",c=!1;return d;function d(g){return(g===72||g===104)&&Bb.call(i,i.previous)&&!Xm(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):a(g)}function f(g){if(cr(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const w=o.toLowerCase();if(w==="http"||w==="https")return e.consume(g),m}return a(g)}function m(g){return g===47?(e.consume(g),c?h:(c=!0,m)):a(g)}function h(g){return g===null||Iu(g)||un(g)||Ei(g)||Qu(g)?a(g):e.attempt(Tb,e.attempt(Fb,x),a)(g)}function x(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(g)}}function DS(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),c):a(d)}function c(d){return d===null?a(d):n(d)}}function TS(e,n,a){let i,o,c;return d;function d(h){return h===46||h===95?e.check(Rb,m,f)(h):h===null||un(h)||Ei(h)||h!==45&&Qu(h)?m(h):(c=!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||!c?a(h):n(h)}}function FS(e,n){let a=0,i=0;return o;function o(d){return d===40?(a++,e.consume(d),o):d===41&&i<a?c(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?e.check(Rb,n,c)(d):d===null||un(d)||Ei(d)?n(d):(e.consume(d),o)}function c(d){return d===41&&i++,e.consume(d),o}}function RS(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),c):f===93?(e.consume(f),o):f===60||f===null||un(f)||Ei(f)?n(f):a(f)}function o(f){return f===null||f===40||f===91||un(f)||Ei(f)?n(f):i(f)}function c(f){return cr(f)?d(f):a(f)}function d(f){return f===59?(e.consume(f),i):cr(f)?(e.consume(f),d):a(f)}}function MS(e,n,a){return i;function i(c){return e.consume(c),o}function o(c){return ir(c)?a(c):n(c)}}function _b(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||un(e)}function Bb(e){return!cr(e)}function Ob(e){return!(e===47||lm(e))}function lm(e){return e===43||e===45||e===46||e===95||ir(e)}function Xm(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 zS={tokenize:US,partial:!0};function _S(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:LS,continuation:{tokenize:IS},exit:HS}},text:{91:{name:"gfmFootnoteCall",tokenize:$S},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:BS,resolveTo:OS}}}}function BS(e,n,a){const i=this;let o=i.events.length;const c=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=ha(i.sliceSerialize({start:d.end,end:i.now()}));return h.codePointAt(0)!==94||!c.includes(h.slice(1))?a(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function OS(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 c={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},c.start),end:Object.assign({},c.end)},f=[e[a+1],e[a+2],["enter",i,n],e[a+3],e[a+4],["enter",o,n],["exit",o,n],["enter",c,n],["enter",d,n],["exit",d,n],["exit",c,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(a,e.length-a+1,...f),e}function $S(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c=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(c>999||g===93&&!d||g===null||g===91||un(g))return a(g);if(g===93){e.exit("chunkString");const w=e.exit("gfmFootnoteCallString");return o.includes(ha(i.sliceSerialize(w)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):a(g)}return un(g)||(d=!0),c++,e.consume(g),g===92?x:h}function x(g){return g===91||g===92||g===93?(e.consume(g),c++,h):h(g)}}function LS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c,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 c=ha(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),w}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 w(j){return j===58?(e.enter("definitionMarker"),e.consume(j),e.exit("definitionMarker"),o.includes(c)||o.push(c),$t(e,b,"gfmFootnoteDefinitionWhitespace")):a(j)}function b(j){return n(j)}}function IS(e,n,a){return e.check(Po,n,e.attempt(zS,n,a))}function HS(e){e.exit("gfmFootnoteDefinition")}function US(e,n,a){const i=this;return $t(e,o,"gfmFootnoteDefinitionIndent",5);function o(c){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?n(c):a(c)}}function qS(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:c,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)},w=[["enter",x,f],["enter",d[h][1],f],["exit",d[h][1],f],["enter",g,f]],b=f.parser.constructs.insideSpan.null;b&&Hr(w,w.length,0,Zu(b,d.slice(h+1,m),f)),Hr(w,w.length,0,[["exit",g,f],["enter",d[m][1],f],["exit",d[m][1],f],["exit",x,f]]),Hr(d,h-1,m-h+3,w),m=h+w.length-2;break}}for(m=-1;++m<d.length;)d[m][1].type==="strikethroughSequenceTemporary"&&(d[m][1].type="data");return d}function c(d,f,m){const h=this.previous,x=this.events;let g=0;return w;function w(j){return h===126&&x[x.length-1][1].type!=="characterEscape"?m(j):(d.enter("strikethroughSequenceTemporary"),b(j))}function b(j){const k=vs(h);if(j===126)return g>1?m(j):(d.consume(j),g++,b);if(g<2&&!a)return m(j);const E=d.exit("strikethroughSequenceTemporary"),N=vs(j);return E._open=!N||N===2&&!!k,E._close=!k||k===2&&!!N,f(j)}}}class YS{constructor(){this.map=[]}add(n,a,i){XS(this,n,a,i)}consume(n){if(this.map.sort(function(c,d){return c[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 c of o)n.push(c);o=i.pop()}this.map.length=0}}function XS(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 WS(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 c=i.length-1;i[c]=i[c]==="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 GS(){return{flow:{null:{name:"table",tokenize:VS,resolveAll:KS}}}}function VS(e,n,a){const i=this;let o=0,c=0,d;return f;function f(_){let $=i.events.length-1;for(;$>-1;){const ne=i.events[$][1].type;if(ne==="lineEnding"||ne==="linePrefix")$--;else break}const L=$>-1?i.events[$][1].type:null,W=L==="tableHead"||L==="tableRow"?F:m;return W===F&&i.parser.lazy[i.now().line]?a(_):W(_)}function m(_){return e.enter("tableHead"),e.enter("tableRow"),h(_)}function h(_){return _===124||(d=!0,c+=1),x(_)}function x(_){return _===null?a(_):it(_)?c>1?(c=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),b):a(_):Tt(_)?$t(e,x,"whitespace")(_):(c+=1,d&&(d=!1,o+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),g(_)))}function g(_){return _===null||_===124||un(_)?(e.exit("data"),x(_)):(e.consume(_),_===92?w:g)}function w(_){return _===92||_===124?(e.consume(_),g):g(_)}function b(_){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(_):(e.enter("tableDelimiterRow"),d=!1,Tt(_)?$t(e,j,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):j(_))}function j(_){return _===45||_===58?E(_):_===124?(d=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),k):H(_)}function k(_){return Tt(_)?$t(e,E,"whitespace")(_):E(_)}function E(_){return _===58?(c+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),N):_===45?(c+=1,N(_)):_===null||it(_)?T(_):H(_)}function N(_){return _===45?(e.enter("tableDelimiterFiller"),C(_)):H(_)}function C(_){return _===45?(e.consume(_),C):_===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),z):(e.exit("tableDelimiterFiller"),z(_))}function z(_){return Tt(_)?$t(e,T,"whitespace")(_):T(_)}function T(_){return _===124?j(_):_===null||it(_)?!d||o!==c?H(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(_)):H(_)}function H(_){return a(_)}function F(_){return e.enter("tableRow"),I(_)}function I(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),I):_===null||it(_)?(e.exit("tableRow"),n(_)):Tt(_)?$t(e,I,"whitespace")(_):(e.enter("data"),V(_))}function V(_){return _===null||_===124||un(_)?(e.exit("data"),I(_)):(e.consume(_),_===92?X:V)}function X(_){return _===92||_===124?(e.consume(_),V):V(_)}}function KS(e,n){let a=-1,i=!0,o=0,c=[0,0,0,0],d=[0,0,0,0],f=!1,m=0,h,x,g;const w=new YS;for(;++a<e.length;){const b=e[a],j=b[1];b[0]==="enter"?j.type==="tableHead"?(f=!1,m!==0&&(Eg(w,n,m,h,x),x=void 0,m=0),h={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},w.add(a,0,[["enter",h,n]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(i=!0,g=void 0,c=[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)},w.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&&(c[1]!==0&&(d[0]=d[1],g=vu(w,n,c,o,void 0,g),c=[0,0,0,0]),d[2]=a)):j.type==="tableCellDivider"&&(i?i=!1:(c[1]!==0&&(d[0]=d[1],g=vu(w,n,c,o,void 0,g)),c=d,d=[c[1],a,0,0])):j.type==="tableHead"?(f=!0,m=a):j.type==="tableRow"||j.type==="tableDelimiterRow"?(m=a,c[1]!==0?(d[0]=d[1],g=vu(w,n,c,o,a,g)):d[1]!==0&&(g=vu(w,n,d,o,a,g)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(d[3]=a)}for(m!==0&&Eg(w,n,m,h,x),w.consume(n.events),a=-1;++a<n.events.length;){const b=n.events[a];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=WS(n.events,a))}return e}function vu(e,n,a,i,o,c){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(c.end=Object.assign({},xs(n.events,a[0])),e.add(a[0],0,[["exit",c,n]]));const m=xs(n.events,a[1]);if(c={type:d,start:Object.assign({},m),end:Object.assign({},m)},e.add(a[1],0,[["enter",c,n]]),a[2]!==0){const h=xs(n.events,a[2]),x=xs(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 w=n.events[a[2]],b=n.events[a[3]];if(w[1].end=Object.assign({},b[1].end),w[1].type="chunkText",w[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&&(c.end=Object.assign({},xs(n.events,o)),e.add(o,0,[["exit",c,n]]),c=void 0),c}function Eg(e,n,a,i,o){const c=[],d=xs(n.events,a);o&&(o.end=Object.assign({},d),c.push(["exit",o,n])),i.end=Object.assign({},d),c.push(["exit",i,n]),e.add(a+1,0,c)}function xs(e,n){const a=e[n],i=a[0]==="enter"?"start":"end";return a[1][i]}const PS={name:"tasklistCheck",tokenize:ZS};function QS(){return{text:{91:PS}}}function ZS(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"),c)}function c(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):Tt(m)?e.check({tokenize:JS},n,a)(m):a(m)}}function JS(e,n,a){return $t(e,i,"whitespace");function i(o){return o===null?a(o):n(o)}}function eC(e){return Vy([CS(),_S(),qS(e),GS(),QS()])}const tC={};function Wm(e){const n=this,a=e||tC,i=n.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),c=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(eC(a)),c.push(wS()),d.push(kS(a))}function Es({content:e,className:n=""}){return l.jsx("div",{className:`office-markdown ${n}`,children:l.jsx(Um,{remarkPlugins:[Wm],components:{code:nC,table:({children:a})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:a})})},children:e})})}function nC({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
80
|
+
`)?l.jsx(rC,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"px-1 py-0.5 rounded text-[0.9em] font-mono",style:{background:"rgba(148,163,184,0.15)",color:"var(--terminal-text)"},...a,children:n})}function rC({children:e,language:n}){const[a,i]=v.useState(!1),o=String(e).replace(/\n$/,""),c=()=>{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:c,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 Ag={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},aC=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function lC(e,n){const a=parseInt(e.replace("#",""),16),i=Math.max(0,(a>>16&255)-n),o=Math.max(0,(a>>8&255)-n),c=Math.max(0,(a&255)-n);return`#${(i<<16|o<<8|c).toString(16).padStart(6,"0")}`}function iC(e,n){const a=parseInt(e.replace("#",""),16),i=Math.min(255,(a>>16&255)+n),o=Math.min(255,(a>>8&255)+n),c=Math.min(255,(a&255)+n);return`#${(i<<16|o<<8|c).toString(16).padStart(6,"0")}`}function $b(e,n){const a=Ag[e];if(a&&n)return n[a];const i=aC.exec(e);if(i){const[,o,c,d]=i,f=Ag[c],m=f&&n?n[f]:c,h=parseInt(d,10);return o==="darken"?lC(m,h):iC(m,h)}return e}function im(e,n=12){return e.map(a=>({...a,x:n-a.x-a.w}))}function sC(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:im(e.left.pixels)}:n==="left"&&e.right?{name:e.right.name,pixels:im(e.right.pixels)}:e.down}function oC(e,n){return sm(e,"hair",n,1)}function sm(e,n,a,i){const o=e.layers.findIndex(d=>d.name===n),c=[...e.layers];if(o>=0)c[o]={...a,name:n};else{const d=i??c.length;c.splice(d,0,{...a,name:n})}return{...e,layers:c}}const Gm=new Map,Vm=new Map;function Lb(e,n){Gm.set(e,n)}function nd(e,n){Vm.set(e,n)}function om(e){return Gm.get(e)}function P8(e){return Vm.get(e)}function Q8(){return Array.from(Gm.keys())}function Z8(){return Array.from(Vm.keys())}function cC(e,n,a,i,o=2){e.clearRect(0,0,n.width*o,n.height*o);for(const c of n.layers)Ib(e,c.pixels,o,a,i)}function Yl(e,n,a,i,o){for(const c of n){const d=$b(c.c,o);c.a!==void 0&&c.a!==1&&(e.globalAlpha=c.a),e.fillStyle=d,e.fillRect(a+c.x,i+c.y,c.w,c.h),c.a!==void 0&&c.a!==1&&(e.globalAlpha=1)}}function J8(e,n){const a=n.scale;e.clearRect(0,0,n.canvasWidth,n.canvasHeight),Ib(e,n.pixels,a,0)}function Ib(e,n,a,i,o){for(const c of n){const d=$b(c.c,o);c.a!==void 0&&c.a!==1&&(e.globalAlpha=c.a),e.fillStyle=d,e.fillRect(c.x*a,(c.y+i)*a,c.w*a,c.h*a),c.a!==void 0&&c.a!==1&&(e.globalAlpha=1)}}const Yu=new Map;function Vl(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 uC(e){return Yu.get(e)}function Hb(){return Array.from(Yu.values())}Vl("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}]}});Vl("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}]}});Vl("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}]}});Vl("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}]}});Vl("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"}]}});Vl("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}]}});Vl("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}]}});Vl("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 dC={short:1,messy:1,bun:2,long:2,mohawk:3,slicked:3,bob:4,curly:4},fC={short:0,messy:0,bun:500,long:500,mohawk:2e3,slicked:2e3,bob:5e3,curly:5e3};function Ub(e){return dC[e]??1}function qb(e,n){return n>=Ub(e)}function hC(e){return fC[e]??0}const Xu=new Map;function _a(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 mC(e){return Xu.get(e)}function Yb(){return Array.from(Xu.values())}_a("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"}]}});_a("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"}]}});_a("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"}]}});_a("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)"}]}});_a("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)"}]}});_a("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"}]}});_a("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"}]}});_a("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"}]}});_a("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"}]}});_a("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 pC={tshirt:1,polo:1,hoodie:2,vest:2,suit:3,tank:3,overalls:4,turtleneck:4,labcoat:5,robe:5},xC={tshirt:0,polo:0,hoodie:500,vest:500,suit:3e3,tank:1e3,overalls:5e3,turtleneck:5e3,labcoat:1e4,robe:1e4};function Xb(e){return pC[e]??1}function Wb(e,n){return n>=Xb(e)}function gC(e){return xC[e]??0}const Wo=new Map;function Wt(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Wo.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;Wo.set(e,{id:e,name:n,layer:{...o,name:"accessory"}})}}function yC(e){return Wo.get(e)}function bC(e,n){const a=Wo.get(e);if(!a)return;if(a.directions)return sC(a.directions,n);if(n==="down")return a.layer;const i=a.layer.pixels.filter(c=>c.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(c=>({...c,x:c.x+o})):i}}function Gb(){return Array.from(Wo.values())}Wt("none","None",{name:"accessory",pixels:[]});Wt("glasses","Glasses",{down:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:7,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:5,y:4,w:2,h:1,c:"#2A3A50",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#2A3A50",a:.4},{x:10,y:3,w:2,h:1,c:"#2A3A50",a:.4}]},left:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:5,y:4,w:6,h:1,c:"#2A3A50",a:.3}]}});Wt("round-glasses","Round Glasses",{down:{name:"accessory",pixels:[{x:2,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:7,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:3,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:8,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:5,y:4,w:2,h:1,c:"#8B7355",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#8B7355",a:.3},{x:10,y:3,w:2,h:1,c:"#8B7355",a:.3}]},left:{name:"accessory",pixels:[{x:2,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:3,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:5,y:4,w:6,h:1,c:"#8B7355",a:.25}]}});Wt("sunglasses","Sunglasses",{down:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:7,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:5,y:4,w:2,h:1,c:"#1A1A2E",a:.4},{x:3,y:4,w:1,h:1,c:"#334",a:.3},{x:8,y:4,w:1,h:1,c:"#334",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#1A1A2E",a:.4},{x:10,y:3,w:2,h:1,c:"#1A1A2E",a:.4}]},left:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:3,y:4,w:1,h:1,c:"#334",a:.3},{x:5,y:4,w:6,h:1,c:"#1A1A2E",a:.35}]}});Wt("headphones","Headphones",{down:{name:"accessory",pixels:[{x:0,y:0,w:12,h:1,c:"#333",a:.7},{x:-1,y:1,w:2,h:5,c:"#444"},{x:11,y:1,w:2,h:5,c:"#444"},{x:-1,y:2,w:2,h:3,c:"#555",a:.3},{x:11,y:2,w:2,h:3,c:"#555",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:0,w:12,h:1,c:"#333",a:.7},{x:-1,y:1,w:2,h:5,c:"#444"},{x:11,y:1,w:2,h:5,c:"#444"},{x:-1,y:2,w:2,h:3,c:"#555",a:.3},{x:11,y:2,w:2,h:3,c:"#555",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:10,h:1,c:"#333",a:.7},{x:-1,y:1,w:3,h:5,c:"#444"},{x:-1,y:2,w:3,h:3,c:"#555",a:.3}]}});Wt("beret","Beret",{down:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#E91E63"},{x:1,y:0,w:2,h:1,c:"#E91E63",a:.6},{x:4,y:-1,w:4,h:1,c:"#F06292",a:.3}]},up:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#E91E63"},{x:9,y:0,w:2,h:1,c:"#E91E63",a:.6}]},left:{name:"accessory",pixels:[{x:0,y:-1,w:8,h:2,c:"#E91E63"},{x:2,y:-1,w:4,h:1,c:"#F06292",a:.3}]}});Wt("cap","Cap",{down:{name:"accessory",pixels:[{x:1,y:-1,w:10,h:2,c:"#1565C0"},{x:0,y:1,w:12,h:1,c:"#0D47A1"},{x:3,y:-1,w:6,h:1,c:"#1E88E5",a:.3}]},up:{name:"accessory",pixels:[{x:1,y:-1,w:10,h:2,c:"#1565C0"},{x:3,y:-1,w:6,h:1,c:"#1E88E5",a:.3},{x:5,y:1,w:2,h:1,c:"#0D47A1",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:-1,w:9,h:2,c:"#1565C0"},{x:-2,y:1,w:6,h:1,c:"#0D47A1"},{x:2,y:-1,w:5,h:1,c:"#1E88E5",a:.3}]}});Wt("badge","Badge",{down:{name:"accessory",pixels:[{x:5,y:8,w:2,h:3,c:"#2196F3",a:.4},{x:4,y:11,w:4,h:3,c:"#FFF",a:.5},{x:5,y:12,w:2,h:1,c:"#333",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:3,y:8,w:1,h:3,c:"#2196F3",a:.4},{x:2,y:11,w:3,h:3,c:"#FFF",a:.5}]}});Wt("lapels","Lapels",{down:{name:"accessory",pixels:[{x:1,y:10,w:3,h:2,c:"#1A1A2E",a:.4},{x:8,y:10,w:3,h:2,c:"#1A1A2E",a:.4}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:1,y:10,w:3,h:2,c:"#1A1A2E",a:.4}]}});Wt("blush","Blush",{down:{name:"accessory",pixels:[{x:2,y:6,w:1,h:1,c:"#FFCDD2",a:.3},{x:9,y:6,w:1,h:1,c:"#FFCDD2",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:2,y:6,w:1,h:1,c:"#FFCDD2",a:.3}]}});Wt("scarf","Scarf",{down:{name:"accessory",pixels:[{x:2,y:9,w:8,h:2,c:"#E53935",a:.6},{x:3,y:9,w:6,h:1,c:"#EF5350",a:.3},{x:3,y:11,w:2,h:3,c:"#E53935",a:.5}]},up:{name:"accessory",pixels:[{x:2,y:9,w:8,h:2,c:"#E53935",a:.6},{x:3,y:9,w:6,h:1,c:"#EF5350",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:9,w:8,h:2,c:"#E53935",a:.6},{x:2,y:9,w:5,h:1,c:"#EF5350",a:.3},{x:1,y:11,w:2,h:3,c:"#E53935",a:.5}]}});Wt("tie","Tie",{down:{name:"accessory",pixels:[{x:5,y:9,w:2,h:1,c:"#B71C1C"},{x:5,y:10,w:2,h:4,c:"#D32F2F"},{x:5,y:10,w:1,h:4,c:"#E53935",a:.3},{x:5,y:14,w:2,h:1,c:"#B71C1C",a:.8}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:4,y:9,w:2,h:1,c:"#B71C1C"},{x:4,y:10,w:2,h:4,c:"#D32F2F"},{x:4,y:14,w:2,h:1,c:"#B71C1C",a:.8}]}});Wt("bowtie","Bowtie",{down:{name:"accessory",pixels:[{x:3,y:9,w:2,h:1,c:"#D32F2F"},{x:7,y:9,w:2,h:1,c:"#D32F2F"},{x:5,y:9,w:2,h:1,c:"#B71C1C"},{x:4,y:9,w:1,h:1,c:"#E53935",a:.3},{x:7,y:9,w:1,h:1,c:"#E53935",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:3,y:9,w:3,h:1,c:"#D32F2F"},{x:4,y:9,w:1,h:1,c:"#B71C1C"}]}});Wt("cat-ears","Cat Ears",{down:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#555"},{x:0,y:-2,w:3,h:1,c:"#555"},{x:0,y:-1,w:3,h:1,c:"#555"},{x:1,y:-2,w:1,h:1,c:"#FFB0C0",a:.6},{x:9,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:1,c:"#555"},{x:9,y:-1,w:3,h:1,c:"#555"},{x:10,y:-2,w:1,h:1,c:"#FFB0C0",a:.6}]},up:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#555"},{x:0,y:-2,w:3,h:1,c:"#555"},{x:0,y:-1,w:3,h:1,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:1,c:"#555"},{x:9,y:-1,w:3,h:1,c:"#555"}]},left:{name:"accessory",pixels:[{x:2,y:-3,w:2,h:1,c:"#555"},{x:1,y:-2,w:3,h:1,c:"#555"},{x:1,y:-1,w:3,h:1,c:"#555"},{x:2,y:-2,w:1,h:1,c:"#FFB0C0",a:.6}]}});Wt("bear-ears","Bear Ears",{down:{name:"accessory",pixels:[{x:0,y:-2,w:3,h:2,c:"#8B6914"},{x:1,y:-1,w:1,h:1,c:"#C4A24A",a:.5},{x:9,y:-2,w:3,h:2,c:"#8B6914"},{x:10,y:-1,w:1,h:1,c:"#C4A24A",a:.5}]},up:{name:"accessory",pixels:[{x:0,y:-2,w:3,h:2,c:"#8B6914"},{x:9,y:-2,w:3,h:2,c:"#8B6914"}]},left:{name:"accessory",pixels:[{x:1,y:-2,w:3,h:2,c:"#8B6914"},{x:2,y:-1,w:1,h:1,c:"#C4A24A",a:.5}]}});Wt("bunny-ears","Bunny Ears",{down:{name:"accessory",pixels:[{x:2,y:-5,w:2,h:4,c:"#F5F5F5"},{x:2,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:8,y:-5,w:2,h:4,c:"#F5F5F5"},{x:9,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:9,y:-6,w:2,h:1,c:"#F5F5F5"}]},up:{name:"accessory",pixels:[{x:2,y:-5,w:2,h:4,c:"#F5F5F5"},{x:8,y:-5,w:2,h:4,c:"#F5F5F5"},{x:9,y:-6,w:2,h:1,c:"#F5F5F5"}]},left:{name:"accessory",pixels:[{x:3,y:-5,w:2,h:4,c:"#F5F5F5"},{x:3,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:4,y:-6,w:2,h:1,c:"#F5F5F5"}]}});Wt("dog-nose","Dog Nose",{down:{name:"accessory",pixels:[{x:4,y:5,w:4,h:3,c:"#D2B48C",a:.5},{x:5,y:5,w:2,h:1,c:"#222"},{x:6,y:7,w:1,h:1,c:"#FF6B8A",a:.7}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:0,y:5,w:4,h:2,c:"#D2B48C",a:.5},{x:0,y:5,w:2,h:1,c:"#222"},{x:1,y:7,w:1,h:1,c:"#FF6B8A",a:.7}]}});Wt("fox-mask","Fox Mask",{down:{name:"accessory",pixels:[{x:0,y:-3,w:2,h:1,c:"#E65100"},{x:-1,y:-2,w:3,h:1,c:"#E65100"},{x:0,y:-1,w:3,h:1,c:"#E65100"},{x:10,y:-3,w:2,h:1,c:"#E65100"},{x:10,y:-2,w:3,h:1,c:"#E65100"},{x:9,y:-1,w:3,h:1,c:"#E65100"},{x:0,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:11,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:1,y:5,w:2,h:2,c:"#FFF",a:.25},{x:9,y:5,w:2,h:2,c:"#FFF",a:.25},{x:5,y:6,w:2,h:1,c:"#222",a:.6}]},up:{name:"accessory",pixels:[{x:0,y:-3,w:2,h:1,c:"#E65100"},{x:-1,y:-2,w:3,h:1,c:"#E65100"},{x:0,y:-1,w:3,h:1,c:"#E65100"},{x:10,y:-3,w:2,h:1,c:"#E65100"},{x:10,y:-2,w:3,h:1,c:"#E65100"},{x:9,y:-1,w:3,h:1,c:"#E65100"}]},left:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#E65100"},{x:0,y:-2,w:3,h:1,c:"#E65100"},{x:1,y:-1,w:3,h:1,c:"#E65100"},{x:1,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:1,y:5,w:2,h:2,c:"#FFF",a:.25},{x:1,y:6,w:2,h:1,c:"#222",a:.6}]}});Wt("crown","Crown",{down:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#FFD700"},{x:3,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:7,y:-3,w:2,h:2,c:"#FFD700"},{x:4,y:-2,w:1,h:1,c:"#E53935",a:.8},{x:6,y:-1,w:1,h:1,c:"#42A5F5",a:.8},{x:8,y:-2,w:1,h:1,c:"#66BB6A",a:.8},{x:3,y:-1,w:6,h:1,c:"#FFF",a:.15}]},up:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#FFD700"},{x:3,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:7,y:-3,w:2,h:2,c:"#FFD700"},{x:3,y:-1,w:6,h:1,c:"#FFF",a:.15}]},left:{name:"accessory",pixels:[{x:1,y:-1,w:7,h:2,c:"#FFD700"},{x:2,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:3,y:-2,w:1,h:1,c:"#E53935",a:.8},{x:5,y:-1,w:1,h:1,c:"#42A5F5",a:.8},{x:2,y:-1,w:5,h:1,c:"#FFF",a:.15}]}});Wt("halo","Halo",{down:{name:"accessory",pixels:[{x:2,y:-3,w:8,h:1,c:"#FFE082",a:.7},{x:1,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:10,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:3,y:-4,w:6,h:1,c:"#FFF9C4",a:.4},{x:3,y:-3,w:6,h:1,c:"#FFF",a:.15}]},up:{name:"accessory",pixels:[{x:2,y:-3,w:8,h:1,c:"#FFE082",a:.7},{x:1,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:10,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:3,y:-4,w:6,h:1,c:"#FFF9C4",a:.4},{x:3,y:-3,w:6,h:1,c:"#FFF",a:.15}]},left:{name:"accessory",pixels:[{x:1,y:-3,w:7,h:1,c:"#FFE082",a:.7},{x:0,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:8,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:2,y:-4,w:5,h:1,c:"#FFF9C4",a:.4},{x:2,y:-3,w:5,h:1,c:"#FFF",a:.15}]}});Wt("horns","Horns",{down:{name:"accessory",pixels:[{x:1,y:-1,w:2,h:2,c:"#8B0000"},{x:0,y:-3,w:2,h:2,c:"#A00"},{x:0,y:-4,w:1,h:1,c:"#C62828"},{x:9,y:-1,w:2,h:2,c:"#8B0000"},{x:10,y:-3,w:2,h:2,c:"#A00"},{x:11,y:-4,w:1,h:1,c:"#C62828"}]},up:{name:"accessory",pixels:[{x:1,y:-1,w:2,h:2,c:"#8B0000"},{x:0,y:-3,w:2,h:2,c:"#A00"},{x:0,y:-4,w:1,h:1,c:"#C62828"},{x:9,y:-1,w:2,h:2,c:"#8B0000"},{x:10,y:-3,w:2,h:2,c:"#A00"},{x:11,y:-4,w:1,h:1,c:"#C62828"}]},left:{name:"accessory",pixels:[{x:2,y:-1,w:2,h:2,c:"#8B0000"},{x:1,y:-3,w:2,h:2,c:"#A00"},{x:1,y:-4,w:1,h:1,c:"#C62828"}]}});Wt("mask","Mask",{down:{name:"accessory",pixels:[{x:1,y:3,w:10,h:3,c:"#1A1A2E",a:.75},{x:3,y:4,w:2,h:1,c:"#000",a:0},{x:7,y:4,w:2,h:1,c:"#000",a:0},{x:1,y:3,w:10,h:1,c:"#FFD700",a:.3},{x:1,y:5,w:10,h:1,c:"#FFD700",a:.2}]},up:{name:"accessory",pixels:[{x:0,y:4,w:12,h:1,c:"#1A1A2E",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:3,w:6,h:3,c:"#1A1A2E",a:.75},{x:2,y:4,w:2,h:1,c:"#000",a:0},{x:1,y:3,w:6,h:1,c:"#FFD700",a:.3},{x:1,y:5,w:6,h:1,c:"#FFD700",a:.2}]}});Wt("bandana","Bandana",{down:{name:"accessory",pixels:[{x:0,y:1,w:12,h:2,c:"#E53935"},{x:1,y:1,w:10,h:1,c:"#EF5350",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:1,w:12,h:2,c:"#E53935"},{x:1,y:1,w:10,h:1,c:"#EF5350",a:.3},{x:11,y:2,w:2,h:2,c:"#E53935",a:.7},{x:12,y:3,w:1,h:1,c:"#C62828",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:1,w:10,h:2,c:"#E53935"},{x:1,y:1,w:8,h:1,c:"#EF5350",a:.3}]}});Wt("eyepatch","Eye Patch",{down:{name:"accessory",pixels:[{x:0,y:3,w:12,h:1,c:"#222",a:.5},{x:2,y:3,w:3,h:3,c:"#1A1A1A"},{x:3,y:4,w:1,h:1,c:"#333",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:12,h:1,c:"#222",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:3,w:10,h:1,c:"#222",a:.5},{x:1,y:3,w:3,h:3,c:"#1A1A1A"},{x:2,y:4,w:1,h:1,c:"#333",a:.3}]}});Wt("cat-face","Cat Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#555"},{x:2,y:0,w:8,h:1,c:"#555"},{x:0,y:-2,w:3,h:2,c:"#555"},{x:1,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:2,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:1,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:10,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:2,y:3,w:3,h:3,c:"#222"},{x:7,y:3,w:3,h:3,c:"#222"},{x:3,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:8,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:3,y:4,w:1,h:1,c:"#111"},{x:8,y:4,w:1,h:1,c:"#111"},{x:5,y:5,w:2,h:1,c:"#FFB0C0"},{x:4,y:6,w:1,h:1,c:"#444",a:.6},{x:7,y:6,w:1,h:1,c:"#444",a:.6},{x:0,y:5,w:2,h:1,c:"#888",a:.4},{x:10,y:5,w:2,h:1,c:"#888",a:.4},{x:0,y:6,w:2,h:1,c:"#888",a:.3},{x:10,y:6,w:2,h:1,c:"#888",a:.3}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#555"},{x:2,y:0,w:8,h:1,c:"#555"},{x:0,y:-2,w:3,h:2,c:"#555"},{x:1,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:2,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:5,y:1,w:2,h:5,c:"#4A4A4A",a:.3},{x:9,y:8,w:2,h:2,c:"#555"},{x:10,y:7,w:1,h:1,c:"#555"}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#555"},{x:2,y:0,w:7,h:1,c:"#555"},{x:2,y:-2,w:3,h:2,c:"#555"},{x:3,y:-3,w:2,h:1,c:"#555"},{x:3,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:2,y:3,w:3,h:3,c:"#222"},{x:3,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:3,y:4,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:2,c:"#555"},{x:0,y:5,w:2,h:1,c:"#FFB0C0"},{x:-1,y:5,w:2,h:1,c:"#888",a:.4},{x:-1,y:6,w:2,h:1,c:"#888",a:.3}]}});Wt("bear-face","Bear Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#8B6914"},{x:2,y:-1,w:8,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:9,y:-1,w:3,h:3,c:"#8B6914"},{x:1,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:10,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:3,y:5,w:6,h:4,c:"#C4A24A",a:.7},{x:3,y:3,w:2,h:2,c:"#111"},{x:7,y:3,w:2,h:2,c:"#111"},{x:3,y:3,w:1,h:1,c:"#FFF",a:.3},{x:7,y:3,w:1,h:1,c:"#FFF",a:.3},{x:5,y:5,w:2,h:1,c:"#222"},{x:5,y:7,w:2,h:1,c:"#6B4F10",a:.5}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#8B6914"},{x:2,y:-1,w:8,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:9,y:-1,w:3,h:3,c:"#8B6914"},{x:1,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:10,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:5,y:1,w:2,h:5,c:"#7A5B10",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#8B6914"},{x:2,y:-1,w:7,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:0,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:0,y:4,w:3,h:4,c:"#C4A24A",a:.7},{x:3,y:3,w:2,h:2,c:"#111"},{x:3,y:3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:5,w:2,h:1,c:"#222"}]}});Wt("panda-face","Panda Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#F5F5F5"},{x:2,y:-1,w:8,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:9,y:-2,w:3,h:3,c:"#222"},{x:2,y:2,w:3,h:4,c:"#222"},{x:7,y:2,w:3,h:4,c:"#222"},{x:3,y:3,w:1,h:2,c:"#FFF"},{x:8,y:3,w:1,h:2,c:"#FFF"},{x:3,y:4,w:1,h:1,c:"#111"},{x:8,y:4,w:1,h:1,c:"#111"},{x:5,y:6,w:2,h:1,c:"#222"},{x:5,y:7,w:1,h:1,c:"#CCC",a:.4},{x:6,y:7,w:1,h:1,c:"#CCC",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#F5F5F5"},{x:2,y:-1,w:8,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:9,y:-2,w:3,h:3,c:"#222"},{x:5,y:1,w:2,h:5,c:"#EEE",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#F5F5F5"},{x:2,y:-1,w:7,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:2,y:2,w:3,h:4,c:"#222"},{x:3,y:3,w:1,h:2,c:"#FFF"},{x:3,y:4,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:2,c:"#F5F5F5"},{x:1,y:6,w:1,h:1,c:"#222"}]}});Wt("frog-face","Frog Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#4CAF50"},{x:2,y:0,w:8,h:1,c:"#4CAF50"},{x:1,y:-2,w:4,h:3,c:"#4CAF50"},{x:7,y:-2,w:4,h:3,c:"#4CAF50"},{x:2,y:-1,w:2,h:2,c:"#FFF"},{x:8,y:-1,w:2,h:2,c:"#FFF"},{x:3,y:0,w:1,h:1,c:"#111"},{x:9,y:0,w:1,h:1,c:"#111"},{x:3,y:5,w:6,h:3,c:"#81C784",a:.5},{x:2,y:7,w:8,h:1,c:"#388E3C",a:.6},{x:4,y:4,w:1,h:1,c:"#388E3C",a:.5},{x:7,y:4,w:1,h:1,c:"#388E3C",a:.5},{x:1,y:5,w:2,h:1,c:"#FF8A80",a:.25},{x:9,y:5,w:2,h:1,c:"#FF8A80",a:.25}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#4CAF50"},{x:2,y:0,w:8,h:1,c:"#4CAF50"},{x:1,y:-2,w:4,h:2,c:"#4CAF50"},{x:7,y:-2,w:4,h:2,c:"#4CAF50"},{x:5,y:2,w:2,h:4,c:"#388E3C",a:.2}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#4CAF50"},{x:2,y:0,w:7,h:1,c:"#4CAF50"},{x:0,y:-2,w:4,h:3,c:"#4CAF50"},{x:1,y:-1,w:2,h:2,c:"#FFF"},{x:2,y:0,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:3,c:"#81C784",a:.5},{x:0,y:7,w:8,h:1,c:"#388E3C",a:.6},{x:1,y:5,w:1,h:1,c:"#FF8A80",a:.25}]}});Wt("rabbit-face","Rabbit Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#F5F5F5"},{x:2,y:0,w:8,h:1,c:"#F5F5F5"},{x:2,y:-6,w:3,h:6,c:"#F5F5F5"},{x:7,y:-6,w:3,h:6,c:"#F5F5F5"},{x:3,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:8,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:2,y:3,w:3,h:3,c:"#E57373",a:.7},{x:7,y:3,w:3,h:3,c:"#E57373",a:.7},{x:3,y:3,w:1,h:1,c:"#FFF",a:.4},{x:8,y:3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:1,c:"#FFB0C0"},{x:5,y:6,w:1,h:1,c:"#DDD",a:.4},{x:6,y:6,w:1,h:1,c:"#DDD",a:.4},{x:0,y:4,w:2,h:3,c:"#F5F5F5",a:.6},{x:10,y:4,w:2,h:3,c:"#F5F5F5",a:.6}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#F5F5F5"},{x:2,y:0,w:8,h:1,c:"#F5F5F5"},{x:2,y:-6,w:3,h:6,c:"#F5F5F5"},{x:7,y:-6,w:3,h:6,c:"#F5F5F5"},{x:3,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:8,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:5,y:8,w:3,h:2,c:"#FFF"}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#F5F5F5"},{x:2,y:0,w:7,h:1,c:"#F5F5F5"},{x:3,y:-6,w:3,h:6,c:"#F5F5F5"},{x:4,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:2,y:3,w:3,h:3,c:"#E57373",a:.7},{x:3,y:3,w:1,h:1,c:"#FFF",a:.4},{x:0,y:4,w:3,h:3,c:"#F5F5F5"},{x:1,y:5,w:1,h:1,c:"#FFB0C0"},{x:0,y:4,w:2,h:3,c:"#F5F5F5",a:.6}]}});Wt("dog-face","Dog Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:3,y:5,w:6,h:4,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:7,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:7,y:2,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:2,c:"#222"},{x:5,y:7,w:2,h:2,c:"#FF6B8A",a:.8},{x:5,y:7,w:1,h:1,c:"#FF8A9E",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:5,y:0,w:2,h:6,c:"#B8883C",a:.3},{x:2,y:8,w:8,h:1,c:"#A67B3D",a:.5}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#D2A25C"},{x:2,y:-1,w:7,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:-1,y:4,w:3,h:4,c:"#D2A25C"},{x:-1,y:5,w:2,h:3,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:0,y:5,w:2,h:1,c:"#222"},{x:0,y:7,w:2,h:1,c:"#FF6B8A",a:.7}]}});const vC={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 Vb(e){return vC[e]??1}function Kb(e,n){return n>=Vb(e)}const wC={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 kC(e){return wC[e]??0}Wt("star-glasses","Star Glasses",{down:{name:"accessory",pixels:[{x:1,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:2,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:2,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:7,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:8,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:8,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:5,y:4,w:2,h:1,c:"#FF4081",a:.4}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#FF4081",a:.3},{x:10,y:3,w:2,h:1,c:"#FF4081",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:2,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:2,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:5,y:4,w:6,h:1,c:"#FF4081",a:.3}]}});function Fo({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 jC(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}),c=o.reduce((f,m)=>f+m,0);let d=Math.random()*c;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 SC(e,n,a=20){if(e.length===0)return[];const i=jC(e,n);for(let c=0;c<a;c++){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 w=Bu(m,i[g]);w<h&&(h=w,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 w of d[m])h.r+=w.r,h.g+=w.g,h.b+=w.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 c of e){let d=1/0,f=0;for(let m=0;m<n;m++){const h=Bu(c,i[m]);h<d&&(d=h,f=m)}o[f]++}return i.map((c,d)=>({c,count:o[d]})).sort((c,d)=>d.count-c.count).map(c=>c.c)}function CC(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 c=a.getContext("2d");c.drawImage(e,0,0);const d=c.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 Dg(e){return .299*e.r+.587*e.g+.114*e.b}function Tg(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 NC(e,n=8){const a=CC(e),i=SC(a,n);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const o=[...i].sort((g,w)=>Dg(w)-Dg(g)),c=[...i].sort((g,w)=>Tg(w)-Tg(g)),d=o[0],f=o[o.length-1],m=c[0],h=o[o.length-2],x=o[o.length-1];return{skinColor:Fo(d),hairColor:Fo(f),shirtColor:Fo(m),pantsColor:Fo(h),shoeColor:Fo(x)}}const EC=[{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}],AC=[{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"}],DC=[{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"}],TC=[{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 FC(){return{width:12,height:22,layers:[{name:"lower",pixels:EC},{name:"torso",pixels:AC},{name:"head",pixels:DC},{name:"hair",pixels:TC},{name:"accessory",pixels:[]}]}}const RC=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const e of RC)Lb(`mini:${e}`,FC());const MC=[{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"}],zC=[{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"}],_C=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function BC(){return{width:12,height:22,layers:[{name:"torso",pixels:MC},{name:"head",pixels:zC},{name:"hair",pixels:_C},{name:"accessory",pixels:[]}]}}Lb("mini-seated:default",BC());const OC={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"}]},$C={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"}]},LC={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"}]},IC={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",OC);nd("bulletin",$C);nd("decision",IC);nd("knowledge",LC);const Nh=16,Eh=24,HC=60,UC={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function Pb(e,n){if(!e)return e;let a=e;if(n!=null&&n.hairStyle){const i=uC(n.hairStyle);i&&(a=oC(a,i.layer))}if(n!=null&&n.outfitStyle){const i=mC(n.outfitStyle);i&&(a=sm(a,"torso",i.layer,1))}if(n!=null&&n.accessory&&n.accessory!=="none"){const i=yC(n.accessory);i&&(a=sm(a,"accessory",i.layer))}return a}function Wl({roleId:e,className:n,appearance:a,scale:i}){const o=v.useRef(null),c=v.useRef(0),d=v.useRef(0),f=v.useRef(a);f.current=a;const m=i??4,h=Nh*m,x=Eh*m,g=v.useMemo(()=>{const w=om(`mini:${e}`)??om("mini:default");return Pb(w,a)},[e,a==null?void 0:a.hairStyle,a==null?void 0:a.outfitStyle,a==null?void 0:a.accessory]);return v.useEffect(()=>{const w=o.current;if(!w)return;const b=w.getContext("2d");if(!b)return;const j=UC[e]??0,k=()=>{d.current++;const E=f.current;if(!E||!g){c.current=requestAnimationFrame(k);return}const C=(d.current+j)%HC<30?1:0;b.clearRect(0,0,Nh,Eh),b.save(),b.translate(2,1),cC(b,g,C,E,1),b.restore(),c.current=requestAnimationFrame(k)};return c.current=requestAnimationFrame(k),()=>cancelAnimationFrame(c.current)},[e,g]),l.jsx("canvas",{ref:o,width:Nh,height:Eh,className:n,style:{imageRendering:"pixelated",display:"block",width:h,height:x}})}const qC="https://api.tycono.ai",Km=qC;async function Ro(e){const n=await fetch(`${Km}${e}`);if(!n.ok)throw new Error(`Cloud API error: ${n.status}`);return n.json()}async function yi(e,n){const a=await fetch(`${Km}${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:()=>Ro("/api/health"),getMyName:e=>Ro(`/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 Ro(`/api/store/characters${a?`?${a}`:""}`)},getCharacter:e=>Ro(`/api/store/characters/${e}`),getCharacterVersion:e=>Ro(`/api/store/characters/${e}/version`),voteCharacter:(e,n,a)=>yi(`/api/store/characters/${e}/vote`,{instanceId:n,vote:a}),trackInstall:e=>yi(`/api/store/characters/${e}/install`,{}),syncCheck:e=>yi("/api/sync/check",{roles:e}),syncPull:e=>yi("/api/sync/pull",{sourceId:e}),publishCharacter:e=>yi("/api/store/publish",e),deleteCharacter:(e,n)=>{const a=n?`?publisher_id=${encodeURIComponent(n)}`:"";return fetch(`${Km}/api/store/characters/${e}${a}`,{method:"DELETE"}).then(i=>i.json())},uploadTelemetry:e=>yi("/api/telemetry",e),syncStats:e=>yi("/api/stats/sync",e)},YC={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},Ah={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},XC={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},WC=500,Fg=360,Rg=700,GC=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function Mg({role:e,allRoles:n,recentActivity:a,onClose:i,onFireRole:o,terminalWidth:c=0,activeSessionId:d,activeTask:f,isWorking:m,startedAt:h,onAbortSession:x,sessions:g,streamingSessionId:w,onCreateSessionSilent:b,onSendMessage:j,onFocusTerminal:k,onCustomize:E,onUpdateRole:N,appearance:C,relationships:z,roleLevel:T,onMaximize:H}){var st,Ke;const[F,I]=v.useState(WC),[V,X]=v.useState(!1),_=v.useRef(0),$=v.useRef(0),[L,W]=v.useState(!1),[ne,K]=v.useState(!1),[q,ie]=v.useState(!1),[de,me]=v.useState(!1),[D,U]=v.useState("talk"),[Y,R]=v.useState(!1),[O,ae]=v.useState(""),[te,Se]=v.useState(!1),je=v.useRef(null),[_e,Oe]=v.useState(!1),[Xe,rt]=v.useState(""),[De,We]=v.useState(!1),{events:Ot,status:yt}=My(d??null),[bt,jt]=v.useState(0);v.useEffect(()=>{if(!m||!h){jt(0);return}const Re=new Date(h).getTime(),Ie=()=>jt(Math.floor((Date.now()-Re)/1e3));Ie();const Lt=setInterval(Ie,1e3);return()=>clearInterval(Lt)},[m,h]);const qe=c>0,at=qe?c:0,pt=qe?Math.max(Fg,window.innerWidth-c-100):Rg,zt=Math.min(F,pt),fe=v.useCallback(Re=>{Re.preventDefault(),_.current=Re.clientX,$.current=zt,X(!0);const Ie=H,Lt=()=>{X(!1),document.removeEventListener("mousemove",Vt),document.removeEventListener("mouseup",Lt)},Vt=Et=>{const Gt=_.current-Et.clientX,dn=$.current+Gt;if(dn>=window.innerWidth*.6&&Ie){Lt(),Ie();return}const En=Math.min(Rg,Math.max(Fg,dn));I(En)};document.addEventListener("mousemove",Vt),document.addEventListener("mouseup",Lt)},[zt,H]),be=v.useRef(null),ve=e?g.find(Re=>Re.roleId===e.id):null,Q=Re=>{if(!e)return;const Ie=m?"talk":D;ve?(j(ve.id,Re,Ie),k(e.id)):(be.current={content:Re,mode:Ie},b(e.id))};v.useEffect(()=>{if(ve&&be.current){const{content:Re,mode:Ie}=be.current;be.current=null,j(ve.id,Re,Ie),e&&k(e.id)}},[ve==null?void 0:ve.id]);const Z=(()=>{if(!Ot.length)return null;const Re=[];let Ie=0,Lt=0,Vt=0;for(const Et of Ot)if(Et.type==="thinking")Ie++;else if(Et.type==="text")Lt++;else if(Et.type==="tool:start"){const Gt=String(Et.data.name??"");Re.includes(Gt)||Re.push(Gt)}else Et.type==="dispatch:start"&&Vt++;return{tools:Re,thinkCount:Ie,textCount:Lt,dispatchCount:Vt,total:Ot.length}})(),Ee=f||(()=>{if(!ve)return null;const Re=ve.messages;for(let Ie=Re.length-1;Ie>=0;Ie--)if(Re[Ie].from==="ceo")return Re[Ie].content;return null})(),xe=(()=>{if(!ve)return null;const Re=ve.messages;for(let Ie=Re.length-1;Ie>=0;Ie--)if(Re[Ie].from==="role"&&Re[Ie].content)return Re[Ie].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:at},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:at,width:zt,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 Ae=Ah[e.id]??"#666",ze=YC[e.id]??"👤",$e=n.filter(Re=>Re.reportsTo===e.id),Le=ve&&w===ve.id,Ye=e.name||XC[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:at},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)] ${V?"resizing":""}`,style:{borderLeftColor:Ae,right:at,width:zt,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 ${V?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:fe}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Ae}ee, ${Ae}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:"🎨"}),H&&l.jsx("button",{onClick:H,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(Wl,{roleId:e.id,appearance:C,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:[ze," ",e.id.toUpperCase(),m&&l.jsx("span",{className:"text-[9px] font-semibold px-2 py-0.5 rounded-full animate-pulse",style:{background:"rgba(251,191,36,0.25)",color:"#fde68a"},children:"WORKING"})]}),Y?l.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async Re=>{Re.preventDefault();const Ie=O.trim();if(!Ie||Ie===Ye||!N){R(!1);return}Se(!0);try{await N(e.id,{name:Ie})}catch{}Se(!1),R(!1)},children:[l.jsx("input",{ref:je,value:O,onChange:Re=>ae(Re.target.value),onKeyDown:Re=>{Re.key==="Escape"&&R(!1)},disabled:te,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:te,className:"text-white/80 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✓"}),l.jsx("button",{type:"button",onClick:()=>R(!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:()=>{N&&(ae(Ye),R(!0))},title:N?"Click to edit name":void 0,children:[Ye,N&&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.",T??1]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:m?"var(--idle-amber)":"var(--active-green)"}}),m?"Working":"Idle"]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsx("span",{children:e.level}),e.reportsTo&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"opacity-60",children:["→"," ",e.reportsTo]})]})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[m&&l.jsxs("div",{className:"px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--idle-amber)"}}),l.jsxs("span",{className:"text-xs font-semibold",style:{color:"var(--idle-amber)"},children:["Working",bt>0?` · ${GC(bt)}`:""]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"}),d&&x&&l.jsx("button",{onClick:()=>x(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"})]})]}),Ee&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:Ee})]}),m&&d&&Z&&l.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Activity"}),l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"View details ↗"})]}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[Z.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 ×",Z.thinkCount]}),Z.tools.map(Re=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(59,130,246,0.15)",color:"#60a5fa"},children:Re},Re)),Z.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 ×",Z.dispatchCount]}),Z.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 ×",Z.textCount]}),(yt==="streaming"||yt==="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:[Z.total," events"]})]}),m&&xe&&l.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Last Message"}),l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"})]}),l.jsxs("div",{className:"rounded-lg p-2.5 text-xs leading-relaxed line-clamp-3 overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:[xe.slice(0,200),xe.length>200&&"..."]})]}),m&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(zg,{onSend:Q,disabled:!!Le,placeholder:"Ask something...",color:Ae})}),!m&&l.jsxs("div",{className:"px-4 pt-4 pb-2",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-secondary)"},children:"Latest"}),l.jsx(KC,{icon:ze,roleId:e.id,roleName:Ye,color:Ae,text:a})]}),!m&&l.jsx("div",{className:"px-4 py-3",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[xe&&l.jsxs("div",{className:"px-3 pt-2.5 pb-2 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--terminal-border)"},onClick:()=>k(e.id),children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"Last response"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:"View ↗"})]}),l.jsxs("div",{className:"text-xs leading-relaxed line-clamp-2 overflow-hidden",style:{color:"var(--terminal-text-secondary)"},children:[xe.slice(0,150),xe.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:D==="talk"?"var(--accent)":"transparent",color:D==="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:D==="do"?"var(--idle-amber)":"transparent",color:D==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),l.jsx(zg,{onSend:Q,disabled:!!Le,placeholder:D==="talk"?"Ask something...":"Give a directive...",color:Ae})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(wu,{title:`Profile${e.persona?"":" (empty)"}`,open:L,onToggle:()=>W(Re=>!Re),children:[_e?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:Xe,onChange:Re=>rt(Re.target.value),onKeyDown:Re=>{Re.key==="Escape"&&Oe(!1)},disabled:De,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:()=>Oe(!1),disabled:De,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(N){We(!0);try{await N(e.id,{persona:Xe.trim()})}catch{}We(!1),Oe(!1)}},disabled:De,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold",style:{background:"var(--active-green)",color:"#000"},children:De?"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:()=>{N&&(rt(e.persona||""),Oe(!0))},title:N?"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."}),N&&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(Dh,{label:"Level",value:e.level}),l.jsx(Dh,{label:"Reports to",value:e.reportsTo}),l.jsx(Dh,{label:"Status",value:e.status})]}),$e.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:$e.map(Re=>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:Ah[Re.id]??"#666"},children:Re.id.slice(0,2).toUpperCase()}),l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text)"},children:Re.name})]},Re.id))})]})]}),e.authority&&l.jsxs(wu,{title:"Authority",open:ne,onToggle:()=>K(Re=>!Re),children:[((st=e.authority.autonomous)==null?void 0:st.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((Re,Ie)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Re]},Ie))]}),((Ke=e.authority.needsApproval)==null?void 0:Ke.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((Re,Ie)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Re]},Ie))]})]}),e&&z&&(()=>{const Re=z.filter(Ie=>Ie.roleA===e.id||Ie.roleB===e.id).filter(Ie=>Ie.familiarity>0).sort((Ie,Lt)=>Lt.familiarity-Ie.familiarity);return Re.length===0?null:l.jsx(wu,{title:`Relationships (${Re.length})`,open:q,onToggle:()=>ie(Ie=>!Ie),children:l.jsx("div",{className:"space-y-1.5",children:Re.map((Ie,Lt)=>{const Vt=Ie.roleA===e.id?Ie.roleB:Ie.roleA,Et=n.find(En=>En.id===Vt),Gt=Ie.familiarity>=80?"Best Partner":Ie.familiarity>=50?"Friend":Ie.familiarity>=20?"Colleague":"Acquaintance",dn=Ie.familiarity>=80?"#4CAF50":Ie.familiarity>=50?"#2196F3":Ie.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:Ah[Vt]??"var(--terminal-text-secondary)"},children:(Et==null?void 0:Et.name)??Vt}),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:`${Ie.familiarity}%`,background:dn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:Gt})]},Lt)})})})})(),e.journal&&l.jsx(wu,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:de,onToggle:()=>me(Re=>!Re),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(Es,{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(VC,{role:e,appearance:C}),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 VC({role:e,appearance:n}){const[a,i]=v.useState("idle"),[o,c]=v.useState(""),[d,f]=v.useState(!1),[m,h]=v.useState(null),[x,g]=v.useState(!1),[w,b]=v.useState(!1),[j,k]=v.useState(null);v.useEffect(()=>{kr.getCharacterVersion(e.id).then(C=>h((C==null?void 0:C.version)??null)).catch(()=>h(null)),ye.getPreferences().then(C=>k(C.instanceId??null)).catch(()=>{})},[e.id]);const E=async()=>{var C,z;if(!d){f(!0);return}i("publishing");try{let T=null;try{T=await ye.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:T??[],resume:{summary:((z=e.persona)==null?void 0:z.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 F="1.0.0";try{const I=await kr.getCharacterVersion(e.id);if(I!=null&&I.version){const V=I.version.split(".").map(Number);V[2]=(V[2]??0)+1,F=V.join(".")}}catch{}await kr.publishCharacter({id:e.id,name:e.name||e.id,version:F,data:H,publisherId:j??void 0}),i("done"),c(`Published v${F}`),h(F),f(!1)}catch(T){i("error"),c(T instanceof Error?T.message:"Failed"),f(!1)}},N=async()=>{b(!0);try{await kr.deleteCharacter(e.id,j??void 0),h(null),i("idle"),c(""),g(!1)}catch{c("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:E,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:N,disabled:w,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:w?"...":"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 KC({icon:e,roleId:n,roleName:a,color:i,text:o}){const c=!!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}),c?l.jsx("div",{className:"text-sm leading-relaxed",style:{color:"var(--terminal-text)"},children:l.jsx(Es,{content:o})}):l.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function wu({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 zg({onSend:e,disabled:n,placeholder:a,color:i}){const[o,c]=v.useState(""),d=v.useRef(!1),f=()=>{const m=o.trim();!m||n||(e(m),c(""))};return l.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[l.jsx("input",{type:"text",value:o,onChange:m=>c(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 Dh({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 PC(e,n){var a,i=1;e==null&&(e=0),n==null&&(n=0);function o(){var c,d=a.length,f,m=0,h=0;for(c=0;c<d;++c)f=a[c],m+=f.x,h+=f.y;for(m=(m/d-e)*i,h=(h/d-n)*i,c=0;c<d;++c)f=a[c],f.x-=m,f.y-=h}return o.initialize=function(c){a=c},o.x=function(c){return arguments.length?(e=+c,o):e},o.y=function(c){return arguments.length?(n=+c,o):n},o.strength=function(c){return arguments.length?(i=+c,o):i},o}function QC(e){const n=+this._x.call(null,e),a=+this._y.call(null,e);return Qb(this.cover(n,a),n,a,e)}function Qb(e,n,a,i){if(isNaN(n)||isNaN(a))return e;var o,c=e._root,d={data:i},f=e._x0,m=e._y0,h=e._x1,x=e._y1,g,w,b,j,k,E,N,C;if(!c)return e._root=d,e;for(;c.length;)if((k=n>=(g=(f+h)/2))?f=g:h=g,(E=a>=(w=(m+x)/2))?m=w:x=w,o=c,!(c=c[N=E<<1|k]))return o[N]=d,e;if(b=+e._x.call(null,c.data),j=+e._y.call(null,c.data),n===b&&a===j)return d.next=c,o?o[N]=d:e._root=d,e;do o=o?o[N]=new Array(4):e._root=new Array(4),(k=n>=(g=(f+h)/2))?f=g:h=g,(E=a>=(w=(m+x)/2))?m=w:x=w;while((N=E<<1|k)===(C=(j>=w)<<1|b>=g));return o[C]=c,o[N]=d,e}function ZC(e){var n,a,i=e.length,o,c,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(c=+this._y.call(null,n))||(d[a]=o,f[a]=c,o<m&&(m=o),o>x&&(x=o),c<h&&(h=c),c>g&&(g=c));if(m>x||h>g)return this;for(this.cover(m,h).cover(x,g),a=0;a<i;++a)Qb(this,d[a],f[a],e[a]);return this}function JC(e,n){if(isNaN(e=+e)||isNaN(n=+n))return this;var a=this._x0,i=this._y0,o=this._x1,c=this._y1;if(isNaN(a))o=(a=Math.floor(e))+1,c=(i=Math.floor(n))+1;else{for(var d=o-a||1,f=this._root,m,h;a>e||e>=o||i>n||n>=c;)switch(h=(n<i)<<1|e<a,m=new Array(4),m[h]=f,f=m,d*=2,h){case 0:o=a+d,c=i+d;break;case 1:a=o-d,c=i+d;break;case 2:o=a+d,i=c-d;break;case 3:a=o-d,i=c-d;break}this._root&&this._root.length&&(this._root=f)}return this._x0=a,this._y0=i,this._x1=o,this._y1=c,this}function eN(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function tN(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 ur(e,n,a,i,o){this.node=e,this.x0=n,this.y0=a,this.x1=i,this.y1=o}function nN(e,n,a){var i,o=this._x0,c=this._y0,d,f,m,h,x=this._x1,g=this._y1,w=[],b=this._root,j,k;for(b&&w.push(new ur(b,o,c,x,g)),a==null?a=1/0:(o=e-a,c=n-a,x=e+a,g=n+a,a*=a);j=w.pop();)if(!(!(b=j.node)||(d=j.x0)>x||(f=j.y0)>g||(m=j.x1)<o||(h=j.y1)<c))if(b.length){var E=(d+m)/2,N=(f+h)/2;w.push(new ur(b[3],E,N,m,h),new ur(b[2],d,N,E,h),new ur(b[1],E,f,m,N),new ur(b[0],d,f,E,N)),(k=(n>=N)<<1|e>=E)&&(j=w[w.length-1],w[w.length-1]=w[w.length-1-k],w[w.length-1-k]=j)}else{var C=e-+this._x.call(null,b.data),z=n-+this._y.call(null,b.data),T=C*C+z*z;if(T<a){var H=Math.sqrt(a=T);o=e-H,c=n-H,x=e+H,g=n+H,i=b.data}}return i}function rN(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,c,d=this._x0,f=this._y0,m=this._x1,h=this._y1,x,g,w,b,j,k,E,N;if(!a)return this;if(a.length)for(;;){if((j=x>=(w=(d+m)/2))?d=w:m=w,(k=g>=(b=(f+h)/2))?f=b:h=b,n=a,!(a=a[E=k<<1|j]))return this;if(!a.length)break;(n[E+1&3]||n[E+2&3]||n[E+3&3])&&(i=n,N=E)}for(;a.data!==e;)if(o=a,!(a=a.next))return this;return(c=a.next)&&delete a.next,o?(c?o.next=c:delete o.next,this):n?(c?n[E]=c:delete n[E],(a=n[0]||n[1]||n[2]||n[3])&&a===(n[3]||n[2]||n[1]||n[0])&&!a.length&&(i?i[N]=a:this._root=a),this):(this._root=c,this)}function aN(e){for(var n=0,a=e.length;n<a;++n)this.remove(e[n]);return this}function lN(){return this._root}function iN(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function sN(e){var n=[],a,i=this._root,o,c,d,f,m;for(i&&n.push(new ur(i,this._x0,this._y0,this._x1,this._y1));a=n.pop();)if(!e(i=a.node,c=a.x0,d=a.y0,f=a.x1,m=a.y1)&&i.length){var h=(c+f)/2,x=(d+m)/2;(o=i[3])&&n.push(new ur(o,h,x,f,m)),(o=i[2])&&n.push(new ur(o,c,x,h,m)),(o=i[1])&&n.push(new ur(o,h,d,f,x)),(o=i[0])&&n.push(new ur(o,c,d,h,x))}return this}function oN(e){var n=[],a=[],i;for(this._root&&n.push(new ur(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var o=i.node;if(o.length){var c,d=i.x0,f=i.y0,m=i.x1,h=i.y1,x=(d+m)/2,g=(f+h)/2;(c=o[0])&&n.push(new ur(c,d,f,x,g)),(c=o[1])&&n.push(new ur(c,x,f,m,g)),(c=o[2])&&n.push(new ur(c,d,g,x,h)),(c=o[3])&&n.push(new ur(c,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 cN(e){return e[0]}function uN(e){return arguments.length?(this._x=e,this):this._x}function dN(e){return e[1]}function fN(e){return arguments.length?(this._y=e,this):this._y}function Pm(e,n,a){var i=new Qm(n??cN,a??dN,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function Qm(e,n,a,i,o,c){this._x=e,this._y=n,this._x0=a,this._y0=i,this._x1=o,this._y1=c,this._root=void 0}function _g(e){for(var n={data:e.data},a=n;e=e.next;)a=a.next={data:e.data};return n}var dr=Pm.prototype=Qm.prototype;dr.copy=function(){var e=new Qm(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,a,i;if(!n)return e;if(!n.length)return e._root=_g(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]=_g(i));return e};dr.add=QC;dr.addAll=ZC;dr.cover=JC;dr.data=eN;dr.extent=tN;dr.find=nN;dr.remove=rN;dr.removeAll=aN;dr.root=lN;dr.size=iN;dr.visit=sN;dr.visitAfter=oN;dr.x=uN;dr.y=fN;function Si(e){return function(){return e}}function Xl(e){return(e()-.5)*1e-6}function hN(e){return e.x+e.vx}function mN(e){return e.y+e.vy}function pN(e){var n,a,i,o=1,c=1;typeof e!="function"&&(e=Si(e==null?1:+e));function d(){for(var h,x=n.length,g,w,b,j,k,E,N=0;N<c;++N)for(g=Pm(n,hN,mN).visitAfter(f),h=0;h<x;++h)w=n[h],k=a[w.index],E=k*k,b=w.x+w.vx,j=w.y+w.vy,g.visit(C);function C(z,T,H,F,I){var V=z.data,X=z.r,_=k+X;if(V){if(V.index>w.index){var $=b-V.x-V.vx,L=j-V.y-V.vy,W=$*$+L*L;W<_*_&&($===0&&($=Xl(i),W+=$*$),L===0&&(L=Xl(i),W+=L*L),W=(_-(W=Math.sqrt(W)))/W*o,w.vx+=($*=W)*(_=(X*=X)/(E+X)),w.vy+=(L*=W)*_,V.vx-=$*(_=1-_),V.vy-=L*_)}return}return T>b+_||F<b-_||H>j+_||I<j-_}}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?(c=+h,d):c},d.strength=function(h){return arguments.length?(o=+h,d):o},d.radius=function(h){return arguments.length?(e=typeof h=="function"?h:Si(+h),m(),d):e},d}function xN(e){return e.index}function Bg(e,n){var a=e.get(n);if(!a)throw new Error("node not found: "+n);return a}function gN(e){var n=xN,a=g,i,o=Si(30),c,d,f,m,h,x=1;e==null&&(e=[]);function g(E){return 1/Math.min(f[E.source.index],f[E.target.index])}function w(E){for(var N=0,C=e.length;N<x;++N)for(var z=0,T,H,F,I,V,X,_;z<C;++z)T=e[z],H=T.source,F=T.target,I=F.x+F.vx-H.x-H.vx||Xl(h),V=F.y+F.vy-H.y-H.vy||Xl(h),X=Math.sqrt(I*I+V*V),X=(X-c[z])/X*E*i[z],I*=X,V*=X,F.vx-=I*(_=m[z]),F.vy-=V*_,H.vx+=I*(_=1-_),H.vy+=V*_}function b(){if(d){var E,N=d.length,C=e.length,z=new Map(d.map((H,F)=>[n(H,F,d),H])),T;for(E=0,f=new Array(N);E<C;++E)T=e[E],T.index=E,typeof T.source!="object"&&(T.source=Bg(z,T.source)),typeof T.target!="object"&&(T.target=Bg(z,T.target)),f[T.source.index]=(f[T.source.index]||0)+1,f[T.target.index]=(f[T.target.index]||0)+1;for(E=0,m=new Array(C);E<C;++E)T=e[E],m[E]=f[T.source.index]/(f[T.source.index]+f[T.target.index]);i=new Array(C),j(),c=new Array(C),k()}}function j(){if(d)for(var E=0,N=e.length;E<N;++E)i[E]=+a(e[E],E,e)}function k(){if(d)for(var E=0,N=e.length;E<N;++E)c[E]=+o(e[E],E,e)}return w.initialize=function(E,N){d=E,h=N,b()},w.links=function(E){return arguments.length?(e=E,b(),w):e},w.id=function(E){return arguments.length?(n=E,w):n},w.iterations=function(E){return arguments.length?(x=+E,w):x},w.strength=function(E){return arguments.length?(a=typeof E=="function"?E:Si(+E),j(),w):a},w.distance=function(E){return arguments.length?(o=typeof E=="function"?E:Si(+E),k(),w):o},w}var yN={value:()=>{}};function Zb(){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 bN(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=Zb.prototype={constructor:Ou,on:function(e,n){var a=this._,i=bN(e+"",a),o,c=-1,d=i.length;if(arguments.length<2){for(;++c<d;)if((o=(e=i[c]).type)&&(o=vN(a[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++c<d;)if(o=(e=i[c]).type)a[o]=Og(a[o],e.name,n);else if(n==null)for(o in a)a[o]=Og(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,c;i<o;++i)a[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(c=this._[e],i=0,o=c.length;i<o;++i)c[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,c=i.length;o<c;++o)i[o].value.apply(n,a)}};function vN(e,n){for(var a=0,i=e.length,o;a<i;++a)if((o=e[a]).name===n)return o.value}function Og(e,n,a){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=yN,e=e.slice(0,i).concat(e.slice(i+1));break}return a!=null&&e.push({name:n,value:a}),e}var ws=0,Oo=0,Mo=0,Jb=1e3,Wu,$o,Gu=0,Ai=0,rd=0,Go=typeof performance=="object"&&performance.now?performance:Date,ev=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function tv(){return Ai||(ev(wN),Ai=Go.now()+rd)}function wN(){Ai=0}function cm(){this._call=this._time=this._next=null}cm.prototype=nv.prototype={constructor:cm,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?tv():+a)+(n==null?0:+n),!this._next&&$o!==this&&($o?$o._next=this:Wu=this,$o=this),this._call=e,this._time=a,um()},stop:function(){this._call&&(this._call=null,this._time=1/0,um())}};function nv(e,n,a){var i=new cm;return i.restart(e,n,a),i}function kN(){tv(),++ws;for(var e=Wu,n;e;)(n=Ai-e._time)>=0&&e._call.call(void 0,n),e=e._next;--ws}function $g(){Ai=(Gu=Go.now())+rd,ws=Oo=0;try{kN()}finally{ws=0,SN(),Ai=0}}function jN(){var e=Go.now(),n=e-Gu;n>Jb&&(rd-=n,Gu=e)}function SN(){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,um(i)}function um(e){if(!ws){Oo&&(Oo=clearTimeout(Oo));var n=e-Ai;n>24?(e<1/0&&(Oo=setTimeout($g,e-Go.now()-rd)),Mo&&(Mo=clearInterval(Mo))):(Mo||(Gu=Go.now(),Mo=setInterval(jN,Jb)),ws=1,ev($g))}}const CN=1664525,NN=1013904223,Lg=4294967296;function EN(){let e=1;return()=>(e=(CN*e+NN)%Lg)/Lg}function AN(e){return e.x}function DN(e){return e.y}var TN=10,FN=Math.PI*(3-Math.sqrt(5));function RN(e){var n,a=1,i=.001,o=1-Math.pow(i,1/300),c=0,d=.6,f=new Map,m=nv(g),h=Zb("tick","end"),x=EN();e==null&&(e=[]);function g(){w(),h.call("tick",n),a<i&&(m.stop(),h.call("end",n))}function w(k){var E,N=e.length,C;k===void 0&&(k=1);for(var z=0;z<k;++z)for(a+=(c-a)*o,f.forEach(function(T){T(a)}),E=0;E<N;++E)C=e[E],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,E=e.length,N;k<E;++k){if(N=e[k],N.index=k,N.fx!=null&&(N.x=N.fx),N.fy!=null&&(N.y=N.fy),isNaN(N.x)||isNaN(N.y)){var C=TN*Math.sqrt(.5+k),z=k*FN;N.x=C*Math.cos(z),N.y=C*Math.sin(z)}(isNaN(N.vx)||isNaN(N.vy))&&(N.vx=N.vy=0)}}function j(k){return k.initialize&&k.initialize(e,x),k}return b(),n={tick:w,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?(c=+k,n):c},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,E){return arguments.length>1?(E==null?f.delete(k):f.set(k,j(E)),n):f.get(k)},find:function(k,E,N){var C=0,z=e.length,T,H,F,I,V;for(N==null?N=1/0:N*=N,C=0;C<z;++C)I=e[C],T=k-I.x,H=E-I.y,F=T*T+H*H,F<N&&(V=I,N=F);return V},on:function(k,E){return arguments.length>1?(h.on(k,E),n):h.on(k)}}}function MN(){var e,n,a,i,o=Si(-30),c,d=1,f=1/0,m=.81;function h(b){var j,k=e.length,E=Pm(e,AN,DN).visitAfter(g);for(i=b,j=0;j<k;++j)n=e[j],E.visit(w)}function x(){if(e){var b,j=e.length,k;for(c=new Array(j),b=0;b<j;++b)k=e[b],c[k.index]=+o(k,b,e)}}function g(b){var j=0,k,E,N=0,C,z,T;if(b.length){for(C=z=T=0;T<4;++T)(k=b[T])&&(E=Math.abs(k.value))&&(j+=k.value,N+=E,C+=E*k.x,z+=E*k.y);b.x=C/N,b.y=z/N}else{k=b,k.x=k.data.x,k.y=k.data.y;do j+=c[k.data.index];while(k=k.next)}b.value=j}function w(b,j,k,E){if(!b.value)return!0;var N=b.x-n.x,C=b.y-n.y,z=E-j,T=N*N+C*C;if(z*z/m<T)return T<f&&(N===0&&(N=Xl(a),T+=N*N),C===0&&(C=Xl(a),T+=C*C),T<d&&(T=Math.sqrt(d*T)),n.vx+=N*b.value*i/T,n.vy+=C*b.value*i/T),!0;if(b.length||T>=f)return;(b.data!==n||b.next)&&(N===0&&(N=Xl(a),T+=N*N),C===0&&(C=Xl(a),T+=C*C),T<d&&(T=Math.sqrt(d*T)));do b.data!==n&&(z=c[b.data.index]*i/T,n.vx+=N*z,n.vy+=C*z);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:Si(+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 cl(e){return Array.isArray?Array.isArray(e):lv(e)==="[object Array]"}function zN(e){if(typeof e=="string")return e;let n=e+"";return n=="0"&&1/e==-1/0?"-0":n}function _N(e){return e==null?"":zN(e)}function Fa(e){return typeof e=="string"}function rv(e){return typeof e=="number"}function BN(e){return e===!0||e===!1||ON(e)&&lv(e)=="[object Boolean]"}function av(e){return typeof e=="object"}function ON(e){return av(e)&&e!==null}function Lr(e){return e!=null}function Th(e){return!e.trim().length}function lv(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const $N="Incorrect 'index' type",LN=e=>`Invalid value for key ${e}`,IN=e=>`Pattern length exceeds max of ${e}.`,HN=e=>`Missing ${e} property in key`,UN=e=>`Property 'weight' in key '${e}' must be a positive integer`,Ig=Object.prototype.hasOwnProperty;class qN{constructor(n){this._keys=[],this._keyMap={};let a=0;n.forEach(i=>{let o=iv(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 iv(e){let n=null,a=null,i=null,o=1,c=null;if(Fa(e)||cl(e))i=e,n=Hg(e),a=dm(e);else{if(!Ig.call(e,"name"))throw new Error(HN("name"));const d=e.name;if(i=d,Ig.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(UN(d));n=Hg(d),a=dm(d),c=e.getFn}return{path:n,id:a,weight:o,src:i,getFn:c}}function Hg(e){return cl(e)?e:e.split(".")}function dm(e){return cl(e)?e.join("."):e}function YN(e,n){let a=[],i=!1;const o=(c,d,f)=>{if(Lr(c))if(!d[f])a.push(c);else{let m=d[f];const h=c[m];if(!Lr(h))return;if(f===d.length-1&&(Fa(h)||rv(h)||BN(h)))a.push(_N(h));else if(cl(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,Fa(n)?n.split("."):n,0),i?a:a[0]}const XN={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},WN={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},GN={location:0,threshold:.6,distance:100},VN={useExtendedSearch:!1,getFn:YN,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var mt={...WN,...XN,...GN,...VN};const KN=/[^ ]+/g;function PN(e=1,n=3){const a=new Map,i=Math.pow(10,n);return{get(o){const c=o.match(KN).length;if(a.has(c))return a.get(c);const d=1/Math.pow(c,.5*e),f=parseFloat(Math.round(d*i)/i);return a.set(c,f),f},clear(){a.clear()}}}class Zm{constructor({getFn:n=mt.getFn,fieldNormWeight:a=mt.fieldNormWeight}={}){this.norm=PN(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,Fa(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();Fa(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(!Lr(n)||Th(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,c)=>{let d=o.getFn?o.getFn(n):this.getFn(n,o.path);if(Lr(d)){if(cl(d)){let f=[];const m=[{nestedArrIndex:-1,value:d}];for(;m.length;){const{nestedArrIndex:h,value:x}=m.pop();if(Lr(x))if(Fa(x)&&!Th(x)){let g={v:x,i:h,n:this.norm.get(x)};f.push(g)}else cl(x)&&x.forEach((g,w)=>{m.push({nestedArrIndex:w,value:g})})}i.$[c]=f}else if(Fa(d)&&!Th(d)){let f={v:d,n:this.norm.get(d)};i.$[c]=f}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function sv(e,n,{getFn:a=mt.getFn,fieldNormWeight:i=mt.fieldNormWeight}={}){const o=new Zm({getFn:a,fieldNormWeight:i});return o.setKeys(e.map(iv)),o.setSources(n),o.create(),o}function QN(e,{getFn:n=mt.getFn,fieldNormWeight:a=mt.fieldNormWeight}={}){const{keys:i,records:o}=e,c=new Zm({getFn:n,fieldNormWeight:a});return c.setKeys(i),c.setIndexRecords(o),c}function ku(e,{errors:n=0,currentLocation:a=0,expectedLocation:i=0,distance:o=mt.distance,ignoreLocation:c=mt.ignoreLocation}={}){const d=n/e.length;if(c)return d;const f=Math.abs(i-a);return o?d+f/o:f?1:d}function ZN(e=[],n=mt.minMatchCharLength){let a=[],i=-1,o=-1,c=0;for(let d=e.length;c<d;c+=1){let f=e[c];f&&i===-1?i=c:!f&&i!==-1&&(o=c-1,o-i+1>=n&&a.push([i,o]),i=-1)}return e[c-1]&&c-i>=n&&a.push([i,c-1]),a}const ji=32;function JN(e,n,a,{location:i=mt.location,distance:o=mt.distance,threshold:c=mt.threshold,findAllMatches:d=mt.findAllMatches,minMatchCharLength:f=mt.minMatchCharLength,includeMatches:m=mt.includeMatches,ignoreLocation:h=mt.ignoreLocation}={}){if(n.length>ji)throw new Error(IN(ji));const x=n.length,g=e.length,w=Math.max(0,Math.min(i,g));let b=c,j=w;const k=f>1||m,E=k?Array(g):[];let N;for(;(N=e.indexOf(n,j))>-1;){let I=ku(n,{currentLocation:N,expectedLocation:w,distance:o,ignoreLocation:h});if(b=Math.min(I,b),j=N+x,k){let V=0;for(;V<x;)E[N+V]=1,V+=1}}j=-1;let C=[],z=1,T=x+g;const H=1<<x-1;for(let I=0;I<x;I+=1){let V=0,X=T;for(;V<X;)ku(n,{errors:I,currentLocation:w+X,expectedLocation:w,distance:o,ignoreLocation:h})<=b?V=X:T=X,X=Math.floor((T-V)/2+V);T=X;let _=Math.max(1,w-X+1),$=d?g:Math.min(w+X,g)+x,L=Array($+2);L[$+1]=(1<<I)-1;for(let ne=$;ne>=_;ne-=1){let K=ne-1,q=a[e.charAt(K)];if(k&&(E[K]=+!!q),L[ne]=(L[ne+1]<<1|1)&q,I&&(L[ne]|=(C[ne+1]|C[ne])<<1|1|C[ne+1]),L[ne]&H&&(z=ku(n,{errors:I,currentLocation:K,expectedLocation:w,distance:o,ignoreLocation:h}),z<=b)){if(b=z,j=K,j<=w)break;_=Math.max(1,2*w-j)}}if(ku(n,{errors:I+1,currentLocation:w,expectedLocation:w,distance:o,ignoreLocation:h})>b)break;C=L}const F={isMatch:j>=0,score:Math.max(.001,z)};if(k){const I=ZN(E,f);I.length?m&&(F.indices=I):F.isMatch=!1}return F}function eE(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 Vu=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 ov{constructor(n,{location:a=mt.location,threshold:i=mt.threshold,distance:o=mt.distance,includeMatches:c=mt.includeMatches,findAllMatches:d=mt.findAllMatches,minMatchCharLength:f=mt.minMatchCharLength,isCaseSensitive:m=mt.isCaseSensitive,ignoreDiacritics:h=mt.ignoreDiacritics,ignoreLocation:x=mt.ignoreLocation}={}){if(this.options={location:a,threshold:i,distance:o,includeMatches:c,findAllMatches:d,minMatchCharLength:f,isCaseSensitive:m,ignoreDiacritics:h,ignoreLocation:x},n=m?n:n.toLowerCase(),n=h?Vu(n):n,this.pattern=n,this.chunks=[],!this.pattern.length)return;const g=(b,j)=>{this.chunks.push({pattern:b,alphabet:eE(b),startIndex:j})},w=this.pattern.length;if(w>ji){let b=0;const j=w%ji,k=w-j;for(;b<k;)g(this.pattern.substr(b,ji),b),b+=ji;if(j){const E=w-ji;g(this.pattern.substr(E),E)}}else g(this.pattern,0)}searchIn(n){const{isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o}=this.options;if(n=a?n:n.toLowerCase(),n=i?Vu(n):n,this.pattern===n){let k={isMatch:!0,score:0};return o&&(k.indices=[[0,n.length-1]]),k}const{location:c,distance:d,threshold:f,findAllMatches:m,minMatchCharLength:h,ignoreLocation:x}=this.options;let g=[],w=0,b=!1;this.chunks.forEach(({pattern:k,alphabet:E,startIndex:N})=>{const{isMatch:C,score:z,indices:T}=JN(n,k,E,{location:c+N,distance:d,threshold:f,findAllMatches:m,minMatchCharLength:h,includeMatches:o,ignoreLocation:x});C&&(b=!0),w+=z,C&&T&&(g=[...g,...T])});let j={isMatch:b,score:b?w/this.chunks.length:1};return b&&o&&(j.indices=g),j}}class Kl{constructor(n){this.pattern=n}static isMultiMatch(n){return Ug(n,this.multiRegex)}static isSingleMatch(n){return Ug(n,this.singleRegex)}search(){}}function Ug(e,n){const a=e.match(n);return a?a[1]:null}class tE extends Kl{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 nE extends Kl{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 rE extends Kl{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 aE extends Kl{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 lE extends Kl{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 iE extends Kl{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 cv extends Kl{constructor(n,{location:a=mt.location,threshold:i=mt.threshold,distance:o=mt.distance,includeMatches:c=mt.includeMatches,findAllMatches:d=mt.findAllMatches,minMatchCharLength:f=mt.minMatchCharLength,isCaseSensitive:m=mt.isCaseSensitive,ignoreDiacritics:h=mt.ignoreDiacritics,ignoreLocation:x=mt.ignoreLocation}={}){super(n),this._bitapSearch=new ov(n,{location:a,threshold:i,distance:o,includeMatches:c,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 uv extends Kl{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=[],c=this.pattern.length;for(;(i=n.indexOf(this.pattern,a))>-1;)a=i+c,o.push([i,a-1]);const d=!!o.length;return{isMatch:d,score:d?0:1,indices:o}}}const fm=[tE,uv,rE,aE,iE,lE,nE,cv],qg=fm.length,sE=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,oE="|";function cE(e,n={}){return e.split(oE).map(a=>{let i=a.trim().split(sE).filter(c=>c&&!!c.trim()),o=[];for(let c=0,d=i.length;c<d;c+=1){const f=i[c];let m=!1,h=-1;for(;!m&&++h<qg;){const x=fm[h];let g=x.isMultiMatch(f);g&&(o.push(new x(g,n)),m=!0)}if(!m)for(h=-1;++h<qg;){const x=fm[h];let g=x.isSingleMatch(f);if(g){o.push(new x(g,n));break}}}return o})}const uE=new Set([cv.type,uv.type]);class dE{constructor(n,{isCaseSensitive:a=mt.isCaseSensitive,ignoreDiacritics:i=mt.ignoreDiacritics,includeMatches:o=mt.includeMatches,minMatchCharLength:c=mt.minMatchCharLength,ignoreLocation:d=mt.ignoreLocation,findAllMatches:f=mt.findAllMatches,location:m=mt.location,threshold:h=mt.threshold,distance:x=mt.distance}={}){this.query=null,this.options={isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o,minMatchCharLength:c,findAllMatches:f,ignoreLocation:d,location:m,threshold:h,distance:x},n=a?n:n.toLowerCase(),n=i?Vu(n):n,this.pattern=n,this.query=cE(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:c}=this.options;n=o?n:n.toLowerCase(),n=c?Vu(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 w=0,b=g.length;w<b;w+=1){const j=g[w],{isMatch:k,indices:E,score:N}=j.search(n);if(k){if(d+=1,m+=N,i){const C=j.constructor.type;uE.has(C)?f=[...f,...E]:f.push(E)}}else{m=0,d=0,f.length=0;break}}if(d){let w={isMatch:!0,score:m/d};return i&&(w.indices=f),w}}return{isMatch:!1,score:1}}}const hm=[];function fE(...e){hm.push(...e)}function mm(e,n){for(let a=0,i=hm.length;a<i;a+=1){let o=hm[a];if(o.condition(e,n))return new o(e,n)}return new ov(e,n)}const Ku={AND:"$and",OR:"$or"},pm={PATH:"$path",PATTERN:"$val"},xm=e=>!!(e[Ku.AND]||e[Ku.OR]),hE=e=>!!e[pm.PATH],mE=e=>!cl(e)&&av(e)&&!xm(e),Yg=e=>({[Ku.AND]:Object.keys(e).map(n=>({[n]:e[n]}))});function dv(e,n,{auto:a=!0}={}){const i=o=>{let c=Object.keys(o);const d=hE(o);if(!d&&c.length>1&&!xm(o))return i(Yg(o));if(mE(o)){const m=d?o[pm.PATH]:c[0],h=d?o[pm.PATTERN]:o[m];if(!Fa(h))throw new Error(LN(m));const x={keyId:dm(m),pattern:h};return a&&(x.searcher=mm(h,n)),x}let f={children:[],operator:c[0]};return c.forEach(m=>{const h=o[m];cl(h)&&h.forEach(x=>{f.children.push(i(x))})}),f};return xm(e)||(e=Yg(e)),i(e)}function pE(e,{ignoreFieldNorm:n=mt.ignoreFieldNorm}){e.forEach(a=>{let i=1;a.matches.forEach(({key:o,norm:c,score:d})=>{const f=o?o.weight:null;i*=Math.pow(d===0&&f?Number.EPSILON:d,(f||1)*(n?1:c))}),a.score=i})}function xE(e,n){const a=e.matches;n.matches=[],Lr(a)&&a.forEach(i=>{if(!Lr(i.indices)||!i.indices.length)return;const{indices:o,value:c}=i;let d={indices:o,value:c};i.key&&(d.key=i.key.src),i.idx>-1&&(d.refIndex=i.idx),n.matches.push(d)})}function gE(e,n){n.score=e.score}function yE(e,n,{includeMatches:a=mt.includeMatches,includeScore:i=mt.includeScore}={}){const o=[];return a&&o.push(xE),i&&o.push(gE),e.map(c=>{const{idx:d}=c,f={item:n[d],refIndex:d};return o.length&&o.forEach(m=>{m(c,f)}),f})}class As{constructor(n,a={},i){this.options={...mt,...a},this.options.useExtendedSearch,this._keyStore=new qN(this.options.keys),this.setCollection(n,i)}setCollection(n,a){if(this._docs=n,a&&!(a instanceof Zm))throw new Error($N);this._myIndex=a||sv(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(n){Lr(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 c=this._docs[i];n(c,i)&&(this.removeAt(i),i-=1,o-=1,a.push(c))}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:c,sortFn:d,ignoreFieldNorm:f}=this.options;let m=Fa(n)?Fa(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return pE(m,{ignoreFieldNorm:f}),c&&m.sort(d),rv(a)&&a>-1&&(m=m.slice(0,a)),yE(m,this._docs,{includeMatches:i,includeScore:o})}_searchStringList(n){const a=mm(n,this.options),{records:i}=this._myIndex,o=[];return i.forEach(({v:c,i:d,n:f})=>{if(!Lr(c))return;const{isMatch:m,score:h,indices:x}=a.searchIn(c);m&&o.push({item:c,idx:d,matches:[{score:h,value:c,norm:f,indices:x}]})}),o}_searchLogical(n){const a=dv(n,this.options),i=(f,m,h)=>{if(!f.children){const{keyId:g,searcher:w}=f,b=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(m,g),searcher:w});return b&&b.length?[{idx:h,item:m,matches:b}]:[]}const x=[];for(let g=0,w=f.children.length;g<w;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,c={},d=[];return o.forEach(({$:f,i:m})=>{if(Lr(f)){let h=i(a,f,m);h.length&&(c[m]||(c[m]={idx:m,item:f,matches:[]},d.push(c[m])),h.forEach(({matches:x})=>{c[m].matches.push(...x)}))}}),d}_searchObjectList(n){const a=mm(n,this.options),{keys:i,records:o}=this._myIndex,c=[];return o.forEach(({$:d,i:f})=>{if(!Lr(d))return;let m=[];i.forEach((h,x)=>{m.push(...this._findMatches({key:h,value:d[x],searcher:a}))}),m.length&&c.push({idx:f,item:d,matches:m})}),c}_findMatches({key:n,value:a,searcher:i}){if(!Lr(a))return[];let o=[];if(cl(a))a.forEach(({v:c,i:d,n:f})=>{if(!Lr(c))return;const{isMatch:m,score:h,indices:x}=i.searchIn(c);m&&o.push({score:h,key:n,value:c,idx:d,norm:f,indices:x})});else{const{v:c,n:d}=a,{isMatch:f,score:m,indices:h}=i.searchIn(c);f&&o.push({score:m,key:n,value:c,norm:d,indices:h})}return o}}As.version="7.1.0";As.createIndex=sv;As.parseIndex=QN;As.config=mt;As.parseQuery=dv;fE(dE);const il={architecture:{bg:"rgba(59,130,246,0.15)",border:"#3b82f6",text:"#60a5fa"},knowledge:{bg:"rgba(245,158,11,0.15)",border:"#f59e0b",text:"#fbbf24"},roles:{bg:"rgba(139,92,246,0.15)",border:"#8b5cf6",text:"#a78bfa"},projects:{bg:"rgba(34,197,94,0.15)",border:"#22c55e",text:"#4ade80"},operations:{bg:"rgba(236,72,153,0.15)",border:"#ec4899",text:"#f472b6"},company:{bg:"rgba(239,68,68,0.15)",border:"#ef4444",text:"#f87171"},methodologies:{bg:"rgba(14,165,233,0.15)",border:"#0ea5e9",text:"#38bdf8"},src:{bg:"rgba(251,146,60,0.15)",border:"#fb923c",text:"#fdba74"},general:{bg:"rgba(148,163,184,0.12)",border:"#64748b",text:"#94a3b8"}};function gm(e){return il[e]??il.general}function bE(e){return e>1600?"macro":e<800?"micro":"standard"}function vE(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 c=0,d=0;for(const m of o)c+=m.x??0,d+=m.y??0;const f=o.length;a.push({domain:i,count:f,centerX:c/f,centerY:d/f,nodes:o})}return a}function wE(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 kE(e,n,a){const i=[...new Set(a.map(m=>m.category||"general"))],o=new Map,c=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:c+f*Math.cos(x),y:d+f*Math.sin(x)})}),o}function jE(e,n=.12){let a;function i(o){for(const c of a){const d=e.get(c.category)||e.get("general");d&&c.x!==void 0&&c.y!==void 0&&(c.vx=(c.vx||0)+(d.x-c.x)*o*n,c.vy=(c.vy||0)+(d.y-c.y)*o*n)}}return i.initialize=function(o){a=o},i}function SE(e){return e.map(n=>{let a=0;for(const o of n.nodes){const c=(o.x??0)-n.centerX,d=(o.y??0)-n.centerY,f=Math.sqrt(c*c+d*d);f>a&&(a=f)}const i=Math.max(40,n.count*8);return{...n,radius:a+i}})}function CE(e,n,a,i){if(!e)return a;const o=new Set([e]),c=new Set;let d=new Set([e]);for(let f=0;f<i;f++){const m=new Set;for(const h of d)if(!c.has(h)){c.add(h);for(const x of n){const g=typeof x.source=="string"?x.source:x.source.id,w=typeof x.target=="string"?x.target:x.target.id;g===h&&!o.has(w)&&(o.add(w),m.add(w)),w===h&&!o.has(g)&&(o.add(g),m.add(g))}}d=m}return o}function NE({docs:e,onNodeClick:n,selectedDocId:a,matchedIds:i,localGraphMode:o,onLocalModeChange:c,onClusterClick:d}){var R;const f=v.useRef(null),m=v.useRef(null),[h,x]=v.useState({width:600,height:400}),[g,w]=v.useState({nodes:[],links:[]}),[b,j]=v.useState(null),[k,E]=v.useState(null),[N,C]=v.useState(new Set),[z,T]=v.useState(null),[H,F]=v.useState({x:0,y:0}),[I,V]=v.useState({x:0,y:0,w:600,h:400}),X=v.useRef(!1),_=v.useRef({x:0,y:0,vx:0,vy:0}),$=v.useRef(null),L=v.useRef(null),W=v.useMemo(()=>bE(I.w),[I.w]),ne=v.useMemo(()=>vE(g.nodes),[g.nodes]),K=v.useMemo(()=>SE(ne),[ne]),q=v.useMemo(()=>{if(o==="global"||!a)return null;const O=new Set(g.nodes.map(te=>te.id)),ae=o==="1-hop"?1:2;return CE(a,g.links,O,ae)},[o,a,g.nodes,g.links]);v.useEffect(()=>{const O=f.current;if(!O)return;const ae=new ResizeObserver(te=>{const{width:Se,height:je}=te[0].contentRect;Se>0&&je>0&&(x({width:Se,height:je}),V(_e=>({..._e,w:Se,h:je})))});return ae.observe(O),()=>ae.disconnect()},[]),v.useEffect(()=>{if(e.length===0)return;const O=new Set(e.map(qe=>qe.id)),ae=e.map(qe=>({id:qe.id,title:qe.title,category:qe.category,akb_type:qe.akb_type,tldr:qe.tldr,tags:qe.tags})),te=(qe,at)=>{if(!at.startsWith(".")&&!at.startsWith("/"))return at;const pt=qe.split("/");pt.pop();const zt=at.split("/");for(const fe of zt)fe===".."?pt.pop():fe!=="."&&fe!==""&&pt.push(fe);return pt.join("/")},Se=[];for(const qe of e)for(const at of qe.links){const pt=te(qe.id,at.href);O.has(pt)&&pt!==qe.id&&(Se.some(zt=>zt.source===qe.id&&zt.target===pt||zt.source===pt&&zt.target===qe.id)||Se.push({source:qe.id,target:pt,label:at.text}))}const{width:je,height:_e}=h,Oe=ae.length,Xe=Oe>100?-600:Oe>50?-500:-400,rt=Oe>100?180:Oe>50?160:140,De=Oe>100?60:50,We=Math.max(je,Oe*12),Ot=Math.max(_e,Oe*10),yt=kE(We,Ot,ae),bt=RN(ae).force("link",gN(Se).id(qe=>qe.id).distance(rt)).force("charge",MN().strength(Xe)).force("center",PC(We/2,Ot/2)).force("collide",pN(De)).force("cluster",jE(yt,.15));L.current=bt,bt.on("tick",()=>{w({nodes:[...ae],links:[...Se]})}),bt.alpha(1).restart();const jt=Oe>100?300:150;for(let qe=0;qe<jt;qe++)bt.tick();if(bt.stop(),w({nodes:[...ae],links:[...Se]}),ae.length>0){let qe=1/0,at=1/0,pt=-1/0,zt=-1/0;for(const be of ae){const ve=be.x??0,Q=be.y??0;ve<qe&&(qe=ve),Q<at&&(at=Q),ve>pt&&(pt=ve),Q>zt&&(zt=Q)}const fe=100;V({x:qe-fe,y:at-fe,w:Math.max(je,pt-qe+fe*2),h:Math.max(_e,zt-at+fe*2)})}return()=>{bt.stop()}},[e,h]);const ie=O=>{if(typeof O=="string"){const ae=g.nodes.find(te=>te.id===O);return{x:(ae==null?void 0:ae.x)??0,y:(ae==null?void 0:ae.y)??0}}return{x:O.x??0,y:O.y??0}},de=v.useCallback(O=>{O.preventDefault();const ae=O.deltaY>0?1.1:.9;V(te=>{const Se=Math.max(200,Math.min(h.width*3,te.w*ae)),je=Math.max(150,Math.min(h.height*3,te.h*ae)),_e=(Se-te.w)/2,Oe=(je-te.h)/2;return{x:te.x-_e,y:te.y-Oe,w:Se,h:je}})},[h]),me=v.useCallback(O=>{O.button===0&&(X.current=!0,_.current={x:O.clientX,y:O.clientY,vx:I.x,vy:I.y})},[I]),D=v.useCallback(O=>{var ae;if($.current){const te=m.current;if(!te)return;const Se=te.getBoundingClientRect(),je=I.w/Se.width,_e=I.h/Se.height,Oe=I.x+(O.clientX-Se.left)*je,Xe=I.y+(O.clientY-Se.top)*_e;$.current.fx=Oe,$.current.fy=Xe,(ae=L.current)==null||ae.alpha(.3).restart();return}if(X.current){const te=(O.clientX-_.current.x)*(I.w/h.width),Se=(O.clientY-_.current.y)*(I.h/h.height);V(je=>({...je,x:_.current.vx-te,y:_.current.vy-Se}))}},[I,h]),U=v.useCallback(()=>{X.current=!1,$.current&&($.current.fx=null,$.current.fy=null,$.current=null)},[]),Y=v.useCallback((O,ae)=>{var te;O.stopPropagation(),$.current=ae,(te=L.current)==null||te.alpha(.3).restart()},[]);return l.jsxs("div",{ref:f,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[l.jsxs("svg",{ref:m,width:h.width,height:h.height,viewBox:`${I.x} ${I.y} ${I.w} ${I.h}`,style:{display:"block",cursor:X.current?"grabbing":"grab"},onWheel:de,onMouseDown:me,onMouseMove:D,onMouseUp:U,onMouseLeave:U,children:[l.jsx("defs",{children:l.jsx("pattern",{id:"grid",width:"20",height:"20",patternUnits:"userSpaceOnUse",children:l.jsx("circle",{cx:"0",cy:"0",r:"0.5",fill:"rgba(255,255,255,0.06)"})})}),l.jsx("rect",{x:I.x-100,y:I.y-100,width:I.w+200,height:I.h+200,fill:"url(#grid)",pointerEvents:"none"}),W==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:ne.map(O=>{const ae=il[O.domain]??il.general,te=Math.max(40,Math.sqrt(O.count)*25),je=i===null||O.nodes.some(_e=>i.has(_e.id))?1:.4;return l.jsxs("g",{transform:`translate(${O.centerX}, ${O.centerY})`,style:{cursor:"pointer",opacity:je,transition:"opacity 0.3s ease"},onMouseEnter:_e=>{var Xe;const Oe=(Xe=f.current)==null?void 0:Xe.getBoundingClientRect();Oe&&F({x:_e.clientX-Oe.left,y:_e.clientY-Oe.top}),j({id:`cluster-${O.domain}`,title:`${O.domain} (${O.count})`,category:O.domain,akb_type:"hub"})},onMouseLeave:()=>j(null),children:[l.jsx("circle",{r:te,fill:ae.bg,stroke:ae.border,strokeWidth:3,opacity:.8}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:ae.text,fontSize:16,fontFamily:"monospace",fontWeight:"bold",style:{pointerEvents:"none"},children:O.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:ae.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",O.count,")"]})]},O.domain)})}),W!=="macro"&&l.jsxs(l.Fragment,{children:[W==="standard"&&K.map(O=>{const ae=il[O.domain]??il.general;if(O.count<2)return null;const te=i===null||O.nodes.some(je=>i.has(je.id)),Se=te?.08:.04;return l.jsxs("g",{children:[l.jsx("circle",{cx:O.centerX,cy:O.centerY,r:O.radius,fill:ae.bg,stroke:ae.border,strokeWidth:1,opacity:Se,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:O.centerX,y:O.centerY-O.radius-8,textAnchor:"middle",fill:ae.text,fontSize:12,fontFamily:"monospace",fontWeight:"600",opacity:te?.85:.5,onClick:()=>d(O.domain),style:{cursor:"pointer",pointerEvents:"auto",transition:"opacity 0.3s ease"},children:[O.domain," (",O.count,")"]})]},`cluster-bg-${O.domain}`)}),g.links.map((O,ae)=>{const te=ie(O.source),Se=ie(O.target),je=k===ae,_e=(te.x+Se.x)/2,Oe=(te.y+Se.y)/2,Xe=typeof O.source=="string"?O.source:O.source.id,rt=typeof O.target=="string"?O.target:O.target.id,De=q===null||q.has(Xe)&&q.has(rt),yt=je||z!==null&&(Xe===z||rt===z)||a&&(Xe===a||rt===a),bt=De?1:.3,jt=yt?bt:bt*.15;return l.jsxs("g",{style:{opacity:jt,transition:"opacity 0.25s ease"},children:[l.jsx("line",{x1:te.x,y1:te.y,x2:Se.x,y2:Se.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>{E(ae),C(new Set([Xe,rt]))},onMouseLeave:()=>{E(null),C(new Set)}}),l.jsx("line",{x1:te.x,y1:te.y,x2:Se.x,y2:Se.y,stroke:yt?"rgba(148,163,184,0.8)":"rgba(148,163,184,0.4)",strokeWidth:yt?1.5:.5,pointerEvents:"none"}),je&&O.label&&l.jsx("text",{x:_e,y:Oe-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:O.label.length>30?O.label.slice(0,28)+"..":O.label})})]},ae)}),g.nodes.map(O=>{const ae=il[O.category]??il.general,te=O.akb_type==="hub",Se=te?24:16,je=W==="micro"?Se*1.5:Se,_e=(b==null?void 0:b.id)===O.id,Oe=a===O.id,Xe=N.has(O.id),rt=_e?1.1:Oe?1.05:1,De=i===null||i.has(O.id),We=q===null||q.has(O.id),Ot=De&&We?1:.35,yt=W==="micro"?wE(O.tldr,60):"",bt=W==="micro"&&O.tags?O.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${O.x??0}, ${O.y??0}) scale(${rt})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:Ot},onClick:jt=>{jt.stopPropagation();const qe=e.find(at=>at.id===O.id);qe&&n(qe)},onMouseDown:jt=>Y(jt,O),onMouseEnter:jt=>{var at;j(O),T(O.id);const qe=(at=f.current)==null?void 0:at.getBoundingClientRect();qe&&F({x:jt.clientX-qe.left,y:jt.clientY-qe.top})},onMouseLeave:()=>{j(null),T(null)},children:[Oe&&l.jsx("rect",{x:-je/2-4,y:-je/2-4,width:je+8,height:je+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:te?5:2,opacity:.6}),!Oe&&Xe&&l.jsx("rect",{x:-je/2-3,y:-je/2-3,width:je+6,height:je+6,fill:"none",stroke:"#60a5fa",strokeWidth:1.5,rx:te?5:2,opacity:.7}),l.jsx("rect",{x:-je/2,y:-je/2,width:je,height:je,fill:ae.border,rx:te?4:2,opacity:_e?1:.9}),l.jsx("rect",{x:-je/2+3,y:-je/2+3,width:Math.max(0,je-6),height:Math.max(0,je-6),fill:ae.bg,rx:te?3:1}),l.jsx("text",{y:je/2+14,textAnchor:"middle",fill:Oe?"#e2e8f0":"#cbd5e1",fontSize:W==="micro"?13:12,fontFamily:"monospace",fontWeight:Oe?"bold":"normal",style:{pointerEvents:"none"},children:O.title.length>36?O.title.slice(0,34)+"..":O.title}),W==="micro"&&yt&&l.jsx("text",{y:je/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:10,fontFamily:"system-ui, sans-serif",opacity:.85,style:{pointerEvents:"none"},children:yt}),W==="micro"&&bt.length>0&&l.jsx("g",{transform:`translate(0, ${je/2+(yt?42:28)})`,children:bt.map((jt,qe)=>{const at=jt.length*5+8;let zt=-bt.reduce((fe,be)=>fe+be.length*5+10,0)/2;for(let fe=0;fe<qe;fe++)zt+=bt[fe].length*5+10;return l.jsxs("g",{transform:`translate(${zt+at/2}, 0)`,children:[l.jsx("rect",{x:-at/2,y:-6,width:at,height:12,fill:ae.bg,stroke:ae.border,strokeWidth:.5,rx:3}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:ae.text,fontSize:9,fontFamily:"monospace",style:{pointerEvents:"none"},children:jt})]},jt)})})]},O.id)})]})]}),b&&!$.current&&l.jsxs("div",{className:"absolute z-10 pointer-events-none p-2.5 rounded text-xs max-w-[240px]",style:{left:Math.min(H.x+16,h.width-250),top:Math.max(H.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:b.title}),l.jsxs("div",{className:"text-[10px] opacity-60 mb-1",children:[b.akb_type.toUpperCase()," / ",b.category]}),b.id.startsWith("cluster-")?l.jsx("div",{className:"text-[10px] text-green-400",children:"Zoom in to see documents"}):l.jsxs(l.Fragment,{children:[((R=e.find(O=>O.id===b.id))==null?void 0:R.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(O=>O.id===b.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(O=>{const ae=o===O,te=O!=="global"&&!a,Se=O==="global"?"🌐 All":O==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!te&&c(O),disabled:te,className:"px-2 py-1 text-[10px] font-medium cursor-pointer transition-all",style:{background:ae?"rgba(22,163,106,0.3)":"transparent",color:te?"var(--terminal-text-muted)":ae?"#4ade80":"var(--terminal-text-secondary)",opacity:te?.4:1,cursor:te?"not-allowed":"pointer"},title:te?"Select a node first":`Show ${O==="global"?"all nodes":`nodes within ${O}`}`,children:Se},O)})}),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 EE(e){const n=[],a=new Map;return[...e].sort((o,c)=>o.id.localeCompare(c.id)).forEach(o=>{const c=o.id.split("/");let d=n,f="";for(let m=0;m<c.length-1;m++)if(f=f?`${f}/${c[m]}`:c[m],a.has(f))d=a.get(f).children;else{const h={type:"folder",name:c[m],path:f,children:[]};a.set(f,h),d.push(h),d=h.children}d.push({type:"file",name:c[c.length-1],path:o.id,doc:o})}),n}function AE({docs:e,onDocumentClick:n,selectedDocId:a,matchedIds:i}){const[o,c]=v.useState(new Set(["knowledge","projects","architecture","operations","company"])),[d,f]=v.useState(null),[m,h]=v.useState([]),[x,g]=v.useState(-1),w=v.useMemo(()=>EE(e),[e]),b=H=>{c(F=>{const I=new Set(F);return I.has(H)?I.delete(H):I.add(H),I})},j=H=>{f(H),n(H);const F=m.slice(0,x+1);F.push(H),F.length>10&&F.shift(),h(F),g(F.length-1)},k=()=>{f(null),n(null)},E=()=>{if(x>0){const H=x-1;g(H),f(m[H]),n(m[H])}},N=()=>{if(x<m.length-1){const H=x+1;g(H),f(m[H]),n(m[H])}},C=H=>{const F=m.indexOf(H);F!==-1&&(g(F),f(H),n(H))},z=H=>{H==="hub"&&k()},T=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"}),w.map(H=>l.jsx(fv,{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:T?l.jsx(hv,{doc:T,onClose:k,onBreadcrumbClick:z,history:m,historyIndex:x,onHistoryBack:E,onHistoryForward:N,onHistoryJump:C,onNavigateDoc:j,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 fv({node:e,level:n,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:c,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",w=e.type==="folder"||f===null||f.has(e.path);if(e.type==="folder"){const E=f===null||(((j=e.children)==null?void 0:j.some(N=>{if(N.type==="file")return f.has(N.path);const C=z=>{var T;return z.type==="file"?f.has(z.path):((T=z.children)==null?void 0:T.some(C))??!1};return C(N)}))??!1);return l.jsxs("div",{style:{opacity:E?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:()=>c(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(N=>l.jsx(fv,{node:N,level:n+1,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:c,onFileClick:d,matchedIds:f},N.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:w?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 DE(e){const n=e.split(`
|
|
82
|
+
`),a=[],i=new Map;for(const o of n){const c=o.match(/^(#{2,3})\s+(.+)$/);if(!c)continue;const d=c[1].length,f=c[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 hv({doc:e,onClose:n,onBreadcrumbClick:a,history:i,historyIndex:o,onHistoryBack:c,onHistoryForward:d,onHistoryJump:f,onNavigateDoc:m,allDocs:h}){const[x,g]=v.useState(null),[w,b]=v.useState(!1),[j,k]=v.useState(null),E=v.useRef(null),[N,C]=v.useState(null);v.useEffect(()=>{if("content"in e&&e.content){g(e);return}b(!0),k(null),ye.getKnowledgeDoc(e.id).then(g).catch(W=>k(W instanceof Error?W.message:"Failed to load")).finally(()=>b(!1))},[e]);const z=v.useMemo(()=>!x||e.format==="html"?[]:DE(x.content),[x,e.format]),T=W=>{if(!E.current)return;const ne=E.current.querySelectorAll("h2, h3");for(const K of ne){const ie=(K.textContent||"").toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(W.startsWith(ie)){K.scrollIntoView({behavior:"smooth",block:"start"}),C(W);break}}},H=gm(e.category),F=e.akb_type==="hub",I=z.length>0&&!w&&!j,V=v.useMemo(()=>new Set(h.map(W=>W.id)),[h]),X=v.useCallback(W=>{const K=W.target.closest("a");if(!K)return;const q=K.getAttribute("href");if(!q||q.startsWith("http://")||q.startsWith("https://")||q.startsWith("#"))return;const ie=q.split("#")[0];if(!ie.endsWith(".md"))return;W.preventDefault();const de=e.id.substring(0,e.id.lastIndexOf("/"));let me=ie;if(ie.startsWith("./")||ie.startsWith("../")){const D=de.split("/"),U=ie.split("/");for(const Y of U)Y===".."?D.pop():Y!=="."&&D.push(Y);me=D.join("/")}if(V.has(me))m(me);else{const D=me.split("/").pop()||"",U=h.find(Y=>Y.id.endsWith("/"+D)||Y.id===D);U&&m(U.id)}},[e.id,h,V,m]),_=i.slice(0,o).reverse().filter(W=>W!==e.id).slice(0,3).map(W=>h.find(ne=>ne.id===W)).filter(W=>W!==void 0),$=o>0,L=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:c,disabled:!$,className:"text-xs font-semibold cursor-pointer hover:opacity-70 disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--active-green)"},title:"Back",children:"←"}),l.jsx("button",{onClick:d,disabled:!L,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:_.map(W=>l.jsxs("button",{onClick:()=>f(W.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:W.title,children:["📄 ",W.title.length>15?W.title.slice(0,15)+"...":W.title]},W.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:H.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:F?"📘":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(W=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium",style:{background:H.bg,color:H.text,border:`1px solid ${H.border}`},children:W},W))})]})]}),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:E,className:"flex-1 overflow-y-auto p-4",onClick:X,children:[w&&l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"Loading..."}),j&&l.jsx("div",{className:"text-xs p-2 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:j}),x&&l.jsx(Es,{content:x.content})]}),I&&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:z.map(W=>l.jsx("button",{onClick:()=>T(W.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(W.level-2)*8+8,color:N===W.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:N===W.id?"bold":"normal"},children:W.text.length>30?W.text.slice(0,28)+"..":W.text},W.id))})]})]})]})}const TE=500,Xg=360,FE=700;function Zo(e,n,a){const i=n??TE,[o,c]=v.useState(i),[d,f]=v.useState(!1),m=v.useRef(0),h=v.useRef(0),x=v.useRef(a);x.current=a;const g=e>0,w=g?e:0,b=Math.max(FE,i),j=g?Math.max(Xg,window.innerWidth-e-100):b,k=Math.min(o,j),E=v.useCallback(N=>{N.preventDefault(),m.current=N.clientX,h.current=k,f(!0);const C=()=>{f(!1),document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",C)},z=T=>{const H=m.current-T.clientX,F=h.current+H;if(F>=window.innerWidth*.6&&x.current){C(),x.current();return}const I=Math.min(b,Math.max(Xg,F));c(I)};document.addEventListener("mousemove",z),document.addEventListener("mouseup",C)},[k]);return{panelRight:w,panelWidth:k,isResizing:d,handleResizeStart:E}}function Wg({docs:e,onClose:n,onRefresh:a,terminalWidth:i=0,initialDocId:o,onMaximize:c}){const[d,f]=v.useState(()=>{const O=localStorage.getItem("kb-view-mode");return O==="graph"||O==="tree"||O==="list"||O==="health"?O:"graph"}),[m,h]=v.useState(null),[x,g]=v.useState(null),[w,b]=v.useState([]),[j,k]=v.useState(-1),[E,N]=v.useState("global"),[C,z]=v.useState(""),T=v.useMemo(()=>{const O=new Set(e.map(te=>te.category)),ae=Object.keys(il);return[...O].sort((te,Se)=>{const je=ae.includes(te)?0:1,_e=ae.includes(Se)?0:1;return je-_e||te.localeCompare(Se)})},[e]),[H,F]=v.useState(()=>new Set);v.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const I=v.useMemo(()=>new As(e,{keys:["title","tldr","tags","id"],threshold:.3,includeScore:!0}),[e]),V=v.useMemo(()=>{let O=new Set(e.map(ae=>ae.id));if(C.trim()){const ae=I.search(C);O=new Set(ae.map(te=>te.item.id))}return H.size>0&&(O=new Set(Array.from(O).filter(ae=>{const te=e.find(Se=>Se.id===ae);return te&&H.has(te.category)}))),O.size===e.length?null:O},[e,C,I,H]),X=v.useMemo(()=>V===null?e:e.filter(O=>V.has(O.id)),[e,V]),_=O=>{F(ae=>{if(ae.size===0)return new Set(T.filter(je=>je!==O));const te=new Set(ae);if(te.has(O)){if(te.delete(O),te.size===0)return new Set}else if(te.add(O),te.size===T.length)return new Set;return te})},{panelRight:$,panelWidth:L,isResizing:W,handleResizeStart:ne}=Zo(i,void 0,c),K=O=>{h(O.id),q(O.id)},q=O=>{g(O);const ae=w.slice(0,j+1);ae.push(O),ae.length>10&&ae.shift(),b(ae),k(ae.length-1)},ie=()=>{g(null)},de=()=>{if(j>0){const O=j-1;k(O),g(w[O]),h(w[O])}},me=()=>{if(j<w.length-1){const O=j+1;k(O),g(w[O]),h(w[O])}},D=O=>{const ae=w.indexOf(O);ae!==-1&&(k(ae),g(O),h(O))},U=O=>{O==="hub"&&ie()},Y=O=>{F(ae=>ae.size===1&&ae.has(O)?new Set:new Set([O]))},R=m?e.find(O=>O.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:$},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)] ${W?"resizing":""}`,style:{right:$,width:L,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 ${W?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:ne}),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:[l.jsx("button",{className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-sm hover:bg-white/30 cursor-help",title:`Keyboard Shortcuts:
|
|
83
|
+
• Esc — Close panel
|
|
84
|
+
• Mouse Wheel — Zoom in/out
|
|
85
|
+
• Mouse Drag — Pan view
|
|
86
|
+
• Click Cluster Label — Filter to domain
|
|
87
|
+
• Hover Edge — Highlight connected nodes`,children:"?"}),c&&l.jsx("button",{onClick:c,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(ju,{icon:"🕸️",label:"Graph",active:d==="graph",onClick:()=>f("graph")}),l.jsx(ju,{icon:"🌲",label:"Tree",active:d==="tree",onClick:()=>{f("tree"),h(null)}}),l.jsx(ju,{icon:"📋",label:"List",active:d==="list",onClick:()=>{f("list"),h(null)}}),l.jsx(ju,{icon:"🏥",label:"Health",active:d==="health",onClick:()=>{f("health"),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:C,onChange:O=>z(O.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)"}}),C&&l.jsx("button",{onClick:()=>z(""),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:T.map(O=>{const ae=gm(O),te=H.size===0||H.has(O);return l.jsx("button",{onClick:()=>_(O),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:te?ae.bg:"transparent",color:te?ae.text:"var(--terminal-text-muted)",border:`1px solid ${te?ae.border:"var(--terminal-border)"}`,opacity:te?1:.5},children:O},O)})}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:X.length===e.length?`${e.length} documents`:`${X.length} of ${e.length} documents`})]}),d==="graph"&&l.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col animate-fadeIn",children:[x&&(()=>{const O=e.find(ae=>ae.id===x);return O?l.jsx("div",{className:"flex-1 overflow-y-auto",children:l.jsx(hv,{doc:O,onClose:ie,onBreadcrumbClick:U,history:w,historyIndex:j,onHistoryBack:de,onHistoryForward:me,onHistoryJump:D,onNavigateDoc:q,allDocs:e})}):null})(),!x&&l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx(NE,{docs:e,onNodeClick:K,selectedDocId:m,matchedIds:V,localGraphMode:E,onLocalModeChange:N,onClusterClick:Y}),R&&!x&&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:R.title}),l.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:R.status==="active"?"#16a34a":R.status==="draft"?"#f59e0b":"#94a3b8"}}),R.tldr&&l.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:R.tldr}),R.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"}),R.links.slice(0,5).map((O,ae)=>l.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",O.text]},ae))]})]})]}),!x&&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:T.map(O=>{const ae=gm(O);return l.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[l.jsx("div",{className:"w-2 h-2",style:{background:ae.border}}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:O})]},O)})})})]}),d==="tree"&&l.jsx(AE,{docs:e,onDocumentClick:O=>h(O),selectedDocId:m,matchedIds:V}),d==="list"&&l.jsx(RE,{icon:"📋",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"}),d==="health"&&l.jsx(ME,{onNavigateDoc:O=>h(O)})]})]})}function ju({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 RE({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 ME({onNavigateDoc:e}){const[n,a]=v.useState(null),[i,o]=v.useState(!0),[c,d]=v.useState(null);if(v.useEffect(()=>{ye.getKnowledgeHealth().then(k=>{a(k),o(!1)}).catch(k=>{d(k.message||"Failed to fetch health data"),o(!1)})},[]),i)return l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading health data..."})});if(c)return l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-sm",style:{color:"#ef4444"},children:["Error: ",c]})});if(!n)return null;const{health:f,orphanDocs:m,staleDocs:h,brokenLinks:x,suggestions:g,totalDocs:w,linkedDocs:b}=n;let j="#4ade80";return f<70&&(j="#f59e0b"),f<50&&(j="#ef4444"),l.jsx("div",{className:"flex-1 overflow-y-auto p-6 animate-fadeIn",children:l.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[l.jsxs("div",{className:"p-6 rounded-lg",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-lg font-bold mb-1",style:{color:"var(--terminal-text)"},children:"Knowledge Health"}),l.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[w," total documents, ",b," linked"]})]}),l.jsx("div",{className:"text-4xl font-bold px-6 py-3 rounded-lg",style:{color:j,background:`${j}15`,border:`2px solid ${j}40`},children:f})]}),l.jsx("div",{className:"w-full h-2 rounded-full overflow-hidden",style:{background:"var(--hud-bg)"},children:l.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${f}%`,background:j}})})]}),g.length>0&&l.jsxs("div",{className:"p-4 rounded-lg",style:{background:"rgba(59,130,246,0.1)",border:"1px solid rgba(59,130,246,0.3)"},children:[l.jsx("div",{className:"text-sm font-bold mb-2",style:{color:"#60a5fa"},children:"💡 Suggestions"}),l.jsx("ul",{className:"space-y-1",children:g.map((k,E)=>l.jsxs("li",{className:"text-xs",style:{color:"var(--terminal-text)"},children:["• ",k]},E))})]}),m.length>0&&l.jsxs("div",{className:"p-4 rounded-lg",style:{background:"rgba(245,158,11,0.1)",border:"1px solid rgba(245,158,11,0.3)"},children:[l.jsxs("div",{className:"text-sm font-bold mb-2",style:{color:"#fbbf24"},children:["📦 Orphan Documents (",m.length,")"]}),l.jsx("div",{className:"text-xs mb-2",style:{color:"var(--terminal-text-muted)"},children:"Documents not registered in any Hub"}),l.jsx("ul",{className:"space-y-1",children:m.map((k,E)=>l.jsx("li",{children:l.jsx("button",{onClick:()=>e(k),className:"text-xs hover:underline",style:{color:"#fbbf24"},children:k})},E))})]}),h.length>0&&l.jsxs("div",{className:"p-4 rounded-lg",style:{background:"rgba(236,72,153,0.1)",border:"1px solid rgba(236,72,153,0.3)"},children:[l.jsxs("div",{className:"text-sm font-bold mb-2",style:{color:"#f472b6"},children:["📅 Stale Documents (",h.length,")"]}),l.jsx("div",{className:"text-xs mb-2",style:{color:"var(--terminal-text-muted)"},children:"Documents marked as deprecated or stale"}),l.jsx("ul",{className:"space-y-1",children:h.map((k,E)=>l.jsx("li",{children:l.jsx("button",{onClick:()=>e(k),className:"text-xs hover:underline",style:{color:"#f472b6"},children:k})},E))})]}),x.length>0&&l.jsxs("div",{className:"p-4 rounded-lg",style:{background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.3)"},children:[l.jsxs("div",{className:"text-sm font-bold mb-2",style:{color:"#f87171"},children:["🔗 Broken Links (",x.length,")"]}),l.jsx("div",{className:"text-xs mb-2",style:{color:"var(--terminal-text-muted)"},children:"Links pointing to non-existent documents"}),l.jsx("ul",{className:"space-y-2",children:x.map((k,E)=>l.jsxs("li",{className:"space-y-0.5",children:[l.jsx("button",{onClick:()=>e(k.file),className:"text-xs hover:underline block",style:{color:"#f87171"},children:k.file}),l.jsxs("div",{className:"text-xs pl-4",style:{color:"var(--terminal-text-muted)"},children:["→ ",k.link]})]},E))})]}),m.length===0&&h.length===0&&x.length===0&&l.jsxs("div",{className:"p-8 rounded-lg text-center",style:{background:"rgba(34,197,94,0.1)",border:"1px solid rgba(34,197,94,0.3)"},children:[l.jsx("div",{className:"text-4xl mb-3",children:"🎉"}),l.jsx("div",{className:"text-lg font-bold mb-2",style:{color:"#4ade80"},children:"All documents are healthy!"}),l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"No orphan documents, stale content, or broken links detected."})]})]})})}function Gg({waves:e,decisions:n,mode:a,onClose:i,onOpenWaveCenter:o,onUpdateDecision:c,onDeleteDecision:d,terminalWidth:f=0,onMaximize:m}){const[h,x]=v.useState("decisions"),{panelRight:g,panelWidth:w,isResizing:b,handleResizeStart:j}=Zo(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:w,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(Fh,{label:`Decisions (${n.length})`,active:h==="decisions",onClick:()=>x("decisions")}),o?l.jsx(Fh,{label:"Waves →",active:!1,onClick:o}):l.jsx(Fh,{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(zE,{decision:k,onSave:c,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,E)=>l.jsx(_E,{title:`Wave ${k.id}`,subtitle:k.startedAt,content:k.directive},E))]})]})]})}function zE({decision:e,onSave:n,onDelete:a}){const[i,o]=v.useState(!1),[c,d]=v.useState(!1),[f,m]=v.useState(e.content),[h,x]=v.useState(!1),g=mv(e.content).slice(0,160),w=e.content.length>100,b=v.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=v.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:()=>{c||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&&!c&&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&&c?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(Es,{content:e.content})}):null,!i&&w&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:g})]})}function Fh({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 mv(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 _E({title:e,subtitle:n,content:a}){const[i,o]=v.useState(!1),c=a.length>100,d=mv(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(Es,{content:a})}),!i&&c&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:d})]})}const ks=[{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"}}],ym=[{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"]}],BE={completedQuests:[],activeChapter:1,sideQuestsCompleted:[]};function Vg(){return{...BE}}function bm(e,n){return n.completedQuests.includes(e.id)?"completed":"active"}function pv(e){return ks.filter(n=>bm(n,e)==="active")}function OE(e){const n=pv(e);return n.find(i=>i.chapter===e.activeChapter)??n[0]??null}function $E(e,n){const a=ks.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 Kg(e){let n=1;for(const a of ym)if(a.questIds.every(i=>e.completedQuests.includes(i))){const i=ym.find(o=>o.num===a.num+1);i&&(n=i.num)}return n!==e.activeChapter?{...e,activeChapter:n}:e}function LE(e){const n=ks.filter(i=>i.type==="main").length;return{completed:e.completedQuests.filter(i=>{var o;return((o=ks.find(c=>c.id===i))==null?void 0:o.type)==="main"}).length,total:n}}function IE(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 HE({progress:e,onQuestAction:n,onClose:a,terminalWidth:i=0}){const{completed:o,total:c}=LE(e),d=c>0?Math.round(o/c*100):0,{panelRight:f,panelWidth:m,isResizing:h,handleResizeStart:x}=Zo(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,"/",c," 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:ym.map(g=>{const w=ks.filter(k=>g.questIds.includes(k.id)),b=w.every(k=>e.completedQuests.includes(k.id)),j=w.some(k=>bm(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:w.map(k=>{const E=bm(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:E==="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:E==="completed"?"var(--terminal-text-muted)":"var(--terminal-text)",textDecoration:E==="completed"?"line-through":"none"},children:k.title}),E==="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 →"})]}),E==="active"&&l.jsx("div",{className:"text-[10px] mt-1 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:k.description}),E==="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 UE({projectId:e,onClose:n,terminalWidth:a=0}){const[i,o]=v.useState(null),{panelRight:c,panelWidth:d,isResizing:f,handleResizeStart:m}=Zo(a);if(v.useEffect(()=>{ye.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:c},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:c,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(w=>w.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:c},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:c,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(Es,{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(w=>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:w.title}),l.jsx(qE,{status:w.status})]}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-muted)"},children:w.role}),w.description&&l.jsx("div",{className:"text-xs mt-1.5 line-clamp-2",style:{color:"var(--terminal-text-secondary)"},children:w.description})]},w.id))})]})]})]})]})}function qE({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 YE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function XE({roleId:e,roleName:n,mode:a="assign",onClose:i,onExecutionStart:o}){const[c,d]=v.useState(""),f=v.useRef(null);v.useEffect(()=>{var g;(g=f.current)==null||g.focus()},[]);const m=()=>{c.trim()&&(o(e,c.trim()),i())},h=g=>{g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&m(),g.key==="Escape"&&i()},x=YE[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:c,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:!c.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 Pg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function Jm({event:e,isThinkingCollapsed:n,onToggleThinking:a,onNavigateToSession:i,onOpenKnowledgeDoc:o,compact:c}){var f;const d=Pg[e.roleId]??"#888";switch(e.type){case"text":{const m=e.data.text??"",h=c?m.slice(0,300):m;return/[#*|`\[\]_~>-]/.test(h)?l.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:l.jsx(Um,{remarkPlugins:[Wm],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 ${c?"max-h-[60px]":"max-h-[120px]"}`,children:[m.slice(0,c?200:500),m.length>(c?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):"",w=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:c?200:400},children:w}):l.jsxs(l.Fragment,{children:[x&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${c?"max-w-[200px]":"max-w-[400px]"}`,children:x}),w&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${c?"max-w-[200px]":"max-w-[400px]"}`,children:w})]})]})}case"dispatch:start":{const m=e.data.targetRoleId??e.data.roleId??"",h=e.data.task??"",x=e.data.childSessionId,g=Pg[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,c?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"msg: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,c?50:80)]});case"msg: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"msg:error":return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-red-900/20 border border-red-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400"}),l.jsx("span",{className:"text-red-300 font-bold text-[11px]",children:"Error"}),l.jsx("span",{className:"text-red-200/70 text-[10px]",children:e.data.message})]})});case"msg:awaiting_input":{const m=e.data.question??"";return l.jsxs("div",{className:"mt-2 p-2 rounded-lg border",style:{background:"#F59E0B11",borderColor:"#F59E0B33"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsx("span",{className:"font-bold text-[11px]",style:{color:"#F59E0B"},children:"Awaiting Reply"})]}),m&&l.jsx("div",{className:"mt-1 text-[11px] text-[var(--terminal-text)] whitespace-pre-wrap",children:m})]})}case"msg:reply":return l.jsx("div",{className:"mt-1 p-2 rounded-lg bg-blue-900/20 border border-blue-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-blue-300 font-bold text-[11px]",children:"CEO replied:"}),l.jsx("span",{className:"text-blue-200/80 text-[11px]",children:e.data.response??""})]})});case"import:scan":case"import:process":case"import:created":return l.jsxs("div",{className:"text-cyan-300/70 text-[11px]",children:["[",e.type,"] ",JSON.stringify(e.data)]});default:return null}}function WE({sessionId:e,title:n,color:a,variant:i,style:o,onClose:c,onMinimize:d,onDone:f,onNavigateToSession:m,onOpenKnowledgeDoc:h}){const{events:x,status:g,textOutput:w,childSessionIds:b}=My(e),[j,k]=v.useState(0),[E,N]=v.useState(new Set),C=v.useRef(null),z=v.useRef(Date.now()),T=v.useRef(!1);v.useEffect(()=>{const $=setInterval(()=>{k(Math.floor((Date.now()-z.current)/1e3))},1e3);return()=>clearInterval($)},[]),v.useEffect(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[x]),v.useEffect(()=>{(g==="done"||g==="error")&&!T.current&&(T.current=!0,f==null||f())},[g,f]);const H=$=>{N(L=>{const W=new Set(L);return W.has($)?W.delete($):W.add($),W})},F={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[g],I={idle:"#888",connecting:"#888",streaming:a,done:"#2E7D32",error:"#C62828"}[g],V=$=>`${Math.floor($/60)}:${String($%60).padStart(2,"0")}`,X=g==="done"||g==="error",_=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:V(j)}),l.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${I}22`,color:I},children:F}),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:"–"}),X&&l.jsx("button",{onClick:c,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($=>l.jsx(Jm,{event:$,isThinkingCollapsed:E.has($.seq),onToggleThinking:()=>H($.seq),onNavigateToSession:m,onOpenKnowledgeDoc:h},$.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`,w.length>0&&` · ${w.length} chars`,b.length>0&&` · ${b.length} dispatches`]}),X&&l.jsx("button",{onClick:c,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:X?c:void 0}),_]}):_}const GE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function VE({orgNodes:e,rootId:n,activeRoles:a,onToggleRole:i}){const o=e[n];if(!o)return null;const c=!!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 E=e[k];E&&(j.push(E),h.push(E))}m.set(b.id,j)}const x=b=>!a||a.has(b),g=c?f.filter(b=>a.has(b.id)).length+h.filter(b=>a.has(b.id)).length:f.length+h.length,w=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:c?"Select Target Roles":"Propagation Preview"}),c&&l.jsxs("span",{className:"text-[10px] text-white/50",children:[g,"/",w," 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=GE[b.id]??"#888";return l.jsx(KE,{node:b,active:j,color:k,interactive:c,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(z=>z.children.includes(b.id)))==null?void 0:C.id,E=k?x(k):!0,N=c&&E;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${N?"cursor-pointer select-none":c?"cursor-not-allowed":""} ${j&&E?"border-white/15 text-white/40":"border-white/5 text-white/15 opacity-50"}`,onClick:N?()=>i(b.id,!j):void 0,title:c?E?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:c?`${g} role${g!==1?"s":""} will receive this wave`:`${w} role${w!==1?"s":""} will receive this wave`})]})}function KE({node:e,active:n,color:a,interactive:i,onToggle:o,subRoles:c,activeRoles:d}){const f=v.useCallback(m=>{if(!(!i||!o)){if(n){o(e.id,!1);for(const h of c)d!=null&&d.has(h.id)&&o(h.id,!1)}else if(o(e.id,!0),m.shiftKey)for(const h of c)d!=null&&d.has(h.id)||o(h.id,!0)}},[i,o,n,e.id,c,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 PE({cLevelRoles:e,orgNodes:n,rootId:a,onClose:i,onDispatch:o}){const[c,d]=v.useState(""),f=v.useRef(null),[m,h]=v.useState(()=>{const k=new Set,E=n[a];if(E)for(const N of E.children){k.add(N);const C=n[N];if(C)for(const z of C.children)k.add(z)}return k});v.useEffect(()=>{var k;(k=f.current)==null||k.focus()},[]);const x=v.useCallback((k,E)=>{h(N=>{const C=new Set(N);return E?C.add(k):C.delete(k),C})},[]),g=e.filter(k=>m.has(k.id)).length,w=()=>{if(!c.trim()||g===0)return;const k=n[a];let E=0;if(k)for(const z of k.children){E++;const T=n[z];T&&(E+=T.children.length)}const C=m.size>=E?void 0:Array.from(m);o(c.trim(),C),i()},b=k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&w(),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(VE,{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:c,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:w,disabled:!c.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 QE(){const e=v.useRef(null),n=v.useRef(0),a=v.useCallback((o,c,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(),w=new TextDecoder;let b="",j="",k=Date.now();const E=6e4,N=setInterval(()=>{Date.now()-k>E&&(console.warn("[WaveStream] Stale connection — no data for 60s"),f.abort(),clearInterval(N))},1e4);try{for(;;){const{done:C,value:z}=await g.read();if(C)break;k=Date.now(),b+=w.decode(z,{stream:!0});const T=b.split(`
|
|
88
|
+
`);b=T.pop()??"";for(const H of T)if(H.startsWith("event: "))j=H.slice(7).trim();else if(H.startsWith("data: ")){try{const F=JSON.parse(H.slice(6));ZE(j,F,c,d)}catch{}j=""}}}finally{clearInterval(N)}}).catch(x=>{x.name!=="AbortError"&&console.error("[WaveStream] Connection error:",x)})},[]),i=v.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{connectWaveStream:a,disconnectWaveStream:i}}function ZE(e,n,a,i){switch(e){case"wave:event":JE(n,a);break;case"wave:role-attached":e6(n,a,i);break;case"wave:role-detached":t6(n,a);break;case"wave:done":n6(a);break}}function JE(e,n){const{event:a,sessionId:i}=e,{roleId:o}=a;n(c=>{const d=new Map(c),f=d.get(o);if(!f||f.events.some(h=>h.seq===a.seq&&h.roleId===a.roleId))return c;const m={...f,sessionId:i||f.sessionId,events:[...f.events,a]};return a.type==="msg:start"?(m.status="streaming",m.streamStatus="streaming"):a.type==="msg:done"?(m.status="done",m.streamStatus="done"):a.type==="msg:error"?(m.status="error",m.streamStatus="error"):a.type==="msg:awaiting_input"?(m.status="awaiting_input",m.streamStatus="done"):a.type==="msg:reply"&&(m.status="streaming",m.streamStatus="streaming"),d.set(o,m),d})}function e6(e,n,a){const{sessionId:i,roleId:o}=e;n(c=>{const d=new Map(c),f=d.get(o);if(f){const m=f.status==="awaiting_input"||f.status==="done"||f.status==="error";d.set(o,{...f,sessionId:i,status:m?f.status:"streaming",streamStatus:m?f.streamStatus:"streaming"})}else{const m=a[o];d.set(o,{sessionId:i,roleId:o,roleName:(m==null?void 0:m.name)??o,children:(m==null?void 0:m.children)??[],status:"streaming",events:[],streamStatus:"streaming"})}return d})}function t6(e,n){const{roleId:a,reason:i}=e,o=i==="error"?"error":"done";n(c=>{const d=new Map(c),f=d.get(a);return!f||f.status==="done"||f.status==="error"?c:(d.set(a,{...f,status:o,streamStatus:o==="error"?"error":"done"}),d)})}function n6(e){e(n=>{const a=new Map(n);let i=!1;for(const[o,c]of a)c.status==="waiting"&&(a.set(o,{...c,status:"not-dispatched"}),i=!0);return i?a:n})}function xv(e,n,a,i){const[o,c]=v.useState(new Map),[d,f]=v.useState(null),[m,h]=v.useState(new Set),x=v.useRef(new Map),g=v.useRef(o);g.current=o;const w=v.useRef(!1),{connectWaveStream:b,disconnectWaveStream:j}=QE(),k=v.useCallback(()=>{if(!a||Object.keys(n).length===0)return null;const _=new Map,$=new Set,L=ne=>{const K=n[ne];K&&($.add(ne),_.set(ne,{sessionId:"",roleId:ne,roleName:K.name,children:K.children,status:"waiting",events:[],streamStatus:"idle"}),K.children.forEach(L))},W=n[a];return W&&(_.set(a,{sessionId:"",roleId:a,roleName:"CEO",children:W.children,status:"not-dispatched",events:[],streamStatus:"idle"}),W.children.forEach(L)),{initial:_,allRoles:$}},[n,a]);v.useEffect(()=>{if(w.current)if(e.length>0)w.current=!1;else return;const _=k();if(!_)return;const{initial:$,allRoles:L}=_;for(const W of e){const ne=$.get(W.roleId);ne&&(ne.sessionId=W.sessionId,ne.status="streaming",ne.streamStatus="connecting")}c($),h(W=>{if(W.size===0){const ne=new Set(L);return ne.delete(a),ne}return W}),e.length>0&&f(W=>W??e[0].roleId)},[e,n,a,k]);const E=v.useCallback(_=>{h($=>{const L=new Set($);return L.has(_)?L.delete(_):L.add(_),L})},[]),N=v.useCallback(_=>{for(const[,$]of x.current)$.controller.abort();x.current.clear(),w.current=!0,c(_);for(const[$,L]of _)if($!==a&&L.events.length>0){f($);break}},[a]),C=v.useCallback((_,$)=>{const L=x.current.get(_);if(L&&!L.controller.signal.aborted){console.log(`[WaveTree] connectStream SKIP (already connected) → role=${$} session=${_}`);return}L&&L.controller.abort(),console.log(`[WaveTree] connectStream → role=${$} session=${_}`),c(q=>{const ie=new Map(q),de=ie.get($);return de&&ie.set($,{...de,sessionId:_,status:"streaming",streamStatus:"connecting",events:[]}),ie});const W=new AbortController,ne={controller:W,lastSeq:-1};x.current.set(_,ne);const K=`/api/sessions/${_}/stream?from=0`;fetch(K,{signal:W.signal}).then(async q=>{if(!q.ok||!q.body){c(U=>{const Y=new Map(U),R=Y.get($);return R&&Y.set($,{...R,streamStatus:"error"}),Y});return}console.log(`[WaveTree SSE] connected → role=${$} status=${q.status}`),c(U=>{const Y=new Map(U),R=Y.get($);return R&&Y.set($,{...R,streamStatus:"streaming",status:"streaming"}),Y});const ie=q.body.getReader(),de=new TextDecoder;let me="",D="";for(;;){const{done:U,value:Y}=await ie.read();if(U){W.abort();break}me+=de.decode(Y,{stream:!0});const R=me.split(`
|
|
89
|
+
`);me=R.pop()??"";for(const O of R)if(O.startsWith("event: "))D=O.slice(7).trim();else if(O.startsWith("data: ")){try{const ae=JSON.parse(O.slice(6));if(console.log(`[WaveTree SSE] role=${$} event=${D} type=${(ae==null?void 0:ae.type)??"?"} seq=${(ae==null?void 0:ae.seq)??"?"}`),D==="activity"){const te=ae;te.seq>ne.lastSeq&&(ne.lastSeq=te.seq),c(Se=>{const je=new Map(Se),_e=je.get($);if(!_e||_e.events.some(Xe=>Xe.seq===te.seq))return Se;const Oe={..._e,events:[..._e.events,te]};if(te.type==="dispatch:start"&&te.data.childSessionId){const Xe=te.data.targetRoleId??te.data.roleId,rt=te.data.childSessionId;if(console.log(`[WaveTree] dispatch:start → target=${Xe} childSession=${rt??"none"} from=${$}`),Xe&&rt){const De=je.get(Xe);De&&(je.set(Xe,{...De,sessionId:rt,status:"streaming",streamStatus:"connecting"}),setTimeout(()=>C(rt,Xe),0))}}return te.type==="msg:done"?(Oe.status="done",Oe.streamStatus="done"):te.type==="msg:error"?(Oe.status="error",Oe.streamStatus="error"):te.type==="msg:awaiting_input"?(Oe.status="awaiting_input",Oe.streamStatus="done"):te.type==="msg:reply"&&(Oe.status="streaming",Oe.streamStatus="streaming"),je.set($,Oe),je})}else if(D==="stream:end"){const te=ae.reason;te!=="replied"&&c(Se=>{const je=new Map(Se),_e=je.get($);if(!_e)return Se;const Oe=te==="error"?"error":te==="awaiting_input"?"awaiting_input":"done";return je.set($,{..._e,status:_e.status==="streaming"?Oe:_e.status,streamStatus:Oe==="error"?"error":"done"}),je})}}catch{}D=""}}}).catch(q=>{q.name!=="AbortError"&&c(ie=>{const de=new Map(ie),me=de.get($);return me&&de.set($,{...me,streamStatus:"error"}),de})})},[]),z=v.useRef(new Set),T=v.useRef(!1),H=v.useRef(n);H.current=n;const F=v.useRef(e);F.current=e,v.useEffect(()=>{if(!(!i||F.current.length===0))return T.current=!0,b(i,c,H.current),()=>{j(),T.current=!1}},[i,b,j]),v.useEffect(()=>{if(i||e.length===0)return;T.current=!1;const _=new Set;for(const $ of e)_.add($.sessionId),C($.sessionId,$.roleId);return z.current=_,()=>{for(const $ of z.current){const L=x.current.get($);L&&(L.controller.abort(),x.current.delete($))}z.current.clear()}},[e,C,i]);const I=(()=>{let _=0,$=0,L=0,W=0;for(const[ne,K]of o)ne!==a&&(W++,K.status==="done"?_++:K.status==="streaming"?$++:K.status==="awaiting_input"&&L++);return{done:_,total:W,running:$,awaitingInput:L}})(),V=I.total>0&&I.done>0&&I.running===0&&I.awaitingInput===0&&Array.from(o.values()).every(_=>!ol(_.status)&&_.streamStatus!=="streaming"&&_.streamStatus!=="connecting");v.useEffect(()=>{V&&c(_=>{const $=new Map(_);let L=!1;for(const[W,ne]of $)ne.status==="waiting"&&($.set(W,{...ne,status:"not-dispatched"}),L=!0);return L?$:_})},[V]);const X=v.useCallback(()=>{for(const[,$]of x.current)$.controller.abort();x.current.clear(),w.current=!1;const _=k();if(_){c(_.initial);const $=new Set(_.allRoles);$.delete(a),h($)}f(a)},[k,a]);return{nodes:o,selectedRoleId:d,selectNode:f,checkedRoles:m,toggleCheck:E,setCheckedRoles:h,progress:I,allDone:V,connectStream:C,injectStaticNodes:N,reset:X}}const Qg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},Da=130,ea=44,Zg=80;function r6(e,n){if(!e.get(n))return{layout:[],width:300,height:200};const i=[],o=[],c=[{id:n,depth:0,parentId:null}],d=new Set;for(;c.length>0;){const{id:x,depth:g,parentId:w}=c.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*Zg+20,parentId:w});const b=e.get(x);if(b)for(const j of b.children)e.has(j)&&!d.has(j)&&c.push({id:j,depth:g+1,parentId:x})}const f=Math.max(...o.map(x=>x.length))*(Da+16),m=Math.max(f,280);for(const x of o){const g=x.length*(Da+16)-16,w=(m-g)/2;x.forEach((b,j)=>{const k=i.find(E=>E.roleId===b);k&&(k.x=w+j*(Da+16))})}const h=o.length*Zg+40;return{layout:i,width:m,height:h}}function gv({nodes:e,rootId:n,selectedRoleId:a,onSelectNode:i,checkedRoles:o,onToggleCheck:c,eligibleRoles:d}){const{layout:f,width:m,height:h}=r6(e,n),x=!!c,g=b=>{const j=f.find(k=>k.roleId===b);return j?{cx:j.x+Da/2,cy:j.y+ea/2}:{cx:0,cy:0}},w=b=>{switch(b.status){case"streaming":return Qg[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),E=e.get(b.roleId),N=e.get(b.parentId);let C="rgba(180,200,240,0.15)",z="4 4",T="";return(E==null?void 0:E.status)==="done"||(N==null?void 0:N.status)==="done"?(C="#2E7D3266",z=""):(E==null?void 0:E.status)==="awaiting_input"?(C="#F59E0B",z="6 4",T="wave-edge-flow"):(E==null?void 0:E.status)==="streaming"&&(C=Qg[b.roleId]??"#FBBF24",z="6 4",T="wave-edge-flow"),l.jsx("line",{x1:j.cx,y1:j.cy+ea/2-4,x2:k.cx,y2:k.cy-ea/2+4,stroke:C,strokeWidth:1.5,strokeDasharray:z,className:T},`${b.parentId}-${b.roleId}`)}),f.map(b=>{const j=e.get(b.roleId);if(!j)return null;const k=w(j),E=a===b.roleId,N=b.roleId===n,C=(o==null?void 0:o.has(b.roleId))??!1,z=N?E?.7:.5:j.status==="not-dispatched"&&!C?.35:1;return l.jsxs("g",{transform:`translate(${b.x}, ${b.y})`,style:{cursor:"pointer",opacity:z},onClick:()=>i(b.roleId),children:[l.jsx("rect",{x:0,y:0,width:Da,height:ea,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:E?"#fff":C?"#EF5350":k,strokeWidth:E||C?2:1.5,strokeDasharray:j.status==="not-dispatched"&&!C?"4 3":""}),l.jsx("circle",{cx:14,cy:ea/2,r:4,fill:k,filter:ol(j.status)?"url(#glow)":void 0,children:ol(j.status)&&l.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),l.jsx("text",{x:26,y:ea/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:ea/2+10,fill:"var(--terminal-text-muted, #888)",fontSize:8,fontFamily:"var(--pixel-font)",children:j.status==="streaming"?"Working...":j.status==="awaiting_input"?"Awaiting Reply":j.status==="done"?j.children.some(T=>{const H=e.get(T);return H&&ol(H.status)})?"Supervising...":"Complete":j.status==="error"?"Error":j.status==="waiting"?"Waiting":""}),j.status==="done"&&!x&&l.jsx("text",{x:Da-18,y:ea/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),j.status==="error"&&!x&&l.jsx("text",{x:Da-18,y:ea/2+4,fontSize:14,fill:"#C62828",children:"✗"}),x&&!N&&(()=>{const T=!d||d.has(b.roleId);return l.jsxs("g",{onClick:H=>{H.stopPropagation(),T&&(c==null||c(b.roleId))},style:{cursor:T?"pointer":"default",opacity:T?1:.2},children:[l.jsx("rect",{x:Da-24,y:ea/2-10,width:20,height:20,fill:"transparent"}),l.jsx("rect",{x:Da-20,y:ea/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:Da-18,y:ea/2+4,fontSize:10,fontWeight:700,fill:"#fff",children:"✓"})]})})()]},b.roleId)})]})}const a6={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function l6({directive:e,rootDispatches:n,orgNodes:a,rootRoleId:i,waveId:o,onClose:c,onMinimize:d,onDone:f,onOpenKnowledgeDoc:m,onSave:h}){const{nodes:x,selectedRoleId:g,selectNode:w,progress:b,allDone:j,connectStream:k}=xv(n,a,i,o),[E,N]=v.useState(0),[C,z]=v.useState(new Set),[T,H]=v.useState(""),[F,I]=v.useState(!1),[V,X]=v.useState(!1),_=v.useRef(null),$=v.useRef(Date.now()),L=v.useRef(!1),W=v.useCallback(async()=>{if(h){X(!0);try{const Y=n.map(R=>R.sessionId).filter(Boolean);await h(Y)}catch(Y){console.error("Save failed:",Y)}finally{X(!1),c()}}},[h,n,c]),ne=v.useCallback(async()=>{if(!g||!T.trim())return;const Y=x.get(g);if(!(!(Y!=null&&Y.sessionId)||Y.status!=="awaiting_input"&&Y.status!=="done")){I(!0);try{await ye.replyToSession(Y.sessionId,T.trim()),H(""),k(Y.sessionId,g)}catch(R){console.error("Reply failed:",R)}finally{I(!1)}}},[g,T,x,k]),K=v.useCallback(async Y=>{const R=x.get(Y);if(R!=null&&R.sessionId)try{await ye.abortSession(R.sessionId)}catch{}},[x]),q=v.useCallback(async()=>{for(const[,Y]of x)if(ol(Y.status))try{Y.sessionId&&await ye.abortSession(Y.sessionId)}catch{}},[x]);v.useEffect(()=>{const Y=setInterval(()=>{N(Math.floor((Date.now()-$.current)/1e3))},1e3);return()=>clearInterval(Y)},[]);const ie=v.useRef(!1);v.useEffect(()=>{const Y=_.current;if(!Y)return;const R=()=>{const O=Y.scrollHeight-Y.scrollTop-Y.clientHeight<60;ie.current=!O};return Y.addEventListener("scroll",R),()=>Y.removeEventListener("scroll",R)},[]),v.useEffect(()=>{ie.current=!1,_.current&&(_.current.scrollTop=_.current.scrollHeight)},[g]),v.useEffect(()=>{_.current&&!ie.current&&(_.current.scrollTop=_.current.scrollHeight)},[x]),v.useEffect(()=>{j&&!L.current&&(L.current=!0,f==null||f()),!j&&L.current&&(L.current=!1)},[j,f]);const de=Y=>`${Math.floor(Y/60)}:${String(Y%60).padStart(2,"0")}`,me=g?x.get(g):null,D=g?a6[g]??"#888":"#888",U=Y=>{z(R=>{const O=new Set(R);return O.has(Y)?O.delete(Y):O.add(Y),O})};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:de(E)}),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:c,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:"streaming",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(Y=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:Y.color,animation:Y.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:Y.label})]},Y.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"35vh"},children:l.jsx(gv,{nodes:x,rootId:i,selectedRoleId:g,onSelectNode:w})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[me&&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:D}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:me.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:me.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:me.status==="awaiting_input"?"#F59E0B22":`${D}22`,color:me.status==="awaiting_input"?"#F59E0B":D},children:me.status==="streaming"?"Working":me.status==="done"?"Complete":me.status==="error"?"Error":me.status==="waiting"?"Waiting":me.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),ol(me.status)&&me.sessionId&&l.jsx("button",{onClick:()=>K(me.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Force stop this execution",children:"Stop"})]}),l.jsxs("div",{ref:_,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[me&&me.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:me.status==="waiting"?"Waiting for dispatch...":me.status==="streaming"?"Connecting to activity stream...":me.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),me==null?void 0:me.events.map(Y=>l.jsx(Jm,{event:Y,isThinkingCollapsed:C.has(Y.seq),onToggleThinking:()=>U(Y.seq),onNavigateToSession:R=>{const O=me==null?void 0:me.events.find(te=>te.type==="dispatch:start"&&te.data.childSessionId===R),ae=O==null?void 0:O.data.targetRoleId;ae&&x.has(ae)&&w(ae)},onOpenKnowledgeDoc:m},Y.seq)),(me==null?void 0:me.status)==="streaming"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(me==null?void 0:me.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:[me.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:T,onChange:Y=>H(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),ne())},placeholder:"Type your response...",disabled:F,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:ne,disabled:F||!T.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:F?"...":"Reply"})]})]}),(me==null?void 0:me.status)==="done"&&me.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 ",me.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:T,onChange:Y=>H(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),ne())},placeholder:"e.g., 좋아 KB-3 진행해, Engineer에게 시켜...",disabled:F,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:ne,disabled:F||!T.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:F?"...":"Send"})]})]}),!me&&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:me&&me.events.length>0&&`${me.events.length} events`}),j&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:c,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:W,disabled:V,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:V?"Saving...":"Save Wave"})]})]})]})]})]})]})}const i6={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function Jg({orgNodes:e,rootRoleId:n,cLevelRoles:a,pastWaves:i,activeWaves:o,onDispatch:c,onClose:d,onDone:f,onSave:m,onOpenKnowledgeDoc:h,onRefreshWaves:x,terminalWidth:g=0,onMaximize:w,inline:b=!1,onOpenSaveModal:j}){const[k,E]=v.useState(""),[N,C]=v.useState(null),[z,T]=v.useState(!1),[H,F]=v.useState(o.length>0?0:-1),[,I]=v.useState(!1),V=v.useRef(null),X=H>=0?o[H]??null:null,_=v.useMemo(()=>[],[]),$=(X==null?void 0:X.rootDispatches)??_,L=xv($,e,n,(X==null?void 0:X.id)??null);v.useEffect(()=>{if(N){const le=s6(e,n,N.roles);L.injectStaticNodes(le);for(const Be of N.roles??[])if(Ry(Be.status)&&Be.sessionId){const Pe=le.get(Be.roleId);Pe!=null&&Pe.sessionId&&setTimeout(()=>L.connectStream(Pe.sessionId,Be.roleId),100)}}},[N,e,n]),v.useEffect(()=>{!L.selectedRoleId&&n&&L.selectNode(n)},[n]);const W=v.useRef(o.length);v.useEffect(()=>{const le=o.length>W.current;W.current=o.length,le&&(F(0),C(null),I(!1))},[o.length]);const[ne,K]=v.useState(null),q=v.useMemo(()=>{if(!ne)return null;const le=ne.modified.length+ne.untracked.length;return{branch:ne.branch,dirty:le>0,count:le}},[ne]),ie=v.useCallback(()=>{ye.getSaveStatus("code").then(le=>{K({dirty:le.modified.length+le.untracked.length>0,modified:le.modified,untracked:le.untracked,lastCommit:le.lastCommit,branch:le.branch})}).catch(()=>{})},[]);v.useEffect(()=>{ie()},[ie]);const[de,me]=v.useState(0);v.useEffect(()=>{if(!X)return;const le=setInterval(()=>{me(Math.floor((Date.now()-X.startedAt)/1e3))},1e3);return()=>clearInterval(le)},[X]);const[D,U]=v.useState(""),[Y,R]=v.useState(!1),[O,ae]=v.useState([]),[te,Se]=v.useState(!1),[je,_e]=v.useState(null),Oe=v.useRef(null);v.useEffect(()=>{if(je){const le=setTimeout(()=>_e(null),3e3);return()=>clearTimeout(le)}},[je]);const Xe=v.useCallback(async le=>["image/png","image/jpeg","image/gif","image/webp"].includes(le.type)?le.size>5*1024*1024?(_e(`Too large: ${(le.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(Pe=>{const Ze=new FileReader;Ze.onload=()=>{const vn=Ze.result.split(",")[1];Pe({type:"image",data:vn,name:le.name,mediaType:le.type})},Ze.onerror=()=>{_e("Failed to read file"),Pe(null)},Ze.readAsDataURL(le)}):(_e(`Unsupported: ${le.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),rt=v.useCallback(async le=>{const Be=[];for(const Pe of Array.from(le)){const Ze=await Xe(Pe);Ze&&Be.push(Ze)}Be.length>0&&ae(Pe=>[...Pe,...Be])},[Xe]),De=v.useCallback(le=>{le.preventDefault(),le.stopPropagation(),Se(!0)},[]),We=v.useCallback(le=>{le.preventDefault(),le.stopPropagation(),Se(!1)},[]),Ot=v.useCallback(le=>{le.preventDefault(),le.stopPropagation(),Se(!1),le.dataTransfer.files.length>0&&rt(le.dataTransfer.files)},[rt]),yt=v.useCallback(le=>{const Be=[];for(let Pe=0;Pe<le.clipboardData.items.length;Pe++){const Ze=le.clipboardData.items[Pe];if(Ze.type.startsWith("image/")){const vn=Ze.getAsFile();vn&&Be.push(vn)}}Be.length>0&&(le.preventDefault(),rt(Be))},[rt]),[bt,jt]=v.useState(320),qe=v.useRef(!1),at=v.useRef(0),pt=v.useRef(0),zt=v.useCallback(le=>{le.preventDefault(),qe.current=!0,at.current=le.clientX,pt.current=bt;const Be=Ze=>{if(!qe.current)return;const vn=at.current-Ze.clientX;jt(Math.max(200,Math.min(500,pt.current+vn)))},Pe=()=>{qe.current=!1,window.removeEventListener("mousemove",Be),window.removeEventListener("mouseup",Pe)};window.addEventListener("mousemove",Be),window.addEventListener("mouseup",Pe)},[bt]),[fe,be]=v.useState(new Set),ve=v.useRef(null),Q=v.useRef(!1);v.useEffect(()=>{const le=ve.current;if(!le)return;const Be=()=>{const Pe=le.scrollHeight-le.scrollTop-le.clientHeight<60;Q.current=!Pe};return le.addEventListener("scroll",Be),()=>le.removeEventListener("scroll",Be)},[]),v.useEffect(()=>{!Q.current&&ve.current&&(ve.current.scrollTop=ve.current.scrollHeight)},[L.nodes,L.selectedRoleId]);const Z=L.selectedRoleId?L.nodes.get(L.selectedRoleId)??null:null,Ee=Z?i6[Z.roleId]??"#888":"#888",xe=L.progress.running>0||L.progress.awaitingInput>0,Ae=L.selectedRoleId===n,ze=!!N&&!X,$e=(X==null?void 0:X.directive)??(N==null?void 0:N.directive)??"",Le=v.useCallback(le=>{const Be=new Set,Pe=[le];for(;Pe.length>0;){const Ze=Pe.shift();if(Be.has(Ze))continue;Be.add(Ze);const vn=e[Ze];vn&&Pe.push(...vn.children)}return Be},[e]),Ye=v.useMemo(()=>{if(!L.selectedRoleId)return new Set;const le=Le(L.selectedRoleId);return le.delete(n),le},[L.selectedRoleId,Le,n]),st=v.useRef(null);v.useEffect(()=>{if(L.selectedRoleId===st.current||(st.current=L.selectedRoleId,!L.selectedRoleId))return;const le=Le(L.selectedRoleId);le.delete(n),L.setCheckedRoles(le)},[L.selectedRoleId,Le,n]);const Ke=L.checkedRoles.size,Re=()=>{if(!k.trim()&&O.length===0||Ke===0)return;const Be=Array.from(L.nodes.keys()).filter(Ze=>Ze!==n).every(Ze=>L.checkedRoles.has(Ze)),Pe=O.length>0?O:void 0;c(k.trim(),Be?void 0:Array.from(L.checkedRoles),Pe),E(""),ae([])},Ie=le=>{le.key==="Enter"&&(le.metaKey||le.ctrlKey)&&(le.preventDefault(),Re()),le.key==="Escape"&&d()},Lt=v.useCallback(async()=>{if(!L.selectedRoleId||!D.trim()&&O.length===0)return;const le=L.nodes.get(L.selectedRoleId);if(!le)return;const Be=O.length>0?O:void 0;R(!0);try{if(le.status==="awaiting_input"&&le.sessionId){const Pe=await ye.replyToSession(le.sessionId,D.trim(),Be);U(""),ae([]),!!(X!=null&&X.id)||L.connectStream(Pe.sessionId||le.sessionId,L.selectedRoleId)}else{const Pe=(X==null?void 0:X.id)??(N==null?void 0:N.waveId)??(N==null?void 0:N.id),Ze=await ye.execute({type:"assign",roleId:L.selectedRoleId,task:D.trim(),...Pe&&{waveId:Pe},...Be&&{attachments:Be}});U(""),ae([]),Ze.sessionId&&(X!=null&&X.id||L.connectStream(Ze.sessionId,L.selectedRoleId))}}catch(Pe){console.error("Reply failed:",Pe)}finally{R(!1)}},[L,D,O,X,N]),Vt=v.useCallback(async le=>{const Be=L.nodes.get(le);if(Be!=null&&Be.sessionId)try{await ye.abortSession(Be.sessionId)}catch{}},[L.nodes]),Et=v.useCallback(async()=>{for(const[,le]of L.nodes)if(ol(le.status))try{le.sessionId&&await ye.abortSession(le.sessionId)}catch{}},[L.nodes]),Gt=v.useCallback(async le=>{T(!0),C(null),F(-1);try{const Be=await ye.getWaveDetail(le);Be.replay&&C(Be.replay)}catch(Be){console.error("Failed to load wave:",Be)}finally{T(!1)}},[]),dn=v.useRef(!1),En=v.useRef(null);v.useEffect(()=>{if(!(N||z)&&((X==null?void 0:X.id)!==En.current&&(dn.current=!1,En.current=(X==null?void 0:X.id)??null),L.allDone&&!dn.current&&X&&(dn.current=!0,ie(),f==null||f(),m))){const le=X.rootDispatches.map(Be=>Be.sessionId).filter(Boolean);m(X.directive,le,{waveId:X.id,sessionIds:X.sessionIds}).catch(()=>{})}},[L.allDone,X,f,m,ie,N,z]);const ee=v.useCallback(async()=>{if(!m||!X)return;const le=X.rootDispatches.map(Be=>Be.sessionId).filter(Boolean);await m(X.directive,le,{waveId:X.id,sessionIds:X.sessionIds})},[m,X]),He=le=>{be(Be=>{const Pe=new Set(Be);return Pe.has(le)?Pe.delete(le):Pe.add(le),Pe})},lt=le=>{const Be=Math.floor(le/60),Pe=le%60;return`${Be}:${Pe.toString().padStart(2,"0")}`},{panelRight:Kt,panelWidth:ke,isResizing:St,handleResizeStart:jn}=Zo(g,700,w),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"}),xe&&l.jsxs("span",{className:"text-white/60 text-xs",children:[L.progress.running+L.progress.awaitingInput," active",L.progress.awaitingInput>0&&` (${L.progress.awaitingInput} awaiting)`]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[w&&l.jsx("button",{onClick:w,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:X?`${o.length} active wave${o.length!==1?"s":""}`:ze?"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:[(X||ze)&&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:xe?"#FBBF24":L.allDone||ze?"#2E7D32":"#B71C1C",animation:xe?"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:["“",$e,"”"]}),X&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:lt(de)}),ze&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:xe?"#FBBF2422":"#2E7D3222",color:xe?"#FBBF24":"#2E7D32"},children:xe?"LIVE":"REPLAY"}),ze&&(N==null?void 0:N.startedAt)&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:new Date(N.startedAt).toLocaleString()}),L.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:[L.progress.awaitingInput," awaiting"]}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:L.allDone||ze&&!xe?"#2E7D3222":"#B71C1C22",color:L.allDone||ze&&!xe?"#2E7D32":"#B71C1C"},children:[L.progress.done,"/",L.progress.total]}),xe&&l.jsx("button",{onClick:Et,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:X||ze?"Org Propagation":"Select Target Roles"}),l.jsxs("span",{className:"ml-auto text-[10px] text-[var(--terminal-text-muted)]",children:[L.checkedRoles.size,"/",L.progress.total," selected"]}),(X||ze)&&l.jsx("div",{className:"flex gap-x-3",children:[{label:"streaming",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(le=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:le.color,animation:le.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:le.label})]},le.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(gv,{nodes:L.nodes,rootId:n,selectedRoleId:L.selectedRoleId,onSelectNode:L.selectNode,checkedRoles:L.checkedRoles,onToggleCheck:L.toggleCheck,eligibleRoles:Ye})})]}),z?l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"Loading wave data..."}):Ae?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:[Ke," target role",Ke!==1?"s":""," selected"]})]}),l.jsxs("div",{ref:ve,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-2 text-xs font-mono select-text",children:[$e&&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:$e}),X&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",children:["dispatched ",lt(de)," ago to ",X.rootDispatches.length," role",X.rootDispatches.length!==1?"s":""]})]})]}),!$e&&!X&&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:[O.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:O.map((le,Be)=>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:${le.mediaType};base64,${le.data}`,alt:le.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>ae(Pe=>Pe.filter((Ze,vn)=>vn!==Be)),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:le.name})]},Be))}),je&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:je}),l.jsxs("div",{className:"flex gap-2 items-end",children:[l.jsx("button",{onClick:()=>{var le;return(le=Oe.current)==null?void 0:le.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:V,value:k,onChange:le=>E(le.target.value),onKeyDown:Ie,onPaste:yt,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:Re,disabled:!k.trim()&&O.length===0||Ke===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()&&Ke>0?"#B71C1C":"#333",color:"#fff",minWidth:140},children:["Dispatch to ",Ke," Role",Ke!==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:Ee}}),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==="streaming"?"#FBBF2422":`${Ee}22`,color:Z.status==="awaiting_input"?"#F59E0B":Z.status==="streaming"?"#FBBF24":Ee},children:Z.status==="streaming"?"Working...":Z.status==="done"?Z.children.some(le=>{const Be=L.nodes.get(le);return Be&&ol(Be.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"]}),ol(Z.status)&&Z.sessionId&&l.jsx("button",{onClick:()=>Vt(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:Oe,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:le=>{var Be;(Be=le.target.files)!=null&&Be.length&&rt(le.target.files),le.target.value=""},className:"hidden"}),l.jsxs("div",{ref:ve,className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text transition-colors ${te?"bg-amber-500/5 ring-1 ring-inset ring-amber-500/30":""}`,onDragOver:De,onDragLeave:We,onDrop:Ot,children:[Z&&$e&&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:$e})]}),Z&&Z.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:Z.status==="waiting"?"Waiting for dispatch...":Z.status==="streaming"?"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((le,Be)=>{const Pe=Z.events,Ze=le.type==="msg:start"&&Be>0,vn=Pe[Be+1];if((le.type==="msg:done"||le.type==="msg:error"||le.type==="msg:awaiting_input")&&(vn==null?void 0:vn.type)==="msg:start")return null;if(Ze){const gn=le.data.task??"",mn=gn.match(/\[CEO Follow-up\]\n([\s\S]+)$/),Ur=mn?mn[1].trim():gn;return l.jsx(v.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:Ur})]})},`followup-${le.seq}`)}return l.jsx(Jm,{event:le,isThinkingCollapsed:fe.has(le.seq),onToggleThinking:()=>He(le.seq),onNavigateToSession:gn=>{for(const[,mn]of L.nodes)if(mn.events.some(Ur=>Ur.data.childSessionId===gn)){L.selectNode(mn.roleId);return}},onOpenKnowledgeDoc:h},le.seq)}),(Z==null?void 0:Z.status)==="streaming"&&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")&&(O.length>0||je||te)&&l.jsxs("div",{className:"px-4 pt-2 border-t shrink-0",style:{borderColor:"var(--terminal-border)"},children:[je&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:je}),te&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-1",children:"Drop image here"}),O.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-1",children:O.map((le,Be)=>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:${le.mediaType};base64,${le.data}`,alt:le.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>ae(Pe=>Pe.filter((Ze,vn)=>vn!==Be)),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:le.name})]},Be))})]}),(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 le;return(le=Oe.current)==null?void 0:le.click()},disabled:Y,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:D,onChange:le=>U(le.target.value),onKeyDown:le=>{le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),Lt())},onPaste:yt,placeholder:"Type your response...",disabled:Y,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:Lt,disabled:Y||!D.trim()&&O.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:Y?"...":"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 le;return(le=Oe.current)==null?void 0:le.click()},disabled:Y,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:D,onChange:le=>U(le.target.value),onKeyDown:le=>{le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),Lt())},onPaste:yt,placeholder:"Send a follow-up directive...",disabled:Y,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:Lt,disabled:Y||!D.trim()&&O.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:Y?"...":"Send"})]})]}),L.allDone&&X&&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:ee,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:bt,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:zt}),l.jsx("div",{className:"p-3 pb-0",children:l.jsx("button",{onClick:()=>{C(null),F(-1),I(!0),L.reset()},className:"w-full px-3 py-1.5 text-[11px] font-bold rounded-lg cursor-pointer transition-colors",style:{background:!N&&H<0?"#B71C1C":"var(--terminal-inline-bg)",color:!N&&H<0?"#fff":"var(--terminal-text-secondary)",border:"1px solid",borderColor:!N&&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((le,Be)=>l.jsxs("button",{onClick:()=>{F(Be),C(null),I(!1),L.reset()},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:H===Be&&!N?"var(--terminal-bg)":"transparent",border:H===Be&&!N?"1px solid var(--accent)":"1px solid transparent"},children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 shrink-0 animate-pulse"}),l.jsxs("span",{className:"text-[11px] text-[var(--terminal-text)] truncate font-medium",children:[le.directive.slice(0,40),le.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[le.rootDispatches.length," role",le.rootDispatches.length!==1?"s":""]})]},le.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(le=>l.jsx(o6,{wave:le,active:(N==null?void 0:N.id)===le.id,onLoad:()=>Gt(le.id)},le.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:ke,background:"var(--terminal-bg)",borderLeft:"1px solid var(--terminal-border)",transition:St?"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 s6(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))},c=e[n];c&&(i.set(n,{sessionId:"",roleId:n,roleName:"CEO",children:c.children,status:"not-dispatched",events:[],streamStatus:"idle"}),c.children.forEach(o));for(const d of a){const f=i.get(d.roleId);if(f){const h=Ry(d.status);i.set(d.roleId,{...f,sessionId:d.sessionId??"",status:d.status||"done",events:d.events,streamStatus:h?"connecting":"done"})}const m=d.childSessions??[];for(const h of m){const x=i.get(h.roleId);x&&i.set(h.roleId,{...x,sessionId:h.sessionId??"",status:h.status||"done",events:h.events,streamStatus:"done"})}}return i}function o6({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 c6={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 ep(e){return c6[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const yv=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],bv=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],vv=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],wv=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],kv=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],ul={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 u6({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 zo({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(u6,{color:o,selected:o===a,onClick:()=>i(o)},o))})]})}function Rh({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(c=>{const d=o?o.getLockLevel(c.id):1,f=o!=null&&o.getCost?o.getCost(c.id):0,m=c.id===a,h=o?d>o.roleLevel&&!m:!1,x=f>0&&(o==null?void 0:o.purchased)&&!o.purchased.has(c.id)&&!m,g=(o==null?void 0:o.coinBalance)!==void 0?o.coinBalance>=f:!0,w=h||!1,b=o?m&&d>o.roleLevel:!1;return l.jsxs("button",{onClick:()=>{if(!w){if(x&&!h){g&&(o!=null&&o.onPurchase)&&o.onPurchase(c.id,f);return}i(c.id===a?void 0:c.id)}},className:"customize-swatch",style:{width:"auto",height:"auto",padding:w||x?"2px 6px 12px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:m?"rgba(255,255,255,0.15)":w?"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&&!w?"2px solid rgba(255,200,0,0.3)":"2px solid transparent",color:w?"rgba(255,255,255,0.25)":x?"rgba(255,255,255,0.45)":m?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:w?"not-allowed":x?g?"pointer":"not-allowed":"pointer",opacity:w?.35:1,position:"relative"},children:[c.name,w&&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]}),!w&&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]})]},c.id)})})]})}function Mh({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 Ll(e){return e[Math.floor(Math.random()*e.length)]}function gs(e){var o,c,d;const n=Hb().filter(f=>!e||qb(f.id,e)),a=Yb().filter(f=>!e||Wb(f.id,e)),i=Gb().filter(f=>!e||Kb(f.id,e));return{skinColor:Ll(yv),hairColor:Ll(bv),shirtColor:Ll(vv),pantsColor:Ll(wv),shoeColor:Ll(kv),hairStyle:(o=Ll(n))==null?void 0:o.id,outfitStyle:(c=Ll(a))==null?void 0:c.id,accessory:(d=Ll(i))==null?void 0:d.id}}function jv({roleId:e,appearance:n,onChange:a,onRandomize:i,onReset:o,label:c,roleLevel:d,coinBalance:f,purchased:m,onPurchase:h}){const[x,g]=v.useState("look"),w=v.useCallback((F,I)=>{a({...n,[F]:I})},[n,a]),b=v.useRef(null),j=v.useCallback(F=>{var X;const I=(X=F.target.files)==null?void 0:X[0];if(!I)return;const V=new Image;V.onload=()=>{const _=NC(V);a({..._,hairStyle:n.hairStyle,outfitStyle:n.outfitStyle,accessory:n.accessory}),URL.revokeObjectURL(V.src)},V.src=URL.createObjectURL(I),F.target.value=""},[n.hairStyle,n.outfitStyle,n.accessory,a]),k=Hb(),E=Yb(),N=Gb(),C=d!==void 0?k.filter(F=>qb(F.id,d)).length:k.length,z=d!==void 0?E.filter(F=>Wb(F.id,d)).length:E.length,T=d!==void 0?N.filter(F=>Kb(F.id,d)).length:N.length,H=(F,I)=>d!==void 0?{roleLevel:d,getLockLevel:F,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(Wl,{roleId:e,appearance:n,scale:12})}),c&&l.jsx("div",{className:"customize-preview-name",children:c}),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 F;return(F=b.current)==null?void 0:F.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(Mh,{label:"LOOK",active:x==="look",onClick:()=>g("look")}),l.jsx(Mh,{label:"OUTFIT",active:x==="outfit",onClick:()=>g("outfit")}),l.jsx(Mh,{label:"ACCESSORY",active:x==="accessory",onClick:()=>g("accessory")})]}),x==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(zo,{label:"SKIN",presets:yv,value:n.skinColor,onChange:F=>w("skinColor",F)}),l.jsx(zo,{label:"HAIR COLOR",presets:bv,value:n.hairColor,onChange:F=>w("hairColor",F)}),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(Rh,{label:"HAIR STYLE",items:k,value:n.hairStyle,onChange:F=>w("hairStyle",F),lockInfo:H(Ub,hC)})]}),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:[z,"/",E.length," unlocked"]})]}),l.jsx(Rh,{label:"STYLE",items:E,value:n.outfitStyle,onChange:F=>w("outfitStyle",F),lockInfo:H(Xb,gC)}),l.jsx(zo,{label:"TOP",presets:vv,value:n.shirtColor,onChange:F=>w("shirtColor",F)}),l.jsx(zo,{label:"PANTS",presets:wv,value:n.pantsColor,onChange:F=>w("pantsColor",F)}),l.jsx(zo,{label:"SHOES",presets:kv,value:n.shoeColor,onChange:F=>w("shoeColor",F)})]}),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:[T,"/",N.length," unlocked"]})]}),l.jsx(Rh,{label:"ACCESSORY",items:N,value:n.accessory,onChange:F=>w("accessory",F),lockInfo:H(Vb,kC)}),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 d6=[{value:"c-level",label:"C-Level"},{value:"member",label:"Member"}];function vm(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function zh(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 f6={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 Ul=null;async function h6(){if(Ul)return Ul;try{const a=await ye.getPreferences();if(a.instanceId)return Ul=a.instanceId,localStorage.setItem("tycono_instance_id",Ul),Ul}catch{}const e="tycono_instance_id";let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),Ul=n,n}const _o=4;function m6(e,n,a){const i=e.trim();if(!i||i.startsWith("#"))return null;const o=i.split(",").map(g=>g.trim()),c=o[0];if(!c)return null;const d=vm(c),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:c,id:d,level:m,reportsTo:h,error:x}}function p6({existingRoles:e,onClose:n,onHire:a,onStoreVisit:i,questHint:o}){const[c,d]=v.useState("single"),[f,m]=v.useState([]),[h,x]=v.useState(!1),[g,w]=v.useState("popular"),[b,j]=v.useState(""),[k,E]=v.useState(null),[N,C]=v.useState(!1),[z,T]=v.useState(""),[H,F]=v.useState("browse"),[I,V]=v.useState(""),[X,_]=v.useState(""),[$,L]=v.useState("ceo"),[W,ne]=v.useState(null),[K,q]=v.useState(1),[ie,de]=v.useState(""),[me,D]=v.useState(""),[U,Y]=v.useState(!1),[R,O]=v.useState("member"),[ae,te]=v.useState(()=>{const ee=e.find(He=>He.level==="c-level");return(ee==null?void 0:ee.id)??"ceo"}),[Se,je]=v.useState(""),[_e,Oe]=v.useState(gs),[Xe,rt]=v.useState(!1),[De,We]=v.useState(""),[Ot,yt]=v.useState([]),[bt,jt]=v.useState(new Set),[qe,at]=v.useState(""),[pt,zt]=v.useState("input"),[fe,be]=v.useState({done:0,total:0}),ve=v.useRef(null),Q=v.useRef(null),Z=v.useRef(null);v.useEffect(()=>{ye.getSkills().then(ee=>yt(ee.filter(He=>He.installed))).catch(()=>{}),h6().then(ee=>ne(ee)).catch(()=>{})},[]),v.useEffect(()=>{var ee,He,lt;c==="single"?(K===1&&((ee=ve.current)==null||ee.focus()),K===2&&((He=Q.current)==null||He.focus())):c==="bulk"&&pt==="input"&&((lt=Z.current)==null||lt.focus())},[K,c,pt]),v.useEffect(()=>{c==="store"&&H==="browse"&&f.length===0&&Ee()},[c,H]);const Ee=async()=>{x(!0);try{const ee=await kr.getCharacters({sort:g,instanceId:W??void 0});m(ee.characters)}catch{T("Failed to load job board")}x(!1)};v.useEffect(()=>{c==="store"&&H==="browse"&&Ee()},[g,W]);const xe=v.useMemo(()=>{if(!b.trim())return f;const ee=b.toLowerCase();return f.filter(He=>He.name.toLowerCase().includes(ee)||He.id.toLowerCase().includes(ee)||(He.tagline??"").toLowerCase().includes(ee))},[f,b]),Ae=v.useMemo(()=>new Set(e.map(ee=>ee.id)),[e]),ze=v.useMemo(()=>{const ee=qe.split(`
|
|
90
|
+
`),He=new Set;return ee.map(lt=>m6(lt,Ae,He)).filter(lt=>lt!==null)},[qe,Ae]),$e=ze.length>0&&ze.every(ee=>!ee.error),Le=ee=>{de(ee),U||D(vm(ee))},Ye=ie.trim().length>0&&me.trim().length>0&&!e.some(ee=>ee.id===me),st=Se.trim().length>0,Ke=async()=>{rt(!0),We("");const ee=zh(R);try{await a({id:me,name:ie.trim(),level:R,reportsTo:ae,persona:Se.trim(),...ee,skills:bt.size>0?[...bt]:void 0},_e),n()}catch(He){We(He instanceof Error?He.message:"Failed to create role"),rt(!1)}},Re=ee=>ee===1?Ye:ee===2?st:!0,Ie=async()=>{rt(!0),We(""),be({done:0,total:ze.length});try{for(let ee=0;ee<ze.length;ee++){const He=ze[ee],lt=zh(He.level),Kt=gs(),ke=`${He.name}. A ${He.level} role reporting to ${He.reportsTo}.`;await a({id:He.id,name:He.name,level:He.level,reportsTo:He.reportsTo,persona:ke,...lt},Kt),be({done:ee+1,total:ze.length})}n()}catch(ee){We(ee instanceof Error?ee.message:"Failed to create roles"),rt(!1)}},Lt=async ee=>{C(!0),T("");try{const He=await kr.getCharacter(ee);E(He),V(He.name||""),_(vm(He.name||ee)),F("review")}catch{T("Failed to load character details")}finally{C(!1)}},Vt=async(ee,He)=>{if(!W)return;const lt=f.find(ke=>ke.id===ee);if(!lt)return;const Kt=lt.my_vote===He?0:He;try{const ke=await kr.voteCharacter(ee,W,Kt);m(St=>St.map(jn=>jn.id===ee?{...jn,upvotes:ke.upvotes,downvotes:ke.downvotes,vote_score:ke.upvotes-ke.downvotes,my_vote:Kt===0?null:Kt}:jn))}catch{}},Et=async()=>{if(!k)return;rt(!0),We("");const ee=k,He=ee.level==="c-level"?"c-level":"member",lt=zh(He),Kt=ee.skills!=null&&typeof ee.skills=="object"&&!Array.isArray(ee.skills)&&"primary"in ee.skills;try{await a({id:X,name:I.trim(),level:He,reportsTo:$,persona:ee.persona||`${I}. Imported from Job Board.`,authority:ee.authority||lt.authority,knowledge:lt.knowledge,reports:lt.reports,source:{id:`tycono/${ee.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:Kt?ee.skills:void 0},ee.appearance?ee.appearance:gs()),kr.trackInstall(ee.id).catch(()=>{}),n()}catch(ke){We(ke instanceof Error?ke.message:"Failed to hire"),rt(!1)}},Gt=async ee=>{if(W)try{await kr.deleteCharacter(ee,W),m(He=>He.filter(lt=>lt.id!==ee))}catch{}},dn=ee=>{ee.key==="Escape"&&n(),ee.key==="Enter"&&(ee.metaKey||ee.ctrlKey)&&(c==="single"?K<_o&&Re(K)?q(K+1):K===_o&&Ke():c==="bulk"?pt==="input"&&$e?zt("review"):pt==="review"&&Ie():c==="store"&&H==="review"&&Et())},En=e.some(ee=>ee.id===me)&&me.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:dn,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"),We("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${c==="single"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Single"}),l.jsx("button",{onClick:()=>{d("bulk"),We("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${c==="bulk"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Bulk"}),l.jsx("button",{onClick:()=>{d("store"),We(""),i==null||i()},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${c==="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&&c==="single"&&K===1&&!ie&&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 ee=f6[o.roleId];ee&&(de(ee.name),D(ee.id),Y(!0),O(ee.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:c==="single"?`Step ${K} of ${_o}`:c==="bulk"?pt==="input"?"Enter roles, one per line":`Review ${ze.length} roles`:H==="browse"?`${f.length} roles available`:"Review & customize"}),c==="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:ee=>ee.stopPropagation(),children:"Open in browser ↗"})]})]}),c==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:_o},(ee,He)=>He+1).map(ee=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:ee<=K?"#2E7D32":"rgba(255,255,255,0.1)"}},ee))}),l.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:c==="store"?l.jsxs(l.Fragment,{children:[H==="browse"&&l.jsxs("div",{className:"space-y-3",children:[W?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:[W.slice(0,8),"..."]})]}),l.jsx("button",{onClick:()=>{Ul=null,localStorage.removeItem("tycono_instance_id"),ne(null)},className:"text-white/30 hover:text-white/60 cursor-pointer",children:"Sign out"})]}):l.jsx(x6,{onLogin:ee=>{Ul=ee,localStorage.setItem("tycono_instance_id",ee),ne(ee)}}),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:ee=>{if(ee.key==="Enter"){const lt=ee.target.value.trim().replace(/^tycono:/,"");lt&&(Lt(lt),ee.target.value="")}}}),l.jsx("button",{onClick:()=>{const ee=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(ee){const lt=ee.value.trim().replace(/^tycono:/,"");lt&&(Lt(lt),ee.value="")}},disabled:N,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:N?"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:ee=>j(ee.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:ee=>w(ee.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..."}):z?l.jsxs("div",{className:"text-center py-8",children:[l.jsx("div",{className:"text-xs text-red-400 mb-2",children:z}),l.jsx("button",{onClick:Ee,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):xe.length===0?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:b?"No matches found":"No characters in store yet"}):l.jsx("div",{className:"space-y-2 max-h-[380px] overflow-y-auto pr-1",children:xe.map(ee=>l.jsx(g6,{char:ee,isHired:Ae.has(ee.id),onSelect:()=>Lt(ee.id),onVote:He=>Vt(ee.id,He),onDelete:()=>Gt(ee.id),fetching:N,token:W},ee.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(Wl,{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:ee=>V(ee.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:X,onChange:ee=>_(ee.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(ee=>ee.id===X)&&X.length>0&&l.jsx("div",{className:"text-xs text-red-500 mt-1",children:"ID already exists"})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Level"}),l.jsx("div",{className:"text-sm text-white/70 p-2 rounded-lg bg-white/5 border border-white/10",children:k.level==="c-level"?"C-Level":"Member"})]}),l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Reports To"}),l.jsxs("select",{value:$,onChange:ee=>L(ee.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(ee=>l.jsxs("option",{value:ee.id,className:"bg-[var(--wall)] text-white",children:[ee.name," (",ee.id,")"]},ee.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,ke;const ee=k.skills;if(ee&&typeof ee=="object"&&!Array.isArray(ee)&&"primary"in ee){const St=[];return(ke=(Kt=ee.primary)==null?void 0:Kt.frontmatter)!=null&&ke.name&&St.push(ee.primary.frontmatter.name),ee.shared&&ee.shared.forEach(jn=>{var hn;return St.push(((hn=jn.frontmatter)==null?void 0:hn.name)||jn.id)}),St.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(ee)?ee:[]).map((St,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 St=="string"?St:St.name},jn))})()})]})]}),De&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:De})]})]}):c==="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:ve,value:ie,onChange:ee=>Le(ee.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:me,onChange:ee=>{D(ee.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),Y(!0)},className:`w-full p-2.5 rounded-lg border bg-white/5 text-sm text-white/90 font-mono focus:outline-none transition-colors ${En?"border-red-400":"border-white/10 focus:border-white/25"}`}),En&&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:d6.map(ee=>l.jsx("button",{onClick:()=>{if(O(ee.value),ee.value==="c-level")te("ceo");else{const He=e.find(lt=>lt.level==="c-level");te((He==null?void 0:He.id)??"ceo")}},className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${R===ee.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:ee.label},ee.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"}),R==="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:ae,onChange:ee=>te(ee.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(ee=>ee.level==="c-level").map(ee=>l.jsxs("option",{value:ee.id,className:"bg-[var(--wall)] text-white",children:[ee.name," (",ee.id,")"]},ee.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:Q,value:Se,onChange:ee=>je(ee.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"})]}),Ot.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:Ot.map(ee=>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:bt.has(ee.id),onChange:()=>jt(He=>{const lt=new Set(He);return lt.has(ee.id)?lt.delete(ee.id):lt.add(ee.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:ee.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:ee.description})]})]},ee.id))})]})]}),K===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx(jv,{roleId:"default",appearance:_e,onChange:Oe,onRandomize:()=>Oe(gs()),onReset:()=>Oe(gs()),label:l.jsxs("span",{children:[me||"new-role"," — ",ie||"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(Wl,{roleId:"default",appearance:_e,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(Bo,{label:"Name",value:ie}),l.jsx(Bo,{label:"ID",value:me,mono:!0}),l.jsx(Bo,{label:"Level",value:R}),l.jsx(Bo,{label:"Reports To",value:ae}),bt.size>0&&l.jsx(Bo,{label:"Skills",value:[...bt].join(", ")})]})]}),l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),l.jsx("div",{className:"text-xs text-white/60 leading-relaxed",children:Se})]})]}),De&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:De})]})]}):l.jsxs(l.Fragment,{children:[pt==="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:qe,onChange:ee=>at(ee.target.value),placeholder:`Name, Level, ReportsTo
|
|
91
|
+
e.g.
|
|
92
|
+
Data Analyst
|
|
93
|
+
DevOps Engineer, member, cto
|
|
94
|
+
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."})]}),ze.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 (",ze.length," role",ze.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:ze.map((ee,He)=>l.jsxs("tr",{className:`border-b border-white/5 ${ee.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:ee.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:ee.id}),l.jsx("td",{className:"p-2 text-white/60",children:ee.level}),l.jsx("td",{className:"p-2 text-white/60",children:ee.reportsTo}),ee.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:ee.error})]},He))})]})})]})]}),pt==="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 — ",ze.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:ze.map((ee,He)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:He+1}),l.jsx("td",{className:"p-2 text-white/80",children:ee.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:ee.id}),l.jsx("td",{className:"p-2 text-white/60",children:ee.level}),l.jsx("td",{className:"p-2 text-white/60",children:ee.reportsTo})]},He))})]})}),Xe&&fe.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:[fe.done,"/",fe.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:`${fe.done/fe.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."}),De&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:De})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[c==="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"}),c==="bulk"&&pt==="review"&&l.jsx("button",{onClick:()=>zt("input"),disabled:Xe,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"}),c==="store"&&H==="review"&&l.jsx("button",{onClick:()=>{F("browse"),E(null),We("")},disabled:Xe,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"}),c==="single"?K<_o?l.jsx("button",{onClick:()=>q(K+1),disabled:!Re(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:Ke,disabled:Xe,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Xe?"Hiring...":"HIRE"}):c==="bulk"?pt==="input"?l.jsxs("button",{onClick:()=>zt("review"),disabled:!$e,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:["Review (",ze.length,")"]}):l.jsx("button",{onClick:Ie,disabled:Xe,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Xe?`Hiring ${fe.done}/${fe.total}...`:`HIRE ALL (${ze.length})`}):H==="review"?l.jsx("button",{onClick:Et,disabled:Xe||!I.trim()||!X.trim()||e.some(ee=>ee.id===X),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:Xe?"Hiring...":"HIRE"}):null]})]})]})]})}function x6({onLogin:e}){const[n,a]=v.useState(""),[i,o]=v.useState(!1),[c,d]=v.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"})]}),c&&l.jsx("div",{className:"text-[10px] text-red-400",children:c}),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 g6({char:e,isHired:n,onSelect:a,onVote:i,onDelete:o,fetching:c,token:d}){const[f,m]=v.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:c,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 Bo({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 y6({roleId:e,roleName:n,onClose:a,onConfirm:i}){const[o,c]=v.useState(!1),d=async()=>{c(!0);try{await i(e)}finally{c(!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 b6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function v6({roleId:e,title:n,roleColor:a,active:i,isWave:o,isWaveStreaming:c,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&&c&&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:b6[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 w6({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(Um,{remarkPlugins:[Wm],components:{code:k6,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:a})})}function k6({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
95
|
+
`)?l.jsx(j6,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"terminal-inline-code",...a,children:n})}function j6({children:e,language:n}){const[a,i]=v.useState(!1),o=String(e).replace(/\n$/,""),c=()=>{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:c,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 S6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function C6({attachments:e}){const[n,a]=v.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 _h(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 N6(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:_h(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=_h(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?_h(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,c,d;const[a,i]=v.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:(c=e.task)==null?void 0:c.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 A6({events:e,isStreaming:n}){const[a,i]=v.useState(!1);if(e.length===0)return null;const o=N6(e);if(o.length===0)return null;const c=e.filter(w=>w.type==="thinking").length,d=e.filter(w=>w.type==="tool"),f=e.filter(w=>w.type==="dispatch"||w.type==="dispatch:progress"),m=e.filter(w=>w.type==="turn").reduce((w,b)=>Math.max(w,b.turn??0),0),h=[];if(c>0&&h.push("thinking"),d.length>0){const w=[...new Set(d.map(b=>b.toolName))];w.length<=3?h.push(w.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((w,b)=>l.jsx(E6,{event:w,isStreaming:n&&b===o.length-1},b))})]})}function D6(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 T6({message:e,roleId:n,roleColor:a}){const i=e.from==="ceo",o=e.type==="system",c=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(C6,{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?D6(e.events):void 0),f=((d==null?void 0:d.length)??0)>0,m=!!e.thinking,h=m&&!e.content&&c&&!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:S6[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(A6,{events:d,isStreaming:c}),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(w6,{content:e.content,streaming:c}):c&&!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"})]}):c&&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,c&&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 Sv({messages:e,roleId:n,roleColor:a}){var o;const i=v.useRef(null);return v.useEffect(()=>{var c;(c=i.current)==null||c.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(c=>l.jsx(T6,{message:c,roleId:n,roleColor:a},c.id)),l.jsx("div",{ref:i})]})}const F6=5*1024*1024,R6=["image/png","image/jpeg","image/gif","image/webp"];function tp({mode:e,onModeChange:n,onSend:a,disabled:i,disabledReason:o,onStop:c}){const[d,f]=v.useState(""),[m,h]=v.useState([]),[x,g]=v.useState(!1),[w,b]=v.useState(null),j=v.useRef(null),k=v.useRef(null),E=v.useRef(!1);v.useEffect(()=>{const $=j.current;$&&($.style.height="0",$.style.height=Math.min($.scrollHeight,120)+"px")},[d]),v.useEffect(()=>{if(w){const $=setTimeout(()=>b(null),3e3);return()=>clearTimeout($)}},[w]);const N=v.useCallback(async $=>R6.includes($.type)?$.size>F6?(b(`File too large: ${($.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(L=>{const W=new FileReader;W.onload=()=>{const K=W.result.split(",")[1];L({type:"image",data:K,name:$.name,mediaType:$.type})},W.onerror=()=>{b("Failed to read file"),L(null)},W.readAsDataURL($)}):(b(`Unsupported format: ${$.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),C=v.useCallback(async $=>{const L=Array.from($),W=[];for(const ne of L){const K=await N(ne);K&&W.push(K)}W.length>0&&h(ne=>[...ne,...W])},[N]),z=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!0)},[]),T=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!1)},[]),H=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!1);const L=$.dataTransfer.files;L.length>0&&C(L)},[C]),F=v.useCallback($=>{const L=$.clipboardData.items,W=[];for(let ne=0;ne<L.length;ne++){const K=L[ne];if(K.type.startsWith("image/")){const q=K.getAsFile();q&&W.push(q)}}W.length>0&&($.preventDefault(),C(W))},[C]),I=v.useCallback($=>{const L=$.target.files;L&&L.length>0&&C(L),$.target.value=""},[C]),V=v.useCallback($=>{h(L=>L.filter((W,ne)=>ne!==$))},[]),X=()=>{const $=d.trim();!$&&m.length===0||i||(a($,m.length>0?m:void 0),f(""),h([]))},_=$=>{if($.key==="Enter"&&!$.shiftKey){if(E.current)return;$.preventDefault(),X()}};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:z,onDragLeave:T,onDrop:H,children:[w&&l.jsx("div",{className:"text-[10px] text-red-400 mb-2 text-center",children:w}),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(($,L)=>l.jsxs("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${$.mediaType};base64,${$.data}`,alt:$.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>V(L),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[8px] text-white truncate px-1 py-0.5",children:$.name})]},L))}),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 $;return($=k.current)==null?void 0:$.click()},disabled:i,className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--terminal-surface-light)] hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Attach image (PNG, JPG, GIF, WebP)",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{ref:k,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:I,className:"hidden"}),l.jsx("textarea",{ref:j,value:d,onChange:$=>f($.target.value),onKeyDown:_,onCompositionStart:()=>{E.current=!0},onCompositionEnd:()=>{E.current=!1},onPaste:F,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&&c&&l.jsx("button",{onClick:c,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:X,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 M6={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},Cv={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function ey(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function z6({msg:e}){const n=M6[e.roleId]??"#888",a=Cv[e.roleId]??e.roleId;if(e.type==="dispatch"){const i=e.text.includes("WAVE"),o=e.text.includes("completed")||e.text.includes("완료"),c=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:ey(e.ts)}),l.jsx("span",{className:"text-[10px] shrink-0 mt-0.5",children:c}),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:ey(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 _6({channel:e,allRoles:n,onUpdateMembers:a,onUpdateTopic:i,onSendMessage:o}){const c=v.useRef(null),d=v.useRef(null),[f,m]=v.useState("");v.useEffect(()=>{var z;const N=d.current;if(!N)return;N.scrollHeight-N.scrollTop-N.clientHeight<80&&((z=c.current)==null||z.scrollIntoView({behavior:"smooth"}))},[e.messages.length]);const[h,x]=v.useState(!1),[g,w]=v.useState(!1),[b,j]=v.useState(""),k=o&&e.id!=="general",E=()=>{!f.trim()||!o||(o(e.id,f.trim()),m(""),setTimeout(()=>{var N;return(N=c.current)==null?void 0:N.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(N=>Cv[N]??N).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:N=>j(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(i(e.id,b.trim()),w(!1)),N.key==="Escape"&&w(!1)},onBlur:()=>{i(e.id,b.trim()),w(!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??""),w(!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(N=>{const C=e.members.includes(N.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 z=C?e.members.filter(T=>T!==N.id):[...e.members,N.id];a(e.id,z)},children:[C?"✓ ":"",N.name]},N.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(N=>l.jsx(z6,{msg:N},N.id)),l.jsx("div",{ref:c})]}),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:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),E())},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 Bh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},B6=400,O6=800;function ty({sessions:e,activeSessionId:n,roles:a,streamingSessionId:i,width:o,onWidthChange:c,onSwitchSession:d,onCloseSession:f,onCreateSession:m,onClearEmpty:h,onCloseAll:x,onSendMessage:g,onModeChange:w,onStopSession:b,onCloseTerminal:j,onMaximize:k,chatChannels:E,activeChatChannelId:N,onSwitchChatChannel:C,onCreateChatChannel:z,onDeleteChatChannel:T,onUpdateChatMembers:H,onUpdateChatTopic:F,onSendChatMessage:I,unreadChannels:V}){const[X,_]=v.useState(!1),[$,L]=v.useState(!1),[W,ne]=v.useState(!1),[K,q]=v.useState(""),ie=N!=null,de=E==null?void 0:E.find(De=>De.id===N),[me,D]=v.useState(!1),[U,Y]=v.useState(!1),[R,O]=v.useState(!1),ae=v.useRef(0),te=v.useRef(0),Se=v.useRef(null),je=e.find(De=>De.id===n),_e=i===n,Oe=e.filter(De=>De.messages.length===0).length,Xe=v.useCallback(()=>{const De=Se.current;De&&(Y(De.scrollLeft>0),O(De.scrollLeft+De.clientWidth<De.scrollWidth-1))},[]);v.useEffect(()=>{if(!n||!Se.current)return;const De=Se.current.querySelector(`[data-session-id="${n}"]`);De&&De.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),Xe()},[n,e.length,Xe]),v.useEffect(()=>{const De=Se.current;if(!De)return;Xe(),De.addEventListener("scroll",Xe);const We=new ResizeObserver(Xe);return We.observe(De),()=>{De.removeEventListener("scroll",Xe),We.disconnect()}},[Xe]);const rt=v.useCallback(De=>{De.preventDefault(),ae.current=De.clientX,te.current=o,D(!0);const We=k,Ot=()=>{D(!1),document.removeEventListener("mousemove",yt),document.removeEventListener("mouseup",Ot)},yt=bt=>{const jt=ae.current-bt.clientX,qe=te.current+jt;if(qe>=window.innerWidth*.6&&We){Ot(),We();return}const at=Math.min(O6,Math.max(B6,qe));c==null||c(at)};document.addEventListener("mousemove",yt),document.addEventListener("mouseup",Ot)},[o,c,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:[c&&l.jsx("div",{className:`terminal-resize-handle absolute top-0 left-0 w-1 h-full cursor-col-resize z-10 transition-colors ${me?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:rt}),l.jsxs("div",{className:"flex items-center bg-[var(--terminal-bg-deeper)] border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"relative flex-1 min-w-0",children:[U&&l.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-6 bg-gradient-to-r from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"}),l.jsxs("div",{ref:Se,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[E==null?void 0:E.map(De=>l.jsxs("button",{onClick:()=>{C==null||C(De.id)},className:`flex items-center gap-1 px-2.5 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors group ${N===De.id?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface)]"}`,style:N===De.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),l.jsx("span",{className:"truncate",children:De.name}),(V==null?void 0:V.has(De.id))&&N!==De.id&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!De.isDefault&&l.jsx("span",{onClick:We=>{We.stopPropagation(),T==null||T(De.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:"×"})]},De.id)),E&&E.length>0&&e.length>0&&l.jsx("div",{className:"w-px h-4 bg-[var(--terminal-border)] shrink-0 mx-1"}),e.map(De=>l.jsx(v6,{roleId:De.roleId,title:De.title,roleColor:Bh[De.roleId]??"#666",active:!ie&&De.id===n,isWave:De.source==="wave",isWaveStreaming:De.source==="wave"&&De.status==="active",onClick:()=>{C==null||C(null),d(De.id)},onClose:We=>{We.stopPropagation(),f(De.id)},"data-session-id":De.id},De.id))]}),R&&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:()=>{_(!X),L(!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:"+"}),X&&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:[z&&l.jsxs(l.Fragment,{children:[W?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:De=>q(De.target.value),onKeyDown:De=>{De.key==="Enter"&&K.trim()&&(z(K.trim(),[]),q(""),ne(!1),_(!1)),De.key==="Escape"&&(ne(!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:()=>ne(!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(De=>l.jsxs("button",{onClick:()=>{m(De.id),C==null||C(null),_(!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:Bh[De.id]??"#666"}}),De.id.toUpperCase()," — ",De.name]},De.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{L(!$),_(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-xs cursor-pointer tracking-tight",title:"Manage sessions",children:"···"}),$&&l.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[l.jsxs("div",{className:"px-3 py-1.5 text-[10px] text-[var(--terminal-text-muted)] border-b border-[var(--terminal-border)]",children:[e.length," session",e.length!==1?"s":""]}),Oe>0&&h&&l.jsxs("button",{onClick:()=>{h(),L(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:["Clear empty sessions (",Oe,")"]}),e.length>0&&x&&l.jsx("button",{onClick:()=>{x(),L(!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:"×"})]}),ie&&de?l.jsx(_6,{channel:de,allRoles:a,onUpdateMembers:H,onUpdateTopic:F,onSendMessage:I}):je?l.jsxs(l.Fragment,{children:[l.jsx(Sv,{messages:je.messages,roleId:je.roleId,roleColor:Bh[je.roleId]??"#666"}),l.jsx(tp,{mode:je.mode,onModeChange:De=>w(je.id,De),onSend:(De,We)=>g(je.id,De,je.mode,We),disabled:_e,disabledReason:_e?`${je.roleId.toUpperCase()} is responding...`:void 0,onStop:_e&&b?()=>b(je.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 $6(){const e=v.useRef(null),n=v.useCallback(()=>{var i;(i=e.current)==null||i.abort(),e.current=null},[]);return{sendMessage:v.useCallback((i,o,c,d,f)=>{n();const m=new AbortController;return e.current=m,fetch(`/api/sessions/${i}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o,mode:c,attachments:f}),signal:m.signal}).then(async h=>{var E,N,C,z,T;if(!h.ok||!h.body){d.onError("Failed to connect");return}const x=h.body.getReader(),g=new TextDecoder;let w="",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:F}=await x.read();if(H)break;b=Date.now(),w+=g.decode(F,{stream:!0});const I=w.split(`
|
|
96
|
+
`);w=I.pop()??"";let V="";for(let X=0;X<I.length;X++){const _=I[X];if(_.startsWith("event: ")){V=_.slice(7).trim();continue}if(_.startsWith("data: ")){let $;try{$=JSON.parse(_.slice(6))}catch{V="";continue}switch(V){case"thinking":$.text&&((E=d.onThinking)==null||E.call(d,$.text));break;case"output":$.text&&d.onText($.text);break;case"tool":(N=d.onToolUse)==null||N.call(d,$.name,$.input);break;case"dispatch":(C=d.onDispatch)==null||C.call(d,$.roleId,$.task);break;case"dispatch:progress":(z=d.onDispatchProgress)==null||z.call(d,$.roleId,$.type,$);break;case"turn":(T=d.onTurn)==null||T.call(d,$.turn);break;case"done":d.onDone($);break;case"error":d.onError($.message??"Unknown error");break;default:$.text&&d.onText($.text);break}V=""}}}}finally{clearInterval(k)}}).catch(h=>{h.name!=="AbortError"&&d.onError(h.message)}),{abort:n}},[n]),abort:n}}const Nv="tycono-appearances",wm="tycono-theme";function ny(){try{const e=localStorage.getItem(Nv);return e?JSON.parse(e):{}}catch{return{}}}function Oh(e){localStorage.setItem(Nv,JSON.stringify(e))}function ry(){try{const e=localStorage.getItem(wm);if(e&&e in ul)return e}catch{}return"default"}const Ev=new Set;for(const e of Object.values(ul))for(const n of Object.keys(e.vars))Ev.add(n);function L6(e){var i;const n=(i=ul[e])==null?void 0:i.vars;if(!n)return;const a=document.documentElement;for(const o of Ev)o in n||a.style.removeProperty(o);for(const[o,c]of Object.entries(n))a.style.setProperty(o,c)}const $h={mode:"auto",intervalSec:18,dailyBudgetUsd:1},km="tycono-speech-settings",Lh="tycono-language";function I6(){try{const e=localStorage.getItem(km);return e?{...$h,...JSON.parse(e)}:$h}catch{return $h}}function H6(){const[e,n]=v.useState(ny),[a,i]=v.useState(ry),[o,c]=v.useState(I6),[d,f]=v.useState(()=>{try{return localStorage.getItem(Lh)??"auto"}catch{return"auto"}}),[m,h]=v.useState(new Set),x=v.useRef(!1);v.useEffect(()=>{x.current||(x.current=!0,ye.getPreferences().then(C=>{const z=Object.keys(C.appearances??{}).length>0||C.theme!=="default";if(C.speech&&(c(T=>({...T,...C.speech})),localStorage.setItem(km,JSON.stringify(C.speech))),C.language&&(f(C.language),localStorage.setItem(Lh,C.language)),C.purchasedItems&&h(new Set(C.purchasedItems)),z){const T=C.appearances;n(T),Oh(T),C.theme&&C.theme in ul&&(i(C.theme),localStorage.setItem(wm,C.theme))}else{const T=ny(),H=ry();(Object.keys(T).length>0||H!=="default")&&ye.updatePreferences({appearances:T,theme:H}).catch(()=>{})}}).catch(()=>{}))},[]),v.useEffect(()=>{L6(a)},[a]);const g=v.useCallback(C=>e[C]??ep(C),[e]),w=v.useCallback((C,z)=>{n(T=>{const H={...T,[C]:z};return Oh(H),ye.updatePreferences({appearances:H}).catch(()=>{}),H})},[]),b=v.useCallback(C=>{n(z=>{const T={...z};return delete T[C],Oh(T),ye.updatePreferences({appearances:T}).catch(()=>{}),T})},[]),j=v.useCallback(C=>{i(C),localStorage.setItem(wm,C),ye.updatePreferences({theme:C}).catch(()=>{})},[]),k=v.useCallback(C=>{c(z=>{const T={...z,...C};return localStorage.setItem(km,JSON.stringify(T)),ye.updatePreferences({speech:T}).catch(()=>{}),T})},[]),E=v.useCallback(C=>{f(C),localStorage.setItem(Lh,C),ye.updatePreferences({language:C}).catch(()=>{})},[]),N=v.useCallback(C=>{h(z=>{const T=new Set(z);return T.add(C),ye.updatePreferences({purchasedItems:Array.from(T)}).catch(()=>{}),T})},[]);return{appearances:e,getAppearance:g,setAppearance:w,resetAppearance:b,theme:a,setTheme:j,speechSettings:o,setSpeechSettings:k,language:d,setLanguage:E,purchasedItems:m,addPurchasedItem:N}}const U6=3e4,q6=3e5;function Y6(){var $;const[e,n]=v.useState("akb"),[a,i]=v.useState(null),[o,c]=v.useState("synced"),[d,f]=v.useState([]),[m,h]=v.useState(null),[x,g]=v.useState(!1),w=v.useRef(null),b=v.useRef(null),j=v.useRef(e);j.current=e;const k=v.useCallback(async()=>{try{const L=await ye.getSaveStatus(j.current);i(L),L.noGit?c("no-git"):c(W=>W==="saving"?W:L.dirty?"dirty":"synced")}catch{c("error")}},[]),E=v.useCallback(async()=>{try{const L=await ye.getSyncStatus(j.current);h({ahead:L.ahead,behind:L.behind,branch:L.branch,hasRemote:L.hasRemote})}catch{}},[]),N=v.useCallback(()=>{w.current&&clearInterval(w.current),k(),w.current=setInterval(k,U6),b.current&&clearInterval(b.current),E(),b.current=setInterval(E,q6)},[k,E]);v.useEffect(()=>()=>{w.current&&clearInterval(w.current),b.current&&clearInterval(b.current)},[]);const C=v.useCallback(L=>{n(L),j.current=L,i(null),h(null),f([]),setTimeout(()=>{k(),E()},0)},[k,E]),z=v.useCallback(async L=>{c("saving");try{const W=await ye.save(L,j.current);return await k(),W}catch(W){throw c("error"),W}},[k]),T=v.useCallback(async()=>{try{const L=await ye.getSaveHistory(20,j.current);f(L)}catch{}},[]),H=v.useCallback(async L=>{c("saving");try{await ye.restoreSave(L,void 0,j.current),await k()}catch(W){throw c("error"),W}},[k]),F=v.useCallback(async()=>{g(!0);try{const L=await ye.pull(j.current);return await k(),await E(),L}catch(L){throw L}finally{g(!1)}},[k,E]),I=v.useCallback(async()=>{try{await ye.initGit(j.current),await k()}catch{c("error")}},[k]),V=a?a.modified.length+a.untracked.length:0,X=(($=a==null?void 0:a.lastCommit)==null?void 0:$.date)??null,_=v.useCallback(async()=>{N()},[N]);return{state:o,dirtyCount:V,lastSaved:X,status:a,save:z,history:d,loadHistory:T,restore:H,refresh:_,initGit:I,repo:e,setRepo:C,syncInfo:m,fetchSyncStatus:E,pull:F,pulling:x}}const ay={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."]},ly={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."]},X6=[{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."}]}],W6=18e3,iy=6e3,G6=2500,V6=30*6e4,Av="tycono:relationships";function K6(){try{const e=localStorage.getItem(Av);return e?JSON.parse(e):[]}catch{return[]}}function P6(e){localStorage.setItem(Av,JSON.stringify(e))}function Su(e,n,a){const[i,o]=n<a?[n,a]:[a,n];let c=e.find(d=>d.roleA===i&&d.roleB===o);return c||(c={roleA:i,roleB:o,dispatches:0,wavesTogether:0,conversations:0,familiarity:0,lastInteraction:new Date().toISOString()},e.push(c)),c}function Cu(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function Nu(e){return e[Math.floor(Math.random()*e.length)]}function Q6(e,n,a){const i=a.find(f=>f.id===e),o=a.find(f=>f.id===n);if(!i||!o)return null;const c=i.level==="c-level",d=o.level==="c-level";return c&&d?"c-level":i.reportsTo===n||o.reportsTo===e?"superior-subordinate":(i.reportsTo===o.reportsTo,"peer")}function Z6(e,n){return e.relation==="any"?!0:e.relation===n}function J6({roles:e,roleStatuses:n,activeExecs:a,getStandupSpeech:i}){const[o,c]=v.useState(new Map),[d,f]=v.useState(K6),m=v.useRef({}),h=v.useRef(null),x=v.useRef(e),g=v.useRef(n),w=v.useRef(a),b=v.useRef(i),j=v.useRef(d);x.current=e,g.current=n,w.current=a,b.current=i,j.current=d,v.useEffect(()=>{const T=Date.now();for(const[H,F]of Object.entries(n))Wn(F)&&(m.current[H]=T)},[n]),v.useEffect(()=>{P6(d)},[d]);const k=v.useCallback(T=>{const H=g.current[T],F=w.current.find($=>$.roleId===T);if(Wn(H)&&(F!=null&&F.task))return null;const I=b.current(T);if(I&&Math.random()<.3)return{text:I,type:"work",ts:Date.now()};const V=Date.now(),X=m.current[T]??0;if(V-X>V6&&Math.random()<.5){const $=ly[T]??ly.engineer;return{text:Nu($),type:"guilt",ts:V}}const _=ay[T]??ay.engineer;return{text:Nu(_),type:"personality",ts:V}},[]),E=v.useCallback(T=>{if(h.current)return!1;const H=T.filter(ie=>!Wn(g.current[ie.id]));if(H.length<2)return!1;const F=[...H].sort(()=>Math.random()-.5),I=F[0],V=F[1],X=Q6(I.id,V.id,T);if(!X)return!1;const _=Su(j.current,I.id,V.id),$=Cu(_),L=X6.filter(ie=>Z6(ie,X)&&$>=ie.minFamiliarity);if(L.length===0)return!1;const W=Nu(L);let ne=I.id,K=V.id;W.relation==="superior-subordinate"&&(V.reportsTo===I.id||I.level==="c-level"?(ne=I.id,K=V.id):(ne=V.id,K=I.id)),h.current={templateId:W.id,roleA:ne,roleB:K,turnIdx:0,timer:null};const q=ie=>{if(!h.current||ie>=W.turns.length){h.current=null,f(U=>{const Y=[...U],R=Su(Y,ne,K);return R.conversations++,R.familiarity=Cu(R),R.lastInteraction=new Date().toISOString(),Y}),setTimeout(()=>{c(U=>{const Y=new Map(U);return Y.delete(ne),Y.delete(K),Y})},iy);return}const de=W.turns[ie],me=de.speaker==="A"?ne:K,D=de.speaker==="A"?K:ne;c(U=>{const Y=new Map(U);if(Y.set(me,{text:de.text,type:"social",partnerId:D,ts:Date.now()}),ie>0){const R=W.turns[ie-1].speaker==="A"?ne:K;R!==me&&Y.delete(R)}return Y}),h.current.turnIdx=ie,h.current.timer=setTimeout(()=>q(ie+1),G6)};return q(0),!0},[]);v.useEffect(()=>{const T=setInterval(()=>{const H=x.current;if(H.length===0||h.current||Math.random()<.35&&E(H))return;const F=H.filter(X=>!Wn(g.current[X.id]));if(F.length===0)return;const I=Nu(F),V=k(I.id);V&&(c(X=>{const _=new Map(X);return _.set(I.id,V),_}),setTimeout(()=>{c(X=>{const _=new Map(X),$=_.get(I.id);return $&&$.ts===V.ts&&_.delete(I.id),_})},iy))},W6);return()=>{var H;clearInterval(T),(H=h.current)!=null&&H.timer&&clearTimeout(h.current.timer)}},[k,E]);const N=v.useCallback(T=>{const H=o.get(T);return(H==null?void 0:H.text)??""},[o]),C=v.useCallback((T,H)=>{f(F=>{const I=[...F],V=Su(I,T,H);return V.dispatches++,V.familiarity=Cu(V),V.lastInteraction=new Date().toISOString(),I})},[]),z=v.useCallback(T=>{T.length<2||f(H=>{const F=[...H];for(let I=0;I<T.length;I++)for(let V=I+1;V<T.length;V++){const X=Su(F,T[I],T[V]);X.wavesTogether++,X.familiarity=Cu(X),X.lastInteraction=new Date().toISOString()}return F})},[]);return{speeches:o,getSpeech:N,relationships:d,notifyDispatch:C,notifyWave:z}}const Dv="tycono:office-chat";let eA=0;function tA(){return`chat-${Date.now()}-${++eA}`}function Ih(){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 nA(){try{const e=localStorage.getItem(Dv);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[...Ih(),...i]}const a=Ih();for(const i of a)n.find(o=>o.id===i.id)||n.unshift(i);return n}}catch{}return Ih()}function rA(e){const n=e.map(a=>({...a,messages:a.messages.slice(-200)}));localStorage.setItem(Dv,JSON.stringify(n))}function aA(){const[e,n]=v.useState(nA),[a,i]=v.useState(null),[o,c]=v.useState(new Set);v.useEffect(()=>{rA(e)},[e]);const d=v.useCallback(b=>{i(b),b&&c(j=>{const k=new Set(j);return k.delete(b),k})},[]),f=v.useCallback(b=>{const j={...b,id:tA()};n(k=>{const E=k.map(N=>N.id==="general"?b.type==="dispatch"?{...N,messages:[...N.messages,j].slice(-200)}:N:b.channelId?N.id===b.channelId?{...N,messages:[...N.messages,j].slice(-200)}:N:N.members.length>0&&N.members.includes(b.roleId)?{...N,messages:[...N.messages,j].slice(-200)}:N);return c(N=>{const C=new Set(N);for(const z of E){const T=k.find(H=>H.id===z.id);T&&z.messages.length>T.messages.length&&C.add(z.id)}return C}),E})},[]),m=v.useCallback((b,j,k)=>{const E=`ch-${Date.now()}`,N={id:E,name:b.startsWith("#")?b:`#${b}`,members:j,isDefault:!1,messages:[],topic:k};n(C=>[...C,N]),i(E)},[]),h=v.useCallback(b=>{n(j=>j.filter(k=>k.id!==b||k.isDefault)),i(j=>j===b?"general":j)},[]),x=v.useCallback((b,j)=>{n(k=>k.map(E=>E.id===b&&!E.isDefault?{...E,members:j}:E))},[]),g=v.useCallback((b,j)=>{n(k=>k.map(E=>E.id===b&&!E.isDefault?{...E,topic:j||void 0}:E))},[]),w=v.useCallback(b=>{n(j=>j.map(k=>{if(k.id==="watercooler"){const E=b.filter(N=>N.level!=="c-level").map(N=>N.id);if(k.members.length!==E.length||!E.every(N=>k.members.includes(N)))return{...k,members:E}}return k}))},[]);return{channels:e,activeChannelId:a,setActiveChannelId:d,pushMessage:f,createChannel:m,deleteChannel:h,updateMembers:x,updateTopic:g,unreadChannels:o,syncDefaultMembers:w}}const lA=45e3,sy=5e3,iA=4,sA=20;function oA({roles:e,roleStatuses:n,activeExecs:a,channels:i,relationships:o,pushMessage:c,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)??lA/1e3)*1e3,w=v.useRef(e),b=v.useRef(n),j=v.useRef(a),k=v.useRef(i),E=v.useRef(o),N=v.useRef(c),C=v.useRef(0),z=v.useRef(!1);w.current=e,b.current=n,j.current=a,k.current=i,E.current=o,N.current=c;const T=v.useCallback(async(I,V)=>{if(z.current)return!1;z.current=!0;try{if(!w.current.find(q=>q.id===I))return!1;const _=V.messages.slice(-sA).map(q=>({roleId:q.roleId,text:q.text,ts:q.ts})),$=w.current.filter(q=>V.members.includes(q.id)),L=E.current.filter(q=>q.roleA===I||q.roleB===I).map(q=>({partnerId:q.roleA===I?q.roleB:q.roleA,familiarity:q.familiarity})),W=j.current.find(q=>q.roleId===I),ne=W?{currentTask:W.task,taskProgress:null}:{currentTask:null,taskProgress:null},K=await ye.chatInChannel({channelId:V.name.replace("#",""),channelTopic:V.topic,roleId:I,history:_,members:$.map(q=>({id:q.id,name:q.name,level:q.level})),relationships:L,workContext:ne});return K.message?(N.current({ts:Date.now(),roleId:I,text:K.message,type:"chat",channelId:V.id}),!0):!1}catch{return!1}finally{z.current=!1}},[]),H=v.useCallback(async(I,V)=>{if(C.current>=iA){C.current=0;return}const X=I.members.filter(W=>W!==V&&!Wn(b.current[W]));if(X.length===0){C.current=0;return}const _=X[Math.floor(Math.random()*X.length)];if(Math.random()>.7){C.current=0;return}const $=C.current*2e3,L=Math.random()*5e3;setTimeout(async()=>{C.current++;const W=k.current.find(K=>K.id===I.id);if(!W)return;if(await T(_,W)){const K=.6-C.current*.1;Math.random()<K?H(W,_):C.current=0}else C.current=0},sy+$+L)},[T]);return v.useEffect(()=>{if(!x)return;const I=setInterval(async()=>{const V=w.current;if(V.length===0||z.current)return;const X=V.filter(ne=>!Wn(b.current[ne.id]));if(X.length===0)return;const _=X[Math.floor(Math.random()*X.length)],$=k.current.filter(ne=>ne.members.length===0?!0:ne.members.includes(_.id));if($.length===0)return;const L=$[Math.floor(Math.random()*$.length)];C.current=0,await T(_.id,L)&&H(L,_.id)},g);return()=>clearInterval(I)},[x,g,T,H]),{triggerCeoReaction:v.useCallback(I=>{if(!x)return;const V=k.current.find(X=>X.id===I);V&&(C.current=0,setTimeout(()=>{H(V,"ceo")},sy))},[x,H])}}const Tv=[[1,8],[3,5],[8,1],[5,3]],cA=[[1,4],[2,3],[4,1],[3,2]];function Eu(e){const n=e===1||e===3?-1:0,a=Tv[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=Tv[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 Il(e,n){const a=e===1||e===3?-1:0,i=cA[e],o=a,c=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+c,w:3,h:4-c,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+c,w:3,h:4-c,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 oy={down:[Eu(0),Eu(1),Eu(2),Eu(3)],up:[Au(0),Au(1),Au(2),Au(3)],right:[Il(0,!0),Il(1,!0),Il(2,!0),Il(3,!0)],left:[Il(0,!1),Il(1,!1),Il(2,!1),Il(3,!1)]},Fe="#FAFAF7",Yn="#FFFFFF",Te="#EDE8E2",tt="#DDD6CC",Vo="#1A1A2E",ad="#2A2A2A",np="#FFB0B0",cy=[{x:2,y:0,w:1,h:1,c:Te},{x:3,y:0,w:1,h:1,c:Fe},{x:4,y:0,w:1,h:1,c:Yn},{x:5,y:0,w:1,h:1,c:Fe},{x:6,y:0,w:1,h:1,c:Te},{x:1,y:1,w:1,h:1,c:tt},{x:2,y:1,w:1,h:1,c:Fe},{x:3,y:1,w:1,h:1,c:Yn},{x:4,y:1,w:1,h:1,c:Fe},{x:5,y:1,w:1,h:1,c:Yn},{x:6,y:1,w:1,h:1,c:Fe},{x:7,y:1,w:1,h:1,c:tt},{x:0,y:2,w:1,h:1,c:tt},{x:1,y:2,w:1,h:1,c:Te},{x:2,y:2,w:1,h:1,c:Fe},{x:3,y:2,w:1,h:1,c:Fe},{x:4,y:2,w:1,h:1,c:Yn},{x:5,y:2,w:1,h:1,c:Fe},{x:6,y:2,w:1,h:1,c:Fe},{x:7,y:2,w:1,h:1,c:Te},{x:8,y:2,w:1,h:1,c:tt},{x:1,y:3,w:1,h:1,c:Te},{x:2,y:3,w:1,h:1,c:Fe},{x:3,y:3,w:1,h:1,c:Vo},{x:4,y:3,w:1,h:1,c:Fe},{x:5,y:3,w:1,h:1,c:Vo},{x:6,y:3,w:1,h:1,c:Fe},{x:7,y:3,w:1,h:1,c:Te},{x:2,y:4,w:1,h:1,c:Te},{x:3,y:4,w:1,h:1,c:Fe},{x:4,y:4,w:1,h:1,c:ad},{x:5,y:4,w:1,h:1,c:Fe},{x:6,y:4,w:1,h:1,c:Te},{x:3,y:5,w:1,h:1,c:tt},{x:4,y:5,w:1,h:1,c:Te},{x:5,y:5,w:1,h:1,c:tt},{x:2,y:6,w:1,h:1,c:Te},{x:3,y:6,w:1,h:1,c:Fe},{x:4,y:6,w:1,h:1,c:Yn},{x:5,y:6,w:1,h:1,c:Fe},{x:6,y:6,w:1,h:1,c:Te},{x:2,y:7,w:1,h:1,c:tt},{x:3,y:7,w:1,h:1,c:Te},{x:4,y:7,w:1,h:1,c:Fe},{x:5,y:7,w:1,h:1,c:Te},{x:6,y:7,w:1,h:1,c:tt}],uA=[{x:3,y:8,w:1,h:1,c:Te},{x:5,y:8,w:1,h:1,c:Te},{x:3,y:9,w:1,h:1,c:tt},{x:5,y:9,w:1,h:1,c:tt}],dA=[{x:2,y:8,w:1,h:1,c:Te},{x:6,y:8,w:1,h:1,c:Te},{x:2,y:9,w:1,h:1,c:tt},{x:6,y:9,w:1,h:1,c:tt}],uy=[{x:2,y:0,w:1,h:1,c:Te},{x:3,y:0,w:1,h:1,c:Fe},{x:4,y:0,w:1,h:1,c:Yn},{x:5,y:0,w:1,h:1,c:Fe},{x:6,y:0,w:1,h:1,c:Te},{x:1,y:1,w:1,h:1,c:tt},{x:2,y:1,w:1,h:1,c:Te},{x:3,y:1,w:1,h:1,c:Fe},{x:4,y:1,w:1,h:1,c:Yn},{x:5,y:1,w:1,h:1,c:Fe},{x:6,y:1,w:1,h:1,c:Te},{x:7,y:1,w:1,h:1,c:tt},{x:0,y:2,w:1,h:1,c:tt},{x:1,y:2,w:1,h:1,c:Te},{x:2,y:2,w:1,h:1,c:Fe},{x:3,y:2,w:1,h:1,c:Fe},{x:4,y:2,w:1,h:1,c:Fe},{x:5,y:2,w:1,h:1,c:Fe},{x:6,y:2,w:1,h:1,c:Fe},{x:7,y:2,w:1,h:1,c:Te},{x:8,y:2,w:1,h:1,c:tt},{x:1,y:3,w:1,h:1,c:tt},{x:2,y:3,w:1,h:1,c:Te},{x:3,y:3,w:1,h:1,c:Fe},{x:4,y:3,w:1,h:1,c:Fe},{x:5,y:3,w:1,h:1,c:Fe},{x:6,y:3,w:1,h:1,c:Te},{x:7,y:3,w:1,h:1,c:tt},{x:2,y:4,w:1,h:1,c:tt},{x:3,y:4,w:1,h:1,c:Te},{x:4,y:4,w:1,h:1,c:Fe},{x:5,y:4,w:1,h:1,c:Te},{x:6,y:4,w:1,h:1,c:tt},{x:3,y:5,w:1,h:1,c:tt},{x:4,y:5,w:1,h:1,c:Te},{x:5,y:5,w:1,h:1,c:tt},{x:2,y:6,w:1,h:1,c:Te},{x:3,y:6,w:1,h:1,c:Fe},{x:4,y:6,w:1,h:1,c:Fe},{x:5,y:6,w:1,h:1,c:Fe},{x:6,y:6,w:1,h:1,c:Te},{x:2,y:7,w:1,h:1,c:tt},{x:3,y:7,w:1,h:1,c:Te},{x:4,y:7,w:1,h:1,c:Fe},{x:5,y:7,w:1,h:1,c:Te},{x:6,y:7,w:1,h:1,c:tt},{x:4,y:5,w:1,h:1,c:Fe},{x:4,y:4,w:1,h:1,c:Yn}],fA=[{x:3,y:8,w:1,h:1,c:Te},{x:5,y:8,w:1,h:1,c:Te},{x:3,y:9,w:1,h:1,c:tt},{x:5,y:9,w:1,h:1,c:tt}],hA=[{x:2,y:8,w:1,h:1,c:Te},{x:6,y:8,w:1,h:1,c:Te},{x:2,y:9,w:1,h:1,c:tt},{x:6,y:9,w:1,h:1,c:tt}],jm=[{x:8,y:0,w:1,h:1,c:Te},{x:9,y:0,w:1,h:1,c:Fe},{x:10,y:0,w:1,h:1,c:Yn},{x:11,y:0,w:1,h:1,c:Fe},{x:7,y:1,w:1,h:1,c:tt},{x:8,y:1,w:1,h:1,c:Fe},{x:9,y:1,w:1,h:1,c:Yn},{x:10,y:1,w:1,h:1,c:Fe},{x:11,y:1,w:1,h:1,c:Fe},{x:12,y:1,w:1,h:1,c:Te},{x:0,y:2,w:1,h:1,c:Yn},{x:1,y:2,w:1,h:1,c:Fe},{x:3,y:2,w:1,h:1,c:Te},{x:4,y:2,w:1,h:1,c:Fe},{x:5,y:2,w:1,h:1,c:Fe},{x:6,y:2,w:1,h:1,c:Fe},{x:7,y:2,w:1,h:1,c:Te},{x:8,y:2,w:1,h:1,c:Fe},{x:9,y:2,w:1,h:1,c:Fe},{x:10,y:2,w:1,h:1,c:Fe},{x:11,y:2,w:1,h:1,c:Fe},{x:12,y:2,w:1,h:1,c:Te},{x:0,y:3,w:1,h:1,c:Te},{x:1,y:3,w:1,h:1,c:tt},{x:3,y:3,w:1,h:1,c:tt},{x:4,y:3,w:1,h:1,c:Te},{x:5,y:3,w:1,h:1,c:Fe},{x:6,y:3,w:1,h:1,c:Te},{x:7,y:3,w:1,h:1,c:tt},{x:8,y:3,w:1,h:1,c:Fe},{x:9,y:3,w:1,h:1,c:Vo},{x:10,y:3,w:1,h:1,c:Fe},{x:11,y:3,w:1,h:1,c:Te},{x:3,y:4,w:1,h:1,c:tt},{x:4,y:4,w:1,h:1,c:Te},{x:5,y:4,w:1,h:1,c:Fe},{x:6,y:4,w:1,h:1,c:Te},{x:8,y:4,w:1,h:1,c:Te},{x:9,y:4,w:1,h:1,c:Fe},{x:10,y:4,w:1,h:1,c:ad}],Fv=[{x:4,y:5,w:1,h:1,c:Te},{x:6,y:5,w:1,h:1,c:Te},{x:8,y:5,w:1,h:1,c:Te},{x:10,y:5,w:1,h:1,c:Te},{x:4,y:6,w:1,h:1,c:tt},{x:6,y:6,w:1,h:1,c:tt},{x:8,y:6,w:1,h:1,c:tt},{x:10,y:6,w:1,h:1,c:tt}],Rv=[{x:3,y:5,w:1,h:1,c:Te},{x:5,y:5,w:1,h:1,c:Te},{x:9,y:5,w:1,h:1,c:Te},{x:11,y:5,w:1,h:1,c:Te},{x:3,y:6,w:1,h:1,c:tt},{x:5,y:6,w:1,h:1,c:tt},{x:9,y:6,w:1,h:1,c:tt},{x:11,y:6,w:1,h:1,c:tt}];function rp(e,n=13){return e.map(a=>({...a,x:n-1-a.x}))}const dy=rp(jm),mA=rp(Fv),pA=rp(Rv),xA={down:[[...cy,...uA],[...cy,...dA]],up:[[...uy,...fA],[...uy,...hA]],right:[[...jm,...Fv],[...jm,...Rv]],left:[[...dy,...mA],[...dy,...pA]]},gA=[{x:4,y:5,w:1,h:1,c:np}],On="#FFD4D4",na="#FFCCD5",yA=[{x:2,y:0,w:1,h:1,c:tt},{x:3,y:0,w:1,h:1,c:Te},{x:4,y:0,w:1,h:1,c:Fe},{x:5,y:0,w:1,h:1,c:Yn},{x:6,y:0,w:1,h:1,c:Te},{x:7,y:0,w:1,h:1,c:tt},{x:1,y:1,w:1,h:1,c:tt},{x:2,y:1,w:1,h:1,c:Te},{x:3,y:1,w:1,h:1,c:Fe},{x:4,y:1,w:1,h:1,c:Yn},{x:5,y:1,w:1,h:1,c:Fe},{x:6,y:1,w:1,h:1,c:Yn},{x:7,y:1,w:1,h:1,c:Te},{x:8,y:1,w:1,h:1,c:tt},{x:1,y:2,w:1,h:1,c:Te},{x:2,y:2,w:1,h:1,c:Fe},{x:3,y:2,w:1,h:1,c:Vo},{x:4,y:2,w:1,h:1,c:Fe},{x:5,y:2,w:1,h:1,c:Fe},{x:6,y:2,w:1,h:1,c:Vo},{x:7,y:2,w:1,h:1,c:Fe},{x:8,y:2,w:1,h:1,c:Te},{x:2,y:3,w:1,h:1,c:Te},{x:3,y:3,w:1,h:1,c:Fe},{x:4,y:3,w:1,h:1,c:ad},{x:5,y:3,w:1,h:1,c:np},{x:6,y:3,w:1,h:1,c:Fe},{x:7,y:3,w:1,h:1,c:Te},{x:2,y:4,w:1,h:1,c:tt},{x:3,y:4,w:1,h:1,c:Te},{x:4,y:4,w:1,h:1,c:Fe},{x:5,y:4,w:1,h:1,c:Fe},{x:6,y:4,w:1,h:1,c:Te},{x:7,y:4,w:1,h:1,c:tt},{x:0,y:5,w:1,h:1,c:Te},{x:1,y:5,w:1,h:1,c:na},{x:2,y:5,w:1,h:1,c:Fe},{x:3,y:5,w:1,h:1,c:On},{x:4,y:5,w:1,h:1,c:On},{x:5,y:5,w:1,h:1,c:On},{x:6,y:5,w:1,h:1,c:On},{x:7,y:5,w:1,h:1,c:Fe},{x:8,y:5,w:1,h:1,c:na},{x:9,y:5,w:1,h:1,c:Te},{x:1,y:6,w:1,h:1,c:Te},{x:2,y:6,w:1,h:1,c:Fe},{x:3,y:6,w:1,h:1,c:On},{x:4,y:6,w:1,h:1,c:na},{x:5,y:6,w:1,h:1,c:na},{x:6,y:6,w:1,h:1,c:On},{x:7,y:6,w:1,h:1,c:Fe},{x:8,y:6,w:1,h:1,c:Te},{x:2,y:7,w:1,h:1,c:Fe},{x:3,y:7,w:1,h:1,c:On},{x:4,y:7,w:1,h:1,c:On},{x:5,y:7,w:1,h:1,c:On},{x:6,y:7,w:1,h:1,c:On},{x:7,y:7,w:1,h:1,c:Fe},{x:0,y:8,w:1,h:1,c:Te},{x:1,y:8,w:1,h:1,c:na},{x:2,y:8,w:1,h:1,c:tt},{x:3,y:8,w:1,h:1,c:Te},{x:4,y:8,w:1,h:1,c:Fe},{x:5,y:8,w:1,h:1,c:Fe},{x:6,y:8,w:1,h:1,c:Te},{x:7,y:8,w:1,h:1,c:tt},{x:8,y:8,w:1,h:1,c:na},{x:9,y:8,w:1,h:1,c:Te},{x:4,y:9,w:1,h:1,c:Fe},{x:5,y:9,w:1,h:1,c:Yn}],bA=[{x:2,y:0,w:1,h:1,c:tt},{x:3,y:0,w:1,h:1,c:Te},{x:4,y:0,w:1,h:1,c:Fe},{x:5,y:0,w:1,h:1,c:Yn},{x:6,y:0,w:1,h:1,c:Te},{x:7,y:0,w:1,h:1,c:tt},{x:1,y:1,w:1,h:1,c:tt},{x:2,y:1,w:1,h:1,c:Te},{x:3,y:1,w:1,h:1,c:Fe},{x:4,y:1,w:1,h:1,c:Yn},{x:5,y:1,w:1,h:1,c:Fe},{x:6,y:1,w:1,h:1,c:Yn},{x:7,y:1,w:1,h:1,c:Te},{x:8,y:1,w:1,h:1,c:tt},{x:1,y:2,w:1,h:1,c:Te},{x:2,y:2,w:1,h:1,c:Fe},{x:3,y:2,w:1,h:1,c:Te},{x:4,y:2,w:1,h:1,c:Fe},{x:5,y:2,w:1,h:1,c:Fe},{x:6,y:2,w:1,h:1,c:Te},{x:7,y:2,w:1,h:1,c:Fe},{x:8,y:2,w:1,h:1,c:Te},{x:2,y:3,w:1,h:1,c:Te},{x:3,y:3,w:1,h:1,c:Fe},{x:4,y:3,w:1,h:1,c:ad},{x:5,y:3,w:1,h:1,c:np},{x:6,y:3,w:1,h:1,c:Fe},{x:7,y:3,w:1,h:1,c:Te},{x:2,y:4,w:1,h:1,c:tt},{x:3,y:4,w:1,h:1,c:Te},{x:4,y:4,w:1,h:1,c:Fe},{x:5,y:4,w:1,h:1,c:Fe},{x:6,y:4,w:1,h:1,c:Te},{x:7,y:4,w:1,h:1,c:tt},{x:0,y:5,w:1,h:1,c:Te},{x:1,y:5,w:1,h:1,c:na},{x:2,y:5,w:1,h:1,c:Fe},{x:3,y:5,w:1,h:1,c:On},{x:4,y:5,w:1,h:1,c:On},{x:5,y:5,w:1,h:1,c:On},{x:6,y:5,w:1,h:1,c:On},{x:7,y:5,w:1,h:1,c:Fe},{x:8,y:5,w:1,h:1,c:na},{x:9,y:5,w:1,h:1,c:Te},{x:1,y:6,w:1,h:1,c:Te},{x:2,y:6,w:1,h:1,c:Fe},{x:3,y:6,w:1,h:1,c:On},{x:4,y:6,w:1,h:1,c:na},{x:5,y:6,w:1,h:1,c:na},{x:6,y:6,w:1,h:1,c:On},{x:7,y:6,w:1,h:1,c:Fe},{x:8,y:6,w:1,h:1,c:Te},{x:2,y:7,w:1,h:1,c:Fe},{x:3,y:7,w:1,h:1,c:On},{x:4,y:7,w:1,h:1,c:On},{x:5,y:7,w:1,h:1,c:On},{x:6,y:7,w:1,h:1,c:On},{x:7,y:7,w:1,h:1,c:Fe},{x:0,y:8,w:1,h:1,c:Te},{x:1,y:8,w:1,h:1,c:na},{x:2,y:8,w:1,h:1,c:tt},{x:3,y:8,w:1,h:1,c:Te},{x:4,y:8,w:1,h:1,c:Fe},{x:5,y:8,w:1,h:1,c:Fe},{x:6,y:8,w:1,h:1,c:Te},{x:7,y:8,w:1,h:1,c:tt},{x:8,y:8,w:1,h:1,c:na},{x:9,y:8,w:1,h:1,c:Te},{x:5,y:9,w:1,h:1,c:Fe},{x:6,y:9,w:1,h:1,c:Yn}],vA=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],wA=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],kA=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],ht=4,sn=28,qn=2,Mt=4,Nt=4,sl=[{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 ap(e,n,a){const c=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 w=Math.min(d,n-g*d);for(let b=0;b<w;b++)m.push({dx:x+b*28,dy:c+g*28,room:e.id})}return m}function jA(e){const i=sl[0],o={id:"main",wx:ht+Nt,wy:ht,ww:160-2*(ht+Nt),wh:sn,fx:ht+Nt,fy:ht+sn+qn,fw:160-2*(ht+Nt),fh:120-ht-sn-qn-ht,...i},c=ap(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*(ht+Nt))/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:c,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 SA(e){const o={id:"exec",wx:ht+Nt,wy:ht,ww:144-ht-Nt-Mt/2,wh:sn,fx:ht+Nt,fy:ht+sn+qn,fw:144-ht-Nt-Mt/2,fh:66,...sl[0]},c={id:"work",wx:144+Mt/2+Nt,wy:ht,ww:144-Mt/2-Nt-ht,wh:sn,fx:144+Mt/2+Nt,fy:ht+sn+qn,fw:144-Mt/2-Nt-ht,fh:66,...sl[1]},d={id:"meet",wx:ht+Nt,wy:ht+sn+qn+66+Mt,ww:144-ht-Nt-Mt/2,wh:sn,fx:ht+Nt,fy:ht+sn+qn+66+Mt+sn+qn,fw:144-ht-Nt-Mt/2,fh:70,...sl[2]},f={id:"comm",wx:144+Mt/2+Nt,wy:ht+sn+qn+66+Mt,ww:144-Mt/2-Nt-ht,wh:sn,fx:144+Mt/2+Nt,fy:ht+sn+qn+66+Mt+sn+qn,fw:144-Mt/2-Nt-ht,fh:70,...sl[3]},m={exec:o,work:c,meet:d,comm:f},h=[];let x=e;const g=[[o,Math.min(3,x)],[c,0]];g[1][1]=Math.min(3,x-g[0][1]);const w=[[d,0],[f,0]];let b=x-g[0][1]-g[1][1];b>0&&(w[0][1]=Math.min(2,b),b-=w[0][1]),b>0&&(w[1][1]=Math.min(2,b));for(const[F,I]of[...g,...w])I>0&&h.push(...ap(F,I,3));const j=ht+sn+qn+66,k=144-Mt/2,E={exec_work:{id:"exec_work",type:"v",doorY:ht+sn+qn+20+12,xA:k-2,xB:c.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:ht+sn+qn+66+Mt+sn+qn+20+12,xA:k-2,xB:f.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:ht+Nt+40+14,yA:j-2,yB:d.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+Mt/2+Nt+40+14,yA:j-2,yB:f.fy+2}},N={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},C={exec:o.fy+52,work:c.fy+48,meet:d.fy+56,comm:f.fy+54},z={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:c.fx+14,y:c.fy+48},{x:c.fx+44,y:c.fy+48},{x:c.fx+70,y:c.fy+48},{x:c.fx+100,y:c.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}]},T=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0",facility:{id:"theme",label:"THEME",icon:"🎨",color:"#42A5F5",hitW:12,hitH:10}},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10,facility:{id:"settings",label:"SETTINGS",icon:"⚙",color:"#78909C",hitW:10,hitH:10}},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:14,facility:{id:"stats",label:"STATS",icon:"📊",color:"#7E57C2",hitW:16,hitH:8}},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"📋",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"📜",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],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:E,adjacency:N,corridorY:C,waypoints:z,wallDecorations:T,furniture:H}}function CA(e){const d={id:"exec",wx:ht+Nt,wy:ht,ww:180-ht-Nt-Mt/2,wh:sn,fx:ht+Nt,fy:ht+sn+qn,fw:180-ht-Nt-Mt/2,fh:82,...sl[0]},f={id:"work",wx:180+Mt/2+Nt,wy:ht,ww:180-Mt/2-Nt-ht,wh:sn,fx:180+Mt/2+Nt,fy:ht+sn+qn,fw:180-Mt/2-Nt-ht,fh:82,...sl[1]},m=ht+sn+qn+82,h={id:"meet",wx:ht+Nt,wy:m+Mt,ww:180-ht-Nt-Mt/2,wh:sn,fx:ht+Nt,fy:m+Mt+sn+qn,fw:180-ht-Nt-Mt/2,fh:86,...sl[2]},x={id:"comm",wx:180+Mt/2+Nt,wy:m+Mt,ww:180-Mt/2-Nt-ht,wh:sn,fx:180+Mt/2+Nt,fy:m+Mt+sn+qn,fw:180-Mt/2-Nt-ht,fh:86,...sl[3]},g={exec:d,work:f,meet:h,comm:x},w=[];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 E=b-j[0][1]-j[1][1];E>0&&(k[0][1]=Math.min(3,E),E-=k[0][1]),E>0&&(k[1][1]=Math.min(3,E));for(const[V,X]of[...j,...k])X>0&&w.push(...ap(V,X,4));const N=180-Mt/2,C={exec_work:{id:"exec_work",type:"v",doorY:d.fy+82/2,xA:N-2,xB:f.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:h.fy+86/2,xA:N-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}},z={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"}]},T={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:T.exec},{x:d.fx+d.fw/2,y:T.exec},{x:d.fx+d.fw-10,y:T.exec}],work:[{x:f.fx+10,y:T.work},{x:f.fx+f.fw/2,y:T.work},{x:f.fx+f.fw-10,y:T.work}],meet:[{x:h.fx+10,y:T.meet},{x:h.fx+h.fw/2,y:T.meet},{x:h.fx+h.fw-10,y:T.meet}],comm:[{x:x.fx+10,y:T.comm},{x:x.fx+x.fw/2,y:T.comm},{x:x.fx+x.fw-10,y:T.comm}]},F=[{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:w,doors:C,adjacency:z,corridorY:T,waypoints:H,wallDecorations:F,furniture:I}}const NA=2;function Mv(e,n,a){return a||(n?n==="L"&&e<=12-NA?"M":n==="M"&&e>12?"L":n:e<=12?"M":"L")}function zv(e,n){switch(n??Mv(e)){case"S":return jA(e);case"M":return SA(e);case"L":return CA(e)}}function EA(e,n){if(!n||Object.keys(n).length===0)return e;const a=i=>i.map(o=>{const c=n[o.id];return c?{...o,offsetX:c.offsetX,offsetY:c.offsetY}:o});return{...e,wallDecorations:a(e.wallDecorations),furniture:a(e.furniture)}}function AA(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 fy(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 DA(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 Lo;function TA(e){Lo=e}function B(e,n,a,i,o,c){e=Math.round(e),n=Math.round(n),!(c!==void 0&&c<.01)&&(c!==void 0&&c!==1&&(Lo.globalAlpha=c),Lo.fillStyle=o,Lo.fillRect(e,n,a,i),c!==void 0&&c!==1&&(Lo.globalAlpha=1))}function dt(e,n,a,i){B(e,n,1,1,a,i)}let $u=1;function Ds(e){$u=e}function Ra(){return $u=$u*16807%2147483647,($u&65535)/65535}function _v(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),c=Math.min(n,a,i);let d=0,f=0;const m=(o+c)/2;if(o!==c){const h=o-c;f=m>.5?h/(2-o-c):h/(o+c),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 Bv(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))},c=d=>Math.round(d*255).toString(16).padStart(2,"0");return"#"+c(o(0))+c(o(8))+c(o(4))}function Ma(e,n=1){const[a,i,o]=_v(e);return Bv(a+15*n,Math.min(100,i+8),o-12*n)}function bn(e,n=1){const[a,i,o]=_v(e);return Bv(a-10*n,i-3,o+10*n)}const Un={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},Ir={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},Ca={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},ra="#100A06";function FA(e,n,a=14,i=12){B(e,n,a,i,"#4A3828"),B(e+1,n+1,a-2,i-2,"#5A4838"),B(e+2,n+2,a-4,i-4,"#4A7098"),B(e+2,n+2,a-4,Math.floor((i-4)/2),"#6A90B8",.35);const o=Math.floor(a/2);B(e+o,n+1,1,i-2,"#4A3828"),B(e+1,n+Math.floor(i/2),a-2,1,"#4A3828",.5),dt(e+3,n+3,"#8AB8E8",.35),dt(e+o+2,n+3,"#8AB8E8",.25),B(e-1,n+i,a+2,2,"#5A4838"),B(e-1,n+i,a+2,1,bn("#5A4838",.5),.35)}function RA(e,n,a){B(e,n,10,8,"#3A2818"),B(e+1,n+1,8,6,a),B(e+2,n+2,4,3,bn(a,1.2),.3),dt(e+3,n+2,bn(a,2),.25)}function MA(e,n){B(e,n,7,7,"#3A2818"),B(e+1,n+1,5,5,"#F0EDE5"),dt(e+3,n+1,"#AAA"),dt(e+3,n+5,"#AAA"),dt(e+1,n+3,"#AAA"),dt(e+5,n+3,"#AAA"),dt(e+3,n+3,"#222"),B(e+3,n+1,1,2,"#333"),dt(e+4,n+3,"#D32F2F")}function zA(e,n){B(e,n,26,16,"#586878"),B(e+1,n+1,24,13,"#ECEFF1"),B(e+1,n+1,24,1,"#F5F5F5",.4),B(e+3,n+3,14,1,"#1565C0",.6),B(e+3,n+5,18,1,"#333",.2),B(e+3,n+7,12,1,"#D32F2F",.35),B(e+3,n+9,16,1,"#333",.15),B(e+1,n+14,24,2,"#708898"),B(e+3,n+14,3,1,"#D32F2F"),B(e+7,n+14,3,1,"#1565C0"),B(e+11,n+14,3,1,"#2E7D32")}function _A(e,n){B(e,n,22,16,"#6A5030"),B(e+1,n+1,20,14,"#C4A66A"),Ds(88);for(let a=0;a<14;a++)for(let i=0;i<20;i++)Ra()>.5&&dt(e+1+i,n+1+a,Ra()>.5?"#B89858":"#D4B87A",.18);B(e+2,n+2,5,4,"#FFF176"),B(e+8,n+2,5,4,"#90CAF9"),B(e+14,n+3,5,4,"#CE93D8"),B(e+3,n+8,7,4,"#C8E6C9"),B(e+11,n+8,8,4,"#F8BBD0"),dt(e+4,n+2,"#E53935"),dt(e+10,n+2,"#1E88E5"),dt(e+16,n+3,"#FF9800")}function BA(e,n){B(e,n,20,3,"#5A4030"),B(e,n,20,1,bn("#5A4030",.5),.35),B(e,n+2,20,1,Ma("#5A4030",.5),.3),B(e+2,n-4,3,4,"#E53935"),B(e+2,n-4,3,1,bn("#E53935",1),.3),B(e+6,n-3,2,3,"#1E88E5"),B(e+9,n-5,4,5,"#43A047"),B(e+14,n-3,3,3,"#FFD54F"),dt(e+15,n-3,"#FFF176",.4)}function OA(e,n){B(e,n,16,12,"#1E1E28"),B(e+1,n+1,14,9,"#0C1420"),B(e+2,n+2,12,1,"#EF4444",.6),dt(e+2,n+4,"#4CAF50"),B(e+4,n+4,7,1,"#8b949e",.4),dt(e+2,n+6,"#FF9800"),B(e+4,n+6,5,1,"#8b949e",.3),dt(e+2,n+8,"#42A5F5"),B(e+4,n+8,8,1,"#8b949e",.25),B(e+7,n+10,2,2,"#1E1E28"),B(e+5,n+11,6,1,"#586878")}function $A(e,n,a){B(e+2,n+20,22,2,ra,.15),B(e,n,22,20,Ir.deep),B(e+1,n+1,20,18,Ir.base),B(e,n,22,1,Ir.hi,.35),B(e,n,1,20,Ir.hi,.2);for(const c of[6,12])B(e+1,n+c,20,2,Ir.sh),B(e+1,n+c,20,1,Ir.hi,.2);const i=["#E53935","#1E88E5","#43A047","#8E24AA","#FB8C00","#00897B","#5C6BC0"];let o=e+2;for(let c=0;c<5;c++){const d=2+c%2;B(o,n+1,d,5,i[c]),B(o,n+1,d,1,bn(i[c],1),.35),o+=d+1}o=e+2;for(let c=0;c<4;c++)B(o,n+7,4,5,i[c+3]),B(o,n+7,4,1,bn(i[c+3],1),.25),o+=5;B(e+2,n+14,4,4,"#FFD54F"),B(e+8,n+14,7,4,"#90CAF9"),a&&B(e,n-1,22,1,a,.7)}function LA(e,n){B(e+2,n+11,6,2,ra,.1),B(e+2,n+8,6,4,"#8B5E3C"),B(e+1,n+7,8,2,Ma("#A06E48",.3)),B(e+2,n+7,6,1,bn("#A06E48",.5),.4),B(e+1,n+3,3,4,"#2E7D32"),B(e+5,n+2,3,4,"#2E7D32"),B(e+2,n+1,4,4,"#43A047"),B(e+3,n+0,3,3,"#66BB6A"),dt(e+4,n,"#81C784"),dt(e+3,n+1,"#A5D6A7",.4)}function IA(e,n){vi(e+4,n-4,"down"),vi(e+16,n-4,"down"),vi(e+28,n-4,"down"),B(e+3,n+24,34,3,ra,.15),B(e,n+2,36,18,Un.deep),B(e+1,n+3,34,16,Un.base),B(e+1,n+3,34,1,Un.hi,.35);for(let a=0;a<14;a+=3)B(e+1,n+4+a,34,1,Ma(Un.base,.2),.08);B(e,n+20,36,4,Un.deep),B(e+1,n+21,34,2,Un.sh),B(e+6,n+7,10,6,"#1A1A24"),B(e+7,n+8,8,4,"#0C1420"),B(e+8,n+9,4,1,"#2A6898",.4),B(e+20,n+8,6,4,"#F0F0F0"),B(e+15,n+7,3,3,"#ECEFF1"),dt(e+16,n+8,"#795548"),vi(e+4,n+24,"up"),vi(e+16,n+24,"up"),vi(e+28,n+24,"up")}function HA(e,n){B(e+2,n+16,36,3,ra,.15),B(e,n,36,5,"#5D4037"),B(e+1,n+1,34,3,"#6D4C41"),B(e+1,n+1,34,1,bn("#6D4C41",.5),.3),B(e,n+5,36,8,"#5D4037"),B(e+2,n+6,15,6,"#6D4C41"),B(e+3,n+6,13,1,bn("#6D4C41",.5),.35),B(e+19,n+6,15,6,"#6D4C41"),B(e+20,n+6,13,1,bn("#6D4C41",.5),.35),B(e+17,n+6,2,6,"#5D4037"),B(e,n+13,36,3,Ma("#5D4037",1)),B(e-2,n+2,3,12,"#5D4037"),B(e+35,n+2,3,12,"#5D4037"),B(e+4,n+7,6,4,"#FF8A65"),B(e+5,n+7,4,1,bn("#FF8A65",1),.35)}function UA(e,n){B(e+2,n+10,22,2,ra,.12),B(e,n,22,8,Ir.deep),B(e+1,n+1,20,6,Ir.base),B(e+1,n+1,20,1,Ir.hi,.3),B(e,n+8,22,2,Ir.sh),B(e+3,n+2,6,4,"#F0F0F0"),B(e+13,n+3,3,3,"#ECEFF1"),dt(e+14,n+4,"#795548")}function qA(e,n){B(e+1,n+14,10,2,ra,.12),B(e,n,10,14,"#546E7A"),B(e,n,10,1,bn("#546E7A",1),.35),B(e+1,n+1,8,3,"#78909C"),B(e+1,n+5,8,4,"#37474F"),dt(e+2,n+6,"#EF5350"),dt(e+4,n+6,"#66BB6A"),B(e+2,n+11,4,2,"#ECEFF1")}function YA(e,n){B(e+2,n+18,28,3,ra,.12),B(e,n,28,18,"#37474F"),B(e+1,n+1,26,15,"#0D47A1"),B(e+2,n+2,24,13,"#1565C0"),B(e+2,n+2,24,4,"#1976D2",.4),B(e+2,n+12,24,3,"#F9A825",.35),B(e+4,n+8,2,5,"#2E7D32"),B(e+6,n+9,2,4,"#43A047"),B(e+20,n+7,2,6,"#2E7D32"),B(e+22,n+8,2,5,"#388E3C"),B(e+9,n+5,4,2,"#FF8A65"),dt(e+12,n+5,"#FF5722"),B(e+16,n+8,3,2,"#FFD54F"),dt(e+15,n+8,"#FFC107"),dt(e+13,n+3,"#90CAF9",.5),dt(e+14,n+4,"#BBDEFB",.35),dt(e+8,n+3,"#BBDEFB",.3),B(e,n+16,28,2,"#455A64"),B(e+1,n+16,26,1,bn("#455A64",.5),.3)}function XA(e,n){B(e,n,24,10,"#1A1A2E"),B(e+2,n+1,20,8,"#E040FB",.15),B(e+3,n+2,4,6,"#E040FB",.7),B(e+4,n+3,2,4,"#1A1A2E"),B(e+8,n+2,1,6,"#00E5FF",.7),B(e+8,n+2,4,1,"#00E5FF",.7),B(e+8,n+4,4,1,"#00E5FF",.7),B(e+11,n+2,1,3,"#00E5FF",.7),B(e+13,n+2,1,6,"#E040FB",.7),B(e+13,n+2,4,1,"#E040FB",.7),B(e+13,n+4,3,1,"#E040FB",.7),B(e+13,n+7,4,1,"#E040FB",.7),B(e+18,n+2,1,6,"#00E5FF",.7),B(e+21,n+2,1,6,"#00E5FF",.7),B(e+19,n+3,1,2,"#00E5FF",.5),B(e+20,n+5,1,2,"#00E5FF",.5)}function WA(e,n){B(e+2,n+28,16,3,ra,.15),B(e,n,16,28,"#1A237E"),B(e+1,n+1,14,3,"#283593"),B(e+2,n+4,12,10,"#0D1117"),B(e+3,n+5,10,8,"#1B5E20"),B(e+5,n+6,2,2,"#4CAF50"),B(e+9,n+8,2,2,"#FF5722"),B(e+7,n+10,3,1,"#FFD54F"),dt(e+6,n+7,"#81C784"),B(e+1,n+14,14,6,"#1A237E"),B(e+2,n+15,4,4,"#212121"),dt(e+4,n+16,"#F44336"),dt(e+9,n+16,"#F44336"),dt(e+11,n+16,"#2196F3"),dt(e+10,n+18,"#FFEB3B"),B(e,n+20,16,8,"#0D47A1"),B(e+1,n+21,14,6,"#1565C0"),B(e,n+4,1,14,"#FF4081",.4),B(e+15,n+4,1,14,"#FF4081",.4)}function GA(e,n){B(e+2,n+24,20,3,ra,.15),B(e,n,20,24,"#4E342E"),B(e+1,n+1,18,22,"#5D4037"),B(e+2,n+1,16,4,"#FF6F00"),B(e+3,n+2,14,2,"#FF8F00",.6),B(e+2,n+5,16,10,"#1A1A2E"),B(e+3,n+6,14,8,"#212121"),B(e+4,n+7,4,4,"#333"),B(e+5,n+8,2,2,"#E53935"),B(e+10,n+7,4,4,"#333"),B(e+11,n+8,2,2,"#1E88E5"),B(e+3,n+16,14,6,"#3E2723");for(let a=0;a<7;a++)B(e+4+a*2,n+17,1,4,"#5D4037",.5);B(e+1,n+5,18,1,"#FFD54F",.5),B(e+1,n+15,18,1,"#FFD54F",.5)}function VA(e,n){B(e+2,n+22,22,2,ra,.12),B(e,n,22,22,Ir.deep),B(e+1,n+1,20,20,"#37474F"),B(e+2,n+2,18,18,"#546E7A",.3),B(e+1,n+10,20,1,Ir.base),B(e+1,n+10,20,1,Ir.hi,.2),B(e+4,n+3,4,5,"#FFD54F"),B(e+5,n+4,2,3,"#FFC107"),B(e+4,n+7,4,1,"#FFA000"),dt(e+5,n+3,"#FFF176",.5),B(e+13,n+4,4,4,"#B0BEC5"),B(e+14,n+3,2,1,"#CFD8DC"),dt(e+14,n+5,"#ECEFF1",.6),B(e+5,n+12,3,3,"#A1887F"),B(e+6,n+11,1,1,"#D7CCC8"),B(e+12,n+12,6,4,"#5D4037"),B(e+13,n+13,4,2,"#FFD54F",.6),B(e+2,n+2,2,18,"#fff",.08)}function KA(e,n){B(e+2,n+16,26,3,ra,.18),B(e,n,26,10,Un.deep),B(e+1,n+1,24,8,Un.base),B(e+1,n+2,24,1,Un.hi,.2),B(e+1,n+4,24,1,Ma(Un.base,.2),.1),B(e+1,n+6,24,1,Un.hi,.15),B(e+1,n+1,24,1,Un.hi,.4),B(e+1,n+1,1,8,Un.hi,.2),B(e,n+10,26,5,Un.deep),B(e+1,n+11,24,3,Un.sh),B(e+1,n+10,24,1,Ma(Un.base,1.5),.4),B(e+1,n+14,24,1,Un.base,.15),B(e+2,n+12,10,1,Un.deep,.4),B(e+14,n+12,10,1,Un.deep,.4),dt(e+7,n+11,"#C8D0D8",.6),dt(e+19,n+11,"#C8D0D8",.6),B(e+6,n-5,14,7,"#1E1E28"),B(e+7,n-4,12,5,"#0C1420"),B(e+8,n-3,5,1,"#2A6898",.6),B(e+8,n-2,8,1,"#1A3858",.4),B(e+8,n-1,3,1,"#2A6898",.35),dt(e+7,n-4,"#4A98D8",.25),dt(e+12,n+1,"#4CAF50",.4),B(e+12,n+2,2,3,"#586878"),B(e+10,n+4,6,1,"#8898A8"),B(e+6,n+4,12,4,"#222228"),B(e+6,n+4,12,1,"#333338",.4);for(let a=0;a<5;a++)dt(e+7+a*2,n+5,"#444",.6),dt(e+7+a*2,n+6,"#3A3A3E",.4);B(e+20,n+5,3,4,"#333338"),B(e+20,n+5,3,1,"#444448"),B(e+1,n+3,4,4,"#F0EDE8"),B(e+1,n+3,4,1,"#F8F6F2"),dt(e+2,n+5,"#6D4C41")}function vi(e,n,a){B(e+1,n+9,10,2,ra,.1),dt(e+5,n+9,"#1E1E22"),dt(e+1,n+10,"#1A1A1E"),dt(e+9,n+10,"#1A1A1E"),dt(e+3,n+11,"#1A1A1E"),dt(e+7,n+11,"#1A1A1E"),B(e+1,n+2,8,6,Ca.base),B(e+2,n+3,6,4,Ca.hi,.35),B(e+2,n+3,6,1,bn(Ca.hi,.5),.25),B(e+1,n+7,8,1,Ca.deep),a==="up"?(B(e,n+7,10,3,Ca.deep),B(e+1,n+8,8,1,Ca.sh)):(B(e,n-1,10,3,Ca.deep),B(e+1,n,8,1,Ca.sh)),B(e,n+3,1,4,Ca.sh),B(e+9,n+3,1,4,Ca.sh)}const Ov={bookshelf:(e,n,a)=>$A(e,n,a.accent),plant:(e,n)=>LA(e,n),"meeting-table":(e,n)=>IA(e,n),sofa:(e,n)=>HA(e,n),"coffee-table":(e,n)=>UA(e,n),"coffee-machine":(e,n)=>qA(e,n),window:(e,n,a)=>FA(e,n,a.windowW??16,a.windowH??14),picture:(e,n,a)=>RA(e,n,a.pictureColor??"#1565C0"),clock:(e,n)=>MA(e,n),whiteboard:(e,n)=>zA(e,n),"bulletin-board":(e,n)=>_A(e,n),shelf:(e,n)=>BA(e,n),screen:(e,n)=>OA(e,n),aquarium:(e,n)=>YA(e,n),"neon-sign":(e,n)=>XA(e,n),arcade:(e,n)=>WA(e,n),jukebox:(e,n)=>GA(e,n),"trophy-case":(e,n)=>VA(e,n)};function js(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 PA(e){for(const n of e.wallDecorations){const a=e.rooms[n.room];if(!a)continue;const{x:i,y:o}=js(n,a),c=Ov[n.type];c&&c(i,o,n)}}function QA(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:c,y:d}=js(i,o),f=Ov[i.type];f&&n.push({y:d,draw:()=>f(c,d,i)})}}function wi(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:c,y:d}=js(i,o);n.push({id:i.facility.id,label:i.facility.label,icon:i.facility.icon,color:i.facility.color,dx:c,dy:d,pw:i.facility.hitW,ph:i.facility.hitH})}return n}const ZA={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 Sm(e){return ZA[e]??{w:16,h:16}}function Hh(e,n,a,i){for(let o=e.furniture.length-1;o>=0;o--){const c=e.furniture[o],d=e.rooms[c.room];if(!d||c.condition==="no-desks"&&i.has(c.room))continue;const{x:f,y:m}=js(c,d),h=Sm(c.type);if(n>=f&&n<=f+h.w&&a>=m&&a<=m+h.h)return c.id}for(let o=e.wallDecorations.length-1;o>=0;o--){const c=e.wallDecorations[o],d=e.rooms[c.room];if(!d)continue;const{x:f,y:m}=js(c,d),h=Sm(c.type);if(n>=f&&n<=f+h.w&&a>=m&&a<=m+h.h)return c.id}return null}function hy(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}=js(d,f),x=Sm(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 my(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 py(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 xy=[{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,JA=4,bi=4,Lu=2,qt=4,ql=4;let Je=zv(7);const Pu={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},gy={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 e8(e,n){const a=gy[e]||gy.default;return a[n]||a.en||a.default||[]}let Ea=wi(Je);function $v(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function Lv(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let kn={};function t8(e){const n={};for(let a=0;a<e.length&&a<Je.desks.length;a++)n[e[a]]=Je.desks[a];return n}let Ve,Jn=null,ki=null,ll=!1,fa=null,$r=null,Iv=0,lr=null,Hn=null,Hl=null,Na=null,Uh=900;function n8(e,n){const{wx:a,wy:i,ww:o,wh:c,wallColor:d,baseboardColor:f}=e,m=Ma(d,.5),h=bn(d,.5),x=[];if(n){const g=n.x-a,w=n.w;g>0&&x.push({sx:a,sw:g}),g+w<o&&x.push({sx:n.x+w,sw:o-g-w})}else x.push({sx:a,sw:o});for(const g of x){B(g.sx,i,g.sw,c,d);for(let w=0;w<c;w+=4)B(g.sx,i+w,g.sw,1,h,.08),B(g.sx,i+w+2,g.sw,1,m,.05);Ds(Math.round(g.sx*7+i*13));for(let w=0;w<g.sw;w+=3)Ra()>.4&&B(g.sx+w,i,1,c,h,.04);B(g.sx,i,g.sw,2,h,.3),B(g.sx,i,g.sw,1,bn(d,1),.2),B(g.sx,i+c-2,g.sw,2,m,.3),B(g.sx,i+c,g.sw,Lu,f),B(g.sx,i+c,g.sw,1,bn(f,.5),.4)}n&&(B(n.x-1,i,1,c+Lu,"#4A3828"),B(n.x+n.w,i,1,c+Lu,"#4A3828"),B(n.x,i,n.w,1,"#0A0808",.12)),B(e.fx,e.fy,e.fw,3,"#0A0808",.12),B(e.fx,e.fy+3,e.fw,2,"#0A0808",.06)}function r8(e){const n="#504038",a=Ma(n,.5),i=bn(n,.5),o=e.wx-ql,c=e.wy,d=e.wh+Lu+e.fh;B(o,c,ql,d,n),B(o,c,1,d,i,.3),B(o+ql-1,c,1,d,a,.4);for(let m=0;m<d;m+=6)B(o+1,c+m,ql-2,1,i,.06);const f=e.wx+e.ww;B(f,c,ql,d,n),B(f,c,1,d,i,.2),B(f+ql-1,c,1,d,a,.3)}function qh(e){const{fx:n,fy:a,fw:i,fh:o}=e,c="#B08040",d="#C89848",f="#8A6030",m="#6A4820";B(n,a,i,o,c),Ds(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 w=n+g+x,b=Math.max(n,w),j=Math.min(w+19,n+i)-b;if(j<=0)continue;const k=Ra()>.5?d:c;B(b,a+h,j,4,k,.25),B(b,a+h,j,1,d,.3),B(b,a+h+4,j,1,m,.35),w>=n&&w<n+i&&B(w,a+h,1,4,m,.2),B(b,a+h+2,j,1,f,.1)}}B(n,a,i,2,"#0A0808",.08),B(n,a,2,o,"#0A0808",.06)}function yy(e){const{fx:n,fy:a,fw:i,fh:o}=e,c="#1C2A38",d="#101820";Ds(99),B(n,a,i,o,c);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);Ra()>.5&&B(n+m,a+f,h,x,bn(c,.2),.15),B(n+m+2,a+f+2,h-4,x-4,bn(c,.3),.08),B(n+m,a+f,h,1,d,.5),B(n+m,a+f,1,x,d,.5),B(n+m+1,a+f+1,1,x-1,bn(c,.4),.1),Ra()>.85&&dt(n+m+4+Math.floor(Ra()*8),a+f+4+Math.floor(Ra()*8),"#3A6A9A",.08)}}function a8(e){const{fx:n,fy:a,fw:i,fh:o}=e,c="#387848",d="#4A9058",f="#285E38";B(n,a,i,o,c),Ds(77);for(let h=0;h<o;h+=2)for(let x=0;x<i;x+=2)Ra()>.5&&dt(n+x,a+h,d,.1),Ra()>.8&&dt(n+x+1,a+h+1,f,.12);const m=5;B(n+m,a+m,i-m*2,1,d,.45),B(n+m,a+o-m-1,i-m*2,1,f,.45),B(n+m,a+m,1,o-m*2,d,.35),B(n+i-m-1,a+m,1,o-m*2,f,.35)}function l8(e){const{fx:n,fy:a,fw:i,fh:o}=e,c="#D8C490",d="#B09060",f="#907848";Ds(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),w=(h/8+m/8)%2===0?d:c;B(n+h,a+m,x,g,w),B(n+h+1,a+m+1,x-2,1,bn(w,.4),.2),B(n+h+1,a+m+1,1,g-2,bn(w,.4),.15),B(n+h+x-2,a+m+2,1,g-3,Ma(w,.4),.15),B(n+h+2,a+m+g-2,x-3,1,Ma(w,.4),.15),B(n+h,a+m,x,1,f,.3),B(n+h,a+m,1,g,f,.3)}}function i8(){const{canvasW:e,canvasH:n,rooms:a,doors:i}=Je,o="#2A1E14",c="#3A2E24";if(B(0,0,e,bi,o),B(0,n-bi,e,bi,o),B(0,0,bi,n,o),B(e-bi,0,bi,n,o),B(0,0,e,1,c,.3),B(0,0,1,n,c,.2),!a.exec||!a.work||!a.meet||!a.comm)return;const d=a.exec,f=a.meet,m=e/2,h=m-qt/2,x=d.fy+d.fh,g=i.exec_work,w=i.meet_comm,b=i.exec_meet,j=i.work_comm,k=24,E=28,N=((g==null?void 0:g.doorY)??d.fy+20)-k/2,C=((b==null?void 0:b.doorX)??bi+ql+54)-E/2,z=((j==null?void 0:j.doorX)??m+qt/2+ql+54)-E/2,T=((w==null?void 0:w.doorY)??f.fy+20)-k/2;B(0,x,C,qt,o),B(C+E,x,h-C-E,qt,o),B(h+qt,x,z-h-qt,qt,o),B(z+E,x,e-z-E,qt,o),B(0,x,C,1,c,.3),B(C+E,x,h-C-E,1,c,.3),B(h+qt,x,z-h-qt,1,c,.3),B(z+E,x,e-z-E,1,c,.3),B(h,0,qt,N,o),B(h,N+k,qt,x-N-k,o),B(h,x+qt,qt,T-x-qt,o),B(h,T+k,qt,n-T-k,o),B(h,0,1,N,c,.2),B(h,N+k,1,x-N-k,c,.2),B(h,x+qt,1,T-x-qt,c,.2),B(h,T+k,1,n-T-k,c,.2),B(h,N,qt,k,"#C4A070"),B(h+qt/2,N,qt/2,k,"#3A4858"),B(h,T,qt,k,"#7AA880"),B(h+qt/2,T,qt/2,k,"#C8B890");const H="#4A3828";B(h,N-1,qt,1,H),B(h,N+k,qt,1,H),B(C-1,x,1,qt,H),B(C+E,x,1,qt,H),B(z-1,x,1,qt,H),B(z+E,x,1,qt,H),B(h,T-1,qt,1,H),B(h,T+k,qt,1,H)}const by=new Map;function s8(e,n="right"){const a=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${n}`;let i=by.get(a);if(!i){const o=om("mini-seated:default"),c=Pb(o,e);let d=c?c.layers.flatMap(f=>f.pixels):[];n==="left"&&d.length>0&&(d=im(d,12)),i=d,by.set(a,i)}return i}function o8(e,n,a,i="right"){Yl(Ve,s8(a,i),e,n,a)}function c8(e,n,a,i,o,c="right"){vi(e+8,n+20,"up"),o||o8(e+8,n+0+i,a,c),KA(e,n+14)}function u8(e,n,a,i,o){const c=i in oy?i:"down",d=o%4,f=oy[c][d];Yl(Ve,f,e,n,a);const m=d===1||d===3?-1:0;if(a.accessory&&a.accessory!=="none"){const h=bC(a.accessory,c);h&&h.pixels.length>0&&Yl(Ve,h.pixels,e,n+m,a)}Ve.globalAlpha=1}let qo=[],Ci=!1,Ss=0;function d8(){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 f8(e){if(e.stateTimer--,Ci){Ss++,e.dir="down",e.walkFrame=0,e.tongueTimer++,e.idleTime=0;return}else Ss=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=lp(e,i),c=Je.waypoints[i];if(c&&c.length>0){const d=c[Math.floor(Math.random()*c.length)],f=o[o.length-1]??{x:e.x,y:e.y},m=Ni(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=Ni(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[c,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=c;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 h8(e){const n=Math.round(e.x),a=Math.round(e.y);if(Ci&&Ss>90){const d=Math.floor(Ss/12)%2===0?yA:bA;Yl(Ve,kA,n,a),Yl(Ve,d,n,a);return}const i=e.state==="walking"?e.walkFrame:0,o=xA[e.dir][i],c=e.dir==="left"||e.dir==="right";Yl(Ve,c?wA:vA,n,a),Yl(Ve,o,n,a),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&Yl(Ve,gA,n,a)}function m8(e){const n={};let a=0;for(const i of e){const o=kn[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 Ni(e,n,a,i,o){const c=Je.corridorY[o]??n,d=[];return n<c-4&&d.push({x:e,y:c}),Math.abs(e-a)>4&&d.push({x:a,y:c}),d.push({x:a,y:i}),d}function Yh(e,n,a,i){const o=Je.adjacency[a];if(!o)return[];const c=o.find(x=>x.room===i);if(!c)return[];const d=Je.doors[c.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=c.side==="A"?d.xA:d.xB,g=c.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=c.side==="A"?d.yA:d.yB,g=c.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 lp(e,n){const a=Je.adjacency[e.room];if(!a)return[];if(!a.find(o=>o.room===n)){for(const o of a){const c=Je.adjacency[o.room];if(c!=null&&c.find(d=>d.room===n)){const d=Yh(e.x,e.y,e.room,o.room),f=d[d.length-1],m=Yh((f==null?void 0:f.x)??e.x,(f==null?void 0:f.y)??e.y,o.room,n);return[...d,...m]}}return[]}return Yh(e.x,e.y,e.room,n)}function p8(e){if(e.room!==e.homeRoom){const n=lp({...e},e.homeRoom),a=n[n.length-1],i=Ni((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 Ni(e.x,e.y,e.homeX,e.homeY,e.room)}function x8(e,n){if(Uh--,Uh<=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}Uh=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++,Jn===a){i.sittingTime=0,i.bobY=-3;const c=kn[a];if(c){const d=c.dx+13;i.lookDir=Iv<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 c=Object.keys(Je.rooms);if(Math.random()<.15&&c.length>1){const d=c.filter(x=>x!==i.room),f=d[Math.floor(Math.random()*d.length)],m=lp(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},w=Ni(g.x,g.y,x.x,x.y,f);i.path=[...m,...w]}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=Ni(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,Jn===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 c=i.path[0],d=c.x-i.x,f=c.y-i.y,m=Math.sqrt(d*d+f*f);if(m<1.5){i.x=c.x,i.y=c.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(Jn===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 c=o[Math.floor(Math.random()*o.length)];i.path=Ni(i.x,i.y,c.x,c.y,i.room)}i.walkTimer=0}else i.state="returning",i.path=p8(i),i.walkTimer=0}}function g8(e,n,a,i){const{canvasW:o,canvasH:c,rooms:d}=Je;Ve.clearRect(0,0,o,c),B(0,0,o,c,"#2A1E14");const f={wood:qh,dark:yy,carpet:a8,tile:l8};for(const b of Object.values(d))(f[b.floorType]??qh)(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 N=(k.exec_meet.doorX??0)-14,C=(k.work_comm.doorX??0)-28/2,z=b.fy+b.fh,T=j.fy;qh({fx:N,fy:z,fw:28,fh:T-z}),yy({fx:C,fy:z,fw:28,fh:T-z})}}const h={};if(m.length>=4){const{doors:b}=Je,j=28,k=b.exec_meet,E=b.work_comm;k!=null&&k.doorX&&(h.meet={x:k.doorX-j/2,w:j}),E!=null&&E.doorX&&(h.comm={x:E.doorX-j/2,w:j})}for(const b of Object.values(d))n8(b,h[b.id]),r8(b);i8(),PA(Je);const x=[],g=new Set(Object.values(kn).map(b=>b.room));QA(Je,x,g);for(const[b,j]of Object.entries(kn)){const k=e[b];if(!k)continue;const E=k.state==="sitting",N=n(b),C=Wn(a[b]),z=k.isStretching&&k.stretchTimer>0?Math.sin(k.stretchTimer*.15)*1:0;x.push({y:j.dy+14,draw:()=>{const T=E?k.bobY+z:0;if(c8(j.dx,j.dy,N,T,!E,k.lookDir),E&&C){const H=Pu[b]??"#388bfd";B(j.dx+7,j.dy+14-4,12,5,H,.15),dt(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:()=>u8(Math.round(j.x),Math.round(j.y),k,j.dir,j.walkFrame)})}i&&x.push({y:i.y+10,draw:()=>h8(i)}),x.sort((b,j)=>b.y-j.y);for(const b of x)b.draw();for(const b of Ea){const j=ki===b.id,k=Lv(b);if(Ve.save(),Ve.globalAlpha=j?.9:.5,Ve.fillStyle=b.color,Ve.fillRect(k.cx-1,k.botY-2,3,3),j){const E=$v(b);Ve.globalAlpha=.3,Ve.strokeStyle=b.color,Ve.lineWidth=1,Ve.strokeRect(E.x-1,E.y-1,E.w+2,E.h+2)}Ve.restore()}if(ll){const b=new Set(Object.values(kn).map(j=>j.room));if(fa&&fa!==$r)if(fa.startsWith("desk:")){const j=fa.slice(5),k=kn[j];k&&my(Ve,k.dx,k.dy,"#FBBF24")}else hy(Ve,Je,fa,"#FBBF24",b);if($r)if($r.startsWith("desk:")){const j=$r.slice(5),k=kn[j];k&&my(Ve,k.dx,k.dy,"#3B82F6")}else hy(Ve,Je,$r,"#3B82F6",b)}if(Jn){const b=kn[Jn],j=e[Jn];if(b&&j){Ve.save(),Ve.globalAlpha=.25,Ve.fillStyle=Pu[Jn]??"#fff",j.state==="sitting"?Ve.fillRect(b.dx-1,b.dy+6,28,30):Ve.fillRect(Math.round(j.x)-1,Math.round(j.y)-1,14,24),Ve.globalAlpha=.95,Ve.fillStyle="#FBBF24",Ve.font="bold 8px monospace",Ve.textAlign="center";const k=j.state==="sitting"?b.dx+13:Math.round(j.x)+6,E=j.state==="sitting"?b.dy-1:Math.round(j.y)-5;Ve.fillText("!",k,E),Ve.restore()}}const w=3600;for(const[,b]of Object.entries(e))if(b.state==="sitting"&&b.sittingTime>w&&!b.isStretching){const j=Object.values(kn).find(T=>T.dx+8===b.homeX&&T.dy+34===b.homeY);if(!j)continue;const k=j.dx+13,E=j.dy,N=Math.floor(b.sittingTime/40)%3;Ve.save(),Ve.font="5px monospace",Ve.textAlign="center";const C=[.7,.5,.3],z=[{x:3,y:-2-N},{x:6,y:-5-(N+1)%3},{x:4,y:-8-(N+2)%3}];for(let T=0;T<3;T++)Ve.globalAlpha=C[T],Ve.fillStyle="#93C5FD",Ve.font=`${4+T}px monospace`,Ve.fillText("z",k+z[T].x,E+z[T].y);Ve.restore()}qo=qo.filter(b=>b.life>0);for(const b of qo)b.x+=b.vx,b.y+=b.vy,b.life--,Ve.save(),Ve.globalAlpha=Math.min(1,b.life/(b.maxLife*.3)),Ve.fillStyle=b.color??"#FF6B8A",Ve.font="8px serif",Ve.fillText(b.char,Math.round(b.x),Math.round(b.y)),Ve.restore();if(Ci&&i&&Ss<=90){const b=Math.round(i.x),j=Math.round(i.y);Ve.save(),Ve.globalAlpha=.9,Ve.fillStyle="#FBBF24",Ve.font="bold 5px monospace",Ve.textAlign="center",Ve.fillText("!",b+4,j-2),Ve.restore()}if(i&&!Ci&&i.state==="idle"&&i.idleTime>600){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(i.idleTime/40)%3;Ve.save();const E=[{x:3,y:-2-k},{x:5,y:-5-(k+1)%3},{x:4,y:-8-(k+2)%3}];for(let N=0;N<3;N++)Ve.globalAlpha=[.7,.5,.3][N],Ve.fillStyle="#93C5FD",Ve.font=`${3+N}px monospace`,Ve.textAlign="center",Ve.fillText("z",b+E[N].x,j+E[N].y);Ve.restore()}if(Ci&&i&&Ss<=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"&&(Ve.fillStyle="#FAFAF7",Ve.fillRect(b+4+k,j-1,2,2))}}function y8(e,n){for(let a=0;a<4;a++)qo.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 b8(e,n){for(let a=0;a<3;a++)qo.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 v8({roles:e,projects:n,roleStatuses:a,activeExecs:i,onRoleClick:o,onProjectClick:c,onBulletinClick:d,onDecisionsClick:f,onKnowledgeClick:m,onSettingsClick:h,onThemeClick:x,onStatsClick:g,getRoleSpeech:w,getAppearance:b,onHireClick:j,onMascotClick:k,roleLevels:E,coinBalance:N=0,onCoinsSpent:C,onFurniturePlaced:z,purchasedPreset:T,language:H="en"}){const F=v.useRef(null),I=v.useRef(null),V=v.useRef(null),X=v.useRef({}),_=v.useRef(null),$=v.useRef(0),L=v.useRef(JA),[W,ne]=v.useState(!1),[K,q]=v.useState(null),[ie,de]=v.useState(null),me=v.useRef({}),D=v.useRef({}),U=v.useRef([]),Y=v.useRef([]);v.useEffect(()=>{ll=W},[W]),v.useEffect(()=>{Hl=K,Na=ie},[K,ie]);const[R,O]=v.useState(!1);v.useEffect(()=>{ye.getPreferences().then(fe=>{const be=fe.furnitureOverrides;be&&Object.keys(be).length>0&&(me.current=be);const ve=fe.deskOverrides;ve&&Object.keys(ve).length>0&&(D.current=ve);const Q=fe.removedFurniture;Q&&Q.length>0&&(U.current=Q);const Z=fe.addedFurniture;Z&&Z.length>0&&(Y.current=Z),O(!0)}).catch(()=>{O(!0)})},[]);const ae=v.useRef({roleStatuses:a,activeExecs:i,getRoleSpeech:w,getAppearance:b});ae.current={roleStatuses:a,activeExecs:i,getRoleSpeech:w,getAppearance:b};const te=v.useRef({}),Se=v.useMemo(()=>e.map(fe=>fe.id),[e]),je=v.useRef(Je);v.useEffect(()=>{if(!R)return;const fe=Se.length,be=Mv(fe,je.current.preset,T),ve=je.current.preset!==be;let Q=zv(fe,be);U.current.length>0&&(Q=fy(Q,U.current)),Y.current.length>0&&(Q=DA(Q,Y.current)),Object.keys(me.current).length>0&&(Q=EA(Q,me.current)),Je=Q,je.current=Q,kn=t8(Se),Object.keys(D.current).length>0&&AA(kn,D.current),Ea=wi(Q),X.current=m8(Se),_.current=d8();const Z=F.current;Z&&(Z.width=Q.canvasW,Z.height=Q.canvasH,ve&&(Z.style.opacity="0",Z.style.transition="opacity 0.3s",setTimeout(()=>{Z.style.opacity="1"},50))),Oe()},[Se,T,R]);const _e=v.useCallback(fe=>{var be,ve;return((ve=(be=ae.current).getAppearance)==null?void 0:ve.call(be,fe))??ep(fe)},[]),Oe=v.useCallback(()=>{const fe=I.current,be=F.current;if(!fe||!be)return;const ve=fe.parentElement;if(!ve)return;const Q=ve.clientWidth,Z=ve.clientHeight;if(Q===0||Z===0)return;const{canvasW:Ee,canvasH:xe}=Je;let Ae=Math.min(Q/Ee,Z/xe);Ae=Math.round(Ae*2)/2,Ae=Math.max(2,Math.min(Ae,5)),L.current=Ae,be.style.width=Ee*Ae+"px",be.style.height=xe*Ae+"px",fe.style.width=Ee*Ae+"px",fe.style.height=xe*Ae+"px"},[]);v.useEffect(()=>{var xe;const fe=F.current;if(!fe)return;const be=fe.getContext("2d");if(!be)return;Ve=be,TA(be),Oe();const ve=new ResizeObserver(()=>Oe()),Q=(xe=I.current)==null?void 0:xe.parentElement;Q&&ve.observe(Q);let Z;const Ee=()=>{$.current++,x8(X.current,$.current),_.current&&f8(_.current),g8(X.current,_e,ae.current.roleStatuses,_.current),Xe(),Z=requestAnimationFrame(Ee)};return Z=requestAnimationFrame(Ee),()=>{cancelAnimationFrame(Z),ve.disconnect()}},[_e,Oe]),v.useEffect(()=>{var Ee;const fe=V.current;if(!fe)return;fe.innerHTML="";const be={};for(const xe of e)be[xe.id]=xe.name;for(const xe of Se){const Ae=Pu[xe]??"#8b949e",ze=be[xe],$e=ze&&ze.toLowerCase()!==xe.toLowerCase()?`${xe.toUpperCase()} · ${ze}`:xe.toUpperCase(),Le=document.createElement("div");Le.className="td-nametag",Le.dataset.role=xe;const Ye=document.createElement("span");Ye.className="td-dot",Ye.style.background=Ae,Le.appendChild(Ye),Le.appendChild(document.createTextNode($e));const st=((Ee=E==null?void 0:E[xe])==null?void 0:Ee.level)??1;if(st>1){const Re=document.createElement("span");Re.className="td-lvl",Re.textContent=`Lv.${st}`,Le.appendChild(Re)}fe.appendChild(Le);const Ke=document.createElement("div");Ke.className="td-bubble",Ke.dataset.role=xe,Ke.dataset.type="bubble",fe.appendChild(Ke)}const ve={meeting:()=>{const xe=n[0];xe?c(xe.id):d()},bulletin:d,decisions:f,knowledge:m,settings:h,theme:x,stats:g};for(const xe of Ea){const Ae=document.createElement("div");Ae.className="td-facility-label",Ae.dataset.facility=xe.id,xe.id==="meeting"&&(Ae.dataset.questTarget="meeting-room"),xe.id==="knowledge"&&(Ae.dataset.questTarget="knowledge-hub"),xe.id==="bulletin"&&(Ae.dataset.questTarget="bulletin-board"),xe.id==="stats"&&(Ae.dataset.questTarget="stats-btn"),xe.id==="settings"&&(Ae.dataset.questTarget="settings-btn"),xe.id==="theme"&&(Ae.dataset.questTarget="theme-btn"),Ae.textContent=`${xe.icon} ${xe.label}`,Ae.style.borderColor=`${xe.color}44`;const ze=ve[xe.id];ze&&Ae.addEventListener("click",ze),Ae.addEventListener("mouseenter",()=>{ki=xe.id}),Ae.addEventListener("mouseleave",()=>{ki=null}),fe.appendChild(Ae)}const Q=document.createElement("div");Q.className="td-nametag td-nametag-mascot",Q.dataset.role="mascot";const Z=document.createElement("span");Z.className="td-dot",Z.style.background="#ffd700",Q.appendChild(Z),Q.appendChild(document.createTextNode("Pupu")),Q.addEventListener("click",()=>k==null?void 0:k()),fe.appendChild(Q)},[Se,e,n,c,d,f,m,h,x,g,k,E]);const Xe=v.useCallback(()=>{var ze;const fe=V.current;if(!fe)return;const be=L.current,ve=X.current,{getRoleSpeech:Q,roleStatuses:Z,activeExecs:Ee}=ae.current;for(const $e of Object.keys(ve)){const Le=ve[$e],Ye=kn[$e];if(!Ye)continue;let st,Ke,Re;Le.state==="sitting"?(st=Ye.dx+13,Re=Ye.dy+2,Ke=Ye.dy+37):(st=Math.round(Le.x)+6,Re=Math.round(Le.y)-2,Ke=Math.round(Le.y)+18);const Ie=st/Je.canvasW*100,Lt=fe.querySelector(`.td-nametag[data-role="${$e}"]`);if(Lt){Lt.style.left=Ie+"%",Lt.style.top=Ke*be+2+"px";const Et=Lt.querySelector(".td-dot");if(Et){const Gt=Wn(Z[$e]);Et.style.background=Gt?"#FBBF24":Pu[$e]??"#8b949e",Gt?Et.style.animation="td-pulse 1s ease-in-out infinite":Et.style.animation=""}}const Vt=fe.querySelector(`.td-bubble[data-role="${$e}"]`);if(Vt){const Et=Date.now(),Gt=Wn(Z[$e]),dn=(ze=Ee.find(Kt=>Kt.roleId===$e))==null?void 0:ze.task,En=Q($e);let ee="";const He=te.current[$e];if(He){if(He.speechDismissTime&&Et>=He.speechDismissTime&&(He.currentSpeech=null,He.speechDismissTime=null),He.hoverStartTime&&!He.currentSpeech){const Kt=Et-He.hoverStartTime,ke=!He.lastSpeechTime||Et-He.lastSpeechTime>=5e3;if(Kt>=2e3&&ke){const St=e8($e,H),jn=St[Math.floor(Math.random()*St.length)];He.currentSpeech=jn,He.lastSpeechTime=Et,He.speechDismissTime=Et+3e3}}ee=He.currentSpeech||""}const lt=Gt&&dn?dn.slice(0,60):ee?ee.slice(0,60):En?En.slice(0,60):"";lt&&Le.state==="sitting"?(Vt.style.display="",Vt.style.left=Ie+"%",Vt.style.top=(Re-10)*be+"px",Vt.textContent=lt):Vt.style.display="none"}}const xe=fe.querySelector(".td-nametag-mascot"),Ae=_.current;if(xe&&Ae){const $e=Ae.dir==="left"||Ae.dir==="right",Le=Math.round(Ae.x)+($e?6:4),Ye=Math.round(Ae.y)+($e?7:10);xe.style.left=Le/Je.canvasW*100+"%",xe.style.top=Ye*be+2+"px"}for(const $e of Ea){const Le=fe.querySelector(`.td-facility-label[data-facility="${$e.id}"]`);if(Le){const Ye=Lv($e);Le.style.left=Ye.cx/Je.canvasW*100+"%",Le.style.top=Ye.botY*be-4+"px",Le.classList.toggle("td-facility-label--hover",ki===$e.id)}}},[]),rt=v.useCallback(fe=>{const be=F.current;if(!be)return null;const ve=be.getBoundingClientRect(),Q=L.current,Z=(fe.clientX-ve.left)/Q,Ee=(fe.clientY-ve.top)/Q,xe=X.current;for(const[ze,$e]of Object.entries(kn)){if(!xe[ze])continue;const Le=xe[ze];if(Le.state==="sitting"){if(Z>=$e.dx&&Z<=$e.dx+26&&Ee>=$e.dy&&Ee<=$e.dy+40)return{type:"role",id:ze}}else if(Z>=Le.x-2&&Z<=Le.x+14&&Ee>=Le.y-2&&Ee<=Le.y+20)return{type:"role",id:ze}}const Ae=_.current;if(Ae){const ze=Ae.dir==="left"||Ae.dir==="right",$e=ze?13:9,Le=ze?7:10;if(Z>=Ae.x&&Z<=Ae.x+$e&&Ee>=Ae.y&&Ee<=Ae.y+Le)return{type:"mascot",id:"mascot"}}for(const ze of Ea){const $e=$v(ze);if(Z>=$e.x&&Z<=$e.x+$e.w&&Ee>=$e.y&&Ee<=$e.y+$e.h)return{type:"facility",id:ze.id}}return null},[]),De=v.useCallback(fe=>{const be=F.current;if(!be)return{mx:0,my:0};const ve=be.getBoundingClientRect(),Q=L.current;return{mx:(fe.clientX-ve.left)/Q,my:(fe.clientY-ve.top)/Q}},[]),We=v.useCallback(fe=>{ye.updatePreferences(fe).catch(()=>{})},[]),Ot=v.useCallback(fe=>{const be=Y.current.some(Q=>Q.id===fe),ve={};if(be){const Q=Y.current.filter(Z=>Z.id!==fe);Y.current=Q,ve.addedFurniture=Q}else{const Q=[...U.current,fe];U.current=Q,ve.removedFurniture=Q}Je=fy(Je,[fe]),Ea=wi(Je),$r=null,fa=null,We(ve)},[We]),yt=v.useCallback((fe,be)=>{if(!Hl||!Na)return;const ve=xy.find(Le=>Le.type===Hl),Q=(ve==null?void 0:ve.price)??0;if(Q>0&&N<Q)return;let Z=null;for(const[Le,Ye]of Object.entries(Je.rooms)){const st=Na==="wall"?Ye.wx:Ye.fx,Ke=Na==="wall"?Ye.wy:Ye.fy,Re=Na==="wall"?Ye.ww:Ye.fw,Ie=Na==="wall"?Ye.wh:Ye.fh;if(fe>=st&&fe<=st+Re&&be>=Ke&&be<=Ke+Ie){Z=Le;break}}if(!Z)return;const Ee=Je.rooms[Z],xe=Na==="wall"?Ee.wx:Ee.fx,Ae=Na==="wall"?Ee.wy:Ee.fy,ze={id:`user-${Hl}-${Date.now()}`,type:Hl,room:Z,zone:Na,offsetX:Math.round(fe-xe),offsetY:Math.round(be-Ae)},$e=[...Y.current,ze];if(Y.current=$e,Na==="wall"?Je.wallDecorations.push(ze):Je.furniture.push(ze),Ea=wi(Je),We({addedFurniture:$e}),z==null||z(Hl,Q),Q>0){const Le=ze.type;Fy(async()=>{const{api:Ye}=await Promise.resolve().then(()=>Mw);return{api:Ye}},void 0).then(({api:Ye})=>{Ye.spendCoins(Q,`furniture: ${Le}`,ze.id).then(st=>C==null?void 0:C(st.balance)).catch(()=>{})})}q(null),de(null)},[We,N,C,z]),bt=v.useCallback(fe=>{const be=F.current;if(ll&&lr){const{mx:xe,my:Ae}=De(fe),$e=[...Je.furniture,...Je.wallDecorations].find(st=>st.id===lr.defId);if(!$e)return;const Le=xe-lr.startMx,Ye=Ae-lr.startMy;$e.offsetX=Math.round(lr.origOffX+Le),$e.offsetY=Math.round(lr.origOffY+Ye),Ea=wi(Je),be&&(be.style.cursor="grabbing");return}if(ll&&Hn){const{mx:xe,my:Ae}=De(fe),ze=kn[Hn.roleId];if(!ze)return;ze.dx=Math.round(Hn.origDx+(xe-Hn.startMx)),ze.dy=Math.round(Hn.origDy+(Ae-Hn.startMy));const $e=X.current[Hn.roleId];$e&&($e.homeX=ze.dx+8,$e.homeY=ze.dy+34),be&&(be.style.cursor="grabbing");return}if(ll){const{mx:xe,my:Ae}=De(fe);if(Hl){be&&(be.style.cursor="crosshair");return}const ze=new Set(Object.values(kn).map(Le=>Le.room)),$e=Hh(Je,xe,Ae,ze);if($e)fa=$e;else{const Le=py(kn,xe,Ae);fa=Le?`desk:${Le}`:null}Jn=null,ki=null,be&&(be.style.cursor=fa?"grab":"default");return}const ve=rt(fe),Q=Jn;Jn=(ve==null?void 0:ve.type)==="role"?ve.id:null,ki=(ve==null?void 0:ve.type)==="facility"?ve.id:null,Ci=(ve==null?void 0:ve.type)==="mascot",fa=null,be&&(be.style.cursor=ve?"pointer":"default");const{mx:Z}=De(fe);Iv=Z;const Ee=Date.now();if(Jn&&Jn!==Q){te.current[Jn]||(te.current[Jn]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const xe=te.current[Jn];xe.hoverStartTime=Ee}else if(!Jn&&Q){const xe=te.current[Q];xe&&(xe.hoverStartTime=null)}},[rt,De]),jt=v.useCallback(fe=>{if(!ll)return;const{mx:be,my:ve}=De(fe);if(Hl){yt(be,ve),fe.preventDefault();return}const Q=new Set(Object.values(kn).map(xe=>xe.room)),Z=Hh(Je,be,ve,Q);if(Z){const Ae=[...Je.furniture,...Je.wallDecorations].find(ze=>ze.id===Z);Ae&&($r=Z,lr={defId:Z,startMx:be,startMy:ve,origOffX:Ae.offsetX,origOffY:Ae.offsetY},fe.preventDefault());return}const Ee=py(kn,be,ve);if(Ee){const xe=kn[Ee];$r=`desk:${Ee}`,Hn={roleId:Ee,startMx:be,startMy:ve,origDx:xe.dx,origDy:xe.dy},fe.preventDefault();return}$r=null},[De,yt]),qe=v.useCallback(fe=>{if(lr){const ve=[...Je.furniture,...Je.wallDecorations].find(Q=>Q.id===lr.defId);if(ve){const Q={...me.current,[ve.id]:{offsetX:ve.offsetX,offsetY:ve.offsetY}};me.current=Q,We({furnitureOverrides:Q}),Ea=wi(Je)}lr=null,F.current&&(F.current.style.cursor="grab");return}if(Hn){const be=kn[Hn.roleId];if(be){const ve={...D.current,[Hn.roleId]:{dx:be.dx,dy:be.dy}};D.current=ve,We({deskOverrides:ve})}Hn=null,F.current&&(F.current.style.cursor="grab")}},[We]),at=v.useCallback(fe=>{if(!ll)return;fe.preventDefault();const{mx:be,my:ve}=De(fe),Q=new Set(Object.values(kn).map(Ee=>Ee.room)),Z=Hh(Je,be,ve,Q);Z&&Ot(Z)},[De,Ot]);v.useEffect(()=>{const fe=be=>{!ll||!$r||(be.key==="Delete"||be.key==="Backspace")&&($r.startsWith("desk:")||Ot($r))};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[Ot]);const pt=v.useCallback(()=>{if(lr){const be=[...Je.furniture,...Je.wallDecorations].find(ve=>ve.id===lr.defId);be&&(be.offsetX=lr.origOffX,be.offsetY=lr.origOffY,Ea=wi(Je)),lr=null}if(Hn){const fe=kn[Hn.roleId];fe&&(fe.dx=Hn.origDx,fe.dy=Hn.origDy);const be=X.current[Hn.roleId];be&&(be.homeX=fe.dx+8,be.homeY=fe.dy+34),Hn=null}Jn=null,ki=null,Ci=!1,fa=null,F.current&&(F.current.style.cursor="default")},[]),zt=v.useCallback(fe=>{if(ll)return;const be=rt(fe);if(be){if(be.type==="role"){const ve=X.current[be.id],Q=kn[be.id];if(ve&&Q){const Z=ve.state==="sitting"?Q.dx+13:Math.round(ve.x)+6,Ee=ve.state==="sitting"?Q.dy+2:Math.round(ve.y)-2;b8(Z,Ee)}o(be.id);return}if(be.type==="mascot"){const ve=_.current;ve&&y8(Math.round(ve.x)+4,Math.round(ve.y)-2),k==null||k();return}switch(be.id){case"meeting":{const ve=n[0];ve?c(ve.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}}},[rt,o,c,d,f,m,h,x,g]);return l.jsxs("div",{className:`td-scene${W?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:I,className:"td-wrap",children:[l.jsx("canvas",{ref:F,width:Je.canvasW,height:Je.canvasH,className:"td-canvas",onClick:zt,onMouseDown:jt,onMouseUp:qe,onMouseMove:bt,onMouseLeave:pt,onContextMenu:at}),l.jsx("div",{ref:V,className:"td-overlay"})]}),W&&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${W?" td-edit-btn--active":""}`,"data-quest-target":"edit-btn",onClick:()=>{ne(fe=>{const be=!fe;return be||(q(null),de(null)),be}),$r=null,lr=null,Hn=null},title:W?"Exit Edit Mode":"Edit Furniture Layout",children:[l.jsx("span",{className:"td-edit-btn__icon",children:W?"✓":"✎"}),l.jsx("span",{className:"td-edit-btn__label",children:W?"DONE":"EDIT"})]}),W&&l.jsx("div",{className:"td-palette",children:xy.map(fe=>{const be=fe.price===0||N>=fe.price,ve=fe.price===0?"Free":`${fe.price>=1e3?`${(fe.price/1e3).toFixed(fe.price%1e3===0?0:1)}K`:fe.price}`;return l.jsxs("button",{className:`td-palette__item${K===fe.type?" td-palette__item--active":""}${be?"":" td-palette__item--locked"}`,onClick:()=>{be&&(K===fe.type?(q(null),de(null)):(q(fe.type),de(fe.zone)))},title:`${fe.label} — ${ve}`,style:be?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:fe.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:fe.price===0?"#4CAF50":be?"#FFD54F":"#EF5350"},children:ve})]},fe.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 w8({role:e,appearance:n,onSave:a,onReset:i,onClose:o,theme:c,onThemeChange:d,onUpdateName:f,initialTab:m,characterOnly:h,speechSettings:x,onSpeechSettingsChange:g,language:w,onLanguageChange:b,roleLevel:j,coinBalance:k,purchased:E,onPurchase:N}){var ne;const[C,z]=v.useState(m??"character"),[T,H]=v.useState({...n}),[F,I]=v.useState(e.name),[V,X]=v.useState(!1),_=v.useCallback(()=>H(gs(j)),[j]),$=v.useCallback(()=>{const K=ep(e.id);H({...K}),i()},[e.id,i]),L=v.useCallback(async()=>{a(T);const K=F.trim();if(f&&K&&K!==e.name){X(!0);try{await f(e.id,K)}catch{}X(!1)}o()},[T,a,o,F,e.name,e.id,f]),W=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," –"]}),f?l.jsx("input",{value:F,onChange:K=>I(K.target.value),disabled:V,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:()=>z("character"),children:"CHARACTER"}),!h&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${C==="office"?"active":""}`,onClick:()=>z("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${C==="settings"?"active":""}`,onClick:()=>z("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:o,children:"X"})]}),C==="character"?l.jsx("div",{className:"customize-body",children:l.jsx(jv,{roleId:e.id,appearance:T,onChange:H,onRandomize:_,onReset:$,label:W,roleLevel:j,coinBalance:k,purchased:E,onPurchase:N})}):C==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(ul).map(([K,q])=>l.jsxs("button",{className:`customize-theme-card ${c===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: $",((ne=x==null?void 0:x.dailyBudgetUsd)==null?void 0:ne.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 ${(w??"auto")===K?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(w??"auto")===K?"rgba(255,255,255,0.08)":"transparent",color:(w??"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:L,children:"SAVE"})]})]})})}function vy(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"),c=e.some(f=>f.status==="M");return`${o&&!c?"add":"update"}: ${i.join(", ")}`}function wy(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 k8({onInitGit:e,onDelegate:n,delegateRoleName:a}){const[i,o]=v.useState(!1),[c,d]=v.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=c&&!c.ok&&c.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"}),!c&&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"]})]})]}),c&&c.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:c.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"]})]})]}),c&&!c.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:c.message})]})}function j8({repo:e,onConnected:n,onDelegate:a,delegateRoleName:i}){const[o,c]=v.useState("idle"),[d,f]=v.useState(null),[m,h]=v.useState(""),[x,g]=v.useState("private"),[w,b]=v.useState(""),[j,k]=v.useState(null),[E,N]=v.useState(!1),C=async()=>{c("checking"),k(null);try{const F=await ye.getGithubStatus(e);f(F),F.hasRemote?n():F.ghInstalled&&F.authenticated?c("ready"):c("idle")}catch{c("idle")}},z=async()=>{if(m.trim()){N(!0),k(null);try{const F=await ye.githubCreateRepo(m.trim(),x,e);k(F),F.ok&&setTimeout(n,1500)}catch(F){k({ok:!1,message:F instanceof Error?F.message:"Failed"})}finally{N(!1)}}},T=async()=>{if(w.trim()){N(!0),k(null);try{const F=await ye.addRemote(w.trim(),e);k(F),F.ok&&setTimeout(n,1500)}catch(F){k({ok:!1,message:F instanceof Error?F.message:"Failed"})}finally{N(!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:()=>c("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:()=>c("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:()=>c("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:F=>h(F.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:F=>g(F.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:z,disabled:E||!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:E?"CREATING...":"CREATE & PUSH"}),l.jsx("button",{onClick:()=>c("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:w,onChange:F=>b(F.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:T,disabled:E||!w.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:E?"ADDING...":"ADD REMOTE & PUSH"}),l.jsx("button",{onClick:()=>{c("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 S8({status:e,history:n,onClose:a,onSave:i,onLoadHistory:o,onRestore:c,saving:d,onDelegate:f,delegateRoleName:m,repo:h,onRepoChange:x,syncInfo:g,onPull:w,pulling:b,onRefresh:j,onInitGit:k}){const[E,N]=v.useState("save"),[C,z]=v.useState(""),[T,H]=v.useState(null),[F,I]=v.useState(!1),[V,X]=v.useState(null),[_,$]=v.useState(null),L=v.useRef(null);v.useEffect(()=>{E==="history"&&o()},[E,o]),v.useEffect(()=>{var D;(D=L.current)==null||D.focus()},[]);const W=[...((e==null?void 0:e.modified)??[]).map(D=>({status:"M",file:D})),...((e==null?void 0:e.untracked)??[]).map(D=>({status:"A",file:D}))],ne=v.useRef(!1);v.useEffect(()=>{!ne.current&&W.length>0&&!C&&(z(vy(W)),ne.current=!0)},[W.length]),v.useEffect(()=>{ne.current=!1,z(""),$(null),X(null),H(null)},[h]);const K=v.useCallback(()=>{z(vy(W))},[W]),q=async()=>{H(null),X(null);try{const D=await i(C||void 0);X(D),z("")}catch(D){H(D instanceof Error?D.message:"Save failed")}},ie=async()=>{$(null),H(null);try{const D=await w();$(D)}catch(D){H(D instanceof Error?D.message:"Pull failed")}},de=async D=>{if(confirm(`Restore from commit ${D.slice(0,7)}? This creates a new commit with those files.`)){I(!0);try{await c(D),I(!1)}catch(U){H(U instanceof Error?U.message:"Restore failed"),I(!1)}}};v.useEffect(()=>{const D=U=>{U.key==="Escape"&&a()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[a]);const me=D=>{D.key==="Enter"&&(D.metaKey||D.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:me,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(D=>l.jsx("button",{onClick:()=>x(D),className:"flex-1 py-1.5 text-[10px] font-bold uppercase tracking-wider cursor-pointer",style:{background:h===D?"var(--hud-bg-alt)":"transparent",color:h===D?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:h===D?"2px solid var(--accent)":"2px solid transparent"},children:D==="akb"?"AKB":"CODE"},D))}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["save","history"].map(D=>l.jsx("button",{onClick:()=>N(D),className:"flex-1 py-2 text-[11px] font-bold uppercase tracking-wider cursor-pointer",style:{background:E===D?"var(--hud-bg-alt)":"transparent",color:E===D?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:E===D?"2px solid var(--accent)":"2px solid transparent"},children:D==="save"?"SAVE":"HISTORY"},D))}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[E==="save"&&l.jsxs(l.Fragment,{children:[(e==null?void 0:e.noGit)&&l.jsx(k8,{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:ie,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"})]}),_&&l.jsx("div",{className:"text-[11px] p-2",style:{background:_.status==="ok"||_.status==="up-to-date"?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${_.status==="ok"||_.status==="up-to-date"?"var(--active-green)":"#D32F2F"}`,color:_.status==="ok"||_.status==="up-to-date"?"var(--active-green)":"#EF5350"},children:_.message}),l.jsx("div",{className:"text-[11px]",style:{color:"var(--terminal-text-secondary)"},children:W.length>0?l.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",W.length," unsaved change",W.length>1?"s":""]}):l.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),W.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:W.map(({status:D,file:U})=>l.jsxs("div",{className:"flex gap-2",children:[l.jsx("span",{style:{color:D==="A"?"var(--active-green)":"var(--idle-amber)",width:"14px"},children:D}),l.jsx("span",{style:{color:"var(--terminal-text-secondary)"},children:U})]},U))})]}),W.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:L,type:"text",value:C,onChange:D=>z(D.target.value),placeholder:"Auto-generated — edit if needed",className:"w-full px-3 py-2 text-[12px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}})]}),W.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 D=W.map(U=>`${U.status} ${U.file}`).join(`
|
|
97
|
+
`);f(D)},disabled:d,className:"py-2.5 px-4 text-[11px] font-bold uppercase tracking-wider cursor-pointer disabled:opacity-50",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"2px solid var(--pixel-border)"},title:`Delegate to ${m??"AI role"} — they'll review, commit, push & merge`,children:["🤖"," ",(m==null?void 0:m.toUpperCase())??"DELEGATE"]})]}),e&&!e.hasRemote&&!e.noGit&&l.jsx(j8,{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}),V&&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! ",V.filesChanged," file",V.filesChanged>1?"s":""," committed",V.pushed?" & pushed":"",V.pushError?` (push error: ${V.pushError})`:""]}),T&&l.jsx("div",{className:"text-[11px] p-2",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:T}),(e==null?void 0:e.lastCommit)&&l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:["Last save: ",e.lastCommit.message," (",wy(e.lastCommit.date),")"]})]}),E==="history"&&l.jsxs(l.Fragment,{children:[n.length===0&&l.jsx("div",{className:"text-[11px] text-center py-8",style:{color:"var(--terminal-text-muted)"},children:"No save history"}),l.jsx("div",{className:"space-y-1",children:n.map(D=>l.jsxs("div",{className:"flex items-center justify-between py-2 px-3 group",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--accent)"},children:D.shortSha}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:D.message})]}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:wy(D.date)})]}),l.jsx("button",{onClick:()=>de(D.sha),disabled:F,className:"text-[10px] font-bold px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--idle-amber)"},children:"LOAD"})]},D.sha))})]})]})]})]})}function C8({onClose:e}){const[n,a]=v.useState(null),[i,o]=v.useState(!0),[c,d]=v.useState(null),[,f]=v.useState(!1);return v.useEffect(()=>{Promise.all([ye.getCompanyStats(),ye.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..."}):c||!n?l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[c||"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(N8,{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 N8({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:ky(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:ky(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 ky(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 A8({onClose:e,onSyncComplete:n}){const[a,i]=v.useState([]),[o,c]=v.useState([]),[d,f]=v.useState(!0),[m,h]=v.useState(null),[x,g]=v.useState(new Set),[w,b]=v.useState(null),[j,k]=v.useState(null),E=v.useCallback(async()=>{f(!0),b(null);try{const{roles:C}=await ye.getSyncRoles();i(C);const z=C.filter(T=>T.source.sync!=="off");if(z.length===0){c([]),k(null);return}try{const T=await kr.syncCheck(z.map(F=>({roleId:F.roleId,sourceId:F.source.id,currentVersion:F.source.upstream_version??F.source.forked_at??"0.0.0"})));k(!0);const H=[];for(const F of T.updates){if(!F.hasUpdate)continue;const I=z.find(L=>L.roleId===F.roleId);if(!I)continue;const{character:V}=await kr.syncPull(F.sourceId),X=[];I.persona.trim()!==V.persona.trim()&&X.push({field:"persona",local:I.persona.slice(0,120)+(I.persona.length>120?"...":""),upstream:V.persona.slice(0,120)+(V.persona.length>120?"...":"")});const _=JSON.stringify(I.authority),$=JSON.stringify(V.authority);_!==$&&X.push({field:"authority",local:`${I.authority.autonomous.length} autonomous, ${I.authority.needsApproval.length} approval`,upstream:`${V.authority.autonomous.length} autonomous, ${V.authority.needsApproval.length} approval`}),X.length>0&&H.push({roleId:F.roleId,roleName:I.name,sourceId:F.sourceId,currentVersion:F.currentVersion,latestVersion:F.latestVersion,fields:X})}c(H)}catch{k(!1),c([])}}catch(C){b(C instanceof Error?C.message:"Failed to check for updates")}finally{f(!1)}},[]);v.useEffect(()=>{E()},[E]);const N=async C=>{h(C.roleId);try{const{character:z,version:T}=await kr.syncPull(C.sourceId);await ye.applySyncUpdate({roleId:C.roleId,changes:{persona:z.persona,authority:z.authority},upstreamVersion:T}),g(H=>new Set(H).add(C.roleId)),n==null||n()}catch(z){b(z instanceof Error?z.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:E,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."}),w&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:w}),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:()=>N(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(z=>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:z.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",{}),z.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",{}),z.upstream]})]})]},z.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 D8({onClose:e}){const[n,a]=v.useState(null),[i,o]=v.useState(!0),[c,d]=v.useState(null),[f,m]=v.useState(null),h=v.useCallback(async()=>{o(!0),d(null);try{const C=await ye.getGitStatus();a(C)}catch(C){d(C instanceof Error?C.message:"Failed to load git status")}finally{o(!1)}},[]);v.useEffect(()=>{h()},[h]);const x=async C=>{m(C.path);try{await ye.deleteWorktree(C.path),await h()}catch(z){d(z instanceof Error?z.message:"Failed to remove worktree")}finally{m(null)}},g=async C=>{m(C);try{await ye.deleteBranch(C),await h()}catch(z){d(z instanceof Error?z.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(c&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[c,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const w=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 z=C.split("/");if(z.length>1){const T=z[z.length-1],H=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const F of H)if(T.toLowerCase().includes(F))return F}return null}function E(C,z=40){return C.length<=z?C:"..."+C.slice(C.length-z+3)}function N(C){const z=Date.now()-new Date(C).getTime(),T=Math.floor(z/6e4);if(T<1)return"just now";if(T<60)return`${T}m ago`;const H=Math.floor(T/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:"×"})]})]}),c&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:c}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},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?"...":""," · ",N(n.lastCommit.date)]})]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Fu,{label:"Active Worktrees",count:w.length}),w.map(C=>l.jsx(Xh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:E,timeAgo:N,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(Xh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:E,timeAgo:N,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(Xh,{wt:C,roleFromBranch:C.roleId||k(C.branch),truncatePath:E,timeAgo:N,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))]}),w.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," · ",N(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 Xh({wt:e,roleFromBranch:n,truncatePath:a,timeAgo:i,removing:o,onRemove:c,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:c,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 T8({onClose:e}){const[n,a]=v.useState(null),[i,o]=v.useState(!0),[c,d]=v.useState(null),[f,m]=v.useState(null),h=v.useCallback(async()=>{o(!0),d(null);try{const k=await ye.getActiveSessions();a(k)}catch(k){d(k instanceof Error?k.message:"Failed to load sessions")}finally{o(!1)}},[]);v.useEffect(()=>{h();const k=setInterval(h,1e4);return()=>clearInterval(k)},[h]);const x=async k=>{m(k);try{await ye.deleteActiveSession(k),await h()}catch(E){d(E instanceof Error?E.message:"Failed to remove session")}finally{m(null)}},g=async()=>{try{await ye.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(c&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[c,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const w=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:"×"})]})]}),c&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:c}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13,display:"flex",justifyContent:"space-between"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Sessions: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.active})]}),l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Ports in use: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.totalPorts})]})]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Wh,{label:"Active",count:w.length}),w.map(k=>l.jsx(Gh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#4FC3F7"},k.sessionId))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Wh,{label:"Idle",count:b.length}),b.map(k=>l.jsx(Gh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#FFB74D"},k.sessionId))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Wh,{label:"Dead",count:j.length}),j.map(k=>l.jsx(Gh,{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 Wh({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 F8(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 Gh({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.messageStatus&&l.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)"},children:e.messageStatus})]}),e.task&&l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:4},children:['"',e.task.slice(0,60),e.task.length>60?"...":"",'"']}),l.jsxs("div",{style:{fontSize:11,display:"flex",gap:8,marginBottom:2},children:[l.jsxs("span",{style:{color:"#81C784"},children:["API:",o.api||"?"]}),l.jsxs("span",{style:{color:"#64B5F6"},children:["Vite:",o.vite||"?"]}),o.hmr&&l.jsxs("span",{style:{color:"#FFB74D"},children:["HMR:",o.hmr]})]}),l.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[e.sessionId.slice(0,12),"...",e.worktreePath&&l.jsxs(l.Fragment,{children:[" · ",R8(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" · ","PID:",e.pid]})," · ",F8(e.startedAt)]})]}),l.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0,marginLeft:8},children:[o.vite&&l.jsx("button",{onClick:()=>window.open(`http://localhost:${o.vite}`,"_blank"),style:{background:"rgba(100,200,255,0.15)",border:"1px solid rgba(100,200,255,0.2)",color:"#64B5F6",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:"pointer",fontWeight:600,textTransform:"uppercase",letterSpacing:.5},title:`Open http://localhost:${o.vite}`,children:"OPEN"}),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},children:n?"...":"STOP"})]})]})})}function R8(e,n=35){return e.length<=n?e:"..."+e.slice(e.length-n+3)}function M8({onClose:e,speechSettings:n,onSpeechSettingsChange:a,language:i,onLanguageChange:o,onOpenSync:c,onOpenGitStatus:d,onOpenSessions:f,onOpenStats:m}){var ie;const[h,x]=v.useState(null),[g,w]=v.useState(null),[b,j]=v.useState(!1),[k,E]=v.useState(!1),[N,C]=v.useState(!1),[z,T]=v.useState(null),[H,F]=v.useState(""),[I,V]=v.useState(!1),[X,_]=v.useState(!1),[$,L]=v.useState(null),[W,ne]=v.useState(!1);v.useEffect(()=>{ye.getPreferences().then(async de=>{const me=de;if(x(me.instanceId??null),me.instanceId)try{const{name:D}=await kr.getMyName(me.instanceId);w(D)}catch{}}).catch(()=>{}),ye.getCodeRoot().then(({codeRoot:de})=>{T(de),de&&F(de)}).catch(()=>{})},[]);const K=async()=>{C(!0);try{const me=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();me.ok&&(x(me.newInstanceId),E(!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:de=>de.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(de=>l.jsxs("button",{onClick:()=>a==null?void 0:a({mode:de}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(n==null?void 0:n.mode)===de?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(n==null?void 0:n.mode)===de?"rgba(255,255,255,0.08)":"transparent",color:(n==null?void 0:n.mode)===de?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:de==="template"?"TEMPLATE":de==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:de==="template"?"Static pool ($0)":de==="llm"?"LLM generated":"Detect engine"})]},de))}),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:de=>a==null?void 0:a({intervalSec:Number(de.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: $",((ie=n==null?void 0:n.dailyBudgetUsd)==null?void 0:ie.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(n==null?void 0:n.dailyBudgetUsd)??1,onChange:de=>a==null?void 0:a({dailyBudgetUsd:Number(de.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:de,label:me})=>l.jsx("button",{onClick:()=>o==null?void 0:o(de),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(i??"auto")===de?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(i??"auto")===de?"rgba(255,255,255,0.08)":"transparent",color:(i??"auto")===de?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:me},de))}),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:de=>{F(de.target.value),L(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()){_(!0),L(null);try{const de=await ye.setCodeRoot(H.trim());T(de.codeRoot),F(de.codeRoot),V(!1),ne(!0),setTimeout(()=>ne(!1),3e3)}catch(de){L(de instanceof Error?de.message:"Failed to set code root")}finally{_(!1)}}},disabled:X||!H.trim(),style:{padding:"8px 12px",fontSize:10,fontWeight:600,background:"var(--accent)",border:"none",color:"#fff",borderRadius:6,cursor:"pointer",opacity:X||!H.trim()?.5:1},children:X?"...":"Save"}),l.jsx("button",{onClick:()=>{V(!1),F(z||""),L(null)},style:{padding:"8px 10px",fontSize:10,background:"transparent",border:"1px solid rgba(255,255,255,0.1)",color:"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer"},children:"Cancel"})]}),$&&l.jsx("div",{style:{fontSize:9,color:"#ff6b6b",marginTop:4},children:$})]}):l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l.jsx("code",{style:{flex:1,padding:"8px 10px",fontSize:10,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:z?"var(--terminal-text)":"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z||"Not configured"}),l.jsx("button",{onClick:()=>{V(!0),L(null),ne(!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"})]}),W&&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:N,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:N?"...":"Confirm Regenerate"}),l.jsx("button",{onClick:()=>E(!1),style:{padding:"4px 12px",fontSize:9,border:"none",background:"transparent",color:"var(--terminal-text-muted)",cursor:"pointer"},children:"Cancel"})]})]}):l.jsx("button",{onClick:()=>E(!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:[c&&l.jsx("button",{onClick:()=>{e(),c()},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:de=>de.currentTarget.style.color="var(--accent)",onMouseLeave:de=>de.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile →"})})]})})]})})}function z8({theme:e,onThemeChange:n,onClose:a}){const i=v.useRef(null);return v.useEffect(()=>{const o=c=>{i.current&&!i.current.contains(c.target)&&a()};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[a]),l.jsx("div",{ref:i,className:"theme-dropup",children:Object.entries(ul).map(([o,c])=>l.jsxs("button",{className:`theme-dropup__item${e===o?" theme-dropup__item--active":""}`,onClick:()=>{n(o),a()},title:c.name,children:[l.jsxs("span",{className:"theme-dropup__swatch",style:{background:c.vars["--hud-bg"],borderColor:c.vars["--pixel-border"]},children:[l.jsx("span",{style:{background:c.vars["--accent"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:c.vars["--active-green"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:c.vars["--idle-amber"],width:5,height:5,borderRadius:1}})]}),l.jsx("span",{className:"theme-dropup__name",children:c.icon})]},o))})}const bs={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function _8({roles:e,roleStatuses:n,activeExecs:a,sessions:i,knowledgeDocs:o,roleLevels:c,companyName:d,getAppearance:f,waveCenterWaves:m,renderProfile:h,channel:x,onChannelChange:g,onClose:w,children:b}){const[j,k]=v.useState(!1),E=m.filter(I=>I.rootDispatches.some(V=>{const X=n[V.roleId];return X==="working"||X==="thinking"})),N=[...e].sort((I,V)=>I.level==="c-level"&&V.level!=="c-level"?-1:I.level!=="c-level"&&V.level==="c-level"?1:I.name.localeCompare(V.name)),C=e.filter(I=>Wn(n[I.id])).length,z=i.filter(I=>I.status==="active").length,T=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"?(T==null?void 0:T.name)??x.roleId:"Dashboard",F=x.type==="terminal"?`${z} active sessions`:x.type==="wave"?`${E.length} running`:x.type==="knowledge"?`${o.length} documents`:x.type==="role"?(T==null?void 0:T.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"]})]}),E.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:["⚡"," ",E[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:[E[0].rootDispatches.filter(I=>{const V=n[I.roleId];return V==="working"||V==="thinking"}).length,"/",E[0].rootDispatches.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:z||void 0,active:x.type==="terminal",onClick:()=>g({type:"terminal"})}),l.jsx(Ru,{icon:"⚡",label:"Waves",live:E.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"}),N.map(I=>{var W;const V=n[I.id],X=a.find(ne=>ne.roleId===I.id),_=bs[I.id]??"#666",$=(W=c[I.id])==null?void 0:W.level,L=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:L?`${_}18`:"transparent",borderLeft:L?`2px solid ${_}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx(Wl,{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(V)?"#4CAF50":V==="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,$!=null&&l.jsxs("span",{className:"ml-1 opacity-40 text-[8px]",children:["Lv.",$]})]}),X?l.jsx("div",{className:"text-[9px] truncate",style:{color:_},children:X.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(V)&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:_}})]},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 V=e.find($=>$.id===I.roleId),X=bs[I.roleId]??"#666",_=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:_?`${X}18`:"transparent"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:X}}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text, #fff5eb)"},children:(V==null?void 0:V.name)??I.roleId}),l.jsx("div",{className:"text-[8px] truncate",style:{color:"var(--terminal-text-muted)"},children:I.task.slice(0,40)})]})]},I.sessionId??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:w,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"&&T&&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:`${bs[T.id]??"#666"}30`},title:"View profile",children:[l.jsx(Wl,{roleId:T.id,appearance:f(T.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[T.id])?"#4CAF50":n[T.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:F}),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 B8({role:e,messages:n,isStreaming:a,mode:i,onModeChange:o,onSend:c,isWave:d}){const f=bs[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsx(Sv,{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(tp,{mode:i,onModeChange:o,onSend:(m,h)=>c(m,i,h),disabled:a,disabledReason:a?`${e.id.toUpperCase()} is responding...`:void 0})]})}function O8({role:e,onSend:n,getAppearance:a,onOpenProfile:i}){const[o,c]=v.useState("talk"),d=bs[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(Wl,{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(tp,{mode:o,onModeChange:c,onSend:f=>n(f,o),disabled:!1})]})}function Ru({icon:e,label:n,active:a,badge:i,live:o,onClick:c}){return l.jsxs("button",{onClick:c,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 $8({roles:e,roleStatuses:n,activeExecs:a,waves:i,knowledgeDocs:o,roleLevels:c,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(jy,{label:"New Wave",icon:"⚡",color:"#EF4444",onClick:m}),l.jsx(jy,{label:"Knowledge",icon:"📚",color:"#0D9488",onClick:h})]}),x.length>0&&l.jsx(Mu,{title:"Currently Working",count:x.length,children:a.map(g=>{const w=e.find(j=>j.id===g.roleId),b=bs[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(Wl,{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:w==null?void 0:w.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 w=n[g.id]??"offline",b=(j=c[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(w)?"#4CAF50":w==="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 w;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]})," — ",(w=g.directive)==null?void 0:w.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 jy({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 Cm=5e4;function Hv(e){return e<Cm?1:Math.max(1,Math.floor(Math.sqrt(e/Cm)))}function Sy(e){return Cm*e*e}function L8(e){const n=Hv(e),a=Sy(n),i=Sy(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:Hv(o),totalTokens:o,progress:L8(o)}}return n}const I8=[{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 Cy(e){return I8.filter(n=>n.check(e))}const Ny={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function H8({importReq:e,onImportDone:n}){var cc,uc,Hs,dc,fc;const[a,i]=v.useState([]),[o,c]=v.useState([]),[d,f]=v.useState([]),[m,h]=v.useState([]),[x,g]=v.useState([]),[w,b]=v.useState([]),[j,k]=v.useState("TYCONO"),[E,N]=v.useState(!0),[C,z]=v.useState(null),[T,H]=v.useState({type:"none"}),[F,I]=v.useState(null),[V,X]=v.useState(null),[_,$]=v.useState([]),[L,W]=v.useState(!1),[ne,K]=v.useState(!1),[q,ie]=v.useState([]),[de,me]=v.useState([]),[D,U]=v.useState(0),[Y,R]=v.useState(!1),[O,ae]=v.useState({}),[te,Se]=v.useState("ceo"),[je,_e]=v.useState(null),[Oe,Xe]=v.useState(!1),[rt,De]=v.useState(!1),[We,Ot]=v.useState({}),yt=v.useRef({}),[bt,jt]=v.useState(!1),[qe,at]=v.useState(null),[pt,zt]=v.useState({}),[fe,be]=v.useState([]),ve=v.useMemo(()=>{const A={};for(const P of fe)A[P.roleId]=P;return A},[fe]),[Q,Z]=v.useState([]),[Ee,xe]=v.useState(0),[Ae,ze]=v.useState(Vg()),$e=v.useRef(Vg()),Le=v.useRef(!1),Ye=v.useRef(-1),[st,Ke]=v.useState(null),Re=v.useRef(null),[Ie,Lt]=v.useState(void 0),[Vt,Et]=v.useState(!1);v.useEffect(()=>{ye.getStatus().then(A=>{Lt(A.engine),Et(!!A.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:Gt,setAppearance:dn,resetAppearance:En,theme:ee,setTheme:He,speechSettings:lt,setSpeechSettings:Kt,language:ke,setLanguage:St,purchasedItems:jn,addPurchasedItem:hn}=H6(),[le,Be]=v.useState(null),[,Pe]=v.useState("character"),Ze=Y6(),[vn,Gn]=v.useState(!1),[gn,mn]=v.useState(!1),[Ur,Pl]=v.useState(!1),[Ts,Ti]=v.useState(!1),[Jo,ma]=v.useState(!1),[aa,fl]=v.useState([]),[hl,Ba]=v.useState(!1),[Oa,Sn]=v.useState(!1),[Sr,ec]=v.useState(null);v.useEffect(()=>{Ze.refresh()},[]),v.useEffect(()=>{const A=P=>{(P.metaKey||P.ctrlKey)&&P.key==="s"&&(P.preventDefault(),Gn(!0))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[]),v.useEffect(()=>{if(!Ts)return;let A=!1;const P=async()=>{try{const pe=await ye.getGitStatus();A||ec(pe)}catch{}};P();const oe=setInterval(P,1e4);return()=>{A=!0,clearInterval(oe)}},[Ts]),v.useEffect(()=>{let A=!1;const P=async()=>{try{const pe=await ye.getActiveSessions();A||fl(pe.sessions)}catch{}};P();const oe=setInterval(P,5e3);return()=>{A=!0,clearInterval(oe)}},[]);const[fr,pa]=v.useState(null),[ml,$a]=v.useState(null),[La,tc]=v.useState([]),[la,Ql]=v.useState(!1),qr=v.useRef(!1),er=v.useRef(null);let Fs=v.useRef(0);const nc=v.useRef(new Set),Rs=v.useRef(Date.now()),xa=(A,P,oe)=>{const pe={id:Fs.current++,type:A,text:P,detail:oe};tc(Ne=>[...Ne,pe])};v.useEffect(()=>{var A;la&&((A=er.current)==null||A.scrollIntoView({behavior:"smooth"}))},[La,la]),v.useEffect(()=>{e&&(qr.current||(qr.current=!0,$a("Scanning knowledge sources..."),tc([{id:0,type:"scan",text:"Starting knowledge import..."}]),Fs.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 A=>{var Ne;const P=(Ne=A.body)==null?void 0:Ne.getReader();if(!P)return;const oe=new TextDecoder;let pe="";for(;;){const{done:Ue,value:It}=await P.read();if(Ue)break;pe+=oe.decode(It,{stream:!0});const ot=pe.split(`
|
|
98
|
+
`);pe=ot.pop()||"";let et="";for(const ct of ot)if(ct.startsWith("event: "))et=ct.slice(7).trim();else if(ct.startsWith("data: ")&&et){try{const ft=JSON.parse(ct.slice(6));switch(et){case"scanning":$a(`Scanning: ${ft.path} (${ft.fileCount} files)`),xa("scan",`Found ${ft.fileCount} files`,ft.path);break;case"processing":pa({index:ft.index,total:ft.total}),$a(`Importing knowledge... (${ft.index}/${ft.total})`),xa("process",`Processing: ${ft.file}`,`${ft.index} / ${ft.total}`);break;case"created":xa("created",ft.title,ft.summary);break;case"skipped":xa("process",`Skipped: ${ft.file}`,ft.reason);break;case"done":$a(null),pa(null),xa("done",`Import complete! ${ft.created} created, ${ft.skipped} skipped.`),vt(`Knowledge import complete! ${ft.created} documents imported.`,"#2E7D32"),n==null||n();break;case"error":$a(null),pa(null),xa("error",ft.message),vt(`Import failed: ${ft.message}`,"#B71C1C"),n==null||n();break}}catch{}et=""}}}).catch(A=>{$a(null),xa("error",A.message),vt(`Import error: ${A.message}`,"#B71C1C"),n==null||n()})))},[e]);const[hr,ia]=v.useState("iso"),An=v.useRef("iso"),[Cr,$n]=v.useState({type:"dashboard"}),[Fi,pl]=v.useState(typeof window<"u"?window.innerWidth:1200);v.useEffect(()=>{const A=()=>pl(window.innerWidth);return window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]);const Ri=Fi<1024,[Nr,Er]=v.useState(!1),[Ia,rc]=v.useState(560),[Ln,Jt]=v.useState([]),[ga,tr]=v.useState(null),[Ar,Vn]=v.useState(null),{sendMessage:Ms}=$6();v.useEffect(()=>{Promise.all([ye.getCompany().then(A=>{k(A.name),i(A.roles)}),ye.getOrgTree().then(A=>{ae(A.nodes),Se(A.root)}).catch(()=>{}),ye.getCostSummary().then(A=>_i(Vh(A.byRole))).catch(()=>{})]).catch(A=>z(`Failed to load: ${A.message}`)).finally(()=>N(!1)),ye.getProjects().then(c).catch(()=>{}),ye.getStandups().then(f).catch(()=>{}),ye.getWaves().then(h).catch(()=>{}),ye.getDecisions().then(g).catch(()=>{}),ye.getActiveWaves().then(({waves:A})=>{A.length>0&&ie(A.map(P=>({...P,rootDispatches:P.dispatches.map(({sessionId:oe,roleId:pe,roleName:Ne})=>({sessionId:oe,roleId:pe,roleName:Ne}))})))}).catch(()=>{}),ye.getKnowledge().then(b).catch(()=>{}),ye.getQuestProgress().then(A=>{const P=Kg(A);P.activeChapter!==A.activeChapter&&ye.saveQuestProgress(P).catch(()=>{}),ze(P),$e.current=P,Le.current=!0,ye.getCoins().then(oe=>{var pe;oe.totalEarned===0?ye.migrateCoins(((pe=P.completedQuests)==null?void 0:pe.length)??0).then(Ne=>xe(Ne.balance)).catch(()=>{}):xe(oe.balance)}).catch(()=>{})}).catch(()=>{Le.current=!0})},[]),v.useEffect(()=>{if(Ye.current===-1){Ye.current=o.length;return}o.length>Ye.current&&en({type:"project_created"}),Ye.current=o.length},[o.length]);const Mi=v.useRef(!1);v.useEffect(()=>{if(!(!Le.current||a.length===0||Mi.current)){Mi.current=!0;for(const A of a)en({type:"role_hired",condition:{roleId:A.id,roleCount:a.length}})}},[a.length]),v.useEffect(()=>{ye.getSessions().then(A=>{const P=A.filter(pe=>pe.source!=="wave");if(P.length>0){const pe=P.map(Ue=>({...Ue,messages:[]}));Jt(pe);const Ne=pe.find(Ue=>Ue.status==="active")??pe[0];tr(Ne.id),sa()}const oe=A.filter(pe=>pe.source==="wave").map(pe=>pe.id);oe.length>0&&ye.deleteSessions(oe).catch(()=>{})}).catch(A=>{console.error("Failed to load sessions",A)})},[]),v.useEffect(()=>{const A=()=>{fetch("/api/exec/status").then(oe=>oe.json()).then(oe=>{zt(oe.statuses??{}),be(oe.activeExecutions??[])}).catch(()=>{})};A();const P=setInterval(A,3e3);return()=>clearInterval(P)},[]);const Dr=v.useMemo(()=>{const A={...pt};if(Ar){const P=Ln.find(oe=>oe.id===Ar);P&&A[P.roleId]!=="awaiting_input"&&(A[P.roleId]="working")}return A},[pt,Ar,Ln]);v.useEffect(()=>{T.type==="role"?ye.getRole(T.roleId).then(I).catch(console.error):I(null)},[T]);const mr=()=>H({type:"none"}),zs=async(A,P)=>{const oe=await ye.updateDecision(A,P);g(pe=>pe.map(Ne=>Ne.id===A?oe:Ne))},zi=async A=>{await ye.deleteDecision(A),g(P=>P.filter(oe=>oe.id!==A))},nr=A=>{H(A),Er(!1),K(!1)},sa=()=>{Er(!0),H({type:"none"}),K(!1)},pr=()=>{An.current="iso",$n({type:"wave"}),ia("pro"),K(!0),Er(!1),H({type:"none"})},_s=async(A,P)=>{const oe=a.find(Ne=>Ne.id===A),pe=(V==null?void 0:V.mode)==="ask";X(null);try{const Ue=(await ye.execute({type:"assign",roleId:A,task:P,readOnly:pe})).sessionId,It=Ny[A]??"#666",ot=`${A.toUpperCase()} · ${(oe==null?void 0:oe.name)??A}`;R(!1),$([{sessionId:Ue,title:ot,color:It}]),en({type:"task_executed",condition:{roleId:A}}),tn.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(oe==null?void 0:oe.name)??A}] ${pe?"Ask":"Assign"}: ${P}`,type:"dispatch",targetRoleId:A})}catch(Ne){vt(`Failed to execute: ${Ne instanceof Error?Ne.message:"unknown"}`,"#C62828")}},Zl=v.useRef(0),vt=(A,P)=>{const oe=++Zl.current;Z(pe=>[...pe,{id:oe,message:A,color:P}]),setTimeout(()=>Z(pe=>pe.filter(Ne=>Ne.id!==oe)),4e3)},Bs=A=>{Re.current&&clearTimeout(Re.current),Ke(A),Re.current=setTimeout(()=>Ke(null),8e3)},en=A=>{if(!Le.current)return;let P=$e.current;const oe=pv(P);let pe=0;const Ne=[];for(const It of oe){if(!IE(It,A))continue;const{progress:ot,quest:et}=$E(P,It.id);et&&(P=ot,pe+=et.rewards.coins??0,Ne.push(et.title))}if(Ne.length===0)return;P=Kg(P),$e.current=P,ze(P);const Ue=pe>0?` 💰 +${pe.toLocaleString()}`:"";Ne.length===1?vt(`📋 Quest complete: ${Ne[0]}${Ue}`,"#7C3AED"):vt(`📋 ${Ne.length} quests complete!${Ue}`,"#7C3AED"),Ke(null),ye.saveQuestProgress(P).catch(()=>{}),pe>0&&ye.earnCoins(pe,`quests: ${Ne.length}`,Ne.join(",")).then(It=>xe(It.balance)).catch(()=>{})};v.useEffect(()=>{if(!st)return;const A=document.querySelector(`[data-quest-target="${st}"]`);if(!A)return;A.classList.add("quest-spotlight");const P=()=>{A.classList.remove("quest-spotlight"),Ke(null),Re.current&&clearTimeout(Re.current)};return A.addEventListener("click",P,{once:!0}),()=>{A.classList.remove("quest-spotlight"),A.removeEventListener("click",P)}},[st]);const _i=A=>{var oe,pe;const P=yt.current;for(const[Ne,Ue]of Object.entries(A)){const It=((oe=P[Ne])==null?void 0:oe.level)??0;if(It>0&&Ue.level>It){const ot=((pe=a.find(et=>et.id===Ne))==null?void 0:pe.name)??Ne.toUpperCase();vt(`${ot} leveled up to Lv.${Ue.level}!`,"#7C3AED")}}yt.current=A,Ot(A)};v.useEffect(()=>{const A={roles:Object.entries(We).map(([Ne,Ue])=>({id:Ne,level:Ue.level,totalTokens:Ue.totalTokens})),totalTokens:Object.values(We).reduce((Ne,Ue)=>Ne+Ue.totalTokens,0),roleCount:a.length,completedQuests:Ae.completedQuests},P=Cy(A),oe=new Set(P.map(Ne=>Ne.id));if(Date.now()-Rs.current>5e3){const Ne=nc.current;for(const Ue of P)Ne.has(Ue.id)||vt(`${Ue.icon} Badge earned: ${Ue.name}!`,"#D4A017")}nc.current=oe},[We,a.length,Ae.completedQuests]);const ya=v.useMemo(()=>OE(Ae),[Ae]),Bi=()=>{var P;const A=_[_.length-1];A&&(vt(`${A.title} completed`,A.color),tn.pushMessage({ts:Date.now(),roleId:((P=A.title.split(" · ")[0])==null?void 0:P.toLowerCase())??"unknown",text:`[${A.title}] Completed`,type:"dispatch"})),ye.getStandups().then(f).catch(console.error),ye.getCompany().then(oe=>i(oe.roles)).catch(console.error),ye.getCostSummary().then(oe=>_i(Vh(oe.byRole))).catch(()=>{})},Yr=v.useRef(new Map),rr=A=>{if(Yr.current.has(A))return;const P=new AbortController;Yr.current.set(A,P),Vn(oe=>oe??A),fetch(`/api/sessions/${A}/stream?from=0`,{signal:P.signal}).then(async oe=>{var It,ot;if(!oe.ok||!oe.body)return;const pe=oe.body.getReader(),Ne=new TextDecoder;let Ue="";for(;;){const{done:et,value:ct}=await pe.read();if(et)break;Ue+=Ne.decode(ct,{stream:!0});const ft=Ue.split(`
|
|
99
|
+
`);Ue=ft.pop()??"";let Pt="";for(const va of ft)if(va.startsWith("event: "))Pt=va.slice(7).trim();else if(va.startsWith("data: ")){try{const Ct=JSON.parse(va.slice(6));Pt==="stream:end"?(Jt(on=>on.map(Yt=>{if(Yt.id!==A)return Yt;const Fn=Yt.messages.map(wn=>wn.status==="streaming"?{...wn,status:"done"}:wn);return{...Yt,messages:Fn}})),Vn(on=>on===A?null:on),Yr.current.delete(A)):Pt==="activity"&&(Ct.type==="text"&&((It=Ct.data)!=null&&It.text)?Jt(on=>on.map(Yt=>{if(Yt.id!==A)return Yt;const Fn=[...Yt.messages],wn=Fn[Fn.length-1];return(wn==null?void 0:wn.from)==="role"&&wn.status==="streaming"&&(Fn[Fn.length-1]={...wn,content:wn.content+Ct.data.text}),{...Yt,messages:Fn}})):Ct.type==="thinking"&&((ot=Ct.data)!=null&&ot.text)?Jt(on=>on.map(Yt=>{if(Yt.id!==A)return Yt;const Fn=[...Yt.messages],wn=Fn[Fn.length-1];return(wn==null?void 0:wn.from)==="role"&&wn.status==="streaming"&&(Fn[Fn.length-1]={...wn,thinking:(wn.thinking??"")+Ct.data.text}),{...Yt,messages:Fn}})):(Ct.type==="msg:done"||Ct.type==="msg:error")&&(Jt(on=>on.map(Yt=>{if(Yt.id!==A)return Yt;const Fn=Yt.messages.map(wn=>wn.status==="streaming"?{...wn,status:Ct.type==="msg:done"?"done":"error"}:wn);return{...Yt,messages:Fn}})),Vn(on=>on===A?null:on),Yr.current.delete(A)))}catch{}Pt=""}}}).catch(()=>{Yr.current.delete(A),Vn(oe=>oe===A?null:oe)})},oa=async(A,P,oe)=>{W(!1);try{const pe=await ye.execute({type:"wave",directive:A,targetRoles:P,...oe&&{attachments:oe}});en({type:"wave_dispatched"});const Ne=pe.waveId??`wave-${Date.now()}`,Ue=pe.sessionIds??[],It=te&&O[te]?O[te].children.map(Ct=>a.find(on=>on.id===Ct)).filter(Ct=>!!Ct):a.filter(Ct=>Ct.level==="c-level"),ot=P?It.filter(Ct=>P.includes(Ct.id)):It,et=Ue.map((Ct,on)=>{var Yt,Fn;return{roleId:((Yt=ot[on])==null?void 0:Yt.id)??`role-${on}`,roleName:((Fn=ot[on])==null?void 0:Fn.name)??`C-Level ${on+1}`,sessionId:Ct}});tn.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${A}" → ${et.map(Ct=>Ct.roleName).join(", ")}`,type:"dispatch"});const ct={id:Ne,directive:A,rootDispatches:et.map(({roleId:Ct,roleName:on,sessionId:Yt})=>({roleId:Ct,roleName:on,sessionId:Yt})),startedAt:Date.now(),sessionIds:Ue};ie(Ct=>[ct,...Ct]),pr();const ft=new Date().toISOString(),va=et.map(Ct=>({id:Ct.sessionId,roleId:Ct.roleId,title:`WAVE: ${Ct.roleName}`,mode:"do",source:"wave",messages:[{id:`msg-${Ct.sessionId}-ceo`,from:"ceo",content:A,type:"directive",status:"done",timestamp:ft}],status:"active",createdAt:ft,updatedAt:ft})).map((Ct,on)=>({...Ct,messages:[...Ct.messages,{id:`msg-${et[on].sessionId}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:ft}]}));Jt(Ct=>[...va,...Ct]);for(const Ct of va)rr(Ct.id)}catch(pe){vt(`Failed to start wave: ${pe instanceof Error?pe.message:"unknown"}`,"#C62828")}},Xr=()=>{ye.getWaves().then(h).catch(console.error),ye.getStandups().then(f).catch(console.error)},Ha=()=>{ye.getCompany().then(A=>i(A.roles)).catch(console.error),ye.getOrgTree().then(A=>{ae(A.nodes),Se(A.root)}).catch(console.error),ye.getCostSummary().then(A=>_i(Vh(A.byRole))).catch(()=>{})},ld=async(A,P)=>{await ye.createRole(A),dn(A.id,P),Ha(),vt(`${A.name} hired!`,"#2E7D32"),en({type:"role_hired",condition:{roleId:A.id,roleCount:a.length+1}})},Os=async A=>{var P;await ye.deleteRole(A),Ha(),Jt(oe=>oe.filter(pe=>pe.roleId!==A)),ga&&((P=Ln.find(oe=>oe.id===ga))==null?void 0:P.roleId)===A&&tr(null),at(null),vt(`${A.toUpperCase()} removed`,"#B71C1C")},Jl=async(A,P)=>{await ye.updateRole(A,P),Ha(),T.type==="role"&&T.roleId===A&&ye.getRole(A).then(I).catch(console.error),P.name&&vt(`${A.toUpperCase()} renamed to "${P.name}"`,"#1565C0"),P.persona!==void 0&&(vt(`${A.toUpperCase()} persona updated`,"#2E7D32"),en({type:"persona_updated"}))},ei=A=>{sa(),en({type:"terminal_opened"})},ti=async A=>{try{const P=await ye.createSession(A,"talk");Jt(oe=>[P,...oe]),tr(P.id),sa()}catch(P){console.error("Failed to create session",P),vt(`Failed to create session: ${P instanceof Error?P.message:"API unreachable"}`,"#B71C1C")}},$s=async A=>{try{const P=await ye.createSession(A,"talk");Jt(oe=>[P,...oe]),tr(P.id)}catch(P){console.error("Failed to create session",P),vt(`Failed to create session: ${P instanceof Error?P.message:"API unreachable"}`,"#B71C1C")}},id=async A=>{const P=ve[A],oe=(P==null?void 0:P.sessionId)??(P==null?void 0:P.id);if(oe&&Wn(Dr[A])){const Ne=a.find(ct=>ct.id===A),Ue=Ny[A]??"#666",It=`${A.toUpperCase()} · ${(Ne==null?void 0:Ne.name)??A}`,ot=Ln.find(ct=>ct.roleId===A&&ct.status==="active"),et=(ot==null?void 0:ot.id)??oe;$([{sessionId:et,title:It,color:Ue}]),R(!1);return}const pe=Ln.find(Ne=>Ne.roleId===A);if(pe)tr(pe.id),tn.setActiveChannelId(null);else try{const Ne=await ye.createSession(A,"talk");Jt(Ue=>[Ne,...Ue]),tr(Ne.id),tn.setActiveChannelId(null)}catch(Ne){console.error("Failed to create session",Ne)}sa()},ac=async A=>{const P=Ln.find(oe=>oe.id===A);if((P==null?void 0:P.source)==="wave"){{const oe=Yr.current.get(P.id);oe&&(oe.abort(),Yr.current.delete(P.id))}Jt(oe=>{var Ne;const pe=oe.filter(Ue=>Ue.id!==A);return ga===A&&tr(((Ne=pe[0])==null?void 0:Ne.id)??null),pe});return}try{await ye.deleteSession(A),Jt(oe=>{var Ne;const pe=oe.filter(Ue=>Ue.id!==A);return ga===A&&tr(((Ne=pe[0])==null?void 0:Ne.id)??null),pe})}catch(oe){console.error("Failed to delete session",oe),vt(`Failed to close session: ${oe instanceof Error?oe.message:"API error"}`,"#B71C1C")}},lc=async()=>{try{const{ids:A}=await ye.deleteEmptySessions();if(A.length===0)return;Jt(P=>{var pe;const oe=P.filter(Ne=>!A.includes(Ne.id));return ga&&A.includes(ga)&&tr(((pe=oe[0])==null?void 0:pe.id)??null),oe}),vt(`Cleared ${A.length} empty session${A.length!==1?"s":""}`,"#2E7D32")}catch(A){vt(`Failed to clear empty sessions: ${A instanceof Error?A.message:"API error"}`,"#B71C1C")}},Oi=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const A=Ln.filter(P=>P.source!=="wave").map(P=>P.id);for(const P of Ln)if(P.source==="wave"){const oe=Yr.current.get(P.id);oe&&(oe.abort(),Yr.current.delete(P.id))}try{A.length>0&&await ye.deleteSessions(A),Jt([]),tr(null),vt("All sessions closed","#2E7D32")}catch(P){vt(`Failed to close sessions: ${P instanceof Error?P.message:"API error"}`,"#B71C1C")}},ba=(A,P)=>{Jt(oe=>oe.map(pe=>{if(pe.id!==A)return pe;const Ne=[...pe.messages],Ue=Ne[Ne.length-1];if(Ue&&Ue.from==="role"&&Ue.status==="streaming"){const It=[...Ue.streamEvents??[],P];Ne[Ne.length-1]={...Ue,streamEvents:It}}return{...pe,messages:Ne}}))},Ua=(A,P,oe,pe)=>{const Ne={id:`msg-${Date.now()}-ceo`,from:"ceo",content:P,type:oe==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:pe},Ue={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};Jt(ot=>ot.map(et=>et.id===A?{...et,messages:[...et.messages,Ne,Ue],updatedAt:new Date().toISOString()}:et));const It=Ln.find(ot=>ot.id===A);oe==="talk"?en({type:"talk_mode_used"}):oe==="do"&&(en({type:"do_mode_used"}),It&&en({type:"task_executed",condition:{roleId:It.roleId}})),Vn(A),Ms(A,P,oe,{onThinking:ot=>{Jt(et=>et.map(ct=>{if(ct.id!==A)return ct;const ft=[...ct.messages],Pt=ft[ft.length-1];return Pt&&Pt.from==="role"&&Pt.status==="streaming"&&(ft[ft.length-1]={...Pt,thinking:(Pt.thinking??"")+ot}),{...ct,messages:ft}})),ba(A,{type:"thinking",timestamp:Date.now(),text:ot})},onText:ot=>{Jt(et=>et.map(ct=>{if(ct.id!==A)return ct;const ft=[...ct.messages],Pt=ft[ft.length-1];return Pt&&Pt.from==="role"&&Pt.status==="streaming"&&(ft[ft.length-1]={...Pt,content:Pt.content+ot}),{...ct,messages:ft}}))},onToolUse:(ot,et)=>{ba(A,{type:"tool",timestamp:Date.now(),toolName:ot,toolInput:et})},onDispatch:(ot,et)=>{ba(A,{type:"dispatch",timestamp:Date.now(),roleId:ot,task:et})},onDispatchProgress:(ot,et,ct)=>{var ft;et==="tool"?ba(A,{type:"dispatch:progress",timestamp:Date.now(),roleId:ot,progressType:"tool",toolName:ct.name,toolInput:ct.input}):et==="thinking"?ba(A,{type:"dispatch:progress",timestamp:Date.now(),roleId:ot,progressType:"thinking",text:ct.text}):et==="text"?ba(A,{type:"dispatch:progress",timestamp:Date.now(),roleId:ot,progressType:"text",text:(ft=ct.text)==null?void 0:ft.slice(-200)}):(et==="done"||et==="error")&&ba(A,{type:"dispatch:progress",timestamp:Date.now(),roleId:ot,progressType:et})},onTurn:ot=>{ba(A,{type:"turn",timestamp:Date.now(),turn:ot})},onDone:()=>{Jt(ot=>ot.map(et=>{if(et.id!==A)return et;const ct=et.messages.map(Pt=>Pt.status==="streaming"?{...Pt,status:"done"}:Pt),ft=et.messages.length<=2?P.slice(0,40).replace(/\n/g," "):et.title;return{...et,messages:ct,title:ft}})),Vn(null)},onError:ot=>{Jt(et=>et.map(ct=>{if(ct.id!==A)return ct;const ft=ct.messages.map(Pt=>Pt.status==="streaming"?{...Pt,status:"error",content:Pt.content||ot}:Pt);return{...ct,messages:ft}})),Vn(null)}},pe)},Ls=(A,P)=>{Jt(oe=>oe.map(pe=>pe.id===A?{...pe,mode:P}:pe)),ye.updateSession(A,{mode:P}).catch(console.error)},sd=new Date().toISOString().slice(0,10),ic=o[0],Is={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},od=A=>{const P=Is[A];if(!P)return"";for(const oe of d){const pe=oe.content,Ne=pe.indexOf(`## ${P}`);if(Ne===-1)continue;const Ue=pe.indexOf(`
|
|
100
|
+
## `,Ne+10),ot=(Ue===-1?pe.slice(Ne):pe.slice(Ne,Ue)).split(`
|
|
101
|
+
`).filter(et=>et.trim().length>0);for(const et of ot){const ct=et.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(ct.startsWith("|")||ct.startsWith("{")||ct.startsWith("[")||ct.startsWith("```")||ct.startsWith("---")||ct.includes("Journal")||ct.includes("(c-level)")||ct.includes("(team-lead)")||ct.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(ct))&&ct.length>15&&ct.length<120)return ct}}return""},sc=A=>{const P=Is[A];if(!P)return"";for(const oe of d){const pe=oe.content,Ne=pe.indexOf(`## ${P}`);if(Ne===-1)continue;const Ue=pe.indexOf(`
|
|
102
|
+
## `,Ne+10),ot=(Ue===-1?pe.slice(Ne):pe.slice(Ne,Ue)).replace(/^## .+\n/,"").trim();if(ot)return ot.slice(0,1500)}return""},tn=aA();v.useEffect(()=>{a.length>0&&tn.syncDefaultMembers(a)},[a]);const $i=J6({roles:a,roleStatuses:pt,activeExecs:fe,getStandupSpeech:od}),Li=oA({roles:a,roleStatuses:pt,activeExecs:fe,channels:tn.channels,relationships:$i.relationships,pushMessage:tn.pushMessage,speechSettings:lt,engineType:Ie,hasApiKey:Vt}),oc=v.useCallback((A,P)=>{tn.pushMessage({ts:Date.now(),roleId:"ceo",text:P,type:"chat",channelId:A}),Li.triggerCeoReaction(A)},[tn,Li]);return E?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(ml||La.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:()=>Ql(A=>!A),children:[ml?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:ml||"Knowledge import finished"}),fr&&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:`${fr.index/fr.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:la?"▲":"▼"})]}),la&&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:[La.map(A=>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:[A.type==="scan"&&"🔍",A.type==="process"&&"⚙️",A.type==="created"&&"✅",A.type==="done"&&"🎉",A.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:A.type==="error"?"#EF4444":A.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:A.text}),A.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:A.detail})]})]},A.id)),l.jsx("div",{ref:er})]})]}),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 A=Ee>=1e6?`${(Ee/1e6).toFixed(1)}M`:Ee>=1e3?`${(Ee/1e3).toFixed(1)}K`:String(Ee),P=fe.length,oe=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:A})]}),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:`${oe}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:oe})]})]})})(),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})]}),fe.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:fe.length})]}),(()=>{const A={roles:Object.entries(We).map(([oe,pe])=>({id:oe,level:pe.level,totalTokens:pe.totalTokens})),totalTokens:Object.values(We).reduce((oe,pe)=>oe+pe.totalTokens,0),roleCount:a.length},P=Cy(A);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(oe=>l.jsx("span",{title:`${oe.name}: ${oe.description}`,style:{fontSize:12,cursor:"default"},children:oe.icon},oe.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:sd})]})]}),(ml||La.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:()=>Ql(A=>!A),children:[ml?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:ml||"Knowledge import finished"}),fr&&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:`${fr.index/fr.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:la?"▲":"▼"})]}),la&&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:[La.map(A=>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:[A.type==="scan"&&"🔍",A.type==="process"&&"⚙️",A.type==="created"&&"✅",A.type==="done"&&"🎉",A.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:A.type==="error"?"#EF4444":A.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:A.text}),A.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:A.detail})]})]},A.id)),l.jsx("div",{ref:er}),La.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(v8,{roles:a,projects:o,waves:m,standups:d,decisions:x,roleStatuses:Dr,activeExecs:fe,onRoleClick:A=>nr({type:"role",roleId:A}),onProjectClick:A=>nr({type:"project",projectId:A}),onBulletinClick:()=>{nr({type:"bulletin"}),en({type:"bulletin_visited"})},onDecisionsClick:()=>nr({type:"decisions"}),onKnowledgeClick:()=>{nr({type:"knowledge"}),en({type:"knowledge_visited"})},onSettingsClick:()=>{Ba(!0),en({type:"settings_visited"})},onThemeClick:()=>Sn(A=>!A),onStatsClick:()=>{mn(!0),en({type:"stats_visited"})},knowledgeDocsCount:w.length,getRoleSpeech:$i.getSpeech,getAppearance:Gt,onHireClick:()=>jt(!0),onMascotClick:()=>nr({type:"quest"}),roleLevels:We,language:ke,coinBalance:Ee,onCoinsSpent:A=>xe(A),onFurniturePlaced:(A,P)=>{en({type:"furniture_placed"}),P>0&&en({type:"furniture_purchased"})}})}),Nr&&l.jsx("div",{className:Ri?"absolute inset-0 z-50":"contents",children:l.jsx(ty,{sessions:Ln,activeSessionId:ga,roles:a,streamingSessionId:Ar,width:Ri?Fi:Ia,onWidthChange:Ri?void 0:rc,onSwitchSession:tr,onCloseSession:ac,onCreateSession:ti,onClearEmpty:lc,onCloseAll:Oi,onSendMessage:Ua,onModeChange:Ls,onStopSession:A=>ye.abortSession(A).catch(()=>{}),onCloseTerminal:()=>Er(!1),onMaximize:()=>{An.current="iso",$n({type:"terminal"}),ia("pro")},chatChannels:tn.channels,activeChatChannelId:tn.activeChannelId,onSwitchChatChannel:tn.setActiveChannelId,onCreateChatChannel:(...A)=>{const P=tn.createChannel(...A);return en({type:"chat_channel_created"}),P},onDeleteChatChannel:tn.deleteChannel,onUpdateChatMembers:tn.updateMembers,onUpdateChatTopic:tn.updateTopic,onSendChatMessage:oc,unreadChannels:tn.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:()=>ia("iso"),className:`view-toggle-btn ${hr==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{An.current="iso",ia("pro")},className:`view-toggle-btn ${hr==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${Oa?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>Sn(A=>!A),title:"Office Theme",children:[((cc=ul[ee])==null?void 0:cc.icon)??"","▾"]}),Oa&&l.jsx(z8,{theme:ee,onThemeChange:A=>{He(A),en({type:"theme_changed"})},onClose:()=>Sn(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>Ba(!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"?Gn(!0):Ti(!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"}),Sr&&(Sr.worktrees.length>0||Sr.staleBranches.length>0)&&l.jsxs("span",{style:{color:Sr.worktrees.some(A=>A.status==="stale")?"#ff6b6b":Sr.worktrees.some(A=>A.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["·"," ","📂"," ",Sr.worktrees.length," worktree",Sr.worktrees.length!==1?"s":"",Sr.staleBranches.length>0&&` · ⚠ ${Sr.staleBranches.length} branch${Sr.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[q.length>0&&!ne&&l.jsx("button",{onClick:()=>pr(),className:`px-3 py-1 font-black text-white cursor-pointer ${rt?"":"animate-pulse"}`,style:{background:rt?"#2E7D32":"#B71C1C",border:`2px solid ${rt?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:rt?"WAVE DONE":`WAVE (${q.length})`}),je&&Oe&&q.length===0&&l.jsx("button",{onClick:()=>Xe(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${rt?"":"animate-pulse"}`,style:{background:rt?"#2E7D32":"#B71C1C",border:`2px solid ${rt?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:rt?"WAVE DONE":"WAVE"}),_.length>0&&Y&&l.jsxs("button",{onClick:()=>R(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:_[_.length-1].color,border:`2px solid ${_[_.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[_[_.length-1].title.slice(0,20),_[_.length-1].title.length>20?"..":""]}),aa.length>0&&l.jsxs("button",{onClick:()=>ma(!0),className:"px-2 py-1 font-black cursor-pointer text-[10px]",style:{background:"var(--hud-bg-alt)",color:aa.some(A=>A.messageStatus==="awaiting_input")?"#FFB74D":aa.some(A=>A.messageStatus==="streaming")?"#4FC3F7":"var(--terminal-text-muted)",border:"2px solid var(--pixel-border)",fontFamily:"var(--pixel-font)",borderRadius:4},title:`${aa.length} active session${aa.length!==1?"s":""}`,children:["🔄"," ",aa.length," session",aa.length!==1?"s":""]}),l.jsxs("button",{onClick:()=>pr(),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:()=>Nr?Er(!1):ei(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:Nr?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${Nr?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),hr!=="pro"&&T.type==="role"&&F&&(()=>{var P,oe;const A=ve[F.id];return l.jsx(Mg,{role:F,allRoles:a,recentActivity:sc(F.id),onClose:mr,onFireRole:(pe,Ne)=>{at({roleId:pe,roleName:Ne}),mr()},terminalWidth:Nr?Ia:0,activeSessionId:((P=_.find(pe=>pe.sessionId===(A==null?void 0:A.sessionId)))==null?void 0:P.sessionId)??(A==null?void 0:A.sessionId),activeTask:A==null?void 0:A.task,isWorking:Wn(Dr[F.id]),startedAt:A==null?void 0:A.startedAt,onAbortSession:pe=>{ye.abortSession(pe).catch(()=>{})},sessions:Ln,streamingSessionId:Ar,onCreateSessionSilent:$s,onSendMessage:Ua,onFocusTerminal:id,onCustomize:pe=>{const Ne=a.find(Ue=>Ue.id===pe);Ne&&(Pe("character"),Be(Ne))},onUpdateRole:Jl,appearance:Gt(F.id),relationships:$i.relationships,roleLevel:(oe=We[F.id])==null?void 0:oe.level,onMaximize:()=>{An.current="iso",$n({type:"role",roleId:F.id}),ia("pro")}})})(),hr!=="pro"&&T.type==="project"&&ic&&l.jsx(UE,{projectId:ic.id,onClose:mr,terminalWidth:Nr?Ia:0}),hr!=="pro"&&(T.type==="bulletin"||T.type==="decisions")&&l.jsx(Gg,{standups:d,waves:m,decisions:x,mode:T.type==="bulletin"?"bulletin":"decisions",onClose:mr,onOpenWaveCenter:()=>pr(),onUpdateDecision:zs,onDeleteDecision:zi,terminalWidth:Nr?Ia:0,onMaximize:()=>{An.current="iso",$n({type:"operations"}),ia("pro")}}),hr!=="pro"&&T.type==="quest"&&l.jsx(HE,{progress:Ae,onClose:mr,terminalWidth:Nr?Ia:0,onQuestAction:A=>{var oe;mr();const P=ks.find(pe=>pe.id===A);(oe=P==null?void 0:P.hint)!=null&&oe.target&&Bs(P.hint.target)}}),hr!=="pro"&&T.type==="knowledge"&&l.jsx(Wg,{docs:w,onClose:mr,onRefresh:()=>ye.getKnowledge().then(b).catch(()=>{}),terminalWidth:Nr?Ia:0,initialDocId:T.docId,onMaximize:()=>{An.current="iso",$n({type:"knowledge"}),ia("pro")}}),hr==="pro"&&l.jsxs(_8,{roles:a,roleStatuses:Dr,activeExecs:fe,waves:m,knowledgeDocs:w,sessions:Ln,roleLevels:We,companyName:j,getAppearance:Gt,waveCenterWaves:q,renderProfile:Cr.type==="role"&&F?A=>{var oe,pe;const P=ve[F.id];return l.jsx(Mg,{role:F,allRoles:a,recentActivity:sc(F.id),onClose:A,onFireRole:(Ne,Ue)=>{at({roleId:Ne,roleName:Ue})},terminalWidth:0,activeSessionId:((oe=_.find(Ne=>Ne.sessionId===(P==null?void 0:P.sessionId)))==null?void 0:oe.sessionId)??(P==null?void 0:P.sessionId),activeTask:P==null?void 0:P.task,isWorking:Wn(Dr[F.id]),startedAt:P==null?void 0:P.startedAt,onAbortSession:Ne=>{ye.abortSession(Ne).catch(()=>{})},sessions:Ln,streamingSessionId:Ar,onCreateSessionSilent:$s,onSendMessage:Ua,onFocusTerminal:()=>{},onCustomize:Ne=>{const Ue=a.find(It=>It.id===Ne);Ue&&(Pe("character"),Be(Ue))},onUpdateRole:Jl,appearance:Gt(F.id),relationships:$i.relationships,roleLevel:(pe=We[F.id])==null?void 0:pe.level})}:void 0,channel:Cr,onChannelChange:A=>{$n(A),A.type==="role"?nr({type:"role",roleId:A.roleId}):A.type==="knowledge"?nr({type:"knowledge"}):A.type==="operations"?nr({type:"bulletin"}):A.type==="wave"?K(!0):A.type==="terminal"?Er(!0):(H({type:"none"}),K(!1))},onClose:()=>{ia(An.current),H({type:"none"}),K(!1)},children:[Cr.type==="dashboard"&&l.jsx($8,{roles:a,roleStatuses:Dr,activeExecs:fe,waves:m,knowledgeDocs:w,roleLevels:We,getAppearance:Gt,onRoleClick:A=>$n({type:"role",roleId:A}),onWaveClick:()=>$n({type:"wave"}),onKnowledgeClick:()=>$n({type:"knowledge"})}),Cr.type==="terminal"&&l.jsx(ty,{sessions:Ln,activeSessionId:ga,roles:a,streamingSessionId:Ar,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:tr,onCloseSession:ac,onCreateSession:ti,onClearEmpty:lc,onCloseAll:Oi,onSendMessage:Ua,onModeChange:Ls,onStopSession:A=>ye.abortSession(A).catch(()=>{}),onCloseTerminal:()=>$n({type:"dashboard"}),chatChannels:tn.channels,activeChatChannelId:tn.activeChannelId,onSwitchChatChannel:tn.setActiveChannelId,onCreateChatChannel:(...A)=>{const P=tn.createChannel(...A);return en({type:"chat_channel_created"}),P},onDeleteChatChannel:tn.deleteChannel,onUpdateChatMembers:tn.updateMembers,onUpdateChatTopic:tn.updateTopic,onSendChatMessage:oc,unreadChannels:tn.unreadChannels}),Cr.type==="wave"&&l.jsx(Jg,{orgNodes:O,rootRoleId:te,cLevelRoles:te&&O[te]?O[te].children.map(A=>a.find(P=>P.id===A)).filter(A=>!!A):a.filter(A=>A.level==="c-level"),pastWaves:m,activeWaves:q,onDispatch:(A,P)=>oa(A,P),onClose:()=>$n({type:"dashboard"}),onDone:()=>{Xr(),De(!0),vt("Wave complete","#2E7D32")},onSave:async(A,P,oe)=>{try{await ye.saveWave({directive:A,sessionIds:P,waveId:oe==null?void 0:oe.waveId}),Xr(),vt("Wave saved","#2E7D32")}catch(pe){vt(`Save failed: ${pe instanceof Error?pe.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:A=>{$n({type:"knowledge"}),nr({type:"knowledge",docId:A}),ye.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ye.getWaves().then(h).catch(()=>{}),terminalWidth:0,inline:!0,onOpenSaveModal:()=>Gn(!0)}),Cr.type==="knowledge"&&l.jsx(Wg,{docs:w,onClose:()=>$n({type:"dashboard"}),onRefresh:()=>ye.getKnowledge().then(b).catch(()=>{}),terminalWidth:0}),Cr.type==="operations"&&l.jsx(Gg,{standups:d,waves:m,decisions:x,mode:"bulletin",onClose:()=>$n({type:"dashboard"}),onOpenWaveCenter:()=>$n({type:"wave"}),onUpdateDecision:zs,onDeleteDecision:zi,terminalWidth:0}),Cr.type==="role"&&(()=>{const A=Cr.roleId,P=a.find(pe=>pe.id===A);if(!P)return null;const oe=Ln.find(pe=>pe.roleId===A);return oe?l.jsx(B8,{role:P,messages:oe.messages,isStreaming:Ar===oe.id,mode:oe.mode,onModeChange:pe=>Ls(oe.id,pe),onSend:(pe,Ne,Ue)=>Ua(oe.id,pe,Ne,Ue),isWave:oe.source==="wave"}):l.jsx(O8,{role:P,getAppearance:Gt,onSend:async(pe,Ne)=>{try{const Ue=await ye.createSession(A,"talk");Jt(It=>[Ue,...It]),tr(Ue.id),Ua(Ue.id,pe,Ne)}catch(Ue){vt(`Failed to create session: ${Ue instanceof Error?Ue.message:"API unreachable"}`,"#B71C1C")}}})})()]}),V&&l.jsx(XE,{roleId:V.roleId,roleName:V.roleName,mode:V.mode,onClose:()=>X(null),onExecutionStart:_s}),je&&!Oe&&l.jsx(l6,{directive:je.directive,rootDispatches:je.rootDispatches,orgNodes:O,rootRoleId:te,onClose:()=>{_e(null),Xe(!1),De(!1)},onMinimize:()=>Xe(!0),onDone:()=>{Xr(),De(!0),vt("Wave complete","#2E7D32")},onSave:async A=>{try{await ye.saveWave({directive:je.directive,sessionIds:A}),Xr(),vt("Wave saved to bulletin","#2E7D32")}catch(P){vt(`Save failed: ${P instanceof Error?P.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:A=>{_e(null),Xe(!1),De(!1),nr({type:"knowledge",docId:A}),ye.getKnowledge().then(b).catch(()=>{})}}),ne&&hr!=="pro"&&l.jsx(Jg,{orgNodes:O,rootRoleId:te,cLevelRoles:te&&O[te]?O[te].children.map(A=>a.find(P=>P.id===A)).filter(A=>!!A):a.filter(A=>A.level==="c-level"),pastWaves:m,activeWaves:q,onDispatch:(A,P)=>oa(A,P),onClose:()=>K(!1),onMaximize:()=>{An.current="iso",$n({type:"wave"}),ia("pro")},onDone:()=>{Xr(),De(!0),vt("Wave complete","#2E7D32")},onSave:async(A,P,oe)=>{try{await ye.saveWave({directive:A,sessionIds:P,waveId:oe==null?void 0:oe.waveId}),Xr(),vt("Wave saved","#2E7D32")}catch(pe){vt(`Save failed: ${pe instanceof Error?pe.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:A=>{K(!1),nr({type:"knowledge",docId:A}),ye.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ye.getWaves().then(h).catch(()=>{}),terminalWidth:Nr?Ia:0,onOpenSaveModal:()=>Gn(!0)}),_.length>0&&!Y&&(()=>{var oe;const A=_[_.length-1],P=de.length>1;return l.jsxs(l.Fragment,{children:[P&&_.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:de.map((pe,Ne)=>l.jsx("button",{onClick:()=>{U(Ne),$([{sessionId:pe.sessionId,title:`CEO WAVE · ${pe.roleId.toUpperCase()}`,color:"#B71C1C"}])},className:"px-3 py-1.5 text-xs font-bold rounded-t-lg cursor-pointer transition-colors",style:{background:D===Ne?"#B71C1C":"var(--terminal-bg)",color:D===Ne?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${D===Ne?"#B71C1C":"var(--terminal-border)"}`,borderBottom:"none"},children:pe.roleId.toUpperCase()},pe.sessionId))}),l.jsx(WE,{sessionId:A.sessionId,title:_.length>1?A.title:P?`CEO WAVE · ${((oe=de[D])==null?void 0:oe.roleName)??""}`:A.title,color:A.color,variant:"modal",style:P&&_.length===1?{marginTop:28}:void 0,onClose:()=>{const pe=Ln.filter(Ne=>Ne.source==="wave").map(Ne=>Ne.id);pe.length>0&&(Jt(Ne=>Ne.filter(Ue=>Ue.source!=="wave")),ye.deleteSessions(pe).catch(()=>{})),$([]),me([]),U(0),R(!1)},onMinimize:()=>R(!0),onDone:()=>{Bi(),Xr()},onNavigateToSession:()=>{},onOpenKnowledgeDoc:pe=>{$([]),me([]),U(0),R(!1),nr({type:"knowledge",docId:pe}),ye.getKnowledge().then(b).catch(()=>{})}},A.sessionId)]})})(),_.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:()=>$(A=>A.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 ",(uc=_[_.length-2])==null?void 0:uc.title]})})}),L&&l.jsx(PE,{cLevelRoles:te&&O[te]?O[te].children.map(A=>a.find(P=>P.id===A)).filter(A=>!!A):a.filter(A=>A.level==="c-level"),orgNodes:O,rootId:te,onClose:()=>W(!1),onDispatch:(A,P)=>oa(A,P)}),bt&&l.jsx(p6,{existingRoles:a,onClose:()=>jt(!1),onHire:ld,onStoreVisit:()=>en({type:"store_visited"}),questHint:((Hs=ya==null?void 0:ya.hint)==null?void 0:Hs.target)==="hire-btn"?{message:ya.description,roleId:((dc=ya.trigger.condition)==null?void 0:dc.roleId)??void 0}:void 0}),qe&&l.jsx(y6,{roleId:qe.roleId,roleName:qe.roleName,onClose:()=>at(null),onConfirm:Os}),le&&l.jsx(w8,{role:le,appearance:Gt(le.id),onSave:A=>{dn(le.id,A),en({type:"accessory_changed"})},onReset:()=>En(le.id),onClose:()=>{Be(null),Pe("character")},theme:ee,onThemeChange:A=>{He(A),en({type:"theme_changed"})},onUpdateName:async(A,P)=>{await Jl(A,{name:P})},initialTab:"character",characterOnly:!0,speechSettings:lt,onSpeechSettingsChange:Kt,language:ke,onLanguageChange:St,roleLevel:(fc=We[le.id])==null?void 0:fc.level,coinBalance:Ee,purchased:jn,onPurchase:(A,P)=>{ye.spendCoins(P,`Purchased ${A}`,A).then(oe=>{xe(oe.balance),hn(A)}).catch(()=>{})}}),vn&&(()=>{const A=a.find(P=>P.id==="cto")??a.find(P=>P.level==="c-level")??a[0];return l.jsx(S8,{status:Ze.status,history:Ze.history,onClose:()=>Gn(!1),onSave:async P=>{const oe=await Ze.save(P);return oe!=null&&oe.ok&&en({type:"save_committed"}),oe},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:(A==null?void 0:A.name)??(A==null?void 0:A.id),onDelegate:A?async P=>{Gn(!1);try{const oe=await ye.createSession(A.id,"do");Jt(Ne=>[oe,...Ne]),tr(oe.id),sa();const pe=`Review the following unsaved changes, write a proper commit message, save (git add + commit), and push. If the current branch is not the main branch, create a PR and merge it.
|
|
103
|
+
|
|
104
|
+
Changed files:
|
|
105
|
+
${P}`;Ua(oe.id,pe,"do")}catch(oe){vt(`Failed to delegate: ${oe instanceof Error?oe.message:"error"}`,"#B71C1C")}}:void 0})})(),gn&&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:A=>A.stopPropagation(),children:l.jsx(C8,{onClose:()=>mn(!1)})})}),Ur&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Pl(!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:A=>A.stopPropagation(),children:l.jsx(A8,{onClose:()=>Pl(!1),onSyncComplete:()=>{}})})}),hl&&l.jsx(M8,{onClose:()=>Ba(!1),speechSettings:lt,onSpeechSettingsChange:Kt,language:ke,onLanguageChange:St,onOpenSync:()=>Pl(!0),onOpenGitStatus:()=>Ti(!0),onOpenSessions:()=>ma(!0),onOpenStats:()=>mn(!0)}),Ts&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ti(!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:A=>A.stopPropagation(),children:l.jsx(D8,{onClose:()=>Ti(!1)})})}),Jo&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>ma(!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:A=>A.stopPropagation(),children:l.jsx(T8,{onClose:()=>ma(!1)})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:Q.map(A=>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:A.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"}),A.message]},A.id))})]})}function zu({onSelect:e,onClose:n}){const[a,i]=v.useState(null),[o,c]=v.useState(!0),[d,f]=v.useState(""),[m,h]=v.useState(!1),[x,g]=v.useState(!1),w=v.useRef(null),b=v.useCallback(async k=>{c(!0);try{const E=await ye.browse(k);i(E)}catch{}finally{c(!1)}},[]);v.useEffect(()=>{b()},[b]),v.useEffect(()=>{var k;m&&((k=w.current)==null||k.focus())},[m]);const j=async()=>{if(!(!a||!d.trim())){g(!0);try{const k=await ye.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:w,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 U8={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function Ey(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function q8({onComplete:e}){const[n,a]=v.useState(0),[i,o]=v.useState(null),[c,d]=v.useState("none"),[f,m]=v.useState(""),[h,x]=v.useState(!0),[g,w]=v.useState(""),[b,j]=v.useState(""),[k,E]=v.useState("en"),N=v.useRef(null),[C,z]=v.useState("new"),[T,H]=v.useState(""),[F,I]=v.useState(""),[V,X]=v.useState(!1),[_,$]=v.useState(!1),[L,W]=v.useState(!1),[ne,K]=v.useState(""),[q,ie]=v.useState(!1),[de,me]=v.useState(!1),[D,U]=v.useState([]),[Y,R]=v.useState(""),[O,ae]=v.useState(!1),[te,Se]=v.useState(""),[je,_e]=v.useState(null),[Oe,Xe]=v.useState(!1),[rt,De]=v.useState(!1),[We,Ot]=v.useState([]),[yt,bt]=v.useState("startup"),[jt,qe]=v.useState(!1),[at,pt]=v.useState(!1),[zt,fe]=v.useState(null),[be,ve]=v.useState([]),[Q,Z]=v.useState(""),[Ee,xe]=v.useState(!1),[Ae,ze]=v.useState(!1),[$e,Le]=v.useState([]),Ye=v.useMemo(()=>Ey(C),[C]),st=Ye[n]??"engine";v.useEffect(()=>{ye.detectEngine().then(ke=>{o(ke),d(ke.recommended),x(!1)}).catch(()=>x(!1)),ye.getTeams().then(Ot).catch(()=>{}),ye.getStatus().then(ke=>{I(ke.companyRoot||"")}).catch(()=>{})},[]),v.useEffect(()=>{var ke;st==="company"&&((ke=N.current)==null||ke.focus())},[st]),v.useEffect(()=>{if(V||!F)return;const ke=g.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");H(ke?`${F}/${ke}`:F)},[g,F,V]);const Ke=()=>{switch(st){case"engine":return c!=="none"||f.length>10;case"company":return g.trim().length>0;case"workspace":return C==="existing-akb"?je===!0:!0;case"team":return!0;case"create":return!at;default:return!1}},Re=()=>{n<Ye.length-1&&Ke()&&a(n+1),st==="create"&&!jt&&!Ee&&(C==="existing-akb"?En():dn())},Ie=()=>{n>0&&a(n-1)},Lt=v.useRef(C);v.useEffect(()=>{if(Lt.current===C)return;Lt.current=C;const St=Ey(C).indexOf("workspace");St>=0&&a(St)},[C]);const Vt=async()=>{if(te.trim()){Xe(!0);try{const ke=await ye.validatePath(te.trim());_e(ke.valid&&ke.hasClaudeMd===!0)}catch{_e(!1)}finally{Xe(!1)}}},Et=()=>{const ke=Y.trim();ke&&!D.includes(ke)&&(U([...D,ke]),R(""))},Gt=async ke=>{ze(!0),Le([]);try{const{tools:St}=await ye.getRequiredTools(ke);if(St.filter(hn=>!hn.installed).length===0){ze(!1);return}await ye.installTools(ke,(hn,le)=>{const Be=le.tool||"";hn==="checking"?Le(Pe=>[...Pe,{event:hn,tool:Be,detail:"checking..."}]):hn==="installing"?Le(Pe=>[...Pe,{event:hn,tool:Be,detail:"installing..."}]):hn==="installed"?Le(Pe=>[...Pe,{event:hn,tool:Be,detail:"installed"}]):hn==="skipped"?Le(Pe=>[...Pe,{event:hn,tool:Be,detail:le.reason||"skipped"}]):hn==="error"&&Le(Pe=>[...Pe,{event:hn,tool:Be,detail:le.error||"failed"}])})}catch{}finally{ze(!1)}},dn=async()=>{qe(!0),fe(null);try{const ke={companyName:g.trim(),description:b.trim()||"An AI-powered organization",team:yt,knowledgePaths:D.length>0?D:void 0,language:k!=="auto"?k:void 0,location:T.trim()||void 0,codeRoot:ne.trim()||void 0};(c==="direct-api"||f)&&(ke.apiKey=f||void 0);const St=await ye.scaffold(ke);ve(St.created),Z(St.projectRoot),pt(!0),qe(!1),yt!=="custom"&&Gt(yt)}catch(ke){fe(ke instanceof Error?ke.message:"Scaffold failed"),qe(!1)}},En=async()=>{xe(!0),fe(null);try{const ke=await ye.connectAkb(te.trim());ke.ok?(pt(!0),ve([`Connected to: ${ke.companyRoot}`])):fe(ke.error||"Failed to connect")}catch(ke){fe(ke instanceof Error?ke.message:"Connect failed")}finally{xe(!1)}},ee=()=>{D.length>0?e({paths:D,companyRoot:""}):e()},He=ke=>{ke.key==="Enter"&&Ke()&&(ke.preventDefault(),Re())},lt=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
|
|
106
|
+
bg-[var(--terminal-bg)] text-[var(--terminal-text)]
|
|
107
|
+
border border-[var(--terminal-border)]
|
|
108
|
+
focus:border-[var(--terminal-border-hover)]
|
|
109
|
+
placeholder:text-[var(--terminal-text-muted)]`,Kt=ke=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ke?"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:He,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:Ye.map((ke,St)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:St<=n?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:St===n?"var(--terminal-text)":"var(--terminal-text-muted)"},children:U8[ke]})]},ke))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[st==="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(c==="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(c==="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"})]})]}),c==="direct-api"&&!(i!=null&&i.apiKey)&&l.jsx("input",{type:"password",className:`${lt} mt-3`,placeholder:"sk-ant-...",value:f,onChange:ke=>m(ke.target.value),autoFocus:!0})]})]})]}),st==="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:N,className:lt,placeholder:"e.g. Acme Corp",value:g,onChange:ke=>w(ke.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:ke=>j(ke.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:ke=>E(ke.target.value),children:[l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"한국어"}),l.jsx("option",{value:"ja",children:"日本語"})]})]})]}),st==="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(ip,{text:`"New Company" creates a fresh workspace with roles, knowledge base, and project structure.
|
|
110
|
+
|
|
111
|
+
"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:()=>z("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:()=>z("existing-akb"),children:"Connect Existing"})]}),C==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Ay,{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:T,onChange:ke=>{H(ke.target.value),X(!0)}}),l.jsx("button",{onClick:()=>$(!_),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(zu,{onSelect:ke=>{H(ke),X(!0),$(!1)},onClose:()=>$(!1)})]}),l.jsxs(Dy,{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.
|
|
112
|
+
|
|
113
|
+
Skip this if you don't have a codebase yet — you can connect one later from Settings.`,tag:"optional",open:L,onToggle:()=>W(!L),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${lt} flex-1`,placeholder:"/path/to/code/repo",value:ne,onChange:ke=>K(ke.target.value)}),l.jsx("button",{onClick:()=>ie(!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:ke=>{K(ke),ie(!1)},onClose:()=>ie(!1)})]}),l.jsxs(Dy,{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.
|
|
114
|
+
|
|
115
|
+
Skip this to start with an empty knowledge base. You can import documents anytime from the office.`,tag:"optional",open:de,onToggle:()=>me(!de),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${lt} flex-1`,placeholder:"/path/to/docs",value:Y,onChange:ke=>R(ke.target.value),onKeyDown:ke=>{ke.key==="Enter"&&(ke.preventDefault(),Et())}}),l.jsx("button",{onClick:()=>ae(!O),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"}),l.jsx("button",{onClick:Et,disabled:!Y.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:Y.trim()?1:.5},children:"Add"})]}),O&&l.jsx(zu,{onSelect:ke=>{D.includes(ke)||U([...D,ke]),ae(!1)},onClose:()=>ae(!1)}),D.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:D.map((ke,St)=>l.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:[l.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"var(--pixel-font)"},children:ke}),l.jsx("button",{onClick:()=>U(D.filter((jn,hn)=>hn!==St)),className:"opacity-50 hover:opacity-100",children:"✕"})]},St))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(Ay,{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:te,onChange:ke=>{Se(ke.target.value),_e(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>De(!rt),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:Vt,disabled:Oe||!te.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:Oe||!te.trim()?.5:1},children:Oe?"...":"Verify"})]}),je===!0&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found"]}),je===!1&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),rt&&l.jsx(zu,{onSelect:ke=>{Se(ke),_e(null),De(!1)},onClose:()=>De(!1)})]})})]}),st==="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."}),We.map(ke=>l.jsxs("div",{className:Kt(yt===ke.id),onClick:()=>bt(ke.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:ke.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ke.roles.map(St=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px]",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:St.id.toUpperCase()},St.id))})]},ke.id)),l.jsxs("div",{className:Kt(yt==="custom"),onClick:()=>bt("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."})]})]}),st==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:at?C==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!at&&!jt&&!Ee&&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:"})," ",te]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",c==="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:"})," ",T||"(default)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",c==="claude-cli"?"Claude Code CLI":"Direct API"]}),ne.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Code Repo:"})," ",ne]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",D.length>0?`Import ${D.length} source(s)`:"Fresh (empty)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Team:"})," ",yt]}),D.length>0&&l.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),zt&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:zt})]}),(jt||Ee)&&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:Ee?"Connecting to AKB...":"Scaffolding your company..."})]}),at&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),Q&&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:"})," ",Q]}),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:be.map((ke,St)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",ke]},St))}),(Ae||$e.length>0)&&l.jsxs("div",{className:"rounded-lg p-4 text-xs space-y-1",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"font-medium mb-2",style:{color:"var(--terminal-text-secondary)"},children:Ae?"Installing skill tools...":"Skill tools"}),$e.map((ke,St)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:ke.event==="installed"||ke.event==="skipped"?"var(--active-green)":ke.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:ke.event==="installed"||ke.event==="skipped"?"✓":ke.event==="error"?"✗":"…"}),l.jsx("span",{children:ke.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:ke.detail})]},St)),Ae&&l.jsxs("div",{className:"flex items-center gap-2 mt-1",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("div",{className:"w-3 h-3 border border-current rounded-full animate-spin",style:{borderTopColor:"var(--accent)"}}),l.jsx("span",{children:"Please wait..."})]})]}),D.length>0&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"var(--accent)",color:"#fff",opacity:.9},children:"Knowledge import will start in the background after entering the office."})]})]})]}),l.jsxs("div",{className:"px-6 py-4 flex justify-between items-center",style:{borderTop:"1px solid var(--terminal-border)"},children:[l.jsx("div",{children:n>0&&!at&&l.jsx("button",{onClick:Ie,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," / ",Ye.length]}),l.jsx("div",{children:at?l.jsx("button",{onClick:ee,disabled:Ae,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:Ae?.5:1},children:Ae?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:Re,disabled:!Ke()||jt||Ee,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Ke()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Ke()&&!jt&&!Ee?1:.5},children:st==="create"?jt||Ee?Ee?"Connecting...":"Creating...":C==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function ip({text:e}){const[n,a]=v.useState(!1),[i,o]=v.useState({top:0,left:0}),c=v.useRef(null),d=()=>{if(c.current){const f=c.current.getBoundingClientRect();o({top:f.bottom+6,left:f.left})}a(!0)};return l.jsxs("span",{className:"inline-flex",ref:c,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 Ay({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(ip,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:a})]}),o]})}function Dy({icon:e,title:n,hint:a,help:i,tag:o,open:c,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(ip,{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:c?"▲":"▼"})]}),!c&&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})}),c&&l.jsx("div",{className:"px-3 pb-3 space-y-2",children:f})]})}function Y8(){const[e,n]=v.useState(null),[a,i]=v.useState(!0),[o,c]=v.useState(null),d=v.useCallback(async()=>{i(!0),c(null);try{const f=await ye.getStatus();n(f)}catch(f){c(f instanceof Error?f.message:"Failed to fetch status")}finally{i(!1)}},[]);return v.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 X8=v.lazy(()=>Fy(()=>import("./preview-app-BHNMBMSl.js"),[]));function Uv(){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 W8(){var e;try{const n=localStorage.getItem("tycono-theme"),a=n&&n in ul?n:"default",i=(e=ul[a])==null?void 0:e.vars;if(!i)return;const o=document.documentElement;for(const[c,d]of Object.entries(i))o.style.setProperty(c,d)}catch{}}function G8(){const{initialized:e,loading:n,refetch:a}=Y8(),[i,o]=v.useState(null);v.useEffect(()=>{W8()},[]);const c=d=>{d&&o(d),a()};return n?l.jsx(Uv,{}):e?l.jsx(H8,{importReq:i,onImportDone:()=>o(null)}):l.jsx(q8,{onComplete:c})}function V8(){const e=new URLSearchParams(window.location.search).has("sprite-preview");return l.jsx(Fw,{children:e?l.jsx(v.Suspense,{fallback:l.jsx(Uv,{}),children:l.jsx(X8,{})}):l.jsx(G8,{})})}Aw.createRoot(document.getElementById("root")).render(l.jsx(v.StrictMode,{children:l.jsx(V8,{})}));export{bv as H,wv as P,kv as S,Z8 as a,vv as b,yv as c,om as d,cC as e,P8 as f,Q8 as g,J8 as h,l as j,v as r};
|