tycono 0.1.64 โ 0.1.66
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/bin/tycono.ts +13 -4
- package/package.json +1 -1
- package/src/api/src/create-server.ts +5 -1
- package/src/api/src/engine/agent-loop.ts +17 -6
- package/src/api/src/engine/context-assembler.ts +156 -48
- package/src/api/src/engine/knowledge-gate.ts +335 -0
- package/src/api/src/engine/llm-adapter.ts +7 -1
- package/src/api/src/engine/runners/claude-cli.ts +98 -116
- package/src/api/src/engine/runners/types.ts +2 -0
- package/src/api/src/engine/tools/executor.ts +3 -5
- package/src/api/src/routes/active-sessions.ts +143 -0
- package/src/api/src/routes/coins.ts +137 -0
- package/src/api/src/routes/execute.ts +158 -48
- package/src/api/src/routes/knowledge.ts +30 -0
- package/src/api/src/routes/operations.ts +48 -11
- package/src/api/src/routes/sessions.ts +1 -1
- package/src/api/src/routes/setup.ts +68 -1
- package/src/api/src/routes/speech.ts +334 -142
- package/src/api/src/services/activity-stream.ts +1 -1
- package/src/api/src/services/job-manager.ts +185 -9
- package/src/api/src/services/port-registry.ts +222 -0
- package/src/api/src/services/scaffold.ts +90 -0
- package/src/api/src/services/session-store.ts +75 -5
- package/src/web/dist/assets/index-BDLT2xew.js +109 -0
- package/src/web/dist/assets/index-LvS5V8aP.css +1 -0
- package/src/web/dist/assets/{preview-app-qIFqrb-y.js โ preview-app-AJtyaM6L.js} +1 -1
- package/src/web/dist/index.html +2 -2
- package/templates/skills/_manifest.json +6 -0
- package/templates/skills/agent-browser/SKILL.md +159 -0
- package/templates/skills/agent-browser/meta.json +19 -0
- package/templates/teams/agency.json +3 -3
- package/templates/teams/research.json +3 -3
- package/templates/teams/startup.json +3 -3
- package/src/web/dist/assets/index-B3dNhn76.js +0 -101
- package/src/web/dist/assets/index-C7IEX_o_.css +0 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var pw=Object.defineProperty;var xw=(e,n,a)=>n in e?pw(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var E0=(e,n,a)=>xw(e,typeof n!="symbol"?n+"":n,a);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function a(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(o){if(o.ep)return;o.ep=!0;const u=a(o);fetch(o.href,u)}})();function Mg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var th={exports:{}},go={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var A0;function yw(){if(A0)return go;A0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(i,o,u){var d=null;if(u!==void 0&&(d=""+u),o.key!==void 0&&(d=""+o.key),"key"in o){u={};for(var h in o)h!=="key"&&(u[h]=o[h])}else u=o;return o=u.ref,{$$typeof:e,type:i,key:d,ref:o!==void 0?o:null,props:u}}return go.Fragment=n,go.jsx=a,go.jsxs=a,go}var D0;function gw(){return D0||(D0=1,th.exports=yw()),th.exports}var l=gw(),nh={exports:{}},ct={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react.production.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var T0;function bw(){if(T0)return ct;T0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),v=Symbol.iterator;function b(F){return F===null||typeof F!="object"?null:(F=v&&F[v]||F["@@iterator"],typeof F=="function"?F:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,C={};function N(F,W,D){this.props=F,this.context=W,this.refs=C,this.updater=D||j}N.prototype.isReactComponent={},N.prototype.setState=function(F,W){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,W,"setState")},N.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function E(){}E.prototype=N.prototype;function _(F,W,D){this.props=F,this.context=W,this.refs=C,this.updater=D||j}var z=_.prototype=new E;z.constructor=_,k(z,N.prototype),z.isPureReactComponent=!0;var U=Array.isArray;function B(){}var $={H:null,A:null,T:null,S:null},q=Object.prototype.hasOwnProperty;function L(F,W,D){var te=D.ref;return{$$typeof:e,type:F,key:W,ref:te!==void 0?te:null,props:D}}function R(F,W){return L(F.type,W,F.props)}function I(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function H(F){var W={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(D){return W[D]})}var Q=/\/+/g;function oe(F,W){return typeof F=="object"&&F!==null&&F.key!=null?H(""+F.key):W.toString(36)}function re(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(B,B):(F.status="pending",F.then(function(W){F.status==="pending"&&(F.status="fulfilled",F.value=W)},function(W){F.status==="pending"&&(F.status="rejected",F.reason=W)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function Y(F,W,D,te,je){var ve=typeof F;(ve==="undefined"||ve==="boolean")&&(F=null);var ze=!1;if(F===null)ze=!0;else switch(ve){case"bigint":case"string":case"number":ze=!0;break;case"object":switch(F.$$typeof){case e:case n:ze=!0;break;case x:return ze=F._init,Y(ze(F._payload),W,D,te,je)}}if(ze)return je=je(F),ze=te===""?"."+oe(F,0):te,U(je)?(D="",ze!=null&&(D=ze.replace(Q,"$&/")+"/"),Y(je,W,D,"",function(Oe){return Oe})):je!=null&&(I(je)&&(je=R(je,D+(je.key==null||F&&F.key===je.key?"":(""+je.key).replace(Q,"$&/")+"/")+ze)),W.push(je)),1;ze=0;var Xe=te===""?".":te+":";if(U(F))for(var de=0;de<F.length;de++)te=F[de],ve=Xe+oe(te,de),ze+=Y(te,W,D,ve,je);else if(de=b(F),typeof de=="function")for(F=de.call(F),de=0;!(te=F.next()).done;)te=te.value,ve=Xe+oe(te,de++),ze+=Y(te,W,D,ve,je);else if(ve==="object"){if(typeof F.then=="function")return Y(re(F),W,D,te,je);throw W=String(F),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return ze}function ae(F,W,D){if(F==null)return F;var te=[],je=0;return Y(F,te,"","",function(ve){return W.call(D,ve,je++)}),te}function Z(F){if(F._status===-1){var W=F._result;W=W(),W.then(function(D){(F._status===0||F._status===-1)&&(F._status=1,F._result=D)},function(D){(F._status===0||F._status===-1)&&(F._status=2,F._result=D)}),F._status===-1&&(F._status=0,F._result=W)}if(F._status===1)return F._result.default;throw F._result}var G=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},A={map:ae,forEach:function(F,W,D){ae(F,function(){W.apply(this,arguments)},D)},count:function(F){var W=0;return ae(F,function(){W++}),W},toArray:function(F){return ae(F,function(W){return W})||[]},only:function(F){if(!I(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return ct.Activity=y,ct.Children=A,ct.Component=N,ct.Fragment=a,ct.Profiler=o,ct.PureComponent=_,ct.StrictMode=i,ct.Suspense=m,ct.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=$,ct.__COMPILER_RUNTIME={__proto__:null,c:function(F){return $.H.useMemoCache(F)}},ct.cache=function(F){return function(){return F.apply(null,arguments)}},ct.cacheSignal=function(){return null},ct.cloneElement=function(F,W,D){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var te=k({},F.props),je=F.key;if(W!=null)for(ve in W.key!==void 0&&(je=""+W.key),W)!q.call(W,ve)||ve==="key"||ve==="__self"||ve==="__source"||ve==="ref"&&W.ref===void 0||(te[ve]=W[ve]);var ve=arguments.length-2;if(ve===1)te.children=D;else if(1<ve){for(var ze=Array(ve),Xe=0;Xe<ve;Xe++)ze[Xe]=arguments[Xe+2];te.children=ze}return L(F.type,je,te)},ct.createContext=function(F){return F={$$typeof:d,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:u,_context:F},F},ct.createElement=function(F,W,D){var te,je={},ve=null;if(W!=null)for(te in W.key!==void 0&&(ve=""+W.key),W)q.call(W,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(je[te]=W[te]);var ze=arguments.length-2;if(ze===1)je.children=D;else if(1<ze){for(var Xe=Array(ze),de=0;de<ze;de++)Xe[de]=arguments[de+2];je.children=Xe}if(F&&F.defaultProps)for(te in ze=F.defaultProps,ze)je[te]===void 0&&(je[te]=ze[te]);return L(F,ve,je)},ct.createRef=function(){return{current:null}},ct.forwardRef=function(F){return{$$typeof:h,render:F}},ct.isValidElement=I,ct.lazy=function(F){return{$$typeof:x,_payload:{_status:-1,_result:F},_init:Z}},ct.memo=function(F,W){return{$$typeof:f,type:F,compare:W===void 0?null:W}},ct.startTransition=function(F){var W=$.T,D={};$.T=D;try{var te=F(),je=$.S;je!==null&&je(D,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(B,G)}catch(ve){G(ve)}finally{W!==null&&D.types!==null&&(W.types=D.types),$.T=W}},ct.unstable_useCacheRefresh=function(){return $.H.useCacheRefresh()},ct.use=function(F){return $.H.use(F)},ct.useActionState=function(F,W,D){return $.H.useActionState(F,W,D)},ct.useCallback=function(F,W){return $.H.useCallback(F,W)},ct.useContext=function(F){return $.H.useContext(F)},ct.useDebugValue=function(){},ct.useDeferredValue=function(F,W){return $.H.useDeferredValue(F,W)},ct.useEffect=function(F,W){return $.H.useEffect(F,W)},ct.useEffectEvent=function(F){return $.H.useEffectEvent(F)},ct.useId=function(){return $.H.useId()},ct.useImperativeHandle=function(F,W,D){return $.H.useImperativeHandle(F,W,D)},ct.useInsertionEffect=function(F,W){return $.H.useInsertionEffect(F,W)},ct.useLayoutEffect=function(F,W){return $.H.useLayoutEffect(F,W)},ct.useMemo=function(F,W){return $.H.useMemo(F,W)},ct.useOptimistic=function(F,W){return $.H.useOptimistic(F,W)},ct.useReducer=function(F,W,D){return $.H.useReducer(F,W,D)},ct.useRef=function(F){return $.H.useRef(F)},ct.useState=function(F){return $.H.useState(F)},ct.useSyncExternalStore=function(F,W,D){return $.H.useSyncExternalStore(F,W,D)},ct.useTransition=function(){return $.H.useTransition()},ct.version="19.2.4",ct}var F0;function Cm(){return F0||(F0=1,nh.exports=bw()),nh.exports}var w=Cm(),rh={exports:{}},bo={},ah={exports:{}},lh={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var M0;function vw(){return M0||(M0=1,(function(e){function n(Y,ae){var Z=Y.length;Y.push(ae);e:for(;0<Z;){var G=Z-1>>>1,A=Y[G];if(0<o(A,ae))Y[G]=ae,Y[Z]=A,Z=G;else break e}}function a(Y){return Y.length===0?null:Y[0]}function i(Y){if(Y.length===0)return null;var ae=Y[0],Z=Y.pop();if(Z!==ae){Y[0]=Z;e:for(var G=0,A=Y.length,F=A>>>1;G<F;){var W=2*(G+1)-1,D=Y[W],te=W+1,je=Y[te];if(0>o(D,Z))te<A&&0>o(je,D)?(Y[G]=je,Y[te]=Z,G=te):(Y[G]=D,Y[W]=Z,G=W);else if(te<A&&0>o(je,Z))Y[G]=je,Y[te]=Z,G=te;else break e}}return ae}function o(Y,ae){var Z=Y.sortIndex-ae.sortIndex;return Z!==0?Z:Y.id-ae.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();e.unstable_now=function(){return d.now()-h}}var m=[],f=[],x=1,y=null,v=3,b=!1,j=!1,k=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function z(Y){for(var ae=a(f);ae!==null;){if(ae.callback===null)i(f);else if(ae.startTime<=Y)i(f),ae.sortIndex=ae.expirationTime,n(m,ae);else break;ae=a(f)}}function U(Y){if(k=!1,z(Y),!j)if(a(m)!==null)j=!0,B||(B=!0,H());else{var ae=a(f);ae!==null&&re(U,ae.startTime-Y)}}var B=!1,$=-1,q=5,L=-1;function R(){return C?!0:!(e.unstable_now()-L<q)}function I(){if(C=!1,B){var Y=e.unstable_now();L=Y;var ae=!0;try{e:{j=!1,k&&(k=!1,E($),$=-1),b=!0;var Z=v;try{t:{for(z(Y),y=a(m);y!==null&&!(y.expirationTime>Y&&R());){var G=y.callback;if(typeof G=="function"){y.callback=null,v=y.priorityLevel;var A=G(y.expirationTime<=Y);if(Y=e.unstable_now(),typeof A=="function"){y.callback=A,z(Y),ae=!0;break t}y===a(m)&&i(m),z(Y)}else i(m);y=a(m)}if(y!==null)ae=!0;else{var F=a(f);F!==null&&re(U,F.startTime-Y),ae=!1}}break e}finally{y=null,v=Z,b=!1}ae=void 0}}finally{ae?H():B=!1}}}var H;if(typeof _=="function")H=function(){_(I)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,oe=Q.port2;Q.port1.onmessage=I,H=function(){oe.postMessage(null)}}else H=function(){N(I,0)};function re(Y,ae){$=N(function(){Y(e.unstable_now())},ae)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Y){Y.callback=null},e.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<Y?Math.floor(1e3/Y):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(Y){switch(v){case 1:case 2:case 3:var ae=3;break;default:ae=v}var Z=v;v=ae;try{return Y()}finally{v=Z}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(Y,ae){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var Z=v;v=Y;try{return ae()}finally{v=Z}},e.unstable_scheduleCallback=function(Y,ae,Z){var G=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?G+Z:G):Z=G,Y){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=Z+A,Y={id:x++,callback:ae,priorityLevel:Y,startTime:Z,expirationTime:A,sortIndex:-1},Z>G?(Y.sortIndex=Z,n(f,Y),a(m)===null&&Y===a(f)&&(k?(E($),$=-1):k=!0,re(U,Z-G))):(Y.sortIndex=A,n(m,Y),j||b||(j=!0,B||(B=!0,H()))),Y},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(Y){var ae=v;return function(){var Z=v;v=ae;try{return Y.apply(this,arguments)}finally{v=Z}}}})(lh)),lh}var R0;function ww(){return R0||(R0=1,ah.exports=vw()),ah.exports}var ih={exports:{}},Zn={};/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var z0;function kw(){if(z0)return Zn;z0=1;var e=Cm();function n(m){var f="https://react.dev/errors/"+m;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)f+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var i={d:{f:a,r:function(){throw Error(n(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},o=Symbol.for("react.portal");function u(m,f,x){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:m,containerInfo:f,implementation:x}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Zn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Zn.createPortal=function(m,f){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(n(299));return u(m,f,null,x)},Zn.flushSync=function(m){var f=d.T,x=i.p;try{if(d.T=null,i.p=2,m)return m()}finally{d.T=f,i.p=x,i.d.f()}},Zn.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,i.d.C(m,f))},Zn.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},Zn.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var x=f.as,y=h(x,f.crossOrigin),v=typeof f.integrity=="string"?f.integrity:void 0,b=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;x==="style"?i.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:v,fetchPriority:b}):x==="script"&&i.d.X(m,{crossOrigin:y,integrity:v,fetchPriority:b,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Zn.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var x=h(f.as,f.crossOrigin);i.d.M(m,{crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&i.d.M(m)},Zn.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var x=f.as,y=h(x,f.crossOrigin);i.d.L(m,x,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},Zn.preloadModule=function(m,f){if(typeof m=="string")if(f){var x=h(f.as,f.crossOrigin);i.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else i.d.m(m)},Zn.requestFormReset=function(m){i.d.r(m)},Zn.unstable_batchedUpdates=function(m,f){return m(f)},Zn.useFormState=function(m,f,x){return d.H.useFormState(m,f,x)},Zn.useFormStatus=function(){return d.H.useHostTransitionStatus()},Zn.version="19.2.4",Zn}var _0;function jw(){if(_0)return ih.exports;_0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),ih.exports=kw(),ih.exports}/**
|
|
34
|
+
* @license React
|
|
35
|
+
* react-dom-client.production.js
|
|
36
|
+
*
|
|
37
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the MIT license found in the
|
|
40
|
+
* LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/var B0;function Sw(){if(B0)return bo;B0=1;var e=ww(),n=Cm(),a=jw();function i(t){var r="https://react.dev/errors/"+t;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)r+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function u(t){var r=t,s=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(s=r.return),t=r.return;while(t)}return r.tag===3?s:null}function d(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function h(t){if(t.tag===31){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function m(t){if(u(t)!==t)throw Error(i(188))}function f(t){var r=t.alternate;if(!r){if(r=u(t),r===null)throw Error(i(188));return r!==t?null:t}for(var s=t,c=r;;){var p=s.return;if(p===null)break;var g=p.alternate;if(g===null){if(c=p.return,c!==null){s=c;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===s)return m(p),t;if(g===c)return m(p),r;g=g.sibling}throw Error(i(188))}if(s.return!==c.return)s=p,c=g;else{for(var S=!1,M=p.child;M;){if(M===s){S=!0,s=p,c=g;break}if(M===c){S=!0,c=p,s=g;break}M=M.sibling}if(!S){for(M=g.child;M;){if(M===s){S=!0,s=g,c=p;break}if(M===c){S=!0,c=g,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 y=Object.assign,v=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),_=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function H(t){return t===null||typeof t!="object"?null:(t=I&&t[I]||t["@@iterator"],typeof t=="function"?t:null)}var Q=Symbol.for("react.client.reference");function oe(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Q?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case N:return"Profiler";case C:return"StrictMode";case U:return"Suspense";case B:return"SuspenseList";case L:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case j:return"Portal";case _:return t.displayName||"Context";case E: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 $:return r=t.displayName||null,r!==null?r:oe(t.type)||"Memo";case q:r=t._payload,t=t._init;try{return oe(t(r))}catch{}}return null}var re=Array.isArray,Y=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},G=[],A=-1;function F(t){return{current:t}}function W(t){0>A||(t.current=G[A],G[A]=null,A--)}function D(t,r){A++,G[A]=t.current,t.current=r}var te=F(null),je=F(null),ve=F(null),ze=F(null);function Xe(t,r){switch(D(ve,r),D(je,t),D(te,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?Q1(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=Q1(r),t=P1(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}W(te),D(te,t)}function de(){W(te),W(je),W(ve)}function Oe(t){t.memoizedState!==null&&D(ze,t);var r=te.current,s=P1(r,t.type);r!==s&&(D(je,t),D(te,s))}function Qe(t){je.current===t&&(W(te),W(je)),ze.current===t&&(W(ze),mo._currentValue=Z)}var Se,Je;function Re(t){if(Se===void 0)try{throw Error()}catch(s){var r=s.stack.trim().match(/\n( *(at )?)/);Se=r&&r[1]||"",Je=-1<s.stack.indexOf(`
|
|
42
|
+
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
+
`+Se+t+Je}var Et=!1;function ut(t,r){if(!t||Et)return"";Et=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(r){var we=function(){throw Error()};if(Object.defineProperty(we.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(we,[])}catch(ce){var se=ce}Reflect.construct(t,[],we)}else{try{we.call()}catch(ce){se=ce}t.call(we.prototype)}}else{try{throw Error()}catch(ce){se=ce}(we=t())&&typeof we.catch=="function"&&we.catch(function(){})}}catch(ce){if(ce&&se&&typeof ce.stack=="string")return[ce.stack,se.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),S=g[0],M=g[1];if(S&&M){var X=S.split(`
|
|
44
|
+
`),ie=M.split(`
|
|
45
|
+
`);for(p=c=0;c<X.length&&!X[c].includes("DetermineComponentFrameRoot");)c++;for(;p<ie.length&&!ie[p].includes("DetermineComponentFrameRoot");)p++;if(c===X.length||p===ie.length)for(c=X.length-1,p=ie.length-1;1<=c&&0<=p&&X[c]!==ie[p];)p--;for(;1<=c&&0<=p;c--,p--)if(X[c]!==ie[p]){if(c!==1||p!==1)do if(c--,p--,0>p||X[c]!==ie[p]){var fe=`
|
|
46
|
+
`+X[c].replace(" at new "," at ");return t.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",t.displayName)),fe}while(1<=c&&0<=p);break}}}finally{Et=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?Re(s):""}function gt(t,r){switch(t.tag){case 26:case 27:case 5:return Re(t.type);case 16:return Re("Lazy");case 13:return t.child!==r&&r!==null?Re("Suspense Fallback"):Re("Suspense");case 19:return Re("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 Re("Activity");default:return""}}function kt(t){try{var r="",s=null;do r+=gt(t,s),s=t,t=t.return;while(t);return r}catch(c){return`
|
|
47
|
+
Error generating stack: `+c.message+`
|
|
48
|
+
`+c.stack}}var pe=Object.prototype.hasOwnProperty,xe=e.unstable_scheduleCallback,ge=e.unstable_cancelCallback,$e=e.unstable_shouldYield,Be=e.unstable_requestPaint,Le=e.unstable_now,Ee=e.unstable_getCurrentPriorityLevel,P=e.unstable_ImmediatePriority,ue=e.unstable_UserBlockingPriority,ye=e.unstable_NormalPriority,Ne=e.unstable_LowPriority,Me=e.unstable_IdlePriority,Pe=e.log,_t=e.unstable_setDisableYieldValue,dt=null,ht=null;function bt(t){if(typeof Pe=="function"&&_t(t),ht&&typeof ht.setStrictMode=="function")try{ht.setStrictMode(dt,t)}catch{}}var et=Math.clz32?Math.clz32:nn,Fe=Math.log,_e=Math.LN2;function nn(t){return t>>>=0,t===0?32:31-(Fe(t)/_e|0)|0}var fn=256,Vt=262144,yt=4194304;function pn(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 Mn(t,r,s){var c=t.pendingLanes;if(c===0)return 0;var p=0,g=t.suspendedLanes,S=t.pingedLanes;t=t.warmLanes;var M=c&134217727;return M!==0?(c=M&~g,c!==0?p=pn(c):(S&=M,S!==0?p=pn(S):s||(s=M&~t,s!==0&&(p=pn(s))))):(M=c&~g,M!==0?p=pn(M):S!==0?p=pn(S):s||(s=c&~t,s!==0&&(p=pn(s)))),p===0?0:r!==0&&r!==p&&(r&g)===0&&(g=p&-p,s=r&-r,g>=s||g===32&&(s&4194048)!==0)?r:p}function J(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function We(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 ot(){var t=yt;return yt<<=1,(yt&62914560)===0&&(yt=4194304),t}function xn(t){for(var r=[],s=0;31>s;s++)r.push(t);return r}function ke(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Mt(t,r,s,c,p,g){var S=t.pendingLanes;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=s,t.entangledLanes&=s,t.errorRecoveryDisabledLanes&=s,t.shellSuspendCounter=0;var M=t.entanglements,X=t.expirationTimes,ie=t.hiddenUpdates;for(s=S&~s;0<s;){var fe=31-et(s),we=1<<fe;M[fe]=0,X[fe]=-1;var se=ie[fe];if(se!==null)for(ie[fe]=null,fe=0;fe<se.length;fe++){var ce=se[fe];ce!==null&&(ce.lane&=-536870913)}s&=~we}c!==0&&hn(t,c,0),g!==0&&p===0&&t.tag!==0&&(t.suspendedLanes|=g&~(S&~r))}function hn(t,r,s){t.pendingLanes|=r,t.suspendedLanes&=~r;var c=31-et(r);t.entangledLanes|=r,t.entanglements[c]=t.entanglements[c]|1073741824|s&261930}function cn(t,r){var s=t.entangledLanes|=r;for(t=t.entanglements;s;){var c=31-et(s),p=1<<c;p&r|t[c]&r&&(t[c]|=r),s&=~p}}function ua(t,r){var s=r&-r;return s=(s&42)!==0?1:wt(s),(s&(t.suspendedLanes|r))!==0?0:s}function wt(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 nr(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function il(){var t=ae.p;return t!==0?t:(t=window.event,t===void 0?32:v0(t.type))}function Vo(t,r){var s=ae.p;try{return ae.p=t,r()}finally{ae.p=s}}var wr=Math.random().toString(36).slice(2),Rn="__reactFiber$"+wr,Ln="__reactProps$"+wr,da="__reactContainer$"+wr,sl="__reactEvents$"+wr,ad="__reactListeners$"+wr,Ds="__reactHandles$"+wr,Go="__reactResources$"+wr,Fa="__reactMarker$"+wr;function Fi(t){delete t[Rn],delete t[Ln],delete t[sl],delete t[ad],delete t[Ds]}function fa(t){var r=t[Rn];if(r)return r;for(var s=t.parentNode;s;){if(r=s[da]||s[Rn]){if(s=r.alternate,r.child!==null||s!==null&&s.child!==null)for(t=a0(t);t!==null;){if(s=t[Rn])return s;t=a0(t)}return r}t=s,s=t.parentNode}return null}function qn(t){if(t=t[Rn]||t[da]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function Gl(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function kr(t){var r=t[Go];return r||(r=t[Go]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function yn(t){t[Fa]=!0}var Ma=new Set,Ra={};function cr(t,r){za(t,r),za(t+"Capture",r)}function za(t,r){for(Ra[t]=r,t=0;t<r.length;t++)Ma.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]*$"),Ts={},Fs={};function Ms(t){return pe.call(Fs,t)?!0:pe.call(Ts,t)?!1:ol.test(t)?Fs[t]=!0:(Ts[t]=!0,!1)}function Kl(t,r,s){if(Ms(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 Ql(t,r,s){if(s===null)t.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttribute(r,""+s)}}function Zr(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 Sn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function wn(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Jr(t,r,s){var c=Object.getOwnPropertyDescriptor(t.constructor.prototype,r);if(!t.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var p=c.get,g=c.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return p.call(this)},set:function(S){s=""+S,g.call(this,S)}}),Object.defineProperty(t,r,{enumerable:c.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function ea(t){if(!t._valueTracker){var r=wn(t)?"checked":"value";t._valueTracker=Jr(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=wn(t)?t.checked?"true":"false":t.value),t=c,t!==s?(r.setValue(t),!0):!1}function Cn(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 ur(t){return t.replace(Ko,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Pl(t,r,s,c,p,g,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=""+Sn(r)):t.value!==""+Sn(r)&&(t.value=""+Sn(r)):S!=="submit"&&S!=="reset"||t.removeAttribute("value"),r!=null?ha(t,S,Sn(r)):s!=null?ha(t,S,Sn(s)):c!=null&&t.removeAttribute("value"),p==null&&g!=null&&(t.defaultChecked=!!g),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?t.name=""+Sn(M):t.removeAttribute("name")}function rr(t,r,s,c,p,g,S,M){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(t.type=g),r!=null||s!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){ea(t);return}s=s!=null?""+Sn(s):"",r=r!=null?""+Sn(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),ea(t)}function ha(t,r,s){r==="number"&&Cn(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function dr(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=""+Sn(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 Qo(t,r,s){if(r!=null&&(r=""+Sn(r),r!==t.value&&(t.value=r),s==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=s!=null?""+Sn(s):""}function In(t,r,s,c){if(r==null){if(c!=null){if(s!=null)throw Error(i(92));if(re(c)){if(1<c.length)throw Error(i(93));c=c[0]}s=c}s==null&&(s=""),r=s}s=Sn(r),t.defaultValue=s,c=t.textContent,c===s&&c!==""&&c!==null&&(t.value=c),ea(t)}function Ut(t,r){if(r){var s=t.firstChild;if(s&&s===t.lastChild&&s.nodeType===3){s.nodeValue=r;return}}t.textContent=r}var ma=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 Yn(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||ma.has(r)?r==="float"?t.cssFloat=s:t[r]=(""+s).trim():t[r]=s+"px"}function ta(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&&Yn(t,p,c)}else for(var g in r)r.hasOwnProperty(g)&&Yn(t,g,r[g])}function Zl(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 ld=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"]]),Jl=/^[\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 jr(t){return Jl.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function Xn(){}var mn=null;function pa(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var na=null,cl=null;function Po(t){var r=qn(t);if(r&&(t=r.stateNode)){var s=t[Ln]||null;e:switch(t=r.stateNode,r.type){case"input":if(Pl(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="'+ur(""+r)+'"][type="radio"]'),r=0;r<s.length;r++){var c=s[r];if(c!==t&&c.form===t.form){var p=c[Ln]||null;if(!p)throw Error(i(90));Pl(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":Qo(t,s.value,s.defaultValue);break e;case"select":r=s.value,r!=null&&dr(t,!!s.multiple,r,!1)}}}var At=!1;function Zo(t,r,s){if(At)return t(r,s);At=!0;try{var c=t(r);return c}finally{if(At=!1,(na!==null||cl!==null)&&(qc(),na&&(r=na,t=cl,cl=na=null,Po(r),t)))for(r=0;r<t.length;r++)Po(t[r])}}function qt(t,r){var s=t.stateNode;if(s===null)return null;var c=s[Ln]||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 Sr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_a=!1;if(Sr)try{var ei={};Object.defineProperty(ei,"passive",{get:function(){_a=!0}}),window.addEventListener("test",ei,ei),window.removeEventListener("test",ei,ei)}catch{_a=!1}var xa=null,ti=null,$r=null;function Mi(){if($r)return $r;var t,r=ti,s=r.length,c,p="value"in xa?xa.value:xa.textContent,g=p.length;for(t=0;t<s&&r[t]===p[t];t++);var S=s-t;for(c=1;c<=S&&r[s-c]===p[g-c];c++);return $r=p.slice(t,1<c?1-c:void 0)}function Ri(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 zi(){return!0}function _i(){return!1}function Pn(t){function r(s,c,p,g,S){this._reactName=s,this._targetInst=p,this.type=c,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var M in t)t.hasOwnProperty(M)&&(s=t[M],this[M]=s?s(g):g[M]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?zi:_i,this.isPropagationStopped=_i,this}return y(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=zi)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=zi)},persist:function(){},isPersistent:zi}),r}var ya={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ul=Pn(ya),ni=y({},ya,{view:0,detail:0}),Jo=Pn(ni),Bi,Oi,fr,Lr=y({},ni,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:T,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!==fr&&(fr&&t.type==="mousemove"?(Bi=t.screenX-fr.screenX,Oi=t.screenY-fr.screenY):Oi=Bi=0,fr=t),Bi)},movementY:function(t){return"movementY"in t?t.movementY:Oi}}),$i=Pn(Lr),id=y({},Lr,{dataTransfer:0}),ga=Pn(id),ec=y({},ni,{relatedTarget:0}),Rs=Pn(ec),tc=y({},ya,{animationName:0,elapsedTime:0,pseudoElement:0}),Gt=Pn(tc),dl=y({},ya,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),nc=Pn(dl),rc=y({},ya,{data:0}),zs=Pn(rc),ac={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lc={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"},ic={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sc(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=ic[t])?!!r[t]:!1}function T(){return sc}var K=y({},ni,{key:function(t){if(t.key){var r=ac[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Ri(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?lc[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:T,charCode:function(t){return t.type==="keypress"?Ri(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ri(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),ee=Pn(K),he=y({},Lr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ce=Pn(he),Ye=y({},ni,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:T}),mt=Pn(Ye),it=y({},ya,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ge=Pn(it),rt=y({},Lr,{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}),at=Pn(rt),Yt=y({},ya,{newState:0,oldState:0}),jt=Pn(Yt),ar=[9,13,27,32],fl=Sr&&"CompositionEvent"in window,Kt=null;Sr&&"documentMode"in document&&(Kt=document.documentMode);var hl=Sr&&"TextEvent"in window&&!Kt,Ir=Sr&&(!fl||Kt&&8<Kt&&11>=Kt),Hn=" ",Li=!1;function gn(t,r){switch(t){case"keyup":return ar.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ip(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ii=!1;function Lv(t,r){switch(t){case"compositionend":return ip(r);case"keypress":return r.which!==32?null:(Li=!0,Hn);case"textInput":return t=r.data,t===Hn&&Li?null:t;default:return null}}function Iv(t,r){if(Ii)return t==="compositionend"||!fl&&gn(t,r)?(t=Mi(),$r=ti=xa=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 Ir&&r.locale!=="ko"?null:r.data;default:return null}}var Hv={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function sp(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!Hv[t.type]:r==="textarea"}function op(t,r,s,c){na?cl?cl.push(c):cl=[c]:na=c,r=Qc(r,"onChange"),0<r.length&&(s=new ul("onChange","change",null,s,c),t.push({event:s,listeners:r}))}var _s=null,Bs=null;function Uv(t){Y1(t,0)}function oc(t){var r=Gl(t);if(Or(r))return t}function cp(t,r){if(t==="change")return r}var up=!1;if(Sr){var sd;if(Sr){var od="oninput"in document;if(!od){var dp=document.createElement("div");dp.setAttribute("oninput","return;"),od=typeof dp.oninput=="function"}sd=od}else sd=!1;up=sd&&(!document.documentMode||9<document.documentMode)}function fp(){_s&&(_s.detachEvent("onpropertychange",hp),Bs=_s=null)}function hp(t){if(t.propertyName==="value"&&oc(Bs)){var r=[];op(r,Bs,t,pa(t)),Zo(Uv,r)}}function qv(t,r,s){t==="focusin"?(fp(),_s=r,Bs=s,_s.attachEvent("onpropertychange",hp)):t==="focusout"&&fp()}function Yv(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return oc(Bs)}function Xv(t,r){if(t==="click")return oc(r)}function Wv(t,r){if(t==="input"||t==="change")return oc(r)}function Vv(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var Cr=typeof Object.is=="function"?Object.is:Vv;function Os(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(!pe.call(r,p)||!Cr(t[p],r[p]))return!1}return!0}function mp(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function pp(t,r){var s=mp(t);t=0;for(var 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=mp(s)}}function xp(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?xp(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function yp(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=Cn(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=Cn(t.document)}return r}function cd(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}var Gv=Sr&&"documentMode"in document&&11>=document.documentMode,Hi=null,ud=null,$s=null,dd=!1;function gp(t,r,s){var c=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;dd||Hi==null||Hi!==Cn(c)||(c=Hi,"selectionStart"in c&&cd(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),$s&&Os($s,c)||($s=c,c=Qc(ud,"onSelect"),0<c.length&&(r=new ul("onSelect","select",null,r,s),t.push({event:r,listeners:c}),r.target=Hi)))}function ri(t,r){var s={};return s[t.toLowerCase()]=r.toLowerCase(),s["Webkit"+t]="webkit"+r,s["Moz"+t]="moz"+r,s}var Ui={animationend:ri("Animation","AnimationEnd"),animationiteration:ri("Animation","AnimationIteration"),animationstart:ri("Animation","AnimationStart"),transitionrun:ri("Transition","TransitionRun"),transitionstart:ri("Transition","TransitionStart"),transitioncancel:ri("Transition","TransitionCancel"),transitionend:ri("Transition","TransitionEnd")},fd={},bp={};Sr&&(bp=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 ai(t){if(fd[t])return fd[t];if(!Ui[t])return t;var r=Ui[t],s;for(s in r)if(r.hasOwnProperty(s)&&s in bp)return fd[t]=r[s];return t}var vp=ai("animationend"),wp=ai("animationiteration"),kp=ai("animationstart"),Kv=ai("transitionrun"),Qv=ai("transitionstart"),Pv=ai("transitioncancel"),jp=ai("transitionend"),Sp=new Map,hd="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");hd.push("scrollEnd");function ra(t,r){Sp.set(t,r),cr(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)},Hr=[],qi=0,md=0;function uc(){for(var t=qi,r=md=qi=0;r<t;){var s=Hr[r];Hr[r++]=null;var c=Hr[r];Hr[r++]=null;var p=Hr[r];Hr[r++]=null;var g=Hr[r];if(Hr[r++]=null,c!==null&&p!==null){var S=c.pending;S===null?p.next=p:(p.next=S.next,S.next=p),c.pending=p}g!==0&&Cp(s,p,g)}}function dc(t,r,s,c){Hr[qi++]=t,Hr[qi++]=r,Hr[qi++]=s,Hr[qi++]=c,md|=c,t.lanes|=c,t=t.alternate,t!==null&&(t.lanes|=c)}function pd(t,r,s,c){return dc(t,r,s,c),fc(t)}function li(t,r){return dc(t,null,null,r),fc(t)}function Cp(t,r,s){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s);for(var p=!1,g=t.return;g!==null;)g.childLanes|=s,c=g.alternate,c!==null&&(c.childLanes|=s),g.tag===22&&(t=g.stateNode,t===null||t._visibility&1||(p=!0)),t=g,g=g.return;return t.tag===3?(g=t.stateNode,p&&r!==null&&(p=31-et(s),t=g.hiddenUpdates,c=t[p],c===null?t[p]=[r]:c.push(r),r.lane=s|536870912),g):null}function fc(t){if(50<io)throw io=0,Cf=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var Yi={};function Zv(t,r,s,c){this.tag=t,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nr(t,r,s,c){return new Zv(t,r,s,c)}function xd(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ba(t,r){var s=t.alternate;return s===null?(s=Nr(t.tag,r,t.key,t.mode),s.elementType=t.elementType,s.type=t.type,s.stateNode=t.stateNode,s.alternate=t,t.alternate=s):(s.pendingProps=r,s.type=t.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=t.flags&65011712,s.childLanes=t.childLanes,s.lanes=t.lanes,s.child=t.child,s.memoizedProps=t.memoizedProps,s.memoizedState=t.memoizedState,s.updateQueue=t.updateQueue,r=t.dependencies,s.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},s.sibling=t.sibling,s.index=t.index,s.ref=t.ref,s.refCleanup=t.refCleanup,s}function Np(t,r){t.flags&=65011714;var s=t.alternate;return s===null?(t.childLanes=0,t.lanes=r,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=s.childLanes,t.lanes=s.lanes,t.child=s.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=s.memoizedProps,t.memoizedState=s.memoizedState,t.updateQueue=s.updateQueue,t.type=s.type,r=s.dependencies,t.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),t}function hc(t,r,s,c,p,g){var S=0;if(c=t,typeof t=="function")xd(t)&&(S=1);else if(typeof t=="string")S=rw(t,s,te.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case L:return t=Nr(31,s,r,p),t.elementType=L,t.lanes=g,t;case k:return ii(s.children,p,g,r);case C:S=8,p|=24;break;case N:return t=Nr(12,s,r,p|2),t.elementType=N,t.lanes=g,t;case U:return t=Nr(13,s,r,p),t.elementType=U,t.lanes=g,t;case B:return t=Nr(19,s,r,p),t.elementType=B,t.lanes=g,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:S=10;break e;case E:S=9;break e;case z:S=11;break e;case $: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=Nr(S,s,r,p),r.elementType=t,r.type=c,r.lanes=g,r}function ii(t,r,s,c){return t=Nr(7,t,c,r),t.lanes=s,t}function yd(t,r,s){return t=Nr(6,t,null,r),t.lanes=s,t}function Ep(t){var r=Nr(18,null,null,0);return r.stateNode=t,r}function gd(t,r,s){return r=Nr(4,t.children!==null?t.children:[],t.key,r),r.lanes=s,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var Ap=new WeakMap;function Ur(t,r){if(typeof t=="object"&&t!==null){var s=Ap.get(t);return s!==void 0?s:(r={value:t,source:r,stack:kt(r)},Ap.set(t,r),r)}return{value:t,source:r,stack:kt(r)}}var Xi=[],Wi=0,mc=null,Ls=0,qr=[],Yr=0,ml=null,ba=1,va="";function Oa(t,r){Xi[Wi++]=Ls,Xi[Wi++]=mc,mc=t,Ls=r}function Dp(t,r,s){qr[Yr++]=ba,qr[Yr++]=va,qr[Yr++]=ml,ml=t;var c=ba;t=va;var p=32-et(c)-1;c&=~(1<<p),s+=1;var g=32-et(r)+p;if(30<g){var S=p-p%5;g=(c&(1<<S)-1).toString(32),c>>=S,p-=S,ba=1<<32-et(r)+p|s<<p|c,va=g+t}else ba=1<<g|s<<p|c,va=t}function bd(t){t.return!==null&&(Oa(t,1),Dp(t,1,0))}function vd(t){for(;t===mc;)mc=Xi[--Wi],Xi[Wi]=null,Ls=Xi[--Wi],Xi[Wi]=null;for(;t===ml;)ml=qr[--Yr],qr[Yr]=null,va=qr[--Yr],qr[Yr]=null,ba=qr[--Yr],qr[Yr]=null}function Tp(t,r){qr[Yr++]=ba,qr[Yr++]=va,qr[Yr++]=ml,ba=r.id,va=r.overflow,ml=t}var Wn=null,ln=null,Rt=!1,pl=null,Xr=!1,wd=Error(i(519));function xl(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Is(Ur(r,t)),wd}function Fp(t){var r=t.stateNode,s=t.type,c=t.memoizedProps;switch(r[Rn]=t,r[Ln]=c,s){case"dialog":Ct("cancel",r),Ct("close",r);break;case"iframe":case"object":case"embed":Ct("load",r);break;case"video":case"audio":for(s=0;s<oo.length;s++)Ct(oo[s],r);break;case"source":Ct("error",r);break;case"img":case"image":case"link":Ct("error",r),Ct("load",r);break;case"details":Ct("toggle",r);break;case"input":Ct("invalid",r),rr(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Ct("invalid",r);break;case"textarea":Ct("invalid",r),In(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||G1(r.textContent,s)?(c.popover!=null&&(Ct("beforetoggle",r),Ct("toggle",r)),c.onScroll!=null&&Ct("scroll",r),c.onScrollEnd!=null&&Ct("scrollend",r),c.onClick!=null&&(r.onclick=Xn),r=!0):r=!1,r||xl(t,!0)}function Mp(t){for(Wn=t.return;Wn;)switch(Wn.tag){case 5:case 31:case 13:Xr=!1;return;case 27:case 3:Xr=!0;return;default:Wn=Wn.return}}function Vi(t){if(t!==Wn)return!1;if(!Rt)return Mp(t),Rt=!0,!1;var r=t.tag,s;if((s=r!==3&&r!==27)&&((s=r===5)&&(s=t.type,s=!(s!=="form"&&s!=="button")||If(t.type,t.memoizedProps)),s=!s),s&&ln&&xl(t),Mp(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));ln=r0(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));ln=r0(t)}else r===27?(r=ln,Tl(t.type)?(t=Xf,Xf=null,ln=t):ln=r):ln=Wn?Vr(t.stateNode.nextSibling):null;return!0}function si(){ln=Wn=null,Rt=!1}function kd(){var t=pl;return t!==null&&(xr===null?xr=t:xr.push.apply(xr,t),pl=null),t}function Is(t){pl===null?pl=[t]:pl.push(t)}var jd=F(null),oi=null,$a=null;function yl(t,r,s){D(jd,r._currentValue),r._currentValue=s}function La(t){t._currentValue=jd.current,W(jd)}function Sd(t,r,s){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===s)break;t=t.return}}function Cd(t,r,s,c){var p=t.child;for(p!==null&&(p.return=t);p!==null;){var g=p.dependencies;if(g!==null){var S=p.child;g=g.firstContext;e:for(;g!==null;){var M=g;g=p;for(var X=0;X<r.length;X++)if(M.context===r[X]){g.lanes|=s,M=g.alternate,M!==null&&(M.lanes|=s),Sd(g.return,s,t),c||(S=null);break e}g=M.next}}else if(p.tag===18){if(S=p.return,S===null)throw Error(i(341));S.lanes|=s,g=S.alternate,g!==null&&(g.lanes|=s),Sd(S,s,t),S=null}else S=p.child;if(S!==null)S.return=p;else for(S=p;S!==null;){if(S===t){S=null;break}if(p=S.sibling,p!==null){p.return=S.return,S=p;break}S=S.return}p=S}}function Gi(t,r,s,c){t=null;for(var p=r,g=!1;p!==null;){if(!g){if((p.flags&524288)!==0)g=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var S=p.alternate;if(S===null)throw Error(i(387));if(S=S.memoizedProps,S!==null){var 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(mo):t=[mo])}p=p.return}t!==null&&Cd(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 ci(t){oi=t,$a=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Vn(t){return Rp(oi,t)}function xc(t,r){return oi===null&&ci(t),Rp(t,r)}function Rp(t,r){var s=r._currentValue;if(r={context:r,memoizedValue:s,next:null},$a===null){if(t===null)throw Error(i(308));$a=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else $a=$a.next=r;return s}var Jv=typeof AbortController<"u"?AbortController:function(){var t=[],r=this.signal={aborted:!1,addEventListener:function(s,c){t.push(c)}};this.abort=function(){r.aborted=!0,t.forEach(function(s){return s()})}},e2=e.unstable_scheduleCallback,t2=e.unstable_NormalPriority,Nn={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Nd(){return{controller:new Jv,data:new Map,refCount:0}}function Hs(t){t.refCount--,t.refCount===0&&e2(t2,function(){t.controller.abort()})}var Us=null,Ed=0,Ki=0,Qi=null;function n2(t,r){if(Us===null){var s=Us=[];Ed=0,Ki=Ff(),Qi={status:"pending",value:void 0,then:function(c){s.push(c)}}}return Ed++,r.then(zp,zp),r}function zp(){if(--Ed===0&&Us!==null){Qi!==null&&(Qi.status="fulfilled");var t=Us;Us=null,Ki=0,Qi=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function r2(t,r){var s=[],c={status:"pending",value:null,reason:null,then:function(p){s.push(p)}};return t.then(function(){c.status="fulfilled",c.value=r;for(var p=0;p<s.length;p++)(0,s[p])(r)},function(p){for(c.status="rejected",c.reason=p,p=0;p<s.length;p++)(0,s[p])(void 0)}),c}var _p=Y.S;Y.S=function(t,r){g1=Le(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&n2(t,r),_p!==null&&_p(t,r)};var ui=F(null);function Ad(){var t=ui.current;return t!==null?t:en.pooledCache}function yc(t,r){r===null?D(ui,ui.current):D(ui,r.pool)}function Bp(){var t=Ad();return t===null?null:{parent:Nn._currentValue,pool:t}}var Pi=Error(i(460)),Dd=Error(i(474)),gc=Error(i(542)),bc={then:function(){}};function Op(t){return t=t.status,t==="fulfilled"||t==="rejected"}function $p(t,r,s){switch(s=t[s],s===void 0?t.push(r):s!==r&&(r.then(Xn,Xn),r=s),r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,Ip(t),t;default:if(typeof r.status=="string")r.then(Xn,Xn);else{if(t=en,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,Ip(t),t}throw fi=r,Pi}}function di(t){try{var r=t._init;return r(t._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(fi=s,Pi):s}}var fi=null;function Lp(){if(fi===null)throw Error(i(459));var t=fi;return fi=null,t}function Ip(t){if(t===Pi||t===gc)throw Error(i(483))}var Zi=null,qs=0;function vc(t){var r=qs;return qs+=1,Zi===null&&(Zi=[]),$p(Zi,t,r)}function Ys(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function wc(t,r){throw r.$$typeof===v?Error(i(525)):(t=Object.prototype.toString.call(r),Error(i(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t)))}function Hp(t){function r(ne,V){if(t){var le=ne.deletions;le===null?(ne.deletions=[V],ne.flags|=16):le.push(V)}}function s(ne,V){if(!t)return null;for(;V!==null;)r(ne,V),V=V.sibling;return null}function c(ne){for(var V=new Map;ne!==null;)ne.key!==null?V.set(ne.key,ne):V.set(ne.index,ne),ne=ne.sibling;return V}function p(ne,V){return ne=Ba(ne,V),ne.index=0,ne.sibling=null,ne}function g(ne,V,le){return ne.index=le,t?(le=ne.alternate,le!==null?(le=le.index,le<V?(ne.flags|=67108866,V):le):(ne.flags|=67108866,V)):(ne.flags|=1048576,V)}function S(ne){return t&&ne.alternate===null&&(ne.flags|=67108866),ne}function M(ne,V,le,be){return V===null||V.tag!==6?(V=yd(le,ne.mode,be),V.return=ne,V):(V=p(V,le),V.return=ne,V)}function X(ne,V,le,be){var Ke=le.type;return Ke===k?fe(ne,V,le.props.children,be,le.key):V!==null&&(V.elementType===Ke||typeof Ke=="object"&&Ke!==null&&Ke.$$typeof===q&&di(Ke)===V.type)?(V=p(V,le.props),Ys(V,le),V.return=ne,V):(V=hc(le.type,le.key,le.props,null,ne.mode,be),Ys(V,le),V.return=ne,V)}function ie(ne,V,le,be){return V===null||V.tag!==4||V.stateNode.containerInfo!==le.containerInfo||V.stateNode.implementation!==le.implementation?(V=gd(le,ne.mode,be),V.return=ne,V):(V=p(V,le.children||[]),V.return=ne,V)}function fe(ne,V,le,be,Ke){return V===null||V.tag!==7?(V=ii(le,ne.mode,be,Ke),V.return=ne,V):(V=p(V,le),V.return=ne,V)}function we(ne,V,le){if(typeof V=="string"&&V!==""||typeof V=="number"||typeof V=="bigint")return V=yd(""+V,ne.mode,le),V.return=ne,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case b:return le=hc(V.type,V.key,V.props,null,ne.mode,le),Ys(le,V),le.return=ne,le;case j:return V=gd(V,ne.mode,le),V.return=ne,V;case q:return V=di(V),we(ne,V,le)}if(re(V)||H(V))return V=ii(V,ne.mode,le,null),V.return=ne,V;if(typeof V.then=="function")return we(ne,vc(V),le);if(V.$$typeof===_)return we(ne,xc(ne,V),le);wc(ne,V)}return null}function se(ne,V,le,be){var Ke=V!==null?V.key:null;if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return Ke!==null?null:M(ne,V,""+le,be);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case b:return le.key===Ke?X(ne,V,le,be):null;case j:return le.key===Ke?ie(ne,V,le,be):null;case q:return le=di(le),se(ne,V,le,be)}if(re(le)||H(le))return Ke!==null?null:fe(ne,V,le,be,null);if(typeof le.then=="function")return se(ne,V,vc(le),be);if(le.$$typeof===_)return se(ne,V,xc(ne,le),be);wc(ne,le)}return null}function ce(ne,V,le,be,Ke){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return ne=ne.get(le)||null,M(V,ne,""+be,Ke);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case b:return ne=ne.get(be.key===null?le:be.key)||null,X(V,ne,be,Ke);case j:return ne=ne.get(be.key===null?le:be.key)||null,ie(V,ne,be,Ke);case q:return be=di(be),ce(ne,V,le,be,Ke)}if(re(be)||H(be))return ne=ne.get(le)||null,fe(V,ne,be,Ke,null);if(typeof be.then=="function")return ce(ne,V,le,vc(be),Ke);if(be.$$typeof===_)return ce(ne,V,le,xc(V,be),Ke);wc(V,be)}return null}function He(ne,V,le,be){for(var Ke=null,Ot=null,qe=V,pt=V=0,Tt=null;qe!==null&&pt<le.length;pt++){qe.index>pt?(Tt=qe,qe=null):Tt=qe.sibling;var $t=se(ne,qe,le[pt],be);if($t===null){qe===null&&(qe=Tt);break}t&&qe&&$t.alternate===null&&r(ne,qe),V=g($t,V,pt),Ot===null?Ke=$t:Ot.sibling=$t,Ot=$t,qe=Tt}if(pt===le.length)return s(ne,qe),Rt&&Oa(ne,pt),Ke;if(qe===null){for(;pt<le.length;pt++)qe=we(ne,le[pt],be),qe!==null&&(V=g(qe,V,pt),Ot===null?Ke=qe:Ot.sibling=qe,Ot=qe);return Rt&&Oa(ne,pt),Ke}for(qe=c(qe);pt<le.length;pt++)Tt=ce(qe,ne,pt,le[pt],be),Tt!==null&&(t&&Tt.alternate!==null&&qe.delete(Tt.key===null?pt:Tt.key),V=g(Tt,V,pt),Ot===null?Ke=Tt:Ot.sibling=Tt,Ot=Tt);return t&&qe.forEach(function(_l){return r(ne,_l)}),Rt&&Oa(ne,pt),Ke}function tt(ne,V,le,be){if(le==null)throw Error(i(151));for(var Ke=null,Ot=null,qe=V,pt=V=0,Tt=null,$t=le.next();qe!==null&&!$t.done;pt++,$t=le.next()){qe.index>pt?(Tt=qe,qe=null):Tt=qe.sibling;var _l=se(ne,qe,$t.value,be);if(_l===null){qe===null&&(qe=Tt);break}t&&qe&&_l.alternate===null&&r(ne,qe),V=g(_l,V,pt),Ot===null?Ke=_l:Ot.sibling=_l,Ot=_l,qe=Tt}if($t.done)return s(ne,qe),Rt&&Oa(ne,pt),Ke;if(qe===null){for(;!$t.done;pt++,$t=le.next())$t=we(ne,$t.value,be),$t!==null&&(V=g($t,V,pt),Ot===null?Ke=$t:Ot.sibling=$t,Ot=$t);return Rt&&Oa(ne,pt),Ke}for(qe=c(qe);!$t.done;pt++,$t=le.next())$t=ce(qe,ne,pt,$t.value,be),$t!==null&&(t&&$t.alternate!==null&&qe.delete($t.key===null?pt:$t.key),V=g($t,V,pt),Ot===null?Ke=$t:Ot.sibling=$t,Ot=$t);return t&&qe.forEach(function(mw){return r(ne,mw)}),Rt&&Oa(ne,pt),Ke}function Zt(ne,V,le,be){if(typeof le=="object"&&le!==null&&le.type===k&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case b:e:{for(var Ke=le.key;V!==null;){if(V.key===Ke){if(Ke=le.type,Ke===k){if(V.tag===7){s(ne,V.sibling),be=p(V,le.props.children),be.return=ne,ne=be;break e}}else if(V.elementType===Ke||typeof Ke=="object"&&Ke!==null&&Ke.$$typeof===q&&di(Ke)===V.type){s(ne,V.sibling),be=p(V,le.props),Ys(be,le),be.return=ne,ne=be;break e}s(ne,V);break}else r(ne,V);V=V.sibling}le.type===k?(be=ii(le.props.children,ne.mode,be,le.key),be.return=ne,ne=be):(be=hc(le.type,le.key,le.props,null,ne.mode,be),Ys(be,le),be.return=ne,ne=be)}return S(ne);case j:e:{for(Ke=le.key;V!==null;){if(V.key===Ke)if(V.tag===4&&V.stateNode.containerInfo===le.containerInfo&&V.stateNode.implementation===le.implementation){s(ne,V.sibling),be=p(V,le.children||[]),be.return=ne,ne=be;break e}else{s(ne,V);break}else r(ne,V);V=V.sibling}be=gd(le,ne.mode,be),be.return=ne,ne=be}return S(ne);case q:return le=di(le),Zt(ne,V,le,be)}if(re(le))return He(ne,V,le,be);if(H(le)){if(Ke=H(le),typeof Ke!="function")throw Error(i(150));return le=Ke.call(le),tt(ne,V,le,be)}if(typeof le.then=="function")return Zt(ne,V,vc(le),be);if(le.$$typeof===_)return Zt(ne,V,xc(ne,le),be);wc(ne,le)}return typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint"?(le=""+le,V!==null&&V.tag===6?(s(ne,V.sibling),be=p(V,le),be.return=ne,ne=be):(s(ne,V),be=yd(le,ne.mode,be),be.return=ne,ne=be),S(ne)):s(ne,V)}return function(ne,V,le,be){try{qs=0;var Ke=Zt(ne,V,le,be);return Zi=null,Ke}catch(qe){if(qe===Pi||qe===gc)throw qe;var Ot=Nr(29,qe,null,ne.mode);return Ot.lanes=be,Ot.return=ne,Ot}finally{}}}var hi=Hp(!0),Up=Hp(!1),gl=!1;function Td(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Fd(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function bl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function vl(t,r,s){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(It&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),Cp(t,null,s),r}return dc(t,c,r,s),fc(t)}function Xs(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,cn(t,s)}}function Md(t,r){var s=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,s===c)){var p=null,g=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};g===null?p=g=S:g=g.next=S,s=s.next}while(s!==null);g===null?p=g=r:g=g.next=r}else p=g=r;s={baseState:c.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:c.shared,callbacks:c.callbacks},t.updateQueue=s;return}t=s.lastBaseUpdate,t===null?s.firstBaseUpdate=r:t.next=r,s.lastBaseUpdate=r}var Rd=!1;function Ws(){if(Rd){var t=Qi;if(t!==null)throw t}}function Vs(t,r,s,c){Rd=!1;var p=t.updateQueue;gl=!1;var g=p.firstBaseUpdate,S=p.lastBaseUpdate,M=p.shared.pending;if(M!==null){p.shared.pending=null;var X=M,ie=X.next;X.next=null,S===null?g=ie:S.next=ie,S=X;var fe=t.alternate;fe!==null&&(fe=fe.updateQueue,M=fe.lastBaseUpdate,M!==S&&(M===null?fe.firstBaseUpdate=ie:M.next=ie,fe.lastBaseUpdate=X))}if(g!==null){var we=p.baseState;S=0,fe=ie=X=null,M=g;do{var se=M.lane&-536870913,ce=se!==M.lane;if(ce?(Dt&se)===se:(c&se)===se){se!==0&&se===Ki&&(Rd=!0),fe!==null&&(fe=fe.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var He=t,tt=M;se=r;var Zt=s;switch(tt.tag){case 1:if(He=tt.payload,typeof He=="function"){we=He.call(Zt,we,se);break e}we=He;break e;case 3:He.flags=He.flags&-65537|128;case 0:if(He=tt.payload,se=typeof He=="function"?He.call(Zt,we,se):He,se==null)break e;we=y({},we,se);break e;case 2:gl=!0}}se=M.callback,se!==null&&(t.flags|=64,ce&&(t.flags|=8192),ce=p.callbacks,ce===null?p.callbacks=[se]:ce.push(se))}else ce={lane:se,tag:M.tag,payload:M.payload,callback:M.callback,next:null},fe===null?(ie=fe=ce,X=we):fe=fe.next=ce,S|=se;if(M=M.next,M===null){if(M=p.shared.pending,M===null)break;ce=M,M=ce.next,ce.next=null,p.lastBaseUpdate=ce,p.shared.pending=null}}while(!0);fe===null&&(X=we),p.baseState=X,p.firstBaseUpdate=ie,p.lastBaseUpdate=fe,g===null&&(p.shared.lanes=0),Cl|=S,t.lanes=S,t.memoizedState=we}}function qp(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function Yp(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;t<s.length;t++)qp(s[t],r)}var Ji=F(null),kc=F(0);function Xp(t,r){t=Ga,D(kc,t),D(Ji,r),Ga=t|r.baseLanes}function zd(){D(kc,Ga),D(Ji,Ji.current)}function _d(){Ga=kc.current,W(Ji),W(kc)}var Er=F(null),Wr=null;function wl(t){var r=t.alternate;D(kn,kn.current&1),D(Er,t),Wr===null&&(r===null||Ji.current!==null||r.memoizedState!==null)&&(Wr=t)}function Bd(t){D(kn,kn.current),D(Er,t),Wr===null&&(Wr=t)}function Wp(t){t.tag===22?(D(kn,kn.current),D(Er,t),Wr===null&&(Wr=t)):kl()}function kl(){D(kn,kn.current),D(Er,Er.current)}function Ar(t){W(Er),Wr===t&&(Wr=null),W(kn)}var kn=F(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||qf(s)||Yf(s)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Ia=0,ft=null,Qt=null,En=null,Sc=!1,es=!1,mi=!1,Cc=0,Gs=0,ts=null,a2=0;function bn(){throw Error(i(321))}function Od(t,r){if(r===null)return!1;for(var s=0;s<r.length&&s<t.length;s++)if(!Cr(t[s],r[s]))return!1;return!0}function $d(t,r,s,c,p,g){return Ia=g,ft=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Y.H=t===null||t.memoizedState===null?Dx:Jd,mi=!1,g=s(c,p),mi=!1,es&&(g=Gp(r,s,c,p)),Vp(t),g}function Vp(t){Y.H=Ps;var r=Qt!==null&&Qt.next!==null;if(Ia=0,En=Qt=ft=null,Sc=!1,Gs=0,ts=null,r)throw Error(i(300));t===null||An||(t=t.dependencies,t!==null&&pc(t)&&(An=!0))}function Gp(t,r,s,c){ft=t;var p=0;do{if(es&&(ts=null),Gs=0,es=!1,25<=p)throw Error(i(301));if(p+=1,En=Qt=null,t.updateQueue!=null){var g=t.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}Y.H=Tx,g=r(s,c)}while(es);return g}function l2(){var t=Y.H,r=t.useState()[0];return r=typeof r.then=="function"?Ks(r):r,t=t.useState()[0],(Qt!==null?Qt.memoizedState:null)!==t&&(ft.flags|=1024),r}function Ld(){var t=Cc!==0;return Cc=0,t}function Id(t,r,s){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~s}function Hd(t){if(Sc){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}Sc=!1}Ia=0,En=Qt=ft=null,es=!1,Gs=Cc=0,ts=null}function lr(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return En===null?ft.memoizedState=En=t:En=En.next=t,En}function jn(){if(Qt===null){var t=ft.alternate;t=t!==null?t.memoizedState:null}else t=Qt.next;var r=En===null?ft.memoizedState:En.next;if(r!==null)En=r,Qt=t;else{if(t===null)throw ft.alternate===null?Error(i(467)):Error(i(310));Qt=t,t={memoizedState:Qt.memoizedState,baseState:Qt.baseState,baseQueue:Qt.baseQueue,queue:Qt.queue,next:null},En===null?ft.memoizedState=En=t:En=En.next=t}return En}function Nc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ks(t){var r=Gs;return Gs+=1,ts===null&&(ts=[]),t=$p(ts,t,r),r=ft,(En===null?r.memoizedState:En.next)===null&&(r=r.alternate,Y.H=r===null||r.memoizedState===null?Dx:Jd),t}function Ec(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Ks(t);if(t.$$typeof===_)return Vn(t)}throw Error(i(438,String(t)))}function Ud(t){var r=null,s=ft.updateQueue;if(s!==null&&(r=s.memoCache),r==null){var c=ft.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=Nc(),ft.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]=R;return r.index++,s}function Ha(t,r){return typeof r=="function"?r(t):r}function Ac(t){var r=jn();return qd(r,Qt,t)}function qd(t,r,s){var c=t.queue;if(c===null)throw Error(i(311));c.lastRenderedReducer=s;var p=t.baseQueue,g=c.pending;if(g!==null){if(p!==null){var S=p.next;p.next=g.next,g.next=S}r.baseQueue=p=g,c.pending=null}if(g=t.baseState,p===null)t.memoizedState=g;else{r=p.next;var M=S=null,X=null,ie=r,fe=!1;do{var we=ie.lane&-536870913;if(we!==ie.lane?(Dt&we)===we:(Ia&we)===we){var se=ie.revertLane;if(se===0)X!==null&&(X=X.next={lane:0,revertLane:0,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),we===Ki&&(fe=!0);else if((Ia&se)===se){ie=ie.next,se===Ki&&(fe=!0);continue}else we={lane:0,revertLane:ie.revertLane,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},X===null?(M=X=we,S=g):X=X.next=we,ft.lanes|=se,Cl|=se;we=ie.action,mi&&s(g,we),g=ie.hasEagerState?ie.eagerState:s(g,we)}else se={lane:we,revertLane:ie.revertLane,gesture:ie.gesture,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},X===null?(M=X=se,S=g):X=X.next=se,ft.lanes|=we,Cl|=we;ie=ie.next}while(ie!==null&&ie!==r);if(X===null?S=g:X.next=M,!Cr(g,t.memoizedState)&&(An=!0,fe&&(s=Qi,s!==null)))throw s;t.memoizedState=g,t.baseState=S,t.baseQueue=X,c.lastRenderedState=g}return p===null&&(c.lanes=0),[t.memoizedState,c.dispatch]}function Yd(t){var r=jn(),s=r.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=t;var c=s.dispatch,p=s.pending,g=r.memoizedState;if(p!==null){s.pending=null;var S=p=p.next;do g=t(g,S.action),S=S.next;while(S!==p);Cr(g,r.memoizedState)||(An=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),s.lastRenderedState=g}return[g,c]}function Kp(t,r,s){var c=ft,p=jn(),g=Rt;if(g){if(s===void 0)throw Error(i(407));s=s()}else s=r();var S=!Cr((Qt||p).memoizedState,s);if(S&&(p.memoizedState=s,An=!0),p=p.queue,Vd(Zp.bind(null,c,p,t),[t]),p.getSnapshot!==r||S||En!==null&&En.memoizedState.tag&1){if(c.flags|=2048,ns(9,{destroy:void 0},Pp.bind(null,c,p,s,r),null),en===null)throw Error(i(349));g||(Ia&127)!==0||Qp(c,r,s)}return s}function Qp(t,r,s){t.flags|=16384,t={getSnapshot:r,value:s},r=ft.updateQueue,r===null?(r=Nc(),ft.updateQueue=r,r.stores=[t]):(s=r.stores,s===null?r.stores=[t]:s.push(t))}function Pp(t,r,s,c){r.value=s,r.getSnapshot=c,Jp(r)&&ex(t)}function Zp(t,r,s){return s(function(){Jp(r)&&ex(t)})}function Jp(t){var r=t.getSnapshot;t=t.value;try{var s=r();return!Cr(t,s)}catch{return!0}}function ex(t){var r=li(t,2);r!==null&&yr(r,t,2)}function Xd(t){var r=lr();if(typeof t=="function"){var s=t;if(t=s(),mi){bt(!0);try{s()}finally{bt(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ha,lastRenderedState:t},r}function tx(t,r,s,c){return t.baseState=s,qd(t,Qt,typeof c=="function"?c:Ha)}function i2(t,r,s,c,p){if(Fc(t))throw Error(i(485));if(t=r.action,t!==null){var g={payload:p,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};Y.T!==null?s(!0):g.isTransition=!1,c(g),s=r.pending,s===null?(g.next=r.pending=g,nx(r,g)):(g.next=s.next,r.pending=s.next=g)}}function nx(t,r){var s=r.action,c=r.payload,p=t.state;if(r.isTransition){var g=Y.T,S={};Y.T=S;try{var M=s(p,c),X=Y.S;X!==null&&X(S,M),rx(t,r,M)}catch(ie){Wd(t,r,ie)}finally{g!==null&&S.types!==null&&(g.types=S.types),Y.T=g}}else try{g=s(p,c),rx(t,r,g)}catch(ie){Wd(t,r,ie)}}function rx(t,r,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(c){ax(t,r,c)},function(c){return Wd(t,r,c)}):ax(t,r,s)}function ax(t,r,s){r.status="fulfilled",r.value=s,lx(r),t.state=s,r=t.pending,r!==null&&(s=r.next,s===r?t.pending=null:(s=s.next,r.next=s,nx(t,s)))}function Wd(t,r,s){var c=t.pending;if(t.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=s,lx(r),r=r.next;while(r!==c)}t.action=null}function lx(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function ix(t,r){return r}function sx(t,r){if(Rt){var s=en.formState;if(s!==null){e:{var c=ft;if(Rt){if(ln){t:{for(var p=ln,g=Xr;p.nodeType!==8;){if(!g){p=null;break t}if(p=Vr(p.nextSibling),p===null){p=null;break t}}g=p.data,p=g==="F!"||g==="F"?p:null}if(p){ln=Vr(p.nextSibling),c=p.data==="F!";break e}}xl(c)}c=!1}c&&(r=s[0])}}return s=lr(),s.memoizedState=s.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ix,lastRenderedState:r},s.queue=c,s=Nx.bind(null,ft,c),c.dispatch=s,c=Xd(!1),g=Zd.bind(null,ft,!1,c.queue),c=lr(),p={state:r,dispatch:null,action:t,pending:null},c.queue=p,s=i2.bind(null,ft,p,g,s),p.dispatch=s,c.memoizedState=t,[r,s,!1]}function ox(t){var r=jn();return cx(r,Qt,t)}function cx(t,r,s){if(r=qd(t,r,ix)[0],t=Ac(Ha)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=Ks(r)}catch(S){throw S===Pi?gc:S}else c=r;r=jn();var p=r.queue,g=p.dispatch;return s!==r.memoizedState&&(ft.flags|=2048,ns(9,{destroy:void 0},s2.bind(null,p,s),null)),[c,g,t]}function s2(t,r){t.action=r}function ux(t){var r=jn(),s=Qt;if(s!==null)return cx(r,s,t);jn(),r=r.memoizedState,s=jn();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=ft.updateQueue,r===null&&(r=Nc(),ft.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 dx(){return jn().memoizedState}function Dc(t,r,s,c){var p=lr();ft.flags|=t,p.memoizedState=ns(1|r,{destroy:void 0},s,c===void 0?null:c)}function Tc(t,r,s,c){var p=jn();c=c===void 0?null:c;var g=p.memoizedState.inst;Qt!==null&&c!==null&&Od(c,Qt.memoizedState.deps)?p.memoizedState=ns(r,g,s,c):(ft.flags|=t,p.memoizedState=ns(1|r,g,s,c))}function fx(t,r){Dc(8390656,8,t,r)}function Vd(t,r){Tc(2048,8,t,r)}function o2(t){ft.flags|=4;var r=ft.updateQueue;if(r===null)r=Nc(),ft.updateQueue=r,r.events=[t];else{var s=r.events;s===null?r.events=[t]:s.push(t)}}function hx(t){var r=jn().memoizedState;return o2({ref:r,nextImpl:t}),function(){if((It&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function mx(t,r){return Tc(4,2,t,r)}function px(t,r){return Tc(4,4,t,r)}function xx(t,r){if(typeof r=="function"){t=t();var s=r(t);return function(){typeof s=="function"?s():r(null)}}if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function yx(t,r,s){s=s!=null?s.concat([t]):null,Tc(4,4,xx.bind(null,r,t),s)}function Gd(){}function gx(t,r){var s=jn();r=r===void 0?null:r;var c=s.memoizedState;return r!==null&&Od(r,c[1])?c[0]:(s.memoizedState=[t,r],t)}function bx(t,r){var s=jn();r=r===void 0?null:r;var c=s.memoizedState;if(r!==null&&Od(r,c[1]))return c[0];if(c=t(),mi){bt(!0);try{t()}finally{bt(!1)}}return s.memoizedState=[c,r],c}function Kd(t,r,s){return s===void 0||(Ia&1073741824)!==0&&(Dt&261930)===0?t.memoizedState=r:(t.memoizedState=s,t=v1(),ft.lanes|=t,Cl|=t,s)}function vx(t,r,s,c){return Cr(s,r)?s:Ji.current!==null?(t=Kd(t,s,c),Cr(t,r)||(An=!0),t):(Ia&42)===0||(Ia&1073741824)!==0&&(Dt&261930)===0?(An=!0,t.memoizedState=s):(t=v1(),ft.lanes|=t,Cl|=t,r)}function wx(t,r,s,c,p){var g=ae.p;ae.p=g!==0&&8>g?g:8;var S=Y.T,M={};Y.T=M,Zd(t,!1,r,s);try{var X=p(),ie=Y.S;if(ie!==null&&ie(M,X),X!==null&&typeof X=="object"&&typeof X.then=="function"){var fe=r2(X,c);Qs(t,r,fe,Fr(t))}else Qs(t,r,c,Fr(t))}catch(we){Qs(t,r,{then:function(){},status:"rejected",reason:we},Fr())}finally{ae.p=g,S!==null&&M.types!==null&&(S.types=M.types),Y.T=S}}function c2(){}function Qd(t,r,s,c){if(t.tag!==5)throw Error(i(476));var p=kx(t).queue;wx(t,p,r,Z,s===null?c2:function(){return jx(t),s(c)})}function kx(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ha,lastRenderedState:Z},next:null};var s={};return r.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ha,lastRenderedState:s},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function jx(t){var r=kx(t);r.next===null&&(r=t.alternate.memoizedState),Qs(t,r.next.queue,{},Fr())}function Pd(){return Vn(mo)}function Sx(){return jn().memoizedState}function Cx(){return jn().memoizedState}function u2(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=Fr();t=bl(s);var c=vl(r,t,s);c!==null&&(yr(c,r,s),Xs(c,r,s)),r={cache:Nd()},t.payload=r;return}r=r.return}}function d2(t,r,s){var c=Fr();s={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Fc(t)?Ex(r,s):(s=pd(t,r,s,c),s!==null&&(yr(s,t,c),Ax(s,r,c)))}function Nx(t,r,s){var c=Fr();Qs(t,r,s,c)}function Qs(t,r,s,c){var p={lane:c,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Fc(t))Ex(r,p);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var S=r.lastRenderedState,M=g(S,s);if(p.hasEagerState=!0,p.eagerState=M,Cr(M,S))return dc(t,r,p,0),en===null&&uc(),!1}catch{}finally{}if(s=pd(t,r,p,c),s!==null)return yr(s,t,c),Ax(s,r,c),!0}return!1}function Zd(t,r,s,c){if(c={lane:2,revertLane:Ff(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Fc(t)){if(r)throw Error(i(479))}else r=pd(t,s,c,2),r!==null&&yr(r,t,2)}function Fc(t){var r=t.alternate;return t===ft||r!==null&&r===ft}function Ex(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 Ax(t,r,s){if((s&4194048)!==0){var c=r.lanes;c&=t.pendingLanes,s|=c,r.lanes=s,cn(t,s)}}var Ps={readContext:Vn,use:Ec,useCallback:bn,useContext:bn,useEffect:bn,useImperativeHandle:bn,useLayoutEffect:bn,useInsertionEffect:bn,useMemo:bn,useReducer:bn,useRef:bn,useState:bn,useDebugValue:bn,useDeferredValue:bn,useTransition:bn,useSyncExternalStore:bn,useId:bn,useHostTransitionStatus:bn,useFormState:bn,useActionState:bn,useOptimistic:bn,useMemoCache:bn,useCacheRefresh:bn};Ps.useEffectEvent=bn;var Dx={readContext:Vn,use:Ec,useCallback:function(t,r){return lr().memoizedState=[t,r===void 0?null:r],t},useContext:Vn,useEffect:fx,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,Dc(4194308,4,xx.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=lr();r=r===void 0?null:r;var c=t();if(mi){bt(!0);try{t()}finally{bt(!1)}}return s.memoizedState=[c,r],c},useReducer:function(t,r,s){var c=lr();if(s!==void 0){var p=s(r);if(mi){bt(!0);try{s(r)}finally{bt(!1)}}}else p=r;return c.memoizedState=c.baseState=p,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:p},c.queue=t,t=t.dispatch=d2.bind(null,ft,t),[c.memoizedState,t]},useRef:function(t){var r=lr();return t={current:t},r.memoizedState=t},useState:function(t){t=Xd(t);var r=t.queue,s=Nx.bind(null,ft,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:Gd,useDeferredValue:function(t,r){var s=lr();return Kd(s,t,r)},useTransition:function(){var t=Xd(!1);return t=wx.bind(null,ft,t.queue,!0,!1),lr().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var c=ft,p=lr();if(Rt){if(s===void 0)throw Error(i(407));s=s()}else{if(s=r(),en===null)throw Error(i(349));(Dt&127)!==0||Qp(c,r,s)}p.memoizedState=s;var g={value:s,getSnapshot:r};return p.queue=g,fx(Zp.bind(null,c,g,t),[t]),c.flags|=2048,ns(9,{destroy:void 0},Pp.bind(null,c,g,s,r),null),s},useId:function(){var t=lr(),r=en.identifierPrefix;if(Rt){var s=va,c=ba;s=(c&~(1<<32-et(c)-1)).toString(32)+s,r="_"+r+"R_"+s,s=Cc++,0<s&&(r+="H"+s.toString(32)),r+="_"}else s=a2++,r="_"+r+"r_"+s.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Pd,useFormState:sx,useActionState:sx,useOptimistic:function(t){var r=lr();r.memoizedState=r.baseState=t;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=s,r=Zd.bind(null,ft,!0,s),s.dispatch=r,[t,r]},useMemoCache:Ud,useCacheRefresh:function(){return lr().memoizedState=u2.bind(null,ft)},useEffectEvent:function(t){var r=lr(),s={impl:t};return r.memoizedState=s,function(){if((It&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}},Jd={readContext:Vn,use:Ec,useCallback:gx,useContext:Vn,useEffect:Vd,useImperativeHandle:yx,useInsertionEffect:mx,useLayoutEffect:px,useMemo:bx,useReducer:Ac,useRef:dx,useState:function(){return Ac(Ha)},useDebugValue:Gd,useDeferredValue:function(t,r){var s=jn();return vx(s,Qt.memoizedState,t,r)},useTransition:function(){var t=Ac(Ha)[0],r=jn().memoizedState;return[typeof t=="boolean"?t:Ks(t),r]},useSyncExternalStore:Kp,useId:Sx,useHostTransitionStatus:Pd,useFormState:ox,useActionState:ox,useOptimistic:function(t,r){var s=jn();return tx(s,Qt,t,r)},useMemoCache:Ud,useCacheRefresh:Cx};Jd.useEffectEvent=hx;var Tx={readContext:Vn,use:Ec,useCallback:gx,useContext:Vn,useEffect:Vd,useImperativeHandle:yx,useInsertionEffect:mx,useLayoutEffect:px,useMemo:bx,useReducer:Yd,useRef:dx,useState:function(){return Yd(Ha)},useDebugValue:Gd,useDeferredValue:function(t,r){var s=jn();return Qt===null?Kd(s,t,r):vx(s,Qt.memoizedState,t,r)},useTransition:function(){var t=Yd(Ha)[0],r=jn().memoizedState;return[typeof t=="boolean"?t:Ks(t),r]},useSyncExternalStore:Kp,useId:Sx,useHostTransitionStatus:Pd,useFormState:ux,useActionState:ux,useOptimistic:function(t,r){var s=jn();return Qt!==null?tx(s,Qt,t,r):(s.baseState=t,[t,s.queue.dispatch])},useMemoCache:Ud,useCacheRefresh:Cx};Tx.useEffectEvent=hx;function ef(t,r,s,c){r=t.memoizedState,s=s(c,r),s=s==null?r:y({},r,s),t.memoizedState=s,t.lanes===0&&(t.updateQueue.baseState=s)}var tf={enqueueSetState:function(t,r,s){t=t._reactInternals;var c=Fr(),p=bl(c);p.payload=r,s!=null&&(p.callback=s),r=vl(t,p,c),r!==null&&(yr(r,t,c),Xs(r,t,c))},enqueueReplaceState:function(t,r,s){t=t._reactInternals;var c=Fr(),p=bl(c);p.tag=1,p.payload=r,s!=null&&(p.callback=s),r=vl(t,p,c),r!==null&&(yr(r,t,c),Xs(r,t,c))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var s=Fr(),c=bl(s);c.tag=2,r!=null&&(c.callback=r),r=vl(t,c,s),r!==null&&(yr(r,t,s),Xs(r,t,s))}};function Fx(t,r,s,c,p,g,S){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,g,S):r.prototype&&r.prototype.isPureReactComponent?!Os(s,c)||!Os(p,g):!0}function Mx(t,r,s,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(s,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(s,c),r.state!==t&&tf.enqueueReplaceState(r,r.state,null)}function pi(t,r){var s=r;if("ref"in r){s={};for(var c in r)c!=="ref"&&(s[c]=r[c])}if(t=t.defaultProps){s===r&&(s=y({},s));for(var p in t)s[p]===void 0&&(s[p]=t[p])}return s}function Rx(t){cc(t)}function zx(t){console.error(t)}function _x(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 Bx(t,r,s){try{var c=t.onCaughtError;c(s.value,{componentStack:s.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function nf(t,r,s){return s=bl(s),s.tag=3,s.payload={element:null},s.callback=function(){Mc(t,r)},s}function Ox(t){return t=bl(t),t.tag=3,t}function $x(t,r,s,c){var p=s.type.getDerivedStateFromError;if(typeof p=="function"){var g=c.value;t.payload=function(){return p(g)},t.callback=function(){Bx(r,s,c)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(t.callback=function(){Bx(r,s,c),typeof p!="function"&&(Nl===null?Nl=new Set([this]):Nl.add(this));var M=c.stack;this.componentDidCatch(c.value,{componentStack:M!==null?M:""})})}function f2(t,r,s,c,p){if(s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=s.alternate,r!==null&&Gi(r,s,p,!0),s=Er.current,s!==null){switch(s.tag){case 31:case 13:return Wr===null?Yc():s.alternate===null&&vn===0&&(vn=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),Af(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)),Af(t,c,p)),!1}throw Error(i(435,s.tag))}return Af(t,c,p),Yc(),!1}if(Rt)return r=Er.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,c!==wd&&(t=Error(i(422),{cause:c}),Is(Ur(t,s)))):(c!==wd&&(r=Error(i(423),{cause:c}),Is(Ur(r,s))),t=t.current.alternate,t.flags|=65536,p&=-p,t.lanes|=p,c=Ur(c,s),p=nf(t.stateNode,c,p),Md(t,p),vn!==4&&(vn=2)),!1;var g=Error(i(520),{cause:c});if(g=Ur(g,s),lo===null?lo=[g]:lo.push(g),vn!==4&&(vn=2),r===null)return!0;c=Ur(c,s),s=r;do{switch(s.tag){case 3:return s.flags|=65536,t=p&-p,s.lanes|=t,t=nf(s.stateNode,c,t),Md(s,t),!1;case 1:if(r=s.type,g=s.stateNode,(s.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Nl===null||!Nl.has(g))))return s.flags|=65536,p&=-p,s.lanes|=p,p=Ox(p),$x(p,t,s,c),Md(s,p),!1}s=s.return}while(s!==null);return!1}var rf=Error(i(461)),An=!1;function Gn(t,r,s,c){r.child=t===null?Up(r,null,s,c):hi(r,t.child,s,c)}function Lx(t,r,s,c,p){s=s.render;var g=r.ref;if("ref"in c){var S={};for(var M in c)M!=="ref"&&(S[M]=c[M])}else S=c;return ci(r),c=$d(t,r,s,S,g,p),M=Ld(),t!==null&&!An?(Id(t,r,p),Ua(t,r,p)):(Rt&&M&&bd(r),r.flags|=1,Gn(t,r,c,p),r.child)}function Ix(t,r,s,c,p){if(t===null){var g=s.type;return typeof g=="function"&&!xd(g)&&g.defaultProps===void 0&&s.compare===null?(r.tag=15,r.type=g,Hx(t,r,g,c,p)):(t=hc(s.type,null,c,r,r.mode,p),t.ref=r.ref,t.return=r,r.child=t)}if(g=t.child,!ff(t,p)){var S=g.memoizedProps;if(s=s.compare,s=s!==null?s:Os,s(S,c)&&t.ref===r.ref)return Ua(t,r,p)}return r.flags|=1,t=Ba(g,c),t.ref=r.ref,t.return=r,r.child=t}function Hx(t,r,s,c,p){if(t!==null){var g=t.memoizedProps;if(Os(g,c)&&t.ref===r.ref)if(An=!1,r.pendingProps=c=g,ff(t,p))(t.flags&131072)!==0&&(An=!0);else return r.lanes=t.lanes,Ua(t,r,p)}return af(t,r,s,c,p)}function Ux(t,r,s,c){var p=c.children,g=t!==null?t.memoizedState:null;if(t===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((r.flags&128)!==0){if(g=g!==null?g.baseLanes|s:s,t!==null){for(c=r.child=t.child,p=0;c!==null;)p=p|c.lanes|c.childLanes,c=c.sibling;c=p&~g}else c=0,r.child=null;return qx(t,r,g,s,c)}if((s&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&yc(r,g!==null?g.cachePool:null),g!==null?Xp(r,g):zd(),Wp(r);else return c=r.lanes=536870912,qx(t,r,g!==null?g.baseLanes|s:s,s,c)}else g!==null?(yc(r,g.cachePool),Xp(r,g),kl(),r.memoizedState=null):(t!==null&&yc(r,null),zd(),kl());return Gn(t,r,p,s),r.child}function Zs(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function qx(t,r,s,c,p){var g=Ad();return g=g===null?null:{parent:Nn._currentValue,pool:g},r.memoizedState={baseLanes:s,cachePool:g},t!==null&&yc(r,null),zd(),Wp(r),t!==null&&Gi(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 Yx(t,r,s){return hi(r,t.child,null,s),t=Rc(r,r.pendingProps),t.flags|=2,Ar(r),r.memoizedState=null,t}function h2(t,r,s){var c=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,t===null){if(Rt){if(c.mode==="hidden")return t=Rc(r,c),r.lanes=536870912,Zs(null,t);if(Bd(r),(t=ln)?(t=n0(t,Xr),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:ml!==null?{id:ba,overflow:va}:null,retryLane:536870912,hydrationErrors:null},s=Ep(t),s.return=r,r.child=s,Wn=r,ln=null)):t=null,t===null)throw xl(r);return r.lanes=536870912,null}return Rc(r,c)}var g=t.memoizedState;if(g!==null){var S=g.dehydrated;if(Bd(r),p)if(r.flags&256)r.flags&=-257,r=Yx(t,r,s);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(An||Gi(t,r,s,!1),p=(s&t.childLanes)!==0,An||p){if(c=en,c!==null&&(S=ua(c,s),S!==0&&S!==g.retryLane))throw g.retryLane=S,li(t,S),yr(c,t,S),rf;Yc(),r=Yx(t,r,s)}else t=g.treeContext,ln=Vr(S.nextSibling),Wn=r,Rt=!0,pl=null,Xr=!1,t!==null&&Tp(r,t),r=Rc(r,c),r.flags|=4096;return r}return t=Ba(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 af(t,r,s,c,p){return ci(r),s=$d(t,r,s,c,void 0,p),c=Ld(),t!==null&&!An?(Id(t,r,p),Ua(t,r,p)):(Rt&&c&&bd(r),r.flags|=1,Gn(t,r,s,p),r.child)}function Xx(t,r,s,c,p,g){return ci(r),r.updateQueue=null,s=Gp(r,c,s,p),Vp(t),c=Ld(),t!==null&&!An?(Id(t,r,g),Ua(t,r,g)):(Rt&&c&&bd(r),r.flags|=1,Gn(t,r,s,g),r.child)}function Wx(t,r,s,c,p){if(ci(r),r.stateNode===null){var g=Yi,S=s.contextType;typeof S=="object"&&S!==null&&(g=Vn(S)),g=new s(c,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=tf,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=c,g.state=r.memoizedState,g.refs={},Td(r),S=s.contextType,g.context=typeof S=="object"&&S!==null?Vn(S):Yi,g.state=r.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(ef(r,s,S,c),g.state=r.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(S=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),S!==g.state&&tf.enqueueReplaceState(g,g.state,null),Vs(r,c,g,p),Ws(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(t===null){g=r.stateNode;var M=r.memoizedProps,X=pi(s,M);g.props=X;var ie=g.context,fe=s.contextType;S=Yi,typeof fe=="object"&&fe!==null&&(S=Vn(fe));var we=s.getDerivedStateFromProps;fe=typeof we=="function"||typeof g.getSnapshotBeforeUpdate=="function",M=r.pendingProps!==M,fe||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(M||ie!==S)&&Mx(r,g,c,S),gl=!1;var se=r.memoizedState;g.state=se,Vs(r,c,g,p),Ws(),ie=r.memoizedState,M||se!==ie||gl?(typeof we=="function"&&(ef(r,s,we,c),ie=r.memoizedState),(X=gl||Fx(r,s,X,c,se,ie,S))?(fe||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=ie),g.props=c,g.state=ie,g.context=S,c=X):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{g=r.stateNode,Fd(t,r),S=r.memoizedProps,fe=pi(s,S),g.props=fe,we=r.pendingProps,se=g.context,ie=s.contextType,X=Yi,typeof ie=="object"&&ie!==null&&(X=Vn(ie)),M=s.getDerivedStateFromProps,(ie=typeof M=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==we||se!==X)&&Mx(r,g,c,X),gl=!1,se=r.memoizedState,g.state=se,Vs(r,c,g,p),Ws();var ce=r.memoizedState;S!==we||se!==ce||gl||t!==null&&t.dependencies!==null&&pc(t.dependencies)?(typeof M=="function"&&(ef(r,s,M,c),ce=r.memoizedState),(fe=gl||Fx(r,s,fe,c,se,ce,X)||t!==null&&t.dependencies!==null&&pc(t.dependencies))?(ie||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,ce,X),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,ce,X)),typeof g.componentDidUpdate=="function"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===t.memoizedProps&&se===t.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&se===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=ce),g.props=c,g.state=ce,g.context=X,c=fe):(typeof g.componentDidUpdate!="function"||S===t.memoizedProps&&se===t.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===t.memoizedProps&&se===t.memoizedState||(r.flags|=1024),c=!1)}return g=c,zc(t,r),c=(r.flags&128)!==0,g||c?(g=r.stateNode,s=c&&typeof s.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,t!==null&&c?(r.child=hi(r,t.child,null,p),r.child=hi(r,null,s,p)):Gn(t,r,s,p),r.memoizedState=g.state,t=r.child):t=Ua(t,r,p),t}function Vx(t,r,s,c){return si(),r.flags|=256,Gn(t,r,s,c),r.child}var lf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function sf(t){return{baseLanes:t,cachePool:Bp()}}function of(t,r,s){return t=t!==null?t.childLanes&~s:0,r&&(t|=Tr),t}function Gx(t,r,s){var c=r.pendingProps,p=!1,g=(r.flags&128)!==0,S;if((S=g)||(S=t!==null&&t.memoizedState===null?!1:(kn.current&2)!==0),S&&(p=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,t===null){if(Rt){if(p?wl(r):kl(),(t=ln)?(t=n0(t,Xr),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:ml!==null?{id:ba,overflow:va}:null,retryLane:536870912,hydrationErrors:null},s=Ep(t),s.return=r,r.child=s,Wn=r,ln=null)):t=null,t===null)throw xl(r);return Yf(t)?r.lanes=32:r.lanes=536870912,null}var M=c.children;return c=c.fallback,p?(kl(),p=r.mode,M=_c({mode:"hidden",children:M},p),c=ii(c,p,s,null),M.return=r,c.return=r,M.sibling=c,r.child=M,c=r.child,c.memoizedState=sf(s),c.childLanes=of(t,S,s),r.memoizedState=lf,Zs(null,c)):(wl(r),cf(r,M))}var X=t.memoizedState;if(X!==null&&(M=X.dehydrated,M!==null)){if(g)r.flags&256?(wl(r),r.flags&=-257,r=uf(t,r,s)):r.memoizedState!==null?(kl(),r.child=t.child,r.flags|=128,r=null):(kl(),M=c.fallback,p=r.mode,c=_c({mode:"visible",children:c.children},p),M=ii(M,p,s,null),M.flags|=2,c.return=r,M.return=r,c.sibling=M,r.child=c,hi(r,t.child,null,s),c=r.child,c.memoizedState=sf(s),c.childLanes=of(t,S,s),r.memoizedState=lf,r=Zs(null,c));else if(wl(r),Yf(M)){if(S=M.nextSibling&&M.nextSibling.dataset,S)var ie=S.dgst;S=ie,c=Error(i(419)),c.stack="",c.digest=S,Is({value:c,source:null,stack:null}),r=uf(t,r,s)}else if(An||Gi(t,r,s,!1),S=(s&t.childLanes)!==0,An||S){if(S=en,S!==null&&(c=ua(S,s),c!==0&&c!==X.retryLane))throw X.retryLane=c,li(t,c),yr(S,t,c),rf;qf(M)||Yc(),r=uf(t,r,s)}else qf(M)?(r.flags|=192,r.child=t.child,r=null):(t=X.treeContext,ln=Vr(M.nextSibling),Wn=r,Rt=!0,pl=null,Xr=!1,t!==null&&Tp(r,t),r=cf(r,c.children),r.flags|=4096);return r}return p?(kl(),M=c.fallback,p=r.mode,X=t.child,ie=X.sibling,c=Ba(X,{mode:"hidden",children:c.children}),c.subtreeFlags=X.subtreeFlags&65011712,ie!==null?M=Ba(ie,M):(M=ii(M,p,s,null),M.flags|=2),M.return=r,c.return=r,c.sibling=M,r.child=c,Zs(null,c),c=r.child,M=t.child.memoizedState,M===null?M=sf(s):(p=M.cachePool,p!==null?(X=Nn._currentValue,p=p.parent!==X?{parent:X,pool:X}:p):p=Bp(),M={baseLanes:M.baseLanes|s,cachePool:p}),c.memoizedState=M,c.childLanes=of(t,S,s),r.memoizedState=lf,Zs(t.child,c)):(wl(r),s=t.child,t=s.sibling,s=Ba(s,{mode:"visible",children:c.children}),s.return=r,s.sibling=null,t!==null&&(S=r.deletions,S===null?(r.deletions=[t],r.flags|=16):S.push(t)),r.child=s,r.memoizedState=null,s)}function cf(t,r){return r=_c({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function _c(t,r){return t=Nr(22,t,null,r),t.lanes=0,t}function uf(t,r,s){return hi(r,t.child,null,s),t=cf(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Kx(t,r,s){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Sd(t.return,r,s)}function df(t,r,s,c,p,g){var S=t.memoizedState;S===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:s,tailMode:p,treeForkCount:g}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=c,S.tail=s,S.tailMode=p,S.treeForkCount=g)}function Qx(t,r,s){var c=r.pendingProps,p=c.revealOrder,g=c.tail;c=c.children;var S=kn.current,M=(S&2)!==0;if(M?(S=S&1|2,r.flags|=128):S&=1,D(kn,S),Gn(t,r,c,s),c=Rt?Ls:0,!M&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Kx(t,s,r);else if(t.tag===19)Kx(t,s,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(p){case"forwards":for(s=r.child,p=null;s!==null;)t=s.alternate,t!==null&&jc(t)===null&&(p=s),s=s.sibling;s=p,s===null?(p=r.child,r.child=null):(p=s.sibling,s.sibling=null),df(r,!1,p,s,g,c);break;case"backwards":case"unstable_legacy-backwards":for(s=null,p=r.child,r.child=null;p!==null;){if(t=p.alternate,t!==null&&jc(t)===null){r.child=p;break}t=p.sibling,p.sibling=s,s=p,p=t}df(r,!0,s,null,g,c);break;case"together":df(r,!1,null,null,void 0,c);break;default:r.memoizedState=null}return r.child}function Ua(t,r,s){if(t!==null&&(r.dependencies=t.dependencies),Cl|=r.lanes,(s&r.childLanes)===0)if(t!==null){if(Gi(t,r,s,!1),(s&r.childLanes)===0)return null}else return null;if(t!==null&&r.child!==t.child)throw Error(i(153));if(r.child!==null){for(t=r.child,s=Ba(t,t.pendingProps),r.child=s,s.return=r;t.sibling!==null;)t=t.sibling,s=s.sibling=Ba(t,t.pendingProps),s.return=r;s.sibling=null}return r.child}function ff(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&pc(t)))}function m2(t,r,s){switch(r.tag){case 3:Xe(r,r.stateNode.containerInfo),yl(r,Nn,t.memoizedState.cache),si();break;case 27:case 5:Oe(r);break;case 4:Xe(r,r.stateNode.containerInfo);break;case 10:yl(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Bd(r),null;break;case 13:var c=r.memoizedState;if(c!==null)return c.dehydrated!==null?(wl(r),r.flags|=128,null):(s&r.child.childLanes)!==0?Gx(t,r,s):(wl(r),t=Ua(t,r,s),t!==null?t.sibling:null);wl(r);break;case 19:var p=(t.flags&128)!==0;if(c=(s&r.childLanes)!==0,c||(Gi(t,r,s,!1),c=(s&r.childLanes)!==0),p){if(c)return Qx(t,r,s);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),D(kn,kn.current),c)break;return null;case 22:return r.lanes=0,Ux(t,r,s,r.pendingProps);case 24:yl(r,Nn,t.memoizedState.cache)}return Ua(t,r,s)}function Px(t,r,s){if(t!==null)if(t.memoizedProps!==r.pendingProps)An=!0;else{if(!ff(t,s)&&(r.flags&128)===0)return An=!1,m2(t,r,s);An=(t.flags&131072)!==0}else An=!1,Rt&&(r.flags&1048576)!==0&&Dp(r,Ls,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(t=di(r.elementType),r.type=t,typeof t=="function")xd(t)?(c=pi(t,c),r.tag=1,r=Wx(null,r,t,c,s)):(r.tag=0,r=af(null,r,t,c,s));else{if(t!=null){var p=t.$$typeof;if(p===z){r.tag=11,r=Lx(null,r,t,c,s);break e}else if(p===$){r.tag=14,r=Ix(null,r,t,c,s);break e}}throw r=oe(t)||t,Error(i(306,r,""))}}return r;case 0:return af(t,r,r.type,r.pendingProps,s);case 1:return c=r.type,p=pi(c,r.pendingProps),Wx(t,r,c,p,s);case 3:e:{if(Xe(r,r.stateNode.containerInfo),t===null)throw Error(i(387));c=r.pendingProps;var g=r.memoizedState;p=g.element,Fd(t,r),Vs(r,c,null,s);var S=r.memoizedState;if(c=S.cache,yl(r,Nn,c),c!==g.cache&&Cd(r,[Nn],s,!0),Ws(),c=S.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=Vx(t,r,c,s);break e}else if(c!==p){p=Ur(Error(i(424)),r),Is(p),r=Vx(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(ln=Vr(t.firstChild),Wn=r,Rt=!0,pl=null,Xr=!0,s=Up(r,null,c,s),r.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling}else{if(si(),c===p){r=Ua(t,r,s);break e}Gn(t,r,c,s)}r=r.child}return r;case 26:return zc(t,r),t===null?(s=o0(r.type,null,r.pendingProps,null))?r.memoizedState=s:Rt||(s=r.type,t=r.pendingProps,c=Pc(ve.current).createElement(s),c[Rn]=r,c[Ln]=t,Kn(c,s,t),yn(c),r.stateNode=c):r.memoizedState=o0(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return Oe(r),t===null&&Rt&&(c=r.stateNode=l0(r.type,r.pendingProps,ve.current),Wn=r,Xr=!0,p=ln,Tl(r.type)?(Xf=p,ln=Vr(c.firstChild)):ln=p),Gn(t,r,r.pendingProps.children,s),zc(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&Rt&&((p=c=ln)&&(c=Y2(c,r.type,r.pendingProps,Xr),c!==null?(r.stateNode=c,Wn=r,ln=Vr(c.firstChild),Xr=!1,p=!0):p=!1),p||xl(r)),Oe(r),p=r.type,g=r.pendingProps,S=t!==null?t.memoizedProps:null,c=g.children,If(p,g)?c=null:S!==null&&If(p,S)&&(r.flags|=32),r.memoizedState!==null&&(p=$d(t,r,l2,null,null,s),mo._currentValue=p),zc(t,r),Gn(t,r,c,s),r.child;case 6:return t===null&&Rt&&((t=s=ln)&&(s=X2(s,r.pendingProps,Xr),s!==null?(r.stateNode=s,Wn=r,ln=null,t=!0):t=!1),t||xl(r)),null;case 13:return Gx(t,r,s);case 4:return Xe(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=hi(r,null,c,s):Gn(t,r,c,s),r.child;case 11:return Lx(t,r,r.type,r.pendingProps,s);case 7:return Gn(t,r,r.pendingProps,s),r.child;case 8:return Gn(t,r,r.pendingProps.children,s),r.child;case 12:return Gn(t,r,r.pendingProps.children,s),r.child;case 10:return c=r.pendingProps,yl(r,r.type,c.value),Gn(t,r,c.children,s),r.child;case 9:return p=r.type._context,c=r.pendingProps.children,ci(r),p=Vn(p),c=c(p),r.flags|=1,Gn(t,r,c,s),r.child;case 14:return Ix(t,r,r.type,r.pendingProps,s);case 15:return Hx(t,r,r.type,r.pendingProps,s);case 19:return Qx(t,r,s);case 31:return h2(t,r,s);case 22:return Ux(t,r,s,r.pendingProps);case 24:return ci(r),c=Vn(Nn),t===null?(p=Ad(),p===null&&(p=en,g=Nd(),p.pooledCache=g,g.refCount++,g!==null&&(p.pooledCacheLanes|=s),p=g),r.memoizedState={parent:c,cache:p},Td(r),yl(r,Nn,p)):((t.lanes&s)!==0&&(Fd(t,r),Vs(r,null,null,s),Ws()),p=t.memoizedState,g=r.memoizedState,p.parent!==c?(p={parent:c,cache:c},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),yl(r,Nn,c)):(c=g.cache,yl(r,Nn,c),c!==p.cache&&Cd(r,[Nn],s,!0))),Gn(t,r,r.pendingProps.children,s),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function qa(t){t.flags|=4}function hf(t,r,s,c,p){if((r=(t.mode&32)!==0)&&(r=!1),r){if(t.flags|=16777216,(p&335544128)===p)if(t.stateNode.complete)t.flags|=8192;else if(S1())t.flags|=8192;else throw fi=bc,Dd}else t.flags&=-16777217}function Zx(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!h0(r))if(S1())t.flags|=8192;else throw fi=bc,Dd}function Bc(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?ot():536870912,t.lanes|=r,is|=r)}function Js(t,r){if(!Rt)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 sn(t){var r=t.alternate!==null&&t.alternate.child===t.child,s=0,c=0;if(r)for(var p=t.child;p!==null;)s|=p.lanes|p.childLanes,c|=p.subtreeFlags&65011712,c|=p.flags&65011712,p.return=t,p=p.sibling;else for(p=t.child;p!==null;)s|=p.lanes|p.childLanes,c|=p.subtreeFlags,c|=p.flags,p.return=t,p=p.sibling;return t.subtreeFlags|=c,t.childLanes=s,r}function p2(t,r,s){var c=r.pendingProps;switch(vd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return sn(r),null;case 1:return sn(r),null;case 3:return s=r.stateNode,c=null,t!==null&&(c=t.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),La(Nn),de(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(Vi(r)?qa(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,kd())),sn(r),null;case 26:var p=r.type,g=r.memoizedState;return t===null?(qa(r),g!==null?(sn(r),Zx(r,g)):(sn(r),hf(r,p,null,c,s))):g?g!==t.memoizedState?(qa(r),sn(r),Zx(r,g)):(sn(r),r.flags&=-16777217):(t=t.memoizedProps,t!==c&&qa(r),sn(r),hf(r,p,t,c,s)),null;case 27:if(Qe(r),s=ve.current,p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&qa(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return sn(r),null}t=te.current,Vi(r)?Fp(r):(t=l0(p,c,s),r.stateNode=t,qa(r))}return sn(r),null;case 5:if(Qe(r),p=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==c&&qa(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return sn(r),null}if(g=te.current,Vi(r))Fp(r);else{var S=Pc(ve.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof c.is=="string"?S.createElement("select",{is:c.is}):S.createElement("select"),c.multiple?g.multiple=!0:c.size&&(g.size=c.size);break;default:g=typeof c.is=="string"?S.createElement(p,{is:c.is}):S.createElement(p)}}g[Rn]=r,g[Ln]=c;e:for(S=r.child;S!==null;){if(S.tag===5||S.tag===6)g.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===r)break e;for(;S.sibling===null;){if(S.return===null||S.return===r)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}r.stateNode=g;e:switch(Kn(g,p,c),p){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&qa(r)}}return sn(r),hf(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==c&&qa(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(i(166));if(t=ve.current,Vi(r)){if(t=r.stateNode,s=r.memoizedProps,c=null,p=Wn,p!==null)switch(p.tag){case 27:case 5:c=p.memoizedProps}t[Rn]=r,t=!!(t.nodeValue===s||c!==null&&c.suppressHydrationWarning===!0||G1(t.nodeValue,s)),t||xl(r,!0)}else t=Pc(t).createTextNode(c),t[Rn]=r,r.stateNode=t}return sn(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(c=Vi(r),s!==null){if(t===null){if(!c)throw Error(i(318));if(t=r.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(557));t[Rn]=r}else si(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;sn(r),t=!1}else s=kd(),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 sn(r),null;case 13:if(c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=Vi(r),c!==null&&c.dehydrated!==null){if(t===null){if(!p)throw Error(i(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[Rn]=r}else si(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;sn(r),p=!1}else p=kd(),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),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==p&&(c.flags|=2048)),s!==t&&s&&(r.child.flags|=8192),Bc(r,r.updateQueue),sn(r),null);case 4:return de(),t===null&&_f(r.stateNode.containerInfo),sn(r),null;case 10:return La(r.type),sn(r),null;case 19:if(W(kn),c=r.memoizedState,c===null)return sn(r),null;if(p=(r.flags&128)!==0,g=c.rendering,g===null)if(p)Js(c,!1);else{if(vn!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(g=jc(t),g!==null){for(r.flags|=128,Js(c,!1),t=g.updateQueue,r.updateQueue=t,Bc(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)Np(s,t),s=s.sibling;return D(kn,kn.current&1|2),Rt&&Oa(r,c.treeForkCount),r.child}t=t.sibling}c.tail!==null&&Le()>Hc&&(r.flags|=128,p=!0,Js(c,!1),r.lanes=4194304)}else{if(!p)if(t=jc(g),t!==null){if(r.flags|=128,p=!0,t=t.updateQueue,r.updateQueue=t,Bc(r,t),Js(c,!0),c.tail===null&&c.tailMode==="hidden"&&!g.alternate&&!Rt)return sn(r),null}else 2*Le()-c.renderingStartTime>Hc&&s!==536870912&&(r.flags|=128,p=!0,Js(c,!1),r.lanes=4194304);c.isBackwards?(g.sibling=r.child,r.child=g):(t=c.last,t!==null?t.sibling=g:r.child=g,c.last=g)}return c.tail!==null?(t=c.tail,c.rendering=t,c.tail=t.sibling,c.renderingStartTime=Le(),t.sibling=null,s=kn.current,D(kn,p?s&1|2:s&1),Rt&&Oa(r,c.treeForkCount),t):(sn(r),null);case 22:case 23:return Ar(r),_d(),c=r.memoizedState!==null,t!==null?t.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(s&536870912)!==0&&(r.flags&128)===0&&(sn(r),r.subtreeFlags&6&&(r.flags|=8192)):sn(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&&W(ui),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),La(Nn),sn(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function x2(t,r){switch(vd(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return La(Nn),de(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return Qe(r),null;case 31:if(r.memoizedState!==null){if(Ar(r),r.alternate===null)throw Error(i(340));si()}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));si()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return W(kn),null;case 4:return de(),null;case 10:return La(r.type),null;case 22:case 23:return Ar(r),_d(),t!==null&&W(ui),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return La(Nn),null;case 25:return null;default:return null}}function Jx(t,r){switch(vd(r),r.tag){case 3:La(Nn),de();break;case 26:case 27:case 5:Qe(r);break;case 4:de();break;case 31:r.memoizedState!==null&&Ar(r);break;case 13:Ar(r);break;case 19:W(kn);break;case 10:La(r.type);break;case 22:case 23:Ar(r),_d(),t!==null&&W(ui);break;case 24:La(Nn)}}function eo(t,r){try{var s=r.updateQueue,c=s!==null?s.lastEffect:null;if(c!==null){var p=c.next;s=p;do{if((s.tag&t)===t){c=void 0;var g=s.create,S=s.inst;c=g(),S.destroy=c}s=s.next}while(s!==p)}}catch(M){Wt(r,r.return,M)}}function jl(t,r,s){try{var c=r.updateQueue,p=c!==null?c.lastEffect:null;if(p!==null){var g=p.next;c=g;do{if((c.tag&t)===t){var S=c.inst,M=S.destroy;if(M!==void 0){S.destroy=void 0,p=r;var X=s,ie=M;try{ie()}catch(fe){Wt(p,X,fe)}}}c=c.next}while(c!==g)}}catch(fe){Wt(r,r.return,fe)}}function e1(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{Yp(r,s)}catch(c){Wt(t,t.return,c)}}}function t1(t,r,s){s.props=pi(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(c){Wt(t,r,c)}}function to(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){Wt(t,r,p)}}function wa(t,r){var s=t.ref,c=t.refCleanup;if(s!==null)if(typeof c=="function")try{c()}catch(p){Wt(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){Wt(t,r,p)}else s.current=null}function n1(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){Wt(t,t.return,p)}}function mf(t,r,s){try{var c=t.stateNode;$2(c,t.type,s,r),c[Ln]=r}catch(p){Wt(t,t.return,p)}}function r1(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Tl(t.type)||t.tag===4}function pf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||r1(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Tl(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function xf(t,r,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(t,r):(r=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,r.appendChild(t),s=s._reactRootContainer,s!=null||r.onclick!==null||(r.onclick=Xn));else if(c!==4&&(c===27&&Tl(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(xf(t,r,s),t=t.sibling;t!==null;)xf(t,r,s),t=t.sibling}function 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&&Tl(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 a1(t){var r=t.stateNode,s=t.memoizedProps;try{for(var c=t.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);Kn(r,c,s),r[Rn]=t,r[Ln]=s}catch(g){Wt(t,t.return,g)}}var Ya=!1,Dn=!1,yf=!1,l1=typeof WeakSet=="function"?WeakSet:Set,Un=null;function y2(t,r){if(t=t.containerInfo,$f=au,t=yp(t),cd(t)){if("selectionStart"in t)var s={start:t.selectionStart,end:t.selectionEnd};else e:{s=(s=t.ownerDocument)&&s.defaultView||window;var c=s.getSelection&&s.getSelection();if(c&&c.rangeCount!==0){s=c.anchorNode;var p=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{s.nodeType,g.nodeType}catch{s=null;break e}var S=0,M=-1,X=-1,ie=0,fe=0,we=t,se=null;t:for(;;){for(var ce;we!==s||p!==0&&we.nodeType!==3||(M=S+p),we!==g||c!==0&&we.nodeType!==3||(X=S+c),we.nodeType===3&&(S+=we.nodeValue.length),(ce=we.firstChild)!==null;)se=we,we=ce;for(;;){if(we===t)break t;if(se===s&&++ie===p&&(M=S),se===g&&++fe===c&&(X=S),(ce=we.nextSibling)!==null)break;we=se,se=we.parentNode}we=ce}s=M===-1||X===-1?null:{start:M,end:X}}else s=null}s=s||{start:0,end:0}}else s=null;for(Lf={focusedElem:t,selectionRange:s},au=!1,Un=r;Un!==null;)if(r=Un,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,Un=t;else for(;Un!==null;){switch(r=Un,g=r.alternate,t=r.flags,r.tag){case 0:if((t&4)!==0&&(t=r.updateQueue,t=t!==null?t.events:null,t!==null))for(s=0;s<t.length;s++)p=t[s],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&g!==null){t=void 0,s=r,p=g.memoizedProps,g=g.memoizedState,c=s.stateNode;try{var He=pi(s.type,p);t=c.getSnapshotBeforeUpdate(He,g),c.__reactInternalSnapshotBeforeUpdate=t}catch(tt){Wt(s,s.return,tt)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,s=t.nodeType,s===9)Uf(t);else if(s===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Uf(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(i(163))}if(t=r.sibling,t!==null){t.return=r.return,Un=t;break}Un=r.return}}function i1(t,r,s){var c=s.flags;switch(s.tag){case 0:case 11:case 15:Wa(t,s),c&4&&eo(5,s);break;case 1:if(Wa(t,s),c&4)if(t=s.stateNode,r===null)try{t.componentDidMount()}catch(S){Wt(s,s.return,S)}else{var p=pi(s.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(p,r,t.__reactInternalSnapshotBeforeUpdate)}catch(S){Wt(s,s.return,S)}}c&64&&e1(s),c&512&&to(s,s.return);break;case 3:if(Wa(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{Yp(t,r)}catch(S){Wt(s,s.return,S)}}break;case 27:r===null&&c&4&&a1(s);case 26:case 5:Wa(t,s),r===null&&c&4&&n1(s),c&512&&to(s,s.return);break;case 12:Wa(t,s);break;case 31:Wa(t,s),c&4&&c1(t,s);break;case 13:Wa(t,s),c&4&&u1(t,s),c&64&&(t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(s=N2.bind(null,s),W2(t,s))));break;case 22:if(c=s.memoizedState!==null||Ya,!c){r=r!==null&&r.memoizedState!==null||Dn,p=Ya;var g=Dn;Ya=c,(Dn=r)&&!g?Va(t,s,(s.subtreeFlags&8772)!==0):Wa(t,s),Ya=p,Dn=g}break;case 30:break;default:Wa(t,s)}}function s1(t){var r=t.alternate;r!==null&&(t.alternate=null,s1(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&Fi(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 un=null,hr=!1;function Xa(t,r,s){for(s=s.child;s!==null;)o1(t,r,s),s=s.sibling}function o1(t,r,s){if(ht&&typeof ht.onCommitFiberUnmount=="function")try{ht.onCommitFiberUnmount(dt,s)}catch{}switch(s.tag){case 26:Dn||wa(s,r),Xa(t,r,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:Dn||wa(s,r);var c=un,p=hr;Tl(s.type)&&(un=s.stateNode,hr=!1),Xa(t,r,s),uo(s.stateNode),un=c,hr=p;break;case 5:Dn||wa(s,r);case 6:if(c=un,p=hr,un=null,Xa(t,r,s),un=c,hr=p,un!==null)if(hr)try{(un.nodeType===9?un.body:un.nodeName==="HTML"?un.ownerDocument.body:un).removeChild(s.stateNode)}catch(g){Wt(s,r,g)}else try{un.removeChild(s.stateNode)}catch(g){Wt(s,r,g)}break;case 18:un!==null&&(hr?(t=un,e0(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,s.stateNode),ms(t)):e0(un,s.stateNode));break;case 4:c=un,p=hr,un=s.stateNode.containerInfo,hr=!0,Xa(t,r,s),un=c,hr=p;break;case 0:case 11:case 14:case 15:jl(2,s,r),Dn||jl(4,s,r),Xa(t,r,s);break;case 1:Dn||(wa(s,r),c=s.stateNode,typeof c.componentWillUnmount=="function"&&t1(s,r,c)),Xa(t,r,s);break;case 21:Xa(t,r,s);break;case 22:Dn=(c=Dn)||s.memoizedState!==null,Xa(t,r,s),Dn=c;break;default:Xa(t,r,s)}}function c1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{ms(t)}catch(s){Wt(r,r.return,s)}}}function u1(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{ms(t)}catch(s){Wt(r,r.return,s)}}function g2(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new l1),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new l1),r;default:throw Error(i(435,t.tag))}}function $c(t,r){var s=g2(t);r.forEach(function(c){if(!s.has(c)){s.add(c);var p=E2.bind(null,t,c);c.then(p,p)}})}function mr(t,r){var s=r.deletions;if(s!==null)for(var c=0;c<s.length;c++){var p=s[c],g=t,S=r,M=S;e:for(;M!==null;){switch(M.tag){case 27:if(Tl(M.type)){un=M.stateNode,hr=!1;break e}break;case 5:un=M.stateNode,hr=!1;break e;case 3:case 4:un=M.stateNode.containerInfo,hr=!0;break e}M=M.return}if(un===null)throw Error(i(160));o1(g,S,p),un=null,hr=!1,g=p.alternate,g!==null&&(g.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)d1(r,t),r=r.sibling}var aa=null;function d1(t,r){var s=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:mr(r,t),pr(t),c&4&&(jl(3,t,t.return),eo(3,t),jl(5,t,t.return));break;case 1:mr(r,t),pr(t),c&512&&(Dn||s===null||wa(s,s.return)),c&64&&Ya&&(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(mr(r,t),pr(t),c&512&&(Dn||s===null||wa(s,s.return)),c&4){var g=s!==null?s.memoizedState:null;if(c=t.memoizedState,s===null)if(c===null)if(t.stateNode===null){e:{c=t.type,s=t.memoizedProps,p=p.ownerDocument||p;t:switch(c){case"title":g=p.getElementsByTagName("title")[0],(!g||g[Fa]||g[Rn]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=p.createElement(c),p.head.insertBefore(g,p.querySelector("head > title"))),Kn(g,c,s),g[Rn]=t,yn(g),c=g;break e;case"link":var S=d0("link","href",p).get(c+(s.href||""));if(S){for(var M=0;M<S.length;M++)if(g=S[M],g.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&g.getAttribute("rel")===(s.rel==null?null:s.rel)&&g.getAttribute("title")===(s.title==null?null:s.title)&&g.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(M,1);break t}}g=p.createElement(c),Kn(g,c,s),p.head.appendChild(g);break;case"meta":if(S=d0("meta","content",p).get(c+(s.content||""))){for(M=0;M<S.length;M++)if(g=S[M],g.getAttribute("content")===(s.content==null?null:""+s.content)&&g.getAttribute("name")===(s.name==null?null:s.name)&&g.getAttribute("property")===(s.property==null?null:s.property)&&g.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&g.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(M,1);break t}}g=p.createElement(c),Kn(g,c,s),p.head.appendChild(g);break;default:throw Error(i(468,c))}g[Rn]=t,yn(g),c=g}t.stateNode=c}else f0(p,t.type,t.stateNode);else t.stateNode=u0(p,c,t.memoizedProps);else g!==c?(g===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):g.count--,c===null?f0(p,t.type,t.stateNode):u0(p,c,t.memoizedProps)):c===null&&t.stateNode!==null&&mf(t,t.memoizedProps,s.memoizedProps)}break;case 27:mr(r,t),pr(t),c&512&&(Dn||s===null||wa(s,s.return)),s!==null&&c&4&&mf(t,t.memoizedProps,s.memoizedProps);break;case 5:if(mr(r,t),pr(t),c&512&&(Dn||s===null||wa(s,s.return)),t.flags&32){p=t.stateNode;try{Ut(p,"")}catch(He){Wt(t,t.return,He)}}c&4&&t.stateNode!=null&&(p=t.memoizedProps,mf(t,p,s!==null?s.memoizedProps:p)),c&1024&&(yf=!0);break;case 6:if(mr(r,t),pr(t),c&4){if(t.stateNode===null)throw Error(i(162));c=t.memoizedProps,s=t.stateNode;try{s.nodeValue=c}catch(He){Wt(t,t.return,He)}}break;case 3:if(eu=null,p=aa,aa=Zc(r.containerInfo),mr(r,t),aa=p,pr(t),c&4&&s!==null&&s.memoizedState.isDehydrated)try{ms(r.containerInfo)}catch(He){Wt(t,t.return,He)}yf&&(yf=!1,f1(t));break;case 4:c=aa,aa=Zc(t.stateNode.containerInfo),mr(r,t),pr(t),aa=c;break;case 12:mr(r,t),pr(t);break;case 31:mr(r,t),pr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,$c(t,c)));break;case 13:mr(r,t),pr(t),t.child.flags&8192&&t.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Ic=Le()),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,$c(t,c)));break;case 22:p=t.memoizedState!==null;var X=s!==null&&s.memoizedState!==null,ie=Ya,fe=Dn;if(Ya=ie||p,Dn=fe||X,mr(r,t),Dn=fe,Ya=ie,pr(t),c&8192)e:for(r=t.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(s===null||X||Ya||Dn||xi(t)),s=null,r=t;;){if(r.tag===5||r.tag===26){if(s===null){X=s=r;try{if(g=X.stateNode,p)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{M=X.stateNode;var we=X.memoizedProps.style,se=we!=null&&we.hasOwnProperty("display")?we.display:null;M.style.display=se==null||typeof se=="boolean"?"":(""+se).trim()}}catch(He){Wt(X,X.return,He)}}}else if(r.tag===6){if(s===null){X=r;try{X.stateNode.nodeValue=p?"":X.memoizedProps}catch(He){Wt(X,X.return,He)}}}else if(r.tag===18){if(s===null){X=r;try{var ce=X.stateNode;p?t0(ce,!0):t0(X.stateNode,!1)}catch(He){Wt(X,X.return,He)}}}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:mr(r,t),pr(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,$c(t,c)));break;case 30:break;case 21:break;default:mr(r,t),pr(t)}}function pr(t){var r=t.flags;if(r&2){try{for(var s,c=t.return;c!==null;){if(r1(c)){s=c;break}c=c.return}if(s==null)throw Error(i(160));switch(s.tag){case 27:var p=s.stateNode,g=pf(t);Oc(t,g,p);break;case 5:var S=s.stateNode;s.flags&32&&(Ut(S,""),s.flags&=-33);var M=pf(t);Oc(t,M,S);break;case 3:case 4:var X=s.stateNode.containerInfo,ie=pf(t);xf(t,ie,X);break;default:throw Error(i(161))}}catch(fe){Wt(t,t.return,fe)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function f1(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;f1(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),t=t.sibling}}function Wa(t,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)i1(t,r.alternate,r),r=r.sibling}function xi(t){for(t=t.child;t!==null;){var r=t;switch(r.tag){case 0:case 11:case 14:case 15:jl(4,r,r.return),xi(r);break;case 1:wa(r,r.return);var s=r.stateNode;typeof s.componentWillUnmount=="function"&&t1(r,r.return,s),xi(r);break;case 27:uo(r.stateNode);case 26:case 5:wa(r,r.return),xi(r);break;case 22:r.memoizedState===null&&xi(r);break;case 30:xi(r);break;default:xi(r)}t=t.sibling}}function Va(t,r,s){for(s=s&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var c=r.alternate,p=t,g=r,S=g.flags;switch(g.tag){case 0:case 11:case 15:Va(p,g,s),eo(4,g);break;case 1:if(Va(p,g,s),c=g,p=c.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(ie){Wt(c,c.return,ie)}if(c=g,p=c.updateQueue,p!==null){var M=c.stateNode;try{var X=p.shared.hiddenCallbacks;if(X!==null)for(p.shared.hiddenCallbacks=null,p=0;p<X.length;p++)qp(X[p],M)}catch(ie){Wt(c,c.return,ie)}}s&&S&64&&e1(g),to(g,g.return);break;case 27:a1(g);case 26:case 5:Va(p,g,s),s&&c===null&&S&4&&n1(g),to(g,g.return);break;case 12:Va(p,g,s);break;case 31:Va(p,g,s),s&&S&4&&c1(p,g);break;case 13:Va(p,g,s),s&&S&4&&u1(p,g);break;case 22:g.memoizedState===null&&Va(p,g,s),to(g,g.return);break;case 30:break;default:Va(p,g,s)}r=r.sibling}}function gf(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&&Hs(s))}function bf(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&Hs(t))}function la(t,r,s,c){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)h1(t,r,s,c),r=r.sibling}function h1(t,r,s,c){var p=r.flags;switch(r.tag){case 0:case 11:case 15:la(t,r,s,c),p&2048&&eo(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&&Hs(t)));break;case 12:if(p&2048){la(t,r,s,c),t=r.stateNode;try{var g=r.memoizedProps,S=g.id,M=g.onPostCommit;typeof M=="function"&&M(S,r.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(X){Wt(r,r.return,X)}}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:g=r.stateNode,S=r.alternate,r.memoizedState!==null?g._visibility&2?la(t,r,s,c):no(t,r):g._visibility&2?la(t,r,s,c):(g._visibility|=2,rs(t,r,s,c,(r.subtreeFlags&10256)!==0||!1)),p&2048&&gf(S,r);break;case 24:la(t,r,s,c),p&2048&&bf(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 g=t,S=r,M=s,X=c,ie=S.flags;switch(S.tag){case 0:case 11:case 15:rs(g,S,M,X,p),eo(8,S);break;case 23:break;case 22:var fe=S.stateNode;S.memoizedState!==null?fe._visibility&2?rs(g,S,M,X,p):no(g,S):(fe._visibility|=2,rs(g,S,M,X,p)),p&&ie&2048&&gf(S.alternate,S);break;case 24:rs(g,S,M,X,p),p&&ie&2048&&bf(S.alternate,S);break;default:rs(g,S,M,X,p)}r=r.sibling}}function no(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:no(s,c),p&2048&&gf(c.alternate,c);break;case 24:no(s,c),p&2048&&bf(c.alternate,c);break;default:no(s,c)}r=r.sibling}}var ro=8192;function as(t,r,s){if(t.subtreeFlags&ro)for(t=t.child;t!==null;)m1(t,r,s),t=t.sibling}function m1(t,r,s){switch(t.tag){case 26:as(t,r,s),t.flags&ro&&t.memoizedState!==null&&aw(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=ro,ro=16777216,as(t,r,s),ro=c):as(t,r,s));break;default:as(t,r,s)}}function p1(t){var r=t.alternate;if(r!==null&&(t=r.child,t!==null)){r.child=null;do r=t.sibling,t.sibling=null,t=r;while(t!==null)}}function ao(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];Un=c,y1(c,t)}p1(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)x1(t),t=t.sibling}function x1(t){switch(t.tag){case 0:case 11:case 15:ao(t),t.flags&2048&&jl(9,t,t.return);break;case 3:ao(t);break;case 12:ao(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)):ao(t);break;default:ao(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];Un=c,y1(c,t)}p1(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:jl(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 y1(t,r){for(;Un!==null;){var s=Un;switch(s.tag){case 0:case 11:case 15:jl(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:Hs(s.memoizedState.cache)}if(c=s.child,c!==null)c.return=s,Un=c;else e:for(s=t;Un!==null;){c=Un;var p=c.sibling,g=c.return;if(s1(c),c===s){Un=null;break e}if(p!==null){p.return=g,Un=p;break e}Un=g}}}var b2={getCacheForType:function(t){var r=Vn(Nn),s=r.data.get(t);return s===void 0&&(s=t(),r.data.set(t,s)),s},cacheSignal:function(){return Vn(Nn).controller.signal}},v2=typeof WeakMap=="function"?WeakMap:Map,It=0,en=null,St=null,Dt=0,Xt=0,Dr=null,Sl=!1,ls=!1,vf=!1,Ga=0,vn=0,Cl=0,yi=0,wf=0,Tr=0,is=0,lo=null,xr=null,kf=!1,Ic=0,g1=0,Hc=1/0,Uc=null,Nl=null,zn=0,El=null,ss=null,Ka=0,jf=0,Sf=null,b1=null,io=0,Cf=null;function Fr(){return(It&2)!==0&&Dt!==0?Dt&-Dt:Y.T!==null?Ff():il()}function v1(){if(Tr===0)if((Dt&536870912)===0||Rt){var t=Vt;Vt<<=1,(Vt&3932160)===0&&(Vt=262144),Tr=t}else Tr=536870912;return t=Er.current,t!==null&&(t.flags|=32),Tr}function yr(t,r,s){(t===en&&(Xt===2||Xt===9)||t.cancelPendingCommit!==null)&&(os(t,0),Al(t,Dt,Tr,!1)),ke(t,s),((It&2)===0||t!==en)&&(t===en&&((It&2)===0&&(yi|=s),vn===4&&Al(t,Dt,Tr,!1)),ka(t))}function w1(t,r,s){if((It&6)!==0)throw Error(i(327));var c=!s&&(r&127)===0&&(r&t.expiredLanes)===0||J(t,r),p=c?j2(t,r):Ef(t,r,!0),g=c;do{if(p===0){ls&&!c&&Al(t,r,0,!1);break}else{if(s=t.current.alternate,g&&!w2(s)){p=Ef(t,r,!1),g=!1;continue}if(p===2){if(g=r,t.errorRecoveryDisabledLanes&g)var S=0;else S=t.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){r=S;e:{var M=t;p=lo;var X=M.current.memoizedState.isDehydrated;if(X&&(os(M,S).flags|=256),S=Ef(M,S,!1),S!==2){if(vf&&!X){M.errorRecoveryDisabledLanes|=g,yi|=g,p=4;break e}g=xr,xr=p,g!==null&&(xr===null?xr=g:xr.push.apply(xr,g))}p=S}if(g=!1,p!==2)continue}}if(p===1){os(t,0),Al(t,r,0,!0);break}e:{switch(c=t,g=p,g){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:Al(c,r,Tr,!Sl);break e;case 2:xr=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(p=Ic+300-Le(),10<p)){if(Al(c,r,Tr,!Sl),Mn(c,0,!0)!==0)break e;Ka=r,c.timeoutHandle=Z1(k1.bind(null,c,s,xr,Uc,kf,r,Tr,yi,is,Sl,g,"Throttled",-0,0),p);break e}k1(c,s,xr,Uc,kf,r,Tr,yi,is,Sl,g,null,-0,0)}}break}while(!0);ka(t)}function k1(t,r,s,c,p,g,S,M,X,ie,fe,we,se,ce){if(t.timeoutHandle=-1,we=r.subtreeFlags,we&8192||(we&16785408)===16785408){we={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Xn},m1(r,g,we);var He=(g&62914560)===g?Ic-Le():(g&4194048)===g?g1-Le():0;if(He=lw(we,He),He!==null){Ka=g,t.cancelPendingCommit=He(T1.bind(null,t,r,g,s,c,p,S,M,X,fe,we,null,se,ce)),Al(t,g,S,!ie);return}}T1(t,r,g,s,c,p,S,M,X)}function w2(t){for(var r=t;;){var s=r.tag;if((s===0||s===11||s===15)&&r.flags&16384&&(s=r.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var c=0;c<s.length;c++){var p=s[c],g=p.getSnapshot;p=p.value;try{if(!Cr(g(),p))return!1}catch{return!1}}if(s=r.child,r.subtreeFlags&16384&&s!==null)s.return=r,r=s;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Al(t,r,s,c){r&=~wf,r&=~yi,t.suspendedLanes|=r,t.pingedLanes&=~r,c&&(t.warmLanes|=r),c=t.expirationTimes;for(var p=r;0<p;){var g=31-et(p),S=1<<g;c[g]=-1,p&=~S}s!==0&&hn(t,s,r)}function qc(){return(It&6)===0?(so(0),!1):!0}function Nf(){if(St!==null){if(Xt===0)var t=St.return;else t=St,$a=oi=null,Hd(t),Zi=null,qs=0,t=St;for(;t!==null;)Jx(t.alternate,t),t=t.return;St=null}}function os(t,r){var s=t.timeoutHandle;s!==-1&&(t.timeoutHandle=-1,H2(s)),s=t.cancelPendingCommit,s!==null&&(t.cancelPendingCommit=null,s()),Ka=0,Nf(),en=t,St=s=Ba(t.current,null),Dt=r,Xt=0,Dr=null,Sl=!1,ls=J(t,r),vf=!1,is=Tr=wf=yi=Cl=vn=0,xr=lo=null,kf=!1,(r&8)!==0&&(r|=r&32);var c=t.entangledLanes;if(c!==0)for(t=t.entanglements,c&=r;0<c;){var p=31-et(c),g=1<<p;r|=t[p],c&=~g}return Ga=r,uc(),s}function j1(t,r){ft=null,Y.H=Ps,r===Pi||r===gc?(r=Lp(),Xt=3):r===Dd?(r=Lp(),Xt=4):Xt=r===rf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Dr=r,St===null&&(vn=1,Mc(t,Ur(r,t.current)))}function S1(){var t=Er.current;return t===null?!0:(Dt&4194048)===Dt?Wr===null:(Dt&62914560)===Dt||(Dt&536870912)!==0?t===Wr:!1}function C1(){var t=Y.H;return Y.H=Ps,t===null?Ps:t}function N1(){var t=Y.A;return Y.A=b2,t}function Yc(){vn=4,Sl||(Dt&4194048)!==Dt&&Er.current!==null||(ls=!0),(Cl&134217727)===0&&(yi&134217727)===0||en===null||Al(en,Dt,Tr,!1)}function Ef(t,r,s){var c=It;It|=2;var p=C1(),g=N1();(en!==t||Dt!==r)&&(Uc=null,os(t,r)),r=!1;var S=vn;e:do try{if(Xt!==0&&St!==null){var M=St,X=Dr;switch(Xt){case 8:Nf(),S=6;break e;case 3:case 2:case 9:case 6:Er.current===null&&(r=!0);var ie=Xt;if(Xt=0,Dr=null,cs(t,M,X,ie),s&&ls){S=0;break e}break;default:ie=Xt,Xt=0,Dr=null,cs(t,M,X,ie)}}k2(),S=vn;break}catch(fe){j1(t,fe)}while(!0);return r&&t.shellSuspendCounter++,$a=oi=null,It=c,Y.H=p,Y.A=g,St===null&&(en=null,Dt=0,uc()),S}function k2(){for(;St!==null;)E1(St)}function j2(t,r){var s=It;It|=2;var c=C1(),p=N1();en!==t||Dt!==r?(Uc=null,Hc=Le()+500,os(t,r)):ls=J(t,r);e:do try{if(Xt!==0&&St!==null){r=St;var g=Dr;t:switch(Xt){case 1:Xt=0,Dr=null,cs(t,r,g,1);break;case 2:case 9:if(Op(g)){Xt=0,Dr=null,A1(r);break}r=function(){Xt!==2&&Xt!==9||en!==t||(Xt=7),ka(t)},g.then(r,r);break e;case 3:Xt=7;break e;case 4:Xt=5;break e;case 7:Op(g)?(Xt=0,Dr=null,A1(r)):(Xt=0,Dr=null,cs(t,r,g,7));break;case 5:var S=null;switch(St.tag){case 26:S=St.memoizedState;case 5:case 27:var M=St;if(S?h0(S):M.stateNode.complete){Xt=0,Dr=null;var X=M.sibling;if(X!==null)St=X;else{var ie=M.return;ie!==null?(St=ie,Xc(ie)):St=null}break t}}Xt=0,Dr=null,cs(t,r,g,5);break;case 6:Xt=0,Dr=null,cs(t,r,g,6);break;case 8:Nf(),vn=6;break e;default:throw Error(i(462))}}S2();break}catch(fe){j1(t,fe)}while(!0);return $a=oi=null,Y.H=c,Y.A=p,It=s,St!==null?0:(en=null,Dt=0,uc(),vn)}function S2(){for(;St!==null&&!$e();)E1(St)}function E1(t){var r=Px(t.alternate,t,Ga);t.memoizedProps=t.pendingProps,r===null?Xc(t):St=r}function A1(t){var r=t,s=r.alternate;switch(r.tag){case 15:case 0:r=Xx(s,r,r.pendingProps,r.type,void 0,Dt);break;case 11:r=Xx(s,r,r.pendingProps,r.type.render,r.ref,Dt);break;case 5:Hd(r);default:Jx(s,r),r=St=Np(r,Ga),r=Px(s,r,Ga)}t.memoizedProps=t.pendingProps,r===null?Xc(t):St=r}function cs(t,r,s,c){$a=oi=null,Hd(r),Zi=null,qs=0;var p=r.return;try{if(f2(t,p,r,s,Dt)){vn=1,Mc(t,Ur(s,t.current)),St=null;return}}catch(g){if(p!==null)throw St=p,g;vn=1,Mc(t,Ur(s,t.current)),St=null;return}r.flags&32768?(Rt||c===1?t=!0:ls||(Dt&536870912)!==0?t=!1:(Sl=t=!0,(c===2||c===9||c===3||c===6)&&(c=Er.current,c!==null&&c.tag===13&&(c.flags|=16384))),D1(r,t)):Xc(r)}function Xc(t){var r=t;do{if((r.flags&32768)!==0){D1(r,Sl);return}t=r.return;var s=p2(r.alternate,r,Ga);if(s!==null){St=s;return}if(r=r.sibling,r!==null){St=r;return}St=r=t}while(r!==null);vn===0&&(vn=5)}function D1(t,r){do{var s=x2(t.alternate,t);if(s!==null){s.flags&=32767,St=s;return}if(s=t.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!r&&(t=t.sibling,t!==null)){St=t;return}St=t=s}while(t!==null);vn=6,St=null}function T1(t,r,s,c,p,g,S,M,X){t.cancelPendingCommit=null;do Wc();while(zn!==0);if((It&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(g=r.lanes|r.childLanes,g|=md,Mt(t,s,g,S,M,X),t===en&&(St=en=null,Dt=0),ss=r,El=t,Ka=s,jf=g,Sf=p,b1=c,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,A2(ye,function(){return _1(),null})):(t.callbackNode=null,t.callbackPriority=0),c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=Y.T,Y.T=null,p=ae.p,ae.p=2,S=It,It|=4;try{y2(t,r,s)}finally{It=S,ae.p=p,Y.T=c}}zn=1,F1(),M1(),R1()}}function F1(){if(zn===1){zn=0;var t=El,r=ss,s=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||s){s=Y.T,Y.T=null;var c=ae.p;ae.p=2;var p=It;It|=4;try{d1(r,t);var g=Lf,S=yp(t.containerInfo),M=g.focusedElem,X=g.selectionRange;if(S!==M&&M&&M.ownerDocument&&xp(M.ownerDocument.documentElement,M)){if(X!==null&&cd(M)){var ie=X.start,fe=X.end;if(fe===void 0&&(fe=ie),"selectionStart"in M)M.selectionStart=ie,M.selectionEnd=Math.min(fe,M.value.length);else{var we=M.ownerDocument||document,se=we&&we.defaultView||window;if(se.getSelection){var ce=se.getSelection(),He=M.textContent.length,tt=Math.min(X.start,He),Zt=X.end===void 0?tt:Math.min(X.end,He);!ce.extend&&tt>Zt&&(S=Zt,Zt=tt,tt=S);var ne=pp(M,tt),V=pp(M,Zt);if(ne&&V&&(ce.rangeCount!==1||ce.anchorNode!==ne.node||ce.anchorOffset!==ne.offset||ce.focusNode!==V.node||ce.focusOffset!==V.offset)){var le=we.createRange();le.setStart(ne.node,ne.offset),ce.removeAllRanges(),tt>Zt?(ce.addRange(le),ce.extend(V.node,V.offset)):(le.setEnd(V.node,V.offset),ce.addRange(le))}}}}for(we=[],ce=M;ce=ce.parentNode;)ce.nodeType===1&&we.push({element:ce,left:ce.scrollLeft,top:ce.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;M<we.length;M++){var be=we[M];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}au=!!$f,Lf=$f=null}finally{It=p,ae.p=c,Y.T=s}}t.current=r,zn=2}}function M1(){if(zn===2){zn=0;var t=El,r=ss,s=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||s){s=Y.T,Y.T=null;var c=ae.p;ae.p=2;var p=It;It|=4;try{i1(t,r.alternate,r)}finally{It=p,ae.p=c,Y.T=s}}zn=3}}function R1(){if(zn===4||zn===3){zn=0,Be();var t=El,r=ss,s=Ka,c=b1;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?zn=5:(zn=0,ss=El=null,z1(t,t.pendingLanes));var p=t.pendingLanes;if(p===0&&(Nl=null),nr(s),r=r.stateNode,ht&&typeof ht.onCommitFiberRoot=="function")try{ht.onCommitFiberRoot(dt,r,void 0,(r.current.flags&128)===128)}catch{}if(c!==null){r=Y.T,p=ae.p,ae.p=2,Y.T=null;try{for(var g=t.onRecoverableError,S=0;S<c.length;S++){var M=c[S];g(M.value,{componentStack:M.stack})}}finally{Y.T=r,ae.p=p}}(Ka&3)!==0&&Wc(),ka(t),p=t.pendingLanes,(s&261930)!==0&&(p&42)!==0?t===Cf?io++:(io=0,Cf=t):io=0,so(0)}}function z1(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,Hs(r)))}function Wc(){return F1(),M1(),R1(),_1()}function _1(){if(zn!==5)return!1;var t=El,r=jf;jf=0;var s=nr(Ka),c=Y.T,p=ae.p;try{ae.p=32>s?32:s,Y.T=null,s=Sf,Sf=null;var g=El,S=Ka;if(zn=0,ss=El=null,Ka=0,(It&6)!==0)throw Error(i(331));var M=It;if(It|=4,x1(g.current),h1(g,g.current,S,s),It=M,so(0,!1),ht&&typeof ht.onPostCommitFiberRoot=="function")try{ht.onPostCommitFiberRoot(dt,g)}catch{}return!0}finally{ae.p=p,Y.T=c,z1(t,r)}}function B1(t,r,s){r=Ur(s,r),r=nf(t.stateNode,r,2),t=vl(t,r,2),t!==null&&(ke(t,2),ka(t))}function Wt(t,r,s){if(t.tag===3)B1(t,t,s);else for(;r!==null;){if(r.tag===3){B1(r,t,s);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Nl===null||!Nl.has(c))){t=Ur(s,t),s=Ox(2),c=vl(r,s,2),c!==null&&($x(s,c,r,t),ke(c,2),ka(c));break}}r=r.return}}function Af(t,r,s){var c=t.pingCache;if(c===null){c=t.pingCache=new v2;var p=new Set;c.set(r,p)}else p=c.get(r),p===void 0&&(p=new Set,c.set(r,p));p.has(s)||(vf=!0,p.add(s),t=C2.bind(null,t,r,s),r.then(t,t))}function C2(t,r,s){var c=t.pingCache;c!==null&&c.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,en===t&&(Dt&s)===s&&(vn===4||vn===3&&(Dt&62914560)===Dt&&300>Le()-Ic?(It&2)===0&&os(t,0):wf|=s,is===Dt&&(is=0)),ka(t)}function O1(t,r){r===0&&(r=ot()),t=li(t,r),t!==null&&(ke(t,r),ka(t))}function N2(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),O1(t,s)}function E2(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),O1(t,s)}function A2(t,r){return xe(t,r)}var Vc=null,us=null,Df=!1,Gc=!1,Tf=!1,Dl=0;function ka(t){t!==us&&t.next===null&&(us===null?Vc=us=t:us=us.next=t),Gc=!0,Df||(Df=!0,T2())}function so(t,r){if(!Tf&&Gc){Tf=!0;do for(var s=!1,c=Vc;c!==null;){if(t!==0){var p=c.pendingLanes;if(p===0)var g=0;else{var S=c.suspendedLanes,M=c.pingedLanes;g=(1<<31-et(42|t)+1)-1,g&=p&~(S&~M),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(s=!0,H1(c,g))}else g=Dt,g=Mn(c,c===en?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||J(c,g)||(s=!0,H1(c,g));c=c.next}while(s);Tf=!1}}function D2(){$1()}function $1(){Gc=Df=!1;var t=0;Dl!==0&&I2()&&(t=Dl);for(var r=Le(),s=null,c=Vc;c!==null;){var p=c.next,g=L1(c,r);g===0?(c.next=null,s===null?Vc=p:s.next=p,p===null&&(us=s)):(s=c,(t!==0||(g&3)!==0)&&(Gc=!0)),c=p}zn!==0&&zn!==5||so(t),Dl!==0&&(Dl=0)}function L1(t,r){for(var s=t.suspendedLanes,c=t.pingedLanes,p=t.expirationTimes,g=t.pendingLanes&-62914561;0<g;){var S=31-et(g),M=1<<S,X=p[S];X===-1?((M&s)===0||(M&c)!==0)&&(p[S]=We(M,r)):X<=r&&(t.expiredLanes|=M),g&=~M}if(r=en,s=Dt,s=Mn(t,t===r?s:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c=t.callbackNode,s===0||t===r&&(Xt===2||Xt===9)||t.cancelPendingCommit!==null)return c!==null&&c!==null&&ge(c),t.callbackNode=null,t.callbackPriority=0;if((s&3)===0||J(t,s)){if(r=s&-s,r===t.callbackPriority)return r;switch(c!==null&&ge(c),nr(s)){case 2:case 8:s=ue;break;case 32:s=ye;break;case 268435456:s=Me;break;default:s=ye}return c=I1.bind(null,t),s=xe(s,c),t.callbackPriority=r,t.callbackNode=s,r}return c!==null&&c!==null&&ge(c),t.callbackPriority=2,t.callbackNode=null,2}function I1(t,r){if(zn!==0&&zn!==5)return t.callbackNode=null,t.callbackPriority=0,null;var s=t.callbackNode;if(Wc()&&t.callbackNode!==s)return null;var c=Dt;return c=Mn(t,t===en?c:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),c===0?null:(w1(t,c,r),L1(t,Le()),t.callbackNode!=null&&t.callbackNode===s?I1.bind(null,t):null)}function H1(t,r){if(Wc())return null;w1(t,r,!0)}function T2(){U2(function(){(It&6)!==0?xe(P,D2):$1()})}function Ff(){if(Dl===0){var t=Ki;t===0&&(t=fn,fn<<=1,(fn&261888)===0&&(fn=256)),Dl=t}return Dl}function U1(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:jr(""+t)}function q1(t,r){var s=r.ownerDocument.createElement("input");return s.name=r.name,s.value=r.value,t.id&&s.setAttribute("form",t.id),r.parentNode.insertBefore(s,r),t=new FormData(t),s.parentNode.removeChild(s),t}function F2(t,r,s,c,p){if(r==="submit"&&s&&s.stateNode===p){var g=U1((p[Ln]||null).action),S=c.submitter;S&&(r=(r=S[Ln]||null)?U1(r.formAction):S.getAttribute("formAction"),r!==null&&(g=r,S=null));var M=new ul("action","action",null,c,p);t.push({event:M,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Dl!==0){var X=S?q1(p,S):new FormData(p);Qd(s,{pending:!0,data:X,method:p.method,action:g},null,X)}}else typeof g=="function"&&(M.preventDefault(),X=S?q1(p,S):new FormData(p),Qd(s,{pending:!0,data:X,method:p.method,action:g},g,X))},currentTarget:p}]})}}for(var Mf=0;Mf<hd.length;Mf++){var Rf=hd[Mf],M2=Rf.toLowerCase(),R2=Rf[0].toUpperCase()+Rf.slice(1);ra(M2,"on"+R2)}ra(vp,"onAnimationEnd"),ra(wp,"onAnimationIteration"),ra(kp,"onAnimationStart"),ra("dblclick","onDoubleClick"),ra("focusin","onFocus"),ra("focusout","onBlur"),ra(Kv,"onTransitionRun"),ra(Qv,"onTransitionStart"),ra(Pv,"onTransitionCancel"),ra(jp,"onTransitionEnd"),za("onMouseEnter",["mouseout","mouseover"]),za("onMouseLeave",["mouseout","mouseover"]),za("onPointerEnter",["pointerout","pointerover"]),za("onPointerLeave",["pointerout","pointerover"]),cr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),cr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),cr("onBeforeInput",["compositionend","keypress","textInput","paste"]),cr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),cr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),cr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var oo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),z2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(oo));function Y1(t,r){r=(r&4)!==0;for(var s=0;s<t.length;s++){var c=t[s],p=c.event;c=c.listeners;e:{var g=void 0;if(r)for(var S=c.length-1;0<=S;S--){var M=c[S],X=M.instance,ie=M.currentTarget;if(M=M.listener,X!==g&&p.isPropagationStopped())break e;g=M,p.currentTarget=ie;try{g(p)}catch(fe){cc(fe)}p.currentTarget=null,g=X}else for(S=0;S<c.length;S++){if(M=c[S],X=M.instance,ie=M.currentTarget,M=M.listener,X!==g&&p.isPropagationStopped())break e;g=M,p.currentTarget=ie;try{g(p)}catch(fe){cc(fe)}p.currentTarget=null,g=X}}}}function Ct(t,r){var s=r[sl];s===void 0&&(s=r[sl]=new Set);var c=t+"__bubble";s.has(c)||(X1(r,t,2,!1),s.add(c))}function zf(t,r,s){var c=0;r&&(c|=4),X1(s,t,c,r)}var Kc="_reactListening"+Math.random().toString(36).slice(2);function _f(t){if(!t[Kc]){t[Kc]=!0,Ma.forEach(function(s){s!=="selectionchange"&&(z2.has(s)||zf(s,!1,t),zf(s,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[Kc]||(r[Kc]=!0,zf("selectionchange",!1,r))}}function X1(t,r,s,c){switch(v0(r)){case 2:var p=ow;break;case 8:p=cw;break;default:p=Qf}s=p.bind(null,r,s,t),p=void 0,!_a||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),c?p!==void 0?t.addEventListener(r,s,{capture:!0,passive:p}):t.addEventListener(r,s,!0):p!==void 0?t.addEventListener(r,s,{passive:p}):t.addEventListener(r,s,!1)}function Bf(t,r,s,c,p){var g=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var S=c.tag;if(S===3||S===4){var M=c.stateNode.containerInfo;if(M===p)break;if(S===4)for(S=c.return;S!==null;){var X=S.tag;if((X===3||X===4)&&S.stateNode.containerInfo===p)return;S=S.return}for(;M!==null;){if(S=fa(M),S===null)return;if(X=S.tag,X===5||X===6||X===26||X===27){c=g=S;continue e}M=M.parentNode}}c=c.return}Zo(function(){var ie=g,fe=pa(s),we=[];e:{var se=Sp.get(t);if(se!==void 0){var ce=ul,He=t;switch(t){case"keypress":if(Ri(s)===0)break e;case"keydown":case"keyup":ce=ee;break;case"focusin":He="focus",ce=Rs;break;case"focusout":He="blur",ce=Rs;break;case"beforeblur":case"afterblur":ce=Rs;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":ce=$i;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ce=ga;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ce=mt;break;case vp:case wp:case kp:ce=Gt;break;case jp:ce=Ge;break;case"scroll":case"scrollend":ce=Jo;break;case"wheel":ce=at;break;case"copy":case"cut":case"paste":ce=nc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ce=Ce;break;case"toggle":case"beforetoggle":ce=jt}var tt=(r&4)!==0,Zt=!tt&&(t==="scroll"||t==="scrollend"),ne=tt?se!==null?se+"Capture":null:se;tt=[];for(var V=ie,le;V!==null;){var be=V;if(le=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||le===null||ne===null||(be=qt(V,ne),be!=null&&tt.push(co(V,be,le))),Zt)break;V=V.return}0<tt.length&&(se=new ce(se,He,null,s,fe),we.push({event:se,listeners:tt}))}}if((r&7)===0){e:{if(se=t==="mouseover"||t==="pointerover",ce=t==="mouseout"||t==="pointerout",se&&s!==mn&&(He=s.relatedTarget||s.fromElement)&&(fa(He)||He[da]))break e;if((ce||se)&&(se=fe.window===fe?fe:(se=fe.ownerDocument)?se.defaultView||se.parentWindow:window,ce?(He=s.relatedTarget||s.toElement,ce=ie,He=He?fa(He):null,He!==null&&(Zt=u(He),tt=He.tag,He!==Zt||tt!==5&&tt!==27&&tt!==6)&&(He=null)):(ce=null,He=ie),ce!==He)){if(tt=$i,be="onMouseLeave",ne="onMouseEnter",V="mouse",(t==="pointerout"||t==="pointerover")&&(tt=Ce,be="onPointerLeave",ne="onPointerEnter",V="pointer"),Zt=ce==null?se:Gl(ce),le=He==null?se:Gl(He),se=new tt(be,V+"leave",ce,s,fe),se.target=Zt,se.relatedTarget=le,be=null,fa(fe)===ie&&(tt=new tt(ne,V+"enter",He,s,fe),tt.target=le,tt.relatedTarget=Zt,be=tt),Zt=be,ce&&He)t:{for(tt=_2,ne=ce,V=He,le=0,be=ne;be;be=tt(be))le++;be=0;for(var Ke=V;Ke;Ke=tt(Ke))be++;for(;0<le-be;)ne=tt(ne),le--;for(;0<be-le;)V=tt(V),be--;for(;le--;){if(ne===V||V!==null&&ne===V.alternate){tt=ne;break t}ne=tt(ne),V=tt(V)}tt=null}else tt=null;ce!==null&&W1(we,se,ce,tt,!1),He!==null&&Zt!==null&&W1(we,Zt,He,tt,!0)}}e:{if(se=ie?Gl(ie):window,ce=se.nodeName&&se.nodeName.toLowerCase(),ce==="select"||ce==="input"&&se.type==="file")var Ot=cp;else if(sp(se))if(up)Ot=Wv;else{Ot=Yv;var qe=qv}else ce=se.nodeName,!ce||ce.toLowerCase()!=="input"||se.type!=="checkbox"&&se.type!=="radio"?ie&&Zl(ie.elementType)&&(Ot=cp):Ot=Xv;if(Ot&&(Ot=Ot(t,ie))){op(we,Ot,s,fe);break e}qe&&qe(t,se,ie),t==="focusout"&&ie&&se.type==="number"&&ie.memoizedProps.value!=null&&ha(se,"number",se.value)}switch(qe=ie?Gl(ie):window,t){case"focusin":(sp(qe)||qe.contentEditable==="true")&&(Hi=qe,ud=ie,$s=null);break;case"focusout":$s=ud=Hi=null;break;case"mousedown":dd=!0;break;case"contextmenu":case"mouseup":case"dragend":dd=!1,gp(we,s,fe);break;case"selectionchange":if(Gv)break;case"keydown":case"keyup":gp(we,s,fe)}var pt;if(fl)e:{switch(t){case"compositionstart":var Tt="onCompositionStart";break e;case"compositionend":Tt="onCompositionEnd";break e;case"compositionupdate":Tt="onCompositionUpdate";break e}Tt=void 0}else Ii?gn(t,s)&&(Tt="onCompositionEnd"):t==="keydown"&&s.keyCode===229&&(Tt="onCompositionStart");Tt&&(Ir&&s.locale!=="ko"&&(Ii||Tt!=="onCompositionStart"?Tt==="onCompositionEnd"&&Ii&&(pt=Mi()):(xa=fe,ti="value"in xa?xa.value:xa.textContent,Ii=!0)),qe=Qc(ie,Tt),0<qe.length&&(Tt=new zs(Tt,t,null,s,fe),we.push({event:Tt,listeners:qe}),pt?Tt.data=pt:(pt=ip(s),pt!==null&&(Tt.data=pt)))),(pt=hl?Lv(t,s):Iv(t,s))&&(Tt=Qc(ie,"onBeforeInput"),0<Tt.length&&(qe=new zs("onBeforeInput","beforeinput",null,s,fe),we.push({event:qe,listeners:Tt}),qe.data=pt)),F2(we,t,ie,s,fe)}Y1(we,r)})}function co(t,r,s){return{instance:t,listener:r,currentTarget:s}}function Qc(t,r){for(var s=r+"Capture",c=[];t!==null;){var p=t,g=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||g===null||(p=qt(t,s),p!=null&&c.unshift(co(t,p,g)),p=qt(t,r),p!=null&&c.push(co(t,p,g))),t.tag===3)return c;t=t.return}return[]}function _2(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function W1(t,r,s,c,p){for(var g=r._reactName,S=[];s!==null&&s!==c;){var M=s,X=M.alternate,ie=M.stateNode;if(M=M.tag,X!==null&&X===c)break;M!==5&&M!==26&&M!==27||ie===null||(X=ie,p?(ie=qt(s,g),ie!=null&&S.unshift(co(s,ie,X))):p||(ie=qt(s,g),ie!=null&&S.push(co(s,ie,X)))),s=s.return}S.length!==0&&t.push({event:r,listeners:S})}var B2=/\r\n?/g,O2=/\u0000|\uFFFD/g;function V1(t){return(typeof t=="string"?t:""+t).replace(B2,`
|
|
49
|
+
`).replace(O2,"")}function G1(t,r){return r=V1(r),V1(t)===r}function Pt(t,r,s,c,p,g){switch(s){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||Ut(t,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&Ut(t,""+c);break;case"className":Ql(t,"class",c);break;case"tabIndex":Ql(t,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":Ql(t,s,c);break;case"style":ta(t,c,g);break;case"data":if(r!=="object"){Ql(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=jr(""+c),t.setAttribute(s,c);break;case"action":case"formAction":if(typeof c=="function"){t.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(s==="formAction"?(r!=="input"&&Pt(t,r,"name",p.name,p,null),Pt(t,r,"formEncType",p.formEncType,p,null),Pt(t,r,"formMethod",p.formMethod,p,null),Pt(t,r,"formTarget",p.formTarget,p,null)):(Pt(t,r,"encType",p.encType,p,null),Pt(t,r,"method",p.method,p,null),Pt(t,r,"target",p.target,p,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=jr(""+c),t.setAttribute(s,c);break;case"onClick":c!=null&&(t.onclick=Xn);break;case"onScroll":c!=null&&Ct("scroll",t);break;case"onScrollEnd":c!=null&&Ct("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=jr(""+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":Ct("beforetoggle",t),Ct("toggle",t),Kl(t,"popover",c);break;case"xlinkActuate":Zr(t,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Zr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Zr(t,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Zr(t,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Zr(t,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Zr(t,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Zr(t,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Zr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Zr(t,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Kl(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=ld.get(s)||s,Kl(t,s,c))}}function Of(t,r,s,c,p,g){switch(s){case"style":ta(t,c,g);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(s=c.__html,s!=null){if(p.children!=null)throw Error(i(60));t.innerHTML=s}}break;case"children":typeof c=="string"?Ut(t,c):(typeof c=="number"||typeof c=="bigint")&&Ut(t,""+c);break;case"onScroll":c!=null&&Ct("scroll",t);break;case"onScrollEnd":c!=null&&Ct("scrollend",t);break;case"onClick":c!=null&&(t.onclick=Xn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ra.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(p=s.endsWith("Capture"),r=s.slice(2,p?s.length-7:void 0),g=t[Ln]||null,g=g!=null?g[s]:null,typeof g=="function"&&t.removeEventListener(r,g,p),typeof c=="function")){typeof g!="function"&&g!==null&&(s in t?t[s]=null:t.hasAttribute(s)&&t.removeAttribute(s)),t.addEventListener(r,c,p);break e}s in t?t[s]=c:c===!0?t.setAttribute(s,""):Kl(t,s,c)}}}function Kn(t,r,s){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ct("error",t),Ct("load",t);var c=!1,p=!1,g;for(g in s)if(s.hasOwnProperty(g)){var S=s[g];if(S!=null)switch(g){case"src":c=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:Pt(t,r,g,S,s,null)}}p&&Pt(t,r,"srcSet",s.srcSet,s,null),c&&Pt(t,r,"src",s.src,s,null);return;case"input":Ct("invalid",t);var M=g=S=p=null,X=null,ie=null;for(c in s)if(s.hasOwnProperty(c)){var fe=s[c];if(fe!=null)switch(c){case"name":p=fe;break;case"type":S=fe;break;case"checked":X=fe;break;case"defaultChecked":ie=fe;break;case"value":g=fe;break;case"defaultValue":M=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(i(137,r));break;default:Pt(t,r,c,fe,s,null)}}rr(t,g,M,X,ie,S,p,!1);return;case"select":Ct("invalid",t),c=S=g=null;for(p in s)if(s.hasOwnProperty(p)&&(M=s[p],M!=null))switch(p){case"value":g=M;break;case"defaultValue":S=M;break;case"multiple":c=M;default:Pt(t,r,p,M,s,null)}r=g,s=S,t.multiple=!!c,r!=null?dr(t,!!c,r,!1):s!=null&&dr(t,!!c,s,!0);return;case"textarea":Ct("invalid",t),g=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":g=M;break;case"dangerouslySetInnerHTML":if(M!=null)throw Error(i(91));break;default:Pt(t,r,S,M,s,null)}In(t,c,p,g);return;case"option":for(X in s)if(s.hasOwnProperty(X)&&(c=s[X],c!=null))switch(X){case"selected":t.selected=c&&typeof c!="function"&&typeof c!="symbol";break;default:Pt(t,r,X,c,s,null)}return;case"dialog":Ct("beforetoggle",t),Ct("toggle",t),Ct("cancel",t),Ct("close",t);break;case"iframe":case"object":Ct("load",t);break;case"video":case"audio":for(c=0;c<oo.length;c++)Ct(oo[c],t);break;case"image":Ct("error",t),Ct("load",t);break;case"details":Ct("toggle",t);break;case"embed":case"source":case"link":Ct("error",t),Ct("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ie in s)if(s.hasOwnProperty(ie)&&(c=s[ie],c!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:Pt(t,r,ie,c,s,null)}return;default:if(Zl(r)){for(fe in s)s.hasOwnProperty(fe)&&(c=s[fe],c!==void 0&&Of(t,r,fe,c,s,void 0));return}}for(M in s)s.hasOwnProperty(M)&&(c=s[M],c!=null&&Pt(t,r,M,c,s,null))}function $2(t,r,s,c){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,g=null,S=null,M=null,X=null,ie=null,fe=null;for(ce in s){var we=s[ce];if(s.hasOwnProperty(ce)&&we!=null)switch(ce){case"checked":break;case"value":break;case"defaultValue":X=we;default:c.hasOwnProperty(ce)||Pt(t,r,ce,null,c,we)}}for(var se in c){var ce=c[se];if(we=s[se],c.hasOwnProperty(se)&&(ce!=null||we!=null))switch(se){case"type":g=ce;break;case"name":p=ce;break;case"checked":ie=ce;break;case"defaultChecked":fe=ce;break;case"value":S=ce;break;case"defaultValue":M=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(i(137,r));break;default:ce!==we&&Pt(t,r,se,ce,c,we)}}Pl(t,S,M,X,ie,fe,g,p);return;case"select":ce=S=M=se=null;for(g in s)if(X=s[g],s.hasOwnProperty(g)&&X!=null)switch(g){case"value":break;case"multiple":ce=X;default:c.hasOwnProperty(g)||Pt(t,r,g,null,c,X)}for(p in c)if(g=c[p],X=s[p],c.hasOwnProperty(p)&&(g!=null||X!=null))switch(p){case"value":se=g;break;case"defaultValue":M=g;break;case"multiple":S=g;default:g!==X&&Pt(t,r,p,g,c,X)}r=M,s=S,c=ce,se!=null?dr(t,!!s,se,!1):!!c!=!!s&&(r!=null?dr(t,!!s,r,!0):dr(t,!!s,s?[]:"",!1));return;case"textarea":ce=se=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:Pt(t,r,M,null,c,p)}for(S in c)if(p=c[S],g=s[S],c.hasOwnProperty(S)&&(p!=null||g!=null))switch(S){case"value":se=p;break;case"defaultValue":ce=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(i(91));break;default:p!==g&&Pt(t,r,S,p,c,g)}Qo(t,se,ce);return;case"option":for(var He in s)if(se=s[He],s.hasOwnProperty(He)&&se!=null&&!c.hasOwnProperty(He))switch(He){case"selected":t.selected=!1;break;default:Pt(t,r,He,null,c,se)}for(X in c)if(se=c[X],ce=s[X],c.hasOwnProperty(X)&&se!==ce&&(se!=null||ce!=null))switch(X){case"selected":t.selected=se&&typeof se!="function"&&typeof se!="symbol";break;default:Pt(t,r,X,se,c,ce)}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 tt in s)se=s[tt],s.hasOwnProperty(tt)&&se!=null&&!c.hasOwnProperty(tt)&&Pt(t,r,tt,null,c,se);for(ie in c)if(se=c[ie],ce=s[ie],c.hasOwnProperty(ie)&&se!==ce&&(se!=null||ce!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(i(137,r));break;default:Pt(t,r,ie,se,c,ce)}return;default:if(Zl(r)){for(var Zt in s)se=s[Zt],s.hasOwnProperty(Zt)&&se!==void 0&&!c.hasOwnProperty(Zt)&&Of(t,r,Zt,void 0,c,se);for(fe in c)se=c[fe],ce=s[fe],!c.hasOwnProperty(fe)||se===ce||se===void 0&&ce===void 0||Of(t,r,fe,se,c,ce);return}}for(var ne in s)se=s[ne],s.hasOwnProperty(ne)&&se!=null&&!c.hasOwnProperty(ne)&&Pt(t,r,ne,null,c,se);for(we in c)se=c[we],ce=s[we],!c.hasOwnProperty(we)||se===ce||se==null&&ce==null||Pt(t,r,we,se,c,ce)}function K1(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function L2(){if(typeof performance.getEntriesByType=="function"){for(var t=0,r=0,s=performance.getEntriesByType("resource"),c=0;c<s.length;c++){var p=s[c],g=p.transferSize,S=p.initiatorType,M=p.duration;if(g&&M&&K1(S)){for(S=0,M=p.responseEnd,c+=1;c<s.length;c++){var X=s[c],ie=X.startTime;if(ie>M)break;var fe=X.transferSize,we=X.initiatorType;fe&&K1(we)&&(X=X.responseEnd,S+=fe*(X<M?1:(M-ie)/(X-ie)))}if(--c,r+=8*(g+S)/(p.duration/1e3),t++,10<t)break}}if(0<t)return r/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var $f=null,Lf=null;function Pc(t){return t.nodeType===9?t:t.ownerDocument}function Q1(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 P1(t,r){if(t===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&r==="foreignObject"?0:t}function If(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Hf=null;function I2(){var t=window.event;return t&&t.type==="popstate"?t===Hf?!1:(Hf=t,!0):(Hf=null,!1)}var Z1=typeof setTimeout=="function"?setTimeout:void 0,H2=typeof clearTimeout=="function"?clearTimeout:void 0,J1=typeof Promise=="function"?Promise:void 0,U2=typeof queueMicrotask=="function"?queueMicrotask:typeof J1<"u"?function(t){return J1.resolve(null).then(t).catch(q2)}:Z1;function q2(t){setTimeout(function(){throw t})}function Tl(t){return t==="head"}function e0(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")uo(t.ownerDocument.documentElement);else if(s==="head"){s=t.ownerDocument.head,uo(s);for(var g=s.firstChild;g;){var S=g.nextSibling,M=g.nodeName;g[Fa]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&g.rel.toLowerCase()==="stylesheet"||s.removeChild(g),g=S}}else s==="body"&&uo(t.ownerDocument.body);s=p}while(s);ms(r)}function t0(t,r){var s=t;t=0;do{var c=s.nextSibling;if(s.nodeType===1?r?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(r?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),c&&c.nodeType===8)if(s=c.data,s==="/$"){if(t===0)break;t--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||t++;s=c}while(s)}function Uf(t){var r=t.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var s=r;switch(r=r.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":Uf(s),Fi(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}t.removeChild(s)}}function Y2(t,r,s,c){for(;t.nodeType===1;){var p=s;if(t.nodeName.toLowerCase()!==r.toLowerCase()){if(!c&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(c){if(!t[Fa])switch(r){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(g=t.getAttribute("rel"),g==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(g!==p.rel||t.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||t.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||t.getAttribute("title")!==(p.title==null?null:p.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(g=t.getAttribute("src"),(g!==(p.src==null?null:p.src)||t.getAttribute("type")!==(p.type==null?null:p.type)||t.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&g&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(r==="input"&&t.type==="hidden"){var g=p.name==null?null:""+p.name;if(p.type==="hidden"&&t.getAttribute("name")===g)return t}else return t;if(t=Vr(t.nextSibling),t===null)break}return null}function X2(t,r,s){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=Vr(t.nextSibling),t===null))return null;return t}function n0(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Vr(t.nextSibling),t===null))return null;return t}function qf(t){return t.data==="$?"||t.data==="$~"}function Yf(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function W2(t,r){var s=t.ownerDocument;if(t.data==="$~")t._reactRetry=r;else if(t.data!=="$?"||s.readyState!=="loading")r();else{var c=function(){r(),s.removeEventListener("DOMContentLoaded",c)};s.addEventListener("DOMContentLoaded",c),t._reactRetry=c}}function Vr(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return t}var Xf=null;function r0(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="/$"||s==="/&"){if(r===0)return Vr(t.nextSibling);r--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||r++}t=t.nextSibling}return null}function a0(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var s=t.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(r===0)return t;r--}else s!=="/$"&&s!=="/&"||r++}t=t.previousSibling}return null}function l0(t,r,s){switch(r=Pc(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 uo(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Fi(t)}var Gr=new Map,i0=new Set;function Zc(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Qa=ae.d;ae.d={f:V2,r:G2,D:K2,C:Q2,L:P2,m:Z2,X:ew,S:J2,M:tw};function V2(){var t=Qa.f(),r=qc();return t||r}function G2(t){var r=qn(t);r!==null&&r.tag===5&&r.type==="form"?jx(r):Qa.r(t)}var ds=typeof document>"u"?null:document;function s0(t,r,s){var c=ds;if(c&&typeof r=="string"&&r){var p=ur(r);p='link[rel="'+t+'"][href="'+p+'"]',typeof s=="string"&&(p+='[crossorigin="'+s+'"]'),i0.has(p)||(i0.add(p),t={rel:t,crossOrigin:s,href:r},c.querySelector(p)===null&&(r=c.createElement("link"),Kn(r,"link",t),yn(r),c.head.appendChild(r)))}}function K2(t){Qa.D(t),s0("dns-prefetch",t,null)}function Q2(t,r){Qa.C(t,r),s0("preconnect",t,r)}function P2(t,r,s){Qa.L(t,r,s);var c=ds;if(c&&t&&r){var p='link[rel="preload"][as="'+ur(r)+'"]';r==="image"&&s&&s.imageSrcSet?(p+='[imagesrcset="'+ur(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(p+='[imagesizes="'+ur(s.imageSizes)+'"]')):p+='[href="'+ur(t)+'"]';var g=p;switch(r){case"style":g=fs(t);break;case"script":g=hs(t)}Gr.has(g)||(t=y({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),Gr.set(g,t),c.querySelector(p)!==null||r==="style"&&c.querySelector(fo(g))||r==="script"&&c.querySelector(ho(g))||(r=c.createElement("link"),Kn(r,"link",t),yn(r),c.head.appendChild(r)))}}function Z2(t,r){Qa.m(t,r);var s=ds;if(s&&t){var c=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+ur(c)+'"][href="'+ur(t)+'"]',g=p;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=hs(t)}if(!Gr.has(g)&&(t=y({rel:"modulepreload",href:t},r),Gr.set(g,t),s.querySelector(p)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(ho(g)))return}c=s.createElement("link"),Kn(c,"link",t),yn(c),s.head.appendChild(c)}}}function J2(t,r,s){Qa.S(t,r,s);var c=ds;if(c&&t){var p=kr(c).hoistableStyles,g=fs(t);r=r||"default";var S=p.get(g);if(!S){var M={loading:0,preload:null};if(S=c.querySelector(fo(g)))M.loading=5;else{t=y({rel:"stylesheet",href:t,"data-precedence":r},s),(s=Gr.get(g))&&Wf(t,s);var X=S=c.createElement("link");yn(X),Kn(X,"link",t),X._p=new Promise(function(ie,fe){X.onload=ie,X.onerror=fe}),X.addEventListener("load",function(){M.loading|=1}),X.addEventListener("error",function(){M.loading|=2}),M.loading|=4,Jc(S,r,c)}S={type:"stylesheet",instance:S,count:1,state:M},p.set(g,S)}}}function ew(t,r){Qa.X(t,r);var s=ds;if(s&&t){var c=kr(s).hoistableScripts,p=hs(t),g=c.get(p);g||(g=s.querySelector(ho(p)),g||(t=y({src:t,async:!0},r),(r=Gr.get(p))&&Vf(t,r),g=s.createElement("script"),yn(g),Kn(g,"link",t),s.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(p,g))}}function tw(t,r){Qa.M(t,r);var s=ds;if(s&&t){var c=kr(s).hoistableScripts,p=hs(t),g=c.get(p);g||(g=s.querySelector(ho(p)),g||(t=y({src:t,async:!0,type:"module"},r),(r=Gr.get(p))&&Vf(t,r),g=s.createElement("script"),yn(g),Kn(g,"link",t),s.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(p,g))}}function o0(t,r,s,c){var p=(p=ve.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=kr(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 g=kr(p).hoistableStyles,S=g.get(t);if(S||(p=p.ownerDocument||p,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(t,S),(g=p.querySelector(fo(t)))&&!g._p&&(S.instance=g,S.state.loading=5),Gr.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},Gr.set(t,s),g||nw(p,t,s,S.state))),r&&c===null)throw Error(i(528,""));return S}if(r&&c!==null)throw Error(i(529,""));return null;case"script":return r=s.async,s=s.src,typeof s=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=hs(s),s=kr(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="'+ur(t)+'"'}function fo(t){return'link[rel="stylesheet"]['+t+"]"}function c0(t){return y({},t,{"data-precedence":t.precedence,precedence:null})}function nw(t,r,s,c){t.querySelector('link[rel="preload"][as="style"]['+r+"]")?c.loading=1:(r=t.createElement("link"),c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2}),Kn(r,"link",s),yn(r),t.head.appendChild(r))}function hs(t){return'[src="'+ur(t)+'"]'}function ho(t){return"script[async]"+t}function u0(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var c=t.querySelector('style[data-href~="'+ur(s.href)+'"]');if(c)return r.instance=c,yn(c),c;var p=y({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return c=(t.ownerDocument||t).createElement("style"),yn(c),Kn(c,"style",p),Jc(c,s.precedence,t),r.instance=c;case"stylesheet":p=fs(s.href);var g=t.querySelector(fo(p));if(g)return r.state.loading|=4,r.instance=g,yn(g),g;c=c0(s),(p=Gr.get(p))&&Wf(c,p),g=(t.ownerDocument||t).createElement("link"),yn(g);var S=g;return S._p=new Promise(function(M,X){S.onload=M,S.onerror=X}),Kn(g,"link",c),r.state.loading|=4,Jc(g,s.precedence,t),r.instance=g;case"script":return g=hs(s.src),(p=t.querySelector(ho(g)))?(r.instance=p,yn(p),p):(c=s,(p=Gr.get(g))&&(c=y({},s),Vf(c,p)),t=t.ownerDocument||t,p=t.createElement("script"),yn(p),Kn(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,g=p,S=0;S<c.length;S++){var M=c[S];if(M.dataset.precedence===r)g=M;else if(g!==p)break}g?g.parentNode.insertBefore(t,g.nextSibling):(r=s.nodeType===9?s.head:s,r.insertBefore(t,r.firstChild))}function Wf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function Vf(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var eu=null;function d0(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 g=s[p];if(!(g[Fa]||g[Rn]||t==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(r)||"";S=t+S;var M=c.get(S);M?M.push(g):c.set(S,[g])}}return c}function f0(t,r,s){t=t.ownerDocument||t,t.head.insertBefore(s,r==="title"?t.querySelector("head > title"):null)}function rw(t,r,s){if(s===1||r.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return t=r.disabled,typeof r.precedence=="string"&&t==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function h0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function aw(t,r,s,c){if(s.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var p=fs(c.href),g=r.querySelector(fo(p));if(g){r=g._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=g,yn(g);return}g=r.ownerDocument||r,c=c0(c),(p=Gr.get(p))&&Wf(c,p),g=g.createElement("link"),yn(g);var S=g;S._p=new Promise(function(M,X){S.onload=M,S.onerror=X}),Kn(g,"link",c),s.instance=g}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(s,r),(r=s.state.preload)&&(s.state.loading&3)===0&&(t.count++,s=tu.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var Gf=0;function lw(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 g=t.unsuspend;t.unsuspend=null,g()}},6e4+r);0<t.imgBytes&&Gf===0&&(Gf=62500*L2());var p=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&ru(t,t.stylesheets),t.unsuspend)){var g=t.unsuspend;t.unsuspend=null,g()}},(t.imgBytes>Gf?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(iw,t),nu=null,tu.call(t))}function iw(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]"),g=0;g<p.length;g++){var S=p[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),c=S)}c&&s.set(null,c)}p=r.instance,S=p.getAttribute("data-precedence"),g=s.get(S)||c,g===c&&s.set(null,p),s.set(S,p),this.count++,c=tu.bind(this),p.addEventListener("load",c),p.addEventListener("error",c),g?g.parentNode.insertBefore(p,g.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(p,t.firstChild)),r.state.loading|=4}}var mo={$$typeof:_,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function sw(t,r,s,c,p,g,S,M,X){this.tag=1,this.containerInfo=t,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=xn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xn(0),this.hiddenUpdates=xn(null),this.identifierPrefix=c,this.onUncaughtError=p,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=X,this.incompleteTransitions=new Map}function m0(t,r,s,c,p,g,S,M,X,ie,fe,we){return t=new sw(t,r,s,S,X,ie,fe,we,M),r=1,g===!0&&(r|=24),g=Nr(3,null,null,r),t.current=g,g.stateNode=t,r=Nd(),r.refCount++,t.pooledCache=r,r.refCount++,g.memoizedState={element:c,isDehydrated:s,cache:r},Td(g),t}function p0(t){return t?(t=Yi,t):Yi}function x0(t,r,s,c,p,g){p=p0(p),c.context===null?c.context=p:c.pendingContext=p,c=bl(r),c.payload={element:s},g=g===void 0?null:g,g!==null&&(c.callback=g),s=vl(t,c,r),s!==null&&(yr(s,t,r),Xs(s,t,r))}function y0(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var s=t.retryLane;t.retryLane=s!==0&&s<r?s:r}}function Kf(t,r){y0(t,r),(t=t.alternate)&&y0(t,r)}function g0(t){if(t.tag===13||t.tag===31){var r=li(t,67108864);r!==null&&yr(r,t,67108864),Kf(t,67108864)}}function b0(t){if(t.tag===13||t.tag===31){var r=Fr();r=wt(r);var s=li(t,r);s!==null&&yr(s,t,r),Kf(t,r)}}var au=!0;function ow(t,r,s,c){var p=Y.T;Y.T=null;var g=ae.p;try{ae.p=2,Qf(t,r,s,c)}finally{ae.p=g,Y.T=p}}function cw(t,r,s,c){var p=Y.T;Y.T=null;var g=ae.p;try{ae.p=8,Qf(t,r,s,c)}finally{ae.p=g,Y.T=p}}function Qf(t,r,s,c){if(au){var p=Pf(c);if(p===null)Bf(t,r,c,lu,s),w0(t,c);else if(dw(p,t,r,s,c))c.stopPropagation();else if(w0(t,c),r&4&&-1<uw.indexOf(t)){for(;p!==null;){var g=qn(p);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=pn(g.pendingLanes);if(S!==0){var M=g;for(M.pendingLanes|=2,M.entangledLanes|=2;S;){var X=1<<31-et(S);M.entanglements[1]|=X,S&=~X}ka(g),(It&6)===0&&(Hc=Le()+500,so(0))}}break;case 31:case 13:M=li(g,2),M!==null&&yr(M,g,2),qc(),Kf(g,2)}if(g=Pf(c),g===null&&Bf(t,r,c,lu,s),g===p)break;p=g}p!==null&&c.stopPropagation()}else Bf(t,r,c,null,s)}}function Pf(t){return t=pa(t),Zf(t)}var lu=null;function Zf(t){if(lu=null,t=fa(t),t!==null){var r=u(t);if(r===null)t=null;else{var s=r.tag;if(s===13){if(t=d(r),t!==null)return t;t=null}else if(s===31){if(t=h(r),t!==null)return t;t=null}else if(s===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null)}}return lu=t,null}function v0(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ee()){case P:return 2;case ue:return 8;case ye:case Ne:return 32;case Me:return 268435456;default:return 32}default:return 32}}var Jf=!1,Fl=null,Ml=null,Rl=null,po=new Map,xo=new Map,zl=[],uw="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function w0(t,r){switch(t){case"focusin":case"focusout":Fl=null;break;case"dragenter":case"dragleave":Ml=null;break;case"mouseover":case"mouseout":Rl=null;break;case"pointerover":case"pointerout":po.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":xo.delete(r.pointerId)}}function yo(t,r,s,c,p,g){return t===null||t.nativeEvent!==g?(t={blockedOn:r,domEventName:s,eventSystemFlags:c,nativeEvent:g,targetContainers:[p]},r!==null&&(r=qn(r),r!==null&&g0(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),t)}function dw(t,r,s,c,p){switch(r){case"focusin":return Fl=yo(Fl,t,r,s,c,p),!0;case"dragenter":return Ml=yo(Ml,t,r,s,c,p),!0;case"mouseover":return Rl=yo(Rl,t,r,s,c,p),!0;case"pointerover":var g=p.pointerId;return po.set(g,yo(po.get(g)||null,t,r,s,c,p)),!0;case"gotpointercapture":return g=p.pointerId,xo.set(g,yo(xo.get(g)||null,t,r,s,c,p)),!0}return!1}function k0(t){var r=fa(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,Vo(t.priority,function(){b0(s)});return}}else if(r===31){if(r=h(s),r!==null){t.blockedOn=r,Vo(t.priority,function(){b0(s)});return}}else if(r===3&&s.stateNode.current.memoizedState.isDehydrated){t.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}t.blockedOn=null}function iu(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var s=Pf(t.nativeEvent);if(s===null){s=t.nativeEvent;var c=new s.constructor(s.type,s);mn=c,s.target.dispatchEvent(c),mn=null}else return r=qn(s),r!==null&&g0(r),t.blockedOn=s,!1;r.shift()}return!0}function j0(t,r,s){iu(t)&&s.delete(r)}function fw(){Jf=!1,Fl!==null&&iu(Fl)&&(Fl=null),Ml!==null&&iu(Ml)&&(Ml=null),Rl!==null&&iu(Rl)&&(Rl=null),po.forEach(j0),xo.forEach(j0)}function su(t,r){t.blockedOn===r&&(t.blockedOn=null,Jf||(Jf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,fw)))}var ou=null;function S0(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(Zf(c||s)===null)continue;break}var g=qn(s);g!==null&&(t.splice(r,3),r-=3,Qd(g,{pending:!0,data:p,method:s.method,action:c},c,p))}}))}function ms(t){function r(X){return su(X,t)}Fl!==null&&su(Fl,t),Ml!==null&&su(Ml,t),Rl!==null&&su(Rl,t),po.forEach(r),xo.forEach(r);for(var s=0;s<zl.length;s++){var c=zl[s];c.blockedOn===t&&(c.blockedOn=null)}for(;0<zl.length&&(s=zl[0],s.blockedOn===null);)k0(s),s.blockedOn===null&&zl.shift();if(s=(t.ownerDocument||t).$$reactFormReplay,s!=null)for(c=0;c<s.length;c+=3){var p=s[c],g=s[c+1],S=p[Ln]||null;if(typeof g=="function")S||S0(s);else if(S){var M=null;if(g&&g.hasAttribute("formAction")){if(p=g,S=g[Ln]||null)M=S.formAction;else if(Zf(p)!==null)continue}else M=S.action;typeof M=="function"?s[c+1]=M:(s.splice(c,3),c-=3),S0(s)}}}function C0(){function t(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return p=S})},focusReset:"manual",scroll:"manual"})}function r(){p!==null&&(p(),p=null),c||setTimeout(s,20)}function s(){if(!c&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,p=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(s,100),function(){c=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),p!==null&&(p(),p=null)}}}function eh(t){this._internalRoot=t}cu.prototype.render=eh.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var s=r.current,c=Fr();x0(s,c,t,r,null,null)},cu.prototype.unmount=eh.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;x0(t.current,2,null,t,null,null),qc(),r[da]=null}};function cu(t){this._internalRoot=t}cu.prototype.unstable_scheduleHydration=function(t){if(t){var r=il();t={blockedOn:null,target:t,priority:r};for(var s=0;s<zl.length&&r!==0&&r<zl[s].priority;s++);zl.splice(s,0,t),s===0&&k0(t)}};var N0=n.version;if(N0!=="19.2.4")throw Error(i(527,N0,"19.2.4"));ae.findDOMNode=function(t){var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(i(188)):(t=Object.keys(t).join(","),Error(i(268,t)));return t=f(r),t=t!==null?x(t):null,t=t===null?null:t.stateNode,t};var hw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var uu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!uu.isDisabled&&uu.supportsFiber)try{dt=uu.inject(hw),ht=uu}catch{}}return bo.createRoot=function(t,r){if(!o(t))throw Error(i(299));var s=!1,c="",p=Rx,g=zx,S=_x;return r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=m0(t,1,!1,null,null,s,c,null,p,g,S,C0),t[da]=r.current,_f(t),new eh(r)},bo.hydrateRoot=function(t,r,s){if(!o(t))throw Error(i(299));var c=!1,p="",g=Rx,S=zx,M=_x,X=null;return s!=null&&(s.unstable_strictMode===!0&&(c=!0),s.identifierPrefix!==void 0&&(p=s.identifierPrefix),s.onUncaughtError!==void 0&&(g=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(M=s.onRecoverableError),s.formState!==void 0&&(X=s.formState)),r=m0(t,1,!0,r,s??null,c,p,X,g,S,M,C0),r.context=p0(null),s=r.current,c=Fr(),c=wt(c),p=bl(c),p.callback=null,vl(s,p,c),s=c,r.current.lanes=s,ke(r,s),ka(r),t[da]=r.current,_f(t),new cu(r)},bo.version="19.2.4",bo}var O0;function Cw(){if(O0)return rh.exports;O0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),rh.exports=Sw(),rh.exports}var Nw=Cw();const Ew="modulepreload",Aw=function(e){return"/"+e},$0={},Rg=function(n,a,i){let o=Promise.resolve();if(a&&a.length>0){let d=function(f){return Promise.all(f.map(x=>Promise.resolve(x).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),m=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=d(a.map(f=>{if(f=Aw(f),f in $0)return;$0[f]=!0;const x=f.endsWith(".css"),y=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const v=document.createElement("link");if(v.rel=x?"stylesheet":Ew,x||(v.as="script"),v.crossOrigin="",v.href=f,m&&v.setAttribute("nonce",m),document.head.appendChild(v),x)return new Promise((b,j)=>{v.addEventListener("load",b),v.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${f}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return o.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return n().catch(u)})};class Dw extends w.Component{constructor(){super(...arguments);E0(this,"state",{hasError:!1,error:null})}static getDerivedStateFromError(a){return{hasError:!0,error:a}}render(){var a;return this.state.hasError?l.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:l.jsxs("div",{className:"text-center max-w-md",children:[l.jsx("div",{className:"text-4xl mb-3",children:"๐จ"}),l.jsx("div",{className:"text-gray-800 font-semibold mb-2",children:"Something went wrong"}),l.jsx("div",{className:"text-gray-500 text-sm mb-4",children:((a=this.state.error)==null?void 0:a.message)??"An unexpected error occurred."}),l.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white rounded-lg text-sm hover:bg-gray-700",children:"Reload"})]})}):this.props.children}}const el="/api";async function zt(e){const n=await fetch(`${el}${e}`);if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function rn(e,n){const a=await fetch(`${el}${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(`${el}${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 Pa(e,n){const a={method:"DELETE"};n!==void 0&&(a.headers={"Content-Type":"application/json"},a.body=JSON.stringify(n));const i=await fetch(`${el}${e}`,a);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const me={getCompany:()=>zt("/company"),getRoles:()=>zt("/roles"),getRole:e=>zt(`/roles/${e}`),getProjects:()=>zt("/projects"),getProject:e=>zt(`/projects/${e}`),getStandups:()=>zt("/operations/standups"),getWaves:()=>zt("/operations/waves"),getWaveDetail:e=>zt(`/operations/waves/${e}`),patchWave:(e,n)=>du(`/operations/waves/${e}`,n),getDecisions:()=>zt("/operations/decisions"),getOrgTree:()=>zt("/engine/org"),getSkills:()=>zt("/skills"),exportSkills:e=>zt(`/skills/export/${e}`),getSkillRegistry:()=>zt("/skills/registry"),installRegistrySkill:(e,n)=>rn("/skills/registry/install",{skillId:e,url:n}),createRole:e=>rn("/engine/roles",e),updateRole:(e,n)=>du(`/engine/roles/${e}`,n),deleteRole:e=>Pa(`/engine/roles/${e}`),getSessions:()=>zt("/sessions"),getSession:e=>zt(`/sessions/${e}`),createSession:(e,n="talk")=>rn("/sessions",{roleId:e,mode:n}),deleteSession:e=>Pa(`/sessions/${e}`),deleteSessions:e=>Pa("/sessions",{ids:e}),deleteEmptySessions:()=>Pa("/sessions?empty=true"),updateSession:(e,n)=>du(`/sessions/${e}`,n),sendSessionMessage:(e,n,a="talk")=>rn(`/exec/session/${e}/message`,{content:n,mode:a}),startJob:e=>rn("/jobs",e),getJob:e=>zt(`/jobs/${e}`),listJobs:e=>{const n=new URLSearchParams;e!=null&&e.status&&n.set("status",e.status),e!=null&&e.roleId&&n.set("roleId",e.roleId);const a=n.toString();return zt(`/jobs${a?"?"+a:""}`)},abortJob:e=>Pa(`/jobs/${e}`),replyToJob:(e,n)=>rn(`/jobs/${e}/reply`,{message:n}),saveWave:e=>rn("/waves/save",e),getStatus:()=>zt("/status"),detectEngine:()=>rn("/setup/detect-engine",{}),validatePath:e=>rn("/setup/validate-path",{path:e}),scaffold:e=>rn("/setup/scaffold",e),getTeams:()=>zt("/setup/teams"),browse:e=>rn("/setup/browse",{path:e}),connectAkb:e=>rn("/setup/connect-akb",{path:e}),getRequiredTools:e=>rn("/setup/required-tools",{team:e}),installTools:(e,n)=>fetch(`${el}/setup/install-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({team:e})}).then(a=>{var h;const i=(h=a.body)==null?void 0:h.getReader();if(!i)return;const o=new TextDecoder;let u="";const d=()=>i.read().then(({done:m,value:f})=>{if(m)return;u+=o.decode(f,{stream:!0});const x=u.split(`
|
|
50
|
+
`);u=x.pop()||"";let y="";for(const v of x)if(v.startsWith("event: "))y=v.slice(7);else if(v.startsWith("data: ")&&y){try{n(y,JSON.parse(v.slice(6)))}catch{}y=""}return d()});return d()}),getKnowledge:()=>zt("/knowledge"),getKnowledgeDoc:e=>{const n=e.split("/").map(encodeURIComponent).join("/");return zt(`/knowledge/${n}`)},createKnowledgeDoc:e=>rn("/knowledge",e),updateKnowledgeDoc:(e,n)=>{const a=e.split("/").map(encodeURIComponent).join("/");return fetch(`${el}/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 Pa(`/knowledge/${n}`)},getPreferences:()=>zt("/preferences"),updatePreferences:e=>du("/preferences",e),chatInChannel:e=>rn("/speech/chat",e),getSaveStatus:(e="akb")=>zt(`/save/status?repo=${e}`),save:(e,n="akb")=>rn(`/save?repo=${n}`,{message:e}),getSaveHistory:(e=20,n="akb")=>zt(`/save/history?limit=${e}&repo=${n}`),restoreSave:(e,n,a="akb")=>rn(`/save/restore?repo=${a}`,{sha:e,paths:n}),initGit:()=>rn("/save/init",{}),getSyncStatus:(e="akb")=>zt(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${el}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>zt(`/save/github-status?repo=${e}`),githubCreateRepo:(e,n="private",a="akb")=>rn(`/save/github-create-repo?repo=${a}`,{name:e,visibility:n}),addRemote:(e,n="akb")=>rn(`/save/remote?repo=${n}`,{url:e}),setCodeRoot:async e=>{const n=await fetch(`${el}/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:()=>zt("/setup/code-root"),getCostSummary:()=>zt("/cost/summary"),getSyncRoles:()=>zt("/sync/roles"),applySyncUpdate:e=>rn("/sync/apply",e),getCompanyStats:()=>zt("/sync/stats"),getCoins:()=>zt("/coins"),earnCoins:(e,n,a)=>rn("/coins/earn",{amount:e,reason:n,ref:a}),spendCoins:(e,n,a)=>rn("/coins/spend",{amount:e,reason:n,ref:a}),migrateCoins:e=>rn("/coins/migrate",{completedQuests:e}),getQuestProgress:()=>zt("/quests/progress"),saveQuestProgress:e=>fetch(`${el}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(n=>n.json()),getActiveSessions:()=>zt("/active-sessions"),getActiveSession:e=>zt(`/active-sessions/${e}`),registerActiveSession:e=>rn("/active-sessions/register",e),deleteActiveSession:e=>Pa(`/active-sessions/${e}`),cleanupActiveSessions:()=>rn("/active-sessions/cleanup",{}),getGitStatus:()=>zt("/git/status"),deleteWorktree:e=>Pa(`/git/worktrees/${encodeURIComponent(e)}`),deleteBranch:e=>Pa(`/git/branches/${encodeURIComponent(e)}`)},Tw=Object.freeze(Object.defineProperty({__proto__:null,api:me},Symbol.toStringTag,{value:"Module"}));function zg(e){const[n,a]=w.useState([]),[i,o]=w.useState("idle"),[u,d]=w.useState(""),[h,m]=w.useState([]),f=w.useRef(-1),x=w.useRef(null),y=w.useRef(0),v=w.useCallback(()=>{var N;if(!e)return;(N=x.current)==null||N.abort();const j=new AbortController;x.current=j,o("connecting");const k=f.current+1,C=`/api/jobs/${e}/stream?from=${k}`;fetch(C,{signal:j.signal}).then(async E=>{if(!E.ok||!E.body){o("error");return}o("streaming");const _=E.body.getReader(),z=new TextDecoder;let U="";for(;;){const{done:B,value:$}=await _.read();if(B)break;U+=z.decode($,{stream:!0});const q=U.split(`
|
|
51
|
+
`);U=q.pop()??"";let L="";for(const R of q)if(R.startsWith("event: "))L=R.slice(7).trim();else if(R.startsWith("data: ")){try{const I=JSON.parse(R.slice(6));if(L==="activity"){const H=I;H.seq>f.current&&(f.current=H.seq),a(Q=>Q.some(oe=>oe.seq===H.seq)?Q:[...Q,H]),H.type==="text"&&d(Q=>Q+(H.data.text??"")),H.type==="dispatch:start"&&H.data.childJobId&&m(Q=>[...Q,H.data.childJobId]),H.type==="job:done"?o("done"):H.type==="job:error"&&o("error")}else if(L==="stream:end"){const H=I.reason;o(H==="done"?"done":H==="error"?"error":"done")}}catch{}L=""}}i==="streaming"&&o("done")}).catch(E=>{E.name!=="AbortError"&&(o("error"),y.current<3&&(y.current++,setTimeout(v,1e3*y.current)))})},[e]),b=w.useCallback(()=>{y.current=0,v()},[v]);return w.useEffect(()=>{if(!e){a([]),o("idle"),d(""),m([]),f.current=-1;return}return a([]),d(""),m([]),f.current=-1,y.current=0,v(),()=>{var j;(j=x.current)==null||j.abort()}},[e,v]),{events:n,status:i,textOutput:u,childJobIds:h,reconnect:b}}function Fw(e,n){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const Mw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Rw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zw={};function L0(e,n){return(zw.jsx?Rw:Mw).test(e)}const _w=/[ \t\n\f\r]/g;function Bw(e){return typeof e=="object"?e.type==="text"?I0(e.value):!1:I0(e)}function I0(e){return e.replace(_w,"")===""}class Uo{constructor(n,a,i){this.normal=a,this.property=n,i&&(this.space=i)}}Uo.prototype.normal={};Uo.prototype.property={};Uo.prototype.space=void 0;function _g(e,n){const a={},i={};for(const o of e)Object.assign(a,o.property),Object.assign(i,o.normal);return new Uo(a,i,n)}function Kh(e){return e.toLowerCase()}class vr{constructor(n,a){this.attribute=a,this.property=n}}vr.prototype.attribute="";vr.prototype.booleanish=!1;vr.prototype.boolean=!1;vr.prototype.commaOrSpaceSeparated=!1;vr.prototype.commaSeparated=!1;vr.prototype.defined=!1;vr.prototype.mustUseProperty=!1;vr.prototype.number=!1;vr.prototype.overloadedBoolean=!1;vr.prototype.property="";vr.prototype.spaceSeparated=!1;vr.prototype.space=void 0;let Ow=0;const xt=Ti(),Tn=Ti(),Qh=Ti(),Te=Ti(),an=Ti(),bs=Ti(),Mr=Ti();function Ti(){return 2**++Ow}const Ph=Object.freeze(Object.defineProperty({__proto__:null,boolean:xt,booleanish:Tn,commaOrSpaceSeparated:Mr,commaSeparated:bs,number:Te,overloadedBoolean:Qh,spaceSeparated:an},Symbol.toStringTag,{value:"Module"})),sh=Object.keys(Ph);class Nm extends vr{constructor(n,a,i,o){let u=-1;if(super(n,a),H0(this,"space",o),typeof i=="number")for(;++u<sh.length;){const d=sh[u];H0(this,sh[u],(i&Ph[d])===Ph[d])}}}Nm.prototype.defined=!0;function H0(e,n,a){a&&(e[n]=a)}function Cs(e){const n={},a={};for(const[i,o]of Object.entries(e.properties)){const u=new Nm(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(u.mustUseProperty=!0),n[i]=u,a[Kh(i)]=i,a[Kh(u.attribute)]=i}return new Uo(n,a,e.space)}const Bg=Cs({properties:{ariaActiveDescendant:null,ariaAtomic:Tn,ariaAutoComplete:null,ariaBusy:Tn,ariaChecked:Tn,ariaColCount:Te,ariaColIndex:Te,ariaColSpan:Te,ariaControls:an,ariaCurrent:null,ariaDescribedBy:an,ariaDetails:null,ariaDisabled:Tn,ariaDropEffect:an,ariaErrorMessage:null,ariaExpanded:Tn,ariaFlowTo:an,ariaGrabbed:Tn,ariaHasPopup:null,ariaHidden:Tn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:an,ariaLevel:Te,ariaLive:null,ariaModal:Tn,ariaMultiLine:Tn,ariaMultiSelectable:Tn,ariaOrientation:null,ariaOwns:an,ariaPlaceholder:null,ariaPosInSet:Te,ariaPressed:Tn,ariaReadOnly:Tn,ariaRelevant:null,ariaRequired:Tn,ariaRoleDescription:an,ariaRowCount:Te,ariaRowIndex:Te,ariaRowSpan:Te,ariaSelected:Tn,ariaSetSize:Te,ariaSort:null,ariaValueMax:Te,ariaValueMin:Te,ariaValueNow:Te,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function Og(e,n){return n in e?e[n]:n}function $g(e,n){return Og(e,n.toLowerCase())}const $w=Cs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:bs,acceptCharset:an,accessKey:an,action:null,allow:null,allowFullScreen:xt,allowPaymentRequest:xt,allowUserMedia:xt,alt:null,as:null,async:xt,autoCapitalize:null,autoComplete:an,autoFocus:xt,autoPlay:xt,blocking:an,capture:null,charSet:null,checked:xt,cite:null,className:an,cols:Te,colSpan:null,content:null,contentEditable:Tn,controls:xt,controlsList:an,coords:Te|bs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:xt,defer:xt,dir:null,dirName:null,disabled:xt,download:Qh,draggable:Tn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:xt,formTarget:null,headers:an,height:Te,hidden:Qh,high:Te,href:null,hrefLang:null,htmlFor:an,httpEquiv:an,id:null,imageSizes:null,imageSrcSet:null,inert:xt,inputMode:null,integrity:null,is:null,isMap:xt,itemId:null,itemProp:an,itemRef:an,itemScope:xt,itemType:an,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:xt,low:Te,manifest:null,max:null,maxLength:Te,media:null,method:null,min:null,minLength:Te,multiple:xt,muted:xt,name:null,nonce:null,noModule:xt,noValidate:xt,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:xt,optimum:Te,pattern:null,ping:an,placeholder:null,playsInline:xt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:xt,referrerPolicy:null,rel:an,required:xt,reversed:xt,rows:Te,rowSpan:Te,sandbox:an,scope:null,scoped:xt,seamless:xt,selected:xt,shadowRootClonable:xt,shadowRootDelegatesFocus:xt,shadowRootMode:null,shape:null,size:Te,sizes:null,slot:null,span:Te,spellCheck:Tn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Te,step:null,style:null,tabIndex:Te,target:null,title:null,translate:null,type:null,typeMustMatch:xt,useMap:null,value:Tn,width:Te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:an,axis:null,background:null,bgColor:null,border:Te,borderColor:null,bottomMargin:Te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:xt,declare:xt,event:null,face:null,frame:null,frameBorder:null,hSpace:Te,leftMargin:Te,link:null,longDesc:null,lowSrc:null,marginHeight:Te,marginWidth:Te,noResize:xt,noHref:xt,noShade:xt,noWrap:xt,object:null,profile:null,prompt:null,rev:null,rightMargin:Te,rules:null,scheme:null,scrolling:Tn,standby:null,summary:null,text:null,topMargin:Te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:xt,disableRemotePlayback:xt,prefix:null,property:null,results:Te,security:null,unselectable:null},space:"html",transform:$g}),Lw=Cs({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Mr,accentHeight:Te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Te,amplitude:Te,arabicForm:null,ascent:Te,attributeName:null,attributeType:null,azimuth:Te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Te,by:null,calcMode:null,capHeight:Te,className:an,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:Te,diffuseConstant:Te,direction:null,display:null,dur:null,divisor:Te,dominantBaseline:null,download:xt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Te,enableBackground:null,end:null,event:null,exponent:Te,externalResourcesRequired:null,fill:null,fillOpacity:Te,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:Te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Te,horizOriginX:Te,horizOriginY:Te,id:null,ideographic:Te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Te,k:Te,k1:Te,k2:Te,k3:Te,k4:Te,kernelMatrix:Mr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Te,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:Te,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:Te,overlineThickness:Te,paintOrder:null,panose1:null,path:null,pathLength:Te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:an,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Te,pointsAtY:Te,pointsAtZ:Te,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:Te,specularExponent:Te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Te,strikethroughThickness:Te,string:null,stroke:null,strokeDashArray:Mr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Te,strokeOpacity:Te,strokeWidth:null,style:null,surfaceScale:Te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Mr,tabIndex:Te,tableValues:null,target:null,targetX:Te,targetY:Te,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:Te,underlineThickness:Te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Te,values:null,vAlphabetic:Te,vMathematical:Te,vectorEffect:null,vHanging:Te,vIdeographic:Te,version:null,vertAdvY:Te,vertOriginX:Te,vertOriginY:Te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Og}),Lg=Cs({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Ig=Cs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:$g}),Hg=Cs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),Iw={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"},Hw=/[A-Z]/g,U0=/-[a-z]/g,Uw=/^data[-\w.:]+$/i;function qw(e,n){const a=Kh(n);let i=n,o=vr;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&Uw.test(n)){if(n.charAt(4)==="-"){const u=n.slice(5).replace(U0,Xw);i="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=n.slice(4);if(!U0.test(u)){let d=u.replace(Hw,Yw);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}o=Nm}return new o(i,n)}function Yw(e){return"-"+e.toLowerCase()}function Xw(e){return e.charAt(1).toUpperCase()}const Ww=_g([Bg,$w,Lg,Ig,Hg],"html"),Em=_g([Bg,Lw,Lg,Ig,Hg],"svg");function Vw(e){return e.join(" ").trim()}var ps={},oh,q0;function Gw(){if(q0)return oh;q0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,h=/^\s+|\s+$/g,m=`
|
|
52
|
+
`,f="/",x="*",y="",v="comment",b="declaration";function j(C,N){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];N=N||{};var E=1,_=1;function z(oe){var re=oe.match(n);re&&(E+=re.length);var Y=oe.lastIndexOf(m);_=~Y?oe.length-Y:_+oe.length}function U(){var oe={line:E,column:_};return function(re){return re.position=new B(oe),L(),re}}function B(oe){this.start=oe,this.end={line:E,column:_},this.source=N.source}B.prototype.content=C;function $(oe){var re=new Error(N.source+":"+E+":"+_+": "+oe);if(re.reason=oe,re.filename=N.source,re.line=E,re.column=_,re.source=C,!N.silent)throw re}function q(oe){var re=oe.exec(C);if(re){var Y=re[0];return z(Y),C=C.slice(Y.length),re}}function L(){q(a)}function R(oe){var re;for(oe=oe||[];re=I();)re!==!1&&oe.push(re);return oe}function I(){var oe=U();if(!(f!=C.charAt(0)||x!=C.charAt(1))){for(var re=2;y!=C.charAt(re)&&(x!=C.charAt(re)||f!=C.charAt(re+1));)++re;if(re+=2,y===C.charAt(re-1))return $("End of comment missing");var Y=C.slice(2,re-2);return _+=2,z(Y),C=C.slice(re),_+=2,oe({type:v,comment:Y})}}function H(){var oe=U(),re=q(i);if(re){if(I(),!q(o))return $("property missing ':'");var Y=q(u),ae=oe({type:b,property:k(re[0].replace(e,y)),value:Y?k(Y[0].replace(e,y)):y});return q(d),ae}}function Q(){var oe=[];R(oe);for(var re;re=H();)re!==!1&&(oe.push(re),R(oe));return oe}return L(),Q()}function k(C){return C?C.replace(h,y):y}return oh=j,oh}var Y0;function Kw(){if(Y0)return ps;Y0=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(Gw());function a(i,o){let u=null;if(!i||typeof i!="string")return u;const d=(0,n.default)(i),h=typeof o=="function";return d.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:x}=m;h?o(f,x,m):x&&(u=u||{},u[f]=x)}),u}return ps}var vo={},X0;function Qw(){if(X0)return vo;X0=1,Object.defineProperty(vo,"__esModule",{value:!0}),vo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,u=function(f){return!f||a.test(f)||e.test(f)},d=function(f,x){return x.toUpperCase()},h=function(f,x){return"".concat(x,"-")},m=function(f,x){return x===void 0&&(x={}),u(f)?f:(f=f.toLowerCase(),x.reactCompat?f=f.replace(o,h):f=f.replace(i,h),f.replace(n,d))};return vo.camelCase=m,vo}var wo,W0;function Pw(){if(W0)return wo;W0=1;var e=wo&&wo.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(Kw()),a=Qw();function i(o,u){var d={};return!o||typeof o!="string"||(0,n.default)(o,function(h,m){h&&m&&(d[(0,a.camelCase)(h,u)]=m)}),d}return i.default=i,wo=i,wo}var Zw=Pw();const Jw=Mg(Zw),Ug=qg("end"),Am=qg("start");function qg(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 e5(e){const n=Am(e),a=Ug(e);if(n&&a)return{start:n,end:a}}function Ro(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?V0(e.position):"start"in e||"end"in e?V0(e):"line"in e||"column"in e?Zh(e):""}function Zh(e){return G0(e&&e.line)+":"+G0(e&&e.column)}function V0(e){return Zh(e&&e.start)+"-"+Zh(e&&e.end)}function G0(e){return e&&typeof e=="number"?e:1}class tr extends Error{constructor(n,a,i){super(),typeof a=="string"&&(i=a,a=void 0);let o="",u={},d=!1;if(a&&("line"in a&&"column"in a?u={place:a}:"start"in a&&"end"in a?u={place:a}:"type"in a?u={ancestors:[a],place:a.position}:u={...a}),typeof n=="string"?o=n:!u.cause&&n&&(d=!0,o=n.message,u.cause=n),!u.ruleId&&!u.source&&typeof i=="string"){const m=i.indexOf(":");m===-1?u.ruleId=i:(u.source=i.slice(0,m),u.ruleId=i.slice(m+1))}if(!u.place&&u.ancestors&&u.ancestors){const m=u.ancestors[u.ancestors.length-1];m&&(u.place=m.position)}const h=u.place&&"start"in u.place?u.place.start:u.place;this.ancestors=u.ancestors||void 0,this.cause=u.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=h?h.line:void 0,this.name=Ro(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}}tr.prototype.file="";tr.prototype.name="";tr.prototype.reason="";tr.prototype.message="";tr.prototype.stack="";tr.prototype.column=void 0;tr.prototype.line=void 0;tr.prototype.ancestors=void 0;tr.prototype.cause=void 0;tr.prototype.fatal=void 0;tr.prototype.place=void 0;tr.prototype.ruleId=void 0;tr.prototype.source=void 0;const Dm={}.hasOwnProperty,t5=new Map,n5=/[A-Z]/g,r5=new Set(["table","tbody","thead","tfoot","tr"]),a5=new Set(["td","th"]),Yg="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function l5(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=h5(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=f5(a,n.jsx,n.jsxs)}const o={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Em:Ww,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},u=Xg(o,e,void 0);return u&&typeof u!="string"?u:o.create(e,o.Fragment,{children:u||void 0},void 0)}function Xg(e,n,a){if(n.type==="element")return i5(e,n,a);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return s5(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return c5(e,n,a);if(n.type==="mdxjsEsm")return o5(e,n);if(n.type==="root")return u5(e,n,a);if(n.type==="text")return d5(e,n)}function i5(e,n,a){const i=e.schema;let o=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=Em,e.schema=o),e.ancestors.push(n);const u=Vg(e,n.tagName,!1),d=m5(e,n);let h=Fm(e,n);return r5.has(n.tagName)&&(h=h.filter(function(m){return typeof m=="string"?!Bw(m):!0})),Wg(e,d,u,n),Tm(d,h),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function s5(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)}Bo(e,n.position)}function o5(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Bo(e,n.position)}function c5(e,n,a){const i=e.schema;let o=i;n.name==="svg"&&i.space==="html"&&(o=Em,e.schema=o),e.ancestors.push(n);const u=n.name===null?e.Fragment:Vg(e,n.name,!0),d=p5(e,n),h=Fm(e,n);return Wg(e,d,u,n),Tm(d,h),e.ancestors.pop(),e.schema=i,e.create(n,u,d,a)}function u5(e,n,a){const i={};return Tm(i,Fm(e,n)),e.create(n,e.Fragment,i,a)}function d5(e,n){return n.value}function Wg(e,n,a,i){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(n.node=i)}function Tm(e,n){if(n.length>0){const a=n.length>1?n:n[0];a&&(e.children=a)}}function f5(e,n,a){return i;function i(o,u,d,h){const f=Array.isArray(d.children)?a:n;return h?f(u,d,h):f(u,d)}}function h5(e,n){return a;function a(i,o,u,d){const h=Array.isArray(u.children),m=Am(i);return n(o,u,d,h,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function m5(e,n){const a={};let i,o;for(o in n.properties)if(o!=="children"&&Dm.call(n.properties,o)){const u=x5(e,o,n.properties[o]);if(u){const[d,h]=u;e.tableCellAlignToStyle&&d==="align"&&typeof h=="string"&&a5.has(n.tagName)?i=h:a[d]=h}}if(i){const u=a.style||(a.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return a}function p5(e,n){const a={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const u=i.data.estree.body[0];u.type;const d=u.expression;d.type;const h=d.properties[0];h.type,Object.assign(a,e.evaluater.evaluateExpression(h.argument))}else Bo(e,n.position);else{const o=i.name;let u;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const h=i.value.data.estree.body[0];h.type,u=e.evaluater.evaluateExpression(h.expression)}else Bo(e,n.position);else u=i.value===null?!0:i.value;a[o]=u}return a}function Fm(e,n){const a=[];let i=-1;const o=e.passKeys?new Map:t5;for(;++i<n.children.length;){const u=n.children[i];let d;if(e.passKeys){const m=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(m){const f=o.get(m)||0;d=m+"-"+f,o.set(m,f+1)}}const h=Xg(e,u,d);h!==void 0&&a.push(h)}return a}function x5(e,n,a){const i=qw(e.schema,n);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=i.commaSeparated?Fw(a):Vw(a)),i.property==="style"){let o=typeof a=="object"?a:y5(e,String(a));return e.stylePropertyNameCase==="css"&&(o=g5(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?Iw[i.property]||i.property:i.attribute,a]}}function y5(e,n){try{return Jw(n,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const i=a,o=new tr("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=Yg+"#cannot-parse-style-attribute",o}}function Vg(e,n,a){let i;if(!a)i={type:"Literal",value:n};else if(n.includes(".")){const o=n.split(".");let u=-1,d;for(;++u<o.length;){const h=L0(o[u])?{type:"Identifier",name:o[u]}:{type:"Literal",value:o[u]};d=d?{type:"MemberExpression",object:d,property:h,computed:!!(u&&h.type==="Literal"),optional:!1}:h}i=d}else i=L0(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const o=i.value;return Dm.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);Bo(e)}function Bo(e,n){const a=new tr("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=Yg+"#cannot-handle-mdx-estrees-without-createevaluater",a}function g5(e){const n={};let a;for(a in e)Dm.call(e,a)&&(n[b5(a)]=e[a]);return n}function b5(e){let n=e.replace(n5,v5);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function v5(e){return"-"+e.toLowerCase()}const ch={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},w5={};function Mm(e,n){const a=w5,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Gg(e,i,o)}function Gg(e,n,a){if(k5(e)){if("value"in e)return e.type==="html"&&!a?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return K0(e.children,n,a)}return Array.isArray(e)?K0(e,n,a):""}function K0(e,n,a){const i=[];let o=-1;for(;++o<e.length;)i[o]=Gg(e[o],n,a);return i.join("")}function k5(e){return!!(e&&typeof e=="object")}const Q0=document.createElement("i");function Rm(e){const n="&"+e+";";Q0.innerHTML=n;const a=Q0.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 Kr(e,n){return e.length>0?(Br(e,e.length,0,n),e):n}const P0={}.hasOwnProperty;function Kg(e){const n={};let a=-1;for(;++a<e.length;)j5(n,e[a]);return n}function j5(e,n){let a;for(a in n){const o=(P0.call(e,a)?e[a]:void 0)||(e[a]={}),u=n[a];let d;if(u)for(d in u){P0.call(o,d)||(o[d]=[]);const h=u[d];S5(o[d],Array.isArray(h)?h:h?[h]:[])}}}function S5(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 Qg(e,n){const a=Number.parseInt(e,n);return a<9||a===11||a>13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"๏ฟฝ":String.fromCodePoint(a)}function ca(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ir=Xl(/[A-Za-z]/),er=Xl(/[\dA-Za-z]/),C5=Xl(/[#-'*+\--9=?A-Z^-~]/);function $u(e){return e!==null&&(e<32||e===127)}const Jh=Xl(/\d/),N5=Xl(/[\dA-Fa-f]/),E5=Xl(/[!-/:-@[-`{-~]/);function Ze(e){return e!==null&&e<-2}function tn(e){return e!==null&&(e<0||e===32)}function Nt(e){return e===-2||e===-1||e===32}const Ku=Xl(new RegExp("\\p{P}|\\p{S}","u")),Ai=Xl(/\s/);function Xl(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&&er(e.charCodeAt(a+1))&&er(e.charCodeAt(a+2)))o=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(d=String.fromCharCode(u));else if(u>55295&&u<57344){const h=e.charCodeAt(a+1);u<56320&&h>56319&&h<57344?(d=String.fromCharCode(u,h),o=1):d="๏ฟฝ"}else d=String.fromCharCode(u);d&&(n.push(e.slice(i,a),encodeURIComponent(d)),i=a+o+1,d=""),o&&(a+=o,o=0)}return n.join("")+e.slice(i)}function Bt(e,n,a,i){const o=i?i-1:Number.POSITIVE_INFINITY;let u=0;return d;function d(m){return Nt(m)?(e.enter(a),h(m)):n(m)}function h(m){return Nt(m)&&u++<o?(e.consume(m),h):(e.exit(a),n(m))}}const A5={tokenize:D5};function D5(e){const n=e.attempt(this.parser.constructs.contentInitial,i,o);let a;return n;function i(h){if(h===null){e.consume(h);return}return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Bt(e,n,"linePrefix")}function o(h){return e.enter("paragraph"),u(h)}function u(h){const m=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=m),a=m,d(h)}function d(h){if(h===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(h);return}return Ze(h)?(e.consume(h),e.exit("chunkText"),u):(e.consume(h),d)}}const T5={tokenize:F5},Z0={tokenize:M5};function F5(e){const n=this,a=[];let i=0,o,u,d;return h;function h(_){if(i<a.length){const z=a[i];return n.containerState=z[1],e.attempt(z[0].continuation,m,f)(_)}return f(_)}function m(_){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&E();const z=n.events.length;let U=z,B;for(;U--;)if(n.events[U][0]==="exit"&&n.events[U][1].type==="chunkFlow"){B=n.events[U][1].end;break}N(i);let $=z;for(;$<n.events.length;)n.events[$][1].end={...B},$++;return Br(n.events,U+1,0,n.events.slice(z)),n.events.length=$,f(_)}return h(_)}function f(_){if(i===a.length){if(!o)return v(_);if(o.currentConstruct&&o.currentConstruct.concrete)return j(_);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(Z0,x,y)(_)}function x(_){return o&&E(),N(i),v(_)}function y(_){return n.parser.lazy[n.now().line]=i!==a.length,d=n.now().offset,j(_)}function v(_){return n.containerState={},e.attempt(Z0,b,j)(_)}function b(_){return i++,a.push([n.currentConstruct,n.containerState]),v(_)}function j(_){if(_===null){o&&E(),N(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){C(e.exit("chunkFlow"),!0),N(0),e.consume(_);return}return Ze(_)?(e.consume(_),C(e.exit("chunkFlow")),i=0,n.interrupt=void 0,h):(e.consume(_),k)}function C(_,z){const U=n.sliceStream(_);if(z&&U.push(null),_.previous=u,u&&(u.next=_),u=_,o.defineSkip(_.start),o.write(U),n.parser.lazy[_.start.line]){let B=o.events.length;for(;B--;)if(o.events[B][1].start.offset<d&&(!o.events[B][1].end||o.events[B][1].end.offset>d))return;const $=n.events.length;let q=$,L,R;for(;q--;)if(n.events[q][0]==="exit"&&n.events[q][1].type==="chunkFlow"){if(L){R=n.events[q][1].end;break}L=!0}for(N(i),B=$;B<n.events.length;)n.events[B][1].end={...R},B++;Br(n.events,q+1,0,n.events.slice($)),n.events.length=B}}function N(_){let z=a.length;for(;z-- >_;){const U=a[z];n.containerState=U[1],U[0].exit.call(n,e)}a.length=_}function E(){o.write([null]),u=void 0,o=void 0,n.containerState._closeFlow=void 0}}function M5(e,n,a){return Bt(e,e.attempt(this.parser.constructs.document,n,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function vs(e){if(e===null||tn(e)||Ai(e))return 1;if(Ku(e))return 2}function Qu(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 em={name:"attention",resolveAll:R5,tokenize:z5};function R5(e,n){let a=-1,i,o,u,d,h,m,f,x;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(i=a;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[i][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;m=e[i][1].end.offset-e[i][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const y={...e[i][1].end},v={...e[a][1].start};J0(y,-m),J0(v,m),d={type:m>1?"strongSequence":"emphasisSequence",start:y,end:{...e[i][1].end}},h={type:m>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:v},u={type:m>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[a][1].start}},o={type:m>1?"strong":"emphasis",start:{...d.start},end:{...h.end}},e[i][1].end={...d.start},e[a][1].start={...h.end},f=[],e[i][1].end.offset-e[i][1].start.offset&&(f=Kr(f,[["enter",e[i][1],n],["exit",e[i][1],n]])),f=Kr(f,[["enter",o,n],["enter",d,n],["exit",d,n],["enter",u,n]]),f=Kr(f,Qu(n.parser.constructs.insideSpan.null,e.slice(i+1,a),n)),f=Kr(f,[["exit",u,n],["enter",h,n],["exit",h,n],["exit",o,n]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,f=Kr(f,[["enter",e[a][1],n],["exit",e[a][1],n]])):x=0,Br(e,i-1,a-i+3,f),a=i+f.length-x-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function z5(e,n){const a=this.parser.constructs.attentionMarkers.null,i=this.previous,o=vs(i);let u;return d;function d(m){return u=m,e.enter("attentionSequence"),h(m)}function h(m){if(m===u)return e.consume(m),h;const f=e.exit("attentionSequence"),x=vs(m),y=!x||x===2&&o||a.includes(m),v=!o||o===2&&x||a.includes(i);return f._open=!!(u===42?y:y&&(o||!v)),f._close=!!(u===42?v:v&&(x||!y)),n(m)}}function J0(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const _5={name:"autolink",tokenize:B5};function B5(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 ir(b)?(e.consume(b),d):b===64?a(b):f(b)}function d(b){return b===43||b===45||b===46||er(b)?(i=1,h(b)):f(b)}function h(b){return b===58?(e.consume(b),i=0,m):(b===43||b===45||b===46||er(b))&&i++<32?(e.consume(b),h):(i=0,f(b))}function m(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):b===null||b===32||b===60||$u(b)?a(b):(e.consume(b),m)}function f(b){return b===64?(e.consume(b),x):C5(b)?(e.consume(b),f):a(b)}function x(b){return er(b)?y(b):a(b)}function y(b){return b===46?(e.consume(b),i=0,x):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):v(b)}function v(b){if((b===45||er(b))&&i++<63){const j=b===45?v:y;return e.consume(b),j}return a(b)}}const qo={partial:!0,tokenize:O5};function O5(e,n,a){return i;function i(u){return Nt(u)?Bt(e,o,"linePrefix")(u):o(u)}function o(u){return u===null||Ze(u)?n(u):a(u)}}const Pg={continuation:{tokenize:L5},exit:I5,name:"blockQuote",tokenize:$5};function $5(e,n,a){const i=this;return o;function o(d){if(d===62){const h=i.containerState;return h.open||(e.enter("blockQuote",{_container:!0}),h.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),u}return a(d)}function u(d){return Nt(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(d))}}function L5(e,n,a){const i=this;return o;function o(d){return Nt(d)?Bt(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):u(d)}function u(d){return e.attempt(Pg,n,a)(d)}}function I5(e){e.exit("blockQuote")}const Zg={name:"characterEscape",tokenize:H5};function H5(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 E5(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):a(u)}}const Jg={name:"characterReference",tokenize:U5};function U5(e,n,a){const i=this;let o=0,u,d;return h;function h(y){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(y),e.exit("characterReferenceMarker"),m}function m(y){return y===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(y),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),u=31,d=er,x(y))}function f(y){return y===88||y===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(y),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,d=N5,x):(e.enter("characterReferenceValue"),u=7,d=Jh,x(y))}function x(y){if(y===59&&o){const v=e.exit("characterReferenceValue");return d===er&&!Rm(i.sliceSerialize(v))?a(y):(e.enter("characterReferenceMarker"),e.consume(y),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(y)&&o++<u?(e.consume(y),x):a(y)}}const ey={partial:!0,tokenize:Y5},ty={concrete:!0,name:"codeFenced",tokenize:q5};function q5(e,n,a){const i=this,o={partial:!0,tokenize:U};let u=0,d=0,h;return m;function m(B){return f(B)}function f(B){const $=i.events[i.events.length-1];return u=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,h=B,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(B)}function x(B){return B===h?(d++,e.consume(B),x):d<3?a(B):(e.exit("codeFencedFenceSequence"),Nt(B)?Bt(e,y,"whitespace")(B):y(B))}function y(B){return B===null||Ze(B)?(e.exit("codeFencedFence"),i.interrupt?n(B):e.check(ey,k,z)(B)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(B))}function v(B){return B===null||Ze(B)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),y(B)):Nt(B)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Bt(e,b,"whitespace")(B)):B===96&&B===h?a(B):(e.consume(B),v)}function b(B){return B===null||Ze(B)?y(B):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),j(B))}function j(B){return B===null||Ze(B)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),y(B)):B===96&&B===h?a(B):(e.consume(B),j)}function k(B){return e.attempt(o,z,C)(B)}function C(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),N}function N(B){return u>0&&Nt(B)?Bt(e,E,"linePrefix",u+1)(B):E(B)}function E(B){return B===null||Ze(B)?e.check(ey,k,z)(B):(e.enter("codeFlowValue"),_(B))}function _(B){return B===null||Ze(B)?(e.exit("codeFlowValue"),E(B)):(e.consume(B),_)}function z(B){return e.exit("codeFenced"),n(B)}function U(B,$,q){let L=0;return R;function R(re){return B.enter("lineEnding"),B.consume(re),B.exit("lineEnding"),I}function I(re){return B.enter("codeFencedFence"),Nt(re)?Bt(B,H,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(re):H(re)}function H(re){return re===h?(B.enter("codeFencedFenceSequence"),Q(re)):q(re)}function Q(re){return re===h?(L++,B.consume(re),Q):L>=d?(B.exit("codeFencedFenceSequence"),Nt(re)?Bt(B,oe,"whitespace")(re):oe(re)):q(re)}function oe(re){return re===null||Ze(re)?(B.exit("codeFencedFence"),$(re)):q(re)}}}function Y5(e,n,a){const i=this;return o;function o(d){return d===null?a(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u)}function u(d){return i.parser.lazy[i.now().line]?a(d):n(d)}}const uh={name:"codeIndented",tokenize:W5},X5={partial:!0,tokenize:V5};function W5(e,n,a){const i=this;return o;function o(f){return e.enter("codeIndented"),Bt(e,u,"linePrefix",5)(f)}function u(f){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(f):a(f)}function d(f){return f===null?m(f):Ze(f)?e.attempt(X5,d,m)(f):(e.enter("codeFlowValue"),h(f))}function h(f){return f===null||Ze(f)?(e.exit("codeFlowValue"),d(f)):(e.consume(f),h)}function m(f){return e.exit("codeIndented"),n(f)}}function V5(e,n,a){const i=this;return o;function o(d){return i.parser.lazy[i.now().line]?a(d):Ze(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):Bt(e,u,"linePrefix",5)(d)}function u(d){const h=i.events[i.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(d):Ze(d)?o(d):a(d)}}const G5={name:"codeText",previous:Q5,resolve:K5,tokenize:P5};function K5(e){let n=e.length-4,a=3,i,o;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=a;++i<n;)if(e[i][1].type==="codeTextData"){e[a][1].type="codeTextPadding",e[n][1].type="codeTextPadding",a+=2,n-=2;break}}for(i=a-1,n++;++i<=n;)o===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(o=i):(i===n||e[i][1].type==="lineEnding")&&(e[o][1].type="codeTextData",i!==o+2&&(e[o][1].end=e[i-1][1].end,e.splice(o+2,i-o-2),n-=i-o-2,i=o+2),o=void 0);return e}function Q5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function P5(e,n,a){let i=0,o,u;return d;function d(y){return e.enter("codeText"),e.enter("codeTextSequence"),h(y)}function h(y){return y===96?(e.consume(y),i++,h):(e.exit("codeTextSequence"),m(y))}function m(y){return y===null?a(y):y===32?(e.enter("space"),e.consume(y),e.exit("space"),m):y===96?(u=e.enter("codeTextSequence"),o=0,x(y)):Ze(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(y))}function f(y){return y===null||y===32||y===96||Ze(y)?(e.exit("codeTextData"),m(y)):(e.consume(y),f)}function x(y){return y===96?(e.consume(y),o++,x):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(y)):(u.type="codeTextData",f(y))}}class Z5{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&&ko(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),ko(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),ko(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);ko(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);ko(this.left,a.reverse())}}}function ko(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 eb(e){const n={};let a=-1,i,o,u,d,h,m,f;const x=new Z5(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,J5(x,a)),a=n[a],f=!0);else if(i[1]._container){for(u=a,o=void 0;u--;)if(d=x.get(u),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),d[1].type="lineEnding",o=u);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;o&&(i[1].end={...x.get(o)[1].start},h=x.slice(o,a),h.unshift(i),x.splice(o,a-o+1,h))}}return Br(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function J5(e,n){const a=e.get(n)[1],i=e.get(n)[2];let o=n-1;const u=[];let d=a._tokenizer;d||(d=i.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const h=d.events,m=[],f={};let x,y,v=-1,b=a,j=0,k=0;const C=[k];for(;b;){for(;e.get(++o)[1]!==b;);u.push(o),b._tokenizer||(x=i.sliceStream(b),b.next||x.push(null),y&&d.defineSkip(b.start),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),y=b,b=b.next}for(b=a;++v<h.length;)h[v][0]==="exit"&&h[v-1][0]==="enter"&&h[v][1].type===h[v-1][1].type&&h[v][1].start.line!==h[v][1].end.line&&(k=v+1,C.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):C.pop(),v=C.length;v--;){const N=h.slice(C[v],C[v+1]),E=u.pop();m.push([E,E+N.length-1]),e.splice(E,2,N)}for(m.reverse(),v=-1;++v<m.length;)f[j+m[v][0]]=j+m[v][1],j+=m[v][1]-m[v][0]-1;return f}const ek={resolve:nk,tokenize:rk},tk={partial:!0,tokenize:ak};function nk(e){return eb(e),e}function rk(e,n){let a;return i;function i(h){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),o(h)}function o(h){return h===null?u(h):Ze(h)?e.check(tk,d,u)(h):(e.consume(h),o)}function u(h){return e.exit("chunkContent"),e.exit("content"),n(h)}function d(h){return e.consume(h),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,o}}function ak(e,n,a){const i=this;return o;function o(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Bt(e,u,"linePrefix")}function u(d){if(d===null||Ze(d))return a(d);const h=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(d):e.interrupt(i.parser.constructs.flow,a,n)(d)}}function tb(e,n,a,i,o,u,d,h,m){const f=m||Number.POSITIVE_INFINITY;let x=0;return y;function y(N){return N===60?(e.enter(i),e.enter(o),e.enter(u),e.consume(N),e.exit(u),v):N===null||N===32||N===41||$u(N)?a(N):(e.enter(i),e.enter(d),e.enter(h),e.enter("chunkString",{contentType:"string"}),k(N))}function v(N){return N===62?(e.enter(u),e.consume(N),e.exit(u),e.exit(o),e.exit(i),n):(e.enter(h),e.enter("chunkString",{contentType:"string"}),b(N))}function b(N){return N===62?(e.exit("chunkString"),e.exit(h),v(N)):N===null||N===60||Ze(N)?a(N):(e.consume(N),N===92?j:b)}function j(N){return N===60||N===62||N===92?(e.consume(N),b):b(N)}function k(N){return!x&&(N===null||N===41||tn(N))?(e.exit("chunkString"),e.exit(h),e.exit(d),e.exit(i),n(N)):x<f&&N===40?(e.consume(N),x++,k):N===41?(e.consume(N),x--,k):N===null||N===32||N===40||$u(N)?a(N):(e.consume(N),N===92?C:k)}function C(N){return N===40||N===41||N===92?(e.consume(N),k):k(N)}}function nb(e,n,a,i,o,u){const d=this;let h=0,m;return f;function f(b){return e.enter(i),e.enter(o),e.consume(b),e.exit(o),e.enter(u),x}function x(b){return h>999||b===null||b===91||b===93&&!m||b===94&&!h&&"_hiddenFootnoteSupport"in d.parser.constructs?a(b):b===93?(e.exit(u),e.enter(o),e.consume(b),e.exit(o),e.exit(i),n):Ze(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),y(b))}function y(b){return b===null||b===91||b===93||Ze(b)||h++>999?(e.exit("chunkString"),x(b)):(e.consume(b),m||(m=!Nt(b)),b===92?v:y)}function v(b){return b===91||b===92||b===93?(e.consume(b),h++,y):y(b)}}function rb(e,n,a,i,o,u){let d;return h;function h(v){return v===34||v===39||v===40?(e.enter(i),e.enter(o),e.consume(v),e.exit(o),d=v===40?41:v,m):a(v)}function m(v){return v===d?(e.enter(o),e.consume(v),e.exit(o),e.exit(i),n):(e.enter(u),f(v))}function f(v){return v===d?(e.exit(u),m(d)):v===null?a(v):Ze(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),Bt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(v))}function x(v){return v===d||v===null||Ze(v)?(e.exit("chunkString"),f(v)):(e.consume(v),v===92?y:x)}function y(v){return v===d||v===92?(e.consume(v),x):x(v)}}function zo(e,n){let a;return i;function i(o){return Ze(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,i):Nt(o)?Bt(e,i,a?"linePrefix":"lineSuffix")(o):n(o)}}const lk={name:"definition",tokenize:sk},ik={partial:!0,tokenize:ok};function sk(e,n,a){const i=this;let o;return u;function u(b){return e.enter("definition"),d(b)}function d(b){return nb.call(i,e,h,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function h(b){return o=ca(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),m):a(b)}function m(b){return tn(b)?zo(e,f)(b):f(b)}function f(b){return tb(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(ik,y,y)(b)}function y(b){return Nt(b)?Bt(e,v,"whitespace")(b):v(b)}function v(b){return b===null||Ze(b)?(e.exit("definition"),i.parser.defined.push(o),n(b)):a(b)}}function ok(e,n,a){return i;function i(h){return tn(h)?zo(e,o)(h):a(h)}function o(h){return rb(e,u,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function u(h){return Nt(h)?Bt(e,d,"whitespace")(h):d(h)}function d(h){return h===null||Ze(h)?n(h):a(h)}}const ck={name:"hardBreakEscape",tokenize:uk};function uk(e,n,a){return i;function i(u){return e.enter("hardBreakEscape"),e.consume(u),o}function o(u){return Ze(u)?(e.exit("hardBreakEscape"),n(u)):a(u)}}const dk={name:"headingAtx",resolve:fk,tokenize:hk};function fk(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 hk(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||tn(x)?(e.exit("atxHeadingSequence"),h(x)):a(x)}function h(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||Ze(x)?(e.exit("atxHeading"),n(x)):Nt(x)?Bt(e,h,"whitespace")(x):(e.enter("atxHeadingText"),f(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),h(x))}function f(x){return x===null||x===35||tn(x)?(e.exit("atxHeadingText"),h(x)):(e.consume(x),f)}}const mk=["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"],ny=["pre","script","style","textarea"],pk={concrete:!0,name:"htmlFlow",resolveTo:gk,tokenize:bk},xk={partial:!0,tokenize:wk},yk={partial:!0,tokenize:vk};function gk(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 bk(e,n,a){const i=this;let o,u,d,h,m;return f;function f(D){return x(D)}function x(D){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(D),y}function y(D){return D===33?(e.consume(D),v):D===47?(e.consume(D),u=!0,k):D===63?(e.consume(D),o=3,i.interrupt?n:A):ir(D)?(e.consume(D),d=String.fromCharCode(D),C):a(D)}function v(D){return D===45?(e.consume(D),o=2,b):D===91?(e.consume(D),o=5,h=0,j):ir(D)?(e.consume(D),o=4,i.interrupt?n:A):a(D)}function b(D){return D===45?(e.consume(D),i.interrupt?n:A):a(D)}function j(D){const te="CDATA[";return D===te.charCodeAt(h++)?(e.consume(D),h===te.length?i.interrupt?n:H:j):a(D)}function k(D){return ir(D)?(e.consume(D),d=String.fromCharCode(D),C):a(D)}function C(D){if(D===null||D===47||D===62||tn(D)){const te=D===47,je=d.toLowerCase();return!te&&!u&&ny.includes(je)?(o=1,i.interrupt?n(D):H(D)):mk.includes(d.toLowerCase())?(o=6,te?(e.consume(D),N):i.interrupt?n(D):H(D)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(D):u?E(D):_(D))}return D===45||er(D)?(e.consume(D),d+=String.fromCharCode(D),C):a(D)}function N(D){return D===62?(e.consume(D),i.interrupt?n:H):a(D)}function E(D){return Nt(D)?(e.consume(D),E):R(D)}function _(D){return D===47?(e.consume(D),R):D===58||D===95||ir(D)?(e.consume(D),z):Nt(D)?(e.consume(D),_):R(D)}function z(D){return D===45||D===46||D===58||D===95||er(D)?(e.consume(D),z):U(D)}function U(D){return D===61?(e.consume(D),B):Nt(D)?(e.consume(D),U):_(D)}function B(D){return D===null||D===60||D===61||D===62||D===96?a(D):D===34||D===39?(e.consume(D),m=D,$):Nt(D)?(e.consume(D),B):q(D)}function $(D){return D===m?(e.consume(D),m=null,L):D===null||Ze(D)?a(D):(e.consume(D),$)}function q(D){return D===null||D===34||D===39||D===47||D===60||D===61||D===62||D===96||tn(D)?U(D):(e.consume(D),q)}function L(D){return D===47||D===62||Nt(D)?_(D):a(D)}function R(D){return D===62?(e.consume(D),I):a(D)}function I(D){return D===null||Ze(D)?H(D):Nt(D)?(e.consume(D),I):a(D)}function H(D){return D===45&&o===2?(e.consume(D),Y):D===60&&o===1?(e.consume(D),ae):D===62&&o===4?(e.consume(D),F):D===63&&o===3?(e.consume(D),A):D===93&&o===5?(e.consume(D),G):Ze(D)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(xk,W,Q)(D)):D===null||Ze(D)?(e.exit("htmlFlowData"),Q(D)):(e.consume(D),H)}function Q(D){return e.check(yk,oe,W)(D)}function oe(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),re}function re(D){return D===null||Ze(D)?Q(D):(e.enter("htmlFlowData"),H(D))}function Y(D){return D===45?(e.consume(D),A):H(D)}function ae(D){return D===47?(e.consume(D),d="",Z):H(D)}function Z(D){if(D===62){const te=d.toLowerCase();return ny.includes(te)?(e.consume(D),F):H(D)}return ir(D)&&d.length<8?(e.consume(D),d+=String.fromCharCode(D),Z):H(D)}function G(D){return D===93?(e.consume(D),A):H(D)}function A(D){return D===62?(e.consume(D),F):D===45&&o===2?(e.consume(D),A):H(D)}function F(D){return D===null||Ze(D)?(e.exit("htmlFlowData"),W(D)):(e.consume(D),F)}function W(D){return e.exit("htmlFlow"),n(D)}}function vk(e,n,a){const i=this;return o;function o(d){return Ze(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 wk(e,n,a){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(qo,n,a)}}const kk={name:"htmlText",tokenize:jk};function jk(e,n,a){const i=this;let o,u,d;return h;function h(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),m}function m(A){return A===33?(e.consume(A),f):A===47?(e.consume(A),U):A===63?(e.consume(A),_):ir(A)?(e.consume(A),q):a(A)}function f(A){return A===45?(e.consume(A),x):A===91?(e.consume(A),u=0,j):ir(A)?(e.consume(A),E):a(A)}function x(A){return A===45?(e.consume(A),b):a(A)}function y(A){return A===null?a(A):A===45?(e.consume(A),v):Ze(A)?(d=y,ae(A)):(e.consume(A),y)}function v(A){return A===45?(e.consume(A),b):y(A)}function b(A){return A===62?Y(A):A===45?v(A):y(A)}function j(A){const F="CDATA[";return A===F.charCodeAt(u++)?(e.consume(A),u===F.length?k:j):a(A)}function k(A){return A===null?a(A):A===93?(e.consume(A),C):Ze(A)?(d=k,ae(A)):(e.consume(A),k)}function C(A){return A===93?(e.consume(A),N):k(A)}function N(A){return A===62?Y(A):A===93?(e.consume(A),N):k(A)}function E(A){return A===null||A===62?Y(A):Ze(A)?(d=E,ae(A)):(e.consume(A),E)}function _(A){return A===null?a(A):A===63?(e.consume(A),z):Ze(A)?(d=_,ae(A)):(e.consume(A),_)}function z(A){return A===62?Y(A):_(A)}function U(A){return ir(A)?(e.consume(A),B):a(A)}function B(A){return A===45||er(A)?(e.consume(A),B):$(A)}function $(A){return Ze(A)?(d=$,ae(A)):Nt(A)?(e.consume(A),$):Y(A)}function q(A){return A===45||er(A)?(e.consume(A),q):A===47||A===62||tn(A)?L(A):a(A)}function L(A){return A===47?(e.consume(A),Y):A===58||A===95||ir(A)?(e.consume(A),R):Ze(A)?(d=L,ae(A)):Nt(A)?(e.consume(A),L):Y(A)}function R(A){return A===45||A===46||A===58||A===95||er(A)?(e.consume(A),R):I(A)}function I(A){return A===61?(e.consume(A),H):Ze(A)?(d=I,ae(A)):Nt(A)?(e.consume(A),I):L(A)}function H(A){return A===null||A===60||A===61||A===62||A===96?a(A):A===34||A===39?(e.consume(A),o=A,Q):Ze(A)?(d=H,ae(A)):Nt(A)?(e.consume(A),H):(e.consume(A),oe)}function Q(A){return A===o?(e.consume(A),o=void 0,re):A===null?a(A):Ze(A)?(d=Q,ae(A)):(e.consume(A),Q)}function oe(A){return A===null||A===34||A===39||A===60||A===61||A===96?a(A):A===47||A===62||tn(A)?L(A):(e.consume(A),oe)}function re(A){return A===47||A===62||tn(A)?L(A):a(A)}function Y(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),n):a(A)}function ae(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),Z}function Z(A){return Nt(A)?Bt(e,G,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):G(A)}function G(A){return e.enter("htmlTextData"),d(A)}}const zm={name:"labelEnd",resolveAll:Ek,resolveTo:Ak,tokenize:Dk},Sk={tokenize:Tk},Ck={tokenize:Fk},Nk={tokenize:Mk};function Ek(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 Ak(e,n){let a=e.length,i=0,o,u,d,h;for(;a--;)if(o=e[a][1],u){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[a][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(d){if(e[a][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(u=a,o.type!=="labelLink")){i=2;break}}else o.type==="labelEnd"&&(d=a);const m={type:e[u][1].type==="labelLink"?"link":"image",start:{...e[u][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[u][1].start},end:{...e[d][1].end}},x={type:"labelText",start:{...e[u+i+2][1].end},end:{...e[d-2][1].start}};return h=[["enter",m,n],["enter",f,n]],h=Kr(h,e.slice(u+1,u+i+3)),h=Kr(h,[["enter",x,n]]),h=Kr(h,Qu(n.parser.constructs.insideSpan.null,e.slice(u+i+4,d-3),n)),h=Kr(h,[["exit",x,n],e[d-2],e[d-1],["exit",f,n]]),h=Kr(h,e.slice(d+1)),h=Kr(h,[["exit",m,n]]),Br(e,u,e.length,h),e}function Dk(e,n,a){const i=this;let o=i.events.length,u,d;for(;o--;)if((i.events[o][1].type==="labelImage"||i.events[o][1].type==="labelLink")&&!i.events[o][1]._balanced){u=i.events[o][1];break}return h;function h(v){return u?u._inactive?y(v):(d=i.parser.defined.includes(ca(i.sliceSerialize({start:u.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(v),e.exit("labelMarker"),e.exit("labelEnd"),m):a(v)}function m(v){return v===40?e.attempt(Sk,x,d?x:y)(v):v===91?e.attempt(Ck,x,d?f:y)(v):d?x(v):y(v)}function f(v){return e.attempt(Nk,x,y)(v)}function x(v){return n(v)}function y(v){return u._balanced=!0,a(v)}}function Tk(e,n,a){return i;function i(y){return e.enter("resource"),e.enter("resourceMarker"),e.consume(y),e.exit("resourceMarker"),o}function o(y){return tn(y)?zo(e,u)(y):u(y)}function u(y){return y===41?x(y):tb(e,d,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(y)}function d(y){return tn(y)?zo(e,m)(y):x(y)}function h(y){return a(y)}function m(y){return y===34||y===39||y===40?rb(e,f,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(y):x(y)}function f(y){return tn(y)?zo(e,x)(y):x(y)}function x(y){return y===41?(e.enter("resourceMarker"),e.consume(y),e.exit("resourceMarker"),e.exit("resource"),n):a(y)}}function Fk(e,n,a){const i=this;return o;function o(h){return nb.call(i,e,u,d,"reference","referenceMarker","referenceString")(h)}function u(h){return i.parser.defined.includes(ca(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(h):a(h)}function d(h){return a(h)}}function Mk(e,n,a){return i;function i(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),o}function o(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),n):a(u)}}const Rk={name:"labelStartImage",resolveAll:zm.resolveAll,tokenize:zk};function zk(e,n,a){const i=this;return o;function o(h){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(h),e.exit("labelImageMarker"),u}function u(h){return h===91?(e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelImage"),d):a(h)}function d(h){return h===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(h):n(h)}}const _k={name:"labelStartLink",resolveAll:zm.resolveAll,tokenize:Bk};function Bk(e,n,a){const i=this;return o;function o(d){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelLink"),u}function u(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(d):n(d)}}const dh={name:"lineEnding",tokenize:Ok};function Ok(e,n){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Bt(e,n,"linePrefix")}}const Fu={name:"thematicBreak",tokenize:$k};function $k(e,n,a){let i=0,o;return u;function u(f){return e.enter("thematicBreak"),d(f)}function d(f){return o=f,h(f)}function h(f){return f===o?(e.enter("thematicBreakSequence"),m(f)):i>=3&&(f===null||Ze(f))?(e.exit("thematicBreak"),n(f)):a(f)}function m(f){return f===o?(e.consume(f),i++,m):(e.exit("thematicBreakSequence"),Nt(f)?Bt(e,h,"whitespace")(f):h(f))}}const gr={continuation:{tokenize:Uk},exit:Yk,name:"list",tokenize:Hk},Lk={partial:!0,tokenize:Xk},Ik={partial:!0,tokenize:qk};function Hk(e,n,a){const i=this,o=i.events[i.events.length-1];let u=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,d=0;return h;function h(b){const j=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:Jh(b)){if(i.containerState.type||(i.containerState.type=j,e.enter(j,{_container:!0})),j==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(Fu,a,f)(b):f(b);if(!i.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(b)}return a(b)}function m(b){return Jh(b)&&++d<10?(e.consume(b),m):(!i.interrupt||d<2)&&(i.containerState.marker?b===i.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),f(b)):a(b)}function f(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||b,e.check(qo,i.interrupt?a:x,e.attempt(Lk,v,y))}function x(b){return i.containerState.initialBlankLine=!0,u++,v(b)}function y(b){return Nt(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),v):a(b)}function v(b){return i.containerState.size=u+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(b)}}function Uk(e,n,a){const i=this;return i.containerState._closeFlow=void 0,e.check(qo,o,u);function o(h){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Bt(e,n,"listItemIndent",i.containerState.size+1)(h)}function u(h){return i.containerState.furtherBlankLines||!Nt(h)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,d(h)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(Ik,n,d)(h))}function d(h){return i.containerState._closeFlow=!0,i.interrupt=void 0,Bt(e,e.attempt(gr,n,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function qk(e,n,a){const i=this;return Bt(e,o,"listItemIndent",i.containerState.size+1);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===i.containerState.size?n(u):a(u)}}function Yk(e){e.exit(this.containerState.type)}function Xk(e,n,a){const i=this;return Bt(e,o,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(u){const d=i.events[i.events.length-1];return!Nt(u)&&d&&d[1].type==="listItemPrefixWhitespace"?n(u):a(u)}}const ry={name:"setextUnderline",resolveTo:Wk,tokenize:Vk};function Wk(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 Vk(e,n,a){const i=this;let o;return u;function u(f){let x=i.events.length,y;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){y=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||y)?(e.enter("setextHeadingLine"),o=f,d(f)):a(f)}function d(f){return e.enter("setextHeadingLineSequence"),h(f)}function h(f){return f===o?(e.consume(f),h):(e.exit("setextHeadingLineSequence"),Nt(f)?Bt(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||Ze(f)?(e.exit("setextHeadingLine"),n(f)):a(f)}}const Gk={tokenize:Kk};function Kk(e){const n=this,a=e.attempt(qo,i,e.attempt(this.parser.constructs.flowInitial,o,Bt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(ek,o)),"linePrefix")));return a;function i(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),n.currentConstruct=void 0,a}function o(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),n.currentConstruct=void 0,a}}const Qk={resolveAll:lb()},Pk=ab("string"),Zk=ab("text");function ab(e){return{resolveAll:lb(e==="text"?Jk:void 0),tokenize:n};function n(a){const i=this,o=this.parser.constructs[e],u=a.attempt(o,d,h);return d;function d(x){return f(x)?u(x):h(x)}function h(x){if(x===null){a.consume(x);return}return a.enter("data"),a.consume(x),m}function m(x){return f(x)?(a.exit("data"),u(x)):(a.consume(x),m)}function f(x){if(x===null)return!0;const y=o[x];let v=-1;if(y)for(;++v<y.length;){const b=y[v];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function lb(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 Jk(e,n){let a=0;for(;++a<=e.length;)if((a===e.length||e[a][1].type==="lineEnding")&&e[a-1][1].type==="data"){const i=e[a-1][1],o=n.sliceStream(i);let u=o.length,d=-1,h=0,m;for(;u--;){const f=o[u];if(typeof f=="string"){for(d=f.length;f.charCodeAt(d-1)===32;)h++,d--;if(d)break;d=-1}else if(f===-2)m=!0,h++;else if(f!==-1){u++;break}}if(n._contentTypeTextTrailing&&a===e.length&&(h=0),h){const f={type:a===e.length||m||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?d:i.start._bufferIndex+d,_index:i.start._index+u,line:i.end.line,column:i.end.column-h,offset:i.end.offset-h},end:{...i.end}};i.end={...f.start},i.start.offset===i.end.offset?Object.assign(i,f):(e.splice(a,0,["enter",f,n],["exit",f,n]),a+=2)}a++}return e}const e3={42:gr,43:gr,45:gr,48:gr,49:gr,50:gr,51:gr,52:gr,53:gr,54:gr,55:gr,56:gr,57:gr,62:Pg},t3={91:lk},n3={[-2]:uh,[-1]:uh,32:uh},r3={35:dk,42:Fu,45:[ry,Fu],60:pk,61:ry,95:Fu,96:ty,126:ty},a3={38:Jg,92:Zg},l3={[-5]:dh,[-4]:dh,[-3]:dh,33:Rk,38:Jg,42:em,60:[_5,kk],91:_k,92:[ck,Zg],93:zm,95:em,96:G5},i3={null:[em,Qk]},s3={null:[42,95]},o3={null:[]},c3=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:s3,contentInitial:t3,disable:o3,document:e3,flow:r3,flowInitial:n3,insideSpan:i3,string:a3,text:l3},Symbol.toStringTag,{value:"Module"}));function u3(e,n,a){let i={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const o={},u=[];let d=[],h=[];const m={attempt:$(U),check:$(B),consume:E,enter:_,exit:z,interrupt:$(B,{interrupt:!0})},f={code:null,containerState:{},defineSkip:k,events:[],now:j,parser:e,previous:null,sliceSerialize:v,sliceStream:b,write:y};let x=n.tokenize.call(f,m);return n.resolveAll&&u.push(n),f;function y(I){return d=Kr(d,I),C(),d[d.length-1]!==null?[]:(q(n,0),f.events=Qu(u,f.events,f),f.events)}function v(I,H){return f3(b(I),H)}function b(I){return d3(d,I)}function j(){const{_bufferIndex:I,_index:H,line:Q,column:oe,offset:re}=i;return{_bufferIndex:I,_index:H,line:Q,column:oe,offset:re}}function k(I){o[I.line]=I.column,R()}function C(){let I;for(;i._index<d.length;){const H=d[i._index];if(typeof H=="string")for(I=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===I&&i._bufferIndex<H.length;)N(H.charCodeAt(i._bufferIndex));else N(H)}}function N(I){x=x(I)}function E(I){Ze(I)?(i.line++,i.column=1,i.offset+=I===-3?2:1,R()):I!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===d[i._index].length&&(i._bufferIndex=-1,i._index++)),f.previous=I}function _(I,H){const Q=H||{};return Q.type=I,Q.start=j(),f.events.push(["enter",Q,f]),h.push(Q),Q}function z(I){const H=h.pop();return H.end=j(),f.events.push(["exit",H,f]),H}function U(I,H){q(I,H.from)}function B(I,H){H.restore()}function $(I,H){return Q;function Q(oe,re,Y){let ae,Z,G,A;return Array.isArray(oe)?W(oe):"tokenize"in oe?W([oe]):F(oe);function F(ve){return ze;function ze(Xe){const de=Xe!==null&&ve[Xe],Oe=Xe!==null&&ve.null,Qe=[...Array.isArray(de)?de:de?[de]:[],...Array.isArray(Oe)?Oe:Oe?[Oe]:[]];return W(Qe)(Xe)}}function W(ve){return ae=ve,Z=0,ve.length===0?Y:D(ve[Z])}function D(ve){return ze;function ze(Xe){return A=L(),G=ve,ve.partial||(f.currentConstruct=ve),ve.name&&f.parser.constructs.disable.null.includes(ve.name)?je():ve.tokenize.call(H?Object.assign(Object.create(f),H):f,m,te,je)(Xe)}}function te(ve){return I(G,A),re}function je(ve){return A.restore(),++Z<ae.length?D(ae[Z]):Y}}}function q(I,H){I.resolveAll&&!u.includes(I)&&u.push(I),I.resolve&&Br(f.events,H,f.events.length-H,I.resolve(f.events.slice(H),f)),I.resolveTo&&(f.events=I.resolveTo(f.events,f))}function L(){const I=j(),H=f.previous,Q=f.currentConstruct,oe=f.events.length,re=Array.from(h);return{from:oe,restore:Y};function Y(){i=I,f.previous=H,f.currentConstruct=Q,f.events.length=oe,h=re,R()}}function R(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function d3(e,n){const a=n.start._index,i=n.start._bufferIndex,o=n.end._index,u=n.end._bufferIndex;let d;if(a===o)d=[e[a].slice(i,u)];else{if(d=e.slice(a,o),i>-1){const h=d[0];typeof h=="string"?d[0]=h.slice(i):d.shift()}u>0&&d.push(e[o].slice(0,u))}return d}function f3(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 h3(e){const i={constructs:Kg([c3,...(e||{}).extensions||[]]),content:o(A5),defined:[],document:o(T5),flow:o(Gk),lazy:{},string:o(Pk),text:o(Zk)};return i;function o(u){return d;function d(h){return u3(i,u,h)}}}function m3(e){for(;!eb(e););return e}const ay=/[\0\t\n\r]/g;function p3(){let e=1,n="",a=!0,i;return o;function o(u,d,h){const m=[];let f,x,y,v,b;for(u=n+(typeof u=="string"?u.toString():new TextDecoder(d||void 0).decode(u)),y=0,n="",a&&(u.charCodeAt(0)===65279&&y++,a=void 0);y<u.length;){if(ay.lastIndex=y,f=ay.exec(u),v=f&&f.index!==void 0?f.index:u.length,b=u.charCodeAt(v),!f){n=u.slice(y);break}if(b===10&&y===v&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),y<v&&(m.push(u.slice(y,v)),e+=v-y),b){case 0:{m.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,m.push(-2);e++<x;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:i=!0,e=1}y=v+1}return h&&(i&&m.push(-5),n&&m.push(n),m.push(null)),m}}const x3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function y3(e){return e.replace(x3,g3)}function g3(e,n,a){if(n)return n;if(a.charCodeAt(0)===35){const o=a.charCodeAt(1),u=o===120||o===88;return Qg(a.slice(u?2:1),u?16:10)}return Rm(a)||e}const ib={}.hasOwnProperty;function b3(e,n,a){return n&&typeof n=="object"&&(a=n,n=void 0),v3(a)(m3(h3(a).document().write(p3()(e,n,!0))))}function v3(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(pe),autolinkProtocol:L,autolinkEmail:L,atxHeading:u(Et),blockQuote:u(Oe),characterEscape:L,characterReference:L,codeFenced:u(Qe),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:u(Qe,d),codeText:u(Se,d),codeTextData:L,data:L,codeFlowValue:L,definition:u(Je),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:u(Re),hardBreakEscape:u(ut),hardBreakTrailing:u(ut),htmlFlow:u(gt,d),htmlFlowData:L,htmlText:u(gt,d),htmlTextData:L,image:u(kt),label:d,link:u(pe),listItem:u(ge),listItemValue:v,listOrdered:u(xe,y),listUnordered:u(xe),paragraph:u($e),reference:D,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:u(Et),strong:u(Be),thematicBreak:u(Ee)},exit:{atxHeading:m(),atxHeadingSequence:U,autolink:m(),autolinkEmail:de,autolinkProtocol:Xe,blockQuote:m(),characterEscapeValue:R,characterReferenceMarkerHexadecimal:je,characterReferenceMarkerNumeric:je,characterReferenceValue:ve,characterReference:ze,codeFenced:m(C),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:j,codeFlowValue:R,codeIndented:m(N),codeText:m(re),codeTextData:R,data:R,definition:m(),definitionDestinationString:z,definitionLabelString:E,definitionTitleString:_,emphasis:m(),hardBreakEscape:m(H),hardBreakTrailing:m(H),htmlFlow:m(Q),htmlFlowData:R,htmlText:m(oe),htmlTextData:R,image:m(ae),label:G,labelText:Z,lineEnding:I,link:m(Y),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:te,resourceDestinationString:A,resourceTitleString:F,resource:W,setextHeading:m(q),setextHeadingLineSequence:$,setextHeadingText:B,strong:m(),thematicBreak:m()}};sb(n,(e||{}).mdastExtensions||[]);const a={};return i;function i(P){let ue={type:"root",children:[]};const ye={stack:[ue],tokenStack:[],config:n,enter:h,exit:f,buffer:d,resume:x,data:a},Ne=[];let Me=-1;for(;++Me<P.length;)if(P[Me][1].type==="listOrdered"||P[Me][1].type==="listUnordered")if(P[Me][0]==="enter")Ne.push(Me);else{const Pe=Ne.pop();Me=o(P,Pe,Me)}for(Me=-1;++Me<P.length;){const Pe=n[P[Me][0]];ib.call(Pe,P[Me][1].type)&&Pe[P[Me][1].type].call(Object.assign({sliceSerialize:P[Me][2].sliceSerialize},ye),P[Me][1])}if(ye.tokenStack.length>0){const Pe=ye.tokenStack[ye.tokenStack.length-1];(Pe[1]||ly).call(ye,void 0,Pe[0])}for(ue.position={start:Bl(P.length>0?P[0][1].start:{line:1,column:1,offset:0}),end:Bl(P.length>0?P[P.length-2][1].end:{line:1,column:1,offset:0})},Me=-1;++Me<n.transforms.length;)ue=n.transforms[Me](ue)||ue;return ue}function o(P,ue,ye){let Ne=ue-1,Me=-1,Pe=!1,_t,dt,ht,bt;for(;++Ne<=ye;){const et=P[Ne];switch(et[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{et[0]==="enter"?Me++:Me--,bt=void 0;break}case"lineEndingBlank":{et[0]==="enter"&&(_t&&!bt&&!Me&&!ht&&(ht=Ne),bt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:bt=void 0}if(!Me&&et[0]==="enter"&&et[1].type==="listItemPrefix"||Me===-1&&et[0]==="exit"&&(et[1].type==="listUnordered"||et[1].type==="listOrdered")){if(_t){let Fe=Ne;for(dt=void 0;Fe--;){const _e=P[Fe];if(_e[1].type==="lineEnding"||_e[1].type==="lineEndingBlank"){if(_e[0]==="exit")continue;dt&&(P[dt][1].type="lineEndingBlank",Pe=!0),_e[1].type="lineEnding",dt=Fe}else if(!(_e[1].type==="linePrefix"||_e[1].type==="blockQuotePrefix"||_e[1].type==="blockQuotePrefixWhitespace"||_e[1].type==="blockQuoteMarker"||_e[1].type==="listItemIndent"))break}ht&&(!dt||ht<dt)&&(_t._spread=!0),_t.end=Object.assign({},dt?P[dt][1].start:et[1].end),P.splice(dt||Ne,0,["exit",_t,et[2]]),Ne++,ye++}if(et[1].type==="listItemPrefix"){const Fe={type:"listItem",_spread:!1,start:Object.assign({},et[1].start),end:void 0};_t=Fe,P.splice(Ne,0,["enter",Fe,et[2]]),Ne++,ye++,ht=void 0,bt=!0}}}return P[ue][1]._spread=Pe,ye}function u(P,ue){return ye;function ye(Ne){h.call(this,P(Ne),Ne),ue&&ue.call(this,Ne)}}function d(){this.stack.push({type:"fragment",children:[]})}function h(P,ue,ye){this.stack[this.stack.length-1].children.push(P),this.stack.push(P),this.tokenStack.push([ue,ye||void 0]),P.position={start:Bl(ue.start),end:void 0}}function m(P){return ue;function ue(ye){P&&P.call(this,ye),f.call(this,ye)}}function f(P,ue){const ye=this.stack.pop(),Ne=this.tokenStack.pop();if(Ne)Ne[0].type!==P.type&&(ue?ue.call(this,P,Ne[0]):(Ne[1]||ly).call(this,P,Ne[0]));else throw new Error("Cannot close `"+P.type+"` ("+Ro({start:P.start,end:P.end})+"): itโs not open");ye.position.end=Bl(P.end)}function x(){return Mm(this.stack.pop())}function y(){this.data.expectingFirstListItemValue=!0}function v(P){if(this.data.expectingFirstListItemValue){const ue=this.stack[this.stack.length-2];ue.start=Number.parseInt(this.sliceSerialize(P),10),this.data.expectingFirstListItemValue=void 0}}function b(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.lang=P}function j(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.meta=P}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.value=P.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function N(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.value=P.replace(/(\r?\n|\r)$/g,"")}function E(P){const ue=this.resume(),ye=this.stack[this.stack.length-1];ye.label=ue,ye.identifier=ca(this.sliceSerialize(P)).toLowerCase()}function _(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.title=P}function z(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.url=P}function U(P){const ue=this.stack[this.stack.length-1];if(!ue.depth){const ye=this.sliceSerialize(P).length;ue.depth=ye}}function B(){this.data.setextHeadingSlurpLineEnding=!0}function $(P){const ue=this.stack[this.stack.length-1];ue.depth=this.sliceSerialize(P).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function L(P){const ye=this.stack[this.stack.length-1].children;let Ne=ye[ye.length-1];(!Ne||Ne.type!=="text")&&(Ne=Le(),Ne.position={start:Bl(P.start),end:void 0},ye.push(Ne)),this.stack.push(Ne)}function R(P){const ue=this.stack.pop();ue.value+=this.sliceSerialize(P),ue.position.end=Bl(P.end)}function I(P){const ue=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=ue.children[ue.children.length-1];ye.position.end=Bl(P.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(ue.type)&&(L.call(this,P),R.call(this,P))}function H(){this.data.atHardBreak=!0}function Q(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.value=P}function oe(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.value=P}function re(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.value=P}function Y(){const P=this.stack[this.stack.length-1];if(this.data.inReference){const ue=this.data.referenceType||"shortcut";P.type+="Reference",P.referenceType=ue,delete P.url,delete P.title}else delete P.identifier,delete P.label;this.data.referenceType=void 0}function ae(){const P=this.stack[this.stack.length-1];if(this.data.inReference){const ue=this.data.referenceType||"shortcut";P.type+="Reference",P.referenceType=ue,delete P.url,delete P.title}else delete P.identifier,delete P.label;this.data.referenceType=void 0}function Z(P){const ue=this.sliceSerialize(P),ye=this.stack[this.stack.length-2];ye.label=y3(ue),ye.identifier=ca(ue).toLowerCase()}function G(){const P=this.stack[this.stack.length-1],ue=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const Ne=P.children;ye.children=Ne}else ye.alt=ue}function A(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.url=P}function F(){const P=this.resume(),ue=this.stack[this.stack.length-1];ue.title=P}function W(){this.data.inReference=void 0}function D(){this.data.referenceType="collapsed"}function te(P){const ue=this.resume(),ye=this.stack[this.stack.length-1];ye.label=ue,ye.identifier=ca(this.sliceSerialize(P)).toLowerCase(),this.data.referenceType="full"}function je(P){this.data.characterReferenceType=P.type}function ve(P){const ue=this.sliceSerialize(P),ye=this.data.characterReferenceType;let Ne;ye?(Ne=Qg(ue,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ne=Rm(ue);const Me=this.stack[this.stack.length-1];Me.value+=Ne}function ze(P){const ue=this.stack.pop();ue.position.end=Bl(P.end)}function Xe(P){R.call(this,P);const ue=this.stack[this.stack.length-1];ue.url=this.sliceSerialize(P)}function de(P){R.call(this,P);const ue=this.stack[this.stack.length-1];ue.url="mailto:"+this.sliceSerialize(P)}function Oe(){return{type:"blockquote",children:[]}}function Qe(){return{type:"code",lang:null,meta:null,value:""}}function Se(){return{type:"inlineCode",value:""}}function Je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Re(){return{type:"emphasis",children:[]}}function Et(){return{type:"heading",depth:0,children:[]}}function ut(){return{type:"break"}}function gt(){return{type:"html",value:""}}function kt(){return{type:"image",title:null,url:"",alt:null}}function pe(){return{type:"link",title:null,url:"",children:[]}}function xe(P){return{type:"list",ordered:P.type==="listOrdered",start:null,spread:P._spread,children:[]}}function ge(P){return{type:"listItem",spread:P._spread,checked:null,children:[]}}function $e(){return{type:"paragraph",children:[]}}function Be(){return{type:"strong",children:[]}}function Le(){return{type:"text",value:""}}function Ee(){return{type:"thematicBreak"}}}function Bl(e){return{line:e.line,column:e.column,offset:e.offset}}function sb(e,n){let a=-1;for(;++a<n.length;){const i=n[a];Array.isArray(i)?sb(e,i):w3(e,i)}}function w3(e,n){let a;for(a in n)if(ib.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 ly(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+Ro({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+Ro({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Ro({start:n.start,end:n.end})+") is still open")}function k3(e){const n=this;n.parser=a;function a(i){return b3(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function j3(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 S3(e,n){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,a),[e.applyData(n,a),{type:"text",value:`
|
|
55
|
+
`}]}function C3(e,n){const a=n.value?n.value+`
|
|
56
|
+
`:"",i={},o=n.lang?n.lang.split(/\s+/):[];o.length>0&&(i.className=["language-"+o[0]]);let u={type:"element",tagName:"code",properties:i,children:[{type:"text",value:a}]};return n.meta&&(u.data={meta:n.meta}),e.patch(n,u),u=e.applyData(n,u),u={type:"element",tagName:"pre",properties:{},children:[u]},e.patch(n,u),u}function N3(e,n){const a={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function E3(e,n){const a={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function A3(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,h=e.footnoteCounts.get(i);h===void 0?(h=0,e.footnoteOrder.push(i),d=e.footnoteOrder.length):d=u+1,h+=1,e.footnoteCounts.set(i,h);const m={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(n,m);const f={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(n,f),e.applyData(n,f)}function D3(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 T3(e,n){if(e.options.allowDangerousHtml){const a={type:"raw",value:n.value};return e.patch(n,a),e.applyData(n,a)}}function ob(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 F3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return ob(e,n);const o={src:Ns(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(o.title=i.title);const u={type:"element",tagName:"img",properties:o,children:[]};return e.patch(n,u),e.applyData(n,u)}function M3(e,n){const a={src:Ns(n.url)};n.alt!==null&&n.alt!==void 0&&(a.alt=n.alt),n.title!==null&&n.title!==void 0&&(a.title=n.title);const i={type:"element",tagName:"img",properties:a,children:[]};return e.patch(n,i),e.applyData(n,i)}function R3(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 z3(e,n){const a=String(n.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return ob(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 _3(e,n){const a={href:Ns(n.url)};n.title!==null&&n.title!==void 0&&(a.title=n.title);const i={type:"element",tagName:"a",properties:a,children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function B3(e,n,a){const i=e.all(n),o=a?O3(a):cb(n),u={},d=[];if(typeof n.checked=="boolean"){const x=i[0];let y;x&&x.type==="element"&&x.tagName==="p"?y=x:(y={type:"element",tagName:"p",properties:{},children:[]},i.unshift(y)),y.children.length>0&&y.children.unshift({type:"text",value:" "}),y.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),u.className=["task-list-item"]}let h=-1;for(;++h<i.length;){const x=i[h];(o||h!==0||x.type!=="element"||x.tagName!=="p")&&d.push({type:"text",value:`
|
|
57
|
+
`}),x.type==="element"&&x.tagName==="p"&&!o?d.push(...x.children):d.push(x)}const m=i[i.length-1];m&&(o||m.type!=="element"||m.tagName!=="p")&&d.push({type:"text",value:`
|
|
58
|
+
`});const f={type:"element",tagName:"li",properties:u,children:d};return e.patch(n,f),e.applyData(n,f)}function O3(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=cb(a[i])}return n}function cb(e){const n=e.spread;return n??e.children.length>1}function $3(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 L3(e,n){const a={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function I3(e,n){const a={type:"root",children:e.wrap(e.all(n))};return e.patch(n,a),e.applyData(n,a)}function H3(e,n){const a={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}function U3(e,n){const a=e.all(n),i=a.shift(),o=[];if(i){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(n.children[0],d),o.push(d)}if(a.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},h=Am(n.children[1]),m=Ug(n.children[n.children.length-1]);h&&m&&(d.position={start:h,end:m}),o.push(d)}const u={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(n,u),e.applyData(n,u)}function q3(e,n,a){const i=a?a.children:void 0,u=(i?i.indexOf(n):1)===0?"th":"td",d=a&&a.type==="table"?a.align:void 0,h=d?d.length:n.children.length;let m=-1;const f=[];for(;++m<h;){const y=n.children[m],v={},b=d?d[m]:void 0;b&&(v.align=b);let j={type:"element",tagName:u,properties:v,children:[]};y&&(j.children=e.all(y),e.patch(y,j),j=e.applyData(y,j)),f.push(j)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(n,x),e.applyData(n,x)}function Y3(e,n){const a={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,a),e.applyData(n,a)}const iy=9,sy=32;function X3(e){const n=String(e),a=/\r?\n|\r/g;let i=a.exec(n),o=0;const u=[];for(;i;)u.push(oy(n.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=a.exec(n);return u.push(oy(n.slice(o),o>0,!1)),u.join("")}function oy(e,n,a){let i=0,o=e.length;if(n){let u=e.codePointAt(i);for(;u===iy||u===sy;)i++,u=e.codePointAt(i)}if(a){let u=e.codePointAt(o-1);for(;u===iy||u===sy;)o--,u=e.codePointAt(o-1)}return o>i?e.slice(i,o):""}function W3(e,n){const a={type:"text",value:X3(String(n.value))};return e.patch(n,a),e.applyData(n,a)}function V3(e,n){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,a),e.applyData(n,a)}const G3={blockquote:j3,break:S3,code:C3,delete:N3,emphasis:E3,footnoteReference:A3,heading:D3,html:T3,imageReference:F3,image:M3,inlineCode:R3,linkReference:z3,link:_3,listItem:B3,list:$3,paragraph:L3,root:I3,strong:H3,table:U3,tableCell:Y3,tableRow:q3,text:W3,thematicBreak:V3,toml:fu,yaml:fu,definition:fu,footnoteDefinition:fu};function fu(){}const ub=-1,Pu=0,_o=1,Lu=2,_m=3,Bm=4,Om=5,$m=6,db=7,fb=8,cy=typeof self=="object"?self:globalThis,K3=(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 Pu:case ub:return a(d,o);case _o:{const h=a([],o);for(const m of d)h.push(i(m));return h}case Lu:{const h=a({},o);for(const[m,f]of d)h[i(m)]=i(f);return h}case _m:return a(new Date(d),o);case Bm:{const{source:h,flags:m}=d;return a(new RegExp(h,m),o)}case Om:{const h=a(new Map,o);for(const[m,f]of d)h.set(i(m),i(f));return h}case $m:{const h=a(new Set,o);for(const m of d)h.add(i(m));return h}case db:{const{name:h,message:m}=d;return a(new cy[h](m),o)}case fb:return a(BigInt(d),o);case"BigInt":return a(Object(BigInt(d)),o);case"ArrayBuffer":return a(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:h}=new Uint8Array(d);return a(new DataView(h),d)}}return a(new cy[u](d),o)};return i},uy=e=>K3(new Map,e)(0),xs="",{toString:Q3}={},{keys:P3}=Object,jo=e=>{const n=typeof e;if(n!=="object"||!e)return[Pu,n];const a=Q3.call(e).slice(8,-1);switch(a){case"Array":return[_o,xs];case"Object":return[Lu,xs];case"Date":return[_m,xs];case"RegExp":return[Bm,xs];case"Map":return[Om,xs];case"Set":return[$m,xs];case"DataView":return[_o,a]}return a.includes("Array")?[_o,a]:a.includes("Error")?[db,a]:[Lu,a]},hu=([e,n])=>e===Pu&&(n==="function"||n==="symbol"),Z3=(e,n,a,i)=>{const o=(d,h)=>{const m=i.push(d)-1;return a.set(h,m),m},u=d=>{if(a.has(d))return a.get(d);let[h,m]=jo(d);switch(h){case Pu:{let x=d;switch(m){case"bigint":h=fb,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([ub],d)}return o([h,x],d)}case _o:{if(m){let v=d;return m==="DataView"?v=new Uint8Array(d.buffer):m==="ArrayBuffer"&&(v=new Uint8Array(d)),o([m,[...v]],d)}const x=[],y=o([h,x],d);for(const v of d)x.push(u(v));return y}case Lu:{if(m)switch(m){case"BigInt":return o([m,d.toString()],d);case"Boolean":case"Number":case"String":return o([m,d.valueOf()],d)}if(n&&"toJSON"in d)return u(d.toJSON());const x=[],y=o([h,x],d);for(const v of P3(d))(e||!hu(jo(d[v])))&&x.push([u(v),u(d[v])]);return y}case _m:return o([h,d.toISOString()],d);case Bm:{const{source:x,flags:y}=d;return o([h,{source:x,flags:y}],d)}case Om:{const x=[],y=o([h,x],d);for(const[v,b]of d)(e||!(hu(jo(v))||hu(jo(b))))&&x.push([u(v),u(b)]);return y}case $m:{const x=[],y=o([h,x],d);for(const v of d)(e||!hu(jo(v)))&&x.push(u(v));return y}}const{message:f}=d;return o([h,{name:m,message:f}],d)};return u},dy=(e,{json:n,lossy:a}={})=>{const i=[];return Z3(!(n||a),!!n,new Map,i)(e),i},Iu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?uy(dy(e,n)):structuredClone(e):(e,n)=>uy(dy(e,n));function J3(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 ej(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function tj(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||J3,i=e.options.footnoteBackLabel||ej,o=e.options.footnoteLabel||"Footnotes",u=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let m=-1;for(;++m<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[m]);if(!f)continue;const x=e.all(f),y=String(f.identifier).toUpperCase(),v=Ns(y.toLowerCase());let b=0;const j=[],k=e.footnoteCounts.get(y);for(;k!==void 0&&++b<=k;){j.length>0&&j.push({type:"text",value:" "});let E=typeof a=="string"?a:a(m,b);typeof E=="string"&&(E={type:"text",value:E}),j.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+v+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(m,b),className:["data-footnote-backref"]},children:Array.isArray(E)?E:[E]})}const C=x[x.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const E=C.children[C.children.length-1];E&&E.type==="text"?E.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...j)}else x.push(...j);const N={type:"element",tagName:"li",properties:{id:n+"fn-"+v},children:e.wrap(x,!0)};e.patch(f,N),h.push(N)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:u,properties:{...Iu(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
59
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(h,!0)},{type:"text",value:`
|
|
60
|
+
`}]}}const Zu=(function(e){if(e==null)return lj;if(typeof e=="function")return Ju(e);if(typeof e=="object")return Array.isArray(e)?nj(e):rj(e);if(typeof e=="string")return aj(e);throw new Error("Expected function, string, or object as test")});function nj(e){const n=[];let a=-1;for(;++a<e.length;)n[a]=Zu(e[a]);return Ju(i);function i(...o){let u=-1;for(;++u<n.length;)if(n[u].apply(this,o))return!0;return!1}}function rj(e){const n=e;return Ju(a);function a(i){const o=i;let u;for(u in e)if(o[u]!==n[u])return!1;return!0}}function aj(e){return Ju(n);function n(a){return a&&a.type===e}}function Ju(e){return n;function n(a,i,o){return!!(ij(a)&&e.call(this,a,typeof i=="number"?i:void 0,o||void 0))}}function lj(){return!0}function ij(e){return e!==null&&typeof e=="object"&&"type"in e}const hb=[],sj=!0,tm=!1,oj="skip";function mb(e,n,a,i){let o;typeof n=="function"&&typeof a!="function"?(i=a,a=n):o=n;const u=Zu(o),d=i?-1:1;h(e,void 0,[])();function h(m,f,x){const y=m&&typeof m=="object"?m:{};if(typeof y.type=="string"){const b=typeof y.tagName=="string"?y.tagName:typeof y.name=="string"?y.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(m.type+(b?"<"+b+">":""))+")"})}return v;function v(){let b=hb,j,k,C;if((!n||u(m,f,x[x.length-1]||void 0))&&(b=cj(a(m,x)),b[0]===tm))return b;if("children"in m&&m.children){const N=m;if(N.children&&b[0]!==oj)for(k=(i?N.children.length:-1)+d,C=x.concat(N);k>-1&&k<N.children.length;){const E=N.children[k];if(j=h(E,k,C)(),j[0]===tm)return j;k=typeof j[1]=="number"?j[1]:k+d}}return b}}}function cj(e){return Array.isArray(e)?e:typeof e=="number"?[sj,e]:e==null?hb:[e]}function Lm(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),mb(e,u,h,o);function h(m,f){const x=f[f.length-1],y=x?x.children.indexOf(m):void 0;return d(m,y,x)}}const nm={}.hasOwnProperty,uj={};function dj(e,n){const a=n||uj,i=new Map,o=new Map,u=new Map,d={...G3,...a.handlers},h={all:f,applyData:hj,definitionById:i,footnoteById:o,footnoteCounts:u,footnoteOrder:[],handlers:d,one:m,options:a,patch:fj,wrap:pj};return Lm(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const y=x.type==="definition"?i:o,v=String(x.identifier).toUpperCase();y.has(v)||y.set(v,x)}}),h;function m(x,y){const v=x.type,b=h.handlers[v];if(nm.call(h.handlers,v)&&b)return b(h,x,y);if(h.options.passThrough&&h.options.passThrough.includes(v)){if("children"in x){const{children:k,...C}=x,N=Iu(C);return N.children=h.all(x),N}return Iu(x)}return(h.options.unknownHandler||mj)(h,x,y)}function f(x){const y=[];if("children"in x){const v=x.children;let b=-1;for(;++b<v.length;){const j=h.one(v[b],x);if(j){if(b&&v[b-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=fy(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=fy(k.value))}Array.isArray(j)?y.push(...j):y.push(j)}}}return y}}function fj(e,n){e.position&&(n.position=e5(e))}function hj(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,Iu(u)),"children"in a&&a.children&&o!==null&&o!==void 0&&(a.children=o)}return a}function mj(e,n){const a=n.data||{},i="value"in n&&!(nm.call(a,"hProperties")||nm.call(a,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function pj(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 fy(e){let n=0,a=e.charCodeAt(n);for(;a===9||a===32;)n++,a=e.charCodeAt(n);return e.slice(n)}function hy(e,n){const a=dj(e,n),i=a.one(e,void 0),o=tj(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 xj(e,n){return e&&"run"in e?async function(a,i){const o=hy(a,{file:i,...n});await e.run(o,i)}:function(a,i){return hy(a,{file:i,...e||n})}}function my(e){if(e)throw e}var fh,py;function yj(){if(py)return fh;py=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):n.call(f)==="[object Array]"},u=function(f){if(!f||n.call(f)!=="[object Object]")return!1;var x=e.call(f,"constructor"),y=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!x&&!y)return!1;var v;for(v in f);return typeof v>"u"||e.call(f,v)},d=function(f,x){a&&x.name==="__proto__"?a(f,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):f[x.name]=x.newValue},h=function(f,x){if(x==="__proto__")if(e.call(f,x)){if(i)return i(f,x).value}else return;return f[x]};return fh=function m(){var f,x,y,v,b,j,k=arguments[0],C=1,N=arguments.length,E=!1;for(typeof k=="boolean"&&(E=k,k=arguments[1]||{},C=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});C<N;++C)if(f=arguments[C],f!=null)for(x in f)y=h(k,x),v=h(f,x),k!==v&&(E&&v&&(u(v)||(b=o(v)))?(b?(b=!1,j=y&&o(y)?y:[]):j=y&&u(y)?y:{},d(k,{name:x,newValue:m(E,j,v)})):typeof v<"u"&&d(k,{name:x,newValue:v}));return k},fh}var gj=yj();const hh=Mg(gj);function rm(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function bj(){const e=[],n={run:a,use:i};return n;function a(...o){let u=-1;const d=o.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);h(null,...o);function h(m,...f){const x=e[++u];let y=-1;if(m){d(m);return}for(;++y<o.length;)(f[y]===null||f[y]===void 0)&&(f[y]=o[y]);o=f,x?vj(x,h)(...f):d(null,...f)}}function i(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),n}}function vj(e,n){let a;return i;function i(...d){const h=e.length>d.length;let m;h&&d.push(o);try{m=e.apply(this,d)}catch(f){const x=f;if(h&&a)throw x;return o(x)}h||(m&&m.then&&typeof m.then=="function"?m.then(u,o):m instanceof Error?o(m):u(m))}function o(d,...h){a||(a=!0,n(d,...h))}function u(d){o(null,d)}}const Ca={basename:wj,dirname:kj,extname:jj,join:Sj,sep:"/"};function wj(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Yo(e);let a=0,i=-1,o=e.length,u;if(n===void 0||n.length===0||n.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else i<0&&(u=!0,i=o+1);return i<0?"":e.slice(a,i)}if(n===e)return"";let d=-1,h=n.length-1;for(;o--;)if(e.codePointAt(o)===47){if(u){a=o+1;break}}else d<0&&(u=!0,d=o+1),h>-1&&(e.codePointAt(o)===n.codePointAt(h--)?h<0&&(i=o):(h=-1,i=d));return a===i?i=d:i<0&&(i=e.length),e.slice(a,i)}function kj(e){if(Yo(e),e.length===0)return".";let n=-1,a=e.length,i;for(;--a;)if(e.codePointAt(a)===47){if(i){n=a;break}}else i||(i=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function jj(e){Yo(e);let n=e.length,a=-1,i=0,o=-1,u=0,d;for(;n--;){const h=e.codePointAt(n);if(h===47){if(d){i=n+1;break}continue}a<0&&(d=!0,a=n+1),h===46?o<0?o=n:u!==1&&(u=1):o>-1&&(u=-1)}return o<0||a<0||u===0||u===1&&o===a-1&&o===i+1?"":e.slice(o,a)}function Sj(...e){let n=-1,a;for(;++n<e.length;)Yo(e[n]),e[n]&&(a=a===void 0?e[n]:a+"/"+e[n]);return a===void 0?".":Cj(a)}function Cj(e){Yo(e);const n=e.codePointAt(0)===47;let a=Nj(e,!n);return a.length===0&&!n&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),n?"/"+a:a}function Nj(e,n){let a="",i=0,o=-1,u=0,d=-1,h,m;for(;++d<=e.length;){if(d<e.length)h=e.codePointAt(d);else{if(h===47)break;h=47}if(h===47){if(!(o===d-1||u===1))if(o!==d-1&&u===2){if(a.length<2||i!==2||a.codePointAt(a.length-1)!==46||a.codePointAt(a.length-2)!==46){if(a.length>2){if(m=a.lastIndexOf("/"),m!==a.length-1){m<0?(a="",i=0):(a=a.slice(0,m),i=a.length-1-a.lastIndexOf("/")),o=d,u=0;continue}}else if(a.length>0){a="",i=0,o=d,u=0;continue}}n&&(a=a.length>0?a+"/..":"..",i=2)}else a.length>0?a+="/"+e.slice(o+1,d):a=e.slice(o+1,d),i=d-o-1;o=d,u=0}else h===46&&u>-1?u++:u=-1}return a}function Yo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Ej={cwd:Aj};function Aj(){return"/"}function am(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Dj(e){if(typeof e=="string")e=new URL(e);else if(!am(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return Tj(e)}function Tj(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=e.pathname;let a=-1;for(;++a<n.length;)if(n.codePointAt(a)===37&&n.codePointAt(a+1)===50){const i=n.codePointAt(a+2);if(i===70||i===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(n)}const mh=["history","path","basename","stem","extname","dirname"];class pb{constructor(n){let a;n?am(n)?a={path:n}:typeof n=="string"||Fj(n)?a={value:n}:a=n:a={},this.cwd="cwd"in a?"":Ej.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<mh.length;){const u=mh[i];u in a&&a[u]!==void 0&&a[u]!==null&&(this[u]=u==="history"?[...a[u]]:a[u])}let o;for(o in a)mh.includes(o)||(this[o]=a[o])}get basename(){return typeof this.path=="string"?Ca.basename(this.path):void 0}set basename(n){xh(n,"basename"),ph(n,"basename"),this.path=Ca.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?Ca.dirname(this.path):void 0}set dirname(n){xy(this.basename,"dirname"),this.path=Ca.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?Ca.extname(this.path):void 0}set extname(n){if(ph(n,"extname"),xy(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=Ca.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){am(n)&&(n=Dj(n)),xh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?Ca.basename(this.path,this.extname):void 0}set stem(n){xh(n,"stem"),ph(n,"stem"),this.path=Ca.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 tr(n,a,i);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function ph(e,n){if(e&&e.includes(Ca.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+Ca.sep+"`")}function xh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function xy(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function Fj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Mj=(function(e){const i=this.constructor.prototype,o=i[e],u=function(){return o.apply(u,arguments)};return Object.setPrototypeOf(u,i),u}),Rj={}.hasOwnProperty;class Im extends Mj{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=bj()}copy(){const n=new Im;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];n.use(...i)}return n.data(hh(!0,{},this.namespace)),n}data(n,a){return typeof n=="string"?arguments.length===2?(bh("data",this.frozen),this.namespace[n]=a,this):Rj.call(this.namespace,n)&&this.namespace[n]||void 0:n?(bh("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[a,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const o=a.call(n,...i);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const a=mu(n),i=this.parser||this.Parser;return yh("parse",i),i(String(a),a)}process(n,a){const i=this;return this.freeze(),yh("process",this.parser||this.Parser),gh("process",this.compiler||this.Compiler),a?o(void 0,a):new Promise(o);function o(u,d){const h=mu(n),m=i.parse(h);i.run(m,h,function(x,y,v){if(x||!y||!v)return f(x);const b=y,j=i.stringify(b,v);Bj(j)?v.value=j:v.result=j,f(x,v)});function f(x,y){x||!y?d(x):u?u(y):a(void 0,y)}}}processSync(n){let a=!1,i;return this.freeze(),yh("processSync",this.parser||this.Parser),gh("processSync",this.compiler||this.Compiler),this.process(n,o),gy("processSync","process",a),i;function o(u,d){a=!0,my(u),i=d}}run(n,a,i){yy(n),this.freeze();const o=this.transformers;return!i&&typeof a=="function"&&(i=a,a=void 0),i?u(void 0,i):new Promise(u);function u(d,h){const m=mu(a);o.run(n,m,f);function f(x,y,v){const b=y||n;x?h(x):d?d(b):i(void 0,b,v)}}}runSync(n,a){let i=!1,o;return this.run(n,a,u),gy("runSync","run",i),o;function u(d,h){my(d),o=h,i=!0}}stringify(n,a){this.freeze();const i=mu(a),o=this.compiler||this.Compiler;return gh("stringify",o),yy(n),o(n,i)}use(n,...a){const i=this.attachers,o=this.namespace;if(bh("use",this.frozen),n!=null)if(typeof n=="function")m(n,a);else if(typeof n=="object")Array.isArray(n)?h(n):d(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function u(f){if(typeof f=="function")m(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[x,...y]=f;m(x,y)}else d(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function d(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(f.plugins),f.settings&&(o.settings=hh(!0,o.settings,f.settings))}function h(f){let x=-1;if(f!=null)if(Array.isArray(f))for(;++x<f.length;){const y=f[x];u(y)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,x){let y=-1,v=-1;for(;++y<i.length;)if(i[y][0]===f){v=y;break}if(v===-1)i.push([f,...x]);else if(x.length>0){let[b,...j]=x;const k=i[v][1];rm(k)&&rm(b)&&(b=hh(!0,k,b)),i[v]=[f,b,...j]}}}}const zj=new Im().freeze();function yh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function gh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function bh(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function yy(e){if(!rm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function gy(e,n,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function mu(e){return _j(e)?e:new pb(e)}function _j(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Bj(e){return typeof e=="string"||Oj(e)}function Oj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const $j="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",by=[],vy={allowDangerousHtml:!0},Lj=/^(https?|ircs?|mailto|xmpp)$/i,Ij=[{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 Hm(e){const n=Hj(e),a=Uj(e);return qj(n.runSync(n.parse(a),a),e)}function Hj(e){const n=e.rehypePlugins||by,a=e.remarkPlugins||by,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...vy}:vy;return zj().use(k3).use(a).use(xj,i).use(n)}function Uj(e){const n=e.children||"",a=new pb;return typeof n=="string"&&(a.value=n),a}function qj(e,n){const a=n.allowedElements,i=n.allowElement,o=n.components,u=n.disallowedElements,d=n.skipHtml,h=n.unwrapDisallowed,m=n.urlTransform||Yj;for(const x of Ij)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+$j+x.id,void 0);return Lm(e,f),l5(e,{Fragment:l.Fragment,components:o,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function f(x,y,v){if(x.type==="raw"&&v&&typeof y=="number")return d?v.children.splice(y,1):v.children[y]={type:"text",value:x.value},y;if(x.type==="element"){let b;for(b in ch)if(Object.hasOwn(ch,b)&&Object.hasOwn(x.properties,b)){const j=x.properties[b],k=ch[b];(k===null||k.includes(x.tagName))&&(x.properties[b]=m(String(j||""),b,x))}}if(x.type==="element"){let b=a?!a.includes(x.tagName):u?u.includes(x.tagName):!1;if(!b&&i&&typeof y=="number"&&(b=!i(x,y,v)),b&&v&&typeof y=="number")return h&&x.children?v.children.splice(y,1,...x.children):v.children.splice(y,1),y}}}function Yj(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||Lj.test(e.slice(0,n))?e:""}function wy(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 Xj(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Wj(e,n,a){const o=Zu((a||{}).ignore||[]),u=Vj(n);let d=-1;for(;++d<u.length;)mb(e,"text",h);function h(f,x){let y=-1,v;for(;++y<x.length;){const b=x[y],j=v?v.children:void 0;if(o(b,j?j.indexOf(b):void 0,v))return;v=b}if(v)return m(f,x)}function m(f,x){const y=x[x.length-1],v=u[d][0],b=u[d][1];let j=0;const C=y.children.indexOf(f);let N=!1,E=[];v.lastIndex=0;let _=v.exec(f.value);for(;_;){const z=_.index,U={index:_.index,input:_.input,stack:[...x,f]};let B=b(..._,U);if(typeof B=="string"&&(B=B.length>0?{type:"text",value:B}:void 0),B===!1?v.lastIndex=z+1:(j!==z&&E.push({type:"text",value:f.value.slice(j,z)}),Array.isArray(B)?E.push(...B):B&&E.push(B),j=z+_[0].length,N=!0),!v.global)break;_=v.exec(f.value)}return N?(j<f.value.length&&E.push({type:"text",value:f.value.slice(j)}),y.children.splice(C,1,...E)):E=[f],C+E.length}}function Vj(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([Gj(o[0]),Kj(o[1])])}return n}function Gj(e){return typeof e=="string"?new RegExp(Xj(e),"g"):e}function Kj(e){return typeof e=="function"?e:function(){return e}}const vh="phrasing",wh=["autolink","link","image","label"];function Qj(){return{transforms:[r4],enter:{literalAutolink:Zj,literalAutolinkEmail:kh,literalAutolinkHttp:kh,literalAutolinkWww:kh},exit:{literalAutolink:n4,literalAutolinkEmail:t4,literalAutolinkHttp:Jj,literalAutolinkWww:e4}}}function Pj(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:vh,notInConstruct:wh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:vh,notInConstruct:wh},{character:":",before:"[ps]",after:"\\/",inConstruct:vh,notInConstruct:wh}]}}function Zj(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function kh(e){this.config.enter.autolinkProtocol.call(this,e)}function Jj(e){this.config.exit.autolinkProtocol.call(this,e)}function e4(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 t4(e){this.config.exit.autolinkEmail.call(this,e)}function n4(e){this.exit(e)}function r4(e){Wj(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,a4],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),l4]],{ignore:["link","linkReference"]})}function a4(e,n,a,i,o){let u="";if(!xb(o)||(/^w/i.test(n)&&(a=n+a,n="",u="http://"),!i4(a)))return!1;const d=s4(a+i);if(!d[0])return!1;const h={type:"link",title:null,url:u+n+d[0],children:[{type:"text",value:n+d[0]}]};return d[1]?[h,{type:"text",value:d[1]}]:h}function l4(e,n,a,i){return!xb(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+a,children:[{type:"text",value:n+"@"+a}]}}function i4(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 s4(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=wy(e,"(");let u=wy(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 xb(e,n){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Ai(a)||Ku(a))&&(!n||a!==47)}yb.peek=x4;function o4(){this.buffer()}function c4(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function u4(){this.buffer()}function d4(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function f4(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=ca(this.sliceSerialize(e)).toLowerCase(),a.label=n}function h4(e){this.exit(e)}function m4(e){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=ca(this.sliceSerialize(e)).toLowerCase(),a.label=n}function p4(e){this.exit(e)}function x4(){return"["}function yb(e,n,a,i){const o=a.createTracker(i);let u=o.move("[^");const d=a.enter("footnoteReference"),h=a.enter("reference");return u+=o.move(a.safe(a.associationId(e),{after:"]",before:u})),h(),d(),u+=o.move("]"),u}function y4(){return{enter:{gfmFootnoteCallString:o4,gfmFootnoteCall:c4,gfmFootnoteDefinitionLabelString:u4,gfmFootnoteDefinition:d4},exit:{gfmFootnoteCallString:f4,gfmFootnoteCall:h4,gfmFootnoteDefinitionLabelString:m4,gfmFootnoteDefinition:p4}}}function g4(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:a,footnoteReference:yb},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,o,u,d){const h=u.createTracker(d);let m=h.move("[^");const f=u.enter("footnoteDefinition"),x=u.enter("label");return m+=h.move(u.safe(u.associationId(i),{before:m,after:"]"})),x(),m+=h.move("]:"),i.children&&i.children.length>0&&(h.shift(4),m+=h.move((n?`
|
|
65
|
+
`:" ")+u.indentLines(u.containerFlow(i,h.current()),n?gb:b4))),f(),m}}function b4(e,n,a){return n===0?e:gb(e,n,a)}function gb(e,n,a){return(a?"":" ")+e}const v4=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];bb.peek=C4;function w4(){return{canContainEols:["delete"],enter:{strikethrough:j4},exit:{strikethrough:S4}}}function k4(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:v4}],handlers:{delete:bb}}}function j4(e){this.enter({type:"delete",children:[]},e)}function S4(e){this.exit(e)}function bb(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 C4(){return"~"}function N4(e){return e.length}function E4(e,n){const a=n||{},i=(a.align||[]).concat(),o=a.stringLength||N4,u=[],d=[],h=[],m=[];let f=0,x=-1;for(;++x<e.length;){const k=[],C=[];let N=-1;for(e[x].length>f&&(f=e[x].length);++N<e[x].length;){const E=A4(e[x][N]);if(a.alignDelimiters!==!1){const _=o(E);C[N]=_,(m[N]===void 0||_>m[N])&&(m[N]=_)}k.push(E)}d[x]=k,h[x]=C}let y=-1;if(typeof i=="object"&&"length"in i)for(;++y<f;)u[y]=ky(i[y]);else{const k=ky(i);for(;++y<f;)u[y]=k}y=-1;const v=[],b=[];for(;++y<f;){const k=u[y];let C="",N="";k===99?(C=":",N=":"):k===108?C=":":k===114&&(N=":");let E=a.alignDelimiters===!1?1:Math.max(1,m[y]-C.length-N.length);const _=C+"-".repeat(E)+N;a.alignDelimiters!==!1&&(E=C.length+E+N.length,E>m[y]&&(m[y]=E),b[y]=E),v[y]=_}d.splice(1,0,v),h.splice(1,0,b),x=-1;const j=[];for(;++x<d.length;){const k=d[x],C=h[x];y=-1;const N=[];for(;++y<f;){const E=k[y]||"";let _="",z="";if(a.alignDelimiters!==!1){const U=m[y]-(C[y]||0),B=u[y];B===114?_=" ".repeat(U):B===99?U%2?(_=" ".repeat(U/2+.5),z=" ".repeat(U/2-.5)):(_=" ".repeat(U/2),z=_):z=" ".repeat(U)}a.delimiterStart!==!1&&!y&&N.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&E==="")&&(a.delimiterStart!==!1||y)&&N.push(" "),a.alignDelimiters!==!1&&N.push(_),N.push(E),a.alignDelimiters!==!1&&N.push(z),a.padding!==!1&&N.push(" "),(a.delimiterEnd!==!1||y!==f-1)&&N.push("|")}j.push(a.delimiterEnd===!1?N.join("").replace(/ +$/,""):N.join(""))}return j.join(`
|
|
66
|
+
`)}function A4(e){return e==null?"":String(e)}function ky(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 D4(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()),T4);return o(),d}function T4(e,n,a){return">"+(a?"":" ")+e}function F4(e,n){return jy(e,n.inConstruct,!0)&&!jy(e,n.notInConstruct,!1)}function jy(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 Sy(e,n,a,i){let o=-1;for(;++o<a.unsafe.length;)if(a.unsafe[o].character===`
|
|
67
|
+
`&&F4(a.stack,a.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
68
|
+
`}function M4(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 R4(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 z4(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 _4(e,n,a,i){const o=z4(a),u=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(R4(e,a)){const y=a.enter("codeIndented"),v=a.indentLines(u,B4);return y(),v}const h=a.createTracker(i),m=o.repeat(Math.max(M4(u,o)+1,3)),f=a.enter("codeFenced");let x=h.move(m);if(e.lang){const y=a.enter(`codeFencedLang${d}`);x+=h.move(a.safe(e.lang,{before:x,after:" ",encode:["`"],...h.current()})),y()}if(e.lang&&e.meta){const y=a.enter(`codeFencedMeta${d}`);x+=h.move(" "),x+=h.move(a.safe(e.meta,{before:x,after:`
|
|
69
|
+
`,encode:["`"],...h.current()})),y()}return x+=h.move(`
|
|
70
|
+
`),u&&(x+=h.move(u+`
|
|
71
|
+
`)),x+=h.move(m),f(),x}function B4(e,n,a){return(a?"":" ")+e}function Um(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 O4(e,n,a,i){const o=Um(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("definition");let h=a.enter("label");const m=a.createTracker(i);let f=m.move("[");return f+=m.move(a.safe(a.associationId(e),{before:f,after:"]",...m.current()})),f+=m.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=a.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(a.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=a.enter("destinationRaw"),f+=m.move(a.safe(e.url,{before:f,after:e.title?" ":`
|
|
72
|
+
`,...m.current()}))),h(),e.title&&(h=a.enter(`title${u}`),f+=m.move(" "+o),f+=m.move(a.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),d(),f}function $4(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 Oo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Hu(e,n,a){const i=vs(e),o=vs(n);return i===void 0?o===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}vb.peek=L4;function vb(e,n,a,i){const o=$4(a),u=a.enter("emphasis"),d=a.createTracker(i),h=d.move(o);let m=d.move(a.containerPhrasing(e,{after:o,before:h,...d.current()}));const f=m.charCodeAt(0),x=Hu(i.before.charCodeAt(i.before.length-1),f,o);x.inside&&(m=Oo(f)+m.slice(1));const y=m.charCodeAt(m.length-1),v=Hu(i.after.charCodeAt(0),y,o);v.inside&&(m=m.slice(0,-1)+Oo(y));const b=d.move(o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},h+m+b}function L4(e,n,a){return a.options.emphasis||"*"}function I4(e,n){let a=!1;return Lm(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,tm}),!!((!e.depth||e.depth<3)&&Mm(e)&&(n.options.setext||a))}function H4(e,n,a,i){const o=Math.max(Math.min(6,e.depth||1),1),u=a.createTracker(i);if(I4(e,a)){const x=a.enter("headingSetext"),y=a.enter("phrasing"),v=a.containerPhrasing(e,{...u.current(),before:`
|
|
73
|
+
`,after:`
|
|
74
|
+
`});return y(),x(),v+`
|
|
75
|
+
`+(o===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
|
|
76
|
+
`))+1))}const d="#".repeat(o),h=a.enter("headingAtx"),m=a.enter("phrasing");u.move(d+" ");let f=a.containerPhrasing(e,{before:"# ",after:`
|
|
77
|
+
`,...u.current()});return/^[\t ]/.test(f)&&(f=Oo(f.charCodeAt(0))+f.slice(1)),f=f?d+" "+f:d,a.options.closeAtx&&(f+=" "+d),m(),h(),f}wb.peek=U4;function wb(e){return e.value||""}function U4(){return"<"}kb.peek=q4;function kb(e,n,a,i){const o=Um(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let h=a.enter("label");const m=a.createTracker(i);let f=m.move("![");return f+=m.move(a.safe(e.alt,{before:f,after:"]",...m.current()})),f+=m.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=a.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(a.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=a.enter("destinationRaw"),f+=m.move(a.safe(e.url,{before:f,after:e.title?" ":")",...m.current()}))),h(),e.title&&(h=a.enter(`title${u}`),f+=m.move(" "+o),f+=m.move(a.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),f+=m.move(")"),d(),f}function q4(){return"!"}jb.peek=Y4;function jb(e,n,a,i){const o=e.referenceType,u=a.enter("imageReference");let d=a.enter("label");const h=a.createTracker(i);let m=h.move("![");const f=a.safe(e.alt,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const y=a.safe(a.associationId(e),{before:m,after:"]",...h.current()});return d(),a.stack=x,u(),o==="full"||!f||f!==y?m+=h.move(y+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function Y4(){return"!"}Sb.peek=X4;function Sb(e,n,a){let i=e.value||"",o="`",u=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(i);)o+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++u<a.unsafe.length;){const d=a.unsafe[u],h=a.compilePattern(d);let m;if(d.atBreak)for(;m=h.exec(i);){let f=m.index;i.charCodeAt(f)===10&&i.charCodeAt(f-1)===13&&f--,i=i.slice(0,f)+" "+i.slice(m.index+1)}}return o+i+o}function X4(){return"`"}function Cb(e,n){const a=Mm(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(a===e.url||"mailto:"+a===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Nb.peek=W4;function Nb(e,n,a,i){const o=Um(a),u=o==='"'?"Quote":"Apostrophe",d=a.createTracker(i);let h,m;if(Cb(e,a)){const x=a.stack;a.stack=[],h=a.enter("autolink");let y=d.move("<");return y+=d.move(a.containerPhrasing(e,{before:y,after:">",...d.current()})),y+=d.move(">"),h(),a.stack=x,y}h=a.enter("link"),m=a.enter("label");let f=d.move("[");return f+=d.move(a.containerPhrasing(e,{before:f,after:"](",...d.current()})),f+=d.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(a.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(m=a.enter("destinationRaw"),f+=d.move(a.safe(e.url,{before:f,after:e.title?" ":")",...d.current()}))),m(),e.title&&(m=a.enter(`title${u}`),f+=d.move(" "+o),f+=d.move(a.safe(e.title,{before:f,after:o,...d.current()})),f+=d.move(o),m()),f+=d.move(")"),h(),f}function W4(e,n,a){return Cb(e,a)?"<":"["}Eb.peek=V4;function Eb(e,n,a,i){const o=e.referenceType,u=a.enter("linkReference");let d=a.enter("label");const h=a.createTracker(i);let m=h.move("[");const f=a.containerPhrasing(e,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const y=a.safe(a.associationId(e),{before:m,after:"]",...h.current()});return d(),a.stack=x,u(),o==="full"||!f||f!==y?m+=h.move(y+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function V4(){return"["}function qm(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 G4(e){const n=qm(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 K4(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 Ab(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 Q4(e,n,a,i){const o=a.enter("list"),u=a.bulletCurrent;let d=e.ordered?K4(a):qm(a);const h=e.ordered?d==="."?")":".":G4(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),Ab(a)===d&&x){let y=-1;for(;++y<e.children.length;){const v=e.children[y];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(d=h),a.bulletCurrent=d;const f=a.containerFlow(e,i);return a.bulletLastUsed=d,a.bulletCurrent=u,o(),f}function P4(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 Z4(e,n,a,i){const o=P4(a);let u=a.bulletCurrent||qm(a);n&&n.type==="list"&&n.ordered&&(u=(typeof n.start=="number"&&n.start>-1?n.start:1)+(a.options.incrementListMarker===!1?0:n.children.indexOf(e))+u);let d=u.length+1;(o==="tab"||o==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(d=Math.ceil(d/4)*4);const h=a.createTracker(i);h.move(u+" ".repeat(d-u.length)),h.shift(d);const m=a.enter("listItem"),f=a.indentLines(a.containerFlow(e,h.current()),x);return m(),f;function x(y,v,b){return v?(b?"":" ".repeat(d))+y:(b?u:u+" ".repeat(d-u.length))+y}}function J4(e,n,a,i){const o=a.enter("paragraph"),u=a.enter("phrasing"),d=a.containerPhrasing(e,i);return u(),o(),d}const eS=Zu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function tS(e,n,a,i){return(e.children.some(function(d){return eS(d)})?a.containerPhrasing:a.containerFlow).call(a,e,i)}function nS(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}Db.peek=rS;function Db(e,n,a,i){const o=nS(a),u=a.enter("strong"),d=a.createTracker(i),h=d.move(o+o);let m=d.move(a.containerPhrasing(e,{after:o,before:h,...d.current()}));const f=m.charCodeAt(0),x=Hu(i.before.charCodeAt(i.before.length-1),f,o);x.inside&&(m=Oo(f)+m.slice(1));const y=m.charCodeAt(m.length-1),v=Hu(i.after.charCodeAt(0),y,o);v.inside&&(m=m.slice(0,-1)+Oo(y));const b=d.move(o+o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},h+m+b}function rS(e,n,a){return a.options.strong||"*"}function aS(e,n,a,i){return a.safe(e.value,i)}function lS(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 iS(e,n,a){const i=(Ab(a)+(a.options.ruleSpaces?" ":"")).repeat(lS(a));return a.options.ruleSpaces?i.slice(0,-1):i}const Tb={blockquote:D4,break:Sy,code:_4,definition:O4,emphasis:vb,hardBreak:Sy,heading:H4,html:wb,image:kb,imageReference:jb,inlineCode:Sb,link:Nb,linkReference:Eb,list:Q4,listItem:Z4,paragraph:J4,root:tS,strong:Db,text:aS,thematicBreak:iS};function sS(){return{enter:{table:oS,tableData:Cy,tableHeader:Cy,tableRow:uS},exit:{codeText:dS,table:cS,tableData:jh,tableHeader:jh,tableRow:jh}}}function oS(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 cS(e){this.exit(e),this.data.inTable=void 0}function uS(e){this.enter({type:"tableRow",children:[]},e)}function jh(e){this.exit(e)}function Cy(e){this.enter({type:"tableCell",children:[]},e)}function dS(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,fS));const a=this.stack[this.stack.length-1];a.type,a.value=n,this.exit(e)}function fS(e,n){return n==="|"?n:e}function hS(e){const n=e||{},a=n.tableCellPadding,i=n.tablePipeAlign,o=n.stringLength,u=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
78
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:d,tableCell:m,tableRow:h}};function d(b,j,k,C){return f(x(b,k,C),b.align)}function h(b,j,k,C){const N=y(b,k,C),E=f([N]);return E.slice(0,E.indexOf(`
|
|
79
|
+
`))}function m(b,j,k,C){const N=k.enter("tableCell"),E=k.enter("phrasing"),_=k.containerPhrasing(b,{...C,before:u,after:u});return E(),N(),_}function f(b,j){return E4(b,{align:j,alignDelimiters:i,padding:a,stringLength:o})}function x(b,j,k){const C=b.children;let N=-1;const E=[],_=j.enter("table");for(;++N<C.length;)E[N]=y(C[N],j,k);return _(),E}function y(b,j,k){const C=b.children;let N=-1;const E=[],_=j.enter("tableRow");for(;++N<C.length;)E[N]=m(C[N],b,j,k);return _(),E}function v(b,j,k){let C=Tb.inlineCode(b,j,k);return k.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function mS(){return{exit:{taskListCheckValueChecked:Ny,taskListCheckValueUnchecked:Ny,paragraph:xS}}}function pS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:yS}}}function Ny(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function xS(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const o=n.children;let u=-1,d;for(;++u<o.length;){const h=o[u];if(h.type==="paragraph"){d=h;break}}d===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function yS(e,n,a,i){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",h=a.createTracker(i);u&&h.move(d);let m=Tb.listItem(e,n,a,{...i,...h.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),m;function f(x){return x+d}}function gS(){return[Qj(),y4(),w4(),sS(),mS()]}function bS(e){return{extensions:[Pj(),g4(e),k4(),hS(e),pS()]}}const vS={tokenize:NS,partial:!0},Fb={tokenize:ES,partial:!0},Mb={tokenize:AS,partial:!0},Rb={tokenize:DS,partial:!0},wS={tokenize:TS,partial:!0},zb={name:"wwwAutolink",tokenize:SS,previous:Bb},_b={name:"protocolAutolink",tokenize:CS,previous:Ob},ll={name:"emailAutolink",tokenize:jS,previous:$b},Da={};function kS(){return{text:Da}}let gi=48;for(;gi<123;)Da[gi]=ll,gi++,gi===58?gi=65:gi===91&&(gi=97);Da[43]=ll;Da[45]=ll;Da[46]=ll;Da[95]=ll;Da[72]=[ll,_b];Da[104]=[ll,_b];Da[87]=[ll,zb];Da[119]=[ll,zb];function jS(e,n,a){const i=this;let o,u;return d;function d(y){return!lm(y)||!$b.call(i,i.previous)||Ym(i.events)?a(y):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(y))}function h(y){return lm(y)?(e.consume(y),h):y===64?(e.consume(y),m):a(y)}function m(y){return y===46?e.check(wS,x,f)(y):y===45||y===95||er(y)?(u=!0,e.consume(y),m):x(y)}function f(y){return e.consume(y),o=!0,m}function x(y){return u&&o&&ir(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(y)):a(y)}}function SS(e,n,a){const i=this;return o;function o(d){return d!==87&&d!==119||!Bb.call(i,i.previous)||Ym(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(vS,e.attempt(Fb,e.attempt(Mb,u),a),a)(d))}function u(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(d)}}function CS(e,n,a){const i=this;let o="",u=!1;return d;function d(y){return(y===72||y===104)&&Ob.call(i,i.previous)&&!Ym(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(y),e.consume(y),h):a(y)}function h(y){if(ir(y)&&o.length<5)return o+=String.fromCodePoint(y),e.consume(y),h;if(y===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(y),m}return a(y)}function m(y){return y===47?(e.consume(y),u?f:(u=!0,m)):a(y)}function f(y){return y===null||$u(y)||tn(y)||Ai(y)||Ku(y)?a(y):e.attempt(Fb,e.attempt(Mb,x),a)(y)}function x(y){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(y)}}function NS(e,n,a){let i=0;return o;function o(d){return(d===87||d===119)&&i<3?(i++,e.consume(d),o):d===46&&i===3?(e.consume(d),u):a(d)}function u(d){return d===null?a(d):n(d)}}function ES(e,n,a){let i,o,u;return d;function d(f){return f===46||f===95?e.check(Rb,m,h)(f):f===null||tn(f)||Ai(f)||f!==45&&Ku(f)?m(f):(u=!0,e.consume(f),d)}function h(f){return f===95?i=!0:(o=i,i=void 0),e.consume(f),d}function m(f){return o||i||!u?a(f):n(f)}}function AS(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(Rb,n,u)(d):d===null||tn(d)||Ai(d)?n(d):(e.consume(d),o)}function u(d){return d===41&&i++,e.consume(d),o}}function DS(e,n,a){return i;function i(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(e.consume(h),i):h===38?(e.consume(h),u):h===93?(e.consume(h),o):h===60||h===null||tn(h)||Ai(h)?n(h):a(h)}function o(h){return h===null||h===40||h===91||tn(h)||Ai(h)?n(h):i(h)}function u(h){return ir(h)?d(h):a(h)}function d(h){return h===59?(e.consume(h),i):ir(h)?(e.consume(h),d):a(h)}}function TS(e,n,a){return i;function i(u){return e.consume(u),o}function o(u){return er(u)?a(u):n(u)}}function Bb(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||tn(e)}function Ob(e){return!ir(e)}function $b(e){return!(e===47||lm(e))}function lm(e){return e===43||e===45||e===46||e===95||er(e)}function Ym(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 FS={tokenize:LS,partial:!0};function MS(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:BS,continuation:{tokenize:OS},exit:$S}},text:{91:{name:"gfmFootnoteCall",tokenize:_S},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:RS,resolveTo:zS}}}}function RS(e,n,a){const i=this;let o=i.events.length;const u=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d;for(;o--;){const m=i.events[o][1];if(m.type==="labelImage"){d=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return h;function h(m){if(!d||!d._balanced)return a(m);const f=ca(i.sliceSerialize({start:d.end,end:i.now()}));return f.codePointAt(0)!==94||!u.includes(f.slice(1))?a(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function zS(e,n){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},h=[e[a+1],e[a+2],["enter",i,n],e[a+3],e[a+4],["enter",o,n],["exit",o,n],["enter",u,n],["enter",d,n],["exit",d,n],["exit",u,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(a,e.length-a+1,...h),e}function _S(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return h;function h(y){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(y),e.exit("gfmFootnoteCallLabelMarker"),m}function m(y){return y!==94?a(y):(e.enter("gfmFootnoteCallMarker"),e.consume(y),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(y){if(u>999||y===93&&!d||y===null||y===91||tn(y))return a(y);if(y===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(ca(i.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(y),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):a(y)}return tn(y)||(d=!0),u++,e.consume(y),y===92?x:f}function x(y){return y===91||y===92||y===93?(e.consume(y),u++,f):f(y)}}function BS(e,n,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,h;return m;function m(j){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(j){return j===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):a(j)}function x(j){if(d>999||j===93&&!h||j===null||j===91||tn(j))return a(j);if(j===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return u=ca(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(j),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return tn(j)||(h=!0),d++,e.consume(j),j===92?y:x}function y(j){return j===91||j===92||j===93?(e.consume(j),d++,x):x(j)}function v(j){return j===58?(e.enter("definitionMarker"),e.consume(j),e.exit("definitionMarker"),o.includes(u)||o.push(u),Bt(e,b,"gfmFootnoteDefinitionWhitespace")):a(j)}function b(j){return n(j)}}function OS(e,n,a){return e.check(qo,n,e.attempt(FS,n,a))}function $S(e){e.exit("gfmFootnoteDefinition")}function LS(e,n,a){const i=this;return Bt(e,o,"gfmFootnoteDefinitionIndent",5);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?n(u):a(u)}}function IS(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:u,resolveAll:o};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(d,h){let m=-1;for(;++m<d.length;)if(d[m][0]==="enter"&&d[m][1].type==="strikethroughSequenceTemporary"&&d[m][1]._close){let f=m;for(;f--;)if(d[f][0]==="exit"&&d[f][1].type==="strikethroughSequenceTemporary"&&d[f][1]._open&&d[m][1].end.offset-d[m][1].start.offset===d[f][1].end.offset-d[f][1].start.offset){d[m][1].type="strikethroughSequence",d[f][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},d[f][1].start),end:Object.assign({},d[m][1].end)},y={type:"strikethroughText",start:Object.assign({},d[f][1].end),end:Object.assign({},d[m][1].start)},v=[["enter",x,h],["enter",d[f][1],h],["exit",d[f][1],h],["enter",y,h]],b=h.parser.constructs.insideSpan.null;b&&Br(v,v.length,0,Qu(b,d.slice(f+1,m),h)),Br(v,v.length,0,[["exit",y,h],["enter",d[m][1],h],["exit",d[m][1],h],["exit",x,h]]),Br(d,f-1,m-f+3,v),m=f+v.length-2;break}}for(m=-1;++m<d.length;)d[m][1].type==="strikethroughSequenceTemporary"&&(d[m][1].type="data");return d}function u(d,h,m){const f=this.previous,x=this.events;let y=0;return v;function v(j){return f===126&&x[x.length-1][1].type!=="characterEscape"?m(j):(d.enter("strikethroughSequenceTemporary"),b(j))}function b(j){const k=vs(f);if(j===126)return y>1?m(j):(d.consume(j),y++,b);if(y<2&&!a)return m(j);const C=d.exit("strikethroughSequenceTemporary"),N=vs(j);return C._open=!N||N===2&&!!k,C._close=!k||k===2&&!!N,h(j)}}}class HS{constructor(){this.map=[]}add(n,a,i){US(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 US(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 qS(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 YS(){return{flow:{null:{name:"table",tokenize:XS,resolveAll:WS}}}}function XS(e,n,a){const i=this;let o=0,u=0,d;return h;function h(R){let I=i.events.length-1;for(;I>-1;){const oe=i.events[I][1].type;if(oe==="lineEnding"||oe==="linePrefix")I--;else break}const H=I>-1?i.events[I][1].type:null,Q=H==="tableHead"||H==="tableRow"?B:m;return Q===B&&i.parser.lazy[i.now().line]?a(R):Q(R)}function m(R){return e.enter("tableHead"),e.enter("tableRow"),f(R)}function f(R){return R===124||(d=!0,u+=1),x(R)}function x(R){return R===null?a(R):Ze(R)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),b):a(R):Nt(R)?Bt(e,x,"whitespace")(R):(u+=1,d&&(d=!1,o+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),y(R)))}function y(R){return R===null||R===124||tn(R)?(e.exit("data"),x(R)):(e.consume(R),R===92?v:y)}function v(R){return R===92||R===124?(e.consume(R),y):y(R)}function b(R){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(R):(e.enter("tableDelimiterRow"),d=!1,Nt(R)?Bt(e,j,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):j(R))}function j(R){return R===45||R===58?C(R):R===124?(d=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),k):U(R)}function k(R){return Nt(R)?Bt(e,C,"whitespace")(R):C(R)}function C(R){return R===58?(u+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),N):R===45?(u+=1,N(R)):R===null||Ze(R)?z(R):U(R)}function N(R){return R===45?(e.enter("tableDelimiterFiller"),E(R)):U(R)}function E(R){return R===45?(e.consume(R),E):R===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),_):(e.exit("tableDelimiterFiller"),_(R))}function _(R){return Nt(R)?Bt(e,z,"whitespace")(R):z(R)}function z(R){return R===124?j(R):R===null||Ze(R)?!d||o!==u?U(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(R)):U(R)}function U(R){return a(R)}function B(R){return e.enter("tableRow"),$(R)}function $(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),$):R===null||Ze(R)?(e.exit("tableRow"),n(R)):Nt(R)?Bt(e,$,"whitespace")(R):(e.enter("data"),q(R))}function q(R){return R===null||R===124||tn(R)?(e.exit("data"),$(R)):(e.consume(R),R===92?L:q)}function L(R){return R===92||R===124?(e.consume(R),q):q(R)}}function WS(e,n){let a=-1,i=!0,o=0,u=[0,0,0,0],d=[0,0,0,0],h=!1,m=0,f,x,y;const v=new HS;for(;++a<e.length;){const b=e[a],j=b[1];b[0]==="enter"?j.type==="tableHead"?(h=!1,m!==0&&(Ey(v,n,m,f,x),x=void 0,m=0),f={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(a,0,[["enter",f,n]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(i=!0,y=void 0,u=[0,0,0,0],d=[0,a+1,0,0],h&&(h=!1,x={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},v.add(a,0,[["enter",x,n]])),o=j.type==="tableDelimiterRow"?2:x?3:1):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(i=!1,d[2]===0&&(u[1]!==0&&(d[0]=d[1],y=pu(v,n,u,o,void 0,y),u=[0,0,0,0]),d[2]=a)):j.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],y=pu(v,n,u,o,void 0,y)),u=d,d=[u[1],a,0,0])):j.type==="tableHead"?(h=!0,m=a):j.type==="tableRow"||j.type==="tableDelimiterRow"?(m=a,u[1]!==0?(d[0]=d[1],y=pu(v,n,u,o,a,y)):d[1]!==0&&(y=pu(v,n,d,o,a,y)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(d[3]=a)}for(m!==0&&Ey(v,n,m,f,x),v.consume(n.events),a=-1;++a<n.events.length;){const b=n.events[a];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=qS(n.events,a))}return e}function pu(e,n,a,i,o,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",h="tableContent";a[0]!==0&&(u.end=Object.assign({},ys(n.events,a[0])),e.add(a[0],0,[["exit",u,n]]));const m=ys(n.events,a[1]);if(u={type:d,start:Object.assign({},m),end:Object.assign({},m)},e.add(a[1],0,[["enter",u,n]]),a[2]!==0){const f=ys(n.events,a[2]),x=ys(n.events,a[3]),y={type:h,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(a[2],0,[["enter",y,n]]),i!==2){const v=n.events[a[2]],b=n.events[a[3]];if(v[1].end=Object.assign({},b[1].end),v[1].type="chunkText",v[1].contentType="text",a[3]>a[2]+1){const j=a[2]+1,k=a[3]-a[2]-1;e.add(j,k,[])}}e.add(a[3]+1,0,[["exit",y,n]])}return o!==void 0&&(u.end=Object.assign({},ys(n.events,o)),e.add(o,0,[["exit",u,n]]),u=void 0),u}function Ey(e,n,a,i,o){const u=[],d=ys(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 ys(e,n){const a=e[n],i=a[0]==="enter"?"start":"end";return a[1][i]}const VS={name:"tasklistCheck",tokenize:KS};function GS(){return{text:{91:VS}}}function KS(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 tn(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),d):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),d):a(m)}function d(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),h):a(m)}function h(m){return Ze(m)?n(m):Nt(m)?e.check({tokenize:QS},n,a)(m):a(m)}}function QS(e,n,a){return Bt(e,i,"whitespace");function i(o){return o===null?a(o):n(o)}}function PS(e){return Kg([kS(),MS(),IS(e),YS(),GS()])}const ZS={};function Xm(e){const n=this,a=e||ZS,i=n.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(PS(a)),u.push(gS()),d.push(bS(a))}function Xo({content:e,className:n=""}){return l.jsx("div",{className:`office-markdown ${n}`,children:l.jsx(Hm,{remarkPlugins:[Xm],components:{code:JS,table:({children:a})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:a})})},children:e})})}function JS({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
80
|
+
`)?l.jsx(eC,{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 eC({children:e,language:n}){const[a,i]=w.useState(!1),o=String(e).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"office-code-block group relative my-2",children:[n&&l.jsx("div",{className:"text-[10px] text-gray-400 px-3 pt-1.5",children:n}),l.jsx("button",{onClick:u,className:"absolute top-1.5 right-2 text-[10px] text-gray-400 hover:text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:o})})]})}const Ay={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},tC=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function nC(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 rC(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 Lb(e,n){const a=Ay[e];if(a&&n)return n[a];const i=tC.exec(e);if(i){const[,o,u,d]=i,h=Ay[u],m=h&&n?n[h]:u,f=parseInt(d,10);return o==="darken"?nC(m,f):rC(m,f)}return e}function im(e,n=12){return e.map(a=>({...a,x:n-a.x-a.w}))}function aC(e,n){return n==="down"?e.down:n==="up"&&e.up?e.up:n==="left"&&e.left?e.left:n==="right"&&e.right?e.right:n==="right"&&e.left?{name:e.left.name,pixels:im(e.left.pixels)}:n==="left"&&e.right?{name:e.right.name,pixels:im(e.right.pixels)}:e.down}function lC(e,n){return sm(e,"hair",n,1)}function sm(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 Wm=new Map,Vm=new Map;function Ib(e,n){Wm.set(e,n)}function ed(e,n){Vm.set(e,n)}function om(e){return Wm.get(e)}function iC(e){return Vm.get(e)}function z8(){return Array.from(Wm.keys())}function _8(){return Array.from(Vm.keys())}function sC(e,n,a,i,o=2){e.clearRect(0,0,n.width*o,n.height*o);for(const u of n.layers)Hb(e,u.pixels,o,a,i)}function ql(e,n,a,i,o){for(const u of n){const d=Lb(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 oC(e,n){const a=n.scale;e.clearRect(0,0,n.canvasWidth,n.canvasHeight),Hb(e,n.pixels,a,0)}function Hb(e,n,a,i,o){for(const u of n){const d=Lb(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 Uu=new Map;function Wl(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;Uu.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;Uu.set(e,{id:e,name:n,layer:{...o,name:"hair"}})}}function cC(e){return Uu.get(e)}function Ub(){return Array.from(Uu.values())}Wl("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}]}});Wl("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}]}});Wl("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}]}});Wl("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}]}});Wl("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"}]}});Wl("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}]}});Wl("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}]}});Wl("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 qu=new Map;function Ta(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;qu.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;qu.set(e,{id:e,name:n,layer:{...o,name:"torso"}})}}function uC(e){return qu.get(e)}function qb(){return Array.from(qu.values())}Ta("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"}]}});Ta("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"}]}});Ta("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"}]}});Ta("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)"}]}});Ta("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)"}]}});Ta("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"}]}});Ta("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"}]}});Ta("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"}]}});Ta("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"}]}});Ta("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 $o=new Map;function Ht(e,n,a){if("down"in a&&!("pixels"in a)){const o=a;$o.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;$o.set(e,{id:e,name:n,layer:{...o,name:"accessory"}})}}function dC(e){return $o.get(e)}function fC(e,n){const a=$o.get(e);if(!a)return;if(a.directions)return aC(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 Yb(){return Array.from($o.values())}Ht("none","None",{name:"accessory",pixels:[]});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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"}]}});Ht("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}]}});Ht("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}]}});Ht("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"}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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"}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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}]}});Ht("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"}]}});Ht("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"}]}});Ht("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}]}});Ht("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}]}});Ht("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 hC={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 Xb(e){return hC[e]??1}function Wb(e,n){return n>=Xb(e)}Ht("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 So({r:e,g:n,b:a}){return`#${(e<<16|n<<8|a).toString(16).padStart(6,"0")}`}function Mu(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 mC(e,n){const a=[];a.push(e[Math.floor(Math.random()*e.length)]);for(let i=1;i<n;i++){const o=e.map(h=>{let m=1/0;for(const f of a)m=Math.min(m,Mu(h,f));return m}),u=o.reduce((h,m)=>h+m,0);let d=Math.random()*u;for(let h=0;h<e.length;h++)if(d-=o[h],d<=0){a.push(e[h]);break}a.length<=i&&a.push(e[Math.floor(Math.random()*e.length)])}return a}function pC(e,n,a=20){if(e.length===0)return[];const i=mC(e,n);for(let u=0;u<a;u++){const d=Array.from({length:n},()=>[]);for(const m of e){let f=1/0,x=0;for(let y=0;y<n;y++){const v=Mu(m,i[y]);v<f&&(f=v,x=y)}d[x].push(m)}let h=!0;for(let m=0;m<n;m++){if(d[m].length===0)continue;const f={r:0,g:0,b:0};for(const v of d[m])f.r+=v.r,f.g+=v.g,f.b+=v.b;const x=d[m].length,y={r:Math.round(f.r/x),g:Math.round(f.g/x),b:Math.round(f.b/x)};Mu(y,i[m])>1&&(h=!1),i[m]=y}if(h)break}const o=new Array(n).fill(0);for(const u of e){let d=1/0,h=0;for(let m=0;m<n;m++){const f=Mu(u,i[m]);f<d&&(d=f,h=m)}o[h]++}return i.map((u,d)=>({c:u,count:o[d]})).sort((u,d)=>d.count-u.count).map(u=>u.c)}function xC(e,n=1e4){const a=document.createElement("canvas"),i=e instanceof HTMLImageElement?e.naturalWidth:e.width,o=e instanceof HTMLImageElement?e.naturalHeight:e.height;a.width=i,a.height=o;const u=a.getContext("2d");u.drawImage(e,0,0);const d=u.getImageData(0,0,i,o).data,h=i*o,m=Math.max(1,Math.floor(h/n)),f=[];for(let x=0;x<h;x+=m){const y=x*4;d[y+3]<128||f.push({r:d[y],g:d[y+1],b:d[y+2]})}return f}function Dy(e){return .299*e.r+.587*e.g+.114*e.b}function Ty(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 yC(e,n=8){const a=xC(e),i=pC(a,n);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const o=[...i].sort((y,v)=>Dy(v)-Dy(y)),u=[...i].sort((y,v)=>Ty(v)-Ty(y)),d=o[0],h=o[o.length-1],m=u[0],f=o[o.length-2],x=o[o.length-1];return{skinColor:So(d),hairColor:So(h),shirtColor:So(m),pantsColor:So(f),shoeColor:So(x)}}const gC=[{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}],bC=[{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"}],vC=[{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"}],wC=[{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 kC(){return{width:12,height:22,layers:[{name:"lower",pixels:gC},{name:"torso",pixels:bC},{name:"head",pixels:vC},{name:"hair",pixels:wC},{name:"accessory",pixels:[]}]}}const jC=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const e of jC)Ib(`mini:${e}`,kC());const SC=[{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"}],CC=[{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"}],NC=[{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 EC(){return{width:12,height:22,layers:[{name:"torso",pixels:SC},{name:"head",pixels:CC},{name:"hair",pixels:NC},{name:"accessory",pixels:[]}]}}Ib("mini-seated:default",EC());const AC={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"}]},DC={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"}]},TC={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"}]},FC={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"}]};ed("meeting",AC);ed("bulletin",DC);ed("decision",FC);ed("knowledge",TC);const Sh=16,Ch=24,MC=60,RC={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function Vb(e,n){if(!e)return e;let a=e;if(n!=null&&n.hairStyle){const i=cC(n.hairStyle);i&&(a=lC(a,i.layer))}if(n!=null&&n.outfitStyle){const i=uC(n.outfitStyle);i&&(a=sm(a,"torso",i.layer,1))}if(n!=null&&n.accessory&&n.accessory!=="none"){const i=dC(n.accessory);i&&(a=sm(a,"accessory",i.layer))}return a}function nl({roleId:e,className:n,appearance:a,scale:i}){const o=w.useRef(null),u=w.useRef(0),d=w.useRef(0),h=w.useRef(a);h.current=a;const m=i??4,f=Sh*m,x=Ch*m,y=w.useMemo(()=>{const v=om(`mini:${e}`)??om("mini:default");return Vb(v,a)},[e,a==null?void 0:a.hairStyle,a==null?void 0:a.outfitStyle,a==null?void 0:a.accessory]);return w.useEffect(()=>{const v=o.current;if(!v)return;const b=v.getContext("2d");if(!b)return;const j=RC[e]??0,k=()=>{d.current++;const C=h.current;if(!C||!y){u.current=requestAnimationFrame(k);return}const E=(d.current+j)%MC<30?1:0;b.clearRect(0,0,Sh,Ch),b.save(),b.translate(2,1),sC(b,y,E,C,1),b.restore(),u.current=requestAnimationFrame(k)};return u.current=requestAnimationFrame(k),()=>cancelAnimationFrame(u.current)},[e,y]),l.jsx("canvas",{ref:o,width:Sh,height:Ch,className:n,style:{imageRendering:"pixelated",display:"block",width:f,height:x}})}const zC="https://api.tycono.ai",Gm=zC;async function Co(e){const n=await fetch(`${Gm}${e}`);if(!n.ok)throw new Error(`Cloud API error: ${n.status}`);return n.json()}async function bi(e,n){const a=await fetch(`${Gm}${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 br={health:()=>Co("/api/health"),getMyName:e=>Co(`/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 Co(`/api/store/characters${a?`?${a}`:""}`)},getCharacter:e=>Co(`/api/store/characters/${e}`),getCharacterVersion:e=>Co(`/api/store/characters/${e}/version`),voteCharacter:(e,n,a)=>bi(`/api/store/characters/${e}/vote`,{instanceId:n,vote:a}),trackInstall:e=>bi(`/api/store/characters/${e}/install`,{}),syncCheck:e=>bi("/api/sync/check",{roles:e}),syncPull:e=>bi("/api/sync/pull",{sourceId:e}),publishCharacter:e=>bi("/api/store/publish",e),deleteCharacter:(e,n)=>{const a=n?`?publisher_id=${encodeURIComponent(n)}`:"";return fetch(`${Gm}/api/store/characters/${e}${a}`,{method:"DELETE"}).then(i=>i.json())},uploadTelemetry:e=>bi("/api/telemetry",e),syncStats:e=>bi("/api/stats/sync",e)},_C={cto:"๐๏ธ",cbo:"๐",pm:"๐",engineer:"โ๏ธ",designer:"๐จ",qa:"๐"},Nh={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},BC={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},OC=500,Fy=360,My=700,$C=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function Ry({role:e,allRoles:n,recentActivity:a,onClose:i,onFireRole:o,terminalWidth:u=0,activeJobId:d,activeTask:h,isWorking:m,jobStartedAt:f,onStopJob:x,sessions:y,streamingSessionId:v,onCreateSessionSilent:b,onSendMessage:j,onFocusTerminal:k,onCustomize:C,onUpdateRole:N,appearance:E,relationships:_,roleLevel:z,onMaximize:U}){var bt,et;const[B,$]=w.useState(OC),[q,L]=w.useState(!1),R=w.useRef(0),I=w.useRef(0),[H,Q]=w.useState(!1),[oe,re]=w.useState(!1),[Y,ae]=w.useState(!1),[Z,G]=w.useState(!1),[A,F]=w.useState("talk"),[W,D]=w.useState(!1),[te,je]=w.useState(""),[ve,ze]=w.useState(!1),Xe=w.useRef(null),[de,Oe]=w.useState(!1),[Qe,Se]=w.useState(""),[Je,Re]=w.useState(!1),{events:Et,status:ut}=zg(d??null),[gt,kt]=w.useState(0);w.useEffect(()=>{if(!m||!f){kt(0);return}const Fe=new Date(f).getTime(),_e=()=>kt(Math.floor((Date.now()-Fe)/1e3));_e();const nn=setInterval(_e,1e3);return()=>clearInterval(nn)},[m,f]);const pe=u>0,xe=pe?u:0,ge=pe?Math.max(Fy,window.innerWidth-u-100):My,$e=Math.min(B,ge),Be=w.useCallback(Fe=>{Fe.preventDefault(),R.current=Fe.clientX,I.current=$e,L(!0);const _e=U,nn=()=>{L(!1),document.removeEventListener("mousemove",fn),document.removeEventListener("mouseup",nn)},fn=Vt=>{const yt=R.current-Vt.clientX,pn=I.current+yt;if(pn>=window.innerWidth*.6&&_e){nn(),_e();return}const Mn=Math.min(My,Math.max(Fy,pn));$(Mn)};document.addEventListener("mousemove",fn),document.addEventListener("mouseup",nn)},[$e,U]),Le=w.useRef(null),Ee=e?y.find(Fe=>Fe.roleId===e.id):null,P=Fe=>{if(!e)return;const _e=m?"talk":A;Ee?(j(Ee.id,Fe,_e),k(e.id)):(Le.current={content:Fe,mode:_e},b(e.id))};w.useEffect(()=>{if(Ee&&Le.current){const{content:Fe,mode:_e}=Le.current;Le.current=null,j(Ee.id,Fe,_e),e&&k(e.id)}},[Ee==null?void 0:Ee.id]);const ue=(()=>{if(!Et.length)return null;const Fe=[];let _e=0,nn=0,fn=0;for(const Vt of Et)if(Vt.type==="thinking")_e++;else if(Vt.type==="text")nn++;else if(Vt.type==="tool:start"){const yt=String(Vt.data.name??"");Fe.includes(yt)||Fe.push(yt)}else Vt.type==="dispatch:start"&&fn++;return{tools:Fe,thinkCount:_e,textCount:nn,dispatchCount:fn,total:Et.length}})(),ye=h||(()=>{if(!Ee)return null;const Fe=Ee.messages;for(let _e=Fe.length-1;_e>=0;_e--)if(Fe[_e].from==="ceo")return Fe[_e].content;return null})(),Ne=(()=>{if(!Ee)return null;const Fe=Ee.messages;for(let _e=Fe.length-1;_e>=0;_e--)if(Fe[_e].from==="role"&&Fe[_e].content)return Fe[_e].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:xe},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:xe,width:$e,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 Me=Nh[e.id]??"#666",Pe=_C[e.id]??"๐ค",_t=n.filter(Fe=>Fe.reportsTo===e.id),dt=Ee&&v===Ee.id,ht=e.name||BC[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:xe},onClick:i}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${q?"resizing":""}`,style:{borderLeftColor:Me,right:xe,width:$e,background:"var(--terminal-bg)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${q?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:Be}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Me}ee, ${Me}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:"๐จ"}),U&&l.jsx("button",{onClick:U,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(nl,{roleId:e.id,appearance:E,scale:8})})}),l.jsxs("div",{className:"flex-1 min-w-0 text-white pb-1",children:[l.jsxs("div",{className:"text-lg font-bold flex items-center gap-2",style:{fontFamily:"var(--pixel-font)"},children:[Pe," ",e.id.toUpperCase(),m&&l.jsx("span",{className:"text-[9px] font-semibold px-2 py-0.5 rounded-full animate-pulse",style:{background:"rgba(251,191,36,0.25)",color:"#fde68a"},children:"WORKING"})]}),W?l.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async Fe=>{Fe.preventDefault();const _e=te.trim();if(!_e||_e===ht||!N){D(!1);return}ze(!0);try{await N(e.id,{name:_e})}catch{}ze(!1),D(!1)},children:[l.jsx("input",{ref:Xe,value:te,onChange:Fe=>je(Fe.target.value),onKeyDown:Fe=>{Fe.key==="Escape"&&D(!1)},disabled:ve,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:ve,className:"text-white/80 hover:text-white text-[10px] cursor-pointer shrink-0",children:"โ"}),l.jsx("button",{type:"button",onClick:()=>D(!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&&(je(ht),D(!0))},title:N?"Click to edit name":void 0,children:[ht,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.",z??1]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:m?"var(--idle-amber)":"var(--active-green)"}}),m?"Working":"Idle"]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsx("span",{children:e.level}),e.reportsTo&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"opacity-60",children:["โ"," ",e.reportsTo]})]})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[m&&l.jsxs("div",{className:"px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--idle-amber)"}}),l.jsxs("span",{className:"text-xs font-semibold",style:{color:"var(--idle-amber)"},children:["Working",gt>0?` ยท ${$C(gt)}`:""]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat โ"}),d&&x&&l.jsx("button",{onClick:()=>x(d),className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold transition-colors",style:{background:"rgba(239,68,68,0.15)",color:"#ef4444"},children:"Stop"})]})]}),ye&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:ye})]}),m&&d&&ue&&l.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Activity"}),l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"View details โ"})]}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[ue.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 ร",ue.thinkCount]}),ue.tools.map(Fe=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(59,130,246,0.15)",color:"#60a5fa"},children:Fe},Fe)),ue.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 ร",ue.dispatchCount]}),ue.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 ร",ue.textCount]}),(ut==="streaming"||ut==="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:[ue.total," events"]})]}),m&&Ne&&l.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Last Message"}),l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat โ"})]}),l.jsxs("div",{className:"rounded-lg p-2.5 text-xs leading-relaxed line-clamp-3 overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:[Ne.slice(0,200),Ne.length>200&&"..."]})]}),m&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(zy,{onSend:P,disabled:!!dt,placeholder:"Ask something...",color:Me})}),!m&&l.jsxs("div",{className:"px-4 pt-4 pb-2",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-secondary)"},children:"Latest"}),l.jsx(IC,{icon:Pe,roleId:e.id,roleName:ht,color:Me,text:a})]}),!m&&l.jsx("div",{className:"px-4 py-3",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[Ne&&l.jsxs("div",{className:"px-3 pt-2.5 pb-2 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--terminal-border)"},onClick:()=>k(e.id),children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"Last response"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:"View โ"})]}),l.jsxs("div",{className:"text-xs leading-relaxed line-clamp-2 overflow-hidden",style:{color:"var(--terminal-text-secondary)"},children:[Ne.slice(0,150),Ne.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:()=>F("talk"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:A==="talk"?"var(--accent)":"transparent",color:A==="talk"?"#fff":"var(--terminal-text-secondary)"},children:"Talk"}),l.jsx("button",{onClick:()=>F("do"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:A==="do"?"var(--idle-amber)":"transparent",color:A==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),l.jsx(zy,{onSend:P,disabled:!!dt,placeholder:A==="talk"?"Ask something...":"Give a directive...",color:Me})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(xu,{title:`Profile${e.persona?"":" (empty)"}`,open:H,onToggle:()=>Q(Fe=>!Fe),children:[de?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:Qe,onChange:Fe=>Se(Fe.target.value),onKeyDown:Fe=>{Fe.key==="Escape"&&Oe(!1)},disabled:Je,autoFocus:!0,rows:5,placeholder:"Describe this role's personality and communication style. How do they talk? Are they sarcastic? Cheerful? Blunt?",className:"w-full text-xs leading-relaxed rounded-lg p-3 outline-none resize-y",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--active-green)",color:"var(--terminal-text)",fontFamily:"inherit",minHeight:"80px"}}),l.jsxs("div",{className:"flex gap-1.5 justify-end",children:[l.jsx("button",{onClick:()=>Oe(!1),disabled:Je,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){Re(!0);try{await N(e.id,{persona:Qe.trim()})}catch{}Re(!1),Oe(!1)}},disabled:Je,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold",style:{background:"var(--active-green)",color:"#000"},children:Je?"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&&(Se(e.persona||""),Oe(!0))},title:N?"Click to edit persona":void 0,children:[e.persona||l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:"No persona set. Click to add one."}),N&&l.jsx("span",{className:"opacity-0 group-hover/persona:opacity-60 text-[10px] ml-1",children:"โ"})]}),l.jsxs("div",{className:"space-y-0 mt-2",children:[l.jsx(Eh,{label:"Level",value:e.level}),l.jsx(Eh,{label:"Reports to",value:e.reportsTo}),l.jsx(Eh,{label:"Status",value:e.status})]}),_t.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:_t.map(Fe=>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:Nh[Fe.id]??"#666"},children:Fe.id.slice(0,2).toUpperCase()}),l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text)"},children:Fe.name})]},Fe.id))})]})]}),e.authority&&l.jsxs(xu,{title:"Authority",open:oe,onToggle:()=>re(Fe=>!Fe),children:[((bt=e.authority.autonomous)==null?void 0:bt.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((Fe,_e)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Fe]},_e))]}),((et=e.authority.needsApproval)==null?void 0:et.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((Fe,_e)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",Fe]},_e))]})]}),e&&_&&(()=>{const Fe=_.filter(_e=>_e.roleA===e.id||_e.roleB===e.id).filter(_e=>_e.familiarity>0).sort((_e,nn)=>nn.familiarity-_e.familiarity);return Fe.length===0?null:l.jsx(xu,{title:`Relationships (${Fe.length})`,open:Y,onToggle:()=>ae(_e=>!_e),children:l.jsx("div",{className:"space-y-1.5",children:Fe.map((_e,nn)=>{const fn=_e.roleA===e.id?_e.roleB:_e.roleA,Vt=n.find(Mn=>Mn.id===fn),yt=_e.familiarity>=80?"Best Partner":_e.familiarity>=50?"Friend":_e.familiarity>=20?"Colleague":"Acquaintance",pn=_e.familiarity>=80?"#4CAF50":_e.familiarity>=50?"#2196F3":_e.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:Nh[fn]??"var(--terminal-text-secondary)"},children:(Vt==null?void 0:Vt.name)??fn}),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:`${_e.familiarity}%`,background:pn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:yt})]},nn)})})})})(),e.journal&&l.jsx(xu,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:Z,onToggle:()=>G(Fe=>!Fe),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(Xo,{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(LC,{role:e,appearance:E}),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 LC({role:e,appearance:n}){const[a,i]=w.useState("idle"),[o,u]=w.useState(""),[d,h]=w.useState(!1),[m,f]=w.useState(null),[x,y]=w.useState(!1),[v,b]=w.useState(!1),[j,k]=w.useState(null);w.useEffect(()=>{br.getCharacterVersion(e.id).then(E=>f((E==null?void 0:E.version)??null)).catch(()=>f(null)),me.getPreferences().then(E=>k(E.instanceId??null)).catch(()=>{})},[e.id]);const C=async()=>{var E,_;if(!d){h(!0);return}i("publishing");try{let z=null;try{z=await me.exportSkills(e.id)}catch{}const U={roleId:e.id,persona:e.persona??"",authority:e.authority??{autonomous:[],needsApproval:[]},level:e.level,tagline:((E=(e.persona??"").split(/[.\n]/)[0])==null?void 0:E.trim().slice(0,80))||e.name,chatStyle:"Professional and focused",skills: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&&(U.appearance=n);let B="1.0.0";try{const $=await br.getCharacterVersion(e.id);if($!=null&&$.version){const q=$.version.split(".").map(Number);q[2]=(q[2]??0)+1,B=q.join(".")}}catch{}await br.publishCharacter({id:e.id,name:e.name||e.id,version:B,data:U,publisherId:j??void 0}),i("done"),u(`Published v${B}`),f(B),h(!1)}catch(z){i("error"),u(z instanceof Error?z.message:"Failed"),h(!1)}},N=async()=>{b(!0);try{await br.deleteCharacter(e.id,j??void 0),f(null),i("idle"),u(""),y(!1)}catch{u("Delete failed")}b(!1)};return l.jsx("div",{className:"px-4 pb-2 shrink-0",children:l.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"px-3 py-2.5 flex items-center justify-between gap-2",style:{background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider shrink-0",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Cloud Store"}),m&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded shrink-0",style:{background:"rgba(34,197,94,0.1)",color:"rgba(34,197,94,0.6)",border:"1px solid rgba(34,197,94,0.2)"},children:["v",m]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a==="done"?l.jsxs(l.Fragment,{children:[l.jsx("a",{href:"https://tycono.ai/store.html",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] hover:underline",style:{color:"var(--terminal-text-muted)"},onClick:E=>E.stopPropagation(),children:"View on Store โ"}),l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--active-green)"},children:o})]}):a==="error"?l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#ef4444"},children:o}):l.jsx("button",{onClick:C,disabled:a==="publishing",className:"text-[10px] px-2.5 py-1 rounded font-semibold cursor-pointer transition-colors disabled:opacity-50",style:{background:d?"rgba(59,130,246,0.3)":"rgba(59,130,246,0.15)",color:"#60a5fa",border:d?"1px solid rgba(59,130,246,0.5)":"1px solid transparent"},children:a==="publishing"?"Publishing...":d?"Confirm?":m?"Update":"Publish"}),m&&!x&&l.jsx("button",{onClick:()=>y(!0),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer transition-colors",style:{color:"rgba(239,68,68,0.4)"},title:"Remove from store",children:"โ"}),x&&l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:N,disabled:v,className:"text-[10px] px-2 py-1 rounded font-semibold cursor-pointer disabled:opacity-50",style:{background:"rgba(239,68,68,0.2)",color:"#ef4444",border:"1px solid rgba(239,68,68,0.3)"},children:v?"...":"Delete"}),l.jsx("button",{onClick:()=>y(!1),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)"},children:"No"})]})]})]})})})}function IC({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(Xo,{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 zy({onSend:e,disabled:n,placeholder:a,color:i}){const[o,u]=w.useState(""),d=()=>{const h=o.trim();!h||n||(e(h),u(""))};return l.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[l.jsx("input",{type:"text",value:o,onChange:h=>u(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),d())},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:d,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 Eh({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 HC(e,n){var a,i=1;e==null&&(e=0),n==null&&(n=0);function o(){var u,d=a.length,h,m=0,f=0;for(u=0;u<d;++u)h=a[u],m+=h.x,f+=h.y;for(m=(m/d-e)*i,f=(f/d-n)*i,u=0;u<d;++u)h=a[u],h.x-=m,h.y-=f}return o.initialize=function(u){a=u},o.x=function(u){return arguments.length?(e=+u,o):e},o.y=function(u){return arguments.length?(n=+u,o):n},o.strength=function(u){return arguments.length?(i=+u,o):i},o}function UC(e){const n=+this._x.call(null,e),a=+this._y.call(null,e);return Gb(this.cover(n,a),n,a,e)}function Gb(e,n,a,i){if(isNaN(n)||isNaN(a))return e;var o,u=e._root,d={data:i},h=e._x0,m=e._y0,f=e._x1,x=e._y1,y,v,b,j,k,C,N,E;if(!u)return e._root=d,e;for(;u.length;)if((k=n>=(y=(h+f)/2))?h=y:f=y,(C=a>=(v=(m+x)/2))?m=v:x=v,o=u,!(u=u[N=C<<1|k]))return o[N]=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[N]=d:e._root=d,e;do o=o?o[N]=new Array(4):e._root=new Array(4),(k=n>=(y=(h+f)/2))?h=y:f=y,(C=a>=(v=(m+x)/2))?m=v:x=v;while((N=C<<1|k)===(E=(j>=v)<<1|b>=y));return o[E]=u,o[N]=d,e}function qC(e){var n,a,i=e.length,o,u,d=new Array(i),h=new Array(i),m=1/0,f=1/0,x=-1/0,y=-1/0;for(a=0;a<i;++a)isNaN(o=+this._x.call(null,n=e[a]))||isNaN(u=+this._y.call(null,n))||(d[a]=o,h[a]=u,o<m&&(m=o),o>x&&(x=o),u<f&&(f=u),u>y&&(y=u));if(m>x||f>y)return this;for(this.cover(m,f).cover(x,y),a=0;a<i;++a)Gb(this,d[a],h[a],e[a]);return this}function YC(e,n){if(isNaN(e=+e)||isNaN(n=+n))return this;var a=this._x0,i=this._y0,o=this._x1,u=this._y1;if(isNaN(a))o=(a=Math.floor(e))+1,u=(i=Math.floor(n))+1;else{for(var d=o-a||1,h=this._root,m,f;a>e||e>=o||i>n||n>=u;)switch(f=(n<i)<<1|e<a,m=new Array(4),m[f]=h,h=m,d*=2,f){case 0:o=a+d,u=i+d;break;case 1:a=o-d,u=i+d;break;case 2:o=a+d,i=u-d;break;case 3:a=o-d,i=u-d;break}this._root&&this._root.length&&(this._root=h)}return this._x0=a,this._y0=i,this._x1=o,this._y1=u,this}function XC(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function WC(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 sr(e,n,a,i,o){this.node=e,this.x0=n,this.y0=a,this.x1=i,this.y1=o}function VC(e,n,a){var i,o=this._x0,u=this._y0,d,h,m,f,x=this._x1,y=this._y1,v=[],b=this._root,j,k;for(b&&v.push(new sr(b,o,u,x,y)),a==null?a=1/0:(o=e-a,u=n-a,x=e+a,y=n+a,a*=a);j=v.pop();)if(!(!(b=j.node)||(d=j.x0)>x||(h=j.y0)>y||(m=j.x1)<o||(f=j.y1)<u))if(b.length){var C=(d+m)/2,N=(h+f)/2;v.push(new sr(b[3],C,N,m,f),new sr(b[2],d,N,C,f),new sr(b[1],C,h,m,N),new sr(b[0],d,h,C,N)),(k=(n>=N)<<1|e>=C)&&(j=v[v.length-1],v[v.length-1]=v[v.length-1-k],v[v.length-1-k]=j)}else{var E=e-+this._x.call(null,b.data),_=n-+this._y.call(null,b.data),z=E*E+_*_;if(z<a){var U=Math.sqrt(a=z);o=e-U,u=n-U,x=e+U,y=n+U,i=b.data}}return i}function GC(e){if(isNaN(x=+this._x.call(null,e))||isNaN(y=+this._y.call(null,e)))return this;var n,a=this._root,i,o,u,d=this._x0,h=this._y0,m=this._x1,f=this._y1,x,y,v,b,j,k,C,N;if(!a)return this;if(a.length)for(;;){if((j=x>=(v=(d+m)/2))?d=v:m=v,(k=y>=(b=(h+f)/2))?h=b:f=b,n=a,!(a=a[C=k<<1|j]))return this;if(!a.length)break;(n[C+1&3]||n[C+2&3]||n[C+3&3])&&(i=n,N=C)}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[C]=u:delete n[C],(a=n[0]||n[1]||n[2]||n[3])&&a===(n[3]||n[2]||n[1]||n[0])&&!a.length&&(i?i[N]=a:this._root=a),this):(this._root=u,this)}function KC(e){for(var n=0,a=e.length;n<a;++n)this.remove(e[n]);return this}function QC(){return this._root}function PC(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function ZC(e){var n=[],a,i=this._root,o,u,d,h,m;for(i&&n.push(new sr(i,this._x0,this._y0,this._x1,this._y1));a=n.pop();)if(!e(i=a.node,u=a.x0,d=a.y0,h=a.x1,m=a.y1)&&i.length){var f=(u+h)/2,x=(d+m)/2;(o=i[3])&&n.push(new sr(o,f,x,h,m)),(o=i[2])&&n.push(new sr(o,u,x,f,m)),(o=i[1])&&n.push(new sr(o,f,d,h,x)),(o=i[0])&&n.push(new sr(o,u,d,f,x))}return this}function JC(e){var n=[],a=[],i;for(this._root&&n.push(new sr(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var o=i.node;if(o.length){var u,d=i.x0,h=i.y0,m=i.x1,f=i.y1,x=(d+m)/2,y=(h+f)/2;(u=o[0])&&n.push(new sr(u,d,h,x,y)),(u=o[1])&&n.push(new sr(u,x,h,m,y)),(u=o[2])&&n.push(new sr(u,d,y,x,f)),(u=o[3])&&n.push(new sr(u,x,y,m,f))}a.push(i)}for(;i=a.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function eN(e){return e[0]}function tN(e){return arguments.length?(this._x=e,this):this._x}function nN(e){return e[1]}function rN(e){return arguments.length?(this._y=e,this):this._y}function Km(e,n,a){var i=new Qm(n??eN,a??nN,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function Qm(e,n,a,i,o,u){this._x=e,this._y=n,this._x0=a,this._y0=i,this._x1=o,this._y1=u,this._root=void 0}function _y(e){for(var n={data:e.data},a=n;e=e.next;)a=a.next={data:e.data};return n}var or=Km.prototype=Qm.prototype;or.copy=function(){var e=new Qm(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,a,i;if(!n)return e;if(!n.length)return e._root=_y(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]=_y(i));return e};or.add=UC;or.addAll=qC;or.cover=YC;or.data=XC;or.extent=WC;or.find=VC;or.remove=GC;or.removeAll=KC;or.root=QC;or.size=PC;or.visit=ZC;or.visitAfter=JC;or.x=tN;or.y=rN;function Ci(e){return function(){return e}}function Yl(e){return(e()-.5)*1e-6}function aN(e){return e.x+e.vx}function lN(e){return e.y+e.vy}function iN(e){var n,a,i,o=1,u=1;typeof e!="function"&&(e=Ci(e==null?1:+e));function d(){for(var f,x=n.length,y,v,b,j,k,C,N=0;N<u;++N)for(y=Km(n,aN,lN).visitAfter(h),f=0;f<x;++f)v=n[f],k=a[v.index],C=k*k,b=v.x+v.vx,j=v.y+v.vy,y.visit(E);function E(_,z,U,B,$){var q=_.data,L=_.r,R=k+L;if(q){if(q.index>v.index){var I=b-q.x-q.vx,H=j-q.y-q.vy,Q=I*I+H*H;Q<R*R&&(I===0&&(I=Yl(i),Q+=I*I),H===0&&(H=Yl(i),Q+=H*H),Q=(R-(Q=Math.sqrt(Q)))/Q*o,v.vx+=(I*=Q)*(R=(L*=L)/(C+L)),v.vy+=(H*=Q)*R,q.vx-=I*(R=1-R),q.vy-=H*R)}return}return z>b+R||B<b-R||U>j+R||$<j-R}}function h(f){if(f.data)return f.r=a[f.data.index];for(var x=f.r=0;x<4;++x)f[x]&&f[x].r>f.r&&(f.r=f[x].r)}function m(){if(n){var f,x=n.length,y;for(a=new Array(x),f=0;f<x;++f)y=n[f],a[y.index]=+e(y,f,n)}}return d.initialize=function(f,x){n=f,i=x,m()},d.iterations=function(f){return arguments.length?(u=+f,d):u},d.strength=function(f){return arguments.length?(o=+f,d):o},d.radius=function(f){return arguments.length?(e=typeof f=="function"?f:Ci(+f),m(),d):e},d}function sN(e){return e.index}function By(e,n){var a=e.get(n);if(!a)throw new Error("node not found: "+n);return a}function oN(e){var n=sN,a=y,i,o=Ci(30),u,d,h,m,f,x=1;e==null&&(e=[]);function y(C){return 1/Math.min(h[C.source.index],h[C.target.index])}function v(C){for(var N=0,E=e.length;N<x;++N)for(var _=0,z,U,B,$,q,L,R;_<E;++_)z=e[_],U=z.source,B=z.target,$=B.x+B.vx-U.x-U.vx||Yl(f),q=B.y+B.vy-U.y-U.vy||Yl(f),L=Math.sqrt($*$+q*q),L=(L-u[_])/L*C*i[_],$*=L,q*=L,B.vx-=$*(R=m[_]),B.vy-=q*R,U.vx+=$*(R=1-R),U.vy+=q*R}function b(){if(d){var C,N=d.length,E=e.length,_=new Map(d.map((U,B)=>[n(U,B,d),U])),z;for(C=0,h=new Array(N);C<E;++C)z=e[C],z.index=C,typeof z.source!="object"&&(z.source=By(_,z.source)),typeof z.target!="object"&&(z.target=By(_,z.target)),h[z.source.index]=(h[z.source.index]||0)+1,h[z.target.index]=(h[z.target.index]||0)+1;for(C=0,m=new Array(E);C<E;++C)z=e[C],m[C]=h[z.source.index]/(h[z.source.index]+h[z.target.index]);i=new Array(E),j(),u=new Array(E),k()}}function j(){if(d)for(var C=0,N=e.length;C<N;++C)i[C]=+a(e[C],C,e)}function k(){if(d)for(var C=0,N=e.length;C<N;++C)u[C]=+o(e[C],C,e)}return v.initialize=function(C,N){d=C,f=N,b()},v.links=function(C){return arguments.length?(e=C,b(),v):e},v.id=function(C){return arguments.length?(n=C,v):n},v.iterations=function(C){return arguments.length?(x=+C,v):x},v.strength=function(C){return arguments.length?(a=typeof C=="function"?C:Ci(+C),j(),v):a},v.distance=function(C){return arguments.length?(o=typeof C=="function"?C:Ci(+C),k(),v):o},v}var cN={value:()=>{}};function Kb(){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 Ru(a)}function Ru(e){this._=e}function uN(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}})}Ru.prototype=Kb.prototype={constructor:Ru,on:function(e,n){var a=this._,i=uN(e+"",a),o,u=-1,d=i.length;if(arguments.length<2){for(;++u<d;)if((o=(e=i[u]).type)&&(o=dN(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]=Oy(a[o],e.name,n);else if(n==null)for(o in a)a[o]=Oy(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 Ru(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 dN(e,n){for(var a=0,i=e.length,o;a<i;++a)if((o=e[a]).name===n)return o.value}function Oy(e,n,a){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=cN,e=e.slice(0,i).concat(e.slice(i+1));break}return a!=null&&e.push({name:n,value:a}),e}var ws=0,To=0,No=0,Qb=1e3,Yu,Fo,Xu=0,Di=0,td=0,Lo=typeof performance=="object"&&performance.now?performance:Date,Pb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Zb(){return Di||(Pb(fN),Di=Lo.now()+td)}function fN(){Di=0}function cm(){this._call=this._time=this._next=null}cm.prototype=Jb.prototype={constructor:cm,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?Zb():+a)+(n==null?0:+n),!this._next&&Fo!==this&&(Fo?Fo._next=this:Yu=this,Fo=this),this._call=e,this._time=a,um()},stop:function(){this._call&&(this._call=null,this._time=1/0,um())}};function Jb(e,n,a){var i=new cm;return i.restart(e,n,a),i}function hN(){Zb(),++ws;for(var e=Yu,n;e;)(n=Di-e._time)>=0&&e._call.call(void 0,n),e=e._next;--ws}function $y(){Di=(Xu=Lo.now())+td,ws=To=0;try{hN()}finally{ws=0,pN(),Di=0}}function mN(){var e=Lo.now(),n=e-Xu;n>Qb&&(td-=n,Xu=e)}function pN(){for(var e,n=Yu,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:Yu=a);Fo=e,um(i)}function um(e){if(!ws){To&&(To=clearTimeout(To));var n=e-Di;n>24?(e<1/0&&(To=setTimeout($y,e-Lo.now()-td)),No&&(No=clearInterval(No))):(No||(Xu=Lo.now(),No=setInterval(mN,Qb)),ws=1,Pb($y))}}const xN=1664525,yN=1013904223,Ly=4294967296;function gN(){let e=1;return()=>(e=(xN*e+yN)%Ly)/Ly}function bN(e){return e.x}function vN(e){return e.y}var wN=10,kN=Math.PI*(3-Math.sqrt(5));function jN(e){var n,a=1,i=.001,o=1-Math.pow(i,1/300),u=0,d=.6,h=new Map,m=Jb(y),f=Kb("tick","end"),x=gN();e==null&&(e=[]);function y(){v(),f.call("tick",n),a<i&&(m.stop(),f.call("end",n))}function v(k){var C,N=e.length,E;k===void 0&&(k=1);for(var _=0;_<k;++_)for(a+=(u-a)*o,h.forEach(function(z){z(a)}),C=0;C<N;++C)E=e[C],E.fx==null?E.x+=E.vx*=d:(E.x=E.fx,E.vx=0),E.fy==null?E.y+=E.vy*=d:(E.y=E.fy,E.vy=0);return n}function b(){for(var k=0,C=e.length,N;k<C;++k){if(N=e[k],N.index=k,N.fx!=null&&(N.x=N.fx),N.fy!=null&&(N.y=N.fy),isNaN(N.x)||isNaN(N.y)){var E=wN*Math.sqrt(.5+k),_=k*kN;N.x=E*Math.cos(_),N.y=E*Math.sin(_)}(isNaN(N.vx)||isNaN(N.vy))&&(N.vx=N.vy=0)}}function j(k){return k.initialize&&k.initialize(e,x),k}return b(),n={tick:v,restart:function(){return m.restart(y),n},stop:function(){return m.stop(),n},nodes:function(k){return arguments.length?(e=k,b(),h.forEach(j),n):e},alpha:function(k){return arguments.length?(a=+k,n):a},alphaMin:function(k){return arguments.length?(i=+k,n):i},alphaDecay:function(k){return arguments.length?(o=+k,n):+o},alphaTarget:function(k){return arguments.length?(u=+k,n):u},velocityDecay:function(k){return arguments.length?(d=1-k,n):1-d},randomSource:function(k){return arguments.length?(x=k,h.forEach(j),n):x},force:function(k,C){return arguments.length>1?(C==null?h.delete(k):h.set(k,j(C)),n):h.get(k)},find:function(k,C,N){var E=0,_=e.length,z,U,B,$,q;for(N==null?N=1/0:N*=N,E=0;E<_;++E)$=e[E],z=k-$.x,U=C-$.y,B=z*z+U*U,B<N&&(q=$,N=B);return q},on:function(k,C){return arguments.length>1?(f.on(k,C),n):f.on(k)}}}function SN(){var e,n,a,i,o=Ci(-30),u,d=1,h=1/0,m=.81;function f(b){var j,k=e.length,C=Km(e,bN,vN).visitAfter(y);for(i=b,j=0;j<k;++j)n=e[j],C.visit(v)}function x(){if(e){var b,j=e.length,k;for(u=new Array(j),b=0;b<j;++b)k=e[b],u[k.index]=+o(k,b,e)}}function y(b){var j=0,k,C,N=0,E,_,z;if(b.length){for(E=_=z=0;z<4;++z)(k=b[z])&&(C=Math.abs(k.value))&&(j+=k.value,N+=C,E+=C*k.x,_+=C*k.y);b.x=E/N,b.y=_/N}else{k=b,k.x=k.data.x,k.y=k.data.y;do j+=u[k.data.index];while(k=k.next)}b.value=j}function v(b,j,k,C){if(!b.value)return!0;var N=b.x-n.x,E=b.y-n.y,_=C-j,z=N*N+E*E;if(_*_/m<z)return z<h&&(N===0&&(N=Yl(a),z+=N*N),E===0&&(E=Yl(a),z+=E*E),z<d&&(z=Math.sqrt(d*z)),n.vx+=N*b.value*i/z,n.vy+=E*b.value*i/z),!0;if(b.length||z>=h)return;(b.data!==n||b.next)&&(N===0&&(N=Yl(a),z+=N*N),E===0&&(E=Yl(a),z+=E*E),z<d&&(z=Math.sqrt(d*z)));do b.data!==n&&(_=u[b.data.index]*i/z,n.vx+=N*_,n.vy+=E*_);while(b=b.next)}return f.initialize=function(b,j){e=b,a=j,x()},f.strength=function(b){return arguments.length?(o=typeof b=="function"?b:Ci(+b),x(),f):o},f.distanceMin=function(b){return arguments.length?(d=b*b,f):Math.sqrt(d)},f.distanceMax=function(b){return arguments.length?(h=b*b,f):Math.sqrt(h)},f.theta=function(b){return arguments.length?(m=b*b,f):Math.sqrt(m)},f}function rl(e){return Array.isArray?Array.isArray(e):nv(e)==="[object Array]"}function CN(e){if(typeof e=="string")return e;let n=e+"";return n=="0"&&1/e==-1/0?"-0":n}function NN(e){return e==null?"":CN(e)}function Na(e){return typeof e=="string"}function ev(e){return typeof e=="number"}function EN(e){return e===!0||e===!1||AN(e)&&nv(e)=="[object Boolean]"}function tv(e){return typeof e=="object"}function AN(e){return tv(e)&&e!==null}function zr(e){return e!=null}function Ah(e){return!e.trim().length}function nv(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const DN="Incorrect 'index' type",TN=e=>`Invalid value for key ${e}`,FN=e=>`Pattern length exceeds max of ${e}.`,MN=e=>`Missing ${e} property in key`,RN=e=>`Property 'weight' in key '${e}' must be a positive integer`,Iy=Object.prototype.hasOwnProperty;class zN{constructor(n){this._keys=[],this._keyMap={};let a=0;n.forEach(i=>{let o=rv(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 rv(e){let n=null,a=null,i=null,o=1,u=null;if(Na(e)||rl(e))i=e,n=Hy(e),a=dm(e);else{if(!Iy.call(e,"name"))throw new Error(MN("name"));const d=e.name;if(i=d,Iy.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(RN(d));n=Hy(d),a=dm(d),u=e.getFn}return{path:n,id:a,weight:o,src:i,getFn:u}}function Hy(e){return rl(e)?e:e.split(".")}function dm(e){return rl(e)?e.join("."):e}function _N(e,n){let a=[],i=!1;const o=(u,d,h)=>{if(zr(u))if(!d[h])a.push(u);else{let m=d[h];const f=u[m];if(!zr(f))return;if(h===d.length-1&&(Na(f)||ev(f)||EN(f)))a.push(NN(f));else if(rl(f)){i=!0;for(let x=0,y=f.length;x<y;x+=1)o(f[x],d,h+1)}else d.length&&o(f,d,h+1)}};return o(e,Na(n)?n.split("."):n,0),i?a:a[0]}const BN={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ON={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},$N={location:0,threshold:.6,distance:100},LN={useExtendedSearch:!1,getFn:_N,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var st={...ON,...BN,...$N,...LN};const IN=/[^ ]+/g;function HN(e=1,n=3){const a=new Map,i=Math.pow(10,n);return{get(o){const u=o.match(IN).length;if(a.has(u))return a.get(u);const d=1/Math.pow(u,.5*e),h=parseFloat(Math.round(d*i)/i);return a.set(u,h),h},clear(){a.clear()}}}class Pm{constructor({getFn:n=st.getFn,fieldNormWeight:a=st.fieldNormWeight}={}){this.norm=HN(a,3),this.getFn=n,this.isCreated=!1,this.setIndexRecords()}setSources(n=[]){this.docs=n}setIndexRecords(n=[]){this.records=n}setKeys(n=[]){this.keys=n,this._keysMap={},n.forEach((a,i)=>{this._keysMap[a.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Na(this.docs[0])?this.docs.forEach((n,a)=>{this._addString(n,a)}):this.docs.forEach((n,a)=>{this._addObject(n,a)}),this.norm.clear())}add(n){const a=this.size();Na(n)?this._addString(n,a):this._addObject(n,a)}removeAt(n){this.records.splice(n,1);for(let a=n,i=this.size();a<i;a+=1)this.records[a].i-=1}getValueForItemAtKeyId(n,a){return n[this._keysMap[a]]}size(){return this.records.length}_addString(n,a){if(!zr(n)||Ah(n))return;let i={v:n,i:a,n:this.norm.get(n)};this.records.push(i)}_addObject(n,a){let i={i:a,$:{}};this.keys.forEach((o,u)=>{let d=o.getFn?o.getFn(n):this.getFn(n,o.path);if(zr(d)){if(rl(d)){let h=[];const m=[{nestedArrIndex:-1,value:d}];for(;m.length;){const{nestedArrIndex:f,value:x}=m.pop();if(zr(x))if(Na(x)&&!Ah(x)){let y={v:x,i:f,n:this.norm.get(x)};h.push(y)}else rl(x)&&x.forEach((y,v)=>{m.push({nestedArrIndex:v,value:y})})}i.$[u]=h}else if(Na(d)&&!Ah(d)){let h={v:d,n:this.norm.get(d)};i.$[u]=h}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function av(e,n,{getFn:a=st.getFn,fieldNormWeight:i=st.fieldNormWeight}={}){const o=new Pm({getFn:a,fieldNormWeight:i});return o.setKeys(e.map(rv)),o.setSources(n),o.create(),o}function UN(e,{getFn:n=st.getFn,fieldNormWeight:a=st.fieldNormWeight}={}){const{keys:i,records:o}=e,u=new Pm({getFn:n,fieldNormWeight:a});return u.setKeys(i),u.setIndexRecords(o),u}function yu(e,{errors:n=0,currentLocation:a=0,expectedLocation:i=0,distance:o=st.distance,ignoreLocation:u=st.ignoreLocation}={}){const d=n/e.length;if(u)return d;const h=Math.abs(i-a);return o?d+h/o:h?1:d}function qN(e=[],n=st.minMatchCharLength){let a=[],i=-1,o=-1,u=0;for(let d=e.length;u<d;u+=1){let h=e[u];h&&i===-1?i=u:!h&&i!==-1&&(o=u-1,o-i+1>=n&&a.push([i,o]),i=-1)}return e[u-1]&&u-i>=n&&a.push([i,u-1]),a}const ji=32;function YN(e,n,a,{location:i=st.location,distance:o=st.distance,threshold:u=st.threshold,findAllMatches:d=st.findAllMatches,minMatchCharLength:h=st.minMatchCharLength,includeMatches:m=st.includeMatches,ignoreLocation:f=st.ignoreLocation}={}){if(n.length>ji)throw new Error(FN(ji));const x=n.length,y=e.length,v=Math.max(0,Math.min(i,y));let b=u,j=v;const k=h>1||m,C=k?Array(y):[];let N;for(;(N=e.indexOf(n,j))>-1;){let $=yu(n,{currentLocation:N,expectedLocation:v,distance:o,ignoreLocation:f});if(b=Math.min($,b),j=N+x,k){let q=0;for(;q<x;)C[N+q]=1,q+=1}}j=-1;let E=[],_=1,z=x+y;const U=1<<x-1;for(let $=0;$<x;$+=1){let q=0,L=z;for(;q<L;)yu(n,{errors:$,currentLocation:v+L,expectedLocation:v,distance:o,ignoreLocation:f})<=b?q=L:z=L,L=Math.floor((z-q)/2+q);z=L;let R=Math.max(1,v-L+1),I=d?y:Math.min(v+L,y)+x,H=Array(I+2);H[I+1]=(1<<$)-1;for(let oe=I;oe>=R;oe-=1){let re=oe-1,Y=a[e.charAt(re)];if(k&&(C[re]=+!!Y),H[oe]=(H[oe+1]<<1|1)&Y,$&&(H[oe]|=(E[oe+1]|E[oe])<<1|1|E[oe+1]),H[oe]&U&&(_=yu(n,{errors:$,currentLocation:re,expectedLocation:v,distance:o,ignoreLocation:f}),_<=b)){if(b=_,j=re,j<=v)break;R=Math.max(1,2*v-j)}}if(yu(n,{errors:$+1,currentLocation:v,expectedLocation:v,distance:o,ignoreLocation:f})>b)break;E=H}const B={isMatch:j>=0,score:Math.max(.001,_)};if(k){const $=qN(C,h);$.length?m&&(B.indices=$):B.isMatch=!1}return B}function XN(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 Wu=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 lv{constructor(n,{location:a=st.location,threshold:i=st.threshold,distance:o=st.distance,includeMatches:u=st.includeMatches,findAllMatches:d=st.findAllMatches,minMatchCharLength:h=st.minMatchCharLength,isCaseSensitive:m=st.isCaseSensitive,ignoreDiacritics:f=st.ignoreDiacritics,ignoreLocation:x=st.ignoreLocation}={}){if(this.options={location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:h,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x},n=m?n:n.toLowerCase(),n=f?Wu(n):n,this.pattern=n,this.chunks=[],!this.pattern.length)return;const y=(b,j)=>{this.chunks.push({pattern:b,alphabet:XN(b),startIndex:j})},v=this.pattern.length;if(v>ji){let b=0;const j=v%ji,k=v-j;for(;b<k;)y(this.pattern.substr(b,ji),b),b+=ji;if(j){const C=v-ji;y(this.pattern.substr(C),C)}}else y(this.pattern,0)}searchIn(n){const{isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o}=this.options;if(n=a?n:n.toLowerCase(),n=i?Wu(n):n,this.pattern===n){let k={isMatch:!0,score:0};return o&&(k.indices=[[0,n.length-1]]),k}const{location:u,distance:d,threshold:h,findAllMatches:m,minMatchCharLength:f,ignoreLocation:x}=this.options;let y=[],v=0,b=!1;this.chunks.forEach(({pattern:k,alphabet:C,startIndex:N})=>{const{isMatch:E,score:_,indices:z}=YN(n,k,C,{location:u+N,distance:d,threshold:h,findAllMatches:m,minMatchCharLength:f,includeMatches:o,ignoreLocation:x});E&&(b=!0),v+=_,E&&z&&(y=[...y,...z])});let j={isMatch:b,score:b?v/this.chunks.length:1};return b&&o&&(j.indices=y),j}}class Vl{constructor(n){this.pattern=n}static isMultiMatch(n){return Uy(n,this.multiRegex)}static isSingleMatch(n){return Uy(n,this.singleRegex)}search(){}}function Uy(e,n){const a=e.match(n);return a?a[1]:null}class WN extends Vl{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 VN extends Vl{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 GN extends Vl{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 KN extends Vl{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 QN extends Vl{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 PN extends Vl{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 iv extends Vl{constructor(n,{location:a=st.location,threshold:i=st.threshold,distance:o=st.distance,includeMatches:u=st.includeMatches,findAllMatches:d=st.findAllMatches,minMatchCharLength:h=st.minMatchCharLength,isCaseSensitive:m=st.isCaseSensitive,ignoreDiacritics:f=st.ignoreDiacritics,ignoreLocation:x=st.ignoreLocation}={}){super(n),this._bitapSearch=new lv(n,{location:a,threshold:i,distance:o,includeMatches:u,findAllMatches:d,minMatchCharLength:h,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(n){return this._bitapSearch.searchIn(n)}}class sv extends Vl{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 fm=[WN,sv,GN,KN,PN,QN,VN,iv],qy=fm.length,ZN=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,JN="|";function eE(e,n={}){return e.split(JN).map(a=>{let i=a.trim().split(ZN).filter(u=>u&&!!u.trim()),o=[];for(let u=0,d=i.length;u<d;u+=1){const h=i[u];let m=!1,f=-1;for(;!m&&++f<qy;){const x=fm[f];let y=x.isMultiMatch(h);y&&(o.push(new x(y,n)),m=!0)}if(!m)for(f=-1;++f<qy;){const x=fm[f];let y=x.isSingleMatch(h);if(y){o.push(new x(y,n));break}}}return o})}const tE=new Set([iv.type,sv.type]);class nE{constructor(n,{isCaseSensitive:a=st.isCaseSensitive,ignoreDiacritics:i=st.ignoreDiacritics,includeMatches:o=st.includeMatches,minMatchCharLength:u=st.minMatchCharLength,ignoreLocation:d=st.ignoreLocation,findAllMatches:h=st.findAllMatches,location:m=st.location,threshold:f=st.threshold,distance:x=st.distance}={}){this.query=null,this.options={isCaseSensitive:a,ignoreDiacritics:i,includeMatches:o,minMatchCharLength:u,findAllMatches:h,ignoreLocation:d,location:m,threshold:f,distance:x},n=a?n:n.toLowerCase(),n=i?Wu(n):n,this.pattern=n,this.query=eE(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?Wu(n):n;let d=0,h=[],m=0;for(let f=0,x=a.length;f<x;f+=1){const y=a[f];h.length=0,d=0;for(let v=0,b=y.length;v<b;v+=1){const j=y[v],{isMatch:k,indices:C,score:N}=j.search(n);if(k){if(d+=1,m+=N,i){const E=j.constructor.type;tE.has(E)?h=[...h,...C]:h.push(C)}}else{m=0,d=0,h.length=0;break}}if(d){let v={isMatch:!0,score:m/d};return i&&(v.indices=h),v}}return{isMatch:!1,score:1}}}const hm=[];function rE(...e){hm.push(...e)}function mm(e,n){for(let a=0,i=hm.length;a<i;a+=1){let o=hm[a];if(o.condition(e,n))return new o(e,n)}return new lv(e,n)}const Vu={AND:"$and",OR:"$or"},pm={PATH:"$path",PATTERN:"$val"},xm=e=>!!(e[Vu.AND]||e[Vu.OR]),aE=e=>!!e[pm.PATH],lE=e=>!rl(e)&&tv(e)&&!xm(e),Yy=e=>({[Vu.AND]:Object.keys(e).map(n=>({[n]:e[n]}))});function ov(e,n,{auto:a=!0}={}){const i=o=>{let u=Object.keys(o);const d=aE(o);if(!d&&u.length>1&&!xm(o))return i(Yy(o));if(lE(o)){const m=d?o[pm.PATH]:u[0],f=d?o[pm.PATTERN]:o[m];if(!Na(f))throw new Error(TN(m));const x={keyId:dm(m),pattern:f};return a&&(x.searcher=mm(f,n)),x}let h={children:[],operator:u[0]};return u.forEach(m=>{const f=o[m];rl(f)&&f.forEach(x=>{h.children.push(i(x))})}),h};return xm(e)||(e=Yy(e)),i(e)}function iE(e,{ignoreFieldNorm:n=st.ignoreFieldNorm}){e.forEach(a=>{let i=1;a.matches.forEach(({key:o,norm:u,score:d})=>{const h=o?o.weight:null;i*=Math.pow(d===0&&h?Number.EPSILON:d,(h||1)*(n?1:u))}),a.score=i})}function sE(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 oE(e,n){n.score=e.score}function cE(e,n,{includeMatches:a=st.includeMatches,includeScore:i=st.includeScore}={}){const o=[];return a&&o.push(sE),i&&o.push(oE),e.map(u=>{const{idx:d}=u,h={item:n[d],refIndex:d};return o.length&&o.forEach(m=>{m(u,h)}),h})}class Es{constructor(n,a={},i){this.options={...st,...a},this.options.useExtendedSearch,this._keyStore=new zN(this.options.keys),this.setCollection(n,i)}setCollection(n,a){if(this._docs=n,a&&!(a instanceof Pm))throw new Error(DN);this._myIndex=a||av(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:h}=this.options;let m=Na(n)?Na(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return iE(m,{ignoreFieldNorm:h}),u&&m.sort(d),ev(a)&&a>-1&&(m=m.slice(0,a)),cE(m,this._docs,{includeMatches:i,includeScore:o})}_searchStringList(n){const a=mm(n,this.options),{records:i}=this._myIndex,o=[];return i.forEach(({v:u,i:d,n:h})=>{if(!zr(u))return;const{isMatch:m,score:f,indices:x}=a.searchIn(u);m&&o.push({item:u,idx:d,matches:[{score:f,value:u,norm:h,indices:x}]})}),o}_searchLogical(n){const a=ov(n,this.options),i=(h,m,f)=>{if(!h.children){const{keyId:y,searcher:v}=h,b=this._findMatches({key:this._keyStore.get(y),value:this._myIndex.getValueForItemAtKeyId(m,y),searcher:v});return b&&b.length?[{idx:f,item:m,matches:b}]:[]}const x=[];for(let y=0,v=h.children.length;y<v;y+=1){const b=h.children[y],j=i(b,m,f);if(j.length)x.push(...j);else if(h.operator===Vu.AND)return[]}return x},o=this._myIndex.records,u={},d=[];return o.forEach(({$:h,i:m})=>{if(zr(h)){let f=i(a,h,m);f.length&&(u[m]||(u[m]={idx:m,item:h,matches:[]},d.push(u[m])),f.forEach(({matches:x})=>{u[m].matches.push(...x)}))}}),d}_searchObjectList(n){const a=mm(n,this.options),{keys:i,records:o}=this._myIndex,u=[];return o.forEach(({$:d,i:h})=>{if(!zr(d))return;let m=[];i.forEach((f,x)=>{m.push(...this._findMatches({key:f,value:d[x],searcher:a}))}),m.length&&u.push({idx:h,item:d,matches:m})}),u}_findMatches({key:n,value:a,searcher:i}){if(!zr(a))return[];let o=[];if(rl(a))a.forEach(({v:u,i:d,n:h})=>{if(!zr(u))return;const{isMatch:m,score:f,indices:x}=i.searchIn(u);m&&o.push({score:f,key:n,value:u,idx:d,norm:h,indices:x})});else{const{v:u,n:d}=a,{isMatch:h,score:m,indices:f}=i.searchIn(u);h&&o.push({score:m,key:n,value:u,norm:d,indices:f})}return o}}Es.version="7.1.0";Es.createIndex=av;Es.parseIndex=UN;Es.config=st;Es.parseQuery=ov;rE(nE);const sa={tech:{bg:"rgba(59,130,246,0.15)",border:"#3b82f6",text:"#60a5fa"},market:{bg:"rgba(245,158,11,0.15)",border:"#f59e0b",text:"#fbbf24"},strategy:{bg:"rgba(139,92,246,0.15)",border:"#8b5cf6",text:"#a78bfa"},financial:{bg:"rgba(34,197,94,0.15)",border:"#22c55e",text:"#4ade80"},process:{bg:"rgba(236,72,153,0.15)",border:"#ec4899",text:"#f472b6"},competitor:{bg:"rgba(239,68,68,0.15)",border:"#ef4444",text:"#f87171"},domain:{bg:"rgba(14,165,233,0.15)",border:"#0ea5e9",text:"#38bdf8"},general:{bg:"rgba(148,163,184,0.12)",border:"#64748b",text:"#94a3b8"}};function uE(e){return sa[e]??sa.general}function dE(e){return e>1600?"macro":e<800?"micro":"standard"}function fE(e){const n=new Map;for(const i of e){const o=i.category||"general";n.has(o)||n.set(o,[]),n.get(o).push(i)}const a=[];for(const[i,o]of n){let u=0,d=0;for(const m of o)u+=m.x??0,d+=m.y??0;const h=o.length;a.push({domain:i,count:h,centerX:u/h,centerY:d/h,nodes:o})}return a}function hE(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 mE(e,n,a){const i=[...new Set(a.map(m=>m.category||"general"))],o=new Map,u=e/2,d=n/2,h=Math.min(e,n)*.3;return i.forEach((m,f)=>{const x=2*Math.PI*f/i.length-Math.PI/2;o.set(m,{x:u+h*Math.cos(x),y:d+h*Math.sin(x)})}),o}function pE(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 xE(e){return e.map(n=>{let a=0;for(const o of n.nodes){const u=(o.x??0)-n.centerX,d=(o.y??0)-n.centerY,h=Math.sqrt(u*u+d*d);h>a&&(a=h)}const i=Math.max(40,n.count*8);return{...n,radius:a+i}})}function yE(e,n,a,i){if(!e)return a;const o=new Set([e]),u=new Set;let d=new Set([e]);for(let h=0;h<i;h++){const m=new Set;for(const f of d)if(!u.has(f)){u.add(f);for(const x of n){const y=typeof x.source=="string"?x.source:x.source.id,v=typeof x.target=="string"?x.target:x.target.id;y===f&&!o.has(v)&&(o.add(v),m.add(v)),v===f&&!o.has(y)&&(o.add(y),m.add(y))}}d=m}return o}function gE({docs:e,onNodeClick:n,selectedDocId:a,matchedIds:i,localGraphMode:o,onLocalModeChange:u}){var Z;const d=w.useRef(null),h=w.useRef(null),[m,f]=w.useState({width:600,height:400}),[x,y]=w.useState({nodes:[],links:[]}),[v,b]=w.useState(null),[j,k]=w.useState(null),[C,N]=w.useState({x:0,y:0}),[E,_]=w.useState({x:0,y:0,w:600,h:400}),z=w.useRef(!1),U=w.useRef({x:0,y:0,vx:0,vy:0}),B=w.useRef(null),$=w.useRef(null),q=w.useMemo(()=>dE(E.w),[E.w]),L=w.useMemo(()=>fE(x.nodes),[x.nodes]),R=w.useMemo(()=>xE(L),[L]),I=w.useMemo(()=>{if(o==="global"||!a)return null;const G=new Set(x.nodes.map(F=>F.id)),A=o==="1-hop"?1:2;return yE(a,x.links,G,A)},[o,a,x.nodes,x.links]);w.useEffect(()=>{const G=d.current;if(!G)return;const A=new ResizeObserver(F=>{const{width:W,height:D}=F[0].contentRect;W>0&&D>0&&(f({width:W,height:D}),_(te=>({...te,w:W,h:D})))});return A.observe(G),()=>A.disconnect()},[]),w.useEffect(()=>{if(e.length===0)return;const G=new Set(e.map(Re=>Re.id)),A=e.map(Re=>({id:Re.id,title:Re.title,category:Re.category,akb_type:Re.akb_type,tldr:Re.tldr,tags:Re.tags})),F=(Re,Et)=>{if(!Et.startsWith(".")&&!Et.startsWith("/"))return Et;const ut=Re.split("/");ut.pop();const gt=Et.split("/");for(const kt of gt)kt===".."?ut.pop():kt!=="."&&kt!==""&&ut.push(kt);return ut.join("/")},W=[];for(const Re of e)for(const Et of Re.links){const ut=F(Re.id,Et.href);G.has(ut)&&ut!==Re.id&&(W.some(gt=>gt.source===Re.id&>.target===ut||gt.source===ut&>.target===Re.id)||W.push({source:Re.id,target:ut,label:Et.text}))}const{width:D,height:te}=m,je=A.length,ve=je>100?-600:je>50?-500:-400,ze=je>100?180:je>50?160:140,Xe=je>100?60:50,de=Math.max(D,je*12),Oe=Math.max(te,je*10),Qe=mE(de,Oe,A),Se=jN(A).force("link",oN(W).id(Re=>Re.id).distance(ze)).force("charge",SN().strength(ve)).force("center",HC(de/2,Oe/2)).force("collide",iN(Xe)).force("cluster",pE(Qe,.15));$.current=Se,Se.on("tick",()=>{y({nodes:[...A],links:[...W]})}),Se.alpha(1).restart();const Je=je>100?300:150;for(let Re=0;Re<Je;Re++)Se.tick();if(Se.stop(),y({nodes:[...A],links:[...W]}),A.length>0){let Re=1/0,Et=1/0,ut=-1/0,gt=-1/0;for(const pe of A){const xe=pe.x??0,ge=pe.y??0;xe<Re&&(Re=xe),ge<Et&&(Et=ge),xe>ut&&(ut=xe),ge>gt&&(gt=ge)}const kt=100;_({x:Re-kt,y:Et-kt,w:Math.max(D,ut-Re+kt*2),h:Math.max(te,gt-Et+kt*2)})}return()=>{Se.stop()}},[e,m]);const H=G=>{if(typeof G=="string"){const A=x.nodes.find(F=>F.id===G);return{x:(A==null?void 0:A.x)??0,y:(A==null?void 0:A.y)??0}}return{x:G.x??0,y:G.y??0}},Q=w.useCallback(G=>{G.preventDefault();const A=G.deltaY>0?1.1:.9;_(F=>{const W=Math.max(200,Math.min(m.width*3,F.w*A)),D=Math.max(150,Math.min(m.height*3,F.h*A)),te=(W-F.w)/2,je=(D-F.h)/2;return{x:F.x-te,y:F.y-je,w:W,h:D}})},[m]),oe=w.useCallback(G=>{G.button===0&&(z.current=!0,U.current={x:G.clientX,y:G.clientY,vx:E.x,vy:E.y})},[E]),re=w.useCallback(G=>{var A;if(B.current){const F=h.current;if(!F)return;const W=F.getBoundingClientRect(),D=E.w/W.width,te=E.h/W.height,je=E.x+(G.clientX-W.left)*D,ve=E.y+(G.clientY-W.top)*te;B.current.fx=je,B.current.fy=ve,(A=$.current)==null||A.alpha(.3).restart();return}if(z.current){const F=(G.clientX-U.current.x)*(E.w/m.width),W=(G.clientY-U.current.y)*(E.h/m.height);_(D=>({...D,x:U.current.vx-F,y:U.current.vy-W}))}},[E,m]),Y=w.useCallback(()=>{z.current=!1,B.current&&(B.current.fx=null,B.current.fy=null,B.current=null)},[]),ae=w.useCallback((G,A)=>{var F;G.stopPropagation(),B.current=A,(F=$.current)==null||F.alpha(.3).restart()},[]);return l.jsxs("div",{ref:d,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[l.jsxs("svg",{ref:h,width:m.width,height:m.height,viewBox:`${E.x} ${E.y} ${E.w} ${E.h}`,style:{display:"block",cursor:z.current?"grabbing":"grab"},onWheel:Q,onMouseDown:oe,onMouseMove:re,onMouseUp:Y,onMouseLeave:Y,children:[l.jsx("defs",{children:l.jsx("pattern",{id:"grid",width:"20",height:"20",patternUnits:"userSpaceOnUse",children:l.jsx("circle",{cx:"0",cy:"0",r:"0.5",fill:"rgba(255,255,255,0.06)"})})}),l.jsx("rect",{x:E.x-100,y:E.y-100,width:E.w+200,height:E.h+200,fill:"url(#grid)",pointerEvents:"none"}),q==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:L.map(G=>{const A=sa[G.domain]??sa.general,F=Math.max(40,Math.sqrt(G.count)*25),D=i===null||G.nodes.some(te=>i.has(te.id))?1:.2;return l.jsxs("g",{transform:`translate(${G.centerX}, ${G.centerY})`,style:{cursor:"pointer",opacity:D,transition:"opacity 0.3s ease"},onMouseEnter:te=>{var ve;const je=(ve=d.current)==null?void 0:ve.getBoundingClientRect();je&&N({x:te.clientX-je.left,y:te.clientY-je.top}),b({id:`cluster-${G.domain}`,title:`${G.domain} (${G.count})`,category:G.domain,akb_type:"hub"})},onMouseLeave:()=>b(null),children:[l.jsx("circle",{r:F,fill:A.bg,stroke:A.border,strokeWidth:3,opacity:.8}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:A.text,fontSize:16,fontFamily:"monospace",fontWeight:"bold",style:{pointerEvents:"none"},children:G.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:A.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",G.count,")"]})]},G.domain)})}),q!=="macro"&&l.jsxs(l.Fragment,{children:[q==="standard"&&R.map(G=>{const A=sa[G.domain]??sa.general;if(G.count<2)return null;const F=i===null||G.nodes.some(D=>i.has(D.id)),W=F?.08:.02;return l.jsxs("g",{children:[l.jsx("circle",{cx:G.centerX,cy:G.centerY,r:G.radius,fill:A.bg,stroke:A.border,strokeWidth:1,strokeDasharray:"6 4",opacity:W,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:G.centerX,y:G.centerY-G.radius-8,textAnchor:"middle",fill:A.text,fontSize:10,fontFamily:"monospace",fontWeight:"600",opacity:F?.6:.2,style:{pointerEvents:"none",transition:"opacity 0.3s ease"},children:[G.domain," (",G.count,")"]})]},`cluster-bg-${G.domain}`)}),x.links.map((G,A)=>{const F=H(G.source),W=H(G.target),D=j===A,te=(F.x+W.x)/2,je=(F.y+W.y)/2,ve=typeof G.source=="string"?G.source:G.source.id,ze=typeof G.target=="string"?G.target:G.target.id,de=I===null||I.has(ve)&&I.has(ze)?1:.1;return l.jsxs("g",{style:{opacity:de,transition:"opacity 0.3s ease"},children:[l.jsx("line",{x1:F.x,y1:F.y,x2:W.x,y2:W.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>k(A),onMouseLeave:()=>k(null)}),l.jsx("line",{x1:F.x,y1:F.y,x2:W.x,y2:W.y,stroke:D?"rgba(148,163,184,0.7)":"rgba(148,163,184,0.3)",strokeWidth:D?2:1.5,strokeDasharray:"4 3",pointerEvents:"none"}),D&&G.label&&l.jsx("text",{x:te,y:je-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:G.label.length>30?G.label.slice(0,28)+"..":G.label})})]},A)}),x.nodes.map(G=>{const A=sa[G.category]??sa.general,F=G.akb_type==="hub",W=F?24:16,D=q==="micro"?W*1.5:W,te=(v==null?void 0:v.id)===G.id,je=a===G.id,ve=te?1.1:je?1.05:1,ze=i===null||i.has(G.id),Xe=I===null||I.has(G.id),de=ze&&Xe?1:.15,Oe=q==="micro"?hE(G.tldr,50):"",Qe=q==="micro"&&G.tags?G.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${G.x??0}, ${G.y??0}) scale(${ve})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:de},onClick:Se=>{Se.stopPropagation();const Je=e.find(Re=>Re.id===G.id);Je&&n(Je)},onMouseDown:Se=>ae(Se,G),onMouseEnter:Se=>{var Re;b(G);const Je=(Re=d.current)==null?void 0:Re.getBoundingClientRect();Je&&N({x:Se.clientX-Je.left,y:Se.clientY-Je.top})},onMouseLeave:()=>b(null),children:[je&&l.jsx("rect",{x:-D/2-4,y:-D/2-4,width:D+8,height:D+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:F?5:2,opacity:.6}),l.jsx("rect",{x:-D/2,y:-D/2,width:D,height:D,fill:A.border,rx:F?4:2,opacity:te?1:.9}),l.jsx("rect",{x:-D/2+3,y:-D/2+3,width:Math.max(0,D-6),height:Math.max(0,D-6),fill:A.bg,rx:F?3:1}),l.jsx("text",{y:D/2+14,textAnchor:"middle",fill:je?"#e2e8f0":"#94a3b8",fontSize:q==="micro"?10:11,fontFamily:"monospace",fontWeight:je?"bold":"normal",style:{pointerEvents:"none"},children:G.title.length>24?G.title.slice(0,22)+"..":G.title}),q==="micro"&&Oe&&l.jsx("text",{y:D/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:8,fontFamily:"system-ui, sans-serif",opacity:.7,style:{pointerEvents:"none"},children:Oe}),q==="micro"&&Qe.length>0&&l.jsx("g",{transform:`translate(0, ${D/2+(Oe?42:28)})`,children:Qe.map((Se,Je)=>{const Re=Se.length*5+8;let ut=-Qe.reduce((gt,kt)=>gt+kt.length*5+10,0)/2;for(let gt=0;gt<Je;gt++)ut+=Qe[gt].length*5+10;return l.jsxs("g",{transform:`translate(${ut+Re/2}, 0)`,children:[l.jsx("rect",{x:-Re/2,y:-6,width:Re,height:12,fill:A.bg,stroke:A.border,strokeWidth:.5,rx:3}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:A.text,fontSize:7,fontFamily:"monospace",style:{pointerEvents:"none"},children:Se})]},Se)})})]},G.id)})]})]}),v&&!B.current&&l.jsxs("div",{className:"absolute z-10 pointer-events-none p-2.5 rounded text-xs max-w-[240px]",style:{left:Math.min(C.x+16,m.width-250),top:Math.max(C.y-30,8),background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",boxShadow:"0 4px 12px rgba(0,0,0,0.4)"},children:[l.jsx("div",{className:"font-bold mb-1",children:v.title}),l.jsxs("div",{className:"text-[10px] opacity-60 mb-1",children:[v.akb_type.toUpperCase()," / ",v.category]}),v.id.startsWith("cluster-")?l.jsx("div",{className:"text-[10px] text-green-400",children:"Zoom in to see documents"}):l.jsxs(l.Fragment,{children:[((Z=e.find(G=>G.id===v.id))==null?void 0:Z.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(G=>G.id===v.id).tldr}),l.jsx("div",{className:"text-[10px] text-green-400",children:"Click to open | Drag to move"})]})]}),l.jsxs("div",{className:"absolute bottom-3 left-3 px-2 py-1 rounded text-[10px] font-mono",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color: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(G=>{const A=o===G,F=G!=="global"&&!a,W=G==="global"?"๐ All":G==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!F&&u(G),disabled:F,className:"px-2 py-1 text-[10px] font-medium cursor-pointer transition-all",style:{background:A?"rgba(22,163,106,0.3)":"transparent",color:F?"var(--terminal-text-muted)":A?"#4ade80":"var(--terminal-text-secondary)",opacity:F?.4:1,cursor:F?"not-allowed":"pointer"},title:F?"Select a node first":`Show ${G==="global"?"all nodes":`nodes within ${G}`}`,children:W},G)})}),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 bE(e){const n=[],a=new Map;return[...e].sort((o,u)=>o.id.localeCompare(u.id)).forEach(o=>{const u=o.id.split("/");let d=n,h="";for(let m=0;m<u.length-1;m++)if(h=h?`${h}/${u[m]}`:u[m],a.has(h))d=a.get(h).children;else{const f={type:"folder",name:u[m],path:h,children:[]};a.set(h,f),d.push(f),d=f.children}d.push({type:"file",name:u[u.length-1],path:o.id,doc:o})}),n}function vE({docs:e,onDocumentClick:n,selectedDocId:a,matchedIds:i}){const[o,u]=w.useState(new Set(["knowledge","projects","architecture","operations","company"])),[d,h]=w.useState(null),m=w.useMemo(()=>bE(e),[e]),f=b=>{u(j=>{const k=new Set(j);return k.has(b)?k.delete(b):k.add(b),k})},x=b=>{h(b),n(b)},y=()=>{h(null),n(null)},v=d?e.find(b=>b.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"}),m.map(b=>l.jsx(cv,{node:b,level:0,expandedFolders:o,selectedDocId:a,viewingDocId:d,onToggleFolder:f,onFileClick:x,matchedIds:i},b.path))]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:v?l.jsx(kE,{doc:v,onClose:y}):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 cv({node:e,level:n,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:h}){var b,j,k;const m=a.has(e.path),f=e.type==="file"&&e.path===i,x=e.type==="file"&&e.path===o,y=((b=e.doc)==null?void 0:b.akb_type)==="hub",v=e.type==="folder"||h===null||h.has(e.path);if(e.type==="folder"){const C=h===null||(((j=e.children)==null?void 0:j.some(N=>{if(N.type==="file")return h.has(N.path);const E=_=>{var z;return _.type==="file"?h.has(_.path):((z=_.children)==null?void 0:z.some(E))??!1};return E(N)}))??!1);return l.jsxs("div",{style:{opacity:C?1:.3,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(N=>l.jsx(cv,{node:N,level:n+1,expandedFolders:a,selectedDocId:i,viewingDocId:o,onToggleFolder:u,onFileClick:d,matchedIds:h},N.path)))]})}return l.jsxs("div",{className:`flex items-center gap-1 py-0.5 px-1 rounded cursor-pointer transition-colors ${x?"bg-green-500/20":f?"bg-white/10":"hover:bg-white/5"}`,style:{paddingLeft:n*12+4,opacity:v?1:.2,transition:"opacity 0.2s ease"},onClick:()=>d(e.path),children:[l.jsx("span",{className:"text-[10px]",children:y?"๐":"๐"}),l.jsx("span",{className:`text-[11px] truncate ${y?"font-semibold":""}`,style:{color:y?"#16a34a":"var(--terminal-text)"},children:e.name})]})}function wE(e){const n=e.split(`
|
|
82
|
+
`),a=[],i=new Map;for(const o of n){const u=o.match(/^(#{2,3})\s+(.+)$/);if(!u)continue;const d=u[1].length,h=u[2].trim();let m=h.toLowerCase().replace(/[^a-z0-9๊ฐ-ํฃ\s-]/g,"").replace(/\s+/g,"-").slice(0,50);const f=i.get(m)||0;i.set(m,f+1);const x=f>0?`${m}-${f}`:m;a.push({id:x,text:h,level:d})}return a}function kE({doc:e,onClose:n}){const[a,i]=w.useState(null),[o,u]=w.useState(!1),[d,h]=w.useState(null),m=w.useRef(null),[f,x]=w.useState(null);w.useEffect(()=>{if("content"in e&&e.content){i(e);return}u(!0),h(null),me.getKnowledgeDoc(e.id).then(i).catch(C=>h(C instanceof Error?C.message:"Failed to load")).finally(()=>u(!1))},[e]);const y=w.useMemo(()=>!a||e.format==="html"?[]:wE(a.content),[a,e.format]),v=C=>{if(!m.current)return;const N=m.current.querySelectorAll("h2, h3");for(const E of N){const z=(E.textContent||"").toLowerCase().replace(/[^a-z0-9๊ฐ-ํฃ\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(C.startsWith(z)){E.scrollIntoView({behavior:"smooth",block:"start"}),x(C);break}}},b=uE(e.category),j=e.akb_type==="hub",k=y.length>0&&!o&&!d;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.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:j?"๐":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(C=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium",style:{background:b.bg,color:b.text,border:`1px solid ${b.border}`},children:C},C))})]})]}),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:m,className:"flex-1 overflow-y-auto p-4",children:[o&&l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"Loading..."}),d&&l.jsx("div",{className:"text-xs p-2 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:d}),a&&l.jsx(Xo,{content:a.content})]}),k&&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:y.map(C=>l.jsx("button",{onClick:()=>v(C.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(C.level-2)*8+8,color:f===C.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:f===C.id?"bold":"normal"},children:C.text.length>30?C.text.slice(0,28)+"..":C.text},C.id))})]})]})]})}const jE=500,Xy=360,SE=700;function Wo(e,n,a){const i=n??jE,[o,u]=w.useState(i),[d,h]=w.useState(!1),m=w.useRef(0),f=w.useRef(0),x=w.useRef(a);x.current=a;const y=e>0,v=y?e:0,b=Math.max(SE,i),j=y?Math.max(Xy,window.innerWidth-e-100):b,k=Math.min(o,j),C=w.useCallback(N=>{N.preventDefault(),m.current=N.clientX,f.current=k,h(!0);const E=()=>{h(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",E)},_=z=>{const U=m.current-z.clientX,B=f.current+U;if(B>=window.innerWidth*.6&&x.current){E(),x.current();return}const $=Math.min(b,Math.max(Xy,B));u($)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",E)},[k]);return{panelRight:v,panelWidth:k,isResizing:d,handleResizeStart:C}}function Wy({docs:e,onClose:n,onRefresh:a,terminalWidth:i=0,initialDocId:o,onMaximize:u}){const[d,h]=w.useState(()=>{const R=localStorage.getItem("kb-view-mode");return R==="graph"||R==="tree"||R==="list"?R:"graph"}),[m,f]=w.useState(null),[x,y]=w.useState("global"),[v,b]=w.useState(""),[j,k]=w.useState(()=>new Set(Object.keys(sa)));w.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const C=w.useMemo(()=>new Es(e,{keys:["title","tldr","tags"],threshold:.3,includeScore:!0}),[e]),N=w.useMemo(()=>{let R=new Set(e.map(I=>I.id));if(v.trim()){const I=C.search(v);R=new Set(I.map(H=>H.item.id))}return R=new Set(Array.from(R).filter(I=>{const H=e.find(Q=>Q.id===I);return H&&j.has(H.category)})),R.size===e.length?null:R},[e,v,C,j]),E=w.useMemo(()=>N===null?e:e.filter(R=>N.has(R.id)),[e,N]),_=R=>{k(I=>{const H=new Set(I);return H.has(R)?H.delete(R):H.add(R),H})},{panelRight:z,panelWidth:U,isResizing:B,handleResizeStart:$}=Wo(i,void 0,u),q=R=>{f(R.id)},L=m?e.find(R=>R.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)] ${B?"resizing":""}`,style:{right:z,width:U,background:"var(--terminal-bg)",borderLeftColor:"#16a34a"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${B?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:$}),l.jsxs("div",{className:"p-5 text-white relative",style:{background:"#16a34a"},children:[l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1",children:[u&&l.jsx("button",{onClick:u,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-sm hover:bg-white/30 cursor-pointer",title:"Maximize (Pro View)",children:"โคข"}),l.jsx("button",{onClick:n,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"ร"})]}),l.jsxs("div",{className:"text-lg font-bold",children:["๐"," Knowledge Base"]}),l.jsxs("div",{className:"text-xs opacity-80 mt-0.5",children:[e.length," documents"]})]}),l.jsxs("div",{className:"flex gap-1 p-2",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx(Dh,{icon:"๐ธ๏ธ",label:"Graph",active:d==="graph",onClick:()=>h("graph")}),l.jsx(Dh,{icon:"๐ฒ",label:"Tree",active:d==="tree",onClick:()=>{h("tree"),f(null)}}),l.jsx(Dh,{icon:"๐",label:"List",active:d==="list",onClick:()=>{h("list"),f(null)}})]}),l.jsxs("div",{className:"p-3 space-y-2",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-sm",children:"๐"}),l.jsx("input",{type:"text",value:v,onChange:R=>b(R.target.value),placeholder:"Search docs...",className:"w-full pl-8 pr-3 py-1.5 text-xs rounded focus:outline-none transition-colors",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}}),v&&l.jsx("button",{onClick:()=>b(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs hover:opacity-70",style:{color:"var(--terminal-text-muted)"},children:"โ"})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:Object.entries(sa).map(([R,I])=>{const H=j.has(R);return l.jsx("button",{onClick:()=>_(R),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:H?I.bg:"transparent",color:H?I.text:"var(--terminal-text-muted)",border:`1px solid ${H?I.border:"var(--terminal-border)"}`,opacity:H?1:.5},children:R},R)})}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:E.length===e.length?`${e.length} documents`:`${E.length} of ${e.length} documents`})]}),d==="graph"&&l.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col animate-fadeIn",children:[l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx(gE,{docs:e,onNodeClick:q,selectedDocId:m,matchedIds:N,localGraphMode:x,onLocalModeChange:y}),L&&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:L.title}),l.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:L.status==="active"?"#16a34a":L.status==="draft"?"#f59e0b":"#94a3b8"}}),L.tldr&&l.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:L.tldr}),L.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"}),L.links.slice(0,5).map((R,I)=>l.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["๐"," ",R.text]},I))]})]})]}),l.jsx("div",{className:"shrink-0 p-2",style:{borderTop:"1px solid var(--terminal-border)"},children:l.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(sa).map(([R,I])=>l.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[l.jsx("div",{className:"w-2 h-2",style:{background:I.border}}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:R})]},R))})})]}),d==="tree"&&l.jsx(vE,{docs:e,onDocumentClick:R=>f(R),selectedDocId:m,matchedIds:N}),d==="list"&&l.jsx(CE,{icon:"๐",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"})]})]})}function Dh({icon:e,label:n,active:a,onClick:i}){return l.jsxs("button",{onClick:i,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 text-xs font-medium rounded cursor-pointer transition-all",style:{background:a?"rgba(22,163,106,0.2)":"transparent",color:a?"#4ade80":"var(--terminal-text-muted)",border:a?"1px solid rgba(22,163,106,0.4)":"1px solid transparent"},children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{children:n})]})}function CE({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 Vy({standups:e,waves:n,decisions:a,mode:i,onClose:o,onOpenWaveCenter:u,terminalWidth:d=0,onMaximize:h}){const[m,f]=w.useState(i==="decisions"?"decisions":"standups"),{panelRight:x,panelWidth:y,isResizing:v,handleResizeStart:b}=Wo(d,void 0,h);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:x},onClick:o}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${v?"resizing":""}`,style:{right:x,width:y,background:"var(--terminal-bg)",borderLeftColor:"var(--desk-wood)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${v?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:b}),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:[h&&l.jsx("button",{onClick:h,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:o,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.jsx("div",{className:"text-lg font-bold",children:i==="bulletin"?"๐ Bulletin Board":"๐ Decision Log"})]}),l.jsx("div",{className:"flex",style:{borderBottom:"1px solid var(--terminal-border)"},children:i==="bulletin"?l.jsxs(l.Fragment,{children:[l.jsx(gu,{label:`Standups (${e.length})`,active:m==="standups",onClick:()=>f("standups")}),u?l.jsx(gu,{label:"Waves โ",active:!1,onClick:u}):l.jsx(gu,{label:`Waves (${n.length})`,active:m==="waves",onClick:()=>f("waves")})]}):l.jsx(gu,{label:`Decisions (${a.length})`,active:m==="decisions",onClick:()=>f("decisions")})}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[m==="standups"&&e.map((j,k)=>l.jsx(Th,{title:`Standup ${j.date}`,content:j.content},k)),m==="waves"&&n.map((j,k)=>l.jsx(Th,{title:`Wave ${j.id}`,subtitle:j.startedAt,content:j.directive},k)),m==="decisions"&&a.map((j,k)=>l.jsx(Th,{title:`#${j.id} ${j.title}`,subtitle:j.date,content:j.content},k))]})]})]})}function gu({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 NE(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 Th({title:e,subtitle:n,content:a}){const[i,o]=w.useState(!1),u=a.length>100,d=NE(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(Xo,{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 ks=[{id:"ch1-q1",chapter:1,title:"Hire your first employee",description:'Every company starts with its first hire. Click the HIRE button to open the recruitment panel. Choose a role name (e.g. "PM"), set a level, and bring them on board. Each role becomes an AI agent that works for your company.',type:"main",trigger:{type:"role_hired"},rewards:{coins:1e3},hint:{target:"hire-btn",message:"Click HIRE to recruit your first team member"}},{id:"ch1-q2",chapter:1,title:"Open the Terminal",description:"The Terminal is your command center โ where you talk to your team. Click TERMINAL in the bottom bar to open it. You'll see a chat-like interface where you can select any role and give them instructions.",type:"main",trigger:{type:"terminal_opened"},rewards:{coins:500},hint:{target:"terminal-btn",message:"Click TERMINAL to open your command center"}},{id:"ch1-q3",chapter:1,title:"Talk to your team",description:`Use "Talk" mode to have a conversation with your team. Talk mode is for quick questions, brainstorming, and discussions โ the AI role will respond with advice but won't modify any files. Select a role tab and type your message.`,type:"main",trigger:{type:"talk_mode_used"},rewards:{coins:1e3},hint:{target:"terminal-btn",message:"Open the terminal, select Talk mode, and chat"}},{id:"ch2-q1",chapter:2,title:"Create a project",description:"Projects organize your company's work. Click the Meeting Room in the office view to create one. Give it a name, description, and the system will scaffold a project folder with PRD, tasks, and design docs that your AI team will use.",type:"main",trigger:{type:"project_created"},rewards:{coins:1500},hint:{target:"meeting-room",message:"Click the Meeting Room to create a project"}},{id:"ch2-q2",chapter:2,title:"Give your first order",description:'Use "Do" mode to assign real work. Unlike Talk mode, Do mode lets roles execute tasks โ they can read/write files, create documents, and run commands. Switch to Do mode in the terminal and give your team member a task.',type:"main",trigger:{type:"do_mode_used"},rewards:{badge:"first-launch",coins:2e3},hint:{target:"terminal-btn",message:"Open the terminal, switch to Do mode, and assign a task"}},{id:"ch3-q1",chapter:3,title:"Create a chat channel",description:'Chat channels let multiple roles discuss topics together โ like Slack for your AI team. Click the "+" button next to channel tabs in the terminal to create a new channel. Add members and set a topic for focused collaboration.',type:"main",trigger:{type:"chat_channel_created"},rewards:{coins:1500},hint:{target:"terminal-btn",message:'Open the terminal and click "+" to create a chat channel'}},{id:"ch3-q2",chapter:3,title:"Dispatch a CEO Wave",description:"CEO Wave broadcasts a directive to your entire C-Level team at once. It's like an all-hands announcement โ each C-Level role receives the wave and can delegate to their reports. Use it for company-wide initiatives, pivots, or big decisions.",type:"main",trigger:{type:"wave_dispatched"},rewards:{badge:"team-builder",coins:3e3},hint:{target:"wave-btn",message:"Click CEO WAVE to broadcast to your team"}},{id:"ch4-q1",chapter:4,title:"Hire a CTO",description:"C-Level roles are special โ they can delegate work to their reports and make autonomous decisions. A CTO manages your technical team (Engineers, QA). Hire one with the C-Level tier to unlock the org hierarchy.",type:"main",trigger:{type:"role_hired",condition:{roleId:"cto"}},rewards:{coins:2e3},hint:{target:"hire-btn",message:"Hire a CTO to lead your tech team"}},{id:"ch4-q2",chapter:4,title:"Hire an Engineer",description:'Engineers are the builders. They read architecture docs, write code, and ship features. Set their "Reports To" to CTO so the org hierarchy works โ when you wave, the CTO can delegate tasks down to engineers automatically.',type:"main",trigger:{type:"role_hired",condition:{roleId:"engineer"}},rewards:{coins:2500},hint:{target:"hire-btn",message:"Hire an Engineer to start building"}},{id:"ch4-q3",chapter:4,title:"Define a persona",description:"Each role has a persona โ their personality, expertise, and communication style. Click a role in the office to open their panel, then edit their persona. A well-defined persona makes the AI role more consistent and specialized.",type:"main",trigger:{type:"persona_updated"},rewards:{coins:2e3},hint:{target:"terminal-btn",message:"Click a role in the office, then edit their persona"}},{id:"ch5-q1",chapter:5,title:"Explore the Knowledge Base",description:"The Knowledge Hub stores your company's documents โ architecture decisions, domain knowledge, meeting notes. Your AI team reads these docs for context when working. Click the Knowledge bookshelf in the office to browse.",type:"main",trigger:{type:"knowledge_visited"},rewards:{coins:2e3},hint:{target:"knowledge-hub",message:"Click the Knowledge Hub to explore your docs"}},{id:"ch5-q2",chapter:5,title:"Check the Bulletin Board",description:"The Bulletin Board shows your company's daily standups and wave execution logs. Every time a role completes work, they post a standup. Waves show the full chain of delegation. It's your company's activity feed.",type:"main",trigger:{type:"bulletin_visited"},rewards:{badge:"scholar",coins:2e3},hint:{target:"bulletin-board",message:"Click the Bulletin Board for company updates"}},{id:"ch6-q1",chapter:6,title:"Visit the Character Store",description:"The Store has community-created characters with unique pixel art designs. Browse characters shared by other Tycono users, preview their look, and import them into your team. Open HIRE and switch to the Store tab.",type:"main",trigger:{type:"store_visited"},rewards:{coins:3e3},hint:{target:"hire-btn",message:"Open HIRE and check out the Store tab"}},{id:"ch6-q2",chapter:6,title:"Customize a character",description:"Every role has a pixel art character you can customize โ change hair, skin, outfit, and accessories. Click a role in the office view to open their panel, then click the character sprite to enter the customization editor.",type:"main",trigger:{type:"accessory_changed"},rewards:{badge:"explorer",coins:5e3},hint:{target:"hire-btn",message:"Click a team member to customize their look"}},{id:"ch6-q3",chapter:6,title:"Change the office theme",description:"Your office supports multiple visual themes โ each changes the color palette, mood, and atmosphere. Click the theme icon in the bottom bar to browse available themes and pick the one that matches your company's vibe.",type:"main",trigger:{type:"theme_changed"},rewards:{badge:"stylist",coins:2e3},hint:{target:"theme-btn",message:"Click the Theme button to change your office look"}},{id:"ch7-q1",chapter:7,title:"Decorate your office",description:"Enter Edit mode to rearrange your office layout. You can drag furniture, place decorations, and create different room zones. Click the EDIT button, then drag items to place them. Click DONE when finished.",type:"main",trigger:{type:"furniture_placed"},rewards:{coins:2e3},hint:{target:"edit-btn",message:"Click EDIT to enter furniture layout mode"}},{id:"ch7-q2",chapter:7,title:"Buy premium furniture",description:"Spend coins earned from quests and achievements to buy premium furniture. Enter Edit mode and browse the furniture shop โ each item has a coin price. Premium items add unique visual flair to your office.",type:"main",trigger:{type:"furniture_purchased"},rewards:{badge:"interior-designer",coins:3e3},hint:{target:"edit-btn",message:"Enter EDIT mode and buy furniture with coins"}},{id:"ch8-q1",chapter:8,title:"Review company stats",description:"The Stats panel shows your company's performance metrics โ token usage per role, activity levels, role leaderboard, and growth over time. Click the Stats facility in the office to see how your team is performing.",type:"main",trigger:{type:"stats_visited"},rewards:{coins:2e3},hint:{target:"stats-btn",message:"Click Stats to see your company metrics"}},{id:"ch8-q2",chapter:8,title:"Save your progress",description:"Tycono uses git to track all changes your AI team makes. Press Cmd+S (or click the save indicator) to commit your company's current state. Each save creates a git commit โ you can view history and even restore previous states.",type:"main",trigger:{type:"save_committed"},rewards:{coins:2e3},hint:{target:"save-btn",message:"Press Cmd+S or click Save to commit changes"}},{id:"ch8-q3",chapter:8,title:"Open Settings",description:"The Settings panel lets you configure your company โ adjust API keys, execution engine preferences, and other system options. Click the gear icon in the bottom bar to access it.",type:"main",trigger:{type:"settings_visited"},rewards:{coins:2e3},hint:{target:"settings-btn",message:"Click the Settings gear to configure your company"}},{id:"ch9-q1",chapter:9,title:"Hire a Designer",description:"A Designer handles UI/UX work โ wireframes, mockups, and visual design decisions. They complement your Engineer by focusing on the user experience side. Hire one to round out your product team.",type:"main",trigger:{type:"role_hired",condition:{roleId:"designer"}},rewards:{coins:2500},hint:{target:"hire-btn",message:"Hire a Designer for your creative team"}},{id:"ch9-q2",chapter:9,title:"Hire a QA Engineer",description:"QA Engineers test your product, find bugs, and ensure quality. They review code changes, write test plans, and validate that features work as expected. Essential for any serious product team.",type:"main",trigger:{type:"role_hired",condition:{roleId:"qa"}},rewards:{coins:3e3},hint:{target:"hire-btn",message:"Hire a QA Engineer for quality assurance"}},{id:"ch9-q3",chapter:9,title:"Build a 5-person team",description:"Growing your team unlocks the full potential of delegation. With 5+ members, your C-Level roles can distribute work across specialized team members, creating a real organizational hierarchy.",type:"main",trigger:{type:"role_hired",condition:{minRoles:5}},rewards:{badge:"growing-company",coins:5e3},hint:{target:"hire-btn",message:"Keep hiring until you have 5+ team members"}},{id:"ch10-q1",chapter:10,title:"Build a 7-person team",description:"A full-size team with diverse roles means your company can handle any challenge. CEO at the top, C-Levels managing domains, and specialists executing. You've built a real AI-powered organization.",type:"main",trigger:{type:"role_hired",condition:{minRoles:7}},rewards:{badge:"tycoon-master",coins:1e4},hint:{target:"hire-btn",message:"Keep hiring until you have 7+ team members"}}],ym=[{num:1,title:"Getting Started",questIds:["ch1-q1","ch1-q2","ch1-q3"]},{num:2,title:"First Project",questIds:["ch2-q1","ch2-q2"]},{num:3,title:"Team Communication",questIds:["ch3-q1","ch3-q2"]},{num:4,title:"Building the Team",questIds:["ch4-q1","ch4-q2","ch4-q3"]},{num:5,title:"Knowledge & Docs",questIds:["ch5-q1","ch5-q2"]},{num:6,title:"Customization",questIds:["ch6-q1","ch6-q2","ch6-q3"]},{num:7,title:"Office Design",questIds:["ch7-q1","ch7-q2"]},{num:8,title:"Operations",questIds:["ch8-q1","ch8-q2","ch8-q3"]},{num:9,title:"Scaling Up",questIds:["ch9-q1","ch9-q2","ch9-q3"]},{num:10,title:"Tycoon Master",questIds:["ch10-q1"]}],EE={completedQuests:[],activeChapter:1,sideQuestsCompleted:[]};function Gy(){return{...EE}}function gm(e,n){return n.completedQuests.includes(e.id)?"completed":"active"}function uv(e){return ks.filter(n=>gm(n,e)==="active")}function AE(e){return uv(e)[0]??null}function DE(e,n){const a=ks.find(o=>o.id===n);return a?e.completedQuests.includes(n)?{progress:e,quest:null}:{progress:{...e,completedQuests:[...e.completedQuests,n],firstCompletedAt:e.firstCompletedAt??new Date().toISOString()},quest:a}:{progress:e,quest:null}}function TE(e){let n=1;for(const a of ym)if(a.questIds.every(i=>e.completedQuests.includes(i))){const i=ym.find(o=>o.num===a.num+1);i&&(n=i.num)}return n!==e.activeChapter?{...e,activeChapter:n}:e}function FE(e){const n=ks.filter(i=>i.type==="main").length;return{completed:e.completedQuests.filter(i=>{var o;return((o=ks.find(u=>u.id===i))==null?void 0:o.type)==="main"}).length,total:n}}function ME(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 RE({progress:e,onQuestAction:n,onClose:a,terminalWidth:i=0}){const{completed:o,total:u}=FE(e),d=u>0?Math.round(o/u*100):0,{panelRight:h,panelWidth:m,isResizing:f,handleResizeStart:x}=Wo(i);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:h},onClick:a}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${f?"resizing":""}`,style:{right:h,width:m,background:"var(--terminal-bg)",borderLeftColor:"var(--desk-wood)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${f?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:x}),l.jsxs("div",{className:"p-5 text-white relative",style:{background:"linear-gradient(135deg, #8B5E3C, #6B4226)"},children:[l.jsx("button",{onClick:a,className:"absolute top-3 right-3 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"ร"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xl",children:"๐พ"}),l.jsxs("div",{children:[l.jsx("div",{className:"text-lg font-bold",children:"Pupu's Quest Board"}),l.jsxs("div",{className:"text-xs opacity-70 mt-0.5",children:[o,"/",u," quests completed ยท ",d,"%"]})]})]}),l.jsx("div",{className:"mt-3",children:l.jsx("div",{className:"h-2 rounded-full overflow-hidden bg-white/15",children:l.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${d}%`,background:"#F4D03F"}})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-5 flex flex-col gap-3",children:ym.map(y=>{const v=ks.filter(k=>y.questIds.includes(k.id)),b=v.every(k=>e.completedQuests.includes(k.id)),j=v.some(k=>gm(k,e)==="active");return l.jsxs("div",{className:"rounded-lg",style:{background:j?"var(--hud-bg-alt)":"transparent",border:j?"1px solid var(--accent)":"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[l.jsx("span",{className:"text-sm",children:b?"โ
":"๐ก"}),l.jsxs("span",{className:"text-sm font-medium",style:{color:j?"var(--accent)":"var(--terminal-text)"},children:["Chapter ",y.num,": ",y.title]})]}),l.jsx("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:v.map(k=>{const C=gm(k,e);return l.jsxs("div",{className:"flex items-start gap-2 pl-2",children:[l.jsx("span",{className:"text-xs mt-0.5 shrink-0",children:C==="completed"?"โ":"โ"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs",style:{color:C==="completed"?"var(--terminal-text-muted)":"var(--terminal-text)",textDecoration:C==="completed"?"line-through":"none"},children:k.title}),C==="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 โ"})]}),C==="active"&&l.jsx("div",{className:"text-[10px] mt-1 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:k.description}),C==="active"&&k.hint&&l.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:"var(--accent)"},children:["๐ก ",k.hint.message]})]})]},k.id)})})]},y.num)})})]})]})}function zE({projectId:e,onClose:n,terminalWidth:a=0}){const[i,o]=w.useState(null),{panelRight:u,panelWidth:d,isResizing:h,handleResizeStart:m}=Wo(a);if(w.useEffect(()=>{me.getProject(e).then(o).catch(console.error)},[e]),!i)return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:u},onClick:n}),l.jsx("div",{className:"side-panel open fixed top-0 h-full z-50 flex items-center justify-center border-l-[3px] border-[var(--meeting-blue)]",style:{right:u,width:d,background:"var(--terminal-bg)"},children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading project..."})})]});const f=i.tasks.filter(v=>v.status==="done").length,x=i.tasks.length,y=x>0?Math.round(f/x*100):0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:u},onClick:n}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] border-[var(--meeting-blue)] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${h?"resizing":""}`,style:{right:u,width:d,background:"var(--terminal-bg)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${h?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:m}),l.jsxs("div",{className:"p-5 bg-[var(--meeting-blue)] text-white relative",children:[l.jsx("div",{className:"text-sm opacity-70",children:"Meeting Room"}),l.jsx("button",{onClick:n,className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"ร"}),l.jsx("div",{className:"text-xl font-bold mt-1",children:i.name}),l.jsxs("div",{className:"flex items-center gap-3 mt-3 text-sm",children:[l.jsxs("span",{children:["Tasks: ",x]}),l.jsxs("span",{children:["Done: ",f]}),l.jsxs("span",{children:["Progress: ",y,"%"]})]}),l.jsx("div",{className:"mt-2 h-1.5 bg-white/20 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-white rounded-full transition-all",style:{width:`${y}%`}})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[i.prd&&l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"PRD"}),l.jsx("div",{className:"rounded-lg p-4 text-xs leading-relaxed max-h-60 overflow-y-auto",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(Xo,{content:i.prd})})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:["Tasks (",x,")"]}),l.jsx("div",{className:"space-y-2",children:i.tasks.map(v=>l.jsxs("div",{className:"rounded-lg p-3",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm font-medium",style:{color:"var(--terminal-text)"},children:v.title}),l.jsx(_E,{status:v.status})]}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-muted)"},children:v.role}),v.description&&l.jsx("div",{className:"text-xs mt-1.5 line-clamp-2",style:{color:"var(--terminal-text-secondary)"},children:v.description})]},v.id))})]})]})]})]})}function _E({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 BE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function OE({roleId:e,roleName:n,mode:a="assign",onClose:i,onExecutionStart:o}){const[u,d]=w.useState(""),h=w.useRef(null);w.useEffect(()=>{var y;(y=h.current)==null||y.focus()},[]);const m=()=>{u.trim()&&(o(e,u.trim()),i())},f=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&m(),y.key==="Escape"&&i()},x=BE[e]??"#666";return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:`linear-gradient(135deg, ${x}, ${x}cc)`},children:[l.jsx("div",{className:"text-lg font-bold",children:a==="ask"?"Ask":"Assign Task"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:a==="ask"?`to ${n}`:`to ${n} (${e})`})]}),l.jsxs("div",{className:"p-5",children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Task Description"}),l.jsx("textarea",{ref:h,value:u,onChange:y=>d(y.target.value),onKeyDown:f,placeholder:a==="ask"?"What would you like to ask?":"Describe the task...",className:"w-full h-32 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-white/30 mt-1",children:"Cmd+Enter to submit"})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:m,disabled:!u.trim(),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:x},children:a==="ask"?"Ask":"Assign"})]})]})]})}const Ky={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function nd({event:e,isThinkingCollapsed:n,onToggleThinking:a,onNavigateToJob:i,onOpenKnowledgeDoc:o,compact:u}){var h;const d=Ky[e.roleId]??"#888";switch(e.type){case"text":{const m=e.data.text??"",f=u?m.slice(0,300):m;return/[#*|`\[\]_~>-]/.test(f)?l.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:l.jsx(Hm,{remarkPlugins:[Xm],children:f})}):l.jsx("div",{className:"text-green-300/90 whitespace-pre-wrap leading-relaxed",children:f})}case"thinking":{const m=e.data.text??"";return l.jsxs("div",{className:"group",children:[l.jsxs("button",{onClick:a,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-[10px] cursor-pointer flex items-center gap-1 select-text",children:[l.jsx("span",{children:n?"โถ":"โผ"}),l.jsx("span",{className:"italic",children:"thinking..."})]}),!n&&l.jsxs("div",{className:`ml-3 text-[var(--terminal-text-muted)] italic whitespace-pre-wrap opacity-60 text-[11px] overflow-hidden ${u?"max-h-[60px]":"max-h-[120px]"}`,children:[m.slice(0,u?200:500),m.length>(u?200:500)?"...":""]})]})}case"tool:start":{const m=String(e.data.name??""),f=e.data.input,x=typeof(f==null?void 0:f.command)=="string"?f.command.slice(0,80):"",y=typeof(f==null?void 0:f.file_path)=="string"?String(f.file_path):typeof(f==null?void 0:f.path)=="string"?String(f.path):"",v=y?y.split("/").pop()??"":"",b=/^(write_file|Write|edit_file|Edit)$/i.test(m),j=(h=y.match(/(?:^|\/)knowledge\/(.+\.md)$/))==null?void 0:h[1],k=b&&j&&o;return l.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[l.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${k?"text-green-400/80 bg-green-400/10":"text-blue-400/80 bg-blue-400/10"}`,children:k?b&&m.toLowerCase().includes("edit")?"Edit":"Write":m}),k?l.jsx("button",{onClick:()=>o(j),className:"text-[10px] text-green-400 hover:text-green-300 underline underline-offset-2 cursor-pointer truncate",style:{maxWidth:u?200:400},children:v}):l.jsxs(l.Fragment,{children:[x&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:x}),v&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${u?"max-w-[200px]":"max-w-[400px]"}`,children:v})]})]})}case"dispatch:start":{const m=e.data.targetRoleId??e.data.roleId??"",f=e.data.task??"",x=e.data.childJobId,y=Ky[m]??"#888";return l.jsx("div",{className:"my-1 p-2 rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",style:{borderColor:`${y}44`,background:`${y}11`},onClick:()=>x&&(i==null?void 0:i(x)),children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{style:{color:y},className:"font-bold text-[11px]",children:["โ"," ",m.toUpperCase()]}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] text-[10px] truncate flex-1",children:f.slice(0,u?60:100)}),x&&i&&l.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/10 text-[var(--terminal-text-muted)]",children:["View ","โ"]})]})})}case"dispatch:done":return l.jsx("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pl-3 border-l-2 border-[var(--terminal-border)] my-0.5",children:"Dispatch completed"});case"turn:complete":return l.jsx("div",{className:"border-t border-[var(--terminal-border)] my-2 relative",children:l.jsxs("span",{className:"absolute -top-2 left-2 bg-[var(--terminal-bg)] px-2 text-[9px] text-[var(--terminal-text-muted)]",children:["Turn ",e.data.turn]})});case"stderr":return l.jsxs("div",{className:"text-red-400/80 text-[11px]",children:["โ "," ",e.data.message]});case"job:start":return l.jsxs("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pb-1",children:[l.jsx("span",{style:{color:d},className:"font-bold",children:e.roleId.toUpperCase()})," ","started: ",(e.data.task??"").slice(0,u?50:80)]});case"job:done":{const m=e.data.turns??0,f=e.data.toolCalls??0;return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-green-900/20 border border-green-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"}),l.jsx("span",{className:"text-green-300 font-bold text-[11px]",children:"Complete"}),l.jsxs("span",{className:"text-[var(--terminal-text-muted)] text-[10px]",children:[m," turns ยท ",f," tools"]})]})})}case"job:error":return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-red-900/20 border border-red-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400"}),l.jsx("span",{className:"text-red-300 font-bold text-[11px]",children:"Error"}),l.jsx("span",{className:"text-red-200/70 text-[10px]",children:e.data.message})]})});case"job:awaiting_input":{const m=e.data.question??"";return l.jsxs("div",{className:"mt-2 p-2 rounded-lg border",style:{background:"#F59E0B11",borderColor:"#F59E0B33"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsx("span",{className:"font-bold text-[11px]",style:{color:"#F59E0B"},children:"Awaiting Reply"})]}),m&&l.jsx("div",{className:"mt-1 text-[11px] text-[var(--terminal-text)] whitespace-pre-wrap",children:m})]})}case"job:reply":return l.jsx("div",{className:"mt-1 p-2 rounded-lg bg-blue-900/20 border border-blue-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-blue-300 font-bold text-[11px]",children:"CEO replied:"}),l.jsx("span",{className:"text-blue-200/80 text-[11px]",children:e.data.response??""})]})});case"import:scan":case"import:process":case"import:created":return l.jsxs("div",{className:"text-cyan-300/70 text-[11px]",children:["[",e.type,"] ",JSON.stringify(e.data)]});default:return null}}function $E({jobId:e,title:n,color:a,variant:i,style:o,onClose:u,onMinimize:d,onDone:h,onNavigateToJob:m,onOpenKnowledgeDoc:f}){const{events:x,status:y,textOutput:v,childJobIds:b}=zg(e),[j,k]=w.useState(0),[C,N]=w.useState(new Set),E=w.useRef(null),_=w.useRef(Date.now()),z=w.useRef(!1);w.useEffect(()=>{const I=setInterval(()=>{k(Math.floor((Date.now()-_.current)/1e3))},1e3);return()=>clearInterval(I)},[]),w.useEffect(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[x]),w.useEffect(()=>{(y==="done"||y==="error")&&!z.current&&(z.current=!0,h==null||h())},[y,h]);const U=I=>{N(H=>{const Q=new Set(H);return Q.has(I)?Q.delete(I):Q.add(I),Q})},B={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[y],$={idle:"#888",connecting:"#888",streaming:a,done:"#2E7D32",error:"#C62828"}[y],q=I=>`${Math.floor(I/60)}:${String(I%60).padStart(2,"0")}`,L=y==="done"||y==="error",R=l.jsxs("div",{className:i==="modal"?"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col":"bg-[var(--terminal-bg)] rounded-xl border border-[var(--terminal-border)] overflow-hidden flex flex-col max-h-[400px]",style:o,children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full animate-pulse",style:{background:$}}),l.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:`${$}22`,color:$},children:B}),d&&i==="modal"&&l.jsx("button",{onClick:d,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"โ"}),L&&l.jsx("button",{onClick:u,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",children:"ร"})]})]}),l.jsxs("div",{ref:E,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono",children:[x.length===0&&y==="connecting"&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:"Connecting to activity stream..."}),x.map(I=>l.jsx(nd,{event:I,isThinkingCollapsed:C.has(I.seq),onToggleThinking:()=>U(I.seq),onNavigateToJob:m,onOpenKnowledgeDoc:f},I.seq)),y==="streaming"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),l.jsxs("div",{className:"px-5 py-3 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[l.jsxs("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[x.length>0&&`${x.length} events`,v.length>0&&` ยท ${v.length} chars`,b.length>0&&` ยท ${b.length} dispatches`]}),L&&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:L?u:void 0}),R]}):R}const LE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function dv({orgNodes:e,rootId:n,activeRoles:a,onToggleRole:i}){const o=e[n];if(!o)return null;const u=!!a&&!!i,h=o.children.map(b=>e[b]).filter(Boolean),m=new Map,f=[];for(const b of h){const j=[];for(const k of b.children){const C=e[k];C&&(j.push(C),f.push(C))}m.set(b.id,j)}const x=b=>!a||a.has(b),y=u?h.filter(b=>a.has(b.id)).length+f.filter(b=>a.has(b.id)).length:h.length+f.length,v=h.length+f.length;return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider",children:u?"Select Target Roles":"Propagation Preview"}),u&&l.jsxs("span",{className:"text-[10px] text-white/50",children:[y,"/",v," selected"]})]}),l.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4",children:[l.jsx("div",{className:"flex justify-center mb-2",children:l.jsx("span",{className:"px-3 py-1 text-[10px] font-bold rounded border-2 border-white/20 bg-white/5 text-white/30 uppercase",children:"CEO"})}),h.length>0&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-3 bg-white/15"})}),h.length>1&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"h-px bg-white/15",style:{width:`${Math.min(h.length*80,320)}px`}})}),l.jsx("div",{className:"flex justify-center gap-3 mb-2 flex-wrap",children:h.map(b=>{const j=x(b.id),k=LE[b.id]??"#888";return l.jsx(IE,{node:b,active:j,color:k,interactive:u,onToggle:i,subRoles:m.get(b.id)??[],activeRoles:a},b.id)})}),f.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-2 bg-white/10"})}),l.jsx("div",{className:"flex justify-center gap-2 flex-wrap",children:f.map(b=>{var E;const j=x(b.id),k=(E=h.find(_=>_.children.includes(b.id)))==null?void 0:E.id,C=k?x(k):!0,N=u&&C;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${N?"cursor-pointer select-none":u?"cursor-not-allowed":""} ${j&&C?"border-white/15 text-white/40":"border-white/5 text-white/15 opacity-50"}`,onClick:N?()=>i(b.id,!j):void 0,title:u?C?j?"Click to exclude":"Click to include":`Enable ${k==null?void 0:k.toUpperCase()} first`:void 0,children:b.id},b.id)})}),l.jsx("div",{className:"text-center text-[8px] text-white/30 mt-1",children:"via re-dispatch"})]})]}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1.5",children:u?`${y} role${y!==1?"s":""} will receive this wave`:`${v} role${v!==1?"s":""} will receive this wave`})]})}function IE({node:e,active:n,color:a,interactive:i,onToggle:o,subRoles:u,activeRoles:d}){const h=w.useCallback(m=>{if(!(!i||!o)){if(n){o(e.id,!1);for(const f of u)d!=null&&d.has(f.id)&&o(f.id,!1)}else if(o(e.id,!0),m.shiftKey)for(const f of u)d!=null&&d.has(f.id)||o(f.id,!0)}},[i,o,n,e.id,u,d]);return l.jsxs("div",{className:"flex flex-col items-center",children:[l.jsx("span",{className:`px-2.5 py-1 text-[10px] font-bold rounded border-2 uppercase transition-all ${i?"cursor-pointer select-none hover:scale-105":""}`,style:{borderColor:n?a:`${a}44`,color:n?a:`${a}44`,background:n?`${a}22`:"transparent",opacity:n?1:.4},onClick:h,title:i?n?"Click to exclude (disables subordinates)":"Click to include / Shift+click to include with all subordinates":void 0,children:e.id}),l.jsx("span",{className:"text-[8px] text-white/30 mt-0.5",children:i?n?"active":"off":"direct"})]})}function HE({cLevelRoles:e,orgNodes:n,rootId:a,onClose:i,onDispatch:o}){const[u,d]=w.useState(""),h=w.useRef(null),[m,f]=w.useState(()=>{const k=new Set,C=n[a];if(C)for(const N of C.children){k.add(N);const E=n[N];if(E)for(const _ of E.children)k.add(_)}return k});w.useEffect(()=>{var k;(k=h.current)==null||k.focus()},[]);const x=w.useCallback((k,C)=>{f(N=>{const E=new Set(N);return C?E.add(k):E.delete(k),E})},[]),y=e.filter(k=>m.has(k.id)).length,v=()=>{if(!u.trim()||y===0)return;const k=n[a];let C=0;if(k)for(const _ of k.children){C++;const z=n[_];z&&(C+=z.children.length)}const E=m.size>=C?void 0:Array.from(m);o(u.trim(),E),i()},b=k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&v(),k.key==="Escape"&&i()},j=a&&Object.keys(n).length>0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsx("div",{className:"text-lg font-bold",children:"CEO Wave"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:j?"Select target roles and broadcast a directive":"Broadcast a directive to all C-Level reports"})]}),l.jsxs("div",{className:"p-5 space-y-4",children:[j&&l.jsx(dv,{orgNodes:n,rootId:a,activeRoles:m,onToggleRole:x}),!j&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Dispatching to"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:e.length>0?e.map(k=>l.jsxs("span",{className:"px-3 py-1.5 text-xs font-semibold rounded-lg border-2 border-red-200 bg-red-50 text-red-800",children:[k.id.toUpperCase()," ยท ",k.name]},k.id)):l.jsx("span",{className:"text-xs text-gray-400 italic",children:"No C-Level roles found"})}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Each C-Level receives the directive and delegates to their reports"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Directive"}),l.jsx("textarea",{ref:h,value:u,onChange:k=>d(k.target.value),onKeyDown:b,placeholder:"e.g. Report current status across all departments",className:"w-full h-28 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Cmd+Enter to dispatch"})]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),l.jsxs("button",{onClick:v,disabled:!u.trim()||y===0,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:["Dispatch to ",y," Role",y!==1?"s":""]})]})]})]})}function fv(e,n,a){const[i,o]=w.useState(new Map),[u,d]=w.useState(null),h=w.useRef(new Map),m=w.useRef(i);m.current=i,w.useEffect(()=>{if(!a||Object.keys(n).length===0)return;const v=new Map,b=k=>{const C=n[k];C&&(v.set(k,{jobId:null,roleId:k,roleName:C.name,children:C.children,status:"waiting",events:[],streamStatus:"idle"}),C.children.forEach(b))},j=n[a];j&&(v.set(a,{jobId:null,roleId:a,roleName:"CEO",children:j.children,status:"not-dispatched",events:[],streamStatus:"idle"}),j.children.forEach(b));for(const k of e){const C=v.get(k.roleId);C&&(C.jobId=k.jobId,C.status="running",C.streamStatus="connecting")}o(v),e.length>0&&d(e[0].roleId)},[e,n,a]);const f=w.useCallback((v,b)=>{console.log(`[WaveTree] connectStream โ role=${b} job=${v}`);const j=h.current.get(v);j&&j.controller.abort();const k=new AbortController,C={controller:k,lastSeq:-1};h.current.set(v,C);const E=`/api/jobs/${v}/stream?from=0`;fetch(E,{signal:k.signal}).then(async _=>{if(!_.ok||!_.body){o($=>{const q=new Map($),L=q.get(b);return L&&q.set(b,{...L,streamStatus:"error"}),q});return}o($=>{const q=new Map($),L=q.get(b);return L&&q.set(b,{...L,streamStatus:"streaming",status:"running"}),q});const z=_.body.getReader(),U=new TextDecoder;let B="";for(;;){const{done:$,value:q}=await z.read();if($)break;B+=U.decode(q,{stream:!0});const L=B.split(`
|
|
83
|
+
`);B=L.pop()??"";let R="";for(const I of L)if(I.startsWith("event: "))R=I.slice(7).trim();else if(I.startsWith("data: ")){try{const H=JSON.parse(I.slice(6));if(R==="activity"){const Q=H;Q.seq>C.lastSeq&&(C.lastSeq=Q.seq),o(oe=>{const re=new Map(oe),Y=re.get(b);if(!Y||Y.events.some(Z=>Z.seq===Q.seq))return oe;const ae={...Y,events:[...Y.events,Q]};if(Q.type==="dispatch:start"&&Q.data.childJobId){const Z=Q.data.childJobId,G=Q.data.targetRoleId??Q.data.roleId;if(console.log(`[WaveTree] dispatch:start โ target=${G} childJob=${Z} from=${b}/${v}`),G){const A=re.get(G);A?(re.set(G,{...A,jobId:Z,status:"running",streamStatus:"connecting"}),setTimeout(()=>f(Z,G),0)):console.warn(`[WaveTree] dispatch:start โ no node found for role "${G}"`)}}return Q.type==="job:done"?(console.log(`[WaveTree] job:done โ role=${b} job=${v}`),ae.status="done",ae.streamStatus="done"):Q.type==="job:error"?(console.log(`[WaveTree] job:error โ role=${b} job=${v}`),ae.status="error",ae.streamStatus="error"):Q.type==="job:awaiting_input"?(console.log(`[WaveTree] job:awaiting_input โ role=${b} job=${v}`),ae.status="awaiting_input",ae.streamStatus="done"):Q.type==="job:reply"&&(console.log(`[WaveTree] job:reply โ role=${b} job=${v}`),ae.status="running",ae.streamStatus="streaming"),re.set(b,ae),re})}else if(R==="stream:end"){const Q=H.reason;console.log(`[WaveTree] stream:end โ role=${b} job=${v} reason=${Q}`),Q!=="replied"&&o(oe=>{const re=new Map(oe),Y=re.get(b);if(!Y)return oe;const ae=Q==="error"?"error":Q==="awaiting_input"?"awaiting_input":"done";return re.set(b,{...Y,status:Y.status==="running"?ae:Y.status,streamStatus:ae==="error"?"error":"done"}),re})}}catch{}R=""}}}).catch(_=>{_.name!=="AbortError"&&o(z=>{const U=new Map(z),B=U.get(b);return B&&U.set(b,{...B,streamStatus:"error"}),U})})},[]);w.useEffect(()=>{if(e.length!==0){for(const v of e)f(v.jobId,v.roleId);return()=>{for(const[,v]of h.current)v.controller.abort();h.current.clear()}}},[e,f]);const x=(()=>{let v=0,b=0,j=0,k=0;for(const[C,N]of i)C!==a&&(k++,N.status==="done"?v++:N.status==="running"?b++:N.status==="awaiting_input"&&j++);return{done:v,total:k,running:b,awaitingInput:j}})(),y=x.total>0&&x.running===0&&x.awaitingInput===0&&Array.from(i.values()).every(v=>v.status!=="running"&&v.status!=="awaiting_input"&&v.streamStatus!=="streaming"&&v.streamStatus!=="connecting");return w.useEffect(()=>{y&&o(v=>{const b=new Map(v);let j=!1;for(const[k,C]of b)C.status==="waiting"&&(b.set(k,{...C,status:"not-dispatched"}),j=!0);return j?b:v})},[y]),{nodes:i,selectedRoleId:u,selectNode:d,progress:x,allDone:y,connectStream:f}}const Qy={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},Si=120,Za=44,Py=80;function UE(e,n){if(!e.get(n))return{layout:[],width:300,height:200};const i=[],o=[],u=[{id:n,depth:0,parentId:null}],d=new Set;for(;u.length>0;){const{id:x,depth:y,parentId:v}=u.shift();if(d.has(x))continue;for(d.add(x);o.length<=y;)o.push([]);o[y].push(x),i.push({roleId:x,x:0,y:y*Py+20,parentId:v});const b=e.get(x);if(b)for(const j of b.children)e.has(j)&&!d.has(j)&&u.push({id:j,depth:y+1,parentId:x})}const h=Math.max(...o.map(x=>x.length))*(Si+16),m=Math.max(h,280);for(const x of o){const y=x.length*(Si+16)-16,v=(m-y)/2;x.forEach((b,j)=>{const k=i.find(C=>C.roleId===b);k&&(k.x=v+j*(Si+16))})}const f=o.length*Py+40;return{layout:i,width:m,height:f}}function Zm({nodes:e,rootId:n,selectedRoleId:a,onSelectNode:i}){const{layout:o,width:u,height:d}=UE(e,n),h=f=>{const x=o.find(y=>y.roleId===f);return x?{cx:x.x+Si/2,cy:x.y+Za/2}:{cx:0,cy:0}},m=f=>{switch(f.status){case"running":return Qy[f.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 ${u} ${d}`,width:Math.max(u,280),height:d,className:"block",style:{minWidth:u},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"})]})]})}),o.filter(f=>f.parentId).map(f=>{const x=h(f.parentId),y=h(f.roleId),v=e.get(f.roleId),b=e.get(f.parentId);let j="rgba(180,200,240,0.15)",k="4 4",C="";return(v==null?void 0:v.status)==="done"||(b==null?void 0:b.status)==="done"?(j="#2E7D3266",k=""):(v==null?void 0:v.status)==="awaiting_input"?(j="#F59E0B",k="6 4",C="wave-edge-flow"):(v==null?void 0:v.status)==="running"&&(j=Qy[f.roleId]??"#FBBF24",k="6 4",C="wave-edge-flow"),l.jsx("line",{x1:x.cx,y1:x.cy+Za/2-4,x2:y.cx,y2:y.cy-Za/2+4,stroke:j,strokeWidth:1.5,strokeDasharray:k,className:C},`${f.parentId}-${f.roleId}`)}),o.map(f=>{const x=e.get(f.roleId);if(!x)return null;const y=m(x),v=a===f.roleId,b=f.roleId===n,j=b?.4:x.status==="not-dispatched"?.35:1;return l.jsxs("g",{transform:`translate(${f.x}, ${f.y})`,style:{cursor:b?"default":"pointer",opacity:j},onClick:()=>!b&&i(f.roleId),children:[l.jsx("rect",{x:0,y:0,width:Si,height:Za,rx:8,ry:8,fill:"var(--terminal-bg-deeper, #181825)",stroke:v?"#fff":y,strokeWidth:v?2:1.5,strokeDasharray:x.status==="not-dispatched"?"4 3":""}),l.jsx("circle",{cx:14,cy:Za/2,r:4,fill:y,filter:x.status==="running"||x.status==="awaiting_input"?"url(#glow)":void 0,children:(x.status==="running"||x.status==="awaiting_input")&&l.jsx("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"1.5s",repeatCount:"indefinite"})}),l.jsx("text",{x:26,y:Za/2-4,fill:"var(--terminal-text, #fff)",fontSize:10,fontWeight:700,fontFamily:"var(--pixel-font)",children:x.roleId.toUpperCase()}),l.jsx("text",{x:26,y:Za/2+10,fill:"var(--terminal-text-muted, #888)",fontSize:8,fontFamily:"var(--pixel-font)",children:x.status==="running"?"Working...":x.status==="awaiting_input"?"Awaiting Reply":x.status==="done"?"Complete":x.status==="error"?"Error":x.status==="waiting"?"Waiting":""}),x.status==="done"&&l.jsx("text",{x:Si-18,y:Za/2+4,fontSize:14,fill:"#2E7D32",children:"โ"}),x.status==="error"&&l.jsx("text",{x:Si-18,y:Za/2+4,fontSize:14,fill:"#C62828",children:"โ"})]},f.roleId)})]})}const qE={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function YE({directive:e,rootJobs:n,orgNodes:a,rootRoleId:i,onClose:o,onMinimize:u,onDone:d,onOpenKnowledgeDoc:h,onSave:m}){const{nodes:f,selectedRoleId:x,selectNode:y,progress:v,allDone:b,connectStream:j}=fv(n,a,i),[k,C]=w.useState(0),[N,E]=w.useState(new Set),[_,z]=w.useState(""),[U,B]=w.useState(!1),[$,q]=w.useState(!1),L=w.useRef(null),R=w.useRef(Date.now()),I=w.useRef(!1),H=w.useCallback(async()=>{if(m){q(!0);try{const F=n.map(W=>W.jobId);await m(F)}catch(F){console.error("Save failed:",F)}finally{q(!1),o()}}},[m,n,o]),Q=w.useCallback(async()=>{if(!x||!_.trim())return;const F=f.get(x);if(!(!(F!=null&&F.jobId)||F.status!=="awaiting_input"&&F.status!=="done")){B(!0);try{const{jobId:W}=await me.replyToJob(F.jobId,_.trim());z(""),j(W,x)}catch(W){console.error("Reply failed:",W)}finally{B(!1)}}},[x,_,f,j]),oe=w.useCallback(async F=>{const W=f.get(F);if(W!=null&&W.jobId)try{await me.abortJob(W.jobId)}catch(D){console.error("Abort failed:",D)}},[f]),re=w.useCallback(async()=>{for(const[,F]of f)if((F.status==="running"||F.status==="awaiting_input")&&F.jobId)try{await me.abortJob(F.jobId)}catch{}},[f]);w.useEffect(()=>{const F=setInterval(()=>{C(Math.floor((Date.now()-R.current)/1e3))},1e3);return()=>clearInterval(F)},[]);const Y=w.useRef(!1);w.useEffect(()=>{const F=L.current;if(!F)return;const W=()=>{const D=F.scrollHeight-F.scrollTop-F.clientHeight<60;Y.current=!D};return F.addEventListener("scroll",W),()=>F.removeEventListener("scroll",W)},[]),w.useEffect(()=>{Y.current=!1,L.current&&(L.current.scrollTop=L.current.scrollHeight)},[x]),w.useEffect(()=>{L.current&&!Y.current&&(L.current.scrollTop=L.current.scrollHeight)},[f]),w.useEffect(()=>{b&&!I.current&&(I.current=!0,d==null||d()),!b&&I.current&&(I.current=!1)},[b,d]);const ae=F=>`${Math.floor(F/60)}:${String(F%60).padStart(2,"0")}`,Z=x?f.get(x):null,G=x?qE[x]??"#888":"#888",A=F=>{E(W=>{const D=new Set(W);return D.has(F)?D.delete(F):D.add(F),D})};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm pointer-events-none"}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[960px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:b?"#2E7D32":"#B71C1C",animation:b?void 0:"wave-pulse 2s ease-in-out infinite"}}),l.jsx("div",{children:l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:b?"WAVE COMPLETE":"WAVE COMMAND CENTER"})})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:ae(k)}),v.awaitingInput>0&&l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[v.awaitingInput," awaiting reply"]}),l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:b?"#2E7D3222":"#B71C1C22",color:b?"#2E7D32":"#B71C1C"},children:[v.done,"/",v.total," done"]}),!b&&(v.running>0||v.awaitingInput>0)&&l.jsx("button",{onClick:re,className:"text-xs px-2 py-0.5 rounded font-semibold cursor-pointer",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Stop all running jobs",children:"Stop All"}),l.jsx("button",{onClick:u,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"โ"}),l.jsx("button",{onClick:o,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",title:b?"Dismiss wave":"Close (jobs keep running)",children:"ร"})]})]}),l.jsx("div",{className:"px-5 py-2 border-b border-[var(--terminal-border)] shrink-0",children:l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic",children:["โ",e,"โ"]})}),l.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[l.jsxs("div",{className:"shrink-0 border-b border-[var(--terminal-border)] flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",children:[l.jsx("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:"Org Propagation"}),l.jsx("div",{className:"flex gap-x-3 ml-auto",children:[{label:"running",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(F=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:F.color,animation:F.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:F.label})]},F.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"35vh"},children:l.jsx(Zm,{nodes:f,rootId:i,selectedRoleId:x,onSelectNode:y})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[Z&&l.jsxs("div",{className:"px-4 py-2 border-b border-[var(--terminal-border)] shrink-0 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:G}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:Z.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:Z.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:Z.status==="awaiting_input"?"#F59E0B22":`${G}22`,color:Z.status==="awaiting_input"?"#F59E0B":G},children:Z.status==="running"?"Working":Z.status==="done"?"Complete":Z.status==="error"?"Error":Z.status==="waiting"?"Waiting":Z.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),(Z.status==="running"||Z.status==="awaiting_input")&&Z.jobId&&l.jsx("button",{onClick:()=>oe(Z.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Force stop this job",children:"Stop"})]}),l.jsxs("div",{ref:L,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[Z&&Z.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:Z.status==="waiting"?"Waiting for dispatch...":Z.status==="running"?"Connecting to activity stream...":Z.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),Z==null?void 0:Z.events.map(F=>l.jsx(nd,{event:F,isThinkingCollapsed:N.has(F.seq),onToggleThinking:()=>A(F.seq),onNavigateToJob:W=>{for(const[,D]of f)if(D.jobId===W){y(D.roleId);return}},onOpenKnowledgeDoc:h},F.seq)),(Z==null?void 0:Z.status)==="running"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(Z==null?void 0:Z.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:[Z.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:_,onChange:F=>z(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),Q())},placeholder:"Type your response...",disabled:U,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#F59E0B]",autoFocus:!0}),l.jsx("button",{onClick:Q,disabled:U||!_.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:U?"...":"Reply"})]})]}),(Z==null?void 0:Z.status)==="done"&&Z.jobId&&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 ",Z.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:_,onChange:F=>z(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),Q())},placeholder:"e.g., ์ข์ KB-3 ์งํํด, Engineer์๊ฒ ์์ผ...",disabled:U,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:Q,disabled:U||!_.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:U?"...":"Send"})]})]}),!Z&&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:Z&&Z.events.length>0&&`${Z.events.length} events`}),b&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:o,className:"px-4 py-1.5 text-xs rounded-lg font-semibold cursor-pointer",style:{background:"rgba(255,255,255,0.08)",color:"var(--terminal-text-muted)"},children:"Dismiss"}),m&&l.jsx("button",{onClick:H,disabled:$,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:$?"Saving...":"Save Wave"})]})]})]})]})]})]})}const hv={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function Zy({orgNodes:e,rootRoleId:n,cLevelRoles:a,pastWaves:i,activeWaves:o,onDispatch:u,onClose:d,onDone:h,onSave:m,onOpenKnowledgeDoc:f,onRefreshWaves:x,terminalWidth:y=0,onMaximize:v}){const[b,j]=w.useState(o.length>0?"monitor":"dispatch"),[k,C]=w.useState(0),[N,E]=w.useState(""),_=w.useRef(null),[z,U]=w.useState(null),[B,$]=w.useState(!1),[q,L]=w.useState(null);w.useEffect(()=>{const D=()=>me.getSaveStatus("code").then(je=>{L({dirty:je.dirty,count:je.modified.length+je.untracked.length,branch:je.branch})}).catch(()=>{});D();const te=setInterval(D,3e4);return()=>clearInterval(te)},[]);const[R,I]=w.useState(()=>{const D=new Set,te=e[n];if(te)for(const je of te.children){D.add(je);const ve=e[je];if(ve)for(const ze of ve.children)D.add(ze)}return D}),{panelRight:H,panelWidth:Q,isResizing:oe,handleResizeStart:re}=Wo(y,720,v);w.useEffect(()=>{o.length>0&&b==="dispatch"&&(j("monitor"),C(0))},[o.length,b]),w.useEffect(()=>{b==="dispatch"&&setTimeout(()=>{var D;return(D=_.current)==null?void 0:D.focus()},100)},[b]);const Y=w.useCallback((D,te)=>{I(je=>{const ve=new Set(je);return te?ve.add(D):ve.delete(D),ve})},[]),ae=a.filter(D=>R.has(D.id)).length,Z=()=>{if(!N.trim()||ae===0)return;const D=e[n];let te=0;if(D)for(const ze of D.children){te++;const Xe=e[ze];Xe&&(te+=Xe.children.length)}const ve=R.size>=te?void 0:Array.from(R);u(N.trim(),ve),E("")},G=D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&Z(),D.key==="Escape"&&b==="dispatch"&&d()},A=w.useCallback(async D=>{$(!0),U(null),C(-1),j("monitor");try{const te=await me.getWaveDetail(D);te.replay&&U(te.replay)}catch(te){console.error("Failed to load wave:",te)}finally{$(!1)}},[]),F=k>=0?o[k]??null:null,W=!!n&&Object.keys(e).length>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:H},onClick:d}),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)] ${oe?"resizing":""}`,style:{right:H,width:Q,background:"var(--terminal-bg)",borderLeftColor:"#B71C1C"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${oe?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:re}),l.jsxs("div",{className:"px-5 py-3 text-white relative shrink-0",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1",children:[v&&l.jsx("button",{onClick:v,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:d,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.jsx("div",{className:"text-lg font-bold",children:"Wave Center"}),l.jsx("div",{className:"text-xs opacity-70 mt-0.5",children:o.length>0?`${o.length} active wave${o.length!==1?"s":""}`:"Broadcast directives to your organization"})]}),l.jsxs("div",{className:"flex shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("button",{onClick:()=>j("dispatch"),className:"px-4 py-2 text-xs font-semibold cursor-pointer transition-colors",style:{color:b==="dispatch"?"#D32F2F":"var(--terminal-text-muted)",borderBottom:b==="dispatch"?"2px solid #D32F2F":"2px solid transparent"},children:"New Wave"}),l.jsxs("button",{onClick:()=>j("monitor"),className:"px-4 py-2 text-xs font-semibold cursor-pointer transition-colors flex items-center gap-1.5",style:{color:b==="monitor"?"#D32F2F":"var(--terminal-text-muted)",borderBottom:b==="monitor"?"2px solid #D32F2F":"2px solid transparent"},children:["Monitor",o.length>0&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse"})]}),l.jsxs("button",{onClick:()=>j("monitor"),className:"px-4 py-2 text-xs font-semibold cursor-pointer transition-colors ml-auto",style:{color:"var(--terminal-text-muted)"},children:["History (",i.length,")"]})]}),l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:b==="dispatch"?l.jsx(XE,{orgNodes:e,rootId:n,hasOrgData:W,cLevelRoles:a,activeRoles:R,onToggleRole:Y,directive:N,onDirectiveChange:E,onSubmit:Z,onKeyDown:G,activeCLevelCount:ae,inputRef:_}):F?l.jsx(WE,{wave:F,orgNodes:e,rootRoleId:n,onDone:h,onSave:m,onOpenKnowledgeDoc:f}):z?l.jsx(GE,{replay:z,orgNodes:e,rootRoleId:n,onOpenKnowledgeDoc:f,onRefreshWaves:x}):B?l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"Loading wave data..."}):l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-[var(--terminal-text-muted)] gap-3 p-8",children:[l.jsx("span",{className:"text-3xl",children:"๐"}),l.jsx("div",{className:"text-sm",children:"No active waves"}),l.jsx("div",{className:"text-[10px]",children:"Select a past wave from the list, or start a new one"}),l.jsx("button",{onClick:()=>j("dispatch"),className:"px-4 py-2 text-xs font-semibold rounded-lg cursor-pointer",style:{background:"#B71C1C",color:"#fff"},children:"Start New Wave"})]})}),l.jsxs("div",{className:"w-[220px] shrink-0 border-l flex flex-col",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[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((D,te)=>l.jsxs("button",{onClick:()=>{j("monitor"),C(te),U(null)},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:b==="monitor"&&k===te?"var(--terminal-bg)":"transparent",border:b==="monitor"&&k===te?"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:[D.directive.slice(0,40),D.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[D.rootJobs.length," role",D.rootJobs.length!==1?"s":""]})]},D.id))})]}),q&&l.jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:"var(--terminal-border)"},children:l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:q.dirty?"var(--idle-amber)":"#2E7D32"}}),l.jsx("span",{className:"text-[10px] font-mono text-[var(--terminal-text-muted)] truncate",children:q.branch}),q.dirty&&l.jsxs("span",{className:"text-[9px] ml-auto shrink-0",style:{color:"var(--idle-amber)"},children:[q.count," uncommitted"]}),!q.dirty&&l.jsx("span",{className:"text-[9px] text-green-400 ml-auto shrink-0",children:"clean"})]})}),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(D=>l.jsx(KE,{wave:D,active:(z==null?void 0:z.id)===D.id,onLoad:()=>A(D.id)},D.id))})]})]})]})]})]})}function XE({orgNodes:e,rootId:n,hasOrgData:a,cLevelRoles:i,activeRoles:o,onToggleRole:u,directive:d,onDirectiveChange:h,onSubmit:m,onKeyDown:f,activeCLevelCount:x,inputRef:y}){return l.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[a&&l.jsx(dv,{orgNodes:e,rootId:n,activeRoles:o,onToggleRole:u}),!a&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider mb-2",children:"Dispatching to"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:i.length>0?i.map(v=>l.jsxs("span",{className:"px-3 py-1.5 text-xs font-semibold rounded-lg",style:{background:"#B71C1C22",color:"#E57373",border:"1px solid #B71C1C44"},children:[v.id.toUpperCase()," ยท ",v.name]},v.id)):l.jsx("span",{className:"text-xs text-[var(--terminal-text-muted)] italic",children:"No C-Level roles found"})})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider mb-2",children:"Directive"}),l.jsx("textarea",{ref:y,value:d,onChange:v=>h(v.target.value),onKeyDown:f,placeholder:"e.g. Report current status across all departments",className:"w-full h-28 p-3 rounded-lg border text-sm resize-none focus:outline-none transition-colors",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}}),l.jsxs("div",{className:"flex items-center justify-between mt-2",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"Cmd+Enter to dispatch"}),l.jsxs("button",{onClick:m,disabled:!d.trim()||x===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 ",x," Role",x!==1?"s":""]})]})]})]})}function WE({wave:e,orgNodes:n,rootRoleId:a,onDone:i,onSave:o,onOpenKnowledgeDoc:u}){var ze,Xe;const{nodes:d,selectedRoleId:h,selectNode:m,progress:f,allDone:x,connectStream:y}=fv(e.rootJobs,n,a),[v,b]=w.useState(0),[j,k]=w.useState(new Set),[C,N]=w.useState(""),[E,_]=w.useState(!1),[z,U]=w.useState(null),[B,$]=w.useState(""),[q,L]=w.useState(!1),[R,I]=w.useState(null),[H,Q]=w.useState(!1),oe=w.useRef(null),re=w.useRef(null),Y=w.useRef(!1),ae=w.useCallback(async()=>{if(!h||!C.trim())return;const de=d.get(h);if(!(!(de!=null&&de.jobId)||de.status!=="awaiting_input"&&de.status!=="done")){_(!0);try{const{jobId:Oe}=await me.replyToJob(de.jobId,C.trim());N(""),y(Oe,h)}catch(Oe){console.error("Reply failed:",Oe)}finally{_(!1)}}},[h,C,d,y]),Z=w.useCallback(async de=>{const Oe=d.get(de);if(Oe!=null&&Oe.jobId)try{await me.abortJob(Oe.jobId)}catch{}},[d]),G=w.useCallback(async()=>{for(const[,de]of d)if((de.status==="running"||de.status==="awaiting_input")&&de.jobId)try{await me.abortJob(de.jobId)}catch{}},[d]);w.useEffect(()=>{const de=setInterval(()=>{b(Math.floor((Date.now()-e.startedAt)/1e3))},1e3);return()=>clearInterval(de)},[e.startedAt]);const A=w.useRef(!1);w.useEffect(()=>{const de=re.current;if(!de)return;const Oe=()=>{const Qe=de.scrollHeight-de.scrollTop-de.clientHeight<60;A.current=!Qe};return de.addEventListener("scroll",Oe),()=>de.removeEventListener("scroll",Oe)},[]),w.useEffect(()=>{A.current=!1,re.current&&(re.current.scrollTop=re.current.scrollHeight)},[h]),w.useEffect(()=>{re.current&&!A.current&&(re.current.scrollTop=re.current.scrollHeight)},[d]);const F=w.useCallback(()=>{me.getSaveStatus("code").then(de=>{if(U(de),!B){const Oe=e.directive.slice(0,60).replace(/\n/g," ");$(`wave: ${Oe}`)}}).catch(()=>{})},[e.directive,B]),W=w.useCallback(async()=>{if(B.trim()){L(!0),I(null);try{const de=await me.save(B.trim(),"code");I({ok:!0,sha:de.commitSha}),oe.current&&de.commitSha&&me.patchWave(oe.current,{commitSha:de.commitSha,commitMessage:B.trim()}).catch(()=>{}),F()}catch(de){I({ok:!1,error:de instanceof Error?de.message:"Commit failed"})}finally{L(!1)}}},[B,F]);w.useEffect(()=>{if(x&&!Y.current){if(Y.current=!0,i==null||i(),o){const de=e.rootJobs.map(Oe=>Oe.jobId);o(e.directive,de,{waveId:e.id,sessionIds:e.sessionIds}).then(()=>{me.getWaves().then(Oe=>{Oe.length>0&&(oe.current=Oe[0].id)}).catch(()=>{})}).catch(()=>{})}F()}!x&&Y.current&&(Y.current=!1)},[x,i,o,e,F]);const D=de=>`${Math.floor(de/60)}:${String(de%60).padStart(2,"0")}`,te=h?d.get(h):null,je=h?hv[h]??"#888":"#888",ve=de=>{k(Oe=>{const Qe=new Set(Oe);return Qe.has(de)?Qe.delete(de):Qe.add(de),Qe})};return l.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[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:x?"#2E7D32":"#B71C1C",animation:x?void 0:"wave-pulse 2s ease-in-out infinite"}}),l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic flex-1 min-w-0 truncate",children:["โ",e.directive,"โ"]}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:D(v)}),f.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:[f.awaitingInput," awaiting"]}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:x?"#2E7D3222":"#B71C1C22",color:x?"#2E7D32":"#B71C1C"},children:[f.done,"/",f.total]}),!x&&(f.running>0||f.awaitingInput>0)&&l.jsx("button",{onClick:G,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:"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(de=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:de.color,animation:de.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:de.label})]},de.label))})]}),l.jsx("div",{className:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(Zm,{nodes:d,rootId:a,selectedRoleId:h,onSelectNode:m})})]}),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:je}}),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":`${je}22`,color:te.status==="awaiting_input"?"#F59E0B":je},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"}),(te.status==="running"||te.status==="awaiting_input")&&te.jobId&&l.jsx("button",{onClick:()=>Z(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.jsxs("div",{ref:re,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[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 in this wave.":""}),te==null?void 0:te.events.map(de=>l.jsx(nd,{event:de,isThinkingCollapsed:j.has(de.seq),onToggleThinking:()=>ve(de.seq),onNavigateToJob:Oe=>{for(const[,Qe]of d)if(Qe.jobId===Oe){m(Qe.roleId);return}},onOpenKnowledgeDoc:u},de.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"&&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("input",{type:"text",value:C,onChange:de=>N(de.target.value),onKeyDown:de=>{de.key==="Enter"&&!de.shiftKey&&(de.preventDefault(),ae())},placeholder:"Type your response...",disabled:E,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:ae,disabled:E||!C.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:E?"...":"Reply"})]})]}),(te==null?void 0:te.status)==="done"&&te.jobId&&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("input",{type:"text",value:C,onChange:de=>N(de.target.value),onKeyDown:de=>{de.key==="Enter"&&!de.shiftKey&&(de.preventDefault(),ae())},placeholder:"Send a follow-up directive...",disabled:E,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:ae,disabled:E||!C.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:E?"...":"Send"})]})]}),l.jsxs("div",{className:"px-4 py-2 border-t flex items-center justify-between shrink-0",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:te&&te.events.length>0&&`${te.events.length} events`}),x&&z&&l.jsxs("div",{className:"flex items-center gap-2",children:[z.dirty&&l.jsxs("button",{onClick:()=>Q(de=>!de),className:"px-3 py-1.5 text-[10px] font-bold cursor-pointer rounded",style:{background:H?"var(--idle-amber)":"var(--terminal-bg)",color:H?"#000":"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:[z.modified.length+z.untracked.length," changes"]}),!z.dirty&&(R==null?void 0:R.ok)&&l.jsxs("span",{className:"text-[10px] text-green-400 font-mono",children:["committed ",(ze=R.sha)==null?void 0:ze.slice(0,7)]}),!z.dirty&&!R&&l.jsx("span",{className:"text-[10px] text-green-400",children:"no uncommitted changes"})]})]}),x&&H&&(z==null?void 0:z.dirty)&&l.jsx("div",{className:"border-t overflow-y-auto",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)",maxHeight:"40vh"},children:l.jsxs("div",{className:"px-4 py-3 space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:["Code Changes (",z.branch,")"]}),l.jsx("button",{onClick:()=>F(),className:"text-[9px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] cursor-pointer",children:"refresh"})]}),l.jsxs("div",{className:"max-h-[120px] overflow-y-auto space-y-0.5",children:[z.modified.map(de=>l.jsxs("div",{className:"text-[10px] font-mono text-[var(--terminal-text)] flex items-center gap-1.5",children:[l.jsx("span",{className:"text-yellow-500",children:"M"}),l.jsx("span",{className:"truncate",children:de})]},de)),z.untracked.map(de=>l.jsxs("div",{className:"text-[10px] font-mono text-[var(--terminal-text)] flex items-center gap-1.5",children:[l.jsx("span",{className:"text-green-400",children:"+"}),l.jsx("span",{className:"truncate",children:de})]},de))]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:B,onChange:de=>$(de.target.value),onKeyDown:de=>{de.key==="Enter"&&W()},placeholder:"Commit message...",disabled:q,className:"flex-1 px-2 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none font-mono",style:{borderColor:"var(--terminal-border)"}}),l.jsx("button",{onClick:W,disabled:q||!B.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32",color:"#fff"},children:q?"...":"Commit"})]}),(R==null?void 0:R.error)&&l.jsx("div",{className:"text-[10px] text-red-400",children:R.error}),(R==null?void 0:R.ok)&&l.jsxs("div",{className:"text-[10px] text-green-400 font-mono",children:["Committed: ",(Xe=R.sha)==null?void 0:Xe.slice(0,7)]})]})})]})]})}function VE(e,n,a){const i=new Map,o=d=>{const h=e[d];!h||i.has(d)||(i.set(d,{jobId:null,roleId:d,roleName:h.name,children:h.children,status:"not-dispatched",events:[],streamStatus:"idle"}),h.children.forEach(o))},u=e[n];u&&(i.set(n,{jobId:null,roleId:n,roleName:"CEO",children:u.children,status:"not-dispatched",events:[],streamStatus:"idle"}),u.children.forEach(o));for(const d of a){const h=i.get(d.roleId);h&&i.set(d.roleId,{...h,jobId:d.jobId,status:d.status||"done",events:d.events,streamStatus:"done"});for(const m of d.childJobs){const f=i.get(m.roleId);f&&i.set(m.roleId,{...f,jobId:m.jobId,status:m.status||"done",events:m.events,streamStatus:"done"})}}return i}function GE({replay:e,orgNodes:n,rootRoleId:a,onOpenKnowledgeDoc:i,onRefreshWaves:o}){var ae,Z,G;const u=w.useMemo(()=>VE(n,a,e.roles),[n,a,e]),[d,h]=w.useState(((ae=e.roles[0])==null?void 0:ae.roleId)??null),[m,f]=w.useState(new Set),x=w.useRef(null),[y,v]=w.useState(null),[b,j]=w.useState(`wave: ${e.directive.slice(0,60).replace(/\n/g," ")}`),[k,C]=w.useState(!1),[N,E]=w.useState(null),[_,z]=w.useState(!1),[U,B]=w.useState(""),[$,q]=w.useState(!1),L=d?u.get(d):null,R=d?hv[d]??"#888":"#888";w.useEffect(()=>{x.current&&(x.current.scrollTop=0)},[d]);const I=w.useCallback(()=>{me.getSaveStatus("code").then(v).catch(()=>{})},[]);w.useEffect(()=>{I()},[I]);const H=w.useCallback(async()=>{if(b.trim()){C(!0),E(null);try{const A=await me.save(b.trim(),"code");E({ok:!0,sha:A.commitSha}),A.commitSha&&me.patchWave(e.id,{commitSha:A.commitSha,commitMessage:b.trim()}).then(()=>{o==null||o()}).catch(()=>{}),I()}catch(A){E({ok:!1,error:A instanceof Error?A.message:"Commit failed"})}finally{C(!1)}}},[b,I,e.id,o]),Q=w.useCallback(async()=>{var F;if(!d||!U.trim())return;const A=u.get(d);if(A){q(!0);try{const W=e.roles.findIndex(te=>te.roleId===d),D=(F=e.sessionIds)==null?void 0:F[W];if(D){await me.sendSessionMessage(D,U.trim(),"do"),B("");return}if(A.jobId)try{await me.replyToJob(A.jobId,U.trim()),B("");return}catch{}await me.startJob({type:"assign",roleId:d,task:U.trim()}),B("")}catch(W){console.error("Follow-up failed:",W)}finally{q(!1)}}},[d,U,u,e.roles,e.sessionIds]),oe=A=>{f(F=>{const W=new Set(F);return W.has(A)?W.delete(A):W.add(A),W})},re=e.startedAt?new Date(e.startedAt).toLocaleString():"",Y=w.useMemo(()=>{let A=0,F=0;for(const[W,D]of u)W!==a&&(F++,D.status==="done"&&A++);return{done:A,total:F}},[u,a]);return l.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[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:"#2E7D32"}}),l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic flex-1 min-w-0 truncate",children:["โ",e.directive,"โ"]}),l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:"#2E7D3222",color:"#2E7D32"},children:"REPLAY"}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:re}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:"#2E7D3222",color:"#2E7D32"},children:[Y.done,"/",Y.total]})]}),l.jsxs("div",{className:"shrink-0 border-b flex flex-col",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("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:"overflow-x-auto overflow-y-auto px-3 pb-2",style:{maxHeight:"30vh"},children:l.jsx(Zm,{nodes:u,rootId:a,selectedRoleId:d,onSelectNode:h})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[L&&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:R}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:L.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:L.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:`${R}22`,color:R},children:L.status==="done"?"Complete":L.status==="error"?"Error":L.status}),l.jsxs("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[L.events.length," events"]})]}),l.jsxs("div",{ref:x,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[L&&L.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:L.status==="not-dispatched"?"This role was not dispatched in this wave.":"No events recorded for this role."}),L==null?void 0:L.events.map(A=>l.jsx(nd,{event:A,isThinkingCollapsed:m.has(A.seq),onToggleThinking:()=>oe(A.seq),onNavigateToJob:F=>{for(const[,W]of u)if(W.jobId===F){h(W.roleId);return}},onOpenKnowledgeDoc:i},A.seq)),!L&&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"})]}),(L==null?void 0:L.status)==="done"&&L.jobId&&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 ",L.roleName]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:U,onChange:A=>B(A.target.value),onKeyDown:A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),Q())},placeholder:"Send a follow-up directive...",disabled:$,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:Q,disabled:$||!U.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:$?"...":"Send"})]})]}),l.jsxs("div",{className:"px-4 py-2 border-t flex items-center justify-between shrink-0",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:L&&L.events.length>0&&`${L.events.length} events`}),y&&l.jsxs("div",{className:"flex items-center gap-2",children:[y.dirty&&l.jsxs("button",{onClick:()=>z(A=>!A),className:"px-3 py-1.5 text-[10px] font-bold cursor-pointer rounded",style:{background:_?"var(--idle-amber)":"var(--terminal-bg)",color:_?"#000":"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:[y.modified.length+y.untracked.length," changes"]}),!y.dirty&&(N==null?void 0:N.ok)&&l.jsxs("span",{className:"text-[10px] text-green-400 font-mono",children:["committed ",(Z=N.sha)==null?void 0:Z.slice(0,7)]}),!y.dirty&&!N&&l.jsx("span",{className:"text-[10px] text-green-400",children:"no uncommitted changes"})]})]}),_&&(y==null?void 0:y.dirty)&&l.jsx("div",{className:"border-t overflow-y-auto",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)",maxHeight:"40vh"},children:l.jsxs("div",{className:"px-4 py-3 space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:["Code Changes (",y.branch,")"]}),l.jsx("button",{onClick:I,className:"text-[9px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] cursor-pointer",children:"refresh"})]}),l.jsxs("div",{className:"max-h-[120px] overflow-y-auto space-y-0.5",children:[y.modified.map(A=>l.jsxs("div",{className:"text-[10px] font-mono text-[var(--terminal-text)] flex items-center gap-1.5",children:[l.jsx("span",{className:"text-yellow-500",children:"M"}),l.jsx("span",{className:"truncate",children:A})]},A)),y.untracked.map(A=>l.jsxs("div",{className:"text-[10px] font-mono text-[var(--terminal-text)] flex items-center gap-1.5",children:[l.jsx("span",{className:"text-green-400",children:"+"}),l.jsx("span",{className:"truncate",children:A})]},A))]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:b,onChange:A=>j(A.target.value),onKeyDown:A=>{A.key==="Enter"&&H()},placeholder:"Commit message...",disabled:k,className:"flex-1 px-2 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none font-mono",style:{borderColor:"var(--terminal-border)"}}),l.jsx("button",{onClick:H,disabled:k||!b.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32",color:"#fff"},children:k?"...":"Commit"})]}),(N==null?void 0:N.error)&&l.jsx("div",{className:"text-[10px] text-red-400",children:N.error}),(N==null?void 0:N.ok)&&l.jsxs("div",{className:"text-[10px] text-green-400 font-mono",children:["Committed: ",(G=N.sha)==null?void 0:G.slice(0,7)]})]})})]})]})}function KE({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:[l.jsx("span",{className:"text-[10px]",children:"โถ"}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:o}),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 QE={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 Jm(e){return QE[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const mv=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],pv=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],xv=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],yv=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],gv=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],al={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 PE({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 Eo({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(PE,{color:o,selected:o===a,onClick:()=>i(o)},o))})]})}function Fh({label:e,items:n,value:a,onChange:i,lockInfo:o}){return l.jsxs("div",{className:"customize-row",children:[l.jsx("div",{className:"customize-row-header",children:l.jsx("span",{className:"customize-row-label",children:e})}),l.jsx("div",{className:"customize-swatches",style:{gap:4},children:n.map(u=>{const d=o?o.getLockLevel(u.id):1,h=u.id===a,m=o?d>o.roleLevel&&!h:!1,f=o?h&&d>o.roleLevel:!1;return l.jsxs("button",{onClick:()=>{m||i(u.id===a?void 0:u.id)},className:"customize-swatch",style:{width:"auto",height:"auto",padding:m?"2px 6px 10px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:h?"rgba(255,255,255,0.15)":m?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",outline:h?f?"2px solid #F59E0B":"2px solid #fff":"2px solid transparent",color:m?"rgba(255,255,255,0.25)":h?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:m?"not-allowed":"pointer",opacity:m?.35:1,position:"relative"},children:[u.name,m&&l.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:"rgba(255,255,255,0.5)",whiteSpace:"nowrap"},children:["๐"," Lv.",d]}),f&&l.jsxs("span",{style:{position:"absolute",bottom:-8,left:"50%",transform:"translateX(-50%)",fontSize:7,color:"#F59E0B",whiteSpace:"nowrap"},children:["โ "," Lv.",d]})]},u.id)})})]})}function Mh({label:e,active:n,onClick:a}){return l.jsx("button",{onClick:a,style:{flex:1,padding:"6px 0",fontSize:10,fontFamily:"var(--font-pixel, monospace)",fontWeight:"bold",letterSpacing:1,background:n?"rgba(255,255,255,0.08)":"transparent",color:n?"#fff":"rgba(255,255,255,0.35)",border:"none",borderBottom:n?"2px solid #3B82F6":"2px solid transparent",cursor:"pointer",transition:"all 0.15s"},children:e})}function Ol(e){return e[Math.floor(Math.random()*e.length)]}function gs(e){var o,u,d;const n=Ub(),a=qb(),i=Yb().filter(h=>!e||Wb(h.id,e));return{skinColor:Ol(mv),hairColor:Ol(pv),shirtColor:Ol(xv),pantsColor:Ol(yv),shoeColor:Ol(gv),hairStyle:(o=Ol(n))==null?void 0:o.id,outfitStyle:(u=Ol(a))==null?void 0:u.id,accessory:(d=Ol(i))==null?void 0:d.id}}function bv({roleId:e,appearance:n,onChange:a,onRandomize:i,onReset:o,label:u,roleLevel:d}){const[h,m]=w.useState("look"),f=w.useCallback((C,N)=>{a({...n,[C]:N})},[n,a]),x=w.useRef(null),y=w.useCallback(C=>{var _;const N=(_=C.target.files)==null?void 0:_[0];if(!N)return;const E=new Image;E.onload=()=>{const z=yC(E);a({...z,hairStyle:n.hairStyle,outfitStyle:n.outfitStyle,accessory:n.accessory}),URL.revokeObjectURL(E.src)},E.src=URL.createObjectURL(N),C.target.value=""},[n.hairStyle,n.outfitStyle,n.accessory,a]),v=Ub(),b=qb(),j=Yb(),k=d!==void 0?j.filter(C=>Wb(C.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(nl,{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 C;return(C=x.current)==null?void 0:C.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),l.jsx("input",{ref:x,type:"file",accept:"image/*",onChange:y,style:{display:"none"}})]})]}),l.jsxs("div",{className:"customize-colors",children:[l.jsxs("div",{style:{display:"flex",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:[l.jsx(Mh,{label:"LOOK",active:h==="look",onClick:()=>m("look")}),l.jsx(Mh,{label:"OUTFIT",active:h==="outfit",onClick:()=>m("outfit")}),l.jsx(Mh,{label:"ACCESSORY",active:h==="accessory",onClick:()=>m("accessory")})]}),h==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(Eo,{label:"SKIN",presets:mv,value:n.skinColor,onChange:C=>f("skinColor",C)}),l.jsx(Eo,{label:"HAIR COLOR",presets:pv,value:n.hairColor,onChange:C=>f("hairColor",C)}),l.jsx(Fh,{label:"HAIR STYLE",items:v,value:n.hairStyle,onChange:C=>f("hairStyle",C)})]}),h==="outfit"&&l.jsxs(l.Fragment,{children:[l.jsx(Fh,{label:"STYLE",items:b,value:n.outfitStyle,onChange:C=>f("outfitStyle",C)}),l.jsx(Eo,{label:"TOP",presets:xv,value:n.shirtColor,onChange:C=>f("shirtColor",C)}),l.jsx(Eo,{label:"PANTS",presets:yv,value:n.pantsColor,onChange:C=>f("pantsColor",C)}),l.jsx(Eo,{label:"SHOES",presets:gv,value:n.shoeColor,onChange:C=>f("shoeColor",C)})]}),h==="accessory"&&l.jsxs(l.Fragment,{children:[d!==void 0&&l.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("span",{children:["Lv.",d]}),l.jsxs("span",{children:[k,"/",j.length," unlocked"]})]}),l.jsx(Fh,{label:"ACCESSORY",items:j,value:n.accessory,onChange:C=>f("accessory",C),lockInfo:d!==void 0?{roleLevel:d,getLockLevel:Xb}: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 ZE=[{value:"c-level",label:"C-Level"},{value:"team-lead",label:"Team Lead"},{value:"member",label:"Member"}];function bm(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Rh(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"}};case"team-lead":return{authority:{autonomous:["Task planning","Sprint management"],needsApproval:["Architecture changes","New tool adoption"]},knowledge:{reads:["projects/","architecture/"],writes:["projects/"]},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 JE={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 Hl=null;async function e6(){if(Hl)return Hl;try{const a=await me.getPreferences();if(a.instanceId)return Hl=a.instanceId,localStorage.setItem("tycono_instance_id",Hl),Hl}catch{}const e="tycono_instance_id";let n=localStorage.getItem(e);return n||(n=crypto.randomUUID(),localStorage.setItem(e,n)),Hl=n,n}const Ao=4;function t6(e,n,a){const i=e.trim();if(!i||i.startsWith("#"))return null;const o=i.split(",").map(y=>y.trim()),u=o[0];if(!u)return null;const d=bm(u),h=(o[1]||"member").toLowerCase(),m=h==="c-level"?"c-level":h==="team-lead"?"team-lead":"member",f=o[2]||"ceo";let x;return n.has(d)?x="ID already exists":a.has(d)&&(x="Duplicate ID in batch"),a.add(d),{name:u,id:d,level:m,reportsTo:f,error:x}}function n6({existingRoles:e,onClose:n,onHire:a,onStoreVisit:i,questHint:o}){const[u,d]=w.useState("single"),[h,m]=w.useState([]),[f,x]=w.useState(!1),[y,v]=w.useState("popular"),[b,j]=w.useState(""),[k,C]=w.useState(null),[N,E]=w.useState(!1),[_,z]=w.useState(""),[U,B]=w.useState("browse"),[$,q]=w.useState(""),[L,R]=w.useState(""),[I,H]=w.useState("ceo"),[Q,oe]=w.useState(null),[re,Y]=w.useState(1),[ae,Z]=w.useState(""),[G,A]=w.useState(""),[F,W]=w.useState(!1),[D,te]=w.useState("member"),[je,ve]=w.useState("ceo"),[ze,Xe]=w.useState(""),[de,Oe]=w.useState(gs),[Qe,Se]=w.useState(!1),[Je,Re]=w.useState(""),[Et,ut]=w.useState([]),[gt,kt]=w.useState(new Set),[pe,xe]=w.useState(""),[ge,$e]=w.useState("input"),[Be,Le]=w.useState({done:0,total:0}),Ee=w.useRef(null),P=w.useRef(null),ue=w.useRef(null);w.useEffect(()=>{me.getSkills().then(J=>ut(J.filter(We=>We.installed))).catch(()=>{}),e6().then(J=>oe(J)).catch(()=>{})},[]),w.useEffect(()=>{var J,We,ot;u==="single"?(re===1&&((J=Ee.current)==null||J.focus()),re===2&&((We=P.current)==null||We.focus())):u==="bulk"&&ge==="input"&&((ot=ue.current)==null||ot.focus())},[re,u,ge]),w.useEffect(()=>{u==="store"&&U==="browse"&&h.length===0&&ye()},[u,U]);const ye=async()=>{x(!0);try{const J=await br.getCharacters({sort:y,instanceId:Q??void 0});m(J.characters)}catch{z("Failed to load store")}x(!1)};w.useEffect(()=>{u==="store"&&U==="browse"&&ye()},[y,Q]);const Ne=w.useMemo(()=>{if(!b.trim())return h;const J=b.toLowerCase();return h.filter(We=>We.name.toLowerCase().includes(J)||We.id.toLowerCase().includes(J)||(We.tagline??"").toLowerCase().includes(J))},[h,b]),Me=w.useMemo(()=>new Set(e.map(J=>J.id)),[e]),Pe=w.useMemo(()=>{const J=pe.split(`
|
|
84
|
+
`),We=new Set;return J.map(ot=>t6(ot,Me,We)).filter(ot=>ot!==null)},[pe,Me]),_t=Pe.length>0&&Pe.every(J=>!J.error),dt=J=>{Z(J),F||A(bm(J))},ht=ae.trim().length>0&&G.trim().length>0&&!e.some(J=>J.id===G),bt=ze.trim().length>0,et=async()=>{Se(!0),Re("");const J=Rh(D);try{await a({id:G,name:ae.trim(),level:D,reportsTo:je,persona:ze.trim(),...J,skills:gt.size>0?[...gt]:void 0},de),n()}catch(We){Re(We instanceof Error?We.message:"Failed to create role"),Se(!1)}},Fe=J=>J===1?ht:J===2?bt:!0,_e=async()=>{Se(!0),Re(""),Le({done:0,total:Pe.length});try{for(let J=0;J<Pe.length;J++){const We=Pe[J],ot=Rh(We.level),xn=gs(),ke=`${We.name}. A ${We.level} role reporting to ${We.reportsTo}.`;await a({id:We.id,name:We.name,level:We.level,reportsTo:We.reportsTo,persona:ke,...ot},xn),Le({done:J+1,total:Pe.length})}n()}catch(J){Re(J instanceof Error?J.message:"Failed to create roles"),Se(!1)}},nn=async J=>{E(!0),z("");try{const We=await br.getCharacter(J);C(We),q(We.name||""),R(bm(We.name||J)),B("review")}catch{z("Failed to load character details")}finally{E(!1)}},fn=async(J,We)=>{if(!Q)return;const ot=h.find(ke=>ke.id===J);if(!ot)return;const xn=ot.my_vote===We?0:We;try{const ke=await br.voteCharacter(J,Q,xn);m(Mt=>Mt.map(hn=>hn.id===J?{...hn,upvotes:ke.upvotes,downvotes:ke.downvotes,vote_score:ke.upvotes-ke.downvotes,my_vote:xn===0?null:xn}:hn))}catch{}},Vt=async()=>{if(!k)return;Se(!0),Re("");const J=k,We=J.level==="c-level"||J.level==="team-lead"?J.level:"member",ot=Rh(We),xn=J.skills!=null&&typeof J.skills=="object"&&!Array.isArray(J.skills)&&"primary"in J.skills;try{await a({id:L,name:$.trim(),level:We,reportsTo:I,persona:J.persona||`${$}. Imported from Tycono Store.`,authority:J.authority||ot.authority,knowledge:ot.knowledge,reports:ot.reports,source:{id:`tycono/${J.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:xn?J.skills:void 0},J.appearance?J.appearance:gs()),br.trackInstall(J.id).catch(()=>{}),n()}catch(ke){Re(ke instanceof Error?ke.message:"Failed to hire"),Se(!1)}},yt=async J=>{if(Q)try{await br.deleteCharacter(J,Q),m(We=>We.filter(ot=>ot.id!==J))}catch{}},pn=J=>{J.key==="Escape"&&n(),J.key==="Enter"&&(J.metaKey||J.ctrlKey)&&(u==="single"?re<Ao&&Fe(re)?Y(re+1):re===Ao&&et():u==="bulk"?ge==="input"&&_t?$e("review"):ge==="review"&&_e():u==="store"&&U==="review"&&Vt())},Mn=e.some(J=>J.id===G)&&G.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:pn,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"),Re("")},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"),Re("")},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"),Re(""),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:"Store"})]})]}),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"&&re===1&&!ae&&l.jsx("button",{className:"ml-auto px-2 py-0.5 rounded text-[10px] font-semibold cursor-pointer hover:brightness-125",style:{background:"rgba(255,255,255,0.15)",color:"#fff"},onClick:()=>{const J=JE[o.roleId];J&&(Z(J.name),A(J.id),W(!0),te(J.level))},children:"Auto-fill โ"})]}),l.jsxs("div",{className:"text-sm opacity-80 mt-0.5 flex items-center gap-2",children:[l.jsx("span",{children:u==="single"?`Step ${re} of ${Ao}`:u==="bulk"?ge==="input"?"Enter roles, one per line":`Review ${Pe.length} roles`:U==="browse"?`${h.length} characters available`:"Review & customize"}),u==="store"&&U==="browse"&&l.jsx("a",{href:"https://tycono.ai/store.html",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] opacity-60 hover:opacity-100 transition-opacity",onClick:J=>J.stopPropagation(),children:"Open in browser โ"})]})]}),u==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:Ao},(J,We)=>We+1).map(J=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:J<=re?"#2E7D32":"rgba(255,255,255,0.1)"}},J))}),l.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:u==="store"?l.jsxs(l.Fragment,{children:[U==="browse"&&l.jsxs("div",{className:"space-y-3",children:[Q?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:[Q.slice(0,8),"..."]})]}),l.jsx("button",{onClick:()=>{Hl=null,localStorage.removeItem("tycono_instance_id"),oe(null)},className:"text-white/30 hover:text-white/60 cursor-pointer",children:"Sign out"})]}):l.jsx(r6,{onLogin:J=>{Hl=J,localStorage.setItem("tycono_instance_id",J),oe(J)}}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{placeholder:"Paste ID (tycono:engineer)",className:"flex-1 p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-accent/40 transition-colors font-mono",onKeyDown:J=>{if(J.key==="Enter"){const ot=J.target.value.trim().replace(/^tycono:/,"");ot&&(nn(ot),J.target.value="")}}}),l.jsx("button",{onClick:()=>{const J=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(J){const ot=J.value.trim().replace(/^tycono:/,"");ot&&(nn(ot),J.value="")}},disabled:N,className:"px-3 py-2 rounded-lg bg-accent/10 border border-accent/25 text-accent text-xs font-medium hover:bg-accent/20 transition-colors shrink-0 cursor-pointer disabled:opacity-50",children:N?"Loading...":"Fetch"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex-1 h-px bg-white/10"}),l.jsx("span",{className:"text-[10px] text-white/30",children:"or browse"}),l.jsx("div",{className:"flex-1 h-px bg-white/10"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:b,onChange:J=>j(J.target.value),placeholder:"Search characters...",className:"flex-1 p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-white/25 transition-colors",autoFocus:!0}),l.jsxs("select",{value:y,onChange:J=>v(J.target.value),className:"px-2 py-2 rounded-lg border border-white/10 bg-white/5 text-xs text-white/70 focus:outline-none cursor-pointer",children:[l.jsx("option",{value:"popular",className:"bg-[var(--wall)]",children:"Popular"}),l.jsx("option",{value:"installs",className:"bg-[var(--wall)]",children:"Most Hired"}),l.jsx("option",{value:"newest",className:"bg-[var(--wall)]",children:"Newest"}),l.jsx("option",{value:"name",className:"bg-[var(--wall)]",children:"A-Z"})]})]}),f?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:"Loading store..."}):_?l.jsxs("div",{className:"text-center py-8",children:[l.jsx("div",{className:"text-xs text-red-400 mb-2",children:_}),l.jsx("button",{onClick:ye,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):Ne.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:Ne.map(J=>l.jsx(a6,{char:J,isHired:Me.has(J.id),onSelect:()=>nn(J.id),onVote:We=>fn(J.id,We),onDelete:()=>yt(J.id),fetching:N,token:Q},J.id))})]}),U==="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(nl,{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:$,onChange:J=>q(J.target.value),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Role ID"}),l.jsx("input",{value:L,onChange:J=>R(J.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 font-mono focus:outline-none focus:border-white/25 transition-colors"}),e.some(J=>J.id===L)&&L.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":k.level==="team-lead"?"Lead":"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:I,onChange:J=>H(J.target.value),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors",children:[l.jsx("option",{value:"ceo",className:"bg-[var(--wall)] text-white",children:"CEO"}),e.map(J=>l.jsxs("option",{value:J.id,className:"bg-[var(--wall)] text-white",children:[J.name," (",J.id,")"]},J.id))]})]})]})]})]}),k.persona&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),l.jsx("div",{className:"text-xs text-white/60 leading-relaxed line-clamp-3",children:k.persona})]}),k.skills&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Skills"}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:(()=>{var xn,ke;const J=k.skills;if(J&&typeof J=="object"&&!Array.isArray(J)&&"primary"in J){const Mt=[];return(ke=(xn=J.primary)==null?void 0:xn.frontmatter)!=null&&ke.name&&Mt.push(J.primary.frontmatter.name),J.shared&&J.shared.forEach(hn=>{var cn;return Mt.push(((cn=hn.frontmatter)==null?void 0:cn.name)||hn.id)}),Mt.map(hn=>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:hn},hn))}return(Array.isArray(J)?J:[]).map((Mt,hn)=>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 Mt=="string"?Mt:Mt.name},hn))})()})]})]}),Je&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Je})]})]}):u==="single"?l.jsxs(l.Fragment,{children:[re===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:Ee,value:ae,onChange:J=>dt(J.target.value),placeholder:"e.g. Data Analyst",className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-white/25 transition-colors"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role ID (slug)"}),l.jsx("input",{value:G,onChange:J=>{A(J.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),W(!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 ${Mn?"border-red-400":"border-white/10 focus:border-white/25"}`}),Mn&&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:ZE.map(J=>l.jsx("button",{onClick:()=>te(J.value),className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${D===J.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:J.label},J.value))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Reports To"}),l.jsxs("select",{value:je,onChange:J=>ve(J.target.value),className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors",children:[l.jsx("option",{value:"ceo",className:"bg-[var(--wall)] text-white",children:"CEO"}),e.map(J=>l.jsxs("option",{value:J.id,className:"bg-[var(--wall)] text-white",children:[J.name," (",J.id,")"]},J.id))]})]})]}),re===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:P,value:ze,onChange:J=>Xe(J.target.value),placeholder:"Describe this role's personality, expertise, and working style...",className:"w-full h-32 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"This defines how the AI agent will behave in this role"})]}),Et.length>0&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Skills"}),l.jsx("div",{className:"space-y-1.5 max-h-[120px] overflow-y-auto",children:Et.map(J=>l.jsxs("label",{className:"flex items-center gap-2 p-2 rounded-lg border border-white/10 bg-white/5 cursor-pointer hover:border-white/20 transition-colors",children:[l.jsx("input",{type:"checkbox",checked:gt.has(J.id),onChange:()=>kt(We=>{const ot=new Set(We);return ot.has(J.id)?ot.delete(J.id):ot.add(J.id),ot}),className:"accent-green-600"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-xs font-semibold text-white/80",children:J.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:J.description})]})]},J.id))})]})]}),re===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx(bv,{roleId:"default",appearance:de,onChange:Oe,onRandomize:()=>Oe(gs()),onReset:()=>Oe(gs()),label:l.jsxs("span",{children:[G||"new-role"," โ ",ae||"New Role"]})})}),re===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(nl,{roleId:"default",appearance:de,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(Do,{label:"Name",value:ae}),l.jsx(Do,{label:"ID",value:G,mono:!0}),l.jsx(Do,{label:"Level",value:D}),l.jsx(Do,{label:"Reports To",value:je}),gt.size>0&&l.jsx(Do,{label:"Skills",value:[...gt].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})]})]}),Je&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Je})]})]}):l.jsxs(l.Fragment,{children:[ge==="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:pe,onChange:J=>xe(J.target.value),placeholder:`Name, Level, ReportsTo
|
|
85
|
+
e.g.
|
|
86
|
+
Data Analyst
|
|
87
|
+
DevOps Engineer, member, cto
|
|
88
|
+
VP Marketing, c-level, ceo`,className:"w-full h-40 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors font-mono"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Format: Name, Level (member/team-lead/c-level), ReportsTo. Level and ReportsTo are optional."})]}),Pe.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 (",Pe.length," role",Pe.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:Pe.map((J,We)=>l.jsxs("tr",{className:`border-b border-white/5 ${J.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:J.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:J.id}),l.jsx("td",{className:"p-2 text-white/60",children:J.level}),l.jsx("td",{className:"p-2 text-white/60",children:J.reportsTo}),J.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:J.error})]},We))})]})})]})]}),ge==="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 โ ",Pe.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:Pe.map((J,We)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:We+1}),l.jsx("td",{className:"p-2 text-white/80",children:J.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:J.id}),l.jsx("td",{className:"p-2 text-white/60",children:J.level}),l.jsx("td",{className:"p-2 text-white/60",children:J.reportsTo})]},We))})]})}),Qe&&Be.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:[Be.done,"/",Be.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:`${Be.done/Be.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."}),Je&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:Je})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[u==="single"&&re>1&&l.jsx("button",{onClick:()=>Y(re-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"&&ge==="review"&&l.jsx("button",{onClick:()=>$e("input"),disabled:Qe,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"&&U==="review"&&l.jsx("button",{onClick:()=>{B("browse"),C(null),Re("")},disabled:Qe,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"?re<Ao?l.jsx("button",{onClick:()=>Y(re+1),disabled:!Fe(re),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:et,disabled:Qe,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:Qe?"Hiring...":"HIRE"}):u==="bulk"?ge==="input"?l.jsxs("button",{onClick:()=>$e("review"),disabled:!_t,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 (",Pe.length,")"]}):l.jsx("button",{onClick:_e,disabled:Qe,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:Qe?`Hiring ${Be.done}/${Be.total}...`:`HIRE ALL (${Pe.length})`}):U==="review"?l.jsx("button",{onClick:Vt,disabled:Qe||!$.trim()||!L.trim()||e.some(J=>J.id===L),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:Qe?"Hiring...":"HIRE"}):null]})]})]})]})}function r6({onLogin:e}){const[n,a]=w.useState(""),[i,o]=w.useState(!1),[u,d]=w.useState(""),h=()=>{const m=n.trim();if(m){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(m)){d("Invalid token format");return}e(m)}};return l.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] p-3 space-y-2",children:[l.jsx("div",{className:"text-[11px] text-white/50",children:"Sign in to vote, publish, and manage your characters."}),i?l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:n,onChange:m=>{a(m.target.value),d("")},onKeyDown:m=>{m.key==="Enter"&&h()},placeholder:"Paste your token here...",className:"flex-1 px-2 py-1.5 rounded-lg border border-white/10 bg-white/5 text-xs text-white/90 font-mono placeholder-white/20 focus:outline-none focus:border-amber-800/40",autoFocus:!0}),l.jsx("button",{onClick:h,disabled:!n.trim(),className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer text-green-400 bg-green-900/20 border border-green-800/30 hover:bg-green-900/40 disabled:opacity-30 transition-colors",children:"Sign in"})]}),u&&l.jsx("div",{className:"text-[10px] text-red-400",children:u}),l.jsx("button",{onClick:o.bind(null,!1),className:"text-[10px] text-white/30 hover:text-white/50 cursor-pointer",children:"Cancel"})]}):l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:o.bind(null,!0),className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer text-amber-400 bg-amber-900/20 border border-amber-800/30 hover:bg-amber-900/40 transition-colors",children:"Paste Token"}),l.jsx("span",{className:"text-[10px] text-white/20 self-center",children:"from Settings โ Token"})]})]})}function a6({char:e,isHired:n,onSelect:a,onVote:i,onDelete:o,fetching:u,token:d}){const[h,m]=w.useState(!1),f=d&&e.publisher_id===d,x=!!d;return l.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border border-white/10 bg-white/[0.03] hover:bg-white/[0.06] transition-colors group",children:[l.jsxs("div",{className:"flex flex-col items-center gap-0.5 shrink-0 w-8",children:[l.jsx("button",{onClick:y=>{y.stopPropagation(),i(1)},disabled:!x,className:`text-[14px] leading-none transition-colors ${x?"cursor-pointer":"cursor-not-allowed opacity-30"} ${e.my_vote===1?"text-green-400":"text-white/20 hover:text-green-400/60"}`,title:x?"Upvote":"Sign in to vote",children:"โฒ"}),l.jsx("span",{className:`text-[11px] font-bold tabular-nums ${(e.vote_score??0)>0?"text-green-400/80":(e.vote_score??0)<0?"text-red-400/80":"text-white/30"}`,children:e.vote_score??0}),l.jsx("button",{onClick:y=>{y.stopPropagation(),i(-1)},disabled:!x,className:`text-[14px] leading-none transition-colors ${x?"cursor-pointer":"cursor-not-allowed opacity-30"} ${e.my_vote===-1?"text-red-400":"text-white/20 hover:text-red-400/60"}`,title:x?"Downvote":"Sign in to vote",children:"โผ"})]}),l.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:a,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-white/90 truncate",children:e.name}),l.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded font-semibold uppercase ${e.level==="c-level"?"bg-amber-900/30 text-amber-400 border border-amber-800/30":e.level==="team-lead"?"bg-blue-900/30 text-blue-400 border border-blue-800/30":"bg-white/5 text-white/40 border border-white/10"}`,children:e.level}),n&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-green-900/20 text-green-400/60 border border-green-800/20",children:"Hired"})]}),e.tagline&&l.jsx("div",{className:"text-[11px] text-white/40 truncate mt-0.5",children:e.tagline}),l.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[l.jsxs("span",{className:"text-[10px] text-white/25",children:[e.installs??0," installs"]}),l.jsxs("span",{className:"text-[10px] text-white/25",children:["v",e.version]}),l.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:e.id})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[l.jsx("button",{onClick:a,disabled:u,className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer transition-colors disabled:opacity-40 text-green-400 bg-green-900/20 border border-green-800/30 hover:bg-green-900/40",children:"Hire"}),f&&(h?l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:y=>{y.stopPropagation(),o(),m(!1)},className:"px-2 py-1.5 text-[10px] font-semibold rounded cursor-pointer text-red-400 bg-red-900/30 border border-red-800/40 hover:bg-red-900/50",children:"Confirm"}),l.jsx("button",{onClick:y=>{y.stopPropagation(),m(!1)},className:"px-2 py-1.5 text-[10px] rounded cursor-pointer text-white/40 hover:text-white/60",children:"No"})]}):l.jsx("button",{onClick:y=>{y.stopPropagation(),m(!0)},className:"w-7 h-7 rounded-lg flex items-center justify-center cursor-pointer text-white/15 hover:text-red-400/60 hover:bg-red-900/10 transition-colors opacity-0 group-hover:opacity-100",title:"Delete from store",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2"})})}))]})]})}function Do({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 l6({roleId:e,roleName:n,onClose:a,onConfirm:i}){const[o,u]=w.useState(!1),d=async()=>{u(!0);try{await i(e)}finally{u(!1)}};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:a}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsx("div",{className:"text-lg font-bold",children:"Fire Role"}),l.jsxs("div",{className:"text-sm opacity-80 mt-0.5",children:["Remove ",n," (",e,")"]})]}),l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"p-4 rounded-lg border-2 border-red-300 bg-red-50 mb-4",children:[l.jsx("div",{className:"text-sm font-bold text-red-800 mb-1",children:"Warning"}),l.jsxs("div",{className:"text-xs text-red-700 leading-relaxed",children:["This will permanently delete the role directory including",l.jsx("strong",{children:" role.yaml"}),", ",l.jsx("strong",{children:"profile.md"}),", ",l.jsx("strong",{children:"SKILL.md"}),", and all journal entries. This action cannot be undone."]})]}),l.jsxs("div",{className:"text-sm text-gray-600",children:["Are you sure you want to fire ",l.jsx("strong",{children:n}),"?"]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:a,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:d,disabled:o,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:o?"Removing...":"Confirm Fire"})]})]})]})}const i6={cto:"๐๏ธ",cbo:"๐",pm:"๐",engineer:"โ๏ธ",designer:"๐จ",qa:"๐"};function s6({roleId:e,title:n,roleColor:a,active:i,isWave:o,isWaveStreaming:u,onClick:d,onClose:h,"data-session-id":m}){const f=o?"#F59E0B":a;return l.jsxs("button",{onClick:d,"data-session-id":m,className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors max-w-[180px] group ${i?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] hover:bg-[var(--terminal-surface)]"}`,style:i?{borderTop:`2px solid ${f}`}:void 0,children:[o&&u&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse shrink-0"}),l.jsx("span",{className:"text-xs",children:i6[e]??"๐ค"}),l.jsx("span",{className:`truncate ${o?"text-amber-400/90":""}`,children:n}),l.jsx("span",{onClick:h,className:"ml-auto text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none",children:"ร"})]})}function o6({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(Hm,{remarkPlugins:[Xm],components:{code:c6,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:a})})}function c6({className:e,children:n,...a}){const i=/language-(\w+)/.exec(e??"");return i||typeof n=="string"&&n.includes(`
|
|
89
|
+
`)?l.jsx(u6,{language:i==null?void 0:i[1],children:n}):l.jsx("code",{className:"terminal-inline-code",...a,children:n})}function u6({children:e,language:n}){const[a,i]=w.useState(!1),o=String(e).replace(/\n$/,""),u=()=>{navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"terminal-code-block group relative my-2",children:[n&&l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] px-3 pt-1.5",children:n}),l.jsx("button",{onClick:u,className:"absolute top-1.5 right-2 text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:a?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:o})})]})}const d6={cto:"๐๏ธ",cbo:"๐",pm:"๐",engineer:"โ๏ธ",designer:"๐จ",qa:"๐"};function f6({attachments:e}){const[n,a]=w.useState(null);return e.length===0?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:e.map((i,o)=>l.jsxs("button",{onClick:()=>a(o),className:"relative w-20 h-20 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)] cursor-pointer hover:border-[var(--terminal-border-hover)] transition-colors",children:[l.jsx("img",{src:`data:${i.mediaType};base64,${i.data}`,alt:i.name,className:"w-full h-full object-cover"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[8px] text-white truncate px-1 py-0.5",children:i.name})]},o))}),n!==null&&l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/80 flex items-center justify-center",onClick:()=>a(null),children:l.jsxs("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[l.jsx("img",{src:`data:${e[n].mediaType};base64,${e[n].data}`,alt:e[n].name,className:"max-w-full max-h-[90vh] object-contain rounded-lg"}),l.jsx("button",{onClick:()=>a(null),className:"absolute top-2 right-2 w-8 h-8 rounded-full bg-black/70 text-white flex items-center justify-center cursor-pointer hover:bg-black/90",children:"x"}),l.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 bg-black/70 text-white text-sm px-3 py-1 rounded",children:e[n].name})]})})]})}function zh(e,n){return n?n.file_path?String(n.file_path).replace(/^.*\/(?=[^/]+\/)/,""):n.path?String(n.path).replace(/^.*\/(?=[^/]+\/)/,""):n.pattern?String(n.pattern):n.command?String(n.command).slice(0,60):n.query?String(n.query).slice(0,60):n.url?String(n.url).slice(0,60):"":""}function h6(e){const n=[];let a="";for(const i of e)if(i.type==="thinking")i.text&&(a=i.text),n.length===0||n[n.length-1].type!=="thinking"?n.push({type:"thinking",text:i.text}):n[n.length-1].text=i.text;else if(i.type==="tool")n.push({type:"tool",toolName:i.toolName,toolSummary:zh(i.toolName??"",i.toolInput),toolInput:i.toolInput});else if(i.type==="dispatch")n.push({type:"dispatch",roleId:i.roleId,task:i.task});else if(i.type==="dispatch:progress"){const o=n.length>0?n[n.length-1]:null;(o==null?void 0:o.type)==="dispatch:progress"&&o.roleId===i.roleId?i.progressType==="tool"?(o.toolName=i.toolName,o.toolSummary=zh(i.toolName??"",i.toolInput),o.progressType="tool"):i.progressType==="thinking"?(o.text=i.text,o.progressType="thinking"):i.progressType==="text"?(o.text=i.text,o.progressType="text"):(i.progressType==="done"||i.progressType==="error")&&(o.progressType=i.progressType):n.push({type:"dispatch:progress",roleId:i.roleId,progressType:i.progressType,text:i.text,toolName:i.toolName,toolSummary:i.toolName?zh(i.toolName,i.toolInput):void 0})}if(a){const i=n.filter(o=>o.type==="thinking");i.length>0&&(i[i.length-1].text=a)}return n}function m6({event:e,isStreaming:n}){var o,u,d;const[a,i]=w.useState(!1);switch(e.type){case"thinking":return l.jsxs("div",{className:"stream-event-thinking",children:[l.jsxs("div",{className:"stream-event-thinking-header",onClick:()=>i(!a),children:[l.jsx("span",{className:"stream-event-thinking-icon"}),l.jsxs("span",{className:"stream-event-thinking-label",children:["thinking",n?"...":""]}),e.text&&!n&&l.jsx("span",{className:"stream-event-thinking-toggle",children:a?"โพ":"โธ"})]}),(n||a)&&e.text&&l.jsx("div",{className:"stream-event-thinking-content",children:e.text.slice(-500)})]});case"tool":return l.jsxs("div",{className:"stream-event-tool",children:[l.jsx("span",{className:"stream-event-tool-badge",children:e.toolName}),e.toolSummary&&l.jsx("span",{className:"stream-event-tool-path",children:e.toolSummary}),e.toolInput&&l.jsx("span",{className:"stream-event-tool-toggle",onClick:()=>i(!a),children:a?"โพ":"โธ"}),a&&e.toolInput&&l.jsx("div",{className:"stream-event-tool-detail",children:JSON.stringify(e.toolInput,null,1).slice(0,300)})]});case"dispatch":return l.jsxs("div",{className:"stream-event-dispatch",children:[l.jsxs("span",{className:"stream-event-dispatch-badge",children:["โ"," ",(o=e.roleId)==null?void 0:o.toUpperCase()]}),l.jsx("span",{className:"stream-event-dispatch-task",children:(u=e.task)==null?void 0:u.slice(0,80)})]});case"dispatch:progress":return l.jsxs("div",{className:"stream-event-dispatch-progress",children:[l.jsx("span",{className:"stream-event-dispatch-progress-role",children:(d=e.roleId)==null?void 0:d.toUpperCase()}),e.progressType==="thinking"&&l.jsxs("span",{className:"stream-event-dispatch-progress-status",children:["thinking",n?"...":""]}),e.progressType==="tool"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"stream-event-tool-badge",children:e.toolName}),e.toolSummary&&l.jsx("span",{className:"stream-event-tool-path",children:e.toolSummary})]}),e.progressType==="text"&&e.text&&l.jsx("span",{className:"stream-event-dispatch-progress-status",children:"responding..."}),e.progressType==="done"&&l.jsx("span",{className:"stream-event-dispatch-progress-done",children:"done"}),e.progressType==="error"&&l.jsx("span",{className:"stream-event-dispatch-progress-error",children:"error"})]});default:return null}}function p6({events:e,isStreaming:n}){const[a,i]=w.useState(!1);if(e.length===0)return null;const o=h6(e);if(o.length===0)return null;const u=e.filter(v=>v.type==="thinking").length,d=e.filter(v=>v.type==="tool"),h=e.filter(v=>v.type==="dispatch"||v.type==="dispatch:progress"),m=e.filter(v=>v.type==="turn").reduce((v,b)=>Math.max(v,b.turn??0),0),f=[];if(u>0&&f.push("thinking"),d.length>0){const v=[...new Set(d.map(b=>b.toolName))];v.length<=3?f.push(v.join(", ")):f.push(`${d.length} tool calls`)}h.length>0&&f.push(`${h.length} dispatch`),m>1&&f.push(`${m} turns`);const x=f.join(" ยท "),y=!a;return l.jsxs("div",{className:"stream-activity-log",children:[l.jsxs("div",{className:"stream-activity-header",onClick:()=>i(!a),children:[n&&l.jsx("span",{className:"stream-activity-pulse"}),l.jsxs("span",{className:"stream-activity-summary",children:[a?"โธ":"โพ"," ",x,n?"...":""]})]}),y&&l.jsx("div",{className:"stream-activity-events",children:o.map((v,b)=>l.jsx(m6,{event:v,isStreaming:n&&b===o.length-1},b))})]})}function x6(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 y6({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(f6,{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?x6(e.events):void 0),h=((d==null?void 0:d.length)??0)>0,m=!!e.thinking,f=m&&!e.content&&u&&!h;return l.jsxs("div",{className:"flex gap-2.5 mb-3",children:[l.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center text-sm shrink-0 mt-5",style:{background:`${a}33`},children:d6[n]??"๐ค"}),l.jsxs("div",{className:"max-w-[85%] min-w-0",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] mb-1",children:n.toUpperCase()}),h&&l.jsx(p6,{events:d,isStreaming:u}),m&&!h&&l.jsxs("details",{open:f,className:"mb-1",children:[l.jsxs("summary",{className:"text-[10px] text-purple-400/70 cursor-pointer select-none flex items-center gap-1",children:[f&&l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-purple-400 animate-pulse"}),"thinking",f?"...":` (${e.thinking.length} chars)`]}),l.jsx("div",{className:"text-[11px] text-[var(--terminal-text-muted)] leading-relaxed mt-1 pl-2 border-l border-purple-400/20 max-h-32 overflow-y-auto",children:e.thinking.slice(-500)})]}),l.jsxs("div",{className:"rounded-xl rounded-tl-sm px-4 py-2.5 text-sm text-[var(--terminal-text)] leading-relaxed",style:{borderLeft:`3px solid ${a}`,background:"var(--terminal-surface)"},children:[e.content?l.jsx(o6,{content:e.content,streaming:u}):u&&!m?l.jsx("span",{className:"inline-block w-2 h-4 bg-[var(--terminal-text-secondary)] animate-pulse"}):u&&m?l.jsx("span",{className:"text-[11px] text-purple-400/50 italic",children:"analyzing..."}):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"})]})]})]})}function vv({messages:e,roleId:n,roleColor:a}){var o;const i=w.useRef(null);return w.useEffect(()=>{var u;(u=i.current)==null||u.scrollIntoView({behavior:"smooth"})},[e,(o=e[e.length-1])==null?void 0:o.content]),e.length===0?l.jsxs("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:["Start a conversation with ",n.toUpperCase()]}):l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 terminal-scrollbar",children:[e.map(u=>l.jsx(y6,{message:u,roleId:n,roleColor:a},u.id)),l.jsx("div",{ref:i})]})}const g6=5*1024*1024,b6=["image/png","image/jpeg","image/gif","image/webp"];function ep({mode:e,onModeChange:n,onSend:a,disabled:i,disabledReason:o}){const[u,d]=w.useState(""),[h,m]=w.useState([]),[f,x]=w.useState(!1),[y,v]=w.useState(null),b=w.useRef(null),j=w.useRef(null);w.useEffect(()=>{const L=b.current;L&&(L.style.height="0",L.style.height=Math.min(L.scrollHeight,120)+"px")},[u]),w.useEffect(()=>{if(y){const L=setTimeout(()=>v(null),3e3);return()=>clearTimeout(L)}},[y]);const k=w.useCallback(async L=>b6.includes(L.type)?L.size>g6?(v(`File too large: ${(L.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(R=>{const I=new FileReader;I.onload=()=>{const Q=I.result.split(",")[1];R({type:"image",data:Q,name:L.name,mediaType:L.type})},I.onerror=()=>{v("Failed to read file"),R(null)},I.readAsDataURL(L)}):(v(`Unsupported format: ${L.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),C=w.useCallback(async L=>{const R=Array.from(L),I=[];for(const H of R){const Q=await k(H);Q&&I.push(Q)}I.length>0&&m(H=>[...H,...I])},[k]),N=w.useCallback(L=>{L.preventDefault(),L.stopPropagation(),x(!0)},[]),E=w.useCallback(L=>{L.preventDefault(),L.stopPropagation(),x(!1)},[]),_=w.useCallback(L=>{L.preventDefault(),L.stopPropagation(),x(!1);const R=L.dataTransfer.files;R.length>0&&C(R)},[C]),z=w.useCallback(L=>{const R=L.clipboardData.items,I=[];for(let H=0;H<R.length;H++){const Q=R[H];if(Q.type.startsWith("image/")){const oe=Q.getAsFile();oe&&I.push(oe)}}I.length>0&&(L.preventDefault(),C(I))},[C]),U=w.useCallback(L=>{const R=L.target.files;R&&R.length>0&&C(R),L.target.value=""},[C]),B=w.useCallback(L=>{m(R=>R.filter((I,H)=>H!==L))},[]),$=()=>{const L=u.trim();!L&&h.length===0||i||(a(L,h.length>0?h:void 0),d(""),m([]))},q=L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),$())};return l.jsxs("div",{className:`border-t border-[var(--terminal-border)] p-3 shrink-0 transition-colors ${f?"bg-[var(--terminal-surface-light)] border-amber-500/50":""}`,onDragOver:N,onDragLeave:E,onDrop:_,children:[y&&l.jsx("div",{className:"text-[10px] text-red-400 mb-2 text-center",children:y}),o&&l.jsx("div",{className:"text-[10px] text-amber-400/70 mb-2 text-center",children:o}),h.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:h.map((L,R)=>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:${L.mediaType};base64,${L.data}`,alt:L.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>B(R),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:L.name})]},R))}),f&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-2",children:"Drop image here"}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"flex rounded-lg overflow-hidden border border-[var(--terminal-border)] shrink-0",children:[l.jsx("button",{onClick:()=>n("talk"),className:`px-2.5 py-1.5 text-[11px] font-semibold cursor-pointer transition-colors ${e==="talk"?"bg-[var(--desk-wood)] text-white":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)]"}`,children:"Talk"}),l.jsx("button",{onClick:()=>n("do"),className:`px-2.5 py-1.5 text-[11px] font-semibold cursor-pointer transition-colors ${e==="do"?"bg-amber-700 text-white":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)]"}`,children:"Do"})]}),l.jsx("button",{onClick:()=>{var L;return(L=j.current)==null?void 0:L.click()},disabled:i,className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--terminal-surface-light)] hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Attach image (PNG, JPG, GIF, WebP)",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{ref:j,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:U,className:"hidden"}),l.jsx("textarea",{ref:b,value:u,onChange:L=>d(L.target.value),onKeyDown:q,onPaste:z,placeholder:i?"Waiting...":e==="talk"?"Ask something...":"Give a directive...",disabled:i,rows:1,className:"flex-1 bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] rounded-lg px-3 py-2 text-sm text-[var(--terminal-text)] placeholder:text-[var(--terminal-text-muted)] resize-none focus:outline-none focus:border-[var(--terminal-border-hover)] disabled:opacity-40 terminal-scrollbar"}),l.jsx("button",{onClick:$,disabled:i||!u.trim()&&h.length===0,className:"w-8 h-8 rounded-lg bg-[var(--terminal-surface-light)] text-[var(--terminal-text-secondary)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--desk-wood)] hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M22 2L11 13"}),l.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})]})}const v6={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},wv={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function Jy(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function w6({msg:e}){const n=v6[e.roleId]??"#888",a=wv[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:Jy(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:Jy(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 k6({channel:e,allRoles:n,onUpdateMembers:a,onUpdateTopic:i,onSendMessage:o}){const u=w.useRef(null),d=w.useRef(null),[h,m]=w.useState("");w.useEffect(()=>{var _;const N=d.current;if(!N)return;N.scrollHeight-N.scrollTop-N.clientHeight<80&&((_=u.current)==null||_.scrollIntoView({behavior:"smooth"}))},[e.messages.length]);const[f,x]=w.useState(!1),[y,v]=w.useState(!1),[b,j]=w.useState(""),k=o&&e.id!=="general",C=()=>{!h.trim()||!o||(o(e.id,h.trim()),m(""),setTimeout(()=>{var N;return(N=u.current)==null?void 0:N.scrollIntoView({behavior:"smooth"})},50))};return l.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[l.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto terminal-scrollbar py-2 min-h-0",children:[l.jsxs("div",{className:"px-3 py-2 mb-2 border-b border-[var(--terminal-border)] flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-[var(--terminal-text)]",children:e.name}),e.members.length>0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.members.map(N=>wv[N]??N).join(", ")}),e.members.length===0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.isDefault?"system logs":"no members"}),!e.isDefault&&n&&a&&l.jsx("button",{className:"ml-auto text-[10px] px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 text-[var(--terminal-text-muted)]",onClick:()=>x(!f),children:f?"Done":"Invite"})]}),!e.isDefault&&i&&l.jsx("div",{className:"px-3 pb-2 mb-1",children:y?l.jsx("input",{autoFocus:!0,value:b,onChange:N=>j(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(i(e.id,b.trim()),v(!1)),N.key==="Escape"&&v(!1)},onBlur:()=>{i(e.id,b.trim()),v(!1)},placeholder:"Set a topic for this channel...",className:"w-full bg-transparent text-[10px] text-[var(--terminal-text-muted)] outline-none border-b border-[var(--terminal-border)] pb-0.5"}):l.jsx("button",{onClick:()=>{j(e.topic??""),v(!0)},className:"text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] cursor-pointer italic",children:e.topic||"Click to set channel topic..."})}),f&&!e.isDefault&&n&&a&&l.jsx("div",{className:"px-3 pb-2 mb-2 border-b border-[var(--terminal-border)]",children:l.jsx("div",{className:"flex flex-wrap gap-1",children:n.map(N=>{const E=e.members.includes(N.id);return l.jsxs("button",{className:`text-[10px] px-2 py-1 rounded ${E?"bg-white/15 text-[var(--terminal-text)]":"bg-white/5 text-[var(--terminal-text-muted)]"}`,onClick:()=>{const _=E?e.members.filter(z=>z!==N.id):[...e.members,N.id];a(e.id,_)},children:[E?"โ ":"",N.name]},N.id)})})}),e.messages.length===0&&l.jsx("div",{className:"flex-1 flex flex-col items-center justify-center text-[var(--terminal-text-muted)] text-xs gap-1 py-8",children:l.jsx("span",{children:e.isDefault?"No dispatch events yet":"No messages yet โ invite roles to start chatting"})}),e.messages.map(N=>l.jsx(w6,{msg:N},N.id)),l.jsx("div",{ref:u})]}),k&&l.jsx("div",{className:"shrink-0 px-3 py-2 border-t border-[var(--terminal-border)]",children:l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("span",{className:"text-[10px] font-semibold shrink-0",style:{color:"#FFB300"},children:"CEO"}),l.jsx("input",{type:"text",value:h,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),C())},placeholder:"Say something...",className:"flex-1 px-2 py-1 text-xs rounded border bg-transparent text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#FFB300]/50"})]})})]})}const _h={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},j6=400,S6=800;function eg({sessions:e,activeSessionId:n,roles:a,streamingSessionId:i,width:o,onWidthChange:u,onSwitchSession:d,onCloseSession:h,onCreateSession:m,onClearEmpty:f,onCloseAll:x,onSendMessage:y,onModeChange:v,onCloseTerminal:b,onMaximize:j,chatChannels:k,activeChatChannelId:C,onSwitchChatChannel:N,onCreateChatChannel:E,onDeleteChatChannel:_,onUpdateChatMembers:z,onUpdateChatTopic:U,onSendChatMessage:B,unreadChannels:$}){const[q,L]=w.useState(!1),[R,I]=w.useState(!1),[H,Q]=w.useState(!1),[oe,re]=w.useState(""),Y=C!=null,ae=k==null?void 0:k.find(Se=>Se.id===C),[Z,G]=w.useState(!1),[A,F]=w.useState(!1),[W,D]=w.useState(!1),te=w.useRef(0),je=w.useRef(0),ve=w.useRef(null),ze=e.find(Se=>Se.id===n),Xe=i===n,de=e.filter(Se=>Se.messages.length===0).length,Oe=w.useCallback(()=>{const Se=ve.current;Se&&(F(Se.scrollLeft>0),D(Se.scrollLeft+Se.clientWidth<Se.scrollWidth-1))},[]);w.useEffect(()=>{if(!n||!ve.current)return;const Se=ve.current.querySelector(`[data-session-id="${n}"]`);Se&&Se.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),Oe()},[n,e.length,Oe]),w.useEffect(()=>{const Se=ve.current;if(!Se)return;Oe(),Se.addEventListener("scroll",Oe);const Je=new ResizeObserver(Oe);return Je.observe(Se),()=>{Se.removeEventListener("scroll",Oe),Je.disconnect()}},[Oe]);const Qe=w.useCallback(Se=>{Se.preventDefault(),te.current=Se.clientX,je.current=o,G(!0);const Je=j,Re=()=>{G(!1),document.removeEventListener("mousemove",Et),document.removeEventListener("mouseup",Re)},Et=ut=>{const gt=te.current-ut.clientX,kt=je.current+gt;if(kt>=window.innerWidth*.6&&Je){Re(),Je();return}const pe=Math.min(S6,Math.max(j6,kt));u==null||u(pe)};document.addEventListener("mousemove",Et),document.addEventListener("mouseup",Re)},[o,u,j]);return l.jsxs("div",{className:"shrink-0 bg-[var(--terminal-bg)] border-l border-[var(--terminal-border)] flex flex-col h-full relative",style:{width:o},children:[u&&l.jsx("div",{className:`terminal-resize-handle absolute top-0 left-0 w-1 h-full cursor-col-resize z-10 transition-colors ${Z?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:Qe}),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:[A&&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:ve,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[k==null?void 0:k.map(Se=>l.jsxs("button",{onClick:()=>{N==null||N(Se.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===Se.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===Se.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"๐ฌ"}),l.jsx("span",{className:"truncate",children:Se.name}),($==null?void 0:$.has(Se.id))&&C!==Se.id&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!Se.isDefault&&l.jsx("span",{onClick:Je=>{Je.stopPropagation(),_==null||_(Se.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:"ร"})]},Se.id)),k&&k.length>0&&e.length>0&&l.jsx("div",{className:"w-px h-4 bg-[var(--terminal-border)] shrink-0 mx-1"}),e.map(Se=>l.jsx(s6,{roleId:Se.roleId,title:Se.title,roleColor:_h[Se.roleId]??"#666",active:!Y&&Se.id===n,isWave:Se.source==="wave",isWaveStreaming:Se.source==="wave"&&Se.status==="active",onClick:()=>{N==null||N(null),d(Se.id)},onClose:Je=>{Je.stopPropagation(),h(Se.id)},"data-session-id":Se.id},Se.id))]}),W&&l.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-6 bg-gradient-to-l from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{L(!q),I(!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:"+"}),q&&l.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[E&&l.jsxs(l.Fragment,{children:[H?l.jsxs("div",{className:"px-3 py-2 flex items-center gap-1",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"#"}),l.jsx("input",{autoFocus:!0,value:oe,onChange:Se=>re(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&oe.trim()&&(E(oe.trim(),[]),re(""),Q(!1),L(!1)),Se.key==="Escape"&&(Q(!1),re(""))},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:()=>Q(!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(Se=>l.jsxs("button",{onClick:()=>{m(Se.id),N==null||N(null),L(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:_h[Se.id]??"#666"}}),Se.id.toUpperCase()," โ ",Se.name]},Se.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{I(!R),L(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-xs cursor-pointer tracking-tight",title:"Manage sessions",children:"ยทยทยท"}),R&&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":""]}),de>0&&f&&l.jsxs("button",{onClick:()=>{f(),I(!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 (",de,")"]}),e.length>0&&x&&l.jsx("button",{onClick:()=>{x(),I(!1)},className:"w-full text-left px-3 py-2 text-xs text-[#E57373] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:"Close all sessions"}),e.length===0&&l.jsx("div",{className:"px-3 py-2 text-xs text-[var(--terminal-text-muted)]",children:"No sessions"})]})]}),j&&l.jsx("button",{onClick:j,className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",title:"Maximize (Pro View)",children:"โคข"}),l.jsx("button",{onClick:b,className:"px-2 py-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",children:"ร"})]}),Y&&ae?l.jsx(k6,{channel:ae,allRoles:a,onUpdateMembers:z,onUpdateTopic:U,onSendMessage:B}):ze?l.jsxs(l.Fragment,{children:[l.jsx(vv,{messages:ze.messages,roleId:ze.roleId,roleColor:_h[ze.roleId]??"#666"}),ze.source==="wave"?l.jsxs("div",{className:"shrink-0 px-4 py-2 border-t border-[var(--terminal-border)] bg-[var(--terminal-bg-deeper)] flex items-center gap-2",children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",style:ze.status==="active"?{animation:"pulse 2s infinite"}:void 0}),l.jsx("span",{className:"text-[11px] text-amber-400/80",children:"Wave execution ยท read-only"}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] ml-auto",children:"Interact via Wave Command Center"})]}):l.jsx(ep,{mode:ze.mode,onModeChange:Se=>v(ze.id,Se),onSend:(Se,Je)=>y(ze.id,Se,ze.mode,Je),disabled:Xe,disabledReason:Xe?`${ze.roleId.toUpperCase()} is responding...`:void 0})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"No active session. Click [+] to start."})]})}function C6(){const e=w.useRef(null),n=w.useCallback(()=>{var i;(i=e.current)==null||i.abort(),e.current=null},[]);return{sendMessage:w.useCallback((i,o,u,d,h)=>{n();const m=new AbortController;return e.current=m,fetch(`/api/exec/session/${i}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o,mode:u,attachments:h}),signal:m.signal}).then(async f=>{var C,N,E,_,z;if(!f.ok||!f.body){d.onError("Failed to connect");return}const x=f.body.getReader(),y=new TextDecoder;let v="",b=Date.now();const j=6e4,k=setInterval(()=>{Date.now()-b>j&&(clearInterval(k),m.abort(),d.onError("Connection stale โ no data received for 60s"))},1e4);try{for(;;){const{done:U,value:B}=await x.read();if(U)break;b=Date.now(),v+=y.decode(B,{stream:!0});const $=v.split(`
|
|
90
|
+
`);v=$.pop()??"";let q="";for(let L=0;L<$.length;L++){const R=$[L];if(R.startsWith("event: ")){q=R.slice(7).trim();continue}if(R.startsWith("data: ")){let I;try{I=JSON.parse(R.slice(6))}catch{q="";continue}switch(q){case"thinking":I.text&&((C=d.onThinking)==null||C.call(d,I.text));break;case"output":I.text&&d.onText(I.text);break;case"tool":(N=d.onToolUse)==null||N.call(d,I.name,I.input);break;case"dispatch":(E=d.onDispatch)==null||E.call(d,I.roleId,I.task);break;case"dispatch:progress":(_=d.onDispatchProgress)==null||_.call(d,I.roleId,I.type,I);break;case"turn":(z=d.onTurn)==null||z.call(d,I.turn);break;case"done":d.onDone(I);break;case"error":d.onError(I.message??"Unknown error");break;default:I.text&&d.onText(I.text);break}q=""}}}}finally{clearInterval(k)}}).catch(f=>{f.name!=="AbortError"&&d.onError(f.message)}),{abort:n}},[n]),abort:n}}const kv="tycono-appearances",vm="tycono-theme";function tg(){try{const e=localStorage.getItem(kv);return e?JSON.parse(e):{}}catch{return{}}}function Bh(e){localStorage.setItem(kv,JSON.stringify(e))}function ng(){try{const e=localStorage.getItem(vm);if(e&&e in al)return e}catch{}return"default"}const jv=new Set;for(const e of Object.values(al))for(const n of Object.keys(e.vars))jv.add(n);function N6(e){var i;const n=(i=al[e])==null?void 0:i.vars;if(!n)return;const a=document.documentElement;for(const o of jv)o in n||a.style.removeProperty(o);for(const[o,u]of Object.entries(n))a.style.setProperty(o,u)}const Oh={mode:"auto",intervalSec:18,dailyBudgetUsd:1},wm="tycono-speech-settings",$h="tycono-language";function E6(){try{const e=localStorage.getItem(wm);return e?{...Oh,...JSON.parse(e)}:Oh}catch{return Oh}}function A6(){const[e,n]=w.useState(tg),[a,i]=w.useState(ng),[o,u]=w.useState(E6),[d,h]=w.useState(()=>{try{return localStorage.getItem($h)??"auto"}catch{return"auto"}}),m=w.useRef(!1);w.useEffect(()=>{m.current||(m.current=!0,me.getPreferences().then(k=>{const C=Object.keys(k.appearances??{}).length>0||k.theme!=="default";if(k.speech&&(u(N=>({...N,...k.speech})),localStorage.setItem(wm,JSON.stringify(k.speech))),k.language&&(h(k.language),localStorage.setItem($h,k.language)),C){const N=k.appearances;n(N),Bh(N),k.theme&&k.theme in al&&(i(k.theme),localStorage.setItem(vm,k.theme))}else{const N=tg(),E=ng();(Object.keys(N).length>0||E!=="default")&&me.updatePreferences({appearances:N,theme:E}).catch(()=>{})}}).catch(()=>{}))},[]),w.useEffect(()=>{N6(a)},[a]);const f=w.useCallback(k=>e[k]??Jm(k),[e]),x=w.useCallback((k,C)=>{n(N=>{const E={...N,[k]:C};return Bh(E),me.updatePreferences({appearances:E}).catch(()=>{}),E})},[]),y=w.useCallback(k=>{n(C=>{const N={...C};return delete N[k],Bh(N),me.updatePreferences({appearances:N}).catch(()=>{}),N})},[]),v=w.useCallback(k=>{i(k),localStorage.setItem(vm,k),me.updatePreferences({theme:k}).catch(()=>{})},[]),b=w.useCallback(k=>{u(C=>{const N={...C,...k};return localStorage.setItem(wm,JSON.stringify(N)),me.updatePreferences({speech:N}).catch(()=>{}),N})},[]),j=w.useCallback(k=>{h(k),localStorage.setItem($h,k),me.updatePreferences({language:k}).catch(()=>{})},[]);return{appearances:e,getAppearance:f,setAppearance:x,resetAppearance:y,theme:a,setTheme:v,speechSettings:o,setSpeechSettings:b,language:d,setLanguage:j}}const D6=3e4,T6=3e5;function F6(){var I;const[e,n]=w.useState("akb"),[a,i]=w.useState(null),[o,u]=w.useState("synced"),[d,h]=w.useState([]),[m,f]=w.useState(null),[x,y]=w.useState(!1),v=w.useRef(null),b=w.useRef(null),j=w.useRef(e);j.current=e;const k=w.useCallback(async()=>{try{const H=await me.getSaveStatus(j.current);i(H),H.noGit?u("no-git"):u(Q=>Q==="saving"?Q:H.dirty?"dirty":"synced")}catch{u("error")}},[]),C=w.useCallback(async()=>{try{const H=await me.getSyncStatus(j.current);f({ahead:H.ahead,behind:H.behind,branch:H.branch,hasRemote:H.hasRemote})}catch{}},[]),N=w.useCallback(()=>{v.current&&clearInterval(v.current),k(),v.current=setInterval(k,D6),b.current&&clearInterval(b.current),C(),b.current=setInterval(C,T6)},[k,C]);w.useEffect(()=>()=>{v.current&&clearInterval(v.current),b.current&&clearInterval(b.current)},[]);const E=w.useCallback(H=>{n(H),j.current=H,i(null),f(null),h([]),setTimeout(()=>{k(),C()},0)},[k,C]),_=w.useCallback(async H=>{u("saving");try{const Q=await me.save(H,j.current);return await k(),Q}catch(Q){throw u("error"),Q}},[k]),z=w.useCallback(async()=>{try{const H=await me.getSaveHistory(20,j.current);h(H)}catch{}},[]),U=w.useCallback(async H=>{u("saving");try{await me.restoreSave(H,void 0,j.current),await k()}catch(Q){throw u("error"),Q}},[k]),B=w.useCallback(async()=>{y(!0);try{const H=await me.pull(j.current);return await k(),await C(),H}catch(H){throw H}finally{y(!1)}},[k,C]),$=w.useCallback(async()=>{try{await me.initGit(),await k()}catch{u("error")}},[k]),q=a?a.modified.length+a.untracked.length:0,L=((I=a==null?void 0:a.lastCommit)==null?void 0:I.date)??null,R=w.useCallback(async()=>{N()},[N]);return{state:o,dirtyCount:q,lastSaved:L,status:a,save:_,history:d,loadHistory:z,restore:U,refresh:R,initGit:$,repo:e,setRepo:E,syncInfo:m,fetchSyncStatus:C,pull:B,pulling:x}}const rg={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."]},ag={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."]},M6=[{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."}]}],R6=18e3,lg=6e3,z6=2500,_6=30*6e4,Sv="tycono:relationships";function B6(){try{const e=localStorage.getItem(Sv);return e?JSON.parse(e):[]}catch{return[]}}function O6(e){localStorage.setItem(Sv,JSON.stringify(e))}function bu(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 vu(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function wu(e){return e[Math.floor(Math.random()*e.length)]}function $6(e,n,a){const i=a.find(h=>h.id===e),o=a.find(h=>h.id===n);if(!i||!o)return null;const u=i.level==="c-level",d=o.level==="c-level";return u&&d?"c-level":i.reportsTo===n||o.reportsTo===e?"superior-subordinate":(i.reportsTo===o.reportsTo,"peer")}function L6(e,n){return e.relation==="any"?!0:e.relation===n}function I6({roles:e,roleStatuses:n,activeExecs:a,getStandupSpeech:i}){const[o,u]=w.useState(new Map),[d,h]=w.useState(B6),m=w.useRef({}),f=w.useRef(null),x=w.useRef(e),y=w.useRef(n),v=w.useRef(a),b=w.useRef(i),j=w.useRef(d);x.current=e,y.current=n,v.current=a,b.current=i,j.current=d,w.useEffect(()=>{const z=Date.now();for(const[U,B]of Object.entries(n))B==="working"&&(m.current[U]=z)},[n]),w.useEffect(()=>{O6(d)},[d]);const k=w.useCallback(z=>{const U=y.current[z],B=v.current.find(I=>I.roleId===z);if(U==="working"&&(B!=null&&B.task))return null;const $=b.current(z);if($&&Math.random()<.3)return{text:$,type:"work",ts:Date.now()};const q=Date.now(),L=m.current[z]??0;if(q-L>_6&&Math.random()<.5){const I=ag[z]??ag.engineer;return{text:wu(I),type:"guilt",ts:q}}const R=rg[z]??rg.engineer;return{text:wu(R),type:"personality",ts:q}},[]),C=w.useCallback(z=>{if(f.current)return!1;const U=z.filter(ae=>y.current[ae.id]!=="working");if(U.length<2)return!1;const B=[...U].sort(()=>Math.random()-.5),$=B[0],q=B[1],L=$6($.id,q.id,z);if(!L)return!1;const R=bu(j.current,$.id,q.id),I=vu(R),H=M6.filter(ae=>L6(ae,L)&&I>=ae.minFamiliarity);if(H.length===0)return!1;const Q=wu(H);let oe=$.id,re=q.id;Q.relation==="superior-subordinate"&&(q.reportsTo===$.id||$.level==="c-level"?(oe=$.id,re=q.id):(oe=q.id,re=$.id)),f.current={templateId:Q.id,roleA:oe,roleB:re,turnIdx:0,timer:null};const Y=ae=>{if(!f.current||ae>=Q.turns.length){f.current=null,h(F=>{const W=[...F],D=bu(W,oe,re);return D.conversations++,D.familiarity=vu(D),D.lastInteraction=new Date().toISOString(),W}),setTimeout(()=>{u(F=>{const W=new Map(F);return W.delete(oe),W.delete(re),W})},lg);return}const Z=Q.turns[ae],G=Z.speaker==="A"?oe:re,A=Z.speaker==="A"?re:oe;u(F=>{const W=new Map(F);if(W.set(G,{text:Z.text,type:"social",partnerId:A,ts:Date.now()}),ae>0){const D=Q.turns[ae-1].speaker==="A"?oe:re;D!==G&&W.delete(D)}return W}),f.current.turnIdx=ae,f.current.timer=setTimeout(()=>Y(ae+1),z6)};return Y(0),!0},[]);w.useEffect(()=>{const z=setInterval(()=>{const U=x.current;if(U.length===0||f.current||Math.random()<.35&&C(U))return;const B=U.filter(L=>y.current[L.id]!=="working");if(B.length===0)return;const $=wu(B),q=k($.id);q&&(u(L=>{const R=new Map(L);return R.set($.id,q),R}),setTimeout(()=>{u(L=>{const R=new Map(L),I=R.get($.id);return I&&I.ts===q.ts&&R.delete($.id),R})},lg))},R6);return()=>{var U;clearInterval(z),(U=f.current)!=null&&U.timer&&clearTimeout(f.current.timer)}},[k,C]);const N=w.useCallback(z=>{const U=o.get(z);return(U==null?void 0:U.text)??""},[o]),E=w.useCallback((z,U)=>{h(B=>{const $=[...B],q=bu($,z,U);return q.dispatches++,q.familiarity=vu(q),q.lastInteraction=new Date().toISOString(),$})},[]),_=w.useCallback(z=>{z.length<2||h(U=>{const B=[...U];for(let $=0;$<z.length;$++)for(let q=$+1;q<z.length;q++){const L=bu(B,z[$],z[q]);L.wavesTogether++,L.familiarity=vu(L),L.lastInteraction=new Date().toISOString()}return B})},[]);return{speeches:o,getSpeech:N,relationships:d,notifyDispatch:E,notifyWave:_}}const Cv="tycono:office-chat";let H6=0;function U6(){return`chat-${Date.now()}-${++H6}`}function Lh(){return[{id:"general",name:"#general",members:[],isDefault:!0,messages:[],topic:"Company-wide announcements and general discussion"},{id:"watercooler",name:"#watercooler",members:[],isDefault:!0,messages:[],topic:"No managers allowed. Vent, gossip, joke around. Talk freely about work frustrations, complain about directives you disagree with, share hot takes."}]}function q6(){try{const e=localStorage.getItem(Cv);if(e){const n=JSON.parse(e);if(n.find(i=>i.id==="office")&&!n.find(i=>i.id==="general")){const i=n.filter(o=>o.id!=="office");return[...Lh(),...i]}const a=Lh();for(const i of a)n.find(o=>o.id===i.id)||n.unshift(i);return n}}catch{}return Lh()}function Y6(e){const n=e.map(a=>({...a,messages:a.messages.slice(-200)}));localStorage.setItem(Cv,JSON.stringify(n))}function X6(){const[e,n]=w.useState(q6),[a,i]=w.useState(null),[o,u]=w.useState(new Set);w.useEffect(()=>{Y6(e)},[e]);const d=w.useCallback(b=>{i(b),b&&u(j=>{const k=new Set(j);return k.delete(b),k})},[]),h=w.useCallback(b=>{const j={...b,id:U6()};n(k=>{const C=k.map(N=>N.id==="general"?b.type==="dispatch"?{...N,messages:[...N.messages,j].slice(-200)}:N:b.channelId?N.id===b.channelId?{...N,messages:[...N.messages,j].slice(-200)}:N:N.members.length>0&&N.members.includes(b.roleId)?{...N,messages:[...N.messages,j].slice(-200)}:N);return u(N=>{const E=new Set(N);for(const _ of C){const z=k.find(U=>U.id===_.id);z&&_.messages.length>z.messages.length&&E.add(_.id)}return E}),C})},[]),m=w.useCallback((b,j,k)=>{const C=`ch-${Date.now()}`,N={id:C,name:b.startsWith("#")?b:`#${b}`,members:j,isDefault:!1,messages:[],topic:k};n(E=>[...E,N]),i(C)},[]),f=w.useCallback(b=>{n(j=>j.filter(k=>k.id!==b||k.isDefault)),i(j=>j===b?"general":j)},[]),x=w.useCallback((b,j)=>{n(k=>k.map(C=>C.id===b&&!C.isDefault?{...C,members:j}:C))},[]),y=w.useCallback((b,j)=>{n(k=>k.map(C=>C.id===b&&!C.isDefault?{...C,topic:j||void 0}:C))},[]),v=w.useCallback(b=>{n(j=>j.map(k=>{if(k.id==="watercooler"){const C=b.filter(N=>N.level!=="c-level").map(N=>N.id);if(k.members.length!==C.length||!C.every(N=>k.members.includes(N)))return{...k,members:C}}return k}))},[]);return{channels:e,activeChannelId:a,setActiveChannelId:d,pushMessage:h,createChannel:m,deleteChannel:f,updateMembers:x,updateTopic:y,unreadChannels:o,syncDefaultMembers:v}}const W6=45e3,ig=5e3,V6=4,G6=20;function K6({roles:e,roleStatuses:n,activeExecs:a,channels:i,relationships:o,pushMessage:u,speechSettings:d,engineType:h,hasApiKey:m}){const x=((d==null?void 0:d.mode)==="auto"?h==="claude-cli"||h==="local"?"llm":"template":(d==null?void 0:d.mode)??"template")==="llm"&&(m!==!1||h==="claude-cli"),y=((d==null?void 0:d.intervalSec)??W6/1e3)*1e3,v=w.useRef(e),b=w.useRef(n),j=w.useRef(a),k=w.useRef(i),C=w.useRef(o),N=w.useRef(u),E=w.useRef(0),_=w.useRef(!1);v.current=e,b.current=n,j.current=a,k.current=i,C.current=o,N.current=u;const z=w.useCallback(async($,q)=>{if(_.current)return!1;_.current=!0;try{if(!v.current.find(Y=>Y.id===$))return!1;const R=q.messages.slice(-G6).map(Y=>({roleId:Y.roleId,text:Y.text,ts:Y.ts})),I=v.current.filter(Y=>q.members.includes(Y.id)),H=C.current.filter(Y=>Y.roleA===$||Y.roleB===$).map(Y=>({partnerId:Y.roleA===$?Y.roleB:Y.roleA,familiarity:Y.familiarity})),Q=j.current.find(Y=>Y.roleId===$),oe=Q?{currentTask:Q.task,taskProgress:null}:{currentTask:null,taskProgress:null},re=await me.chatInChannel({channelId:q.name.replace("#",""),channelTopic:q.topic,roleId:$,history:R,members:I.map(Y=>({id:Y.id,name:Y.name,level:Y.level})),relationships:H,workContext:oe});return re.message?(N.current({ts:Date.now(),roleId:$,text:re.message,type:"chat",channelId:q.id}),!0):!1}catch{return!1}finally{_.current=!1}},[]),U=w.useCallback(async($,q)=>{if(E.current>=V6){E.current=0;return}const L=$.members.filter(Q=>Q!==q&&b.current[Q]!=="working");if(L.length===0){E.current=0;return}const R=L[Math.floor(Math.random()*L.length)];if(Math.random()>.7){E.current=0;return}const I=E.current*2e3,H=Math.random()*5e3;setTimeout(async()=>{E.current++;const Q=k.current.find(re=>re.id===$.id);if(!Q)return;if(await z(R,Q)){const re=.6-E.current*.1;Math.random()<re?U(Q,R):E.current=0}else E.current=0},ig+I+H)},[z]);return w.useEffect(()=>{if(!x)return;const $=setInterval(async()=>{const q=v.current;if(q.length===0||_.current)return;const L=q.filter(oe=>b.current[oe.id]!=="working");if(L.length===0)return;const R=L[Math.floor(Math.random()*L.length)],I=k.current.filter(oe=>oe.members.length===0?!0:oe.members.includes(R.id));if(I.length===0)return;const H=I[Math.floor(Math.random()*I.length)];E.current=0,await z(R.id,H)&&U(H,R.id)},y);return()=>clearInterval($)},[x,y,z,U]),{triggerCeoReaction:w.useCallback($=>{if(!x)return;const q=k.current.find(L=>L.id===$);q&&(E.current=0,setTimeout(()=>{U(q,"ceo")},ig))},[x,U])}}function ku({type:e,className:n}){const a=w.useRef(null),i=iC(e);return w.useEffect(()=>{const o=a.current;if(!o||!i)return;const u=o.getContext("2d");u&&oC(u,i)},[e,i]),i?l.jsx("canvas",{ref:a,width:i.canvasWidth,height:i.canvasHeight,className:n,style:{imageRendering:"pixelated",display:"block"}}):null}const Nv=[[1,8],[3,5],[8,1],[5,3]],Q6=[[1,4],[2,3],[4,1],[3,2]];function ju(e){const n=e===1||e===3?-1:0,a=Nv[e],i=e<2?[0,1]:[1,0],o=n;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:a[0],y:13,w:3,h:4,c:"$pants"},{x:a[1],y:13,w:3,h:4,c:"$pants"},{x:a[0]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:a[1]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:a[0],y:16,w:3,h:2,c:"$shoes"},{x:a[1],y:16,w:3,h:2,c:"$shoes"},{x:a[0],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:a[1],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:1,y:o+8,w:10,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.35},{x:1,y:o+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:10,y:o+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:-1,y:o+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:o+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:-1,y:o+12,w:2,h:1,c:"$skin"},{x:11,y:o+12,w:2,h:1,c:"$skin"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:1,y:o+0,w:10,h:7,c:"$skin"},{x:3,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:o+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:o+3,w:1,h:1,c:"#FFF",a:.4},{x:7,y:o+3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:o+6,w:2,h:1,c:"darken($skin, 25)",a:.35},{x:0,y:o+3,w:1,h:1,c:"$skin"},{x:11,y:o+3,w:1,h:1,c:"$skin"},{x:1,y:o+0,w:10,h:3,c:"$hair"},{x:0,y:o+1,w:2,h:3,c:"$hair"},{x:10,y:o+1,w:2,h:3,c:"$hair"},{x:2,y:o+0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]}function Su(e){const n=e===1||e===3?-1:0,a=Nv[e],i=e<2?[0,1]:[1,0],o=n;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:a[0],y:13,w:3,h:4,c:"$pants"},{x:a[1],y:13,w:3,h:4,c:"$pants"},{x:a[0],y:16,w:3,h:2,c:"$shoes"},{x:a[1],y:16,w:3,h:2,c:"$shoes"},{x:1,y:o+8,w:10,h:6,c:"$shirt"},{x:2,y:o+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:5,y:o+10,w:2,h:3,c:"darken($shirt, 30)",a:.12},{x:-1,y:o+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:o+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:4,y:o+6,w:4,h:3,c:"$skin"},{x:1,y:o+0,w:10,h:7,c:"$skin"},{x:1,y:o+0,w:10,h:6,c:"$hair"},{x:0,y:o+1,w:2,h:5,c:"$hair"},{x:10,y:o+1,w:2,h:5,c:"$hair"},{x:2,y:o+0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:0,y:o+4,w:1,h:1,c:"$skin",a:.6},{x:11,y:o+4,w:1,h:1,c:"$skin",a:.6}]}function $l(e,n){const a=e===1||e===3?-1:0,i=Q6[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 sg={down:[ju(0),ju(1),ju(2),ju(3)],up:[Su(0),Su(1),Su(2),Su(3)],right:[$l(0,!0),$l(1,!0),$l(2,!0),$l(3,!0)],left:[$l(0,!1),$l(1,!1),$l(2,!1),$l(3,!1)]},De="#FAFAF7",$n="#FFFFFF",Ae="#EDE8E2",Ve="#DDD6CC",Io="#1A1A2E",rd="#2A2A2A",tp="#FFB0B0",og=[{x:2,y:0,w:1,h:1,c:Ae},{x:3,y:0,w:1,h:1,c:De},{x:4,y:0,w:1,h:1,c:$n},{x:5,y:0,w:1,h:1,c:De},{x:6,y:0,w:1,h:1,c:Ae},{x:1,y:1,w:1,h:1,c:Ve},{x:2,y:1,w:1,h:1,c:De},{x:3,y:1,w:1,h:1,c:$n},{x:4,y:1,w:1,h:1,c:De},{x:5,y:1,w:1,h:1,c:$n},{x:6,y:1,w:1,h:1,c:De},{x:7,y:1,w:1,h:1,c:Ve},{x:0,y:2,w:1,h:1,c:Ve},{x:1,y:2,w:1,h:1,c:Ae},{x:2,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:De},{x:4,y:2,w:1,h:1,c:$n},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:De},{x:7,y:2,w:1,h:1,c:Ae},{x:8,y:2,w:1,h:1,c:Ve},{x:1,y:3,w:1,h:1,c:Ae},{x:2,y:3,w:1,h:1,c:De},{x:3,y:3,w:1,h:1,c:Io},{x:4,y:3,w:1,h:1,c:De},{x:5,y:3,w:1,h:1,c:Io},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:Ae},{x:2,y:4,w:1,h:1,c:Ae},{x:3,y:4,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:rd},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:Ae},{x:3,y:5,w:1,h:1,c:Ve},{x:4,y:5,w:1,h:1,c:Ae},{x:5,y:5,w:1,h:1,c:Ve},{x:2,y:6,w:1,h:1,c:Ae},{x:3,y:6,w:1,h:1,c:De},{x:4,y:6,w:1,h:1,c:$n},{x:5,y:6,w:1,h:1,c:De},{x:6,y:6,w:1,h:1,c:Ae},{x:2,y:7,w:1,h:1,c:Ve},{x:3,y:7,w:1,h:1,c:Ae},{x:4,y:7,w:1,h:1,c:De},{x:5,y:7,w:1,h:1,c:Ae},{x:6,y:7,w:1,h:1,c:Ve}],P6=[{x:3,y:8,w:1,h:1,c:Ae},{x:5,y:8,w:1,h:1,c:Ae},{x:3,y:9,w:1,h:1,c:Ve},{x:5,y:9,w:1,h:1,c:Ve}],Z6=[{x:2,y:8,w:1,h:1,c:Ae},{x:6,y:8,w:1,h:1,c:Ae},{x:2,y:9,w:1,h:1,c:Ve},{x:6,y:9,w:1,h:1,c:Ve}],cg=[{x:2,y:0,w:1,h:1,c:Ae},{x:3,y:0,w:1,h:1,c:De},{x:4,y:0,w:1,h:1,c:$n},{x:5,y:0,w:1,h:1,c:De},{x:6,y:0,w:1,h:1,c:Ae},{x:1,y:1,w:1,h:1,c:Ve},{x:2,y:1,w:1,h:1,c:Ae},{x:3,y:1,w:1,h:1,c:De},{x:4,y:1,w:1,h:1,c:$n},{x:5,y:1,w:1,h:1,c:De},{x:6,y:1,w:1,h:1,c:Ae},{x:7,y:1,w:1,h:1,c:Ve},{x:0,y:2,w:1,h:1,c:Ve},{x:1,y:2,w:1,h:1,c:Ae},{x:2,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:De},{x:4,y:2,w:1,h:1,c:De},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:De},{x:7,y:2,w:1,h:1,c:Ae},{x:8,y:2,w:1,h:1,c:Ve},{x:1,y:3,w:1,h:1,c:Ve},{x:2,y:3,w:1,h:1,c:Ae},{x:3,y:3,w:1,h:1,c:De},{x:4,y:3,w:1,h:1,c:De},{x:5,y:3,w:1,h:1,c:De},{x:6,y:3,w:1,h:1,c:Ae},{x:7,y:3,w:1,h:1,c:Ve},{x:2,y:4,w:1,h:1,c:Ve},{x:3,y:4,w:1,h:1,c:Ae},{x:4,y:4,w:1,h:1,c:De},{x:5,y:4,w:1,h:1,c:Ae},{x:6,y:4,w:1,h:1,c:Ve},{x:3,y:5,w:1,h:1,c:Ve},{x:4,y:5,w:1,h:1,c:Ae},{x:5,y:5,w:1,h:1,c:Ve},{x:2,y:6,w:1,h:1,c:Ae},{x:3,y:6,w:1,h:1,c:De},{x:4,y:6,w:1,h:1,c:De},{x:5,y:6,w:1,h:1,c:De},{x:6,y:6,w:1,h:1,c:Ae},{x:2,y:7,w:1,h:1,c:Ve},{x:3,y:7,w:1,h:1,c:Ae},{x:4,y:7,w:1,h:1,c:De},{x:5,y:7,w:1,h:1,c:Ae},{x:6,y:7,w:1,h:1,c:Ve},{x:4,y:5,w:1,h:1,c:De},{x:4,y:4,w:1,h:1,c:$n}],J6=[{x:3,y:8,w:1,h:1,c:Ae},{x:5,y:8,w:1,h:1,c:Ae},{x:3,y:9,w:1,h:1,c:Ve},{x:5,y:9,w:1,h:1,c:Ve}],eA=[{x:2,y:8,w:1,h:1,c:Ae},{x:6,y:8,w:1,h:1,c:Ae},{x:2,y:9,w:1,h:1,c:Ve},{x:6,y:9,w:1,h:1,c:Ve}],km=[{x:8,y:0,w:1,h:1,c:Ae},{x:9,y:0,w:1,h:1,c:De},{x:10,y:0,w:1,h:1,c:$n},{x:11,y:0,w:1,h:1,c:De},{x:7,y:1,w:1,h:1,c:Ve},{x:8,y:1,w:1,h:1,c:De},{x:9,y:1,w:1,h:1,c:$n},{x:10,y:1,w:1,h:1,c:De},{x:11,y:1,w:1,h:1,c:De},{x:12,y:1,w:1,h:1,c:Ae},{x:0,y:2,w:1,h:1,c:$n},{x:1,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:Ae},{x:4,y:2,w:1,h:1,c:De},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:De},{x:7,y:2,w:1,h:1,c:Ae},{x:8,y:2,w:1,h:1,c:De},{x:9,y:2,w:1,h:1,c:De},{x:10,y:2,w:1,h:1,c:De},{x:11,y:2,w:1,h:1,c:De},{x:12,y:2,w:1,h:1,c:Ae},{x:0,y:3,w:1,h:1,c:Ae},{x:1,y:3,w:1,h:1,c:Ve},{x:3,y:3,w:1,h:1,c:Ve},{x:4,y:3,w:1,h:1,c:Ae},{x:5,y:3,w:1,h:1,c:De},{x:6,y:3,w:1,h:1,c:Ae},{x:7,y:3,w:1,h:1,c:Ve},{x:8,y:3,w:1,h:1,c:De},{x:9,y:3,w:1,h:1,c:Io},{x:10,y:3,w:1,h:1,c:De},{x:11,y:3,w:1,h:1,c:Ae},{x:3,y:4,w:1,h:1,c:Ve},{x:4,y:4,w:1,h:1,c:Ae},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:Ae},{x:8,y:4,w:1,h:1,c:Ae},{x:9,y:4,w:1,h:1,c:De},{x:10,y:4,w:1,h:1,c:rd}],Ev=[{x:4,y:5,w:1,h:1,c:Ae},{x:6,y:5,w:1,h:1,c:Ae},{x:8,y:5,w:1,h:1,c:Ae},{x:10,y:5,w:1,h:1,c:Ae},{x:4,y:6,w:1,h:1,c:Ve},{x:6,y:6,w:1,h:1,c:Ve},{x:8,y:6,w:1,h:1,c:Ve},{x:10,y:6,w:1,h:1,c:Ve}],Av=[{x:3,y:5,w:1,h:1,c:Ae},{x:5,y:5,w:1,h:1,c:Ae},{x:9,y:5,w:1,h:1,c:Ae},{x:11,y:5,w:1,h:1,c:Ae},{x:3,y:6,w:1,h:1,c:Ve},{x:5,y:6,w:1,h:1,c:Ve},{x:9,y:6,w:1,h:1,c:Ve},{x:11,y:6,w:1,h:1,c:Ve}];function np(e,n=13){return e.map(a=>({...a,x:n-1-a.x}))}const ug=np(km),tA=np(Ev),nA=np(Av),rA={down:[[...og,...P6],[...og,...Z6]],up:[[...cg,...J6],[...cg,...eA]],right:[[...km,...Ev],[...km,...Av]],left:[[...ug,...tA],[...ug,...nA]]},aA=[{x:4,y:5,w:1,h:1,c:tp}],Fn="#FFD4D4",Qr="#FFCCD5",lA=[{x:2,y:0,w:1,h:1,c:Ve},{x:3,y:0,w:1,h:1,c:Ae},{x:4,y:0,w:1,h:1,c:De},{x:5,y:0,w:1,h:1,c:$n},{x:6,y:0,w:1,h:1,c:Ae},{x:7,y:0,w:1,h:1,c:Ve},{x:1,y:1,w:1,h:1,c:Ve},{x:2,y:1,w:1,h:1,c:Ae},{x:3,y:1,w:1,h:1,c:De},{x:4,y:1,w:1,h:1,c:$n},{x:5,y:1,w:1,h:1,c:De},{x:6,y:1,w:1,h:1,c:$n},{x:7,y:1,w:1,h:1,c:Ae},{x:8,y:1,w:1,h:1,c:Ve},{x:1,y:2,w:1,h:1,c:Ae},{x:2,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:Io},{x:4,y:2,w:1,h:1,c:De},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:Io},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:Ae},{x:2,y:3,w:1,h:1,c:Ae},{x:3,y:3,w:1,h:1,c:De},{x:4,y:3,w:1,h:1,c:rd},{x:5,y:3,w:1,h:1,c:tp},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:Ae},{x:2,y:4,w:1,h:1,c:Ve},{x:3,y:4,w:1,h:1,c:Ae},{x:4,y:4,w:1,h:1,c:De},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:Ae},{x:7,y:4,w:1,h:1,c:Ve},{x:0,y:5,w:1,h:1,c:Ae},{x:1,y:5,w:1,h:1,c:Qr},{x:2,y:5,w:1,h:1,c:De},{x:3,y:5,w:1,h:1,c:Fn},{x:4,y:5,w:1,h:1,c:Fn},{x:5,y:5,w:1,h:1,c:Fn},{x:6,y:5,w:1,h:1,c:Fn},{x:7,y:5,w:1,h:1,c:De},{x:8,y:5,w:1,h:1,c:Qr},{x:9,y:5,w:1,h:1,c:Ae},{x:1,y:6,w:1,h:1,c:Ae},{x:2,y:6,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:Fn},{x:4,y:6,w:1,h:1,c:Qr},{x:5,y:6,w:1,h:1,c:Qr},{x:6,y:6,w:1,h:1,c:Fn},{x:7,y:6,w:1,h:1,c:De},{x:8,y:6,w:1,h:1,c:Ae},{x:2,y:7,w:1,h:1,c:De},{x:3,y:7,w:1,h:1,c:Fn},{x:4,y:7,w:1,h:1,c:Fn},{x:5,y:7,w:1,h:1,c:Fn},{x:6,y:7,w:1,h:1,c:Fn},{x:7,y:7,w:1,h:1,c:De},{x:0,y:8,w:1,h:1,c:Ae},{x:1,y:8,w:1,h:1,c:Qr},{x:2,y:8,w:1,h:1,c:Ve},{x:3,y:8,w:1,h:1,c:Ae},{x:4,y:8,w:1,h:1,c:De},{x:5,y:8,w:1,h:1,c:De},{x:6,y:8,w:1,h:1,c:Ae},{x:7,y:8,w:1,h:1,c:Ve},{x:8,y:8,w:1,h:1,c:Qr},{x:9,y:8,w:1,h:1,c:Ae},{x:4,y:9,w:1,h:1,c:De},{x:5,y:9,w:1,h:1,c:$n}],iA=[{x:2,y:0,w:1,h:1,c:Ve},{x:3,y:0,w:1,h:1,c:Ae},{x:4,y:0,w:1,h:1,c:De},{x:5,y:0,w:1,h:1,c:$n},{x:6,y:0,w:1,h:1,c:Ae},{x:7,y:0,w:1,h:1,c:Ve},{x:1,y:1,w:1,h:1,c:Ve},{x:2,y:1,w:1,h:1,c:Ae},{x:3,y:1,w:1,h:1,c:De},{x:4,y:1,w:1,h:1,c:$n},{x:5,y:1,w:1,h:1,c:De},{x:6,y:1,w:1,h:1,c:$n},{x:7,y:1,w:1,h:1,c:Ae},{x:8,y:1,w:1,h:1,c:Ve},{x:1,y:2,w:1,h:1,c:Ae},{x:2,y:2,w:1,h:1,c:De},{x:3,y:2,w:1,h:1,c:Ae},{x:4,y:2,w:1,h:1,c:De},{x:5,y:2,w:1,h:1,c:De},{x:6,y:2,w:1,h:1,c:Ae},{x:7,y:2,w:1,h:1,c:De},{x:8,y:2,w:1,h:1,c:Ae},{x:2,y:3,w:1,h:1,c:Ae},{x:3,y:3,w:1,h:1,c:De},{x:4,y:3,w:1,h:1,c:rd},{x:5,y:3,w:1,h:1,c:tp},{x:6,y:3,w:1,h:1,c:De},{x:7,y:3,w:1,h:1,c:Ae},{x:2,y:4,w:1,h:1,c:Ve},{x:3,y:4,w:1,h:1,c:Ae},{x:4,y:4,w:1,h:1,c:De},{x:5,y:4,w:1,h:1,c:De},{x:6,y:4,w:1,h:1,c:Ae},{x:7,y:4,w:1,h:1,c:Ve},{x:0,y:5,w:1,h:1,c:Ae},{x:1,y:5,w:1,h:1,c:Qr},{x:2,y:5,w:1,h:1,c:De},{x:3,y:5,w:1,h:1,c:Fn},{x:4,y:5,w:1,h:1,c:Fn},{x:5,y:5,w:1,h:1,c:Fn},{x:6,y:5,w:1,h:1,c:Fn},{x:7,y:5,w:1,h:1,c:De},{x:8,y:5,w:1,h:1,c:Qr},{x:9,y:5,w:1,h:1,c:Ae},{x:1,y:6,w:1,h:1,c:Ae},{x:2,y:6,w:1,h:1,c:De},{x:3,y:6,w:1,h:1,c:Fn},{x:4,y:6,w:1,h:1,c:Qr},{x:5,y:6,w:1,h:1,c:Qr},{x:6,y:6,w:1,h:1,c:Fn},{x:7,y:6,w:1,h:1,c:De},{x:8,y:6,w:1,h:1,c:Ae},{x:2,y:7,w:1,h:1,c:De},{x:3,y:7,w:1,h:1,c:Fn},{x:4,y:7,w:1,h:1,c:Fn},{x:5,y:7,w:1,h:1,c:Fn},{x:6,y:7,w:1,h:1,c:Fn},{x:7,y:7,w:1,h:1,c:De},{x:0,y:8,w:1,h:1,c:Ae},{x:1,y:8,w:1,h:1,c:Qr},{x:2,y:8,w:1,h:1,c:Ve},{x:3,y:8,w:1,h:1,c:Ae},{x:4,y:8,w:1,h:1,c:De},{x:5,y:8,w:1,h:1,c:De},{x:6,y:8,w:1,h:1,c:Ae},{x:7,y:8,w:1,h:1,c:Ve},{x:8,y:8,w:1,h:1,c:Qr},{x:9,y:8,w:1,h:1,c:Ae},{x:5,y:9,w:1,h:1,c:De},{x:6,y:9,w:1,h:1,c:$n}],sA=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],oA=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],cA=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],lt=4,Jt=28,On=2,Ft=4,vt=4,tl=[{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 rp(e,n,a){const u=e.fy+Math.max(10,Math.floor(e.fh*.18)),d=Math.min(n,a),h=Math.ceil(n/d),m=[],f=d*28,x=e.fx+Math.max(8,Math.floor((e.fw-f)/2));for(let y=0;y<h&&m.length<n;y++){const v=Math.min(d,n-y*d);for(let b=0;b<v;b++)m.push({dx:x+b*28,dy:u+y*28,room:e.id})}return m}function uA(e){const i=tl[0],o={id:"main",wx:lt+vt,wy:lt,ww:160-2*(lt+vt),wh:Jt,fx:lt+vt,fy:lt+Jt+On,fw:160-2*(lt+vt),fh:120-lt-Jt-On-lt,...i},u=rp(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*(lt+vt))/2),offsetY:10}],h=[{id:"s-plant-l",type:"plant",room:"main",zone:"floor",offsetX:4,offsetY:4},{id:"s-plant-r",type:"plant",room:"main",zone:"floor",anchorX:"right",offsetX:-8,offsetY:4}];return{preset:"S",canvasW:160,canvasH:120,rooms:{main:o},desks:u,doors:{},adjacency:{main:[]},corridorY:{main:o.fy+o.fh-12},waypoints:{main:[{x:o.fx+10,y:o.fy+o.fh-14},{x:o.fx+o.fw/2,y:o.fy+o.fh-14},{x:o.fx+o.fw-10,y:o.fy+o.fh-14}]},wallDecorations:d,furniture:h}}function dA(e){const o={id:"exec",wx:lt+vt,wy:lt,ww:144-lt-vt-Ft/2,wh:Jt,fx:lt+vt,fy:lt+Jt+On,fw:144-lt-vt-Ft/2,fh:66,...tl[0]},u={id:"work",wx:144+Ft/2+vt,wy:lt,ww:144-Ft/2-vt-lt,wh:Jt,fx:144+Ft/2+vt,fy:lt+Jt+On,fw:144-Ft/2-vt-lt,fh:66,...tl[1]},d={id:"meet",wx:lt+vt,wy:lt+Jt+On+66+Ft,ww:144-lt-vt-Ft/2,wh:Jt,fx:lt+vt,fy:lt+Jt+On+66+Ft+Jt+On,fw:144-lt-vt-Ft/2,fh:70,...tl[2]},h={id:"comm",wx:144+Ft/2+vt,wy:lt+Jt+On+66+Ft,ww:144-Ft/2-vt-lt,wh:Jt,fx:144+Ft/2+vt,fy:lt+Jt+On+66+Ft+Jt+On,fw:144-Ft/2-vt-lt,fh:70,...tl[3]},m={exec:o,work:u,meet:d,comm:h},f=[];let x=e;const y=[[o,Math.min(3,x)],[u,0]];y[1][1]=Math.min(3,x-y[0][1]);const v=[[d,0],[h,0]];let b=x-y[0][1]-y[1][1];b>0&&(v[0][1]=Math.min(2,b),b-=v[0][1]),b>0&&(v[1][1]=Math.min(2,b));for(const[B,$]of[...y,...v])$>0&&f.push(...rp(B,$,3));const j=lt+Jt+On+66,k=144-Ft/2,C={exec_work:{id:"exec_work",type:"v",doorY:lt+Jt+On+20+12,xA:k-2,xB:u.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:lt+Jt+On+66+Ft+Jt+On+20+12,xA:k-2,xB:h.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:lt+vt+40+14,yA:j-2,yB:d.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+Ft/2+vt+40+14,yA:j-2,yB:h.fy+2}},N={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},E={exec:o.fy+52,work:u.fy+48,meet:d.fy+56,comm:h.fy+42},_={exec:[{x:o.fx+6,y:o.fy+52},{x:o.fx+60,y:o.fy+54},{x:o.fx+112,y:o.fy+50},{x:o.fx+50,y:o.fy+52}],work:[{x:u.fx+14,y:u.fy+48},{x:u.fx+44,y:u.fy+48},{x:u.fx+70,y:u.fy+48},{x:u.fx+100,y:u.fy+48}],meet:[{x:d.fx+60,y:d.fy+56},{x:d.fx+30,y:d.fy+54},{x:d.fx+110,y:d.fy+50},{x:d.fx+80,y:d.fy+56}],comm:[{x:h.fx+96,y:h.fy+8},{x:h.fx+60,y:h.fy+42},{x:h.fx+40,y:h.fy+42},{x:h.fx+20,y:h.fy+42}]},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}],U=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(o.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:42,facility:{id:"meeting",label:"MEETING",icon:"๐ข",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"๐",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"M",canvasW:288,canvasH:208,rooms:m,desks:f,doors:C,adjacency:N,corridorY:E,waypoints:_,wallDecorations:z,furniture:U}}function fA(e){const d={id:"exec",wx:lt+vt,wy:lt,ww:180-lt-vt-Ft/2,wh:Jt,fx:lt+vt,fy:lt+Jt+On,fw:180-lt-vt-Ft/2,fh:82,...tl[0]},h={id:"work",wx:180+Ft/2+vt,wy:lt,ww:180-Ft/2-vt-lt,wh:Jt,fx:180+Ft/2+vt,fy:lt+Jt+On,fw:180-Ft/2-vt-lt,fh:82,...tl[1]},m=lt+Jt+On+82,f={id:"meet",wx:lt+vt,wy:m+Ft,ww:180-lt-vt-Ft/2,wh:Jt,fx:lt+vt,fy:m+Ft+Jt+On,fw:180-lt-vt-Ft/2,fh:86,...tl[2]},x={id:"comm",wx:180+Ft/2+vt,wy:m+Ft,ww:180-Ft/2-vt-lt,wh:Jt,fx:180+Ft/2+vt,fy:m+Ft+Jt+On,fw:180-Ft/2-vt-lt,fh:86,...tl[3]},y={exec:d,work:h,meet:f,comm:x},v=[];let b=e;const j=[[d,Math.min(5,b)],[h,0]];j[1][1]=Math.min(5,b-j[0][1]);const k=[[f,0],[x,0]];let C=b-j[0][1]-j[1][1];C>0&&(k[0][1]=Math.min(3,C),C-=k[0][1]),C>0&&(k[1][1]=Math.min(3,C));for(const[q,L]of[...j,...k])L>0&&v.push(...rp(q,L,4));const N=180-Ft/2,E={exec_work:{id:"exec_work",type:"v",doorY:d.fy+82/2,xA:N-2,xB:h.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:f.fy+86/2,xA:N-2,xB:x.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:d.fx+54,yA:m-2,yB:f.fy+2},work_comm:{id:"work_comm",type:"h",doorX:h.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:h.fy+82-12,meet:f.fy+86-12,comm:x.fy+86-12},U={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:h.fx+10,y:z.work},{x:h.fx+h.fw/2,y:z.work},{x:h.fx+h.fw-10,y:z.work}],meet:[{x:f.fx+10,y:z.meet},{x:f.fx+f.fw/2,y:z.meet},{x:f.fx+f.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}]},B=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0",facility:{id:"theme",label:"THEME",icon:"๐จ",color:"#42A5F5",hitW:12,hitH:10}},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10,facility:{id:"settings",label:"SETTINGS",icon:"โ",color:"#78909C",hitW:10,hitH:10}},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:14,facility:{id:"stats",label:"STATS",icon:"๐",color:"#7E57C2",hitW:16,hitH:8}},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"๐",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"๐",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],$=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(d.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:42,facility:{id:"meeting",label:"MEETING",icon:"๐ข",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"๐",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"L",canvasW:360,canvasH:260,rooms:y,desks:v,doors:E,adjacency:_,corridorY:z,waypoints:U,wallDecorations:B,furniture:$}}const hA=2;function Dv(e,n){return n?n==="L"&&e<=12-hA?"M":n==="M"&&e>12?"L":n:e<=12?"M":"L"}function Tv(e,n){switch(n??Dv(e)){case"S":return uA(e);case"M":return dA(e);case"L":return fA(e)}}function dg(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 fg(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 Ih(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 hg(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 Mo;function mA(e){Mo=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&&(Mo.globalAlpha=u),Mo.fillStyle=o,Mo.fillRect(e,n,a,i),u!==void 0&&u!==1&&(Mo.globalAlpha=1))}function nt(e,n,a,i){O(e,n,1,1,a,i)}let zu=1;function As(e){zu=e}function Ea(){return zu=zu*16807%2147483647,(zu&65535)/65535}function Fv(e){const n=parseInt(e.slice(1,3),16)/255,a=parseInt(e.slice(3,5),16)/255,i=parseInt(e.slice(5,7),16)/255,o=Math.max(n,a,i),u=Math.min(n,a,i);let d=0,h=0;const m=(o+u)/2;if(o!==u){const f=o-u;h=m>.5?f/(2-o-u):f/(o+u),o===n?d=((a-i)/f+(a<i?6:0))/6:o===a?d=((i-n)/f+2)/6:d=((n-a)/f+4)/6}return[d*360,h*100,m*100]}function Mv(e,n,a){e=(e%360+360)%360,n=Math.max(0,Math.min(100,n))/100,a=Math.max(0,Math.min(100,a))/100;const i=n*Math.min(a,1-a),o=d=>{const h=(d+e/30)%12;return a-i*Math.max(-1,Math.min(h-3,9-h,1))},u=d=>Math.round(d*255).toString(16).padStart(2,"0");return"#"+u(o(0))+u(o(8))+u(o(4))}function Aa(e,n=1){const[a,i,o]=Fv(e);return Mv(a+15*n,Math.min(100,i+8),o-12*n)}function dn(e,n=1){const[a,i,o]=Fv(e);return Mv(a-10*n,i-3,o+10*n)}const Bn={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},_r={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},ja={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),nt(e+3,n+3,"#8AB8E8",.35),nt(e+o+2,n+3,"#8AB8E8",.25),O(e-1,n+i,a+2,2,"#5A4838"),O(e-1,n+i,a+2,1,dn("#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,dn(a,1.2),.3),nt(e+3,n+2,dn(a,2),.25)}function yA(e,n){O(e,n,7,7,"#3A2818"),O(e+1,n+1,5,5,"#F0EDE5"),nt(e+3,n+1,"#AAA"),nt(e+3,n+5,"#AAA"),nt(e+1,n+3,"#AAA"),nt(e+5,n+3,"#AAA"),nt(e+3,n+3,"#222"),O(e+3,n+1,1,2,"#333"),nt(e+4,n+3,"#D32F2F")}function gA(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"),As(88);for(let a=0;a<14;a++)for(let i=0;i<20;i++)Ea()>.5&&nt(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"),nt(e+4,n+2,"#E53935"),nt(e+10,n+2,"#1E88E5"),nt(e+16,n+3,"#FF9800")}function vA(e,n){O(e,n,20,3,"#5A4030"),O(e,n,20,1,dn("#5A4030",.5),.35),O(e,n+2,20,1,Aa("#5A4030",.5),.3),O(e+2,n-4,3,4,"#E53935"),O(e+2,n-4,3,1,dn("#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"),nt(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),nt(e+2,n+4,"#4CAF50"),O(e+4,n+4,7,1,"#8b949e",.4),nt(e+2,n+6,"#FF9800"),O(e+4,n+6,5,1,"#8b949e",.3),nt(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,dn(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,dn(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,Aa("#A06E48",.3)),O(e+2,n+7,6,1,dn("#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"),nt(e+4,n,"#81C784"),nt(e+3,n+1,"#A5D6A7",.4)}function SA(e,n){wi(e+4,n-4,"down"),wi(e+16,n-4,"down"),wi(e+28,n-4,"down"),O(e+3,n+24,34,3,Pr,.15),O(e,n+2,36,18,Bn.deep),O(e+1,n+3,34,16,Bn.base),O(e+1,n+3,34,1,Bn.hi,.35);for(let a=0;a<14;a+=3)O(e+1,n+4+a,34,1,Aa(Bn.base,.2),.08);O(e,n+20,36,4,Bn.deep),O(e+1,n+21,34,2,Bn.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"),nt(e+16,n+8,"#795548"),wi(e+4,n+24,"up"),wi(e+16,n+24,"up"),wi(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,dn("#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,dn("#6D4C41",.5),.35),O(e+19,n+6,15,6,"#6D4C41"),O(e+20,n+6,13,1,dn("#6D4C41",.5),.35),O(e+17,n+6,2,6,"#5D4037"),O(e,n+13,36,3,Aa("#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,dn("#FF8A65",1),.35)}function NA(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"),nt(e+14,n+4,"#795548")}function EA(e,n){O(e+1,n+14,10,2,Pr,.12),O(e,n,10,14,"#546E7A"),O(e,n,10,1,dn("#546E7A",1),.35),O(e+1,n+1,8,3,"#78909C"),O(e+1,n+5,8,4,"#37474F"),nt(e+2,n+6,"#EF5350"),nt(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"),nt(e+12,n+5,"#FF5722"),O(e+16,n+8,3,2,"#FFD54F"),nt(e+15,n+8,"#FFC107"),nt(e+13,n+3,"#90CAF9",.5),nt(e+14,n+4,"#BBDEFB",.35),nt(e+8,n+3,"#BBDEFB",.3),O(e,n+16,28,2,"#455A64"),O(e+1,n+16,26,1,dn("#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"),nt(e+6,n+7,"#81C784"),O(e+1,n+14,14,6,"#1A237E"),O(e+2,n+15,4,4,"#212121"),nt(e+4,n+16,"#F44336"),nt(e+9,n+16,"#F44336"),nt(e+11,n+16,"#2196F3"),nt(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"),nt(e+5,n+3,"#FFF176",.5),O(e+13,n+4,4,4,"#B0BEC5"),O(e+14,n+3,2,1,"#CFD8DC"),nt(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,Bn.deep),O(e+1,n+1,24,8,Bn.base),O(e+1,n+2,24,1,Bn.hi,.2),O(e+1,n+4,24,1,Aa(Bn.base,.2),.1),O(e+1,n+6,24,1,Bn.hi,.15),O(e+1,n+1,24,1,Bn.hi,.4),O(e+1,n+1,1,8,Bn.hi,.2),O(e,n+10,26,5,Bn.deep),O(e+1,n+11,24,3,Bn.sh),O(e+1,n+10,24,1,Aa(Bn.base,1.5),.4),O(e+1,n+14,24,1,Bn.base,.15),O(e+2,n+12,10,1,Bn.deep,.4),O(e+14,n+12,10,1,Bn.deep,.4),nt(e+7,n+11,"#C8D0D8",.6),nt(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),nt(e+7,n-4,"#4A98D8",.25),nt(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++)nt(e+7+a*2,n+5,"#444",.6),nt(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"),nt(e+2,n+5,"#6D4C41")}function wi(e,n,a){O(e+1,n+9,10,2,Pr,.1),nt(e+5,n+9,"#1E1E22"),nt(e+1,n+10,"#1A1A1E"),nt(e+9,n+10,"#1A1A1E"),nt(e+3,n+11,"#1A1A1E"),nt(e+7,n+11,"#1A1A1E"),O(e+1,n+2,8,6,ja.base),O(e+2,n+3,6,4,ja.hi,.35),O(e+2,n+3,6,1,dn(ja.hi,.5),.25),O(e+1,n+7,8,1,ja.deep),a==="up"?(O(e,n+7,10,3,ja.deep),O(e+1,n+8,8,1,ja.sh)):(O(e,n-1,10,3,ja.deep),O(e+1,n,8,1,ja.sh)),O(e,n+3,1,4,ja.sh),O(e+9,n+3,1,4,ja.sh)}const Rv={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)=>NA(e,n),"coffee-machine":(e,n)=>EA(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)=>yA(e,n),whiteboard:(e,n)=>gA(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 js(e,n){const a=e.zone==="wall"?n.wx:n.fx,i=e.zone==="wall"?n.wy:n.fy;return{x:e.anchorX==="right"?(e.zone==="wall"?n.wx+n.ww:n.fx+n.fw)+e.offsetX:a+e.offsetX,y:i+e.offsetY}}function zA(e){for(const n of e.wallDecorations){const a=e.rooms[n.room];if(!a)continue;const{x:i,y:o}=js(n,a),u=Rv[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}=js(i,o),h=Rv[i.type];h&&n.push({y:d,draw:()=>h(u,d,i)})}}function Il(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}=js(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 jm(e){return BA[e]??{w:16,h:16}}function Hh(e,n,a,i){for(let o=e.furniture.length-1;o>=0;o--){const u=e.furniture[o],d=e.rooms[u.room];if(!d||u.condition==="no-desks"&&i.has(u.room))continue;const{x:h,y:m}=js(u,d),f=jm(u.type);if(n>=h&&n<=h+f.w&&a>=m&&a<=m+f.h)return u.id}for(let o=e.wallDecorations.length-1;o>=0;o--){const u=e.wallDecorations[o],d=e.rooms[u.room];if(!d)continue;const{x:h,y:m}=js(u,d),f=jm(u.type);if(n>=h&&n<=h+f.w&&a>=m&&a<=m+f.h)return u.id}return null}function mg(e,n,a,i,o){const d=[...n.wallDecorations,...n.furniture].find(y=>y.id===a);if(!d||d.condition==="no-desks"&&o.has(d.room))return;const h=n.rooms[d.room];if(!h)return;const{x:m,y:f}=js(d,h),x=jm(d.type);e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(m-1,f-1,x.w+2,x.h+2),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(m-.5,f-.5,x.w+1,x.h+1),e.restore()}function pg(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 xg(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 yg=[{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}],Cu=16,OA=4,vi=4,_u=2,Lt=4,Ul=4;let Ie=Tv(7);const Gu={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},gg={ceo:["๋ํ๋?","๋ฌด์จ ์ผ์ด์ ๊ฐ์?","ํ์ ์๊ฐ์ด์ ๊ฐ์?","์ข์ ์์ด๋์ด ์์ผ์๋ฉด ๋ง์ํด์ฃผ์ธ์.","๋ค๋ค ์ํ๊ณ ์๋์?"],cto:["๋ญ ํ์ํ์ ๊ฑฐ ์์ผ์ธ์?","๊ธฐ์ ๊ด๋ จ ์ง๋ฌธ์ด์ ๊ฐ์?","์ํคํ
์ฒ ๋ฆฌ๋ทฐ ์ค์ด์์.","๋ฐฐํฌ๋ ์กฐ๊ธ๋ง ๊ธฐ๋ค๋ ค์ฃผ์ธ์.","์ฝ๋ ๋ด๋๋ฆด๊น์?"],cbo:["๋น์ฆ๋์ค ๊ด๋ จ ์๊ธฐ์ ๊ฐ์?","์์ต ๋ชจ๋ธ ๊ฒํ ์ค์ด์์.","์์ฅ ์กฐ์ฌ ๊ฒฐ๊ณผ ๋ณด์ค๋์?","๊ฒฝ์์ฌ ๋ถ์ ์ค์
๋๋ค.","๋ญ๊ฐ ๋์๋๋ฆด๊น์?"],pm:["ํ๋ก์ ํธ ์งํ ์ํฉ ๊ถ๊ธํ์ ๊ฐ์?","๋ก๋๋งต ์
๋ฐ์ดํธ ์ค์ด์์.","ํ์คํฌ ํ ๋น ์ค์
๋๋ค.","์ฐ์ ์์ ์กฐ์ ์ด ํ์ํ ๊น์?","์คํ๋ฆฐํธ ๋ฆฌ๋ทฐ ์ค๋น ์ค์ด์์."],engineer:["์ผํ๊ณ ์์ด์!","๋ฒ๊ทธ ์์ ์ค์
๋๋ค.","์ฝ๋ ๋ฆฌ๋ทฐ ํ์ํ์ ๊ฐ์?","ํ
์คํธ ์์ฑ ์ค์ด์์.","PR ์ฌ๋ฆฌ๊ณ ์์ด์."],designer:["๋์์ธ ํผ๋๋ฐฑ ์์ผ์ ๊ฐ์?","๋ชฉ์
์์
์ค์ด์์.","UI ๊ฐ์ ์ ์๊ฐ ์ค์
๋๋ค.","์ปฌ๋ฌ ํ๋ ํธ ๊ณ ๋ฏผ ์ค์ด์์.","ํ๋กํ ํ์
๋ณด์ฌ๋๋ฆด๊น์?"],qa:["ํ
์คํธ ์ค์ด์์.","๋ฒ๊ทธ ๋ฐ๊ฒฌํ์ด์!","ํ
์คํธ ์ผ์ด์ค ์์ฑ ์ค์
๋๋ค.","ํ๊ท ํ
์คํธ ์งํ ์ค์ด์์.","ํ์ง ์ฒดํฌ ์ค์
๋๋ค."],"data-analyst":["๋ฐ์ดํฐ ๋ถ์ ์ค์ด์์.","๋ฆฌํฌํธ ์ค๋น ์ค์
๋๋ค.","๋์๋ณด๋ ํ์ธํด๋ณด์ค๋์?","์งํ ์ถ์ ์ค์ด์์.","์ธ์ฌ์ดํธ ๋ฐ๊ฒฌํ์ด์!"],default:["์๋
ํ์ธ์!","๋ฌด์์ ๋์๋๋ฆด๊น์?","์ด์ฌํ ์ผํ๊ณ ์์ด์.","์ข์ ํ๋ฃจ ๋์ธ์!"]};let ia=Il(Ie);function zv(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function _v(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let on={};function $A(e){const n={};for(let a=0;a<e.length&&a<Ie.desks.length;a++)n[e[a]]=Ie.desks[a];return n}let Ue,Qn=null,ki=null,Ja=!1,oa=null,Rr=null,Bv=0,Jn=null,_n=null,Ll=null,Sa=null,Uh=900;function LA(e,n){const{wx:a,wy:i,ww:o,wh:u,wallColor:d,baseboardColor:h}=e,m=Aa(d,.5),f=dn(d,.5),x=[];if(n){const y=n.x-a,v=n.w;y>0&&x.push({sx:a,sw:y}),y+v<o&&x.push({sx:n.x+v,sw:o-y-v})}else x.push({sx:a,sw:o});for(const y of x){O(y.sx,i,y.sw,u,d);for(let v=0;v<u;v+=4)O(y.sx,i+v,y.sw,1,f,.08),O(y.sx,i+v+2,y.sw,1,m,.05);As(Math.round(y.sx*7+i*13));for(let v=0;v<y.sw;v+=3)Ea()>.4&&O(y.sx+v,i,1,u,f,.04);O(y.sx,i,y.sw,2,f,.3),O(y.sx,i,y.sw,1,dn(d,1),.2),O(y.sx,i+u-2,y.sw,2,m,.3),O(y.sx,i+u,y.sw,_u,h),O(y.sx,i+u,y.sw,1,dn(h,.5),.4)}n&&(O(n.x-1,i,1,u+_u,"#4A3828"),O(n.x+n.w,i,1,u+_u,"#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 IA(e){const n="#504038",a=Aa(n,.5),i=dn(n,.5),o=e.wx-Ul,u=e.wy,d=e.wh+_u+e.fh;O(o,u,Ul,d,n),O(o,u,1,d,i,.3),O(o+Ul-1,u,1,d,a,.4);for(let m=0;m<d;m+=6)O(o+1,u+m,Ul-2,1,i,.06);const h=e.wx+e.ww;O(h,u,Ul,d,n),O(h,u,1,d,i,.2),O(h+Ul-1,u,1,d,a,.3)}function qh(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#B08040",d="#C89848",h="#8A6030",m="#6A4820";O(n,a,i,o,u),As(42);for(let f=0;f<o;f+=5){const x=Math.floor(f/5)%2*10;for(let y=-10;y<i+10;y+=20){const v=n+y+x,b=Math.max(n,v),j=Math.min(v+19,n+i)-b;if(j<=0)continue;const k=Ea()>.5?d:u;O(b,a+f,j,4,k,.25),O(b,a+f,j,1,d,.3),O(b,a+f+4,j,1,m,.35),v>=n&&v<n+i&&O(v,a+f,1,4,m,.2),O(b,a+f+2,j,1,h,.1)}}O(n,a,i,2,"#0A0808",.08),O(n,a,2,o,"#0A0808",.06)}function bg(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#1C2A38",d="#101820";As(99),O(n,a,i,o,u);for(let h=0;h<o;h+=Cu)for(let m=0;m<i;m+=Cu){const f=Math.min(Cu,i-m),x=Math.min(Cu,o-h);Ea()>.5&&O(n+m,a+h,f,x,dn(u,.2),.15),O(n+m+2,a+h+2,f-4,x-4,dn(u,.3),.08),O(n+m,a+h,f,1,d,.5),O(n+m,a+h,1,x,d,.5),O(n+m+1,a+h+1,1,x-1,dn(u,.4),.1),Ea()>.85&&nt(n+m+4+Math.floor(Ea()*8),a+h+4+Math.floor(Ea()*8),"#3A6A9A",.08)}}function HA(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#387848",d="#4A9058",h="#285E38";O(n,a,i,o,u),As(77);for(let f=0;f<o;f+=2)for(let x=0;x<i;x+=2)Ea()>.5&&nt(n+x,a+f,d,.1),Ea()>.8&&nt(n+x+1,a+f+1,h,.12);const m=5;O(n+m,a+m,i-m*2,1,d,.45),O(n+m,a+o-m-1,i-m*2,1,h,.45),O(n+m,a+m,1,o-m*2,d,.35),O(n+i-m-1,a+m,1,o-m*2,h,.35)}function UA(e){const{fx:n,fy:a,fw:i,fh:o}=e,u="#D8C490",d="#B09060",h="#907848";As(55);for(let m=0;m<o;m+=8)for(let f=0;f<i;f+=8){const x=Math.min(8,i-f),y=Math.min(8,o-m),v=(f/8+m/8)%2===0?d:u;O(n+f,a+m,x,y,v),O(n+f+1,a+m+1,x-2,1,dn(v,.4),.2),O(n+f+1,a+m+1,1,y-2,dn(v,.4),.15),O(n+f+x-2,a+m+2,1,y-3,Aa(v,.4),.15),O(n+f+2,a+m+y-2,x-3,1,Aa(v,.4),.15),O(n+f,a+m,x,1,h,.3),O(n+f,a+m,1,y,h,.3)}}function qA(){const{canvasW:e,canvasH:n,rooms:a,doors:i}=Ie,o="#2A1E14",u="#3A2E24";if(O(0,0,e,vi,o),O(0,n-vi,e,vi,o),O(0,0,vi,n,o),O(e-vi,0,vi,n,o),O(0,0,e,1,u,.3),O(0,0,1,n,u,.2),!a.exec||!a.work||!a.meet||!a.comm)return;const d=a.exec,h=a.meet,m=e/2,f=m-Lt/2,x=d.fy+d.fh,y=i.exec_work,v=i.meet_comm,b=i.exec_meet,j=i.work_comm,k=24,C=28,N=((y==null?void 0:y.doorY)??d.fy+20)-k/2,E=((b==null?void 0:b.doorX)??vi+Ul+54)-C/2,_=((j==null?void 0:j.doorX)??m+Lt/2+Ul+54)-C/2,z=((v==null?void 0:v.doorY)??h.fy+20)-k/2;O(0,x,E,Lt,o),O(E+C,x,f-E-C,Lt,o),O(f+Lt,x,_-f-Lt,Lt,o),O(_+C,x,e-_-C,Lt,o),O(0,x,E,1,u,.3),O(E+C,x,f-E-C,1,u,.3),O(f+Lt,x,_-f-Lt,1,u,.3),O(_+C,x,e-_-C,1,u,.3),O(f,0,Lt,N,o),O(f,N+k,Lt,x-N-k,o),O(f,x+Lt,Lt,z-x-Lt,o),O(f,z+k,Lt,n-z-k,o),O(f,0,1,N,u,.2),O(f,N+k,1,x-N-k,u,.2),O(f,x+Lt,1,z-x-Lt,u,.2),O(f,z+k,1,n-z-k,u,.2),O(f,N,Lt,k,"#C4A070"),O(f+Lt/2,N,Lt/2,k,"#3A4858"),O(f,z,Lt,k,"#7AA880"),O(f+Lt/2,z,Lt/2,k,"#C8B890");const U="#4A3828";O(f,N-1,Lt,1,U),O(f,N+k,Lt,1,U),O(E-1,x,1,Lt,U),O(E+C,x,1,Lt,U),O(_-1,x,1,Lt,U),O(_+C,x,1,Lt,U),O(f,z-1,Lt,1,U),O(f,z+k,Lt,1,U)}const vg=new Map;function YA(e,n="right"){const a=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${n}`;let i=vg.get(a);if(!i){const o=om("mini-seated:default"),u=Vb(o,e);let d=u?u.layers.flatMap(h=>h.pixels):[];n==="left"&&d.length>0&&(d=im(d,12)),i=d,vg.set(a,i)}return i}function XA(e,n,a,i="right"){ql(Ue,YA(a,i),e,n,a)}function WA(e,n,a,i,o,u="right"){wi(e+8,n+20,"up"),o||XA(e+8,n+0+i,a,u),RA(e,n+14)}function VA(e,n,a,i,o){const u=i in sg?i:"down",d=o%4,h=sg[u][d];ql(Ue,h,e,n,a);const m=d===1||d===3?-1:0;if(a.accessory&&a.accessory!=="none"){const f=fC(a.accessory,u);f&&f.pixels.length>0&&ql(Ue,f.pixels,e,n+m,a)}Ue.globalAlpha=1}let Bu=[],Ni=!1,Ss=0;function GA(){const e=Object.keys(Ie.rooms),n=e[Math.floor(Math.random()*e.length)],a=Ie.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 KA(e){if(e.stateTimer--,Ni){Ss++,e.dir="down",e.walkFrame=0,e.tongueTimer++,e.idleTime=0;return}else Ss=0;if(e.state==="idle"){if(e.tongueTimer++,e.idleTime++,e.stateTimer<=0){e.state="walking",e.tongueTimer=0;const n=Object.keys(Ie.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=ap(e,i),u=Ie.waypoints[i];if(u&&u.length>0){const d=u[Math.floor(Math.random()*u.length)],h=o[o.length-1]??{x:e.x,y:e.y},m=Ei(h.x,h.y,d.x,d.y,i);e.path=[...o,...m]}else e.path=o}else{const a=Ie.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(Ie.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(Ni&&Ss>90){const d=Math.floor(Ss/12)%2===0?lA:iA;ql(Ue,cA,n,a),ql(Ue,d,n,a);return}const i=e.state==="walking"?e.walkFrame:0,o=rA[e.dir][i],u=e.dir==="left"||e.dir==="right";ql(Ue,u?oA:sA,n,a),ql(Ue,o,n,a),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&ql(Ue,aA,n,a)}function PA(e){const n={};let a=0;for(const i of e){const o=on[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=Ie.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 Yh(e,n,a,i){const o=Ie.adjacency[a];if(!o)return[];const u=o.find(x=>x.room===i);if(!u)return[];const d=Ie.doors[u.door];if(!d)return[];const h=[],m=Ie.corridorY[a]??n,f=Ie.corridorY[i]??n;if(Math.abs(n-m)>4&&h.push({x:e,y:m}),d.type==="v"){const x=u.side==="A"?d.xA:d.xB,y=u.side==="A"?d.xB:d.xA;h.push({x,y:m}),h.push({x,y:d.doorY}),h.push({x:y,y:d.doorY}),h.push({x:y,y:f})}else{const x=u.side==="A"?d.yA:d.yB,y=u.side==="A"?d.yB:d.yA;h.push({x:d.doorX,y:m}),h.push({x:d.doorX,y:x}),h.push({x:d.doorX,y}),h.push({x:d.doorX,y:f})}return h}function ap(e,n){const a=Ie.adjacency[e.room];if(!a)return[];if(!a.find(o=>o.room===n)){for(const o of a){const u=Ie.adjacency[o.room];if(u!=null&&u.find(d=>d.room===n)){const d=Yh(e.x,e.y,e.room,o.room),h=d[d.length-1],m=Yh((h==null?void 0:h.x)??e.x,(h==null?void 0:h.y)??e.y,o.room,n);return[...d,...m]}}return[]}return Yh(e.x,e.y,e.room,n)}function ZA(e){if(e.room!==e.homeRoom){const n=ap({...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 JA(e,n){if(Uh--,Uh<=0){const a=Object.entries(e).filter(([,i])=>i.state==="sitting"&&!i.isStretching);if(a.length>0){const[,i]=a[Math.floor(Math.random()*a.length)];i.isStretching=!0,i.stretchTimer=120}Uh=900}for(const[a,i]of Object.entries(e))if(i.stateTimer--,i.isStretching&&i.stretchTimer>0&&(i.stretchTimer--,i.stretchTimer<=0&&(i.isStretching=!1)),i.state==="sitting"){if(i.sittingTime++,Qn===a){i.sittingTime=0,i.bobY=-3;const u=on[a];if(u){const d=u.dx+13;i.lookDir=Bv<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(Ie.rooms);if(Math.random()<.15&&u.length>1){const d=u.filter(x=>x!==i.room),h=d[Math.floor(Math.random()*d.length)],m=ap(i,h),f=Ie.waypoints[h];if(f&&f.length>0){const x=f[Math.floor(Math.random()*f.length)],y=m[m.length-1]??{x:i.x,y:i.y},v=Ei(y.x,y.y,x.x,x.y,h);i.path=[...m,...v]}else i.path=m;i.walkTimer=0}else{const d=Ie.waypoints[i.room];if(d&&d.length>0){const h=d[Math.floor(Math.random()*d.length)];i.path=Ei(i.x,i.y,h.x,h.y,i.room)}i.walkTimer=0}}}else if(i.state==="walking"||i.state==="returning"){if(i.sittingTime=0,Qn===a){i.dir="down",i.walkFrame=0;continue}if(i.path.length===0){i.state==="returning"?(i.state="sitting",i.room=i.homeRoom,i.stateTimer=1200+Math.floor(Math.random()*1800)):(i.state="idle",i.dir="down",i.stateTimer=180+Math.floor(Math.random()*360));continue}const u=i.path[0],d=u.x-i.x,h=u.y-i.y,m=Math.sqrt(d*d+h*h);if(m<1.5){i.x=u.x,i.y=u.y,i.path.shift();for(const[f,x]of Object.entries(Ie.rooms))if(i.x>=x.fx&&i.x<=x.fx+x.fw&&i.y>=x.fy&&i.y<=x.fy+x.fh){i.room=f;break}}else i.x+=d/m*.2,i.y+=h/m*.2,Math.abs(d)>Math.abs(h)?i.dir=d>0?"right":"left":i.dir=h>0?"down":"up",i.walkTimer++,i.walkFrame=Math.floor(i.walkTimer/12)%4}else if(i.state==="idle"){if(Qn===a){i.dir="down";continue}if(i.stateTimer<=0)if(Math.random()<.15){i.state="walking";const o=Ie.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=ZA(i),i.walkTimer=0}}function e8(e,n,a,i){const{canvasW:o,canvasH:u,rooms:d}=Ie;Ue.clearRect(0,0,o,u),O(0,0,o,u,"#2A1E14");const h={wood:qh,dark:bg,carpet:HA,tile:UA};for(const b of Object.values(d))(h[b.floorType]??qh)(b);const m=Object.keys(d);if(m.length>=4){const b=d.exec,j=d.meet,{doors:k}=Ie;if(b&&j&&k.exec_meet&&k.work_comm){const N=(k.exec_meet.doorX??0)-14,E=(k.work_comm.doorX??0)-28/2,_=b.fy+b.fh,z=j.fy;qh({fx:N,fy:_,fw:28,fh:z-_}),bg({fx:E,fy:_,fw:28,fh:z-_})}}const f={};if(m.length>=4){const{doors:b}=Ie,j=28,k=b.exec_meet,C=b.work_comm;k!=null&&k.doorX&&(f.meet={x:k.doorX-j/2,w:j}),C!=null&&C.doorX&&(f.comm={x:C.doorX-j/2,w:j})}for(const b of Object.values(d))LA(b,f[b.id]),IA(b);qA(),zA(Ie);const x=[],y=new Set(Object.values(on).map(b=>b.room));_A(Ie,x,y);for(const[b,j]of Object.entries(on)){const k=e[b];if(!k)continue;const C=k.state==="sitting",N=n(b),E=a[b]==="working",_=k.isStretching&&k.stretchTimer>0?Math.sin(k.stretchTimer*.15)*1:0;x.push({y:j.dy+14,draw:()=>{const z=C?k.bobY+_:0;if(WA(j.dx,j.dy,N,z,!C,k.lookDir),C&&E){const U=Gu[b]??"#388bfd";O(j.dx+7,j.dy+14-4,12,5,U,.15),nt(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 ia){const j=ki===b.id,k=_v(b);if(Ue.save(),Ue.globalAlpha=j?.9:.5,Ue.fillStyle=b.color,Ue.fillRect(k.cx-1,k.botY-2,3,3),j){const C=zv(b);Ue.globalAlpha=.3,Ue.strokeStyle=b.color,Ue.lineWidth=1,Ue.strokeRect(C.x-1,C.y-1,C.w+2,C.h+2)}Ue.restore()}if(Ja){const b=new Set(Object.values(on).map(j=>j.room));if(oa&&oa!==Rr)if(oa.startsWith("desk:")){const j=oa.slice(5),k=on[j];k&&pg(Ue,k.dx,k.dy,"#FBBF24")}else mg(Ue,Ie,oa,"#FBBF24",b);if(Rr)if(Rr.startsWith("desk:")){const j=Rr.slice(5),k=on[j];k&&pg(Ue,k.dx,k.dy,"#3B82F6")}else mg(Ue,Ie,Rr,"#3B82F6",b)}if(Qn){const b=on[Qn],j=e[Qn];if(b&&j){Ue.save(),Ue.globalAlpha=.25,Ue.fillStyle=Gu[Qn]??"#fff",j.state==="sitting"?Ue.fillRect(b.dx-1,b.dy+6,28,30):Ue.fillRect(Math.round(j.x)-1,Math.round(j.y)-1,14,24),Ue.globalAlpha=.95,Ue.fillStyle="#FBBF24",Ue.font="bold 8px monospace",Ue.textAlign="center";const k=j.state==="sitting"?b.dx+13:Math.round(j.x)+6,C=j.state==="sitting"?b.dy-1:Math.round(j.y)-5;Ue.fillText("!",k,C),Ue.restore()}}const v=3600;for(const[,b]of Object.entries(e))if(b.state==="sitting"&&b.sittingTime>v&&!b.isStretching){const j=Object.values(on).find(z=>z.dx+8===b.homeX&&z.dy+34===b.homeY);if(!j)continue;const k=j.dx+13,C=j.dy,N=Math.floor(b.sittingTime/40)%3;Ue.save(),Ue.font="5px monospace",Ue.textAlign="center";const E=[.7,.5,.3],_=[{x:3,y:-2-N},{x:6,y:-5-(N+1)%3},{x:4,y:-8-(N+2)%3}];for(let z=0;z<3;z++)Ue.globalAlpha=E[z],Ue.fillStyle="#93C5FD",Ue.font=`${4+z}px monospace`,Ue.fillText("z",k+_[z].x,C+_[z].y);Ue.restore()}Bu=Bu.filter(b=>b.life>0);for(const b of Bu)b.x+=b.vx,b.y+=b.vy,b.life--,Ue.save(),Ue.globalAlpha=Math.min(1,b.life/(b.maxLife*.3)),Ue.fillStyle=b.color??"#FF6B8A",Ue.font="8px serif",Ue.fillText(b.char,Math.round(b.x),Math.round(b.y)),Ue.restore();if(Ni&&i&&Ss<=90){const b=Math.round(i.x),j=Math.round(i.y);Ue.save(),Ue.globalAlpha=.9,Ue.fillStyle="#FBBF24",Ue.font="bold 5px monospace",Ue.textAlign="center",Ue.fillText("!",b+4,j-2),Ue.restore()}if(i&&!Ni&&i.state==="idle"&&i.idleTime>600){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(i.idleTime/40)%3;Ue.save();const C=[{x:3,y:-2-k},{x:5,y:-5-(k+1)%3},{x:4,y:-8-(k+2)%3}];for(let N=0;N<3;N++)Ue.globalAlpha=[.7,.5,.3][N],Ue.fillStyle="#93C5FD",Ue.font=`${3+N}px monospace`,Ue.textAlign="center",Ue.fillText("z",b+C[N].x,j+C[N].y);Ue.restore()}if(Ni&&i&&Ss<=90){const b=Math.round(i.x),j=Math.round(i.y),k=Math.floor(Date.now()/150)%2===0?-1:1;i.dir==="down"&&(Ue.fillStyle="#FAFAF7",Ue.fillRect(b+4+k,j-1,2,2))}}function wg(e,n){for(let a=0;a<4;a++)Bu.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 t8({roles:e,projects:n,roleStatuses:a,activeExecs:i,onRoleClick:o,onProjectClick:u,onBulletinClick:d,onDecisionsClick:h,onKnowledgeClick:m,onSettingsClick:f,onThemeClick:x,onStatsClick:y,getRoleSpeech:v,getAppearance:b,onHireClick:j,onMascotClick:k,roleLevels:C,coinBalance:N=0,onCoinsSpent:E,onFurniturePlaced:_}){const z=w.useRef(null),U=w.useRef(null),B=w.useRef(null),$=w.useRef({}),q=w.useRef(null),L=w.useRef(0),R=w.useRef(OA),[I,H]=w.useState(!1),[Q,oe]=w.useState(null),[re,Y]=w.useState(null),ae=w.useRef({}),Z=w.useRef({}),G=w.useRef([]),A=w.useRef([]);w.useEffect(()=>{Ja=I},[I]),w.useEffect(()=>{Ll=Q,Sa=re},[Q,re]),w.useEffect(()=>{me.getPreferences().then(pe=>{const xe=pe.furnitureOverrides;xe&&Object.keys(xe).length>0&&(ae.current=xe,Ie=dg(Ie,xe));const ge=pe.deskOverrides;if(ge&&Object.keys(ge).length>0){Z.current=ge,fg(on,ge);for(const[Le,Ee]of Object.entries(on)){const P=$.current[Le];P&&(P.homeX=Ee.dx+8,P.homeY=Ee.dy+34)}}const $e=pe.removedFurniture;$e&&$e.length>0&&(G.current=$e,Ie=Ih(Ie,$e));const Be=pe.addedFurniture;Be&&Be.length>0&&(A.current=Be,Ie=hg(Ie,Be)),ia=Il(Ie)}).catch(()=>{})},[]);const F=w.useRef({roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b});F.current={roleStatuses:a,activeExecs:i,getRoleSpeech:v,getAppearance:b};const W=w.useRef({}),D=w.useMemo(()=>e.map(pe=>pe.id),[e]),te=w.useRef(Ie);w.useEffect(()=>{const pe=D.length,xe=Dv(pe,te.current.preset);let ge=Tv(pe,xe);G.current.length>0&&(ge=Ih(ge,G.current)),A.current.length>0&&(ge=hg(ge,A.current)),Object.keys(ae.current).length>0&&(ge=dg(ge,ae.current)),Ie=ge,te.current=ge,on=$A(D),Object.keys(Z.current).length>0&&fg(on,Z.current),ia=Il(ge),$.current=PA(D),q.current=GA();const $e=z.current;$e&&($e.width=ge.canvasW,$e.height=ge.canvasH),ve()},[D]);const je=w.useCallback(pe=>{var xe,ge;return((ge=(xe=F.current).getAppearance)==null?void 0:ge.call(xe,pe))??Jm(pe)},[]),ve=w.useCallback(()=>{const pe=U.current,xe=z.current;if(!pe||!xe)return;const ge=pe.parentElement;if(!ge)return;const $e=ge.clientWidth,Be=ge.clientHeight;if($e===0||Be===0)return;const{canvasW:Le,canvasH:Ee}=Ie;let P=Math.floor(Math.min($e/Le,Be/Ee));P=Math.max(2,Math.min(P,5)),R.current=P,xe.style.width=Le*P+"px",xe.style.height=Ee*P+"px",pe.style.width=Le*P+"px",pe.style.height=Ee*P+"px"},[]);w.useEffect(()=>{var Ee;const pe=z.current;if(!pe)return;const xe=pe.getContext("2d");if(!xe)return;Ue=xe,mA(xe),ve();const ge=new ResizeObserver(()=>ve()),$e=(Ee=U.current)==null?void 0:Ee.parentElement;$e&&ge.observe($e);let Be;const Le=()=>{L.current++,JA($.current,L.current),q.current&&KA(q.current),e8($.current,je,F.current.roleStatuses,q.current),ze(),Be=requestAnimationFrame(Le)};return Be=requestAnimationFrame(Le),()=>{cancelAnimationFrame(Be),ge.disconnect()}},[je,ve]),w.useEffect(()=>{var Le;const pe=B.current;if(!pe)return;pe.innerHTML="";const xe={};for(const Ee of e)xe[Ee.id]=Ee.name;for(const Ee of D){const P=Gu[Ee]??"#8b949e",ue=xe[Ee],ye=ue&&ue.toLowerCase()!==Ee.toLowerCase()?`${Ee.toUpperCase()} ยท ${ue}`:Ee.toUpperCase(),Ne=document.createElement("div");Ne.className="td-nametag",Ne.dataset.role=Ee;const Me=document.createElement("span");Me.className="td-dot",Me.style.background=P,Ne.appendChild(Me),Ne.appendChild(document.createTextNode(ye));const Pe=((Le=C==null?void 0:C[Ee])==null?void 0:Le.level)??1;if(Pe>1){const dt=document.createElement("span");dt.className="td-lvl",dt.textContent=`Lv.${Pe}`,Ne.appendChild(dt)}pe.appendChild(Ne);const _t=document.createElement("div");_t.className="td-bubble",_t.dataset.role=Ee,_t.dataset.type="bubble",pe.appendChild(_t)}const ge={meeting:()=>{const Ee=n[0];Ee?u(Ee.id):d()},bulletin:d,decisions:h,knowledge:m,settings:f,theme:x,stats:y};for(const Ee of ia){const P=document.createElement("div");P.className="td-facility-label",P.dataset.facility=Ee.id,Ee.id==="meeting"&&(P.dataset.questTarget="meeting-room"),Ee.id==="knowledge"&&(P.dataset.questTarget="knowledge-hub"),Ee.id==="bulletin"&&(P.dataset.questTarget="bulletin-board"),Ee.id==="stats"&&(P.dataset.questTarget="stats-btn"),Ee.id==="settings"&&(P.dataset.questTarget="settings-btn"),Ee.id==="theme"&&(P.dataset.questTarget="theme-btn"),P.textContent=`${Ee.icon} ${Ee.label}`,P.style.borderColor=`${Ee.color}44`;const ue=ge[Ee.id];ue&&P.addEventListener("click",ue),P.addEventListener("mouseenter",()=>{ki=Ee.id}),P.addEventListener("mouseleave",()=>{ki=null}),pe.appendChild(P)}const $e=document.createElement("div");$e.className="td-nametag td-nametag-mascot",$e.dataset.role="mascot";const Be=document.createElement("span");Be.className="td-dot",Be.style.background="#ffd700",$e.appendChild(Be),$e.appendChild(document.createTextNode("Pupu")),$e.addEventListener("click",()=>k==null?void 0:k()),pe.appendChild($e)},[D,e,n,u,d,h,m,f,x,y,k,C]);const ze=w.useCallback(()=>{var ue;const pe=B.current;if(!pe)return;const xe=R.current,ge=$.current,{getRoleSpeech:$e,roleStatuses:Be,activeExecs:Le}=F.current;for(const ye of Object.keys(ge)){const Ne=ge[ye],Me=on[ye];if(!Me)continue;let Pe,_t,dt;Ne.state==="sitting"?(Pe=Me.dx+13,dt=Me.dy+2,_t=Me.dy+37):(Pe=Math.round(Ne.x)+6,dt=Math.round(Ne.y)-2,_t=Math.round(Ne.y)+18);const ht=Pe/Ie.canvasW*100,bt=pe.querySelector(`.td-nametag[data-role="${ye}"]`);if(bt){bt.style.left=ht+"%",bt.style.top=_t*xe+2+"px";const Fe=bt.querySelector(".td-dot");if(Fe){const _e=Be[ye]==="working";Fe.style.background=_e?"#FBBF24":Gu[ye]??"#8b949e",_e?Fe.style.animation="td-pulse 1s ease-in-out infinite":Fe.style.animation=""}}const et=pe.querySelector(`.td-bubble[data-role="${ye}"]`);if(et){const Fe=Date.now(),_e=Be[ye]==="working",nn=(ue=Le.find(Mn=>Mn.roleId===ye))==null?void 0:ue.task,fn=$e(ye);let Vt="";const yt=W.current[ye];if(yt){if(yt.speechDismissTime&&Fe>=yt.speechDismissTime&&(yt.currentSpeech=null,yt.speechDismissTime=null),yt.hoverStartTime&&!yt.currentSpeech){const Mn=Fe-yt.hoverStartTime,J=!yt.lastSpeechTime||Fe-yt.lastSpeechTime>=5e3;if(Mn>=2e3&&J){const We=gg[ye]||gg.default,ot=We[Math.floor(Math.random()*We.length)];yt.currentSpeech=ot,yt.lastSpeechTime=Fe,yt.speechDismissTime=Fe+3e3}}Vt=yt.currentSpeech||""}const pn=_e&&nn?nn.slice(0,60):Vt?Vt.slice(0,60):fn?fn.slice(0,60):"";pn&&Ne.state==="sitting"?(et.style.display="",et.style.left=ht+"%",et.style.top=(dt-10)*xe+"px",et.textContent=pn):et.style.display="none"}}const Ee=pe.querySelector(".td-nametag-mascot"),P=q.current;if(Ee&&P){const ye=P.dir==="left"||P.dir==="right",Ne=Math.round(P.x)+(ye?6:4),Me=Math.round(P.y)+(ye?7:10);Ee.style.left=Ne/Ie.canvasW*100+"%",Ee.style.top=Me*xe+2+"px"}for(const ye of ia){const Ne=pe.querySelector(`.td-facility-label[data-facility="${ye.id}"]`);if(Ne){const Me=_v(ye);Ne.style.left=Me.cx/Ie.canvasW*100+"%",Ne.style.top=Me.botY*xe-4+"px",Ne.classList.toggle("td-facility-label--hover",ki===ye.id)}}},[]),Xe=w.useCallback(pe=>{const xe=z.current;if(!xe)return null;const ge=xe.getBoundingClientRect(),$e=R.current,Be=(pe.clientX-ge.left)/$e,Le=(pe.clientY-ge.top)/$e,Ee=$.current;for(const[ue,ye]of Object.entries(on)){if(!Ee[ue])continue;const Ne=Ee[ue];if(Ne.state==="sitting"){if(Be>=ye.dx&&Be<=ye.dx+26&&Le>=ye.dy&&Le<=ye.dy+40)return{type:"role",id:ue}}else if(Be>=Ne.x-2&&Be<=Ne.x+14&&Le>=Ne.y-2&&Le<=Ne.y+20)return{type:"role",id:ue}}const P=q.current;if(P){const ue=P.dir==="left"||P.dir==="right",ye=ue?13:9,Ne=ue?7:10;if(Be>=P.x&&Be<=P.x+ye&&Le>=P.y&&Le<=P.y+Ne)return{type:"mascot",id:"mascot"}}for(const ue of ia){const ye=zv(ue);if(Be>=ye.x&&Be<=ye.x+ye.w&&Le>=ye.y&&Le<=ye.y+ye.h)return{type:"facility",id:ue.id}}return null},[]),de=w.useCallback(pe=>{const xe=z.current;if(!xe)return{mx:0,my:0};const ge=xe.getBoundingClientRect(),$e=R.current;return{mx:(pe.clientX-ge.left)/$e,my:(pe.clientY-ge.top)/$e}},[]),Oe=w.useCallback(pe=>{me.updatePreferences(pe).catch(()=>{})},[]),Qe=w.useCallback(pe=>{const xe=[...G.current,pe];G.current=xe,Ie=Ih(Ie,[pe]),ia=Il(Ie),Rr=null,oa=null,Oe({removedFurniture:xe})},[Oe]),Se=w.useCallback((pe,xe)=>{if(!Ll||!Sa)return;const ge=yg.find(Ne=>Ne.type===Ll),$e=(ge==null?void 0:ge.price)??0;if($e>0&&N<$e)return;let Be=null;for(const[Ne,Me]of Object.entries(Ie.rooms)){const Pe=Sa==="wall"?Me.wx:Me.fx,_t=Sa==="wall"?Me.wy:Me.fy,dt=Sa==="wall"?Me.ww:Me.fw,ht=Sa==="wall"?Me.wh:Me.fh;if(pe>=Pe&&pe<=Pe+dt&&xe>=_t&&xe<=_t+ht){Be=Ne;break}}if(!Be)return;const Le=Ie.rooms[Be],Ee=Sa==="wall"?Le.wx:Le.fx,P=Sa==="wall"?Le.wy:Le.fy,ue={id:`user-${Ll}-${Date.now()}`,type:Ll,room:Be,zone:Sa,offsetX:Math.round(pe-Ee),offsetY:Math.round(xe-P)},ye=[...A.current,ue];if(A.current=ye,Sa==="wall"?Ie.wallDecorations.push(ue):Ie.furniture.push(ue),ia=Il(Ie),Oe({addedFurniture:ye}),_==null||_(Ll,$e),$e>0){const Ne=ue.type;Rg(async()=>{const{api:Me}=await Promise.resolve().then(()=>Tw);return{api:Me}},void 0).then(({api:Me})=>{Me.spendCoins($e,`furniture: ${Ne}`,ue.id).then(Pe=>E==null?void 0:E(Pe.balance)).catch(()=>{})})}oe(null),Y(null)},[Oe,N,E,_]),Je=w.useCallback(pe=>{const xe=z.current;if(Ja&&Jn){const{mx:Ee,my:P}=de(pe),ye=[...Ie.furniture,...Ie.wallDecorations].find(Pe=>Pe.id===Jn.defId);if(!ye)return;const Ne=Ee-Jn.startMx,Me=P-Jn.startMy;ye.offsetX=Math.round(Jn.origOffX+Ne),ye.offsetY=Math.round(Jn.origOffY+Me),ia=Il(Ie),xe&&(xe.style.cursor="grabbing");return}if(Ja&&_n){const{mx:Ee,my:P}=de(pe),ue=on[_n.roleId];if(!ue)return;ue.dx=Math.round(_n.origDx+(Ee-_n.startMx)),ue.dy=Math.round(_n.origDy+(P-_n.startMy));const ye=$.current[_n.roleId];ye&&(ye.homeX=ue.dx+8,ye.homeY=ue.dy+34),xe&&(xe.style.cursor="grabbing");return}if(Ja){const{mx:Ee,my:P}=de(pe);if(Ll){xe&&(xe.style.cursor="crosshair");return}const ue=new Set(Object.values(on).map(Ne=>Ne.room)),ye=Hh(Ie,Ee,P,ue);if(ye)oa=ye;else{const Ne=xg(on,Ee,P);oa=Ne?`desk:${Ne}`:null}Qn=null,ki=null,xe&&(xe.style.cursor=oa?"grab":"default");return}const ge=Xe(pe),$e=Qn;Qn=(ge==null?void 0:ge.type)==="role"?ge.id:null,ki=(ge==null?void 0:ge.type)==="facility"?ge.id:null,Ni=(ge==null?void 0:ge.type)==="mascot",oa=null,xe&&(xe.style.cursor=ge?"pointer":"default");const{mx:Be}=de(pe);Bv=Be;const Le=Date.now();if(Qn&&Qn!==$e){W.current[Qn]||(W.current[Qn]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const Ee=W.current[Qn];Ee.hoverStartTime=Le}else if(!Qn&&$e){const Ee=W.current[$e];Ee&&(Ee.hoverStartTime=null)}},[Xe,de]),Re=w.useCallback(pe=>{if(!Ja)return;const{mx:xe,my:ge}=de(pe);if(Ll){Se(xe,ge),pe.preventDefault();return}const $e=new Set(Object.values(on).map(Ee=>Ee.room)),Be=Hh(Ie,xe,ge,$e);if(Be){const P=[...Ie.furniture,...Ie.wallDecorations].find(ue=>ue.id===Be);P&&(Rr=Be,Jn={defId:Be,startMx:xe,startMy:ge,origOffX:P.offsetX,origOffY:P.offsetY},pe.preventDefault());return}const Le=xg(on,xe,ge);if(Le){const Ee=on[Le];Rr=`desk:${Le}`,_n={roleId:Le,startMx:xe,startMy:ge,origDx:Ee.dx,origDy:Ee.dy},pe.preventDefault();return}Rr=null},[de,Se]),Et=w.useCallback(pe=>{if(Jn){const ge=[...Ie.furniture,...Ie.wallDecorations].find($e=>$e.id===Jn.defId);if(ge){const $e={...ae.current,[ge.id]:{offsetX:ge.offsetX,offsetY:ge.offsetY}};ae.current=$e,Oe({furnitureOverrides:$e}),ia=Il(Ie)}Jn=null,z.current&&(z.current.style.cursor="grab");return}if(_n){const xe=on[_n.roleId];if(xe){const ge={...Z.current,[_n.roleId]:{dx:xe.dx,dy:xe.dy}};Z.current=ge,Oe({deskOverrides:ge})}_n=null,z.current&&(z.current.style.cursor="grab")}},[Oe]),ut=w.useCallback(pe=>{if(!Ja)return;pe.preventDefault();const{mx:xe,my:ge}=de(pe),$e=new Set(Object.values(on).map(Le=>Le.room)),Be=Hh(Ie,xe,ge,$e);Be&&Qe(Be)},[de,Qe]);w.useEffect(()=>{const pe=xe=>{!Ja||!Rr||(xe.key==="Delete"||xe.key==="Backspace")&&(Rr.startsWith("desk:")||Qe(Rr))};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},[Qe]);const gt=w.useCallback(()=>{if(Jn){const xe=[...Ie.furniture,...Ie.wallDecorations].find(ge=>ge.id===Jn.defId);xe&&(xe.offsetX=Jn.origOffX,xe.offsetY=Jn.origOffY,ia=Il(Ie)),Jn=null}if(_n){const pe=on[_n.roleId];pe&&(pe.dx=_n.origDx,pe.dy=_n.origDy);const xe=$.current[_n.roleId];xe&&(xe.homeX=pe.dx+8,xe.homeY=pe.dy+34),_n=null}Qn=null,ki=null,Ni=!1,oa=null,z.current&&(z.current.style.cursor="default")},[]),kt=w.useCallback(pe=>{if(Ja)return;const xe=Xe(pe);if(xe){if(xe.type==="role"){const ge=$.current[xe.id],$e=on[xe.id];if(ge&&$e){const Be=ge.state==="sitting"?$e.dx+13:Math.round(ge.x)+6,Le=ge.state==="sitting"?$e.dy+2:Math.round(ge.y)-2;wg(Be,Le)}o(xe.id);return}if(xe.type==="mascot"){const ge=q.current;ge&&wg(Math.round(ge.x)+4,Math.round(ge.y)-2),k==null||k();return}switch(xe.id){case"meeting":{const ge=n[0];ge?u(ge.id):d();break}case"bulletin":d();break;case"decisions":h();break;case"knowledge":m();break;case"settings":f==null||f();break;case"theme":x==null||x();break;case"stats":y==null||y();break}}},[Xe,o,u,d,h,m,f,x,y]);return l.jsxs("div",{className:`td-scene${I?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:U,className:"td-wrap",children:[l.jsx("canvas",{ref:z,width:Ie.canvasW,height:Ie.canvasH,className:"td-canvas",onClick:kt,onMouseDown:Re,onMouseUp:Et,onMouseMove:Je,onMouseLeave:gt,onContextMenu:ut}),l.jsx("div",{ref:B,className:"td-overlay"})]}),I&&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${I?" td-edit-btn--active":""}`,"data-quest-target":"edit-btn",onClick:()=>{H(pe=>{const xe=!pe;return xe||(oe(null),Y(null)),xe}),Rr=null,Jn=null,_n=null},title:I?"Exit Edit Mode":"Edit Furniture Layout",children:[l.jsx("span",{className:"td-edit-btn__icon",children:I?"โ":"โ"}),l.jsx("span",{className:"td-edit-btn__label",children:I?"DONE":"EDIT"})]}),I&&l.jsx("div",{className:"td-palette",children:yg.map(pe=>{const xe=pe.price===0||N>=pe.price,ge=pe.price===0?"Free":`${pe.price>=1e3?`${(pe.price/1e3).toFixed(pe.price%1e3===0?0:1)}K`:pe.price}`;return l.jsxs("button",{className:`td-palette__item${Q===pe.type?" td-palette__item--active":""}${xe?"":" td-palette__item--locked"}`,onClick:()=>{xe&&(Q===pe.type?(oe(null),Y(null)):(oe(pe.type),Y(pe.zone)))},title:`${pe.label} โ ${ge}`,style:xe?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:pe.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:pe.price===0?"#4CAF50":xe?"#FFD54F":"#EF5350"},children:ge})]},pe.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 n8({role:e,appearance:n,onSave:a,onReset:i,onClose:o,theme:u,onThemeChange:d,onUpdateName:h,initialTab:m,characterOnly:f,speechSettings:x,onSpeechSettingsChange:y,language:v,onLanguageChange:b,roleLevel:j}){var I;const[k,C]=w.useState(m??"character"),[N,E]=w.useState({...n}),[_,z]=w.useState(e.name),[U,B]=w.useState(!1),$=w.useCallback(()=>E(gs(j)),[j]),q=w.useCallback(()=>{const H=Jm(e.id);E({...H}),i()},[e.id,i]),L=w.useCallback(async()=>{a(N);const H=_.trim();if(h&&H&&H!==e.name){B(!0);try{await h(e.id,H)}catch{}B(!1)}o()},[N,a,o,_,e.name,e.id,h]),R=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," โ"]}),h?l.jsx("input",{value:_,onChange:H=>z(H.target.value),disabled:U,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:H=>H.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:()=>C("character"),children:"CHARACTER"}),!f&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${k==="office"?"active":""}`,onClick:()=>C("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${k==="settings"?"active":""}`,onClick:()=>C("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:o,children:"X"})]}),k==="character"?l.jsx("div",{className:"customize-body",children:l.jsx(bv,{roleId:e.id,appearance:N,onChange:E,onRandomize:$,onReset:q,label:R,roleLevel:j})}):k==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(al).map(([H,Q])=>l.jsxs("button",{className:`customize-theme-card ${u===H?"active":""}`,onClick:()=>d(H),children:[l.jsxs("div",{className:"customize-theme-preview",style:{background:Q.vars["--floor-light"],borderColor:Q.vars["--pixel-border"]},children:[l.jsx("div",{style:{background:Q.vars["--hud-bg"],height:8,borderBottom:`2px solid ${Q.vars["--pixel-border"]}`}}),l.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 p-1",children:[l.jsx("div",{style:{width:10,height:14,background:Q.vars["--accent"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:Q.vars["--active-green"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:Q.vars["--idle-amber"],borderRadius:1}})]}),l.jsx("div",{style:{background:Q.vars["--hud-bg"],height:6,borderTop:`2px solid ${Q.vars["--pixel-border"]}`}})]}),l.jsxs("div",{className:"customize-theme-name",children:[Q.icon," ",Q.name]})]},H))})}):l.jsx("div",{className:"customize-body",children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20,padding:"8px 0"},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"AMBIENT SPEECH MODE"}),l.jsx("div",{style:{display:"flex",gap:6},children:["template","llm","auto"].map(H=>l.jsxs("button",{onClick:()=>y==null?void 0:y({mode:H}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(x==null?void 0:x.mode)===H?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(x==null?void 0:x.mode)===H?"rgba(255,255,255,0.08)":"transparent",color:(x==null?void 0:x.mode)===H?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:H==="template"?"TEMPLATE":H==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:H==="template"?"Static pool ($0)":H==="llm"?"LLM generated":"Detect engine"})]},H))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Auto: CLI Max = AI, BYOK = Template"})]}),l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["SPEECH INTERVAL: ",(x==null?void 0:x.intervalSec)??18,"s"]}),l.jsx("input",{type:"range",min:5,max:120,step:5,value:(x==null?void 0:x.intervalSec)??18,onChange:H=>y==null?void 0:y({intervalSec:Number(H.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"5s (frequent)"}),l.jsx("span",{children:"120s (rare)"})]})]}),(x==null?void 0:x.mode)!=="template"&&l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["DAILY LLM BUDGET: $",((I=x==null?void 0:x.dailyBudgetUsd)==null?void 0:I.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(x==null?void 0:x.dailyBudgetUsd)??1,onChange:H=>y==null?void 0:y({dailyBudgetUsd:Number(H.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"$0 (unlimited)"}),l.jsx("span",{children:"$5.00/day"})]})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"LANGUAGE"}),l.jsx("div",{style:{display:"flex",gap:6},children:[{key:"auto",label:"Auto"},{key:"en",label:"English"},{key:"ko",label:"ํ๊ตญ์ด"},{key:"ja",label:"ๆฅๆฌ่ช"}].map(({key:H,label:Q})=>l.jsx("button",{onClick:()=>b==null?void 0:b(H),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(v??"auto")===H?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(v??"auto")===H?"rgba(255,255,255,0.08)":"transparent",color:(v??"auto")===H?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:Q},H))}),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:L,children:"SAVE"})]})]})})}function kg(e){if(e.length===0)return"";const n={};for(const{file:h}of e){const m=h.split("/"),f=m[0]==="."?m[1]??"root":m[0];(n[f]??(n[f]=[])).push(h)}const a={roles:"roles",projects:"projects",operations:"operations",knowledge:"knowledge",architecture:"architecture",company:"company",".tycono":"config",".claude":"skills"},i=[];for(const[h,m]of Object.entries(n)){const f=a[h]??h;if(m.length===1){const x=m[0].split("/").pop()??m[0];i.push(`${f}/${x}`)}else i.push(`${f} (${m.length} files)`)}const o=e.some(h=>h.status==="A"),u=e.some(h=>h.status==="M");return`${o&&!u?"add":"update"}: ${i.join(", ")}`}function jg(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 r8({onInitGit:e,onDelegate:n,delegateRoleName:a}){const[i,o]=w.useState(!1),[u,d]=w.useState(null),h=async()=>{o(!0),d(null);try{await e(),d({ok:!0,message:"Git repository initialized!"})}catch(f){const x=f instanceof Error?f.message:"Failed";x.includes("not installed")||x.includes("noGitBinary")?d({ok:!1,message:"git is not installed on this system"}):d({ok:!1,message:x})}finally{o(!1)}},m=u&&!u.ok&&u.message.includes("not installed");return l.jsxs("div",{className:"p-3 space-y-2",style:{background:"rgba(211,47,47,0.05)",border:"1px solid var(--pixel-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"No Git Repository"}),!u&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"This project has no git repository. Initialize one to start saving."}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:h,disabled:i,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:i?"INITIALIZING...":"GIT INIT"}),n&&l.jsxs("button",{onClick:n,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["๐ค"," ",(a==null?void 0:a.toUpperCase())??"AI"," FIX"]})]})]}),u&&u.ok&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:"rgba(59,185,80,0.1)",border:"1px solid var(--active-green)",color:"var(--active-green)"},children:u.message}),m&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"#EF5350"},children:"git is not installed on this system."}),l.jsxs("div",{className:"text-[10px] space-y-1",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("div",{children:[l.jsx("b",{children:"macOS:"})," xcode-select --install"]}),l.jsxs("div",{children:[l.jsx("b",{children:"Ubuntu/Debian:"})," sudo apt install git"]}),l.jsxs("div",{children:[l.jsx("b",{children:"Windows:"})," ",l.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"git-scm.com/downloads"})]})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:()=>{d(null)},className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),n&&l.jsxs("button",{onClick:n,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["๐ค"," ",(a==null?void 0:a.toUpperCase())??"AI"," FIX"]})]})]}),u&&!u.ok&&!m&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:u.message})]})}function a8({repo:e,onConnected:n,onDelegate:a,delegateRoleName:i}){const[o,u]=w.useState("idle"),[d,h]=w.useState(null),[m,f]=w.useState(""),[x,y]=w.useState("private"),[v,b]=w.useState(""),[j,k]=w.useState(null),[C,N]=w.useState(!1),E=async()=>{u("checking"),k(null);try{const B=await me.getGithubStatus(e);h(B),B.hasRemote?n():B.ghInstalled&&B.authenticated?u("ready"):u("idle")}catch{u("idle")}},_=async()=>{if(m.trim()){N(!0),k(null);try{const B=await me.githubCreateRepo(m.trim(),x,e);k(B),B.ok&&setTimeout(n,1500)}catch(B){k({ok:!1,message:B instanceof Error?B.message:"Failed"})}finally{N(!1)}}},z=async()=>{if(v.trim()){N(!0),k(null);try{const B=await me.addRemote(v.trim(),e);k(B),B.ok&&setTimeout(n,1500)}catch(B){k({ok:!1,message:B instanceof Error?B.message:"Failed"})}finally{N(!1)}}},U=a?l.jsxs("button",{onClick:a,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},title:`Ask ${i??"AI"} to set up GitHub remote`,children:["๐ค"," ",(i==null?void 0:i.toUpperCase())??"AI"," FIX"]}):null;return l.jsxs("div",{className:"p-3 space-y-2",style:{background:"rgba(100,100,255,0.05)",border:"1px solid var(--pixel-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"No Remote โ Local Only"}),o==="idle"&&!d&&l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:E,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"CONNECT GITHUB"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD REMOTE URL"}),U]}),o==="checking"&&l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"Checking GitHub CLI..."}),o==="idle"&&d&&!d.ghInstalled&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--idle-amber)"},children:"GitHub CLI (gh) not installed."}),l.jsxs("div",{className:"text-[10px] space-y-0.5",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("div",{children:["Install:"," ",l.jsx("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"cli.github.com"})]}),l.jsx("div",{style:{fontFamily:"var(--pixel-font)"},children:"brew install gh && gh auth login"})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:E,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD URL MANUALLY"}),U]})]}),o==="idle"&&d&&d.ghInstalled&&!d.authenticated&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--idle-amber)"},children:"GitHub CLI installed but not logged in."}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)",fontFamily:"var(--pixel-font)"},children:"Run in terminal: gh auth login"}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:E,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD REMOTE URL"}),U]})]}),o==="ready"&&d&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--active-green)"},children:["Logged in as ",d.username||"GitHub user"]}),l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("input",{type:"text",value:m,onChange:B=>f(B.target.value),placeholder:"repository-name",className:"flex-1 px-2 py-1.5 text-[11px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}}),l.jsxs("select",{value:x,onChange:B=>y(B.target.value),className:"px-2 py-1.5 text-[10px] outline-none cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:[l.jsx("option",{value:"private",children:"Private"}),l.jsx("option",{value:"public",children:"Public"})]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:_,disabled:C||!m.trim(),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:C?"CREATING...":"CREATE & PUSH"}),l.jsx("button",{onClick:()=>u("manual"),className:"text-[10px] px-2 py-1 cursor-pointer",style:{background:"transparent",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"USE URL INSTEAD"})]})]}),o==="manual"&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("a",{href:"https://github.com/new",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"Create a new repo on GitHub"})," ","then paste the URL below:"]}),l.jsx("input",{type:"text",value:v,onChange:B=>b(B.target.value),placeholder:"https://github.com/username/repo-name.git",className:"w-full px-2 py-1.5 text-[11px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:z,disabled:C||!v.trim(),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:C?"ADDING...":"ADD REMOTE & PUSH"}),l.jsx("button",{onClick:()=>{u("idle"),h(null)},className:"text-[10px] px-2 py-1 cursor-pointer",style:{background:"transparent",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"BACK"})]})]}),j&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:j.ok?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${j.ok?"var(--active-green)":"#D32F2F"}`,color:j.ok?"var(--active-green)":"#EF5350"},children:j.message})]})}function l8({status:e,history:n,onClose:a,onSave:i,onLoadHistory:o,onRestore:u,saving:d,onDelegate:h,delegateRoleName:m,repo:f,onRepoChange:x,syncInfo:y,onPull:v,pulling:b,onRefresh:j,onInitGit:k}){const[C,N]=w.useState("save"),[E,_]=w.useState(""),[z,U]=w.useState(null),[B,$]=w.useState(!1),[q,L]=w.useState(null),[R,I]=w.useState(null),H=w.useRef(null);w.useEffect(()=>{C==="history"&&o()},[C,o]),w.useEffect(()=>{var A;(A=H.current)==null||A.focus()},[]);const Q=[...((e==null?void 0:e.modified)??[]).map(A=>({status:"M",file:A})),...((e==null?void 0:e.untracked)??[]).map(A=>({status:"A",file:A}))],oe=w.useRef(!1);w.useEffect(()=>{!oe.current&&Q.length>0&&!E&&(_(kg(Q)),oe.current=!0)},[Q.length]),w.useEffect(()=>{oe.current=!1,_(""),I(null),L(null),U(null)},[f]);const re=w.useCallback(()=>{_(kg(Q))},[Q]),Y=async()=>{U(null),L(null);try{const A=await i(E||void 0);L(A),_("")}catch(A){U(A instanceof Error?A.message:"Save failed")}},ae=async()=>{I(null),U(null);try{const A=await v();I(A)}catch(A){U(A instanceof Error?A.message:"Pull failed")}},Z=async A=>{if(confirm(`Restore from commit ${A.slice(0,7)}? This creates a new commit with those files.`)){$(!0);try{await u(A),$(!1)}catch(F){U(F instanceof Error?F.message:"Restore failed"),$(!1)}}};w.useEffect(()=>{const A=F=>{F.key==="Escape"&&a()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[a]);const G=A=>{A.key==="Enter"&&(A.metaKey||A.ctrlKey)&&Y()};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:a}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] max-h-[80vh] z-[61] overflow-hidden flex flex-col",style:{background:"var(--hud-bg)",border:"3px solid var(--pixel-border)",fontFamily:"var(--pixel-font)",color:"var(--terminal-text)"},onKeyDown:G,children:[l.jsxs("div",{className:"px-5 py-3 flex items-center justify-between shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-lg font-black tracking-tight",children:"SAVE GAME"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:(e==null?void 0:e.branch)??""})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[y&&y.hasRemote&&(y.behind>0||y.ahead>0)&&l.jsxs("span",{className:"text-[10px] font-bold",style:{color:y.behind>0?"var(--idle-amber)":"var(--active-green)"},children:[y.behind>0&&`โ${y.behind}`,y.behind>0&&y.ahead>0&&" ",y.ahead>0&&`โ${y.ahead}`]}),l.jsx("button",{onClick:a,className:"text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] cursor-pointer text-lg",children:"ร"})]})]}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["akb","code"].map(A=>l.jsx("button",{onClick:()=>x(A),className:"flex-1 py-1.5 text-[10px] font-bold uppercase tracking-wider cursor-pointer",style:{background:f===A?"var(--hud-bg-alt)":"transparent",color:f===A?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:f===A?"2px solid var(--accent)":"2px solid transparent"},children:A==="akb"?"AKB":"CODE"},A))}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["save","history"].map(A=>l.jsx("button",{onClick:()=>N(A),className:"flex-1 py-2 text-[11px] font-bold uppercase tracking-wider cursor-pointer",style:{background:C===A?"var(--hud-bg-alt)":"transparent",color:C===A?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:C===A?"2px solid var(--accent)":"2px solid transparent"},children:A==="save"?"SAVE":"HISTORY"},A))}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[C==="save"&&l.jsxs(l.Fragment,{children:[(e==null?void 0:e.noGit)&&l.jsx(r8,{onInitGit:async()=>{await(k==null?void 0:k()),j==null||j()},onDelegate:h?()=>{h(`Git is not initialized or not installed for this project. Please check if git is installed (run "git --version"). If git is available, initialize the repository with "git init" and make an initial commit. If git is not installed, provide clear instructions for the user's OS to install it.`)}:void 0,delegateRoleName:m}),y&&y.hasRemote&&y.behind>0&&l.jsxs("div",{className:"flex items-center justify-between p-2",style:{background:"rgba(255,180,0,0.08)",border:"1px solid var(--idle-amber)"},children:[l.jsxs("span",{className:"text-[11px]",style:{color:"var(--idle-amber)"},children:[y.behind," commit",y.behind>1?"s":""," behind remote"]}),l.jsx("button",{onClick:ae,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"})]}),R&&l.jsx("div",{className:"text-[11px] p-2",style:{background:R.status==="ok"||R.status==="up-to-date"?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${R.status==="ok"||R.status==="up-to-date"?"var(--active-green)":"#D32F2F"}`,color:R.status==="ok"||R.status==="up-to-date"?"var(--active-green)":"#EF5350"},children:R.message}),l.jsx("div",{className:"text-[11px]",style:{color:"var(--terminal-text-secondary)"},children:Q.length>0?l.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",Q.length," unsaved change",Q.length>1?"s":""]}):l.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),Q.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:Q.map(({status:A,file:F})=>l.jsxs("div",{className:"flex gap-2",children:[l.jsx("span",{style:{color:A==="A"?"var(--active-green)":"var(--idle-amber)",width:"14px"},children:A}),l.jsx("span",{style:{color:"var(--terminal-text-secondary)"},children:F})]},F))})]}),Q.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:re,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:H,type:"text",value:E,onChange:A=>_(A.target.value),placeholder:"Auto-generated โ edit if needed",className:"w-full px-3 py-2 text-[12px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}})]}),Q.length>0&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:Y,disabled:d,className:"flex-1 py-2.5 text-[12px] font-black uppercase tracking-wider cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"2px solid var(--accent)"},children:d?"SAVING...":e!=null&&e.hasRemote?"SAVE & PUSH":"SAVE"}),h&&l.jsxs("button",{onClick:()=>{const A=Q.map(F=>`${F.status} ${F.file}`).join(`
|
|
91
|
+
`);h(A)},disabled:d,className:"py-2.5 px-4 text-[11px] font-bold uppercase tracking-wider cursor-pointer disabled:opacity-50",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"2px solid var(--pixel-border)"},title:`Delegate to ${m??"AI role"} โ they'll review, commit, push & merge`,children:["๐ค"," ",(m==null?void 0:m.toUpperCase())??"DELEGATE"]})]}),e&&!e.hasRemote&&!e.noGit&&l.jsx(a8,{repo:f,onConnected:()=>j==null?void 0:j(),onDelegate:h?()=>{h(`Set up a GitHub remote for the ${f==="akb"?"AKB":"Code"} repository and push all commits. If gh CLI is available, use "gh repo create". Otherwise, guide through manual setup. Current repo path can be found in config.`)}:void 0,delegateRoleName:m}),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," (",jg(e.lastCommit.date),")"]})]}),C==="history"&&l.jsxs(l.Fragment,{children:[n.length===0&&l.jsx("div",{className:"text-[11px] text-center py-8",style:{color:"var(--terminal-text-muted)"},children:"No save history"}),l.jsx("div",{className:"space-y-1",children:n.map(A=>l.jsxs("div",{className:"flex items-center justify-between py-2 px-3 group",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--accent)"},children:A.shortSha}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:A.message})]}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:jg(A.date)})]}),l.jsx("button",{onClick:()=>Z(A.sha),disabled:B,className:"text-[10px] font-bold px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--idle-amber)"},children:"LOAD"})]},A.sha))})]})]})]})]})}function i8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[,h]=w.useState(!1);return w.useEffect(()=>{Promise.all([me.getCompanyStats(),me.getPreferences()]).then(async([m,f])=>{a(m);const x=f;if(x.instanceId)try{await br.syncStats({instanceId:x.instanceId,roleCount:m.company.roleCount,totalTokens:m.company.totalTokens,rolesData:m.roles.map(y=>({roleId:y.roleId,name:y.name,tokens:y.totalTokens}))}),h(!0)}catch{}}).catch(m=>d(m.message)).finally(()=>o(!1))},[]),i?l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading stats..."}):u||!n?l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u||"Failed to load stats",l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]}):l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:20},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Company Stats"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"ร"})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:20},children:[l.jsx(Nu,{label:"Roles",value:String(n.company.roleCount)}),l.jsx(Nu,{label:"Avg Level",value:`Lv.${n.company.avgLevel}`}),l.jsx(Nu,{label:"Total Tokens",value:n.company.formattedTokens}),l.jsx(Nu,{label:"Total Cost",value:`$${n.company.totalCostUsd.toFixed(2)}`})]}),l.jsx("h4",{style:{margin:"0 0 12px",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},children:"Role Leaderboard"}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[n.roles.map((m,f)=>l.jsx(s8,{role:m,rank:f+1},m.roleId)),n.roles.length===0&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"8px 0"},children:"No role activity yet. Assign tasks to start leveling up!"})]}),Object.keys(n.byModel).length>0&&l.jsxs(l.Fragment,{children:[l.jsx("h4",{style:{margin:"20px 0 12px",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},children:"Model Usage"}),l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:Object.entries(n.byModel).map(([m,f])=>l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,fontSize:12},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.7)"},children:o8(m)}),l.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",f.costUsd.toFixed(2)]})]},m))})]})]})}function Nu({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 s8({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:Sg(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:Sg(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 Sg(e){return e>=20?"#FFD700":e>=10?"#C0A0FF":e>=5?"#4FC3F7":e>=3?"#81C784":"rgba(255,255,255,0.4)"}function o8(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.split("-").slice(0,2).join(" ")}function c8({onClose:e,onSyncComplete:n}){const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,h]=w.useState(!0),[m,f]=w.useState(null),[x,y]=w.useState(new Set),[v,b]=w.useState(null),[j,k]=w.useState(null),C=w.useCallback(async()=>{h(!0),b(null);try{const{roles:E}=await me.getSyncRoles();i(E);const _=E.filter(z=>z.source.sync!=="off");if(_.length===0){u([]),k(null);return}try{const z=await br.syncCheck(_.map(B=>({roleId:B.roleId,sourceId:B.source.id,currentVersion:B.source.upstream_version??B.source.forked_at??"0.0.0"})));k(!0);const U=[];for(const B of z.updates){if(!B.hasUpdate)continue;const $=_.find(H=>H.roleId===B.roleId);if(!$)continue;const{character:q}=await br.syncPull(B.sourceId),L=[];$.persona.trim()!==q.persona.trim()&&L.push({field:"persona",local:$.persona.slice(0,120)+($.persona.length>120?"...":""),upstream:q.persona.slice(0,120)+(q.persona.length>120?"...":"")});const R=JSON.stringify($.authority),I=JSON.stringify(q.authority);R!==I&&L.push({field:"authority",local:`${$.authority.autonomous.length} autonomous, ${$.authority.needsApproval.length} approval`,upstream:`${q.authority.autonomous.length} autonomous, ${q.authority.needsApproval.length} approval`}),L.length>0&&U.push({roleId:B.roleId,roleName:$.name,sourceId:B.sourceId,currentVersion:B.currentVersion,latestVersion:B.latestVersion,fields:L})}u(U)}catch{k(!1),u([])}}catch(E){b(E instanceof Error?E.message:"Failed to check for updates")}finally{h(!1)}},[]);w.useEffect(()=>{C()},[C]);const N=async E=>{f(E.roleId);try{const{character:_,version:z}=await br.syncPull(E.sourceId);await me.applySyncUpdate({roleId:E.roleId,changes:{persona:_.persona,authority:_.authority},upstreamVersion:z}),y(U=>new Set(U).add(E.roleId)),n==null||n()}catch(_){b(_ instanceof Error?_.message:"Failed to apply update")}finally{f(null)}};return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Role Sync"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:C,disabled:d,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:d?"wait":"pointer"},children:d?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"ร"})]})]}),j===!1&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,180,0,0.1)",borderRadius:6,color:"#FFB74D",fontSize:12,marginBottom:12},children:"Cloud API unreachable. Sync requires connection to api.tycono.ai."}),v&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:v}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Tracked roles: "}),l.jsx("span",{style:{fontWeight:500},children:a.length}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)",margin:"0 8px"},children:"ยท"}),l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Updates available: "}),l.jsx("span",{style:{fontWeight:500,color:o.length>0?"#4FC3F7":"rgba(255,255,255,0.7)"},children:o.filter(E=>!x.has(E.roleId)).length}),j===!0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.3)",margin:"0 8px"},children:"ยท"}),l.jsx("span",{style:{fontSize:11,color:"#81C784"},children:"Cloud connected"})]})]}),o.length===0&&!d&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:a.length===0?"No roles with source tracking. Hire from the Store to enable sync.":"All roles are up to date!"}),o.map(E=>l.jsxs("div",{style:{marginBottom:12,padding:14,background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:14,fontWeight:500},children:E.roleName}),l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[E.sourceId," ยท v",E.currentVersion," โ v",E.latestVersion]})]}),x.has(E.roleId)?l.jsx("span",{style:{fontSize:12,color:"#81C784"},children:"Applied โ"}):l.jsx("button",{onClick:()=>N(E),disabled:m===E.roleId,style:{background:"#1565C0",border:"none",color:"white",borderRadius:6,padding:"5px 12px",fontSize:12,cursor:m===E.roleId?"wait":"pointer",opacity:m===E.roleId?.6:1},children:m===E.roleId?"Applying...":"Apply Update"})]}),E.fields.map(_=>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))]},E.roleId)),a.length>0&&l.jsxs("div",{style:{marginTop:16,fontSize:11,color:"rgba(255,255,255,0.3)",lineHeight:1.5},children:["Roles hired from the Store are tracked automatically. Set ",l.jsx("code",{style:{background:"rgba(255,255,255,0.06)",padding:"1px 4px",borderRadius:3},children:"sync: off"})," in role.yaml to stop tracking."]})]})}function u8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[h,m]=w.useState(null),f=w.useCallback(async()=>{o(!0),d(null);try{const E=await me.getGitStatus();a(E)}catch(E){d(E instanceof Error?E.message:"Failed to load git status")}finally{o(!1)}},[]);w.useEffect(()=>{f()},[f]);const x=async E=>{m(E.path);try{await me.deleteWorktree(E.path),await f()}catch(_){d(_ instanceof Error?_.message:"Failed to remove worktree")}finally{m(null)}},y=async E=>{m(E);try{await me.deleteBranch(E),await f()}catch(_){d(_ instanceof Error?_.message:"Failed to delete branch")}finally{m(null)}};if(i&&!n)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading git status..."});if(u&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const v=n.worktrees.filter(E=>E.status==="active"),b=n.worktrees.filter(E=>E.status==="pending-merge"),j=n.worktrees.filter(E=>E.status==="stale");function k(E){const _=E.split("/");if(_.length>1){const z=_[_.length-1],U=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const B of U)if(z.toLowerCase().includes(B))return B}return null}function C(E,_=40){return E.length<=_?E:"..."+E.slice(E.length-_+3)}function N(E){const _=Date.now()-new Date(E).getTime(),z=Math.floor(_/6e4);if(z<1)return"just now";if(z<60)return`${z}m ago`;const U=Math.floor(z/60);return U<24?`${U}h ago`:`${Math.floor(U/24)}d ago`}return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"GIT STATUS"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:f,disabled:i,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:i?"wait":"pointer"},children:i?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"ร"})]})]}),u&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Branch: "}),l.jsx("span",{style:{fontWeight:500},children:n.currentBranch})]}),l.jsx("div",{children:n.unsavedCount>0&&l.jsxs("span",{style:{color:"#FFB74D",fontSize:12},children:[n.unsavedCount," unsaved"]})})]}),n.lastCommit&&l.jsxs("div",{style:{marginTop:6,fontSize:11,color:"rgba(255,255,255,0.4)"},children:["Last commit: ",n.lastCommit.message.slice(0,60),n.lastCommit.message.length>60?"...":""," ยท ",N(n.lastCommit.date)]})]}),v.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Eu,{label:"Active Worktrees",count:v.length}),v.map(E=>l.jsx(Xh,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:C,timeAgo:N,removing:h===E.path,onRemove:()=>x(E),statusColor:"#4FC3F7",statusIcon:"๐"},E.path))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Eu,{label:"Pending Merge",count:b.length}),b.map(E=>l.jsx(Xh,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:C,timeAgo:N,removing:h===E.path,onRemove:()=>x(E),statusColor:"#FFB74D",statusIcon:"โ ๏ธ"},E.path))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Eu,{label:"Stale",count:j.length}),j.map(E=>l.jsx(Xh,{wt:E,roleFromBranch:E.roleId||k(E.branch),truncatePath:C,timeAgo:N,removing:h===E.path,onRemove:()=>x(E),statusColor:"#ff6b6b",statusIcon:"๐ด"},E.path))]}),n.staleBranches.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Eu,{label:"Unmerged Branches",count:n.staleBranches.length}),n.staleBranches.map(E=>l.jsxs("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{style:{fontSize:13},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)",marginRight:6},children:"โ ๏ธ"}),l.jsx("span",{style:{fontWeight:500},children:E})]}),l.jsx("button",{onClick:()=>y(E),disabled:h===E,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:"#ff6b6b",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:h===E?"wait":"pointer",opacity:h===E?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:h===E?"...":"DELETE"})]},E))]}),v.length===0&&b.length===0&&j.length===0&&n.staleBranches.length===0&&l.jsxs("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:["โ"," All clean. No active worktrees or stale branches."]}),n.lastMerge&&l.jsxs("div",{style:{marginTop:16,fontSize:11,color:"rgba(255,255,255,0.3)",lineHeight:1.5},children:["Last merge: ",l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:n.lastMerge.branch})," ยท ",n.lastMerge.roleId," ยท ",N(n.lastMerge.mergedAt)]})]})}function Eu({label:e,count:n}){return l.jsxs("h4",{style:{margin:"16px 0 8px",fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:1},children:[e," (",n,")"]})}function Xh({wt:e,roleFromBranch:n,truncatePath:a,timeAgo:i,removing:o,onRemove:u,statusColor:d,statusIcon:h}){return l.jsx("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:500,marginBottom:2},children:[l.jsx("span",{style:{marginRight:6},children:h}),e.branch,n&&l.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)",textTransform:"uppercase"},children:n})]}),e.task&&l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:2},children:['"',e.task.slice(0,50),e.task.length>50?"...":"",'"']}),l.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[a(e.path)," ยท ",e.filesChanged," file",e.filesChanged!==1?"s":""," changed"," ยท ",i(e.createdAt)]}),e.conflictFiles&&e.conflictFiles.length>0&&l.jsxs("div",{style:{fontSize:10,color:"#ff6b6b",marginTop:4},children:["โ"," CONFLICT: ",e.conflictFiles.join(", ")]})]}),l.jsx("button",{onClick:u,disabled:o,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:d,borderRadius:4,padding:"3px 8px",fontSize:10,cursor:o?"wait":"pointer",opacity:o?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:o?"...":"REMOVE"})]})})}function d8({onClose:e}){const[n,a]=w.useState(null),[i,o]=w.useState(!0),[u,d]=w.useState(null),[h,m]=w.useState(null),f=w.useCallback(async()=>{o(!0),d(null);try{const k=await me.getActiveSessions();a(k)}catch(k){d(k instanceof Error?k.message:"Failed to load sessions")}finally{o(!1)}},[]);w.useEffect(()=>{f();const k=setInterval(f,1e4);return()=>clearInterval(k)},[f]);const x=async k=>{m(k);try{await me.deleteActiveSession(k),await f()}catch(C){d(C instanceof Error?C.message:"Failed to remove session")}finally{m(null)}},y=async()=>{try{await me.cleanupActiveSessions(),await f()}catch(k){d(k instanceof Error?k.message:"Failed to cleanup sessions")}};if(i&&!n)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading sessions..."});if(u&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[u,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const v=n.sessions.filter(k=>k.status==="active"),b=n.sessions.filter(k=>k.status==="idle"),j=n.sessions.filter(k=>k.status==="dead");return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"ACTIVE SESSIONS"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[j.length>0&&l.jsx("button",{onClick:y,style:{background:"rgba(255,180,100,0.15)",border:"1px solid rgba(255,180,100,0.2)",color:"#FFB74D",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Cleanup Dead"}),l.jsx("button",{onClick:f,disabled:i,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:i?"wait":"pointer"},children:i?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"ร"})]})]}),u&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:u}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13,display:"flex",justifyContent:"space-between"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Sessions: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.active})]}),l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Ports in use: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.totalPorts})]})]}),v.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Wh,{label:"Active",count:v.length}),v.map(k=>l.jsx(Vh,{session:k,removing:h===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#4FC3F7"},k.sessionId))]}),b.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Wh,{label:"Idle",count:b.length}),b.map(k=>l.jsx(Vh,{session:k,removing:h===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#FFB74D"},k.sessionId))]}),j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Wh,{label:"Dead",count:j.length}),j.map(k=>l.jsx(Vh,{session:k,removing:h===k.sessionId,onRemove:()=>x(k.sessionId),statusColor:"#ff6b6b"},k.sessionId))]}),n.sessions.length===0&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:"No active sessions. Sessions appear when jobs run with port allocation."})]})}function Wh({label:e,count:n}){return l.jsxs("h4",{style:{margin:"16px 0 8px",fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:1},children:[e," (",n,")"]})}function f8(e){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Vh({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:[" ยท ",h8(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" ยท ","PID:",e.pid]})," ยท ",f8(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 h8(e,n=35){return e.length<=n?e:"..."+e.slice(e.length-n+3)}function m8({onClose:e,speechSettings:n,onSpeechSettingsChange:a,language:i,onLanguageChange:o,onOpenSync:u,onOpenGitStatus:d,onOpenSessions:h,onOpenStats:m}){var ae;const[f,x]=w.useState(null),[y,v]=w.useState(null),[b,j]=w.useState(!1),[k,C]=w.useState(!1),[N,E]=w.useState(!1),[_,z]=w.useState(null),[U,B]=w.useState(""),[$,q]=w.useState(!1),[L,R]=w.useState(!1),[I,H]=w.useState(null),[Q,oe]=w.useState(!1);w.useEffect(()=>{me.getPreferences().then(async Z=>{const G=Z;if(x(G.instanceId??null),G.instanceId)try{const{name:A}=await br.getMyName(G.instanceId);v(A)}catch{}}).catch(()=>{}),me.getCodeRoot().then(({codeRoot:Z})=>{z(Z),Z&&B(Z)}).catch(()=>{})},[]);const re=async()=>{E(!0);try{const G=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();G.ok&&(x(G.newInstanceId),C(!1))}catch{}E(!1)},Y=()=>{f&&navigator.clipboard.writeText(f).then(()=>{j(!0),setTimeout(()=>j(!1),2e3)})};return l.jsx("div",{className:"customize-overlay",onClick:e,children:l.jsxs("div",{className:"customize-modal",onClick:Z=>Z.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(Z=>l.jsxs("button",{onClick:()=>a==null?void 0:a({mode:Z}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(n==null?void 0:n.mode)===Z?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(n==null?void 0:n.mode)===Z?"rgba(255,255,255,0.08)":"transparent",color:(n==null?void 0:n.mode)===Z?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:Z==="template"?"TEMPLATE":Z==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:Z==="template"?"Static pool ($0)":Z==="llm"?"LLM generated":"Detect engine"})]},Z))}),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:Z=>a==null?void 0:a({intervalSec:Number(Z.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: $",((ae=n==null?void 0:n.dailyBudgetUsd)==null?void 0:ae.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(n==null?void 0:n.dailyBudgetUsd)??1,onChange:Z=>a==null?void 0:a({dailyBudgetUsd:Number(Z.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:Z,label:G})=>l.jsx("button",{onClick:()=>o==null?void 0:o(Z),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(i??"auto")===Z?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(i??"auto")===Z?"rgba(255,255,255,0.08)":"transparent",color:(i??"auto")===Z?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:G},Z))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"CODE REPOSITORY"}),$?l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:U,onChange:Z=>{B(Z.target.value),H(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(U.trim()){R(!0),H(null);try{const Z=await me.setCodeRoot(U.trim());z(Z.codeRoot),B(Z.codeRoot),q(!1),oe(!0),setTimeout(()=>oe(!1),3e3)}catch(Z){H(Z instanceof Error?Z.message:"Failed to set code root")}finally{R(!1)}}},disabled:L||!U.trim(),style:{padding:"8px 12px",fontSize:10,fontWeight:600,background:"var(--accent)",border:"none",color:"#fff",borderRadius:6,cursor:"pointer",opacity:L||!U.trim()?.5:1},children:L?"...":"Save"}),l.jsx("button",{onClick:()=>{q(!1),B(_||""),H(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"})]}),I&&l.jsx("div",{style:{fontSize:9,color:"#ff6b6b",marginTop:4},children:I})]}):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),H(null),oe(!1)},style:{padding:"8px 12px",fontSize:10,fontWeight:600,border:"2px solid rgba(255,255,255,0.1)",background:"transparent",color:"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer"},children:"Change"})]}),Q&&l.jsx("div",{style:{fontSize:9,color:"#4ade80",marginTop:4},children:"Code repository updated!"}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Path to your code repository (separate from AKB)"})]}),f&&l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"STORE TOKEN"}),l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l.jsx("code",{style:{flex:1,padding:"8px 10px",fontSize:10,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f}),l.jsx("button",{onClick:Y,style:{padding:"8px 12px",fontSize:10,fontWeight:600,border:"2px solid rgba(255,255,255,0.1)",background:"transparent",color:b?"#4ade80":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",whiteSpace:"nowrap"},children:b?"Copied!":"Copy"})]}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Use this token to sign in on the web Store. Keep it secret โ anyone with this token can act as you."}),l.jsx("div",{style:{marginTop:6},children:k?l.jsxs("div",{style:{background:"rgba(255,50,50,0.08)",border:"1px solid rgba(255,50,50,0.2)",borderRadius:6,padding:"8px 10px"},children:[l.jsx("div",{style:{fontSize:9,color:"rgba(255,100,100,0.8)",marginBottom:6},children:"This will invalidate your current token. Published characters will lose ownership. No migration."}),l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("button",{onClick:re,disabled:N,style:{padding:"4px 12px",fontSize:9,fontWeight:700,border:"1px solid rgba(255,50,50,0.4)",background:"rgba(255,50,50,0.15)",color:"#ff6464",borderRadius:4,cursor:"pointer"},children:N?"...":"Confirm Regenerate"}),l.jsx("button",{onClick:()=>C(!1),style:{padding:"4px 12px",fontSize:9,border:"none",background:"transparent",color:"var(--terminal-text-muted)",cursor:"pointer"},children:"Cancel"})]})]}):l.jsx("button",{onClick:()=>C(!0),style:{padding:"4px 10px",fontSize:9,fontWeight:600,border:"1px solid rgba(255,100,100,0.2)",background:"transparent",color:"rgba(255,100,100,0.6)",borderRadius:4,cursor:"pointer"},children:"Regenerate Token"})})]}),l.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.08)",paddingTop:16,display:"flex",gap:8},children:[u&&l.jsx("button",{onClick:()=>{e(),u()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"๐ ROLE SYNC"}),d&&l.jsx("button",{onClick:()=>{e(),d()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"๐ GIT STATUS"}),h&&l.jsx("button",{onClick:()=>{e(),h()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"๐ฅ SESSIONS"}),m&&l.jsx("button",{onClick:()=>{e(),m()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"๐ COMPANY STATS"}),l.jsx("button",{onClick:()=>window.open("https://tycono.ai/store.html","_blank"),className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"๐ WEB STORE"})]}),y&&l.jsx("div",{style:{textAlign:"center",marginTop:-8},children:l.jsx("a",{href:`https://tycono.ai/profile.html?u=${encodeURIComponent(y)}`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:10,color:"var(--terminal-text-muted)",textDecoration:"none"},onMouseEnter:Z=>Z.currentTarget.style.color="var(--accent)",onMouseLeave:Z=>Z.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile โ"})})]})})]})})}function p8({theme:e,onThemeChange:n,onClose:a}){const i=w.useRef(null);return w.useEffect(()=>{const o=u=>{i.current&&!i.current.contains(u.target)&&a()};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[a]),l.jsx("div",{ref:i,className:"theme-dropup",children:Object.entries(al).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 Ho={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function x8({roles:e,roleStatuses:n,activeExecs:a,sessions:i,knowledgeDocs:o,roleLevels:u,companyName:d,getAppearance:h,waveCenterWaves:m,profileContent:f,channel:x,onChannelChange:y,onClose:v,children:b}){const[j,k]=w.useState(!1),C=m.filter($=>$.rootJobs.some(q=>{const L=n[q.roleId];return L==="working"||L==="thinking"})),N=[...e].sort(($,q)=>$.level==="c-level"&&q.level!=="c-level"?-1:$.level!=="c-level"&&q.level==="c-level"?1:$.name.localeCompare(q.name)),E=e.filter($=>n[$.id]==="working").length,_=i.filter($=>$.status==="active").length,z=x.type==="role"?e.find($=>$.id===x.roleId):null,U=x.type==="dashboard"?"Dashboard":x.type==="terminal"?"Terminal":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",B=x.type==="terminal"?`${_} active sessions`:x.type==="wave"?`${C.length} running`:x.type==="knowledge"?`${o.length} documents`:x.type==="role"?(z==null?void 0:z.level)==="c-level"?"C-Level":"Team member":`${E} working ยท ${e.length} total`;return l.jsxs("div",{className:"fixed inset-0 z-[60] flex",style:{background:"var(--terminal-bg, #1C1612)"},children:[l.jsxs("div",{className:"flex flex-col shrink-0 overflow-y-auto",style:{width:240,borderRight:"1px solid var(--terminal-border, #2E261F)",background:"var(--terminal-surface, #1a1510)"},children:[l.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 shrink-0",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsx("span",{className:"text-[11px] font-bold tracking-wider flex-1",style:{color:"var(--terminal-text, #fff5eb)",fontFamily:"var(--pixel-font)"},children:d}),E>0&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full animate-pulse",style:{background:"#4CAF5020",color:"#4CAF50"},children:[E," live"]})]}),C.length>0&&l.jsxs("button",{className:"mx-3 mt-3 px-3 py-2.5 rounded-lg text-left transition-all hover:opacity-90",style:{background:x.type==="wave"?"#EF444420":"#EF444410",border:"1px solid #EF444430"},onClick:()=>y({type:"wave"}),children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsxs("span",{className:"text-[10px] font-bold truncate flex-1",style:{color:"#EF4444"},children:["โก"," ",C[0].directive.slice(0,28)]}),l.jsx("span",{className:"text-[7px] px-1.5 py-0.5 rounded font-bold shrink-0",style:{background:"#EF4444",color:"#fff"},children:"LIVE"})]}),l.jsxs("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted)"},children:[C[0].rootJobs.filter($=>{const q=n[$.roleId];return q==="working"||q==="thinking"}).length,"/",C[0].rootJobs.length," roles working"]})]}),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:"CHANNELS"}),l.jsx(Au,{icon:"#",label:"general",active:x.type==="terminal",badge:_>0?_:void 0,onClick:()=>y({type:"terminal"})}),l.jsx(Au,{icon:"โก",label:"wave-log",active:x.type==="wave",live:C.length>0,onClick:()=>y({type:"wave"})}),l.jsx(Au,{icon:"#",label:"decisions",active:x.type==="operations",onClick:()=>y({type:"operations"})}),l.jsx(Au,{icon:"๐",label:"knowledge",active:x.type==="knowledge",onClick:()=>y({type:"knowledge"})})]}),l.jsxs("div",{className:"mt-4",children:[l.jsx("div",{className:"px-4 py-1 text-[9px] font-bold tracking-widest",style:{color:"var(--terminal-text-muted)"},children:"TEAM"}),N.map($=>{var Q;const q=n[$.id],L=a.find(oe=>oe.roleId===$.id),R=Ho[$.id]??"#666",I=(Q=u[$.id])==null?void 0:Q.level,H=x.type==="role"&&x.roleId===$.id;return l.jsxs("button",{onClick:()=>y({type:"role",roleId:$.id}),className:"flex items-center gap-2.5 w-full px-4 py-1.5 text-left hover:opacity-80 transition-all",style:{background:H?`${R}18`:"transparent",borderLeft:H?`2px solid ${R}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx(nl,{roleId:$.id,appearance:h($.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:[$.name,I!=null&&l.jsxs("span",{className:"ml-1 opacity-40 text-[8px]",children:["Lv.",I]})]}),L?l.jsx("div",{className:"text-[9px] truncate",style:{color:R},children:L.task.slice(0,28)}):l.jsx("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted, #887766)"},children:$.level==="c-level"?$.id.toUpperCase():$.id})]}),q==="working"&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:R}})]},$.id)})]}),l.jsx("div",{className:"flex-1"}),l.jsx("div",{className:"px-3 py-3 shrink-0",style:{borderTop:"1px solid var(--terminal-border, #2E261F)"},children:l.jsxs("button",{onClick:v,className:"flex items-center gap-2 w-full px-3 py-2.5 rounded-lg hover:opacity-80 transition-opacity",style:{background:"var(--terminal-border, #2E261F)",color:"var(--terminal-text, #fff5eb)"},children:[l.jsx("span",{className:"text-[12px]",children:"๐ข"}),l.jsx("span",{className:"text-[11px] font-medium",children:"Office"})]})})]}),l.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[l.jsxs("div",{className:"px-5 py-3 flex items-center gap-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[x.type==="role"&&z&&l.jsxs("button",{onClick:()=>k($=>!$),className:"relative shrink-0 rounded-lg overflow-hidden hover:opacity-80 transition-opacity cursor-pointer",style:{width:28,height:28,background:`${Ho[z.id]??"#666"}30`},title:"View profile",children:[l.jsx(nl,{roleId:z.id,appearance:h(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:U}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted, #887766)"},children:B}),l.jsx("span",{className:"flex-1"}),x.type==="role"&&l.jsx("button",{onClick:()=>k($=>!$),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:j?"var(--terminal-text)":"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)",background:j?"var(--terminal-border)":"transparent"},children:"Profile"}),x.type!=="dashboard"&&l.jsx("button",{onClick:()=>y({type:"dashboard"}),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Dashboard"})]}),l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx("div",{className:"flex-1 overflow-hidden relative pro-panel-inline",children:b}),j&&x.type==="role"&&f&&l.jsx("div",{className:"shrink-0 overflow-hidden pro-panel-inline",style:{width:420,borderLeft:"1px solid var(--terminal-border, #2E261F)"},children:f})]})]})]})}function y8({role:e,messages:n,isStreaming:a,mode:i,onModeChange:o,onSend:u,isWave:d}){const h=Ho[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsx(vv,{messages:n,roleId:e.id,roleColor:h}),d?l.jsxs("div",{className:"shrink-0 px-4 py-2 border-t flex items-center gap-2",style:{borderColor:"var(--terminal-border)",background:"var(--terminal-bg-deeper)"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",style:{animation:"pulse 2s infinite"}}),l.jsx("span",{className:"text-[11px] text-amber-400/80",children:"Wave execution ยท read-only"})]}):l.jsx(ep,{mode:i,onModeChange:o,onSend:(m,f)=>u(m,i,f),disabled:a,disabledReason:a?`${e.id.toUpperCase()} is responding...`:void 0})]})}function g8({role:e,onSend:n,getAppearance:a,onOpenProfile:i}){const[o,u]=w.useState("talk"),d=Ho[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(nl,{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(ep,{mode:o,onModeChange:u,onSend:h=>n(h,o),disabled:!1})]})}function Au({icon:e,label:n,active:a,badge:i,live:o,onClick:u}){return l.jsxs("button",{onClick:u,className:"flex items-center gap-2.5 w-full px-4 py-1.5 text-left hover:opacity-80 transition-all",style:{background:a?"var(--terminal-border, #2E261F)":"transparent"},children:[l.jsx("span",{className:"text-[11px] w-4 text-center",style:{color:a?"var(--terminal-text)":"var(--terminal-text-muted)"},children:e}),l.jsx("span",{className:"text-[11px] flex-1",style:{color:a?"var(--terminal-text, #fff5eb)":"var(--terminal-text-muted, #887766)",fontWeight:a?600:400},children:n}),o&&l.jsx("span",{className:"text-[7px] px-1 py-0.5 rounded font-bold",style:{background:"#EF444420",color:"#EF4444"},children:"live"}),i!==void 0&&i>0&&!o&&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:i})]})}function b8({roles:e,roleStatuses:n,activeExecs:a,waves:i,knowledgeDocs:o,roleLevels:u,getAppearance:d,onRoleClick:h,onWaveClick:m,onKnowledgeClick:f}){const x=e.filter(y=>n[y.id]==="working");return l.jsx("div",{className:"h-full overflow-y-auto px-6 py-5",children:l.jsxs("div",{className:"space-y-5 max-w-4xl",children:[l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Cg,{label:"New Wave",icon:"โก",color:"#EF4444",onClick:m}),l.jsx(Cg,{label:"Knowledge",icon:"๐",color:"#0D9488",onClick:f})]}),x.length>0&&l.jsx(Du,{title:"Currently Working",count:x.length,children:a.map(y=>{const v=e.find(j=>j.id===y.roleId),b=Ho[y.roleId]??"#666";return l.jsxs("button",{onClick:()=>h(y.roleId),className:"flex items-center gap-3 px-4 py-2.5 rounded hover:opacity-80 w-full text-left",style:{background:`${b}10`},children:[l.jsx("div",{className:"shrink-0",style:{width:24,height:24},children:l.jsx(nl,{roleId:y.roleId,appearance:d(y.roleId),scale:1.2})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-[12px] font-medium",style:{color:b},children:v==null?void 0:v.name}),l.jsx("span",{className:"text-[11px] ml-2 truncate",style:{color:"var(--terminal-text-muted)"},children:y.task.slice(0,60)})]}),l.jsx("span",{className:"text-[10px] animate-pulse",style:{color:b},children:"โ"})]},y.roleId)})}),l.jsx(Du,{title:"Team",count:e.length,children:l.jsx("div",{className:"grid grid-cols-3 gap-1 px-2",children:e.map(y=>{var j;const v=n[y.id]??"offline",b=(j=u[y.id])==null?void 0:j.level;return l.jsxs("button",{onClick:()=>h(y.id),className:"flex items-center gap-2 px-3 py-2 rounded hover:opacity-80 text-left",children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:v==="working"?"#4CAF50":v==="idle"?"#FFC107":"#9E9E9E"}}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:y.name}),b!=null&&l.jsxs("span",{className:"text-[9px] opacity-40",children:["Lv.",b]})]},y.id)})})}),i.length>0&&l.jsx(Du,{title:"Recent Waves",count:i.length,children:i.slice(0,5).map(y=>{var v;return l.jsxs("div",{className:"px-4 py-2 text-[11px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("span",{style:{color:"var(--terminal-text)"},children:["Wave ",y.id]})," โ ",(v=y.directive)==null?void 0:v.slice(0,80)]},y.id)})}),l.jsx(Du,{title:"Knowledge Base",count:o.length,children:l.jsxs("button",{onClick:f,className:"px-4 py-3 text-[11px] hover:opacity-80",style:{color:"var(--terminal-text-muted)"},children:[o.length," documents ยท Click to explore ","โ"]})})]})})}function Cg({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 Du({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 Sm=5e4;function Ov(e){return e<Sm?1:Math.max(1,Math.floor(Math.sqrt(e/Sm)))}function Ng(e){return Sm*e*e}function v8(e){const n=Ov(e),a=Ng(n),i=Ng(n+1);return Math.min(1,(e-a)/(i-a))}function Gh(e){const n={};for(const[a,i]of Object.entries(e)){const o=i.inputTokens+i.outputTokens;n[a]={level:Ov(o),totalTokens:o,progress:v8(o)}}return n}const w8=[{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 Eg(e){return w8.filter(n=>n.check(e))}const k8={cto:"๐๏ธ",cbo:"๐",pm:"๐",engineer:"โ๏ธ",designer:"๐จ",qa:"๐","data-analyst":"๐"},Ou={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},j8={cto:"์ํคํ
์ฒ",cbo:"์์ฅ ๋ถ์",pm:"PRD ์์ฑ",engineer:"์ฝ๋ฉ",designer:"์์ ์ ์",qa:"ํ์ง ๊ฒ์ฆ"};function S8(e){let n=0;for(let i=0;i<e.length;i++)n=e.charCodeAt(i)+((n<<5)-n);return`hsl(${(n%360+360)%360}, 50%, 40%)`}function C8({importJob:e,onImportDone:n}){var zs,ac,lc,ic,sc;const[a,i]=w.useState([]),[o,u]=w.useState([]),[d,h]=w.useState([]),[m,f]=w.useState([]),[x,y]=w.useState([]),[v,b]=w.useState([]),[j,k]=w.useState("TYCONO"),[C,N]=w.useState(!0),[E,_]=w.useState(null),[z,U]=w.useState({type:"none"}),[B,$]=w.useState(null),[q,L]=w.useState(null),[R,I]=w.useState([]),[H,Q]=w.useState(!1),[oe,re]=w.useState(!1),[Y,ae]=w.useState([]),[Z,G]=w.useState([]),[A,F]=w.useState(0),[W,D]=w.useState(!1),[te,je]=w.useState({}),[ve,ze]=w.useState("ceo"),[Xe,de]=w.useState(null),[Oe,Qe]=w.useState(!1),[Se,Je]=w.useState(!1),[Re,Et]=w.useState({}),ut=w.useRef({}),[gt,kt]=w.useState(!1),[pe,xe]=w.useState(null),[ge,$e]=w.useState({}),[Be,Le]=w.useState([]),Ee=w.useMemo(()=>{const T={};for(const K of Be)T[K.roleId]=K;return T},[Be]),[P,ue]=w.useState([]),[ye,Ne]=w.useState(0),[Me,Pe]=w.useState(Gy()),_t=w.useRef(Gy()),dt=w.useRef(!1),ht=w.useRef(-1),[bt,et]=w.useState(null),Fe=w.useRef(null),[_e,nn]=w.useState(void 0),[fn,Vt]=w.useState(!1);w.useEffect(()=>{me.getStatus().then(T=>{nn(T.engine),Vt(!!T.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:yt,setAppearance:pn,resetAppearance:Mn,theme:J,setTheme:We,speechSettings:ot,setSpeechSettings:xn,language:ke,setLanguage:Mt}=A6(),[hn,cn]=w.useState(null),[,ua]=w.useState("character"),wt=F6(),[nr,il]=w.useState(!1),[Vo,wr]=w.useState(!1),[Rn,Ln]=w.useState(!1),[da,sl]=w.useState(!1),[ad,Ds]=w.useState(!1),[Go,Fa]=w.useState(!1),[Fi,fa]=w.useState(!1),[qn,Gl]=w.useState(null);w.useEffect(()=>{wt.refresh()},[]),w.useEffect(()=>{const T=K=>{(K.metaKey||K.ctrlKey)&&K.key==="s"&&(K.preventDefault(),il(!0))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[]),w.useEffect(()=>{if(!da)return;let T=!1;const K=async()=>{try{const he=await me.getGitStatus();T||Gl(he)}catch{}};K();const ee=setInterval(K,1e4);return()=>{T=!0,clearInterval(ee)}},[da]);const[kr,yn]=w.useState(null),[Ma,Ra]=w.useState(null),[cr,za]=w.useState([]),[ol,Ts]=w.useState(!1),Fs=w.useRef(!1),Ms=w.useRef(null);let Kl=w.useRef(0);const Ql=w.useRef(new Set),Zr=w.useRef(Date.now()),Sn=(T,K,ee)=>{const he={id:Kl.current++,type:T,text:K,detail:ee};za(Ce=>[...Ce,he])};w.useEffect(()=>{var T;ol&&((T=Ms.current)==null||T.scrollIntoView({behavior:"smooth"}))},[cr,ol]),w.useEffect(()=>{e&&(Fs.current||(Fs.current=!0,Ra("Scanning knowledge sources..."),za([{id:0,type:"scan",text:"Starting knowledge import..."}]),Kl.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 T=>{var Ce;const K=(Ce=T.body)==null?void 0:Ce.getReader();if(!K)return;const ee=new TextDecoder;let he="";for(;;){const{done:Ye,value:mt}=await K.read();if(Ye)break;he+=ee.decode(mt,{stream:!0});const it=he.split(`
|
|
92
|
+
`);he=it.pop()||"";let Ge="";for(const rt of it)if(rt.startsWith("event: "))Ge=rt.slice(7).trim();else if(rt.startsWith("data: ")&&Ge){try{const at=JSON.parse(rt.slice(6));switch(Ge){case"scanning":Ra(`Scanning: ${at.path} (${at.fileCount} files)`),Sn("scan",`Found ${at.fileCount} files`,at.path);break;case"processing":yn({index:at.index,total:at.total}),Ra(`Importing knowledge... (${at.index}/${at.total})`),Sn("process",`Processing: ${at.file}`,`${at.index} / ${at.total}`);break;case"created":Sn("created",at.title,at.summary);break;case"skipped":Sn("process",`Skipped: ${at.file}`,at.reason);break;case"done":Ra(null),yn(null),Sn("done",`Import complete! ${at.created} created, ${at.skipped} skipped.`),At(`Knowledge import complete! ${at.created} documents imported.`,"#2E7D32"),n==null||n();break;case"error":Ra(null),yn(null),Sn("error",at.message),At(`Import failed: ${at.message}`,"#B71C1C"),n==null||n();break}}catch{}Ge=""}}}).catch(T=>{Ra(null),Sn("error",T.message),At(`Import error: ${T.message}`,"#B71C1C"),n==null||n()})))},[e]);const[wn,Jr]=w.useState("iso"),ea=w.useRef("iso"),[Or,Cn]=w.useState({type:"dashboard"}),[Ko,ur]=w.useState(typeof window<"u"?window.innerWidth:1200);w.useEffect(()=>{const T=()=>ur(window.innerWidth);return window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]);const Pl=Ko<1024,[rr,ha]=w.useState(!1),[dr,Qo]=w.useState(560),[In,Ut]=w.useState([]),[ma,Yn]=w.useState(null),[ta,Zl]=w.useState(null),{sendMessage:ld}=C6(),Jl=w.useRef(new Map);w.useEffect(()=>{Promise.all([me.getCompany().then(T=>{k(T.name),i(T.roles)}),me.getOrgTree().then(T=>{je(T.nodes),ze(T.root)}).catch(()=>{}),me.getCostSummary().then(T=>Sr(Gh(T.byRole))).catch(()=>{})]).catch(T=>_(`Failed to load: ${T.message}`)).finally(()=>N(!1)),me.getProjects().then(u).catch(()=>{}),me.getStandups().then(h).catch(()=>{}),me.getWaves().then(f).catch(()=>{}),me.getDecisions().then(y).catch(()=>{}),me.getKnowledge().then(b).catch(()=>{}),me.getQuestProgress().then(T=>{const K=TE(T);K.activeChapter!==T.activeChapter&&me.saveQuestProgress(K).catch(()=>{}),Pe(K),_t.current=K,dt.current=!0,me.getCoins().then(ee=>{var he;ee.totalEarned===0?me.migrateCoins(((he=K.completedQuests)==null?void 0:he.length)??0).then(Ce=>Ne(Ce.balance)).catch(()=>{}):Ne(ee.balance)}).catch(()=>{})}).catch(()=>{dt.current=!0})},[]),w.useEffect(()=>{if(ht.current===-1){ht.current=o.length;return}o.length>ht.current&&qt({type:"project_created"}),ht.current=o.length},[o.length]),w.useEffect(()=>{if(!(!dt.current||a.length===0))for(const T of a)qt({type:"role_hired",condition:{roleId:T.id,roleCount:a.length}})},[a.length,Me.activeChapter,Me.completedQuests.length]),w.useEffect(()=>{me.getSessions().then(T=>{if(T.length>0){const K=T.map(he=>({...he,messages:[]}));Ut(K);const ee=K.find(he=>he.status==="active")??K[0];Yn(ee.id),pa()}}).catch(T=>{console.error("Failed to load sessions",T)})},[]),w.useEffect(()=>{const T=()=>{fetch("/api/exec/status").then(ee=>ee.json()).then(ee=>{$e(ee.statuses??{}),Le(ee.activeExecutions??[])}).catch(()=>{})};T();const K=setInterval(T,3e3);return()=>clearInterval(K)},[]);const jr=w.useMemo(()=>{const T={...ge};if(ta){const K=In.find(ee=>ee.id===ta);K&&(T[K.roleId]="working")}return T},[ge,ta,In]);w.useEffect(()=>{z.type==="role"?me.getRole(z.roleId).then($).catch(console.error):$(null)},[z]);const Xn=()=>U({type:"none"}),mn=T=>{U(T),ha(!1),re(!1)},pa=()=>{ha(!0),U({type:"none"}),re(!1)},na=()=>{re(!0),ha(!1),U({type:"none"})},cl=async(T,K)=>{const ee=a.find(Ce=>Ce.id===T),he=(q==null?void 0:q.mode)==="ask";L(null);try{const{jobId:Ce}=await me.startJob({type:"assign",roleId:T,task:K,readOnly:he}),Ye=Ou[T]??"#666",mt=`${T.toUpperCase()} ยท ${(ee==null?void 0:ee.name)??T}`;D(!1),I([{jobId:Ce,title:mt,color:Ye}]),qt({type:"task_executed",condition:{roleId:T}}),Gt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO โ ${(ee==null?void 0:ee.name)??T}] ${he?"Ask":"Assign"}: ${K}`,type:"dispatch",targetRoleId:T})}catch(Ce){At(`Failed to start job: ${Ce instanceof Error?Ce.message:"unknown"}`,"#C62828")}},Po=w.useRef(0),At=(T,K)=>{const ee=++Po.current;ue(he=>[...he,{id:ee,message:T,color:K}]),setTimeout(()=>ue(he=>he.filter(Ce=>Ce.id!==ee)),4e3)},Zo=T=>{Fe.current&&clearTimeout(Fe.current),et(T),Fe.current=setTimeout(()=>et(null),8e3)},qt=T=>{if(!dt.current)return;let K=_t.current;const ee=uv(K);let he=0;const Ce=[];for(const mt of ee){if(!ME(mt,T))continue;const{progress:it,quest:Ge}=DE(K,mt.id);Ge&&(K=it,he+=Ge.rewards.coins??0,Ce.push(Ge.title))}if(Ce.length===0)return;_t.current=K,Pe(K);const Ye=he>0?` ๐ฐ +${he.toLocaleString()}`:"";Ce.length===1?At(`๐ Quest complete: ${Ce[0]}${Ye}`,"#7C3AED"):At(`๐ ${Ce.length} quests complete!${Ye}`,"#7C3AED"),et(null),me.saveQuestProgress(K).catch(()=>{}),he>0&&me.earnCoins(he,`quests: ${Ce.length}`,Ce.join(",")).then(mt=>Ne(mt.balance)).catch(()=>{})};w.useEffect(()=>{if(!bt)return;const T=document.querySelector(`[data-quest-target="${bt}"]`);if(!T)return;T.classList.add("quest-spotlight");const K=()=>{T.classList.remove("quest-spotlight"),et(null),Fe.current&&clearTimeout(Fe.current)};return T.addEventListener("click",K,{once:!0}),()=>{T.classList.remove("quest-spotlight"),T.removeEventListener("click",K)}},[bt]);const Sr=T=>{var ee,he;const K=ut.current;for(const[Ce,Ye]of Object.entries(T)){const mt=((ee=K[Ce])==null?void 0:ee.level)??0;if(mt>0&&Ye.level>mt){const it=((he=a.find(Ge=>Ge.id===Ce))==null?void 0:he.name)??Ce.toUpperCase();At(`${it} leveled up to Lv.${Ye.level}!`,"#7C3AED")}}ut.current=T,Et(T)};w.useEffect(()=>{const T={roles:Object.entries(Re).map(([Ce,Ye])=>({id:Ce,level:Ye.level,totalTokens:Ye.totalTokens})),totalTokens:Object.values(Re).reduce((Ce,Ye)=>Ce+Ye.totalTokens,0),roleCount:a.length,completedQuests:Me.completedQuests},K=Eg(T),ee=new Set(K.map(Ce=>Ce.id));if(Date.now()-Zr.current>5e3){const Ce=Ql.current;for(const Ye of K)Ce.has(Ye.id)||At(`${Ye.icon} Badge earned: ${Ye.name}!`,"#D4A017")}Ql.current=ee},[Re,a.length,Me.completedQuests]);const _a=w.useMemo(()=>AE(Me),[Me]),ei=()=>{var K;const T=R[R.length-1];T&&(At(`${T.title} completed`,T.color),Gt.pushMessage({ts:Date.now(),roleId:((K=T.title.split(" ยท ")[0])==null?void 0:K.toLowerCase())??"unknown",text:`[${T.title}] Job completed`,type:"dispatch"})),me.getStandups().then(h).catch(console.error),me.getCompany().then(ee=>i(ee.roles)).catch(console.error),me.getCostSummary().then(ee=>Sr(Gh(ee.byRole))).catch(()=>{})},xa=(T,K)=>{const ee=`wave-${T}`,he=new AbortController;Jl.current.set(T,he);const Ce={id:`msg-wave-${T}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};Ut(Ye=>Ye.map(mt=>mt.id===ee?{...mt,messages:[...mt.messages,Ce]}:mt)),fetch(`/api/jobs/${T}/stream?from=0`,{signal:he.signal}).then(async Ye=>{if(!Ye.ok||!Ye.body)return;const mt=Ye.body.getReader(),it=new TextDecoder;let Ge="";for(;;){const{done:rt,value:at}=await mt.read();if(rt)break;Ge+=it.decode(at,{stream:!0});const Yt=Ge.split(`
|
|
93
|
+
`);Ge=Yt.pop()??"";let jt="";for(const ar of Yt)if(ar.startsWith("event: "))jt=ar.slice(7).trim();else if(ar.startsWith("data: ")){try{const fl=JSON.parse(ar.slice(6));if(jt==="activity"){const Kt=fl;Ut(hl=>hl.map(Ir=>{if(Ir.id!==ee)return Ir;const Hn=[...Ir.messages],Li=Hn[Hn.length-1];if(!Li||Li.from!=="role")return Ir;const gn={...Li};if(Kt.type==="text")gn.content=(gn.content??"")+(Kt.data.text??"");else if(Kt.type==="thinking")gn.thinking=(gn.thinking??"")+(Kt.data.text??""),gn.streamEvents=[...gn.streamEvents??[],{type:"thinking",timestamp:Date.now(),text:Kt.data.text}];else if(Kt.type==="tool:start")gn.streamEvents=[...gn.streamEvents??[],{type:"tool",timestamp:Date.now(),toolName:Kt.data.name,toolInput:Kt.data.input}];else if(Kt.type==="dispatch:start")gn.streamEvents=[...gn.streamEvents??[],{type:"dispatch",timestamp:Date.now(),roleId:Kt.data.targetRoleId,task:Kt.data.task}];else if(Kt.type==="turn:complete")gn.streamEvents=[...gn.streamEvents??[],{type:"turn",timestamp:Date.now(),turn:Kt.data.turn}];else{if(Kt.type==="job:done")return gn.status="done",Hn[Hn.length-1]=gn,{...Ir,messages:Hn,status:"closed"};if(Kt.type==="job:error")return gn.status="error",Kt.data.message&&(gn.content=gn.content||Kt.data.message),Hn[Hn.length-1]=gn,{...Ir,messages:Hn,status:"closed"}}return Hn[Hn.length-1]=gn,{...Ir,messages:Hn}}))}else jt==="stream:end"&&Ut(Kt=>Kt.map(hl=>{if(hl.id!==ee)return hl;const Ir=hl.messages.map(Hn=>Hn.status==="streaming"?{...Hn,status:"done"}:Hn);return{...hl,messages:Ir,status:"closed"}}))}catch{}jt=""}}}).catch(Ye=>{Ye.name!=="AbortError"&&Ut(mt=>mt.map(it=>{if(it.id!==ee)return it;const Ge=it.messages.map(rt=>rt.status==="streaming"?{...rt,status:"error"}:rt);return{...it,messages:Ge,status:"closed"}}))})},ti=async(T,K)=>{Q(!1);try{const ee=await me.startJob({type:"wave",directive:T,targetRoles:K});qt({type:"wave_dispatched"});const he=ee.jobIds??(ee.jobId?[ee.jobId]:[]),Ce=ve&&te[ve]?te[ve].children.map(jt=>a.find(ar=>ar.id===jt)).filter(jt=>!!jt):a.filter(jt=>jt.level==="c-level"),Ye=K?Ce.filter(jt=>K.includes(jt.id)):Ce,mt=he.map((jt,ar)=>{var fl,Kt;return{jobId:jt,roleId:((fl=Ye[ar])==null?void 0:fl.id)??`role-${ar}`,roleName:((Kt=Ye[ar])==null?void 0:Kt.name)??`C-Level ${ar+1}`}});Gt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${T}" โ ${mt.map(jt=>jt.roleName).join(", ")}`,type:"dispatch"});const it=ee.waveId??`wave-${Date.now()}`,Ge=ee.sessionIds??[],rt={id:it,directive:T,rootJobs:mt,startedAt:Date.now(),sessionIds:Ge};ae(jt=>[rt,...jt]),na();const at=new Date().toISOString(),Yt=Ge.length>0?mt.map((jt,ar)=>({id:Ge[ar]??`wave-${jt.jobId}`,roleId:jt.roleId,title:`WAVE: ${jt.roleName}`,mode:"do",source:"wave",jobId:jt.jobId,messages:[{id:`msg-wave-${jt.jobId}-ceo`,from:"ceo",content:T,type:"directive",status:"done",timestamp:at}],status:"active",createdAt:at,updatedAt:at})):mt.map(jt=>({id:`wave-${jt.jobId}`,roleId:jt.roleId,title:`WAVE: ${jt.roleName}`,mode:"do",source:"wave",jobId:jt.jobId,messages:[{id:`msg-wave-${jt.jobId}-ceo`,from:"ceo",content:T,type:"directive",status:"done",timestamp:at}],status:"active",createdAt:at,updatedAt:at}));Ut(jt=>[...Yt,...jt]),Yt.length>0&&(Yn(Yt[0].id),pa());for(const jt of mt)xa(jt.jobId,jt.roleId)}catch(ee){At(`Failed to start wave: ${ee instanceof Error?ee.message:"unknown"}`,"#C62828")}},$r=()=>{me.getWaves().then(f).catch(console.error),me.getStandups().then(h).catch(console.error)},Mi=()=>{me.getCompany().then(T=>i(T.roles)).catch(console.error),me.getOrgTree().then(T=>{je(T.nodes),ze(T.root)}).catch(console.error),me.getCostSummary().then(T=>Sr(Gh(T.byRole))).catch(()=>{})},Ri=async(T,K)=>{await me.createRole(T),pn(T.id,K),Mi(),At(`${T.name} hired!`,"#2E7D32"),qt({type:"role_hired",condition:{roleId:T.id,roleCount:a.length+1}})},zi=async T=>{var K;await me.deleteRole(T),Mi(),Ut(ee=>ee.filter(he=>he.roleId!==T)),ma&&((K=In.find(ee=>ee.id===ma))==null?void 0:K.roleId)===T&&Yn(null),xe(null),At(`${T.toUpperCase()} removed`,"#B71C1C")},_i=async(T,K)=>{await me.updateRole(T,K),Mi(),z.type==="role"&&z.roleId===T&&me.getRole(T).then($).catch(console.error),K.name&&At(`${T.toUpperCase()} renamed to "${K.name}"`,"#1565C0"),K.persona!==void 0&&(At(`${T.toUpperCase()} persona updated`,"#2E7D32"),qt({type:"persona_updated"}))},Pn=T=>{pa(),qt({type:"terminal_opened"})},ya=async T=>{try{const K=await me.createSession(T,"talk");Ut(ee=>[K,...ee]),Yn(K.id),pa()}catch(K){console.error("Failed to create session",K),At(`Failed to create session: ${K instanceof Error?K.message:"API unreachable"}`,"#B71C1C")}},ul=async T=>{try{const K=await me.createSession(T,"talk");Ut(ee=>[K,...ee]),Yn(K.id)}catch(K){console.error("Failed to create session",K),At(`Failed to create session: ${K instanceof Error?K.message:"API unreachable"}`,"#B71C1C")}},ni=async T=>{const K=Ee[T],ee=(K==null?void 0:K.jobId)??(K==null?void 0:K.id);if(ee&&jr[T]==="working"){const Ce=a.find(it=>it.id===T),Ye=Ou[T]??"#666",mt=`${T.toUpperCase()} ยท ${(Ce==null?void 0:Ce.name)??T}`;I([{jobId:ee,title:mt,color:Ye}]),D(!1);return}const he=In.find(Ce=>Ce.roleId===T);if(he)Yn(he.id),Gt.setActiveChannelId(null);else try{const Ce=await me.createSession(T,"talk");Ut(Ye=>[Ce,...Ye]),Yn(Ce.id),Gt.setActiveChannelId(null)}catch(Ce){console.error("Failed to create session",Ce)}pa()},Jo=async T=>{const K=In.find(ee=>ee.id===T);if((K==null?void 0:K.source)==="wave"){if(K.jobId){const ee=Jl.current.get(K.jobId);ee&&(ee.abort(),Jl.current.delete(K.jobId))}Ut(ee=>{var Ce;const he=ee.filter(Ye=>Ye.id!==T);return ma===T&&Yn(((Ce=he[0])==null?void 0:Ce.id)??null),he});return}try{await me.deleteSession(T),Ut(ee=>{var Ce;const he=ee.filter(Ye=>Ye.id!==T);return ma===T&&Yn(((Ce=he[0])==null?void 0:Ce.id)??null),he})}catch(ee){console.error("Failed to delete session",ee),At(`Failed to close session: ${ee instanceof Error?ee.message:"API error"}`,"#B71C1C")}},Bi=async()=>{try{const{ids:T}=await me.deleteEmptySessions();if(T.length===0)return;Ut(K=>{var he;const ee=K.filter(Ce=>!T.includes(Ce.id));return ma&&T.includes(ma)&&Yn(((he=ee[0])==null?void 0:he.id)??null),ee}),At(`Cleared ${T.length} empty session${T.length!==1?"s":""}`,"#2E7D32")}catch(T){At(`Failed to clear empty sessions: ${T instanceof Error?T.message:"API error"}`,"#B71C1C")}},Oi=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const T=In.filter(K=>K.source!=="wave").map(K=>K.id);for(const K of In)if(K.source==="wave"&&K.jobId){const ee=Jl.current.get(K.jobId);ee&&(ee.abort(),Jl.current.delete(K.jobId))}try{T.length>0&&await me.deleteSessions(T),Ut([]),Yn(null),At("All sessions closed","#2E7D32")}catch(K){At(`Failed to close sessions: ${K instanceof Error?K.message:"API error"}`,"#B71C1C")}},fr=(T,K)=>{Ut(ee=>ee.map(he=>{if(he.id!==T)return he;const Ce=[...he.messages],Ye=Ce[Ce.length-1];if(Ye&&Ye.from==="role"&&Ye.status==="streaming"){const mt=[...Ye.streamEvents??[],K];Ce[Ce.length-1]={...Ye,streamEvents:mt}}return{...he,messages:Ce}}))},Lr=(T,K,ee,he)=>{const Ce={id:`msg-${Date.now()}-ceo`,from:"ceo",content:K,type:ee==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:he},Ye={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};Ut(it=>it.map(Ge=>Ge.id===T?{...Ge,messages:[...Ge.messages,Ce,Ye],updatedAt:new Date().toISOString()}:Ge));const mt=In.find(it=>it.id===T);ee==="talk"?qt({type:"talk_mode_used"}):ee==="do"&&(qt({type:"do_mode_used"}),mt&&qt({type:"task_executed",condition:{roleId:mt.roleId}})),Zl(T),ld(T,K,ee,{onThinking:it=>{Ut(Ge=>Ge.map(rt=>{if(rt.id!==T)return rt;const at=[...rt.messages],Yt=at[at.length-1];return Yt&&Yt.from==="role"&&Yt.status==="streaming"&&(at[at.length-1]={...Yt,thinking:(Yt.thinking??"")+it}),{...rt,messages:at}})),fr(T,{type:"thinking",timestamp:Date.now(),text:it})},onText:it=>{Ut(Ge=>Ge.map(rt=>{if(rt.id!==T)return rt;const at=[...rt.messages],Yt=at[at.length-1];return Yt&&Yt.from==="role"&&Yt.status==="streaming"&&(at[at.length-1]={...Yt,content:Yt.content+it}),{...rt,messages:at}}))},onToolUse:(it,Ge)=>{fr(T,{type:"tool",timestamp:Date.now(),toolName:it,toolInput:Ge})},onDispatch:(it,Ge)=>{fr(T,{type:"dispatch",timestamp:Date.now(),roleId:it,task:Ge})},onDispatchProgress:(it,Ge,rt)=>{var at;Ge==="tool"?fr(T,{type:"dispatch:progress",timestamp:Date.now(),roleId:it,progressType:"tool",toolName:rt.name,toolInput:rt.input}):Ge==="thinking"?fr(T,{type:"dispatch:progress",timestamp:Date.now(),roleId:it,progressType:"thinking",text:rt.text}):Ge==="text"?fr(T,{type:"dispatch:progress",timestamp:Date.now(),roleId:it,progressType:"text",text:(at=rt.text)==null?void 0:at.slice(-200)}):(Ge==="done"||Ge==="error")&&fr(T,{type:"dispatch:progress",timestamp:Date.now(),roleId:it,progressType:Ge})},onTurn:it=>{fr(T,{type:"turn",timestamp:Date.now(),turn:it})},onDone:()=>{Ut(it=>it.map(Ge=>{if(Ge.id!==T)return Ge;const rt=Ge.messages.map(Yt=>Yt.status==="streaming"?{...Yt,status:"done"}:Yt),at=Ge.messages.length<=2?K.slice(0,40).replace(/\n/g," "):Ge.title;return{...Ge,messages:rt,title:at}})),Zl(null)},onError:it=>{Ut(Ge=>Ge.map(rt=>{if(rt.id!==T)return rt;const at=rt.messages.map(Yt=>Yt.status==="streaming"?{...Yt,status:"error",content:Yt.content||it}:Yt);return{...rt,messages:at}})),Zl(null)}},he)},$i=(T,K)=>{Ut(ee=>ee.map(he=>he.id===T?{...he,mode:K}:he)),me.updateSession(T,{mode:K}).catch(console.error)},id=new Date().toISOString().slice(0,10),ga=o[0],ec={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},Rs=T=>{const K=ec[T];if(!K)return"";for(const ee of d){const he=ee.content,Ce=he.indexOf(`## ${K}`);if(Ce===-1)continue;const Ye=he.indexOf(`
|
|
94
|
+
## `,Ce+10),it=(Ye===-1?he.slice(Ce):he.slice(Ce,Ye)).split(`
|
|
95
|
+
`).filter(Ge=>Ge.trim().length>0);for(const Ge of it){const rt=Ge.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(rt.startsWith("|")||rt.startsWith("{")||rt.startsWith("[")||rt.startsWith("```")||rt.startsWith("---")||rt.includes("Journal")||rt.includes("(c-level)")||rt.includes("(team-lead)")||rt.includes("(member)")||/^(CEO |์์
๊ฒฐ๊ณผ|์์ฑ\/์์ |APPROVAL|๋น๊ณ |์ํฉ ๋ณด๊ณ |ํ์คํฌ$)/.test(rt))&&rt.length>15&&rt.length<120)return rt}}return""},tc=T=>{const K=ec[T];if(!K)return"";for(const ee of d){const he=ee.content,Ce=he.indexOf(`## ${K}`);if(Ce===-1)continue;const Ye=he.indexOf(`
|
|
96
|
+
## `,Ce+10),it=(Ye===-1?he.slice(Ce):he.slice(Ce,Ye)).replace(/^## .+\n/,"").trim();if(it)return it.slice(0,1500)}return""},Gt=X6();w.useEffect(()=>{a.length>0&&Gt.syncDefaultMembers(a)},[a]);const dl=I6({roles:a,roleStatuses:ge,activeExecs:Be,getStandupSpeech:Rs}),nc=K6({roles:a,roleStatuses:ge,activeExecs:Be,channels:Gt.channels,relationships:dl.relationships,pushMessage:Gt.pushMessage,speechSettings:ot,engineType:_e,hasApiKey:fn}),rc=w.useCallback((T,K)=>{Gt.pushMessage({ts:Date.now(),roleId:"ceo",text:K,type:"chat",channelId:T}),nc.triggerCeoReaction(T)},[Gt,nc]);return C?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(Ma||cr.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:()=>Ts(T=>!T),children:[Ma?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:Ma||"Knowledge import finished"}),kr&&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:`${kr.index/kr.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:[cr.map(T=>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:[T.type==="scan"&&"๐",T.type==="process"&&"โ๏ธ",T.type==="created"&&"โ
",T.type==="done"&&"๐",T.type==="error"&&"โ"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:T.type==="error"?"#EF4444":T.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:T.text}),T.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:T.detail})]})]},T.id)),l.jsx("div",{ref:Ms})]})]}),l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-4xl mb-3",children:"๐ข"}),l.jsx("div",{className:"text-gray-600 font-semibold text-xs",children:"LOADING OFFICE..."})]})})]}):E?l.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:l.jsxs("div",{className:"text-center max-w-md",style:{fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"text-4xl mb-3",children:"โ ๏ธ"}),l.jsx("div",{className:"text-gray-800 font-semibold mb-2 text-xs",children:"CONNECTION ERROR"}),l.jsx("div",{className:"text-gray-500 text-xs mb-4",children:E}),l.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white text-xs font-bold cursor-pointer border-2 border-gray-600",style:{fontFamily:"var(--pixel-font)"},children:"RETRY"})]})}):l.jsxs("div",{className:"flex flex-col",style:{height:"100dvh",fontFamily:"var(--pixel-font)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 text-white text-sm shrink-0 z-[45]",style:{background:"var(--bar-bg, var(--hud-bg))",borderBottom:"3px solid var(--bar-border, var(--pixel-border))"},children:[l.jsxs("div",{className:"font-black text-[13px] tracking-tight",style:{color:"var(--idle-amber)",textShadow:"2px 2px 0 rgba(0,0,0,0.5)"},children:["๐ข"," ",l.jsx("span",{style:{color:"var(--bar-text, var(--terminal-text))"},children:j})]}),l.jsxs("div",{className:"flex gap-4 text-[11px] items-center",style:{color:"var(--bar-text, var(--terminal-text-secondary))"},children:[(()=>{const T=ye>=1e6?`${(ye/1e6).toFixed(1)}M`:ye>=1e3?`${(ye/1e3).toFixed(1)}K`:String(ye),K=Be.length,ee=a.length>0?Math.round(K/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:T})]}),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:`${ee}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:ee})]})]})})(),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})]}),Be.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:Be.length})]}),(()=>{const T={roles:Object.entries(Re).map(([ee,he])=>({id:ee,level:he.level,totalTokens:he.totalTokens})),totalTokens:Object.values(Re).reduce((ee,he)=>ee+he.totalTokens,0),roleCount:a.length},K=Eg(T);return K.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:K.map(ee=>l.jsx("span",{title:`${ee.name}: ${ee.description}`,style:{fontSize:12,cursor:"default"},children:ee.icon},ee.id))}):null})(),l.jsx("span",{className:"px-1.5 py-0.5",style:{background:"var(--bar-border, var(--hud-bg-alt))",border:"1px solid var(--bar-border, var(--pixel-border))",color:"var(--bar-text, var(--terminal-text))"},children:id})]})]}),(Ma||cr.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:()=>Ts(T=>!T),children:[Ma?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:Ma||"Knowledge import finished"}),kr&&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:`${kr.index/kr.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:[cr.map(T=>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:[T.type==="scan"&&"๐",T.type==="process"&&"โ๏ธ",T.type==="created"&&"โ
",T.type==="done"&&"๐",T.type==="error"&&"โ"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:T.type==="error"?"#EF4444":T.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:T.text}),T.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:T.detail})]})]},T.id)),l.jsx("div",{ref:Ms}),cr.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:wn==="iso"?l.jsx(t8,{roles:a,projects:o,waves:m,standups:d,decisions:x,roleStatuses:jr,activeExecs:Be,onRoleClick:T=>mn({type:"role",roleId:T}),onProjectClick:T=>mn({type:"project",projectId:T}),onBulletinClick:()=>{mn({type:"bulletin"}),qt({type:"bulletin_visited"})},onDecisionsClick:()=>mn({type:"decisions"}),onKnowledgeClick:()=>{mn({type:"knowledge"}),qt({type:"knowledge_visited"})},onSettingsClick:()=>{Fa(!0),qt({type:"settings_visited"})},onThemeClick:()=>fa(T=>!T),onStatsClick:()=>{wr(!0),qt({type:"stats_visited"})},knowledgeDocsCount:v.length,getRoleSpeech:dl.getSpeech,getAppearance:yt,onHireClick:()=>kt(!0),onMascotClick:()=>mn({type:"quest"}),roleLevels:Re,coinBalance:ye,onCoinsSpent:T=>Ne(T),onFurniturePlaced:(T,K)=>{qt({type:"furniture_placed"}),K>0&&qt({type:"furniture_purchased"})}}):l.jsxs("div",{className:`${rr?"max-w-full":"max-w-[1100px]"} mx-auto h-full p-4 flex flex-col gap-3 relative z-[1]`,children:[(()=>{const T=a.filter(ee=>ee.level==="c-level"),K=a.filter(ee=>ee.level!=="c-level");return l.jsxs(l.Fragment,{children:[T.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"pixel-section-label",children:"LEADERSHIP"}),l.jsx("div",{className:`grid gap-2 ${T.length===1?"grid-cols-1":"grid-cols-2"}`,children:T.map(ee=>{var he,Ce;return l.jsx(Ag,{role:ee,speech:dl.getSpeech(ee.id),onClick:()=>mn({type:"role",roleId:ee.id}),liveStatus:jr[ee.id],activeTask:(he=Ee[ee.id])==null?void 0:he.task,featured:!0,appearance:yt(ee.id),xpLevel:(Ce=Re[ee.id])==null?void 0:Ce.level},ee.id)})})]}),l.jsx("div",{className:"pixel-section-label",children:"TEAM"}),l.jsxs("div",{className:`grid gap-2 ${rr?"grid-cols-3":"grid-cols-4"}`,children:[K.map(ee=>{var he,Ce;return l.jsx(Ag,{role:ee,speech:dl.getSpeech(ee.id),onClick:()=>mn({type:"role",roleId:ee.id}),liveStatus:jr[ee.id],activeTask:(he=Ee[ee.id])==null?void 0:he.task,appearance:yt(ee.id),xpLevel:(Ce=Re[ee.id])==null?void 0:Ce.level},ee.id)}),l.jsx("div",{className:"pixel-card pixel-card--hire",onClick:()=>kt(!0),children:l.jsxs("div",{className:"pixel-card--hire-inner",children:[l.jsx("span",{className:"pixel-card--hire-icon",children:"+"}),l.jsx("span",{className:"pixel-card--hire-label",children:"HIRE NEW ROLE"})]})})]})]})})(),l.jsx("div",{className:"pixel-section-label mt-1",children:"OFFICE"}),l.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[l.jsxs("div",{className:"facility-card-compact",onClick:ga?()=>mn({type:"project",projectId:ga.id}):void 0,style:ga?void 0:{borderStyle:"dashed",opacity:.5},children:[l.jsxs("div",{className:"fcc-hdr",style:{background:"#3B82F6"},children:["๐ข"," MEETING ROOM"]}),l.jsx("div",{className:"fcc-canvas",children:l.jsx(ku,{type:"meeting"})}),l.jsxs("div",{className:"fcc-body",children:[l.jsx("div",{className:"fcc-desc",children:"Projects, PRDs, and task boards"}),ga?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"fcc-title",children:['"',ga.name,'"']}),l.jsxs("div",{className:"fcc-meta",children:["Status: ",l.jsx("strong",{style:{color:"var(--active-green)"},children:ga.status})]})]}):l.jsx("div",{className:"fcc-meta",style:{fontStyle:"italic"},children:"No active projects"})]})]}),l.jsxs("div",{className:"facility-card-compact",onClick:()=>mn({type:"bulletin"}),children:[l.jsxs("div",{className:"fcc-hdr",style:{background:"#64748b"},children:["๐"," BULLETIN"]}),l.jsx("div",{className:"fcc-canvas",children:l.jsx(ku,{type:"bulletin"})}),l.jsxs("div",{className:"fcc-body",children:[l.jsx("div",{className:"fcc-desc",children:"Waves and daily standups"}),m.slice(0,1).map(T=>l.jsxs("div",{className:"fcc-item",children:["Wave ",T.id]},T.id)),d.slice(0,1).map(T=>l.jsxs("div",{className:"fcc-item",children:["Standup ",T.date]},T.date)),m.length===0&&d.length===0&&l.jsx("div",{className:"fcc-meta",style:{fontStyle:"italic"},children:"No entries yet"})]})]}),l.jsxs("div",{className:"facility-card-compact",onClick:()=>mn({type:"decisions"}),children:[l.jsxs("div",{className:"fcc-hdr",style:{background:"#EF4444"},children:["๐"," DECISIONS"]}),l.jsx("div",{className:"fcc-canvas",children:l.jsx(ku,{type:"decision"})}),l.jsxs("div",{className:"fcc-body",children:[l.jsx("div",{className:"fcc-desc",children:"CEO strategic decision log"}),l.jsxs("div",{className:"fcc-title",children:[x.length," decisions"]}),x.slice(0,2).map(T=>l.jsxs("div",{className:"fcc-item",children:["#",T.id," ",T.title]},T.id))]})]}),l.jsxs("div",{className:"facility-card-compact",onClick:()=>mn({type:"knowledge"}),children:[l.jsxs("div",{className:"fcc-hdr",style:{background:"#0D9488"},children:["๐"," KNOWLEDGE"]}),l.jsx("div",{className:"fcc-canvas",children:l.jsx(ku,{type:"knowledge"})}),l.jsxs("div",{className:"fcc-body",children:[l.jsx("div",{className:"fcc-desc",children:"Research, analysis, and references"}),l.jsxs("div",{className:"fcc-title",children:[v.length," docs"]}),v.slice(0,2).map(T=>l.jsx("div",{className:"fcc-item",children:T.title},T.id))]})]})]})]})}),rr&&l.jsx("div",{className:Pl?"absolute inset-0 z-50":"contents",children:l.jsx(eg,{sessions:In,activeSessionId:ma,roles:a,streamingSessionId:ta,width:Pl?Ko:dr,onWidthChange:Pl?void 0:Qo,onSwitchSession:Yn,onCloseSession:Jo,onCreateSession:ya,onClearEmpty:Bi,onCloseAll:Oi,onSendMessage:Lr,onModeChange:$i,onCloseTerminal:()=>ha(!1),onMaximize:()=>{ea.current=wn==="pro"?"iso":wn,Cn({type:"terminal"}),Jr("pro")},chatChannels:Gt.channels,activeChatChannelId:Gt.activeChannelId,onSwitchChatChannel:Gt.setActiveChannelId,onCreateChatChannel:(...T)=>{const K=Gt.createChannel(...T);return qt({type:"chat_channel_created"}),K},onDeleteChatChannel:Gt.deleteChannel,onUpdateChatMembers:Gt.updateMembers,onUpdateChatTopic:Gt.updateTopic,onSendChatMessage:rc,unreadChannels:Gt.unreadChannels})})]}),l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 text-[10px] shrink-0 z-[45]",style:{background:"var(--bar-bg, var(--hud-bg))",color:"var(--bar-text, var(--terminal-text-secondary))",borderTop:"3px solid var(--bar-border, var(--pixel-border))"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>Jr("card"),className:`view-toggle-btn ${wn==="card"?"active":""}`,children:"CARD"}),l.jsx("button",{onClick:()=>Jr("iso"),className:`view-toggle-btn ${wn==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{ea.current=wn==="pro"?"iso":wn,Jr("pro")},className:`view-toggle-btn ${wn==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${Fi?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>fa(T=>!T),title:"Office Theme",children:[((zs=al[J])==null?void 0:zs.icon)??"","โพ"]}),Fi&&l.jsx(p8,{theme:J,onThemeChange:T=>{We(T),qt({type:"theme_changed"})},onClose:()=>fa(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>Fa(!0),title:"Settings",children:"โ"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("button",{"data-quest-target":"save-btn",onClick:()=>{wt.state==="no-git"||wt.state==="dirty"?il(!0):sl(!0)},title:wt.state==="dirty"?`${wt.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:wt.state==="no-git"?"var(--terminal-text-muted)":wt.state==="saving"||wt.state==="dirty"?"var(--idle-amber)":wt.state==="error"?"#EF5350":"var(--active-green)",animation:wt.state==="saving"?"pulse 1s infinite":void 0}}),l.jsx("span",{style:{color:wt.state==="dirty"?"var(--idle-amber)":"var(--bar-text, var(--terminal-text-muted))"},children:wt.state==="no-git"?"No git":wt.state==="saving"?"Saving...":wt.state==="dirty"?`${wt.dirtyCount} unsaved`:"Saved"}),qn&&(qn.worktrees.length>0||qn.staleBranches.length>0)&&l.jsxs("span",{style:{color:qn.worktrees.some(T=>T.status==="stale")?"#ff6b6b":qn.worktrees.some(T=>T.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["ยท"," ","๐"," ",qn.worktrees.length," worktree",qn.worktrees.length!==1?"s":"",qn.staleBranches.length>0&&` ยท โ ${qn.staleBranches.length} branch${qn.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[Y.length>0&&!oe&&l.jsx("button",{onClick:()=>na(),className:`px-3 py-1 font-black text-white cursor-pointer ${Se?"":"animate-pulse"}`,style:{background:Se?"#2E7D32":"#B71C1C",border:`2px solid ${Se?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Se?"WAVE DONE":`WAVE (${Y.length})`}),Xe&&Oe&&Y.length===0&&l.jsx("button",{onClick:()=>Qe(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${Se?"":"animate-pulse"}`,style:{background:Se?"#2E7D32":"#B71C1C",border:`2px solid ${Se?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Se?"WAVE DONE":"WAVE"}),R.length>0&&W&&l.jsxs("button",{onClick:()=>D(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:R[R.length-1].color,border:`2px solid ${R[R.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[R[R.length-1].title.slice(0,20),R[R.length-1].title.length>20?"..":""]}),l.jsxs("button",{onClick:()=>na(),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:()=>rr?ha(!1):Pn(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:rr?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${rr?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),wn!=="pro"&&z.type==="role"&&B&&(()=>{var K;const T=Ee[B.id];return l.jsx(Ry,{role:B,allRoles:a,recentActivity:tc(B.id),onClose:Xn,onFireRole:(ee,he)=>{xe({roleId:ee,roleName:he}),Xn()},terminalWidth:rr?dr:0,activeJobId:T==null?void 0:T.id,activeTask:T==null?void 0:T.task,isWorking:jr[B.id]==="working",jobStartedAt:T==null?void 0:T.startedAt,onStopJob:ee=>me.abortJob(ee),sessions:In,streamingSessionId:ta,onCreateSessionSilent:ul,onSendMessage:Lr,onFocusTerminal:ni,onCustomize:ee=>{const he=a.find(Ce=>Ce.id===ee);he&&(ua("character"),cn(he))},onUpdateRole:_i,appearance:yt(B.id),relationships:dl.relationships,roleLevel:(K=Re[B.id])==null?void 0:K.level,onMaximize:()=>{ea.current=wn,Cn({type:"role",roleId:B.id}),Jr("pro")}})})(),wn!=="pro"&&z.type==="project"&&ga&&l.jsx(zE,{projectId:ga.id,onClose:Xn,terminalWidth:rr?dr:0}),wn!=="pro"&&(z.type==="bulletin"||z.type==="decisions")&&l.jsx(Vy,{standups:d,waves:m,decisions:x,mode:z.type==="bulletin"?"bulletin":"decisions",onClose:Xn,onOpenWaveCenter:()=>na(),terminalWidth:rr?dr:0,onMaximize:()=>{ea.current=wn,Cn({type:"operations"}),Jr("pro")}}),wn!=="pro"&&z.type==="quest"&&l.jsx(RE,{progress:Me,onClose:Xn,terminalWidth:rr?dr:0,onQuestAction:T=>{var ee;Xn();const K=ks.find(he=>he.id===T);(ee=K==null?void 0:K.hint)!=null&&ee.target&&Zo(K.hint.target)}}),wn!=="pro"&&z.type==="knowledge"&&l.jsx(Wy,{docs:v,onClose:Xn,onRefresh:()=>me.getKnowledge().then(b).catch(()=>{}),terminalWidth:rr?dr:0,initialDocId:z.docId,onMaximize:()=>{ea.current=wn,Cn({type:"knowledge"}),Jr("pro")}}),wn==="pro"&&l.jsxs(x8,{roles:a,roleStatuses:jr,activeExecs:Be,waves:m,knowledgeDocs:v,sessions:In,roleLevels:Re,companyName:j,getAppearance:yt,waveCenterWaves:Y,profileContent:Or.type==="role"&&B?(()=>{var K;const T=Ee[B.id];return l.jsx(Ry,{role:B,allRoles:a,recentActivity:tc(B.id),onClose:()=>{},onFireRole:(ee,he)=>{xe({roleId:ee,roleName:he})},terminalWidth:0,activeJobId:T==null?void 0:T.id,activeTask:T==null?void 0:T.task,isWorking:jr[B.id]==="working",jobStartedAt:T==null?void 0:T.startedAt,onStopJob:ee=>me.abortJob(ee),sessions:In,streamingSessionId:ta,onCreateSessionSilent:ul,onSendMessage:Lr,onFocusTerminal:()=>{},onCustomize:ee=>{const he=a.find(Ce=>Ce.id===ee);he&&(ua("character"),cn(he))},onUpdateRole:_i,appearance:yt(B.id),relationships:dl.relationships,roleLevel:(K=Re[B.id])==null?void 0:K.level})})():void 0,channel:Or,onChannelChange:T=>{Cn(T),T.type==="role"?mn({type:"role",roleId:T.roleId}):T.type==="knowledge"?mn({type:"knowledge"}):T.type==="operations"?mn({type:"bulletin"}):T.type==="wave"?re(!0):T.type==="terminal"?ha(!0):(U({type:"none"}),re(!1))},onClose:()=>{Jr(ea.current),U({type:"none"}),re(!1)},children:[Or.type==="dashboard"&&l.jsx(b8,{roles:a,roleStatuses:jr,activeExecs:Be,waves:m,knowledgeDocs:v,roleLevels:Re,getAppearance:yt,onRoleClick:T=>Cn({type:"role",roleId:T}),onWaveClick:()=>Cn({type:"wave"}),onKnowledgeClick:()=>Cn({type:"knowledge"})}),Or.type==="terminal"&&l.jsx(eg,{sessions:In,activeSessionId:ma,roles:a,streamingSessionId:ta,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:Yn,onCloseSession:Jo,onCreateSession:ya,onClearEmpty:Bi,onCloseAll:Oi,onSendMessage:Lr,onModeChange:$i,onCloseTerminal:()=>Cn({type:"dashboard"}),chatChannels:Gt.channels,activeChatChannelId:Gt.activeChannelId,onSwitchChatChannel:Gt.setActiveChannelId,onCreateChatChannel:(...T)=>{const K=Gt.createChannel(...T);return qt({type:"chat_channel_created"}),K},onDeleteChatChannel:Gt.deleteChannel,onUpdateChatMembers:Gt.updateMembers,onUpdateChatTopic:Gt.updateTopic,onSendChatMessage:rc,unreadChannels:Gt.unreadChannels}),Or.type==="wave"&&l.jsx(Zy,{orgNodes:te,rootRoleId:ve,cLevelRoles:ve&&te[ve]?te[ve].children.map(T=>a.find(K=>K.id===T)).filter(T=>!!T):a.filter(T=>T.level==="c-level"),pastWaves:m,activeWaves:Y,onDispatch:(T,K)=>ti(T,K),onClose:()=>Cn({type:"dashboard"}),onDone:()=>{$r(),Je(!0),At("Wave complete","#2E7D32")},onSave:async(T,K,ee)=>{try{await me.saveWave({directive:T,jobIds:K,waveId:ee==null?void 0:ee.waveId,sessionIds:ee==null?void 0:ee.sessionIds}),$r(),At("Wave saved","#2E7D32")}catch(he){At(`Save failed: ${he instanceof Error?he.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:T=>{Cn({type:"knowledge"}),mn({type:"knowledge",docId:T}),me.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>me.getWaves().then(f).catch(()=>{}),terminalWidth:0}),Or.type==="knowledge"&&l.jsx(Wy,{docs:v,onClose:()=>Cn({type:"dashboard"}),onRefresh:()=>me.getKnowledge().then(b).catch(()=>{}),terminalWidth:0}),Or.type==="operations"&&l.jsx(Vy,{standups:d,waves:m,decisions:x,mode:"bulletin",onClose:()=>Cn({type:"dashboard"}),onOpenWaveCenter:()=>Cn({type:"wave"}),terminalWidth:0}),Or.type==="role"&&(()=>{const T=Or.roleId,K=a.find(he=>he.id===T);if(!K)return null;const ee=In.find(he=>he.roleId===T);return ee?l.jsx(y8,{role:K,messages:ee.messages,isStreaming:ta===ee.id,mode:ee.mode,onModeChange:he=>$i(ee.id,he),onSend:(he,Ce,Ye)=>Lr(ee.id,he,Ce,Ye),isWave:ee.source==="wave"}):l.jsx(g8,{role:K,getAppearance:yt,onSend:(he,Ce)=>{ul(T),setTimeout(()=>{const Ye=In.find(mt=>mt.roleId===T);Ye&&Lr(Ye.id,he,Ce)},100)}})})()]}),q&&l.jsx(OE,{roleId:q.roleId,roleName:q.roleName,mode:q.mode,onClose:()=>L(null),onExecutionStart:cl}),Xe&&!Oe&&l.jsx(YE,{directive:Xe.directive,rootJobs:Xe.rootJobs,orgNodes:te,rootRoleId:ve,onClose:()=>{de(null),Qe(!1),Je(!1)},onMinimize:()=>Qe(!0),onDone:()=>{$r(),Je(!0),At("Wave complete","#2E7D32");const T=Xe.rootJobs.map(K=>K.jobId);me.saveWave({directive:Xe.directive,jobIds:T}).then(()=>At("Wave auto-saved","#1565C0")).catch(()=>{})},onSave:async T=>{try{await me.saveWave({directive:Xe.directive,jobIds:T}),$r(),At("Wave saved to bulletin","#2E7D32")}catch(K){At(`Save failed: ${K instanceof Error?K.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:T=>{de(null),Qe(!1),Je(!1),mn({type:"knowledge",docId:T}),me.getKnowledge().then(b).catch(()=>{})}}),oe&&l.jsx(Zy,{orgNodes:te,rootRoleId:ve,cLevelRoles:ve&&te[ve]?te[ve].children.map(T=>a.find(K=>K.id===T)).filter(T=>!!T):a.filter(T=>T.level==="c-level"),pastWaves:m,activeWaves:Y,onDispatch:(T,K)=>ti(T,K),onClose:()=>re(!1),onMaximize:()=>{ea.current=wn,Cn({type:"wave"}),Jr("pro")},onDone:()=>{$r(),Je(!0),At("Wave complete","#2E7D32")},onSave:async(T,K,ee)=>{try{await me.saveWave({directive:T,jobIds:K,waveId:ee==null?void 0:ee.waveId,sessionIds:ee==null?void 0:ee.sessionIds}),$r(),At("Wave saved","#2E7D32")}catch(he){At(`Save failed: ${he instanceof Error?he.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:T=>{re(!1),mn({type:"knowledge",docId:T}),me.getKnowledge().then(b).catch(()=>{})},onRefreshWaves:()=>me.getWaves().then(f).catch(()=>{}),terminalWidth:rr?dr:0}),R.length>0&&!W&&(()=>{var ee;const T=R[R.length-1],K=Z.length>1;return l.jsxs(l.Fragment,{children:[K&&R.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:Z.map((he,Ce)=>l.jsx("button",{onClick:()=>{F(Ce),I([{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:A===Ce?"#B71C1C":"var(--terminal-bg)",color:A===Ce?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${A===Ce?"#B71C1C":"var(--terminal-border)"}`,borderBottom:"none"},children:he.roleId.toUpperCase()},he.jobId))}),l.jsx($E,{jobId:T.jobId,title:R.length>1?T.title:K?`CEO WAVE ยท ${((ee=Z[A])==null?void 0:ee.roleName)??""}`:T.title,color:T.color,variant:"modal",style:K&&R.length===1?{marginTop:28}:void 0,onClose:()=>{I([]),G([]),F(0),D(!1)},onMinimize:()=>D(!0),onDone:()=>{ei(),$r()},onNavigateToJob:he=>{me.getJob(he).then(Ce=>{const Ye=Ou[Ce.roleId]??"#888";I(mt=>[...mt,{jobId:he,title:`${Ce.roleId.toUpperCase()} ยท ${Ce.task.slice(0,40)}`,color:Ye}])}).catch(console.error)},onOpenKnowledgeDoc:he=>{I([]),G([]),F(0),D(!1),mn({type:"knowledge",docId:he}),me.getKnowledge().then(b).catch(()=>{})}},T.jobId)]})})(),R.length>1&&l.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[62] pointer-events-none",children:l.jsx("div",{className:"pointer-events-auto",children:l.jsxs("button",{onClick:()=>I(T=>T.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 ",(ac=R[R.length-2])==null?void 0:ac.title]})})}),H&&l.jsx(HE,{cLevelRoles:ve&&te[ve]?te[ve].children.map(T=>a.find(K=>K.id===T)).filter(T=>!!T):a.filter(T=>T.level==="c-level"),orgNodes:te,rootId:ve,onClose:()=>Q(!1),onDispatch:(T,K)=>ti(T,K)}),gt&&l.jsx(n6,{existingRoles:a,onClose:()=>kt(!1),onHire:Ri,onStoreVisit:()=>qt({type:"store_visited"}),questHint:((lc=_a==null?void 0:_a.hint)==null?void 0:lc.target)==="hire-btn"?{message:_a.description,roleId:((ic=_a.trigger.condition)==null?void 0:ic.roleId)??void 0}:void 0}),pe&&l.jsx(l6,{roleId:pe.roleId,roleName:pe.roleName,onClose:()=>xe(null),onConfirm:zi}),hn&&l.jsx(n8,{role:hn,appearance:yt(hn.id),onSave:T=>{pn(hn.id,T),qt({type:"accessory_changed"})},onReset:()=>Mn(hn.id),onClose:()=>{cn(null),ua("character")},theme:J,onThemeChange:T=>{We(T),qt({type:"theme_changed"})},onUpdateName:async(T,K)=>{await _i(T,{name:K})},initialTab:"character",characterOnly:!0,speechSettings:ot,onSpeechSettingsChange:xn,language:ke,onLanguageChange:Mt,roleLevel:(sc=Re[hn.id])==null?void 0:sc.level}),nr&&(()=>{const T=a.find(K=>K.id==="cto")??a.find(K=>K.level==="c-level")??a[0];return l.jsx(l8,{status:wt.status,history:wt.history,onClose:()=>il(!1),onSave:async K=>{const ee=await wt.save(K);return ee!=null&&ee.ok&&qt({type:"save_committed"}),ee},onLoadHistory:wt.loadHistory,onRestore:wt.restore,saving:wt.state==="saving",repo:wt.repo,onRepoChange:wt.setRepo,syncInfo:wt.syncInfo,onPull:wt.pull,pulling:wt.pulling,onRefresh:wt.refresh,onInitGit:wt.initGit,delegateRoleName:(T==null?void 0:T.name)??(T==null?void 0:T.id),onDelegate:T?async K=>{il(!1);try{const ee=await me.createSession(T.id,"do");Ut(Ce=>[ee,...Ce]),Yn(ee.id),pa();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.
|
|
97
|
+
|
|
98
|
+
Changed files:
|
|
99
|
+
${K}`;Lr(ee.id,he,"do")}catch(ee){At(`Failed to delegate: ${ee instanceof Error?ee.message:"error"}`,"#B71C1C")}}:void 0})})(),Vo&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>wr(!1),children:l.jsx("div",{style:{width:420,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8},onClick:T=>T.stopPropagation(),children:l.jsx(i8,{onClose:()=>wr(!1)})})}),Rn&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ln(!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:T=>T.stopPropagation(),children:l.jsx(c8,{onClose:()=>Ln(!1),onSyncComplete:()=>{}})})}),Go&&l.jsx(m8,{onClose:()=>Fa(!1),speechSettings:ot,onSpeechSettingsChange:xn,language:ke,onLanguageChange:Mt,onOpenSync:()=>Ln(!0),onOpenGitStatus:()=>sl(!0),onOpenSessions:()=>Ds(!0),onOpenStats:()=>wr(!0)}),da&&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:T=>T.stopPropagation(),children:l.jsx(u8,{onClose:()=>sl(!1)})})}),ad&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ds(!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:T=>T.stopPropagation(),children:l.jsx(d8,{onClose:()=>Ds(!1)})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:P.map(T=>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:T.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"}),T.message]},T.id))})]})}function Ag({role:e,speech:n,onClick:a,liveStatus:i,activeTask:o,featured:u,appearance:d,xpLevel:h}){const m=Ou[e.id]??S8(e.id),f=h??1,x=j8[e.id]??e.name,y=i==="working",v=y&&o?o:n||x;return l.jsxs("div",{className:`pixel-card ${y?"working":""} ${u?"pixel-card--featured":""}`,onClick:a,children:[l.jsxs("div",{className:"pixel-card-hdr",style:{background:m},children:[l.jsxs("span",{children:[e.id.toUpperCase()," ","ยท"," ",e.name.toUpperCase()]}),l.jsxs("span",{className:"lvl",children:["Lv.",f]})]}),l.jsxs("div",{className:"pixel-card-body",children:[l.jsx("div",{className:"pixel-desk"}),l.jsx(nl,{roleId:e.id,appearance:d}),l.jsx("div",{className:"pixel-status-dot",style:{background:y?"var(--idle-amber)":"var(--active-green)"}})]}),l.jsxs("div",{className:"pixel-card-task",children:[l.jsx("span",{className:"pixel-card-task-icon",children:y?"๐ ๏ธ":k8[e.id]??"๐ค"}),l.jsx("span",{className:"pixel-card-task-text",children:v||x})]})]})}function Tu({onSelect:e,onClose:n}){const[a,i]=w.useState(null),[o,u]=w.useState(!0),d=w.useCallback(async h=>{u(!0);try{const m=await me.browse(h);i(m)}catch{}finally{u(!1)}},[]);return w.useEffect(()=>{d()},[d]),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:220,overflowY:"auto"},children:[l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 sticky top-0",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:()=>e(a.current),className:"px-2 py-1 rounded text-[10px] font-medium shrink-0",style:{background:"var(--active-green)",color:"#fff"},children:"Select"}),l.jsx("button",{onClick:n,className:"opacity-50 hover:opacity-100 shrink-0",style:{color:"var(--terminal-text)"},children:"โ"})]}),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:()=>d(a.parent),children:[l.jsx("span",{children:"โฌ๏ธ"}),l.jsx("span",{children:".."})]}),a.dirs.map(h=>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:()=>d(h.path),children:[l.jsx("span",{children:"๐"}),l.jsx("span",{children:h.name})]},h.path)),a.dirs.length===0&&l.jsx("div",{className:"px-3 py-3 text-center",style:{color:"var(--terminal-text-muted)"},children:"No subdirectories"})]}):null}const N8={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function Dg(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function E8({onComplete:e}){const[n,a]=w.useState(0),[i,o]=w.useState(null),[u,d]=w.useState("none"),[h,m]=w.useState(""),[f,x]=w.useState(!0),[y,v]=w.useState(""),[b,j]=w.useState(""),[k,C]=w.useState("auto"),N=w.useRef(null),[E,_]=w.useState("new"),[z,U]=w.useState(""),[B,$]=w.useState(""),[q,L]=w.useState(!1),[R,I]=w.useState(!1),[H,Q]=w.useState(!1),[oe,re]=w.useState(""),[Y,ae]=w.useState(!1),[Z,G]=w.useState(!1),[A,F]=w.useState([]),[W,D]=w.useState(""),[te,je]=w.useState(!1),[ve,ze]=w.useState(""),[Xe,de]=w.useState(null),[Oe,Qe]=w.useState(!1),[Se,Je]=w.useState(!1),[Re,Et]=w.useState([]),[ut,gt]=w.useState("startup"),[kt,pe]=w.useState(!1),[xe,ge]=w.useState(!1),[$e,Be]=w.useState(null),[Le,Ee]=w.useState([]),[P,ue]=w.useState(""),[ye,Ne]=w.useState(!1),[Me,Pe]=w.useState(!1),[_t,dt]=w.useState([]),ht=w.useMemo(()=>Dg(E),[E]),bt=ht[n]??"engine";w.useEffect(()=>{me.detectEngine().then(ke=>{o(ke),d(ke.recommended),x(!1)}).catch(()=>x(!1)),me.getTeams().then(Et).catch(()=>{}),me.getStatus().then(ke=>{$(ke.companyRoot||"")}).catch(()=>{})},[]),w.useEffect(()=>{var ke;bt==="company"&&((ke=N.current)==null||ke.focus())},[bt]),w.useEffect(()=>{if(q||!B)return;const ke=y.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");U(ke?`${B}/${ke}`:B)},[y,B,q]);const et=()=>{switch(bt){case"engine":return u!=="none"||h.length>10;case"company":return y.trim().length>0;case"workspace":return E==="existing-akb"?Xe===!0:!0;case"team":return!0;case"create":return!xe;default:return!1}},Fe=()=>{n<ht.length-1&&et()&&a(n+1),bt==="create"&&!kt&&!ye&&(E==="existing-akb"?Mn():pn())},_e=()=>{n>0&&a(n-1)},nn=w.useRef(E);w.useEffect(()=>{if(nn.current===E)return;nn.current=E;const Mt=Dg(E).indexOf("workspace");Mt>=0&&a(Mt)},[E]);const fn=async()=>{if(ve.trim()){Qe(!0);try{const ke=await me.validatePath(ve.trim());de(ke.valid&&ke.hasClaudeMd===!0)}catch{de(!1)}finally{Qe(!1)}}},Vt=()=>{const ke=W.trim();ke&&!A.includes(ke)&&(F([...A,ke]),D(""))},yt=async ke=>{Pe(!0),dt([]);try{const{tools:Mt}=await me.getRequiredTools(ke);if(Mt.filter(cn=>!cn.installed).length===0){Pe(!1);return}await me.installTools(ke,(cn,ua)=>{const wt=ua.tool||"";cn==="checking"?dt(nr=>[...nr,{event:cn,tool:wt,detail:"checking..."}]):cn==="installing"?dt(nr=>[...nr,{event:cn,tool:wt,detail:"installing..."}]):cn==="installed"?dt(nr=>[...nr,{event:cn,tool:wt,detail:"installed"}]):cn==="skipped"?dt(nr=>[...nr,{event:cn,tool:wt,detail:ua.reason||"skipped"}]):cn==="error"&&dt(nr=>[...nr,{event:cn,tool:wt,detail:ua.error||"failed"}])})}catch{}finally{Pe(!1)}},pn=async()=>{pe(!0),Be(null);try{const ke={companyName:y.trim(),description:b.trim()||"An AI-powered organization",team:ut,knowledgePaths:A.length>0?A:void 0,language:k!=="auto"?k:void 0,location:z.trim()||void 0,codeRoot:oe.trim()||void 0};(u==="direct-api"||h)&&(ke.apiKey=h||void 0);const Mt=await me.scaffold(ke);Ee(Mt.created),ue(Mt.projectRoot),ge(!0),pe(!1),ut!=="custom"&&yt(ut)}catch(ke){Be(ke instanceof Error?ke.message:"Scaffold failed"),pe(!1)}},Mn=async()=>{Ne(!0),Be(null);try{const ke=await me.connectAkb(ve.trim());ke.ok?(ge(!0),Ee([`Connected to: ${ke.companyRoot}`])):Be(ke.error||"Failed to connect")}catch(ke){Be(ke instanceof Error?ke.message:"Connect failed")}finally{Ne(!1)}},J=()=>{A.length>0?e({paths:A,companyRoot:""}):e()},We=ke=>{ke.key==="Enter"&&et()&&(ke.preventDefault(),Fe())},ot=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
|
|
100
|
+
bg-[var(--terminal-bg)] text-[var(--terminal-text)]
|
|
101
|
+
border border-[var(--terminal-border)]
|
|
102
|
+
focus:border-[var(--terminal-border-hover)]
|
|
103
|
+
placeholder:text-[var(--terminal-text-muted)]`,xn=ke=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${ke?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--terminal-border)] bg-[var(--hud-bg-alt)] hover:border-[var(--accent)]/50"}`;return l.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},onKeyDown:We,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:ht.map((ke,Mt)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Mt<=n?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Mt===n?"var(--terminal-text)":"var(--terminal-text-muted)"},children:N8[ke]})]},ke))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[bt==="engine"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"AI Engine Setup"}),f?l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:"Detecting AI engine..."}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:xn(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:xn(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:`${ot} mt-3`,placeholder:"sk-ant-...",value:h,onChange:ke=>m(ke.target.value),autoFocus:!0})]})]})]}),bt==="company"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company"}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),l.jsx("input",{ref:N,className:ot,placeholder:"e.g. Acme Corp",value:y,onChange:ke=>v(ke.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Description"}),l.jsx("textarea",{className:`${ot} resize-none`,rows:3,placeholder:"What does your AI company do?",value:b,onChange:ke=>j(ke.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"AI Response Language"}),l.jsxs("select",{className:ot,value:k,onChange:ke=>C(ke.target.value),children:[l.jsx("option",{value:"auto",children:"Auto"}),l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"ํ๊ตญ์ด"}),l.jsx("option",{value:"ja",children:"ๆฅๆฌ่ช"})]})]})]}),bt==="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(lp,{text:`"New Company" creates a fresh workspace with roles, knowledge base, and project structure.
|
|
104
|
+
|
|
105
|
+
"Connect Existing" links to an existing Tycono workspace you've set up before.`})]}),l.jsxs("div",{className:"flex rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:E==="new"?"var(--accent)":"var(--hud-bg-alt)",color:E==="new"?"#fff":"var(--terminal-text-muted)"},onClick:()=>_("new"),children:"New Company"}),l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:E==="existing-akb"?"var(--accent)":"var(--hud-bg-alt)",color:E==="existing-akb"?"#fff":"var(--terminal-text-muted)",borderLeft:"1px solid var(--terminal-border)"},onClick:()=>_("existing-akb"),children:"Connect Existing"})]}),E==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Tg,{icon:"๐",title:"Company Location",hint:"Where your AI company files will be created.",help:"Roles, knowledge, decisions, and project files are stored here. This is your AI company's home directory. Auto-generated from your company name โ change it if needed.",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${ot} flex-1`,placeholder:"/path/to/your-company",value:z,onChange:ke=>{U(ke.target.value),L(!0)}}),l.jsx("button",{onClick:()=>I(!R),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"๐"})]}),R&&l.jsx(Tu,{onSelect:ke=>{U(ke),L(!0),I(!1)},onClose:()=>I(!1)})]}),l.jsxs(Fg,{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.
|
|
106
|
+
|
|
107
|
+
Skip this if you don't have a codebase yet โ you can connect one later from Settings.`,tag:"optional",open:H,onToggle:()=>Q(!H),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${ot} flex-1`,placeholder:"/path/to/code/repo",value:oe,onChange:ke=>re(ke.target.value)}),l.jsx("button",{onClick:()=>ae(!Y),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"๐"})]}),Y&&l.jsx(Tu,{onSelect:ke=>{re(ke),ae(!1)},onClose:()=>ae(!1)})]}),l.jsxs(Fg,{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.
|
|
108
|
+
|
|
109
|
+
Skip this to start with an empty knowledge base. You can import documents anytime from the office.`,tag:"optional",open:Z,onToggle:()=>G(!Z),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${ot} flex-1`,placeholder:"/path/to/docs",value:W,onChange:ke=>D(ke.target.value),onKeyDown:ke=>{ke.key==="Enter"&&(ke.preventDefault(),Vt())}}),l.jsx("button",{onClick:()=>je(!te),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"๐"}),l.jsx("button",{onClick:Vt,disabled:!W.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:W.trim()?1:.5},children:"Add"})]}),te&&l.jsx(Tu,{onSelect:ke=>{A.includes(ke)||F([...A,ke]),je(!1)},onClose:()=>je(!1)}),A.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:A.map((ke,Mt)=>l.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:[l.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"var(--pixel-font)"},children:ke}),l.jsx("button",{onClick:()=>F(A.filter((hn,cn)=>cn!==Mt)),className:"opacity-50 hover:opacity-100",children:"โ"})]},Mt))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(Tg,{icon:"๐",title:"AKB Path",hint:"Directory with existing CLAUDE.md and AKB structure.",help:"Connect to a directory that was previously set up with Tycono. It must contain a CLAUDE.md file. All existing roles, knowledge, and settings will be loaded.",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${ot} flex-1`,placeholder:"/path/to/your/akb",value:ve,onChange:ke=>{ze(ke.target.value),de(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>Je(!Se),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--hud-bg-alt)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"๐"}),l.jsx("button",{onClick:fn,disabled:Oe||!ve.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:Oe||!ve.trim()?.5:1},children:Oe?"...":"Verify"})]}),Xe===!0&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["โ
"," Valid AKB found"]}),Xe===!1&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["โ"," No valid AKB (CLAUDE.md required)"]}),Se&&l.jsx(Tu,{onSelect:ke=>{ze(ke),de(null),Je(!1)},onClose:()=>Je(!1)})]})})]}),bt==="team"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Team Template"}),l.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"Choose a starting team. You can add or remove roles later."}),Re.map(ke=>l.jsxs("div",{className:xn(ut===ke.id),onClick:()=>gt(ke.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:ke.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ke.roles.map(Mt=>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:Mt.name},Mt.id))})]},ke.id)),l.jsxs("div",{className:xn(ut==="custom"),onClick:()=>gt("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."})]})]}),bt==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:xe?E==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!xe&&!kt&&!ye&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"rounded-lg p-4 space-y-2 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:E==="existing-akb"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Mode:"})," Connect Existing AKB"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Path:"})," ",ve]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Company:"})," ",y]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Location:"})," ",z||"(default)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",u==="claude-cli"?"Claude Code CLI":"Direct API"]}),oe.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Code Repo:"})," ",oe]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",A.length>0?`Import ${A.length} source(s)`:"Fresh (empty)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Team:"})," ",ut]}),A.length>0&&l.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),$e&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:$e})]}),(kt||ye)&&l.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[l.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:ye?"Connecting to AKB...":"Scaffolding your company..."})]}),xe&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"๐ข"}),P&&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:"})," ",P]}),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:Le.map((ke,Mt)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"โ"})," ",ke]},Mt))}),(Me||_t.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:Me?"Installing skill tools...":"Skill tools"}),_t.map((ke,Mt)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:ke.event==="installed"||ke.event==="skipped"?"var(--active-green)":ke.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:ke.event==="installed"||ke.event==="skipped"?"โ":ke.event==="error"?"โ":"โฆ"}),l.jsx("span",{children:ke.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:ke.detail})]},Mt)),Me&&l.jsxs("div",{className:"flex items-center gap-2 mt-1",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("div",{className:"w-3 h-3 border border-current rounded-full animate-spin",style:{borderTopColor:"var(--accent)"}}),l.jsx("span",{children:"Please wait..."})]})]}),A.length>0&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"var(--accent)",color:"#fff",opacity:.9},children:"Knowledge import will start in the background after entering the office."})]})]})]}),l.jsxs("div",{className:"px-6 py-4 flex justify-between items-center",style:{borderTop:"1px solid var(--terminal-border)"},children:[l.jsx("div",{children:n>0&&!xe&&l.jsx("button",{onClick:_e,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," / ",ht.length]}),l.jsx("div",{children:xe?l.jsx("button",{onClick:J,disabled:Me,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:Me?.5:1},children:Me?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:Fe,disabled:!et()||kt||ye,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:et()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:et()&&!kt&&!ye?1:.5},children:bt==="create"?kt||ye?ye?"Connecting...":"Creating...":E==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function lp({text:e}){const[n,a]=w.useState(!1);return l.jsxs("span",{className:"relative inline-flex",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:()=>a(!0),onMouseLeave:()=>a(!1),onClick:i=>{i.stopPropagation(),a(!n)},children:"?"}),n&&l.jsxs("div",{className:"absolute z-50 bottom-full left-0 mb-2 px-3 py-2 rounded-lg text-[11px] leading-relaxed whitespace-pre-line w-60 shadow-lg pointer-events-none",style:{background:"var(--terminal-bg)",color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:[e,l.jsx("div",{className:"absolute top-full left-2 w-0 h-0",style:{borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:"5px solid var(--terminal-border)"}})]})]})}function Tg({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(lp,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:a})]}),o]})}function Fg({icon:e,title:n,hint:a,help:i,tag:o,open:u,onToggle:d,children:h}){return l.jsxs("div",{className:"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 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(lp,{text:i}),o&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded",style:{background:"var(--terminal-surface)",color:"var(--terminal-text-muted)"},children:o}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:u?"โฒ":"โผ"})]}),!u&&l.jsx("div",{className:"px-3 pb-2 -mt-1",children:l.jsx("div",{className:"text-[10px] ml-6",style:{color:"var(--terminal-text-muted)"},children:a})}),u&&l.jsx("div",{className:"px-3 pb-3 space-y-2",children:h})]})}function A8(){const[e,n]=w.useState(null),[a,i]=w.useState(!0),[o,u]=w.useState(null),d=w.useCallback(async()=>{i(!0),u(null);try{const h=await me.getStatus();n(h)}catch(h){u(h instanceof Error?h.message:"Failed to fetch status")}finally{i(!1)}},[]);return w.useEffect(()=>{d()},[d]),{initialized:(e==null?void 0:e.initialized)??!1,companyName:(e==null?void 0:e.companyName)??null,engine:(e==null?void 0:e.engine)??"none",companyRoot:(e==null?void 0:e.companyRoot)??"",loading:a,error:o,refetch:d}}const D8=w.lazy(()=>Rg(()=>import("./preview-app-AJtyaM6L.js"),[]));function $v(){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 al?n:"default",i=(e=al[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]=w.useState(null);w.useEffect(()=>{T8()},[]);const u=d=>{d&&o(d),a()};return n?l.jsx($v,{}):e?l.jsx(C8,{importJob:i,onImportDone:()=>o(null)}):l.jsx(E8,{onComplete:u})}function M8(){const e=new URLSearchParams(window.location.search).has("sprite-preview");return l.jsx(Dw,{children:e?l.jsx(w.Suspense,{fallback:l.jsx($v,{}),children:l.jsx(D8,{})}):l.jsx(F8,{})})}Nw.createRoot(document.getElementById("root")).render(l.jsx(w.StrictMode,{children:l.jsx(M8,{})}));export{pv as H,yv as P,gv as S,_8 as a,xv as b,mv as c,om as d,sC as e,iC as f,z8 as g,oC as h,l as j,w as r};
|