tycono 0.1.83 → 0.1.84
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 +7 -0
- package/src/api/src/services/preferences.ts +5 -0
- package/src/web/dist/assets/index-YE1g0Mgv.js +110 -0
- package/src/web/dist/assets/{preview-app-DbMjPbJZ.js → preview-app-RTesSYsM.js} +1 -1
- package/src/web/dist/index.html +1 -1
- package/src/web/dist/assets/index-BOH9XJbW.js +0 -110
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
var ow=Object.defineProperty;var cw=(e,n,a)=>n in e?ow(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var k0=(e,n,a)=>cw(e,typeof n!="symbol"?n+"":n,a);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function a(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(o){if(o.ep)return;o.ep=!0;const u=a(o);fetch(o.href,u)}})();function Cy(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zf={exports:{}},vo={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var j0;function uw(){if(j0)return vo;j0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(i,o,u){var d=null;if(u!==void 0&&(d=""+u),o.key!==void 0&&(d=""+o.key),"key"in o){u={};for(var f in o)f!=="key"&&(u[f]=o[f])}else u=o;return o=u.ref,{$$typeof:e,type:i,key:d,ref:o!==void 0?o:null,props:u}}return vo.Fragment=n,vo.jsx=a,vo.jsxs=a,vo}var S0;function dw(){return S0||(S0=1,Zf.exports=uw()),Zf.exports}var l=dw(),Jf={exports:{}},mt={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react.production.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var C0;function fw(){if(C0)return mt;C0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),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(B){return B===null||typeof B!="object"?null:(B=w&&B[w]||B["@@iterator"],typeof B=="function"?B:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,E={};function C(B,U,T){this.props=B,this.context=U,this.refs=E,this.updater=T||j}C.prototype.isReactComponent={},C.prototype.setState=function(B,U){if(typeof B!="object"&&typeof B!="function"&&B!=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,B,U,"setState")},C.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function N(){}N.prototype=C.prototype;function _(B,U,T){this.props=B,this.context=U,this.refs=E,this.updater=T||j}var z=_.prototype=new N;z.constructor=_,k(z,C.prototype),z.isPureReactComponent=!0;var H=Array.isArray;function R(){}var I={H:null,A:null,T:null,S:null},q=Object.prototype.hasOwnProperty;function X(B,U,T){var ie=T.ref;return{$$typeof:e,type:B,key:U,ref:ie!==void 0?ie:null,props:T}}function A(B,U){return X(B.type,U,B.props)}function $(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function L(B){var U={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(T){return U[T]})}var Y=/\/+/g;function se(B,U){return typeof B=="object"&&B!==null&&B.key!=null?L(""+B.key):U.toString(36)}function ee(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(R,R):(B.status="pending",B.then(function(U){B.status==="pending"&&(B.status="fulfilled",B.value=U)},function(U){B.status==="pending"&&(B.status="rejected",B.reason=U)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function W(B,U,T,ie,ge){var pe=typeof B;(pe==="undefined"||pe==="boolean")&&(B=null);var ze=!1;if(B===null)ze=!0;else switch(pe){case"bigint":case"string":case"number":ze=!0;break;case"object":switch(B.$$typeof){case e:case n:ze=!0;break;case x:return ze=B._init,W(ze(B._payload),U,T,ie,ge)}}if(ze)return ge=ge(B),ze=ie===""?"."+se(B,0):ie,H(ge)?(T="",ze!=null&&(T=ze.replace(Y,"$&/")+"/"),W(ge,U,T,"",function(st){return st})):ge!=null&&($(ge)&&(ge=A(ge,T+(ge.key==null||B&&B.key===ge.key?"":(""+ge.key).replace(Y,"$&/")+"/")+ze)),U.push(ge)),1;ze=0;var Ie=ie===""?".":ie+":";if(H(B))for(var He=0;He<B.length;He++)ie=B[He],pe=Ie+se(ie,He),ze+=W(ie,U,T,pe,ge);else if(He=b(B),typeof He=="function")for(B=He.call(B),He=0;!(ie=B.next()).done;)ie=ie.value,pe=Ie+se(ie,He++),ze+=W(ie,U,T,pe,ge);else if(pe==="object"){if(typeof B.then=="function")return W(ee(B),U,T,ie,ge);throw U=String(B),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return ze}function oe(B,U,T){if(B==null)return B;var ie=[],ge=0;return W(B,ie,"","",function(pe){return U.call(T,pe,ge++)}),ie}function de(B){if(B._status===-1){var U=B._result;U=U(),U.then(function(T){(B._status===0||B._status===-1)&&(B._status=1,B._result=T)},function(T){(B._status===0||B._status===-1)&&(B._status=2,B._result=T)}),B._status===-1&&(B._status=0,B._result=U)}if(B._status===1)return B._result.default;throw B._result}var V=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},D={map:oe,forEach:function(B,U,T){oe(B,function(){U.apply(this,arguments)},T)},count:function(B){var U=0;return oe(B,function(){U++}),U},toArray:function(B){return oe(B,function(U){return U})||[]},only:function(B){if(!$(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return mt.Activity=g,mt.Children=D,mt.Component=C,mt.Fragment=a,mt.Profiler=o,mt.PureComponent=_,mt.StrictMode=i,mt.Suspense=m,mt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,mt.__COMPILER_RUNTIME={__proto__:null,c:function(B){return I.H.useMemoCache(B)}},mt.cache=function(B){return function(){return B.apply(null,arguments)}},mt.cacheSignal=function(){return null},mt.cloneElement=function(B,U,T){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var ie=k({},B.props),ge=B.key;if(U!=null)for(pe in U.key!==void 0&&(ge=""+U.key),U)!q.call(U,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&U.ref===void 0||(ie[pe]=U[pe]);var pe=arguments.length-2;if(pe===1)ie.children=T;else if(1<pe){for(var ze=Array(pe),Ie=0;Ie<pe;Ie++)ze[Ie]=arguments[Ie+2];ie.children=ze}return X(B.type,ge,ie)},mt.createContext=function(B){return B={$$typeof:d,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:u,_context:B},B},mt.createElement=function(B,U,T){var ie,ge={},pe=null;if(U!=null)for(ie in U.key!==void 0&&(pe=""+U.key),U)q.call(U,ie)&&ie!=="key"&&ie!=="__self"&&ie!=="__source"&&(ge[ie]=U[ie]);var ze=arguments.length-2;if(ze===1)ge.children=T;else if(1<ze){for(var Ie=Array(ze),He=0;He<ze;He++)Ie[He]=arguments[He+2];ge.children=Ie}if(B&&B.defaultProps)for(ie in ze=B.defaultProps,ze)ge[ie]===void 0&&(ge[ie]=ze[ie]);return X(B,pe,ge)},mt.createRef=function(){return{current:null}},mt.forwardRef=function(B){return{$$typeof:f,render:B}},mt.isValidElement=$,mt.lazy=function(B){return{$$typeof:x,_payload:{_status:-1,_result:B},_init:de}},mt.memo=function(B,U){return{$$typeof:h,type:B,compare:U===void 0?null:U}},mt.startTransition=function(B){var U=I.T,T={};I.T=T;try{var ie=B(),ge=I.S;ge!==null&&ge(T,ie),typeof ie=="object"&&ie!==null&&typeof ie.then=="function"&&ie.then(R,V)}catch(pe){V(pe)}finally{U!==null&&T.types!==null&&(U.types=T.types),I.T=U}},mt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},mt.use=function(B){return I.H.use(B)},mt.useActionState=function(B,U,T){return I.H.useActionState(B,U,T)},mt.useCallback=function(B,U){return I.H.useCallback(B,U)},mt.useContext=function(B){return I.H.useContext(B)},mt.useDebugValue=function(){},mt.useDeferredValue=function(B,U){return I.H.useDeferredValue(B,U)},mt.useEffect=function(B,U){return I.H.useEffect(B,U)},mt.useEffectEvent=function(B){return I.H.useEffectEvent(B)},mt.useId=function(){return I.H.useId()},mt.useImperativeHandle=function(B,U,T){return I.H.useImperativeHandle(B,U,T)},mt.useInsertionEffect=function(B,U){return I.H.useInsertionEffect(B,U)},mt.useLayoutEffect=function(B,U){return I.H.useLayoutEffect(B,U)},mt.useMemo=function(B,U){return I.H.useMemo(B,U)},mt.useOptimistic=function(B,U){return I.H.useOptimistic(B,U)},mt.useReducer=function(B,U,T){return I.H.useReducer(B,U,T)},mt.useRef=function(B){return I.H.useRef(B)},mt.useState=function(B){return I.H.useState(B)},mt.useSyncExternalStore=function(B,U,T){return I.H.useSyncExternalStore(B,U,T)},mt.useTransition=function(){return I.H.useTransition()},mt.version="19.2.4",mt}var E0;function wm(){return E0||(E0=1,Jf.exports=fw()),Jf.exports}var v=wm(),eh={exports:{}},wo={},th={exports:{}},nh={};/**
|
|
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 N0;function hw(){return N0||(N0=1,(function(e){function n(W,oe){var de=W.length;W.push(oe);e:for(;0<de;){var V=de-1>>>1,D=W[V];if(0<o(D,oe))W[V]=oe,W[de]=D,de=V;else break e}}function a(W){return W.length===0?null:W[0]}function i(W){if(W.length===0)return null;var oe=W[0],de=W.pop();if(de!==oe){W[0]=de;e:for(var V=0,D=W.length,B=D>>>1;V<B;){var U=2*(V+1)-1,T=W[U],ie=U+1,ge=W[ie];if(0>o(T,de))ie<D&&0>o(ge,T)?(W[V]=ge,W[ie]=de,V=ie):(W[V]=T,W[U]=de,V=U);else if(ie<D&&0>o(ge,de))W[V]=ge,W[ie]=de,V=ie;else break e}}return oe}function o(W,oe){var de=W.sortIndex-oe.sortIndex;return de!==0?de:W.id-oe.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var m=[],h=[],x=1,g=null,w=3,b=!1,j=!1,k=!1,E=!1,C=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function z(W){for(var oe=a(h);oe!==null;){if(oe.callback===null)i(h);else if(oe.startTime<=W)i(h),oe.sortIndex=oe.expirationTime,n(m,oe);else break;oe=a(h)}}function H(W){if(k=!1,z(W),!j)if(a(m)!==null)j=!0,R||(R=!0,L());else{var oe=a(h);oe!==null&&ee(H,oe.startTime-W)}}var R=!1,I=-1,q=5,X=-1;function A(){return E?!0:!(e.unstable_now()-X<q)}function $(){if(E=!1,R){var W=e.unstable_now();X=W;var oe=!0;try{e:{j=!1,k&&(k=!1,N(I),I=-1),b=!0;var de=w;try{t:{for(z(W),g=a(m);g!==null&&!(g.expirationTime>W&&A());){var V=g.callback;if(typeof V=="function"){g.callback=null,w=g.priorityLevel;var D=V(g.expirationTime<=W);if(W=e.unstable_now(),typeof D=="function"){g.callback=D,z(W),oe=!0;break t}g===a(m)&&i(m),z(W)}else i(m);g=a(m)}if(g!==null)oe=!0;else{var B=a(h);B!==null&&ee(H,B.startTime-W),oe=!1}}break e}finally{g=null,w=de,b=!1}oe=void 0}}finally{oe?L():R=!1}}}var L;if(typeof _=="function")L=function(){_($)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,se=Y.port2;Y.port1.onmessage=$,L=function(){se.postMessage(null)}}else L=function(){C($,0)};function ee(W,oe){I=C(function(){W(e.unstable_now())},oe)}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(W){W.callback=null},e.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<W?Math.floor(1e3/W):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(W){switch(w){case 1:case 2:case 3:var oe=3;break;default:oe=w}var de=w;w=oe;try{return W()}finally{w=de}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(W,oe){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var de=w;w=W;try{return oe()}finally{w=de}},e.unstable_scheduleCallback=function(W,oe,de){var V=e.unstable_now();switch(typeof de=="object"&&de!==null?(de=de.delay,de=typeof de=="number"&&0<de?V+de:V):de=V,W){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,W={id:x++,callback:oe,priorityLevel:W,startTime:de,expirationTime:D,sortIndex:-1},de>V?(W.sortIndex=de,n(h,W),a(m)===null&&W===a(h)&&(k?(N(I),I=-1):k=!0,ee(H,de-V))):(W.sortIndex=D,n(m,W),j||b||(j=!0,R||(R=!0,L()))),W},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(W){var oe=w;return function(){var de=w;w=oe;try{return W.apply(this,arguments)}finally{w=de}}}})(nh)),nh}var A0;function mw(){return A0||(A0=1,th.exports=hw()),th.exports}var rh={exports:{}},nr={};/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var D0;function pw(){if(D0)return nr;D0=1;var e=wm();function n(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)h+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var i={d:{f:a,r:function(){throw Error(n(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},o=Symbol.for("react.portal");function u(m,h,x){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:h,implementation:x}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return nr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,nr.createPortal=function(m,h){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(n(299));return u(m,h,null,x)},nr.flushSync=function(m){var h=d.T,x=i.p;try{if(d.T=null,i.p=2,m)return m()}finally{d.T=h,i.p=x,i.d.f()}},nr.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,i.d.C(m,h))},nr.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},nr.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin),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})}},nr.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var x=f(h.as,h.crossOrigin);i.d.M(m,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&i.d.M(m)},nr.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin);i.d.L(m,x,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},nr.preloadModule=function(m,h){if(typeof m=="string")if(h){var x=f(h.as,h.crossOrigin);i.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else i.d.m(m)},nr.requestFormReset=function(m){i.d.r(m)},nr.unstable_batchedUpdates=function(m,h){return m(h)},nr.useFormState=function(m,h,x){return d.H.useFormState(m,h,x)},nr.useFormStatus=function(){return d.H.useHostTransitionStatus()},nr.version="19.2.4",nr}var T0;function xw(){if(T0)return rh.exports;T0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),rh.exports=pw(),rh.exports}/**
|
|
34
|
-
* @license React
|
|
35
|
-
* react-dom-client.production.js
|
|
36
|
-
*
|
|
37
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the MIT license found in the
|
|
40
|
-
* LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/var F0;function gw(){if(F0)return wo;F0=1;var e=mw(),n=wm(),a=xw();function i(t){var r="https://react.dev/errors/"+t;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)r+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function u(t){var r=t,s=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(s=r.return),t=r.return;while(t)}return r.tag===3?s:null}function d(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function f(t){if(t.tag===31){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function m(t){if(u(t)!==t)throw Error(i(188))}function h(t){var r=t.alternate;if(!r){if(r=u(t),r===null)throw Error(i(188));return r!==t?null:t}for(var s=t,c=r;;){var p=s.return;if(p===null)break;var y=p.alternate;if(y===null){if(c=p.return,c!==null){s=c;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===s)return m(p),t;if(y===c)return m(p),r;y=y.sibling}throw Error(i(188))}if(s.return!==c.return)s=p,c=y;else{for(var S=!1,M=p.child;M;){if(M===s){S=!0,s=p,c=y;break}if(M===c){S=!0,c=p,s=y;break}M=M.sibling}if(!S){for(M=y.child;M;){if(M===s){S=!0,s=y,c=p;break}if(M===c){S=!0,c=y,s=p;break}M=M.sibling}if(!S)throw Error(i(189))}}if(s.alternate!==c)throw Error(i(190))}if(s.tag!==3)throw Error(i(188));return s.stateNode.current===s?t:r}function x(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t;for(t=t.child;t!==null;){if(r=x(t),r!==null)return r;t=t.sibling}return null}var g=Object.assign,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"),C=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),_=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),A=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 Y=Symbol.for("react.client.reference");function se(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Y?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case C:return"Profiler";case E:return"StrictMode";case H:return"Suspense";case R:return"SuspenseList";case X:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case j:return"Portal";case _:return t.displayName||"Context";case N:return(t._context.displayName||"Context")+".Consumer";case z: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:se(t.type)||"Memo";case q:r=t._payload,t=t._init;try{return se(t(r))}catch{}}return null}var ee=Array.isArray,W=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},V=[],D=-1;function B(t){return{current:t}}function U(t){0>D||(t.current=V[D],V[D]=null,D--)}function T(t,r){D++,V[D]=t.current,t.current=r}var ie=B(null),ge=B(null),pe=B(null),ze=B(null);function Ie(t,r){switch(T(pe,r),T(ge,t),T(ie,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?X1(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=X1(r),t=W1(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}U(ie),T(ie,t)}function He(){U(ie),U(ge),U(pe)}function st(t){t.memoizedState!==null&&T(ze,t);var r=ie.current,s=W1(r,t.type);r!==s&&(T(ge,t),T(ie,s))}function Pe(t){ge.current===t&&(U(ie),U(ge)),ze.current===t&&(U(ze),xo._currentValue=de)}var et,Ee;function De(t){if(et===void 0)try{throw Error()}catch(s){var r=s.stack.trim().match(/\n( *(at )?)/);et=r&&r[1]||"",Ee=-1<s.stack.indexOf(`
|
|
42
|
-
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
-
`+et+t+Ee}var yt=!1;function ut(t,r){if(!t||yt)return"";yt=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(r){var Ce=function(){throw Error()};if(Object.defineProperty(Ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ce,[])}catch(fe){var ce=fe}Reflect.construct(t,[],Ce)}else{try{Ce.call()}catch(fe){ce=fe}t.call(Ce.prototype)}}else{try{throw Error()}catch(fe){ce=fe}(Ce=t())&&typeof Ce.catch=="function"&&Ce.catch(function(){})}}catch(fe){if(fe&&ce&&typeof fe.stack=="string")return[fe.stack,ce.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=c.DetermineComponentFrameRoot(),S=y[0],M=y[1];if(S&&M){var G=S.split(`
|
|
44
|
-
`),le=M.split(`
|
|
45
|
-
`);for(p=c=0;c<G.length&&!G[c].includes("DetermineComponentFrameRoot");)c++;for(;p<le.length&&!le[p].includes("DetermineComponentFrameRoot");)p++;if(c===G.length||p===le.length)for(c=G.length-1,p=le.length-1;1<=c&&0<=p&&G[c]!==le[p];)p--;for(;1<=c&&0<=p;c--,p--)if(G[c]!==le[p]){if(c!==1||p!==1)do if(c--,p--,0>p||G[c]!==le[p]){var xe=`
|
|
46
|
-
`+G[c].replace(" at new "," at ");return t.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",t.displayName)),xe}while(1<=c&&0<=p);break}}}finally{yt=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?De(s):""}function pt(t,r){switch(t.tag){case 26:case 27:case 5:return De(t.type);case 16:return De("Lazy");case 13:return t.child!==r&&r!==null?De("Suspense Fallback"):De("Suspense");case 19:return De("SuspenseList");case 0:case 15:return ut(t.type,!1);case 11:return ut(t.type.render,!1);case 1:return ut(t.type,!0);case 31:return De("Activity");default:return""}}function jt(t){try{var r="",s=null;do r+=pt(t,s),s=t,t=t.return;while(t);return r}catch(c){return`
|
|
47
|
-
Error generating stack: `+c.message+`
|
|
48
|
-
`+c.stack}}var Wt=Object.prototype.hasOwnProperty,Ft=e.unstable_scheduleCallback,Et=e.unstable_cancelCallback,$n=e.unstable_shouldYield,me=e.unstable_requestPaint,Se=e.unstable_now,Ne=e.unstable_getCurrentPriorityLevel,K=e.unstable_ImmediatePriority,ue=e.unstable_UserBlockingPriority,te=e.unstable_NormalPriority,ke=e.unstable_LowPriority,ve=e.unstable_IdlePriority,_e=e.log,Be=e.unstable_setDisableYieldValue,Oe=null,qe=null;function rt(t){if(typeof _e=="function"&&Be(t),qe&&typeof qe.setStrictMode=="function")try{qe.setStrictMode(Oe,t)}catch{}}var Ve=Math.clz32?Math.clz32:Ue,bt=Math.log,Re=Math.LN2;function Ue(t){return t>>>=0,t===0?32:31-(bt(t)/Re|0)|0}var _t=256,Bt=262144,Ot=4194304;function fn(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 wn(t,r,s){var c=t.pendingLanes;if(c===0)return 0;var p=0,y=t.suspendedLanes,S=t.pingedLanes;t=t.warmLanes;var M=c&134217727;return M!==0?(c=M&~y,c!==0?p=fn(c):(S&=M,S!==0?p=fn(S):s||(s=M&~t,s!==0&&(p=fn(s))))):(M=c&~y,M!==0?p=fn(M):S!==0?p=fn(S):s||(s=c&~t,s!==0&&(p=fn(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 Z(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function $e(t,r){switch(t){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function nt(){var t=Ot;return Ot<<=1,(Ot&62914560)===0&&(Ot=4194304),t}function Pt(t){for(var r=[],s=0;31>s;s++)r.push(t);return r}function we(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function kt(t,r,s,c,p,y){var S=t.pendingLanes;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=s,t.entangledLanes&=s,t.errorRecoveryDisabledLanes&=s,t.shellSuspendCounter=0;var M=t.entanglements,G=t.expirationTimes,le=t.hiddenUpdates;for(s=S&~s;0<s;){var xe=31-Ve(s),Ce=1<<xe;M[xe]=0,G[xe]=-1;var ce=le[xe];if(ce!==null)for(le[xe]=null,xe=0;xe<ce.length;xe++){var fe=ce[xe];fe!==null&&(fe.lane&=-536870913)}s&=~Ce}c!==0&&ln(t,c,0),y!==0&&p===0&&t.tag!==0&&(t.suspendedLanes|=y&~(S&~r))}function ln(t,r,s){t.pendingLanes|=r,t.suspendedLanes&=~r;var c=31-Ve(r);t.entangledLanes|=r,t.entanglements[c]=t.entanglements[c]|1073741824|s&261930}function sn(t,r){var s=t.entangledLanes|=r;for(t=t.entanglements;s;){var c=31-Ve(s),p=1<<c;p&r|t[c]&r&&(t[c]|=r),s&=~p}}function ne(t,r){var s=r&-r;return s=(s&42)!==0?1:Ae(s),(s&(t.suspendedLanes|r))!==0?0:s}function Ae(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 We(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Nt(){var t=oe.p;return t!==0?t:(t=window.event,t===void 0?32:p0(t.type))}function kn(t,r){var s=oe.p;try{return oe.p=t,r()}finally{oe.p=s}}var ur=Math.random().toString(36).slice(2),xn="__reactFiber$"+ur,gn="__reactProps$"+ur,dr="__reactContainer$"+ur,sl="__reactEvents$"+ur,Ju="__reactListeners$"+ur,Fs="__reactHandles$"+ur,Vo="__reactResources$"+ur,Ta="__reactMarker$"+ur;function Ti(t){delete t[xn],delete t[gn],delete t[sl],delete t[Ju],delete t[Fs]}function ca(t){var r=t[xn];if(r)return r;for(var s=t.parentNode;s;){if(r=s[dr]||s[xn]){if(s=r.alternate,r.child!==null||s!==null&&s.child!==null)for(t=J1(t);t!==null;){if(s=t[xn])return s;t=J1(t)}return r}t=s,s=t.parentNode}return null}function Vn(t){if(t=t[xn]||t[dr]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function Wl(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function jr(t){var r=t[Vo];return r||(r=t[Vo]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function jn(t){t[Ta]=!0}var Fa=new Set,Ma={};function fr(t,r){Ra(t,r),Ra(t+"Capture",r)}function Ra(t,r){for(Ma[t]=r,t=0;t<r.length;t++)Fa.add(r[t])}var ol=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ms={},Rs={};function zs(t){return Wt.call(Rs,t)?!0:Wt.call(Ms,t)?!1:ol.test(t)?Rs[t]=!0:(Ms[t]=!0,!1)}function Gl(t,r,s){if(zs(r))if(s===null)t.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":t.removeAttribute(r);return;case"boolean":var c=r.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){t.removeAttribute(r);return}}t.setAttribute(r,""+s)}}function Vl(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,c){if(c===null)t.removeAttribute(s);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(s);return}t.setAttributeNS(r,s,""+c)}}function Dn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Zr(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function ua(t,r,s){var c=Object.getOwnPropertyDescriptor(t.constructor.prototype,r);if(!t.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var p=c.get,y=c.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return p.call(this)},set:function(S){s=""+S,y.call(this,S)}}),Object.defineProperty(t,r,{enumerable:c.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function Jr(t){if(!t._valueTracker){var r=Zr(t)?"checked":"value";t._valueTracker=ua(t,r,""+t[r])}}function Or(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var s=r.getValue(),c="";return t&&(c=Zr(t)?t.checked?"true":"false":t.value),t=c,t!==s?(r.setValue(t),!0):!1}function Tn(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 Ko=/[\n"\\]/g;function hr(t){return t.replace(Ko,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Kl(t,r,s,c,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=""+Dn(r)):t.value!==""+Dn(r)&&(t.value=""+Dn(r)):S!=="submit"&&S!=="reset"||t.removeAttribute("value"),r!=null?da(t,S,Dn(r)):s!=null?da(t,S,Dn(s)):c!=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=""+Dn(M):t.removeAttribute("name")}function Sr(t,r,s,c,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)){Jr(t);return}s=s!=null?""+Dn(s):"",r=r!=null?""+Dn(r):s,M||r===t.value||(t.value=r),t.defaultValue=r}c=c??p,c=typeof c!="function"&&typeof c!="symbol"&&!!c,t.checked=M?t.checked:!!c,t.defaultChecked=!!c,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(t.name=S),Jr(t)}function da(t,r,s){r==="number"&&Tn(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function mr(t,r,s,c){if(t=t.options,r){r={};for(var p=0;p<s.length;p++)r["$"+s[p]]=!0;for(s=0;s<t.length;s++)p=r.hasOwnProperty("$"+t[s].value),t[s].selected!==p&&(t[s].selected=p),p&&c&&(t[s].defaultSelected=!0)}else{for(s=""+Dn(s),r=null,p=0;p<t.length;p++){if(t[p].value===s){t[p].selected=!0,c&&(t[p].defaultSelected=!0);return}r!==null||t[p].disabled||(r=t[p])}r!==null&&(r.selected=!0)}}function Po(t,r,s){if(r!=null&&(r=""+Dn(r),r!==t.value&&(t.value=r),s==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=s!=null?""+Dn(s):""}function Ln(t,r,s,c){if(r==null){if(c!=null){if(s!=null)throw Error(i(92));if(ee(c)){if(1<c.length)throw Error(i(93));c=c[0]}s=c}s==null&&(s=""),r=s}s=Dn(r),t.defaultValue=s,c=t.textContent,c===s&&c!==""&&c!==null&&(t.value=c),Jr(t)}function Gt(t,r){if(r){var s=t.firstChild;if(s&&s===t.lastChild&&s.nodeType===3){s.nodeValue=r;return}}t.textContent=r}var fa=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 Xn(t,r,s){var c=r.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?c?t.setProperty(r,""):r==="float"?t.cssFloat="":t[r]="":c?t.setProperty(r,s):typeof s!="number"||s===0||fa.has(r)?r==="float"?t.cssFloat=s:t[r]=(""+s).trim():t[r]=s+"px"}function ea(t,r,s){if(r!=null&&typeof r!="object")throw Error(i(62));if(t=t.style,s!=null){for(var c in s)!s.hasOwnProperty(c)||r!=null&&r.hasOwnProperty(c)||(c.indexOf("--")===0?t.setProperty(c,""):c==="float"?t.cssFloat="":t[c]="");for(var p in r)c=r[p],r.hasOwnProperty(p)&&s[p]!==c&&Xn(t,p,c)}else for(var y in r)r.hasOwnProperty(y)&&Xn(t,y,r[y])}function ta(t){if(t.indexOf("-")===-1)return!1;switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ed=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Fi=/^[\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 Pl(t){return Fi.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function tr(){}var na=null;function Mi(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var za=null,Fn=null;function _a(t){var r=Vn(t);if(r&&(t=r.stateNode)){var s=t[gn]||null;e:switch(t=r.stateNode,r.type){case"input":if(Kl(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="'+hr(""+r)+'"][type="radio"]'),r=0;r<s.length;r++){var c=s[r];if(c!==t&&c.form===t.form){var p=c[gn]||null;if(!p)throw Error(i(90));Kl(c,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(r=0;r<s.length;r++)c=s[r],c.form===t.form&&Or(c)}break e;case"textarea":Po(t,s.value,s.defaultValue);break e;case"select":r=s.value,r!=null&&mr(t,!!s.multiple,r,!1)}}}var cl=!1;function Qo(t,r,s){if(cl)return t(r,s);cl=!0;try{var c=t(r);return c}finally{if(cl=!1,(za!==null||Fn!==null)&&(qc(),za&&(r=za,t=Fn,Fn=za=null,_a(r),t)))for(r=0;r<t.length;r++)_a(t[r])}}function Ql(t,r){var s=t.stateNode;if(s===null)return null;var c=s[gn]||null;if(c===null)return null;s=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(s&&typeof s!="function")throw Error(i(231,r,typeof s));return s}var xt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_s=!1;if(xt)try{var Qt={};Object.defineProperty(Qt,"passive",{get:function(){_s=!0}}),window.addEventListener("test",Qt,Qt),window.removeEventListener("test",Qt,Qt)}catch{_s=!1}var $r=null,Ba=null,Ri=null;function ul(){if(Ri)return Ri;var t,r=Ba,s=r.length,c,p="value"in $r?$r.value:$r.textContent,y=p.length;for(t=0;t<s&&r[t]===p[t];t++);var S=s-t;for(c=1;c<=S&&r[s-c]===p[y-c];c++);return Ri=p.slice(t,1<c?1-c:void 0)}function zi(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 dl(){return!0}function ha(){return!1}function Wn(t){function r(s,c,p,y,S){this._reactName=s,this._targetInst=p,this.type=c,this.nativeEvent=y,this.target=S,this.currentTarget=null;for(var 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)?dl:ha,this.isPropagationStopped=ha,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=dl)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=dl)},persist:function(){},isPersistent:dl}),r}var Oa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_i=Wn(Oa),$a=g({},Oa,{view:0,detail:0}),td=Wn($a),Bi,Oi,Zl,Jl=g({},$a,{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!==Zl&&(Zl&&t.type==="mousemove"?(Bi=t.screenX-Zl.screenX,Oi=t.screenY-Zl.screenY):Oi=Bi=0,Zl=t),Bi)},movementY:function(t){return"movementY"in t?t.movementY:Oi}}),Bs=Wn(Jl),Zo=g({},Jl,{dataTransfer:0}),ma=Wn(Zo),La=g({},$a,{relatedTarget:0}),ei=Wn(La),nd=g({},Oa,{animationName:0,elapsedTime:0,pseudoElement:0}),Jo=Wn(nd),ec=g({},Oa,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),rd=Wn(ec),tc=g({},Oa,{data:0}),Zt=Wn(tc),$i={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nc={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"},rc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ac(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=rc[t])?!!r[t]:!1}function Li(){return ac}var lc=g({},$a,{key:function(t){if(t.key){var r=$i[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=zi(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?nc[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"?zi(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?zi(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),ic=Wn(lc),sc=g({},Jl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),F=Wn(sc),P=g({},$a,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Li}),re=Wn(P),he=g({},Oa,{propertyName:0,elapsedTime:0,pseudoElement:0}),je=Wn(he),Le=g({},Jl,{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}),It=Wn(Le),dt=g({},Oa,{newState:0,oldState:0}),Ze=Wn(dt),Je=[9,13,27,32],ft=xt&&"CompositionEvent"in window,St=null;xt&&"documentMode"in document&&(St=document.documentMode);var ti=xt&&"TextEvent"in window&&!St,Kn=xt&&(!ft||St&&8<St&&11>=St),ot=" ",$t=!1;function En(t,r){switch(t){case"keyup":return Je.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 Ii=!1;function Mv(t,r){switch(t){case"compositionend":return on(r);case"keypress":return r.which!==32?null:($t=!0,ot);case"textInput":return t=r.data,t===ot&&$t?null:t;default:return null}}function Rv(t,r){if(Ii)return t==="compositionend"||!ft&&En(t,r)?(t=ul(),Ri=Ba=$r=null,Ii=!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 Kn&&r.locale!=="ko"?null:r.data;default:return null}}var zv={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function np(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!zv[t.type]:r==="textarea"}function rp(t,r,s,c){za?Fn?Fn.push(c):Fn=[c]:za=c,r=Pc(r,"onChange"),0<r.length&&(s=new _i("onChange","change",null,s,c),t.push({event:s,listeners:r}))}var Os=null,$s=null;function _v(t){L1(t,0)}function oc(t){var r=Wl(t);if(Or(r))return t}function ap(t,r){if(t==="change")return r}var lp=!1;if(xt){var ad;if(xt){var ld="oninput"in document;if(!ld){var ip=document.createElement("div");ip.setAttribute("oninput","return;"),ld=typeof ip.oninput=="function"}ad=ld}else ad=!1;lp=ad&&(!document.documentMode||9<document.documentMode)}function sp(){Os&&(Os.detachEvent("onpropertychange",op),$s=Os=null)}function op(t){if(t.propertyName==="value"&&oc($s)){var r=[];rp(r,$s,t,Mi(t)),Qo(_v,r)}}function Bv(t,r,s){t==="focusin"?(sp(),Os=r,$s=s,Os.attachEvent("onpropertychange",op)):t==="focusout"&&sp()}function Ov(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return oc($s)}function $v(t,r){if(t==="click")return oc(r)}function Lv(t,r){if(t==="input"||t==="change")return oc(r)}function Iv(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var Cr=typeof Object.is=="function"?Object.is:Iv;function Ls(t,r){if(Cr(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var s=Object.keys(t),c=Object.keys(r);if(s.length!==c.length)return!1;for(c=0;c<s.length;c++){var p=s[c];if(!Wt.call(r,p)||!Cr(t[p],r[p]))return!1}return!0}function cp(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function up(t,r){var s=cp(t);t=0;for(var c;s;){if(s.nodeType===3){if(c=t+s.textContent.length,t<=r&&c>=r)return{node:s,offset:r-t};t=c}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=cp(s)}}function dp(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?dp(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function fp(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=Tn(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=Tn(t.document)}return r}function id(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}var Hv=xt&&"documentMode"in document&&11>=document.documentMode,Hi=null,sd=null,Is=null,od=!1;function hp(t,r,s){var c=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;od||Hi==null||Hi!==Tn(c)||(c=Hi,"selectionStart"in c&&id(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Is&&Ls(Is,c)||(Is=c,c=Pc(sd,"onSelect"),0<c.length&&(r=new _i("onSelect","select",null,r,s),t.push({event:r,listeners:c}),r.target=Hi)))}function ni(t,r){var s={};return s[t.toLowerCase()]=r.toLowerCase(),s["Webkit"+t]="webkit"+r,s["Moz"+t]="moz"+r,s}var Ui={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")},cd={},mp={};xt&&(mp=document.createElement("div").style,"AnimationEvent"in window||(delete Ui.animationend.animation,delete Ui.animationiteration.animation,delete Ui.animationstart.animation),"TransitionEvent"in window||delete Ui.transitionend.transition);function ri(t){if(cd[t])return cd[t];if(!Ui[t])return t;var r=Ui[t],s;for(s in r)if(r.hasOwnProperty(s)&&s in mp)return cd[t]=r[s];return t}var pp=ri("animationend"),xp=ri("animationiteration"),gp=ri("animationstart"),Uv=ri("transitionrun"),qv=ri("transitionstart"),Yv=ri("transitioncancel"),yp=ri("transitionend"),bp=new Map,ud="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(" ");ud.push("scrollEnd");function ra(t,r){bp.set(t,r),fr(r,[t])}var cc=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)},Lr=[],qi=0,dd=0;function uc(){for(var t=qi,r=dd=qi=0;r<t;){var s=Lr[r];Lr[r++]=null;var c=Lr[r];Lr[r++]=null;var p=Lr[r];Lr[r++]=null;var y=Lr[r];if(Lr[r++]=null,c!==null&&p!==null){var S=c.pending;S===null?p.next=p:(p.next=S.next,S.next=p),c.pending=p}y!==0&&vp(s,p,y)}}function dc(t,r,s,c){Lr[qi++]=t,Lr[qi++]=r,Lr[qi++]=s,Lr[qi++]=c,dd|=c,t.lanes|=c,t=t.alternate,t!==null&&(t.lanes|=c)}function fd(t,r,s,c){return dc(t,r,s,c),fc(t)}function ai(t,r){return dc(t,null,null,r),fc(t)}function vp(t,r,s){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s);for(var p=!1,y=t.return;y!==null;)y.childLanes|=s,c=y.alternate,c!==null&&(c.childLanes|=s),y.tag===22&&(t=y.stateNode,t===null||t._visibility&1||(p=!0)),t=y,y=y.return;return t.tag===3?(y=t.stateNode,p&&r!==null&&(p=31-Ve(s),t=y.hiddenUpdates,c=t[p],c===null?t[p]=[r]:c.push(r),r.lane=s|536870912),y):null}function fc(t){if(50<oo)throw oo=0,kf=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var Yi={};function Xv(t,r,s,c){this.tag=t,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Er(t,r,s,c){return new Xv(t,r,s,c)}function hd(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ia(t,r){var s=t.alternate;return s===null?(s=Er(t.tag,r,t.key,t.mode),s.elementType=t.elementType,s.type=t.type,s.stateNode=t.stateNode,s.alternate=t,t.alternate=s):(s.pendingProps=r,s.type=t.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=t.flags&65011712,s.childLanes=t.childLanes,s.lanes=t.lanes,s.child=t.child,s.memoizedProps=t.memoizedProps,s.memoizedState=t.memoizedState,s.updateQueue=t.updateQueue,r=t.dependencies,s.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},s.sibling=t.sibling,s.index=t.index,s.ref=t.ref,s.refCleanup=t.refCleanup,s}function wp(t,r){t.flags&=65011714;var s=t.alternate;return s===null?(t.childLanes=0,t.lanes=r,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=s.childLanes,t.lanes=s.lanes,t.child=s.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=s.memoizedProps,t.memoizedState=s.memoizedState,t.updateQueue=s.updateQueue,t.type=s.type,r=s.dependencies,t.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),t}function hc(t,r,s,c,p,y){var S=0;if(c=t,typeof t=="function")hd(t)&&(S=1);else if(typeof t=="string")S=P2(t,s,ie.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case X:return t=Er(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 C:return t=Er(12,s,r,p|2),t.elementType=C,t.lanes=y,t;case H:return t=Er(13,s,r,p),t.elementType=H,t.lanes=y,t;case R:return t=Er(19,s,r,p),t.elementType=R,t.lanes=y,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:S=10;break e;case N:S=9;break e;case z:S=11;break e;case I:S=14;break e;case q:S=16,c=null;break e}S=29,s=Error(i(130,t===null?"null":typeof t,"")),c=null}return r=Er(S,s,r,p),r.elementType=t,r.type=c,r.lanes=y,r}function li(t,r,s,c){return t=Er(7,t,c,r),t.lanes=s,t}function md(t,r,s){return t=Er(6,t,null,r),t.lanes=s,t}function kp(t){var r=Er(18,null,null,0);return r.stateNode=t,r}function pd(t,r,s){return r=Er(4,t.children!==null?t.children:[],t.key,r),r.lanes=s,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var jp=new WeakMap;function Ir(t,r){if(typeof t=="object"&&t!==null){var s=jp.get(t);return s!==void 0?s:(r={value:t,source:r,stack:jt(r)},jp.set(t,r),r)}return{value:t,source:r,stack:jt(r)}}var Xi=[],Wi=0,mc=null,Hs=0,Hr=[],Ur=0,fl=null,pa=1,xa="";function Ha(t,r){Xi[Wi++]=Hs,Xi[Wi++]=mc,mc=t,Hs=r}function Sp(t,r,s){Hr[Ur++]=pa,Hr[Ur++]=xa,Hr[Ur++]=fl,fl=t;var c=pa;t=xa;var p=32-Ve(c)-1;c&=~(1<<p),s+=1;var y=32-Ve(r)+p;if(30<y){var S=p-p%5;y=(c&(1<<S)-1).toString(32),c>>=S,p-=S,pa=1<<32-Ve(r)+p|s<<p|c,xa=y+t}else pa=1<<y|s<<p|c,xa=t}function xd(t){t.return!==null&&(Ha(t,1),Sp(t,1,0))}function gd(t){for(;t===mc;)mc=Xi[--Wi],Xi[Wi]=null,Hs=Xi[--Wi],Xi[Wi]=null;for(;t===fl;)fl=Hr[--Ur],Hr[Ur]=null,xa=Hr[--Ur],Hr[Ur]=null,pa=Hr[--Ur],Hr[Ur]=null}function Cp(t,r){Hr[Ur++]=pa,Hr[Ur++]=xa,Hr[Ur++]=fl,pa=r.id,xa=r.overflow,fl=t}var Pn=null,mn=null,Lt=!1,hl=null,qr=!1,yd=Error(i(519));function ml(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Us(Ir(r,t)),yd}function Ep(t){var r=t.stateNode,s=t.type,c=t.memoizedProps;switch(r[xn]=t,r[gn]=c,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<uo.length;s++)Dt(uo[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),Sr(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Dt("invalid",r);break;case"textarea":Dt("invalid",r),Ln(r,c.value,c.defaultValue,c.children)}s=c.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||r.textContent===""+s||c.suppressHydrationWarning===!0||q1(r.textContent,s)?(c.popover!=null&&(Dt("beforetoggle",r),Dt("toggle",r)),c.onScroll!=null&&Dt("scroll",r),c.onScrollEnd!=null&&Dt("scrollend",r),c.onClick!=null&&(r.onclick=tr),r=!0):r=!1,r||ml(t,!0)}function Np(t){for(Pn=t.return;Pn;)switch(Pn.tag){case 5:case 31:case 13:qr=!1;return;case 27:case 3:qr=!0;return;default:Pn=Pn.return}}function Gi(t){if(t!==Pn)return!1;if(!Lt)return Np(t),Lt=!0,!1;var r=t.tag,s;if((s=r!==3&&r!==27)&&((s=r===5)&&(s=t.type,s=!(s!=="form"&&s!=="button")||Of(t.type,t.memoizedProps)),s=!s),s&&mn&&ml(t),Np(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));mn=Z1(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));mn=Z1(t)}else r===27?(r=mn,Al(t.type)?(t=Uf,Uf=null,mn=t):mn=r):mn=Pn?Xr(t.stateNode.nextSibling):null;return!0}function ii(){mn=Pn=null,Lt=!1}function bd(){var t=hl;return t!==null&&(yr===null?yr=t:yr.push.apply(yr,t),hl=null),t}function Us(t){hl===null?hl=[t]:hl.push(t)}var vd=B(null),si=null,Ua=null;function pl(t,r,s){T(vd,r._currentValue),r._currentValue=s}function qa(t){t._currentValue=vd.current,U(vd)}function wd(t,r,s){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===s)break;t=t.return}}function kd(t,r,s,c){var p=t.child;for(p!==null&&(p.return=t);p!==null;){var y=p.dependencies;if(y!==null){var S=p.child;y=y.firstContext;e:for(;y!==null;){var 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),wd(y.return,s,t),c||(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),wd(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 Vi(t,r,s,c){t=null;for(var p=r,y=!1;p!==null;){if(!y){if((p.flags&524288)!==0)y=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var S=p.alternate;if(S===null)throw Error(i(387));if(S=S.memoizedProps,S!==null){var M=p.type;Cr(p.pendingProps.value,S.value)||(t!==null?t.push(M):t=[M])}}else if(p===ze.current){if(S=p.alternate,S===null)throw Error(i(387));S.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(t!==null?t.push(xo):t=[xo])}p=p.return}t!==null&&kd(r,t,s,c),r.flags|=262144}function pc(t){for(t=t.firstContext;t!==null;){if(!Cr(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function oi(t){si=t,Ua=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Qn(t){return Ap(si,t)}function xc(t,r){return si===null&&oi(t),Ap(t,r)}function Ap(t,r){var s=r._currentValue;if(r={context:r,memoizedValue:s,next:null},Ua===null){if(t===null)throw Error(i(308));Ua=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else Ua=Ua.next=r;return s}var Wv=typeof AbortController<"u"?AbortController:function(){var t=[],r=this.signal={aborted:!1,addEventListener:function(s,c){t.push(c)}};this.abort=function(){r.aborted=!0,t.forEach(function(s){return s()})}},Gv=e.unstable_scheduleCallback,Vv=e.unstable_NormalPriority,Mn={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function jd(){return{controller:new Wv,data:new Map,refCount:0}}function qs(t){t.refCount--,t.refCount===0&&Gv(Vv,function(){t.controller.abort()})}var Ys=null,Sd=0,Ki=0,Pi=null;function Kv(t,r){if(Ys===null){var s=Ys=[];Sd=0,Ki=Af(),Pi={status:"pending",value:void 0,then:function(c){s.push(c)}}}return Sd++,r.then(Dp,Dp),r}function Dp(){if(--Sd===0&&Ys!==null){Pi!==null&&(Pi.status="fulfilled");var t=Ys;Ys=null,Ki=0,Pi=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function Pv(t,r){var s=[],c={status:"pending",value:null,reason:null,then:function(p){s.push(p)}};return t.then(function(){c.status="fulfilled",c.value=r;for(var p=0;p<s.length;p++)(0,s[p])(r)},function(p){for(c.status="rejected",c.reason=p,p=0;p<s.length;p++)(0,s[p])(void 0)}),c}var Tp=W.S;W.S=function(t,r){h1=Se(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Kv(t,r),Tp!==null&&Tp(t,r)};var ci=B(null);function Cd(){var t=ci.current;return t!==null?t:cn.pooledCache}function gc(t,r){r===null?T(ci,ci.current):T(ci,r.pool)}function Fp(){var t=Cd();return t===null?null:{parent:Mn._currentValue,pool:t}}var Qi=Error(i(460)),Ed=Error(i(474)),yc=Error(i(542)),bc={then:function(){}};function Mp(t){return t=t.status,t==="fulfilled"||t==="rejected"}function Rp(t,r,s){switch(s=t[s],s===void 0?t.push(r):s!==r&&(r.then(tr,tr),r=s),r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,_p(t),t;default:if(typeof r.status=="string")r.then(tr,tr);else{if(t=cn,t!==null&&100<t.shellSuspendCounter)throw Error(i(482));t=r,t.status="pending",t.then(function(c){if(r.status==="pending"){var p=r;p.status="fulfilled",p.value=c}},function(c){if(r.status==="pending"){var p=r;p.status="rejected",p.reason=c}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,_p(t),t}throw di=r,Qi}}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,Qi):s}}var di=null;function zp(){if(di===null)throw Error(i(459));var t=di;return di=null,t}function _p(t){if(t===Qi||t===yc)throw Error(i(483))}var Zi=null,Xs=0;function vc(t){var r=Xs;return Xs+=1,Zi===null&&(Zi=[]),Rp(Zi,t,r)}function Ws(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function wc(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 Bp(t){function r(J,Q){if(t){var ae=J.deletions;ae===null?(J.deletions=[Q],J.flags|=16):ae.push(Q)}}function s(J,Q){if(!t)return null;for(;Q!==null;)r(J,Q),Q=Q.sibling;return null}function c(J){for(var Q=new Map;J!==null;)J.key!==null?Q.set(J.key,J):Q.set(J.index,J),J=J.sibling;return Q}function p(J,Q){return J=Ia(J,Q),J.index=0,J.sibling=null,J}function y(J,Q,ae){return J.index=ae,t?(ae=J.alternate,ae!==null?(ae=ae.index,ae<Q?(J.flags|=67108866,Q):ae):(J.flags|=67108866,Q)):(J.flags|=1048576,Q)}function S(J){return t&&J.alternate===null&&(J.flags|=67108866),J}function M(J,Q,ae,be){return Q===null||Q.tag!==6?(Q=md(ae,J.mode,be),Q.return=J,Q):(Q=p(Q,ae),Q.return=J,Q)}function G(J,Q,ae,be){var tt=ae.type;return tt===k?xe(J,Q,ae.props.children,be,ae.key):Q!==null&&(Q.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===q&&ui(tt)===Q.type)?(Q=p(Q,ae.props),Ws(Q,ae),Q.return=J,Q):(Q=hc(ae.type,ae.key,ae.props,null,J.mode,be),Ws(Q,ae),Q.return=J,Q)}function le(J,Q,ae,be){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==ae.containerInfo||Q.stateNode.implementation!==ae.implementation?(Q=pd(ae,J.mode,be),Q.return=J,Q):(Q=p(Q,ae.children||[]),Q.return=J,Q)}function xe(J,Q,ae,be,tt){return Q===null||Q.tag!==7?(Q=li(ae,J.mode,be,tt),Q.return=J,Q):(Q=p(Q,ae),Q.return=J,Q)}function Ce(J,Q,ae){if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return Q=md(""+Q,J.mode,ae),Q.return=J,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case b:return ae=hc(Q.type,Q.key,Q.props,null,J.mode,ae),Ws(ae,Q),ae.return=J,ae;case j:return Q=pd(Q,J.mode,ae),Q.return=J,Q;case q:return Q=ui(Q),Ce(J,Q,ae)}if(ee(Q)||L(Q))return Q=li(Q,J.mode,ae,null),Q.return=J,Q;if(typeof Q.then=="function")return Ce(J,vc(Q),ae);if(Q.$$typeof===_)return Ce(J,xc(J,Q),ae);wc(J,Q)}return null}function ce(J,Q,ae,be){var tt=Q!==null?Q.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint")return tt!==null?null:M(J,Q,""+ae,be);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case b:return ae.key===tt?G(J,Q,ae,be):null;case j:return ae.key===tt?le(J,Q,ae,be):null;case q:return ae=ui(ae),ce(J,Q,ae,be)}if(ee(ae)||L(ae))return tt!==null?null:xe(J,Q,ae,be,null);if(typeof ae.then=="function")return ce(J,Q,vc(ae),be);if(ae.$$typeof===_)return ce(J,Q,xc(J,ae),be);wc(J,ae)}return null}function fe(J,Q,ae,be,tt){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return J=J.get(ae)||null,M(Q,J,""+be,tt);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case b:return J=J.get(be.key===null?ae:be.key)||null,G(Q,J,be,tt);case j:return J=J.get(be.key===null?ae:be.key)||null,le(Q,J,be,tt);case q:return be=ui(be),fe(J,Q,ae,be,tt)}if(ee(be)||L(be))return J=J.get(ae)||null,xe(Q,J,be,tt,null);if(typeof be.then=="function")return fe(J,Q,ae,vc(be),tt);if(be.$$typeof===_)return fe(J,Q,ae,xc(Q,be),tt);wc(Q,be)}return null}function Ye(J,Q,ae,be){for(var tt=null,qt=null,Ge=Q,vt=Q=0,Rt=null;Ge!==null&&vt<ae.length;vt++){Ge.index>vt?(Rt=Ge,Ge=null):Rt=Ge.sibling;var Yt=ce(J,Ge,ae[vt],be);if(Yt===null){Ge===null&&(Ge=Rt);break}t&&Ge&&Yt.alternate===null&&r(J,Ge),Q=y(Yt,Q,vt),qt===null?tt=Yt:qt.sibling=Yt,qt=Yt,Ge=Rt}if(vt===ae.length)return s(J,Ge),Lt&&Ha(J,vt),tt;if(Ge===null){for(;vt<ae.length;vt++)Ge=Ce(J,ae[vt],be),Ge!==null&&(Q=y(Ge,Q,vt),qt===null?tt=Ge:qt.sibling=Ge,qt=Ge);return Lt&&Ha(J,vt),tt}for(Ge=c(Ge);vt<ae.length;vt++)Rt=fe(Ge,J,vt,ae[vt],be),Rt!==null&&(t&&Rt.alternate!==null&&Ge.delete(Rt.key===null?vt:Rt.key),Q=y(Rt,Q,vt),qt===null?tt=Rt:qt.sibling=Rt,qt=Rt);return t&&Ge.forEach(function(Rl){return r(J,Rl)}),Lt&&Ha(J,vt),tt}function lt(J,Q,ae,be){if(ae==null)throw Error(i(151));for(var tt=null,qt=null,Ge=Q,vt=Q=0,Rt=null,Yt=ae.next();Ge!==null&&!Yt.done;vt++,Yt=ae.next()){Ge.index>vt?(Rt=Ge,Ge=null):Rt=Ge.sibling;var Rl=ce(J,Ge,Yt.value,be);if(Rl===null){Ge===null&&(Ge=Rt);break}t&&Ge&&Rl.alternate===null&&r(J,Ge),Q=y(Rl,Q,vt),qt===null?tt=Rl:qt.sibling=Rl,qt=Rl,Ge=Rt}if(Yt.done)return s(J,Ge),Lt&&Ha(J,vt),tt;if(Ge===null){for(;!Yt.done;vt++,Yt=ae.next())Yt=Ce(J,Yt.value,be),Yt!==null&&(Q=y(Yt,Q,vt),qt===null?tt=Yt:qt.sibling=Yt,qt=Yt);return Lt&&Ha(J,vt),tt}for(Ge=c(Ge);!Yt.done;vt++,Yt=ae.next())Yt=fe(Ge,J,vt,Yt.value,be),Yt!==null&&(t&&Yt.alternate!==null&&Ge.delete(Yt.key===null?vt:Yt.key),Q=y(Yt,Q,vt),qt===null?tt=Yt:qt.sibling=Yt,qt=Yt);return t&&Ge.forEach(function(sw){return r(J,sw)}),Lt&&Ha(J,vt),tt}function rn(J,Q,ae,be){if(typeof ae=="object"&&ae!==null&&ae.type===k&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case b:e:{for(var tt=ae.key;Q!==null;){if(Q.key===tt){if(tt=ae.type,tt===k){if(Q.tag===7){s(J,Q.sibling),be=p(Q,ae.props.children),be.return=J,J=be;break e}}else if(Q.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===q&&ui(tt)===Q.type){s(J,Q.sibling),be=p(Q,ae.props),Ws(be,ae),be.return=J,J=be;break e}s(J,Q);break}else r(J,Q);Q=Q.sibling}ae.type===k?(be=li(ae.props.children,J.mode,be,ae.key),be.return=J,J=be):(be=hc(ae.type,ae.key,ae.props,null,J.mode,be),Ws(be,ae),be.return=J,J=be)}return S(J);case j:e:{for(tt=ae.key;Q!==null;){if(Q.key===tt)if(Q.tag===4&&Q.stateNode.containerInfo===ae.containerInfo&&Q.stateNode.implementation===ae.implementation){s(J,Q.sibling),be=p(Q,ae.children||[]),be.return=J,J=be;break e}else{s(J,Q);break}else r(J,Q);Q=Q.sibling}be=pd(ae,J.mode,be),be.return=J,J=be}return S(J);case q:return ae=ui(ae),rn(J,Q,ae,be)}if(ee(ae))return Ye(J,Q,ae,be);if(L(ae)){if(tt=L(ae),typeof tt!="function")throw Error(i(150));return ae=tt.call(ae),lt(J,Q,ae,be)}if(typeof ae.then=="function")return rn(J,Q,vc(ae),be);if(ae.$$typeof===_)return rn(J,Q,xc(J,ae),be);wc(J,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint"?(ae=""+ae,Q!==null&&Q.tag===6?(s(J,Q.sibling),be=p(Q,ae),be.return=J,J=be):(s(J,Q),be=md(ae,J.mode,be),be.return=J,J=be),S(J)):s(J,Q)}return function(J,Q,ae,be){try{Xs=0;var tt=rn(J,Q,ae,be);return Zi=null,tt}catch(Ge){if(Ge===Qi||Ge===yc)throw Ge;var qt=Er(29,Ge,null,J.mode);return qt.lanes=be,qt.return=J,qt}finally{}}}var fi=Bp(!0),Op=Bp(!1),xl=!1;function Nd(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ad(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 gl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function yl(t,r,s){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Vt&2)!==0){var p=c.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),c.pending=r,r=fc(t),vp(t,null,s),r}return dc(t,c,r,s),fc(t)}function Gs(t,r,s){if(r=r.updateQueue,r!==null&&(r=r.shared,(s&4194048)!==0)){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,sn(t,s)}}function Dd(t,r){var s=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,s===c)){var p=null,y=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};y===null?p=y=S:y=y.next=S,s=s.next}while(s!==null);y===null?p=y=r:y=y.next=r}else p=y=r;s={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:y,shared:c.shared,callbacks:c.callbacks},t.updateQueue=s;return}t=s.lastBaseUpdate,t===null?s.firstBaseUpdate=r:t.next=r,s.lastBaseUpdate=r}var Td=!1;function Vs(){if(Td){var t=Pi;if(t!==null)throw t}}function Ks(t,r,s,c){Td=!1;var p=t.updateQueue;xl=!1;var y=p.firstBaseUpdate,S=p.lastBaseUpdate,M=p.shared.pending;if(M!==null){p.shared.pending=null;var G=M,le=G.next;G.next=null,S===null?y=le:S.next=le,S=G;var xe=t.alternate;xe!==null&&(xe=xe.updateQueue,M=xe.lastBaseUpdate,M!==S&&(M===null?xe.firstBaseUpdate=le:M.next=le,xe.lastBaseUpdate=G))}if(y!==null){var Ce=p.baseState;S=0,xe=le=G=null,M=y;do{var ce=M.lane&-536870913,fe=ce!==M.lane;if(fe?(Mt&ce)===ce:(c&ce)===ce){ce!==0&&ce===Ki&&(Td=!0),xe!==null&&(xe=xe.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var Ye=t,lt=M;ce=r;var rn=s;switch(lt.tag){case 1:if(Ye=lt.payload,typeof Ye=="function"){Ce=Ye.call(rn,Ce,ce);break e}Ce=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=lt.payload,ce=typeof Ye=="function"?Ye.call(rn,Ce,ce):Ye,ce==null)break e;Ce=g({},Ce,ce);break e;case 2:xl=!0}}ce=M.callback,ce!==null&&(t.flags|=64,fe&&(t.flags|=8192),fe=p.callbacks,fe===null?p.callbacks=[ce]:fe.push(ce))}else fe={lane:ce,tag:M.tag,payload:M.payload,callback:M.callback,next:null},xe===null?(le=xe=fe,G=Ce):xe=xe.next=fe,S|=ce;if(M=M.next,M===null){if(M=p.shared.pending,M===null)break;fe=M,M=fe.next,fe.next=null,p.lastBaseUpdate=fe,p.shared.pending=null}}while(!0);xe===null&&(G=Ce),p.baseState=G,p.firstBaseUpdate=le,p.lastBaseUpdate=xe,y===null&&(p.shared.lanes=0),jl|=S,t.lanes=S,t.memoizedState=Ce}}function $p(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function Lp(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;t<s.length;t++)$p(s[t],r)}var Ji=B(null),kc=B(0);function Ip(t,r){t=Za,T(kc,t),T(Ji,r),Za=t|r.baseLanes}function Fd(){T(kc,Za),T(Ji,Ji.current)}function Md(){Za=kc.current,U(Ji),U(kc)}var Nr=B(null),Yr=null;function bl(t){var r=t.alternate;T(Nn,Nn.current&1),T(Nr,t),Yr===null&&(r===null||Ji.current!==null||r.memoizedState!==null)&&(Yr=t)}function Rd(t){T(Nn,Nn.current),T(Nr,t),Yr===null&&(Yr=t)}function Hp(t){t.tag===22?(T(Nn,Nn.current),T(Nr,t),Yr===null&&(Yr=t)):vl()}function vl(){T(Nn,Nn.current),T(Nr,Nr.current)}function Ar(t){U(Nr),Yr===t&&(Yr=null),U(Nn)}var Nn=B(0);function jc(t){for(var r=t;r!==null;){if(r.tag===13){var s=r.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||If(s)||Hf(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 Ya=0,gt=null,tn=null,Rn=null,Sc=!1,es=!1,hi=!1,Cc=0,Ps=0,ts=null,Qv=0;function Sn(){throw Error(i(321))}function zd(t,r){if(r===null)return!1;for(var s=0;s<r.length&&s<t.length;s++)if(!Cr(t[s],r[s]))return!1;return!0}function _d(t,r,s,c,p,y){return Ya=y,gt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,W.H=t===null||t.memoizedState===null?Sx:Pd,hi=!1,y=s(c,p),hi=!1,es&&(y=qp(r,s,c,p)),Up(t),y}function Up(t){W.H=Js;var r=tn!==null&&tn.next!==null;if(Ya=0,Rn=tn=gt=null,Sc=!1,Ps=0,ts=null,r)throw Error(i(300));t===null||zn||(t=t.dependencies,t!==null&&pc(t)&&(zn=!0))}function qp(t,r,s,c){gt=t;var p=0;do{if(es&&(ts=null),Ps=0,es=!1,25<=p)throw Error(i(301));if(p+=1,Rn=tn=null,t.updateQueue!=null){var y=t.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}W.H=Cx,y=r(s,c)}while(es);return y}function Zv(){var t=W.H,r=t.useState()[0];return r=typeof r.then=="function"?Qs(r):r,t=t.useState()[0],(tn!==null?tn.memoizedState:null)!==t&&(gt.flags|=1024),r}function Bd(){var t=Cc!==0;return Cc=0,t}function Od(t,r,s){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~s}function $d(t){if(Sc){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}Sc=!1}Ya=0,Rn=tn=gt=null,es=!1,Ps=Cc=0,ts=null}function ir(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Rn===null?gt.memoizedState=Rn=t:Rn=Rn.next=t,Rn}function An(){if(tn===null){var t=gt.alternate;t=t!==null?t.memoizedState:null}else t=tn.next;var r=Rn===null?gt.memoizedState:Rn.next;if(r!==null)Rn=r,tn=t;else{if(t===null)throw gt.alternate===null?Error(i(467)):Error(i(310));tn=t,t={memoizedState:tn.memoizedState,baseState:tn.baseState,baseQueue:tn.baseQueue,queue:tn.queue,next:null},Rn===null?gt.memoizedState=Rn=t:Rn=Rn.next=t}return Rn}function Ec(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Qs(t){var r=Ps;return Ps+=1,ts===null&&(ts=[]),t=Rp(ts,t,r),r=gt,(Rn===null?r.memoizedState:Rn.next)===null&&(r=r.alternate,W.H=r===null||r.memoizedState===null?Sx:Pd),t}function Nc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Qs(t);if(t.$$typeof===_)return Qn(t)}throw Error(i(438,String(t)))}function Ld(t){var r=null,s=gt.updateQueue;if(s!==null&&(r=s.memoCache),r==null){var c=gt.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(r={data:c.data.map(function(p){return p.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),s===null&&(s=Ec(),gt.updateQueue=s),s.memoCache=r,s=r.data[r.index],s===void 0)for(s=r.data[r.index]=Array(t),c=0;c<t;c++)s[c]=A;return r.index++,s}function Xa(t,r){return typeof r=="function"?r(t):r}function Ac(t){var r=An();return Id(r,tn,t)}function Id(t,r,s){var c=t.queue;if(c===null)throw Error(i(311));c.lastRenderedReducer=s;var p=t.baseQueue,y=c.pending;if(y!==null){if(p!==null){var S=p.next;p.next=y.next,y.next=S}r.baseQueue=p=y,c.pending=null}if(y=t.baseState,p===null)t.memoizedState=y;else{r=p.next;var M=S=null,G=null,le=r,xe=!1;do{var Ce=le.lane&-536870913;if(Ce!==le.lane?(Mt&Ce)===Ce:(Ya&Ce)===Ce){var ce=le.revertLane;if(ce===0)G!==null&&(G=G.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),Ce===Ki&&(xe=!0);else if((Ya&ce)===ce){le=le.next,ce===Ki&&(xe=!0);continue}else Ce={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},G===null?(M=G=Ce,S=y):G=G.next=Ce,gt.lanes|=ce,jl|=ce;Ce=le.action,hi&&s(y,Ce),y=le.hasEagerState?le.eagerState:s(y,Ce)}else ce={lane:Ce,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},G===null?(M=G=ce,S=y):G=G.next=ce,gt.lanes|=Ce,jl|=Ce;le=le.next}while(le!==null&&le!==r);if(G===null?S=y:G.next=M,!Cr(y,t.memoizedState)&&(zn=!0,xe&&(s=Pi,s!==null)))throw s;t.memoizedState=y,t.baseState=S,t.baseQueue=G,c.lastRenderedState=y}return p===null&&(c.lanes=0),[t.memoizedState,c.dispatch]}function Hd(t){var r=An(),s=r.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=t;var c=s.dispatch,p=s.pending,y=r.memoizedState;if(p!==null){s.pending=null;var S=p=p.next;do y=t(y,S.action),S=S.next;while(S!==p);Cr(y,r.memoizedState)||(zn=!0),r.memoizedState=y,r.baseQueue===null&&(r.baseState=y),s.lastRenderedState=y}return[y,c]}function Yp(t,r,s){var c=gt,p=An(),y=Lt;if(y){if(s===void 0)throw Error(i(407));s=s()}else s=r();var S=!Cr((tn||p).memoizedState,s);if(S&&(p.memoizedState=s,zn=!0),p=p.queue,Yd(Gp.bind(null,c,p,t),[t]),p.getSnapshot!==r||S||Rn!==null&&Rn.memoizedState.tag&1){if(c.flags|=2048,ns(9,{destroy:void 0},Wp.bind(null,c,p,s,r),null),cn===null)throw Error(i(349));y||(Ya&127)!==0||Xp(c,r,s)}return s}function Xp(t,r,s){t.flags|=16384,t={getSnapshot:r,value:s},r=gt.updateQueue,r===null?(r=Ec(),gt.updateQueue=r,r.stores=[t]):(s=r.stores,s===null?r.stores=[t]:s.push(t))}function Wp(t,r,s,c){r.value=s,r.getSnapshot=c,Vp(r)&&Kp(t)}function Gp(t,r,s){return s(function(){Vp(r)&&Kp(t)})}function Vp(t){var r=t.getSnapshot;t=t.value;try{var s=r();return!Cr(t,s)}catch{return!0}}function Kp(t){var r=ai(t,2);r!==null&&br(r,t,2)}function Ud(t){var r=ir();if(typeof t=="function"){var s=t;if(t=s(),hi){rt(!0);try{s()}finally{rt(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xa,lastRenderedState:t},r}function Pp(t,r,s,c){return t.baseState=s,Id(t,tn,typeof c=="function"?c:Xa)}function Jv(t,r,s,c,p){if(Fc(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)}};W.T!==null?s(!0):y.isTransition=!1,c(y),s=r.pending,s===null?(y.next=r.pending=y,Qp(r,y)):(y.next=s.next,r.pending=s.next=y)}}function Qp(t,r){var s=r.action,c=r.payload,p=t.state;if(r.isTransition){var y=W.T,S={};W.T=S;try{var M=s(p,c),G=W.S;G!==null&&G(S,M),Zp(t,r,M)}catch(le){qd(t,r,le)}finally{y!==null&&S.types!==null&&(y.types=S.types),W.T=y}}else try{y=s(p,c),Zp(t,r,y)}catch(le){qd(t,r,le)}}function Zp(t,r,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(c){Jp(t,r,c)},function(c){return qd(t,r,c)}):Jp(t,r,s)}function Jp(t,r,s){r.status="fulfilled",r.value=s,ex(r),t.state=s,r=t.pending,r!==null&&(s=r.next,s===r?t.pending=null:(s=s.next,r.next=s,Qp(t,s)))}function qd(t,r,s){var c=t.pending;if(t.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=s,ex(r),r=r.next;while(r!==c)}t.action=null}function ex(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function tx(t,r){return r}function nx(t,r){if(Lt){var s=cn.formState;if(s!==null){e:{var c=gt;if(Lt){if(mn){t:{for(var p=mn,y=qr;p.nodeType!==8;){if(!y){p=null;break t}if(p=Xr(p.nextSibling),p===null){p=null;break t}}y=p.data,p=y==="F!"||y==="F"?p:null}if(p){mn=Xr(p.nextSibling),c=p.data==="F!";break e}}ml(c)}c=!1}c&&(r=s[0])}}return s=ir(),s.memoizedState=s.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:tx,lastRenderedState:r},s.queue=c,s=wx.bind(null,gt,c),c.dispatch=s,c=Ud(!1),y=Kd.bind(null,gt,!1,c.queue),c=ir(),p={state:r,dispatch:null,action:t,pending:null},c.queue=p,s=Jv.bind(null,gt,p,y,s),p.dispatch=s,c.memoizedState=t,[r,s,!1]}function rx(t){var r=An();return ax(r,tn,t)}function ax(t,r,s){if(r=Id(t,r,tx)[0],t=Ac(Xa)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=Qs(r)}catch(S){throw S===Qi?yc:S}else c=r;r=An();var p=r.queue,y=p.dispatch;return s!==r.memoizedState&&(gt.flags|=2048,ns(9,{destroy:void 0},e2.bind(null,p,s),null)),[c,y,t]}function e2(t,r){t.action=r}function lx(t){var r=An(),s=tn;if(s!==null)return ax(r,s,t);An(),r=r.memoizedState,s=An();var c=s.queue.dispatch;return s.memoizedState=t,[r,c,!1]}function ns(t,r,s,c){return t={tag:t,create:s,deps:c,inst:r,next:null},r=gt.updateQueue,r===null&&(r=Ec(),gt.updateQueue=r),s=r.lastEffect,s===null?r.lastEffect=t.next=t:(c=s.next,s.next=t,t.next=c,r.lastEffect=t),t}function ix(){return An().memoizedState}function Dc(t,r,s,c){var p=ir();gt.flags|=t,p.memoizedState=ns(1|r,{destroy:void 0},s,c===void 0?null:c)}function Tc(t,r,s,c){var p=An();c=c===void 0?null:c;var y=p.memoizedState.inst;tn!==null&&c!==null&&zd(c,tn.memoizedState.deps)?p.memoizedState=ns(r,y,s,c):(gt.flags|=t,p.memoizedState=ns(1|r,y,s,c))}function sx(t,r){Dc(8390656,8,t,r)}function Yd(t,r){Tc(2048,8,t,r)}function t2(t){gt.flags|=4;var r=gt.updateQueue;if(r===null)r=Ec(),gt.updateQueue=r,r.events=[t];else{var s=r.events;s===null?r.events=[t]:s.push(t)}}function ox(t){var r=An().memoizedState;return t2({ref:r,nextImpl:t}),function(){if((Vt&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function cx(t,r){return Tc(4,2,t,r)}function ux(t,r){return Tc(4,4,t,r)}function dx(t,r){if(typeof r=="function"){t=t();var s=r(t);return function(){typeof s=="function"?s():r(null)}}if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function fx(t,r,s){s=s!=null?s.concat([t]):null,Tc(4,4,dx.bind(null,r,t),s)}function Xd(){}function hx(t,r){var s=An();r=r===void 0?null:r;var c=s.memoizedState;return r!==null&&zd(r,c[1])?c[0]:(s.memoizedState=[t,r],t)}function mx(t,r){var s=An();r=r===void 0?null:r;var c=s.memoizedState;if(r!==null&&zd(r,c[1]))return c[0];if(c=t(),hi){rt(!0);try{t()}finally{rt(!1)}}return s.memoizedState=[c,r],c}function Wd(t,r,s){return s===void 0||(Ya&1073741824)!==0&&(Mt&261930)===0?t.memoizedState=r:(t.memoizedState=s,t=p1(),gt.lanes|=t,jl|=t,s)}function px(t,r,s,c){return Cr(s,r)?s:Ji.current!==null?(t=Wd(t,s,c),Cr(t,r)||(zn=!0),t):(Ya&42)===0||(Ya&1073741824)!==0&&(Mt&261930)===0?(zn=!0,t.memoizedState=s):(t=p1(),gt.lanes|=t,jl|=t,r)}function xx(t,r,s,c,p){var y=oe.p;oe.p=y!==0&&8>y?y:8;var S=W.T,M={};W.T=M,Kd(t,!1,r,s);try{var G=p(),le=W.S;if(le!==null&&le(M,G),G!==null&&typeof G=="object"&&typeof G.then=="function"){var xe=Pv(G,c);Zs(t,r,xe,Fr(t))}else Zs(t,r,c,Fr(t))}catch(Ce){Zs(t,r,{then:function(){},status:"rejected",reason:Ce},Fr())}finally{oe.p=y,S!==null&&M.types!==null&&(S.types=M.types),W.T=S}}function n2(){}function Gd(t,r,s,c){if(t.tag!==5)throw Error(i(476));var p=gx(t).queue;xx(t,p,r,de,s===null?n2:function(){return yx(t),s(c)})}function gx(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:Xa,lastRenderedState:de},next:null};var s={};return r.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xa,lastRenderedState:s},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function yx(t){var r=gx(t);r.next===null&&(r=t.alternate.memoizedState),Zs(t,r.next.queue,{},Fr())}function Vd(){return Qn(xo)}function bx(){return An().memoizedState}function vx(){return An().memoizedState}function r2(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=Fr();t=gl(s);var c=yl(r,t,s);c!==null&&(br(c,r,s),Gs(c,r,s)),r={cache:jd()},t.payload=r;return}r=r.return}}function a2(t,r,s){var c=Fr();s={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Fc(t)?kx(r,s):(s=fd(t,r,s,c),s!==null&&(br(s,t,c),jx(s,r,c)))}function wx(t,r,s){var c=Fr();Zs(t,r,s,c)}function Zs(t,r,s,c){var p={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Fc(t))kx(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,Cr(M,S))return dc(t,r,p,0),cn===null&&uc(),!1}catch{}finally{}if(s=fd(t,r,p,c),s!==null)return br(s,t,c),jx(s,r,c),!0}return!1}function Kd(t,r,s,c){if(c={lane:2,revertLane:Af(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Fc(t)){if(r)throw Error(i(479))}else r=fd(t,s,c,2),r!==null&&br(r,t,2)}function Fc(t){var r=t.alternate;return t===gt||r!==null&&r===gt}function kx(t,r){es=Sc=!0;var s=t.pending;s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r}function jx(t,r,s){if((s&4194048)!==0){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,sn(t,s)}}var Js={readContext:Qn,use:Nc,useCallback:Sn,useContext:Sn,useEffect:Sn,useImperativeHandle:Sn,useLayoutEffect:Sn,useInsertionEffect:Sn,useMemo:Sn,useReducer:Sn,useRef:Sn,useState:Sn,useDebugValue:Sn,useDeferredValue:Sn,useTransition:Sn,useSyncExternalStore:Sn,useId:Sn,useHostTransitionStatus:Sn,useFormState:Sn,useActionState:Sn,useOptimistic:Sn,useMemoCache:Sn,useCacheRefresh:Sn};Js.useEffectEvent=Sn;var Sx={readContext:Qn,use:Nc,useCallback:function(t,r){return ir().memoizedState=[t,r===void 0?null:r],t},useContext:Qn,useEffect:sx,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,Dc(4194308,4,dx.bind(null,r,t),s)},useLayoutEffect:function(t,r){return Dc(4194308,4,t,r)},useInsertionEffect:function(t,r){Dc(4,2,t,r)},useMemo:function(t,r){var s=ir();r=r===void 0?null:r;var c=t();if(hi){rt(!0);try{t()}finally{rt(!1)}}return s.memoizedState=[c,r],c},useReducer:function(t,r,s){var c=ir();if(s!==void 0){var p=s(r);if(hi){rt(!0);try{s(r)}finally{rt(!1)}}}else p=r;return c.memoizedState=c.baseState=p,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:p},c.queue=t,t=t.dispatch=a2.bind(null,gt,t),[c.memoizedState,t]},useRef:function(t){var r=ir();return t={current:t},r.memoizedState=t},useState:function(t){t=Ud(t);var r=t.queue,s=wx.bind(null,gt,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:Xd,useDeferredValue:function(t,r){var s=ir();return Wd(s,t,r)},useTransition:function(){var t=Ud(!1);return t=xx.bind(null,gt,t.queue,!0,!1),ir().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var c=gt,p=ir();if(Lt){if(s===void 0)throw Error(i(407));s=s()}else{if(s=r(),cn===null)throw Error(i(349));(Mt&127)!==0||Xp(c,r,s)}p.memoizedState=s;var y={value:s,getSnapshot:r};return p.queue=y,sx(Gp.bind(null,c,y,t),[t]),c.flags|=2048,ns(9,{destroy:void 0},Wp.bind(null,c,y,s,r),null),s},useId:function(){var t=ir(),r=cn.identifierPrefix;if(Lt){var s=xa,c=pa;s=(c&~(1<<32-Ve(c)-1)).toString(32)+s,r="_"+r+"R_"+s,s=Cc++,0<s&&(r+="H"+s.toString(32)),r+="_"}else s=Qv++,r="_"+r+"r_"+s.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Vd,useFormState:nx,useActionState:nx,useOptimistic:function(t){var r=ir();r.memoizedState=r.baseState=t;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=s,r=Kd.bind(null,gt,!0,s),s.dispatch=r,[t,r]},useMemoCache:Ld,useCacheRefresh:function(){return ir().memoizedState=r2.bind(null,gt)},useEffectEvent:function(t){var r=ir(),s={impl:t};return r.memoizedState=s,function(){if((Vt&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}},Pd={readContext:Qn,use:Nc,useCallback:hx,useContext:Qn,useEffect:Yd,useImperativeHandle:fx,useInsertionEffect:cx,useLayoutEffect:ux,useMemo:mx,useReducer:Ac,useRef:ix,useState:function(){return Ac(Xa)},useDebugValue:Xd,useDeferredValue:function(t,r){var s=An();return px(s,tn.memoizedState,t,r)},useTransition:function(){var t=Ac(Xa)[0],r=An().memoizedState;return[typeof t=="boolean"?t:Qs(t),r]},useSyncExternalStore:Yp,useId:bx,useHostTransitionStatus:Vd,useFormState:rx,useActionState:rx,useOptimistic:function(t,r){var s=An();return Pp(s,tn,t,r)},useMemoCache:Ld,useCacheRefresh:vx};Pd.useEffectEvent=ox;var Cx={readContext:Qn,use:Nc,useCallback:hx,useContext:Qn,useEffect:Yd,useImperativeHandle:fx,useInsertionEffect:cx,useLayoutEffect:ux,useMemo:mx,useReducer:Hd,useRef:ix,useState:function(){return Hd(Xa)},useDebugValue:Xd,useDeferredValue:function(t,r){var s=An();return tn===null?Wd(s,t,r):px(s,tn.memoizedState,t,r)},useTransition:function(){var t=Hd(Xa)[0],r=An().memoizedState;return[typeof t=="boolean"?t:Qs(t),r]},useSyncExternalStore:Yp,useId:bx,useHostTransitionStatus:Vd,useFormState:lx,useActionState:lx,useOptimistic:function(t,r){var s=An();return tn!==null?Pp(s,tn,t,r):(s.baseState=t,[t,s.queue.dispatch])},useMemoCache:Ld,useCacheRefresh:vx};Cx.useEffectEvent=ox;function Qd(t,r,s,c){r=t.memoizedState,s=s(c,r),s=s==null?r:g({},r,s),t.memoizedState=s,t.lanes===0&&(t.updateQueue.baseState=s)}var Zd={enqueueSetState:function(t,r,s){t=t._reactInternals;var c=Fr(),p=gl(c);p.payload=r,s!=null&&(p.callback=s),r=yl(t,p,c),r!==null&&(br(r,t,c),Gs(r,t,c))},enqueueReplaceState:function(t,r,s){t=t._reactInternals;var c=Fr(),p=gl(c);p.tag=1,p.payload=r,s!=null&&(p.callback=s),r=yl(t,p,c),r!==null&&(br(r,t,c),Gs(r,t,c))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var s=Fr(),c=gl(s);c.tag=2,r!=null&&(c.callback=r),r=yl(t,c,s),r!==null&&(br(r,t,s),Gs(r,t,s))}};function Ex(t,r,s,c,p,y,S){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,y,S):r.prototype&&r.prototype.isPureReactComponent?!Ls(s,c)||!Ls(p,y):!0}function Nx(t,r,s,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(s,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(s,c),r.state!==t&&Zd.enqueueReplaceState(r,r.state,null)}function mi(t,r){var s=r;if("ref"in r){s={};for(var c in r)c!=="ref"&&(s[c]=r[c])}if(t=t.defaultProps){s===r&&(s=g({},s));for(var p in t)s[p]===void 0&&(s[p]=t[p])}return s}function Ax(t){cc(t)}function Dx(t){console.error(t)}function Tx(t){cc(t)}function Mc(t,r){try{var s=t.onUncaughtError;s(r.value,{componentStack:r.stack})}catch(c){setTimeout(function(){throw c})}}function Fx(t,r,s){try{var c=t.onCaughtError;c(s.value,{componentStack:s.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function Jd(t,r,s){return s=gl(s),s.tag=3,s.payload={element:null},s.callback=function(){Mc(t,r)},s}function Mx(t){return t=gl(t),t.tag=3,t}function Rx(t,r,s,c){var p=s.type.getDerivedStateFromError;if(typeof p=="function"){var y=c.value;t.payload=function(){return p(y)},t.callback=function(){Fx(r,s,c)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(t.callback=function(){Fx(r,s,c),typeof p!="function"&&(Sl===null?Sl=new Set([this]):Sl.add(this));var M=c.stack;this.componentDidCatch(c.value,{componentStack:M!==null?M:""})})}function l2(t,r,s,c,p){if(s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=s.alternate,r!==null&&Vi(r,s,p,!0),s=Nr.current,s!==null){switch(s.tag){case 31:case 13:return Yr===null?Yc():s.alternate===null&&Cn===0&&(Cn=3),s.flags&=-257,s.flags|=65536,s.lanes=p,c===bc?s.flags|=16384:(r=s.updateQueue,r===null?s.updateQueue=new Set([c]):r.add(c),Cf(t,c,p)),!1;case 22:return s.flags|=65536,c===bc?s.flags|=16384:(r=s.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([c])},s.updateQueue=r):(s=r.retryQueue,s===null?r.retryQueue=new Set([c]):s.add(c)),Cf(t,c,p)),!1}throw Error(i(435,s.tag))}return Cf(t,c,p),Yc(),!1}if(Lt)return r=Nr.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,c!==yd&&(t=Error(i(422),{cause:c}),Us(Ir(t,s)))):(c!==yd&&(r=Error(i(423),{cause:c}),Us(Ir(r,s))),t=t.current.alternate,t.flags|=65536,p&=-p,t.lanes|=p,c=Ir(c,s),p=Jd(t.stateNode,c,p),Dd(t,p),Cn!==4&&(Cn=2)),!1;var y=Error(i(520),{cause:c});if(y=Ir(y,s),so===null?so=[y]:so.push(y),Cn!==4&&(Cn=2),r===null)return!0;c=Ir(c,s),s=r;do{switch(s.tag){case 3:return s.flags|=65536,t=p&-p,s.lanes|=t,t=Jd(s.stateNode,c,t),Dd(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"&&(Sl===null||!Sl.has(y))))return s.flags|=65536,p&=-p,s.lanes|=p,p=Mx(p),Rx(p,t,s,c),Dd(s,p),!1}s=s.return}while(s!==null);return!1}var ef=Error(i(461)),zn=!1;function Zn(t,r,s,c){r.child=t===null?Op(r,null,s,c):fi(r,t.child,s,c)}function zx(t,r,s,c,p){s=s.render;var y=r.ref;if("ref"in c){var S={};for(var M in c)M!=="ref"&&(S[M]=c[M])}else S=c;return oi(r),c=_d(t,r,s,S,y,p),M=Bd(),t!==null&&!zn?(Od(t,r,p),Wa(t,r,p)):(Lt&&M&&xd(r),r.flags|=1,Zn(t,r,c,p),r.child)}function _x(t,r,s,c,p){if(t===null){var y=s.type;return typeof y=="function"&&!hd(y)&&y.defaultProps===void 0&&s.compare===null?(r.tag=15,r.type=y,Bx(t,r,y,c,p)):(t=hc(s.type,null,c,r,r.mode,p),t.ref=r.ref,t.return=r,r.child=t)}if(y=t.child,!cf(t,p)){var S=y.memoizedProps;if(s=s.compare,s=s!==null?s:Ls,s(S,c)&&t.ref===r.ref)return Wa(t,r,p)}return r.flags|=1,t=Ia(y,c),t.ref=r.ref,t.return=r,r.child=t}function Bx(t,r,s,c,p){if(t!==null){var y=t.memoizedProps;if(Ls(y,c)&&t.ref===r.ref)if(zn=!1,r.pendingProps=c=y,cf(t,p))(t.flags&131072)!==0&&(zn=!0);else return r.lanes=t.lanes,Wa(t,r,p)}return tf(t,r,s,c,p)}function Ox(t,r,s,c){var p=c.children,y=t!==null?t.memoizedState:null;if(t===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((r.flags&128)!==0){if(y=y!==null?y.baseLanes|s:s,t!==null){for(c=r.child=t.child,p=0;c!==null;)p=p|c.lanes|c.childLanes,c=c.sibling;c=p&~y}else c=0,r.child=null;return $x(t,r,y,s,c)}if((s&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&gc(r,y!==null?y.cachePool:null),y!==null?Ip(r,y):Fd(),Hp(r);else return c=r.lanes=536870912,$x(t,r,y!==null?y.baseLanes|s:s,s,c)}else y!==null?(gc(r,y.cachePool),Ip(r,y),vl(),r.memoizedState=null):(t!==null&&gc(r,null),Fd(),vl());return Zn(t,r,p,s),r.child}function eo(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function $x(t,r,s,c,p){var y=Cd();return y=y===null?null:{parent:Mn._currentValue,pool:y},r.memoizedState={baseLanes:s,cachePool:y},t!==null&&gc(r,null),Fd(),Hp(r),t!==null&&Vi(t,r,c,!0),r.childLanes=p,null}function Rc(t,r){return r=_c({mode:r.mode,children:r.children},t.mode),r.ref=t.ref,t.child=r,r.return=t,r}function Lx(t,r,s){return fi(r,t.child,null,s),t=Rc(r,r.pendingProps),t.flags|=2,Ar(r),r.memoizedState=null,t}function i2(t,r,s){var c=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,t===null){if(Lt){if(c.mode==="hidden")return t=Rc(r,c),r.lanes=536870912,eo(null,t);if(Rd(r),(t=mn)?(t=Q1(t,qr),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:fl!==null?{id:pa,overflow:xa}:null,retryLane:536870912,hydrationErrors:null},s=kp(t),s.return=r,r.child=s,Pn=r,mn=null)):t=null,t===null)throw ml(r);return r.lanes=536870912,null}return Rc(r,c)}var y=t.memoizedState;if(y!==null){var S=y.dehydrated;if(Rd(r),p)if(r.flags&256)r.flags&=-257,r=Lx(t,r,s);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(zn||Vi(t,r,s,!1),p=(s&t.childLanes)!==0,zn||p){if(c=cn,c!==null&&(S=ne(c,s),S!==0&&S!==y.retryLane))throw y.retryLane=S,ai(t,S),br(c,t,S),ef;Yc(),r=Lx(t,r,s)}else t=y.treeContext,mn=Xr(S.nextSibling),Pn=r,Lt=!0,hl=null,qr=!1,t!==null&&Cp(r,t),r=Rc(r,c),r.flags|=4096;return r}return t=Ia(t.child,{mode:c.mode,children:c.children}),t.ref=r.ref,r.child=t,t.return=r,t}function zc(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 tf(t,r,s,c,p){return oi(r),s=_d(t,r,s,c,void 0,p),c=Bd(),t!==null&&!zn?(Od(t,r,p),Wa(t,r,p)):(Lt&&c&&xd(r),r.flags|=1,Zn(t,r,s,p),r.child)}function Ix(t,r,s,c,p,y){return oi(r),r.updateQueue=null,s=qp(r,c,s,p),Up(t),c=Bd(),t!==null&&!zn?(Od(t,r,y),Wa(t,r,y)):(Lt&&c&&xd(r),r.flags|=1,Zn(t,r,s,y),r.child)}function Hx(t,r,s,c,p){if(oi(r),r.stateNode===null){var y=Yi,S=s.contextType;typeof S=="object"&&S!==null&&(y=Qn(S)),y=new s(c,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=Zd,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=c,y.state=r.memoizedState,y.refs={},Nd(r),S=s.contextType,y.context=typeof S=="object"&&S!==null?Qn(S):Yi,y.state=r.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(Qd(r,s,S,c),y.state=r.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(S=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),S!==y.state&&Zd.enqueueReplaceState(y,y.state,null),Ks(r,c,y,p),Vs(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(t===null){y=r.stateNode;var M=r.memoizedProps,G=mi(s,M);y.props=G;var le=y.context,xe=s.contextType;S=Yi,typeof xe=="object"&&xe!==null&&(S=Qn(xe));var Ce=s.getDerivedStateFromProps;xe=typeof Ce=="function"||typeof y.getSnapshotBeforeUpdate=="function",M=r.pendingProps!==M,xe||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(M||le!==S)&&Nx(r,y,c,S),xl=!1;var ce=r.memoizedState;y.state=ce,Ks(r,c,y,p),Vs(),le=r.memoizedState,M||ce!==le||xl?(typeof Ce=="function"&&(Qd(r,s,Ce,c),le=r.memoizedState),(G=xl||Ex(r,s,G,c,ce,le,S))?(xe||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(r.flags|=4194308)):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=le),y.props=c,y.state=le,y.context=S,c=G):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{y=r.stateNode,Ad(t,r),S=r.memoizedProps,xe=mi(s,S),y.props=xe,Ce=r.pendingProps,ce=y.context,le=s.contextType,G=Yi,typeof le=="object"&&le!==null&&(G=Qn(le)),M=s.getDerivedStateFromProps,(le=typeof M=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==Ce||ce!==G)&&Nx(r,y,c,G),xl=!1,ce=r.memoizedState,y.state=ce,Ks(r,c,y,p),Vs();var fe=r.memoizedState;S!==Ce||ce!==fe||xl||t!==null&&t.dependencies!==null&&pc(t.dependencies)?(typeof M=="function"&&(Qd(r,s,M,c),fe=r.memoizedState),(xe=xl||Ex(r,s,xe,c,ce,fe,G)||t!==null&&t.dependencies!==null&&pc(t.dependencies))?(le||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(c,fe,G),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(c,fe,G)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===t.memoizedProps&&ce===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&ce===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=fe),y.props=c,y.state=fe,y.context=G,c=xe):(typeof y.componentDidUpdate!="function"||S===t.memoizedProps&&ce===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&ce===t.memoizedState||(r.flags|=1024),c=!1)}return y=c,zc(t,r),c=(r.flags&128)!==0,y||c?(y=r.stateNode,s=c&&typeof s.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,t!==null&&c?(r.child=fi(r,t.child,null,p),r.child=fi(r,null,s,p)):Zn(t,r,s,p),r.memoizedState=y.state,t=r.child):t=Wa(t,r,p),t}function Ux(t,r,s,c){return ii(),r.flags|=256,Zn(t,r,s,c),r.child}var nf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function rf(t){return{baseLanes:t,cachePool:Fp()}}function af(t,r,s){return t=t!==null?t.childLanes&~s:0,r&&(t|=Tr),t}function qx(t,r,s){var c=r.pendingProps,p=!1,y=(r.flags&128)!==0,S;if((S=y)||(S=t!==null&&t.memoizedState===null?!1:(Nn.current&2)!==0),S&&(p=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,t===null){if(Lt){if(p?bl(r):vl(),(t=mn)?(t=Q1(t,qr),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:fl!==null?{id:pa,overflow:xa}:null,retryLane:536870912,hydrationErrors:null},s=kp(t),s.return=r,r.child=s,Pn=r,mn=null)):t=null,t===null)throw ml(r);return Hf(t)?r.lanes=32:r.lanes=536870912,null}var M=c.children;return c=c.fallback,p?(vl(),p=r.mode,M=_c({mode:"hidden",children:M},p),c=li(c,p,s,null),M.return=r,c.return=r,M.sibling=c,r.child=M,c=r.child,c.memoizedState=rf(s),c.childLanes=af(t,S,s),r.memoizedState=nf,eo(null,c)):(bl(r),lf(r,M))}var G=t.memoizedState;if(G!==null&&(M=G.dehydrated,M!==null)){if(y)r.flags&256?(bl(r),r.flags&=-257,r=sf(t,r,s)):r.memoizedState!==null?(vl(),r.child=t.child,r.flags|=128,r=null):(vl(),M=c.fallback,p=r.mode,c=_c({mode:"visible",children:c.children},p),M=li(M,p,s,null),M.flags|=2,c.return=r,M.return=r,c.sibling=M,r.child=c,fi(r,t.child,null,s),c=r.child,c.memoizedState=rf(s),c.childLanes=af(t,S,s),r.memoizedState=nf,r=eo(null,c));else if(bl(r),Hf(M)){if(S=M.nextSibling&&M.nextSibling.dataset,S)var le=S.dgst;S=le,c=Error(i(419)),c.stack="",c.digest=S,Us({value:c,source:null,stack:null}),r=sf(t,r,s)}else if(zn||Vi(t,r,s,!1),S=(s&t.childLanes)!==0,zn||S){if(S=cn,S!==null&&(c=ne(S,s),c!==0&&c!==G.retryLane))throw G.retryLane=c,ai(t,c),br(S,t,c),ef;If(M)||Yc(),r=sf(t,r,s)}else If(M)?(r.flags|=192,r.child=t.child,r=null):(t=G.treeContext,mn=Xr(M.nextSibling),Pn=r,Lt=!0,hl=null,qr=!1,t!==null&&Cp(r,t),r=lf(r,c.children),r.flags|=4096);return r}return p?(vl(),M=c.fallback,p=r.mode,G=t.child,le=G.sibling,c=Ia(G,{mode:"hidden",children:c.children}),c.subtreeFlags=G.subtreeFlags&65011712,le!==null?M=Ia(le,M):(M=li(M,p,s,null),M.flags|=2),M.return=r,c.return=r,c.sibling=M,r.child=c,eo(null,c),c=r.child,M=t.child.memoizedState,M===null?M=rf(s):(p=M.cachePool,p!==null?(G=Mn._currentValue,p=p.parent!==G?{parent:G,pool:G}:p):p=Fp(),M={baseLanes:M.baseLanes|s,cachePool:p}),c.memoizedState=M,c.childLanes=af(t,S,s),r.memoizedState=nf,eo(t.child,c)):(bl(r),s=t.child,t=s.sibling,s=Ia(s,{mode:"visible",children:c.children}),s.return=r,s.sibling=null,t!==null&&(S=r.deletions,S===null?(r.deletions=[t],r.flags|=16):S.push(t)),r.child=s,r.memoizedState=null,s)}function lf(t,r){return r=_c({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function _c(t,r){return t=Er(22,t,null,r),t.lanes=0,t}function sf(t,r,s){return fi(r,t.child,null,s),t=lf(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Yx(t,r,s){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),wd(t.return,r,s)}function of(t,r,s,c,p,y){var S=t.memoizedState;S===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:s,tailMode:p,treeForkCount:y}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=c,S.tail=s,S.tailMode=p,S.treeForkCount=y)}function Xx(t,r,s){var c=r.pendingProps,p=c.revealOrder,y=c.tail;c=c.children;var S=Nn.current,M=(S&2)!==0;if(M?(S=S&1|2,r.flags|=128):S&=1,T(Nn,S),Zn(t,r,c,s),c=Lt?Hs:0,!M&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Yx(t,s,r);else if(t.tag===19)Yx(t,s,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(p){case"forwards":for(s=r.child,p=null;s!==null;)t=s.alternate,t!==null&&jc(t)===null&&(p=s),s=s.sibling;s=p,s===null?(p=r.child,r.child=null):(p=s.sibling,s.sibling=null),of(r,!1,p,s,y,c);break;case"backwards":case"unstable_legacy-backwards":for(s=null,p=r.child,r.child=null;p!==null;){if(t=p.alternate,t!==null&&jc(t)===null){r.child=p;break}t=p.sibling,p.sibling=s,s=p,p=t}of(r,!0,s,null,y,c);break;case"together":of(r,!1,null,null,void 0,c);break;default:r.memoizedState=null}return r.child}function Wa(t,r,s){if(t!==null&&(r.dependencies=t.dependencies),jl|=r.lanes,(s&r.childLanes)===0)if(t!==null){if(Vi(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=Ia(t,t.pendingProps),r.child=s,s.return=r;t.sibling!==null;)t=t.sibling,s=s.sibling=Ia(t,t.pendingProps),s.return=r;s.sibling=null}return r.child}function cf(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&pc(t)))}function s2(t,r,s){switch(r.tag){case 3:Ie(r,r.stateNode.containerInfo),pl(r,Mn,t.memoizedState.cache),ii();break;case 27:case 5:st(r);break;case 4:Ie(r,r.stateNode.containerInfo);break;case 10:pl(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Rd(r),null;break;case 13:var c=r.memoizedState;if(c!==null)return c.dehydrated!==null?(bl(r),r.flags|=128,null):(s&r.child.childLanes)!==0?qx(t,r,s):(bl(r),t=Wa(t,r,s),t!==null?t.sibling:null);bl(r);break;case 19:var p=(t.flags&128)!==0;if(c=(s&r.childLanes)!==0,c||(Vi(t,r,s,!1),c=(s&r.childLanes)!==0),p){if(c)return Xx(t,r,s);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),T(Nn,Nn.current),c)break;return null;case 22:return r.lanes=0,Ox(t,r,s,r.pendingProps);case 24:pl(r,Mn,t.memoizedState.cache)}return Wa(t,r,s)}function Wx(t,r,s){if(t!==null)if(t.memoizedProps!==r.pendingProps)zn=!0;else{if(!cf(t,s)&&(r.flags&128)===0)return zn=!1,s2(t,r,s);zn=(t.flags&131072)!==0}else zn=!1,Lt&&(r.flags&1048576)!==0&&Sp(r,Hs,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(t=ui(r.elementType),r.type=t,typeof t=="function")hd(t)?(c=mi(t,c),r.tag=1,r=Hx(null,r,t,c,s)):(r.tag=0,r=tf(null,r,t,c,s));else{if(t!=null){var p=t.$$typeof;if(p===z){r.tag=11,r=zx(null,r,t,c,s);break e}else if(p===I){r.tag=14,r=_x(null,r,t,c,s);break e}}throw r=se(t)||t,Error(i(306,r,""))}}return r;case 0:return tf(t,r,r.type,r.pendingProps,s);case 1:return c=r.type,p=mi(c,r.pendingProps),Hx(t,r,c,p,s);case 3:e:{if(Ie(r,r.stateNode.containerInfo),t===null)throw Error(i(387));c=r.pendingProps;var y=r.memoizedState;p=y.element,Ad(t,r),Ks(r,c,null,s);var S=r.memoizedState;if(c=S.cache,pl(r,Mn,c),c!==y.cache&&kd(r,[Mn],s,!0),Vs(),c=S.element,y.isDehydrated)if(y={element:c,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=Ux(t,r,c,s);break e}else if(c!==p){p=Ir(Error(i(424)),r),Us(p),r=Ux(t,r,c,s);break e}else{switch(t=r.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(mn=Xr(t.firstChild),Pn=r,Lt=!0,hl=null,qr=!0,s=Op(r,null,c,s),r.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(ii(),c===p){r=Wa(t,r,s);break e}Zn(t,r,c,s)}r=r.child}return r;case 26:return zc(t,r),t===null?(s=r0(r.type,null,r.pendingProps,null))?r.memoizedState=s:Lt||(s=r.type,t=r.pendingProps,c=Qc(pe.current).createElement(s),c[xn]=r,c[gn]=t,Jn(c,s,t),jn(c),r.stateNode=c):r.memoizedState=r0(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return st(r),t===null&&Lt&&(c=r.stateNode=e0(r.type,r.pendingProps,pe.current),Pn=r,qr=!0,p=mn,Al(r.type)?(Uf=p,mn=Xr(c.firstChild)):mn=p),Zn(t,r,r.pendingProps.children,s),zc(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&Lt&&((p=c=mn)&&(c=O2(c,r.type,r.pendingProps,qr),c!==null?(r.stateNode=c,Pn=r,mn=Xr(c.firstChild),qr=!1,p=!0):p=!1),p||ml(r)),st(r),p=r.type,y=r.pendingProps,S=t!==null?t.memoizedProps:null,c=y.children,Of(p,y)?c=null:S!==null&&Of(p,S)&&(r.flags|=32),r.memoizedState!==null&&(p=_d(t,r,Zv,null,null,s),xo._currentValue=p),zc(t,r),Zn(t,r,c,s),r.child;case 6:return t===null&&Lt&&((t=s=mn)&&(s=$2(s,r.pendingProps,qr),s!==null?(r.stateNode=s,Pn=r,mn=null,t=!0):t=!1),t||ml(r)),null;case 13:return qx(t,r,s);case 4:return Ie(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=fi(r,null,c,s):Zn(t,r,c,s),r.child;case 11:return zx(t,r,r.type,r.pendingProps,s);case 7:return Zn(t,r,r.pendingProps,s),r.child;case 8:return Zn(t,r,r.pendingProps.children,s),r.child;case 12:return Zn(t,r,r.pendingProps.children,s),r.child;case 10:return c=r.pendingProps,pl(r,r.type,c.value),Zn(t,r,c.children,s),r.child;case 9:return p=r.type._context,c=r.pendingProps.children,oi(r),p=Qn(p),c=c(p),r.flags|=1,Zn(t,r,c,s),r.child;case 14:return _x(t,r,r.type,r.pendingProps,s);case 15:return Bx(t,r,r.type,r.pendingProps,s);case 19:return Xx(t,r,s);case 31:return i2(t,r,s);case 22:return Ox(t,r,s,r.pendingProps);case 24:return oi(r),c=Qn(Mn),t===null?(p=Cd(),p===null&&(p=cn,y=jd(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=s),p=y),r.memoizedState={parent:c,cache:p},Nd(r),pl(r,Mn,p)):((t.lanes&s)!==0&&(Ad(t,r),Ks(r,null,null,s),Vs()),p=t.memoizedState,y=r.memoizedState,p.parent!==c?(p={parent:c,cache:c},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),pl(r,Mn,c)):(c=y.cache,pl(r,Mn,c),c!==p.cache&&kd(r,[Mn],s,!0))),Zn(t,r,r.pendingProps.children,s),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Ga(t){t.flags|=4}function uf(t,r,s,c,p){if((r=(t.mode&32)!==0)&&(r=!1),r){if(t.flags|=16777216,(p&335544128)===p)if(t.stateNode.complete)t.flags|=8192;else if(b1())t.flags|=8192;else throw di=bc,Ed}else t.flags&=-16777217}function Gx(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!o0(r))if(b1())t.flags|=8192;else throw di=bc,Ed}function Bc(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?nt():536870912,t.lanes|=r,is|=r)}function to(t,r){if(!Lt)switch(t.tailMode){case"hidden":r=t.tail;for(var s=null;r!==null;)r.alternate!==null&&(s=r),r=r.sibling;s===null?t.tail=null:s.sibling=null;break;case"collapsed":s=t.tail;for(var c=null;s!==null;)s.alternate!==null&&(c=s),s=s.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function pn(t){var r=t.alternate!==null&&t.alternate.child===t.child,s=0,c=0;if(r)for(var p=t.child;p!==null;)s|=p.lanes|p.childLanes,c|=p.subtreeFlags&65011712,c|=p.flags&65011712,p.return=t,p=p.sibling;else for(p=t.child;p!==null;)s|=p.lanes|p.childLanes,c|=p.subtreeFlags,c|=p.flags,p.return=t,p=p.sibling;return t.subtreeFlags|=c,t.childLanes=s,r}function o2(t,r,s){var c=r.pendingProps;switch(gd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pn(r),null;case 1:return pn(r),null;case 3:return s=r.stateNode,c=null,t!==null&&(c=t.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),qa(Mn),He(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(Gi(r)?Ga(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,bd())),pn(r),null;case 26:var p=r.type,y=r.memoizedState;return t===null?(Ga(r),y!==null?(pn(r),Gx(r,y)):(pn(r),uf(r,p,null,c,s))):y?y!==t.memoizedState?(Ga(r),pn(r),Gx(r,y)):(pn(r),r.flags&=-16777217):(t=t.memoizedProps,t!==c&&Ga(r),pn(r),uf(r,p,t,c,s)),null;case 27:if(Pe(r),s=pe.current,p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ga(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return pn(r),null}t=ie.current,Gi(r)?Ep(r):(t=e0(p,c,s),r.stateNode=t,Ga(r))}return pn(r),null;case 5:if(Pe(r),p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&Ga(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return pn(r),null}if(y=ie.current,Gi(r))Ep(r);else{var S=Qc(pe.current);switch(y){case 1:y=S.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:y=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":y=S.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":y=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":y=S.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof c.is=="string"?S.createElement("select",{is:c.is}):S.createElement("select"),c.multiple?y.multiple=!0:c.size&&(y.size=c.size);break;default:y=typeof c.is=="string"?S.createElement(p,{is:c.is}):S.createElement(p)}}y[xn]=r,y[gn]=c;e:for(S=r.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===r)break e;for(;S.sibling===null;){if(S.return===null||S.return===r)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}r.stateNode=y;e:switch(Jn(y,p,c),p){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&Ga(r)}}return pn(r),uf(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==c&&Ga(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(i(166));if(t=pe.current,Gi(r)){if(t=r.stateNode,s=r.memoizedProps,c=null,p=Pn,p!==null)switch(p.tag){case 27:case 5:c=p.memoizedProps}t[xn]=r,t=!!(t.nodeValue===s||c!==null&&c.suppressHydrationWarning===!0||q1(t.nodeValue,s)),t||ml(r,!0)}else t=Qc(t).createTextNode(c),t[xn]=r,r.stateNode=t}return pn(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(c=Gi(r),s!==null){if(t===null){if(!c)throw Error(i(318));if(t=r.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(557));t[xn]=r}else ii(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;pn(r),t=!1}else s=bd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return r.flags&256?(Ar(r),r):(Ar(r),null);if((r.flags&128)!==0)throw Error(i(558))}return pn(r),null;case 13:if(c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=Gi(r),c!==null&&c.dehydrated!==null){if(t===null){if(!p)throw Error(i(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[xn]=r}else ii(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;pn(r),p=!1}else p=bd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(Ar(r),r):(Ar(r),null)}return Ar(r),(r.flags&128)!==0?(r.lanes=s,r):(s=c!==null,t=t!==null&&t.memoizedState!==null,s&&(c=r.child,p=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(p=c.alternate.memoizedState.cachePool.pool),y=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(y=c.memoizedState.cachePool.pool),y!==p&&(c.flags|=2048)),s!==t&&s&&(r.child.flags|=8192),Bc(r,r.updateQueue),pn(r),null);case 4:return He(),t===null&&Mf(r.stateNode.containerInfo),pn(r),null;case 10:return qa(r.type),pn(r),null;case 19:if(U(Nn),c=r.memoizedState,c===null)return pn(r),null;if(p=(r.flags&128)!==0,y=c.rendering,y===null)if(p)to(c,!1);else{if(Cn!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(y=jc(t),y!==null){for(r.flags|=128,to(c,!1),t=y.updateQueue,r.updateQueue=t,Bc(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)wp(s,t),s=s.sibling;return T(Nn,Nn.current&1|2),Lt&&Ha(r,c.treeForkCount),r.child}t=t.sibling}c.tail!==null&&Se()>Hc&&(r.flags|=128,p=!0,to(c,!1),r.lanes=4194304)}else{if(!p)if(t=jc(y),t!==null){if(r.flags|=128,p=!0,t=t.updateQueue,r.updateQueue=t,Bc(r,t),to(c,!0),c.tail===null&&c.tailMode==="hidden"&&!y.alternate&&!Lt)return pn(r),null}else 2*Se()-c.renderingStartTime>Hc&&s!==536870912&&(r.flags|=128,p=!0,to(c,!1),r.lanes=4194304);c.isBackwards?(y.sibling=r.child,r.child=y):(t=c.last,t!==null?t.sibling=y:r.child=y,c.last=y)}return c.tail!==null?(t=c.tail,c.rendering=t,c.tail=t.sibling,c.renderingStartTime=Se(),t.sibling=null,s=Nn.current,T(Nn,p?s&1|2:s&1),Lt&&Ha(r,c.treeForkCount),t):(pn(r),null);case 22:case 23:return Ar(r),Md(),c=r.memoizedState!==null,t!==null?t.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(s&536870912)!==0&&(r.flags&128)===0&&(pn(r),r.subtreeFlags&6&&(r.flags|=8192)):pn(r),s=r.updateQueue,s!==null&&Bc(r,s.retryQueue),s=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),c=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),c!==s&&(r.flags|=2048),t!==null&&U(ci),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),qa(Mn),pn(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function c2(t,r){switch(gd(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return qa(Mn),He(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return Pe(r),null;case 31:if(r.memoizedState!==null){if(Ar(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(Ar(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 U(Nn),null;case 4:return He(),null;case 10:return qa(r.type),null;case 22:case 23:return Ar(r),Md(),t!==null&&U(ci),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return qa(Mn),null;case 25:return null;default:return null}}function Vx(t,r){switch(gd(r),r.tag){case 3:qa(Mn),He();break;case 26:case 27:case 5:Pe(r);break;case 4:He();break;case 31:r.memoizedState!==null&&Ar(r);break;case 13:Ar(r);break;case 19:U(Nn);break;case 10:qa(r.type);break;case 22:case 23:Ar(r),Md(),t!==null&&U(ci);break;case 24:qa(Mn)}}function no(t,r){try{var s=r.updateQueue,c=s!==null?s.lastEffect:null;if(c!==null){var p=c.next;s=p;do{if((s.tag&t)===t){c=void 0;var y=s.create,S=s.inst;c=y(),S.destroy=c}s=s.next}while(s!==p)}}catch(M){en(r,r.return,M)}}function wl(t,r,s){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var y=p.next;c=y;do{if((c.tag&t)===t){var S=c.inst,M=S.destroy;if(M!==void 0){S.destroy=void 0,p=r;var G=s,le=M;try{le()}catch(xe){en(p,G,xe)}}}c=c.next}while(c!==y)}}catch(xe){en(r,r.return,xe)}}function Kx(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{Lp(r,s)}catch(c){en(t,t.return,c)}}}function Px(t,r,s){s.props=mi(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(c){en(t,r,c)}}function ro(t,r){try{var s=t.ref;if(s!==null){switch(t.tag){case 26:case 27:case 5:var c=t.stateNode;break;case 30:c=t.stateNode;break;default:c=t.stateNode}typeof s=="function"?t.refCleanup=s(c):s.current=c}}catch(p){en(t,r,p)}}function ga(t,r){var s=t.ref,c=t.refCleanup;if(s!==null)if(typeof c=="function")try{c()}catch(p){en(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){en(t,r,p)}else s.current=null}function Qx(t){var r=t.type,s=t.memoizedProps,c=t.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":s.autoFocus&&c.focus();break e;case"img":s.src?c.src=s.src:s.srcSet&&(c.srcset=s.srcSet)}}catch(p){en(t,t.return,p)}}function df(t,r,s){try{var c=t.stateNode;F2(c,t.type,s,r),c[gn]=r}catch(p){en(t,t.return,p)}}function Zx(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Al(t.type)||t.tag===4}function ff(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Zx(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Al(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 hf(t,r,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(t,r):(r=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,r.appendChild(t),s=s._reactRootContainer,s!=null||r.onclick!==null||(r.onclick=tr));else if(c!==4&&(c===27&&Al(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(hf(t,r,s),t=t.sibling;t!==null;)hf(t,r,s),t=t.sibling}function Oc(t,r,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?s.insertBefore(t,r):s.appendChild(t);else if(c!==4&&(c===27&&Al(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(Oc(t,r,s),t=t.sibling;t!==null;)Oc(t,r,s),t=t.sibling}function Jx(t){var r=t.stateNode,s=t.memoizedProps;try{for(var c=t.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);Jn(r,c,s),r[xn]=t,r[gn]=s}catch(y){en(t,t.return,y)}}var Va=!1,_n=!1,mf=!1,e1=typeof WeakSet=="function"?WeakSet:Set,Gn=null;function u2(t,r){if(t=t.containerInfo,_f=au,t=fp(t),id(t)){if("selectionStart"in t)var s={start:t.selectionStart,end:t.selectionEnd};else e:{s=(s=t.ownerDocument)&&s.defaultView||window;var c=s.getSelection&&s.getSelection();if(c&&c.rangeCount!==0){s=c.anchorNode;var p=c.anchorOffset,y=c.focusNode;c=c.focusOffset;try{s.nodeType,y.nodeType}catch{s=null;break e}var S=0,M=-1,G=-1,le=0,xe=0,Ce=t,ce=null;t:for(;;){for(var fe;Ce!==s||p!==0&&Ce.nodeType!==3||(M=S+p),Ce!==y||c!==0&&Ce.nodeType!==3||(G=S+c),Ce.nodeType===3&&(S+=Ce.nodeValue.length),(fe=Ce.firstChild)!==null;)ce=Ce,Ce=fe;for(;;){if(Ce===t)break t;if(ce===s&&++le===p&&(M=S),ce===y&&++xe===c&&(G=S),(fe=Ce.nextSibling)!==null)break;Ce=ce,ce=Ce.parentNode}Ce=fe}s=M===-1||G===-1?null:{start:M,end:G}}else s=null}s=s||{start:0,end:0}}else s=null;for(Bf={focusedElem:t,selectionRange:s},au=!1,Gn=r;Gn!==null;)if(r=Gn,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,Gn=t;else for(;Gn!==null;){switch(r=Gn,y=r.alternate,t=r.flags,r.tag){case 0:if((t&4)!==0&&(t=r.updateQueue,t=t!==null?t.events:null,t!==null))for(s=0;s<t.length;s++)p=t[s],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&y!==null){t=void 0,s=r,p=y.memoizedProps,y=y.memoizedState,c=s.stateNode;try{var Ye=mi(s.type,p);t=c.getSnapshotBeforeUpdate(Ye,y),c.__reactInternalSnapshotBeforeUpdate=t}catch(lt){en(s,s.return,lt)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,s=t.nodeType,s===9)Lf(t);else if(s===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Lf(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,Gn=t;break}Gn=r.return}}function t1(t,r,s){var c=s.flags;switch(s.tag){case 0:case 11:case 15:Pa(t,s),c&4&&no(5,s);break;case 1:if(Pa(t,s),c&4)if(t=s.stateNode,r===null)try{t.componentDidMount()}catch(S){en(s,s.return,S)}else{var p=mi(s.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(p,r,t.__reactInternalSnapshotBeforeUpdate)}catch(S){en(s,s.return,S)}}c&64&&Kx(s),c&512&&ro(s,s.return);break;case 3:if(Pa(t,s),c&64&&(t=s.updateQueue,t!==null)){if(r=null,s.child!==null)switch(s.child.tag){case 27:case 5:r=s.child.stateNode;break;case 1:r=s.child.stateNode}try{Lp(t,r)}catch(S){en(s,s.return,S)}}break;case 27:r===null&&c&4&&Jx(s);case 26:case 5:Pa(t,s),r===null&&c&4&&Qx(s),c&512&&ro(s,s.return);break;case 12:Pa(t,s);break;case 31:Pa(t,s),c&4&&a1(t,s);break;case 13:Pa(t,s),c&4&&l1(t,s),c&64&&(t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(s=b2.bind(null,s),L2(t,s))));break;case 22:if(c=s.memoizedState!==null||Va,!c){r=r!==null&&r.memoizedState!==null||_n,p=Va;var y=_n;Va=c,(_n=r)&&!y?Qa(t,s,(s.subtreeFlags&8772)!==0):Pa(t,s),Va=p,_n=y}break;case 30:break;default:Pa(t,s)}}function n1(t){var r=t.alternate;r!==null&&(t.alternate=null,n1(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&Ti(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,pr=!1;function Ka(t,r,s){for(s=s.child;s!==null;)r1(t,r,s),s=s.sibling}function r1(t,r,s){if(qe&&typeof qe.onCommitFiberUnmount=="function")try{qe.onCommitFiberUnmount(Oe,s)}catch{}switch(s.tag){case 26:_n||ga(s,r),Ka(t,r,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:_n||ga(s,r);var c=yn,p=pr;Al(s.type)&&(yn=s.stateNode,pr=!1),Ka(t,r,s),ho(s.stateNode),yn=c,pr=p;break;case 5:_n||ga(s,r);case 6:if(c=yn,p=pr,yn=null,Ka(t,r,s),yn=c,pr=p,yn!==null)if(pr)try{(yn.nodeType===9?yn.body:yn.nodeName==="HTML"?yn.ownerDocument.body:yn).removeChild(s.stateNode)}catch(y){en(s,r,y)}else try{yn.removeChild(s.stateNode)}catch(y){en(s,r,y)}break;case 18:yn!==null&&(pr?(t=yn,K1(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,s.stateNode),ms(t)):K1(yn,s.stateNode));break;case 4:c=yn,p=pr,yn=s.stateNode.containerInfo,pr=!0,Ka(t,r,s),yn=c,pr=p;break;case 0:case 11:case 14:case 15:wl(2,s,r),_n||wl(4,s,r),Ka(t,r,s);break;case 1:_n||(ga(s,r),c=s.stateNode,typeof c.componentWillUnmount=="function"&&Px(s,r,c)),Ka(t,r,s);break;case 21:Ka(t,r,s);break;case 22:_n=(c=_n)||s.memoizedState!==null,Ka(t,r,s),_n=c;break;default:Ka(t,r,s)}}function a1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{ms(t)}catch(s){en(r,r.return,s)}}}function l1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{ms(t)}catch(s){en(r,r.return,s)}}function d2(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new e1),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new e1),r;default:throw Error(i(435,t.tag))}}function $c(t,r){var s=d2(t);r.forEach(function(c){if(!s.has(c)){s.add(c);var p=v2.bind(null,t,c);c.then(p,p)}})}function xr(t,r){var s=r.deletions;if(s!==null)for(var c=0;c<s.length;c++){var p=s[c],y=t,S=r,M=S;e:for(;M!==null;){switch(M.tag){case 27:if(Al(M.type)){yn=M.stateNode,pr=!1;break e}break;case 5:yn=M.stateNode,pr=!1;break e;case 3:case 4:yn=M.stateNode.containerInfo,pr=!0;break e}M=M.return}if(yn===null)throw Error(i(160));r1(y,S,p),yn=null,pr=!1,y=p.alternate,y!==null&&(y.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)i1(r,t),r=r.sibling}var aa=null;function i1(t,r){var s=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:xr(r,t),gr(t),c&4&&(wl(3,t,t.return),no(3,t),wl(5,t,t.return));break;case 1:xr(r,t),gr(t),c&512&&(_n||s===null||ga(s,s.return)),c&64&&Va&&(t=t.updateQueue,t!==null&&(c=t.callbacks,c!==null&&(s=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=s===null?c:s.concat(c))));break;case 26:var p=aa;if(xr(r,t),gr(t),c&512&&(_n||s===null||ga(s,s.return)),c&4){var y=s!==null?s.memoizedState:null;if(c=t.memoizedState,s===null)if(c===null)if(t.stateNode===null){e:{c=t.type,s=t.memoizedProps,p=p.ownerDocument||p;t:switch(c){case"title":y=p.getElementsByTagName("title")[0],(!y||y[Ta]||y[xn]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=p.createElement(c),p.head.insertBefore(y,p.querySelector("head > title"))),Jn(y,c,s),y[xn]=t,jn(y),c=y;break e;case"link":var S=i0("link","href",p).get(c+(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(c),Jn(y,c,s),p.head.appendChild(y);break;case"meta":if(S=i0("meta","content",p).get(c+(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(c),Jn(y,c,s),p.head.appendChild(y);break;default:throw Error(i(468,c))}y[xn]=t,jn(y),c=y}t.stateNode=c}else s0(p,t.type,t.stateNode);else t.stateNode=l0(p,c,t.memoizedProps);else y!==c?(y===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):y.count--,c===null?s0(p,t.type,t.stateNode):l0(p,c,t.memoizedProps)):c===null&&t.stateNode!==null&&df(t,t.memoizedProps,s.memoizedProps)}break;case 27:xr(r,t),gr(t),c&512&&(_n||s===null||ga(s,s.return)),s!==null&&c&4&&df(t,t.memoizedProps,s.memoizedProps);break;case 5:if(xr(r,t),gr(t),c&512&&(_n||s===null||ga(s,s.return)),t.flags&32){p=t.stateNode;try{Gt(p,"")}catch(Ye){en(t,t.return,Ye)}}c&4&&t.stateNode!=null&&(p=t.memoizedProps,df(t,p,s!==null?s.memoizedProps:p)),c&1024&&(mf=!0);break;case 6:if(xr(r,t),gr(t),c&4){if(t.stateNode===null)throw Error(i(162));c=t.memoizedProps,s=t.stateNode;try{s.nodeValue=c}catch(Ye){en(t,t.return,Ye)}}break;case 3:if(eu=null,p=aa,aa=Zc(r.containerInfo),xr(r,t),aa=p,gr(t),c&4&&s!==null&&s.memoizedState.isDehydrated)try{ms(r.containerInfo)}catch(Ye){en(t,t.return,Ye)}mf&&(mf=!1,s1(t));break;case 4:c=aa,aa=Zc(t.stateNode.containerInfo),xr(r,t),gr(t),aa=c;break;case 12:xr(r,t),gr(t);break;case 31:xr(r,t),gr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,$c(t,c)));break;case 13:xr(r,t),gr(t),t.child.flags&8192&&t.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Ic=Se()),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,$c(t,c)));break;case 22:p=t.memoizedState!==null;var G=s!==null&&s.memoizedState!==null,le=Va,xe=_n;if(Va=le||p,_n=xe||G,xr(r,t),_n=xe,Va=le,gr(t),c&8192)e:for(r=t.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(s===null||G||Va||_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,ce=Ce!=null&&Ce.hasOwnProperty("display")?Ce.display:null;M.style.display=ce==null||typeof ce=="boolean"?"":(""+ce).trim()}}catch(Ye){en(G,G.return,Ye)}}}else if(r.tag===6){if(s===null){G=r;try{G.stateNode.nodeValue=p?"":G.memoizedProps}catch(Ye){en(G,G.return,Ye)}}}else if(r.tag===18){if(s===null){G=r;try{var fe=G.stateNode;p?P1(fe,!0):P1(G.stateNode,!1)}catch(Ye){en(G,G.return,Ye)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===t)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break e;for(;r.sibling===null;){if(r.return===null||r.return===t)break e;s===r&&(s=null),r=r.return}s===r&&(s=null),r.sibling.return=r.return,r=r.sibling}c&4&&(c=t.updateQueue,c!==null&&(s=c.retryQueue,s!==null&&(c.retryQueue=null,$c(t,s))));break;case 19:xr(r,t),gr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,$c(t,c)));break;case 30:break;case 21:break;default:xr(r,t),gr(t)}}function gr(t){var r=t.flags;if(r&2){try{for(var s,c=t.return;c!==null;){if(Zx(c)){s=c;break}c=c.return}if(s==null)throw Error(i(160));switch(s.tag){case 27:var p=s.stateNode,y=ff(t);Oc(t,y,p);break;case 5:var S=s.stateNode;s.flags&32&&(Gt(S,""),s.flags&=-33);var M=ff(t);Oc(t,M,S);break;case 3:case 4:var G=s.stateNode.containerInfo,le=ff(t);hf(t,le,G);break;default:throw Error(i(161))}}catch(xe){en(t,t.return,xe)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function s1(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;s1(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),t=t.sibling}}function Pa(t,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)t1(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:wl(4,r,r.return),pi(r);break;case 1:ga(r,r.return);var s=r.stateNode;typeof s.componentWillUnmount=="function"&&Px(r,r.return,s),pi(r);break;case 27:ho(r.stateNode);case 26:case 5:ga(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 Qa(t,r,s){for(s=s&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var c=r.alternate,p=t,y=r,S=y.flags;switch(y.tag){case 0:case 11:case 15:Qa(p,y,s),no(4,y);break;case 1:if(Qa(p,y,s),c=y,p=c.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(le){en(c,c.return,le)}if(c=y,p=c.updateQueue,p!==null){var M=c.stateNode;try{var G=p.shared.hiddenCallbacks;if(G!==null)for(p.shared.hiddenCallbacks=null,p=0;p<G.length;p++)$p(G[p],M)}catch(le){en(c,c.return,le)}}s&&S&64&&Kx(y),ro(y,y.return);break;case 27:Jx(y);case 26:case 5:Qa(p,y,s),s&&c===null&&S&4&&Qx(y),ro(y,y.return);break;case 12:Qa(p,y,s);break;case 31:Qa(p,y,s),s&&S&4&&a1(p,y);break;case 13:Qa(p,y,s),s&&S&4&&l1(p,y);break;case 22:y.memoizedState===null&&Qa(p,y,s),ro(y,y.return);break;case 30:break;default:Qa(p,y,s)}r=r.sibling}}function pf(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&&qs(s))}function xf(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&qs(t))}function la(t,r,s,c){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)o1(t,r,s,c),r=r.sibling}function o1(t,r,s,c){var p=r.flags;switch(r.tag){case 0:case 11:case 15:la(t,r,s,c),p&2048&&no(9,r);break;case 1:la(t,r,s,c);break;case 3:la(t,r,s,c),p&2048&&(t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&qs(t)));break;case 12:if(p&2048){la(t,r,s,c),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){en(r,r.return,G)}}else la(t,r,s,c);break;case 31:la(t,r,s,c);break;case 13:la(t,r,s,c);break;case 23:break;case 22:y=r.stateNode,S=r.alternate,r.memoizedState!==null?y._visibility&2?la(t,r,s,c):ao(t,r):y._visibility&2?la(t,r,s,c):(y._visibility|=2,rs(t,r,s,c,(r.subtreeFlags&10256)!==0||!1)),p&2048&&pf(S,r);break;case 24:la(t,r,s,c),p&2048&&xf(r.alternate,r);break;default:la(t,r,s,c)}}function rs(t,r,s,c,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var y=t,S=r,M=s,G=c,le=S.flags;switch(S.tag){case 0:case 11:case 15:rs(y,S,M,G,p),no(8,S);break;case 23:break;case 22:var xe=S.stateNode;S.memoizedState!==null?xe._visibility&2?rs(y,S,M,G,p):ao(y,S):(xe._visibility|=2,rs(y,S,M,G,p)),p&&le&2048&&pf(S.alternate,S);break;case 24:rs(y,S,M,G,p),p&&le&2048&&xf(S.alternate,S);break;default:rs(y,S,M,G,p)}r=r.sibling}}function ao(t,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var s=t,c=r,p=c.flags;switch(c.tag){case 22:ao(s,c),p&2048&&pf(c.alternate,c);break;case 24:ao(s,c),p&2048&&xf(c.alternate,c);break;default:ao(s,c)}r=r.sibling}}var lo=8192;function as(t,r,s){if(t.subtreeFlags&lo)for(t=t.child;t!==null;)c1(t,r,s),t=t.sibling}function c1(t,r,s){switch(t.tag){case 26:as(t,r,s),t.flags&lo&&t.memoizedState!==null&&Q2(s,aa,t.memoizedState,t.memoizedProps);break;case 5:as(t,r,s);break;case 3:case 4:var c=aa;aa=Zc(t.stateNode.containerInfo),as(t,r,s),aa=c;break;case 22:t.memoizedState===null&&(c=t.alternate,c!==null&&c.memoizedState!==null?(c=lo,lo=16777216,as(t,r,s),lo=c):as(t,r,s));break;default:as(t,r,s)}}function u1(t){var r=t.alternate;if(r!==null&&(t=r.child,t!==null)){r.child=null;do r=t.sibling,t.sibling=null,t=r;while(t!==null)}}function io(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var s=0;s<r.length;s++){var c=r[s];Gn=c,f1(c,t)}u1(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)d1(t),t=t.sibling}function d1(t){switch(t.tag){case 0:case 11:case 15:io(t),t.flags&2048&&wl(9,t,t.return);break;case 3:io(t);break;case 12:io(t);break;case 22:var r=t.stateNode;t.memoizedState!==null&&r._visibility&2&&(t.return===null||t.return.tag!==13)?(r._visibility&=-3,Lc(t)):io(t);break;default:io(t)}}function Lc(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var s=0;s<r.length;s++){var c=r[s];Gn=c,f1(c,t)}u1(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:wl(8,r,r.return),Lc(r);break;case 22:s=r.stateNode,s._visibility&2&&(s._visibility&=-3,Lc(r));break;default:Lc(r)}t=t.sibling}}function f1(t,r){for(;Gn!==null;){var s=Gn;switch(s.tag){case 0:case 11:case 15:wl(8,s,r);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var c=s.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:qs(s.memoizedState.cache)}if(c=s.child,c!==null)c.return=s,Gn=c;else e:for(s=t;Gn!==null;){c=Gn;var p=c.sibling,y=c.return;if(n1(c),c===s){Gn=null;break e}if(p!==null){p.return=y,Gn=p;break e}Gn=y}}}var f2={getCacheForType:function(t){var r=Qn(Mn),s=r.data.get(t);return s===void 0&&(s=t(),r.data.set(t,s)),s},cacheSignal:function(){return Qn(Mn).controller.signal}},h2=typeof WeakMap=="function"?WeakMap:Map,Vt=0,cn=null,At=null,Mt=0,Jt=0,Dr=null,kl=!1,ls=!1,gf=!1,Za=0,Cn=0,jl=0,xi=0,yf=0,Tr=0,is=0,so=null,yr=null,bf=!1,Ic=0,h1=0,Hc=1/0,Uc=null,Sl=null,In=0,Cl=null,ss=null,Ja=0,vf=0,wf=null,m1=null,oo=0,kf=null;function Fr(){return(Vt&2)!==0&&Mt!==0?Mt&-Mt:W.T!==null?Af():Nt()}function p1(){if(Tr===0)if((Mt&536870912)===0||Lt){var t=Bt;Bt<<=1,(Bt&3932160)===0&&(Bt=262144),Tr=t}else Tr=536870912;return t=Nr.current,t!==null&&(t.flags|=32),Tr}function br(t,r,s){(t===cn&&(Jt===2||Jt===9)||t.cancelPendingCommit!==null)&&(os(t,0),El(t,Mt,Tr,!1)),we(t,s),((Vt&2)===0||t!==cn)&&(t===cn&&((Vt&2)===0&&(xi|=s),Cn===4&&El(t,Mt,Tr,!1)),ya(t))}function x1(t,r,s){if((Vt&6)!==0)throw Error(i(327));var c=!s&&(r&127)===0&&(r&t.expiredLanes)===0||Z(t,r),p=c?x2(t,r):Sf(t,r,!0),y=c;do{if(p===0){ls&&!c&&El(t,r,0,!1);break}else{if(s=t.current.alternate,y&&!m2(s)){p=Sf(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=so;var G=M.current.memoizedState.isDehydrated;if(G&&(os(M,S).flags|=256),S=Sf(M,S,!1),S!==2){if(gf&&!G){M.errorRecoveryDisabledLanes|=y,xi|=y,p=4;break e}y=yr,yr=p,y!==null&&(yr===null?yr=y:yr.push.apply(yr,y))}p=S}if(y=!1,p!==2)continue}}if(p===1){os(t,0),El(t,r,0,!0);break}e:{switch(c=t,y=p,y){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:El(c,r,Tr,!kl);break e;case 2:yr=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(p=Ic+300-Se(),10<p)){if(El(c,r,Tr,!kl),wn(c,0,!0)!==0)break e;Ja=r,c.timeoutHandle=G1(g1.bind(null,c,s,yr,Uc,bf,r,Tr,xi,is,kl,y,"Throttled",-0,0),p);break e}g1(c,s,yr,Uc,bf,r,Tr,xi,is,kl,y,null,-0,0)}}break}while(!0);ya(t)}function g1(t,r,s,c,p,y,S,M,G,le,xe,Ce,ce,fe){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:tr},c1(r,y,Ce);var Ye=(y&62914560)===y?Ic-Se():(y&4194048)===y?h1-Se():0;if(Ye=Z2(Ce,Ye),Ye!==null){Ja=y,t.cancelPendingCommit=Ye(C1.bind(null,t,r,y,s,c,p,S,M,G,xe,Ce,null,ce,fe)),El(t,y,S,!le);return}}C1(t,r,y,s,c,p,S,M,G)}function m2(t){for(var r=t;;){var s=r.tag;if((s===0||s===11||s===15)&&r.flags&16384&&(s=r.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var c=0;c<s.length;c++){var p=s[c],y=p.getSnapshot;p=p.value;try{if(!Cr(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 El(t,r,s,c){r&=~yf,r&=~xi,t.suspendedLanes|=r,t.pingedLanes&=~r,c&&(t.warmLanes|=r),c=t.expirationTimes;for(var p=r;0<p;){var y=31-Ve(p),S=1<<y;c[y]=-1,p&=~S}s!==0&&ln(t,s,r)}function qc(){return(Vt&6)===0?(co(0),!1):!0}function jf(){if(At!==null){if(Jt===0)var t=At.return;else t=At,Ua=si=null,$d(t),Zi=null,Xs=0,t=At;for(;t!==null;)Vx(t.alternate,t),t=t.return;At=null}}function os(t,r){var s=t.timeoutHandle;s!==-1&&(t.timeoutHandle=-1,z2(s)),s=t.cancelPendingCommit,s!==null&&(t.cancelPendingCommit=null,s()),Ja=0,jf(),cn=t,At=s=Ia(t.current,null),Mt=r,Jt=0,Dr=null,kl=!1,ls=Z(t,r),gf=!1,is=Tr=yf=xi=jl=Cn=0,yr=so=null,bf=!1,(r&8)!==0&&(r|=r&32);var c=t.entangledLanes;if(c!==0)for(t=t.entanglements,c&=r;0<c;){var p=31-Ve(c),y=1<<p;r|=t[p],c&=~y}return Za=r,uc(),s}function y1(t,r){gt=null,W.H=Js,r===Qi||r===yc?(r=zp(),Jt=3):r===Ed?(r=zp(),Jt=4):Jt=r===ef?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Dr=r,At===null&&(Cn=1,Mc(t,Ir(r,t.current)))}function b1(){var t=Nr.current;return t===null?!0:(Mt&4194048)===Mt?Yr===null:(Mt&62914560)===Mt||(Mt&536870912)!==0?t===Yr:!1}function v1(){var t=W.H;return W.H=Js,t===null?Js:t}function w1(){var t=W.A;return W.A=f2,t}function Yc(){Cn=4,kl||(Mt&4194048)!==Mt&&Nr.current!==null||(ls=!0),(jl&134217727)===0&&(xi&134217727)===0||cn===null||El(cn,Mt,Tr,!1)}function Sf(t,r,s){var c=Vt;Vt|=2;var p=v1(),y=w1();(cn!==t||Mt!==r)&&(Uc=null,os(t,r)),r=!1;var S=Cn;e:do try{if(Jt!==0&&At!==null){var M=At,G=Dr;switch(Jt){case 8:jf(),S=6;break e;case 3:case 2:case 9:case 6:Nr.current===null&&(r=!0);var le=Jt;if(Jt=0,Dr=null,cs(t,M,G,le),s&&ls){S=0;break e}break;default:le=Jt,Jt=0,Dr=null,cs(t,M,G,le)}}p2(),S=Cn;break}catch(xe){y1(t,xe)}while(!0);return r&&t.shellSuspendCounter++,Ua=si=null,Vt=c,W.H=p,W.A=y,At===null&&(cn=null,Mt=0,uc()),S}function p2(){for(;At!==null;)k1(At)}function x2(t,r){var s=Vt;Vt|=2;var c=v1(),p=w1();cn!==t||Mt!==r?(Uc=null,Hc=Se()+500,os(t,r)):ls=Z(t,r);e:do try{if(Jt!==0&&At!==null){r=At;var y=Dr;t:switch(Jt){case 1:Jt=0,Dr=null,cs(t,r,y,1);break;case 2:case 9:if(Mp(y)){Jt=0,Dr=null,j1(r);break}r=function(){Jt!==2&&Jt!==9||cn!==t||(Jt=7),ya(t)},y.then(r,r);break e;case 3:Jt=7;break e;case 4:Jt=5;break e;case 7:Mp(y)?(Jt=0,Dr=null,j1(r)):(Jt=0,Dr=null,cs(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?o0(S):M.stateNode.complete){Jt=0,Dr=null;var G=M.sibling;if(G!==null)At=G;else{var le=M.return;le!==null?(At=le,Xc(le)):At=null}break t}}Jt=0,Dr=null,cs(t,r,y,5);break;case 6:Jt=0,Dr=null,cs(t,r,y,6);break;case 8:jf(),Cn=6;break e;default:throw Error(i(462))}}g2();break}catch(xe){y1(t,xe)}while(!0);return Ua=si=null,W.H=c,W.A=p,Vt=s,At!==null?0:(cn=null,Mt=0,uc(),Cn)}function g2(){for(;At!==null&&!$n();)k1(At)}function k1(t){var r=Wx(t.alternate,t,Za);t.memoizedProps=t.pendingProps,r===null?Xc(t):At=r}function j1(t){var r=t,s=r.alternate;switch(r.tag){case 15:case 0:r=Ix(s,r,r.pendingProps,r.type,void 0,Mt);break;case 11:r=Ix(s,r,r.pendingProps,r.type.render,r.ref,Mt);break;case 5:$d(r);default:Vx(s,r),r=At=wp(r,Za),r=Wx(s,r,Za)}t.memoizedProps=t.pendingProps,r===null?Xc(t):At=r}function cs(t,r,s,c){Ua=si=null,$d(r),Zi=null,Xs=0;var p=r.return;try{if(l2(t,p,r,s,Mt)){Cn=1,Mc(t,Ir(s,t.current)),At=null;return}}catch(y){if(p!==null)throw At=p,y;Cn=1,Mc(t,Ir(s,t.current)),At=null;return}r.flags&32768?(Lt||c===1?t=!0:ls||(Mt&536870912)!==0?t=!1:(kl=t=!0,(c===2||c===9||c===3||c===6)&&(c=Nr.current,c!==null&&c.tag===13&&(c.flags|=16384))),S1(r,t)):Xc(r)}function Xc(t){var r=t;do{if((r.flags&32768)!==0){S1(r,kl);return}t=r.return;var s=o2(r.alternate,r,Za);if(s!==null){At=s;return}if(r=r.sibling,r!==null){At=r;return}At=r=t}while(r!==null);Cn===0&&(Cn=5)}function S1(t,r){do{var s=c2(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);Cn=6,At=null}function C1(t,r,s,c,p,y,S,M,G){t.cancelPendingCommit=null;do Wc();while(In!==0);if((Vt&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(y=r.lanes|r.childLanes,y|=dd,kt(t,s,y,S,M,G),t===cn&&(At=cn=null,Mt=0),ss=r,Cl=t,Ja=s,vf=y,wf=p,m1=c,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,w2(te,function(){return T1(),null})):(t.callbackNode=null,t.callbackPriority=0),c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=W.T,W.T=null,p=oe.p,oe.p=2,S=Vt,Vt|=4;try{u2(t,r,s)}finally{Vt=S,oe.p=p,W.T=c}}In=1,E1(),N1(),A1()}}function E1(){if(In===1){In=0;var t=Cl,r=ss,s=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||s){s=W.T,W.T=null;var c=oe.p;oe.p=2;var p=Vt;Vt|=4;try{i1(r,t);var y=Bf,S=fp(t.containerInfo),M=y.focusedElem,G=y.selectionRange;if(S!==M&&M&&M.ownerDocument&&dp(M.ownerDocument.documentElement,M)){if(G!==null&&id(M)){var le=G.start,xe=G.end;if(xe===void 0&&(xe=le),"selectionStart"in M)M.selectionStart=le,M.selectionEnd=Math.min(xe,M.value.length);else{var Ce=M.ownerDocument||document,ce=Ce&&Ce.defaultView||window;if(ce.getSelection){var fe=ce.getSelection(),Ye=M.textContent.length,lt=Math.min(G.start,Ye),rn=G.end===void 0?lt:Math.min(G.end,Ye);!fe.extend&<>rn&&(S=rn,rn=lt,lt=S);var J=up(M,lt),Q=up(M,rn);if(J&&Q&&(fe.rangeCount!==1||fe.anchorNode!==J.node||fe.anchorOffset!==J.offset||fe.focusNode!==Q.node||fe.focusOffset!==Q.offset)){var ae=Ce.createRange();ae.setStart(J.node,J.offset),fe.removeAllRanges(),lt>rn?(fe.addRange(ae),fe.extend(Q.node,Q.offset)):(ae.setEnd(Q.node,Q.offset),fe.addRange(ae))}}}}for(Ce=[],fe=M;fe=fe.parentNode;)fe.nodeType===1&&Ce.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;M<Ce.length;M++){var be=Ce[M];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}au=!!_f,Bf=_f=null}finally{Vt=p,oe.p=c,W.T=s}}t.current=r,In=2}}function N1(){if(In===2){In=0;var t=Cl,r=ss,s=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||s){s=W.T,W.T=null;var c=oe.p;oe.p=2;var p=Vt;Vt|=4;try{t1(t,r.alternate,r)}finally{Vt=p,oe.p=c,W.T=s}}In=3}}function A1(){if(In===4||In===3){In=0,me();var t=Cl,r=ss,s=Ja,c=m1;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?In=5:(In=0,ss=Cl=null,D1(t,t.pendingLanes));var p=t.pendingLanes;if(p===0&&(Sl=null),We(s),r=r.stateNode,qe&&typeof qe.onCommitFiberRoot=="function")try{qe.onCommitFiberRoot(Oe,r,void 0,(r.current.flags&128)===128)}catch{}if(c!==null){r=W.T,p=oe.p,oe.p=2,W.T=null;try{for(var y=t.onRecoverableError,S=0;S<c.length;S++){var M=c[S];y(M.value,{componentStack:M.stack})}}finally{W.T=r,oe.p=p}}(Ja&3)!==0&&Wc(),ya(t),p=t.pendingLanes,(s&261930)!==0&&(p&42)!==0?t===kf?oo++:(oo=0,kf=t):oo=0,co(0)}}function D1(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,qs(r)))}function Wc(){return E1(),N1(),A1(),T1()}function T1(){if(In!==5)return!1;var t=Cl,r=vf;vf=0;var s=We(Ja),c=W.T,p=oe.p;try{oe.p=32>s?32:s,W.T=null,s=wf,wf=null;var y=Cl,S=Ja;if(In=0,ss=Cl=null,Ja=0,(Vt&6)!==0)throw Error(i(331));var M=Vt;if(Vt|=4,d1(y.current),o1(y,y.current,S,s),Vt=M,co(0,!1),qe&&typeof qe.onPostCommitFiberRoot=="function")try{qe.onPostCommitFiberRoot(Oe,y)}catch{}return!0}finally{oe.p=p,W.T=c,D1(t,r)}}function F1(t,r,s){r=Ir(s,r),r=Jd(t.stateNode,r,2),t=yl(t,r,2),t!==null&&(we(t,2),ya(t))}function en(t,r,s){if(t.tag===3)F1(t,t,s);else for(;r!==null;){if(r.tag===3){F1(r,t,s);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Sl===null||!Sl.has(c))){t=Ir(s,t),s=Mx(2),c=yl(r,s,2),c!==null&&(Rx(s,c,r,t),we(c,2),ya(c));break}}r=r.return}}function Cf(t,r,s){var c=t.pingCache;if(c===null){c=t.pingCache=new h2;var p=new Set;c.set(r,p)}else p=c.get(r),p===void 0&&(p=new Set,c.set(r,p));p.has(s)||(gf=!0,p.add(s),t=y2.bind(null,t,r,s),r.then(t,t))}function y2(t,r,s){var c=t.pingCache;c!==null&&c.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,cn===t&&(Mt&s)===s&&(Cn===4||Cn===3&&(Mt&62914560)===Mt&&300>Se()-Ic?(Vt&2)===0&&os(t,0):yf|=s,is===Mt&&(is=0)),ya(t)}function M1(t,r){r===0&&(r=nt()),t=ai(t,r),t!==null&&(we(t,r),ya(t))}function b2(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),M1(t,s)}function v2(t,r){var s=0;switch(t.tag){case 31:case 13:var c=t.stateNode,p=t.memoizedState;p!==null&&(s=p.retryLane);break;case 19:c=t.stateNode;break;case 22:c=t.stateNode._retryCache;break;default:throw Error(i(314))}c!==null&&c.delete(r),M1(t,s)}function w2(t,r){return Ft(t,r)}var Gc=null,us=null,Ef=!1,Vc=!1,Nf=!1,Nl=0;function ya(t){t!==us&&t.next===null&&(us===null?Gc=us=t:us=us.next=t),Vc=!0,Ef||(Ef=!0,j2())}function co(t,r){if(!Nf&&Vc){Nf=!0;do for(var s=!1,c=Gc;c!==null;){if(t!==0){var p=c.pendingLanes;if(p===0)var y=0;else{var S=c.suspendedLanes,M=c.pingedLanes;y=(1<<31-Ve(42|t)+1)-1,y&=p&~(S&~M),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(s=!0,B1(c,y))}else y=Mt,y=wn(c,c===cn?y:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(y&3)===0||Z(c,y)||(s=!0,B1(c,y));c=c.next}while(s);Nf=!1}}function k2(){R1()}function R1(){Vc=Ef=!1;var t=0;Nl!==0&&R2()&&(t=Nl);for(var r=Se(),s=null,c=Gc;c!==null;){var p=c.next,y=z1(c,r);y===0?(c.next=null,s===null?Gc=p:s.next=p,p===null&&(us=s)):(s=c,(t!==0||(y&3)!==0)&&(Vc=!0)),c=p}In!==0&&In!==5||co(t),Nl!==0&&(Nl=0)}function z1(t,r){for(var s=t.suspendedLanes,c=t.pingedLanes,p=t.expirationTimes,y=t.pendingLanes&-62914561;0<y;){var S=31-Ve(y),M=1<<S,G=p[S];G===-1?((M&s)===0||(M&c)!==0)&&(p[S]=$e(M,r)):G<=r&&(t.expiredLanes|=M),y&=~M}if(r=cn,s=Mt,s=wn(t,t===r?s:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c=t.callbackNode,s===0||t===r&&(Jt===2||Jt===9)||t.cancelPendingCommit!==null)return c!==null&&c!==null&&Et(c),t.callbackNode=null,t.callbackPriority=0;if((s&3)===0||Z(t,s)){if(r=s&-s,r===t.callbackPriority)return r;switch(c!==null&&Et(c),We(s)){case 2:case 8:s=ue;break;case 32:s=te;break;case 268435456:s=ve;break;default:s=te}return c=_1.bind(null,t),s=Ft(s,c),t.callbackPriority=r,t.callbackNode=s,r}return c!==null&&c!==null&&Et(c),t.callbackPriority=2,t.callbackNode=null,2}function _1(t,r){if(In!==0&&In!==5)return t.callbackNode=null,t.callbackPriority=0,null;var s=t.callbackNode;if(Wc()&&t.callbackNode!==s)return null;var c=Mt;return c=wn(t,t===cn?c:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c===0?null:(x1(t,c,r),z1(t,Se()),t.callbackNode!=null&&t.callbackNode===s?_1.bind(null,t):null)}function B1(t,r){if(Wc())return null;x1(t,r,!0)}function j2(){_2(function(){(Vt&6)!==0?Ft(K,k2):R1()})}function Af(){if(Nl===0){var t=Ki;t===0&&(t=_t,_t<<=1,(_t&261888)===0&&(_t=256)),Nl=t}return Nl}function O1(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Pl(""+t)}function $1(t,r){var s=r.ownerDocument.createElement("input");return s.name=r.name,s.value=r.value,t.id&&s.setAttribute("form",t.id),r.parentNode.insertBefore(s,r),t=new FormData(t),s.parentNode.removeChild(s),t}function S2(t,r,s,c,p){if(r==="submit"&&s&&s.stateNode===p){var y=O1((p[gn]||null).action),S=c.submitter;S&&(r=(r=S[gn]||null)?O1(r.formAction):S.getAttribute("formAction"),r!==null&&(y=r,S=null));var M=new _i("action","action",null,c,p);t.push({event:M,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Nl!==0){var G=S?$1(p,S):new FormData(p);Gd(s,{pending:!0,data:G,method:p.method,action:y},null,G)}}else typeof y=="function"&&(M.preventDefault(),G=S?$1(p,S):new FormData(p),Gd(s,{pending:!0,data:G,method:p.method,action:y},y,G))},currentTarget:p}]})}}for(var Df=0;Df<ud.length;Df++){var Tf=ud[Df],C2=Tf.toLowerCase(),E2=Tf[0].toUpperCase()+Tf.slice(1);ra(C2,"on"+E2)}ra(pp,"onAnimationEnd"),ra(xp,"onAnimationIteration"),ra(gp,"onAnimationStart"),ra("dblclick","onDoubleClick"),ra("focusin","onFocus"),ra("focusout","onBlur"),ra(Uv,"onTransitionRun"),ra(qv,"onTransitionStart"),ra(Yv,"onTransitionCancel"),ra(yp,"onTransitionEnd"),Ra("onMouseEnter",["mouseout","mouseover"]),Ra("onMouseLeave",["mouseout","mouseover"]),Ra("onPointerEnter",["pointerout","pointerover"]),Ra("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 uo="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(" "),N2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(uo));function L1(t,r){r=(r&4)!==0;for(var s=0;s<t.length;s++){var c=t[s],p=c.event;c=c.listeners;e:{var y=void 0;if(r)for(var S=c.length-1;0<=S;S--){var M=c[S],G=M.instance,le=M.currentTarget;if(M=M.listener,G!==y&&p.isPropagationStopped())break e;y=M,p.currentTarget=le;try{y(p)}catch(xe){cc(xe)}p.currentTarget=null,y=G}else for(S=0;S<c.length;S++){if(M=c[S],G=M.instance,le=M.currentTarget,M=M.listener,G!==y&&p.isPropagationStopped())break e;y=M,p.currentTarget=le;try{y(p)}catch(xe){cc(xe)}p.currentTarget=null,y=G}}}}function Dt(t,r){var s=r[sl];s===void 0&&(s=r[sl]=new Set);var c=t+"__bubble";s.has(c)||(I1(r,t,2,!1),s.add(c))}function Ff(t,r,s){var c=0;r&&(c|=4),I1(s,t,c,r)}var Kc="_reactListening"+Math.random().toString(36).slice(2);function Mf(t){if(!t[Kc]){t[Kc]=!0,Fa.forEach(function(s){s!=="selectionchange"&&(N2.has(s)||Ff(s,!1,t),Ff(s,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[Kc]||(r[Kc]=!0,Ff("selectionchange",!1,r))}}function I1(t,r,s,c){switch(p0(r)){case 2:var p=tw;break;case 8:p=nw;break;default:p=Gf}s=p.bind(null,r,s,t),p=void 0,!_s||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),c?p!==void 0?t.addEventListener(r,s,{capture:!0,passive:p}):t.addEventListener(r,s,!0):p!==void 0?t.addEventListener(r,s,{passive:p}):t.addEventListener(r,s,!1)}function Rf(t,r,s,c,p){var y=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var S=c.tag;if(S===3||S===4){var M=c.stateNode.containerInfo;if(M===p)break;if(S===4)for(S=c.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=ca(M),S===null)return;if(G=S.tag,G===5||G===6||G===26||G===27){c=y=S;continue e}M=M.parentNode}}c=c.return}Qo(function(){var le=y,xe=Mi(s),Ce=[];e:{var ce=bp.get(t);if(ce!==void 0){var fe=_i,Ye=t;switch(t){case"keypress":if(zi(s)===0)break e;case"keydown":case"keyup":fe=ic;break;case"focusin":Ye="focus",fe=ei;break;case"focusout":Ye="blur",fe=ei;break;case"beforeblur":case"afterblur":fe=ei;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=Bs;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=ma;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=re;break;case pp:case xp:case gp:fe=Jo;break;case yp:fe=je;break;case"scroll":case"scrollend":fe=td;break;case"wheel":fe=It;break;case"copy":case"cut":case"paste":fe=rd;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=F;break;case"toggle":case"beforetoggle":fe=Ze}var lt=(r&4)!==0,rn=!lt&&(t==="scroll"||t==="scrollend"),J=lt?ce!==null?ce+"Capture":null:ce;lt=[];for(var Q=le,ae;Q!==null;){var be=Q;if(ae=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||ae===null||J===null||(be=Ql(Q,J),be!=null&<.push(fo(Q,be,ae))),rn)break;Q=Q.return}0<lt.length&&(ce=new fe(ce,Ye,null,s,xe),Ce.push({event:ce,listeners:lt}))}}if((r&7)===0){e:{if(ce=t==="mouseover"||t==="pointerover",fe=t==="mouseout"||t==="pointerout",ce&&s!==na&&(Ye=s.relatedTarget||s.fromElement)&&(ca(Ye)||Ye[dr]))break e;if((fe||ce)&&(ce=xe.window===xe?xe:(ce=xe.ownerDocument)?ce.defaultView||ce.parentWindow:window,fe?(Ye=s.relatedTarget||s.toElement,fe=le,Ye=Ye?ca(Ye):null,Ye!==null&&(rn=u(Ye),lt=Ye.tag,Ye!==rn||lt!==5&<!==27&<!==6)&&(Ye=null)):(fe=null,Ye=le),fe!==Ye)){if(lt=Bs,be="onMouseLeave",J="onMouseEnter",Q="mouse",(t==="pointerout"||t==="pointerover")&&(lt=F,be="onPointerLeave",J="onPointerEnter",Q="pointer"),rn=fe==null?ce:Wl(fe),ae=Ye==null?ce:Wl(Ye),ce=new lt(be,Q+"leave",fe,s,xe),ce.target=rn,ce.relatedTarget=ae,be=null,ca(xe)===le&&(lt=new lt(J,Q+"enter",Ye,s,xe),lt.target=ae,lt.relatedTarget=rn,be=lt),rn=be,fe&&Ye)t:{for(lt=A2,J=fe,Q=Ye,ae=0,be=J;be;be=lt(be))ae++;be=0;for(var tt=Q;tt;tt=lt(tt))be++;for(;0<ae-be;)J=lt(J),ae--;for(;0<be-ae;)Q=lt(Q),be--;for(;ae--;){if(J===Q||Q!==null&&J===Q.alternate){lt=J;break t}J=lt(J),Q=lt(Q)}lt=null}else lt=null;fe!==null&&H1(Ce,ce,fe,lt,!1),Ye!==null&&rn!==null&&H1(Ce,rn,Ye,lt,!0)}}e:{if(ce=le?Wl(le):window,fe=ce.nodeName&&ce.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ce.type==="file")var qt=ap;else if(np(ce))if(lp)qt=Lv;else{qt=Ov;var Ge=Bv}else fe=ce.nodeName,!fe||fe.toLowerCase()!=="input"||ce.type!=="checkbox"&&ce.type!=="radio"?le&&ta(le.elementType)&&(qt=ap):qt=$v;if(qt&&(qt=qt(t,le))){rp(Ce,qt,s,xe);break e}Ge&&Ge(t,ce,le),t==="focusout"&&le&&ce.type==="number"&&le.memoizedProps.value!=null&&da(ce,"number",ce.value)}switch(Ge=le?Wl(le):window,t){case"focusin":(np(Ge)||Ge.contentEditable==="true")&&(Hi=Ge,sd=le,Is=null);break;case"focusout":Is=sd=Hi=null;break;case"mousedown":od=!0;break;case"contextmenu":case"mouseup":case"dragend":od=!1,hp(Ce,s,xe);break;case"selectionchange":if(Hv)break;case"keydown":case"keyup":hp(Ce,s,xe)}var vt;if(ft)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 Ii?En(t,s)&&(Rt="onCompositionEnd"):t==="keydown"&&s.keyCode===229&&(Rt="onCompositionStart");Rt&&(Kn&&s.locale!=="ko"&&(Ii||Rt!=="onCompositionStart"?Rt==="onCompositionEnd"&&Ii&&(vt=ul()):($r=xe,Ba="value"in $r?$r.value:$r.textContent,Ii=!0)),Ge=Pc(le,Rt),0<Ge.length&&(Rt=new Zt(Rt,t,null,s,xe),Ce.push({event:Rt,listeners:Ge}),vt?Rt.data=vt:(vt=on(s),vt!==null&&(Rt.data=vt)))),(vt=ti?Mv(t,s):Rv(t,s))&&(Rt=Pc(le,"onBeforeInput"),0<Rt.length&&(Ge=new Zt("onBeforeInput","beforeinput",null,s,xe),Ce.push({event:Ge,listeners:Rt}),Ge.data=vt)),S2(Ce,t,le,s,xe)}L1(Ce,r)})}function fo(t,r,s){return{instance:t,listener:r,currentTarget:s}}function Pc(t,r){for(var s=r+"Capture",c=[];t!==null;){var p=t,y=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||y===null||(p=Ql(t,s),p!=null&&c.unshift(fo(t,p,y)),p=Ql(t,r),p!=null&&c.push(fo(t,p,y))),t.tag===3)return c;t=t.return}return[]}function A2(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function H1(t,r,s,c,p){for(var y=r._reactName,S=[];s!==null&&s!==c;){var M=s,G=M.alternate,le=M.stateNode;if(M=M.tag,G!==null&&G===c)break;M!==5&&M!==26&&M!==27||le===null||(G=le,p?(le=Ql(s,y),le!=null&&S.unshift(fo(s,le,G))):p||(le=Ql(s,y),le!=null&&S.push(fo(s,le,G)))),s=s.return}S.length!==0&&t.push({event:r,listeners:S})}var D2=/\r\n?/g,T2=/\u0000|\uFFFD/g;function U1(t){return(typeof t=="string"?t:""+t).replace(D2,`
|
|
49
|
-
`).replace(T2,"")}function q1(t,r){return r=U1(r),U1(t)===r}function nn(t,r,s,c,p,y){switch(s){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||Gt(t,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&Gt(t,""+c);break;case"className":Vl(t,"class",c);break;case"tabIndex":Vl(t,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":Vl(t,s,c);break;case"style":ea(t,c,y);break;case"data":if(r!=="object"){Vl(t,"data",c);break}case"src":case"href":if(c===""&&(r!=="a"||s!=="href")){t.removeAttribute(s);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=Pl(""+c),t.setAttribute(s,c);break;case"action":case"formAction":if(typeof c=="function"){t.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(s==="formAction"?(r!=="input"&&nn(t,r,"name",p.name,p,null),nn(t,r,"formEncType",p.formEncType,p,null),nn(t,r,"formMethod",p.formMethod,p,null),nn(t,r,"formTarget",p.formTarget,p,null)):(nn(t,r,"encType",p.encType,p,null),nn(t,r,"method",p.method,p,null),nn(t,r,"target",p.target,p,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=Pl(""+c),t.setAttribute(s,c);break;case"onClick":c!=null&&(t.onclick=tr);break;case"onScroll":c!=null&&Dt("scroll",t);break;case"onScrollEnd":c!=null&&Dt("scrollend",t);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(s=c.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"multiple":t.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":t.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){t.removeAttribute("xlink:href");break}s=Pl(""+c),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,""+c):t.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":c&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,""):t.removeAttribute(s);break;case"capture":case"download":c===!0?t.setAttribute(s,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,c):t.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?t.setAttribute(s,c):t.removeAttribute(s);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?t.removeAttribute(s):t.setAttribute(s,c);break;case"popover":Dt("beforetoggle",t),Dt("toggle",t),Gl(t,"popover",c);break;case"xlinkActuate":Qr(t,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Qr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Qr(t,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Qr(t,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Qr(t,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Qr(t,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Qr(t,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Qr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Qr(t,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Gl(t,"is",c);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=ed.get(s)||s,Gl(t,s,c))}}function zf(t,r,s,c,p,y){switch(s){case"style":ea(t,c,y);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(s=c.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"children":typeof c=="string"?Gt(t,c):(typeof c=="number"||typeof c=="bigint")&&Gt(t,""+c);break;case"onScroll":c!=null&&Dt("scroll",t);break;case"onScrollEnd":c!=null&&Dt("scrollend",t);break;case"onClick":c!=null&&(t.onclick=tr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ma.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[gn]||null,y=y!=null?y[s]:null,typeof y=="function"&&t.removeEventListener(r,y,p),typeof c=="function")){typeof y!="function"&&y!==null&&(s in t?t[s]=null:t.hasAttribute(s)&&t.removeAttribute(s)),t.addEventListener(r,c,p);break e}s in t?t[s]=c:c===!0?t.setAttribute(s,""):Gl(t,s,c)}}}function Jn(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 c=!1,p=!1,y;for(y in s)if(s.hasOwnProperty(y)){var S=s[y];if(S!=null)switch(y){case"src":c=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:nn(t,r,y,S,s,null)}}p&&nn(t,r,"srcSet",s.srcSet,s,null),c&&nn(t,r,"src",s.src,s,null);return;case"input":Dt("invalid",t);var M=y=S=p=null,G=null,le=null;for(c in s)if(s.hasOwnProperty(c)){var xe=s[c];if(xe!=null)switch(c){case"name":p=xe;break;case"type":S=xe;break;case"checked":G=xe;break;case"defaultChecked":le=xe;break;case"value":y=xe;break;case"defaultValue":M=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(i(137,r));break;default:nn(t,r,c,xe,s,null)}}Sr(t,y,M,G,le,S,p,!1);return;case"select":Dt("invalid",t),c=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":c=M;default:nn(t,r,p,M,s,null)}r=y,s=S,t.multiple=!!c,r!=null?mr(t,!!c,r,!1):s!=null&&mr(t,!!c,s,!0);return;case"textarea":Dt("invalid",t),y=p=c=null;for(S in s)if(s.hasOwnProperty(S)&&(M=s[S],M!=null))switch(S){case"value":c=M;break;case"defaultValue":p=M;break;case"children":y=M;break;case"dangerouslySetInnerHTML":if(M!=null)throw Error(i(91));break;default:nn(t,r,S,M,s,null)}Ln(t,c,p,y);return;case"option":for(G in s)if(s.hasOwnProperty(G)&&(c=s[G],c!=null))switch(G){case"selected":t.selected=c&&typeof c!="function"&&typeof c!="symbol";break;default:nn(t,r,G,c,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(c=0;c<uo.length;c++)Dt(uo[c],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(le in s)if(s.hasOwnProperty(le)&&(c=s[le],c!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:nn(t,r,le,c,s,null)}return;default:if(ta(r)){for(xe in s)s.hasOwnProperty(xe)&&(c=s[xe],c!==void 0&&zf(t,r,xe,c,s,void 0));return}}for(M in s)s.hasOwnProperty(M)&&(c=s[M],c!=null&&nn(t,r,M,c,s,null))}function F2(t,r,s,c){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,y=null,S=null,M=null,G=null,le=null,xe=null;for(fe in s){var Ce=s[fe];if(s.hasOwnProperty(fe)&&Ce!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":G=Ce;default:c.hasOwnProperty(fe)||nn(t,r,fe,null,c,Ce)}}for(var ce in c){var fe=c[ce];if(Ce=s[ce],c.hasOwnProperty(ce)&&(fe!=null||Ce!=null))switch(ce){case"type":y=fe;break;case"name":p=fe;break;case"checked":le=fe;break;case"defaultChecked":xe=fe;break;case"value":S=fe;break;case"defaultValue":M=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(i(137,r));break;default:fe!==Ce&&nn(t,r,ce,fe,c,Ce)}}Kl(t,S,M,G,le,xe,y,p);return;case"select":fe=S=M=ce=null;for(y in s)if(G=s[y],s.hasOwnProperty(y)&&G!=null)switch(y){case"value":break;case"multiple":fe=G;default:c.hasOwnProperty(y)||nn(t,r,y,null,c,G)}for(p in c)if(y=c[p],G=s[p],c.hasOwnProperty(p)&&(y!=null||G!=null))switch(p){case"value":ce=y;break;case"defaultValue":M=y;break;case"multiple":S=y;default:y!==G&&nn(t,r,p,y,c,G)}r=M,s=S,c=fe,ce!=null?mr(t,!!s,ce,!1):!!c!=!!s&&(r!=null?mr(t,!!s,r,!0):mr(t,!!s,s?[]:"",!1));return;case"textarea":fe=ce=null;for(M in s)if(p=s[M],s.hasOwnProperty(M)&&p!=null&&!c.hasOwnProperty(M))switch(M){case"value":break;case"children":break;default:nn(t,r,M,null,c,p)}for(S in c)if(p=c[S],y=s[S],c.hasOwnProperty(S)&&(p!=null||y!=null))switch(S){case"value":ce=p;break;case"defaultValue":fe=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(i(91));break;default:p!==y&&nn(t,r,S,p,c,y)}Po(t,ce,fe);return;case"option":for(var Ye in s)if(ce=s[Ye],s.hasOwnProperty(Ye)&&ce!=null&&!c.hasOwnProperty(Ye))switch(Ye){case"selected":t.selected=!1;break;default:nn(t,r,Ye,null,c,ce)}for(G in c)if(ce=c[G],fe=s[G],c.hasOwnProperty(G)&&ce!==fe&&(ce!=null||fe!=null))switch(G){case"selected":t.selected=ce&&typeof ce!="function"&&typeof ce!="symbol";break;default:nn(t,r,G,ce,c,fe)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var lt in s)ce=s[lt],s.hasOwnProperty(lt)&&ce!=null&&!c.hasOwnProperty(lt)&&nn(t,r,lt,null,c,ce);for(le in c)if(ce=c[le],fe=s[le],c.hasOwnProperty(le)&&ce!==fe&&(ce!=null||fe!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(i(137,r));break;default:nn(t,r,le,ce,c,fe)}return;default:if(ta(r)){for(var rn in s)ce=s[rn],s.hasOwnProperty(rn)&&ce!==void 0&&!c.hasOwnProperty(rn)&&zf(t,r,rn,void 0,c,ce);for(xe in c)ce=c[xe],fe=s[xe],!c.hasOwnProperty(xe)||ce===fe||ce===void 0&&fe===void 0||zf(t,r,xe,ce,c,fe);return}}for(var J in s)ce=s[J],s.hasOwnProperty(J)&&ce!=null&&!c.hasOwnProperty(J)&&nn(t,r,J,null,c,ce);for(Ce in c)ce=c[Ce],fe=s[Ce],!c.hasOwnProperty(Ce)||ce===fe||ce==null&&fe==null||nn(t,r,Ce,ce,c,fe)}function Y1(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function M2(){if(typeof performance.getEntriesByType=="function"){for(var t=0,r=0,s=performance.getEntriesByType("resource"),c=0;c<s.length;c++){var p=s[c],y=p.transferSize,S=p.initiatorType,M=p.duration;if(y&&M&&Y1(S)){for(S=0,M=p.responseEnd,c+=1;c<s.length;c++){var G=s[c],le=G.startTime;if(le>M)break;var xe=G.transferSize,Ce=G.initiatorType;xe&&Y1(Ce)&&(G=G.responseEnd,S+=xe*(G<M?1:(M-le)/(G-le)))}if(--c,r+=8*(y+S)/(p.duration/1e3),t++,10<t)break}}if(0<t)return r/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var _f=null,Bf=null;function Qc(t){return t.nodeType===9?t:t.ownerDocument}function X1(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function W1(t,r){if(t===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&r==="foreignObject"?0:t}function Of(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 $f=null;function R2(){var t=window.event;return t&&t.type==="popstate"?t===$f?!1:($f=t,!0):($f=null,!1)}var G1=typeof setTimeout=="function"?setTimeout:void 0,z2=typeof clearTimeout=="function"?clearTimeout:void 0,V1=typeof Promise=="function"?Promise:void 0,_2=typeof queueMicrotask=="function"?queueMicrotask:typeof V1<"u"?function(t){return V1.resolve(null).then(t).catch(B2)}:G1;function B2(t){setTimeout(function(){throw t})}function Al(t){return t==="head"}function K1(t,r){var s=r,c=0;do{var p=s.nextSibling;if(t.removeChild(s),p&&p.nodeType===8)if(s=p.data,s==="/$"||s==="/&"){if(c===0){t.removeChild(p),ms(r);return}c--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")c++;else if(s==="html")ho(t.ownerDocument.documentElement);else if(s==="head"){s=t.ownerDocument.head,ho(s);for(var y=s.firstChild;y;){var S=y.nextSibling,M=y.nodeName;y[Ta]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&y.rel.toLowerCase()==="stylesheet"||s.removeChild(y),y=S}}else s==="body"&&ho(t.ownerDocument.body);s=p}while(s);ms(r)}function P1(t,r){var s=t;t=0;do{var c=s.nextSibling;if(s.nodeType===1?r?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(r?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),c&&c.nodeType===8)if(s=c.data,s==="/$"){if(t===0)break;t--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||t++;s=c}while(s)}function Lf(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":Lf(s),Ti(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}t.removeChild(s)}}function O2(t,r,s,c){for(;t.nodeType===1;){var p=s;if(t.nodeName.toLowerCase()!==r.toLowerCase()){if(!c&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(c){if(!t[Ta])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=Xr(t.nextSibling),t===null)break}return null}function $2(t,r,s){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=Xr(t.nextSibling),t===null))return null;return t}function Q1(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Xr(t.nextSibling),t===null))return null;return t}function If(t){return t.data==="$?"||t.data==="$~"}function Hf(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function L2(t,r){var s=t.ownerDocument;if(t.data==="$~")t._reactRetry=r;else if(t.data!=="$?"||s.readyState!=="loading")r();else{var c=function(){r(),s.removeEventListener("DOMContentLoaded",c)};s.addEventListener("DOMContentLoaded",c),t._reactRetry=c}}function Xr(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 Uf=null;function Z1(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="/$"||s==="/&"){if(r===0)return Xr(t.nextSibling);r--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||r++}t=t.nextSibling}return null}function J1(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(r===0)return t;r--}else s!=="/$"&&s!=="/&"||r++}t=t.previousSibling}return null}function e0(t,r,s){switch(r=Qc(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 ho(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Ti(t)}var Wr=new Map,t0=new Set;function Zc(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var el=oe.d;oe.d={f:I2,r:H2,D:U2,C:q2,L:Y2,m:X2,X:G2,S:W2,M:V2};function I2(){var t=el.f(),r=qc();return t||r}function H2(t){var r=Vn(t);r!==null&&r.tag===5&&r.type==="form"?yx(r):el.r(t)}var ds=typeof document>"u"?null:document;function n0(t,r,s){var c=ds;if(c&&typeof r=="string"&&r){var p=hr(r);p='link[rel="'+t+'"][href="'+p+'"]',typeof s=="string"&&(p+='[crossorigin="'+s+'"]'),t0.has(p)||(t0.add(p),t={rel:t,crossOrigin:s,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),Jn(r,"link",t),jn(r),c.head.appendChild(r)))}}function U2(t){el.D(t),n0("dns-prefetch",t,null)}function q2(t,r){el.C(t,r),n0("preconnect",t,r)}function Y2(t,r,s){el.L(t,r,s);var c=ds;if(c&&t&&r){var p='link[rel="preload"][as="'+hr(r)+'"]';r==="image"&&s&&s.imageSrcSet?(p+='[imagesrcset="'+hr(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(p+='[imagesizes="'+hr(s.imageSizes)+'"]')):p+='[href="'+hr(t)+'"]';var y=p;switch(r){case"style":y=fs(t);break;case"script":y=hs(t)}Wr.has(y)||(t=g({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),Wr.set(y,t),c.querySelector(p)!==null||r==="style"&&c.querySelector(mo(y))||r==="script"&&c.querySelector(po(y))||(r=c.createElement("link"),Jn(r,"link",t),jn(r),c.head.appendChild(r)))}}function X2(t,r){el.m(t,r);var s=ds;if(s&&t){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+hr(c)+'"][href="'+hr(t)+'"]',y=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=hs(t)}if(!Wr.has(y)&&(t=g({rel:"modulepreload",href:t},r),Wr.set(y,t),s.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(po(y)))return}c=s.createElement("link"),Jn(c,"link",t),jn(c),s.head.appendChild(c)}}}function W2(t,r,s){el.S(t,r,s);var c=ds;if(c&&t){var p=jr(c).hoistableStyles,y=fs(t);r=r||"default";var S=p.get(y);if(!S){var M={loading:0,preload:null};if(S=c.querySelector(mo(y)))M.loading=5;else{t=g({rel:"stylesheet",href:t,"data-precedence":r},s),(s=Wr.get(y))&&qf(t,s);var G=S=c.createElement("link");jn(G),Jn(G,"link",t),G._p=new Promise(function(le,xe){G.onload=le,G.onerror=xe}),G.addEventListener("load",function(){M.loading|=1}),G.addEventListener("error",function(){M.loading|=2}),M.loading|=4,Jc(S,r,c)}S={type:"stylesheet",instance:S,count:1,state:M},p.set(y,S)}}}function G2(t,r){el.X(t,r);var s=ds;if(s&&t){var c=jr(s).hoistableScripts,p=hs(t),y=c.get(p);y||(y=s.querySelector(po(p)),y||(t=g({src:t,async:!0},r),(r=Wr.get(p))&&Yf(t,r),y=s.createElement("script"),jn(y),Jn(y,"link",t),s.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},c.set(p,y))}}function V2(t,r){el.M(t,r);var s=ds;if(s&&t){var c=jr(s).hoistableScripts,p=hs(t),y=c.get(p);y||(y=s.querySelector(po(p)),y||(t=g({src:t,async:!0,type:"module"},r),(r=Wr.get(p))&&Yf(t,r),y=s.createElement("script"),jn(y),Jn(y,"link",t),s.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},c.set(p,y))}}function r0(t,r,s,c){var p=(p=pe.current)?Zc(p):null;if(!p)throw Error(i(446));switch(t){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(r=fs(s.href),s=jr(p).hoistableStyles,c=s.get(r),c||(c={type:"style",instance:null,count:0,state:null},s.set(r,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){t=fs(s.href);var y=jr(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(mo(t)))&&!y._p&&(S.instance=y,S.state.loading=5),Wr.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},Wr.set(t,s),y||K2(p,t,s,S.state))),r&&c===null)throw Error(i(528,""));return S}if(r&&c!==null)throw Error(i(529,""));return null;case"script":return r=s.async,s=s.src,typeof s=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=hs(s),s=jr(p).hoistableScripts,c=s.get(r),c||(c={type:"script",instance:null,count:0,state:null},s.set(r,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,t))}}function fs(t){return'href="'+hr(t)+'"'}function mo(t){return'link[rel="stylesheet"]['+t+"]"}function a0(t){return g({},t,{"data-precedence":t.precedence,precedence:null})}function K2(t,r,s,c){t.querySelector('link[rel="preload"][as="style"]['+r+"]")?c.loading=1:(r=t.createElement("link"),c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2}),Jn(r,"link",s),jn(r),t.head.appendChild(r))}function hs(t){return'[src="'+hr(t)+'"]'}function po(t){return"script[async]"+t}function l0(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var c=t.querySelector('style[data-href~="'+hr(s.href)+'"]');if(c)return r.instance=c,jn(c),c;var p=g({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return c=(t.ownerDocument||t).createElement("style"),jn(c),Jn(c,"style",p),Jc(c,s.precedence,t),r.instance=c;case"stylesheet":p=fs(s.href);var y=t.querySelector(mo(p));if(y)return r.state.loading|=4,r.instance=y,jn(y),y;c=a0(s),(p=Wr.get(p))&&qf(c,p),y=(t.ownerDocument||t).createElement("link"),jn(y);var S=y;return S._p=new Promise(function(M,G){S.onload=M,S.onerror=G}),Jn(y,"link",c),r.state.loading|=4,Jc(y,s.precedence,t),r.instance=y;case"script":return y=hs(s.src),(p=t.querySelector(po(y)))?(r.instance=p,jn(p),p):(c=s,(p=Wr.get(y))&&(c=g({},s),Yf(c,p)),t=t.ownerDocument||t,p=t.createElement("script"),jn(p),Jn(p,"link",c),t.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(c=r.instance,r.state.loading|=4,Jc(c,s.precedence,t));return r.instance}function Jc(t,r,s){for(var c=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=c.length?c[c.length-1]:null,y=p,S=0;S<c.length;S++){var M=c[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 qf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function Yf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var eu=null;function i0(t,r,s){if(eu===null){var c=new Map,p=eu=new Map;p.set(s,c)}else p=eu,c=p.get(s),c||(c=new Map,p.set(s,c));if(c.has(t))return c;for(c.set(t,null),s=s.getElementsByTagName(t),p=0;p<s.length;p++){var y=s[p];if(!(y[Ta]||y[xn]||t==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var S=y.getAttribute(r)||"";S=t+S;var M=c.get(S);M?M.push(y):c.set(S,[y])}}return c}function s0(t,r,s){t=t.ownerDocument||t,t.head.insertBefore(s,r==="title"?t.querySelector("head > title"):null)}function P2(t,r,s){if(s===1||r.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return t=r.disabled,typeof r.precedence=="string"&&t==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function o0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Q2(t,r,s,c){if(s.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var p=fs(c.href),y=r.querySelector(mo(p));if(y){r=y._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=tu.bind(t),r.then(t,t)),s.state.loading|=4,s.instance=y,jn(y);return}y=r.ownerDocument||r,c=a0(c),(p=Wr.get(p))&&qf(c,p),y=y.createElement("link"),jn(y);var S=y;S._p=new Promise(function(M,G){S.onload=M,S.onerror=G}),Jn(y,"link",c),s.instance=y}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(s,r),(r=s.state.preload)&&(s.state.loading&3)===0&&(t.count++,s=tu.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var Xf=0;function Z2(t,r){return t.stylesheets&&t.count===0&&ru(t,t.stylesheets),0<t.count||0<t.imgCount?function(s){var c=setTimeout(function(){if(t.stylesheets&&ru(t,t.stylesheets),t.unsuspend){var y=t.unsuspend;t.unsuspend=null,y()}},6e4+r);0<t.imgBytes&&Xf===0&&(Xf=62500*M2());var p=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&ru(t,t.stylesheets),t.unsuspend)){var y=t.unsuspend;t.unsuspend=null,y()}},(t.imgBytes>Xf?50:800)+r);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(c),clearTimeout(p)}}:null}function tu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ru(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var nu=null;function ru(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,nu=new Map,r.forEach(J2,t),nu=null,tu.call(t))}function J2(t,r){if(!(r.state.loading&4)){var s=nu.get(t);if(s)var c=s.get(null);else{s=new Map,nu.set(t,s);for(var p=t.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<p.length;y++){var S=p[y];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),c=S)}c&&s.set(null,c)}p=r.instance,S=p.getAttribute("data-precedence"),y=s.get(S)||c,y===c&&s.set(null,p),s.set(S,p),this.count++,c=tu.bind(this),p.addEventListener("load",c),p.addEventListener("error",c),y?y.parentNode.insertBefore(p,y.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(p,t.firstChild)),r.state.loading|=4}}var xo={$$typeof:_,Provider:null,Consumer:null,_currentValue:de,_currentValue2:de,_threadCount:0};function ew(t,r,s,c,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=Pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pt(0),this.hiddenUpdates=Pt(null),this.identifierPrefix=c,this.onUncaughtError=p,this.onCaughtError=y,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=G,this.incompleteTransitions=new Map}function c0(t,r,s,c,p,y,S,M,G,le,xe,Ce){return t=new ew(t,r,s,S,G,le,xe,Ce,M),r=1,y===!0&&(r|=24),y=Er(3,null,null,r),t.current=y,y.stateNode=t,r=jd(),r.refCount++,t.pooledCache=r,r.refCount++,y.memoizedState={element:c,isDehydrated:s,cache:r},Nd(y),t}function u0(t){return t?(t=Yi,t):Yi}function d0(t,r,s,c,p,y){p=u0(p),c.context===null?c.context=p:c.pendingContext=p,c=gl(r),c.payload={element:s},y=y===void 0?null:y,y!==null&&(c.callback=y),s=yl(t,c,r),s!==null&&(br(s,t,r),Gs(s,t,r))}function f0(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var s=t.retryLane;t.retryLane=s!==0&&s<r?s:r}}function Wf(t,r){f0(t,r),(t=t.alternate)&&f0(t,r)}function h0(t){if(t.tag===13||t.tag===31){var r=ai(t,67108864);r!==null&&br(r,t,67108864),Wf(t,67108864)}}function m0(t){if(t.tag===13||t.tag===31){var r=Fr();r=Ae(r);var s=ai(t,r);s!==null&&br(s,t,r),Wf(t,r)}}var au=!0;function tw(t,r,s,c){var p=W.T;W.T=null;var y=oe.p;try{oe.p=2,Gf(t,r,s,c)}finally{oe.p=y,W.T=p}}function nw(t,r,s,c){var p=W.T;W.T=null;var y=oe.p;try{oe.p=8,Gf(t,r,s,c)}finally{oe.p=y,W.T=p}}function Gf(t,r,s,c){if(au){var p=Vf(c);if(p===null)Rf(t,r,c,lu,s),x0(t,c);else if(aw(p,t,r,s,c))c.stopPropagation();else if(x0(t,c),r&4&&-1<rw.indexOf(t)){for(;p!==null;){var y=Vn(p);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var S=fn(y.pendingLanes);if(S!==0){var M=y;for(M.pendingLanes|=2,M.entangledLanes|=2;S;){var G=1<<31-Ve(S);M.entanglements[1]|=G,S&=~G}ya(y),(Vt&6)===0&&(Hc=Se()+500,co(0))}}break;case 31:case 13:M=ai(y,2),M!==null&&br(M,y,2),qc(),Wf(y,2)}if(y=Vf(c),y===null&&Rf(t,r,c,lu,s),y===p)break;p=y}p!==null&&c.stopPropagation()}else Rf(t,r,c,null,s)}}function Vf(t){return t=Mi(t),Kf(t)}var lu=null;function Kf(t){if(lu=null,t=ca(t),t!==null){var r=u(t);if(r===null)t=null;else{var s=r.tag;if(s===13){if(t=d(r),t!==null)return t;t=null}else if(s===31){if(t=f(r),t!==null)return t;t=null}else if(s===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null)}}return lu=t,null}function p0(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ne()){case K:return 2;case ue:return 8;case te:case ke:return 32;case ve:return 268435456;default:return 32}default:return 32}}var Pf=!1,Dl=null,Tl=null,Fl=null,go=new Map,yo=new Map,Ml=[],rw="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function x0(t,r){switch(t){case"focusin":case"focusout":Dl=null;break;case"dragenter":case"dragleave":Tl=null;break;case"mouseover":case"mouseout":Fl=null;break;case"pointerover":case"pointerout":go.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":yo.delete(r.pointerId)}}function bo(t,r,s,c,p,y){return t===null||t.nativeEvent!==y?(t={blockedOn:r,domEventName:s,eventSystemFlags:c,nativeEvent:y,targetContainers:[p]},r!==null&&(r=Vn(r),r!==null&&h0(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),t)}function aw(t,r,s,c,p){switch(r){case"focusin":return Dl=bo(Dl,t,r,s,c,p),!0;case"dragenter":return Tl=bo(Tl,t,r,s,c,p),!0;case"mouseover":return Fl=bo(Fl,t,r,s,c,p),!0;case"pointerover":var y=p.pointerId;return go.set(y,bo(go.get(y)||null,t,r,s,c,p)),!0;case"gotpointercapture":return y=p.pointerId,yo.set(y,bo(yo.get(y)||null,t,r,s,c,p)),!0}return!1}function g0(t){var r=ca(t.target);if(r!==null){var s=u(r);if(s!==null){if(r=s.tag,r===13){if(r=d(s),r!==null){t.blockedOn=r,kn(t.priority,function(){m0(s)});return}}else if(r===31){if(r=f(s),r!==null){t.blockedOn=r,kn(t.priority,function(){m0(s)});return}}else if(r===3&&s.stateNode.current.memoizedState.isDehydrated){t.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}t.blockedOn=null}function iu(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var s=Vf(t.nativeEvent);if(s===null){s=t.nativeEvent;var c=new s.constructor(s.type,s);na=c,s.target.dispatchEvent(c),na=null}else return r=Vn(s),r!==null&&h0(r),t.blockedOn=s,!1;r.shift()}return!0}function y0(t,r,s){iu(t)&&s.delete(r)}function lw(){Pf=!1,Dl!==null&&iu(Dl)&&(Dl=null),Tl!==null&&iu(Tl)&&(Tl=null),Fl!==null&&iu(Fl)&&(Fl=null),go.forEach(y0),yo.forEach(y0)}function su(t,r){t.blockedOn===r&&(t.blockedOn=null,Pf||(Pf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,lw)))}var ou=null;function b0(t){ou!==t&&(ou=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ou===t&&(ou=null);for(var r=0;r<t.length;r+=3){var s=t[r],c=t[r+1],p=t[r+2];if(typeof c!="function"){if(Kf(c||s)===null)continue;break}var y=Vn(s);y!==null&&(t.splice(r,3),r-=3,Gd(y,{pending:!0,data:p,method:s.method,action:c},c,p))}}))}function ms(t){function r(G){return su(G,t)}Dl!==null&&su(Dl,t),Tl!==null&&su(Tl,t),Fl!==null&&su(Fl,t),go.forEach(r),yo.forEach(r);for(var s=0;s<Ml.length;s++){var c=Ml[s];c.blockedOn===t&&(c.blockedOn=null)}for(;0<Ml.length&&(s=Ml[0],s.blockedOn===null);)g0(s),s.blockedOn===null&&Ml.shift();if(s=(t.ownerDocument||t).$$reactFormReplay,s!=null)for(c=0;c<s.length;c+=3){var p=s[c],y=s[c+1],S=p[gn]||null;if(typeof y=="function")S||b0(s);else if(S){var M=null;if(y&&y.hasAttribute("formAction")){if(p=y,S=y[gn]||null)M=S.formAction;else if(Kf(p)!==null)continue}else M=S.action;typeof M=="function"?s[c+1]=M:(s.splice(c,3),c-=3),b0(s)}}}function v0(){function t(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(S){return p=S})},focusReset:"manual",scroll:"manual"})}function r(){p!==null&&(p(),p=null),c||setTimeout(s,20)}function s(){if(!c&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,p=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(s,100),function(){c=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),p!==null&&(p(),p=null)}}}function Qf(t){this._internalRoot=t}cu.prototype.render=Qf.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var s=r.current,c=Fr();d0(s,c,t,r,null,null)},cu.prototype.unmount=Qf.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;d0(t.current,2,null,t,null,null),qc(),r[dr]=null}};function cu(t){this._internalRoot=t}cu.prototype.unstable_scheduleHydration=function(t){if(t){var r=Nt();t={blockedOn:null,target:t,priority:r};for(var s=0;s<Ml.length&&r!==0&&r<Ml[s].priority;s++);Ml.splice(s,0,t),s===0&&g0(t)}};var w0=n.version;if(w0!=="19.2.4")throw Error(i(527,w0,"19.2.4"));oe.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 iw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:W,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var uu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!uu.isDisabled&&uu.supportsFiber)try{Oe=uu.inject(iw),qe=uu}catch{}}return wo.createRoot=function(t,r){if(!o(t))throw Error(i(299));var s=!1,c="",p=Ax,y=Dx,S=Tx;return r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(y=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=c0(t,1,!1,null,null,s,c,null,p,y,S,v0),t[dr]=r.current,Mf(t),new Qf(r)},wo.hydrateRoot=function(t,r,s){if(!o(t))throw Error(i(299));var c=!1,p="",y=Ax,S=Dx,M=Tx,G=null;return s!=null&&(s.unstable_strictMode===!0&&(c=!0),s.identifierPrefix!==void 0&&(p=s.identifierPrefix),s.onUncaughtError!==void 0&&(y=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(M=s.onRecoverableError),s.formState!==void 0&&(G=s.formState)),r=c0(t,1,!0,r,s??null,c,p,G,y,S,M,v0),r.context=u0(null),s=r.current,c=Fr(),c=Ae(c),p=gl(c),p.callback=null,yl(s,p,c),s=c,r.current.lanes=s,we(r,s),ya(r),t[dr]=r.current,Mf(t),new cu(r)},wo.version="19.2.4",wo}var M0;function yw(){if(M0)return eh.exports;M0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),eh.exports=gw(),eh.exports}var bw=yw();const vw="modulepreload",ww=function(e){return"/"+e},R0={},Ey=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=ww(h),h in R0)return;R0[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":vw,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 u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return o.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return n().catch(u)})};class kw extends v.Component{constructor(){super(...arguments);k0(this,"state",{hasError:!1,error:null})}static getDerivedStateFromError(a){return{hasError:!0,error:a}}render(){var a;return this.state.hasError?l.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:l.jsxs("div",{className:"text-center max-w-md",children:[l.jsx("div",{className:"text-4xl mb-3",children:"🚨"}),l.jsx("div",{className:"text-gray-800 font-semibold mb-2",children:"Something went wrong"}),l.jsx("div",{className:"text-gray-500 text-sm mb-4",children:((a=this.state.error)==null?void 0:a.message)??"An unexpected error occurred."}),l.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white rounded-lg text-sm hover:bg-gray-700",children:"Reload"})]})}):this.props.children}}const Sa="/api";async function Ut(e){const n=await fetch(`${Sa}${e}`);if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function un(e,n){const a=await fetch(`${Sa}${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 du(e,n){const a=await fetch(`${Sa}${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`API error: ${a.status}`);return a.json()}async function jw(e,n){const a=await fetch(`${Sa}${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 tl(e,n){const a={method:"DELETE"};n!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(n));const i=await fetch(`${Sa}${e}`,a);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const ye={getCompany:()=>Ut("/company"),getRoles:()=>Ut("/roles"),getRole:e=>Ut(`/roles/${e}`),getProjects:()=>Ut("/projects"),getProject:e=>Ut(`/projects/${e}`),getStandups:()=>Ut("/operations/standups"),getWaves:()=>Ut("/operations/waves"),getWaveDetail:e=>Ut(`/operations/waves/${e}`),patchWave:(e,n)=>du(`/operations/waves/${e}`,n),getDecisions:()=>Ut("/operations/decisions"),updateDecision:(e,n)=>jw(`/operations/decisions/${e}`,{content:n}),deleteDecision:e=>tl(`/operations/decisions/${e}`),getOrgTree:()=>Ut("/engine/org"),getSkills:()=>Ut("/skills"),exportSkills:e=>Ut(`/skills/export/${e}`),getSkillRegistry:()=>Ut("/skills/registry"),installRegistrySkill:(e,n)=>un("/skills/registry/install",{skillId:e,url:n}),createRole:e=>un("/engine/roles",e),updateRole:(e,n)=>du(`/engine/roles/${e}`,n),deleteRole:e=>tl(`/engine/roles/${e}`),getSessions:()=>Ut("/sessions"),getSession:e=>Ut(`/sessions/${e}`),createSession:(e,n="talk")=>un("/sessions",{roleId:e,mode:n}),deleteSession:e=>tl(`/sessions/${e}`),deleteSessions:e=>tl("/sessions",{ids:e}),deleteEmptySessions:()=>tl("/sessions?empty=true"),updateSession:(e,n)=>du(`/sessions/${e}`,n),abortSession:e=>un(`/sessions/${e}/abort`,{}),replyToSession:(e,n,a)=>un(`/sessions/${e}/reply`,{message:n,...a&&{attachments:a}}),startJob:e=>un("/jobs",e),saveWave:e=>un("/waves/save",e),getStatus:()=>Ut("/status"),detectEngine:()=>un("/setup/detect-engine",{}),validatePath:e=>un("/setup/validate-path",{path:e}),scaffold:e=>un("/setup/scaffold",e),getTeams:()=>Ut("/setup/teams"),browse:e=>un("/setup/browse",{path:e}),mkdir:(e,n)=>un("/setup/mkdir",{path:e,name:n}),connectAkb:e=>un("/setup/connect-akb",{path:e}),getRequiredTools:e=>un("/setup/required-tools",{team:e}),installTools:(e,n)=>fetch(`${Sa}/setup/install-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({team:e})}).then(a=>{var f;const i=(f=a.body)==null?void 0:f.getReader();if(!i)return;const o=new TextDecoder;let u="";const d=()=>i.read().then(({done:m,value:h})=>{if(m)return;u+=o.decode(h,{stream:!0});const x=u.split(`
|
|
50
|
-
`);u=x.pop()||"";let g="";for(const 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:()=>Ut("/knowledge"),getKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return Ut(`/knowledge/${n}`)},createKnowledgeDoc:e=>un("/knowledge",e),updateKnowledgeDoc:(e,n)=>{const a=e.split("/").map(encodeURIComponent).join("/");return fetch(`${Sa}/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 tl(`/knowledge/${n}`)},getPreferences:()=>Ut("/preferences"),updatePreferences:e=>du("/preferences",e),chatInChannel:e=>un("/speech/chat",e),getSaveStatus:(e="akb")=>Ut(`/save/status?repo=${e}`),save:(e,n="akb")=>un(`/save?repo=${n}`,{message:e}),getSaveHistory:(e=20,n="akb")=>Ut(`/save/history?limit=${e}&repo=${n}`),restoreSave:(e,n,a="akb")=>un(`/save/restore?repo=${a}`,{sha:e,paths:n}),initGit:()=>un("/save/init",{}),getSyncStatus:(e="akb")=>Ut(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${Sa}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>Ut(`/save/github-status?repo=${e}`),githubCreateRepo:(e,n="private",a="akb")=>un(`/save/github-create-repo?repo=${a}`,{name:e,visibility:n}),addRemote:(e,n="akb")=>un(`/save/remote?repo=${n}`,{url:e}),setCodeRoot:async e=>{const n=await fetch(`${Sa}/setup/code-root`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({codeRoot:e})}),a=await n.json();if(!n.ok)throw new Error(a.error||`API error: ${n.status}`);return a},getCodeRoot:()=>Ut("/setup/code-root"),getCostSummary:()=>Ut("/cost/summary"),getSyncRoles:()=>Ut("/sync/roles"),applySyncUpdate:e=>un("/sync/apply",e),getCompanyStats:()=>Ut("/sync/stats"),getCoins:()=>Ut("/coins"),earnCoins:(e,n,a)=>un("/coins/earn",{amount:e,reason:n,ref:a}),spendCoins:(e,n,a)=>un("/coins/spend",{amount:e,reason:n,ref:a}),migrateCoins:e=>un("/coins/migrate",{completedQuests:e}),getQuestProgress:()=>Ut("/quests/progress"),saveQuestProgress:e=>fetch(`${Sa}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>n.json()),getActiveSessions:()=>Ut("/active-sessions"),getActiveSession:e=>Ut(`/active-sessions/${e}`),registerActiveSession:e=>un("/active-sessions/register",e),deleteActiveSession:e=>tl(`/active-sessions/${e}`),cleanupActiveSessions:()=>un("/active-sessions/cleanup",{}),getGitStatus:()=>Ut("/git/status"),deleteWorktree:e=>tl(`/git/worktrees/${encodeURIComponent(e)}`),deleteBranch:e=>tl(`/git/branches/${encodeURIComponent(e)}`)},Sw=Object.freeze(Object.defineProperty({__proto__:null,api:ye},Symbol.toStringTag,{value:"Module"}));function Ny(e){const[n,a]=v.useState([]),[i,o]=v.useState("idle"),[u,d]=v.useState(""),[f,m]=v.useState([]),h=v.useRef(-1),x=v.useRef(null),g=v.useRef(0),w=v.useCallback(()=>{var C;if(!e)return;(C=x.current)==null||C.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 N=>{if(!N.ok||!N.body){o("error");return}o("streaming");const _=N.body.getReader(),z=new TextDecoder;let H="";for(;;){const{done:R,value:I}=await _.read();if(R)break;H+=z.decode(I,{stream:!0});const q=H.split(`
|
|
51
|
-
`);H=q.pop()??"";let X="";for(const A of q)if(A.startsWith("event: "))X=A.slice(7).trim();else if(A.startsWith("data: ")){try{const $=JSON.parse(A.slice(6));if(X==="activity"){const L=$;L.seq>h.current&&(h.current=L.seq),a(Y=>Y.some(se=>se.seq===L.seq)?Y:[...Y,L]),L.type==="text"&&d(Y=>Y+(L.data.text??"")),L.type==="dispatch:start"&&L.data.childJobId&&m(Y=>[...Y,L.data.childJobId]),L.type==="job:done"?o("done"):L.type==="job: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(N=>{N.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:u,childJobIds:f,reconnect:b}}function Cw(e,n){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const Ew=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Nw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Aw={};function z0(e,n){return(Aw.jsx?Nw:Ew).test(e)}const Dw=/[ \t\n\f\r]/g;function Tw(e){return typeof e=="object"?e.type==="text"?_0(e.value):!1:_0(e)}function _0(e){return e.replace(Dw,"")===""}class Yo{constructor(n,a,i){this.normal=a,this.property=n,i&&(this.space=i)}}Yo.prototype.normal={};Yo.prototype.property={};Yo.prototype.space=void 0;function Ay(e,n){const a={},i={};for(const o of e)Object.assign(a,o.property),Object.assign(i,o.normal);return new Yo(a,i,n)}function Xh(e){return e.toLowerCase()}class kr{constructor(n,a){this.attribute=a,this.property=n}}kr.prototype.attribute="";kr.prototype.booleanish=!1;kr.prototype.boolean=!1;kr.prototype.commaOrSpaceSeparated=!1;kr.prototype.commaSeparated=!1;kr.prototype.defined=!1;kr.prototype.mustUseProperty=!1;kr.prototype.number=!1;kr.prototype.overloadedBoolean=!1;kr.prototype.property="";kr.prototype.spaceSeparated=!1;kr.prototype.space=void 0;let Fw=0;const wt=Di(),Bn=Di(),Wh=Di(),Me=Di(),hn=Di(),bs=Di(),Mr=Di();function Di(){return 2**++Fw}const Gh=Object.freeze(Object.defineProperty({__proto__:null,boolean:wt,booleanish:Bn,commaOrSpaceSeparated:Mr,commaSeparated:bs,number:Me,overloadedBoolean:Wh,spaceSeparated:hn},Symbol.toStringTag,{value:"Module"})),ah=Object.keys(Gh);class km extends kr{constructor(n,a,i,o){let u=-1;if(super(n,a),B0(this,"space",o),typeof i=="number")for(;++u<ah.length;){const d=ah[u];B0(this,ah[u],(i&Gh[d])===Gh[d])}}}km.prototype.defined=!0;function B0(e,n,a){a&&(e[n]=a)}function Es(e){const n={},a={};for(const[i,o]of Object.entries(e.properties)){const u=new km(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(u.mustUseProperty=!0),n[i]=u,a[Xh(i)]=i,a[Xh(u.attribute)]=i}return new Yo(n,a,e.space)}const Dy=Es({properties:{ariaActiveDescendant:null,ariaAtomic:Bn,ariaAutoComplete:null,ariaBusy:Bn,ariaChecked:Bn,ariaColCount:Me,ariaColIndex:Me,ariaColSpan:Me,ariaControls:hn,ariaCurrent:null,ariaDescribedBy:hn,ariaDetails:null,ariaDisabled:Bn,ariaDropEffect:hn,ariaErrorMessage:null,ariaExpanded:Bn,ariaFlowTo:hn,ariaGrabbed:Bn,ariaHasPopup:null,ariaHidden:Bn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:hn,ariaLevel:Me,ariaLive:null,ariaModal:Bn,ariaMultiLine:Bn,ariaMultiSelectable:Bn,ariaOrientation:null,ariaOwns:hn,ariaPlaceholder:null,ariaPosInSet:Me,ariaPressed:Bn,ariaReadOnly:Bn,ariaRelevant:null,ariaRequired:Bn,ariaRoleDescription:hn,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 Ty(e,n){return n in e?e[n]:n}function Fy(e,n){return Ty(e,n.toLowerCase())}const Mw=Es({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:bs,acceptCharset:hn,accessKey:hn,action:null,allow:null,allowFullScreen:wt,allowPaymentRequest:wt,allowUserMedia:wt,alt:null,as:null,async:wt,autoCapitalize:null,autoComplete:hn,autoFocus:wt,autoPlay:wt,blocking:hn,capture:null,charSet:null,checked:wt,cite:null,className:hn,cols:Me,colSpan:null,content:null,contentEditable:Bn,controls:wt,controlsList:hn,coords:Me|bs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:wt,defer:wt,dir:null,dirName:null,disabled:wt,download:Wh,draggable:Bn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:wt,formTarget:null,headers:hn,height:Me,hidden:Wh,high:Me,href:null,hrefLang:null,htmlFor:hn,httpEquiv:hn,id:null,imageSizes:null,imageSrcSet:null,inert:wt,inputMode:null,integrity:null,is:null,isMap:wt,itemId:null,itemProp:hn,itemRef:hn,itemScope:wt,itemType:hn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:wt,low:Me,manifest:null,max:null,maxLength:Me,media:null,method:null,min:null,minLength:Me,multiple:wt,muted:wt,name:null,nonce:null,noModule:wt,noValidate:wt,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:wt,optimum:Me,pattern:null,ping:hn,placeholder:null,playsInline:wt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:wt,referrerPolicy:null,rel:hn,required:wt,reversed:wt,rows:Me,rowSpan:Me,sandbox:hn,scope:null,scoped:wt,seamless:wt,selected:wt,shadowRootClonable:wt,shadowRootDelegatesFocus:wt,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:wt,useMap:null,value:Bn,width:Me,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:hn,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:wt,declare:wt,event:null,face:null,frame:null,frameBorder:null,hSpace:Me,leftMargin:Me,link:null,longDesc:null,lowSrc:null,marginHeight:Me,marginWidth:Me,noResize:wt,noHref:wt,noShade:wt,noWrap:wt,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:wt,disableRemotePlayback:wt,prefix:null,property:null,results:Me,security:null,unselectable:null},space:"html",transform:Fy}),Rw=Es({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Mr,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:hn,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:wt,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:bs,g2:bs,glyphName:bs,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:Mr,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:hn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Me,pointsAtY:Me,pointsAtZ:Me,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Mr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Mr,rev:Mr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Mr,requiredFeatures:Mr,requiredFonts:Mr,requiredFormats:Mr,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:Mr,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:Mr,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:Mr,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:Ty}),My=Es({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Ry=Es({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Fy}),zy=Es({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),zw={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},_w=/[A-Z]/g,O0=/-[a-z]/g,Bw=/^data[-\w.:]+$/i;function Ow(e,n){const a=Xh(n);let i=n,o=kr;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&Bw.test(n)){if(n.charAt(4)==="-"){const u=n.slice(5).replace(O0,Lw);i="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=n.slice(4);if(!O0.test(u)){let d=u.replace(_w,$w);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}o=km}return new o(i,n)}function $w(e){return"-"+e.toLowerCase()}function Lw(e){return e.charAt(1).toUpperCase()}const Iw=Ay([Dy,Mw,My,Ry,zy],"html"),jm=Ay([Dy,Rw,My,Ry,zy],"svg");function Hw(e){return e.join(" ").trim()}var ps={},lh,$0;function Uw(){if($0)return lh;$0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
|
|
52
|
-
`,h="/",x="*",g="",w="comment",b="declaration";function j(E,C){if(typeof E!="string")throw new TypeError("First argument must be a string");if(!E)return[];C=C||{};var N=1,_=1;function z(se){var ee=se.match(n);ee&&(N+=ee.length);var W=se.lastIndexOf(m);_=~W?se.length-W:_+se.length}function H(){var se={line:N,column:_};return function(ee){return ee.position=new R(se),X(),ee}}function R(se){this.start=se,this.end={line:N,column:_},this.source=C.source}R.prototype.content=E;function I(se){var ee=new Error(C.source+":"+N+":"+_+": "+se);if(ee.reason=se,ee.filename=C.source,ee.line=N,ee.column=_,ee.source=E,!C.silent)throw ee}function q(se){var ee=se.exec(E);if(ee){var W=ee[0];return z(W),E=E.slice(W.length),ee}}function X(){q(a)}function A(se){var ee;for(se=se||[];ee=$();)ee!==!1&&se.push(ee);return se}function $(){var se=H();if(!(h!=E.charAt(0)||x!=E.charAt(1))){for(var ee=2;g!=E.charAt(ee)&&(x!=E.charAt(ee)||h!=E.charAt(ee+1));)++ee;if(ee+=2,g===E.charAt(ee-1))return I("End of comment missing");var W=E.slice(2,ee-2);return _+=2,z(W),E=E.slice(ee),_+=2,se({type:w,comment:W})}}function L(){var se=H(),ee=q(i);if(ee){if($(),!q(o))return I("property missing ':'");var W=q(u),oe=se({type:b,property:k(ee[0].replace(e,g)),value:W?k(W[0].replace(e,g)):g});return q(d),oe}}function Y(){var se=[];A(se);for(var ee;ee=L();)ee!==!1&&(se.push(ee),A(se));return se}return X(),Y()}function k(E){return E?E.replace(f,g):g}return lh=j,lh}var L0;function qw(){if(L0)return ps;L0=1;var e=ps&&ps.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(ps,"__esModule",{value:!0}),ps.default=a;const n=e(Uw());function a(i,o){let u=null;if(!i||typeof i!="string")return u;const d=(0,n.default)(i),f=typeof o=="function";return d.forEach(m=>{if(m.type!=="declaration")return;const{property:h,value:x}=m;f?o(h,x,m):x&&(u=u||{},u[h]=x)}),u}return ps}var ko={},I0;function Yw(){if(I0)return ko;I0=1,Object.defineProperty(ko,"__esModule",{value:!0}),ko.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,u=function(h){return!h||a.test(h)||e.test(h)},d=function(h,x){return x.toUpperCase()},f=function(h,x){return"".concat(x,"-")},m=function(h,x){return x===void 0&&(x={}),u(h)?h:(h=h.toLowerCase(),x.reactCompat?h=h.replace(o,f):h=h.replace(i,f),h.replace(n,d))};return ko.camelCase=m,ko}var jo,H0;function Xw(){if(H0)return jo;H0=1;var e=jo&&jo.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(qw()),a=Yw();function i(o,u){var d={};return!o||typeof o!="string"||(0,n.default)(o,function(f,m){f&&m&&(d[(0,a.camelCase)(f,u)]=m)}),d}return i.default=i,jo=i,jo}var Ww=Xw();const Gw=Cy(Ww),_y=By("end"),Sm=By("start");function By(e){return n;function n(a){const i=a&&a.position&&a.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function Vw(e){const n=Sm(e),a=_y(e);if(n&&a)return{start:n,end:a}}function _o(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?U0(e.position):"start"in e||"end"in e?U0(e):"line"in e||"column"in e?Vh(e):""}function Vh(e){return q0(e&&e.line)+":"+q0(e&&e.column)}function U0(e){return Vh(e&&e.start)+"-"+Vh(e&&e.end)}function q0(e){return e&&typeof e=="number"?e:1}class lr extends Error{constructor(n,a,i){super(),typeof a=="string"&&(i=a,a=void 0);let o="",u={},d=!1;if(a&&("line"in a&&"column"in a?u={place:a}:"start"in a&&"end"in a?u={place:a}:"type"in a?u={ancestors:[a],place:a.position}:u={...a}),typeof n=="string"?o=n:!u.cause&&n&&(d=!0,o=n.message,u.cause=n),!u.ruleId&&!u.source&&typeof i=="string"){const m=i.indexOf(":");m===-1?u.ruleId=i:(u.source=i.slice(0,m),u.ruleId=i.slice(m+1))}if(!u.place&&u.ancestors&&u.ancestors){const m=u.ancestors[u.ancestors.length-1];m&&(u.place=m.position)}const f=u.place&&"start"in u.place?u.place.start:u.place;this.ancestors=u.ancestors||void 0,this.cause=u.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=_o(u.place)||"1:1",this.place=u.place||void 0,this.reason=this.message,this.ruleId=u.ruleId||void 0,this.source=u.source||void 0,this.stack=d&&u.cause&&typeof u.cause.stack=="string"?u.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}lr.prototype.file="";lr.prototype.name="";lr.prototype.reason="";lr.prototype.message="";lr.prototype.stack="";lr.prototype.column=void 0;lr.prototype.line=void 0;lr.prototype.ancestors=void 0;lr.prototype.cause=void 0;lr.prototype.fatal=void 0;lr.prototype.place=void 0;lr.prototype.ruleId=void 0;lr.prototype.source=void 0;const Cm={}.hasOwnProperty,Kw=new Map,Pw=/[A-Z]/g,Qw=new Set(["table","tbody","thead","tfoot","tr"]),Zw=new Set(["td","th"]),Oy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Jw(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=n.filePath||void 0;let i;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=s5(a,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=i5(a,n.jsx,n.jsxs)}const o={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?jm:Iw,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},u=$y(o,e,void 0);return u&&typeof u!="string"?u:o.create(e,o.Fragment,{children:u||void 0},void 0)}function $y(e,n,a){if(n.type==="element")return e5(e,n,a);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return t5(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return r5(e,n,a);if(n.type==="mdxjsEsm")return n5(e,n);if(n.type==="root")return a5(e,n,a);if(n.type==="text")return l5(e,n)}function e5(e,n,a){const i=e.schema;let o=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=jm,e.schema=o),e.ancestors.push(n);const u=Iy(e,n.tagName,!1),d=o5(e,n);let f=Nm(e,n);return Qw.has(n.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!Tw(m):!0})),Ly(e,d,u,n),Em(d,f),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function t5(e,n){if(n.data&&n.data.estree&&e.evaluater){const i=n.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Lo(e,n.position)}function n5(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Lo(e,n.position)}function r5(e,n,a){const i=e.schema;let o=i;n.name==="svg"&&i.space==="html"&&(o=jm,e.schema=o),e.ancestors.push(n);const u=n.name===null?e.Fragment:Iy(e,n.name,!0),d=c5(e,n),f=Nm(e,n);return Ly(e,d,u,n),Em(d,f),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function a5(e,n,a){const i={};return Em(i,Nm(e,n)),e.create(n,e.Fragment,i,a)}function l5(e,n){return n.value}function Ly(e,n,a,i){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(n.node=i)}function Em(e,n){if(n.length>0){const a=n.length>1?n:n[0];a&&(e.children=a)}}function i5(e,n,a){return i;function i(o,u,d,f){const h=Array.isArray(d.children)?a:n;return f?h(u,d,f):h(u,d)}}function s5(e,n){return a;function a(i,o,u,d){const f=Array.isArray(u.children),m=Sm(i);return n(o,u,d,f,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function o5(e,n){const a={};let i,o;for(o in n.properties)if(o!=="children"&&Cm.call(n.properties,o)){const u=u5(e,o,n.properties[o]);if(u){const[d,f]=u;e.tableCellAlignToStyle&&d==="align"&&typeof f=="string"&&Zw.has(n.tagName)?i=f:a[d]=f}}if(i){const u=a.style||(a.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return a}function c5(e,n){const a={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const u=i.data.estree.body[0];u.type;const d=u.expression;d.type;const f=d.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else Lo(e,n.position);else{const o=i.name;let u;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const f=i.value.data.estree.body[0];f.type,u=e.evaluater.evaluateExpression(f.expression)}else Lo(e,n.position);else u=i.value===null?!0:i.value;a[o]=u}return a}function Nm(e,n){const a=[];let i=-1;const o=e.passKeys?new Map:Kw;for(;++i<n.children.length;){const u=n.children[i];let d;if(e.passKeys){const m=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(m){const h=o.get(m)||0;d=m+"-"+h,o.set(m,h+1)}}const f=$y(e,u,d);f!==void 0&&a.push(f)}return a}function u5(e,n,a){const i=Ow(e.schema,n);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=i.commaSeparated?Cw(a):Hw(a)),i.property==="style"){let o=typeof a=="object"?a:d5(e,String(a));return e.stylePropertyNameCase==="css"&&(o=f5(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?zw[i.property]||i.property:i.attribute,a]}}function d5(e,n){try{return Gw(n,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const i=a,o=new lr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=Oy+"#cannot-parse-style-attribute",o}}function Iy(e,n,a){let i;if(!a)i={type:"Literal",value:n};else if(n.includes(".")){const o=n.split(".");let u=-1,d;for(;++u<o.length;){const f=z0(o[u])?{type:"Identifier",name:o[u]}:{type:"Literal",value:o[u]};d=d?{type:"MemberExpression",object:d,property:f,computed:!!(u&&f.type==="Literal"),optional:!1}:f}i=d}else i=z0(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const o=i.value;return Cm.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);Lo(e)}function Lo(e,n){const a=new lr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=Oy+"#cannot-handle-mdx-estrees-without-createevaluater",a}function f5(e){const n={};let a;for(a in e)Cm.call(e,a)&&(n[h5(a)]=e[a]);return n}function h5(e){let n=e.replace(Pw,m5);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function m5(e){return"-"+e.toLowerCase()}const ih={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},p5={};function Am(e,n){const a=p5,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Hy(e,i,o)}function Hy(e,n,a){if(x5(e)){if("value"in e)return e.type==="html"&&!a?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Y0(e.children,n,a)}return Array.isArray(e)?Y0(e,n,a):""}function Y0(e,n,a){const i=[];let o=-1;for(;++o<e.length;)i[o]=Hy(e[o],n,a);return i.join("")}function x5(e){return!!(e&&typeof e=="object")}const X0=document.createElement("i");function Dm(e){const n="&"+e+";";X0.innerHTML=n;const a=X0.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===n?!1:a}function Br(e,n,a,i){const o=e.length;let u=0,d;if(n<0?n=-n>o?0:o+n:n=n>o?o:n,a=a>0?a:0,i.length<1e4)d=Array.from(i),d.unshift(n,a),e.splice(...d);else for(a&&e.splice(n,a);u<i.length;)d=i.slice(u,u+1e4),d.unshift(n,0),e.splice(...d),u+=1e4,n+=1e4}function Vr(e,n){return e.length>0?(Br(e,e.length,0,n),e):n}const W0={}.hasOwnProperty;function Uy(e){const n={};let a=-1;for(;++a<e.length;)g5(n,e[a]);return n}function g5(e,n){let a;for(a in n){const o=(W0.call(e,a)?e[a]:void 0)||(e[a]={}),u=n[a];let d;if(u)for(d in u){W0.call(o,d)||(o[d]=[]);const f=u[d];y5(o[d],Array.isArray(f)?f:f?[f]:[])}}}function y5(e,n){let a=-1;const i=[];for(;++a<n.length;)(n[a].add==="after"?e:i).push(n[a]);Br(e,0,0,i)}function qy(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 oa(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const sr=ql(/[A-Za-z]/),ar=ql(/[\dA-Za-z]/),b5=ql(/[#-'*+\--9=?A-Z^-~]/);function zu(e){return e!==null&&(e<32||e===127)}const Kh=ql(/\d/),v5=ql(/[\dA-Fa-f]/),w5=ql(/[!-/:-@[-`{-~]/);function at(e){return e!==null&&e<-2}function dn(e){return e!==null&&(e<0||e===32)}function Tt(e){return e===-2||e===-1||e===32}const Xu=ql(new RegExp("\\p{P}|\\p{S}","u")),Ni=ql(/\s/);function ql(e){return n;function n(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function Ns(e){const n=[];let a=-1,i=0,o=0;for(;++a<e.length;){const u=e.charCodeAt(a);let d="";if(u===37&&ar(e.charCodeAt(a+1))&&ar(e.charCodeAt(a+2)))o=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(d=String.fromCharCode(u));else if(u>55295&&u<57344){const f=e.charCodeAt(a+1);u<56320&&f>56319&&f<57344?(d=String.fromCharCode(u,f),o=1):d="�"}else d=String.fromCharCode(u);d&&(n.push(e.slice(i,a),encodeURIComponent(d)),i=a+o+1,d=""),o&&(a+=o,o=0)}return n.join("")+e.slice(i)}function Ht(e,n,a,i){const o=i?i-1:Number.POSITIVE_INFINITY;let u=0;return d;function d(m){return Tt(m)?(e.enter(a),f(m)):n(m)}function f(m){return Tt(m)&&u++<o?(e.consume(m),f):(e.exit(a),n(m))}}const k5={tokenize:j5};function j5(e){const n=e.attempt(this.parser.constructs.contentInitial,i,o);let a;return n;function i(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ht(e,n,"linePrefix")}function o(f){return e.enter("paragraph"),u(f)}function u(f){const m=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=m),a=m,d(f)}function d(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return at(f)?(e.consume(f),e.exit("chunkText"),u):(e.consume(f),d)}}const S5={tokenize:C5},G0={tokenize:E5};function C5(e){const n=this,a=[];let i=0,o,u,d;return f;function f(_){if(i<a.length){const z=a[i];return n.containerState=z[1],e.attempt(z[0].continuation,m,h)(_)}return h(_)}function m(_){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&N();const z=n.events.length;let H=z,R;for(;H--;)if(n.events[H][0]==="exit"&&n.events[H][1].type==="chunkFlow"){R=n.events[H][1].end;break}C(i);let I=z;for(;I<n.events.length;)n.events[I][1].end={...R},I++;return Br(n.events,H+1,0,n.events.slice(z)),n.events.length=I,h(_)}return f(_)}function h(_){if(i===a.length){if(!o)return w(_);if(o.currentConstruct&&o.currentConstruct.concrete)return j(_);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(G0,x,g)(_)}function x(_){return o&&N(),C(i),w(_)}function g(_){return n.parser.lazy[n.now().line]=i!==a.length,d=n.now().offset,j(_)}function w(_){return n.containerState={},e.attempt(G0,b,j)(_)}function b(_){return i++,a.push([n.currentConstruct,n.containerState]),w(_)}function j(_){if(_===null){o&&N(),C(0),e.consume(_);return}return o=o||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:u}),k(_)}function k(_){if(_===null){E(e.exit("chunkFlow"),!0),C(0),e.consume(_);return}return at(_)?(e.consume(_),E(e.exit("chunkFlow")),i=0,n.interrupt=void 0,f):(e.consume(_),k)}function E(_,z){const H=n.sliceStream(_);if(z&&H.push(null),_.previous=u,u&&(u.next=_),u=_,o.defineSkip(_.start),o.write(H),n.parser.lazy[_.start.line]){let R=o.events.length;for(;R--;)if(o.events[R][1].start.offset<d&&(!o.events[R][1].end||o.events[R][1].end.offset>d))return;const I=n.events.length;let q=I,X,A;for(;q--;)if(n.events[q][0]==="exit"&&n.events[q][1].type==="chunkFlow"){if(X){A=n.events[q][1].end;break}X=!0}for(C(i),R=I;R<n.events.length;)n.events[R][1].end={...A},R++;Br(n.events,q+1,0,n.events.slice(I)),n.events.length=R}}function C(_){let z=a.length;for(;z-- >_;){const H=a[z];n.containerState=H[1],H[0].exit.call(n,e)}a.length=_}function N(){o.write([null]),u=void 0,o=void 0,n.containerState._closeFlow=void 0}}function E5(e,n,a){return Ht(e,e.attempt(this.parser.constructs.document,n,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ws(e){if(e===null||dn(e)||Ni(e))return 1;if(Xu(e))return 2}function Wu(e,n,a){const i=[];let o=-1;for(;++o<e.length;){const u=e[o].resolveAll;u&&!i.includes(u)&&(n=u(n,a),i.push(u))}return n}const Ph={name:"attention",resolveAll:N5,tokenize:A5};function N5(e,n){let a=-1,i,o,u,d,f,m,h,x;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(i=a;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[i][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;m=e[i][1].end.offset-e[i][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const g={...e[i][1].end},w={...e[a][1].start};V0(g,-m),V0(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},u={type:m>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[a][1].start}},o={type:m>1?"strong":"emphasis",start:{...d.start},end:{...f.end}},e[i][1].end={...d.start},e[a][1].start={...f.end},h=[],e[i][1].end.offset-e[i][1].start.offset&&(h=Vr(h,[["enter",e[i][1],n],["exit",e[i][1],n]])),h=Vr(h,[["enter",o,n],["enter",d,n],["exit",d,n],["enter",u,n]]),h=Vr(h,Wu(n.parser.constructs.insideSpan.null,e.slice(i+1,a),n)),h=Vr(h,[["exit",u,n],["enter",f,n],["exit",f,n],["exit",o,n]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,h=Vr(h,[["enter",e[a][1],n],["exit",e[a][1],n]])):x=0,Br(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 A5(e,n){const a=this.parser.constructs.attentionMarkers.null,i=this.previous,o=ws(i);let u;return d;function d(m){return u=m,e.enter("attentionSequence"),f(m)}function f(m){if(m===u)return e.consume(m),f;const h=e.exit("attentionSequence"),x=ws(m),g=!x||x===2&&o||a.includes(m),w=!o||o===2&&x||a.includes(i);return h._open=!!(u===42?g:g&&(o||!w)),h._close=!!(u===42?w:w&&(x||!g)),n(m)}}function V0(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const D5={name:"autolink",tokenize:T5};function T5(e,n,a){let i=0;return o;function o(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),u}function u(b){return sr(b)?(e.consume(b),d):b===64?a(b):h(b)}function d(b){return b===43||b===45||b===46||ar(b)?(i=1,f(b)):h(b)}function f(b){return b===58?(e.consume(b),i=0,m):(b===43||b===45||b===46||ar(b))&&i++<32?(e.consume(b),f):(i=0,h(b))}function m(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):b===null||b===32||b===60||zu(b)?a(b):(e.consume(b),m)}function h(b){return b===64?(e.consume(b),x):b5(b)?(e.consume(b),h):a(b)}function x(b){return ar(b)?g(b):a(b)}function g(b){return b===46?(e.consume(b),i=0,x):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):w(b)}function w(b){if((b===45||ar(b))&&i++<63){const j=b===45?w:g;return e.consume(b),j}return a(b)}}const Xo={partial:!0,tokenize:F5};function F5(e,n,a){return i;function i(u){return Tt(u)?Ht(e,o,"linePrefix")(u):o(u)}function o(u){return u===null||at(u)?n(u):a(u)}}const Yy={continuation:{tokenize:R5},exit:z5,name:"blockQuote",tokenize:M5};function M5(e,n,a){const i=this;return o;function o(d){if(d===62){const f=i.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),u}return a(d)}function u(d){return Tt(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(d))}}function R5(e,n,a){const i=this;return o;function o(d){return Tt(d)?Ht(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):u(d)}function u(d){return e.attempt(Yy,n,a)(d)}}function z5(e){e.exit("blockQuote")}const Xy={name:"characterEscape",tokenize:_5};function _5(e,n,a){return i;function i(u){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(u),e.exit("escapeMarker"),o}function o(u){return w5(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):a(u)}}const Wy={name:"characterReference",tokenize:B5};function B5(e,n,a){const i=this;let o=0,u,d;return f;function f(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),u=31,d=ar,x(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,d=v5,x):(e.enter("characterReferenceValue"),u=7,d=Kh,x(g))}function x(g){if(g===59&&o){const w=e.exit("characterReferenceValue");return d===ar&&!Dm(i.sliceSerialize(w))?a(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(g)&&o++<u?(e.consume(g),x):a(g)}}const K0={partial:!0,tokenize:$5},P0={concrete:!0,name:"codeFenced",tokenize:O5};function O5(e,n,a){const i=this,o={partial:!0,tokenize:H};let u=0,d=0,f;return m;function m(R){return h(R)}function h(R){const I=i.events[i.events.length-1];return u=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,f=R,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(R)}function x(R){return R===f?(d++,e.consume(R),x):d<3?a(R):(e.exit("codeFencedFenceSequence"),Tt(R)?Ht(e,g,"whitespace")(R):g(R))}function g(R){return R===null||at(R)?(e.exit("codeFencedFence"),i.interrupt?n(R):e.check(K0,k,z)(R)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),w(R))}function w(R){return R===null||at(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(R)):Tt(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ht(e,b,"whitespace")(R)):R===96&&R===f?a(R):(e.consume(R),w)}function b(R){return R===null||at(R)?g(R):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(R))}function j(R){return R===null||at(R)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(R)):R===96&&R===f?a(R):(e.consume(R),j)}function k(R){return e.attempt(o,z,E)(R)}function E(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),C}function C(R){return u>0&&Tt(R)?Ht(e,N,"linePrefix",u+1)(R):N(R)}function N(R){return R===null||at(R)?e.check(K0,k,z)(R):(e.enter("codeFlowValue"),_(R))}function _(R){return R===null||at(R)?(e.exit("codeFlowValue"),N(R)):(e.consume(R),_)}function z(R){return e.exit("codeFenced"),n(R)}function H(R,I,q){let X=0;return A;function A(ee){return R.enter("lineEnding"),R.consume(ee),R.exit("lineEnding"),$}function $(ee){return R.enter("codeFencedFence"),Tt(ee)?Ht(R,L,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ee):L(ee)}function L(ee){return ee===f?(R.enter("codeFencedFenceSequence"),Y(ee)):q(ee)}function Y(ee){return ee===f?(X++,R.consume(ee),Y):X>=d?(R.exit("codeFencedFenceSequence"),Tt(ee)?Ht(R,se,"whitespace")(ee):se(ee)):q(ee)}function se(ee){return ee===null||at(ee)?(R.exit("codeFencedFence"),I(ee)):q(ee)}}}function $5(e,n,a){const i=this;return o;function o(d){return d===null?a(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u)}function u(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}const sh={name:"codeIndented",tokenize:I5},L5={partial:!0,tokenize:H5};function I5(e,n,a){const i=this;return o;function o(h){return e.enter("codeIndented"),Ht(e,u,"linePrefix",5)(h)}function u(h){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(h):a(h)}function d(h){return h===null?m(h):at(h)?e.attempt(L5,d,m)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||at(h)?(e.exit("codeFlowValue"),d(h)):(e.consume(h),f)}function m(h){return e.exit("codeIndented"),n(h)}}function H5(e,n,a){const i=this;return o;function o(d){return i.parser.lazy[i.now().line]?a(d):at(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):Ht(e,u,"linePrefix",5)(d)}function u(d){const f=i.events[i.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?n(d):at(d)?o(d):a(d)}}const U5={name:"codeText",previous:Y5,resolve:q5,tokenize:X5};function q5(e){let n=e.length-4,a=3,i,o;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=a;++i<n;)if(e[i][1].type==="codeTextData"){e[a][1].type="codeTextPadding",e[n][1].type="codeTextPadding",a+=2,n-=2;break}}for(i=a-1,n++;++i<=n;)o===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(o=i):(i===n||e[i][1].type==="lineEnding")&&(e[o][1].type="codeTextData",i!==o+2&&(e[o][1].end=e[i-1][1].end,e.splice(o+2,i-o-2),n-=i-o-2,i=o+2),o=void 0);return e}function Y5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function X5(e,n,a){let i=0,o,u;return d;function d(g){return e.enter("codeText"),e.enter("codeTextSequence"),f(g)}function f(g){return g===96?(e.consume(g),i++,f):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?a(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(u=e.enter("codeTextSequence"),o=0,x(g)):at(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||at(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),h)}function x(g){return g===96?(e.consume(g),o++,x):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(g)):(u.type="codeTextData",h(g))}}class W5{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,a){const i=a??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(n,i):n>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(n,a,i){const o=a||0;this.setCursor(Math.trunc(n));const u=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return i&&So(this.left,i),u.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),So(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),So(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);So(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);So(this.left,a.reverse())}}}function So(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 Gy(e){const n={};let a=-1,i,o,u,d,f,m,h;const x=new W5(e);for(;++a<x.length;){for(;a in n;)a=n[a];if(i=x.get(a),a&&i[1].type==="chunkFlow"&&x.get(a-1)[1].type==="listItemPrefix"&&(m=i[1]._tokenizer.events,u=0,u<m.length&&m[u][1].type==="lineEndingBlank"&&(u+=2),u<m.length&&m[u][1].type==="content"))for(;++u<m.length&&m[u][1].type!=="content";)m[u][1].type==="chunkText"&&(m[u][1]._isInFirstContentOfListItem=!0,u++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,G5(x,a)),a=n[a],h=!0);else if(i[1]._container){for(u=a,o=void 0;u--;)if(d=x.get(u),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),d[1].type="lineEnding",o=u);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;o&&(i[1].end={...x.get(o)[1].start},f=x.slice(o,a),f.unshift(i),x.splice(o,a-o+1,f))}}return Br(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!h}function G5(e,n){const a=e.get(n)[1],i=e.get(n)[2];let o=n-1;const u=[];let d=a._tokenizer;d||(d=i.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const 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;);u.push(o),b._tokenizer||(x=i.sliceStream(b),b.next||x.push(null),g&&d.defineSkip(b.start),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),g=b,b=b.next}for(b=a;++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 C=f.slice(E[w],E[w+1]),N=u.pop();m.push([N,N+C.length-1]),e.splice(N,2,C)}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 V5={resolve:P5,tokenize:Q5},K5={partial:!0,tokenize:Z5};function P5(e){return Gy(e),e}function Q5(e,n){let a;return i;function i(f){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),o(f)}function o(f){return f===null?u(f):at(f)?e.check(K5,d,u)(f):(e.consume(f),o)}function u(f){return e.exit("chunkContent"),e.exit("content"),n(f)}function d(f){return e.consume(f),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,o}}function Z5(e,n,a){const i=this;return o;function o(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Ht(e,u,"linePrefix")}function u(d){if(d===null||at(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 Vy(e,n,a,i,o,u,d,f,m){const h=m||Number.POSITIVE_INFINITY;let x=0;return g;function g(C){return C===60?(e.enter(i),e.enter(o),e.enter(u),e.consume(C),e.exit(u),w):C===null||C===32||C===41||zu(C)?a(C):(e.enter(i),e.enter(d),e.enter(f),e.enter("chunkString",{contentType:"string"}),k(C))}function w(C){return C===62?(e.enter(u),e.consume(C),e.exit(u),e.exit(o),e.exit(i),n):(e.enter(f),e.enter("chunkString",{contentType:"string"}),b(C))}function b(C){return C===62?(e.exit("chunkString"),e.exit(f),w(C)):C===null||C===60||at(C)?a(C):(e.consume(C),C===92?j:b)}function j(C){return C===60||C===62||C===92?(e.consume(C),b):b(C)}function k(C){return!x&&(C===null||C===41||dn(C))?(e.exit("chunkString"),e.exit(f),e.exit(d),e.exit(i),n(C)):x<h&&C===40?(e.consume(C),x++,k):C===41?(e.consume(C),x--,k):C===null||C===32||C===40||zu(C)?a(C):(e.consume(C),C===92?E:k)}function E(C){return C===40||C===41||C===92?(e.consume(C),k):k(C)}}function Ky(e,n,a,i,o,u){const d=this;let f=0,m;return h;function h(b){return e.enter(i),e.enter(o),e.consume(b),e.exit(o),e.enter(u),x}function x(b){return f>999||b===null||b===91||b===93&&!m||b===94&&!f&&"_hiddenFootnoteSupport"in d.parser.constructs?a(b):b===93?(e.exit(u),e.enter(o),e.consume(b),e.exit(o),e.exit(i),n):at(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||at(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 Py(e,n,a,i,o,u){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(u),h(w))}function h(w){return w===d?(e.exit(u),m(d)):w===null?a(w):at(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),Ht(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(w))}function x(w){return w===d||w===null||at(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 Bo(e,n){let a;return i;function i(o){return at(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,i):Tt(o)?Ht(e,i,a?"linePrefix":"lineSuffix")(o):n(o)}}const J5={name:"definition",tokenize:tk},ek={partial:!0,tokenize:nk};function tk(e,n,a){const i=this;let o;return u;function u(b){return e.enter("definition"),d(b)}function d(b){return Ky.call(i,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function f(b){return o=oa(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 dn(b)?Bo(e,h)(b):h(b)}function h(b){return Vy(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(ek,g,g)(b)}function g(b){return Tt(b)?Ht(e,w,"whitespace")(b):w(b)}function w(b){return b===null||at(b)?(e.exit("definition"),i.parser.defined.push(o),n(b)):a(b)}}function nk(e,n,a){return i;function i(f){return dn(f)?Bo(e,o)(f):a(f)}function o(f){return Py(e,u,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function u(f){return Tt(f)?Ht(e,d,"whitespace")(f):d(f)}function d(f){return f===null||at(f)?n(f):a(f)}}const rk={name:"hardBreakEscape",tokenize:ak};function ak(e,n,a){return i;function i(u){return e.enter("hardBreakEscape"),e.consume(u),o}function o(u){return at(u)?(e.exit("hardBreakEscape"),n(u)):a(u)}}const lk={name:"headingAtx",resolve:ik,tokenize:sk};function ik(e,n){let a=e.length-2,i=3,o,u;return e[i][1].type==="whitespace"&&(i+=2),a-2>i&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(i===a-1||a-4>i&&e[a-2][1].type==="whitespace")&&(a-=i+1===a?2:4),a>i&&(o={type:"atxHeadingText",start:e[i][1].start,end:e[a][1].end},u={type:"chunkText",start:e[i][1].start,end:e[a][1].end,contentType:"text"},Br(e,i,a-i+1,[["enter",o,n],["enter",u,n],["exit",u,n],["exit",o,n]])),e}function sk(e,n,a){let i=0;return o;function o(x){return e.enter("atxHeading"),u(x)}function u(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&i++<6?(e.consume(x),d):x===null||dn(x)?(e.exit("atxHeadingSequence"),f(x)):a(x)}function f(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||at(x)?(e.exit("atxHeading"),n(x)):Tt(x)?Ht(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||dn(x)?(e.exit("atxHeadingText"),f(x)):(e.consume(x),h)}}const ok=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Q0=["pre","script","style","textarea"],ck={concrete:!0,name:"htmlFlow",resolveTo:fk,tokenize:hk},uk={partial:!0,tokenize:pk},dk={partial:!0,tokenize:mk};function fk(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function hk(e,n,a){const i=this;let o,u,d,f,m;return h;function h(T){return x(T)}function x(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),g}function g(T){return T===33?(e.consume(T),w):T===47?(e.consume(T),u=!0,k):T===63?(e.consume(T),o=3,i.interrupt?n:D):sr(T)?(e.consume(T),d=String.fromCharCode(T),E):a(T)}function w(T){return T===45?(e.consume(T),o=2,b):T===91?(e.consume(T),o=5,f=0,j):sr(T)?(e.consume(T),o=4,i.interrupt?n:D):a(T)}function b(T){return T===45?(e.consume(T),i.interrupt?n:D):a(T)}function j(T){const ie="CDATA[";return T===ie.charCodeAt(f++)?(e.consume(T),f===ie.length?i.interrupt?n:L:j):a(T)}function k(T){return sr(T)?(e.consume(T),d=String.fromCharCode(T),E):a(T)}function E(T){if(T===null||T===47||T===62||dn(T)){const ie=T===47,ge=d.toLowerCase();return!ie&&!u&&Q0.includes(ge)?(o=1,i.interrupt?n(T):L(T)):ok.includes(d.toLowerCase())?(o=6,ie?(e.consume(T),C):i.interrupt?n(T):L(T)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(T):u?N(T):_(T))}return T===45||ar(T)?(e.consume(T),d+=String.fromCharCode(T),E):a(T)}function C(T){return T===62?(e.consume(T),i.interrupt?n:L):a(T)}function N(T){return Tt(T)?(e.consume(T),N):A(T)}function _(T){return T===47?(e.consume(T),A):T===58||T===95||sr(T)?(e.consume(T),z):Tt(T)?(e.consume(T),_):A(T)}function z(T){return T===45||T===46||T===58||T===95||ar(T)?(e.consume(T),z):H(T)}function H(T){return T===61?(e.consume(T),R):Tt(T)?(e.consume(T),H):_(T)}function R(T){return T===null||T===60||T===61||T===62||T===96?a(T):T===34||T===39?(e.consume(T),m=T,I):Tt(T)?(e.consume(T),R):q(T)}function I(T){return T===m?(e.consume(T),m=null,X):T===null||at(T)?a(T):(e.consume(T),I)}function q(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||dn(T)?H(T):(e.consume(T),q)}function X(T){return T===47||T===62||Tt(T)?_(T):a(T)}function A(T){return T===62?(e.consume(T),$):a(T)}function $(T){return T===null||at(T)?L(T):Tt(T)?(e.consume(T),$):a(T)}function L(T){return T===45&&o===2?(e.consume(T),W):T===60&&o===1?(e.consume(T),oe):T===62&&o===4?(e.consume(T),B):T===63&&o===3?(e.consume(T),D):T===93&&o===5?(e.consume(T),V):at(T)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(uk,U,Y)(T)):T===null||at(T)?(e.exit("htmlFlowData"),Y(T)):(e.consume(T),L)}function Y(T){return e.check(dk,se,U)(T)}function se(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),ee}function ee(T){return T===null||at(T)?Y(T):(e.enter("htmlFlowData"),L(T))}function W(T){return T===45?(e.consume(T),D):L(T)}function oe(T){return T===47?(e.consume(T),d="",de):L(T)}function de(T){if(T===62){const ie=d.toLowerCase();return Q0.includes(ie)?(e.consume(T),B):L(T)}return sr(T)&&d.length<8?(e.consume(T),d+=String.fromCharCode(T),de):L(T)}function V(T){return T===93?(e.consume(T),D):L(T)}function D(T){return T===62?(e.consume(T),B):T===45&&o===2?(e.consume(T),D):L(T)}function B(T){return T===null||at(T)?(e.exit("htmlFlowData"),U(T)):(e.consume(T),B)}function U(T){return e.exit("htmlFlow"),n(T)}}function mk(e,n,a){const i=this;return o;function o(d){return at(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):a(d)}function u(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}function pk(e,n,a){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Xo,n,a)}}const xk={name:"htmlText",tokenize:gk};function gk(e,n,a){const i=this;let o,u,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),_):sr(D)?(e.consume(D),q):a(D)}function h(D){return D===45?(e.consume(D),x):D===91?(e.consume(D),u=0,j):sr(D)?(e.consume(D),N):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):at(D)?(d=g,oe(D)):(e.consume(D),g)}function w(D){return D===45?(e.consume(D),b):g(D)}function b(D){return D===62?W(D):D===45?w(D):g(D)}function j(D){const B="CDATA[";return D===B.charCodeAt(u++)?(e.consume(D),u===B.length?k:j):a(D)}function k(D){return D===null?a(D):D===93?(e.consume(D),E):at(D)?(d=k,oe(D)):(e.consume(D),k)}function E(D){return D===93?(e.consume(D),C):k(D)}function C(D){return D===62?W(D):D===93?(e.consume(D),C):k(D)}function N(D){return D===null||D===62?W(D):at(D)?(d=N,oe(D)):(e.consume(D),N)}function _(D){return D===null?a(D):D===63?(e.consume(D),z):at(D)?(d=_,oe(D)):(e.consume(D),_)}function z(D){return D===62?W(D):_(D)}function H(D){return sr(D)?(e.consume(D),R):a(D)}function R(D){return D===45||ar(D)?(e.consume(D),R):I(D)}function I(D){return at(D)?(d=I,oe(D)):Tt(D)?(e.consume(D),I):W(D)}function q(D){return D===45||ar(D)?(e.consume(D),q):D===47||D===62||dn(D)?X(D):a(D)}function X(D){return D===47?(e.consume(D),W):D===58||D===95||sr(D)?(e.consume(D),A):at(D)?(d=X,oe(D)):Tt(D)?(e.consume(D),X):W(D)}function A(D){return D===45||D===46||D===58||D===95||ar(D)?(e.consume(D),A):$(D)}function $(D){return D===61?(e.consume(D),L):at(D)?(d=$,oe(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,Y):at(D)?(d=L,oe(D)):Tt(D)?(e.consume(D),L):(e.consume(D),se)}function Y(D){return D===o?(e.consume(D),o=void 0,ee):D===null?a(D):at(D)?(d=Y,oe(D)):(e.consume(D),Y)}function se(D){return D===null||D===34||D===39||D===60||D===61||D===96?a(D):D===47||D===62||dn(D)?X(D):(e.consume(D),se)}function ee(D){return D===47||D===62||dn(D)?X(D):a(D)}function W(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),n):a(D)}function oe(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),de}function de(D){return Tt(D)?Ht(e,V,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):V(D)}function V(D){return e.enter("htmlTextData"),d(D)}}const Tm={name:"labelEnd",resolveAll:wk,resolveTo:kk,tokenize:jk},yk={tokenize:Sk},bk={tokenize:Ck},vk={tokenize:Ek};function wk(e){let n=-1;const a=[];for(;++n<e.length;){const i=e[n][1];if(a.push(e[n]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const o=i.type==="labelImage"?4:2;i.type="data",n+=o}}return e.length!==a.length&&Br(e,0,e.length,a),e}function kk(e,n){let a=e.length,i=0,o,u,d,f;for(;a--;)if(o=e[a][1],u){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[a][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(d){if(e[a][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(u=a,o.type!=="labelLink")){i=2;break}}else o.type==="labelEnd"&&(d=a);const m={type:e[u][1].type==="labelLink"?"link":"image",start:{...e[u][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[u][1].start},end:{...e[d][1].end}},x={type:"labelText",start:{...e[u+i+2][1].end},end:{...e[d-2][1].start}};return f=[["enter",m,n],["enter",h,n]],f=Vr(f,e.slice(u+1,u+i+3)),f=Vr(f,[["enter",x,n]]),f=Vr(f,Wu(n.parser.constructs.insideSpan.null,e.slice(u+i+4,d-3),n)),f=Vr(f,[["exit",x,n],e[d-2],e[d-1],["exit",h,n]]),f=Vr(f,e.slice(d+1)),f=Vr(f,[["exit",m,n]]),Br(e,u,e.length,f),e}function jk(e,n,a){const i=this;let o=i.events.length,u,d;for(;o--;)if((i.events[o][1].type==="labelImage"||i.events[o][1].type==="labelLink")&&!i.events[o][1]._balanced){u=i.events[o][1];break}return f;function f(w){return u?u._inactive?g(w):(d=i.parser.defined.includes(oa(i.sliceSerialize({start:u.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(yk,x,d?x:g)(w):w===91?e.attempt(bk,x,d?h:g)(w):d?x(w):g(w)}function h(w){return e.attempt(vk,x,g)(w)}function x(w){return n(w)}function g(w){return u._balanced=!0,a(w)}}function Sk(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 dn(g)?Bo(e,u)(g):u(g)}function u(g){return g===41?x(g):Vy(e,d,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function d(g){return dn(g)?Bo(e,m)(g):x(g)}function f(g){return a(g)}function m(g){return g===34||g===39||g===40?Py(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):x(g)}function h(g){return dn(g)?Bo(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 Ck(e,n,a){const i=this;return o;function o(f){return Ky.call(i,e,u,d,"reference","referenceMarker","referenceString")(f)}function u(f){return i.parser.defined.includes(oa(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(f):a(f)}function d(f){return a(f)}}function Ek(e,n,a){return i;function i(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),o}function o(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),n):a(u)}}const Nk={name:"labelStartImage",resolveAll:Tm.resolveAll,tokenize:Ak};function Ak(e,n,a){const i=this;return o;function o(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),u}function u(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),d):a(f)}function d(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(f):n(f)}}const Dk={name:"labelStartLink",resolveAll:Tm.resolveAll,tokenize:Tk};function Tk(e,n,a){const i=this;return o;function o(d){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelLink"),u}function u(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(d):n(d)}}const oh={name:"lineEnding",tokenize:Fk};function Fk(e,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Ht(e,n,"linePrefix")}}const Du={name:"thematicBreak",tokenize:Mk};function Mk(e,n,a){let i=0,o;return u;function u(h){return e.enter("thematicBreak"),d(h)}function d(h){return o=h,f(h)}function f(h){return h===o?(e.enter("thematicBreakSequence"),m(h)):i>=3&&(h===null||at(h))?(e.exit("thematicBreak"),n(h)):a(h)}function m(h){return h===o?(e.consume(h),i++,m):(e.exit("thematicBreakSequence"),Tt(h)?Ht(e,f,"whitespace")(h):f(h))}}const vr={continuation:{tokenize:Bk},exit:$k,name:"list",tokenize:_k},Rk={partial:!0,tokenize:Lk},zk={partial:!0,tokenize:Ok};function _k(e,n,a){const i=this,o=i.events[i.events.length-1];let u=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,d=0;return 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:Kh(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(Du,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 Kh(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(Xo,i.interrupt?a:x,e.attempt(Rk,w,g))}function x(b){return i.containerState.initialBlankLine=!0,u++,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=u+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(b)}}function Bk(e,n,a){const i=this;return i.containerState._closeFlow=void 0,e.check(Xo,o,u);function o(f){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Ht(e,n,"listItemIndent",i.containerState.size+1)(f)}function u(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(zk,n,d)(f))}function d(f){return i.containerState._closeFlow=!0,i.interrupt=void 0,Ht(e,e.attempt(vr,n,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function Ok(e,n,a){const i=this;return Ht(e,o,"listItemIndent",i.containerState.size+1);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===i.containerState.size?n(u):a(u)}}function $k(e){e.exit(this.containerState.type)}function Lk(e,n,a){const i=this;return Ht(e,o,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(u){const d=i.events[i.events.length-1];return!Tt(u)&&d&&d[1].type==="listItemPrefixWhitespace"?n(u):a(u)}}const Z0={name:"setextUnderline",resolveTo:Ik,tokenize:Hk};function Ik(e,n){let a=e.length,i,o,u;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){i=a;break}e[a][1].type==="paragraph"&&(o=a)}else e[a][1].type==="content"&&e.splice(a,1),!u&&e[a][1].type==="definition"&&(u=a);const d={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",u?(e.splice(o,0,["enter",d,n]),e.splice(u+1,0,["exit",e[i][1],n]),e[i][1].end={...e[u][1].end}):e[i][1]=d,e.push(["exit",d,n]),e}function Hk(e,n,a){const i=this;let o;return u;function u(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)?Ht(e,m,"lineSuffix")(h):m(h))}function m(h){return h===null||at(h)?(e.exit("setextHeadingLine"),n(h)):a(h)}}const Uk={tokenize:qk};function qk(e){const n=this,a=e.attempt(Xo,i,e.attempt(this.parser.constructs.flowInitial,o,Ht(e,e.attempt(this.parser.constructs.flow,o,e.attempt(V5,o)),"linePrefix")));return a;function i(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),n.currentConstruct=void 0,a}function o(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),n.currentConstruct=void 0,a}}const Yk={resolveAll:Zy()},Xk=Qy("string"),Wk=Qy("text");function Qy(e){return{resolveAll:Zy(e==="text"?Gk:void 0),tokenize:n};function n(a){const i=this,o=this.parser.constructs[e],u=a.attempt(o,d,f);return d;function d(x){return h(x)?u(x):f(x)}function f(x){if(x===null){a.consume(x);return}return a.enter("data"),a.consume(x),m}function m(x){return h(x)?(a.exit("data"),u(x)):(a.consume(x),m)}function h(x){if(x===null)return!0;const g=o[x];let 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 Zy(e){return n;function n(a,i){let o=-1,u;for(;++o<=a.length;)u===void 0?a[o]&&a[o][1].type==="data"&&(u=o,o++):(!a[o]||a[o][1].type!=="data")&&(o!==u+2&&(a[u][1].end=a[o-1][1].end,a.splice(u+2,o-u-2),o=u+2),u=void 0);return e?e(a,i):a}}function Gk(e,n){let a=0;for(;++a<=e.length;)if((a===e.length||e[a][1].type==="lineEnding")&&e[a-1][1].type==="data"){const i=e[a-1][1],o=n.sliceStream(i);let u=o.length,d=-1,f=0,m;for(;u--;){const h=o[u];if(typeof h=="string"){for(d=h.length;h.charCodeAt(d-1)===32;)f++,d--;if(d)break;d=-1}else if(h===-2)m=!0,f++;else if(h!==-1){u++;break}}if(n._contentTypeTextTrailing&&a===e.length&&(f=0),f){const h={type:a===e.length||m||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?d:i.start._bufferIndex+d,_index:i.start._index+u,line:i.end.line,column:i.end.column-f,offset:i.end.offset-f},end:{...i.end}};i.end={...h.start},i.start.offset===i.end.offset?Object.assign(i,h):(e.splice(a,0,["enter",h,n],["exit",h,n]),a+=2)}a++}return e}const Vk={42:vr,43:vr,45:vr,48:vr,49:vr,50:vr,51:vr,52:vr,53:vr,54:vr,55:vr,56:vr,57:vr,62:Yy},Kk={91:J5},Pk={[-2]:sh,[-1]:sh,32:sh},Qk={35:lk,42:Du,45:[Z0,Du],60:ck,61:Z0,95:Du,96:P0,126:P0},Zk={38:Wy,92:Xy},Jk={[-5]:oh,[-4]:oh,[-3]:oh,33:Nk,38:Wy,42:Ph,60:[D5,xk],91:Dk,92:[rk,Xy],93:Tm,95:Ph,96:U5},e3={null:[Ph,Yk]},t3={null:[42,95]},n3={null:[]},r3=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:t3,contentInitial:Kk,disable:n3,document:Vk,flow:Qk,flowInitial:Pk,insideSpan:e3,string:Zk,text:Jk},Symbol.toStringTag,{value:"Module"}));function a3(e,n,a){let i={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const o={},u=[];let d=[],f=[];const m={attempt:I(H),check:I(R),consume:N,enter:_,exit:z,interrupt:I(R,{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&&u.push(n),h;function g($){return d=Vr(d,$),E(),d[d.length-1]!==null?[]:(q(n,0),h.events=Wu(u,h.events,h),h.events)}function w($,L){return i3(b($),L)}function b($){return l3(d,$)}function j(){const{_bufferIndex:$,_index:L,line:Y,column:se,offset:ee}=i;return{_bufferIndex:$,_index:L,line:Y,column:se,offset:ee}}function k($){o[$.line]=$.column,A()}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;)C(L.charCodeAt(i._bufferIndex));else C(L)}}function C($){x=x($)}function N($){at($)?(i.line++,i.column=1,i.offset+=$===-3?2:1,A()):$!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===d[i._index].length&&(i._bufferIndex=-1,i._index++)),h.previous=$}function _($,L){const Y=L||{};return Y.type=$,Y.start=j(),h.events.push(["enter",Y,h]),f.push(Y),Y}function z($){const L=f.pop();return L.end=j(),h.events.push(["exit",L,h]),L}function H($,L){q($,L.from)}function R($,L){L.restore()}function I($,L){return Y;function Y(se,ee,W){let oe,de,V,D;return Array.isArray(se)?U(se):"tokenize"in se?U([se]):B(se);function B(pe){return ze;function ze(Ie){const He=Ie!==null&&pe[Ie],st=Ie!==null&&pe.null,Pe=[...Array.isArray(He)?He:He?[He]:[],...Array.isArray(st)?st:st?[st]:[]];return U(Pe)(Ie)}}function U(pe){return oe=pe,de=0,pe.length===0?W:T(pe[de])}function T(pe){return ze;function ze(Ie){return D=X(),V=pe,pe.partial||(h.currentConstruct=pe),pe.name&&h.parser.constructs.disable.null.includes(pe.name)?ge():pe.tokenize.call(L?Object.assign(Object.create(h),L):h,m,ie,ge)(Ie)}}function ie(pe){return $(V,D),ee}function ge(pe){return D.restore(),++de<oe.length?T(oe[de]):W}}}function q($,L){$.resolveAll&&!u.includes($)&&u.push($),$.resolve&&Br(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,Y=h.currentConstruct,se=h.events.length,ee=Array.from(f);return{from:se,restore:W};function W(){i=$,h.previous=L,h.currentConstruct=Y,h.events.length=se,f=ee,A()}}function A(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function l3(e,n){const a=n.start._index,i=n.start._bufferIndex,o=n.end._index,u=n.end._bufferIndex;let d;if(a===o)d=[e[a].slice(i,u)];else{if(d=e.slice(a,o),i>-1){const f=d[0];typeof f=="string"?d[0]=f.slice(i):d.shift()}u>0&&d.push(e[o].slice(0,u))}return d}function i3(e,n){let a=-1;const i=[];let o;for(;++a<e.length;){const u=e[a];let d;if(typeof u=="string")d=u;else switch(u){case-5:{d="\r";break}case-4:{d=`
|
|
53
|
-
`;break}case-3:{d=`\r
|
|
54
|
-
`;break}case-2:{d=n?" ":" ";break}case-1:{if(!n&&o)continue;d=" ";break}default:d=String.fromCharCode(u)}o=u===-2,i.push(d)}return i.join("")}function s3(e){const i={constructs:Uy([r3,...(e||{}).extensions||[]]),content:o(k5),defined:[],document:o(S5),flow:o(Uk),lazy:{},string:o(Xk),text:o(Wk)};return i;function o(u){return d;function d(f){return a3(i,u,f)}}}function o3(e){for(;!Gy(e););return e}const J0=/[\0\t\n\r]/g;function c3(){let e=1,n="",a=!0,i;return o;function o(u,d,f){const m=[];let h,x,g,w,b;for(u=n+(typeof u=="string"?u.toString():new TextDecoder(d||void 0).decode(u)),g=0,n="",a&&(u.charCodeAt(0)===65279&&g++,a=void 0);g<u.length;){if(J0.lastIndex=g,h=J0.exec(u),w=h&&h.index!==void 0?h.index:u.length,b=u.charCodeAt(w),!h){n=u.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(u.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 u3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function d3(e){return e.replace(u3,f3)}function f3(e,n,a){if(n)return n;if(a.charCodeAt(0)===35){const o=a.charCodeAt(1),u=o===120||o===88;return qy(a.slice(u?2:1),u?16:10)}return Dm(a)||e}const Jy={}.hasOwnProperty;function h3(e,n,a){return n&&typeof n=="object"&&(a=n,n=void 0),m3(a)(o3(s3(a).document().write(c3()(e,n,!0))))}function m3(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(Wt),autolinkProtocol:X,autolinkEmail:X,atxHeading:u(yt),blockQuote:u(st),characterEscape:X,characterReference:X,codeFenced:u(Pe),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:u(Pe,d),codeText:u(et,d),codeTextData:X,data:X,codeFlowValue:X,definition:u(Ee),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:u(De),hardBreakEscape:u(ut),hardBreakTrailing:u(ut),htmlFlow:u(pt,d),htmlFlowData:X,htmlText:u(pt,d),htmlTextData:X,image:u(jt),label:d,link:u(Wt),listItem:u(Et),listItemValue:w,listOrdered:u(Ft,g),listUnordered:u(Ft),paragraph:u($n),reference:T,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:u(yt),strong:u(me),thematicBreak:u(Ne)},exit:{atxHeading:m(),atxHeadingSequence:H,autolink:m(),autolinkEmail:He,autolinkProtocol:Ie,blockQuote:m(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:pe,characterReference:ze,codeFenced:m(E),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:j,codeFlowValue:A,codeIndented:m(C),codeText:m(ee),codeTextData:A,data:A,definition:m(),definitionDestinationString:z,definitionLabelString:N,definitionTitleString:_,emphasis:m(),hardBreakEscape:m(L),hardBreakTrailing:m(L),htmlFlow:m(Y),htmlFlowData:A,htmlText:m(se),htmlTextData:A,image:m(oe),label:V,labelText:de,lineEnding:$,link:m(W),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:ie,resourceDestinationString:D,resourceTitleString:B,resource:U,setextHeading:m(q),setextHeadingLineSequence:I,setextHeadingText:R,strong:m(),thematicBreak:m()}};eb(n,(e||{}).mdastExtensions||[]);const a={};return i;function i(K){let ue={type:"root",children:[]};const te={stack:[ue],tokenStack:[],config:n,enter:f,exit:h,buffer:d,resume:x,data:a},ke=[];let ve=-1;for(;++ve<K.length;)if(K[ve][1].type==="listOrdered"||K[ve][1].type==="listUnordered")if(K[ve][0]==="enter")ke.push(ve);else{const _e=ke.pop();ve=o(K,_e,ve)}for(ve=-1;++ve<K.length;){const _e=n[K[ve][0]];Jy.call(_e,K[ve][1].type)&&_e[K[ve][1].type].call(Object.assign({sliceSerialize:K[ve][2].sliceSerialize},te),K[ve][1])}if(te.tokenStack.length>0){const _e=te.tokenStack[te.tokenStack.length-1];(_e[1]||eg).call(te,void 0,_e[0])}for(ue.position={start:zl(K.length>0?K[0][1].start:{line:1,column:1,offset:0}),end:zl(K.length>0?K[K.length-2][1].end:{line:1,column:1,offset:0})},ve=-1;++ve<n.transforms.length;)ue=n.transforms[ve](ue)||ue;return ue}function o(K,ue,te){let ke=ue-1,ve=-1,_e=!1,Be,Oe,qe,rt;for(;++ke<=te;){const Ve=K[ke];switch(Ve[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ve[0]==="enter"?ve++:ve--,rt=void 0;break}case"lineEndingBlank":{Ve[0]==="enter"&&(Be&&!rt&&!ve&&!qe&&(qe=ke),rt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:rt=void 0}if(!ve&&Ve[0]==="enter"&&Ve[1].type==="listItemPrefix"||ve===-1&&Ve[0]==="exit"&&(Ve[1].type==="listUnordered"||Ve[1].type==="listOrdered")){if(Be){let bt=ke;for(Oe=void 0;bt--;){const Re=K[bt];if(Re[1].type==="lineEnding"||Re[1].type==="lineEndingBlank"){if(Re[0]==="exit")continue;Oe&&(K[Oe][1].type="lineEndingBlank",_e=!0),Re[1].type="lineEnding",Oe=bt}else if(!(Re[1].type==="linePrefix"||Re[1].type==="blockQuotePrefix"||Re[1].type==="blockQuotePrefixWhitespace"||Re[1].type==="blockQuoteMarker"||Re[1].type==="listItemIndent"))break}qe&&(!Oe||qe<Oe)&&(Be._spread=!0),Be.end=Object.assign({},Oe?K[Oe][1].start:Ve[1].end),K.splice(Oe||ke,0,["exit",Be,Ve[2]]),ke++,te++}if(Ve[1].type==="listItemPrefix"){const bt={type:"listItem",_spread:!1,start:Object.assign({},Ve[1].start),end:void 0};Be=bt,K.splice(ke,0,["enter",bt,Ve[2]]),ke++,te++,qe=void 0,rt=!0}}}return K[ue][1]._spread=_e,te}function u(K,ue){return te;function te(ke){f.call(this,K(ke),ke),ue&&ue.call(this,ke)}}function d(){this.stack.push({type:"fragment",children:[]})}function f(K,ue,te){this.stack[this.stack.length-1].children.push(K),this.stack.push(K),this.tokenStack.push([ue,te||void 0]),K.position={start:zl(ue.start),end:void 0}}function m(K){return ue;function ue(te){K&&K.call(this,te),h.call(this,te)}}function h(K,ue){const te=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==K.type&&(ue?ue.call(this,K,ke[0]):(ke[1]||eg).call(this,K,ke[0]));else throw new Error("Cannot close `"+K.type+"` ("+_o({start:K.start,end:K.end})+"): it’s not open");te.position.end=zl(K.end)}function x(){return Am(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function w(K){if(this.data.expectingFirstListItemValue){const ue=this.stack[this.stack.length-2];ue.start=Number.parseInt(this.sliceSerialize(K),10),this.data.expectingFirstListItemValue=void 0}}function b(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.lang=K}function j(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.meta=K}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function E(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function C(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K.replace(/(\r?\n|\r)$/g,"")}function N(K){const ue=this.resume(),te=this.stack[this.stack.length-1];te.label=ue,te.identifier=oa(this.sliceSerialize(K)).toLowerCase()}function _(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.title=K}function z(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.url=K}function H(K){const ue=this.stack[this.stack.length-1];if(!ue.depth){const te=this.sliceSerialize(K).length;ue.depth=te}}function R(){this.data.setextHeadingSlurpLineEnding=!0}function I(K){const ue=this.stack[this.stack.length-1];ue.depth=this.sliceSerialize(K).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function X(K){const te=this.stack[this.stack.length-1].children;let ke=te[te.length-1];(!ke||ke.type!=="text")&&(ke=Se(),ke.position={start:zl(K.start),end:void 0},te.push(ke)),this.stack.push(ke)}function A(K){const ue=this.stack.pop();ue.value+=this.sliceSerialize(K),ue.position.end=zl(K.end)}function $(K){const ue=this.stack[this.stack.length-1];if(this.data.atHardBreak){const te=ue.children[ue.children.length-1];te.position.end=zl(K.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(ue.type)&&(X.call(this,K),A.call(this,K))}function L(){this.data.atHardBreak=!0}function Y(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K}function se(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K}function ee(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.value=K}function W(){const K=this.stack[this.stack.length-1];if(this.data.inReference){const ue=this.data.referenceType||"shortcut";K.type+="Reference",K.referenceType=ue,delete K.url,delete K.title}else delete K.identifier,delete K.label;this.data.referenceType=void 0}function oe(){const K=this.stack[this.stack.length-1];if(this.data.inReference){const ue=this.data.referenceType||"shortcut";K.type+="Reference",K.referenceType=ue,delete K.url,delete K.title}else delete K.identifier,delete K.label;this.data.referenceType=void 0}function de(K){const ue=this.sliceSerialize(K),te=this.stack[this.stack.length-2];te.label=d3(ue),te.identifier=oa(ue).toLowerCase()}function V(){const K=this.stack[this.stack.length-1],ue=this.resume(),te=this.stack[this.stack.length-1];if(this.data.inReference=!0,te.type==="link"){const ke=K.children;te.children=ke}else te.alt=ue}function D(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.url=K}function B(){const K=this.resume(),ue=this.stack[this.stack.length-1];ue.title=K}function U(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function ie(K){const ue=this.resume(),te=this.stack[this.stack.length-1];te.label=ue,te.identifier=oa(this.sliceSerialize(K)).toLowerCase(),this.data.referenceType="full"}function ge(K){this.data.characterReferenceType=K.type}function pe(K){const ue=this.sliceSerialize(K),te=this.data.characterReferenceType;let ke;te?(ke=qy(ue,te==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=Dm(ue);const ve=this.stack[this.stack.length-1];ve.value+=ke}function ze(K){const ue=this.stack.pop();ue.position.end=zl(K.end)}function Ie(K){A.call(this,K);const ue=this.stack[this.stack.length-1];ue.url=this.sliceSerialize(K)}function He(K){A.call(this,K);const ue=this.stack[this.stack.length-1];ue.url="mailto:"+this.sliceSerialize(K)}function st(){return{type:"blockquote",children:[]}}function Pe(){return{type:"code",lang:null,meta:null,value:""}}function et(){return{type:"inlineCode",value:""}}function Ee(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function De(){return{type:"emphasis",children:[]}}function yt(){return{type:"heading",depth:0,children:[]}}function ut(){return{type:"break"}}function pt(){return{type:"html",value:""}}function jt(){return{type:"image",title:null,url:"",alt:null}}function Wt(){return{type:"link",title:null,url:"",children:[]}}function Ft(K){return{type:"list",ordered:K.type==="listOrdered",start:null,spread:K._spread,children:[]}}function Et(K){return{type:"listItem",spread:K._spread,checked:null,children:[]}}function $n(){return{type:"paragraph",children:[]}}function me(){return{type:"strong",children:[]}}function Se(){return{type:"text",value:""}}function Ne(){return{type:"thematicBreak"}}}function zl(e){return{line:e.line,column:e.column,offset:e.offset}}function eb(e,n){let a=-1;for(;++a<n.length;){const i=n[a];Array.isArray(i)?eb(e,i):p3(e,i)}}function p3(e,n){let a;for(a in n)if(Jy.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 eg(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+_o({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+_o({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+_o({start:n.start,end:n.end})+") is still open")}function x3(e){const n=this;n.parser=a;function a(i){return h3(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function g3(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 y3(e,n){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,a),[e.applyData(n,a),{type:"text",value:`
|
|
55
|
-
`}]}function b3(e,n){const a=n.value?n.value+`
|
|
56
|
-
`:"",i={},o=n.lang?n.lang.split(/\s+/):[];o.length>0&&(i.className=["language-"+o[0]]);let u={type:"element",tagName:"code",properties:i,children:[{type:"text",value:a}]};return n.meta&&(u.data={meta:n.meta}),e.patch(n,u),u=e.applyData(n,u),u={type:"element",tagName:"pre",properties:{},children:[u]},e.patch(n,u),u}function v3(e,n){const a={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function w3(e,n){const a={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function k3(e,n){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),o=Ns(i.toLowerCase()),u=e.footnoteOrder.indexOf(i);let d,f=e.footnoteCounts.get(i);f===void 0?(f=0,e.footnoteOrder.push(i),d=e.footnoteOrder.length):d=u+1,f+=1,e.footnoteCounts.set(i,f);const m={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(n,m);const h={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(n,h),e.applyData(n,h)}function j3(e,n){const a={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function S3(e,n){if(e.options.allowDangerousHtml){const a={type:"raw",value:n.value};return e.patch(n,a),e.applyData(n,a)}}function tb(e,n){const a=n.referenceType;let i="]";if(a==="collapsed"?i+="[]":a==="full"&&(i+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+i}];const o=e.all(n),u=o[0];u&&u.type==="text"?u.value="["+u.value:o.unshift({type:"text",value:"["});const d=o[o.length-1];return d&&d.type==="text"?d.value+=i:o.push({type:"text",value:i}),o}function C3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return tb(e,n);const o={src:Ns(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(o.title=i.title);const u={type:"element",tagName:"img",properties:o,children:[]};return e.patch(n,u),e.applyData(n,u)}function E3(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 N3(e,n){const a={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,a);const i={type:"element",tagName:"code",properties:{},children:[a]};return e.patch(n,i),e.applyData(n,i)}function A3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return tb(e,n);const o={href:Ns(i.url||"")};i.title!==null&&i.title!==void 0&&(o.title=i.title);const u={type:"element",tagName:"a",properties:o,children:e.all(n)};return e.patch(n,u),e.applyData(n,u)}function D3(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 T3(e,n,a){const i=e.all(n),o=a?F3(a):nb(n),u={},d=[];if(typeof n.checked=="boolean"){const x=i[0];let g;x&&x.type==="element"&&x.tagName==="p"?g=x:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),u.className=["task-list-item"]}let f=-1;for(;++f<i.length;){const x=i[f];(o||f!==0||x.type!=="element"||x.tagName!=="p")&&d.push({type:"text",value:`
|
|
57
|
-
`}),x.type==="element"&&x.tagName==="p"&&!o?d.push(...x.children):d.push(x)}const m=i[i.length-1];m&&(o||m.type!=="element"||m.tagName!=="p")&&d.push({type:"text",value:`
|
|
58
|
-
`});const h={type:"element",tagName:"li",properties:u,children:d};return e.patch(n,h),e.applyData(n,h)}function F3(e){let n=!1;if(e.type==="list"){n=e.spread||!1;const a=e.children;let i=-1;for(;!n&&++i<a.length;)n=nb(a[i])}return n}function nb(e){const n=e.spread;return n??e.children.length>1}function M3(e,n){const a={},i=e.all(n);let o=-1;for(typeof n.start=="number"&&n.start!==1&&(a.start=n.start);++o<i.length;){const d=i[o];if(d.type==="element"&&d.tagName==="li"&&d.properties&&Array.isArray(d.properties.className)&&d.properties.className.includes("task-list-item")){a.className=["contains-task-list"];break}}const u={type:"element",tagName:n.ordered?"ol":"ul",properties:a,children:e.wrap(i,!0)};return e.patch(n,u),e.applyData(n,u)}function R3(e,n){const a={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function z3(e,n){const a={type:"root",children:e.wrap(e.all(n))};return e.patch(n,a),e.applyData(n,a)}function _3(e,n){const a={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function B3(e,n){const a=e.all(n),i=a.shift(),o=[];if(i){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(n.children[0],d),o.push(d)}if(a.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},f=Sm(n.children[1]),m=_y(n.children[n.children.length-1]);f&&m&&(d.position={start:f,end:m}),o.push(d)}const u={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(n,u),e.applyData(n,u)}function O3(e,n,a){const i=a?a.children:void 0,u=(i?i.indexOf(n):1)===0?"th":"td",d=a&&a.type==="table"?a.align:void 0,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:u,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 $3(e,n){const a={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}const tg=9,ng=32;function L3(e){const n=String(e),a=/\r?\n|\r/g;let i=a.exec(n),o=0;const u=[];for(;i;)u.push(rg(n.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=a.exec(n);return u.push(rg(n.slice(o),o>0,!1)),u.join("")}function rg(e,n,a){let i=0,o=e.length;if(n){let u=e.codePointAt(i);for(;u===tg||u===ng;)i++,u=e.codePointAt(i)}if(a){let u=e.codePointAt(o-1);for(;u===tg||u===ng;)o--,u=e.codePointAt(o-1)}return o>i?e.slice(i,o):""}function I3(e,n){const a={type:"text",value:L3(String(n.value))};return e.patch(n,a),e.applyData(n,a)}function H3(e,n){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,a),e.applyData(n,a)}const U3={blockquote:g3,break:y3,code:b3,delete:v3,emphasis:w3,footnoteReference:k3,heading:j3,html:S3,imageReference:C3,image:E3,inlineCode:N3,linkReference:A3,link:D3,listItem:T3,list:M3,paragraph:R3,root:z3,strong:_3,table:B3,tableCell:$3,tableRow:O3,text:I3,thematicBreak:H3,toml:fu,yaml:fu,definition:fu,footnoteDefinition:fu};function fu(){}const rb=-1,Gu=0,Oo=1,_u=2,Fm=3,Mm=4,Rm=5,zm=6,ab=7,lb=8,ag=typeof self=="object"?self:globalThis,q3=(e,n)=>{const a=(o,u)=>(e.set(u,o),o),i=o=>{if(e.has(o))return e.get(o);const[u,d]=n[o];switch(u){case Gu:case rb:return a(d,o);case Oo:{const f=a([],o);for(const m of d)f.push(i(m));return f}case _u:{const f=a({},o);for(const[m,h]of d)f[i(m)]=i(h);return f}case Fm:return a(new Date(d),o);case Mm:{const{source:f,flags:m}=d;return a(new RegExp(f,m),o)}case Rm:{const f=a(new Map,o);for(const[m,h]of d)f.set(i(m),i(h));return f}case zm:{const f=a(new Set,o);for(const m of d)f.add(i(m));return f}case ab:{const{name:f,message:m}=d;return a(new ag[f](m),o)}case lb: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 ag[u](d),o)};return i},lg=e=>q3(new Map,e)(0),xs="",{toString:Y3}={},{keys:X3}=Object,Co=e=>{const n=typeof e;if(n!=="object"||!e)return[Gu,n];const a=Y3.call(e).slice(8,-1);switch(a){case"Array":return[Oo,xs];case"Object":return[_u,xs];case"Date":return[Fm,xs];case"RegExp":return[Mm,xs];case"Map":return[Rm,xs];case"Set":return[zm,xs];case"DataView":return[Oo,a]}return a.includes("Array")?[Oo,a]:a.includes("Error")?[ab,a]:[_u,a]},hu=([e,n])=>e===Gu&&(n==="function"||n==="symbol"),W3=(e,n,a,i)=>{const o=(d,f)=>{const m=i.push(d)-1;return a.set(f,m),m},u=d=>{if(a.has(d))return a.get(d);let[f,m]=Co(d);switch(f){case Gu:{let x=d;switch(m){case"bigint":f=lb,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([rb],d)}return o([f,x],d)}case Oo:{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(u(w));return g}case _u:{if(m)switch(m){case"BigInt":return o([m,d.toString()],d);case"Boolean":case"Number":case"String":return o([m,d.valueOf()],d)}if(n&&"toJSON"in d)return u(d.toJSON());const x=[],g=o([f,x],d);for(const w of X3(d))(e||!hu(Co(d[w])))&&x.push([u(w),u(d[w])]);return g}case Fm:return o([f,d.toISOString()],d);case Mm:{const{source:x,flags:g}=d;return o([f,{source:x,flags:g}],d)}case Rm:{const x=[],g=o([f,x],d);for(const[w,b]of d)(e||!(hu(Co(w))||hu(Co(b))))&&x.push([u(w),u(b)]);return g}case zm:{const x=[],g=o([f,x],d);for(const w of d)(e||!hu(Co(w)))&&x.push(u(w));return g}}const{message:h}=d;return o([f,{name:m,message:h}],d)};return u},ig=(e,{json:n,lossy:a}={})=>{const i=[];return W3(!(n||a),!!n,new Map,i)(e),i},Bu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?lg(ig(e,n)):structuredClone(e):(e,n)=>lg(ig(e,n));function G3(e,n){const a=[{type:"text",value:"↩"}];return n>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(n)}]}),a}function V3(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function K3(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||G3,i=e.options.footnoteBackLabel||V3,o=e.options.footnoteLabel||"Footnotes",u=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},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 N=typeof a=="string"?a:a(m,b);typeof N=="string"&&(N={type:"text",value:N}),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(N)?N:[N]})}const E=x[x.length-1];if(E&&E.type==="element"&&E.tagName==="p"){const N=E.children[E.children.length-1];N&&N.type==="text"?N.value+=" ":E.children.push({type:"text",value:" "}),E.children.push(...j)}else x.push(...j);const C={type:"element",tagName:"li",properties:{id:n+"fn-"+w},children:e.wrap(x,!0)};e.patch(h,C),f.push(C)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:u,properties:{...Bu(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 Vu=(function(e){if(e==null)return J3;if(typeof e=="function")return Ku(e);if(typeof e=="object")return Array.isArray(e)?P3(e):Q3(e);if(typeof e=="string")return Z3(e);throw new Error("Expected function, string, or object as test")});function P3(e){const n=[];let a=-1;for(;++a<e.length;)n[a]=Vu(e[a]);return Ku(i);function i(...o){let u=-1;for(;++u<n.length;)if(n[u].apply(this,o))return!0;return!1}}function Q3(e){const n=e;return Ku(a);function a(i){const o=i;let u;for(u in e)if(o[u]!==n[u])return!1;return!0}}function Z3(e){return Ku(n);function n(a){return a&&a.type===e}}function Ku(e){return n;function n(a,i,o){return!!(e4(a)&&e.call(this,a,typeof i=="number"?i:void 0,o||void 0))}}function J3(){return!0}function e4(e){return e!==null&&typeof e=="object"&&"type"in e}const ib=[],t4=!0,Qh=!1,n4="skip";function sb(e,n,a,i){let o;typeof n=="function"&&typeof a!="function"?(i=a,a=n):o=n;const u=Vu(o),d=i?-1:1;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=ib,j,k,E;if((!n||u(m,h,x[x.length-1]||void 0))&&(b=r4(a(m,x)),b[0]===Qh))return b;if("children"in m&&m.children){const C=m;if(C.children&&b[0]!==n4)for(k=(i?C.children.length:-1)+d,E=x.concat(C);k>-1&&k<C.children.length;){const N=C.children[k];if(j=f(N,k,E)(),j[0]===Qh)return j;k=typeof j[1]=="number"?j[1]:k+d}}return b}}}function r4(e){return Array.isArray(e)?e:typeof e=="number"?[t4,e]:e==null?ib:[e]}function _m(e,n,a,i){let o,u,d;typeof n=="function"&&typeof a!="function"?(u=void 0,d=n,o=a):(u=n,d=a,o=i),sb(e,u,f,o);function f(m,h){const x=h[h.length-1],g=x?x.children.indexOf(m):void 0;return d(m,g,x)}}const Zh={}.hasOwnProperty,a4={};function l4(e,n){const a=n||a4,i=new Map,o=new Map,u=new Map,d={...U3,...a.handlers},f={all:h,applyData:s4,definitionById:i,footnoteById:o,footnoteCounts:u,footnoteOrder:[],handlers:d,one:m,options:a,patch:i4,wrap:c4};return _m(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(Zh.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,C=Bu(E);return C.children=f.all(x),C}return Bu(x)}return(f.options.unknownHandler||o4)(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=sg(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=sg(k.value))}Array.isArray(j)?g.push(...j):g.push(j)}}}return g}}function i4(e,n){e.position&&(n.position=Vw(e))}function s4(e,n){let a=n;if(e&&e.data){const i=e.data.hName,o=e.data.hChildren,u=e.data.hProperties;if(typeof i=="string")if(a.type==="element")a.tagName=i;else{const d="children"in a?a.children:[a];a={type:"element",tagName:i,properties:{},children:d}}a.type==="element"&&u&&Object.assign(a.properties,Bu(u)),"children"in a&&a.children&&o!==null&&o!==void 0&&(a.children=o)}return a}function o4(e,n){const a=n.data||{},i="value"in n&&!(Zh.call(a,"hProperties")||Zh.call(a,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function c4(e,n){const a=[];let i=-1;for(n&&a.push({type:"text",value:`
|
|
61
|
-
`});++i<e.length;)i&&a.push({type:"text",value:`
|
|
62
|
-
`}),a.push(e[i]);return n&&e.length>0&&a.push({type:"text",value:`
|
|
63
|
-
`}),a}function sg(e){let n=0,a=e.charCodeAt(n);for(;a===9||a===32;)n++,a=e.charCodeAt(n);return e.slice(n)}function og(e,n){const a=l4(e,n),i=a.one(e,void 0),o=K3(a),u=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return o&&u.children.push({type:"text",value:`
|
|
64
|
-
`},o),u}function u4(e,n){return e&&"run"in e?async function(a,i){const o=og(a,{file:i,...n});await e.run(o,i)}:function(a,i){return og(a,{file:i,...e||n})}}function cg(e){if(e)throw e}var ch,ug;function d4(){if(ug)return ch;ug=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(h){return typeof Array.isArray=="function"?Array.isArray(h):n.call(h)==="[object Array]"},u=function(h){if(!h||n.call(h)!=="[object Object]")return!1;var x=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!x&&!g)return!1;var 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 ch=function m(){var h,x,g,w,b,j,k=arguments[0],E=1,C=arguments.length,N=!1;for(typeof k=="boolean"&&(N=k,k=arguments[1]||{},E=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});E<C;++E)if(h=arguments[E],h!=null)for(x in h)g=f(k,x),w=f(h,x),k!==w&&(N&&w&&(u(w)||(b=o(w)))?(b?(b=!1,j=g&&o(g)?g:[]):j=g&&u(g)?g:{},d(k,{name:x,newValue:m(N,j,w)})):typeof w<"u"&&d(k,{name:x,newValue:w}));return k},ch}var f4=d4();const uh=Cy(f4);function Jh(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function h4(){const e=[],n={run:a,use:i};return n;function a(...o){let u=-1;const d=o.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);f(null,...o);function f(m,...h){const x=e[++u];let g=-1;if(m){d(m);return}for(;++g<o.length;)(h[g]===null||h[g]===void 0)&&(h[g]=o[g]);o=h,x?m4(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 m4(e,n){let a;return i;function i(...d){const f=e.length>d.length;let m;f&&d.push(o);try{m=e.apply(this,d)}catch(h){const x=h;if(f&&a)throw x;return o(x)}f||(m&&m.then&&typeof m.then=="function"?m.then(u,o):m instanceof Error?o(m):u(m))}function o(d,...f){a||(a=!0,n(d,...f))}function u(d){o(null,d)}}const ka={basename:p4,dirname:x4,extname:g4,join:y4,sep:"/"};function p4(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Wo(e);let a=0,i=-1,o=e.length,u;if(n===void 0||n.length===0||n.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else i<0&&(u=!0,i=o+1);return i<0?"":e.slice(a,i)}if(n===e)return"";let d=-1,f=n.length-1;for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else d<0&&(u=!0,d=o+1),f>-1&&(e.codePointAt(o)===n.codePointAt(f--)?f<0&&(i=o):(f=-1,i=d));return a===i?i=d:i<0&&(i=e.length),e.slice(a,i)}function x4(e){if(Wo(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 g4(e){Wo(e);let n=e.length,a=-1,i=0,o=-1,u=0,d;for(;n--;){const f=e.codePointAt(n);if(f===47){if(d){i=n+1;break}continue}a<0&&(d=!0,a=n+1),f===46?o<0?o=n:u!==1&&(u=1):o>-1&&(u=-1)}return o<0||a<0||u===0||u===1&&o===a-1&&o===i+1?"":e.slice(o,a)}function y4(...e){let n=-1,a;for(;++n<e.length;)Wo(e[n]),e[n]&&(a=a===void 0?e[n]:a+"/"+e[n]);return a===void 0?".":b4(a)}function b4(e){Wo(e);const n=e.codePointAt(0)===47;let a=v4(e,!n);return a.length===0&&!n&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),n?"/"+a:a}function v4(e,n){let a="",i=0,o=-1,u=0,d=-1,f,m;for(;++d<=e.length;){if(d<e.length)f=e.codePointAt(d);else{if(f===47)break;f=47}if(f===47){if(!(o===d-1||u===1))if(o!==d-1&&u===2){if(a.length<2||i!==2||a.codePointAt(a.length-1)!==46||a.codePointAt(a.length-2)!==46){if(a.length>2){if(m=a.lastIndexOf("/"),m!==a.length-1){m<0?(a="",i=0):(a=a.slice(0,m),i=a.length-1-a.lastIndexOf("/")),o=d,u=0;continue}}else if(a.length>0){a="",i=0,o=d,u=0;continue}}n&&(a=a.length>0?a+"/..":"..",i=2)}else a.length>0?a+="/"+e.slice(o+1,d):a=e.slice(o+1,d),i=d-o-1;o=d,u=0}else f===46&&u>-1?u++:u=-1}return a}function Wo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const w4={cwd:k4};function k4(){return"/"}function em(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function j4(e){if(typeof e=="string")e=new URL(e);else if(!em(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return S4(e)}function S4(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=e.pathname;let a=-1;for(;++a<n.length;)if(n.codePointAt(a)===37&&n.codePointAt(a+1)===50){const i=n.codePointAt(a+2);if(i===70||i===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(n)}const dh=["history","path","basename","stem","extname","dirname"];class ob{constructor(n){let a;n?em(n)?a={path:n}:typeof n=="string"||C4(n)?a={value:n}:a=n:a={},this.cwd="cwd"in a?"":w4.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<dh.length;){const u=dh[i];u in a&&a[u]!==void 0&&a[u]!==null&&(this[u]=u==="history"?[...a[u]]:a[u])}let o;for(o in a)dh.includes(o)||(this[o]=a[o])}get basename(){return typeof this.path=="string"?ka.basename(this.path):void 0}set basename(n){hh(n,"basename"),fh(n,"basename"),this.path=ka.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?ka.dirname(this.path):void 0}set dirname(n){dg(this.basename,"dirname"),this.path=ka.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?ka.extname(this.path):void 0}set extname(n){if(fh(n,"extname"),dg(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=ka.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){em(n)&&(n=j4(n)),hh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?ka.basename(this.path,this.extname):void 0}set stem(n){hh(n,"stem"),fh(n,"stem"),this.path=ka.join(this.dirname||"",n+(this.extname||""))}fail(n,a,i){const o=this.message(n,a,i);throw o.fatal=!0,o}info(n,a,i){const o=this.message(n,a,i);return o.fatal=void 0,o}message(n,a,i){const o=new lr(n,a,i);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function fh(e,n){if(e&&e.includes(ka.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+ka.sep+"`")}function hh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function dg(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function C4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const E4=(function(e){const i=this.constructor.prototype,o=i[e],u=function(){return o.apply(u,arguments)};return Object.setPrototypeOf(u,i),u}),N4={}.hasOwnProperty;class Bm extends E4{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=h4()}copy(){const n=new Bm;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];n.use(...i)}return n.data(uh(!0,{},this.namespace)),n}data(n,a){return typeof n=="string"?arguments.length===2?(xh("data",this.frozen),this.namespace[n]=a,this):N4.call(this.namespace,n)&&this.namespace[n]||void 0:n?(xh("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=mu(n),i=this.parser||this.Parser;return mh("parse",i),i(String(a),a)}process(n,a){const i=this;return this.freeze(),mh("process",this.parser||this.Parser),ph("process",this.compiler||this.Compiler),a?o(void 0,a):new Promise(o);function o(u,d){const f=mu(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);T4(j)?w.value=j:w.result=j,h(x,w)});function h(x,g){x||!g?d(x):u?u(g):a(void 0,g)}}}processSync(n){let a=!1,i;return this.freeze(),mh("processSync",this.parser||this.Parser),ph("processSync",this.compiler||this.Compiler),this.process(n,o),hg("processSync","process",a),i;function o(u,d){a=!0,cg(u),i=d}}run(n,a,i){fg(n),this.freeze();const o=this.transformers;return!i&&typeof a=="function"&&(i=a,a=void 0),i?u(void 0,i):new Promise(u);function u(d,f){const m=mu(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,u),hg("runSync","run",i),o;function u(d,f){cg(d),o=f,i=!0}}stringify(n,a){this.freeze();const i=mu(a),o=this.compiler||this.Compiler;return ph("stringify",o),fg(n),o(n,i)}use(n,...a){const i=this.attachers,o=this.namespace;if(xh("use",this.frozen),n!=null)if(typeof n=="function")m(n,a);else if(typeof n=="object")Array.isArray(n)?f(n):d(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function u(h){if(typeof h=="function")m(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[x,...g]=h;m(x,g)}else d(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function d(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");f(h.plugins),h.settings&&(o.settings=uh(!0,o.settings,h.settings))}function f(h){let x=-1;if(h!=null)if(Array.isArray(h))for(;++x<h.length;){const g=h[x];u(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function m(h,x){let g=-1,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];Jh(k)&&Jh(b)&&(b=uh(!0,k,b)),i[w]=[h,b,...j]}}}}const A4=new Bm().freeze();function mh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ph(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xh(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 fg(e){if(!Jh(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function hg(e,n,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function mu(e){return D4(e)?e:new ob(e)}function D4(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function T4(e){return typeof e=="string"||F4(e)}function F4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const M4="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",mg=[],pg={allowDangerousHtml:!0},R4=/^(https?|ircs?|mailto|xmpp)$/i,z4=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Om(e){const n=_4(e),a=B4(e);return O4(n.runSync(n.parse(a),a),e)}function _4(e){const n=e.rehypePlugins||mg,a=e.remarkPlugins||mg,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...pg}:pg;return A4().use(x3).use(a).use(u4,i).use(n)}function B4(e){const n=e.children||"",a=new ob;return typeof n=="string"&&(a.value=n),a}function O4(e,n){const a=n.allowedElements,i=n.allowElement,o=n.components,u=n.disallowedElements,d=n.skipHtml,f=n.unwrapDisallowed,m=n.urlTransform||$4;for(const x of z4)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+M4+x.id,void 0);return _m(e,h),Jw(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 ih)if(Object.hasOwn(ih,b)&&Object.hasOwn(x.properties,b)){const j=x.properties[b],k=ih[b];(k===null||k.includes(x.tagName))&&(x.properties[b]=m(String(j||""),b,x))}}if(x.type==="element"){let b=a?!a.includes(x.tagName):u?u.includes(x.tagName):!1;if(!b&&i&&typeof g=="number"&&(b=!i(x,g,w)),b&&w&&typeof g=="number")return f&&x.children?w.children.splice(g,1,...x.children):w.children.splice(g,1),g}}}function $4(e){const n=e.indexOf(":"),a=e.indexOf("?"),i=e.indexOf("#"),o=e.indexOf("/");return n===-1||o!==-1&&n>o||a!==-1&&n>a||i!==-1&&n>i||R4.test(e.slice(0,n))?e:""}function xg(e,n){const a=String(e);if(typeof n!="string")throw new TypeError("Expected character");let i=0,o=a.indexOf(n);for(;o!==-1;)i++,o=a.indexOf(n,o+n.length);return i}function L4(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function I4(e,n,a){const o=Vu((a||{}).ignore||[]),u=H4(n);let d=-1;for(;++d<u.length;)sb(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=u[d][0],b=u[d][1];let j=0;const E=g.children.indexOf(h);let C=!1,N=[];w.lastIndex=0;let _=w.exec(h.value);for(;_;){const z=_.index,H={index:_.index,input:_.input,stack:[...x,h]};let R=b(..._,H);if(typeof R=="string"&&(R=R.length>0?{type:"text",value:R}:void 0),R===!1?w.lastIndex=z+1:(j!==z&&N.push({type:"text",value:h.value.slice(j,z)}),Array.isArray(R)?N.push(...R):R&&N.push(R),j=z+_[0].length,C=!0),!w.global)break;_=w.exec(h.value)}return C?(j<h.value.length&&N.push({type:"text",value:h.value.slice(j)}),g.children.splice(E,1,...N)):N=[h],E+N.length}}function H4(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const a=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<a.length;){const o=a[i];n.push([U4(o[0]),q4(o[1])])}return n}function U4(e){return typeof e=="string"?new RegExp(L4(e),"g"):e}function q4(e){return typeof e=="function"?e:function(){return e}}const gh="phrasing",yh=["autolink","link","image","label"];function Y4(){return{transforms:[Q4],enter:{literalAutolink:W4,literalAutolinkEmail:bh,literalAutolinkHttp:bh,literalAutolinkWww:bh},exit:{literalAutolink:P4,literalAutolinkEmail:K4,literalAutolinkHttp:G4,literalAutolinkWww:V4}}}function X4(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:gh,notInConstruct:yh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:gh,notInConstruct:yh},{character:":",before:"[ps]",after:"\\/",inConstruct:gh,notInConstruct:yh}]}}function W4(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function bh(e){this.config.enter.autolinkProtocol.call(this,e)}function G4(e){this.config.exit.autolinkProtocol.call(this,e)}function V4(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(e)}function K4(e){this.config.exit.autolinkEmail.call(this,e)}function P4(e){this.exit(e)}function Q4(e){I4(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Z4],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),J4]],{ignore:["link","linkReference"]})}function Z4(e,n,a,i,o){let u="";if(!cb(o)||(/^w/i.test(n)&&(a=n+a,n="",u="http://"),!ej(a)))return!1;const d=tj(a+i);if(!d[0])return!1;const f={type:"link",title:null,url:u+n+d[0],children:[{type:"text",value:n+d[0]}]};return d[1]?[f,{type:"text",value:d[1]}]:f}function J4(e,n,a,i){return!cb(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+a,children:[{type:"text",value:n+"@"+a}]}}function ej(e){const n=e.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function tj(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let a=n[0],i=a.indexOf(")");const o=xg(e,"(");let u=xg(e,")");for(;i!==-1&&o>u;)e+=a.slice(0,i+1),a=a.slice(i+1),i=a.indexOf(")"),u++;return[e,a]}function cb(e,n){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Ni(a)||Xu(a))&&(!n||a!==47)}ub.peek=uj;function nj(){this.buffer()}function rj(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function aj(){this.buffer()}function lj(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ij(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=oa(this.sliceSerialize(e)).toLowerCase(),a.label=n}function sj(e){this.exit(e)}function oj(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=oa(this.sliceSerialize(e)).toLowerCase(),a.label=n}function cj(e){this.exit(e)}function uj(){return"["}function ub(e,n,a,i){const o=a.createTracker(i);let u=o.move("[^");const d=a.enter("footnoteReference"),f=a.enter("reference");return u+=o.move(a.safe(a.associationId(e),{after:"]",before:u})),f(),d(),u+=o.move("]"),u}function dj(){return{enter:{gfmFootnoteCallString:nj,gfmFootnoteCall:rj,gfmFootnoteDefinitionLabelString:aj,gfmFootnoteDefinition:lj},exit:{gfmFootnoteCallString:ij,gfmFootnoteCall:sj,gfmFootnoteDefinitionLabelString:oj,gfmFootnoteDefinition:cj}}}function fj(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:a,footnoteReference:ub},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,o,u,d){const f=u.createTracker(d);let m=f.move("[^");const h=u.enter("footnoteDefinition"),x=u.enter("label");return m+=f.move(u.safe(u.associationId(i),{before:m,after:"]"})),x(),m+=f.move("]:"),i.children&&i.children.length>0&&(f.shift(4),m+=f.move((n?`
|
|
65
|
-
`:" ")+u.indentLines(u.containerFlow(i,f.current()),n?db:hj))),h(),m}}function hj(e,n,a){return n===0?e:db(e,n,a)}function db(e,n,a){return(a?"":" ")+e}const mj=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];fb.peek=bj;function pj(){return{canContainEols:["delete"],enter:{strikethrough:gj},exit:{strikethrough:yj}}}function xj(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:mj}],handlers:{delete:fb}}}function gj(e){this.enter({type:"delete",children:[]},e)}function yj(e){this.exit(e)}function fb(e,n,a,i){const o=a.createTracker(i),u=a.enter("strikethrough");let d=o.move("~~");return d+=a.containerPhrasing(e,{...o.current(),before:d,after:"~"}),d+=o.move("~~"),u(),d}function bj(){return"~"}function vj(e){return e.length}function wj(e,n){const a=n||{},i=(a.align||[]).concat(),o=a.stringLength||vj,u=[],d=[],f=[],m=[];let h=0,x=-1;for(;++x<e.length;){const k=[],E=[];let C=-1;for(e[x].length>h&&(h=e[x].length);++C<e[x].length;){const N=kj(e[x][C]);if(a.alignDelimiters!==!1){const _=o(N);E[C]=_,(m[C]===void 0||_>m[C])&&(m[C]=_)}k.push(N)}d[x]=k,f[x]=E}let g=-1;if(typeof i=="object"&&"length"in i)for(;++g<h;)u[g]=gg(i[g]);else{const k=gg(i);for(;++g<h;)u[g]=k}g=-1;const w=[],b=[];for(;++g<h;){const k=u[g];let E="",C="";k===99?(E=":",C=":"):k===108?E=":":k===114&&(C=":");let N=a.alignDelimiters===!1?1:Math.max(1,m[g]-E.length-C.length);const _=E+"-".repeat(N)+C;a.alignDelimiters!==!1&&(N=E.length+N+C.length,N>m[g]&&(m[g]=N),b[g]=N),w[g]=_}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 C=[];for(;++g<h;){const N=k[g]||"";let _="",z="";if(a.alignDelimiters!==!1){const H=m[g]-(E[g]||0),R=u[g];R===114?_=" ".repeat(H):R===99?H%2?(_=" ".repeat(H/2+.5),z=" ".repeat(H/2-.5)):(_=" ".repeat(H/2),z=_):z=" ".repeat(H)}a.delimiterStart!==!1&&!g&&C.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&N==="")&&(a.delimiterStart!==!1||g)&&C.push(" "),a.alignDelimiters!==!1&&C.push(_),C.push(N),a.alignDelimiters!==!1&&C.push(z),a.padding!==!1&&C.push(" "),(a.delimiterEnd!==!1||g!==h-1)&&C.push("|")}j.push(a.delimiterEnd===!1?C.join("").replace(/ +$/,""):C.join(""))}return j.join(`
|
|
66
|
-
`)}function kj(e){return e==null?"":String(e)}function gg(e){const n=typeof e=="string"?e.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function jj(e,n,a,i){const o=a.enter("blockquote"),u=a.createTracker(i);u.move("> "),u.shift(2);const d=a.indentLines(a.containerFlow(e,u.current()),Sj);return o(),d}function Sj(e,n,a){return">"+(a?"":" ")+e}function Cj(e,n){return yg(e,n.inConstruct,!0)&&!yg(e,n.notInConstruct,!1)}function yg(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 bg(e,n,a,i){let o=-1;for(;++o<a.unsafe.length;)if(a.unsafe[o].character===`
|
|
67
|
-
`&&Cj(a.stack,a.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
68
|
-
`}function Ej(e,n){const a=String(e);let i=a.indexOf(n),o=i,u=0,d=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===o?++u>d&&(d=u):u=1,o=i+n.length,i=a.indexOf(n,o);return d}function Nj(e,n){return!!(n.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Aj(e){const n=e.options.fence||"`";if(n!=="`"&&n!=="~")throw new Error("Cannot serialize code with `"+n+"` for `options.fence`, expected `` ` `` or `~`");return n}function Dj(e,n,a,i){const o=Aj(a),u=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(Nj(e,a)){const g=a.enter("codeIndented"),w=a.indentLines(u,Tj);return g(),w}const f=a.createTracker(i),m=o.repeat(Math.max(Ej(u,o)+1,3)),h=a.enter("codeFenced");let x=f.move(m);if(e.lang){const g=a.enter(`codeFencedLang${d}`);x+=f.move(a.safe(e.lang,{before:x,after:" ",encode:["`"],...f.current()})),g()}if(e.lang&&e.meta){const g=a.enter(`codeFencedMeta${d}`);x+=f.move(" "),x+=f.move(a.safe(e.meta,{before:x,after:`
|
|
69
|
-
`,encode:["`"],...f.current()})),g()}return x+=f.move(`
|
|
70
|
-
`),u&&(x+=f.move(u+`
|
|
71
|
-
`)),x+=f.move(m),h(),x}function Tj(e,n,a){return(a?"":" ")+e}function $m(e){const n=e.options.quote||'"';if(n!=='"'&&n!=="'")throw new Error("Cannot serialize title with `"+n+"` for `options.quote`, expected `\"`, or `'`");return n}function Fj(e,n,a,i){const o=$m(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("definition");let f=a.enter("label");const m=a.createTracker(i);let h=m.move("[");return h+=m.move(a.safe(a.associationId(e),{before:h,after:"]",...m.current()})),h+=m.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(a.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=a.enter("destinationRaw"),h+=m.move(a.safe(e.url,{before:h,after:e.title?" ":`
|
|
72
|
-
`,...m.current()}))),f(),e.title&&(f=a.enter(`title${u}`),h+=m.move(" "+o),h+=m.move(a.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),d(),h}function Mj(e){const n=e.options.emphasis||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize emphasis with `"+n+"` for `options.emphasis`, expected `*`, or `_`");return n}function Io(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ou(e,n,a){const i=ws(e),o=ws(n);return i===void 0?o===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}hb.peek=Rj;function hb(e,n,a,i){const o=Mj(a),u=a.enter("emphasis"),d=a.createTracker(i),f=d.move(o);let m=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const h=m.charCodeAt(0),x=Ou(i.before.charCodeAt(i.before.length-1),h,o);x.inside&&(m=Io(h)+m.slice(1));const g=m.charCodeAt(m.length-1),w=Ou(i.after.charCodeAt(0),g,o);w.inside&&(m=m.slice(0,-1)+Io(g));const b=d.move(o);return u(),a.attentionEncodeSurroundingInfo={after:w.outside,before:x.outside},f+m+b}function Rj(e,n,a){return a.options.emphasis||"*"}function zj(e,n){let a=!1;return _m(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,Qh}),!!((!e.depth||e.depth<3)&&Am(e)&&(n.options.setext||a))}function _j(e,n,a,i){const o=Math.max(Math.min(6,e.depth||1),1),u=a.createTracker(i);if(zj(e,a)){const x=a.enter("headingSetext"),g=a.enter("phrasing"),w=a.containerPhrasing(e,{...u.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");u.move(d+" ");let h=a.containerPhrasing(e,{before:"# ",after:`
|
|
77
|
-
`,...u.current()});return/^[\t ]/.test(h)&&(h=Io(h.charCodeAt(0))+h.slice(1)),h=h?d+" "+h:d,a.options.closeAtx&&(h+=" "+d),m(),f(),h}mb.peek=Bj;function mb(e){return e.value||""}function Bj(){return"<"}pb.peek=Oj;function pb(e,n,a,i){const o=$m(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let f=a.enter("label");const m=a.createTracker(i);let h=m.move("![");return h+=m.move(a.safe(e.alt,{before:h,after:"]",...m.current()})),h+=m.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(a.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=a.enter("destinationRaw"),h+=m.move(a.safe(e.url,{before:h,after:e.title?" ":")",...m.current()}))),f(),e.title&&(f=a.enter(`title${u}`),h+=m.move(" "+o),h+=m.move(a.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),h+=m.move(")"),d(),h}function Oj(){return"!"}xb.peek=$j;function xb(e,n,a,i){const o=e.referenceType,u=a.enter("imageReference");let d=a.enter("label");const f=a.createTracker(i);let m=f.move("![");const h=a.safe(e.alt,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const g=a.safe(a.associationId(e),{before:m,after:"]",...f.current()});return d(),a.stack=x,u(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function $j(){return"!"}gb.peek=Lj;function gb(e,n,a){let i=e.value||"",o="`",u=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(i);)o+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++u<a.unsafe.length;){const d=a.unsafe[u],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 Lj(){return"`"}function yb(e,n){const a=Am(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))}bb.peek=Ij;function bb(e,n,a,i){const o=$m(a),u=o==='"'?"Quote":"Apostrophe",d=a.createTracker(i);let f,m;if(yb(e,a)){const x=a.stack;a.stack=[],f=a.enter("autolink");let g=d.move("<");return g+=d.move(a.containerPhrasing(e,{before:g,after:">",...d.current()})),g+=d.move(">"),f(),a.stack=x,g}f=a.enter("link"),m=a.enter("label");let h=d.move("[");return h+=d.move(a.containerPhrasing(e,{before:h,after:"](",...d.current()})),h+=d.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(a.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(m=a.enter("destinationRaw"),h+=d.move(a.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),m(),e.title&&(m=a.enter(`title${u}`),h+=d.move(" "+o),h+=d.move(a.safe(e.title,{before:h,after:o,...d.current()})),h+=d.move(o),m()),h+=d.move(")"),f(),h}function Ij(e,n,a){return yb(e,a)?"<":"["}vb.peek=Hj;function vb(e,n,a,i){const o=e.referenceType,u=a.enter("linkReference");let d=a.enter("label");const f=a.createTracker(i);let m=f.move("[");const h=a.containerPhrasing(e,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const g=a.safe(a.associationId(e),{before:m,after:"]",...f.current()});return d(),a.stack=x,u(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function Hj(){return"["}function Lm(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function Uj(e){const n=Lm(e),a=e.options.bulletOther;if(!a)return n==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+a+"`) to be different");return a}function qj(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function wb(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function Yj(e,n,a,i){const o=a.enter("list"),u=a.bulletCurrent;let d=e.ordered?qj(a):Lm(a);const f=e.ordered?d==="."?")":".":Uj(a);let m=n&&a.bulletLastUsed?d===a.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((d==="*"||d==="-")&&x&&(!x.children||!x.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(m=!0),wb(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=u,o(),h}function Xj(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function Wj(e,n,a,i){const o=Xj(a);let u=a.bulletCurrent||Lm(a);n&&n.type==="list"&&n.ordered&&(u=(typeof n.start=="number"&&n.start>-1?n.start:1)+(a.options.incrementListMarker===!1?0:n.children.indexOf(e))+u);let d=u.length+1;(o==="tab"||o==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(d=Math.ceil(d/4)*4);const f=a.createTracker(i);f.move(u+" ".repeat(d-u.length)),f.shift(d);const m=a.enter("listItem"),h=a.indentLines(a.containerFlow(e,f.current()),x);return m(),h;function x(g,w,b){return w?(b?"":" ".repeat(d))+g:(b?u:u+" ".repeat(d-u.length))+g}}function Gj(e,n,a,i){const o=a.enter("paragraph"),u=a.enter("phrasing"),d=a.containerPhrasing(e,i);return u(),o(),d}const Vj=Vu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Kj(e,n,a,i){return(e.children.some(function(d){return Vj(d)})?a.containerPhrasing:a.containerFlow).call(a,e,i)}function Pj(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}kb.peek=Qj;function kb(e,n,a,i){const o=Pj(a),u=a.enter("strong"),d=a.createTracker(i),f=d.move(o+o);let m=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const h=m.charCodeAt(0),x=Ou(i.before.charCodeAt(i.before.length-1),h,o);x.inside&&(m=Io(h)+m.slice(1));const g=m.charCodeAt(m.length-1),w=Ou(i.after.charCodeAt(0),g,o);w.inside&&(m=m.slice(0,-1)+Io(g));const b=d.move(o+o);return u(),a.attentionEncodeSurroundingInfo={after:w.outside,before:x.outside},f+m+b}function Qj(e,n,a){return a.options.strong||"*"}function Zj(e,n,a,i){return a.safe(e.value,i)}function Jj(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function eS(e,n,a){const i=(wb(a)+(a.options.ruleSpaces?" ":"")).repeat(Jj(a));return a.options.ruleSpaces?i.slice(0,-1):i}const jb={blockquote:jj,break:bg,code:Dj,definition:Fj,emphasis:hb,hardBreak:bg,heading:_j,html:mb,image:pb,imageReference:xb,inlineCode:gb,link:bb,linkReference:vb,list:Yj,listItem:Wj,paragraph:Gj,root:Kj,strong:kb,text:Zj,thematicBreak:eS};function tS(){return{enter:{table:nS,tableData:vg,tableHeader:vg,tableRow:aS},exit:{codeText:lS,table:rS,tableData:vh,tableHeader:vh,tableRow:vh}}}function nS(e){const n=e._align;this.enter({type:"table",align:n.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function rS(e){this.exit(e),this.data.inTable=void 0}function aS(e){this.enter({type:"tableRow",children:[]},e)}function vh(e){this.exit(e)}function vg(e){this.enter({type:"tableCell",children:[]},e)}function lS(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,iS));const a=this.stack[this.stack.length-1];a.type,a.value=n,this.exit(e)}function iS(e,n){return n==="|"?n:e}function sS(e){const n=e||{},a=n.tableCellPadding,i=n.tablePipeAlign,o=n.stringLength,u=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
78
|
-
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode: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 C=g(b,k,E),N=h([C]);return N.slice(0,N.indexOf(`
|
|
79
|
-
`))}function m(b,j,k,E){const C=k.enter("tableCell"),N=k.enter("phrasing"),_=k.containerPhrasing(b,{...E,before:u,after:u});return N(),C(),_}function h(b,j){return wj(b,{align:j,alignDelimiters:i,padding:a,stringLength:o})}function x(b,j,k){const E=b.children;let C=-1;const N=[],_=j.enter("table");for(;++C<E.length;)N[C]=g(E[C],j,k);return _(),N}function g(b,j,k){const E=b.children;let C=-1;const N=[],_=j.enter("tableRow");for(;++C<E.length;)N[C]=m(E[C],b,j,k);return _(),N}function w(b,j,k){let E=jb.inlineCode(b,j,k);return k.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function oS(){return{exit:{taskListCheckValueChecked:wg,taskListCheckValueUnchecked:wg,paragraph:uS}}}function cS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dS}}}function wg(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function uS(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const o=n.children;let u=-1,d;for(;++u<o.length;){const f=o[u];if(f.type==="paragraph"){d=f;break}}d===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function dS(e,n,a,i){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",f=a.createTracker(i);u&&f.move(d);let m=jb.listItem(e,n,a,{...i,...f.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),m;function h(x){return x+d}}function fS(){return[Y4(),dj(),pj(),tS(),oS()]}function hS(e){return{extensions:[X4(),fj(e),xj(),sS(e),cS()]}}const mS={tokenize:vS,partial:!0},Sb={tokenize:wS,partial:!0},Cb={tokenize:kS,partial:!0},Eb={tokenize:jS,partial:!0},pS={tokenize:SS,partial:!0},Nb={name:"wwwAutolink",tokenize:yS,previous:Db},Ab={name:"protocolAutolink",tokenize:bS,previous:Tb},il={name:"emailAutolink",tokenize:gS,previous:Fb},Aa={};function xS(){return{text:Aa}}let gi=48;for(;gi<123;)Aa[gi]=il,gi++,gi===58?gi=65:gi===91&&(gi=97);Aa[43]=il;Aa[45]=il;Aa[46]=il;Aa[95]=il;Aa[72]=[il,Ab];Aa[104]=[il,Ab];Aa[87]=[il,Nb];Aa[119]=[il,Nb];function gS(e,n,a){const i=this;let o,u;return d;function d(g){return!tm(g)||!Fb.call(i,i.previous)||Im(i.events)?a(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return tm(g)?(e.consume(g),f):g===64?(e.consume(g),m):a(g)}function m(g){return g===46?e.check(pS,x,h)(g):g===45||g===95||ar(g)?(u=!0,e.consume(g),m):x(g)}function h(g){return e.consume(g),o=!0,m}function x(g){return u&&o&&sr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(g)):a(g)}}function yS(e,n,a){const i=this;return o;function o(d){return d!==87&&d!==119||!Db.call(i,i.previous)||Im(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mS,e.attempt(Sb,e.attempt(Cb,u),a),a)(d))}function u(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(d)}}function bS(e,n,a){const i=this;let o="",u=!1;return d;function d(g){return(g===72||g===104)&&Tb.call(i,i.previous)&&!Im(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):a(g)}function f(g){if(sr(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),u?h:(u=!0,m)):a(g)}function h(g){return g===null||zu(g)||dn(g)||Ni(g)||Xu(g)?a(g):e.attempt(Sb,e.attempt(Cb,x),a)(g)}function x(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(g)}}function vS(e,n,a){let i=0;return o;function o(d){return(d===87||d===119)&&i<3?(i++,e.consume(d),o):d===46&&i===3?(e.consume(d),u):a(d)}function u(d){return d===null?a(d):n(d)}}function wS(e,n,a){let i,o,u;return d;function d(h){return h===46||h===95?e.check(Eb,m,f)(h):h===null||dn(h)||Ni(h)||h!==45&&Xu(h)?m(h):(u=!0,e.consume(h),d)}function f(h){return h===95?i=!0:(o=i,i=void 0),e.consume(h),d}function m(h){return o||i||!u?a(h):n(h)}}function kS(e,n){let a=0,i=0;return o;function o(d){return d===40?(a++,e.consume(d),o):d===41&&i<a?u(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?e.check(Eb,n,u)(d):d===null||dn(d)||Ni(d)?n(d):(e.consume(d),o)}function u(d){return d===41&&i++,e.consume(d),o}}function jS(e,n,a){return i;function i(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),i):f===38?(e.consume(f),u):f===93?(e.consume(f),o):f===60||f===null||dn(f)||Ni(f)?n(f):a(f)}function o(f){return f===null||f===40||f===91||dn(f)||Ni(f)?n(f):i(f)}function u(f){return sr(f)?d(f):a(f)}function d(f){return f===59?(e.consume(f),i):sr(f)?(e.consume(f),d):a(f)}}function SS(e,n,a){return i;function i(u){return e.consume(u),o}function o(u){return ar(u)?a(u):n(u)}}function Db(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||dn(e)}function Tb(e){return!sr(e)}function Fb(e){return!(e===47||tm(e))}function tm(e){return e===43||e===45||e===46||e===95||ar(e)}function Im(e){let n=e.length,a=!1;for(;n--;){const i=e[n][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){a=!0;break}if(i._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const CS={tokenize:RS,partial:!0};function ES(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:TS,continuation:{tokenize:FS},exit:MS}},text:{91:{name:"gfmFootnoteCall",tokenize:DS},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:NS,resolveTo:AS}}}}function NS(e,n,a){const i=this;let o=i.events.length;const u=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d;for(;o--;){const m=i.events[o][1];if(m.type==="labelImage"){d=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return f;function f(m){if(!d||!d._balanced)return a(m);const h=oa(i.sliceSerialize({start:d.end,end:i.now()}));return h.codePointAt(0)!==94||!u.includes(h.slice(1))?a(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function AS(e,n){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[a+1],e[a+2],["enter",i,n],e[a+3],e[a+4],["enter",o,n],["exit",o,n],["enter",u,n],["enter",d,n],["exit",d,n],["exit",u,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(a,e.length-a+1,...f),e}function DS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?a(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(u>999||g===93&&!d||g===null||g===91||dn(g))return a(g);if(g===93){e.exit("chunkString");const w=e.exit("gfmFootnoteCallString");return o.includes(oa(i.sliceSerialize(w)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):a(g)}return dn(g)||(d=!0),u++,e.consume(g),g===92?x:h}function x(g){return g===91||g===92||g===93?(e.consume(g),u++,h):h(g)}}function TS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,f;return m;function m(j){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(j){return j===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):a(j)}function x(j){if(d>999||j===93&&!f||j===null||j===91||dn(j))return a(j);if(j===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return u=oa(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),w}return dn(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(u)||o.push(u),Ht(e,b,"gfmFootnoteDefinitionWhitespace")):a(j)}function b(j){return n(j)}}function FS(e,n,a){return e.check(Xo,n,e.attempt(CS,n,a))}function MS(e){e.exit("gfmFootnoteDefinition")}function RS(e,n,a){const i=this;return Ht(e,o,"gfmFootnoteDefinitionIndent",5);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?n(u):a(u)}}function zS(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:u,resolveAll:o};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(d,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&&Br(w,w.length,0,Wu(b,d.slice(h+1,m),f)),Br(w,w.length,0,[["exit",g,f],["enter",d[m][1],f],["exit",d[m][1],f],["exit",x,f]]),Br(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 u(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=ws(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"),C=ws(j);return E._open=!C||C===2&&!!k,E._close=!k||k===2&&!!C,f(j)}}}class _S{constructor(){this.map=[]}add(n,a,i){BS(this,n,a,i)}consume(n){if(this.map.sort(function(u,d){return u[0]-d[0]}),this.map.length===0)return;let a=this.map.length;const i=[];for(;a>0;)a-=1,i.push(n.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),n.length=this.map[a][0];i.push(n.slice()),n.length=0;let o=i.pop();for(;o;){for(const u of o)n.push(u);o=i.pop()}this.map.length=0}}function BS(e,n,a,i){let o=0;if(!(a===0&&i.length===0)){for(;o<e.map.length;){if(e.map[o][0]===n){e.map[o][1]+=a,e.map[o][2].push(...i);return}o+=1}e.map.push([n,a,i])}}function OS(e,n){let a=!1;const i=[];for(;n<e.length;){const o=e[n];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&i.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const u=i.length-1;i[u]=i[u]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);n+=1}return i}function $S(){return{flow:{null:{name:"table",tokenize:LS,resolveAll:IS}}}}function LS(e,n,a){const i=this;let o=0,u=0,d;return f;function f(A){let $=i.events.length-1;for(;$>-1;){const se=i.events[$][1].type;if(se==="lineEnding"||se==="linePrefix")$--;else break}const L=$>-1?i.events[$][1].type:null,Y=L==="tableHead"||L==="tableRow"?R:m;return Y===R&&i.parser.lazy[i.now().line]?a(A):Y(A)}function m(A){return e.enter("tableHead"),e.enter("tableRow"),h(A)}function h(A){return A===124||(d=!0,u+=1),x(A)}function x(A){return A===null?a(A):at(A)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),b):a(A):Tt(A)?Ht(e,x,"whitespace")(A):(u+=1,d&&(d=!1,o+=1),A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),g(A)))}function g(A){return A===null||A===124||dn(A)?(e.exit("data"),x(A)):(e.consume(A),A===92?w:g)}function w(A){return A===92||A===124?(e.consume(A),g):g(A)}function b(A){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(A):(e.enter("tableDelimiterRow"),d=!1,Tt(A)?Ht(e,j,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):j(A))}function j(A){return A===45||A===58?E(A):A===124?(d=!0,e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),k):H(A)}function k(A){return Tt(A)?Ht(e,E,"whitespace")(A):E(A)}function E(A){return A===58?(u+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),C):A===45?(u+=1,C(A)):A===null||at(A)?z(A):H(A)}function C(A){return A===45?(e.enter("tableDelimiterFiller"),N(A)):H(A)}function N(A){return A===45?(e.consume(A),N):A===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),_):(e.exit("tableDelimiterFiller"),_(A))}function _(A){return Tt(A)?Ht(e,z,"whitespace")(A):z(A)}function z(A){return A===124?j(A):A===null||at(A)?!d||o!==u?H(A):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(A)):H(A)}function H(A){return a(A)}function R(A){return e.enter("tableRow"),I(A)}function I(A){return A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),I):A===null||at(A)?(e.exit("tableRow"),n(A)):Tt(A)?Ht(e,I,"whitespace")(A):(e.enter("data"),q(A))}function q(A){return A===null||A===124||dn(A)?(e.exit("data"),I(A)):(e.consume(A),A===92?X:q)}function X(A){return A===92||A===124?(e.consume(A),q):q(A)}}function IS(e,n){let a=-1,i=!0,o=0,u=[0,0,0,0],d=[0,0,0,0],f=!1,m=0,h,x,g;const w=new _S;for(;++a<e.length;){const b=e[a],j=b[1];b[0]==="enter"?j.type==="tableHead"?(f=!1,m!==0&&(kg(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,u=[0,0,0,0],d=[0,a+1,0,0],f&&(f=!1,x={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},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&&(u[1]!==0&&(d[0]=d[1],g=pu(w,n,u,o,void 0,g),u=[0,0,0,0]),d[2]=a)):j.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],g=pu(w,n,u,o,void 0,g)),u=d,d=[u[1],a,0,0])):j.type==="tableHead"?(f=!0,m=a):j.type==="tableRow"||j.type==="tableDelimiterRow"?(m=a,u[1]!==0?(d[0]=d[1],g=pu(w,n,u,o,a,g)):d[1]!==0&&(g=pu(w,n,d,o,a,g)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(d[3]=a)}for(m!==0&&kg(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=OS(n.events,a))}return e}function pu(e,n,a,i,o,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(u.end=Object.assign({},gs(n.events,a[0])),e.add(a[0],0,[["exit",u,n]]));const m=gs(n.events,a[1]);if(u={type:d,start:Object.assign({},m),end:Object.assign({},m)},e.add(a[1],0,[["enter",u,n]]),a[2]!==0){const h=gs(n.events,a[2]),x=gs(n.events,a[3]),g={type:f,start:Object.assign({},h),end:Object.assign({},x)};if(e.add(a[2],0,[["enter",g,n]]),i!==2){const 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&&(u.end=Object.assign({},gs(n.events,o)),e.add(o,0,[["exit",u,n]]),u=void 0),u}function kg(e,n,a,i,o){const u=[],d=gs(n.events,a);o&&(o.end=Object.assign({},d),u.push(["exit",o,n])),i.end=Object.assign({},d),u.push(["exit",i,n]),e.add(a+1,0,u)}function gs(e,n){const a=e[n],i=a[0]==="enter"?"start":"end";return a[1][i]}const HS={name:"tasklistCheck",tokenize:qS};function US(){return{text:{91:HS}}}function qS(e,n,a){const i=this;return o;function o(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?a(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),u)}function u(m){return dn(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 at(m)?n(m):Tt(m)?e.check({tokenize:YS},n,a)(m):a(m)}}function YS(e,n,a){return Ht(e,i,"whitespace");function i(o){return o===null?a(o):n(o)}}function XS(e){return Uy([xS(),ES(),zS(e),$S(),US()])}const WS={};function Hm(e){const n=this,a=e||WS,i=n.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(XS(a)),u.push(fS()),d.push(hS(a))}function As({content:e,className:n=""}){return l.jsx("div",{className:`office-markdown ${n}`,children:l.jsx(Om,{remarkPlugins:[Hm],components:{code:GS,table:({children:a})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:a})})},children:e})})}function GS({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
80
|
-
`)?l.jsx(VS,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"bg-gray-100 text-gray-700 px-1 py-0.5 rounded text-[0.9em] font-mono",...a,children:n})}function VS({children:e,language:n}){const[a,i]=v.useState(!1),o=String(e).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"office-code-block group relative my-2",children:[n&&l.jsx("div",{className:"text-[10px] text-gray-400 px-3 pt-1.5",children:n}),l.jsx("button",{onClick:u,className:"absolute top-1.5 right-2 text-[10px] text-gray-400 hover:text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:o})})]})}const jg={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},KS=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function PS(e,n){const a=parseInt(e.replace("#",""),16),i=Math.max(0,(a>>16&255)-n),o=Math.max(0,(a>>8&255)-n),u=Math.max(0,(a&255)-n);return`#${(i<<16|o<<8|u).toString(16).padStart(6,"0")}`}function QS(e,n){const a=parseInt(e.replace("#",""),16),i=Math.min(255,(a>>16&255)+n),o=Math.min(255,(a>>8&255)+n),u=Math.min(255,(a&255)+n);return`#${(i<<16|o<<8|u).toString(16).padStart(6,"0")}`}function Mb(e,n){const a=jg[e];if(a&&n)return n[a];const i=KS.exec(e);if(i){const[,o,u,d]=i,f=jg[u],m=f&&n?n[f]:u,h=parseInt(d,10);return o==="darken"?PS(m,h):QS(m,h)}return e}function nm(e,n=12){return e.map(a=>({...a,x:n-a.x-a.w}))}function ZS(e,n){return n==="down"?e.down:n==="up"&&e.up?e.up:n==="left"&&e.left?e.left:n==="right"&&e.right?e.right:n==="right"&&e.left?{name:e.left.name,pixels:nm(e.left.pixels)}:n==="left"&&e.right?{name:e.right.name,pixels:nm(e.right.pixels)}:e.down}function JS(e,n){return rm(e,"hair",n,1)}function rm(e,n,a,i){const o=e.layers.findIndex(d=>d.name===n),u=[...e.layers];if(o>=0)u[o]={...a,name:n};else{const d=i??u.length;u.splice(d,0,{...a,name:n})}return{...e,layers:u}}const Um=new Map,qm=new Map;function Rb(e,n){Um.set(e,n)}function Pu(e,n){qm.set(e,n)}function am(e){return Um.get(e)}function z8(e){return qm.get(e)}function _8(){return Array.from(Um.keys())}function B8(){return Array.from(qm.keys())}function eC(e,n,a,i,o=2){e.clearRect(0,0,n.width*o,n.height*o);for(const u of n.layers)zb(e,u.pixels,o,a,i)}function Il(e,n,a,i,o){for(const u of n){const d=Mb(u.c,o);u.a!==void 0&&u.a!==1&&(e.globalAlpha=u.a),e.fillStyle=d,e.fillRect(a+u.x,i+u.y,u.w,u.h),u.a!==void 0&&u.a!==1&&(e.globalAlpha=1)}}function O8(e,n){const a=n.scale;e.clearRect(0,0,n.canvasWidth,n.canvasHeight),zb(e,n.pixels,a,0)}function zb(e,n,a,i,o){for(const u of n){const d=Mb(u.c,o);u.a!==void 0&&u.a!==1&&(e.globalAlpha=u.a),e.fillStyle=d,e.fillRect(u.x*a,(u.y+i)*a,u.w*a,u.h*a),u.a!==void 0&&u.a!==1&&(e.globalAlpha=1)}}const $u=new Map;function Yl(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;$u.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;$u.set(e,{id:e,name:n,layer:{...o,name:"hair"}})}}function tC(e){return $u.get(e)}function _b(){return Array.from($u.values())}Yl("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}]}});Yl("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}]}});Yl("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}]}});Yl("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}]}});Yl("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"}]}});Yl("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}]}});Yl("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}]}});Yl("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 Lu=new Map;function Da(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Lu.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;Lu.set(e,{id:e,name:n,layer:{...o,name:"torso"}})}}function nC(e){return Lu.get(e)}function Bb(){return Array.from(Lu.values())}Da("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"}]}});Da("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"}]}});Da("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"}]}});Da("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)"}]}});Da("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)"}]}});Da("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"}]}});Da("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"}]}});Da("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"}]}});Da("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"}]}});Da("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 Ho=new Map;function Kt(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Ho.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;Ho.set(e,{id:e,name:n,layer:{...o,name:"accessory"}})}}function rC(e){return Ho.get(e)}function aC(e,n){const a=Ho.get(e);if(!a)return;if(a.directions)return ZS(a.directions,n);if(n==="down")return a.layer;const i=a.layer.pixels.filter(u=>u.y<2);if(i.length===0)return;const o=n==="right"?1:n==="left"?-1:0;return{name:a.layer.name,pixels:o?i.map(u=>({...u,x:u.x+o})):i}}function Ob(){return Array.from(Ho.values())}Kt("none","None",{name:"accessory",pixels:[]});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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"}]}});Kt("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}]}});Kt("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}]}});Kt("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"}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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"}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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}]}});Kt("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"}]}});Kt("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"}]}});Kt("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}]}});Kt("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}]}});Kt("dog-face","Dog Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:3,y:5,w:6,h:4,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:7,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:7,y:2,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:2,c:"#222"},{x:5,y:7,w:2,h:2,c:"#FF6B8A",a:.8},{x:5,y:7,w:1,h:1,c:"#FF8A9E",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:5,y:0,w:2,h:6,c:"#B8883C",a:.3},{x:2,y:8,w:8,h:1,c:"#A67B3D",a:.5}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#D2A25C"},{x:2,y:-1,w:7,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:-1,y:4,w:3,h:4,c:"#D2A25C"},{x:-1,y:5,w:2,h:3,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:0,y:5,w:2,h:1,c:"#222"},{x:0,y:7,w:2,h:1,c:"#FF6B8A",a:.7}]}});const lC={none:1,glasses:1,beret:1,cap:1,badge:1,blush:1,lapels:1,"round-glasses":2,headphones:2,scarf:3,tie:3,bowtie:3,sunglasses:4,bandana:4,eyepatch:4,crown:5,halo:5,horns:5,mask:5,"cat-ears":6,"bear-ears":6,"bunny-ears":6,"dog-nose":6,"fox-mask":6,"cat-face":7,"bear-face":7,"panda-face":7,"frog-face":8,"rabbit-face":8,"dog-face":8,"star-glasses":9};function $b(e){return lC[e]??1}function Lb(e,n){return n>=$b(e)}Kt("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 Eo({r:e,g:n,b:a}){return`#${(e<<16|n<<8|a).toString(16).padStart(6,"0")}`}function Tu(e,n){const a=e.r-n.r,i=e.g-n.g,o=e.b-n.b;return a*a+i*i+o*o}function iC(e,n){const a=[];a.push(e[Math.floor(Math.random()*e.length)]);for(let i=1;i<n;i++){const o=e.map(f=>{let m=1/0;for(const h of a)m=Math.min(m,Tu(f,h));return m}),u=o.reduce((f,m)=>f+m,0);let d=Math.random()*u;for(let f=0;f<e.length;f++)if(d-=o[f],d<=0){a.push(e[f]);break}a.length<=i&&a.push(e[Math.floor(Math.random()*e.length)])}return a}function sC(e,n,a=20){if(e.length===0)return[];const i=iC(e,n);for(let u=0;u<a;u++){const d=Array.from({length:n},()=>[]);for(const m of e){let h=1/0,x=0;for(let g=0;g<n;g++){const w=Tu(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)};Tu(g,i[m])>1&&(f=!1),i[m]=g}if(f)break}const o=new Array(n).fill(0);for(const u of e){let d=1/0,f=0;for(let m=0;m<n;m++){const h=Tu(u,i[m]);h<d&&(d=h,f=m)}o[f]++}return i.map((u,d)=>({c:u,count:o[d]})).sort((u,d)=>d.count-u.count).map(u=>u.c)}function oC(e,n=1e4){const a=document.createElement("canvas"),i=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height;a.width=i,a.height=o;const u=a.getContext("2d");u.drawImage(e,0,0);const d=u.getImageData(0,0,i,o).data,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 Sg(e){return .299*e.r+.587*e.g+.114*e.b}function Cg(e){const n=Math.max(e.r,e.g,e.b),a=Math.min(e.r,e.g,e.b);return n===0?0:(n-a)/n*255}function cC(e,n=8){const a=oC(e),i=sC(a,n);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const o=[...i].sort((g,w)=>Sg(w)-Sg(g)),u=[...i].sort((g,w)=>Cg(w)-Cg(g)),d=o[0],f=o[o.length-1],m=u[0],h=o[o.length-2],x=o[o.length-1];return{skinColor:Eo(d),hairColor:Eo(f),shirtColor:Eo(m),pantsColor:Eo(h),shoeColor:Eo(x)}}const uC=[{x:1,y:19,w:10,h:2,c:"#100A06",a:.15},{x:2,y:15,w:3,h:4,c:"$pants"},{x:7,y:15,w:3,h:4,c:"$pants"},{x:2,y:19,w:3,h:2,c:"$shoes"},{x:7,y:19,w:3,h:2,c:"$shoes"},{x:2,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4},{x:7,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4}],dC=[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:4,y:10,w:4,h:2,c:"darken($shirt, 25)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}],fC=[{x:4,y:8,w:4,h:3,c:"$skin"},{x:1,y:1,w:10,h:8,c:"$skin"},{x:3,y:4,w:2,h:2,c:"#1A1A2E"},{x:7,y:4,w:2,h:2,c:"#1A1A2E"},{x:3,y:4,w:1,h:1,c:"#FFF",a:.35},{x:7,y:4,w:1,h:1,c:"#FFF",a:.35},{x:5,y:7,w:2,h:1,c:"darken($skin, 25)",a:.4},{x:0,y:4,w:1,h:1,c:"$skin"},{x:11,y:4,w:1,h:1,c:"$skin"}],hC=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function mC(){return{width:12,height:22,layers:[{name:"lower",pixels:uC},{name:"torso",pixels:dC},{name:"head",pixels:fC},{name:"hair",pixels:hC},{name:"accessory",pixels:[]}]}}const pC=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const e of pC)Rb(`mini:${e}`,mC());const xC=[{x:1,y:10,w:10,h:8,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:7,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:7,c:"darken($shirt, 25)",a:.25},{x:4,y:10,w:4,h:2,c:"darken($shirt, 25)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"}],gC=[{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"}],yC=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function bC(){return{width:12,height:22,layers:[{name:"torso",pixels:xC},{name:"head",pixels:gC},{name:"hair",pixels:yC},{name:"accessory",pixels:[]}]}}Rb("mini-seated:default",bC());const vC={canvasWidth:160,canvasHeight:80,scale:2,pixels:[{x:0,y:0,w:80,h:40,c:"#1e2030"},{x:10,y:2,w:10,h:6,c:"#78889c"},{x:10,y:2,w:10,h:1,c:"#8899ad"},{x:24,y:0,w:10,h:6,c:"#78889c"},{x:24,y:0,w:10,h:1,c:"#8899ad"},{x:38,y:2,w:10,h:6,c:"#78889c"},{x:38,y:2,w:10,h:1,c:"#8899ad"},{x:54,y:2,w:10,h:6,c:"#78889c"},{x:54,y:2,w:10,h:1,c:"#8899ad"},{x:11,y:7,w:2,h:2,c:"#2a2a2a"},{x:17,y:7,w:2,h:2,c:"#2a2a2a"},{x:25,y:5,w:2,h:2,c:"#2a2a2a"},{x:31,y:5,w:2,h:2,c:"#2a2a2a"},{x:39,y:7,w:2,h:2,c:"#2a2a2a"},{x:45,y:7,w:2,h:2,c:"#2a2a2a"},{x:55,y:7,w:2,h:2,c:"#2a2a2a"},{x:61,y:7,w:2,h:2,c:"#2a2a2a"},{x:8,y:8,w:64,h:24,c:"#6b5b4b"},{x:4,y:10,w:72,h:20,c:"#7d6d5d"},{x:2,y:12,w:76,h:16,c:"#7d6d5d"},{x:2,y:12,w:76,h:2,c:"#8b7b6b"},{x:2,y:26,w:76,h:2,c:"#4b3b2b"},{x:2,y:28,w:76,h:3,c:"#4b3b2b"},{x:4,y:28,w:72,h:1,c:"#5b4b3b"},{x:6,y:30,w:3,h:2,c:"#3a2a1a"},{x:71,y:30,w:3,h:2,c:"#3a2a1a"},{x:18,y:14,w:44,h:12,c:"#6b5b4b",a:.5},{x:28,y:14,w:14,h:8,c:"#1a1a2e"},{x:29,y:15,w:12,h:6,c:"#1565C0",a:.5},{x:30,y:16,w:8,h:1,c:"#60A5FA",a:.45},{x:30,y:18,w:5,h:1,c:"#60A5FA",a:.3},{x:58,y:16,w:5,h:5,c:"#795548"},{x:59,y:17,w:3,h:3,c:"#A67C52"},{x:63,y:18,w:2,h:2,c:"#795548"},{x:10,y:16,w:10,h:8,c:"#FFEE58",a:.7},{x:11,y:17,w:8,h:1,c:"#9E9E9E",a:.5},{x:11,y:19,w:8,h:1,c:"#9E9E9E",a:.5},{x:11,y:21,w:6,h:1,c:"#9E9E9E",a:.5},{x:10,y:32,w:10,h:6,c:"#78889c"},{x:10,y:32,w:10,h:1,c:"#8899ad"},{x:24,y:34,w:10,h:6,c:"#78889c"},{x:24,y:34,w:10,h:1,c:"#8899ad"},{x:38,y:32,w:10,h:6,c:"#78889c"},{x:38,y:32,w:10,h:1,c:"#8899ad"},{x:54,y:32,w:10,h:6,c:"#78889c"},{x:54,y:32,w:10,h:1,c:"#8899ad"},{x:11,y:37,w:2,h:2,c:"#2a2a2a"},{x:17,y:37,w:2,h:2,c:"#2a2a2a"},{x:25,y:39,w:2,h:2,c:"#2a2a2a"},{x:31,y:39,w:2,h:2,c:"#2a2a2a"},{x:39,y:37,w:2,h:2,c:"#2a2a2a"},{x:45,y:37,w:2,h:2,c:"#2a2a2a"},{x:55,y:37,w:2,h:2,c:"#2a2a2a"},{x:61,y:37,w:2,h:2,c:"#2a2a2a"}]},wC={canvasWidth:128,canvasHeight:96,scale:2,pixels:[{x:0,y:0,w:64,h:48,c:"#4b3b2b"},{x:3,y:3,w:58,h:42,c:"#8B7355"},{x:4,y:4,w:10,h:10,c:"#A0845C",a:.5},{x:20,y:8,w:8,h:8,c:"#A0845C",a:.4},{x:40,y:6,w:12,h:6,c:"#A0845C",a:.3},{x:8,y:30,w:14,h:10,c:"#A0845C",a:.25},{x:44,y:32,w:10,h:8,c:"#A0845C",a:.3},{x:6,y:8,w:18,h:12,c:"#FFEE58"},{x:5,y:7,w:3,h:3,c:"#EF5350"},{x:6,y:7,w:2,h:2,c:"#C62828"},{x:8,y:10,w:14,h:1,c:"#9E9E9E"},{x:8,y:12,w:12,h:1,c:"#9E9E9E"},{x:8,y:14,w:10,h:1,c:"#9E9E9E"},{x:28,y:6,w:16,h:14,c:"#B3E5FC"},{x:35,y:5,w:3,h:3,c:"#42A5F5"},{x:36,y:5,w:2,h:2,c:"#1565C0"},{x:30,y:9,w:12,h:1,c:"#9E9E9E"},{x:30,y:11,w:10,h:1,c:"#9E9E9E"},{x:30,y:13,w:11,h:1,c:"#9E9E9E"},{x:8,y:24,w:16,h:14,c:"#C8E6C9"},{x:15,y:23,w:3,h:3,c:"#66BB6A"},{x:16,y:23,w:2,h:2,c:"#388E3C"},{x:10,y:27,w:12,h:1,c:"#9E9E9E"},{x:10,y:29,w:8,h:1,c:"#9E9E9E"},{x:10,y:31,w:10,h:1,c:"#9E9E9E"},{x:28,y:24,w:28,h:16,c:"#FFCDD2"},{x:43,y:23,w:3,h:3,c:"#EF5350"},{x:44,y:23,w:2,h:2,c:"#B71C1C"},{x:32,y:27,w:24,h:1,c:"#9E9E9E"},{x:32,y:29,w:20,h:1,c:"#9E9E9E"},{x:32,y:31,w:22,h:1,c:"#9E9E9E"},{x:32,y:33,w:15,h:1,c:"#9E9E9E"},{x:0,y:0,w:64,h:3,c:"#5a4a3a"},{x:0,y:45,w:64,h:3,c:"#3a2a1a"}]},kC={canvasWidth:128,canvasHeight:96,scale:2,pixels:[{x:2,y:0,w:60,h:48,c:"#3b1f0a"},{x:4,y:2,w:56,h:44,c:"#5a3310"},{x:4,y:13,w:56,h:2,c:"#2d1508"},{x:4,y:27,w:56,h:2,c:"#2d1508"},{x:4,y:41,w:56,h:2,c:"#2d1508"},{x:5,y:3,w:4,h:10,c:"#2563EB"},{x:5,y:3,w:4,h:2,c:"#1D4ED8"},{x:10,y:4,w:3,h:9,c:"#DC2626"},{x:10,y:4,w:3,h:2,c:"#B91C1C"},{x:14,y:3,w:5,h:10,c:"#16A34A"},{x:14,y:3,w:5,h:2,c:"#15803D"},{x:20,y:4,w:3,h:9,c:"#9333EA"},{x:20,y:4,w:3,h:2,c:"#7E22CE"},{x:24,y:3,w:4,h:10,c:"#D97706"},{x:24,y:3,w:4,h:2,c:"#B45309"},{x:29,y:4,w:3,h:9,c:"#0891B2"},{x:29,y:4,w:3,h:2,c:"#0E7490"},{x:33,y:3,w:5,h:10,c:"#BE123C"},{x:33,y:3,w:5,h:2,c:"#9F1239"},{x:39,y:4,w:4,h:9,c:"#4F46E5"},{x:39,y:4,w:4,h:2,c:"#3730A3"},{x:44,y:3,w:3,h:10,c:"#065F46"},{x:44,y:3,w:3,h:2,c:"#064E3B"},{x:48,y:4,w:4,h:9,c:"#92400E"},{x:48,y:4,w:4,h:2,c:"#78350F"},{x:53,y:3,w:5,h:10,c:"#1E3A5F"},{x:53,y:3,w:5,h:2,c:"#1e3060"},{x:6,y:6,w:2,h:1,c:"#BFDBFE",a:.7},{x:11,y:7,w:1,h:1,c:"#FCA5A5",a:.7},{x:16,y:6,w:3,h:1,c:"#BBF7D0",a:.7},{x:21,y:7,w:1,h:1,c:"#D8B4FE",a:.7},{x:25,y:6,w:2,h:1,c:"#FDE68A",a:.7},{x:5,y:16,w:5,h:11,c:"#0F766E"},{x:5,y:16,w:5,h:2,c:"#0D6056"},{x:11,y:17,w:3,h:10,c:"#C2410C"},{x:11,y:17,w:3,h:2,c:"#9A3412"},{x:15,y:16,w:4,h:11,c:"#7C3AED"},{x:15,y:16,w:4,h:2,c:"#6D28D9"},{x:20,y:17,w:3,h:10,c:"#1D4ED8"},{x:20,y:17,w:3,h:2,c:"#1E40AF"},{x:24,y:16,w:5,h:11,c:"#166534"},{x:24,y:16,w:5,h:2,c:"#14532D"},{x:30,y:17,w:4,h:10,c:"#991B1B"},{x:30,y:17,w:4,h:2,c:"#7F1D1D"},{x:35,y:16,w:3,h:11,c:"#854D0E"},{x:35,y:16,w:3,h:2,c:"#713F12"},{x:39,y:17,w:4,h:10,c:"#1E40AF"},{x:39,y:17,w:4,h:2,c:"#1E3A8A"},{x:44,y:16,w:5,h:11,c:"#065F46"},{x:44,y:16,w:5,h:2,c:"#064E3B"},{x:50,y:17,w:3,h:10,c:"#831843"},{x:50,y:17,w:3,h:2,c:"#6B21A8"},{x:54,y:16,w:5,h:11,c:"#374151"},{x:54,y:16,w:5,h:2,c:"#1F2937"},{x:5,y:30,w:4,h:11,c:"#0E7490"},{x:5,y:30,w:4,h:2,c:"#0C6B7E"},{x:10,y:31,w:3,h:10,c:"#B45309"},{x:10,y:31,w:3,h:2,c:"#92400E"},{x:14,y:30,w:5,h:11,c:"#6D28D9"},{x:14,y:30,w:5,h:2,c:"#5B21B6"},{x:20,y:30,w:7,h:8,c:"#1e293b"},{x:22,y:32,w:3,h:3,c:"#3b82f6",a:.9},{x:22,y:32,w:1,h:3,c:"#60a5fa",a:.6},{x:28,y:31,w:4,h:10,c:"#DC2626"},{x:28,y:31,w:4,h:2,c:"#B91C1C"},{x:33,y:30,w:3,h:11,c:"#065F46"},{x:33,y:30,w:3,h:2,c:"#064E3B"},{x:37,y:31,w:4,h:10,c:"#1D4ED8"},{x:37,y:31,w:4,h:2,c:"#1E40AF"},{x:42,y:35,w:6,h:6,c:"#92400E"},{x:43,y:30,w:4,h:6,c:"#16a34a",a:.8},{x:43,y:29,w:2,h:3,c:"#15803d",a:.7},{x:45,y:28,w:2,h:4,c:"#16a34a",a:.6},{x:49,y:30,w:3,h:11,c:"#7C3AED"},{x:49,y:30,w:3,h:2,c:"#6D28D9"},{x:53,y:31,w:5,h:10,c:"#B45309"},{x:53,y:31,w:5,h:2,c:"#92400E"},{x:2,y:46,w:60,h:2,c:"#1a0a03"},{x:2,y:0,w:60,h:2,c:"#4a2510"},{x:2,y:0,w:2,h:48,c:"#2d1508"},{x:60,y:0,w:2,h:48,c:"#2d1508"}]},jC={canvasWidth:96,canvasHeight:120,scale:2,pixels:[{x:2,y:0,w:44,h:60,c:"#546E7A"},{x:2,y:0,w:44,h:3,c:"#78909C"},{x:2,y:57,w:44,h:3,c:"#37474F"},{x:2,y:0,w:2,h:60,c:"#455A64"},{x:44,y:0,w:2,h:60,c:"#37474F"},{x:5,y:4,w:38,h:3,c:"#FFD54F",a:.5},{x:6,y:1,w:2,h:4,c:"#FFFDE7"},{x:10,y:0,w:2,h:5,c:"#FFF9C4"},{x:14,y:1,w:2,h:3,c:"#FFFDE7"},{x:18,y:0,w:2,h:4,c:"#FFF8E1"},{x:5,y:5,w:38,h:16,c:"#607D8B"},{x:5,y:5,w:38,h:2,c:"#78909C"},{x:15,y:12,w:18,h:4,c:"#37474F"},{x:22,y:11,w:4,h:6,c:"#455A64"},{x:23,y:13,w:2,h:2,c:"#B0BEC5"},{x:7,y:14,w:8,h:5,c:"#B0BEC5"},{x:8,y:15,w:6,h:1,c:"#607D8B"},{x:8,y:17,w:5,h:1,c:"#607D8B"},{x:5,y:23,w:38,h:16,c:"#607D8B"},{x:5,y:23,w:38,h:2,c:"#78909C"},{x:15,y:30,w:18,h:4,c:"#37474F"},{x:22,y:29,w:4,h:6,c:"#455A64"},{x:23,y:31,w:2,h:2,c:"#B0BEC5"},{x:7,y:32,w:8,h:5,c:"#B0BEC5"},{x:8,y:33,w:6,h:1,c:"#607D8B"},{x:8,y:35,w:4,h:1,c:"#607D8B"},{x:5,y:41,w:38,h:16,c:"#607D8B"},{x:5,y:41,w:38,h:2,c:"#78909C"},{x:15,y:48,w:18,h:4,c:"#37474F"},{x:22,y:47,w:4,h:6,c:"#455A64"},{x:23,y:49,w:2,h:2,c:"#B0BEC5"},{x:7,y:50,w:8,h:5,c:"#B0BEC5"},{x:8,y:51,w:6,h:1,c:"#607D8B"},{x:8,y:53,w:3,h:1,c:"#607D8B"}]};Pu("meeting",vC);Pu("bulletin",wC);Pu("decision",jC);Pu("knowledge",kC);const wh=16,kh=24,SC=60,CC={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function Ib(e,n){if(!e)return e;let a=e;if(n!=null&&n.hairStyle){const i=tC(n.hairStyle);i&&(a=JS(a,i.layer))}if(n!=null&&n.outfitStyle){const i=nC(n.outfitStyle);i&&(a=rm(a,"torso",i.layer,1))}if(n!=null&&n.accessory&&n.accessory!=="none"){const i=rC(n.accessory);i&&(a=rm(a,"accessory",i.layer))}return a}function Ul({roleId:e,className:n,appearance:a,scale:i}){const o=v.useRef(null),u=v.useRef(0),d=v.useRef(0),f=v.useRef(a);f.current=a;const m=i??4,h=wh*m,x=kh*m,g=v.useMemo(()=>{const w=am(`mini:${e}`)??am("mini:default");return Ib(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=CC[e]??0,k=()=>{d.current++;const E=f.current;if(!E||!g){u.current=requestAnimationFrame(k);return}const N=(d.current+j)%SC<30?1:0;b.clearRect(0,0,wh,kh),b.save(),b.translate(2,1),eC(b,g,N,E,1),b.restore(),u.current=requestAnimationFrame(k)};return u.current=requestAnimationFrame(k),()=>cancelAnimationFrame(u.current)},[e,g]),l.jsx("canvas",{ref:o,width:wh,height:kh,className:n,style:{imageRendering:"pixelated",display:"block",width:h,height:x}})}const EC="https://api.tycono.ai",Ym=EC;async function No(e){const n=await fetch(`${Ym}${e}`);if(!n.ok)throw new Error(`Cloud API error: ${n.status}`);return n.json()}async function yi(e,n){const a=await fetch(`${Ym}${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 wr={health:()=>No("/api/health"),getMyName:e=>No(`/api/auth/my-name?instance_id=${encodeURIComponent(e)}`),getCharacters:e=>{const n=new URLSearchParams;e!=null&&e.sort&&n.set("sort",e.sort),e!=null&&e.instanceId&&n.set("instance_id",e.instanceId);const a=n.toString();return No(`/api/store/characters${a?`?${a}`:""}`)},getCharacter:e=>No(`/api/store/characters/${e}`),getCharacterVersion:e=>No(`/api/store/characters/${e}/version`),voteCharacter:(e,n,a)=>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(`${Ym}/api/store/characters/${e}${a}`,{method:"DELETE"}).then(i=>i.json())},uploadTelemetry:e=>yi("/api/telemetry",e),syncStats:e=>yi("/api/stats/sync",e)},NC={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},jh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},AC={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},DC=500,Eg=360,Ng=700,TC=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function Ag({role:e,allRoles:n,recentActivity:a,onClose:i,onFireRole:o,terminalWidth:u=0,activeJobId:d,activeSessionId:f,activeTask:m,isWorking:h,jobStartedAt:x,onStopJob:g,sessions:w,streamingSessionId:b,onCreateSessionSilent:j,onSendMessage:k,onFocusTerminal:E,onCustomize:C,onUpdateRole:N,appearance:_,relationships:z,roleLevel:H,onMaximize:R}){var Ve,bt;const[I,q]=v.useState(DC),[X,A]=v.useState(!1),$=v.useRef(0),L=v.useRef(0),[Y,se]=v.useState(!1),[ee,W]=v.useState(!1),[oe,de]=v.useState(!1),[V,D]=v.useState(!1),[B,U]=v.useState("talk"),[T,ie]=v.useState(!1),[ge,pe]=v.useState(""),[ze,Ie]=v.useState(!1),He=v.useRef(null),[st,Pe]=v.useState(!1),[et,Ee]=v.useState(""),[De,yt]=v.useState(!1),{events:ut,status:pt}=Ny(f??null),[jt,Wt]=v.useState(0);v.useEffect(()=>{if(!h||!x){Wt(0);return}const Re=new Date(x).getTime(),Ue=()=>Wt(Math.floor((Date.now()-Re)/1e3));Ue();const _t=setInterval(Ue,1e3);return()=>clearInterval(_t)},[h,x]);const Ft=u>0,Et=Ft?u:0,$n=Ft?Math.max(Eg,window.innerWidth-u-100):Ng,me=Math.min(I,$n),Se=v.useCallback(Re=>{Re.preventDefault(),$.current=Re.clientX,L.current=me,A(!0);const Ue=R,_t=()=>{A(!1),document.removeEventListener("mousemove",Bt),document.removeEventListener("mouseup",_t)},Bt=Ot=>{const fn=$.current-Ot.clientX,wn=L.current+fn;if(wn>=window.innerWidth*.6&&Ue){_t(),Ue();return}const Z=Math.min(Ng,Math.max(Eg,wn));q(Z)};document.addEventListener("mousemove",Bt),document.addEventListener("mouseup",_t)},[me,R]),Ne=v.useRef(null),K=e?w.find(Re=>Re.roleId===e.id):null,ue=Re=>{if(!e)return;const Ue=h?"talk":B;K?(k(K.id,Re,Ue),E(e.id)):(Ne.current={content:Re,mode:Ue},j(e.id))};v.useEffect(()=>{if(K&&Ne.current){const{content:Re,mode:Ue}=Ne.current;Ne.current=null,k(K.id,Re,Ue),e&&E(e.id)}},[K==null?void 0:K.id]);const te=(()=>{if(!ut.length)return null;const Re=[];let Ue=0,_t=0,Bt=0;for(const Ot of ut)if(Ot.type==="thinking")Ue++;else if(Ot.type==="text")_t++;else if(Ot.type==="tool:start"){const fn=String(Ot.data.name??"");Re.includes(fn)||Re.push(fn)}else Ot.type==="dispatch:start"&&Bt++;return{tools:Re,thinkCount:Ue,textCount:_t,dispatchCount:Bt,total:ut.length}})(),ke=m||(()=>{if(!K)return null;const Re=K.messages;for(let Ue=Re.length-1;Ue>=0;Ue--)if(Re[Ue].from==="ceo")return Re[Ue].content;return null})(),ve=(()=>{if(!K)return null;const Re=K.messages;for(let Ue=Re.length-1;Ue>=0;Ue--)if(Re[Ue].from==="role"&&Re[Ue].content)return Re[Ue].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:Et},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:Et,width:me,background:"var(--terminal-bg)",borderLeftColor:"var(--pixel-border)"},children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading role..."})})]});const _e=jh[e.id]??"#666",Be=NC[e.id]??"👤",Oe=n.filter(Re=>Re.reportsTo===e.id),qe=K&&b===K.id,rt=e.name||AC[e.id]||e.id;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:Et},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)] ${X?"resizing":""}`,style:{borderLeftColor:_e,right:Et,width:me,background:"var(--terminal-bg)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${X?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:Se}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${_e}ee, ${_e}99)`},children:[l.jsx("div",{className:"absolute inset-0 opacity-[0.06]",style:{backgroundImage:"repeating-linear-gradient(45deg, transparent, transparent 8px, white 8px, white 9px)"}}),l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1.5 z-10",children:[C&&l.jsx("button",{onClick:()=>C(e.id),className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-sm hover:bg-black/30 cursor-pointer backdrop-blur-sm",title:"Customize",children:"🎨"}),R&&l.jsx("button",{onClick:R,className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-sm hover:bg-black/30 cursor-pointer backdrop-blur-sm",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-lg hover:bg-black/30 cursor-pointer backdrop-blur-sm",children:"×"})]}),l.jsxs("div",{className:"relative flex items-end gap-4 px-4 pt-4 pb-3",children:[l.jsx("div",{className:"shrink-0 relative",style:{marginBottom:-2},children:l.jsx("div",{className:"rounded-lg p-1",style:{background:"rgba(0,0,0,0.2)"},children:l.jsx(Ul,{roleId:e.id,appearance:_,scale:8})})}),l.jsxs("div",{className:"flex-1 min-w-0 text-white pb-1",children:[l.jsxs("div",{className:"text-lg font-bold flex items-center gap-2",style:{fontFamily:"var(--pixel-font)"},children:[Be," ",e.id.toUpperCase(),h&&l.jsx("span",{className:"text-[9px] font-semibold px-2 py-0.5 rounded-full animate-pulse",style:{background:"rgba(251,191,36,0.25)",color:"#fde68a"},children:"WORKING"})]}),T?l.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async Re=>{Re.preventDefault();const Ue=ge.trim();if(!Ue||Ue===rt||!N){ie(!1);return}Ie(!0);try{await N(e.id,{name:Ue})}catch{}Ie(!1),ie(!1)},children:[l.jsx("input",{ref:He,value:ge,onChange:Re=>pe(Re.target.value),onKeyDown:Re=>{Re.key==="Escape"&&ie(!1)},disabled:ze,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:ze,className:"text-white/80 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✓"}),l.jsx("button",{type:"button",onClick:()=>ie(!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&&(pe(rt),ie(!0))},title:N?"Click to edit name":void 0,children:[rt,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.",H??1]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:h?"var(--idle-amber)":"var(--active-green)"}}),h?"Working":"Idle"]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsx("span",{children:e.level}),e.reportsTo&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"opacity-60",children:["→"," ",e.reportsTo]})]})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[h&&l.jsxs("div",{className:"px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--idle-amber)"}}),l.jsxs("span",{className:"text-xs font-semibold",style:{color:"var(--idle-amber)"},children:["Working",jt>0?` · ${TC(jt)}`:""]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>E(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"}),d&&g&&l.jsx("button",{onClick:()=>g(d),className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold transition-colors",style:{background:"rgba(239,68,68,0.15)",color:"#ef4444"},children:"Stop"})]})]}),ke&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:ke})]}),h&&d&&te&&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:()=>E(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:[te.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 ×",te.thinkCount]}),te.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)),te.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 ×",te.dispatchCount]}),te.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 ×",te.textCount]}),(pt==="streaming"||pt==="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:[te.total," events"]})]}),h&&ve&&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:()=>E(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:[ve.slice(0,200),ve.length>200&&"..."]})]}),h&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(Dg,{onSend:ue,disabled:!!qe,placeholder:"Ask something...",color:_e})}),!h&&l.jsxs("div",{className:"px-4 pt-4 pb-2",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-secondary)"},children:"Latest"}),l.jsx(MC,{icon:Be,roleId:e.id,roleName:rt,color:_e,text:a})]}),!h&&l.jsx("div",{className:"px-4 py-3",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[ve&&l.jsxs("div",{className:"px-3 pt-2.5 pb-2 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--terminal-border)"},onClick:()=>E(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:[ve.slice(0,150),ve.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:B==="talk"?"var(--accent)":"transparent",color:B==="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:B==="do"?"var(--idle-amber)":"transparent",color:B==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),l.jsx(Dg,{onSend:ue,disabled:!!qe,placeholder:B==="talk"?"Ask something...":"Give a directive...",color:_e})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(xu,{title:`Profile${e.persona?"":" (empty)"}`,open:Y,onToggle:()=>se(Re=>!Re),children:[st?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:et,onChange:Re=>Ee(Re.target.value),onKeyDown:Re=>{Re.key==="Escape"&&Pe(!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:()=>Pe(!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){yt(!0);try{await N(e.id,{persona:et.trim()})}catch{}yt(!1),Pe(!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&&(Ee(e.persona||""),Pe(!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(Sh,{label:"Level",value:e.level}),l.jsx(Sh,{label:"Reports to",value:e.reportsTo}),l.jsx(Sh,{label:"Status",value:e.status})]}),Oe.length>0&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"text-[11px] font-semibold mb-1",style:{color:"var(--terminal-text-muted)"},children:"Direct Reports"}),l.jsx("div",{className:"space-y-1",children:Oe.map(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:jh[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(xu,{title:"Authority",open:ee,onToggle:()=>W(Re=>!Re),children:[((Ve=e.authority.autonomous)==null?void 0:Ve.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,Ue)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Re]},Ue))]}),((bt=e.authority.needsApproval)==null?void 0:bt.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,Ue)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Re]},Ue))]})]}),e&&z&&(()=>{const Re=z.filter(Ue=>Ue.roleA===e.id||Ue.roleB===e.id).filter(Ue=>Ue.familiarity>0).sort((Ue,_t)=>_t.familiarity-Ue.familiarity);return Re.length===0?null:l.jsx(xu,{title:`Relationships (${Re.length})`,open:oe,onToggle:()=>de(Ue=>!Ue),children:l.jsx("div",{className:"space-y-1.5",children:Re.map((Ue,_t)=>{const Bt=Ue.roleA===e.id?Ue.roleB:Ue.roleA,Ot=n.find(Z=>Z.id===Bt),fn=Ue.familiarity>=80?"Best Partner":Ue.familiarity>=50?"Friend":Ue.familiarity>=20?"Colleague":"Acquaintance",wn=Ue.familiarity>=80?"#4CAF50":Ue.familiarity>=50?"#2196F3":Ue.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:jh[Bt]??"var(--terminal-text-secondary)"},children:(Ot==null?void 0:Ot.name)??Bt}),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:`${Ue.familiarity}%`,background:wn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:fn})]},_t)})})})})(),e.journal&&l.jsx(xu,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:V,onToggle:()=>D(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(As,{content:e.journal.slice(0,3e3)}),e.journal.length>3e3&&l.jsx("div",{className:"italic mt-2",style:{color:"var(--terminal-text-muted)"},children:"... (truncated)"})]})})]}),l.jsx(FC,{role:e,appearance:_}),o&&l.jsx("div",{className:"px-4 pb-4 mt-auto shrink-0",children:l.jsx("button",{onClick:()=>{o(e.id,e.name),i()},className:"w-full p-2 text-center text-xs font-medium border-2 border-dashed rounded-lg cursor-pointer transition-colors",style:{borderColor:"rgba(239,68,68,0.3)",color:"rgba(239,68,68,0.5)"},children:"Fire Role"})})]})]})]})}function FC({role:e,appearance:n}){const[a,i]=v.useState("idle"),[o,u]=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(()=>{wr.getCharacterVersion(e.id).then(N=>h((N==null?void 0:N.version)??null)).catch(()=>h(null)),ye.getPreferences().then(N=>k(N.instanceId??null)).catch(()=>{})},[e.id]);const E=async()=>{var N,_;if(!d){f(!0);return}i("publishing");try{let z=null;try{z=await ye.exportSkills(e.id)}catch{}const H={roleId:e.id,persona:e.persona??"",authority:e.authority??{autonomous:[],needsApproval:[]},level:e.level,tagline:((N=(e.persona??"").split(/[.\n]/)[0])==null?void 0:N.trim().slice(0,80))||e.name,chatStyle:"Professional and focused",skills:z??[],resume:{summary:((_=e.persona)==null?void 0:_.split(`
|
|
81
|
-
`)[0])??"",strengths:[],specialties:[],experience:""},author:{id:"tycono",name:"Tycono"},tags:[e.level,e.id],price:"free",installs:0,rating:0,featured:!1,randomActive:!0,randomPersonality:""};n&&(H.appearance=n);let R="1.0.0";try{const I=await wr.getCharacterVersion(e.id);if(I!=null&&I.version){const q=I.version.split(".").map(Number);q[2]=(q[2]??0)+1,R=q.join(".")}}catch{}await wr.publishCharacter({id:e.id,name:e.name||e.id,version:R,data:H,publisherId:j??void 0}),i("done"),u(`Published v${R}`),h(R),f(!1)}catch(z){i("error"),u(z instanceof Error?z.message:"Failed"),f(!1)}},C=async()=>{b(!0);try{await wr.deleteCharacter(e.id,j??void 0),h(null),i("idle"),u(""),g(!1)}catch{u("Delete failed")}b(!1)};return l.jsx("div",{className:"px-4 pb-2 shrink-0",children:l.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"px-3 py-2.5 flex items-center justify-between gap-2",style:{background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("a",{href:"https://tycono.ai/store.html",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-bold uppercase tracking-wider shrink-0 hover:underline cursor-pointer",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)",textDecoration:"none"},onClick:N=>N.stopPropagation(),children:"Job Board ↗"}),m&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded shrink-0",style:{background:"rgba(34,197,94,0.1)",color:"rgba(34,197,94,0.6)",border:"1px solid rgba(34,197,94,0.2)"},children:["v",m]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[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:C,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 MC({icon:e,roleId:n,roleName:a,color:i,text:o}){const u=!!o;return l.jsx("div",{className:"relative",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsxs("div",{className:"shrink-0",children:[l.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center text-xl shadow-sm",style:{background:`${i}18`,border:`2px solid ${i}44`},children:e}),l.jsx("div",{className:"text-[9px] font-bold text-center mt-0.5 uppercase tracking-wide",style:{color:i},children:n})]}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"absolute top-3 -left-2 w-0 h-0",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:`8px solid ${i}12`}}),l.jsxs("div",{className:"rounded-xl rounded-tl-sm p-4 border",style:{background:`${i}08`,borderColor:`${i}22`},children:[l.jsx("div",{className:"text-[10px] font-semibold mb-1.5 uppercase tracking-wider",style:{color:i},children:a}),u?l.jsx("div",{className:"text-sm leading-relaxed",style:{color:"var(--terminal-text)"},children:l.jsx(As,{content:o})}):l.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function xu({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 Dg({onSend:e,disabled:n,placeholder:a,color:i}){const[o,u]=v.useState(""),d=v.useRef(!1),f=()=>{const m=o.trim();!m||n||(e(m),u(""))};return l.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[l.jsx("input",{type:"text",value:o,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!d.current&&(m.preventDefault(),f())},onCompositionStart:()=>{d.current=!0},onCompositionEnd:()=>{d.current=!1},placeholder:n?"Waiting...":a,disabled:n,className:"flex-1 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none disabled:opacity-40",style:{background:"var(--hud-bg)",border:"1px solid var(--pixel-border)",color:"var(--terminal-text)"}}),l.jsx("button",{onClick:f,disabled:n||!o.trim(),className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 cursor-pointer text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",style:{background:n||!o.trim()?"#666":i},children:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M22 2L11 13"}),l.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})}function Sh({label:e,value:n}){return l.jsxs("div",{className:"flex justify-between py-1.5 text-xs",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:e}),l.jsx("span",{className:"font-semibold",style:{color:"var(--terminal-text)"},children:n})]})}function RC(e,n){var a,i=1;e==null&&(e=0),n==null&&(n=0);function o(){var u,d=a.length,f,m=0,h=0;for(u=0;u<d;++u)f=a[u],m+=f.x,h+=f.y;for(m=(m/d-e)*i,h=(h/d-n)*i,u=0;u<d;++u)f=a[u],f.x-=m,f.y-=h}return o.initialize=function(u){a=u},o.x=function(u){return arguments.length?(e=+u,o):e},o.y=function(u){return arguments.length?(n=+u,o):n},o.strength=function(u){return arguments.length?(i=+u,o):i},o}function zC(e){const n=+this._x.call(null,e),a=+this._y.call(null,e);return Hb(this.cover(n,a),n,a,e)}function Hb(e,n,a,i){if(isNaN(n)||isNaN(a))return e;var o,u=e._root,d={data:i},f=e._x0,m=e._y0,h=e._x1,x=e._y1,g,w,b,j,k,E,C,N;if(!u)return e._root=d,e;for(;u.length;)if((k=n>=(g=(f+h)/2))?f=g:h=g,(E=a>=(w=(m+x)/2))?m=w:x=w,o=u,!(u=u[C=E<<1|k]))return o[C]=d,e;if(b=+e._x.call(null,u.data),j=+e._y.call(null,u.data),n===b&&a===j)return d.next=u,o?o[C]=d:e._root=d,e;do o=o?o[C]=new Array(4):e._root=new Array(4),(k=n>=(g=(f+h)/2))?f=g:h=g,(E=a>=(w=(m+x)/2))?m=w:x=w;while((C=E<<1|k)===(N=(j>=w)<<1|b>=g));return o[N]=u,o[C]=d,e}function _C(e){var n,a,i=e.length,o,u,d=new Array(i),f=new Array(i),m=1/0,h=1/0,x=-1/0,g=-1/0;for(a=0;a<i;++a)isNaN(o=+this._x.call(null,n=e[a]))||isNaN(u=+this._y.call(null,n))||(d[a]=o,f[a]=u,o<m&&(m=o),o>x&&(x=o),u<h&&(h=u),u>g&&(g=u));if(m>x||h>g)return this;for(this.cover(m,h).cover(x,g),a=0;a<i;++a)Hb(this,d[a],f[a],e[a]);return this}function BC(e,n){if(isNaN(e=+e)||isNaN(n=+n))return this;var a=this._x0,i=this._y0,o=this._x1,u=this._y1;if(isNaN(a))o=(a=Math.floor(e))+1,u=(i=Math.floor(n))+1;else{for(var d=o-a||1,f=this._root,m,h;a>e||e>=o||i>n||n>=u;)switch(h=(n<i)<<1|e<a,m=new Array(4),m[h]=f,f=m,d*=2,h){case 0:o=a+d,u=i+d;break;case 1:a=o-d,u=i+d;break;case 2:o=a+d,i=u-d;break;case 3:a=o-d,i=u-d;break}this._root&&this._root.length&&(this._root=f)}return this._x0=a,this._y0=i,this._x1=o,this._y1=u,this}function OC(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function $C(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function or(e,n,a,i,o){this.node=e,this.x0=n,this.y0=a,this.x1=i,this.y1=o}function LC(e,n,a){var i,o=this._x0,u=this._y0,d,f,m,h,x=this._x1,g=this._y1,w=[],b=this._root,j,k;for(b&&w.push(new or(b,o,u,x,g)),a==null?a=1/0:(o=e-a,u=n-a,x=e+a,g=n+a,a*=a);j=w.pop();)if(!(!(b=j.node)||(d=j.x0)>x||(f=j.y0)>g||(m=j.x1)<o||(h=j.y1)<u))if(b.length){var E=(d+m)/2,C=(f+h)/2;w.push(new or(b[3],E,C,m,h),new or(b[2],d,C,E,h),new or(b[1],E,f,m,C),new or(b[0],d,f,E,C)),(k=(n>=C)<<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 N=e-+this._x.call(null,b.data),_=n-+this._y.call(null,b.data),z=N*N+_*_;if(z<a){var H=Math.sqrt(a=z);o=e-H,u=n-H,x=e+H,g=n+H,i=b.data}}return i}function IC(e){if(isNaN(x=+this._x.call(null,e))||isNaN(g=+this._y.call(null,e)))return this;var n,a=this._root,i,o,u,d=this._x0,f=this._y0,m=this._x1,h=this._y1,x,g,w,b,j,k,E,C;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,C=E)}for(;a.data!==e;)if(o=a,!(a=a.next))return this;return(u=a.next)&&delete a.next,o?(u?o.next=u:delete o.next,this):n?(u?n[E]=u: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[C]=a:this._root=a),this):(this._root=u,this)}function HC(e){for(var n=0,a=e.length;n<a;++n)this.remove(e[n]);return this}function UC(){return this._root}function qC(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function YC(e){var n=[],a,i=this._root,o,u,d,f,m;for(i&&n.push(new or(i,this._x0,this._y0,this._x1,this._y1));a=n.pop();)if(!e(i=a.node,u=a.x0,d=a.y0,f=a.x1,m=a.y1)&&i.length){var h=(u+f)/2,x=(d+m)/2;(o=i[3])&&n.push(new or(o,h,x,f,m)),(o=i[2])&&n.push(new or(o,u,x,h,m)),(o=i[1])&&n.push(new or(o,h,d,f,x)),(o=i[0])&&n.push(new or(o,u,d,h,x))}return this}function XC(e){var n=[],a=[],i;for(this._root&&n.push(new or(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var o=i.node;if(o.length){var u,d=i.x0,f=i.y0,m=i.x1,h=i.y1,x=(d+m)/2,g=(f+h)/2;(u=o[0])&&n.push(new or(u,d,f,x,g)),(u=o[1])&&n.push(new or(u,x,f,m,g)),(u=o[2])&&n.push(new or(u,d,g,x,h)),(u=o[3])&&n.push(new or(u,x,g,m,h))}a.push(i)}for(;i=a.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function WC(e){return e[0]}function GC(e){return arguments.length?(this._x=e,this):this._x}function VC(e){return e[1]}function KC(e){return arguments.length?(this._y=e,this):this._y}function Xm(e,n,a){var i=new Wm(n??WC,a??VC,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function Wm(e,n,a,i,o,u){this._x=e,this._y=n,this._x0=a,this._y0=i,this._x1=o,this._y1=u,this._root=void 0}function Tg(e){for(var n={data:e.data},a=n;e=e.next;)a=a.next={data:e.data};return n}var cr=Xm.prototype=Wm.prototype;cr.copy=function(){var e=new Wm(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=Tg(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]=Tg(i));return e};cr.add=zC;cr.addAll=_C;cr.cover=BC;cr.data=OC;cr.extent=$C;cr.find=LC;cr.remove=IC;cr.removeAll=HC;cr.root=UC;cr.size=qC;cr.visit=YC;cr.visitAfter=XC;cr.x=GC;cr.y=KC;function Si(e){return function(){return e}}function Hl(e){return(e()-.5)*1e-6}function PC(e){return e.x+e.vx}function QC(e){return e.y+e.vy}function ZC(e){var n,a,i,o=1,u=1;typeof e!="function"&&(e=Si(e==null?1:+e));function d(){for(var h,x=n.length,g,w,b,j,k,E,C=0;C<u;++C)for(g=Xm(n,PC,QC).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(N);function N(_,z,H,R,I){var q=_.data,X=_.r,A=k+X;if(q){if(q.index>w.index){var $=b-q.x-q.vx,L=j-q.y-q.vy,Y=$*$+L*L;Y<A*A&&($===0&&($=Hl(i),Y+=$*$),L===0&&(L=Hl(i),Y+=L*L),Y=(A-(Y=Math.sqrt(Y)))/Y*o,w.vx+=($*=Y)*(A=(X*=X)/(E+X)),w.vy+=(L*=Y)*A,q.vx-=$*(A=1-A),q.vy-=L*A)}return}return z>b+A||R<b-A||H>j+A||I<j-A}}function f(h){if(h.data)return h.r=a[h.data.index];for(var x=h.r=0;x<4;++x)h[x]&&h[x].r>h.r&&(h.r=h[x].r)}function m(){if(n){var h,x=n.length,g;for(a=new Array(x),h=0;h<x;++h)g=n[h],a[g.index]=+e(g,h,n)}}return d.initialize=function(h,x){n=h,i=x,m()},d.iterations=function(h){return arguments.length?(u=+h,d):u},d.strength=function(h){return arguments.length?(o=+h,d):o},d.radius=function(h){return arguments.length?(e=typeof h=="function"?h:Si(+h),m(),d):e},d}function JC(e){return e.index}function Fg(e,n){var a=e.get(n);if(!a)throw new Error("node not found: "+n);return a}function eE(e){var n=JC,a=g,i,o=Si(30),u,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 C=0,N=e.length;C<x;++C)for(var _=0,z,H,R,I,q,X,A;_<N;++_)z=e[_],H=z.source,R=z.target,I=R.x+R.vx-H.x-H.vx||Hl(h),q=R.y+R.vy-H.y-H.vy||Hl(h),X=Math.sqrt(I*I+q*q),X=(X-u[_])/X*E*i[_],I*=X,q*=X,R.vx-=I*(A=m[_]),R.vy-=q*A,H.vx+=I*(A=1-A),H.vy+=q*A}function b(){if(d){var E,C=d.length,N=e.length,_=new Map(d.map((H,R)=>[n(H,R,d),H])),z;for(E=0,f=new Array(C);E<N;++E)z=e[E],z.index=E,typeof z.source!="object"&&(z.source=Fg(_,z.source)),typeof z.target!="object"&&(z.target=Fg(_,z.target)),f[z.source.index]=(f[z.source.index]||0)+1,f[z.target.index]=(f[z.target.index]||0)+1;for(E=0,m=new Array(N);E<N;++E)z=e[E],m[E]=f[z.source.index]/(f[z.source.index]+f[z.target.index]);i=new Array(N),j(),u=new Array(N),k()}}function j(){if(d)for(var E=0,C=e.length;E<C;++E)i[E]=+a(e[E],E,e)}function k(){if(d)for(var E=0,C=e.length;E<C;++E)u[E]=+o(e[E],E,e)}return w.initialize=function(E,C){d=E,h=C,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 tE={value:()=>{}};function Ub(){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 Fu(a)}function Fu(e){this._=e}function nE(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}})}Fu.prototype=Ub.prototype={constructor:Fu,on:function(e,n){var a=this._,i=nE(e+"",a),o,u=-1,d=i.length;if(arguments.length<2){for(;++u<d;)if((o=(e=i[u]).type)&&(o=rE(a[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++u<d;)if(o=(e=i[u]).type)a[o]=Mg(a[o],e.name,n);else if(n==null)for(o in a)a[o]=Mg(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 Fu(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var a=new Array(o),i=0,o,u;i<o;++i)a[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(u=this._[e],i=0,o=u.length;i<o;++i)u[i].value.apply(n,a)},apply:function(e,n,a){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],o=0,u=i.length;o<u;++o)i[o].value.apply(n,a)}};function rE(e,n){for(var a=0,i=e.length,o;a<i;++a)if((o=e[a]).name===n)return o.value}function Mg(e,n,a){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=tE,e=e.slice(0,i).concat(e.slice(i+1));break}return a!=null&&e.push({name:n,value:a}),e}var ks=0,Mo=0,Ao=0,qb=1e3,Iu,Ro,Hu=0,Ai=0,Qu=0,Uo=typeof performance=="object"&&performance.now?performance:Date,Yb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Xb(){return Ai||(Yb(aE),Ai=Uo.now()+Qu)}function aE(){Ai=0}function lm(){this._call=this._time=this._next=null}lm.prototype=Wb.prototype={constructor:lm,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?Xb():+a)+(n==null?0:+n),!this._next&&Ro!==this&&(Ro?Ro._next=this:Iu=this,Ro=this),this._call=e,this._time=a,im()},stop:function(){this._call&&(this._call=null,this._time=1/0,im())}};function Wb(e,n,a){var i=new lm;return i.restart(e,n,a),i}function lE(){Xb(),++ks;for(var e=Iu,n;e;)(n=Ai-e._time)>=0&&e._call.call(void 0,n),e=e._next;--ks}function Rg(){Ai=(Hu=Uo.now())+Qu,ks=Mo=0;try{lE()}finally{ks=0,sE(),Ai=0}}function iE(){var e=Uo.now(),n=e-Hu;n>qb&&(Qu-=n,Hu=e)}function sE(){for(var e,n=Iu,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:Iu=a);Ro=e,im(i)}function im(e){if(!ks){Mo&&(Mo=clearTimeout(Mo));var n=e-Ai;n>24?(e<1/0&&(Mo=setTimeout(Rg,e-Uo.now()-Qu)),Ao&&(Ao=clearInterval(Ao))):(Ao||(Hu=Uo.now(),Ao=setInterval(iE,qb)),ks=1,Yb(Rg))}}const oE=1664525,cE=1013904223,zg=4294967296;function uE(){let e=1;return()=>(e=(oE*e+cE)%zg)/zg}function dE(e){return e.x}function fE(e){return e.y}var hE=10,mE=Math.PI*(3-Math.sqrt(5));function pE(e){var n,a=1,i=.001,o=1-Math.pow(i,1/300),u=0,d=.6,f=new Map,m=Wb(g),h=Ub("tick","end"),x=uE();e==null&&(e=[]);function g(){w(),h.call("tick",n),a<i&&(m.stop(),h.call("end",n))}function w(k){var E,C=e.length,N;k===void 0&&(k=1);for(var _=0;_<k;++_)for(a+=(u-a)*o,f.forEach(function(z){z(a)}),E=0;E<C;++E)N=e[E],N.fx==null?N.x+=N.vx*=d:(N.x=N.fx,N.vx=0),N.fy==null?N.y+=N.vy*=d:(N.y=N.fy,N.vy=0);return n}function b(){for(var k=0,E=e.length,C;k<E;++k){if(C=e[k],C.index=k,C.fx!=null&&(C.x=C.fx),C.fy!=null&&(C.y=C.fy),isNaN(C.x)||isNaN(C.y)){var N=hE*Math.sqrt(.5+k),_=k*mE;C.x=N*Math.cos(_),C.y=N*Math.sin(_)}(isNaN(C.vx)||isNaN(C.vy))&&(C.vx=C.vy=0)}}function j(k){return k.initialize&&k.initialize(e,x),k}return b(),n={tick: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?(u=+k,n):u},velocityDecay:function(k){return arguments.length?(d=1-k,n):1-d},randomSource:function(k){return arguments.length?(x=k,f.forEach(j),n):x},force:function(k,E){return arguments.length>1?(E==null?f.delete(k):f.set(k,j(E)),n):f.get(k)},find:function(k,E,C){var N=0,_=e.length,z,H,R,I,q;for(C==null?C=1/0:C*=C,N=0;N<_;++N)I=e[N],z=k-I.x,H=E-I.y,R=z*z+H*H,R<C&&(q=I,C=R);return q},on:function(k,E){return arguments.length>1?(h.on(k,E),n):h.on(k)}}}function xE(){var e,n,a,i,o=Si(-30),u,d=1,f=1/0,m=.81;function h(b){var j,k=e.length,E=Xm(e,dE,fE).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(u=new Array(j),b=0;b<j;++b)k=e[b],u[k.index]=+o(k,b,e)}}function g(b){var j=0,k,E,C=0,N,_,z;if(b.length){for(N=_=z=0;z<4;++z)(k=b[z])&&(E=Math.abs(k.value))&&(j+=k.value,C+=E,N+=E*k.x,_+=E*k.y);b.x=N/C,b.y=_/C}else{k=b,k.x=k.data.x,k.y=k.data.y;do j+=u[k.data.index];while(k=k.next)}b.value=j}function w(b,j,k,E){if(!b.value)return!0;var C=b.x-n.x,N=b.y-n.y,_=E-j,z=C*C+N*N;if(_*_/m<z)return z<f&&(C===0&&(C=Hl(a),z+=C*C),N===0&&(N=Hl(a),z+=N*N),z<d&&(z=Math.sqrt(d*z)),n.vx+=C*b.value*i/z,n.vy+=N*b.value*i/z),!0;if(b.length||z>=f)return;(b.data!==n||b.next)&&(C===0&&(C=Hl(a),z+=C*C),N===0&&(N=Hl(a),z+=N*N),z<d&&(z=Math.sqrt(d*z)));do b.data!==n&&(_=u[b.data.index]*i/z,n.vx+=C*_,n.vy+=N*_);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 al(e){return Array.isArray?Array.isArray(e):Kb(e)==="[object Array]"}function gE(e){if(typeof e=="string")return e;let n=e+"";return n=="0"&&1/e==-1/0?"-0":n}function yE(e){return e==null?"":gE(e)}function Ca(e){return typeof e=="string"}function Gb(e){return typeof e=="number"}function bE(e){return e===!0||e===!1||vE(e)&&Kb(e)=="[object Boolean]"}function Vb(e){return typeof e=="object"}function vE(e){return Vb(e)&&e!==null}function zr(e){return e!=null}function Ch(e){return!e.trim().length}function Kb(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const wE="Incorrect 'index' type",kE=e=>`Invalid value for key ${e}`,jE=e=>`Pattern length exceeds max of ${e}.`,SE=e=>`Missing ${e} property in key`,CE=e=>`Property 'weight' in key '${e}' must be a positive integer`,_g=Object.prototype.hasOwnProperty;class EE{constructor(n){this._keys=[],this._keyMap={};let a=0;n.forEach(i=>{let o=Pb(i);this._keys.push(o),this._keyMap[o.id]=o,a+=o.weight}),this._keys.forEach(i=>{i.weight/=a})}get(n){return this._keyMap[n]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Pb(e){let n=null,a=null,i=null,o=1,u=null;if(Ca(e)||al(e))i=e,n=Bg(e),a=sm(e);else{if(!_g.call(e,"name"))throw new Error(SE("name"));const d=e.name;if(i=d,_g.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(CE(d));n=Bg(d),a=sm(d),u=e.getFn}return{path:n,id:a,weight:o,src:i,getFn:u}}function Bg(e){return al(e)?e:e.split(".")}function sm(e){return al(e)?e.join("."):e}function NE(e,n){let a=[],i=!1;const o=(u,d,f)=>{if(zr(u))if(!d[f])a.push(u);else{let m=d[f];const h=u[m];if(!zr(h))return;if(f===d.length-1&&(Ca(h)||Gb(h)||bE(h)))a.push(yE(h));else if(al(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,Ca(n)?n.split("."):n,0),i?a:a[0]}const AE={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},DE={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},TE={location:0,threshold:.6,distance:100},FE={useExtendedSearch:!1,getFn:NE,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var ht={...DE,...AE,...TE,...FE};const ME=/[^ ]+/g;function RE(e=1,n=3){const a=new Map,i=Math.pow(10,n);return{get(o){const u=o.match(ME).length;if(a.has(u))return a.get(u);const d=1/Math.pow(u,.5*e),f=parseFloat(Math.round(d*i)/i);return a.set(u,f),f},clear(){a.clear()}}}class Gm{constructor({getFn:n=ht.getFn,fieldNormWeight:a=ht.fieldNormWeight}={}){this.norm=RE(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,Ca(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();Ca(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(!zr(n)||Ch(n))return;let i={v:n,i:a,n:this.norm.get(n)};this.records.push(i)}_addObject(n,a){let i={i:a,$:{}};this.keys.forEach((o,u)=>{let d=o.getFn?o.getFn(n):this.getFn(n,o.path);if(zr(d)){if(al(d)){let f=[];const m=[{nestedArrIndex:-1,value:d}];for(;m.length;){const{nestedArrIndex:h,value:x}=m.pop();if(zr(x))if(Ca(x)&&!Ch(x)){let g={v:x,i:h,n:this.norm.get(x)};f.push(g)}else al(x)&&x.forEach((g,w)=>{m.push({nestedArrIndex:w,value:g})})}i.$[u]=f}else if(Ca(d)&&!Ch(d)){let f={v:d,n:this.norm.get(d)};i.$[u]=f}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function Qb(e,n,{getFn:a=ht.getFn,fieldNormWeight:i=ht.fieldNormWeight}={}){const o=new Gm({getFn:a,fieldNormWeight:i});return o.setKeys(e.map(Pb)),o.setSources(n),o.create(),o}function zE(e,{getFn:n=ht.getFn,fieldNormWeight:a=ht.fieldNormWeight}={}){const{keys:i,records:o}=e,u=new Gm({getFn:n,fieldNormWeight:a});return u.setKeys(i),u.setIndexRecords(o),u}function gu(e,{errors:n=0,currentLocation:a=0,expectedLocation:i=0,distance:o=ht.distance,ignoreLocation:u=ht.ignoreLocation}={}){const d=n/e.length;if(u)return d;const f=Math.abs(i-a);return o?d+f/o:f?1:d}function _E(e=[],n=ht.minMatchCharLength){let a=[],i=-1,o=-1,u=0;for(let d=e.length;u<d;u+=1){let f=e[u];f&&i===-1?i=u:!f&&i!==-1&&(o=u-1,o-i+1>=n&&a.push([i,o]),i=-1)}return e[u-1]&&u-i>=n&&a.push([i,u-1]),a}const ji=32;function BE(e,n,a,{location:i=ht.location,distance:o=ht.distance,threshold:u=ht.threshold,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,includeMatches:m=ht.includeMatches,ignoreLocation:h=ht.ignoreLocation}={}){if(n.length>ji)throw new Error(jE(ji));const x=n.length,g=e.length,w=Math.max(0,Math.min(i,g));let b=u,j=w;const k=f>1||m,E=k?Array(g):[];let C;for(;(C=e.indexOf(n,j))>-1;){let I=gu(n,{currentLocation:C,expectedLocation:w,distance:o,ignoreLocation:h});if(b=Math.min(I,b),j=C+x,k){let q=0;for(;q<x;)E[C+q]=1,q+=1}}j=-1;let N=[],_=1,z=x+g;const H=1<<x-1;for(let I=0;I<x;I+=1){let q=0,X=z;for(;q<X;)gu(n,{errors:I,currentLocation:w+X,expectedLocation:w,distance:o,ignoreLocation:h})<=b?q=X:z=X,X=Math.floor((z-q)/2+q);z=X;let A=Math.max(1,w-X+1),$=d?g:Math.min(w+X,g)+x,L=Array($+2);L[$+1]=(1<<I)-1;for(let se=$;se>=A;se-=1){let ee=se-1,W=a[e.charAt(ee)];if(k&&(E[ee]=+!!W),L[se]=(L[se+1]<<1|1)&W,I&&(L[se]|=(N[se+1]|N[se])<<1|1|N[se+1]),L[se]&H&&(_=gu(n,{errors:I,currentLocation:ee,expectedLocation:w,distance:o,ignoreLocation:h}),_<=b)){if(b=_,j=ee,j<=w)break;A=Math.max(1,2*w-j)}}if(gu(n,{errors:I+1,currentLocation:w,expectedLocation:w,distance:o,ignoreLocation:h})>b)break;N=L}const R={isMatch:j>=0,score:Math.max(.001,_)};if(k){const I=_E(E,f);I.length?m&&(R.indices=I):R.isMatch=!1}return R}function OE(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 Uu=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 Zb{constructor(n,{location:a=ht.location,threshold:i=ht.threshold,distance:o=ht.distance,includeMatches:u=ht.includeMatches,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,isCaseSensitive:m=ht.isCaseSensitive,ignoreDiacritics:h=ht.ignoreDiacritics,ignoreLocation:x=ht.ignoreLocation}={}){if(this.options={location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:f,isCaseSensitive:m,ignoreDiacritics:h,ignoreLocation:x},n=m?n:n.toLowerCase(),n=h?Uu(n):n,this.pattern=n,this.chunks=[],!this.pattern.length)return;const g=(b,j)=>{this.chunks.push({pattern:b,alphabet:OE(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?Uu(n):n,this.pattern===n){let k={isMatch:!0,score:0};return o&&(k.indices=[[0,n.length-1]]),k}const{location:u,distance:d,threshold:f,findAllMatches:m,minMatchCharLength:h,ignoreLocation:x}=this.options;let g=[],w=0,b=!1;this.chunks.forEach(({pattern:k,alphabet:E,startIndex:C})=>{const{isMatch:N,score:_,indices:z}=BE(n,k,E,{location:u+C,distance:d,threshold:f,findAllMatches:m,minMatchCharLength:h,includeMatches:o,ignoreLocation:x});N&&(b=!0),w+=_,N&&z&&(g=[...g,...z])});let j={isMatch:b,score:b?w/this.chunks.length:1};return b&&o&&(j.indices=g),j}}class Xl{constructor(n){this.pattern=n}static isMultiMatch(n){return Og(n,this.multiRegex)}static isSingleMatch(n){return Og(n,this.singleRegex)}search(){}}function Og(e,n){const a=e.match(n);return a?a[1]:null}class $E extends Xl{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 LE extends Xl{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 IE extends Xl{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 HE extends Xl{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 UE extends Xl{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 qE extends Xl{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 Jb extends Xl{constructor(n,{location:a=ht.location,threshold:i=ht.threshold,distance:o=ht.distance,includeMatches:u=ht.includeMatches,findAllMatches:d=ht.findAllMatches,minMatchCharLength:f=ht.minMatchCharLength,isCaseSensitive:m=ht.isCaseSensitive,ignoreDiacritics:h=ht.ignoreDiacritics,ignoreLocation:x=ht.ignoreLocation}={}){super(n),this._bitapSearch=new Zb(n,{location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:f,isCaseSensitive:m,ignoreDiacritics:h,ignoreLocation:x})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(n){return this._bitapSearch.searchIn(n)}}class ev extends Xl{constructor(n){super(n)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(n){let a=0,i;const o=[],u=this.pattern.length;for(;(i=n.indexOf(this.pattern,a))>-1;)a=i+u,o.push([i,a-1]);const d=!!o.length;return{isMatch:d,score:d?0:1,indices:o}}}const om=[$E,ev,IE,HE,qE,UE,LE,Jb],$g=om.length,YE=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,XE="|";function WE(e,n={}){return e.split(XE).map(a=>{let i=a.trim().split(YE).filter(u=>u&&!!u.trim()),o=[];for(let u=0,d=i.length;u<d;u+=1){const f=i[u];let m=!1,h=-1;for(;!m&&++h<$g;){const x=om[h];let g=x.isMultiMatch(f);g&&(o.push(new x(g,n)),m=!0)}if(!m)for(h=-1;++h<$g;){const x=om[h];let g=x.isSingleMatch(f);if(g){o.push(new x(g,n));break}}}return o})}const GE=new Set([Jb.type,ev.type]);class VE{constructor(n,{isCaseSensitive:a=ht.isCaseSensitive,ignoreDiacritics:i=ht.ignoreDiacritics,includeMatches:o=ht.includeMatches,minMatchCharLength:u=ht.minMatchCharLength,ignoreLocation:d=ht.ignoreLocation,findAllMatches:f=ht.findAllMatches,location:m=ht.location,threshold:h=ht.threshold,distance:x=ht.distance}={}){this.query=null,this.options={isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o,minMatchCharLength:u,findAllMatches:f,ignoreLocation:d,location:m,threshold:h,distance:x},n=a?n:n.toLowerCase(),n=i?Uu(n):n,this.pattern=n,this.query=WE(this.pattern,this.options)}static condition(n,a){return a.useExtendedSearch}searchIn(n){const a=this.query;if(!a)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:o,ignoreDiacritics:u}=this.options;n=o?n:n.toLowerCase(),n=u?Uu(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:C}=j.search(n);if(k){if(d+=1,m+=C,i){const N=j.constructor.type;GE.has(N)?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 cm=[];function KE(...e){cm.push(...e)}function um(e,n){for(let a=0,i=cm.length;a<i;a+=1){let o=cm[a];if(o.condition(e,n))return new o(e,n)}return new Zb(e,n)}const qu={AND:"$and",OR:"$or"},dm={PATH:"$path",PATTERN:"$val"},fm=e=>!!(e[qu.AND]||e[qu.OR]),PE=e=>!!e[dm.PATH],QE=e=>!al(e)&&Vb(e)&&!fm(e),Lg=e=>({[qu.AND]:Object.keys(e).map(n=>({[n]:e[n]}))});function tv(e,n,{auto:a=!0}={}){const i=o=>{let u=Object.keys(o);const d=PE(o);if(!d&&u.length>1&&!fm(o))return i(Lg(o));if(QE(o)){const m=d?o[dm.PATH]:u[0],h=d?o[dm.PATTERN]:o[m];if(!Ca(h))throw new Error(kE(m));const x={keyId:sm(m),pattern:h};return a&&(x.searcher=um(h,n)),x}let f={children:[],operator:u[0]};return u.forEach(m=>{const h=o[m];al(h)&&h.forEach(x=>{f.children.push(i(x))})}),f};return fm(e)||(e=Lg(e)),i(e)}function ZE(e,{ignoreFieldNorm:n=ht.ignoreFieldNorm}){e.forEach(a=>{let i=1;a.matches.forEach(({key:o,norm:u,score:d})=>{const f=o?o.weight:null;i*=Math.pow(d===0&&f?Number.EPSILON:d,(f||1)*(n?1:u))}),a.score=i})}function JE(e,n){const a=e.matches;n.matches=[],zr(a)&&a.forEach(i=>{if(!zr(i.indices)||!i.indices.length)return;const{indices:o,value:u}=i;let d={indices:o,value:u};i.key&&(d.key=i.key.src),i.idx>-1&&(d.refIndex=i.idx),n.matches.push(d)})}function eN(e,n){n.score=e.score}function tN(e,n,{includeMatches:a=ht.includeMatches,includeScore:i=ht.includeScore}={}){const o=[];return a&&o.push(JE),i&&o.push(eN),e.map(u=>{const{idx:d}=u,f={item:n[d],refIndex:d};return o.length&&o.forEach(m=>{m(u,f)}),f})}class Ds{constructor(n,a={},i){this.options={...ht,...a},this.options.useExtendedSearch,this._keyStore=new EE(this.options.keys),this.setCollection(n,i)}setCollection(n,a){if(this._docs=n,a&&!(a instanceof Gm))throw new Error(wE);this._myIndex=a||Qb(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(n){zr(n)&&(this._docs.push(n),this._myIndex.add(n))}remove(n=()=>!1){const a=[];for(let i=0,o=this._docs.length;i<o;i+=1){const u=this._docs[i];n(u,i)&&(this.removeAt(i),i-=1,o-=1,a.push(u))}return a}removeAt(n){this._docs.splice(n,1),this._myIndex.removeAt(n)}getIndex(){return this._myIndex}search(n,{limit:a=-1}={}){const{includeMatches:i,includeScore:o,shouldSort:u,sortFn:d,ignoreFieldNorm:f}=this.options;let m=Ca(n)?Ca(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return ZE(m,{ignoreFieldNorm:f}),u&&m.sort(d),Gb(a)&&a>-1&&(m=m.slice(0,a)),tN(m,this._docs,{includeMatches:i,includeScore:o})}_searchStringList(n){const a=um(n,this.options),{records:i}=this._myIndex,o=[];return i.forEach(({v:u,i:d,n:f})=>{if(!zr(u))return;const{isMatch:m,score:h,indices:x}=a.searchIn(u);m&&o.push({item:u,idx:d,matches:[{score:h,value:u,norm:f,indices:x}]})}),o}_searchLogical(n){const a=tv(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===qu.AND)return[]}return x},o=this._myIndex.records,u={},d=[];return o.forEach(({$:f,i:m})=>{if(zr(f)){let h=i(a,f,m);h.length&&(u[m]||(u[m]={idx:m,item:f,matches:[]},d.push(u[m])),h.forEach(({matches:x})=>{u[m].matches.push(...x)}))}}),d}_searchObjectList(n){const a=um(n,this.options),{keys:i,records:o}=this._myIndex,u=[];return o.forEach(({$:d,i:f})=>{if(!zr(d))return;let m=[];i.forEach((h,x)=>{m.push(...this._findMatches({key:h,value:d[x],searcher:a}))}),m.length&&u.push({idx:f,item:d,matches:m})}),u}_findMatches({key:n,value:a,searcher:i}){if(!zr(a))return[];let o=[];if(al(a))a.forEach(({v:u,i:d,n:f})=>{if(!zr(u))return;const{isMatch:m,score:h,indices:x}=i.searchIn(u);m&&o.push({score:h,key:n,value:u,idx:d,norm:f,indices:x})});else{const{v:u,n:d}=a,{isMatch:f,score:m,indices:h}=i.searchIn(u);f&&o.push({score:m,key:n,value:u,norm:d,indices:h})}return o}}Ds.version="7.1.0";Ds.createIndex=Qb;Ds.parseIndex=zE;Ds.config=ht;Ds.parseQuery=tv;KE(VE);const ia={tech:{bg:"rgba(59,130,246,0.15)",border:"#3b82f6",text:"#60a5fa"},market:{bg:"rgba(245,158,11,0.15)",border:"#f59e0b",text:"#fbbf24"},strategy:{bg:"rgba(139,92,246,0.15)",border:"#8b5cf6",text:"#a78bfa"},financial:{bg:"rgba(34,197,94,0.15)",border:"#22c55e",text:"#4ade80"},process:{bg:"rgba(236,72,153,0.15)",border:"#ec4899",text:"#f472b6"},competitor:{bg:"rgba(239,68,68,0.15)",border:"#ef4444",text:"#f87171"},domain:{bg:"rgba(14,165,233,0.15)",border:"#0ea5e9",text:"#38bdf8"},general:{bg:"rgba(148,163,184,0.12)",border:"#64748b",text:"#94a3b8"}};function nN(e){return ia[e]??ia.general}function rN(e){return e>1600?"macro":e<800?"micro":"standard"}function aN(e){const n=new Map;for(const i of e){const o=i.category||"general";n.has(o)||n.set(o,[]),n.get(o).push(i)}const a=[];for(const[i,o]of n){let u=0,d=0;for(const m of o)u+=m.x??0,d+=m.y??0;const f=o.length;a.push({domain:i,count:f,centerX:u/f,centerY:d/f,nodes:o})}return a}function lN(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 iN(e,n,a){const i=[...new Set(a.map(m=>m.category||"general"))],o=new Map,u=e/2,d=n/2,f=Math.min(e,n)*.3;return i.forEach((m,h)=>{const x=2*Math.PI*h/i.length-Math.PI/2;o.set(m,{x:u+f*Math.cos(x),y:d+f*Math.sin(x)})}),o}function sN(e,n=.12){let a;function i(o){for(const u of a){const d=e.get(u.category)||e.get("general");d&&u.x!==void 0&&u.y!==void 0&&(u.vx=(u.vx||0)+(d.x-u.x)*o*n,u.vy=(u.vy||0)+(d.y-u.y)*o*n)}}return i.initialize=function(o){a=o},i}function oN(e){return e.map(n=>{let a=0;for(const o of n.nodes){const u=(o.x??0)-n.centerX,d=(o.y??0)-n.centerY,f=Math.sqrt(u*u+d*d);f>a&&(a=f)}const i=Math.max(40,n.count*8);return{...n,radius:a+i}})}function cN(e,n,a,i){if(!e)return a;const o=new Set([e]),u=new Set;let d=new Set([e]);for(let f=0;f<i;f++){const m=new Set;for(const h of d)if(!u.has(h)){u.add(h);for(const x of n){const g=typeof x.source=="string"?x.source:x.source.id,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 uN({docs:e,onNodeClick:n,selectedDocId:a,matchedIds:i,localGraphMode:o,onLocalModeChange:u}){var de;const d=v.useRef(null),f=v.useRef(null),[m,h]=v.useState({width:600,height:400}),[x,g]=v.useState({nodes:[],links:[]}),[w,b]=v.useState(null),[j,k]=v.useState(null),[E,C]=v.useState({x:0,y:0}),[N,_]=v.useState({x:0,y:0,w:600,h:400}),z=v.useRef(!1),H=v.useRef({x:0,y:0,vx:0,vy:0}),R=v.useRef(null),I=v.useRef(null),q=v.useMemo(()=>rN(N.w),[N.w]),X=v.useMemo(()=>aN(x.nodes),[x.nodes]),A=v.useMemo(()=>oN(X),[X]),$=v.useMemo(()=>{if(o==="global"||!a)return null;const V=new Set(x.nodes.map(B=>B.id)),D=o==="1-hop"?1:2;return cN(a,x.links,V,D)},[o,a,x.nodes,x.links]);v.useEffect(()=>{const V=d.current;if(!V)return;const D=new ResizeObserver(B=>{const{width:U,height:T}=B[0].contentRect;U>0&&T>0&&(h({width:U,height:T}),_(ie=>({...ie,w:U,h:T})))});return D.observe(V),()=>D.disconnect()},[]),v.useEffect(()=>{if(e.length===0)return;const V=new Set(e.map(De=>De.id)),D=e.map(De=>({id:De.id,title:De.title,category:De.category,akb_type:De.akb_type,tldr:De.tldr,tags:De.tags})),B=(De,yt)=>{if(!yt.startsWith(".")&&!yt.startsWith("/"))return yt;const ut=De.split("/");ut.pop();const pt=yt.split("/");for(const jt of pt)jt===".."?ut.pop():jt!=="."&&jt!==""&&ut.push(jt);return ut.join("/")},U=[];for(const De of e)for(const yt of De.links){const ut=B(De.id,yt.href);V.has(ut)&&ut!==De.id&&(U.some(pt=>pt.source===De.id&&pt.target===ut||pt.source===ut&&pt.target===De.id)||U.push({source:De.id,target:ut,label:yt.text}))}const{width:T,height:ie}=m,ge=D.length,pe=ge>100?-600:ge>50?-500:-400,ze=ge>100?180:ge>50?160:140,Ie=ge>100?60:50,He=Math.max(T,ge*12),st=Math.max(ie,ge*10),Pe=iN(He,st,D),et=pE(D).force("link",eE(U).id(De=>De.id).distance(ze)).force("charge",xE().strength(pe)).force("center",RC(He/2,st/2)).force("collide",ZC(Ie)).force("cluster",sN(Pe,.15));I.current=et,et.on("tick",()=>{g({nodes:[...D],links:[...U]})}),et.alpha(1).restart();const Ee=ge>100?300:150;for(let De=0;De<Ee;De++)et.tick();if(et.stop(),g({nodes:[...D],links:[...U]}),D.length>0){let De=1/0,yt=1/0,ut=-1/0,pt=-1/0;for(const Wt of D){const Ft=Wt.x??0,Et=Wt.y??0;Ft<De&&(De=Ft),Et<yt&&(yt=Et),Ft>ut&&(ut=Ft),Et>pt&&(pt=Et)}const jt=100;_({x:De-jt,y:yt-jt,w:Math.max(T,ut-De+jt*2),h:Math.max(ie,pt-yt+jt*2)})}return()=>{et.stop()}},[e,m]);const L=V=>{if(typeof V=="string"){const D=x.nodes.find(B=>B.id===V);return{x:(D==null?void 0:D.x)??0,y:(D==null?void 0:D.y)??0}}return{x:V.x??0,y:V.y??0}},Y=v.useCallback(V=>{V.preventDefault();const D=V.deltaY>0?1.1:.9;_(B=>{const U=Math.max(200,Math.min(m.width*3,B.w*D)),T=Math.max(150,Math.min(m.height*3,B.h*D)),ie=(U-B.w)/2,ge=(T-B.h)/2;return{x:B.x-ie,y:B.y-ge,w:U,h:T}})},[m]),se=v.useCallback(V=>{V.button===0&&(z.current=!0,H.current={x:V.clientX,y:V.clientY,vx:N.x,vy:N.y})},[N]),ee=v.useCallback(V=>{var D;if(R.current){const B=f.current;if(!B)return;const U=B.getBoundingClientRect(),T=N.w/U.width,ie=N.h/U.height,ge=N.x+(V.clientX-U.left)*T,pe=N.y+(V.clientY-U.top)*ie;R.current.fx=ge,R.current.fy=pe,(D=I.current)==null||D.alpha(.3).restart();return}if(z.current){const B=(V.clientX-H.current.x)*(N.w/m.width),U=(V.clientY-H.current.y)*(N.h/m.height);_(T=>({...T,x:H.current.vx-B,y:H.current.vy-U}))}},[N,m]),W=v.useCallback(()=>{z.current=!1,R.current&&(R.current.fx=null,R.current.fy=null,R.current=null)},[]),oe=v.useCallback((V,D)=>{var B;V.stopPropagation(),R.current=D,(B=I.current)==null||B.alpha(.3).restart()},[]);return l.jsxs("div",{ref:d,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[l.jsxs("svg",{ref:f,width:m.width,height:m.height,viewBox:`${N.x} ${N.y} ${N.w} ${N.h}`,style:{display:"block",cursor:z.current?"grabbing":"grab"},onWheel:Y,onMouseDown:se,onMouseMove:ee,onMouseUp:W,onMouseLeave:W,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:N.x-100,y:N.y-100,width:N.w+200,height:N.h+200,fill:"url(#grid)",pointerEvents:"none"}),q==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:X.map(V=>{const D=ia[V.domain]??ia.general,B=Math.max(40,Math.sqrt(V.count)*25),T=i===null||V.nodes.some(ie=>i.has(ie.id))?1:.4;return l.jsxs("g",{transform:`translate(${V.centerX}, ${V.centerY})`,style:{cursor:"pointer",opacity:T,transition:"opacity 0.3s ease"},onMouseEnter:ie=>{var pe;const ge=(pe=d.current)==null?void 0:pe.getBoundingClientRect();ge&&C({x:ie.clientX-ge.left,y:ie.clientY-ge.top}),b({id:`cluster-${V.domain}`,title:`${V.domain} (${V.count})`,category:V.domain,akb_type:"hub"})},onMouseLeave:()=>b(null),children:[l.jsx("circle",{r:B,fill:D.bg,stroke:D.border,strokeWidth:3,opacity:.8}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:16,fontFamily:"monospace",fontWeight:"bold",style:{pointerEvents:"none"},children:V.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",V.count,")"]})]},V.domain)})}),q!=="macro"&&l.jsxs(l.Fragment,{children:[q==="standard"&&A.map(V=>{const D=ia[V.domain]??ia.general;if(V.count<2)return null;const B=i===null||V.nodes.some(T=>i.has(T.id)),U=B?.08:.04;return l.jsxs("g",{children:[l.jsx("circle",{cx:V.centerX,cy:V.centerY,r:V.radius,fill:D.bg,stroke:D.border,strokeWidth:1,strokeDasharray:"6 4",opacity:U,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:V.centerX,y:V.centerY-V.radius-8,textAnchor:"middle",fill:D.text,fontSize:12,fontFamily:"monospace",fontWeight:"600",opacity:B?.85:.5,style:{pointerEvents:"none",transition:"opacity 0.3s ease"},children:[V.domain," (",V.count,")"]})]},`cluster-bg-${V.domain}`)}),x.links.map((V,D)=>{const B=L(V.source),U=L(V.target),T=j===D,ie=(B.x+U.x)/2,ge=(B.y+U.y)/2,pe=typeof V.source=="string"?V.source:V.source.id,ze=typeof V.target=="string"?V.target:V.target.id,He=$===null||$.has(pe)&&$.has(ze)?1:.4;return l.jsxs("g",{style:{opacity:He,transition:"opacity 0.3s ease"},children:[l.jsx("line",{x1:B.x,y1:B.y,x2:U.x,y2:U.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>k(D),onMouseLeave:()=>k(null)}),l.jsx("line",{x1:B.x,y1:B.y,x2:U.x,y2:U.y,stroke:T?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.6)",strokeWidth:T?2:1.5,strokeDasharray:"4 3",pointerEvents:"none"}),T&&V.label&&l.jsx("text",{x:ie,y:ge-6,textAnchor:"middle",fill:"#e2e8f0",fontSize:9,fontFamily:"monospace",style:{pointerEvents:"none"},children:l.jsx("tspan",{style:{filter:"drop-shadow(0 0 2px rgba(0,0,0,0.8))"},children:V.label.length>30?V.label.slice(0,28)+"..":V.label})})]},D)}),x.nodes.map(V=>{const D=ia[V.category]??ia.general,B=V.akb_type==="hub",U=B?24:16,T=q==="micro"?U*1.5:U,ie=(w==null?void 0:w.id)===V.id,ge=a===V.id,pe=ie?1.1:ge?1.05:1,ze=i===null||i.has(V.id),Ie=$===null||$.has(V.id),He=ze&&Ie?1:.35,st=q==="micro"?lN(V.tldr,50):"",Pe=q==="micro"&&V.tags?V.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${V.x??0}, ${V.y??0}) scale(${pe})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:He},onClick:et=>{et.stopPropagation();const Ee=e.find(De=>De.id===V.id);Ee&&n(Ee)},onMouseDown:et=>oe(et,V),onMouseEnter:et=>{var De;b(V);const Ee=(De=d.current)==null?void 0:De.getBoundingClientRect();Ee&&C({x:et.clientX-Ee.left,y:et.clientY-Ee.top})},onMouseLeave:()=>b(null),children:[ge&&l.jsx("rect",{x:-T/2-4,y:-T/2-4,width:T+8,height:T+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:B?5:2,opacity:.6}),l.jsx("rect",{x:-T/2,y:-T/2,width:T,height:T,fill:D.border,rx:B?4:2,opacity:ie?1:.9}),l.jsx("rect",{x:-T/2+3,y:-T/2+3,width:Math.max(0,T-6),height:Math.max(0,T-6),fill:D.bg,rx:B?3:1}),l.jsx("text",{y:T/2+14,textAnchor:"middle",fill:ge?"#e2e8f0":"#94a3b8",fontSize:q==="micro"?10:11,fontFamily:"monospace",fontWeight:ge?"bold":"normal",style:{pointerEvents:"none"},children:V.title.length>24?V.title.slice(0,22)+"..":V.title}),q==="micro"&&st&&l.jsx("text",{y:T/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:8,fontFamily:"system-ui, sans-serif",opacity:.7,style:{pointerEvents:"none"},children:st}),q==="micro"&&Pe.length>0&&l.jsx("g",{transform:`translate(0, ${T/2+(st?42:28)})`,children:Pe.map((et,Ee)=>{const De=et.length*5+8;let ut=-Pe.reduce((pt,jt)=>pt+jt.length*5+10,0)/2;for(let pt=0;pt<Ee;pt++)ut+=Pe[pt].length*5+10;return l.jsxs("g",{transform:`translate(${ut+De/2}, 0)`,children:[l.jsx("rect",{x:-De/2,y:-6,width:De,height:12,fill:D.bg,stroke:D.border,strokeWidth:.5,rx:3}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:D.text,fontSize:7,fontFamily:"monospace",style:{pointerEvents:"none"},children:et})]},et)})})]},V.id)})]})]}),w&&!R.current&&l.jsxs("div",{className:"absolute z-10 pointer-events-none p-2.5 rounded text-xs max-w-[240px]",style:{left:Math.min(E.x+16,m.width-250),top:Math.max(E.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:w.title}),l.jsxs("div",{className:"text-[10px] opacity-60 mb-1",children:[w.akb_type.toUpperCase()," / ",w.category]}),w.id.startsWith("cluster-")?l.jsx("div",{className:"text-[10px] text-green-400",children:"Zoom in to see documents"}):l.jsxs(l.Fragment,{children:[((de=e.find(V=>V.id===w.id))==null?void 0:de.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(V=>V.id===w.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:q==="macro"?"#f59e0b":q==="micro"?"#22c55e":"#94a3b8",transition:"color 0.3s ease"},children:[q==="macro"&&"📍 Overview",q==="standard"&&"📍 Standard",q==="micro"&&"📍 Detail"]}),l.jsx("div",{className:"absolute bottom-3 right-3 flex gap-1 rounded overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:["global","1-hop","2-hop"].map(V=>{const D=o===V,B=V!=="global"&&!a,U=V==="global"?"🌐 All":V==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!B&&u(V),disabled:B,className:"px-2 py-1 text-[10px] font-medium cursor-pointer transition-all",style:{background:D?"rgba(22,163,106,0.3)":"transparent",color:B?"var(--terminal-text-muted)":D?"#4ade80":"var(--terminal-text-secondary)",opacity:B?.4:1,cursor:B?"not-allowed":"pointer"},title:B?"Select a node first":`Show ${V==="global"?"all nodes":`nodes within ${V}`}`,children:U},V)})}),e.length===0&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-xs",style:{color:"var(--terminal-text-muted)"},children:"No knowledge documents found"})]})}function dN(e){const n=[],a=new Map;return[...e].sort((o,u)=>o.id.localeCompare(u.id)).forEach(o=>{const u=o.id.split("/");let d=n,f="";for(let m=0;m<u.length-1;m++)if(f=f?`${f}/${u[m]}`:u[m],a.has(f))d=a.get(f).children;else{const h={type:"folder",name:u[m],path:f,children:[]};a.set(f,h),d.push(h),d=h.children}d.push({type:"file",name:u[u.length-1],path:o.id,doc:o})}),n}function fN({docs:e,onDocumentClick:n,selectedDocId:a,matchedIds:i}){const[o,u]=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(()=>dN(e),[e]),b=H=>{u(R=>{const I=new Set(R);return I.has(H)?I.delete(H):I.add(H),I})},j=H=>{f(H),n(H);const R=m.slice(0,x+1);R.push(H),R.length>10&&R.shift(),h(R),g(R.length-1)},k=()=>{f(null),n(null)},E=()=>{if(x>0){const H=x-1;g(H),f(m[H]),n(m[H])}},C=()=>{if(x<m.length-1){const H=x+1;g(H),f(m[H]),n(m[H])}},N=H=>{const R=m.indexOf(H);R!==-1&&(g(R),f(H),n(H))},_=H=>{H==="hub"&&k()},z=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(nv,{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:z?l.jsx(mN,{doc:z,onClose:k,onBreadcrumbClick:_,history:m,historyIndex:x,onHistoryBack:E,onHistoryForward:C,onHistoryJump:N,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 nv({node:e,level:n,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:f}){var b,j,k;const m=a.has(e.path),h=e.type==="file"&&e.path===i,x=e.type==="file"&&e.path===o,g=((b=e.doc)==null?void 0:b.akb_type)==="hub",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(C=>{if(C.type==="file")return f.has(C.path);const N=_=>{var z;return _.type==="file"?f.has(_.path):((z=_.children)==null?void 0:z.some(N))??!1};return N(C)}))??!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:()=>u(e.path),children:[l.jsx("span",{className:"text-[10px]",children:m?"📂":"📁"}),l.jsx("span",{className:"text-[11px]",style:{color:"var(--terminal-text)"},children:e.name})]}),m&&((k=e.children)==null?void 0:k.map(C=>l.jsx(nv,{node:C,level:n+1,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:f},C.path)))]})}return l.jsxs("div",{className:`flex items-center gap-1 py-0.5 px-1 rounded cursor-pointer transition-colors ${x?"bg-green-500/20":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 hN(e){const n=e.split(`
|
|
82
|
-
`),a=[],i=new Map;for(const o of n){const u=o.match(/^(#{2,3})\s+(.+)$/);if(!u)continue;const d=u[1].length,f=u[2].trim();let m=f.toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);const h=i.get(m)||0;i.set(m,h+1);const x=h>0?`${m}-${h}`:m;a.push({id:x,text:f,level:d})}return a}function mN({doc:e,onClose:n,onBreadcrumbClick:a,history:i,historyIndex:o,onHistoryBack:u,onHistoryForward:d,onHistoryJump:f,allDocs:m}){const[h,x]=v.useState(null),[g,w]=v.useState(!1),[b,j]=v.useState(null),k=v.useRef(null),[E,C]=v.useState(null);v.useEffect(()=>{if("content"in e&&e.content){x(e);return}w(!0),j(null),ye.getKnowledgeDoc(e.id).then(x).catch(A=>j(A instanceof Error?A.message:"Failed to load")).finally(()=>w(!1))},[e]);const N=v.useMemo(()=>!h||e.format==="html"?[]:hN(h.content),[h,e.format]),_=A=>{if(!k.current)return;const $=k.current.querySelectorAll("h2, h3");for(const L of $){const se=(L.textContent||"").toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(A.startsWith(se)){L.scrollIntoView({behavior:"smooth",block:"start"}),C(A);break}}},z=nN(e.category),H=e.akb_type==="hub",R=N.length>0&&!g&&!b,I=i.slice(0,o).reverse().filter(A=>A!==e.id).slice(0,3).map(A=>m.find($=>$.id===A)).filter(A=>A!==void 0),q=o>0,X=o<i.length-1;return l.jsxs("div",{className:"h-full flex flex-col",children:[l.jsxs("div",{className:"shrink-0 p-4",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("button",{onClick:u,disabled:!q,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:!X,className:"text-xs font-semibold cursor-pointer hover:opacity-70 disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--active-green)"},title:"Forward",children:"→"}),l.jsx("div",{className:"flex-1 flex items-center gap-1 overflow-x-auto",children:I.map(A=>l.jsxs("button",{onClick:()=>f(A.id),className:"px-2 py-0.5 rounded text-[9px] hover:opacity-70 cursor-pointer whitespace-nowrap",style:{background:"var(--hud-bg)",color:"var(--terminal-text-secondary)"},title:A.title,children:["📄 ",A.title.length>15?A.title.slice(0,15)+"...":A.title]},A.id))})]}),l.jsxs("div",{className:"flex items-center gap-1 mb-2 text-[10px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("button",{onClick:()=>a("hub"),className:"hover:underline cursor-pointer",style:{color:"var(--active-green)"},children:"Knowledge Hub"}),l.jsx("span",{children:"›"}),l.jsx("span",{style:{color:z.text},children:e.category}),l.jsx("span",{children:"›"}),l.jsx("span",{style:{color:"var(--terminal-text)"},children:e.title})]}),l.jsx("div",{className:"flex items-center gap-2 mb-2",children:l.jsxs("button",{onClick:n,className:"text-xs font-semibold cursor-pointer hover:opacity-70",style:{color:"var(--active-green)"},children:["←"," Back"]})}),l.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[l.jsx("span",{className:"text-lg",children:H?"📘":e.format==="html"?"🌐":"📄"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-bold mb-1",style:{color:"var(--terminal-text)"},children:e.title}),l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:e.status==="active"?"#16a34a":e.status==="draft"?"#f59e0b":"#94a3b8"},title:e.status}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:e.id})]}),e.tags.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:e.tags.map(A=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium",style:{background:z.bg,color:z.text,border:`1px solid ${z.border}`},children:A},A))})]})]}),e.tldr&&l.jsx("div",{className:"text-[11px] italic leading-relaxed p-2 rounded",style:{background:"var(--hud-bg)",color:"var(--terminal-text-secondary)"},children:e.tldr})]}),l.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[l.jsxs("div",{ref:k,className:"flex-1 overflow-y-auto p-4",children:[g&&l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"Loading..."}),b&&l.jsx("div",{className:"text-xs p-2 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:b}),h&&l.jsx(As,{content:h.content})]}),R&&l.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:180,background:"var(--hud-bg-alt)",borderLeft:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase mb-2",style:{color:"var(--terminal-text-muted)"},children:"Contents"}),l.jsx("div",{className:"space-y-1",children:N.map(A=>l.jsx("button",{onClick:()=>_(A.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(A.level-2)*8+8,color:E===A.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:E===A.id?"bold":"normal"},children:A.text.length>30?A.text.slice(0,28)+"..":A.text},A.id))})]})]})]})}const pN=500,Ig=360,xN=700;function Go(e,n,a){const i=n??pN,[o,u]=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(xN,i),j=g?Math.max(Ig,window.innerWidth-e-100):b,k=Math.min(o,j),E=v.useCallback(C=>{C.preventDefault(),m.current=C.clientX,h.current=k,f(!0);const N=()=>{f(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",N)},_=z=>{const H=m.current-z.clientX,R=h.current+H;if(R>=window.innerWidth*.6&&x.current){N(),x.current();return}const I=Math.min(b,Math.max(Ig,R));u(I)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",N)},[k]);return{panelRight:w,panelWidth:k,isResizing:d,handleResizeStart:E}}function Hg({docs:e,onClose:n,onRefresh:a,terminalWidth:i=0,initialDocId:o,onMaximize:u}){const[d,f]=v.useState(()=>{const A=localStorage.getItem("kb-view-mode");return A==="graph"||A==="tree"||A==="list"?A:"graph"}),[m,h]=v.useState(null),[x,g]=v.useState("global"),[w,b]=v.useState(""),[j,k]=v.useState(()=>new Set(Object.keys(ia)));v.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const E=v.useMemo(()=>new Ds(e,{keys:["title","tldr","tags"],threshold:.3,includeScore:!0}),[e]),C=v.useMemo(()=>{let A=new Set(e.map($=>$.id));if(w.trim()){const $=E.search(w);A=new Set($.map(L=>L.item.id))}return A=new Set(Array.from(A).filter($=>{const L=e.find(Y=>Y.id===$);return L&&j.has(L.category)})),A.size===e.length?null:A},[e,w,E,j]),N=v.useMemo(()=>C===null?e:e.filter(A=>C.has(A.id)),[e,C]),_=A=>{k($=>{const L=new Set($);return L.has(A)?L.delete(A):L.add(A),L})},{panelRight:z,panelWidth:H,isResizing:R,handleResizeStart:I}=Go(i,void 0,u),q=A=>{h(A.id)},X=m?e.find(A=>A.id===m):null;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:z},onClick:n}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${R?"resizing":""}`,style:{right:z,width:H,background:"var(--terminal-bg)",borderLeftColor:"#16a34a"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${R?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:I}),l.jsxs("div",{className:"p-5 text-white relative",style:{background:"#16a34a"},children:[l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1",children:[u&&l.jsx("button",{onClick:u,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-sm hover:bg-white/30 cursor-pointer",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:n,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"})]}),l.jsxs("div",{className:"text-lg font-bold",children:["📚"," Knowledge Base"]}),l.jsxs("div",{className:"text-xs opacity-80 mt-0.5",children:[e.length," documents"]})]}),l.jsxs("div",{className:"flex gap-1 p-2",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx(Eh,{icon:"🕸️",label:"Graph",active:d==="graph",onClick:()=>f("graph")}),l.jsx(Eh,{icon:"🌲",label:"Tree",active:d==="tree",onClick:()=>{f("tree"),h(null)}}),l.jsx(Eh,{icon:"📋",label:"List",active:d==="list",onClick:()=>{f("list"),h(null)}})]}),l.jsxs("div",{className:"p-3 space-y-2",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-sm",children:"🔍"}),l.jsx("input",{type:"text",value:w,onChange:A=>b(A.target.value),placeholder:"Search docs...",className:"w-full pl-8 pr-3 py-1.5 text-xs rounded focus:outline-none transition-colors",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}}),w&&l.jsx("button",{onClick:()=>b(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs hover:opacity-70",style:{color:"var(--terminal-text-muted)"},children:"✕"})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:Object.entries(ia).map(([A,$])=>{const L=j.has(A);return l.jsx("button",{onClick:()=>_(A),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:L?$.bg:"transparent",color:L?$.text:"var(--terminal-text-muted)",border:`1px solid ${L?$.border:"var(--terminal-border)"}`,opacity:L?1:.5},children:A},A)})}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:N.length===e.length?`${e.length} documents`:`${N.length} of ${e.length} documents`})]}),d==="graph"&&l.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col animate-fadeIn",children:[l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx(uN,{docs:e,onNodeClick:q,selectedDocId:m,matchedIds:C,localGraphMode:x,onLocalModeChange:g}),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:X.title}),l.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:X.status==="active"?"#16a34a":X.status==="draft"?"#f59e0b":"#94a3b8"}}),X.tldr&&l.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:X.tldr}),X.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"}),X.links.slice(0,5).map((A,$)=>l.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",A.text]},$))]})]})]}),l.jsx("div",{className:"shrink-0 p-2",style:{borderTop:"1px solid var(--terminal-border)"},children:l.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(ia).map(([A,$])=>l.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[l.jsx("div",{className:"w-2 h-2",style:{background:$.border}}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:A})]},A))})})]}),d==="tree"&&l.jsx(fN,{docs:e,onDocumentClick:A=>h(A),selectedDocId:m,matchedIds:C}),d==="list"&&l.jsx(gN,{icon:"📋",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"})]})]})}function Eh({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 gN({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 Ug({waves:e,decisions:n,mode:a,onClose:i,onOpenWaveCenter:o,onUpdateDecision:u,onDeleteDecision:d,terminalWidth:f=0,onMaximize:m}){const[h,x]=v.useState("decisions"),{panelRight:g,panelWidth:w,isResizing:b,handleResizeStart:j}=Go(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(Nh,{label:`Decisions (${n.length})`,active:h==="decisions",onClick:()=>x("decisions")}),o?l.jsx(Nh,{label:"Waves →",active:!1,onClick:o}):l.jsx(Nh,{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(yN,{decision:k,onSave:u,onDelete:d},k.id)):l.jsx("div",{className:"text-center py-10 text-sm",style:{color:"var(--terminal-text-muted)"},children:"No decisions yet"})),h==="waves"&&e.map((k,E)=>l.jsx(bN,{title:`Wave ${k.id}`,subtitle:k.startedAt,content:k.directive},E))]})]})]})}function yN({decision:e,onSave:n,onDelete:a}){const[i,o]=v.useState(!1),[u,d]=v.useState(!1),[f,m]=v.useState(e.content),[h,x]=v.useState(!1),g=rv(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:()=>{u||o(!i)},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"font-medium text-sm",style:{color:"var(--terminal-text)"},children:["#",e.id," ",e.title]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[i&&!u&&n&&l.jsx("button",{onClick:k=>{k.stopPropagation(),m(e.content),d(!0)},className:"text-[10px] px-2 py-0.5 rounded hover:bg-white/10 transition-colors",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Edit"}),l.jsx("span",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:i?"▲":"▼"})]})]}),e.date&&l.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:e.date})]}),i&&u?l.jsxs("div",{className:"px-3 pb-3 pt-2",style:{borderTop:"1px solid var(--terminal-border)"},children:[l.jsx("textarea",{value:f,onChange:k=>m(k.target.value),className:"w-full rounded-lg p-3 text-xs leading-relaxed resize-none font-mono terminal-scrollbar focus:outline-none",style:{background:"var(--terminal-inline-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",minHeight:200},rows:12}),l.jsxs("div",{className:"flex items-center justify-between mt-2",children:[l.jsx("div",{children:a&&l.jsx("button",{onClick:j,disabled:h,className:"text-[10px] px-2 py-1 rounded hover:bg-red-900/30 transition-colors disabled:opacity-40",style:{color:"#EF4444",border:"1px solid #EF444440"},children:"Delete"})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>d(!1),disabled:h,className:"text-[10px] px-3 py-1 rounded hover:bg-white/5 transition-colors disabled:opacity-40",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Cancel"}),l.jsx("button",{onClick:b,disabled:h||f===e.content,className:"text-[10px] px-3 py-1 rounded font-semibold transition-colors disabled:opacity-40",style:{background:"var(--desk-wood)",color:"#fff"},children:h?"Saving...":"Save"})]})]})]}):i?l.jsx("div",{className:"px-3 pb-3 text-xs leading-relaxed pt-2",style:{borderTop:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(As,{content:e.content})}):null,!i&&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 Nh({label:e,active:n,onClick:a}){return l.jsx("button",{onClick:a,className:"px-4 py-2.5 text-sm font-medium cursor-pointer",style:{color:n?"var(--accent)":"var(--terminal-text-muted)",borderBottom:n?"2px solid var(--accent)":"2px solid transparent"},children:e})}function rv(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 bN({title:e,subtitle:n,content:a}){const[i,o]=v.useState(!1),u=a.length>100,d=rv(a).slice(0,160);return l.jsxs("div",{className:"mb-3 rounded-lg overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"p-3 cursor-pointer hover:bg-white/5",onClick:()=>o(!i),children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"font-medium text-sm",style:{color:"var(--terminal-text)"},children:e}),l.jsx("span",{className:"text-xs shrink-0 ml-2",style:{color:"var(--terminal-text-muted)"},children:i?"▲":"▼"})]}),n&&l.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:n})]}),i&&l.jsx("div",{className:"px-3 pb-3 text-xs leading-relaxed pt-2",style:{borderTop:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(As,{content:a})}),!i&&u&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:d})]})}const js=[{id:"ch1-q1",chapter:1,title:"Hire your first employee",description:'Every company starts with its first hire. Click the HIRE button to open the recruitment panel. Choose a role name (e.g. "PM"), set a level, and bring them on board. Each role becomes an AI agent that works for your company.',type:"main",trigger:{type:"role_hired"},rewards:{coins:1e3},hint:{target:"hire-btn",message:"Click HIRE to recruit your first team member"}},{id:"ch1-q2",chapter:1,title:"Open the Terminal",description:"The Terminal is your command center — where you talk to your team. Click TERMINAL in the bottom bar to open it. You'll see a chat-like interface where you can select any role and give them instructions.",type:"main",trigger:{type:"terminal_opened"},rewards:{coins:500},hint:{target:"terminal-btn",message:"Click TERMINAL to open your command center"}},{id:"ch1-q3",chapter:1,title:"Talk to your team",description:`Use "Talk" mode to have a conversation with your team. Talk mode is for quick questions, brainstorming, and discussions — the AI role will respond with advice but won't modify any files. Select a role tab and type your message.`,type:"main",trigger:{type:"talk_mode_used"},rewards:{coins:1e3},hint:{target:"terminal-btn",message:"Open the terminal, select Talk mode, and chat"}},{id:"ch2-q1",chapter:2,title:"Create a project",description:"Projects organize your company's work. Click the Meeting Room in the office view to create one. Give it a name, description, and the system will scaffold a project folder with PRD, tasks, and design docs that your AI team will use.",type:"main",trigger:{type:"project_created"},rewards:{coins:1500},hint:{target:"meeting-room",message:"Click the Meeting Room to create a project"}},{id:"ch2-q2",chapter:2,title:"Give your first order",description:'Use "Do" mode to assign real work. Unlike Talk mode, Do mode lets roles execute tasks — they can read/write files, create documents, and run commands. Switch to Do mode in the terminal and give your team member a task.',type:"main",trigger:{type:"do_mode_used"},rewards:{badge:"first-launch",coins:2e3},hint:{target:"terminal-btn",message:"Open the terminal, switch to Do mode, and assign a task"}},{id:"ch3-q1",chapter:3,title:"Create a chat channel",description:'Chat channels let multiple roles discuss topics together — like Slack for your AI team. Click the "+" button next to channel tabs in the terminal to create a new channel. Add members and set a topic for focused collaboration.',type:"main",trigger:{type:"chat_channel_created"},rewards:{coins:1500},hint:{target:"terminal-btn",message:'Open the terminal and click "+" to create a chat channel'}},{id:"ch3-q2",chapter:3,title:"Dispatch a CEO Wave",description:"CEO Wave broadcasts a directive to your entire C-Level team at once. It's like an all-hands announcement — each C-Level role receives the wave and can delegate to their reports. Use it for company-wide initiatives, pivots, or big decisions.",type:"main",trigger:{type:"wave_dispatched"},rewards:{badge:"team-builder",coins:3e3},hint:{target:"wave-btn",message:"Click CEO WAVE to broadcast to your team"}},{id:"ch4-q1",chapter:4,title:"Hire a CTO",description:"C-Level roles are special — they can delegate work to their reports and make autonomous decisions. A CTO manages your technical team (Engineers, QA). Hire one with the C-Level tier to unlock the org hierarchy.",type:"main",trigger:{type:"role_hired",condition:{roleId:"cto"}},rewards:{coins:2e3},hint:{target:"hire-btn",message:"Hire a CTO to lead your tech team"}},{id:"ch4-q2",chapter:4,title:"Hire an Engineer",description:'Engineers are the builders. They read architecture docs, write code, and ship features. Set their "Reports To" to CTO so the org hierarchy works — when you wave, the CTO can delegate tasks down to engineers automatically.',type:"main",trigger:{type:"role_hired",condition:{roleId:"engineer"}},rewards:{coins:2500},hint:{target:"hire-btn",message:"Hire an Engineer to start building"}},{id:"ch4-q3",chapter:4,title:"Define a persona",description:"Each role has a persona — their personality, expertise, and communication style. Click a role in the office to open their panel, then edit their persona. A well-defined persona makes the AI role more consistent and specialized.",type:"main",trigger:{type:"persona_updated"},rewards:{coins:2e3},hint:{target:"terminal-btn",message:"Click a role in the office, then edit their persona"}},{id:"ch5-q1",chapter:5,title:"Explore the Knowledge Base",description:"The Knowledge Hub stores your company's documents — architecture decisions, domain knowledge, meeting notes. Your AI team reads these docs for context when working. Click the Knowledge bookshelf in the office to browse.",type:"main",trigger:{type:"knowledge_visited"},rewards:{coins:2e3},hint:{target:"knowledge-hub",message:"Click the Knowledge Hub to explore your docs"}},{id:"ch5-q2",chapter:5,title:"Check the Bulletin Board",description:"The Bulletin Board shows your company's daily standups and wave execution logs. Every time a role completes work, they post a standup. Waves show the full chain of delegation. It's your company's activity feed.",type:"main",trigger:{type:"bulletin_visited"},rewards:{badge:"scholar",coins:2e3},hint:{target:"bulletin-board",message:"Click the Bulletin Board for company updates"}},{id:"ch6-q1",chapter:6,title:"Visit the Character Store",description:"The Store has community-created characters with unique pixel art designs. Browse characters shared by other Tycono users, preview their look, and import them into your team. Open HIRE and switch to the Store tab.",type:"main",trigger:{type:"store_visited"},rewards:{coins:3e3},hint:{target:"hire-btn",message:"Open HIRE and check out the Store tab"}},{id:"ch6-q2",chapter:6,title:"Customize a character",description:"Every role has a pixel art character you can customize — change hair, skin, outfit, and accessories. Click a role in the office view to open their panel, then click the character sprite to enter the customization editor.",type:"main",trigger:{type:"accessory_changed"},rewards:{badge:"explorer",coins:5e3},hint:{target:"hire-btn",message:"Click a team member to customize their look"}},{id:"ch6-q3",chapter:6,title:"Change the office theme",description:"Your office supports multiple visual themes — each changes the color palette, mood, and atmosphere. Click the theme icon in the bottom bar to browse available themes and pick the one that matches your company's vibe.",type:"main",trigger:{type:"theme_changed"},rewards:{badge:"stylist",coins:2e3},hint:{target:"theme-btn",message:"Click the Theme button to change your office look"}},{id:"ch7-q1",chapter:7,title:"Decorate your office",description:"Enter Edit mode to rearrange your office layout. You can drag furniture, place decorations, and create different room zones. Click the EDIT button, then drag items to place them. Click DONE when finished.",type:"main",trigger:{type:"furniture_placed"},rewards:{coins:2e3},hint:{target:"edit-btn",message:"Click EDIT to enter furniture layout mode"}},{id:"ch7-q2",chapter:7,title:"Buy premium furniture",description:"Spend coins earned from quests and achievements to buy premium furniture. Enter Edit mode and browse the furniture shop — each item has a coin price. Premium items add unique visual flair to your office.",type:"main",trigger:{type:"furniture_purchased"},rewards:{badge:"interior-designer",coins:3e3},hint:{target:"edit-btn",message:"Enter EDIT mode and buy furniture with coins"}},{id:"ch8-q1",chapter:8,title:"Review company stats",description:"The Stats panel shows your company's performance metrics — token usage per role, activity levels, role leaderboard, and growth over time. Click the Stats facility in the office to see how your team is performing.",type:"main",trigger:{type:"stats_visited"},rewards:{coins:2e3},hint:{target:"stats-btn",message:"Click Stats to see your company metrics"}},{id:"ch8-q2",chapter:8,title:"Save your progress",description:"Tycono uses git to track all changes your AI team makes. Press Cmd+S (or click the save indicator) to commit your company's current state. Each save creates a git commit — you can view history and even restore previous states.",type:"main",trigger:{type:"save_committed"},rewards:{coins:2e3},hint:{target:"save-btn",message:"Press Cmd+S or click Save to commit changes"}},{id:"ch8-q3",chapter:8,title:"Open Settings",description:"The Settings panel lets you configure your company — adjust API keys, execution engine preferences, and other system options. Click the gear icon in the bottom bar to access it.",type:"main",trigger:{type:"settings_visited"},rewards:{coins:2e3},hint:{target:"settings-btn",message:"Click the Settings gear to configure your company"}},{id:"ch9-q1",chapter:9,title:"Hire a Designer",description:"A Designer handles UI/UX work — wireframes, mockups, and visual design decisions. They complement your Engineer by focusing on the user experience side. Hire one to round out your product team.",type:"main",trigger:{type:"role_hired",condition:{roleId:"designer"}},rewards:{coins:2500},hint:{target:"hire-btn",message:"Hire a Designer for your creative team"}},{id:"ch9-q2",chapter:9,title:"Hire a QA Engineer",description:"QA Engineers test your product, find bugs, and ensure quality. They review code changes, write test plans, and validate that features work as expected. Essential for any serious product team.",type:"main",trigger:{type:"role_hired",condition:{roleId:"qa"}},rewards:{coins:3e3},hint:{target:"hire-btn",message:"Hire a QA Engineer for quality assurance"}},{id:"ch9-q3",chapter:9,title:"Build a 5-person team",description:"Growing your team unlocks the full potential of delegation. With 5+ members, your C-Level roles can distribute work across specialized team members, creating a real organizational hierarchy.",type:"main",trigger:{type:"role_hired",condition:{minRoles:5}},rewards:{badge:"growing-company",coins:5e3},hint:{target:"hire-btn",message:"Keep hiring until you have 5+ team members"}},{id:"ch10-q1",chapter:10,title:"Build a 7-person team",description:"A full-size team with diverse roles means your company can handle any challenge. CEO at the top, C-Levels managing domains, and specialists executing. You've built a real AI-powered organization.",type:"main",trigger:{type:"role_hired",condition:{minRoles:7}},rewards:{badge:"tycoon-master",coins:1e4},hint:{target:"hire-btn",message:"Keep hiring until you have 7+ team members"}}],hm=[{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"]}],vN={completedQuests:[],activeChapter:1,sideQuestsCompleted:[]};function qg(){return{...vN}}function mm(e,n){return n.completedQuests.includes(e.id)?"completed":"active"}function av(e){return js.filter(n=>mm(n,e)==="active")}function wN(e){const n=av(e);return n.find(i=>i.chapter===e.activeChapter)??n[0]??null}function kN(e,n){const a=js.find(o=>o.id===n);return a?e.completedQuests.includes(n)?{progress:e,quest:null}:{progress:{...e,completedQuests:[...e.completedQuests,n],firstCompletedAt:e.firstCompletedAt??new Date().toISOString()},quest:a}:{progress:e,quest:null}}function Yg(e){let n=1;for(const a of hm)if(a.questIds.every(i=>e.completedQuests.includes(i))){const i=hm.find(o=>o.num===a.num+1);i&&(n=i.num)}return n!==e.activeChapter?{...e,activeChapter:n}:e}function jN(e){const n=js.filter(i=>i.type==="main").length;return{completed:e.completedQuests.filter(i=>{var o;return((o=js.find(u=>u.id===i))==null?void 0:o.type)==="main"}).length,total:n}}function SN(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 CN({progress:e,onQuestAction:n,onClose:a,terminalWidth:i=0}){const{completed:o,total:u}=jN(e),d=u>0?Math.round(o/u*100):0,{panelRight:f,panelWidth:m,isResizing:h,handleResizeStart:x}=Go(i);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:f},onClick:a}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${h?"resizing":""}`,style:{right:f,width:m,background:"var(--terminal-bg)",borderLeftColor:"var(--desk-wood)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${h?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:x}),l.jsxs("div",{className:"p-5 text-white relative",style:{background:"linear-gradient(135deg, #8B5E3C, #6B4226)"},children:[l.jsx("button",{onClick:a,className:"absolute top-3 right-3 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xl",children:"🐾"}),l.jsxs("div",{children:[l.jsx("div",{className:"text-lg font-bold",children:"Pupu's Quest Board"}),l.jsxs("div",{className:"text-xs opacity-70 mt-0.5",children:[o,"/",u," quests completed · ",d,"%"]})]})]}),l.jsx("div",{className:"mt-3",children:l.jsx("div",{className:"h-2 rounded-full overflow-hidden bg-white/15",children:l.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${d}%`,background:"#F4D03F"}})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-5 flex flex-col gap-3",children:hm.map(g=>{const w=js.filter(k=>g.questIds.includes(k.id)),b=w.every(k=>e.completedQuests.includes(k.id)),j=w.some(k=>mm(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=mm(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 EN({projectId:e,onClose:n,terminalWidth:a=0}){const[i,o]=v.useState(null),{panelRight:u,panelWidth:d,isResizing:f,handleResizeStart:m}=Go(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:u},onClick:n}),l.jsx("div",{className:"side-panel open fixed top-0 h-full z-50 flex items-center justify-center border-l-[3px] border-[var(--meeting-blue)]",style:{right:u,width:d,background:"var(--terminal-bg)"},children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading project..."})})]});const h=i.tasks.filter(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:u},onClick:n}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] border-[var(--meeting-blue)] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${f?"resizing":""}`,style:{right:u,width:d,background:"var(--terminal-bg)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${f?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:m}),l.jsxs("div",{className:"p-5 bg-[var(--meeting-blue)] text-white relative",children:[l.jsx("div",{className:"text-sm opacity-70",children:"Meeting Room"}),l.jsx("button",{onClick:n,className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),l.jsx("div",{className:"text-xl font-bold mt-1",children:i.name}),l.jsxs("div",{className:"flex items-center gap-3 mt-3 text-sm",children:[l.jsxs("span",{children:["Tasks: ",x]}),l.jsxs("span",{children:["Done: ",h]}),l.jsxs("span",{children:["Progress: ",g,"%"]})]}),l.jsx("div",{className:"mt-2 h-1.5 bg-white/20 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-white rounded-full transition-all",style:{width:`${g}%`}})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[i.prd&&l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"PRD"}),l.jsx("div",{className:"rounded-lg p-4 text-xs leading-relaxed max-h-60 overflow-y-auto",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(As,{content:i.prd})})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:["Tasks (",x,")"]}),l.jsx("div",{className:"space-y-2",children:i.tasks.map(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(NN,{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 NN({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 AN={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function DN({roleId:e,roleName:n,mode:a="assign",onClose:i,onExecutionStart:o}){const[u,d]=v.useState(""),f=v.useRef(null);v.useEffect(()=>{var g;(g=f.current)==null||g.focus()},[]);const m=()=>{u.trim()&&(o(e,u.trim()),i())},h=g=>{g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&m(),g.key==="Escape"&&i()},x=AN[e]??"#666";return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:`linear-gradient(135deg, ${x}, ${x}cc)`},children:[l.jsx("div",{className:"text-lg font-bold",children:a==="ask"?"Ask":"Assign Task"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:a==="ask"?`to ${n}`:`to ${n} (${e})`})]}),l.jsxs("div",{className:"p-5",children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Task Description"}),l.jsx("textarea",{ref:f,value:u,onChange:g=>d(g.target.value),onKeyDown:h,placeholder:a==="ask"?"What would you like to ask?":"Describe the task...",className:"w-full h-32 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-white/30 mt-1",children:"Cmd+Enter to submit"})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:m,disabled:!u.trim(),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:x},children:a==="ask"?"Ask":"Assign"})]})]})]})}const Xg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function Vm({event:e,isThinkingCollapsed:n,onToggleThinking:a,onNavigateToJob:i,onOpenKnowledgeDoc:o,compact:u}){var f;const d=Xg[e.roleId]??"#888";switch(e.type){case"text":{const m=e.data.text??"",h=u?m.slice(0,300):m;return/[#*|`\[\]_~>-]/.test(h)?l.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:l.jsx(Om,{remarkPlugins:[Hm],children:h})}):l.jsx("div",{className:"text-green-300/90 whitespace-pre-wrap leading-relaxed",children:h})}case"thinking":{const m=e.data.text??"";return l.jsxs("div",{className:"group",children:[l.jsxs("button",{onClick:a,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-[10px] cursor-pointer flex items-center gap-1 select-text",children:[l.jsx("span",{children:n?"▶":"▼"}),l.jsx("span",{className:"italic",children:"thinking..."})]}),!n&&l.jsxs("div",{className:`ml-3 text-[var(--terminal-text-muted)] italic whitespace-pre-wrap opacity-60 text-[11px] overflow-hidden ${u?"max-h-[60px]":"max-h-[120px]"}`,children:[m.slice(0,u?200:500),m.length>(u?200:500)?"...":""]})]})}case"tool:start":{const m=String(e.data.name??""),h=e.data.input,x=typeof(h==null?void 0:h.command)=="string"?h.command.slice(0,80):"",g=typeof(h==null?void 0:h.file_path)=="string"?String(h.file_path):typeof(h==null?void 0:h.path)=="string"?String(h.path):"",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:u?200:400},children:w}):l.jsxs(l.Fragment,{children:[x&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:x}),w&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"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.childJobId,g=Xg[m]??"#888";return l.jsx("div",{className:"my-1 p-2 rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",style:{borderColor:`${g}44`,background:`${g}11`},onClick:()=>x&&(i==null?void 0:i(x)),children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{style:{color:g},className:"font-bold text-[11px]",children:["→"," ",m.toUpperCase()]}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] text-[10px] truncate flex-1",children:h.slice(0,u?60:100)}),x&&i&&l.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/10 text-[var(--terminal-text-muted)]",children:["View ","→"]})]})})}case"dispatch:done":return l.jsx("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pl-3 border-l-2 border-[var(--terminal-border)] my-0.5",children:"Dispatch completed"});case"turn:complete":return l.jsx("div",{className:"border-t border-[var(--terminal-border)] my-2 relative",children:l.jsxs("span",{className:"absolute -top-2 left-2 bg-[var(--terminal-bg)] px-2 text-[9px] text-[var(--terminal-text-muted)]",children:["Turn ",e.data.turn]})});case"stderr":return l.jsxs("div",{className:"text-red-400/80 text-[11px]",children:["⚠"," ",e.data.message]});case"job:start":return l.jsxs("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pb-1",children:[l.jsx("span",{style:{color:d},className:"font-bold",children:e.roleId.toUpperCase()})," ","started: ",(e.data.task??"").slice(0,u?50:80)]});case"job:done":{const m=e.data.turns??0,h=e.data.toolCalls??0;return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-green-900/20 border border-green-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"}),l.jsx("span",{className:"text-green-300 font-bold text-[11px]",children:"Complete"}),l.jsxs("span",{className:"text-[var(--terminal-text-muted)] text-[10px]",children:[m," turns · ",h," tools"]})]})})}case"job:error":return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-red-900/20 border border-red-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400"}),l.jsx("span",{className:"text-red-300 font-bold text-[11px]",children:"Error"}),l.jsx("span",{className:"text-red-200/70 text-[10px]",children:e.data.message})]})});case"job:awaiting_input":{const m=e.data.question??"";return l.jsxs("div",{className:"mt-2 p-2 rounded-lg border",style:{background:"#F59E0B11",borderColor:"#F59E0B33"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsx("span",{className:"font-bold text-[11px]",style:{color:"#F59E0B"},children:"Awaiting Reply"})]}),m&&l.jsx("div",{className:"mt-1 text-[11px] text-[var(--terminal-text)] whitespace-pre-wrap",children:m})]})}case"job:reply":return l.jsx("div",{className:"mt-1 p-2 rounded-lg bg-blue-900/20 border border-blue-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-blue-300 font-bold text-[11px]",children:"CEO replied:"}),l.jsx("span",{className:"text-blue-200/80 text-[11px]",children:e.data.response??""})]})});case"import:scan":case"import:process":case"import:created":return l.jsxs("div",{className:"text-cyan-300/70 text-[11px]",children:["[",e.type,"] ",JSON.stringify(e.data)]});default:return null}}function TN({sessionId:e,title:n,color:a,variant:i,style:o,onClose:u,onMinimize:d,onDone:f,onNavigateToJob:m,onOpenKnowledgeDoc:h}){const{events:x,status:g,textOutput:w,childJobIds:b}=Ny(e),[j,k]=v.useState(0),[E,C]=v.useState(new Set),N=v.useRef(null),_=v.useRef(Date.now()),z=v.useRef(!1);v.useEffect(()=>{const $=setInterval(()=>{k(Math.floor((Date.now()-_.current)/1e3))},1e3);return()=>clearInterval($)},[]),v.useEffect(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)},[x]),v.useEffect(()=>{(g==="done"||g==="error")&&!z.current&&(z.current=!0,f==null||f())},[g,f]);const H=$=>{C(L=>{const Y=new Set(L);return Y.has($)?Y.delete($):Y.add($),Y})},R={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[g],I={idle:"#888",connecting:"#888",streaming:a,done:"#2E7D32",error:"#C62828"}[g],q=$=>`${Math.floor($/60)}:${String($%60).padStart(2,"0")}`,X=g==="done"||g==="error",A=l.jsxs("div",{className:i==="modal"?"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col":"bg-[var(--terminal-bg)] rounded-xl border border-[var(--terminal-border)] overflow-hidden flex flex-col max-h-[400px]",style:o,children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full animate-pulse",style:{background: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:q(j)}),l.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${I}22`,color:I},children:R}),d&&i==="modal"&&l.jsx("button",{onClick:d,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),X&&l.jsx("button",{onClick:u,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",children:"×"})]})]}),l.jsxs("div",{ref:N,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(Vm,{event:$,isThinkingCollapsed:E.has($.seq),onToggleThinking:()=>H($.seq),onNavigateToJob: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:u,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer",style:{background:a},children:"Close"})]})]});return i==="modal"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:X?u:void 0}),A]}):A}const FN={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function MN({orgNodes:e,rootId:n,activeRoles:a,onToggleRole:i}){const o=e[n];if(!o)return null;const u=!!a&&!!i,f=o.children.map(b=>e[b]).filter(Boolean),m=new Map,h=[];for(const b of f){const j=[];for(const k of b.children){const E=e[k];E&&(j.push(E),h.push(E))}m.set(b.id,j)}const x=b=>!a||a.has(b),g=u?f.filter(b=>a.has(b.id)).length+h.filter(b=>a.has(b.id)).length:f.length+h.length,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:u?"Select Target Roles":"Propagation Preview"}),u&&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=FN[b.id]??"#888";return l.jsx(RN,{node:b,active:j,color:k,interactive:u,onToggle:i,subRoles:m.get(b.id)??[],activeRoles:a},b.id)})}),h.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-2 bg-white/10"})}),l.jsx("div",{className:"flex justify-center gap-2 flex-wrap",children:h.map(b=>{var N;const j=x(b.id),k=(N=f.find(_=>_.children.includes(b.id)))==null?void 0:N.id,E=k?x(k):!0,C=u&&E;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${C?"cursor-pointer select-none":u?"cursor-not-allowed":""} ${j&&E?"border-white/15 text-white/40":"border-white/5 text-white/15 opacity-50"}`,onClick:C?()=>i(b.id,!j):void 0,title:u?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:u?`${g} role${g!==1?"s":""} will receive this wave`:`${w} role${w!==1?"s":""} will receive this wave`})]})}function RN({node:e,active:n,color:a,interactive:i,onToggle:o,subRoles:u,activeRoles:d}){const f=v.useCallback(m=>{if(!(!i||!o)){if(n){o(e.id,!1);for(const h of u)d!=null&&d.has(h.id)&&o(h.id,!1)}else if(o(e.id,!0),m.shiftKey)for(const h of u)d!=null&&d.has(h.id)||o(h.id,!0)}},[i,o,n,e.id,u,d]);return l.jsxs("div",{className:"flex flex-col items-center",children:[l.jsx("span",{className:`px-2.5 py-1 text-[10px] font-bold rounded border-2 uppercase transition-all ${i?"cursor-pointer select-none hover:scale-105":""}`,style:{borderColor:n?a:`${a}44`,color:n?a:`${a}44`,background:n?`${a}22`:"transparent",opacity:n?1:.4},onClick:f,title:i?n?"Click to exclude (disables subordinates)":"Click to include / Shift+click to include with all subordinates":void 0,children:e.id}),l.jsx("span",{className:"text-[8px] text-white/30 mt-0.5",children:i?n?"active":"off":"direct"})]})}function zN({cLevelRoles:e,orgNodes:n,rootId:a,onClose:i,onDispatch:o}){const[u,d]=v.useState(""),f=v.useRef(null),[m,h]=v.useState(()=>{const k=new Set,E=n[a];if(E)for(const C of E.children){k.add(C);const N=n[C];if(N)for(const _ of N.children)k.add(_)}return k});v.useEffect(()=>{var k;(k=f.current)==null||k.focus()},[]);const x=v.useCallback((k,E)=>{h(C=>{const N=new Set(C);return E?N.add(k):N.delete(k),N})},[]),g=e.filter(k=>m.has(k.id)).length,w=()=>{if(!u.trim()||g===0)return;const k=n[a];let E=0;if(k)for(const _ of k.children){E++;const z=n[_];z&&(E+=z.children.length)}const N=m.size>=E?void 0:Array.from(m);o(u.trim(),N),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(MN,{orgNodes:n,rootId:a,activeRoles:m,onToggleRole:x}),!j&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Dispatching to"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:e.length>0?e.map(k=>l.jsxs("span",{className:"px-3 py-1.5 text-xs font-semibold rounded-lg border-2 border-red-200 bg-red-50 text-red-800",children:[k.id.toUpperCase()," · ",k.name]},k.id)):l.jsx("span",{className:"text-xs text-gray-400 italic",children:"No C-Level roles found"})}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Each C-Level receives the directive and delegates to their reports"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Directive"}),l.jsx("textarea",{ref:f,value:u,onChange:k=>d(k.target.value),onKeyDown:b,placeholder:"e.g. Report current status across all departments",className:"w-full h-28 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Cmd+Enter to dispatch"})]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),l.jsxs("button",{onClick:w,disabled:!u.trim()||g===0,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:["Dispatch to ",g," Role",g!==1?"s":""]})]})]})]})}function _N(){const e=v.useRef(null),n=v.useRef(0),a=v.useCallback((o,u,d)=>{e.current&&e.current.abort();const f=new AbortController;e.current=f,n.current=0;const h=`/api/waves/${o}/stream?from=0`;fetch(h,{signal:f.signal}).then(async x=>{if(!x.ok||!x.body){console.error(`[WaveStream] Failed to connect: ${x.status}`);return}console.log(`[WaveStream] Connected to wave=${o}`);const g=x.body.getReader(),w=new TextDecoder;let b="",j="",k=Date.now();const E=6e4,C=setInterval(()=>{Date.now()-k>E&&(console.warn("[WaveStream] Stale connection — no data for 60s"),f.abort(),clearInterval(C))},1e4);try{for(;;){const{done:N,value:_}=await g.read();if(N)break;k=Date.now(),b+=w.decode(_,{stream:!0});const z=b.split(`
|
|
83
|
-
`);b=z.pop()??"";for(const H of z)if(H.startsWith("event: "))j=H.slice(7).trim();else if(H.startsWith("data: ")){try{const R=JSON.parse(H.slice(6));BN(j,R,u,d)}catch{}j=""}}}finally{clearInterval(C)}}).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 BN(e,n,a,i){switch(e){case"wave:event":ON(n,a);break;case"wave:role-attached":$N(n,a,i);break;case"wave:role-detached":LN(n,a);break;case"wave:done":IN(a);break}}function ON(e,n){const{event:a,sessionId:i}=e,{roleId:o}=a;n(u=>{const d=new Map(u),f=d.get(o);if(!f||f.events.some(h=>h.seq===a.seq&&h.roleId===a.roleId))return u;const m={...f,sessionId:i||f.sessionId,events:[...f.events,a]};return a.type==="job:start"?(m.status="running",m.streamStatus="streaming"):a.type==="job:done"?(m.status="done",m.streamStatus="done"):a.type==="job:error"?(m.status="error",m.streamStatus="error"):a.type==="job:awaiting_input"?(m.status="awaiting_input",m.streamStatus="done"):a.type==="job:reply"&&(m.status="running",m.streamStatus="streaming"),d.set(o,m),d})}function $N(e,n,a){const{sessionId:i,roleId:o}=e;n(u=>{const d=new Map(u),f=d.get(o);if(f)d.set(o,{...f,sessionId:i,status:"running",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:"running",events:[],streamStatus:"streaming"})}return d})}function LN(e,n){const{roleId:a,reason:i}=e,o=i==="error"?"error":"done";n(u=>{const d=new Map(u),f=d.get(a);return!f||f.status==="done"||f.status==="error"?u:(d.set(a,{...f,status:o,streamStatus:o==="error"?"error":"done"}),d)})}function IN(e){e(n=>{const a=new Map(n);let i=!1;for(const[o,u]of a)u.status==="waiting"&&(a.set(o,{...u,status:"not-dispatched"}),i=!0);return i?a:n})}function lv(e,n,a,i){const[o,u]=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}=_N(),k=v.useCallback(()=>{if(!a||Object.keys(n).length===0)return null;const q=new Map,X=new Set,A=L=>{const Y=n[L];Y&&(X.add(L),q.set(L,{sessionId:"",roleId:L,roleName:Y.name,children:Y.children,status:"waiting",events:[],streamStatus:"idle"}),Y.children.forEach(A))},$=n[a];return $&&(q.set(a,{sessionId:"",roleId:a,roleName:"CEO",children:$.children,status:"not-dispatched",events:[],streamStatus:"idle"}),$.children.forEach(A)),{initial:q,allRoles:X}},[n,a]);v.useEffect(()=>{if(w.current)if(e.length>0)w.current=!1;else return;const q=k();if(!q)return;const{initial:X,allRoles:A}=q;for(const $ of e){const L=X.get($.roleId);L&&(L.sessionId=$.sessionId,L.status="running",L.streamStatus="connecting")}u(X),h($=>{if($.size===0){const L=new Set(A);return L.delete(a),L}return $}),e.length>0&&f($=>$??e[0].roleId)},[e,n,a,k]);const E=v.useCallback(q=>{h(X=>{const A=new Set(X);return A.has(q)?A.delete(q):A.add(q),A})},[]),C=v.useCallback(q=>{for(const[,X]of x.current)X.controller.abort();x.current.clear(),w.current=!0,u(q);for(const[X,A]of q)if(X!==a&&A.events.length>0){f(X);break}},[a]),N=v.useCallback((q,X)=>{const A=x.current.get(q);if(A&&!A.controller.signal.aborted){console.log(`[WaveTree] connectStream SKIP (already connected) → role=${X} session=${q}`);return}A&&A.controller.abort(),console.log(`[WaveTree] connectStream → role=${X} session=${q}`),u(se=>{const ee=new Map(se),W=ee.get(X);return W&&ee.set(X,{...W,sessionId:q,status:"running",streamStatus:"connecting",events:[]}),ee});const $=new AbortController,L={controller:$,lastSeq:-1};x.current.set(q,L);const Y=`/api/sessions/${q}/stream?from=0`;fetch(Y,{signal:$.signal}).then(async se=>{if(!se.ok||!se.body){u(V=>{const D=new Map(V),B=D.get(X);return B&&D.set(X,{...B,streamStatus:"error"}),D});return}console.log(`[WaveTree SSE] connected → role=${X} status=${se.status}`),u(V=>{const D=new Map(V),B=D.get(X);return B&&D.set(X,{...B,streamStatus:"streaming",status:"running"}),D});const ee=se.body.getReader(),W=new TextDecoder;let oe="",de="";for(;;){const{done:V,value:D}=await ee.read();if(V)break;oe+=W.decode(D,{stream:!0});const B=oe.split(`
|
|
84
|
-
`);oe=B.pop()??"";for(const U of B)if(U.startsWith("event: "))de=U.slice(7).trim();else if(U.startsWith("data: ")){try{const T=JSON.parse(U.slice(6));if(console.log(`[WaveTree SSE] role=${X} event=${de} type=${(T==null?void 0:T.type)??"?"} seq=${(T==null?void 0:T.seq)??"?"}`),de==="activity"){const ie=T;ie.seq>L.lastSeq&&(L.lastSeq=ie.seq),u(ge=>{const pe=new Map(ge),ze=pe.get(X);if(!ze||ze.events.some(He=>He.seq===ie.seq))return ge;const Ie={...ze,events:[...ze.events,ie]};if(ie.type==="dispatch:start"&&ie.data.childJobId){const He=ie.data.targetRoleId??ie.data.roleId,st=ie.data.childSessionId;if(console.log(`[WaveTree] dispatch:start → target=${He} childSession=${st??"none"} from=${X}`),He&&st){const Pe=pe.get(He);Pe&&(pe.set(He,{...Pe,sessionId:st,status:"running",streamStatus:"connecting"}),setTimeout(()=>N(st,He),0))}}return ie.type==="job:done"?(Ie.status="done",Ie.streamStatus="done"):ie.type==="job:error"?(Ie.status="error",Ie.streamStatus="error"):ie.type==="job:awaiting_input"?(Ie.status="awaiting_input",Ie.streamStatus="done"):ie.type==="job:reply"&&(Ie.status="running",Ie.streamStatus="streaming"),pe.set(X,Ie),pe})}else if(de==="stream:end"){const ie=T.reason;ie!=="replied"&&u(ge=>{const pe=new Map(ge),ze=pe.get(X);if(!ze)return ge;const Ie=ie==="error"?"error":ie==="awaiting_input"?"awaiting_input":"done";return pe.set(X,{...ze,status:ze.status==="running"?Ie:ze.status,streamStatus:Ie==="error"?"error":"done"}),pe})}}catch{}de=""}}}).catch(se=>{se.name!=="AbortError"&&u(ee=>{const W=new Map(ee),oe=W.get(X);return oe&&W.set(X,{...oe,streamStatus:"error"}),W})})},[]),_=v.useRef(new Set),z=v.useRef(!1);v.useEffect(()=>{if(e.length===0)return;if(i)return z.current=!0,b(i,u,n),()=>{j(),z.current=!1};z.current=!1;const q=new Set;for(const X of e)q.add(X.sessionId),N(X.sessionId,X.roleId);return _.current=q,()=>{for(const X of _.current){const A=x.current.get(X);A&&(A.controller.abort(),x.current.delete(X))}_.current.clear()}},[e,N,i,b,j,n]);const H=(()=>{let q=0,X=0,A=0,$=0;for(const[L,Y]of o)L!==a&&($++,Y.status==="done"?q++:Y.status==="running"?X++:Y.status==="awaiting_input"&&A++);return{done:q,total:$,running:X,awaitingInput:A}})(),R=H.total>0&&H.running===0&&H.awaitingInput===0&&Array.from(o.values()).every(q=>q.status!=="running"&&q.status!=="awaiting_input"&&q.streamStatus!=="streaming"&&q.streamStatus!=="connecting");v.useEffect(()=>{R&&u(q=>{const X=new Map(q);let A=!1;for(const[$,L]of X)L.status==="waiting"&&(X.set($,{...L,status:"not-dispatched"}),A=!0);return A?X:q})},[R]);const I=v.useCallback(()=>{for(const[,X]of x.current)X.controller.abort();x.current.clear(),w.current=!1;const q=k();if(q){u(q.initial);const X=new Set(q.allRoles);X.delete(a),h(X)}f(a)},[k,a]);return{nodes:o,selectedRoleId:d,selectNode:f,checkedRoles:m,toggleCheck:E,setCheckedRoles:h,progress:H,allDone:R,connectStream:N,injectStaticNodes:C,reset:I}}const Wg={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},ja=130,Gr=44,Gg=80;function HN(e,n){if(!e.get(n))return{layout:[],width:300,height:200};const i=[],o=[],u=[{id:n,depth:0,parentId:null}],d=new Set;for(;u.length>0;){const{id:x,depth:g,parentId:w}=u.shift();if(d.has(x))continue;for(d.add(x);o.length<=g;)o.push([]);o[g].push(x),i.push({roleId:x,x:0,y:g*Gg+20,parentId:w});const b=e.get(x);if(b)for(const j of b.children)e.has(j)&&!d.has(j)&&u.push({id:j,depth:g+1,parentId:x})}const f=Math.max(...o.map(x=>x.length))*(ja+16),m=Math.max(f,280);for(const x of o){const g=x.length*(ja+16)-16,w=(m-g)/2;x.forEach((b,j)=>{const k=i.find(E=>E.roleId===b);k&&(k.x=w+j*(ja+16))})}const h=o.length*Gg+40;return{layout:i,width:m,height:h}}function iv({nodes:e,rootId:n,selectedRoleId:a,onSelectNode:i,checkedRoles:o,onToggleCheck:u,eligibleRoles:d}){const{layout:f,width:m,height:h}=HN(e,n),x=!!u,g=b=>{const j=f.find(k=>k.roleId===b);return j?{cx:j.x+ja/2,cy:j.y+Gr/2}:{cx:0,cy:0}},w=b=>{switch(b.status){case"running":return Wg[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),C=e.get(b.parentId);let N="rgba(180,200,240,0.15)",_="4 4",z="";return(E==null?void 0:E.status)==="done"||(C==null?void 0:C.status)==="done"?(N="#2E7D3266",_=""):(E==null?void 0:E.status)==="awaiting_input"?(N="#F59E0B",_="6 4",z="wave-edge-flow"):(E==null?void 0:E.status)==="running"&&(N=Wg[b.roleId]??"#FBBF24",_="6 4",z="wave-edge-flow"),l.jsx("line",{x1:j.cx,y1:j.cy+Gr/2-4,x2:k.cx,y2:k.cy-Gr/2+4,stroke:N,strokeWidth:1.5,strokeDasharray:_,className:z},`${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,C=b.roleId===n,N=(o==null?void 0:o.has(b.roleId))??!1,_=C?E?.7:.5:j.status==="not-dispatched"&&!N?.35:1;return l.jsxs("g",{transform:`translate(${b.x}, ${b.y})`,style:{cursor:"pointer",opacity:_},onClick:()=>i(b.roleId),children:[l.jsx("rect",{x:0,y:0,width:ja,height:Gr,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:E?"#fff":N?"#EF5350":k,strokeWidth:E||N?2:1.5,strokeDasharray:j.status==="not-dispatched"&&!N?"4 3":""}),l.jsx("circle",{cx:14,cy:Gr/2,r:4,fill:k,filter:j.status==="running"||j.status==="awaiting_input"?"url(#glow)":void 0,children:(j.status==="running"||j.status==="awaiting_input")&&l.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),l.jsx("text",{x:26,y:Gr/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:Gr/2+10,fill:"var(--terminal-text-muted, #888)",fontSize:8,fontFamily:"var(--pixel-font)",children:j.status==="running"?"Working...":j.status==="awaiting_input"?"Awaiting Reply":j.status==="done"?"Complete":j.status==="error"?"Error":j.status==="waiting"?"Waiting":""}),j.status==="done"&&!x&&l.jsx("text",{x:ja-18,y:Gr/2+4,fontSize:14,fill:"#2E7D32",children:"✓"}),j.status==="error"&&!x&&l.jsx("text",{x:ja-18,y:Gr/2+4,fontSize:14,fill:"#C62828",children:"✗"}),x&&!C&&(()=>{const z=!d||d.has(b.roleId);return l.jsxs("g",{onClick:H=>{H.stopPropagation(),z&&(u==null||u(b.roleId))},style:{cursor:z?"pointer":"default",opacity:z?1:.2},children:[l.jsx("rect",{x:ja-24,y:Gr/2-10,width:20,height:20,fill:"transparent"}),l.jsx("rect",{x:ja-20,y:Gr/2-6,width:12,height:12,rx:2,ry:2,fill:N?"#EF5350":"transparent",stroke:N?"#EF5350":"#666",strokeWidth:1.5}),N&&l.jsx("text",{x:ja-18,y:Gr/2+4,fontSize:10,fontWeight:700,fill:"#fff",children:"✓"})]})})()]},b.roleId)})]})}const UN={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function qN({directive:e,rootJobs:n,orgNodes:a,rootRoleId:i,waveId:o,onClose:u,onMinimize:d,onDone:f,onOpenKnowledgeDoc:m,onSave:h}){const{nodes:x,selectedRoleId:g,selectNode:w,progress:b,allDone:j,connectStream:k}=lv(n,a,i,o),[E,C]=v.useState(0),[N,_]=v.useState(new Set),[z,H]=v.useState(""),[R,I]=v.useState(!1),[q,X]=v.useState(!1),A=v.useRef(null),$=v.useRef(Date.now()),L=v.useRef(!1),Y=v.useCallback(async()=>{if(h){X(!0);try{const U=n.map(T=>T.jobId).filter(T=>!!T);await h(U)}catch(U){console.error("Save failed:",U)}finally{X(!1),u()}}},[h,n,u]),se=v.useCallback(async()=>{if(!g||!z.trim())return;const U=x.get(g);if(!(!(U!=null&&U.sessionId)||U.status!=="awaiting_input"&&U.status!=="done")){I(!0);try{await ye.replyToSession(U.sessionId,z.trim()),H(""),k(U.sessionId,g)}catch(T){console.error("Reply failed:",T)}finally{I(!1)}}},[g,z,x,k]),ee=v.useCallback(async U=>{const T=x.get(U);if(T!=null&&T.sessionId)try{await ye.abortSession(T.sessionId)}catch(ie){console.error("Abort failed:",ie)}},[x]),W=v.useCallback(async()=>{for(const[,U]of x)if((U.status==="running"||U.status==="awaiting_input")&&U.sessionId)try{await ye.abortSession(U.sessionId)}catch{}},[x]);v.useEffect(()=>{const U=setInterval(()=>{C(Math.floor((Date.now()-$.current)/1e3))},1e3);return()=>clearInterval(U)},[]);const oe=v.useRef(!1);v.useEffect(()=>{const U=A.current;if(!U)return;const T=()=>{const ie=U.scrollHeight-U.scrollTop-U.clientHeight<60;oe.current=!ie};return U.addEventListener("scroll",T),()=>U.removeEventListener("scroll",T)},[]),v.useEffect(()=>{oe.current=!1,A.current&&(A.current.scrollTop=A.current.scrollHeight)},[g]),v.useEffect(()=>{A.current&&!oe.current&&(A.current.scrollTop=A.current.scrollHeight)},[x]),v.useEffect(()=>{j&&!L.current&&(L.current=!0,f==null||f()),!j&&L.current&&(L.current=!1)},[j,f]);const de=U=>`${Math.floor(U/60)}:${String(U%60).padStart(2,"0")}`,V=g?x.get(g):null,D=g?UN[g]??"#888":"#888",B=U=>{_(T=>{const ie=new Set(T);return ie.has(U)?ie.delete(U):ie.add(U),ie})};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:W,className:"text-xs px-2 py-0.5 rounded font-semibold cursor-pointer",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Stop all running jobs",children:"Stop All"}),l.jsx("button",{onClick:d,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),l.jsx("button",{onClick:u,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",title:j?"Dismiss wave":"Close (jobs keep running)",children:"×"})]})]}),l.jsx("div",{className:"px-5 py-2 border-b border-[var(--terminal-border)] shrink-0",children:l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic",children:["“",e,"”"]})}),l.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[l.jsxs("div",{className:"shrink-0 border-b border-[var(--terminal-border)] flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",children:[l.jsx("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:"Org Propagation"}),l.jsx("div",{className:"flex gap-x-3 ml-auto",children:[{label:"running",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(U=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:U.color,animation:U.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:U.label})]},U.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"35vh"},children:l.jsx(iv,{nodes:x,rootId:i,selectedRoleId:g,onSelectNode:w})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[V&&l.jsxs("div",{className:"px-4 py-2 border-b border-[var(--terminal-border)] shrink-0 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:D}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:V.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:V.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:V.status==="awaiting_input"?"#F59E0B22":`${D}22`,color:V.status==="awaiting_input"?"#F59E0B":D},children:V.status==="running"?"Working":V.status==="done"?"Complete":V.status==="error"?"Error":V.status==="waiting"?"Waiting":V.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(V.status==="running"||V.status==="awaiting_input")&&V.sessionId&&l.jsx("button",{onClick:()=>ee(V.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Force stop this job",children:"Stop"})]}),l.jsxs("div",{ref:A,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[V&&V.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:V.status==="waiting"?"Waiting for dispatch...":V.status==="running"?"Connecting to activity stream...":V.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),V==null?void 0:V.events.map(U=>l.jsx(Vm,{event:U,isThinkingCollapsed:N.has(U.seq),onToggleThinking:()=>B(U.seq),onNavigateToJob:T=>{const ie=V==null?void 0:V.events.find(pe=>pe.type==="dispatch:start"&&pe.data.childJobId===T),ge=ie==null?void 0:ie.data.targetRoleId;ge&&x.has(ge)&&w(ge)},onOpenKnowledgeDoc:m},U.seq)),(V==null?void 0:V.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(V==null?void 0:V.status)==="awaiting_input"&&l.jsxs("div",{className:"px-4 py-3 border-t border-[var(--terminal-border)] shrink-0",style:{background:"#F59E0B0A"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#F59E0B"},children:[V.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:z,onChange:U=>H(U.target.value),onKeyDown:U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),se())},placeholder:"Type your response...",disabled:R,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#F59E0B]",autoFocus:!0}),l.jsx("button",{onClick:se,disabled:R||!z.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#F59E0B",color:"#000"},children:R?"...":"Reply"})]})]}),(V==null?void 0:V.status)==="done"&&V.sessionId&&l.jsxs("div",{className:"px-4 py-3 border-t border-[var(--terminal-border)] shrink-0",style:{background:"#1565C00A"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#64B5F6"},children:["Follow-up to ",V.roleName]}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"Send a follow-up directive"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:z,onChange:U=>H(U.target.value),onKeyDown:U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),se())},placeholder:"e.g., 좋아 KB-3 진행해, Engineer에게 시켜...",disabled:R,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#64B5F6]"}),l.jsx("button",{onClick:se,disabled:R||!z.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#1565C0",color:"#fff"},children:R?"...":"Send"})]})]}),!V&&l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-xs",children:"Click a node in the org tree to view activity"}),l.jsxs("div",{className:"px-4 py-2 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:V&&V.events.length>0&&`${V.events.length} events`}),j&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:u,className:"px-4 py-1.5 text-xs rounded-lg font-semibold cursor-pointer",style:{background:"rgba(255,255,255,0.08)",color:"var(--terminal-text-muted)"},children:"Dismiss"}),h&&l.jsx("button",{onClick:Y,disabled:q,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:q?"Saving...":"Save Wave"})]})]})]})]})]})]})}const YN={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function Vg({orgNodes:e,rootRoleId:n,cLevelRoles:a,pastWaves:i,activeWaves:o,onDispatch:u,onClose:d,onDone:f,onSave:m,onOpenKnowledgeDoc:h,onRefreshWaves:x,terminalWidth:g=0,onMaximize:w,inline:b=!1,onOpenSaveModal:j}){const[k,E]=v.useState(""),[C,N]=v.useState(null),[_,z]=v.useState(!1),[H,R]=v.useState(o.length>0?0:-1),[I,q]=v.useState(!1),X=v.useRef(null),A=H>=0?o[H]??null:null,$=v.useMemo(()=>[],[]),L=(A==null?void 0:A.rootJobs)??$,Y=lv(L,e,n,(A==null?void 0:A.id)??null);v.useEffect(()=>{if(C){const ne=XN(e,n,C.roles);Y.injectStaticNodes(ne);for(const Ae of C.roles??[])if(Ae.status==="running"&&Ae.jobId){const We=ne.get(Ae.roleId);We!=null&&We.sessionId&&setTimeout(()=>Y.connectStream(We.sessionId,Ae.roleId),100)}}},[C,e,n]),v.useEffect(()=>{!Y.selectedRoleId&&n&&Y.selectNode(n)},[n]);const se=v.useRef(o.length);v.useEffect(()=>{const ne=o.length>se.current;se.current=o.length,ne?(R(0),N(null),q(!1)):o.length>0&&H<0&&!I&&(R(0),N(null))},[o.length,H,I]);const[ee,W]=v.useState(null),oe=v.useMemo(()=>{if(!ee)return null;const ne=ee.modified.length+ee.untracked.length;return{branch:ee.branch,dirty:ne>0,count:ne}},[ee]),de=v.useCallback(()=>{ye.getSaveStatus("code").then(ne=>{W({dirty:ne.modified.length+ne.untracked.length>0,modified:ne.modified,untracked:ne.untracked,lastCommit:ne.lastCommit,branch:ne.branch})}).catch(()=>{})},[]);v.useEffect(()=>{de()},[de]);const[V,D]=v.useState(0);v.useEffect(()=>{if(!A)return;const ne=setInterval(()=>{D(Math.floor((Date.now()-A.startedAt)/1e3))},1e3);return()=>clearInterval(ne)},[A]);const[B,U]=v.useState(""),[T,ie]=v.useState(!1),[ge,pe]=v.useState([]),[ze,Ie]=v.useState(!1),[He,st]=v.useState(null),Pe=v.useRef(null);v.useEffect(()=>{if(He){const ne=setTimeout(()=>st(null),3e3);return()=>clearTimeout(ne)}},[He]);const et=v.useCallback(async ne=>["image/png","image/jpeg","image/gif","image/webp"].includes(ne.type)?ne.size>5*1024*1024?(st(`Too large: ${(ne.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(We=>{const Nt=new FileReader;Nt.onload=()=>{const kn=Nt.result.split(",")[1];We({type:"image",data:kn,name:ne.name,mediaType:ne.type})},Nt.onerror=()=>{st("Failed to read file"),We(null)},Nt.readAsDataURL(ne)}):(st(`Unsupported: ${ne.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),Ee=v.useCallback(async ne=>{const Ae=[];for(const We of Array.from(ne)){const Nt=await et(We);Nt&&Ae.push(Nt)}Ae.length>0&&pe(We=>[...We,...Ae])},[et]),De=v.useCallback(ne=>{ne.preventDefault(),ne.stopPropagation(),Ie(!0)},[]),yt=v.useCallback(ne=>{ne.preventDefault(),ne.stopPropagation(),Ie(!1)},[]),ut=v.useCallback(ne=>{ne.preventDefault(),ne.stopPropagation(),Ie(!1),ne.dataTransfer.files.length>0&&Ee(ne.dataTransfer.files)},[Ee]),pt=v.useCallback(ne=>{const Ae=[];for(let We=0;We<ne.clipboardData.items.length;We++){const Nt=ne.clipboardData.items[We];if(Nt.type.startsWith("image/")){const kn=Nt.getAsFile();kn&&Ae.push(kn)}}Ae.length>0&&(ne.preventDefault(),Ee(Ae))},[Ee]),[jt,Wt]=v.useState(320),Ft=v.useRef(!1),Et=v.useRef(0),$n=v.useRef(0),me=v.useCallback(ne=>{ne.preventDefault(),Ft.current=!0,Et.current=ne.clientX,$n.current=jt;const Ae=Nt=>{if(!Ft.current)return;const kn=Et.current-Nt.clientX;Wt(Math.max(200,Math.min(500,$n.current+kn)))},We=()=>{Ft.current=!1,window.removeEventListener("mousemove",Ae),window.removeEventListener("mouseup",We)};window.addEventListener("mousemove",Ae),window.addEventListener("mouseup",We)},[jt]),[Se,Ne]=v.useState(new Set),K=v.useRef(null),ue=v.useRef(!1);v.useEffect(()=>{const ne=K.current;if(!ne)return;const Ae=()=>{const We=ne.scrollHeight-ne.scrollTop-ne.clientHeight<60;ue.current=!We};return ne.addEventListener("scroll",Ae),()=>ne.removeEventListener("scroll",Ae)},[]),v.useEffect(()=>{!ue.current&&K.current&&(K.current.scrollTop=K.current.scrollHeight)},[Y.nodes,Y.selectedRoleId]);const te=Y.selectedRoleId?Y.nodes.get(Y.selectedRoleId)??null:null,ke=te?YN[te.roleId]??"#888":"#888",ve=Y.progress.running>0||Y.progress.awaitingInput>0,_e=Y.selectedRoleId===n,Be=!!C&&!A,Oe=(A==null?void 0:A.directive)??(C==null?void 0:C.directive)??"",qe=v.useCallback(ne=>{const Ae=new Set,We=[ne];for(;We.length>0;){const Nt=We.shift();if(Ae.has(Nt))continue;Ae.add(Nt);const kn=e[Nt];kn&&We.push(...kn.children)}return Ae},[e]),rt=v.useMemo(()=>{if(!Y.selectedRoleId)return new Set;const ne=qe(Y.selectedRoleId);return ne.delete(n),ne},[Y.selectedRoleId,qe,n]),Ve=v.useRef(null);v.useEffect(()=>{if(Y.selectedRoleId===Ve.current||(Ve.current=Y.selectedRoleId,!Y.selectedRoleId))return;const ne=qe(Y.selectedRoleId);ne.delete(n),Y.setCheckedRoles(ne)},[Y.selectedRoleId,qe,n]);const bt=Y.checkedRoles.size,Re=()=>{if(!k.trim()&&ge.length===0||bt===0)return;const Ae=Array.from(Y.nodes.keys()).filter(Nt=>Nt!==n).every(Nt=>Y.checkedRoles.has(Nt)),We=ge.length>0?ge:void 0;u(k.trim(),Ae?void 0:Array.from(Y.checkedRoles),We),E(""),pe([])},Ue=ne=>{ne.key==="Enter"&&(ne.metaKey||ne.ctrlKey)&&(ne.preventDefault(),Re()),ne.key==="Escape"&&d()},_t=v.useCallback(async()=>{if(!Y.selectedRoleId||!B.trim()&&ge.length===0)return;const ne=Y.nodes.get(Y.selectedRoleId);if(!ne)return;const Ae=ge.length>0?ge:void 0;ie(!0);try{if(ne.status==="awaiting_input"&&ne.sessionId){const We=await ye.replyToSession(ne.sessionId,B.trim(),Ae);U(""),pe([]),Y.connectStream(We.sessionId||ne.sessionId,Y.selectedRoleId)}else{const We=(A==null?void 0:A.id)??(C==null?void 0:C.waveId)??(C==null?void 0:C.id),Nt=await ye.startJob({type:"assign",roleId:Y.selectedRoleId,task:B.trim(),...We&&{waveId:We},...Ae&&{attachments:Ae}});U(""),pe([]),Nt.sessionId&&Y.connectStream(Nt.sessionId,Y.selectedRoleId)}}catch(We){console.error("Reply failed:",We)}finally{ie(!1)}},[Y,B,ge,A,C]),Bt=v.useCallback(async ne=>{const Ae=Y.nodes.get(ne);if(Ae!=null&&Ae.sessionId)try{await ye.abortSession(Ae.sessionId)}catch{}},[Y.nodes]),Ot=v.useCallback(async()=>{for(const[,ne]of Y.nodes)if((ne.status==="running"||ne.status==="awaiting_input")&&ne.sessionId)try{await ye.abortSession(ne.sessionId)}catch{}},[Y.nodes]),fn=v.useCallback(async ne=>{z(!0),N(null),R(-1);try{const Ae=await ye.getWaveDetail(ne);Ae.replay&&N(Ae.replay)}catch(Ae){console.error("Failed to load wave:",Ae)}finally{z(!1)}},[]),wn=v.useRef(!1);v.useEffect(()=>{Y.allDone&&!wn.current&&A&&(wn.current=!0,de(),f==null||f())},[Y.allDone,A,f,de]);const Z=v.useCallback(async()=>{if(!m||!A)return;const ne=A.rootJobs.map(Ae=>Ae.jobId).filter(Ae=>!!Ae);await m(A.directive,ne,{waveId:A.id,sessionIds:A.sessionIds})},[m,A]),$e=ne=>{Ne(Ae=>{const We=new Set(Ae);return We.has(ne)?We.delete(ne):We.add(ne),We})},nt=ne=>{const Ae=Math.floor(ne/60),We=ne%60;return`${Ae}:${We.toString().padStart(2,"0")}`},{panelRight:Pt,panelWidth:we,isResizing:kt,handleResizeStart:ln}=Go(g,700,w),sn=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"}),ve&&l.jsxs("span",{className:"text-white/60 text-xs",children:[Y.progress.running," running"]}),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:A?`${o.length} active wave${o.length!==1?"s":""}`:Be?"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:[(A||Be)&&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:ve?"#FBBF24":Y.allDone||Be?"#2E7D32":"#B71C1C",animation:ve?"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:["“",Oe,"”"]}),A&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:nt(V)}),Be&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:ve?"#FBBF2422":"#2E7D3222",color:ve?"#FBBF24":"#2E7D32"},children:ve?"LIVE":"REPLAY"}),Be&&(C==null?void 0:C.startedAt)&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:new Date(C.startedAt).toLocaleString()}),Y.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:[Y.progress.awaitingInput," awaiting"]}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:Y.allDone||Be&&!ve?"#2E7D3222":"#B71C1C22",color:Y.allDone||Be&&!ve?"#2E7D32":"#B71C1C"},children:[Y.progress.done,"/",Y.progress.total]}),ve&&l.jsx("button",{onClick:Ot,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:A||Be?"Org Propagation":"Select Target Roles"}),l.jsxs("span",{className:"ml-auto text-[10px] text-[var(--terminal-text-muted)]",children:[Y.checkedRoles.size,"/",Y.progress.total," selected"]}),(A||Be)&&l.jsx("div",{className:"flex gap-x-3",children:[{label:"running",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(ne=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:ne.color,animation:ne.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:ne.label})]},ne.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(iv,{nodes:Y.nodes,rootId:n,selectedRoleId:Y.selectedRoleId,onSelectNode:Y.selectNode,checkedRoles:Y.checkedRoles,onToggleCheck:Y.toggleCheck,eligibleRoles:rt})})]}),_?l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"Loading wave data..."}):_e?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:[bt," target role",bt!==1?"s":""," selected"]})]}),l.jsxs("div",{ref:K,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-2 text-xs font-mono select-text",children:[Oe&&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:Oe}),A&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",children:["dispatched ",nt(V)," ago to ",A.rootJobs.length," role",A.rootJobs.length!==1?"s":""]})]})]}),!Oe&&!A&&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:[ge.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:ge.map((ne,Ae)=>l.jsxs("div",{className:"relative group w-14 h-14 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${ne.mediaType};base64,${ne.data}`,alt:ne.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>pe(We=>We.filter((Nt,kn)=>kn!==Ae)),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-[9px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[7px] text-white truncate px-1",children:ne.name})]},Ae))}),He&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:He}),l.jsxs("div",{className:"flex gap-2 items-end",children:[l.jsx("button",{onClick:()=>{var ne;return(ne=Pe.current)==null?void 0:ne.click()},className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:text-[var(--terminal-text-secondary)] transition-colors",title:"Attach image",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("textarea",{ref:X,value:k,onChange:ne=>E(ne.target.value),onKeyDown:Ue,onPaste:pt,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()&&ge.length===0||bt===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()&&bt>0?"#B71C1C":"#333",color:"#fff",minWidth:140},children:["Dispatch to ",bt," Role",bt!==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:[te&&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:ke}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:te.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:te.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:te.status==="awaiting_input"?"#F59E0B22":te.status==="running"?"#FBBF2422":`${ke}22`,color:te.status==="awaiting_input"?"#F59E0B":te.status==="running"?"#FBBF24":ke},children:te.status==="running"?"Working...":te.status==="done"?"Complete":te.status==="error"?"Error":te.status==="waiting"?"Waiting":te.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),l.jsxs("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[te.events.length," events"]}),(te.status==="running"||te.status==="awaiting_input")&&te.sessionId&&l.jsx("button",{onClick:()=>Bt(te.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},children:"Stop"})]}),l.jsx("input",{ref:Pe,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:ne=>{var Ae;(Ae=ne.target.files)!=null&&Ae.length&&Ee(ne.target.files),ne.target.value=""},className:"hidden"}),l.jsxs("div",{ref:K,className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text transition-colors ${ze?"bg-amber-500/5 ring-1 ring-inset ring-amber-500/30":""}`,onDragOver:De,onDragLeave:yt,onDrop:ut,children:[te&&Oe&&te.status!=="waiting"&&te.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:Oe})]}),te&&te.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:te.status==="waiting"?"Waiting for dispatch...":te.status==="running"?"Connecting to activity stream...":te.status==="not-dispatched"?"This role was not dispatched. Send a follow-up to activate.":""}),te==null?void 0:te.events.map((ne,Ae)=>{const We=te.events,Nt=ne.type==="job:start"&&Ae>0,kn=We[Ae+1];if((ne.type==="job:done"||ne.type==="job:error"||ne.type==="job:awaiting_input")&&(kn==null?void 0:kn.type)==="job:start")return null;if(Nt){const xn=ne.data.task??"",gn=xn.match(/\[CEO Follow-up\]\n([\s\S]+)$/),dr=gn?gn[1].trim():xn;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:dr})]})},`followup-${ne.seq}`)}return l.jsx(Vm,{event:ne,isThinkingCollapsed:Se.has(ne.seq),onToggleThinking:()=>$e(ne.seq),onNavigateToJob:xn=>{for(const[,gn]of Y.nodes)if(gn.events.some(dr=>dr.data.childJobId===xn)){Y.selectNode(gn.roleId);return}},onOpenKnowledgeDoc:h},ne.seq)}),(te==null?void 0:te.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"}),!te&&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"})]}),((te==null?void 0:te.status)==="awaiting_input"||(te==null?void 0:te.status)==="done"||(te==null?void 0:te.status)==="not-dispatched")&&(ge.length>0||He||ze)&&l.jsxs("div",{className:"px-4 pt-2 border-t shrink-0",style:{borderColor:"var(--terminal-border)"},children:[He&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:He}),ze&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-1",children:"Drop image here"}),ge.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-1",children:ge.map((ne,Ae)=>l.jsxs("div",{className:"relative group w-14 h-14 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${ne.mediaType};base64,${ne.data}`,alt:ne.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>pe(We=>We.filter((Nt,kn)=>kn!==Ae)),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-[9px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[7px] text-white truncate px-1",children:ne.name})]},Ae))})]}),(te==null?void 0:te.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:[te.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var ne;return(ne=Pe.current)==null?void 0:ne.click()},disabled:T,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:B,onChange:ne=>U(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),_t())},onPaste:pt,placeholder:"Type your response...",disabled:T,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none",style:{borderColor:"var(--terminal-border)"},autoFocus:!0}),l.jsx("button",{onClick:_t,disabled:T||!B.trim()&&ge.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:T?"...":"Reply"})]})]}),te&&(te.status==="done"||te.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 ",te.roleName]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var ne;return(ne=Pe.current)==null?void 0:ne.click()},disabled:T,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:B,onChange:ne=>U(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),_t())},onPaste:pt,placeholder:"Send a follow-up directive...",disabled:T,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:_t,disabled:T||!B.trim()&&ge.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:T?"...":"Send"})]})]}),Y.allDone&&A&&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:Z,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:jt,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:me}),l.jsx("div",{className:"p-3 pb-0",children:l.jsx("button",{onClick:()=>{N(null),R(-1),q(!0),Y.reset()},className:"w-full px-3 py-1.5 text-[11px] font-bold rounded-lg cursor-pointer transition-colors",style:{background:!C&&H<0?"#B71C1C":"var(--terminal-inline-bg)",color:!C&&H<0?"#fff":"var(--terminal-text-secondary)",border:"1px solid",borderColor:!C&&H<0?"#B71C1C":"var(--terminal-border)"},children:"+ New Wave"})}),o.length>0&&l.jsxs("div",{className:"p-3",children:[l.jsx("div",{className:"text-[10px] font-bold text-[var(--terminal-text-muted)] uppercase tracking-wider mb-2",children:"Active"}),l.jsx("div",{className:"flex flex-col gap-1.5",children:o.map((ne,Ae)=>l.jsxs("button",{onClick:()=>{R(Ae),N(null),q(!1)},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:H===Ae&&!C?"var(--terminal-bg)":"transparent",border:H===Ae&&!C?"1px solid var(--accent)":"1px solid transparent"},children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 shrink-0 animate-pulse"}),l.jsxs("span",{className:"text-[11px] text-[var(--terminal-text)] truncate font-medium",children:[ne.directive.slice(0,40),ne.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[ne.rootJobs.length," role",ne.rootJobs.length!==1?"s":""]})]},ne.id))})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-3",children:[l.jsxs("div",{className:"text-[10px] font-bold text-[var(--terminal-text-muted)] uppercase tracking-wider mb-2",children:["Past Waves (",i.length,")"]}),i.length===0&&l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] italic",children:"No past waves yet"}),l.jsx("div",{className:"flex flex-col gap-1.5",children:i.map(ne=>l.jsx(WN,{wave:ne,active:(C==null?void 0:C.id)===ne.id,onLoad:()=>fn(ne.id)},ne.id))})]}),oe&&l.jsxs("button",{onClick:j,disabled:!j,className:"px-3 py-2.5 border-t shrink-0 flex items-center gap-1.5 w-full text-left hover:bg-white/5 transition-colors cursor-pointer disabled:cursor-default",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:oe.dirty?"var(--idle-amber)":"#2E7D32"}}),l.jsx("span",{className:"text-[10px] font-mono text-[var(--terminal-text-muted)] truncate",children:oe.branch}),oe.dirty&&l.jsxs("span",{className:"text-[9px] ml-auto shrink-0",style:{color:"var(--idle-amber)"},children:[oe.count," unsaved"]}),!oe.dirty&&l.jsx("span",{className:"text-[9px] text-green-400 ml-auto shrink-0",children:"clean"})]})]})]})]});return b?l.jsx("div",{className:"flex flex-col h-full w-full",style:{background:"var(--terminal-bg)"},children:sn}):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:Pt},onClick:d}),l.jsxs("div",{className:"fixed top-0 bottom-0 z-50 flex flex-col",style:{right:Pt,width:we,background:"var(--terminal-bg)",borderLeft:"1px solid var(--terminal-border)",transition:kt?"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:ln}),sn]})]})}function XN(e,n,a){const i=new Map,o=d=>{const f=e[d];!f||i.has(d)||(i.set(d,{sessionId:"",roleId:d,roleName:f.name,children:f.children,status:"not-dispatched",events:[],streamStatus:"idle"}),f.children.forEach(o))},u=e[n];u&&(i.set(n,{sessionId:"",roleId:n,roleName:"CEO",children:u.children,status:"not-dispatched",events:[],streamStatus:"idle"}),u.children.forEach(o));for(const d of a){const f=i.get(d.roleId);if(f){const m=d.status==="running";i.set(d.roleId,{...f,sessionId:d.sessionId??d.jobId??"",status:d.status||"done",events:d.events,streamStatus:m?"connecting":"done"})}for(const m of d.childJobs){const h=i.get(m.roleId);h&&i.set(m.roleId,{...h,sessionId:m.jobId??"",status:m.status||"done",events:m.events,streamStatus:"done"})}}return i}function WN({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 GN={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 Km(e){return GN[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const sv=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],ov=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],cv=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],uv=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],dv=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],ll={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 VN({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 Do({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(VN,{color:o,selected:o===a,onClick:()=>i(o)},o))})]})}function Ah({label:e,items:n,value:a,onChange:i,lockInfo:o}){return l.jsxs("div",{className:"customize-row",children:[l.jsx("div",{className:"customize-row-header",children:l.jsx("span",{className:"customize-row-label",children:e})}),l.jsx("div",{className:"customize-swatches",style:{gap:4},children:n.map(u=>{const d=o?o.getLockLevel(u.id):1,f=u.id===a,m=o?d>o.roleLevel&&!f:!1,h=o?f&&d>o.roleLevel:!1;return l.jsxs("button",{onClick:()=>{m||i(u.id===a?void 0:u.id)},className:"customize-swatch",style:{width:"auto",height:"auto",padding:m?"2px 6px 10px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:f?"rgba(255,255,255,0.15)":m?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",outline:f?h?"2px solid #F59E0B":"2px solid #fff":"2px solid transparent",color:m?"rgba(255,255,255,0.25)":f?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:m?"not-allowed":"pointer",opacity:m?.35:1,position:"relative"},children:[u.name,m&&l.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:"rgba(255,255,255,0.5)",whiteSpace:"nowrap"},children:["🔒"," Lv.",d]}),h&&l.jsxs("span",{style:{position:"absolute",bottom:-8,left:"50%",transform:"translateX(-50%)",fontSize:7,color:"#F59E0B",whiteSpace:"nowrap"},children:["⚠"," Lv.",d]})]},u.id)})})]})}function Dh({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 _l(e){return e[Math.floor(Math.random()*e.length)]}function ys(e){var o,u,d;const n=_b(),a=Bb(),i=Ob().filter(f=>!e||Lb(f.id,e));return{skinColor:_l(sv),hairColor:_l(ov),shirtColor:_l(cv),pantsColor:_l(uv),shoeColor:_l(dv),hairStyle:(o=_l(n))==null?void 0:o.id,outfitStyle:(u=_l(a))==null?void 0:u.id,accessory:(d=_l(i))==null?void 0:d.id}}function fv({roleId:e,appearance:n,onChange:a,onRandomize:i,onReset:o,label:u,roleLevel:d}){const[f,m]=v.useState("look"),h=v.useCallback((E,C)=>{a({...n,[E]:C})},[n,a]),x=v.useRef(null),g=v.useCallback(E=>{var _;const C=(_=E.target.files)==null?void 0:_[0];if(!C)return;const N=new Image;N.onload=()=>{const z=cC(N);a({...z,hairStyle:n.hairStyle,outfitStyle:n.outfitStyle,accessory:n.accessory}),URL.revokeObjectURL(N.src)},N.src=URL.createObjectURL(C),E.target.value=""},[n.hairStyle,n.outfitStyle,n.accessory,a]),w=_b(),b=Bb(),j=Ob(),k=d!==void 0?j.filter(E=>Lb(E.id,d)).length:j.length;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"customize-preview",children:[l.jsx("div",{className:"customize-preview-bg",children:l.jsx(Ul,{roleId:e,appearance:n,scale:12})}),u&&l.jsx("div",{className:"customize-preview-name",children:u}),l.jsxs("div",{className:"customize-preview-actions",children:[l.jsx("button",{className:"customize-btn customize-btn--random",onClick:i,children:"RANDOM"}),l.jsx("button",{className:"customize-btn customize-btn--reset",onClick:o,children:"RESET"}),l.jsx("button",{className:"customize-btn",onClick:()=>{var E;return(E=x.current)==null?void 0:E.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),l.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:g,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(Dh,{label:"LOOK",active:f==="look",onClick:()=>m("look")}),l.jsx(Dh,{label:"OUTFIT",active:f==="outfit",onClick:()=>m("outfit")}),l.jsx(Dh,{label:"ACCESSORY",active:f==="accessory",onClick:()=>m("accessory")})]}),f==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(Do,{label:"SKIN",presets:sv,value:n.skinColor,onChange:E=>h("skinColor",E)}),l.jsx(Do,{label:"HAIR COLOR",presets:ov,value:n.hairColor,onChange:E=>h("hairColor",E)}),l.jsx(Ah,{label:"HAIR STYLE",items:w,value:n.hairStyle,onChange:E=>h("hairStyle",E)})]}),f==="outfit"&&l.jsxs(l.Fragment,{children:[l.jsx(Ah,{label:"STYLE",items:b,value:n.outfitStyle,onChange:E=>h("outfitStyle",E)}),l.jsx(Do,{label:"TOP",presets:cv,value:n.shirtColor,onChange:E=>h("shirtColor",E)}),l.jsx(Do,{label:"PANTS",presets:uv,value:n.pantsColor,onChange:E=>h("pantsColor",E)}),l.jsx(Do,{label:"SHOES",presets:dv,value:n.shoeColor,onChange:E=>h("shoeColor",E)})]}),f==="accessory"&&l.jsxs(l.Fragment,{children:[d!==void 0&&l.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("span",{children:["Lv.",d]}),l.jsxs("span",{children:[k,"/",j.length," unlocked"]})]}),l.jsx(Ah,{label:"ACCESSORY",items:j,value:n.accessory,onChange:E=>h("accessory",E),lockInfo:d!==void 0?{roleLevel:d,getLockLevel:$b}:void 0}),l.jsx("div",{style:{marginTop:12,padding:"8px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,border:"1px dashed rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.25)",fontSize:9,fontFamily:"var(--font-pixel, monospace)",textAlign:"center"},children:d!==void 0&&d<10?"Level up to unlock more accessories":"More accessories coming soon"})]})]})]})}const KN=[{value:"c-level",label:"C-Level"},{value:"member",label:"Member"}];function pm(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Th(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 PN={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 $l=null;async function QN(){if($l)return $l;try{const a=await ye.getPreferences();if(a.instanceId)return $l=a.instanceId,localStorage.setItem("tycono_instance_id",$l),$l}catch{}const e="tycono_instance_id";let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),$l=n,n}const To=4;function ZN(e,n,a){const i=e.trim();if(!i||i.startsWith("#"))return null;const o=i.split(",").map(g=>g.trim()),u=o[0];if(!u)return null;const d=pm(u),m=(o[1]||"member").toLowerCase()==="c-level"?"c-level":"member",h=o[2]||"ceo";let x;return n.has(d)?x="ID already exists":a.has(d)&&(x="Duplicate ID in batch"),a.add(d),{name:u,id:d,level:m,reportsTo:h,error:x}}function JN({existingRoles:e,onClose:n,onHire:a,onStoreVisit:i,questHint:o}){const[u,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),[C,N]=v.useState(!1),[_,z]=v.useState(""),[H,R]=v.useState("browse"),[I,q]=v.useState(""),[X,A]=v.useState(""),[$,L]=v.useState("ceo"),[Y,se]=v.useState(null),[ee,W]=v.useState(1),[oe,de]=v.useState(""),[V,D]=v.useState(""),[B,U]=v.useState(!1),[T,ie]=v.useState("member"),[ge,pe]=v.useState(()=>{const Z=e.find($e=>$e.level==="c-level");return(Z==null?void 0:Z.id)??"ceo"}),[ze,Ie]=v.useState(""),[He,st]=v.useState(ys),[Pe,et]=v.useState(!1),[Ee,De]=v.useState(""),[yt,ut]=v.useState([]),[pt,jt]=v.useState(new Set),[Wt,Ft]=v.useState(""),[Et,$n]=v.useState("input"),[me,Se]=v.useState({done:0,total:0}),Ne=v.useRef(null),K=v.useRef(null),ue=v.useRef(null);v.useEffect(()=>{ye.getSkills().then(Z=>ut(Z.filter($e=>$e.installed))).catch(()=>{}),QN().then(Z=>se(Z)).catch(()=>{})},[]),v.useEffect(()=>{var Z,$e,nt;u==="single"?(ee===1&&((Z=Ne.current)==null||Z.focus()),ee===2&&(($e=K.current)==null||$e.focus())):u==="bulk"&&Et==="input"&&((nt=ue.current)==null||nt.focus())},[ee,u,Et]),v.useEffect(()=>{u==="store"&&H==="browse"&&f.length===0&&te()},[u,H]);const te=async()=>{x(!0);try{const Z=await wr.getCharacters({sort:g,instanceId:Y??void 0});m(Z.characters)}catch{z("Failed to load job board")}x(!1)};v.useEffect(()=>{u==="store"&&H==="browse"&&te()},[g,Y]);const ke=v.useMemo(()=>{if(!b.trim())return f;const Z=b.toLowerCase();return f.filter($e=>$e.name.toLowerCase().includes(Z)||$e.id.toLowerCase().includes(Z)||($e.tagline??"").toLowerCase().includes(Z))},[f,b]),ve=v.useMemo(()=>new Set(e.map(Z=>Z.id)),[e]),_e=v.useMemo(()=>{const Z=Wt.split(`
|
|
85
|
-
`),$e=new Set;return Z.map(nt=>ZN(nt,ve,$e)).filter(nt=>nt!==null)},[Wt,ve]),Be=_e.length>0&&_e.every(Z=>!Z.error),Oe=Z=>{de(Z),B||D(pm(Z))},qe=oe.trim().length>0&&V.trim().length>0&&!e.some(Z=>Z.id===V),rt=ze.trim().length>0,Ve=async()=>{et(!0),De("");const Z=Th(T);try{await a({id:V,name:oe.trim(),level:T,reportsTo:ge,persona:ze.trim(),...Z,skills:pt.size>0?[...pt]:void 0},He),n()}catch($e){De($e instanceof Error?$e.message:"Failed to create role"),et(!1)}},bt=Z=>Z===1?qe:Z===2?rt:!0,Re=async()=>{et(!0),De(""),Se({done:0,total:_e.length});try{for(let Z=0;Z<_e.length;Z++){const $e=_e[Z],nt=Th($e.level),Pt=ys(),we=`${$e.name}. A ${$e.level} role reporting to ${$e.reportsTo}.`;await a({id:$e.id,name:$e.name,level:$e.level,reportsTo:$e.reportsTo,persona:we,...nt},Pt),Se({done:Z+1,total:_e.length})}n()}catch(Z){De(Z instanceof Error?Z.message:"Failed to create roles"),et(!1)}},Ue=async Z=>{N(!0),z("");try{const $e=await wr.getCharacter(Z);E($e),q($e.name||""),A(pm($e.name||Z)),R("review")}catch{z("Failed to load character details")}finally{N(!1)}},_t=async(Z,$e)=>{if(!Y)return;const nt=f.find(we=>we.id===Z);if(!nt)return;const Pt=nt.my_vote===$e?0:$e;try{const we=await wr.voteCharacter(Z,Y,Pt);m(kt=>kt.map(ln=>ln.id===Z?{...ln,upvotes:we.upvotes,downvotes:we.downvotes,vote_score:we.upvotes-we.downvotes,my_vote:Pt===0?null:Pt}:ln))}catch{}},Bt=async()=>{if(!k)return;et(!0),De("");const Z=k,$e=Z.level==="c-level"?"c-level":"member",nt=Th($e),Pt=Z.skills!=null&&typeof Z.skills=="object"&&!Array.isArray(Z.skills)&&"primary"in Z.skills;try{await a({id:X,name:I.trim(),level:$e,reportsTo:$,persona:Z.persona||`${I}. Imported from Job Board.`,authority:Z.authority||nt.authority,knowledge:nt.knowledge,reports:nt.reports,source:{id:`tycono/${Z.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:Pt?Z.skills:void 0},Z.appearance?Z.appearance:ys()),wr.trackInstall(Z.id).catch(()=>{}),n()}catch(we){De(we instanceof Error?we.message:"Failed to hire"),et(!1)}},Ot=async Z=>{if(Y)try{await wr.deleteCharacter(Z,Y),m($e=>$e.filter(nt=>nt.id!==Z))}catch{}},fn=Z=>{Z.key==="Escape"&&n(),Z.key==="Enter"&&(Z.metaKey||Z.ctrlKey)&&(u==="single"?ee<To&&bt(ee)?W(ee+1):ee===To&&Ve():u==="bulk"?Et==="input"&&Be?$n("review"):Et==="review"&&Re():u==="store"&&H==="review"&&Bt())},wn=e.some(Z=>Z.id===V)&&V.length>0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:n}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] max-h-[90vh] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",onKeyDown:fn,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"),De("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="single"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Single"}),l.jsx("button",{onClick:()=>{d("bulk"),De("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="bulk"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Bulk"}),l.jsx("button",{onClick:()=>{d("store"),De(""),i==null||i()},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${u==="store"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Job Board"})]})]}),o&&l.jsxs("div",{className:"mt-2 px-3 py-1.5 rounded-lg text-xs flex items-center gap-2",style:{background:"rgba(0,0,0,0.2)"},children:[l.jsx("span",{children:"🐾"}),l.jsx("span",{className:"opacity-90",children:o.message}),o.roleId&&u==="single"&&ee===1&&!oe&&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 Z=PN[o.roleId];Z&&(de(Z.name),D(Z.id),U(!0),ie(Z.level))},children:"Auto-fill →"})]}),l.jsxs("div",{className:"text-sm opacity-80 mt-0.5 flex items-center gap-2",children:[l.jsx("span",{children:u==="single"?`Step ${ee} of ${To}`:u==="bulk"?Et==="input"?"Enter roles, one per line":`Review ${_e.length} roles`:H==="browse"?`${f.length} roles available`:"Review & customize"}),u==="store"&&H==="browse"&&l.jsx("a",{href:"https://tycono.ai/jobs",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] opacity-60 hover:opacity-100 transition-opacity",onClick:Z=>Z.stopPropagation(),children:"Open in browser ↗"})]})]}),u==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:To},(Z,$e)=>$e+1).map(Z=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:Z<=ee?"#2E7D32":"rgba(255,255,255,0.1)"}},Z))}),l.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:u==="store"?l.jsxs(l.Fragment,{children:[H==="browse"&&l.jsxs("div",{className:"space-y-3",children:[Y?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:[Y.slice(0,8),"..."]})]}),l.jsx("button",{onClick:()=>{$l=null,localStorage.removeItem("tycono_instance_id"),se(null)},className:"text-white/30 hover:text-white/60 cursor-pointer",children:"Sign out"})]}):l.jsx(e6,{onLogin:Z=>{$l=Z,localStorage.setItem("tycono_instance_id",Z),se(Z)}}),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:Z=>{if(Z.key==="Enter"){const nt=Z.target.value.trim().replace(/^tycono:/,"");nt&&(Ue(nt),Z.target.value="")}}}),l.jsx("button",{onClick:()=>{const Z=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(Z){const nt=Z.value.trim().replace(/^tycono:/,"");nt&&(Ue(nt),Z.value="")}},disabled:C,className:"px-3 py-2 rounded-lg bg-accent/10 border border-accent/25 text-accent text-xs font-medium hover:bg-accent/20 transition-colors shrink-0 cursor-pointer disabled:opacity-50",children:C?"Loading...":"Fetch"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex-1 h-px bg-white/10"}),l.jsx("span",{className:"text-[10px] text-white/30",children:"or browse"}),l.jsx("div",{className:"flex-1 h-px bg-white/10"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:b,onChange:Z=>j(Z.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:Z=>w(Z.target.value),className:"px-2 py-2 rounded-lg border border-white/10 bg-white/5 text-xs text-white/70 focus:outline-none cursor-pointer",children:[l.jsx("option",{value:"popular",className:"bg-[var(--wall)]",children:"Popular"}),l.jsx("option",{value:"installs",className:"bg-[var(--wall)]",children:"Most Hired"}),l.jsx("option",{value:"newest",className:"bg-[var(--wall)]",children:"Newest"}),l.jsx("option",{value:"name",className:"bg-[var(--wall)]",children:"A-Z"})]})]}),h?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:"Loading store..."}):_?l.jsxs("div",{className:"text-center py-8",children:[l.jsx("div",{className:"text-xs text-red-400 mb-2",children:_}),l.jsx("button",{onClick:te,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):ke.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:ke.map(Z=>l.jsx(t6,{char:Z,isHired:ve.has(Z.id),onSelect:()=>Ue(Z.id),onVote:$e=>_t(Z.id,$e),onDelete:()=>Ot(Z.id),fetching:C,token:Y},Z.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(Ul,{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:Z=>q(Z.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:Z=>A(Z.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(Z=>Z.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:Z=>L(Z.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(Z=>l.jsxs("option",{value:Z.id,className:"bg-[var(--wall)] text-white",children:[Z.name," (",Z.id,")"]},Z.id))]})]})]})]})]}),k.persona&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),l.jsx("div",{className:"text-xs text-white/60 leading-relaxed line-clamp-3",children:k.persona})]}),k.skills&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Skills"}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:(()=>{var Pt,we;const Z=k.skills;if(Z&&typeof Z=="object"&&!Array.isArray(Z)&&"primary"in Z){const kt=[];return(we=(Pt=Z.primary)==null?void 0:Pt.frontmatter)!=null&&we.name&&kt.push(Z.primary.frontmatter.name),Z.shared&&Z.shared.forEach(ln=>{var sn;return kt.push(((sn=ln.frontmatter)==null?void 0:sn.name)||ln.id)}),kt.map(ln=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-green-900/20 border border-green-800/30 text-green-400",children:ln},ln))}return(Array.isArray(Z)?Z:[]).map((kt,ln)=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-green-900/20 border border-green-800/30 text-green-400",children:typeof kt=="string"?kt:kt.name},ln))})()})]})]}),Ee&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ee})]})]}):u==="single"?l.jsxs(l.Fragment,{children:[ee===1&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role Name"}),l.jsx("input",{ref:Ne,value:oe,onChange:Z=>Oe(Z.target.value),placeholder:"e.g. Data Analyst",className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-white/25 transition-colors"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role ID (slug)"}),l.jsx("input",{value:V,onChange:Z=>{D(Z.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),U(!0)},className:`w-full p-2.5 rounded-lg border bg-white/5 text-sm text-white/90 font-mono focus:outline-none transition-colors ${wn?"border-red-400":"border-white/10 focus:border-white/25"}`}),wn&&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:KN.map(Z=>l.jsx("button",{onClick:()=>{if(ie(Z.value),Z.value==="c-level")pe("ceo");else{const $e=e.find(nt=>nt.level==="c-level");pe(($e==null?void 0:$e.id)??"ceo")}},className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${T===Z.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:Z.label},Z.value))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Reports To"}),T==="c-level"?l.jsx("div",{className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/40",children:"CEO (automatic)"}):l.jsx("select",{value:ge,onChange:Z=>pe(Z.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(Z=>Z.level==="c-level").map(Z=>l.jsxs("option",{value:Z.id,className:"bg-[var(--wall)] text-white",children:[Z.name," (",Z.id,")"]},Z.id))})]})]}),ee===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:K,value:ze,onChange:Z=>Ie(Z.target.value),placeholder:"Describe this role's personality, expertise, and working style...",className:"w-full h-32 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"This defines how the AI agent will behave in this role"})]}),yt.length>0&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Skills"}),l.jsx("div",{className:"space-y-1.5 max-h-[120px] overflow-y-auto",children:yt.map(Z=>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:pt.has(Z.id),onChange:()=>jt($e=>{const nt=new Set($e);return nt.has(Z.id)?nt.delete(Z.id):nt.add(Z.id),nt}),className:"accent-green-600"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-xs font-semibold text-white/80",children:Z.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:Z.description})]})]},Z.id))})]})]}),ee===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx(fv,{roleId:"default",appearance:He,onChange:st,onRandomize:()=>st(ys()),onReset:()=>st(ys()),label:l.jsxs("span",{children:[V||"new-role"," — ",oe||"New Role"]})})}),ee===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(Ul,{roleId:"default",appearance:He,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(Fo,{label:"Name",value:oe}),l.jsx(Fo,{label:"ID",value:V,mono:!0}),l.jsx(Fo,{label:"Level",value:T}),l.jsx(Fo,{label:"Reports To",value:ge}),pt.size>0&&l.jsx(Fo,{label:"Skills",value:[...pt].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:ze})]})]}),Ee&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ee})]})]}):l.jsxs(l.Fragment,{children:[Et==="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:ue,value:Wt,onChange:Z=>Ft(Z.target.value),placeholder:`Name, Level, ReportsTo
|
|
86
|
-
e.g.
|
|
87
|
-
Data Analyst
|
|
88
|
-
DevOps Engineer, member, cto
|
|
89
|
-
VP Marketing, c-level, ceo`,className:"w-full h-40 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors font-mono"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Format: Name, Level (member/c-level), ReportsTo. Level and ReportsTo are optional."})]}),_e.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 (",_e.length," role",_e.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:_e.map((Z,$e)=>l.jsxs("tr",{className:`border-b border-white/5 ${Z.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:Z.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:Z.id}),l.jsx("td",{className:"p-2 text-white/60",children:Z.level}),l.jsx("td",{className:"p-2 text-white/60",children:Z.reportsTo}),Z.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:Z.error})]},$e))})]})})]})]}),Et==="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 — ",_e.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:_e.map((Z,$e)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:$e+1}),l.jsx("td",{className:"p-2 text-white/80",children:Z.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:Z.id}),l.jsx("td",{className:"p-2 text-white/60",children:Z.level}),l.jsx("td",{className:"p-2 text-white/60",children:Z.reportsTo})]},$e))})]})}),Pe&&me.total>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-[10px] text-white/40 mb-1",children:[l.jsx("span",{children:"Hiring..."}),l.jsxs("span",{children:[me.done,"/",me.total]})]}),l.jsx("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${me.done/me.total*100}%`,background:"#2E7D32"}})})]}),l.jsx("div",{className:"text-[10px] text-white/30",children:"Each role will get a random appearance and auto-generated persona. You can customize them later."}),Ee&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Ee})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[u==="single"&&ee>1&&l.jsx("button",{onClick:()=>W(ee-1),className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Back"}),u==="bulk"&&Et==="review"&&l.jsx("button",{onClick:()=>$n("input"),disabled:Pe,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer disabled:opacity-40",children:"Back"}),u==="store"&&H==="review"&&l.jsx("button",{onClick:()=>{R("browse"),E(null),De("")},disabled:Pe,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer disabled:opacity-40",children:"Back"})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx("button",{onClick:n,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),u==="single"?ee<To?l.jsx("button",{onClick:()=>W(ee+1),disabled:!bt(ee),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:"Next"}):l.jsx("button",{onClick:Ve,disabled:Pe,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Pe?"Hiring...":"HIRE"}):u==="bulk"?Et==="input"?l.jsxs("button",{onClick:()=>$n("review"),disabled:!Be,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:["Review (",_e.length,")"]}):l.jsx("button",{onClick:Re,disabled:Pe,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Pe?`Hiring ${me.done}/${me.total}...`:`HIRE ALL (${_e.length})`}):H==="review"?l.jsx("button",{onClick:Bt,disabled:Pe||!I.trim()||!X.trim()||e.some(Z=>Z.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:Pe?"Hiring...":"HIRE"}):null]})]})]})]})}function e6({onLogin:e}){const[n,a]=v.useState(""),[i,o]=v.useState(!1),[u,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"})]}),u&&l.jsx("div",{className:"text-[10px] text-red-400",children:u}),l.jsx("button",{onClick:o.bind(null,!1),className:"text-[10px] text-white/30 hover:text-white/50 cursor-pointer",children:"Cancel"})]}):l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:o.bind(null,!0),className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer text-amber-400 bg-amber-900/20 border border-amber-800/30 hover:bg-amber-900/40 transition-colors",children:"Paste Token"}),l.jsx("span",{className:"text-[10px] text-white/20 self-center",children:"from Settings → Token"})]})]})}function t6({char:e,isHired:n,onSelect:a,onVote:i,onDelete:o,fetching:u,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:u,className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer transition-colors disabled:opacity-40 text-green-400 bg-green-900/20 border border-green-800/30 hover:bg-green-900/40",children:"Hire"}),h&&(f?l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:g=>{g.stopPropagation(),o(),m(!1)},className:"px-2 py-1.5 text-[10px] font-semibold rounded cursor-pointer text-red-400 bg-red-900/30 border border-red-800/40 hover:bg-red-900/50",children:"Confirm"}),l.jsx("button",{onClick:g=>{g.stopPropagation(),m(!1)},className:"px-2 py-1.5 text-[10px] rounded cursor-pointer text-white/40 hover:text-white/60",children:"No"})]}):l.jsx("button",{onClick:g=>{g.stopPropagation(),m(!0)},className:"w-7 h-7 rounded-lg flex items-center justify-center cursor-pointer text-white/15 hover:text-red-400/60 hover:bg-red-900/10 transition-colors opacity-0 group-hover:opacity-100",title:"Delete from store",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2"})})}))]})]})}function Fo({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 n6({roleId:e,roleName:n,onClose:a,onConfirm:i}){const[o,u]=v.useState(!1),d=async()=>{u(!0);try{await i(e)}finally{u(!1)}};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:a}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsx("div",{className:"text-lg font-bold",children:"Fire Role"}),l.jsxs("div",{className:"text-sm opacity-80 mt-0.5",children:["Remove ",n," (",e,")"]})]}),l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"p-4 rounded-lg border-2 border-red-300 bg-red-50 mb-4",children:[l.jsx("div",{className:"text-sm font-bold text-red-800 mb-1",children:"Warning"}),l.jsxs("div",{className:"text-xs text-red-700 leading-relaxed",children:["This will permanently delete the role directory including",l.jsx("strong",{children:" role.yaml"}),", ",l.jsx("strong",{children:"profile.md"}),", ",l.jsx("strong",{children:"SKILL.md"}),", and all journal entries. This action cannot be undone."]})]}),l.jsxs("div",{className:"text-sm text-gray-600",children:["Are you sure you want to fire ",l.jsx("strong",{children:n}),"?"]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:a,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:d,disabled:o,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:o?"Removing...":"Confirm Fire"})]})]})]})}const r6={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function a6({roleId:e,title:n,roleColor:a,active:i,isWave:o,isWaveStreaming:u,onClick:d,onClose:f,"data-session-id":m}){const h=o?"#F59E0B":a;return l.jsxs("button",{onClick:d,"data-session-id":m,className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors max-w-[180px] group ${i?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] hover:bg-[var(--terminal-surface)]"}`,style:i?{borderTop:`2px solid ${h}`}:void 0,children:[o&&u&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse shrink-0"}),l.jsx("span",{className:"text-xs",children:r6[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 l6({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(Om,{remarkPlugins:[Hm],components:{code:i6,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:a})})}function i6({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
90
|
-
`)?l.jsx(s6,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"terminal-inline-code",...a,children:n})}function s6({children:e,language:n}){const[a,i]=v.useState(!1),o=String(e).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"terminal-code-block group relative my-2",children:[n&&l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] px-3 pt-1.5",children:n}),l.jsx("button",{onClick:u,className:"absolute top-1.5 right-2 text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:o})})]})}const o6={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 Fh(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 u6(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:Fh(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=Fh(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?Fh(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 d6({event:e,isStreaming:n}){var o,u,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:(u=e.task)==null?void 0:u.slice(0,80)})]});case"dispatch:progress":return l.jsxs("div",{className:"stream-event-dispatch-progress",children:[l.jsx("span",{className:"stream-event-dispatch-progress-role",children:(d=e.roleId)==null?void 0:d.toUpperCase()}),e.progressType==="thinking"&&l.jsxs("span",{className:"stream-event-dispatch-progress-status",children:["thinking",n?"...":""]}),e.progressType==="tool"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"stream-event-tool-badge",children:e.toolName}),e.toolSummary&&l.jsx("span",{className:"stream-event-tool-path",children:e.toolSummary})]}),e.progressType==="text"&&e.text&&l.jsx("span",{className:"stream-event-dispatch-progress-status",children:"responding..."}),e.progressType==="done"&&l.jsx("span",{className:"stream-event-dispatch-progress-done",children:"done"}),e.progressType==="error"&&l.jsx("span",{className:"stream-event-dispatch-progress-error",children:"error"})]});default:return null}}function f6({events:e,isStreaming:n}){const[a,i]=v.useState(!1);if(e.length===0)return null;const o=u6(e);if(o.length===0)return null;const u=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(u>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(d6,{event:w,isStreaming:n&&b===o.length-1},b))})]})}function h6(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 m6({message:e,roleId:n,roleColor:a}){const i=e.from==="ceo",o=e.type==="system",u=e.status==="streaming";if(o)return l.jsx("div",{className:"flex justify-center my-2",children:l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] bg-[var(--terminal-inline-bg)] px-3 py-1 rounded-full",children:e.content})});if(i)return l.jsx("div",{className:"flex justify-end mb-3",children:l.jsxs("div",{className:"max-w-[85%]",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] text-right mb-1",children:"CEO"}),e.attachments&&e.attachments.length>0&&l.jsx("div",{className:"flex justify-end mb-1",children:l.jsx(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?h6(e.events):void 0),f=((d==null?void 0:d.length)??0)>0,m=!!e.thinking,h=m&&!e.content&&u&&!f;return l.jsxs("div",{className:"flex gap-2.5 mb-3",children:[l.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center text-sm shrink-0 mt-5",style:{background:`${a}33`},children:o6[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(f6,{events:d,isStreaming:u}),m&&!f&&l.jsxs("details",{open:h,className:"mb-1",children:[l.jsxs("summary",{className:"text-[10px] text-purple-400/70 cursor-pointer select-none flex items-center gap-1",children:[h&&l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-purple-400 animate-pulse"}),"thinking",h?"...":` (${e.thinking.length} chars)`]}),l.jsx("div",{className:"text-[11px] text-[var(--terminal-text-muted)] leading-relaxed mt-1 pl-2 border-l border-purple-400/20 max-h-32 overflow-y-auto",children:e.thinking.slice(-500)})]}),l.jsxs("div",{className:"rounded-xl rounded-tl-sm px-4 py-2.5 text-sm text-[var(--terminal-text)] leading-relaxed",style:{borderLeft:`3px solid ${a}`,background:"var(--terminal-surface)"},children:[e.content?l.jsx(l6,{content:e.content,streaming:u}):u&&!m?l.jsxs("span",{className:"typing-dots",children:[l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"})]}):u&&m?l.jsxs("span",{className:"typing-dots",children:[l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"})]}):null,u&&e.content&&l.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-[var(--terminal-text-secondary)] animate-pulse ml-0.5 align-middle"})]}),e.status==="error"&&l.jsx("div",{className:"text-[10px] text-red-400 mt-1",children:"Error occurred"}),e.status==="done"&&(e.turns||e.tokens)&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1 flex gap-2",children:[e.turns&&l.jsxs("span",{children:[e.turns," turns"]}),e.tokens&&l.jsxs("span",{children:[(e.tokens.input+e.tokens.output).toLocaleString()," tokens"]}),e.readOnly&&l.jsx("span",{className:"text-blue-400/60",children:"read-only"})]}),e.knowledgeDebt&&e.knowledgeDebt.length>0&&l.jsxs("div",{className:"mt-1.5 px-3 py-2 rounded-lg text-[10px]",style:{background:"#FFA72615",border:"1px solid #FFA72630"},children:[l.jsxs("div",{className:"font-bold mb-1",style:{color:"#FFA726"},children:["Knowledge Debt (",e.knowledgeDebt.length,")"]}),e.knowledgeDebt.map((x,g)=>l.jsxs("div",{className:"flex gap-1.5 mb-0.5",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("span",{style:{color:"#FFA726"},children:x.type==="orphan"?"⚠":x.type==="no-hub"?"📁":"🔗"}),l.jsxs("span",{children:[x.message,x.file?` (${x.file})`:""]})]},g))]})]})]})}function hv({messages:e,roleId:n,roleColor:a}){var o;const i=v.useRef(null);return v.useEffect(()=>{var u;(u=i.current)==null||u.scrollIntoView({behavior:"smooth"})},[e,(o=e[e.length-1])==null?void 0:o.content]),e.length===0?l.jsxs("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:["Start a conversation with ",n.toUpperCase()]}):l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 terminal-scrollbar",children:[e.map(u=>l.jsx(m6,{message:u,roleId:n,roleColor:a},u.id)),l.jsx("div",{ref:i})]})}const p6=5*1024*1024,x6=["image/png","image/jpeg","image/gif","image/webp"];function Pm({mode:e,onModeChange:n,onSend:a,disabled:i,disabledReason:o,onStop:u}){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 C=v.useCallback(async $=>x6.includes($.type)?$.size>p6?(b(`File too large: ${($.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(L=>{const Y=new FileReader;Y.onload=()=>{const ee=Y.result.split(",")[1];L({type:"image",data:ee,name:$.name,mediaType:$.type})},Y.onerror=()=>{b("Failed to read file"),L(null)},Y.readAsDataURL($)}):(b(`Unsupported format: ${$.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),N=v.useCallback(async $=>{const L=Array.from($),Y=[];for(const se of L){const ee=await C(se);ee&&Y.push(ee)}Y.length>0&&h(se=>[...se,...Y])},[C]),_=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!0)},[]),z=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!1)},[]),H=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),g(!1);const L=$.dataTransfer.files;L.length>0&&N(L)},[N]),R=v.useCallback($=>{const L=$.clipboardData.items,Y=[];for(let se=0;se<L.length;se++){const ee=L[se];if(ee.type.startsWith("image/")){const W=ee.getAsFile();W&&Y.push(W)}}Y.length>0&&($.preventDefault(),N(Y))},[N]),I=v.useCallback($=>{const L=$.target.files;L&&L.length>0&&N(L),$.target.value=""},[N]),q=v.useCallback($=>{h(L=>L.filter((Y,se)=>se!==$))},[]),X=()=>{const $=d.trim();!$&&m.length===0||i||(a($,m.length>0?m:void 0),f(""),h([]))},A=$=>{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:_,onDragLeave:z,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:()=>q(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:A,onCompositionStart:()=>{E.current=!0},onCompositionEnd:()=>{E.current=!1},onPaste:R,placeholder:i?"Waiting...":e==="talk"?"Ask something...":"Give a directive...",disabled:i,rows:1,className:"flex-1 bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] rounded-lg px-3 py-2 text-sm text-[var(--terminal-text)] placeholder:text-[var(--terminal-text-muted)] resize-none focus:outline-none focus:border-[var(--terminal-border-hover)] disabled:opacity-40 terminal-scrollbar"}),i&&u&&l.jsx("button",{onClick:u,className:"w-8 h-8 rounded-lg bg-red-900/40 text-red-400 flex items-center justify-center shrink-0 cursor-pointer hover:bg-red-900/60 hover:text-red-300 transition-colors",title:"Stop",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),l.jsx("button",{onClick: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 g6={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},mv={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function Kg(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function y6({msg:e}){const n=g6[e.roleId]??"#888",a=mv[e.roleId]??e.roleId;if(e.type==="dispatch"){const i=e.text.includes("WAVE"),o=e.text.includes("completed")||e.text.includes("완료"),u=i?"📡":o?"✓":"→",d=o?"text-green-400/70":"text-[var(--terminal-text-muted)]";return l.jsxs("div",{className:"flex items-start gap-2 px-3 py-1 hover:bg-white/[0.02]",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] shrink-0 w-10 text-right mt-0.5",children:Kg(e.ts)}),l.jsx("span",{className:"text-[10px] shrink-0 mt-0.5",children:u}),l.jsx("span",{className:`text-[11px] ${d}`,children:e.text})]})}return l.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-white/[0.02]",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] shrink-0 w-10 text-right mt-0.5",children:Kg(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 b6({channel:e,allRoles:n,onUpdateMembers:a,onUpdateTopic:i,onSendMessage:o}){const u=v.useRef(null),d=v.useRef(null),[f,m]=v.useState("");v.useEffect(()=>{var _;const C=d.current;if(!C)return;C.scrollHeight-C.scrollTop-C.clientHeight<80&&((_=u.current)==null||_.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 C;return(C=u.current)==null?void 0:C.scrollIntoView({behavior:"smooth"})},50))};return l.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[l.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto terminal-scrollbar py-2 min-h-0",children:[l.jsxs("div",{className:"px-3 py-2 mb-2 border-b border-[var(--terminal-border)] flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-[var(--terminal-text)]",children:e.name}),e.members.length>0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.members.map(C=>mv[C]??C).join(", ")}),e.members.length===0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.isDefault?"system logs":"no members"}),!e.isDefault&&n&&a&&l.jsx("button",{className:"ml-auto text-[10px] px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 text-[var(--terminal-text-muted)]",onClick:()=>x(!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:C=>j(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(i(e.id,b.trim()),w(!1)),C.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(C=>{const N=e.members.includes(C.id);return l.jsxs("button",{className:`text-[10px] px-2 py-1 rounded ${N?"bg-white/15 text-[var(--terminal-text)]":"bg-white/5 text-[var(--terminal-text-muted)]"}`,onClick:()=>{const _=N?e.members.filter(z=>z!==C.id):[...e.members,C.id];a(e.id,_)},children:[N?"✓ ":"",C.name]},C.id)})})}),e.messages.length===0&&l.jsx("div",{className:"flex-1 flex flex-col items-center justify-center text-[var(--terminal-text-muted)] text-xs gap-1 py-8",children:l.jsx("span",{children:e.isDefault?"No dispatch events yet":"No messages yet — invite roles to start chatting"})}),e.messages.map(C=>l.jsx(y6,{msg:C},C.id)),l.jsx("div",{ref:u})]}),k&&l.jsx("div",{className:"shrink-0 px-3 py-2 border-t border-[var(--terminal-border)]",children:l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("span",{className:"text-[10px] font-semibold shrink-0",style:{color:"#FFB300"},children:"CEO"}),l.jsx("input",{type:"text",value:f,onChange:C=>m(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.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 Mh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},v6=400,w6=800;function Pg({sessions:e,activeSessionId:n,roles:a,streamingSessionId:i,width:o,onWidthChange:u,onSwitchSession:d,onCloseSession:f,onCreateSession:m,onClearEmpty:h,onCloseAll:x,onSendMessage:g,onModeChange:w,onStopSession:b,onCloseTerminal:j,onMaximize:k,chatChannels:E,activeChatChannelId:C,onSwitchChatChannel:N,onCreateChatChannel:_,onDeleteChatChannel:z,onUpdateChatMembers:H,onUpdateChatTopic:R,onSendChatMessage:I,unreadChannels:q}){const[X,A]=v.useState(!1),[$,L]=v.useState(!1),[Y,se]=v.useState(!1),[ee,W]=v.useState(""),oe=C!=null,de=E==null?void 0:E.find(Ee=>Ee.id===C),[V,D]=v.useState(!1),[B,U]=v.useState(!1),[T,ie]=v.useState(!1),ge=v.useRef(0),pe=v.useRef(0),ze=v.useRef(null),Ie=e.find(Ee=>Ee.id===n),He=i===n,st=e.filter(Ee=>Ee.messages.length===0).length,Pe=v.useCallback(()=>{const Ee=ze.current;Ee&&(U(Ee.scrollLeft>0),ie(Ee.scrollLeft+Ee.clientWidth<Ee.scrollWidth-1))},[]);v.useEffect(()=>{if(!n||!ze.current)return;const Ee=ze.current.querySelector(`[data-session-id="${n}"]`);Ee&&Ee.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),Pe()},[n,e.length,Pe]),v.useEffect(()=>{const Ee=ze.current;if(!Ee)return;Pe(),Ee.addEventListener("scroll",Pe);const De=new ResizeObserver(Pe);return De.observe(Ee),()=>{Ee.removeEventListener("scroll",Pe),De.disconnect()}},[Pe]);const et=v.useCallback(Ee=>{Ee.preventDefault(),ge.current=Ee.clientX,pe.current=o,D(!0);const De=k,yt=()=>{D(!1),document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",yt)},ut=pt=>{const jt=ge.current-pt.clientX,Wt=pe.current+jt;if(Wt>=window.innerWidth*.6&&De){yt(),De();return}const Ft=Math.min(w6,Math.max(v6,Wt));u==null||u(Ft)};document.addEventListener("mousemove",ut),document.addEventListener("mouseup",yt)},[o,u,k]);return l.jsxs("div",{className:"shrink-0 bg-[var(--terminal-bg)] border-l border-[var(--terminal-border)] flex flex-col h-full relative",style:{width:o},children:[u&&l.jsx("div",{className:`terminal-resize-handle absolute top-0 left-0 w-1 h-full cursor-col-resize z-10 transition-colors ${V?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:et}),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:[B&&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:ze,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[E==null?void 0:E.map(Ee=>l.jsxs("button",{onClick:()=>{N==null||N(Ee.id)},className:`flex items-center gap-1 px-2.5 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors group ${C===Ee.id?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface)]"}`,style:C===Ee.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),l.jsx("span",{className:"truncate",children:Ee.name}),(q==null?void 0:q.has(Ee.id))&&C!==Ee.id&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!Ee.isDefault&&l.jsx("span",{onClick:De=>{De.stopPropagation(),z==null||z(Ee.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:"×"})]},Ee.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(Ee=>l.jsx(a6,{roleId:Ee.roleId,title:Ee.title,roleColor:Mh[Ee.roleId]??"#666",active:!oe&&Ee.id===n,isWave:Ee.source==="wave",isWaveStreaming:Ee.source==="wave"&&Ee.status==="active",onClick:()=>{N==null||N(null),d(Ee.id)},onClose:De=>{De.stopPropagation(),f(Ee.id)},"data-session-id":Ee.id},Ee.id))]}),T&&l.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-6 bg-gradient-to-l from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{A(!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:[_&&l.jsxs(l.Fragment,{children:[Y?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:ee,onChange:Ee=>W(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&ee.trim()&&(_(ee.trim(),[]),W(""),se(!1),A(!1)),Ee.key==="Escape"&&(se(!1),W(""))},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:()=>se(!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(Ee=>l.jsxs("button",{onClick:()=>{m(Ee.id),N==null||N(null),A(!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:Mh[Ee.id]??"#666"}}),Ee.id.toUpperCase()," — ",Ee.name]},Ee.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{L(!$),A(!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":""]}),st>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 (",st,")"]}),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:"×"})]}),oe&&de?l.jsx(b6,{channel:de,allRoles:a,onUpdateMembers:H,onUpdateTopic:R,onSendMessage:I}):Ie?l.jsxs(l.Fragment,{children:[l.jsx(hv,{messages:Ie.messages,roleId:Ie.roleId,roleColor:Mh[Ie.roleId]??"#666"}),l.jsx(Pm,{mode:Ie.mode,onModeChange:Ee=>w(Ie.id,Ee),onSend:(Ee,De)=>g(Ie.id,Ee,Ie.mode,De),disabled:He,disabledReason:He?`${Ie.roleId.toUpperCase()} is responding...`:void 0,onStop:He&&b?()=>b(Ie.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 k6(){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,u,d,f)=>{n();const m=new AbortController;return e.current=m,fetch(`/api/exec/session/${i}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o,mode:u,attachments:f}),signal:m.signal}).then(async h=>{var E,C,N,_,z;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:R}=await x.read();if(H)break;b=Date.now(),w+=g.decode(R,{stream:!0});const I=w.split(`
|
|
91
|
-
`);w=I.pop()??"";let q="";for(let X=0;X<I.length;X++){const A=I[X];if(A.startsWith("event: ")){q=A.slice(7).trim();continue}if(A.startsWith("data: ")){let $;try{$=JSON.parse(A.slice(6))}catch{q="";continue}switch(q){case"thinking":$.text&&((E=d.onThinking)==null||E.call(d,$.text));break;case"output":$.text&&d.onText($.text);break;case"tool":(C=d.onToolUse)==null||C.call(d,$.name,$.input);break;case"dispatch":(N=d.onDispatch)==null||N.call(d,$.roleId,$.task);break;case"dispatch:progress":(_=d.onDispatchProgress)==null||_.call(d,$.roleId,$.type,$);break;case"turn":(z=d.onTurn)==null||z.call(d,$.turn);break;case"done":d.onDone($);break;case"error":d.onError($.message??"Unknown error");break;default:$.text&&d.onText($.text);break}q=""}}}}finally{clearInterval(k)}}).catch(h=>{h.name!=="AbortError"&&d.onError(h.message)}),{abort:n}},[n]),abort:n}}const pv="tycono-appearances",xm="tycono-theme";function Qg(){try{const e=localStorage.getItem(pv);return e?JSON.parse(e):{}}catch{return{}}}function Rh(e){localStorage.setItem(pv,JSON.stringify(e))}function Zg(){try{const e=localStorage.getItem(xm);if(e&&e in ll)return e}catch{}return"default"}const xv=new Set;for(const e of Object.values(ll))for(const n of Object.keys(e.vars))xv.add(n);function j6(e){var i;const n=(i=ll[e])==null?void 0:i.vars;if(!n)return;const a=document.documentElement;for(const o of xv)o in n||a.style.removeProperty(o);for(const[o,u]of Object.entries(n))a.style.setProperty(o,u)}const zh={mode:"auto",intervalSec:18,dailyBudgetUsd:1},gm="tycono-speech-settings",_h="tycono-language";function S6(){try{const e=localStorage.getItem(gm);return e?{...zh,...JSON.parse(e)}:zh}catch{return zh}}function C6(){const[e,n]=v.useState(Qg),[a,i]=v.useState(Zg),[o,u]=v.useState(S6),[d,f]=v.useState(()=>{try{return localStorage.getItem(_h)??"auto"}catch{return"auto"}}),m=v.useRef(!1);v.useEffect(()=>{m.current||(m.current=!0,ye.getPreferences().then(k=>{const E=Object.keys(k.appearances??{}).length>0||k.theme!=="default";if(k.speech&&(u(C=>({...C,...k.speech})),localStorage.setItem(gm,JSON.stringify(k.speech))),k.language&&(f(k.language),localStorage.setItem(_h,k.language)),E){const C=k.appearances;n(C),Rh(C),k.theme&&k.theme in ll&&(i(k.theme),localStorage.setItem(xm,k.theme))}else{const C=Qg(),N=Zg();(Object.keys(C).length>0||N!=="default")&&ye.updatePreferences({appearances:C,theme:N}).catch(()=>{})}}).catch(()=>{}))},[]),v.useEffect(()=>{j6(a)},[a]);const h=v.useCallback(k=>e[k]??Km(k),[e]),x=v.useCallback((k,E)=>{n(C=>{const N={...C,[k]:E};return Rh(N),ye.updatePreferences({appearances:N}).catch(()=>{}),N})},[]),g=v.useCallback(k=>{n(E=>{const C={...E};return delete C[k],Rh(C),ye.updatePreferences({appearances:C}).catch(()=>{}),C})},[]),w=v.useCallback(k=>{i(k),localStorage.setItem(xm,k),ye.updatePreferences({theme:k}).catch(()=>{})},[]),b=v.useCallback(k=>{u(E=>{const C={...E,...k};return localStorage.setItem(gm,JSON.stringify(C)),ye.updatePreferences({speech:C}).catch(()=>{}),C})},[]),j=v.useCallback(k=>{f(k),localStorage.setItem(_h,k),ye.updatePreferences({language:k}).catch(()=>{})},[]);return{appearances:e,getAppearance:h,setAppearance:x,resetAppearance:g,theme:a,setTheme:w,speechSettings:o,setSpeechSettings:b,language:d,setLanguage:j}}const E6=3e4,N6=3e5;function A6(){var $;const[e,n]=v.useState("akb"),[a,i]=v.useState(null),[o,u]=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?u("no-git"):u(Y=>Y==="saving"?Y:L.dirty?"dirty":"synced")}catch{u("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{}},[]),C=v.useCallback(()=>{w.current&&clearInterval(w.current),k(),w.current=setInterval(k,E6),b.current&&clearInterval(b.current),E(),b.current=setInterval(E,N6)},[k,E]);v.useEffect(()=>()=>{w.current&&clearInterval(w.current),b.current&&clearInterval(b.current)},[]);const N=v.useCallback(L=>{n(L),j.current=L,i(null),h(null),f([]),setTimeout(()=>{k(),E()},0)},[k,E]),_=v.useCallback(async L=>{u("saving");try{const Y=await ye.save(L,j.current);return await k(),Y}catch(Y){throw u("error"),Y}},[k]),z=v.useCallback(async()=>{try{const L=await ye.getSaveHistory(20,j.current);f(L)}catch{}},[]),H=v.useCallback(async L=>{u("saving");try{await ye.restoreSave(L,void 0,j.current),await k()}catch(Y){throw u("error"),Y}},[k]),R=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(),await k()}catch{u("error")}},[k]),q=a?a.modified.length+a.untracked.length:0,X=(($=a==null?void 0:a.lastCommit)==null?void 0:$.date)??null,A=v.useCallback(async()=>{C()},[C]);return{state:o,dirtyCount:q,lastSaved:X,status:a,save:_,history:d,loadHistory:z,restore:H,refresh:A,initGit:I,repo:e,setRepo:N,syncInfo:m,fetchSyncStatus:E,pull:R,pulling:x}}const Jg={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."]},ey={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."]},D6=[{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."}]}],T6=18e3,ty=6e3,F6=2500,M6=30*6e4,gv="tycono:relationships";function R6(){try{const e=localStorage.getItem(gv);return e?JSON.parse(e):[]}catch{return[]}}function z6(e){localStorage.setItem(gv,JSON.stringify(e))}function yu(e,n,a){const[i,o]=n<a?[n,a]:[a,n];let u=e.find(d=>d.roleA===i&&d.roleB===o);return u||(u={roleA:i,roleB:o,dispatches:0,wavesTogether:0,conversations:0,familiarity:0,lastInteraction:new Date().toISOString()},e.push(u)),u}function bu(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function vu(e){return e[Math.floor(Math.random()*e.length)]}function _6(e,n,a){const i=a.find(f=>f.id===e),o=a.find(f=>f.id===n);if(!i||!o)return null;const u=i.level==="c-level",d=o.level==="c-level";return u&&d?"c-level":i.reportsTo===n||o.reportsTo===e?"superior-subordinate":(i.reportsTo===o.reportsTo,"peer")}function B6(e,n){return e.relation==="any"?!0:e.relation===n}function O6({roles:e,roleStatuses:n,activeExecs:a,getStandupSpeech:i}){const[o,u]=v.useState(new Map),[d,f]=v.useState(R6),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 z=Date.now();for(const[H,R]of Object.entries(n))R==="working"&&(m.current[H]=z)},[n]),v.useEffect(()=>{z6(d)},[d]);const k=v.useCallback(z=>{const H=g.current[z],R=w.current.find($=>$.roleId===z);if(H==="working"&&(R!=null&&R.task))return null;const I=b.current(z);if(I&&Math.random()<.3)return{text:I,type:"work",ts:Date.now()};const q=Date.now(),X=m.current[z]??0;if(q-X>M6&&Math.random()<.5){const $=ey[z]??ey.engineer;return{text:vu($),type:"guilt",ts:q}}const A=Jg[z]??Jg.engineer;return{text:vu(A),type:"personality",ts:q}},[]),E=v.useCallback(z=>{if(h.current)return!1;const H=z.filter(oe=>g.current[oe.id]!=="working");if(H.length<2)return!1;const R=[...H].sort(()=>Math.random()-.5),I=R[0],q=R[1],X=_6(I.id,q.id,z);if(!X)return!1;const A=yu(j.current,I.id,q.id),$=bu(A),L=D6.filter(oe=>B6(oe,X)&&$>=oe.minFamiliarity);if(L.length===0)return!1;const Y=vu(L);let se=I.id,ee=q.id;Y.relation==="superior-subordinate"&&(q.reportsTo===I.id||I.level==="c-level"?(se=I.id,ee=q.id):(se=q.id,ee=I.id)),h.current={templateId:Y.id,roleA:se,roleB:ee,turnIdx:0,timer:null};const W=oe=>{if(!h.current||oe>=Y.turns.length){h.current=null,f(B=>{const U=[...B],T=yu(U,se,ee);return T.conversations++,T.familiarity=bu(T),T.lastInteraction=new Date().toISOString(),U}),setTimeout(()=>{u(B=>{const U=new Map(B);return U.delete(se),U.delete(ee),U})},ty);return}const de=Y.turns[oe],V=de.speaker==="A"?se:ee,D=de.speaker==="A"?ee:se;u(B=>{const U=new Map(B);if(U.set(V,{text:de.text,type:"social",partnerId:D,ts:Date.now()}),oe>0){const T=Y.turns[oe-1].speaker==="A"?se:ee;T!==V&&U.delete(T)}return U}),h.current.turnIdx=oe,h.current.timer=setTimeout(()=>W(oe+1),F6)};return W(0),!0},[]);v.useEffect(()=>{const z=setInterval(()=>{const H=x.current;if(H.length===0||h.current||Math.random()<.35&&E(H))return;const R=H.filter(X=>g.current[X.id]!=="working");if(R.length===0)return;const I=vu(R),q=k(I.id);q&&(u(X=>{const A=new Map(X);return A.set(I.id,q),A}),setTimeout(()=>{u(X=>{const A=new Map(X),$=A.get(I.id);return $&&$.ts===q.ts&&A.delete(I.id),A})},ty))},T6);return()=>{var H;clearInterval(z),(H=h.current)!=null&&H.timer&&clearTimeout(h.current.timer)}},[k,E]);const C=v.useCallback(z=>{const H=o.get(z);return(H==null?void 0:H.text)??""},[o]),N=v.useCallback((z,H)=>{f(R=>{const I=[...R],q=yu(I,z,H);return q.dispatches++,q.familiarity=bu(q),q.lastInteraction=new Date().toISOString(),I})},[]),_=v.useCallback(z=>{z.length<2||f(H=>{const R=[...H];for(let I=0;I<z.length;I++)for(let q=I+1;q<z.length;q++){const X=yu(R,z[I],z[q]);X.wavesTogether++,X.familiarity=bu(X),X.lastInteraction=new Date().toISOString()}return R})},[]);return{speeches:o,getSpeech:C,relationships:d,notifyDispatch:N,notifyWave:_}}const yv="tycono:office-chat";let $6=0;function L6(){return`chat-${Date.now()}-${++$6}`}function Bh(){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 I6(){try{const e=localStorage.getItem(yv);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[...Bh(),...i]}const a=Bh();for(const i of a)n.find(o=>o.id===i.id)||n.unshift(i);return n}}catch{}return Bh()}function H6(e){const n=e.map(a=>({...a,messages:a.messages.slice(-200)}));localStorage.setItem(yv,JSON.stringify(n))}function U6(){const[e,n]=v.useState(I6),[a,i]=v.useState(null),[o,u]=v.useState(new Set);v.useEffect(()=>{H6(e)},[e]);const d=v.useCallback(b=>{i(b),b&&u(j=>{const k=new Set(j);return k.delete(b),k})},[]),f=v.useCallback(b=>{const j={...b,id:L6()};n(k=>{const E=k.map(C=>C.id==="general"?b.type==="dispatch"?{...C,messages:[...C.messages,j].slice(-200)}:C:b.channelId?C.id===b.channelId?{...C,messages:[...C.messages,j].slice(-200)}:C:C.members.length>0&&C.members.includes(b.roleId)?{...C,messages:[...C.messages,j].slice(-200)}:C);return u(C=>{const N=new Set(C);for(const _ of E){const z=k.find(H=>H.id===_.id);z&&_.messages.length>z.messages.length&&N.add(_.id)}return N}),E})},[]),m=v.useCallback((b,j,k)=>{const E=`ch-${Date.now()}`,C={id:E,name:b.startsWith("#")?b:`#${b}`,members:j,isDefault:!1,messages:[],topic:k};n(N=>[...N,C]),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(C=>C.level!=="c-level").map(C=>C.id);if(k.members.length!==E.length||!E.every(C=>k.members.includes(C)))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 q6=45e3,ny=5e3,Y6=4,X6=20;function W6({roles:e,roleStatuses:n,activeExecs:a,channels:i,relationships:o,pushMessage:u,speechSettings:d,engineType:f,hasApiKey:m}){const x=((d==null?void 0:d.mode)==="auto"?f==="claude-cli"||f==="local"?"llm":"template":(d==null?void 0:d.mode)??"template")==="llm"&&(m!==!1||f==="claude-cli"),g=((d==null?void 0:d.intervalSec)??q6/1e3)*1e3,w=v.useRef(e),b=v.useRef(n),j=v.useRef(a),k=v.useRef(i),E=v.useRef(o),C=v.useRef(u),N=v.useRef(0),_=v.useRef(!1);w.current=e,b.current=n,j.current=a,k.current=i,E.current=o,C.current=u;const z=v.useCallback(async(I,q)=>{if(_.current)return!1;_.current=!0;try{if(!w.current.find(W=>W.id===I))return!1;const A=q.messages.slice(-X6).map(W=>({roleId:W.roleId,text:W.text,ts:W.ts})),$=w.current.filter(W=>q.members.includes(W.id)),L=E.current.filter(W=>W.roleA===I||W.roleB===I).map(W=>({partnerId:W.roleA===I?W.roleB:W.roleA,familiarity:W.familiarity})),Y=j.current.find(W=>W.roleId===I),se=Y?{currentTask:Y.task,taskProgress:null}:{currentTask:null,taskProgress:null},ee=await ye.chatInChannel({channelId:q.name.replace("#",""),channelTopic:q.topic,roleId:I,history:A,members:$.map(W=>({id:W.id,name:W.name,level:W.level})),relationships:L,workContext:se});return ee.message?(C.current({ts:Date.now(),roleId:I,text:ee.message,type:"chat",channelId:q.id}),!0):!1}catch{return!1}finally{_.current=!1}},[]),H=v.useCallback(async(I,q)=>{if(N.current>=Y6){N.current=0;return}const X=I.members.filter(Y=>Y!==q&&b.current[Y]!=="working");if(X.length===0){N.current=0;return}const A=X[Math.floor(Math.random()*X.length)];if(Math.random()>.7){N.current=0;return}const $=N.current*2e3,L=Math.random()*5e3;setTimeout(async()=>{N.current++;const Y=k.current.find(ee=>ee.id===I.id);if(!Y)return;if(await z(A,Y)){const ee=.6-N.current*.1;Math.random()<ee?H(Y,A):N.current=0}else N.current=0},ny+$+L)},[z]);return v.useEffect(()=>{if(!x)return;const I=setInterval(async()=>{const q=w.current;if(q.length===0||_.current)return;const X=q.filter(se=>b.current[se.id]!=="working");if(X.length===0)return;const A=X[Math.floor(Math.random()*X.length)],$=k.current.filter(se=>se.members.length===0?!0:se.members.includes(A.id));if($.length===0)return;const L=$[Math.floor(Math.random()*$.length)];N.current=0,await z(A.id,L)&&H(L,A.id)},g);return()=>clearInterval(I)},[x,g,z,H]),{triggerCeoReaction:v.useCallback(I=>{if(!x)return;const q=k.current.find(X=>X.id===I);q&&(N.current=0,setTimeout(()=>{H(q,"ceo")},ny))},[x,H])}}const bv=[[1,8],[3,5],[8,1],[5,3]],G6=[[1,4],[2,3],[4,1],[3,2]];function wu(e){const n=e===1||e===3?-1:0,a=bv[e],i=e<2?[0,1]:[1,0],o=n;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:a[0],y:13,w:3,h:4,c:"$pants"},{x:a[1],y:13,w:3,h:4,c:"$pants"},{x:a[0]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:a[1]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:a[0],y:16,w:3,h:2,c:"$shoes"},{x:a[1],y:16,w:3,h:2,c:"$shoes"},{x:a[0],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:a[1],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:1,y:o+8,w:10,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.35},{x:1,y:o+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:10,y:o+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:-1,y:o+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:o+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:-1,y:o+12,w:2,h:1,c:"$skin"},{x:11,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:1,y:o+0,w:10,h:7,c:"$skin"},{x:3,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:o+3,w:1,h:1,c:"#FFF",a:.4},{x:7,y:o+3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:o+6,w:2,h:1,c:"darken($skin, 25)",a:.35},{x:0,y:o+3,w:1,h:1,c:"$skin"},{x:11,y:o+3,w:1,h:1,c:"$skin"},{x:1,y:o+0,w:10,h:3,c:"$hair"},{x:0,y:o+1,w:2,h:3,c:"$hair"},{x:10,y:o+1,w:2,h:3,c:"$hair"},{x:2,y:o+0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]}function ku(e){const n=e===1||e===3?-1:0,a=bv[e],i=e<2?[0,1]:[1,0],o=n;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:a[0],y:13,w:3,h:4,c:"$pants"},{x:a[1],y:13,w:3,h:4,c:"$pants"},{x:a[0],y:16,w:3,h:2,c:"$shoes"},{x:a[1],y:16,w:3,h:2,c:"$shoes"},{x:1,y:o+8,w:10,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:5,y:o+10,w:2,h:3,c:"darken($shirt, 30)",a:.12},{x:-1,y:o+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:o+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:1,y:o+0,w:10,h:7,c:"$skin"},{x:1,y:o+0,w:10,h:6,c:"$hair"},{x:0,y:o+1,w:2,h:5,c:"$hair"},{x:10,y:o+1,w:2,h:5,c:"$hair"},{x:2,y:o+0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:0,y:o+4,w:1,h:1,c:"$skin",a:.6},{x:11,y:o+4,w:1,h:1,c:"$skin",a:.6}]}function Bl(e,n){const a=e===1||e===3?-1:0,i=G6[e],o=a,u=e%2===0?1:0;return n?[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:i[0],y:13,w:3,h:4,c:"$pants"},{x:i[1],y:13,w:3,h:4,c:"$pants"},{x:i[0],y:16,w:3,h:2,c:"$shoes"},{x:i[1],y:16,w:3,h:2,c:"$shoes"},{x:2,y:o+8,w:8,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:8,y:o+9+u,w:3,h:4-u,c:"$shirt"},{x:9,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:2,y:o+0,w:8,h:7,c:"$skin"},{x:7,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:o+3,w:1,h:1,c:"#FFF",a:.3},{x:9,y:o+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:o+0,w:8,h:3,c:"$hair"},{x:1,y:o+1,w:2,h:4,c:"$hair"},{x:9,y:o+1,w:2,h:3,c:"$hair"},{x:3,y:o+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]:[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:i[0],y:13,w:3,h:4,c:"$pants"},{x:i[1],y:13,w:3,h:4,c:"$pants"},{x:i[0],y:16,w:3,h:2,c:"$shoes"},{x:i[1],y:16,w:3,h:2,c:"$shoes"},{x:2,y:o+8,w:8,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:0,y:o+9+u,w:3,h:4-u,c:"$shirt"},{x:-1,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:2,y:o+0,w:8,h:7,c:"$skin"},{x:3,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:o+3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:o+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:o+0,w:8,h:3,c:"$hair"},{x:1,y:o+1,w:2,h:3,c:"$hair"},{x:9,y:o+1,w:2,h:4,c:"$hair"},{x:3,y:o+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]}const ry={down:[wu(0),wu(1),wu(2),wu(3)],up:[ku(0),ku(1),ku(2),ku(3)],right:[Bl(0,!0),Bl(1,!0),Bl(2,!0),Bl(3,!0)],left:[Bl(0,!1),Bl(1,!1),Bl(2,!1),Bl(3,!1)]},Fe="#FAFAF7",Yn="#FFFFFF",Te="#EDE8E2",Qe="#DDD6CC",qo="#1A1A2E",Zu="#2A2A2A",Qm="#FFB0B0",ay=[{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:Qe},{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:Qe},{x:0,y:2,w:1,h:1,c:Qe},{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:Qe},{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:qo},{x:4,y:3,w:1,h:1,c:Fe},{x:5,y:3,w:1,h:1,c:qo},{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:Zu},{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:Qe},{x:4,y:5,w:1,h:1,c:Te},{x:5,y:5,w:1,h:1,c:Qe},{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:Qe},{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:Qe}],V6=[{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:Qe},{x:5,y:9,w:1,h:1,c:Qe}],K6=[{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:Qe},{x:6,y:9,w:1,h:1,c:Qe}],ly=[{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:Qe},{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:Qe},{x:0,y:2,w:1,h:1,c:Qe},{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:Qe},{x:1,y:3,w:1,h:1,c:Qe},{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:Qe},{x:2,y:4,w:1,h:1,c:Qe},{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:Qe},{x:3,y:5,w:1,h:1,c:Qe},{x:4,y:5,w:1,h:1,c:Te},{x:5,y:5,w:1,h:1,c:Qe},{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:Qe},{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:Qe},{x:4,y:5,w:1,h:1,c:Fe},{x:4,y:4,w:1,h:1,c:Yn}],P6=[{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:Qe},{x:5,y:9,w:1,h:1,c:Qe}],Q6=[{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:Qe},{x:6,y:9,w:1,h:1,c:Qe}],ym=[{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:Qe},{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:Qe},{x:3,y:3,w:1,h:1,c:Qe},{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:Qe},{x:8,y:3,w:1,h:1,c:Fe},{x:9,y:3,w:1,h:1,c:qo},{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:Qe},{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:Zu}],vv=[{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:Qe},{x:6,y:6,w:1,h:1,c:Qe},{x:8,y:6,w:1,h:1,c:Qe},{x:10,y:6,w:1,h:1,c:Qe}],wv=[{x:3,y:5,w:1,h:1,c: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:Qe},{x:5,y:6,w:1,h:1,c:Qe},{x:9,y:6,w:1,h:1,c:Qe},{x:11,y:6,w:1,h:1,c:Qe}];function Zm(e,n=13){return e.map(a=>({...a,x:n-1-a.x}))}const iy=Zm(ym),Z6=Zm(vv),J6=Zm(wv),eA={down:[[...ay,...V6],[...ay,...K6]],up:[[...ly,...P6],[...ly,...Q6]],right:[[...ym,...vv],[...ym,...wv]],left:[[...iy,...Z6],[...iy,...J6]]},tA=[{x:4,y:5,w:1,h:1,c:Qm}],On="#FFD4D4",Kr="#FFCCD5",nA=[{x:2,y:0,w:1,h:1,c:Qe},{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:Qe},{x:1,y:1,w:1,h:1,c:Qe},{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:Qe},{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:qo},{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:qo},{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:Zu},{x:5,y:3,w:1,h:1,c:Qm},{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:Qe},{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:Qe},{x:0,y:5,w:1,h:1,c:Te},{x:1,y:5,w:1,h:1,c:Kr},{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:Kr},{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:Kr},{x:5,y:6,w:1,h:1,c:Kr},{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:Kr},{x:2,y:8,w:1,h:1,c:Qe},{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:Qe},{x:8,y:8,w:1,h:1,c:Kr},{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}],rA=[{x:2,y:0,w:1,h:1,c:Qe},{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:Qe},{x:1,y:1,w:1,h:1,c:Qe},{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:Qe},{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:Zu},{x:5,y:3,w:1,h:1,c:Qm},{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:Qe},{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:Qe},{x:0,y:5,w:1,h:1,c:Te},{x:1,y:5,w:1,h:1,c:Kr},{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:Kr},{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:Kr},{x:5,y:6,w:1,h:1,c:Kr},{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:Kr},{x:2,y:8,w:1,h:1,c:Qe},{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:Qe},{x:8,y:8,w:1,h:1,c:Kr},{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}],aA=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],lA=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],iA=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],ct=4,an=28,qn=2,zt=4,Ct=4,rl=[{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 Jm(e,n,a){const u=e.fy+Math.max(10,Math.floor(e.fh*.18)),d=Math.min(n,a),f=Math.ceil(n/d),m=[],h=d*28,x=e.fx+Math.max(8,Math.floor((e.fw-h)/2));for(let g=0;g<f&&m.length<n;g++){const w=Math.min(d,n-g*d);for(let b=0;b<w;b++)m.push({dx:x+b*28,dy:u+g*28,room:e.id})}return m}function sA(e){const i=rl[0],o={id:"main",wx:ct+Ct,wy:ct,ww:160-2*(ct+Ct),wh:an,fx:ct+Ct,fy:ct+an+qn,fw:160-2*(ct+Ct),fh:120-ct-an-qn-ct,...i},u=Jm(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*(ct+Ct))/2),offsetY:10}],f=[{id:"s-plant-l",type:"plant",room:"main",zone:"floor",offsetX:4,offsetY:4},{id:"s-plant-r",type:"plant",room:"main",zone:"floor",anchorX:"right",offsetX:-8,offsetY:4}];return{preset:"S",canvasW:160,canvasH:120,rooms:{main:o},desks:u,doors:{},adjacency:{main:[]},corridorY:{main:o.fy+o.fh-12},waypoints:{main:[{x:o.fx+10,y:o.fy+o.fh-14},{x:o.fx+o.fw/2,y:o.fy+o.fh-14},{x:o.fx+o.fw-10,y:o.fy+o.fh-14}]},wallDecorations:d,furniture:f}}function oA(e){const o={id:"exec",wx:ct+Ct,wy:ct,ww:144-ct-Ct-zt/2,wh:an,fx:ct+Ct,fy:ct+an+qn,fw:144-ct-Ct-zt/2,fh:66,...rl[0]},u={id:"work",wx:144+zt/2+Ct,wy:ct,ww:144-zt/2-Ct-ct,wh:an,fx:144+zt/2+Ct,fy:ct+an+qn,fw:144-zt/2-Ct-ct,fh:66,...rl[1]},d={id:"meet",wx:ct+Ct,wy:ct+an+qn+66+zt,ww:144-ct-Ct-zt/2,wh:an,fx:ct+Ct,fy:ct+an+qn+66+zt+an+qn,fw:144-ct-Ct-zt/2,fh:70,...rl[2]},f={id:"comm",wx:144+zt/2+Ct,wy:ct+an+qn+66+zt,ww:144-zt/2-Ct-ct,wh:an,fx:144+zt/2+Ct,fy:ct+an+qn+66+zt+an+qn,fw:144-zt/2-Ct-ct,fh:70,...rl[3]},m={exec:o,work:u,meet:d,comm:f},h=[];let x=e;const g=[[o,Math.min(3,x)],[u,0]];g[1][1]=Math.min(3,x-g[0][1]);const 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[R,I]of[...g,...w])I>0&&h.push(...Jm(R,I,3));const j=ct+an+qn+66,k=144-zt/2,E={exec_work:{id:"exec_work",type:"v",doorY:ct+an+qn+20+12,xA:k-2,xB:u.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:ct+an+qn+66+zt+an+qn+20+12,xA:k-2,xB:f.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:ct+Ct+40+14,yA:j-2,yB:d.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+zt/2+Ct+40+14,yA:j-2,yB:f.fy+2}},C={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},N={exec:o.fy+52,work:u.fy+48,meet:d.fy+56,comm:f.fy+54},_={exec:[{x:o.fx+6,y:o.fy+52},{x:o.fx+60,y:o.fy+54},{x:o.fx+112,y:o.fy+50},{x:o.fx+50,y:o.fy+52}],work:[{x:u.fx+14,y:u.fy+48},{x:u.fx+44,y:u.fy+48},{x:u.fx+70,y:u.fy+48},{x:u.fx+100,y:u.fy+48}],meet:[{x:d.fx+60,y:d.fy+56},{x:d.fx+30,y:d.fy+54},{x:d.fx+110,y:d.fy+50},{x:d.fx+80,y:d.fy+56}],comm:[{x:f.fx+96,y:f.fy+8},{x:f.fx+60,y:f.fy+54},{x:f.fx+40,y:f.fy+54},{x:f.fx+20,y:f.fy+54}]},z=[{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:C,corridorY:N,waypoints:_,wallDecorations:z,furniture:H}}function cA(e){const d={id:"exec",wx:ct+Ct,wy:ct,ww:180-ct-Ct-zt/2,wh:an,fx:ct+Ct,fy:ct+an+qn,fw:180-ct-Ct-zt/2,fh:82,...rl[0]},f={id:"work",wx:180+zt/2+Ct,wy:ct,ww:180-zt/2-Ct-ct,wh:an,fx:180+zt/2+Ct,fy:ct+an+qn,fw:180-zt/2-Ct-ct,fh:82,...rl[1]},m=ct+an+qn+82,h={id:"meet",wx:ct+Ct,wy:m+zt,ww:180-ct-Ct-zt/2,wh:an,fx:ct+Ct,fy:m+zt+an+qn,fw:180-ct-Ct-zt/2,fh:86,...rl[2]},x={id:"comm",wx:180+zt/2+Ct,wy:m+zt,ww:180-zt/2-Ct-ct,wh:an,fx:180+zt/2+Ct,fy:m+zt+an+qn,fw:180-zt/2-Ct-ct,fh:86,...rl[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[q,X]of[...j,...k])X>0&&w.push(...Jm(q,X,4));const C=180-zt/2,N={exec_work:{id:"exec_work",type:"v",doorY:d.fy+82/2,xA:C-2,xB:f.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:h.fy+86/2,xA:C-2,xB:x.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:d.fx+54,yA:m-2,yB:h.fy+2},work_comm:{id:"work_comm",type:"h",doorX:f.fx+54,yA:m-2,yB:x.fy+2}},_={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},z={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:z.exec},{x:d.fx+d.fw/2,y:z.exec},{x:d.fx+d.fw-10,y:z.exec}],work:[{x:f.fx+10,y:z.work},{x:f.fx+f.fw/2,y:z.work},{x:f.fx+f.fw-10,y:z.work}],meet:[{x:h.fx+10,y:z.meet},{x:h.fx+h.fw/2,y:z.meet},{x:h.fx+h.fw-10,y:z.meet}],comm:[{x:x.fx+10,y:z.comm},{x:x.fx+x.fw/2,y:z.comm},{x:x.fx+x.fw-10,y:z.comm}]},R=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0",facility:{id:"theme",label:"THEME",icon:"🎨",color:"#42A5F5",hitW:12,hitH:10}},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10,facility:{id:"settings",label:"SETTINGS",icon:"⚙",color:"#78909C",hitW:10,hitH:10}},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:14,facility:{id:"stats",label:"STATS",icon:"📊",color:"#7E57C2",hitW:16,hitH:8}},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"📋",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"📜",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],I=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(d.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:42,facility:{id:"meeting",label:"MEETING",icon:"🏢",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"📚",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"L",canvasW:360,canvasH:260,rooms:g,desks:w,doors:N,adjacency:_,corridorY:z,waypoints:H,wallDecorations:R,furniture:I}}const uA=2;function kv(e,n,a){return a||(n?n==="L"&&e<=12-uA?"M":n==="M"&&e>12?"L":n:e<=12?"M":"L")}function jv(e,n){switch(n??kv(e)){case"S":return sA(e);case"M":return oA(e);case"L":return cA(e)}}function dA(e,n){if(!n||Object.keys(n).length===0)return e;const a=i=>i.map(o=>{const u=n[o.id];return u?{...o,offsetX:u.offsetX,offsetY:u.offsetY}:o});return{...e,wallDecorations:a(e.wallDecorations),furniture:a(e.furniture)}}function fA(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 sy(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 hA(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 zo;function mA(e){zo=e}function O(e,n,a,i,o,u){e=Math.round(e),n=Math.round(n),!(u!==void 0&&u<.01)&&(u!==void 0&&u!==1&&(zo.globalAlpha=u),zo.fillStyle=o,zo.fillRect(e,n,a,i),u!==void 0&&u!==1&&(zo.globalAlpha=1))}function it(e,n,a,i){O(e,n,1,1,a,i)}let Mu=1;function Ts(e){Mu=e}function Ea(){return Mu=Mu*16807%2147483647,(Mu&65535)/65535}function Sv(e){const n=parseInt(e.slice(1,3),16)/255,a=parseInt(e.slice(3,5),16)/255,i=parseInt(e.slice(5,7),16)/255,o=Math.max(n,a,i),u=Math.min(n,a,i);let d=0,f=0;const m=(o+u)/2;if(o!==u){const h=o-u;f=m>.5?h/(2-o-u):h/(o+u),o===n?d=((a-i)/h+(a<i?6:0))/6:o===a?d=((i-n)/h+2)/6:d=((n-a)/h+4)/6}return[d*360,f*100,m*100]}function Cv(e,n,a){e=(e%360+360)%360,n=Math.max(0,Math.min(100,n))/100,a=Math.max(0,Math.min(100,a))/100;const i=n*Math.min(a,1-a),o=d=>{const f=(d+e/30)%12;return a-i*Math.max(-1,Math.min(f-3,9-f,1))},u=d=>Math.round(d*255).toString(16).padStart(2,"0");return"#"+u(o(0))+u(o(8))+u(o(4))}function Na(e,n=1){const[a,i,o]=Sv(e);return Cv(a+15*n,Math.min(100,i+8),o-12*n)}function bn(e,n=1){const[a,i,o]=Sv(e);return Cv(a-10*n,i-3,o+10*n)}const Un={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},_r={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},ba={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},Pr="#100A06";function pA(e,n,a=14,i=12){O(e,n,a,i,"#4A3828"),O(e+1,n+1,a-2,i-2,"#5A4838"),O(e+2,n+2,a-4,i-4,"#4A7098"),O(e+2,n+2,a-4,Math.floor((i-4)/2),"#6A90B8",.35);const o=Math.floor(a/2);O(e+o,n+1,1,i-2,"#4A3828"),O(e+1,n+Math.floor(i/2),a-2,1,"#4A3828",.5),it(e+3,n+3,"#8AB8E8",.35),it(e+o+2,n+3,"#8AB8E8",.25),O(e-1,n+i,a+2,2,"#5A4838"),O(e-1,n+i,a+2,1,bn("#5A4838",.5),.35)}function xA(e,n,a){O(e,n,10,8,"#3A2818"),O(e+1,n+1,8,6,a),O(e+2,n+2,4,3,bn(a,1.2),.3),it(e+3,n+2,bn(a,2),.25)}function gA(e,n){O(e,n,7,7,"#3A2818"),O(e+1,n+1,5,5,"#F0EDE5"),it(e+3,n+1,"#AAA"),it(e+3,n+5,"#AAA"),it(e+1,n+3,"#AAA"),it(e+5,n+3,"#AAA"),it(e+3,n+3,"#222"),O(e+3,n+1,1,2,"#333"),it(e+4,n+3,"#D32F2F")}function yA(e,n){O(e,n,26,16,"#586878"),O(e+1,n+1,24,13,"#ECEFF1"),O(e+1,n+1,24,1,"#F5F5F5",.4),O(e+3,n+3,14,1,"#1565C0",.6),O(e+3,n+5,18,1,"#333",.2),O(e+3,n+7,12,1,"#D32F2F",.35),O(e+3,n+9,16,1,"#333",.15),O(e+1,n+14,24,2,"#708898"),O(e+3,n+14,3,1,"#D32F2F"),O(e+7,n+14,3,1,"#1565C0"),O(e+11,n+14,3,1,"#2E7D32")}function bA(e,n){O(e,n,22,16,"#6A5030"),O(e+1,n+1,20,14,"#C4A66A"),Ts(88);for(let a=0;a<14;a++)for(let i=0;i<20;i++)Ea()>.5&&it(e+1+i,n+1+a,Ea()>.5?"#B89858":"#D4B87A",.18);O(e+2,n+2,5,4,"#FFF176"),O(e+8,n+2,5,4,"#90CAF9"),O(e+14,n+3,5,4,"#CE93D8"),O(e+3,n+8,7,4,"#C8E6C9"),O(e+11,n+8,8,4,"#F8BBD0"),it(e+4,n+2,"#E53935"),it(e+10,n+2,"#1E88E5"),it(e+16,n+3,"#FF9800")}function vA(e,n){O(e,n,20,3,"#5A4030"),O(e,n,20,1,bn("#5A4030",.5),.35),O(e,n+2,20,1,Na("#5A4030",.5),.3),O(e+2,n-4,3,4,"#E53935"),O(e+2,n-4,3,1,bn("#E53935",1),.3),O(e+6,n-3,2,3,"#1E88E5"),O(e+9,n-5,4,5,"#43A047"),O(e+14,n-3,3,3,"#FFD54F"),it(e+15,n-3,"#FFF176",.4)}function wA(e,n){O(e,n,16,12,"#1E1E28"),O(e+1,n+1,14,9,"#0C1420"),O(e+2,n+2,12,1,"#EF4444",.6),it(e+2,n+4,"#4CAF50"),O(e+4,n+4,7,1,"#8b949e",.4),it(e+2,n+6,"#FF9800"),O(e+4,n+6,5,1,"#8b949e",.3),it(e+2,n+8,"#42A5F5"),O(e+4,n+8,8,1,"#8b949e",.25),O(e+7,n+10,2,2,"#1E1E28"),O(e+5,n+11,6,1,"#586878")}function kA(e,n,a){O(e+2,n+20,22,2,Pr,.15),O(e,n,22,20,_r.deep),O(e+1,n+1,20,18,_r.base),O(e,n,22,1,_r.hi,.35),O(e,n,1,20,_r.hi,.2);for(const u of[6,12])O(e+1,n+u,20,2,_r.sh),O(e+1,n+u,20,1,_r.hi,.2);const i=["#E53935","#1E88E5","#43A047","#8E24AA","#FB8C00","#00897B","#5C6BC0"];let o=e+2;for(let u=0;u<5;u++){const d=2+u%2;O(o,n+1,d,5,i[u]),O(o,n+1,d,1,bn(i[u],1),.35),o+=d+1}o=e+2;for(let u=0;u<4;u++)O(o,n+7,4,5,i[u+3]),O(o,n+7,4,1,bn(i[u+3],1),.25),o+=5;O(e+2,n+14,4,4,"#FFD54F"),O(e+8,n+14,7,4,"#90CAF9"),a&&O(e,n-1,22,1,a,.7)}function jA(e,n){O(e+2,n+11,6,2,Pr,.1),O(e+2,n+8,6,4,"#8B5E3C"),O(e+1,n+7,8,2,Na("#A06E48",.3)),O(e+2,n+7,6,1,bn("#A06E48",.5),.4),O(e+1,n+3,3,4,"#2E7D32"),O(e+5,n+2,3,4,"#2E7D32"),O(e+2,n+1,4,4,"#43A047"),O(e+3,n+0,3,3,"#66BB6A"),it(e+4,n,"#81C784"),it(e+3,n+1,"#A5D6A7",.4)}function SA(e,n){vi(e+4,n-4,"down"),vi(e+16,n-4,"down"),vi(e+28,n-4,"down"),O(e+3,n+24,34,3,Pr,.15),O(e,n+2,36,18,Un.deep),O(e+1,n+3,34,16,Un.base),O(e+1,n+3,34,1,Un.hi,.35);for(let a=0;a<14;a+=3)O(e+1,n+4+a,34,1,Na(Un.base,.2),.08);O(e,n+20,36,4,Un.deep),O(e+1,n+21,34,2,Un.sh),O(e+6,n+7,10,6,"#1A1A24"),O(e+7,n+8,8,4,"#0C1420"),O(e+8,n+9,4,1,"#2A6898",.4),O(e+20,n+8,6,4,"#F0F0F0"),O(e+15,n+7,3,3,"#ECEFF1"),it(e+16,n+8,"#795548"),vi(e+4,n+24,"up"),vi(e+16,n+24,"up"),vi(e+28,n+24,"up")}function CA(e,n){O(e+2,n+16,36,3,Pr,.15),O(e,n,36,5,"#5D4037"),O(e+1,n+1,34,3,"#6D4C41"),O(e+1,n+1,34,1,bn("#6D4C41",.5),.3),O(e,n+5,36,8,"#5D4037"),O(e+2,n+6,15,6,"#6D4C41"),O(e+3,n+6,13,1,bn("#6D4C41",.5),.35),O(e+19,n+6,15,6,"#6D4C41"),O(e+20,n+6,13,1,bn("#6D4C41",.5),.35),O(e+17,n+6,2,6,"#5D4037"),O(e,n+13,36,3,Na("#5D4037",1)),O(e-2,n+2,3,12,"#5D4037"),O(e+35,n+2,3,12,"#5D4037"),O(e+4,n+7,6,4,"#FF8A65"),O(e+5,n+7,4,1,bn("#FF8A65",1),.35)}function EA(e,n){O(e+2,n+10,22,2,Pr,.12),O(e,n,22,8,_r.deep),O(e+1,n+1,20,6,_r.base),O(e+1,n+1,20,1,_r.hi,.3),O(e,n+8,22,2,_r.sh),O(e+3,n+2,6,4,"#F0F0F0"),O(e+13,n+3,3,3,"#ECEFF1"),it(e+14,n+4,"#795548")}function NA(e,n){O(e+1,n+14,10,2,Pr,.12),O(e,n,10,14,"#546E7A"),O(e,n,10,1,bn("#546E7A",1),.35),O(e+1,n+1,8,3,"#78909C"),O(e+1,n+5,8,4,"#37474F"),it(e+2,n+6,"#EF5350"),it(e+4,n+6,"#66BB6A"),O(e+2,n+11,4,2,"#ECEFF1")}function AA(e,n){O(e+2,n+18,28,3,Pr,.12),O(e,n,28,18,"#37474F"),O(e+1,n+1,26,15,"#0D47A1"),O(e+2,n+2,24,13,"#1565C0"),O(e+2,n+2,24,4,"#1976D2",.4),O(e+2,n+12,24,3,"#F9A825",.35),O(e+4,n+8,2,5,"#2E7D32"),O(e+6,n+9,2,4,"#43A047"),O(e+20,n+7,2,6,"#2E7D32"),O(e+22,n+8,2,5,"#388E3C"),O(e+9,n+5,4,2,"#FF8A65"),it(e+12,n+5,"#FF5722"),O(e+16,n+8,3,2,"#FFD54F"),it(e+15,n+8,"#FFC107"),it(e+13,n+3,"#90CAF9",.5),it(e+14,n+4,"#BBDEFB",.35),it(e+8,n+3,"#BBDEFB",.3),O(e,n+16,28,2,"#455A64"),O(e+1,n+16,26,1,bn("#455A64",.5),.3)}function DA(e,n){O(e,n,24,10,"#1A1A2E"),O(e+2,n+1,20,8,"#E040FB",.15),O(e+3,n+2,4,6,"#E040FB",.7),O(e+4,n+3,2,4,"#1A1A2E"),O(e+8,n+2,1,6,"#00E5FF",.7),O(e+8,n+2,4,1,"#00E5FF",.7),O(e+8,n+4,4,1,"#00E5FF",.7),O(e+11,n+2,1,3,"#00E5FF",.7),O(e+13,n+2,1,6,"#E040FB",.7),O(e+13,n+2,4,1,"#E040FB",.7),O(e+13,n+4,3,1,"#E040FB",.7),O(e+13,n+7,4,1,"#E040FB",.7),O(e+18,n+2,1,6,"#00E5FF",.7),O(e+21,n+2,1,6,"#00E5FF",.7),O(e+19,n+3,1,2,"#00E5FF",.5),O(e+20,n+5,1,2,"#00E5FF",.5)}function TA(e,n){O(e+2,n+28,16,3,Pr,.15),O(e,n,16,28,"#1A237E"),O(e+1,n+1,14,3,"#283593"),O(e+2,n+4,12,10,"#0D1117"),O(e+3,n+5,10,8,"#1B5E20"),O(e+5,n+6,2,2,"#4CAF50"),O(e+9,n+8,2,2,"#FF5722"),O(e+7,n+10,3,1,"#FFD54F"),it(e+6,n+7,"#81C784"),O(e+1,n+14,14,6,"#1A237E"),O(e+2,n+15,4,4,"#212121"),it(e+4,n+16,"#F44336"),it(e+9,n+16,"#F44336"),it(e+11,n+16,"#2196F3"),it(e+10,n+18,"#FFEB3B"),O(e,n+20,16,8,"#0D47A1"),O(e+1,n+21,14,6,"#1565C0"),O(e,n+4,1,14,"#FF4081",.4),O(e+15,n+4,1,14,"#FF4081",.4)}function FA(e,n){O(e+2,n+24,20,3,Pr,.15),O(e,n,20,24,"#4E342E"),O(e+1,n+1,18,22,"#5D4037"),O(e+2,n+1,16,4,"#FF6F00"),O(e+3,n+2,14,2,"#FF8F00",.6),O(e+2,n+5,16,10,"#1A1A2E"),O(e+3,n+6,14,8,"#212121"),O(e+4,n+7,4,4,"#333"),O(e+5,n+8,2,2,"#E53935"),O(e+10,n+7,4,4,"#333"),O(e+11,n+8,2,2,"#1E88E5"),O(e+3,n+16,14,6,"#3E2723");for(let a=0;a<7;a++)O(e+4+a*2,n+17,1,4,"#5D4037",.5);O(e+1,n+5,18,1,"#FFD54F",.5),O(e+1,n+15,18,1,"#FFD54F",.5)}function MA(e,n){O(e+2,n+22,22,2,Pr,.12),O(e,n,22,22,_r.deep),O(e+1,n+1,20,20,"#37474F"),O(e+2,n+2,18,18,"#546E7A",.3),O(e+1,n+10,20,1,_r.base),O(e+1,n+10,20,1,_r.hi,.2),O(e+4,n+3,4,5,"#FFD54F"),O(e+5,n+4,2,3,"#FFC107"),O(e+4,n+7,4,1,"#FFA000"),it(e+5,n+3,"#FFF176",.5),O(e+13,n+4,4,4,"#B0BEC5"),O(e+14,n+3,2,1,"#CFD8DC"),it(e+14,n+5,"#ECEFF1",.6),O(e+5,n+12,3,3,"#A1887F"),O(e+6,n+11,1,1,"#D7CCC8"),O(e+12,n+12,6,4,"#5D4037"),O(e+13,n+13,4,2,"#FFD54F",.6),O(e+2,n+2,2,18,"#fff",.08)}function RA(e,n){O(e+2,n+16,26,3,Pr,.18),O(e,n,26,10,Un.deep),O(e+1,n+1,24,8,Un.base),O(e+1,n+2,24,1,Un.hi,.2),O(e+1,n+4,24,1,Na(Un.base,.2),.1),O(e+1,n+6,24,1,Un.hi,.15),O(e+1,n+1,24,1,Un.hi,.4),O(e+1,n+1,1,8,Un.hi,.2),O(e,n+10,26,5,Un.deep),O(e+1,n+11,24,3,Un.sh),O(e+1,n+10,24,1,Na(Un.base,1.5),.4),O(e+1,n+14,24,1,Un.base,.15),O(e+2,n+12,10,1,Un.deep,.4),O(e+14,n+12,10,1,Un.deep,.4),it(e+7,n+11,"#C8D0D8",.6),it(e+19,n+11,"#C8D0D8",.6),O(e+6,n-5,14,7,"#1E1E28"),O(e+7,n-4,12,5,"#0C1420"),O(e+8,n-3,5,1,"#2A6898",.6),O(e+8,n-2,8,1,"#1A3858",.4),O(e+8,n-1,3,1,"#2A6898",.35),it(e+7,n-4,"#4A98D8",.25),it(e+12,n+1,"#4CAF50",.4),O(e+12,n+2,2,3,"#586878"),O(e+10,n+4,6,1,"#8898A8"),O(e+6,n+4,12,4,"#222228"),O(e+6,n+4,12,1,"#333338",.4);for(let a=0;a<5;a++)it(e+7+a*2,n+5,"#444",.6),it(e+7+a*2,n+6,"#3A3A3E",.4);O(e+20,n+5,3,4,"#333338"),O(e+20,n+5,3,1,"#444448"),O(e+1,n+3,4,4,"#F0EDE8"),O(e+1,n+3,4,1,"#F8F6F2"),it(e+2,n+5,"#6D4C41")}function vi(e,n,a){O(e+1,n+9,10,2,Pr,.1),it(e+5,n+9,"#1E1E22"),it(e+1,n+10,"#1A1A1E"),it(e+9,n+10,"#1A1A1E"),it(e+3,n+11,"#1A1A1E"),it(e+7,n+11,"#1A1A1E"),O(e+1,n+2,8,6,ba.base),O(e+2,n+3,6,4,ba.hi,.35),O(e+2,n+3,6,1,bn(ba.hi,.5),.25),O(e+1,n+7,8,1,ba.deep),a==="up"?(O(e,n+7,10,3,ba.deep),O(e+1,n+8,8,1,ba.sh)):(O(e,n-1,10,3,ba.deep),O(e+1,n,8,1,ba.sh)),O(e,n+3,1,4,ba.sh),O(e+9,n+3,1,4,ba.sh)}const Ev={bookshelf:(e,n,a)=>kA(e,n,a.accent),plant:(e,n)=>jA(e,n),"meeting-table":(e,n)=>SA(e,n),sofa:(e,n)=>CA(e,n),"coffee-table":(e,n)=>EA(e,n),"coffee-machine":(e,n)=>NA(e,n),window:(e,n,a)=>pA(e,n,a.windowW??16,a.windowH??14),picture:(e,n,a)=>xA(e,n,a.pictureColor??"#1565C0"),clock:(e,n)=>gA(e,n),whiteboard:(e,n)=>yA(e,n),"bulletin-board":(e,n)=>bA(e,n),shelf:(e,n)=>vA(e,n),screen:(e,n)=>wA(e,n),aquarium:(e,n)=>AA(e,n),"neon-sign":(e,n)=>DA(e,n),arcade:(e,n)=>TA(e,n),jukebox:(e,n)=>FA(e,n),"trophy-case":(e,n)=>MA(e,n)};function Ss(e,n){const a=e.zone==="wall"?n.wx:n.fx,i=e.zone==="wall"?n.wy:n.fy;return{x:e.anchorX==="right"?(e.zone==="wall"?n.wx+n.ww:n.fx+n.fw)+e.offsetX:a+e.offsetX,y:i+e.offsetY}}function zA(e){for(const n of e.wallDecorations){const a=e.rooms[n.room];if(!a)continue;const{x:i,y:o}=Ss(n,a),u=Ev[n.type];u&&u(i,o,n)}}function _A(e,n,a){for(const i of e.furniture){const o=e.rooms[i.room];if(!o||i.condition==="no-desks"&&a.has(i.room))continue;const{x:u,y:d}=Ss(i,o),f=Ev[i.type];f&&n.push({y:d,draw:()=>f(u,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:u,y:d}=Ss(i,o);n.push({id:i.facility.id,label:i.facility.label,icon:i.facility.icon,color:i.facility.color,dx:u,dy:d,pw:i.facility.hitW,ph:i.facility.hitH})}return n}const BA={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 bm(e){return BA[e]??{w:16,h:16}}function Oh(e,n,a,i){for(let o=e.furniture.length-1;o>=0;o--){const u=e.furniture[o],d=e.rooms[u.room];if(!d||u.condition==="no-desks"&&i.has(u.room))continue;const{x:f,y:m}=Ss(u,d),h=bm(u.type);if(n>=f&&n<=f+h.w&&a>=m&&a<=m+h.h)return u.id}for(let o=e.wallDecorations.length-1;o>=0;o--){const u=e.wallDecorations[o],d=e.rooms[u.room];if(!d)continue;const{x:f,y:m}=Ss(u,d),h=bm(u.type);if(n>=f&&n<=f+h.w&&a>=m&&a<=m+h.h)return u.id}return null}function oy(e,n,a,i,o){const d=[...n.wallDecorations,...n.furniture].find(g=>g.id===a);if(!d||d.condition==="no-desks"&&o.has(d.room))return;const f=n.rooms[d.room];if(!f)return;const{x:m,y:h}=Ss(d,f),x=bm(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 cy(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 uy(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 dy=[{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}],ju=16,OA=4,bi=4,Ru=2,Xt=4,Ll=4;let Ke=jv(7);const Yu={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},fy={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 $A(e,n){const a=fy[e]||fy.default;return a[n]||a.en||a.default||[]}let wa=wi(Ke);function Nv(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function Av(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let vn={};function LA(e){const n={};for(let a=0;a<e.length&&a<Ke.desks.length;a++)n[e[a]]=Ke.desks[a];return n}let Xe,er=null,ki=null,nl=!1,sa=null,Rr=null,Dv=0,rr=null,Hn=null,Ol=null,va=null,$h=900;function IA(e,n){const{wx:a,wy:i,ww:o,wh:u,wallColor:d,baseboardColor:f}=e,m=Na(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){O(g.sx,i,g.sw,u,d);for(let w=0;w<u;w+=4)O(g.sx,i+w,g.sw,1,h,.08),O(g.sx,i+w+2,g.sw,1,m,.05);Ts(Math.round(g.sx*7+i*13));for(let w=0;w<g.sw;w+=3)Ea()>.4&&O(g.sx+w,i,1,u,h,.04);O(g.sx,i,g.sw,2,h,.3),O(g.sx,i,g.sw,1,bn(d,1),.2),O(g.sx,i+u-2,g.sw,2,m,.3),O(g.sx,i+u,g.sw,Ru,f),O(g.sx,i+u,g.sw,1,bn(f,.5),.4)}n&&(O(n.x-1,i,1,u+Ru,"#4A3828"),O(n.x+n.w,i,1,u+Ru,"#4A3828"),O(n.x,i,n.w,1,"#0A0808",.12)),O(e.fx,e.fy,e.fw,3,"#0A0808",.12),O(e.fx,e.fy+3,e.fw,2,"#0A0808",.06)}function HA(e){const n="#504038",a=Na(n,.5),i=bn(n,.5),o=e.wx-Ll,u=e.wy,d=e.wh+Ru+e.fh;O(o,u,Ll,d,n),O(o,u,1,d,i,.3),O(o+Ll-1,u,1,d,a,.4);for(let m=0;m<d;m+=6)O(o+1,u+m,Ll-2,1,i,.06);const f=e.wx+e.ww;O(f,u,Ll,d,n),O(f,u,1,d,i,.2),O(f+Ll-1,u,1,d,a,.3)}function Lh(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#B08040",d="#C89848",f="#8A6030",m="#6A4820";O(n,a,i,o,u),Ts(42);for(let h=0;h<o;h+=5){const x=Math.floor(h/5)%2*10;for(let g=-10;g<i+10;g+=20){const w=n+g+x,b=Math.max(n,w),j=Math.min(w+19,n+i)-b;if(j<=0)continue;const k=Ea()>.5?d:u;O(b,a+h,j,4,k,.25),O(b,a+h,j,1,d,.3),O(b,a+h+4,j,1,m,.35),w>=n&&w<n+i&&O(w,a+h,1,4,m,.2),O(b,a+h+2,j,1,f,.1)}}O(n,a,i,2,"#0A0808",.08),O(n,a,2,o,"#0A0808",.06)}function hy(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#1C2A38",d="#101820";Ts(99),O(n,a,i,o,u);for(let f=0;f<o;f+=ju)for(let m=0;m<i;m+=ju){const h=Math.min(ju,i-m),x=Math.min(ju,o-f);Ea()>.5&&O(n+m,a+f,h,x,bn(u,.2),.15),O(n+m+2,a+f+2,h-4,x-4,bn(u,.3),.08),O(n+m,a+f,h,1,d,.5),O(n+m,a+f,1,x,d,.5),O(n+m+1,a+f+1,1,x-1,bn(u,.4),.1),Ea()>.85&&it(n+m+4+Math.floor(Ea()*8),a+f+4+Math.floor(Ea()*8),"#3A6A9A",.08)}}function UA(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#387848",d="#4A9058",f="#285E38";O(n,a,i,o,u),Ts(77);for(let h=0;h<o;h+=2)for(let x=0;x<i;x+=2)Ea()>.5&&it(n+x,a+h,d,.1),Ea()>.8&&it(n+x+1,a+h+1,f,.12);const m=5;O(n+m,a+m,i-m*2,1,d,.45),O(n+m,a+o-m-1,i-m*2,1,f,.45),O(n+m,a+m,1,o-m*2,d,.35),O(n+i-m-1,a+m,1,o-m*2,f,.35)}function qA(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#D8C490",d="#B09060",f="#907848";Ts(55);for(let m=0;m<o;m+=8)for(let h=0;h<i;h+=8){const x=Math.min(8,i-h),g=Math.min(8,o-m),w=(h/8+m/8)%2===0?d:u;O(n+h,a+m,x,g,w),O(n+h+1,a+m+1,x-2,1,bn(w,.4),.2),O(n+h+1,a+m+1,1,g-2,bn(w,.4),.15),O(n+h+x-2,a+m+2,1,g-3,Na(w,.4),.15),O(n+h+2,a+m+g-2,x-3,1,Na(w,.4),.15),O(n+h,a+m,x,1,f,.3),O(n+h,a+m,1,g,f,.3)}}function YA(){const{canvasW:e,canvasH:n,rooms:a,doors:i}=Ke,o="#2A1E14",u="#3A2E24";if(O(0,0,e,bi,o),O(0,n-bi,e,bi,o),O(0,0,bi,n,o),O(e-bi,0,bi,n,o),O(0,0,e,1,u,.3),O(0,0,1,n,u,.2),!a.exec||!a.work||!a.meet||!a.comm)return;const d=a.exec,f=a.meet,m=e/2,h=m-Xt/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,C=((g==null?void 0:g.doorY)??d.fy+20)-k/2,N=((b==null?void 0:b.doorX)??bi+Ll+54)-E/2,_=((j==null?void 0:j.doorX)??m+Xt/2+Ll+54)-E/2,z=((w==null?void 0:w.doorY)??f.fy+20)-k/2;O(0,x,N,Xt,o),O(N+E,x,h-N-E,Xt,o),O(h+Xt,x,_-h-Xt,Xt,o),O(_+E,x,e-_-E,Xt,o),O(0,x,N,1,u,.3),O(N+E,x,h-N-E,1,u,.3),O(h+Xt,x,_-h-Xt,1,u,.3),O(_+E,x,e-_-E,1,u,.3),O(h,0,Xt,C,o),O(h,C+k,Xt,x-C-k,o),O(h,x+Xt,Xt,z-x-Xt,o),O(h,z+k,Xt,n-z-k,o),O(h,0,1,C,u,.2),O(h,C+k,1,x-C-k,u,.2),O(h,x+Xt,1,z-x-Xt,u,.2),O(h,z+k,1,n-z-k,u,.2),O(h,C,Xt,k,"#C4A070"),O(h+Xt/2,C,Xt/2,k,"#3A4858"),O(h,z,Xt,k,"#7AA880"),O(h+Xt/2,z,Xt/2,k,"#C8B890");const H="#4A3828";O(h,C-1,Xt,1,H),O(h,C+k,Xt,1,H),O(N-1,x,1,Xt,H),O(N+E,x,1,Xt,H),O(_-1,x,1,Xt,H),O(_+E,x,1,Xt,H),O(h,z-1,Xt,1,H),O(h,z+k,Xt,1,H)}const my=new Map;function XA(e,n="right"){const a=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${n}`;let i=my.get(a);if(!i){const o=am("mini-seated:default"),u=Ib(o,e);let d=u?u.layers.flatMap(f=>f.pixels):[];n==="left"&&d.length>0&&(d=nm(d,12)),i=d,my.set(a,i)}return i}function WA(e,n,a,i="right"){Il(Xe,XA(a,i),e,n,a)}function GA(e,n,a,i,o,u="right"){vi(e+8,n+20,"up"),o||WA(e+8,n+0+i,a,u),RA(e,n+14)}function VA(e,n,a,i,o){const u=i in ry?i:"down",d=o%4,f=ry[u][d];Il(Xe,f,e,n,a);const m=d===1||d===3?-1:0;if(a.accessory&&a.accessory!=="none"){const h=aC(a.accessory,u);h&&h.pixels.length>0&&Il(Xe,h.pixels,e,n+m,a)}Xe.globalAlpha=1}let $o=[],Ci=!1,Cs=0;function KA(){const e=Object.keys(Ke.rooms),n=e[Math.floor(Math.random()*e.length)],a=Ke.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 PA(e){if(e.stateTimer--,Ci){Cs++,e.dir="down",e.walkFrame=0,e.tongueTimer++,e.idleTime=0;return}else Cs=0;if(e.state==="idle"){if(e.tongueTimer++,e.idleTime++,e.stateTimer<=0){e.state="walking",e.tongueTimer=0;const n=Object.keys(Ke.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=ep(e,i),u=Ke.waypoints[i];if(u&&u.length>0){const d=u[Math.floor(Math.random()*u.length)],f=o[o.length-1]??{x:e.x,y:e.y},m=Ei(f.x,f.y,d.x,d.y,i);e.path=[...o,...m]}else e.path=o}else{const a=Ke.waypoints[e.room];if(a&&a.length>0){const i=a[Math.floor(Math.random()*a.length)];e.path=Ei(e.x,e.y,i.x,i.y,e.room)}}e.walkTimer=0}}else if(e.state==="walking"){if(e.idleTime=0,e.path.length===0){e.state="idle",e.dir="down",e.stateTimer=120+Math.floor(Math.random()*240);return}const n=e.path[0],a=n.x-e.x,i=n.y-e.y,o=Math.sqrt(a*a+i*i);if(o<1.5){e.x=n.x,e.y=n.y,e.path.shift();for(const[u,d]of Object.entries(Ke.rooms))if(e.x>=d.fx&&e.x<=d.fx+d.fw&&e.y>=d.fy&&e.y<=d.fy+d.fh){e.room=u;break}}else e.x+=a/o*.15,e.y+=i/o*.15,Math.abs(a)>Math.abs(i)?e.dir=a>0?"right":"left":e.dir=i>0?"down":"up",e.walkTimer++,e.walkFrame=Math.floor(e.walkTimer/15)%2}}function QA(e){const n=Math.round(e.x),a=Math.round(e.y);if(Ci&&Cs>90){const d=Math.floor(Cs/12)%2===0?nA:rA;Il(Xe,iA,n,a),Il(Xe,d,n,a);return}const i=e.state==="walking"?e.walkFrame:0,o=eA[e.dir][i],u=e.dir==="left"||e.dir==="right";Il(Xe,u?lA:aA,n,a),Il(Xe,o,n,a),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&Il(Xe,tA,n,a)}function ZA(e){const n={};let a=0;for(const i of e){const o=vn[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 Ei(e,n,a,i,o){const u=Ke.corridorY[o]??n,d=[];return n<u-4&&d.push({x:e,y:u}),Math.abs(e-a)>4&&d.push({x:a,y:u}),d.push({x:a,y:i}),d}function Ih(e,n,a,i){const o=Ke.adjacency[a];if(!o)return[];const u=o.find(x=>x.room===i);if(!u)return[];const d=Ke.doors[u.door];if(!d)return[];const f=[],m=Ke.corridorY[a]??n,h=Ke.corridorY[i]??n;if(Math.abs(n-m)>4&&f.push({x:e,y:m}),d.type==="v"){const x=u.side==="A"?d.xA:d.xB,g=u.side==="A"?d.xB:d.xA;f.push({x,y:m}),f.push({x,y:d.doorY}),f.push({x:g,y:d.doorY}),f.push({x:g,y:h})}else{const x=u.side==="A"?d.yA:d.yB,g=u.side==="A"?d.yB:d.yA;f.push({x:d.doorX,y:m}),f.push({x:d.doorX,y:x}),f.push({x:d.doorX,y:g}),f.push({x:d.doorX,y:h})}return f}function ep(e,n){const a=Ke.adjacency[e.room];if(!a)return[];if(!a.find(o=>o.room===n)){for(const o of a){const u=Ke.adjacency[o.room];if(u!=null&&u.find(d=>d.room===n)){const d=Ih(e.x,e.y,e.room,o.room),f=d[d.length-1],m=Ih((f==null?void 0:f.x)??e.x,(f==null?void 0:f.y)??e.y,o.room,n);return[...d,...m]}}return[]}return Ih(e.x,e.y,e.room,n)}function JA(e){if(e.room!==e.homeRoom){const n=ep({...e},e.homeRoom),a=n[n.length-1],i=Ei((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 Ei(e.x,e.y,e.homeX,e.homeY,e.room)}function e8(e,n){if($h--,$h<=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}$h=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++,er===a){i.sittingTime=0,i.bobY=-3;const u=vn[a];if(u){const d=u.dx+13;i.lookDir=Dv<d?"left":"right"}}else i.bobY=(n+i.bobOff)%60<30?1:0,i.lookDir="right";if(i.stateTimer<=0){i.state="walking",i.x=i.homeX,i.y=i.homeY,i.room=i.homeRoom;const u=Object.keys(Ke.rooms);if(Math.random()<.15&&u.length>1){const d=u.filter(x=>x!==i.room),f=d[Math.floor(Math.random()*d.length)],m=ep(i,f),h=Ke.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=Ei(g.x,g.y,x.x,x.y,f);i.path=[...m,...w]}else i.path=m;i.walkTimer=0}else{const d=Ke.waypoints[i.room];if(d&&d.length>0){const f=d[Math.floor(Math.random()*d.length)];i.path=Ei(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,er===a){i.dir="down",i.walkFrame=0;continue}if(i.path.length===0){i.state==="returning"?(i.state="sitting",i.room=i.homeRoom,i.stateTimer=1200+Math.floor(Math.random()*1800)):(i.state="idle",i.dir="down",i.stateTimer=180+Math.floor(Math.random()*360));continue}const u=i.path[0],d=u.x-i.x,f=u.y-i.y,m=Math.sqrt(d*d+f*f);if(m<1.5){i.x=u.x,i.y=u.y,i.path.shift();for(const[h,x]of Object.entries(Ke.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(er===a){i.dir="down";continue}if(i.stateTimer<=0)if(Math.random()<.15){i.state="walking";const o=Ke.waypoints[i.room];if(o&&o.length>0){const u=o[Math.floor(Math.random()*o.length)];i.path=Ei(i.x,i.y,u.x,u.y,i.room)}i.walkTimer=0}else i.state="returning",i.path=JA(i),i.walkTimer=0}}function t8(e,n,a,i){const{canvasW:o,canvasH:u,rooms:d}=Ke;Xe.clearRect(0,0,o,u),O(0,0,o,u,"#2A1E14");const f={wood:Lh,dark:hy,carpet:UA,tile:qA};for(const b of Object.values(d))(f[b.floorType]??Lh)(b);const m=Object.keys(d);if(m.length>=4){const b=d.exec,j=d.meet,{doors:k}=Ke;if(b&&j&&k.exec_meet&&k.work_comm){const C=(k.exec_meet.doorX??0)-14,N=(k.work_comm.doorX??0)-28/2,_=b.fy+b.fh,z=j.fy;Lh({fx:C,fy:_,fw:28,fh:z-_}),hy({fx:N,fy:_,fw:28,fh:z-_})}}const h={};if(m.length>=4){const{doors:b}=Ke,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))IA(b,h[b.id]),HA(b);YA(),zA(Ke);const x=[],g=new Set(Object.values(vn).map(b=>b.room));_A(Ke,x,g);for(const[b,j]of Object.entries(vn)){const k=e[b];if(!k)continue;const E=k.state==="sitting",C=n(b),N=a[b]==="working",_=k.isStretching&&k.stretchTimer>0?Math.sin(k.stretchTimer*.15)*1:0;x.push({y:j.dy+14,draw:()=>{const z=E?k.bobY+_:0;if(GA(j.dx,j.dy,C,z,!E,k.lookDir),E&&N){const H=Yu[b]??"#388bfd";O(j.dx+7,j.dy+14-4,12,5,H,.15),it(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:()=>VA(Math.round(j.x),Math.round(j.y),k,j.dir,j.walkFrame)})}i&&x.push({y:i.y+10,draw:()=>QA(i)}),x.sort((b,j)=>b.y-j.y);for(const b of x)b.draw();for(const b of wa){const j=ki===b.id,k=Av(b);if(Xe.save(),Xe.globalAlpha=j?.9:.5,Xe.fillStyle=b.color,Xe.fillRect(k.cx-1,k.botY-2,3,3),j){const E=Nv(b);Xe.globalAlpha=.3,Xe.strokeStyle=b.color,Xe.lineWidth=1,Xe.strokeRect(E.x-1,E.y-1,E.w+2,E.h+2)}Xe.restore()}if(nl){const b=new Set(Object.values(vn).map(j=>j.room));if(sa&&sa!==Rr)if(sa.startsWith("desk:")){const j=sa.slice(5),k=vn[j];k&&cy(Xe,k.dx,k.dy,"#FBBF24")}else oy(Xe,Ke,sa,"#FBBF24",b);if(Rr)if(Rr.startsWith("desk:")){const j=Rr.slice(5),k=vn[j];k&&cy(Xe,k.dx,k.dy,"#3B82F6")}else oy(Xe,Ke,Rr,"#3B82F6",b)}if(er){const b=vn[er],j=e[er];if(b&&j){Xe.save(),Xe.globalAlpha=.25,Xe.fillStyle=Yu[er]??"#fff",j.state==="sitting"?Xe.fillRect(b.dx-1,b.dy+6,28,30):Xe.fillRect(Math.round(j.x)-1,Math.round(j.y)-1,14,24),Xe.globalAlpha=.95,Xe.fillStyle="#FBBF24",Xe.font="bold 8px monospace",Xe.textAlign="center";const k=j.state==="sitting"?b.dx+13:Math.round(j.x)+6,E=j.state==="sitting"?b.dy-1:Math.round(j.y)-5;Xe.fillText("!",k,E),Xe.restore()}}const w=3600;for(const[,b]of Object.entries(e))if(b.state==="sitting"&&b.sittingTime>w&&!b.isStretching){const j=Object.values(vn).find(z=>z.dx+8===b.homeX&&z.dy+34===b.homeY);if(!j)continue;const k=j.dx+13,E=j.dy,C=Math.floor(b.sittingTime/40)%3;Xe.save(),Xe.font="5px monospace",Xe.textAlign="center";const N=[.7,.5,.3],_=[{x:3,y:-2-C},{x:6,y:-5-(C+1)%3},{x:4,y:-8-(C+2)%3}];for(let z=0;z<3;z++)Xe.globalAlpha=N[z],Xe.fillStyle="#93C5FD",Xe.font=`${4+z}px monospace`,Xe.fillText("z",k+_[z].x,E+_[z].y);Xe.restore()}$o=$o.filter(b=>b.life>0);for(const b of $o)b.x+=b.vx,b.y+=b.vy,b.life--,Xe.save(),Xe.globalAlpha=Math.min(1,b.life/(b.maxLife*.3)),Xe.fillStyle=b.color??"#FF6B8A",Xe.font="8px serif",Xe.fillText(b.char,Math.round(b.x),Math.round(b.y)),Xe.restore();if(Ci&&i&&Cs<=90){const b=Math.round(i.x),j=Math.round(i.y);Xe.save(),Xe.globalAlpha=.9,Xe.fillStyle="#FBBF24",Xe.font="bold 5px monospace",Xe.textAlign="center",Xe.fillText("!",b+4,j-2),Xe.restore()}if(i&&!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;Xe.save();const E=[{x:3,y:-2-k},{x:5,y:-5-(k+1)%3},{x:4,y:-8-(k+2)%3}];for(let C=0;C<3;C++)Xe.globalAlpha=[.7,.5,.3][C],Xe.fillStyle="#93C5FD",Xe.font=`${3+C}px monospace`,Xe.textAlign="center",Xe.fillText("z",b+E[C].x,j+E[C].y);Xe.restore()}if(Ci&&i&&Cs<=90){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(Date.now()/150)%2===0?-1:1;i.dir==="down"&&(Xe.fillStyle="#FAFAF7",Xe.fillRect(b+4+k,j-1,2,2))}}function n8(e,n){for(let a=0;a<4;a++)$o.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 r8(e,n){for(let a=0;a<3;a++)$o.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 a8({roles:e,projects:n,roleStatuses:a,activeExecs:i,onRoleClick:o,onProjectClick:u,onBulletinClick:d,onDecisionsClick:f,onKnowledgeClick:m,onSettingsClick:h,onThemeClick:x,onStatsClick:g,getRoleSpeech:w,getAppearance:b,onHireClick:j,onMascotClick:k,roleLevels:E,coinBalance:C=0,onCoinsSpent:N,onFurniturePlaced:_,purchasedPreset:z,language:H="en"}){const R=v.useRef(null),I=v.useRef(null),q=v.useRef(null),X=v.useRef({}),A=v.useRef(null),$=v.useRef(0),L=v.useRef(OA),[Y,se]=v.useState(!1),[ee,W]=v.useState(null),[oe,de]=v.useState(null),V=v.useRef({}),D=v.useRef({}),B=v.useRef([]),U=v.useRef([]);v.useEffect(()=>{nl=Y},[Y]),v.useEffect(()=>{Ol=ee,va=oe},[ee,oe]);const[T,ie]=v.useState(!1);v.useEffect(()=>{ye.getPreferences().then(me=>{const Se=me.furnitureOverrides;Se&&Object.keys(Se).length>0&&(V.current=Se);const Ne=me.deskOverrides;Ne&&Object.keys(Ne).length>0&&(D.current=Ne);const K=me.removedFurniture;K&&K.length>0&&(B.current=K);const ue=me.addedFurniture;ue&&ue.length>0&&(U.current=ue),ie(!0)}).catch(()=>{ie(!0)})},[]);const ge=v.useRef({roleStatuses:a,activeExecs:i,getRoleSpeech:w,getAppearance:b});ge.current={roleStatuses:a,activeExecs:i,getRoleSpeech:w,getAppearance:b};const pe=v.useRef({}),ze=v.useMemo(()=>e.map(me=>me.id),[e]),Ie=v.useRef(Ke);v.useEffect(()=>{if(!T)return;const me=ze.length,Se=kv(me,Ie.current.preset,z),Ne=Ie.current.preset!==Se;let K=jv(me,Se);B.current.length>0&&(K=sy(K,B.current)),U.current.length>0&&(K=hA(K,U.current)),Object.keys(V.current).length>0&&(K=dA(K,V.current)),Ke=K,Ie.current=K,vn=LA(ze),Object.keys(D.current).length>0&&fA(vn,D.current),wa=wi(K),X.current=ZA(ze),A.current=KA();const ue=R.current;ue&&(ue.width=K.canvasW,ue.height=K.canvasH,Ne&&(ue.style.opacity="0",ue.style.transition="opacity 0.3s",setTimeout(()=>{ue.style.opacity="1"},50))),st()},[ze,z,T]);const He=v.useCallback(me=>{var Se,Ne;return((Ne=(Se=ge.current).getAppearance)==null?void 0:Ne.call(Se,me))??Km(me)},[]),st=v.useCallback(()=>{const me=I.current,Se=R.current;if(!me||!Se)return;const Ne=me.parentElement;if(!Ne)return;const K=Ne.clientWidth,ue=Ne.clientHeight;if(K===0||ue===0)return;const{canvasW:te,canvasH:ke}=Ke;let ve=Math.min(K/te,ue/ke);ve=Math.round(ve*2)/2,ve=Math.max(2,Math.min(ve,5)),L.current=ve,Se.style.width=te*ve+"px",Se.style.height=ke*ve+"px",me.style.width=te*ve+"px",me.style.height=ke*ve+"px"},[]);v.useEffect(()=>{var ke;const me=R.current;if(!me)return;const Se=me.getContext("2d");if(!Se)return;Xe=Se,mA(Se),st();const Ne=new ResizeObserver(()=>st()),K=(ke=I.current)==null?void 0:ke.parentElement;K&&Ne.observe(K);let ue;const te=()=>{$.current++,e8(X.current,$.current),A.current&&PA(A.current),t8(X.current,He,ge.current.roleStatuses,A.current),Pe(),ue=requestAnimationFrame(te)};return ue=requestAnimationFrame(te),()=>{cancelAnimationFrame(ue),Ne.disconnect()}},[He,st]),v.useEffect(()=>{var te;const me=q.current;if(!me)return;me.innerHTML="";const Se={};for(const ke of e)Se[ke.id]=ke.name;for(const ke of ze){const ve=Yu[ke]??"#8b949e",_e=Se[ke],Be=_e&&_e.toLowerCase()!==ke.toLowerCase()?`${ke.toUpperCase()} · ${_e}`:ke.toUpperCase(),Oe=document.createElement("div");Oe.className="td-nametag",Oe.dataset.role=ke;const qe=document.createElement("span");qe.className="td-dot",qe.style.background=ve,Oe.appendChild(qe),Oe.appendChild(document.createTextNode(Be));const rt=((te=E==null?void 0:E[ke])==null?void 0:te.level)??1;if(rt>1){const bt=document.createElement("span");bt.className="td-lvl",bt.textContent=`Lv.${rt}`,Oe.appendChild(bt)}me.appendChild(Oe);const Ve=document.createElement("div");Ve.className="td-bubble",Ve.dataset.role=ke,Ve.dataset.type="bubble",me.appendChild(Ve)}const Ne={meeting:()=>{const ke=n[0];ke?u(ke.id):d()},bulletin:d,decisions:f,knowledge:m,settings:h,theme:x,stats:g};for(const ke of wa){const ve=document.createElement("div");ve.className="td-facility-label",ve.dataset.facility=ke.id,ke.id==="meeting"&&(ve.dataset.questTarget="meeting-room"),ke.id==="knowledge"&&(ve.dataset.questTarget="knowledge-hub"),ke.id==="bulletin"&&(ve.dataset.questTarget="bulletin-board"),ke.id==="stats"&&(ve.dataset.questTarget="stats-btn"),ke.id==="settings"&&(ve.dataset.questTarget="settings-btn"),ke.id==="theme"&&(ve.dataset.questTarget="theme-btn"),ve.textContent=`${ke.icon} ${ke.label}`,ve.style.borderColor=`${ke.color}44`;const _e=Ne[ke.id];_e&&ve.addEventListener("click",_e),ve.addEventListener("mouseenter",()=>{ki=ke.id}),ve.addEventListener("mouseleave",()=>{ki=null}),me.appendChild(ve)}const K=document.createElement("div");K.className="td-nametag td-nametag-mascot",K.dataset.role="mascot";const ue=document.createElement("span");ue.className="td-dot",ue.style.background="#ffd700",K.appendChild(ue),K.appendChild(document.createTextNode("Pupu")),K.addEventListener("click",()=>k==null?void 0:k()),me.appendChild(K)},[ze,e,n,u,d,f,m,h,x,g,k,E]);const Pe=v.useCallback(()=>{var _e;const me=q.current;if(!me)return;const Se=L.current,Ne=X.current,{getRoleSpeech:K,roleStatuses:ue,activeExecs:te}=ge.current;for(const Be of Object.keys(Ne)){const Oe=Ne[Be],qe=vn[Be];if(!qe)continue;let rt,Ve,bt;Oe.state==="sitting"?(rt=qe.dx+13,bt=qe.dy+2,Ve=qe.dy+37):(rt=Math.round(Oe.x)+6,bt=Math.round(Oe.y)-2,Ve=Math.round(Oe.y)+18);const Re=rt/Ke.canvasW*100,Ue=me.querySelector(`.td-nametag[data-role="${Be}"]`);if(Ue){Ue.style.left=Re+"%",Ue.style.top=Ve*Se+2+"px";const Bt=Ue.querySelector(".td-dot");if(Bt){const Ot=ue[Be]==="working";Bt.style.background=Ot?"#FBBF24":Yu[Be]??"#8b949e",Ot?Bt.style.animation="td-pulse 1s ease-in-out infinite":Bt.style.animation=""}}const _t=me.querySelector(`.td-bubble[data-role="${Be}"]`);if(_t){const Bt=Date.now(),Ot=ue[Be]==="working",fn=(_e=te.find(Pt=>Pt.roleId===Be))==null?void 0:_e.task,wn=K(Be);let Z="";const $e=pe.current[Be];if($e){if($e.speechDismissTime&&Bt>=$e.speechDismissTime&&($e.currentSpeech=null,$e.speechDismissTime=null),$e.hoverStartTime&&!$e.currentSpeech){const Pt=Bt-$e.hoverStartTime,we=!$e.lastSpeechTime||Bt-$e.lastSpeechTime>=5e3;if(Pt>=2e3&&we){const kt=$A(Be,H),ln=kt[Math.floor(Math.random()*kt.length)];$e.currentSpeech=ln,$e.lastSpeechTime=Bt,$e.speechDismissTime=Bt+3e3}}Z=$e.currentSpeech||""}const nt=Ot&&fn?fn.slice(0,60):Z?Z.slice(0,60):wn?wn.slice(0,60):"";nt&&Oe.state==="sitting"?(_t.style.display="",_t.style.left=Re+"%",_t.style.top=(bt-10)*Se+"px",_t.textContent=nt):_t.style.display="none"}}const ke=me.querySelector(".td-nametag-mascot"),ve=A.current;if(ke&&ve){const Be=ve.dir==="left"||ve.dir==="right",Oe=Math.round(ve.x)+(Be?6:4),qe=Math.round(ve.y)+(Be?7:10);ke.style.left=Oe/Ke.canvasW*100+"%",ke.style.top=qe*Se+2+"px"}for(const Be of wa){const Oe=me.querySelector(`.td-facility-label[data-facility="${Be.id}"]`);if(Oe){const qe=Av(Be);Oe.style.left=qe.cx/Ke.canvasW*100+"%",Oe.style.top=qe.botY*Se-4+"px",Oe.classList.toggle("td-facility-label--hover",ki===Be.id)}}},[]),et=v.useCallback(me=>{const Se=R.current;if(!Se)return null;const Ne=Se.getBoundingClientRect(),K=L.current,ue=(me.clientX-Ne.left)/K,te=(me.clientY-Ne.top)/K,ke=X.current;for(const[_e,Be]of Object.entries(vn)){if(!ke[_e])continue;const Oe=ke[_e];if(Oe.state==="sitting"){if(ue>=Be.dx&&ue<=Be.dx+26&&te>=Be.dy&&te<=Be.dy+40)return{type:"role",id:_e}}else if(ue>=Oe.x-2&&ue<=Oe.x+14&&te>=Oe.y-2&&te<=Oe.y+20)return{type:"role",id:_e}}const ve=A.current;if(ve){const _e=ve.dir==="left"||ve.dir==="right",Be=_e?13:9,Oe=_e?7:10;if(ue>=ve.x&&ue<=ve.x+Be&&te>=ve.y&&te<=ve.y+Oe)return{type:"mascot",id:"mascot"}}for(const _e of wa){const Be=Nv(_e);if(ue>=Be.x&&ue<=Be.x+Be.w&&te>=Be.y&&te<=Be.y+Be.h)return{type:"facility",id:_e.id}}return null},[]),Ee=v.useCallback(me=>{const Se=R.current;if(!Se)return{mx:0,my:0};const Ne=Se.getBoundingClientRect(),K=L.current;return{mx:(me.clientX-Ne.left)/K,my:(me.clientY-Ne.top)/K}},[]),De=v.useCallback(me=>{ye.updatePreferences(me).catch(()=>{})},[]),yt=v.useCallback(me=>{const Se=U.current.some(K=>K.id===me),Ne={};if(Se){const K=U.current.filter(ue=>ue.id!==me);U.current=K,Ne.addedFurniture=K}else{const K=[...B.current,me];B.current=K,Ne.removedFurniture=K}Ke=sy(Ke,[me]),wa=wi(Ke),Rr=null,sa=null,De(Ne)},[De]),ut=v.useCallback((me,Se)=>{if(!Ol||!va)return;const Ne=dy.find(Oe=>Oe.type===Ol),K=(Ne==null?void 0:Ne.price)??0;if(K>0&&C<K)return;let ue=null;for(const[Oe,qe]of Object.entries(Ke.rooms)){const rt=va==="wall"?qe.wx:qe.fx,Ve=va==="wall"?qe.wy:qe.fy,bt=va==="wall"?qe.ww:qe.fw,Re=va==="wall"?qe.wh:qe.fh;if(me>=rt&&me<=rt+bt&&Se>=Ve&&Se<=Ve+Re){ue=Oe;break}}if(!ue)return;const te=Ke.rooms[ue],ke=va==="wall"?te.wx:te.fx,ve=va==="wall"?te.wy:te.fy,_e={id:`user-${Ol}-${Date.now()}`,type:Ol,room:ue,zone:va,offsetX:Math.round(me-ke),offsetY:Math.round(Se-ve)},Be=[...U.current,_e];if(U.current=Be,va==="wall"?Ke.wallDecorations.push(_e):Ke.furniture.push(_e),wa=wi(Ke),De({addedFurniture:Be}),_==null||_(Ol,K),K>0){const Oe=_e.type;Ey(async()=>{const{api:qe}=await Promise.resolve().then(()=>Sw);return{api:qe}},void 0).then(({api:qe})=>{qe.spendCoins(K,`furniture: ${Oe}`,_e.id).then(rt=>N==null?void 0:N(rt.balance)).catch(()=>{})})}W(null),de(null)},[De,C,N,_]),pt=v.useCallback(me=>{const Se=R.current;if(nl&&rr){const{mx:ke,my:ve}=Ee(me),Be=[...Ke.furniture,...Ke.wallDecorations].find(rt=>rt.id===rr.defId);if(!Be)return;const Oe=ke-rr.startMx,qe=ve-rr.startMy;Be.offsetX=Math.round(rr.origOffX+Oe),Be.offsetY=Math.round(rr.origOffY+qe),wa=wi(Ke),Se&&(Se.style.cursor="grabbing");return}if(nl&&Hn){const{mx:ke,my:ve}=Ee(me),_e=vn[Hn.roleId];if(!_e)return;_e.dx=Math.round(Hn.origDx+(ke-Hn.startMx)),_e.dy=Math.round(Hn.origDy+(ve-Hn.startMy));const Be=X.current[Hn.roleId];Be&&(Be.homeX=_e.dx+8,Be.homeY=_e.dy+34),Se&&(Se.style.cursor="grabbing");return}if(nl){const{mx:ke,my:ve}=Ee(me);if(Ol){Se&&(Se.style.cursor="crosshair");return}const _e=new Set(Object.values(vn).map(Oe=>Oe.room)),Be=Oh(Ke,ke,ve,_e);if(Be)sa=Be;else{const Oe=uy(vn,ke,ve);sa=Oe?`desk:${Oe}`:null}er=null,ki=null,Se&&(Se.style.cursor=sa?"grab":"default");return}const Ne=et(me),K=er;er=(Ne==null?void 0:Ne.type)==="role"?Ne.id:null,ki=(Ne==null?void 0:Ne.type)==="facility"?Ne.id:null,Ci=(Ne==null?void 0:Ne.type)==="mascot",sa=null,Se&&(Se.style.cursor=Ne?"pointer":"default");const{mx:ue}=Ee(me);Dv=ue;const te=Date.now();if(er&&er!==K){pe.current[er]||(pe.current[er]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const ke=pe.current[er];ke.hoverStartTime=te}else if(!er&&K){const ke=pe.current[K];ke&&(ke.hoverStartTime=null)}},[et,Ee]),jt=v.useCallback(me=>{if(!nl)return;const{mx:Se,my:Ne}=Ee(me);if(Ol){ut(Se,Ne),me.preventDefault();return}const K=new Set(Object.values(vn).map(ke=>ke.room)),ue=Oh(Ke,Se,Ne,K);if(ue){const ve=[...Ke.furniture,...Ke.wallDecorations].find(_e=>_e.id===ue);ve&&(Rr=ue,rr={defId:ue,startMx:Se,startMy:Ne,origOffX:ve.offsetX,origOffY:ve.offsetY},me.preventDefault());return}const te=uy(vn,Se,Ne);if(te){const ke=vn[te];Rr=`desk:${te}`,Hn={roleId:te,startMx:Se,startMy:Ne,origDx:ke.dx,origDy:ke.dy},me.preventDefault();return}Rr=null},[Ee,ut]),Wt=v.useCallback(me=>{if(rr){const Ne=[...Ke.furniture,...Ke.wallDecorations].find(K=>K.id===rr.defId);if(Ne){const K={...V.current,[Ne.id]:{offsetX:Ne.offsetX,offsetY:Ne.offsetY}};V.current=K,De({furnitureOverrides:K}),wa=wi(Ke)}rr=null,R.current&&(R.current.style.cursor="grab");return}if(Hn){const Se=vn[Hn.roleId];if(Se){const Ne={...D.current,[Hn.roleId]:{dx:Se.dx,dy:Se.dy}};D.current=Ne,De({deskOverrides:Ne})}Hn=null,R.current&&(R.current.style.cursor="grab")}},[De]),Ft=v.useCallback(me=>{if(!nl)return;me.preventDefault();const{mx:Se,my:Ne}=Ee(me),K=new Set(Object.values(vn).map(te=>te.room)),ue=Oh(Ke,Se,Ne,K);ue&&yt(ue)},[Ee,yt]);v.useEffect(()=>{const me=Se=>{!nl||!Rr||(Se.key==="Delete"||Se.key==="Backspace")&&(Rr.startsWith("desk:")||yt(Rr))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},[yt]);const Et=v.useCallback(()=>{if(rr){const Se=[...Ke.furniture,...Ke.wallDecorations].find(Ne=>Ne.id===rr.defId);Se&&(Se.offsetX=rr.origOffX,Se.offsetY=rr.origOffY,wa=wi(Ke)),rr=null}if(Hn){const me=vn[Hn.roleId];me&&(me.dx=Hn.origDx,me.dy=Hn.origDy);const Se=X.current[Hn.roleId];Se&&(Se.homeX=me.dx+8,Se.homeY=me.dy+34),Hn=null}er=null,ki=null,Ci=!1,sa=null,R.current&&(R.current.style.cursor="default")},[]),$n=v.useCallback(me=>{if(nl)return;const Se=et(me);if(Se){if(Se.type==="role"){const Ne=X.current[Se.id],K=vn[Se.id];if(Ne&&K){const ue=Ne.state==="sitting"?K.dx+13:Math.round(Ne.x)+6,te=Ne.state==="sitting"?K.dy+2:Math.round(Ne.y)-2;r8(ue,te)}o(Se.id);return}if(Se.type==="mascot"){const Ne=A.current;Ne&&n8(Math.round(Ne.x)+4,Math.round(Ne.y)-2),k==null||k();return}switch(Se.id){case"meeting":{const Ne=n[0];Ne?u(Ne.id):d();break}case"bulletin":d();break;case"decisions":f();break;case"knowledge":m();break;case"settings":h==null||h();break;case"theme":x==null||x();break;case"stats":g==null||g();break}}},[et,o,u,d,f,m,h,x,g]);return l.jsxs("div",{className:`td-scene${Y?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:I,className:"td-wrap",children:[l.jsx("canvas",{ref:R,width:Ke.canvasW,height:Ke.canvasH,className:"td-canvas",onClick:$n,onMouseDown:jt,onMouseUp:Wt,onMouseMove:pt,onMouseLeave:Et,onContextMenu:Ft}),l.jsx("div",{ref:q,className:"td-overlay"})]}),Y&&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${Y?" td-edit-btn--active":""}`,"data-quest-target":"edit-btn",onClick:()=>{se(me=>{const Se=!me;return Se||(W(null),de(null)),Se}),Rr=null,rr=null,Hn=null},title:Y?"Exit Edit Mode":"Edit Furniture Layout",children:[l.jsx("span",{className:"td-edit-btn__icon",children:Y?"✓":"✎"}),l.jsx("span",{className:"td-edit-btn__label",children:Y?"DONE":"EDIT"})]}),Y&&l.jsx("div",{className:"td-palette",children:dy.map(me=>{const Se=me.price===0||C>=me.price,Ne=me.price===0?"Free":`${me.price>=1e3?`${(me.price/1e3).toFixed(me.price%1e3===0?0:1)}K`:me.price}`;return l.jsxs("button",{className:`td-palette__item${ee===me.type?" td-palette__item--active":""}${Se?"":" td-palette__item--locked"}`,onClick:()=>{Se&&(ee===me.type?(W(null),de(null)):(W(me.type),de(me.zone)))},title:`${me.label} — ${Ne}`,style:Se?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:me.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:me.price===0?"#4CAF50":Se?"#FFD54F":"#EF5350"},children:Ne})]},me.type)})}),j&&l.jsxs("button",{className:"td-hire-btn","data-quest-target":"hire-btn",onClick:j,title:"Hire New Role",children:[l.jsx("span",{className:"td-hire-btn__icon",children:"+"}),l.jsx("span",{className:"td-hire-btn__label",children:"HIRE"})]})]})}function l8({role:e,appearance:n,onSave:a,onReset:i,onClose:o,theme:u,onThemeChange:d,onUpdateName:f,initialTab:m,characterOnly:h,speechSettings:x,onSpeechSettingsChange:g,language:w,onLanguageChange:b,roleLevel:j}){var $;const[k,E]=v.useState(m??"character"),[C,N]=v.useState({...n}),[_,z]=v.useState(e.name),[H,R]=v.useState(!1),I=v.useCallback(()=>N(ys(j)),[j]),q=v.useCallback(()=>{const L=Km(e.id);N({...L}),i()},[e.id,i]),X=v.useCallback(async()=>{a(C);const L=_.trim();if(f&&L&&L!==e.name){R(!0);try{await f(e.id,L)}catch{}R(!1)}o()},[C,a,o,_,e.name,e.id,f]),A=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," –"]}),f?l.jsx("input",{value:_,onChange:L=>z(L.target.value),disabled:H,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:L=>L.stopPropagation(),children:[l.jsxs("div",{className:"customize-header",children:[l.jsxs("div",{className:"customize-tabs",children:[l.jsx("button",{className:`customize-tab ${k==="character"?"active":""}`,onClick:()=>E("character"),children:"CHARACTER"}),!h&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${k==="office"?"active":""}`,onClick:()=>E("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${k==="settings"?"active":""}`,onClick:()=>E("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:o,children:"X"})]}),k==="character"?l.jsx("div",{className:"customize-body",children:l.jsx(fv,{roleId:e.id,appearance:C,onChange:N,onRandomize:I,onReset:q,label:A,roleLevel:j})}):k==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(ll).map(([L,Y])=>l.jsxs("button",{className:`customize-theme-card ${u===L?"active":""}`,onClick:()=>d(L),children:[l.jsxs("div",{className:"customize-theme-preview",style:{background:Y.vars["--floor-light"],borderColor:Y.vars["--pixel-border"]},children:[l.jsx("div",{style:{background:Y.vars["--hud-bg"],height:8,borderBottom:`2px solid ${Y.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:Y.vars["--accent"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:Y.vars["--active-green"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:Y.vars["--idle-amber"],borderRadius:1}})]}),l.jsx("div",{style:{background:Y.vars["--hud-bg"],height:6,borderTop:`2px solid ${Y.vars["--pixel-border"]}`}})]}),l.jsxs("div",{className:"customize-theme-name",children:[Y.icon," ",Y.name]})]},L))})}):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(L=>l.jsxs("button",{onClick:()=>g==null?void 0:g({mode:L}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(x==null?void 0:x.mode)===L?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(x==null?void 0:x.mode)===L?"rgba(255,255,255,0.08)":"transparent",color:(x==null?void 0:x.mode)===L?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:L==="template"?"TEMPLATE":L==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:L==="template"?"Static pool ($0)":L==="llm"?"LLM generated":"Detect engine"})]},L))}),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:L=>g==null?void 0:g({intervalSec:Number(L.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"5s (frequent)"}),l.jsx("span",{children:"120s (rare)"})]})]}),(x==null?void 0:x.mode)!=="template"&&l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["DAILY LLM BUDGET: $",(($=x==null?void 0:x.dailyBudgetUsd)==null?void 0:$.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(x==null?void 0:x.dailyBudgetUsd)??1,onChange:L=>g==null?void 0:g({dailyBudgetUsd:Number(L.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:L,label:Y})=>l.jsx("button",{onClick:()=>b==null?void 0:b(L),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(w??"auto")===L?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(w??"auto")===L?"rgba(255,255,255,0.08)":"transparent",color:(w??"auto")===L?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:Y},L))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]})]})}),k==="character"&&l.jsxs("div",{className:"customize-footer",children:[l.jsx("button",{className:"customize-btn customize-btn--cancel",onClick:o,children:"CANCEL"}),l.jsx("button",{className:"customize-btn customize-btn--save",onClick:X,children:"SAVE"})]})]})})}function py(e){if(e.length===0)return"";const n={};for(const{file:f}of e){const m=f.split("/"),h=m[0]==="."?m[1]??"root":m[0];(n[h]??(n[h]=[])).push(f)}const a={roles:"roles",projects:"projects",operations:"operations",knowledge:"knowledge",architecture:"architecture",company:"company",".tycono":"config",".claude":"skills"},i=[];for(const[f,m]of Object.entries(n)){const h=a[f]??f;if(m.length===1){const x=m[0].split("/").pop()??m[0];i.push(`${h}/${x}`)}else i.push(`${h} (${m.length} files)`)}const o=e.some(f=>f.status==="A"),u=e.some(f=>f.status==="M");return`${o&&!u?"add":"update"}: ${i.join(", ")}`}function xy(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 i8({onInitGit:e,onDelegate:n,delegateRoleName:a}){const[i,o]=v.useState(!1),[u,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=u&&!u.ok&&u.message.includes("not installed");return l.jsxs("div",{className:"p-3 space-y-2",style:{background:"rgba(211,47,47,0.05)",border:"1px solid var(--pixel-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"No Git Repository"}),!u&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"This project has no git repository. Initialize one to start saving."}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:f,disabled:i,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:i?"INITIALIZING...":"GIT INIT"}),n&&l.jsxs("button",{onClick:n,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["🤖"," ",(a==null?void 0:a.toUpperCase())??"AI"," FIX"]})]})]}),u&&u.ok&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:"rgba(59,185,80,0.1)",border:"1px solid var(--active-green)",color:"var(--active-green)"},children:u.message}),m&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"#EF5350"},children:"git is not installed on this system."}),l.jsxs("div",{className:"text-[10px] space-y-1",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("div",{children:[l.jsx("b",{children:"macOS:"})," xcode-select --install"]}),l.jsxs("div",{children:[l.jsx("b",{children:"Ubuntu/Debian:"})," sudo apt install git"]}),l.jsxs("div",{children:[l.jsx("b",{children:"Windows:"})," ",l.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"git-scm.com/downloads"})]})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:()=>{d(null)},className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),n&&l.jsxs("button",{onClick:n,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["🤖"," ",(a==null?void 0:a.toUpperCase())??"AI"," FIX"]})]})]}),u&&!u.ok&&!m&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:u.message})]})}function s8({repo:e,onConnected:n,onDelegate:a,delegateRoleName:i}){const[o,u]=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,C]=v.useState(!1),N=async()=>{u("checking"),k(null);try{const R=await ye.getGithubStatus(e);f(R),R.hasRemote?n():R.ghInstalled&&R.authenticated?u("ready"):u("idle")}catch{u("idle")}},_=async()=>{if(m.trim()){C(!0),k(null);try{const R=await ye.githubCreateRepo(m.trim(),x,e);k(R),R.ok&&setTimeout(n,1500)}catch(R){k({ok:!1,message:R instanceof Error?R.message:"Failed"})}finally{C(!1)}}},z=async()=>{if(w.trim()){C(!0),k(null);try{const R=await ye.addRemote(w.trim(),e);k(R),R.ok&&setTimeout(n,1500)}catch(R){k({ok:!1,message:R instanceof Error?R.message:"Failed"})}finally{C(!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:N,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"CONNECT GITHUB"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD REMOTE URL"}),H]}),o==="checking"&&l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"Checking GitHub CLI..."}),o==="idle"&&d&&!d.ghInstalled&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--idle-amber)"},children:"GitHub CLI (gh) not installed."}),l.jsxs("div",{className:"text-[10px] space-y-0.5",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("div",{children:["Install:"," ",l.jsx("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"cli.github.com"})]}),l.jsx("div",{style:{fontFamily:"var(--pixel-font)"},children:"brew install gh && gh auth login"})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:N,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD URL MANUALLY"}),H]})]}),o==="idle"&&d&&d.ghInstalled&&!d.authenticated&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--idle-amber)"},children:"GitHub CLI installed but not logged in."}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)",fontFamily:"var(--pixel-font)"},children:"Run in terminal: gh auth login"}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:N,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD REMOTE URL"}),H]})]}),o==="ready"&&d&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--active-green)"},children:["Logged in as ",d.username||"GitHub user"]}),l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("input",{type:"text",value:m,onChange:R=>h(R.target.value),placeholder:"repository-name",className:"flex-1 px-2 py-1.5 text-[11px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}}),l.jsxs("select",{value:x,onChange:R=>g(R.target.value),className:"px-2 py-1.5 text-[10px] outline-none cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:[l.jsx("option",{value:"private",children:"Private"}),l.jsx("option",{value:"public",children:"Public"})]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:_,disabled: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:()=>u("manual"),className:"text-[10px] px-2 py-1 cursor-pointer",style:{background:"transparent",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"USE URL INSTEAD"})]})]}),o==="manual"&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("a",{href:"https://github.com/new",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"Create a new repo on GitHub"})," ","then paste the URL below:"]}),l.jsx("input",{type:"text",value:w,onChange:R=>b(R.target.value),placeholder:"https://github.com/username/repo-name.git",className:"w-full px-2 py-1.5 text-[11px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:z,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:()=>{u("idle"),f(null)},className:"text-[10px] px-2 py-1 cursor-pointer",style:{background:"transparent",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"BACK"})]})]}),j&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:j.ok?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${j.ok?"var(--active-green)":"#D32F2F"}`,color:j.ok?"var(--active-green)":"#EF5350"},children:j.message})]})}function o8({status:e,history:n,onClose:a,onSave:i,onLoadHistory:o,onRestore:u,saving:d,onDelegate:f,delegateRoleName:m,repo:h,onRepoChange:x,syncInfo:g,onPull:w,pulling:b,onRefresh:j,onInitGit:k}){const[E,C]=v.useState("save"),[N,_]=v.useState(""),[z,H]=v.useState(null),[R,I]=v.useState(!1),[q,X]=v.useState(null),[A,$]=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 Y=[...((e==null?void 0:e.modified)??[]).map(D=>({status:"M",file:D})),...((e==null?void 0:e.untracked)??[]).map(D=>({status:"A",file:D}))],se=v.useRef(!1);v.useEffect(()=>{!se.current&&Y.length>0&&!N&&(_(py(Y)),se.current=!0)},[Y.length]),v.useEffect(()=>{se.current=!1,_(""),$(null),X(null),H(null)},[h]);const ee=v.useCallback(()=>{_(py(Y))},[Y]),W=async()=>{H(null),X(null);try{const D=await i(N||void 0);X(D),_("")}catch(D){H(D instanceof Error?D.message:"Save failed")}},oe=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 u(D),I(!1)}catch(B){H(B instanceof Error?B.message:"Restore failed"),I(!1)}}};v.useEffect(()=>{const D=B=>{B.key==="Escape"&&a()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[a]);const V=D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&W()};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:a}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] max-h-[80vh] z-[61] overflow-hidden flex flex-col",style:{background:"var(--hud-bg)",border:"3px solid var(--pixel-border)",fontFamily:"var(--pixel-font)",color:"var(--terminal-text)"},onKeyDown:V,children:[l.jsxs("div",{className:"px-5 py-3 flex items-center justify-between shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-lg font-black tracking-tight",children:"SAVE COMPANY"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:(e==null?void 0:e.branch)??""})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[g&&g.hasRemote&&(g.behind>0||g.ahead>0)&&l.jsxs("span",{className:"text-[10px] font-bold",style:{color:g.behind>0?"var(--idle-amber)":"var(--active-green)"},children:[g.behind>0&&`↓${g.behind}`,g.behind>0&&g.ahead>0&&" ",g.ahead>0&&`↑${g.ahead}`]}),l.jsx("button",{onClick:a,className:"text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] cursor-pointer text-lg",children:"×"})]})]}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["akb","code"].map(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:()=>C(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(i8,{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:oe,disabled:b,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--idle-amber)",color:"#000",border:"none",opacity:b?.5:1},children:b?"PULLING...":"↓ PULL"})]}),A&&l.jsx("div",{className:"text-[11px] p-2",style:{background:A.status==="ok"||A.status==="up-to-date"?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${A.status==="ok"||A.status==="up-to-date"?"var(--active-green)":"#D32F2F"}`,color:A.status==="ok"||A.status==="up-to-date"?"var(--active-green)":"#EF5350"},children:A.message}),l.jsx("div",{className:"text-[11px]",style:{color:"var(--terminal-text-secondary)"},children:Y.length>0?l.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",Y.length," unsaved change",Y.length>1?"s":""]}):l.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),Y.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:Y.map(({status:D,file:B})=>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:B})]},B))})]}),Y.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:ee,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:N,onChange:D=>_(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)"}})]}),Y.length>0&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:W,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=Y.map(B=>`${B.status} ${B.file}`).join(`
|
|
92
|
-
`);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(s8,{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}),q&&l.jsxs("div",{className:"text-[11px] p-2",style:{background:"rgba(59,185,80,0.1)",border:"1px solid var(--active-green)",color:"var(--active-green)"},children:["Saved! ",q.filesChanged," file",q.filesChanged>1?"s":""," committed",q.pushed?" & pushed":"",q.pushError?` (push error: ${q.pushError})`:""]}),z&&l.jsx("div",{className:"text-[11px] p-2",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:z}),(e==null?void 0:e.lastCommit)&&l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:["Last save: ",e.lastCommit.message," (",xy(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:xy(D.date)})]}),l.jsx("button",{onClick:()=>de(D.sha),disabled:R,className:"text-[10px] font-bold px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--idle-amber)"},children:"LOAD"})]},D.sha))})]})]})]})]})}function c8({onClose:e}){const[n,a]=v.useState(null),[i,o]=v.useState(!0),[u,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 wr.syncStats({instanceId:x.instanceId,roleCount:m.company.roleCount,totalTokens:m.company.totalTokens,rolesData:m.roles.map(g=>({roleId:g.roleId,name:g.name,tokens:g.totalTokens}))}),f(!0)}catch{}}).catch(m=>d(m.message)).finally(()=>o(!1))},[]),i?l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading stats..."}):u||!n?l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u||"Failed to load stats",l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]}):l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:20},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Company Stats"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:20},children:[l.jsx(Su,{label:"Roles",value:String(n.company.roleCount)}),l.jsx(Su,{label:"Avg Level",value:`Lv.${n.company.avgLevel}`}),l.jsx(Su,{label:"Total Tokens",value:n.company.formattedTokens}),l.jsx(Su,{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(u8,{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:d8(m)}),l.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",h.costUsd.toFixed(2)]})]},m))})]})]})}function Su({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 u8({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:gy(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:gy(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 gy(e){return e>=20?"#FFD700":e>=10?"#C0A0FF":e>=5?"#4FC3F7":e>=3?"#81C784":"rgba(255,255,255,0.4)"}function d8(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.split("-").slice(0,2).join(" ")}function f8({onClose:e,onSyncComplete:n}){const[a,i]=v.useState([]),[o,u]=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:N}=await ye.getSyncRoles();i(N);const _=N.filter(z=>z.source.sync!=="off");if(_.length===0){u([]),k(null);return}try{const z=await wr.syncCheck(_.map(R=>({roleId:R.roleId,sourceId:R.source.id,currentVersion:R.source.upstream_version??R.source.forked_at??"0.0.0"})));k(!0);const H=[];for(const R of z.updates){if(!R.hasUpdate)continue;const I=_.find(L=>L.roleId===R.roleId);if(!I)continue;const{character:q}=await wr.syncPull(R.sourceId),X=[];I.persona.trim()!==q.persona.trim()&&X.push({field:"persona",local:I.persona.slice(0,120)+(I.persona.length>120?"...":""),upstream:q.persona.slice(0,120)+(q.persona.length>120?"...":"")});const A=JSON.stringify(I.authority),$=JSON.stringify(q.authority);A!==$&&X.push({field:"authority",local:`${I.authority.autonomous.length} autonomous, ${I.authority.needsApproval.length} approval`,upstream:`${q.authority.autonomous.length} autonomous, ${q.authority.needsApproval.length} approval`}),X.length>0&&H.push({roleId:R.roleId,roleName:I.name,sourceId:R.sourceId,currentVersion:R.currentVersion,latestVersion:R.latestVersion,fields:X})}u(H)}catch{k(!1),u([])}}catch(N){b(N instanceof Error?N.message:"Failed to check for updates")}finally{f(!1)}},[]);v.useEffect(()=>{E()},[E]);const C=async N=>{h(N.roleId);try{const{character:_,version:z}=await wr.syncPull(N.sourceId);await ye.applySyncUpdate({roleId:N.roleId,changes:{persona:_.persona,authority:_.authority},upstreamVersion:z}),g(H=>new Set(H).add(N.roleId)),n==null||n()}catch(_){b(_ instanceof Error?_.message:"Failed to apply update")}finally{h(null)}};return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Role Sync"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick: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(N=>!x.has(N.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(N=>l.jsxs("div",{style:{marginBottom:12,padding:14,background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:14,fontWeight:500},children:N.roleName}),l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[N.sourceId," · v",N.currentVersion," → v",N.latestVersion]})]}),x.has(N.roleId)?l.jsx("span",{style:{fontSize:12,color:"#81C784"},children:"Applied ✓"}):l.jsx("button",{onClick:()=>C(N),disabled:m===N.roleId,style:{background:"#1565C0",border:"none",color:"white",borderRadius:6,padding:"5px 12px",fontSize:12,cursor:m===N.roleId?"wait":"pointer",opacity:m===N.roleId?.6:1},children:m===N.roleId?"Applying...":"Apply Update"})]}),N.fields.map(_=>l.jsxs("div",{style:{marginBottom:6,fontSize:12},children:[l.jsx("div",{style:{color:"rgba(255,255,255,0.5)",marginBottom:2,textTransform:"uppercase",fontSize:10,letterSpacing:.5},children:_.field}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[l.jsxs("div",{style:{padding:"4px 8px",background:"rgba(255,100,100,0.08)",borderRadius:4,color:"rgba(255,255,255,0.6)"},children:[l.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.3)"},children:"LOCAL"}),l.jsx("br",{}),_.local]}),l.jsxs("div",{style:{padding:"4px 8px",background:"rgba(100,255,100,0.08)",borderRadius:4,color:"rgba(255,255,255,0.6)"},children:[l.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.3)"},children:"UPSTREAM"}),l.jsx("br",{}),_.upstream]})]})]},_.field))]},N.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 h8({onClose:e}){const[n,a]=v.useState(null),[i,o]=v.useState(!0),[u,d]=v.useState(null),[f,m]=v.useState(null),h=v.useCallback(async()=>{o(!0),d(null);try{const N=await ye.getGitStatus();a(N)}catch(N){d(N instanceof Error?N.message:"Failed to load git status")}finally{o(!1)}},[]);v.useEffect(()=>{h()},[h]);const x=async N=>{m(N.path);try{await ye.deleteWorktree(N.path),await h()}catch(_){d(_ instanceof Error?_.message:"Failed to remove worktree")}finally{m(null)}},g=async N=>{m(N);try{await ye.deleteBranch(N),await h()}catch(_){d(_ instanceof Error?_.message:"Failed to delete branch")}finally{m(null)}};if(i&&!n)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading git status..."});if(u&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const w=n.worktrees.filter(N=>N.status==="active"),b=n.worktrees.filter(N=>N.status==="pending-merge"),j=n.worktrees.filter(N=>N.status==="stale");function k(N){const _=N.split("/");if(_.length>1){const z=_[_.length-1],H=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const R of H)if(z.toLowerCase().includes(R))return R}return null}function E(N,_=40){return N.length<=_?N:"..."+N.slice(N.length-_+3)}function C(N){const _=Date.now()-new Date(N).getTime(),z=Math.floor(_/6e4);if(z<1)return"just now";if(z<60)return`${z}m ago`;const H=Math.floor(z/60);return H<24?`${H}h ago`:`${Math.floor(H/24)}d ago`}return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"GIT STATUS"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:h,disabled:i,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:i?"wait":"pointer"},children:i?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),u&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Branch: "}),l.jsx("span",{style:{fontWeight:500},children:n.currentBranch})]}),l.jsx("div",{children:n.unsavedCount>0&&l.jsxs("span",{style:{color:"#FFB74D",fontSize:12},children:[n.unsavedCount," unsaved"]})})]}),n.lastCommit&&l.jsxs("div",{style:{marginTop:6,fontSize:11,color:"rgba(255,255,255,0.4)"},children:["Last commit: ",n.lastCommit.message.slice(0,60),n.lastCommit.message.length>60?"...":""," · ",C(n.lastCommit.date)]})]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Cu,{label:"Active Worktrees",count:w.length}),w.map(N=>l.jsx(Hh,{wt:N,roleFromBranch:N.roleId||k(N.branch),truncatePath:E,timeAgo:C,removing:f===N.path,onRemove:()=>x(N),statusColor:"#4FC3F7",statusIcon:"📂"},N.path))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Cu,{label:"Pending Merge",count:b.length}),b.map(N=>l.jsx(Hh,{wt:N,roleFromBranch:N.roleId||k(N.branch),truncatePath:E,timeAgo:C,removing:f===N.path,onRemove:()=>x(N),statusColor:"#FFB74D",statusIcon:"⚠️"},N.path))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Cu,{label:"Stale",count:j.length}),j.map(N=>l.jsx(Hh,{wt:N,roleFromBranch:N.roleId||k(N.branch),truncatePath:E,timeAgo:C,removing:f===N.path,onRemove:()=>x(N),statusColor:"#ff6b6b",statusIcon:"🔴"},N.path))]}),n.staleBranches.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Cu,{label:"Unmerged Branches",count:n.staleBranches.length}),n.staleBranches.map(N=>l.jsxs("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{style:{fontSize:13},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)",marginRight:6},children:"⚠️"}),l.jsx("span",{style:{fontWeight:500},children:N})]}),l.jsx("button",{onClick:()=>g(N),disabled:f===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:f===N?"wait":"pointer",opacity:f===N?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:f===N?"...":"DELETE"})]},N))]}),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," · ",C(n.lastMerge.mergedAt)]})]})}function Cu({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 Hh({wt:e,roleFromBranch:n,truncatePath:a,timeAgo:i,removing:o,onRemove:u,statusColor:d,statusIcon:f}){return l.jsx("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:500,marginBottom:2},children:[l.jsx("span",{style:{marginRight:6},children:f}),e.branch,n&&l.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)",textTransform:"uppercase"},children:n})]}),e.task&&l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:2},children:['"',e.task.slice(0,50),e.task.length>50?"...":"",'"']}),l.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[a(e.path)," · ",e.filesChanged," file",e.filesChanged!==1?"s":""," changed"," · ",i(e.createdAt)]}),e.conflictFiles&&e.conflictFiles.length>0&&l.jsxs("div",{style:{fontSize:10,color:"#ff6b6b",marginTop:4},children:["⛔"," CONFLICT: ",e.conflictFiles.join(", ")]})]}),l.jsx("button",{onClick:u,disabled:o,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:d,borderRadius:4,padding:"3px 8px",fontSize:10,cursor:o?"wait":"pointer",opacity:o?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:o?"...":"REMOVE"})]})})}function m8({onClose:e}){const[n,a]=v.useState(null),[i,o]=v.useState(!0),[u,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(u&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const 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:"×"})]})]}),u&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13,display:"flex",justifyContent:"space-between"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Sessions: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.active})]}),l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Ports in use: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.totalPorts})]})]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Uh,{label:"Active",count:w.length}),w.map(k=>l.jsx(qh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#4FC3F7"},k.sessionId))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Uh,{label:"Idle",count:b.length}),b.map(k=>l.jsx(qh,{session:k,removing:f===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#FFB74D"},k.sessionId))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Uh,{label:"Dead",count:j.length}),j.map(k=>l.jsx(qh,{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 Uh({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 p8(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 qh({session:e,removing:n,onRemove:a,statusColor:i}){const{ports:o}=e;return l.jsx("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:500,marginBottom:2},children:[l.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:i,marginRight:8,verticalAlign:"middle"}}),l.jsx("span",{style:{textTransform:"uppercase"},children:e.roleName||e.roleId}),e.jobStatus&&l.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)"},children:e.jobStatus})]}),e.task&&l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:4},children:['"',e.task.slice(0,60),e.task.length>60?"...":"",'"']}),l.jsxs("div",{style:{fontSize:11,display:"flex",gap:8,marginBottom:2},children:[l.jsxs("span",{style:{color:"#81C784"},children:["API:",o.api||"?"]}),l.jsxs("span",{style:{color:"#64B5F6"},children:["Vite:",o.vite||"?"]}),o.hmr&&l.jsxs("span",{style:{color:"#FFB74D"},children:["HMR:",o.hmr]})]}),l.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[e.sessionId.slice(0,12),"...",e.worktreePath&&l.jsxs(l.Fragment,{children:[" · ",x8(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" · ","PID:",e.pid]})," · ",p8(e.startedAt)]})]}),l.jsx("button",{onClick:a,disabled:n,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:"#ff6b6b",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:n?"wait":"pointer",opacity:n?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:n?"...":"STOP"})]})})}function x8(e,n=35){return e.length<=n?e:"..."+e.slice(e.length-n+3)}function g8({onClose:e,speechSettings:n,onSpeechSettingsChange:a,language:i,onLanguageChange:o,onOpenSync:u,onOpenGitStatus:d,onOpenSessions:f,onOpenStats:m}){var oe;const[h,x]=v.useState(null),[g,w]=v.useState(null),[b,j]=v.useState(!1),[k,E]=v.useState(!1),[C,N]=v.useState(!1),[_,z]=v.useState(null),[H,R]=v.useState(""),[I,q]=v.useState(!1),[X,A]=v.useState(!1),[$,L]=v.useState(null),[Y,se]=v.useState(!1);v.useEffect(()=>{ye.getPreferences().then(async de=>{const V=de;if(x(V.instanceId??null),V.instanceId)try{const{name:D}=await wr.getMyName(V.instanceId);w(D)}catch{}}).catch(()=>{}),ye.getCodeRoot().then(({codeRoot:de})=>{z(de),de&&R(de)}).catch(()=>{})},[]);const ee=async()=>{N(!0);try{const V=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();V.ok&&(x(V.newInstanceId),E(!1))}catch{}N(!1)},W=()=>{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: $",((oe=n==null?void 0:n.dailyBudgetUsd)==null?void 0:oe.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:V})=>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:V},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=>{R(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()){A(!0),L(null);try{const de=await ye.setCodeRoot(H.trim());z(de.codeRoot),R(de.codeRoot),q(!1),se(!0),setTimeout(()=>se(!1),3e3)}catch(de){L(de instanceof Error?de.message:"Failed to set code root")}finally{A(!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:()=>{q(!1),R(_||""),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:_?"var(--terminal-text)":"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_||"Not configured"}),l.jsx("button",{onClick:()=>{q(!0),L(null),se(!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"})]}),Y&&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:W,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:ee,disabled:C,style:{padding:"4px 12px",fontSize:9,fontWeight:700,border:"1px solid rgba(255,50,50,0.4)",background:"rgba(255,50,50,0.15)",color:"#ff6464",borderRadius:4,cursor:"pointer"},children:C?"...":"Confirm Regenerate"}),l.jsx("button",{onClick:()=>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:[u&&l.jsx("button",{onClick:()=>{e(),u()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🔄 ROLE SYNC"}),d&&l.jsx("button",{onClick:()=>{e(),d()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"📂 GIT STATUS"}),f&&l.jsx("button",{onClick:()=>{e(),f()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🖥 SESSIONS"}),m&&l.jsx("button",{onClick:()=>{e(),m()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"📊 COMPANY STATS"}),l.jsx("button",{onClick:()=>window.open("https://tycono.ai/store.html","_blank"),className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🌐 WEB STORE"})]}),g&&l.jsx("div",{style:{textAlign:"center",marginTop:-8},children:l.jsx("a",{href:`https://tycono.ai/profile.html?u=${encodeURIComponent(g)}`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:10,color:"var(--terminal-text-muted)",textDecoration:"none"},onMouseEnter:de=>de.currentTarget.style.color="var(--accent)",onMouseLeave:de=>de.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile →"})})]})})]})})}function y8({theme:e,onThemeChange:n,onClose:a}){const i=v.useRef(null);return v.useEffect(()=>{const o=u=>{i.current&&!i.current.contains(u.target)&&a()};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[a]),l.jsx("div",{ref:i,className:"theme-dropup",children:Object.entries(ll).map(([o,u])=>l.jsxs("button",{className:`theme-dropup__item${e===o?" theme-dropup__item--active":""}`,onClick:()=>{n(o),a()},title:u.name,children:[l.jsxs("span",{className:"theme-dropup__swatch",style:{background:u.vars["--hud-bg"],borderColor:u.vars["--pixel-border"]},children:[l.jsx("span",{style:{background:u.vars["--accent"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:u.vars["--active-green"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:u.vars["--idle-amber"],width:5,height:5,borderRadius:1}})]}),l.jsx("span",{className:"theme-dropup__name",children:u.icon})]},o))})}const vs={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function b8({roles:e,roleStatuses:n,activeExecs:a,sessions:i,knowledgeDocs:o,roleLevels:u,companyName:d,getAppearance:f,waveCenterWaves:m,renderProfile:h,channel:x,onChannelChange:g,onClose:w,children:b}){const[j,k]=v.useState(!1),E=m.filter(I=>I.rootJobs.some(q=>{const X=n[q.roleId];return X==="working"||X==="thinking"})),C=[...e].sort((I,q)=>I.level==="c-level"&&q.level!=="c-level"?-1:I.level!=="c-level"&&q.level==="c-level"?1:I.name.localeCompare(q.name)),N=e.filter(I=>n[I.id]==="working").length,_=i.filter(I=>I.status==="active").length,z=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"?(z==null?void 0:z.name)??x.roleId:"Dashboard",R=x.type==="terminal"?`${_} active sessions`:x.type==="wave"?`${E.length} running`:x.type==="knowledge"?`${o.length} documents`:x.type==="role"?(z==null?void 0:z.level)==="c-level"?"C-Level":"Team member":`${N} working · ${e.length} total`;return l.jsxs("div",{className:"fixed inset-0 z-[60] flex",style:{background:"var(--terminal-bg, #1C1612)"},children:[l.jsxs("div",{className:"flex flex-col shrink-0 overflow-y-auto",style:{width:240,borderRight:"1px solid var(--terminal-border, #2E261F)",background:"var(--terminal-surface, #1a1510)"},children:[l.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 shrink-0",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsx("span",{className:"text-[11px] font-bold tracking-wider flex-1",style:{color:"var(--terminal-text, #fff5eb)",fontFamily:"var(--pixel-font)"},children:d}),N>0&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full animate-pulse",style:{background:"#4CAF5020",color:"#4CAF50"},children:[N," live"]})]}),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].rootJobs.filter(I=>{const q=n[I.roleId];return q==="working"||q==="thinking"}).length,"/",E[0].rootJobs.length," roles working"]})]}),l.jsxs("div",{className:"mx-3 mt-3 grid grid-cols-2 gap-1.5",children:[l.jsx(Eu,{icon:"💬",label:"Chats",badge:_||void 0,active:x.type==="terminal",onClick:()=>g({type:"terminal"})}),l.jsx(Eu,{icon:"⚡",label:"Waves",live:E.length>0,active:x.type==="wave",onClick:()=>g({type:"wave"})}),l.jsx(Eu,{icon:"📋",label:"Decisions",active:x.type==="operations",onClick:()=>g({type:"operations"})}),l.jsx(Eu,{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"}),C.map(I=>{var Y;const q=n[I.id],X=a.find(se=>se.roleId===I.id),A=vs[I.id]??"#666",$=(Y=u[I.id])==null?void 0:Y.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?`${A}18`:"transparent",borderLeft:L?`2px solid ${A}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx(Ul,{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:q==="working"?"#4CAF50":q==="idle"?"#FFC107":"#9E9E9E",border:"1.5px solid var(--terminal-surface, #1a1510)"}})]}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"text-[11px] truncate",style:{color:"var(--terminal-text, #fff5eb)"},children:[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:A},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})]}),q==="working"&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:A}})]},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 q=e.find($=>$.id===I.roleId),X=vs[I.roleId]??"#666",A=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:A?`${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:(q==null?void 0:q.name)??I.roleId}),l.jsx("div",{className:"text-[8px] truncate",style:{color:"var(--terminal-text-muted)"},children:I.task.slice(0,40)})]})]},I.jobId??I.roleId)})})]}),l.jsx("div",{className:"px-3 py-3 shrink-0",style:{borderTop:"1px solid var(--terminal-border, #2E261F)"},children:l.jsxs("button",{onClick: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"&&z&&l.jsxs("button",{onClick:()=>k(I=>!I),className:"relative shrink-0 rounded-lg overflow-hidden hover:opacity-80 transition-opacity cursor-pointer",style:{width:28,height:28,background:`${vs[z.id]??"#666"}30`},title:"View profile",children:[l.jsx(Ul,{roleId:z.id,appearance:f(z.id),scale:1.5}),l.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full",style:{background:n[z.id]==="working"?"#4CAF50":n[z.id]==="idle"?"#FFC107":"#9E9E9E",border:"2px solid var(--terminal-bg, #1C1612)"}})]}),l.jsx("span",{className:"text-[15px] font-semibold",style:{color:"var(--terminal-text, #fff5eb)"},children:H}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted, #887766)"},children:R}),l.jsx("span",{className:"flex-1"}),x.type==="role"&&l.jsx("button",{onClick:()=>k(I=>!I),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:j?"var(--terminal-text)":"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)",background:j?"var(--terminal-border)":"transparent"},children:"Profile"}),x.type!=="dashboard"&&l.jsx("button",{onClick:()=>g({type:"dashboard"}),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Dashboard"})]}),l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx("div",{className:"flex-1 overflow-hidden relative pro-panel-inline",children:b}),j&&x.type==="role"&&h&&l.jsx("div",{className:"shrink-0 overflow-hidden pro-panel-inline",style:{width:420,borderLeft:"1px solid var(--terminal-border, #2E261F)"},children:h(()=>k(!1))})]})]})]})}function v8({role:e,messages:n,isStreaming:a,mode:i,onModeChange:o,onSend:u,isWave:d}){const f=vs[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsx(hv,{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(Pm,{mode:i,onModeChange:o,onSend:(m,h)=>u(m,i,h),disabled:a,disabledReason:a?`${e.id.toUpperCase()} is responding...`:void 0})]})}function w8({role:e,onSend:n,getAppearance:a,onOpenProfile:i}){const[o,u]=v.useState("talk"),d=vs[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[l.jsx("button",{onClick:i,className:"cursor-pointer hover:opacity-80 transition-opacity",children:l.jsx("div",{className:"rounded-lg p-1",style:{background:`${d}20`},children:l.jsx(Ul,{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(Pm,{mode:o,onModeChange:u,onSend:f=>n(f,o),disabled:!1})]})}function Eu({icon:e,label:n,active:a,badge:i,live:o,onClick:u}){return l.jsxs("button",{onClick:u,className:"flex flex-col items-center gap-1 py-3 rounded-lg transition-all hover:opacity-90",style:{background:a?"var(--desk-wood, #5C3D2E)":"var(--terminal-border, #2E261F)",border:a?"1px solid var(--desk-wood, #5C3D2E)":"1px solid transparent"},children:[l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"text-[16px]",children:e}),o&&l.jsx("span",{className:"absolute -top-1 -right-2 w-2 h-2 rounded-full animate-pulse",style:{background:"#EF4444"}}),i!==void 0&&i>0&&!o&&l.jsx("span",{className:"absolute -top-1.5 -right-3 text-[7px] px-1 py-0.5 rounded-full font-bold leading-none",style:{background:"var(--desk-wood, #5C3D2E)",color:"#fff",minWidth:14,textAlign:"center"},children:i})]}),l.jsx("span",{className:"text-[10px] font-semibold",style:{color:a?"#fff":"var(--terminal-text, #fff5eb)"},children:n})]})}function k8({roles:e,roleStatuses:n,activeExecs:a,waves:i,knowledgeDocs:o,roleLevels:u,getAppearance:d,onRoleClick:f,onWaveClick:m,onKnowledgeClick:h}){const x=e.filter(g=>n[g.id]==="working");return l.jsx("div",{className:"h-full overflow-y-auto px-6 py-5",children:l.jsxs("div",{className:"space-y-5 max-w-4xl",children:[l.jsxs("div",{className:"flex gap-3",children:[l.jsx(yy,{label:"New Wave",icon:"⚡",color:"#EF4444",onClick:m}),l.jsx(yy,{label:"Knowledge",icon:"📚",color:"#0D9488",onClick:h})]}),x.length>0&&l.jsx(Nu,{title:"Currently Working",count:x.length,children:a.map(g=>{const w=e.find(j=>j.id===g.roleId),b=vs[g.roleId]??"#666";return l.jsxs("button",{onClick:()=>f(g.roleId),className:"flex items-center gap-3 px-4 py-2.5 rounded hover:opacity-80 w-full text-left",style:{background:`${b}10`},children:[l.jsx("div",{className:"shrink-0",style:{width:24,height:24},children:l.jsx(Ul,{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(Nu,{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=u[g.id])==null?void 0:j.level;return l.jsxs("button",{onClick:()=>f(g.id),className:"flex items-center gap-2 px-3 py-2 rounded hover:opacity-80 text-left",children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:w==="working"?"#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(Nu,{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(Nu,{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 yy({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 Nu({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 vm=5e4;function Tv(e){return e<vm?1:Math.max(1,Math.floor(Math.sqrt(e/vm)))}function by(e){return vm*e*e}function j8(e){const n=Tv(e),a=by(n),i=by(n+1);return Math.min(1,(e-a)/(i-a))}function Yh(e){const n={};for(const[a,i]of Object.entries(e)){const o=i.inputTokens+i.outputTokens;n[a]={level:Tv(o),totalTokens:o,progress:j8(o)}}return n}const S8=[{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 vy(e){return S8.filter(n=>n.check(e))}const wy={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function C8({importJob:e,onImportDone:n}){var ac,Li,lc,ic,sc;const[a,i]=v.useState([]),[o,u]=v.useState([]),[d,f]=v.useState([]),[m,h]=v.useState([]),[x,g]=v.useState([]),[w,b]=v.useState([]),[j,k]=v.useState("TYCONO"),[E,C]=v.useState(!0),[N,_]=v.useState(null),[z,H]=v.useState({type:"none"}),[R,I]=v.useState(null),[q,X]=v.useState(null),[A,$]=v.useState([]),[L,Y]=v.useState(!1),[se,ee]=v.useState(!1),[W,oe]=v.useState([]),[de,V]=v.useState([]),[D,B]=v.useState(0),[U,T]=v.useState(!1),[ie,ge]=v.useState({}),[pe,ze]=v.useState("ceo"),[Ie,He]=v.useState(null),[st,Pe]=v.useState(!1),[et,Ee]=v.useState(!1),[De,yt]=v.useState({}),ut=v.useRef({}),[pt,jt]=v.useState(!1),[Wt,Ft]=v.useState(null),[Et,$n]=v.useState({}),[me,Se]=v.useState([]),Ne=v.useMemo(()=>{const F={};for(const P of me)F[P.roleId]=P;return F},[me]),[K,ue]=v.useState([]),[te,ke]=v.useState(0),[ve,_e]=v.useState(qg()),Be=v.useRef(qg()),Oe=v.useRef(!1),qe=v.useRef(-1),[rt,Ve]=v.useState(null),bt=v.useRef(null),[Re,Ue]=v.useState(void 0),[_t,Bt]=v.useState(!1);v.useEffect(()=>{ye.getStatus().then(F=>{Ue(F.engine),Bt(!!F.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:Ot,setAppearance:fn,resetAppearance:wn,theme:Z,setTheme:$e,speechSettings:nt,setSpeechSettings:Pt,language:we,setLanguage:kt}=C6(),[ln,sn]=v.useState(null),[,ne]=v.useState("character"),Ae=A6(),[We,Nt]=v.useState(!1),[kn,ur]=v.useState(!1),[xn,gn]=v.useState(!1),[dr,sl]=v.useState(!1),[Ju,Fs]=v.useState(!1),[Vo,Ta]=v.useState(!1),[Ti,ca]=v.useState(!1),[Vn,Wl]=v.useState(null);v.useEffect(()=>{Ae.refresh()},[]),v.useEffect(()=>{const F=P=>{(P.metaKey||P.ctrlKey)&&P.key==="s"&&(P.preventDefault(),Nt(!0))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),v.useEffect(()=>{if(!dr)return;let F=!1;const P=async()=>{try{const he=await ye.getGitStatus();F||Wl(he)}catch{}};P();const re=setInterval(P,1e4);return()=>{F=!0,clearInterval(re)}},[dr]);const[jr,jn]=v.useState(null),[Fa,Ma]=v.useState(null),[fr,Ra]=v.useState([]),[ol,Ms]=v.useState(!1),Rs=v.useRef(!1),zs=v.useRef(null);let Gl=v.useRef(0);const Vl=v.useRef(new Set),Qr=v.useRef(Date.now()),Dn=(F,P,re)=>{const he={id:Gl.current++,type:F,text:P,detail:re};Ra(je=>[...je,he])};v.useEffect(()=>{var F;ol&&((F=zs.current)==null||F.scrollIntoView({behavior:"smooth"}))},[fr,ol]),v.useEffect(()=>{e&&(Rs.current||(Rs.current=!0,Ma("Scanning knowledge sources..."),Ra([{id:0,type:"scan",text:"Starting knowledge import..."}]),Gl.current=1,fetch("/api/setup/import-knowledge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e.paths,companyRoot:e.companyRoot})}).then(async F=>{var je;const P=(je=F.body)==null?void 0:je.getReader();if(!P)return;const re=new TextDecoder;let he="";for(;;){const{done:Le,value:It}=await P.read();if(Le)break;he+=re.decode(It,{stream:!0});const dt=he.split(`
|
|
93
|
-
`);he=dt.pop()||"";let Ze="";for(const Je of dt)if(Je.startsWith("event: "))Ze=Je.slice(7).trim();else if(Je.startsWith("data: ")&&Ze){try{const ft=JSON.parse(Je.slice(6));switch(Ze){case"scanning":Ma(`Scanning: ${ft.path} (${ft.fileCount} files)`),Dn("scan",`Found ${ft.fileCount} files`,ft.path);break;case"processing":jn({index:ft.index,total:ft.total}),Ma(`Importing knowledge... (${ft.index}/${ft.total})`),Dn("process",`Processing: ${ft.file}`,`${ft.index} / ${ft.total}`);break;case"created":Dn("created",ft.title,ft.summary);break;case"skipped":Dn("process",`Skipped: ${ft.file}`,ft.reason);break;case"done":Ma(null),jn(null),Dn("done",`Import complete! ${ft.created} created, ${ft.skipped} skipped.`),xt(`Knowledge import complete! ${ft.created} documents imported.`,"#2E7D32"),n==null||n();break;case"error":Ma(null),jn(null),Dn("error",ft.message),xt(`Import failed: ${ft.message}`,"#B71C1C"),n==null||n();break}}catch{}Ze=""}}}).catch(F=>{Ma(null),Dn("error",F.message),xt(`Import error: ${F.message}`,"#B71C1C"),n==null||n()})))},[e]);const[Zr,ua]=v.useState("iso"),Jr=v.useRef("iso"),[Or,Tn]=v.useState({type:"dashboard"}),[Ko,hr]=v.useState(typeof window<"u"?window.innerWidth:1200);v.useEffect(()=>{const F=()=>hr(window.innerWidth);return window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]);const Kl=Ko<1024,[Sr,da]=v.useState(!1),[mr,Po]=v.useState(560),[Ln,Gt]=v.useState([]),[fa,Xn]=v.useState(null),[ea,ta]=v.useState(null),{sendMessage:ed}=k6(),Fi=v.useRef(new Map);v.useEffect(()=>{Promise.all([ye.getCompany().then(F=>{k(F.name),i(F.roles)}),ye.getOrgTree().then(F=>{ge(F.nodes),ze(F.root)}).catch(()=>{}),ye.getCostSummary().then(F=>$r(Yh(F.byRole))).catch(()=>{})]).catch(F=>_(`Failed to load: ${F.message}`)).finally(()=>C(!1)),ye.getProjects().then(u).catch(()=>{}),ye.getStandups().then(f).catch(()=>{}),ye.getWaves().then(h).catch(()=>{}),ye.getDecisions().then(g).catch(()=>{}),ye.getKnowledge().then(b).catch(()=>{}),ye.getQuestProgress().then(F=>{const P=Yg(F);P.activeChapter!==F.activeChapter&&ye.saveQuestProgress(P).catch(()=>{}),_e(P),Be.current=P,Oe.current=!0,ye.getCoins().then(re=>{var he;re.totalEarned===0?ye.migrateCoins(((he=P.completedQuests)==null?void 0:he.length)??0).then(je=>ke(je.balance)).catch(()=>{}):ke(re.balance)}).catch(()=>{})}).catch(()=>{Oe.current=!0})},[]),v.useEffect(()=>{if(qe.current===-1){qe.current=o.length;return}o.length>qe.current&&Qt({type:"project_created"}),qe.current=o.length},[o.length]);const Pl=v.useRef(!1);v.useEffect(()=>{if(!(!Oe.current||a.length===0||Pl.current)){Pl.current=!0;for(const F of a)Qt({type:"role_hired",condition:{roleId:F.id,roleCount:a.length}})}},[a.length]),v.useEffect(()=>{ye.getSessions().then(F=>{const P=F.filter(he=>he.source!=="wave");if(P.length>0){const he=P.map(Le=>({...Le,messages:[]}));Gt(he);const je=he.find(Le=>Le.status==="active")??he[0];Xn(je.id),_a()}const re=F.filter(he=>he.source==="wave").map(he=>he.id);re.length>0&&ye.deleteSessions(re).catch(()=>{})}).catch(F=>{console.error("Failed to load sessions",F)})},[]),v.useEffect(()=>{const F=()=>{fetch("/api/exec/status").then(re=>re.json()).then(re=>{$n(re.statuses??{}),Se(re.activeExecutions??[])}).catch(()=>{})};F();const P=setInterval(F,3e3);return()=>clearInterval(P)},[]);const tr=v.useMemo(()=>{const F={...Et};if(ea){const P=Ln.find(re=>re.id===ea);P&&(F[P.roleId]="working")}return F},[Et,ea,Ln]);v.useEffect(()=>{z.type==="role"?ye.getRole(z.roleId).then(I).catch(console.error):I(null)},[z]);const na=()=>H({type:"none"}),Mi=async(F,P)=>{const re=await ye.updateDecision(F,P);g(he=>he.map(je=>je.id===F?re:je))},za=async F=>{await ye.deleteDecision(F),g(P=>P.filter(re=>re.id!==F))},Fn=F=>{H(F),da(!1),ee(!1)},_a=()=>{da(!0),H({type:"none"}),ee(!1)},cl=()=>{ee(!0),da(!1),H({type:"none"})},Qo=async(F,P)=>{const re=a.find(je=>je.id===F),he=(q==null?void 0:q.mode)==="ask";X(null);try{const je=await ye.startJob({type:"assign",roleId:F,task:P,readOnly:he}),Le=je.jobId,It=je.sessionId??`job-${Le}`,dt=wy[F]??"#666",Ze=`${F.toUpperCase()} · ${(re==null?void 0:re.name)??F}`;T(!1),$([{sessionId:It,jobId:Le,title:Ze,color:dt}]),Qt({type:"task_executed",condition:{roleId:F}}),Zt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(re==null?void 0:re.name)??F}] ${he?"Ask":"Assign"}: ${P}`,type:"dispatch",targetRoleId:F})}catch(je){xt(`Failed to start job: ${je instanceof Error?je.message:"unknown"}`,"#C62828")}},Ql=v.useRef(0),xt=(F,P)=>{const re=++Ql.current;ue(he=>[...he,{id:re,message:F,color:P}]),setTimeout(()=>ue(he=>he.filter(je=>je.id!==re)),4e3)},_s=F=>{bt.current&&clearTimeout(bt.current),Ve(F),bt.current=setTimeout(()=>Ve(null),8e3)},Qt=F=>{if(!Oe.current)return;let P=Be.current;const re=av(P);let he=0;const je=[];for(const It of re){if(!SN(It,F))continue;const{progress:dt,quest:Ze}=kN(P,It.id);Ze&&(P=dt,he+=Ze.rewards.coins??0,je.push(Ze.title))}if(je.length===0)return;P=Yg(P),Be.current=P,_e(P);const Le=he>0?` 💰 +${he.toLocaleString()}`:"";je.length===1?xt(`📋 Quest complete: ${je[0]}${Le}`,"#7C3AED"):xt(`📋 ${je.length} quests complete!${Le}`,"#7C3AED"),Ve(null),ye.saveQuestProgress(P).catch(()=>{}),he>0&&ye.earnCoins(he,`quests: ${je.length}`,je.join(",")).then(It=>ke(It.balance)).catch(()=>{})};v.useEffect(()=>{if(!rt)return;const F=document.querySelector(`[data-quest-target="${rt}"]`);if(!F)return;F.classList.add("quest-spotlight");const P=()=>{F.classList.remove("quest-spotlight"),Ve(null),bt.current&&clearTimeout(bt.current)};return F.addEventListener("click",P,{once:!0}),()=>{F.classList.remove("quest-spotlight"),F.removeEventListener("click",P)}},[rt]);const $r=F=>{var re,he;const P=ut.current;for(const[je,Le]of Object.entries(F)){const It=((re=P[je])==null?void 0:re.level)??0;if(It>0&&Le.level>It){const dt=((he=a.find(Ze=>Ze.id===je))==null?void 0:he.name)??je.toUpperCase();xt(`${dt} leveled up to Lv.${Le.level}!`,"#7C3AED")}}ut.current=F,yt(F)};v.useEffect(()=>{const F={roles:Object.entries(De).map(([je,Le])=>({id:je,level:Le.level,totalTokens:Le.totalTokens})),totalTokens:Object.values(De).reduce((je,Le)=>je+Le.totalTokens,0),roleCount:a.length,completedQuests:ve.completedQuests},P=vy(F),re=new Set(P.map(je=>je.id));if(Date.now()-Qr.current>5e3){const je=Vl.current;for(const Le of P)je.has(Le.id)||xt(`${Le.icon} Badge earned: ${Le.name}!`,"#D4A017")}Vl.current=re},[De,a.length,ve.completedQuests]);const Ba=v.useMemo(()=>wN(ve),[ve]),Ri=()=>{var P;const F=A[A.length-1];F&&(xt(`${F.title} completed`,F.color),Zt.pushMessage({ts:Date.now(),roleId:((P=F.title.split(" · ")[0])==null?void 0:P.toLowerCase())??"unknown",text:`[${F.title}] Job completed`,type:"dispatch"})),ye.getStandups().then(f).catch(console.error),ye.getCompany().then(re=>i(re.roles)).catch(console.error),ye.getCostSummary().then(re=>$r(Yh(re.byRole))).catch(()=>{})},ul=v.useRef(new Map),zi=F=>{if(ul.current.has(F))return;const P=new AbortController;ul.current.set(F,P),ta(re=>re??F),fetch(`/api/sessions/${F}/stream?from=0`,{signal:P.signal}).then(async re=>{var It,dt;if(!re.ok||!re.body)return;const he=re.body.getReader(),je=new TextDecoder;let Le="";for(;;){const{done:Ze,value:Je}=await he.read();if(Ze)break;Le+=je.decode(Je,{stream:!0});const ft=Le.split(`
|
|
94
|
-
`);Le=ft.pop()??"";let St="";for(const ti of ft)if(ti.startsWith("event: "))St=ti.slice(7).trim();else if(ti.startsWith("data: ")){try{const Kn=JSON.parse(ti.slice(6));St==="stream:end"?(Gt(ot=>ot.map($t=>{if($t.id!==F)return $t;const En=$t.messages.map(on=>on.status==="streaming"?{...on,status:"done"}:on);return{...$t,messages:En}})),ta(ot=>ot===F?null:ot),ul.current.delete(F)):St==="activity"&&(Kn.type==="text"&&((It=Kn.data)!=null&&It.text)?Gt(ot=>ot.map($t=>{if($t.id!==F)return $t;const En=[...$t.messages],on=En[En.length-1];return(on==null?void 0:on.from)==="role"&&on.status==="streaming"&&(En[En.length-1]={...on,content:on.content+Kn.data.text}),{...$t,messages:En}})):Kn.type==="thinking"&&((dt=Kn.data)!=null&&dt.text)?Gt(ot=>ot.map($t=>{if($t.id!==F)return $t;const En=[...$t.messages],on=En[En.length-1];return(on==null?void 0:on.from)==="role"&&on.status==="streaming"&&(En[En.length-1]={...on,thinking:(on.thinking??"")+Kn.data.text}),{...$t,messages:En}})):(Kn.type==="job:done"||Kn.type==="job:error")&&(Gt(ot=>ot.map($t=>{if($t.id!==F)return $t;const En=$t.messages.map(on=>on.status==="streaming"?{...on,status:Kn.type==="job:done"?"done":"error"}:on);return{...$t,messages:En}})),ta(ot=>ot===F?null:ot),ul.current.delete(F)))}catch{}St=""}}}).catch(()=>{ul.current.delete(F),ta(re=>re===F?null:re)})},dl=async(F,P,re)=>{Y(!1);try{const he=await ye.startJob({type:"wave",directive:F,targetRoles:P,...re&&{attachments:re}});Qt({type:"wave_dispatched"});const je=he.jobIds??(he.jobId?[he.jobId]:[]),Le=pe&&ie[pe]?ie[pe].children.map(ot=>a.find($t=>$t.id===ot)).filter(ot=>!!ot):a.filter(ot=>ot.level==="c-level"),It=P?Le.filter(ot=>P.includes(ot.id)):Le,dt=he.waveId??`wave-${Date.now()}`,Ze=he.sessionIds??[],Je=je.map((ot,$t)=>{var En,on;return{jobId:ot,roleId:((En=It[$t])==null?void 0:En.id)??`role-${$t}`,roleName:((on=It[$t])==null?void 0:on.name)??`C-Level ${$t+1}`,sessionId:Ze[$t]??`wave-${ot}`}});Zt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${F}" → ${Je.map(ot=>ot.roleName).join(", ")}`,type:"dispatch"});const ft={id:dt,directive:F,rootJobs:Je,startedAt:Date.now(),sessionIds:Ze};oe(ot=>[ft,...ot]),cl();const St=new Date().toISOString(),Kn=(Ze.length>0?Je.map((ot,$t)=>({id:Ze[$t]??`wave-${ot.jobId}`,roleId:ot.roleId,title:`WAVE: ${ot.roleName}`,mode:"do",source:"wave",jobId:ot.jobId,messages:[{id:`msg-wave-${ot.jobId}-ceo`,from:"ceo",content:F,type:"directive",status:"done",timestamp:St}],status:"active",createdAt:St,updatedAt:St})):Je.map(ot=>({id:`wave-${ot.jobId}`,roleId:ot.roleId,title:`WAVE: ${ot.roleName}`,mode:"do",source:"wave",jobId:ot.jobId,messages:[{id:`msg-wave-${ot.jobId}-ceo`,from:"ceo",content:F,type:"directive",status:"done",timestamp:St}],status:"active",createdAt:St,updatedAt:St}))).map((ot,$t)=>({...ot,messages:[...ot.messages,{id:`msg-wave-${Je[$t].jobId}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:St,jobId:Je[$t].jobId}]}));Gt(ot=>[...Kn,...ot]),Kn.length>0&&(Xn(Kn[0].id),_a());for(const ot of Kn)zi(ot.id)}catch(he){xt(`Failed to start wave: ${he instanceof Error?he.message:"unknown"}`,"#C62828")}},ha=()=>{ye.getWaves().then(h).catch(console.error),ye.getStandups().then(f).catch(console.error)},Wn=()=>{ye.getCompany().then(F=>i(F.roles)).catch(console.error),ye.getOrgTree().then(F=>{ge(F.nodes),ze(F.root)}).catch(console.error),ye.getCostSummary().then(F=>$r(Yh(F.byRole))).catch(()=>{})},Oa=async(F,P)=>{await ye.createRole(F),fn(F.id,P),Wn(),xt(`${F.name} hired!`,"#2E7D32"),Qt({type:"role_hired",condition:{roleId:F.id,roleCount:a.length+1}})},_i=async F=>{var P;await ye.deleteRole(F),Wn(),Gt(re=>re.filter(he=>he.roleId!==F)),fa&&((P=Ln.find(re=>re.id===fa))==null?void 0:P.roleId)===F&&Xn(null),Ft(null),xt(`${F.toUpperCase()} removed`,"#B71C1C")},$a=async(F,P)=>{await ye.updateRole(F,P),Wn(),z.type==="role"&&z.roleId===F&&ye.getRole(F).then(I).catch(console.error),P.name&&xt(`${F.toUpperCase()} renamed to "${P.name}"`,"#1565C0"),P.persona!==void 0&&(xt(`${F.toUpperCase()} persona updated`,"#2E7D32"),Qt({type:"persona_updated"}))},td=F=>{_a(),Qt({type:"terminal_opened"})},Bi=async F=>{try{const P=await ye.createSession(F,"talk");Gt(re=>[P,...re]),Xn(P.id),_a()}catch(P){console.error("Failed to create session",P),xt(`Failed to create session: ${P instanceof Error?P.message:"API unreachable"}`,"#B71C1C")}},Oi=async F=>{try{const P=await ye.createSession(F,"talk");Gt(re=>[P,...re]),Xn(P.id)}catch(P){console.error("Failed to create session",P),xt(`Failed to create session: ${P instanceof Error?P.message:"API unreachable"}`,"#B71C1C")}},Zl=async F=>{const P=Ne[F],re=(P==null?void 0:P.jobId)??(P==null?void 0:P.id);if(re&&tr[F]==="working"){const je=a.find(Je=>Je.id===F),Le=wy[F]??"#666",It=`${F.toUpperCase()} · ${(je==null?void 0:je.name)??F}`,dt=Ln.find(Je=>Je.roleId===F&&Je.status==="active"),Ze=(dt==null?void 0:dt.id)??`job-${re}`;$([{sessionId:Ze,jobId:re,title:It,color:Le}]),T(!1);return}const he=Ln.find(je=>je.roleId===F);if(he)Xn(he.id),Zt.setActiveChannelId(null);else try{const je=await ye.createSession(F,"talk");Gt(Le=>[je,...Le]),Xn(je.id),Zt.setActiveChannelId(null)}catch(je){console.error("Failed to create session",je)}_a()},Jl=async F=>{const P=Ln.find(re=>re.id===F);if((P==null?void 0:P.source)==="wave"){if(P.jobId){const re=Fi.current.get(P.jobId);re&&(re.abort(),Fi.current.delete(P.jobId))}Gt(re=>{var je;const he=re.filter(Le=>Le.id!==F);return fa===F&&Xn(((je=he[0])==null?void 0:je.id)??null),he});return}try{await ye.deleteSession(F),Gt(re=>{var je;const he=re.filter(Le=>Le.id!==F);return fa===F&&Xn(((je=he[0])==null?void 0:je.id)??null),he})}catch(re){console.error("Failed to delete session",re),xt(`Failed to close session: ${re instanceof Error?re.message:"API error"}`,"#B71C1C")}},Bs=async()=>{try{const{ids:F}=await ye.deleteEmptySessions();if(F.length===0)return;Gt(P=>{var he;const re=P.filter(je=>!F.includes(je.id));return fa&&F.includes(fa)&&Xn(((he=re[0])==null?void 0:he.id)??null),re}),xt(`Cleared ${F.length} empty session${F.length!==1?"s":""}`,"#2E7D32")}catch(F){xt(`Failed to clear empty sessions: ${F instanceof Error?F.message:"API error"}`,"#B71C1C")}},Zo=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const F=Ln.filter(P=>P.source!=="wave").map(P=>P.id);for(const P of Ln)if(P.source==="wave"&&P.jobId){const re=Fi.current.get(P.jobId);re&&(re.abort(),Fi.current.delete(P.jobId))}try{F.length>0&&await ye.deleteSessions(F),Gt([]),Xn(null),xt("All sessions closed","#2E7D32")}catch(P){xt(`Failed to close sessions: ${P instanceof Error?P.message:"API error"}`,"#B71C1C")}},ma=(F,P)=>{Gt(re=>re.map(he=>{if(he.id!==F)return he;const je=[...he.messages],Le=je[je.length-1];if(Le&&Le.from==="role"&&Le.status==="streaming"){const It=[...Le.streamEvents??[],P];je[je.length-1]={...Le,streamEvents:It}}return{...he,messages:je}}))},La=(F,P,re,he)=>{const je={id:`msg-${Date.now()}-ceo`,from:"ceo",content:P,type:re==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:he},Le={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};Gt(dt=>dt.map(Ze=>Ze.id===F?{...Ze,messages:[...Ze.messages,je,Le],updatedAt:new Date().toISOString()}:Ze));const It=Ln.find(dt=>dt.id===F);re==="talk"?Qt({type:"talk_mode_used"}):re==="do"&&(Qt({type:"do_mode_used"}),It&&Qt({type:"task_executed",condition:{roleId:It.roleId}})),ta(F),ed(F,P,re,{onThinking:dt=>{Gt(Ze=>Ze.map(Je=>{if(Je.id!==F)return Je;const ft=[...Je.messages],St=ft[ft.length-1];return St&&St.from==="role"&&St.status==="streaming"&&(ft[ft.length-1]={...St,thinking:(St.thinking??"")+dt}),{...Je,messages:ft}})),ma(F,{type:"thinking",timestamp:Date.now(),text:dt})},onText:dt=>{Gt(Ze=>Ze.map(Je=>{if(Je.id!==F)return Je;const ft=[...Je.messages],St=ft[ft.length-1];return St&&St.from==="role"&&St.status==="streaming"&&(ft[ft.length-1]={...St,content:St.content+dt}),{...Je,messages:ft}}))},onToolUse:(dt,Ze)=>{ma(F,{type:"tool",timestamp:Date.now(),toolName:dt,toolInput:Ze})},onDispatch:(dt,Ze)=>{ma(F,{type:"dispatch",timestamp:Date.now(),roleId:dt,task:Ze})},onDispatchProgress:(dt,Ze,Je)=>{var ft;Ze==="tool"?ma(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:dt,progressType:"tool",toolName:Je.name,toolInput:Je.input}):Ze==="thinking"?ma(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:dt,progressType:"thinking",text:Je.text}):Ze==="text"?ma(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:dt,progressType:"text",text:(ft=Je.text)==null?void 0:ft.slice(-200)}):(Ze==="done"||Ze==="error")&&ma(F,{type:"dispatch:progress",timestamp:Date.now(),roleId:dt,progressType:Ze})},onTurn:dt=>{ma(F,{type:"turn",timestamp:Date.now(),turn:dt})},onDone:()=>{Gt(dt=>dt.map(Ze=>{if(Ze.id!==F)return Ze;const Je=Ze.messages.map(St=>St.status==="streaming"?{...St,status:"done"}:St),ft=Ze.messages.length<=2?P.slice(0,40).replace(/\n/g," "):Ze.title;return{...Ze,messages:Je,title:ft}})),ta(null)},onError:dt=>{Gt(Ze=>Ze.map(Je=>{if(Je.id!==F)return Je;const ft=Je.messages.map(St=>St.status==="streaming"?{...St,status:"error",content:St.content||dt}:St);return{...Je,messages:ft}})),ta(null)}},he)},ei=(F,P)=>{Gt(re=>re.map(he=>he.id===F?{...he,mode:P}:he)),ye.updateSession(F,{mode:P}).catch(console.error)},nd=new Date().toISOString().slice(0,10),Jo=o[0],ec={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},rd=F=>{const P=ec[F];if(!P)return"";for(const re of d){const he=re.content,je=he.indexOf(`## ${P}`);if(je===-1)continue;const Le=he.indexOf(`
|
|
95
|
-
## `,je+10),dt=(Le===-1?he.slice(je):he.slice(je,Le)).split(`
|
|
96
|
-
`).filter(Ze=>Ze.trim().length>0);for(const Ze of dt){const Je=Ze.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(Je.startsWith("|")||Je.startsWith("{")||Je.startsWith("[")||Je.startsWith("```")||Je.startsWith("---")||Je.includes("Journal")||Je.includes("(c-level)")||Je.includes("(team-lead)")||Je.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(Je))&&Je.length>15&&Je.length<120)return Je}}return""},tc=F=>{const P=ec[F];if(!P)return"";for(const re of d){const he=re.content,je=he.indexOf(`## ${P}`);if(je===-1)continue;const Le=he.indexOf(`
|
|
97
|
-
## `,je+10),dt=(Le===-1?he.slice(je):he.slice(je,Le)).replace(/^## .+\n/,"").trim();if(dt)return dt.slice(0,1500)}return""},Zt=U6();v.useEffect(()=>{a.length>0&&Zt.syncDefaultMembers(a)},[a]);const $i=O6({roles:a,roleStatuses:Et,activeExecs:me,getStandupSpeech:rd}),nc=W6({roles:a,roleStatuses:Et,activeExecs:me,channels:Zt.channels,relationships:$i.relationships,pushMessage:Zt.pushMessage,speechSettings:nt,engineType:Re,hasApiKey:_t}),rc=v.useCallback((F,P)=>{Zt.pushMessage({ts:Date.now(),roleId:"ceo",text:P,type:"chat",channelId:F}),nc.triggerCeoReaction(F)},[Zt,nc]);return E?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(Fa||fr.length>0)&&l.jsxs("div",{className:"shrink-0 z-[44]",children:[l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-xs cursor-pointer select-none",style:{background:"var(--accent)",color:"#fff",fontFamily:"var(--pixel-font)"},onClick:()=>Ms(F=>!F),children:[Fa?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:Fa||"Knowledge import finished"}),jr&&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:`${jr.index/jr.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:ol?"▲":"▼"})]}),ol&&l.jsxs("div",{className:"overflow-y-auto text-xs",style:{background:"var(--terminal-bg)",borderBottom:"2px solid var(--accent)",maxHeight:240,fontFamily:"var(--pixel-font)"},children:[fr.map(F=>l.jsxs("div",{className:"flex items-start gap-2 px-5 py-1.5",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("span",{className:"shrink-0 mt-0.5",style:{width:14,textAlign:"center"},children:[F.type==="scan"&&"🔍",F.type==="process"&&"⚙️",F.type==="created"&&"✅",F.type==="done"&&"🎉",F.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:F.type==="error"?"#EF4444":F.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:F.text}),F.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:F.detail})]})]},F.id)),l.jsx("div",{ref:zs})]})]}),l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-4xl mb-3",children:"🏢"}),l.jsx("div",{className:"text-gray-600 font-semibold text-xs",children:"LOADING OFFICE..."})]})})]}):N?l.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:l.jsxs("div",{className:"text-center max-w-md",style:{fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"text-4xl mb-3",children:"⚠️"}),l.jsx("div",{className:"text-gray-800 font-semibold mb-2 text-xs",children:"CONNECTION ERROR"}),l.jsx("div",{className:"text-gray-500 text-xs mb-4",children:N}),l.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white text-xs font-bold cursor-pointer border-2 border-gray-600",style:{fontFamily:"var(--pixel-font)"},children:"RETRY"})]})}):l.jsxs("div",{className:"flex flex-col",style:{height:"100dvh",fontFamily:"var(--pixel-font)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 text-white text-sm shrink-0 z-[45]",style:{background:"var(--bar-bg, var(--hud-bg))",borderBottom:"3px solid var(--bar-border, var(--pixel-border))"},children:[l.jsxs("div",{className:"font-black text-[13px] tracking-tight",style:{color:"var(--idle-amber)",textShadow:"2px 2px 0 rgba(0,0,0,0.5)"},children:["🏢"," ",l.jsx("span",{style:{color:"var(--bar-text, var(--terminal-text))"},children:j})]}),l.jsxs("div",{className:"flex gap-4 text-[11px] items-center",style:{color:"var(--bar-text, var(--terminal-text-secondary))"},children:[(()=>{const F=te>=1e6?`${(te/1e6).toFixed(1)}M`:te>=1e3?`${(te/1e3).toFixed(1)}K`:String(te),P=me.length,re=a.length>0?Math.round(P/a.length*100):0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"hidden md:flex items-center gap-1",children:["💰",l.jsx("strong",{className:"text-[var(--active-green)]",children:F})]}),l.jsxs("div",{className:"hidden md:flex items-center gap-1",children:["⚡",l.jsx("div",{className:"w-[50px] h-2 bg-[#111] overflow-hidden",style:{border:"2px solid var(--pixel-border)"},children:l.jsx("div",{className:"h-full",style:{width:`${re}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:re})]})]})})(),l.jsxs("span",{className:"hidden sm:inline",children:["Roles: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:a.length})]}),l.jsxs("span",{className:"hidden sm:inline",children:["Projects: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:o.length})]}),me.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:me.length})]}),(()=>{const F={roles:Object.entries(De).map(([re,he])=>({id:re,level:he.level,totalTokens:he.totalTokens})),totalTokens:Object.values(De).reduce((re,he)=>re+he.totalTokens,0),roleCount:a.length},P=vy(F);return P.length>0?l.jsx("div",{className:"hidden sm:flex",style:{gap:2,alignItems:"center",marginLeft:8,paddingLeft:8,borderLeft:"1px solid rgba(255,255,255,0.1)"},children:P.map(re=>l.jsx("span",{title:`${re.name}: ${re.description}`,style:{fontSize:12,cursor:"default"},children:re.icon},re.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:nd})]})]}),(Fa||fr.length>0)&&l.jsxs("div",{className:"shrink-0 z-[44]",children:[l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-xs cursor-pointer select-none",style:{background:"var(--accent)",color:"#fff",fontFamily:"var(--pixel-font)"},onClick:()=>Ms(F=>!F),children:[Fa?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:Fa||"Knowledge import finished"}),jr&&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:`${jr.index/jr.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:ol?"▲":"▼"})]}),ol&&l.jsxs("div",{className:"overflow-y-auto text-xs",style:{background:"var(--terminal-bg)",borderBottom:"2px solid var(--accent)",maxHeight:240,fontFamily:"var(--pixel-font)"},children:[fr.map(F=>l.jsxs("div",{className:"flex items-start gap-2 px-5 py-1.5",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("span",{className:"shrink-0 mt-0.5",style:{width:14,textAlign:"center"},children:[F.type==="scan"&&"🔍",F.type==="process"&&"⚙️",F.type==="created"&&"✅",F.type==="done"&&"🎉",F.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:F.type==="error"?"#EF4444":F.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:F.text}),F.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:F.detail})]})]},F.id)),l.jsx("div",{ref:zs}),fr.length===0&&l.jsx("div",{className:"px-5 py-4 text-center",style:{color:"var(--terminal-text-muted)"},children:"Waiting for events..."})]})]}),l.jsxs("div",{className:"flex-1 overflow-hidden flex relative",children:[l.jsx("div",{className:"flex-1 overflow-y-auto relative floor-grid",style:{background:"var(--floor-light)"},children:l.jsx(a8,{roles:a,projects:o,waves:m,standups:d,decisions:x,roleStatuses:tr,activeExecs:me,onRoleClick:F=>Fn({type:"role",roleId:F}),onProjectClick:F=>Fn({type:"project",projectId:F}),onBulletinClick:()=>{Fn({type:"bulletin"}),Qt({type:"bulletin_visited"})},onDecisionsClick:()=>Fn({type:"decisions"}),onKnowledgeClick:()=>{Fn({type:"knowledge"}),Qt({type:"knowledge_visited"})},onSettingsClick:()=>{Ta(!0),Qt({type:"settings_visited"})},onThemeClick:()=>ca(F=>!F),onStatsClick:()=>{ur(!0),Qt({type:"stats_visited"})},knowledgeDocsCount:w.length,getRoleSpeech:$i.getSpeech,getAppearance:Ot,onHireClick:()=>jt(!0),onMascotClick:()=>Fn({type:"quest"}),roleLevels:De,language:we,coinBalance:te,onCoinsSpent:F=>ke(F),onFurniturePlaced:(F,P)=>{Qt({type:"furniture_placed"}),P>0&&Qt({type:"furniture_purchased"})}})}),Sr&&l.jsx("div",{className:Kl?"absolute inset-0 z-50":"contents",children:l.jsx(Pg,{sessions:Ln,activeSessionId:fa,roles:a,streamingSessionId:ea,width:Kl?Ko:mr,onWidthChange:Kl?void 0:Po,onSwitchSession:Xn,onCloseSession:Jl,onCreateSession:Bi,onClearEmpty:Bs,onCloseAll:Zo,onSendMessage:La,onModeChange:ei,onStopSession:F=>ye.abortSession(F).catch(()=>{}),onCloseTerminal:()=>da(!1),onMaximize:()=>{Jr.current="iso",Tn({type:"terminal"}),ua("pro")},chatChannels:Zt.channels,activeChatChannelId:Zt.activeChannelId,onSwitchChatChannel:Zt.setActiveChannelId,onCreateChatChannel:(...F)=>{const P=Zt.createChannel(...F);return Qt({type:"chat_channel_created"}),P},onDeleteChatChannel:Zt.deleteChannel,onUpdateChatMembers:Zt.updateMembers,onUpdateChatTopic:Zt.updateTopic,onSendChatMessage:rc,unreadChannels:Zt.unreadChannels})})]}),l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 text-[10px] shrink-0 z-[45]",style:{background:"var(--bar-bg, var(--hud-bg))",color:"var(--bar-text, var(--terminal-text-secondary))",borderTop:"3px solid var(--bar-border, var(--pixel-border))"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>ua("iso"),className:`view-toggle-btn ${Zr==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{Jr.current="iso",ua("pro")},className:`view-toggle-btn ${Zr==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${Ti?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>ca(F=>!F),title:"Office Theme",children:[((ac=ll[Z])==null?void 0:ac.icon)??"","▾"]}),Ti&&l.jsx(y8,{theme:Z,onThemeChange:F=>{$e(F),Qt({type:"theme_changed"})},onClose:()=>ca(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>Ta(!0),title:"Settings",children:"⚙"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("button",{"data-quest-target":"save-btn",onClick:()=>{Ae.state==="no-git"||Ae.state==="dirty"?Nt(!0):sl(!0)},title:Ae.state==="dirty"?`${Ae.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:Ae.state==="no-git"?"var(--terminal-text-muted)":Ae.state==="saving"||Ae.state==="dirty"?"var(--idle-amber)":Ae.state==="error"?"#EF5350":"var(--active-green)",animation:Ae.state==="saving"?"pulse 1s infinite":void 0}}),l.jsx("span",{style:{color:Ae.state==="dirty"?"var(--idle-amber)":"var(--bar-text, var(--terminal-text-muted))"},children:Ae.state==="no-git"?"No git":Ae.state==="saving"?"Saving...":Ae.state==="dirty"?`${Ae.dirtyCount} unsaved`:"Saved"}),Vn&&(Vn.worktrees.length>0||Vn.staleBranches.length>0)&&l.jsxs("span",{style:{color:Vn.worktrees.some(F=>F.status==="stale")?"#ff6b6b":Vn.worktrees.some(F=>F.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["·"," ","📂"," ",Vn.worktrees.length," worktree",Vn.worktrees.length!==1?"s":"",Vn.staleBranches.length>0&&` · ⚠ ${Vn.staleBranches.length} branch${Vn.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[W.length>0&&!se&&l.jsx("button",{onClick:()=>cl(),className:`px-3 py-1 font-black text-white cursor-pointer ${et?"":"animate-pulse"}`,style:{background:et?"#2E7D32":"#B71C1C",border:`2px solid ${et?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:et?"WAVE DONE":`WAVE (${W.length})`}),Ie&&st&&W.length===0&&l.jsx("button",{onClick:()=>Pe(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${et?"":"animate-pulse"}`,style:{background:et?"#2E7D32":"#B71C1C",border:`2px solid ${et?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:et?"WAVE DONE":"WAVE"}),A.length>0&&U&&l.jsxs("button",{onClick:()=>T(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:A[A.length-1].color,border:`2px solid ${A[A.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[A[A.length-1].title.slice(0,20),A[A.length-1].title.length>20?"..":""]}),l.jsxs("button",{onClick:()=>cl(),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:()=>Sr?da(!1):td(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:Sr?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${Sr?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),Zr!=="pro"&&z.type==="role"&&R&&(()=>{var P,re;const F=Ne[R.id];return l.jsx(Ag,{role:R,allRoles:a,recentActivity:tc(R.id),onClose:na,onFireRole:(he,je)=>{Ft({roleId:he,roleName:je}),na()},terminalWidth:Sr?mr:0,activeJobId:F==null?void 0:F.id,activeSessionId:(P=A.find(he=>he.jobId===(F==null?void 0:F.jobId)))==null?void 0:P.sessionId,activeTask:F==null?void 0:F.task,isWorking:tr[R.id]==="working",jobStartedAt:F==null?void 0:F.startedAt,onStopJob:he=>{const je=A.find(Le=>Le.jobId===he);je&&ye.abortSession(je.sessionId)},sessions:Ln,streamingSessionId:ea,onCreateSessionSilent:Oi,onSendMessage:La,onFocusTerminal:Zl,onCustomize:he=>{const je=a.find(Le=>Le.id===he);je&&(ne("character"),sn(je))},onUpdateRole:$a,appearance:Ot(R.id),relationships:$i.relationships,roleLevel:(re=De[R.id])==null?void 0:re.level,onMaximize:()=>{Jr.current="iso",Tn({type:"role",roleId:R.id}),ua("pro")}})})(),Zr!=="pro"&&z.type==="project"&&Jo&&l.jsx(EN,{projectId:Jo.id,onClose:na,terminalWidth:Sr?mr:0}),Zr!=="pro"&&(z.type==="bulletin"||z.type==="decisions")&&l.jsx(Ug,{standups:d,waves:m,decisions:x,mode:z.type==="bulletin"?"bulletin":"decisions",onClose:na,onOpenWaveCenter:()=>cl(),onUpdateDecision:Mi,onDeleteDecision:za,terminalWidth:Sr?mr:0,onMaximize:()=>{Jr.current="iso",Tn({type:"operations"}),ua("pro")}}),Zr!=="pro"&&z.type==="quest"&&l.jsx(CN,{progress:ve,onClose:na,terminalWidth:Sr?mr:0,onQuestAction:F=>{var re;na();const P=js.find(he=>he.id===F);(re=P==null?void 0:P.hint)!=null&&re.target&&_s(P.hint.target)}}),Zr!=="pro"&&z.type==="knowledge"&&l.jsx(Hg,{docs:w,onClose:na,onRefresh:()=>ye.getKnowledge().then(b).catch(()=>{}),terminalWidth:Sr?mr:0,initialDocId:z.docId,onMaximize:()=>{Jr.current="iso",Tn({type:"knowledge"}),ua("pro")}}),Zr==="pro"&&l.jsxs(b8,{roles:a,roleStatuses:tr,activeExecs:me,waves:m,knowledgeDocs:w,sessions:Ln,roleLevels:De,companyName:j,getAppearance:Ot,waveCenterWaves:W,renderProfile:Or.type==="role"&&R?F=>{var re,he;const P=Ne[R.id];return l.jsx(Ag,{role:R,allRoles:a,recentActivity:tc(R.id),onClose:F,onFireRole:(je,Le)=>{Ft({roleId:je,roleName:Le})},terminalWidth:0,activeJobId:P==null?void 0:P.id,activeSessionId:(re=A.find(je=>je.jobId===(P==null?void 0:P.jobId)))==null?void 0:re.sessionId,activeTask:P==null?void 0:P.task,isWorking:tr[R.id]==="working",jobStartedAt:P==null?void 0:P.startedAt,onStopJob:je=>{const Le=A.find(It=>It.jobId===je);Le&&ye.abortSession(Le.sessionId)},sessions:Ln,streamingSessionId:ea,onCreateSessionSilent:Oi,onSendMessage:La,onFocusTerminal:()=>{},onCustomize:je=>{const Le=a.find(It=>It.id===je);Le&&(ne("character"),sn(Le))},onUpdateRole:$a,appearance:Ot(R.id),relationships:$i.relationships,roleLevel:(he=De[R.id])==null?void 0:he.level})}:void 0,channel:Or,onChannelChange:F=>{Tn(F),F.type==="role"?Fn({type:"role",roleId:F.roleId}):F.type==="knowledge"?Fn({type:"knowledge"}):F.type==="operations"?Fn({type:"bulletin"}):F.type==="wave"?ee(!0):F.type==="terminal"?da(!0):(H({type:"none"}),ee(!1))},onClose:()=>{ua(Jr.current),H({type:"none"}),ee(!1)},children:[Or.type==="dashboard"&&l.jsx(k8,{roles:a,roleStatuses:tr,activeExecs:me,waves:m,knowledgeDocs:w,roleLevels:De,getAppearance:Ot,onRoleClick:F=>Tn({type:"role",roleId:F}),onWaveClick:()=>Tn({type:"wave"}),onKnowledgeClick:()=>Tn({type:"knowledge"})}),Or.type==="terminal"&&l.jsx(Pg,{sessions:Ln,activeSessionId:fa,roles:a,streamingSessionId:ea,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:Xn,onCloseSession:Jl,onCreateSession:Bi,onClearEmpty:Bs,onCloseAll:Zo,onSendMessage:La,onModeChange:ei,onStopSession:F=>ye.abortSession(F).catch(()=>{}),onCloseTerminal:()=>Tn({type:"dashboard"}),chatChannels:Zt.channels,activeChatChannelId:Zt.activeChannelId,onSwitchChatChannel:Zt.setActiveChannelId,onCreateChatChannel:(...F)=>{const P=Zt.createChannel(...F);return Qt({type:"chat_channel_created"}),P},onDeleteChatChannel:Zt.deleteChannel,onUpdateChatMembers:Zt.updateMembers,onUpdateChatTopic:Zt.updateTopic,onSendChatMessage:rc,unreadChannels:Zt.unreadChannels}),Or.type==="wave"&&l.jsx(Vg,{orgNodes:ie,rootRoleId:pe,cLevelRoles:pe&&ie[pe]?ie[pe].children.map(F=>a.find(P=>P.id===F)).filter(F=>!!F):a.filter(F=>F.level==="c-level"),pastWaves:m,activeWaves:W,onDispatch:(F,P)=>dl(F,P),onClose:()=>Tn({type:"dashboard"}),onDone:()=>{ha(),Ee(!0),xt("Wave complete","#2E7D32")},onSave:async(F,P,re)=>{try{await ye.saveWave({directive:F,jobIds:P,waveId:re==null?void 0:re.waveId,sessionIds:re==null?void 0:re.sessionIds}),ha(),xt("Wave saved","#2E7D32")}catch(he){xt(`Save failed: ${he instanceof Error?he.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:F=>{Tn({type:"knowledge"}),Fn({type:"knowledge",docId:F}),ye.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ye.getWaves().then(h).catch(()=>{}),terminalWidth:0,inline:!0,onOpenSaveModal:()=>Nt(!0)}),Or.type==="knowledge"&&l.jsx(Hg,{docs:w,onClose:()=>Tn({type:"dashboard"}),onRefresh:()=>ye.getKnowledge().then(b).catch(()=>{}),terminalWidth:0}),Or.type==="operations"&&l.jsx(Ug,{standups:d,waves:m,decisions:x,mode:"bulletin",onClose:()=>Tn({type:"dashboard"}),onOpenWaveCenter:()=>Tn({type:"wave"}),onUpdateDecision:Mi,onDeleteDecision:za,terminalWidth:0}),Or.type==="role"&&(()=>{const F=Or.roleId,P=a.find(he=>he.id===F);if(!P)return null;const re=Ln.find(he=>he.roleId===F);return re?l.jsx(v8,{role:P,messages:re.messages,isStreaming:ea===re.id,mode:re.mode,onModeChange:he=>ei(re.id,he),onSend:(he,je,Le)=>La(re.id,he,je,Le),isWave:re.source==="wave"}):l.jsx(w8,{role:P,getAppearance:Ot,onSend:async(he,je)=>{try{const Le=await ye.createSession(F,"talk");Gt(It=>[Le,...It]),Xn(Le.id),La(Le.id,he,je)}catch(Le){xt(`Failed to create session: ${Le instanceof Error?Le.message:"API unreachable"}`,"#B71C1C")}}})})()]}),q&&l.jsx(DN,{roleId:q.roleId,roleName:q.roleName,mode:q.mode,onClose:()=>X(null),onExecutionStart:Qo}),Ie&&!st&&l.jsx(qN,{directive:Ie.directive,rootJobs:Ie.rootJobs,orgNodes:ie,rootRoleId:pe,onClose:()=>{He(null),Pe(!1),Ee(!1)},onMinimize:()=>Pe(!0),onDone:()=>{ha(),Ee(!0),xt("Wave complete","#2E7D32")},onSave:async F=>{try{await ye.saveWave({directive:Ie.directive,jobIds:F}),ha(),xt("Wave saved to bulletin","#2E7D32")}catch(P){xt(`Save failed: ${P instanceof Error?P.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:F=>{He(null),Pe(!1),Ee(!1),Fn({type:"knowledge",docId:F}),ye.getKnowledge().then(b).catch(()=>{})}}),se&&l.jsx(Vg,{orgNodes:ie,rootRoleId:pe,cLevelRoles:pe&&ie[pe]?ie[pe].children.map(F=>a.find(P=>P.id===F)).filter(F=>!!F):a.filter(F=>F.level==="c-level"),pastWaves:m,activeWaves:W,onDispatch:(F,P)=>dl(F,P),onClose:()=>ee(!1),onMaximize:()=>{Jr.current="iso",Tn({type:"wave"}),ua("pro")},onDone:()=>{ha(),Ee(!0),xt("Wave complete","#2E7D32")},onSave:async(F,P,re)=>{try{await ye.saveWave({directive:F,jobIds:P,waveId:re==null?void 0:re.waveId,sessionIds:re==null?void 0:re.sessionIds}),ha(),xt("Wave saved","#2E7D32")}catch(he){xt(`Save failed: ${he instanceof Error?he.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:F=>{ee(!1),Fn({type:"knowledge",docId:F}),ye.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>ye.getWaves().then(h).catch(()=>{}),terminalWidth:Sr?mr:0,onOpenSaveModal:()=>Nt(!0)}),A.length>0&&!U&&(()=>{var re;const F=A[A.length-1],P=de.length>1;return l.jsxs(l.Fragment,{children:[P&&A.length===1&&l.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[63] flex gap-1 px-2 pt-2",children:de.map((he,je)=>l.jsx("button",{onClick:()=>{B(je),$([{sessionId:he.sessionId,jobId:he.jobId??"",title:`CEO WAVE · ${he.roleId.toUpperCase()}`,color:"#B71C1C"}])},className:"px-3 py-1.5 text-xs font-bold rounded-t-lg cursor-pointer transition-colors",style:{background:D===je?"#B71C1C":"var(--terminal-bg)",color:D===je?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${D===je?"#B71C1C":"var(--terminal-border)"}`,borderBottom:"none"},children:he.roleId.toUpperCase()},he.sessionId))}),l.jsx(TN,{sessionId:F.sessionId,title:A.length>1?F.title:P?`CEO WAVE · ${((re=de[D])==null?void 0:re.roleName)??""}`:F.title,color:F.color,variant:"modal",style:P&&A.length===1?{marginTop:28}:void 0,onClose:()=>{const he=Ln.filter(je=>je.source==="wave").map(je=>je.id);he.length>0&&(Gt(je=>je.filter(Le=>Le.source!=="wave")),ye.deleteSessions(he).catch(()=>{})),$([]),V([]),B(0),T(!1)},onMinimize:()=>T(!0),onDone:()=>{Ri(),ha()},onNavigateToJob:()=>{},onOpenKnowledgeDoc:he=>{$([]),V([]),B(0),T(!1),Fn({type:"knowledge",docId:he}),ye.getKnowledge().then(b).catch(()=>{})}},F.sessionId)]})})(),A.length>1&&l.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[62] pointer-events-none",children:l.jsx("div",{className:"pointer-events-auto",children:l.jsxs("button",{onClick:()=>$(F=>F.slice(0,-1)),className:"mt-2 ml-2 px-3 py-1 text-xs font-bold text-[var(--terminal-text)] bg-[var(--terminal-bg)] border border-[var(--terminal-border)] rounded-lg cursor-pointer hover:bg-[var(--terminal-inline-bg)]",children:["←"," Back to ",(Li=A[A.length-2])==null?void 0:Li.title]})})}),L&&l.jsx(zN,{cLevelRoles:pe&&ie[pe]?ie[pe].children.map(F=>a.find(P=>P.id===F)).filter(F=>!!F):a.filter(F=>F.level==="c-level"),orgNodes:ie,rootId:pe,onClose:()=>Y(!1),onDispatch:(F,P)=>dl(F,P)}),pt&&l.jsx(JN,{existingRoles:a,onClose:()=>jt(!1),onHire:Oa,onStoreVisit:()=>Qt({type:"store_visited"}),questHint:((lc=Ba==null?void 0:Ba.hint)==null?void 0:lc.target)==="hire-btn"?{message:Ba.description,roleId:((ic=Ba.trigger.condition)==null?void 0:ic.roleId)??void 0}:void 0}),Wt&&l.jsx(n6,{roleId:Wt.roleId,roleName:Wt.roleName,onClose:()=>Ft(null),onConfirm:_i}),ln&&l.jsx(l8,{role:ln,appearance:Ot(ln.id),onSave:F=>{fn(ln.id,F),Qt({type:"accessory_changed"})},onReset:()=>wn(ln.id),onClose:()=>{sn(null),ne("character")},theme:Z,onThemeChange:F=>{$e(F),Qt({type:"theme_changed"})},onUpdateName:async(F,P)=>{await $a(F,{name:P})},initialTab:"character",characterOnly:!0,speechSettings:nt,onSpeechSettingsChange:Pt,language:we,onLanguageChange:kt,roleLevel:(sc=De[ln.id])==null?void 0:sc.level}),We&&(()=>{const F=a.find(P=>P.id==="cto")??a.find(P=>P.level==="c-level")??a[0];return l.jsx(o8,{status:Ae.status,history:Ae.history,onClose:()=>Nt(!1),onSave:async P=>{const re=await Ae.save(P);return re!=null&&re.ok&&Qt({type:"save_committed"}),re},onLoadHistory:Ae.loadHistory,onRestore:Ae.restore,saving:Ae.state==="saving",repo:Ae.repo,onRepoChange:Ae.setRepo,syncInfo:Ae.syncInfo,onPull:Ae.pull,pulling:Ae.pulling,onRefresh:Ae.refresh,onInitGit:Ae.initGit,delegateRoleName:(F==null?void 0:F.name)??(F==null?void 0:F.id),onDelegate:F?async P=>{Nt(!1);try{const re=await ye.createSession(F.id,"do");Gt(je=>[re,...je]),Xn(re.id),_a();const he=`Review the following unsaved changes, write a proper commit message, save (git add + commit), and push. If the current branch is not the main branch, create a PR and merge it.
|
|
98
|
-
|
|
99
|
-
Changed files:
|
|
100
|
-
${P}`;La(re.id,he,"do")}catch(re){xt(`Failed to delegate: ${re instanceof Error?re.message:"error"}`,"#B71C1C")}}:void 0})})(),kn&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>ur(!1),children:l.jsx("div",{style:{width:420,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8},onClick:F=>F.stopPropagation(),children:l.jsx(c8,{onClose:()=>ur(!1)})})}),xn&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>gn(!1),children:l.jsx("div",{style:{width:480,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:F=>F.stopPropagation(),children:l.jsx(f8,{onClose:()=>gn(!1),onSyncComplete:()=>{}})})}),Vo&&l.jsx(g8,{onClose:()=>Ta(!1),speechSettings:nt,onSpeechSettingsChange:Pt,language:we,onLanguageChange:kt,onOpenSync:()=>gn(!0),onOpenGitStatus:()=>sl(!0),onOpenSessions:()=>Fs(!0),onOpenStats:()=>ur(!0)}),dr&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>sl(!1),children:l.jsx("div",{style:{width:520,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:F=>F.stopPropagation(),children:l.jsx(h8,{onClose:()=>sl(!1)})})}),Ju&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Fs(!1),children:l.jsx("div",{style:{width:520,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:F=>F.stopPropagation(),children:l.jsx(m8,{onClose:()=>Fs(!1)})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:K.map(F=>l.jsxs("div",{className:"toast-enter flex items-center gap-2 px-4 py-2.5 shadow-lg text-white text-xs font-black",style:{background:F.color,border:"2px solid rgba(0,0,0,0.3)",fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"w-2 h-2 bg-white/60"}),F.message]},F.id))})]})}function Au({onSelect:e,onClose:n}){const[a,i]=v.useState(null),[o,u]=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=>{u(!0);try{const E=await ye.browse(k);i(E)}catch{}finally{u(!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 E8={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function ky(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function N8({onComplete:e}){const[n,a]=v.useState(0),[i,o]=v.useState(null),[u,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"),C=v.useRef(null),[N,_]=v.useState("new"),[z,H]=v.useState(""),[R,I]=v.useState(""),[q,X]=v.useState(!1),[A,$]=v.useState(!1),[L,Y]=v.useState(!1),[se,ee]=v.useState(""),[W,oe]=v.useState(!1),[de,V]=v.useState(!1),[D,B]=v.useState([]),[U,T]=v.useState(""),[ie,ge]=v.useState(!1),[pe,ze]=v.useState(""),[Ie,He]=v.useState(null),[st,Pe]=v.useState(!1),[et,Ee]=v.useState(!1),[De,yt]=v.useState([]),[ut,pt]=v.useState("startup"),[jt,Wt]=v.useState(!1),[Ft,Et]=v.useState(!1),[$n,me]=v.useState(null),[Se,Ne]=v.useState([]),[K,ue]=v.useState(""),[te,ke]=v.useState(!1),[ve,_e]=v.useState(!1),[Be,Oe]=v.useState([]),qe=v.useMemo(()=>ky(N),[N]),rt=qe[n]??"engine";v.useEffect(()=>{ye.detectEngine().then(we=>{o(we),d(we.recommended),x(!1)}).catch(()=>x(!1)),ye.getTeams().then(yt).catch(()=>{}),ye.getStatus().then(we=>{I(we.companyRoot||"")}).catch(()=>{})},[]),v.useEffect(()=>{var we;rt==="company"&&((we=C.current)==null||we.focus())},[rt]),v.useEffect(()=>{if(q||!R)return;const we=g.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");H(we?`${R}/${we}`:R)},[g,R,q]);const Ve=()=>{switch(rt){case"engine":return u!=="none"||f.length>10;case"company":return g.trim().length>0;case"workspace":return N==="existing-akb"?Ie===!0:!0;case"team":return!0;case"create":return!Ft;default:return!1}},bt=()=>{n<qe.length-1&&Ve()&&a(n+1),rt==="create"&&!jt&&!te&&(N==="existing-akb"?wn():fn())},Re=()=>{n>0&&a(n-1)},Ue=v.useRef(N);v.useEffect(()=>{if(Ue.current===N)return;Ue.current=N;const kt=ky(N).indexOf("workspace");kt>=0&&a(kt)},[N]);const _t=async()=>{if(pe.trim()){Pe(!0);try{const we=await ye.validatePath(pe.trim());He(we.valid&&we.hasClaudeMd===!0)}catch{He(!1)}finally{Pe(!1)}}},Bt=()=>{const we=U.trim();we&&!D.includes(we)&&(B([...D,we]),T(""))},Ot=async we=>{_e(!0),Oe([]);try{const{tools:kt}=await ye.getRequiredTools(we);if(kt.filter(sn=>!sn.installed).length===0){_e(!1);return}await ye.installTools(we,(sn,ne)=>{const Ae=ne.tool||"";sn==="checking"?Oe(We=>[...We,{event:sn,tool:Ae,detail:"checking..."}]):sn==="installing"?Oe(We=>[...We,{event:sn,tool:Ae,detail:"installing..."}]):sn==="installed"?Oe(We=>[...We,{event:sn,tool:Ae,detail:"installed"}]):sn==="skipped"?Oe(We=>[...We,{event:sn,tool:Ae,detail:ne.reason||"skipped"}]):sn==="error"&&Oe(We=>[...We,{event:sn,tool:Ae,detail:ne.error||"failed"}])})}catch{}finally{_e(!1)}},fn=async()=>{Wt(!0),me(null);try{const we={companyName:g.trim(),description:b.trim()||"An AI-powered organization",team:ut,knowledgePaths:D.length>0?D:void 0,language:k!=="auto"?k:void 0,location:z.trim()||void 0,codeRoot:se.trim()||void 0};(u==="direct-api"||f)&&(we.apiKey=f||void 0);const kt=await ye.scaffold(we);Ne(kt.created),ue(kt.projectRoot),Et(!0),Wt(!1),ut!=="custom"&&Ot(ut)}catch(we){me(we instanceof Error?we.message:"Scaffold failed"),Wt(!1)}},wn=async()=>{ke(!0),me(null);try{const we=await ye.connectAkb(pe.trim());we.ok?(Et(!0),Ne([`Connected to: ${we.companyRoot}`])):me(we.error||"Failed to connect")}catch(we){me(we instanceof Error?we.message:"Connect failed")}finally{ke(!1)}},Z=()=>{D.length>0?e({paths:D,companyRoot:""}):e()},$e=we=>{we.key==="Enter"&&Ve()&&(we.preventDefault(),bt())},nt=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
|
|
101
|
-
bg-[var(--terminal-bg)] text-[var(--terminal-text)]
|
|
102
|
-
border border-[var(--terminal-border)]
|
|
103
|
-
focus:border-[var(--terminal-border-hover)]
|
|
104
|
-
placeholder:text-[var(--terminal-text-muted)]`,Pt=we=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${we?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--terminal-border)] bg-[var(--hud-bg-alt)] hover:border-[var(--accent)]/50"}`;return l.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},onKeyDown:$e,children:l.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"px-6 py-5",style:{background:"var(--terminal-bg)",borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-lg font-bold",style:{color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:"tycono"}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-secondary)"},children:"Build an AI company. Watch them work."}),l.jsx("div",{className:"flex gap-1.5 mt-4",children:qe.map((we,kt)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:kt<=n?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:kt===n?"var(--terminal-text)":"var(--terminal-text-muted)"},children:E8[we]})]},we))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[rt==="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:Pt(u==="claude-cli"),onClick:()=>(i==null?void 0:i.claudeCli)&&d("claude-cli"),style:{opacity:i!=null&&i.claudeCli?1:.4},children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-lg",children:i!=null&&i.claudeCli?"✅":"❌"}),l.jsxs("div",{children:[l.jsx("div",{className:"font-medium text-sm",children:"Claude Code CLI"}),l.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.claudeCli?"Detected! Recommended — zero config needed.":"Not installed. Get it at claude.ai/download"})]})]})}),l.jsxs("div",{className:Pt(u==="direct-api"),onClick:()=>d("direct-api"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-lg",children:i!=null&&i.apiKey?"✅":"🔑"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"font-medium text-sm",children:"Anthropic API Key (BYOK)"}),l.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.apiKey?"API key found in environment.":"Enter your ANTHROPIC_API_KEY"})]})]}),u==="direct-api"&&!(i!=null&&i.apiKey)&&l.jsx("input",{type:"password",className:`${nt} mt-3`,placeholder:"sk-ant-...",value:f,onChange:we=>m(we.target.value),autoFocus:!0})]})]})]}),rt==="company"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company"}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),l.jsx("input",{ref:C,className:nt,placeholder:"e.g. Acme Corp",value:g,onChange:we=>w(we.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Description"}),l.jsx("textarea",{className:`${nt} resize-none`,rows:3,placeholder:"What does your AI company do?",value:b,onChange:we=>j(we.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"AI Response Language"}),l.jsxs("select",{className:nt,value:k,onChange:we=>E(we.target.value),children:[l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"한국어"}),l.jsx("option",{value:"ja",children:"日本語"})]})]})]}),rt==="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(tp,{text:`"New Company" creates a fresh workspace with roles, knowledge base, and project structure.
|
|
105
|
-
|
|
106
|
-
"Connect Existing" links to an existing Tycono workspace you've set up before.`})]}),l.jsxs("div",{className:"flex rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:N==="new"?"var(--accent)":"var(--hud-bg-alt)",color:N==="new"?"#fff":"var(--terminal-text-muted)"},onClick:()=>_("new"),children:"New Company"}),l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:N==="existing-akb"?"var(--accent)":"var(--hud-bg-alt)",color:N==="existing-akb"?"#fff":"var(--terminal-text-muted)",borderLeft:"1px solid var(--terminal-border)"},onClick:()=>_("existing-akb"),children:"Connect Existing"})]}),N==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(jy,{icon:"📁",title:"Company Location",hint:"Where your AI company files will be created.",help:"Roles, knowledge, decisions, and project files are stored here. This is your AI company's home directory. Auto-generated from your company name — change it if needed.",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${nt} flex-1`,placeholder:"/path/to/your-company",value:z,onChange:we=>{H(we.target.value),X(!0)}}),l.jsx("button",{onClick:()=>$(!A),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"})]}),A&&l.jsx(Au,{onSelect:we=>{H(we),X(!0),$(!1)},onClose:()=>$(!1)})]}),l.jsxs(Sy,{icon:"💻",title:"Code Repository",hint:"Connect a separate code repo.",help:`Link your existing code repo so AI roles can read and write code there.
|
|
107
|
-
|
|
108
|
-
Skip this if you don't have a codebase yet — you can connect one later from Settings.`,tag:"optional",open:L,onToggle:()=>Y(!L),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${nt} flex-1`,placeholder:"/path/to/code/repo",value:se,onChange:we=>ee(we.target.value)}),l.jsx("button",{onClick:()=>oe(!W),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:"📁"})]}),W&&l.jsx(Au,{onSelect:we=>{ee(we),oe(!1)},onClose:()=>oe(!1)})]}),l.jsxs(Sy,{icon:"📚",title:"Knowledge Import",hint:"Import existing documents into knowledge base.",help:`Point to folders with docs (.md, .txt, etc.) — AI will read, summarize, and organize them into a searchable knowledge base.
|
|
109
|
-
|
|
110
|
-
Skip this to start with an empty knowledge base. You can import documents anytime from the office.`,tag:"optional",open:de,onToggle:()=>V(!de),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${nt} flex-1`,placeholder:"/path/to/docs",value:U,onChange:we=>T(we.target.value),onKeyDown:we=>{we.key==="Enter"&&(we.preventDefault(),Bt())}}),l.jsx("button",{onClick:()=>ge(!ie),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:Bt,disabled:!U.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:U.trim()?1:.5},children:"Add"})]}),ie&&l.jsx(Au,{onSelect:we=>{D.includes(we)||B([...D,we]),ge(!1)},onClose:()=>ge(!1)}),D.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:D.map((we,kt)=>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:we}),l.jsx("button",{onClick:()=>B(D.filter((ln,sn)=>sn!==kt)),className:"opacity-50 hover:opacity-100",children:"✕"})]},kt))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(jy,{icon:"🔗",title:"AKB Path",hint:"Directory with existing CLAUDE.md and AKB structure.",help:"Connect to a directory that was previously set up with Tycono. It must contain a CLAUDE.md file. All existing roles, knowledge, and settings will be loaded.",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${nt} flex-1`,placeholder:"/path/to/your/akb",value:pe,onChange:we=>{ze(we.target.value),He(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>Ee(!et),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"}),l.jsx("button",{onClick:_t,disabled:st||!pe.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:st||!pe.trim()?.5:1},children:st?"...":"Verify"})]}),Ie===!0&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found"]}),Ie===!1&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),et&&l.jsx(Au,{onSelect:we=>{ze(we),He(null),Ee(!1)},onClose:()=>Ee(!1)})]})})]}),rt==="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."}),De.map(we=>l.jsxs("div",{className:Pt(ut===we.id),onClick:()=>pt(we.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:we.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:we.roles.map(kt=>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:kt.id.toUpperCase()},kt.id))})]},we.id)),l.jsxs("div",{className:Pt(ut==="custom"),onClick:()=>pt("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."})]})]}),rt==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:Ft?N==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!Ft&&!jt&&!te&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"rounded-lg p-4 space-y-2 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:N==="existing-akb"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Mode:"})," Connect Existing AKB"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Path:"})," ",pe]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Company:"})," ",g]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Location:"})," ",z||"(default)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]}),se.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Code Repo:"})," ",se]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",D.length>0?`Import ${D.length} source(s)`:"Fresh (empty)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Team:"})," ",ut]}),D.length>0&&l.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),$n&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:$n})]}),(jt||te)&&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:te?"Connecting to AKB...":"Scaffolding your company..."})]}),Ft&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),K&&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:"})," ",K]}),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:Se.map((we,kt)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",we]},kt))}),(ve||Be.length>0)&&l.jsxs("div",{className:"rounded-lg p-4 text-xs space-y-1",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"font-medium mb-2",style:{color:"var(--terminal-text-secondary)"},children:ve?"Installing skill tools...":"Skill tools"}),Be.map((we,kt)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:we.event==="installed"||we.event==="skipped"?"var(--active-green)":we.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:we.event==="installed"||we.event==="skipped"?"✓":we.event==="error"?"✗":"…"}),l.jsx("span",{children:we.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:we.detail})]},kt)),ve&&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&&!Ft&&l.jsx("button",{onClick:Re,className:"px-4 py-2 rounded text-sm transition-colors",style:{color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:"Back"})}),l.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[n+1," / ",qe.length]}),l.jsx("div",{children:Ft?l.jsx("button",{onClick:Z,disabled:ve,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:ve?.5:1},children:ve?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:bt,disabled:!Ve()||jt||te,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:Ve()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:Ve()&&!jt&&!te?1:.5},children:rt==="create"?jt||te?te?"Connecting...":"Creating...":N==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function tp({text:e}){const[n,a]=v.useState(!1),[i,o]=v.useState({top:0,left:0}),u=v.useRef(null),d=()=>{if(u.current){const f=u.current.getBoundingClientRect();o({top:f.bottom+6,left:f.left})}a(!0)};return l.jsxs("span",{className:"inline-flex",ref:u,children:[l.jsx("span",{className:"w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center cursor-help shrink-0 select-none",style:{background:"var(--terminal-surface)",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},onMouseEnter:d,onMouseLeave:()=>a(!1),onClick:f=>{f.stopPropagation(),n?a(!1):d()},children:"?"}),n&&l.jsxs("div",{className:"fixed z-[9999] px-3 py-2 rounded-lg text-[11px] leading-relaxed whitespace-pre-line w-60 shadow-lg pointer-events-none",style:{top:i.top,left:Math.min(i.left,window.innerWidth-260),background:"var(--terminal-bg)",color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"absolute bottom-full w-0 h-0",style:{left:8,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderBottom:"5px solid var(--terminal-border)"}}),e]})]})}function jy({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(tp,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:a})]}),o]})}function Sy({icon:e,title:n,hint:a,help:i,tag:o,open:u,onToggle:d,children:f}){return l.jsxs("div",{className:"rounded-lg",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"p-3 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)] transition-colors",onClick:d,children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{className:"text-xs font-medium flex-1",style:{color:"var(--terminal-text)"},children:n}),i&&l.jsx(tp,{text:i}),o&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded",style:{background:"var(--terminal-surface)",color:"var(--terminal-text-muted)"},children:o}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:u?"▲":"▼"})]}),!u&&l.jsx("div",{className:"px-3 pb-2 -mt-1",children:l.jsx("div",{className:"text-[10px] ml-6",style:{color:"var(--terminal-text-muted)"},children:a})}),u&&l.jsx("div",{className:"px-3 pb-3 space-y-2",children:f})]})}function A8(){const[e,n]=v.useState(null),[a,i]=v.useState(!0),[o,u]=v.useState(null),d=v.useCallback(async()=>{i(!0),u(null);try{const f=await ye.getStatus();n(f)}catch(f){u(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 D8=v.lazy(()=>Ey(()=>import("./preview-app-DbMjPbJZ.js"),[]));function Fv(){return l.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"w-10 h-10 mx-auto border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),l.jsx("div",{className:"mt-4 text-sm",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Loading..."})]})})}function T8(){var e;try{const n=localStorage.getItem("tycono-theme"),a=n&&n in ll?n:"default",i=(e=ll[a])==null?void 0:e.vars;if(!i)return;const o=document.documentElement;for(const[u,d]of Object.entries(i))o.style.setProperty(u,d)}catch{}}function F8(){const{initialized:e,loading:n,refetch:a}=A8(),[i,o]=v.useState(null);v.useEffect(()=>{T8()},[]);const u=d=>{d&&o(d),a()};return n?l.jsx(Fv,{}):e?l.jsx(C8,{importJob:i,onImportDone:()=>o(null)}):l.jsx(N8,{onComplete:u})}function M8(){const e=new URLSearchParams(window.location.search).has("sprite-preview");return l.jsx(kw,{children:e?l.jsx(v.Suspense,{fallback:l.jsx(Fv,{}),children:l.jsx(D8,{})}):l.jsx(F8,{})})}bw.createRoot(document.getElementById("root")).render(l.jsx(v.StrictMode,{children:l.jsx(M8,{})}));export{ov as H,uv as P,dv as S,B8 as a,cv as b,sv as c,am as d,eC as e,z8 as f,_8 as g,O8 as h,l as j,v as r};
|