tide-commander 1.35.0 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-B_dgVF7L.js → BossLogsModal-B6meUM1T.js} +1 -1
- package/dist/assets/BossSpawnModal-DzWs1NNZ.js +1 -0
- package/dist/assets/{ControlsModal-WMTTqbca.js → ControlsModal-D2QDZ20h.js} +1 -1
- package/dist/assets/{DockerLogsModal-THzhLHch.js → DockerLogsModal-Bh1ghgFV.js} +1 -1
- package/dist/assets/{EmbeddedEditor-DWLKJYav.js → EmbeddedEditor-C4rKc9Ys.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-DN9ceaS6.js → GmailOAuthSetup-E5_WFtyX.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-bVST2EOB.js → GoogleOAuthSetup-B7NLxSSp.js} +1 -1
- package/dist/assets/{IframeModal-BELsjvgi.js → IframeModal-CGbINL-o.js} +1 -1
- package/dist/assets/{IntegrationsPanel-DwDr4BRt.js → IntegrationsPanel-DZmbjiXV.js} +2 -2
- package/dist/assets/{LogViewerModal-CMe04PO5.js → LogViewerModal-KI2L074n.js} +1 -1
- package/dist/assets/{MonitoringModal-CqSalNeY.js → MonitoringModal-CWqjvTra.js} +1 -1
- package/dist/assets/{PM2LogsModal-CCmCDxVt.js → PM2LogsModal-DRHybuUO.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-IfzPidIv.js → RestoreArchivedAreaModal-DjpKSz7P.js} +1 -1
- package/dist/assets/{SaveSnapshotModal-DUhrVD5l.js → SaveSnapshotModal-CWtf3rgg.js} +1 -1
- package/dist/assets/Scene2DCanvas-CSfRDtXw.js +1 -0
- package/dist/assets/SceneManager-Do4NpOsy.js +104 -0
- package/dist/assets/{SkillsPanel-CPFOI4Tl.js → SkillsPanel-BqZSNfNW.js} +3 -3
- package/dist/assets/{SnapshotManager-Cbu0tJBz.js → SnapshotManager-DyqyIhWz.js} +1 -1
- package/dist/assets/SpawnModal-CGFj_b9I.js +1 -0
- package/dist/assets/SubordinateAssignmentModal-DGFoupVt.js +1 -0
- package/dist/assets/{SupervisorPanel-BvX-dlk_.js → SupervisorPanel-B1PVopnm.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-RUVFmKmf.js → TriggerManagerPanel-CFez7_vm.js} +2 -2
- package/dist/assets/{WorkflowEditorPanel-CwZpEqzM.js → WorkflowEditorPanel-ClMl5U8g.js} +1 -1
- package/dist/assets/{index-DDPUtz8-.js → index-B4SUGrVB.js} +1 -1
- package/dist/assets/{index-CiD1Rwaq.js → index-BK3kI8Cb.js} +1 -1
- package/dist/assets/{index-BFguOWBW.js → index-Bf3KKyiV.js} +2 -2
- package/dist/assets/{index-D4nfDvz4.js → index-Bmu_CPsU.js} +3 -3
- package/dist/assets/index-CbzHGOPP.js +1 -0
- package/dist/assets/index-CpZt7iSV.js +1 -0
- package/dist/assets/{index-B-wV06cR.js → index-CxtzptPF.js} +5 -5
- package/dist/assets/{index-EH8IBvSU.js → index-D2_-BBP8.js} +3 -3
- package/dist/assets/main-C6uuUPJ0.css +1 -0
- package/dist/assets/main-CtGyoZXd.js +152 -0
- package/dist/assets/{web-D1vWYL8u.js → web-C2JUUvGB.js} +1 -1
- package/dist/assets/{web-DUq3Undh.js → web-D4EcUHSn.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/routes/agents.js +209 -1
- package/dist/src/packages/server/routes/areas.js +25 -0
- package/dist/src/packages/server/routes/index.js +2 -0
- package/dist/src/packages/server/routes/workspaces.js +123 -0
- package/dist/src/packages/server/services/agent-service.js +87 -1
- package/dist/src/packages/server/services/area-layout-service.js +260 -0
- package/dist/src/packages/server/services/workspace-service.js +104 -0
- package/package.json +1 -1
- package/dist/assets/BossSpawnModal-CSO1bYxA.js +0 -1
- package/dist/assets/Scene2DCanvas-Bl5DUC7w.js +0 -1
- package/dist/assets/SceneManager-BGO9tiaI.js +0 -104
- package/dist/assets/SpawnModal-BqDbsYLY.js +0 -1
- package/dist/assets/SubordinateAssignmentModal-DOqkhL_L.js +0 -1
- package/dist/assets/camera-D_KeL_pz.js +0 -1
- package/dist/assets/index-C7gqY2AA.js +0 -1
- package/dist/assets/index-H0PzHVFw.js +0 -1
- package/dist/assets/main-Cjm0d8dZ.js +0 -152
- package/dist/assets/main-DqC9_fF4.css +0 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-ponyfill-DZOWXZ4K.js","assets/vendor-react--Eh9ivFN.js","assets/index-Bf3KKyiV.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-three-Chj50gSY.js","assets/web-C2JUUvGB.js","assets/SceneManager-Do4NpOsy.js","assets/prism-cpp-CK2Ly5dS.js","assets/prism-java-CK6tws4L.js","assets/prism-csharp-ByDDDiWW.js","assets/prism-ruby-CQBUuZIF.js","assets/prism-php-Dt9698bA.js","assets/prism-scss-CeN16CFC.js","assets/prism-perl-UZfqnD51.js","assets/prism-haskell-Ce8aBmia.js","assets/prism-elixir-df27OMMQ.js","assets/xterm-6GBZ9nXN.css","assets/SpawnModal-CGFj_b9I.js","assets/BossSpawnModal-DzWs1NNZ.js","assets/SubordinateAssignmentModal-DGFoupVt.js","assets/index-CbzHGOPP.js","assets/index-Bykeknjl.css","assets/index-CxtzptPF.js","assets/index-D2_-BBP8.js","assets/index-Bmu_CPsU.js","assets/SupervisorPanel-B1PVopnm.js","assets/index-CpZt7iSV.js","assets/ControlsModal-D2QDZ20h.js","assets/SkillsPanel-BqZSNfNW.js","assets/SnapshotManager-DyqyIhWz.js","assets/RestoreArchivedAreaModal-DjpKSz7P.js","assets/IntegrationsPanel-DZmbjiXV.js","assets/MonitoringModal-CWqjvTra.js","assets/WorkflowEditorPanel-ClMl5U8g.js","assets/TriggerManagerPanel-CFez7_vm.js","assets/index-B4SUGrVB.js","assets/index-CprCD9du.css","assets/PM2LogsModal-DRHybuUO.js","assets/LogViewerModal-KI2L074n.js","assets/DockerLogsModal-Bh1ghgFV.js","assets/BossLogsModal-B6meUM1T.js","assets/Scene2DCanvas-CSfRDtXw.js","assets/Scene2DCanvas-DwXbvB-b.css","assets/index-BK3kI8Cb.js","assets/index-BZyCMBzi.css","assets/IframeModal-CGbINL-o.js","assets/IframeModal-DJkCGwT6.css","assets/SaveSnapshotModal-CWtf3rgg.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var TE=Object.defineProperty;var _E=(t,e,n)=>e in t?TE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Xe=(t,e,n)=>_E(t,typeof e!="symbol"?e+"":e,n);import"./modulepreload-polyfill-B5Qt9EMX.js";import{r as jx,g as Xu,a as ej,c as J0}from"./vendor-react--Eh9ivFN.js";import{T as EE,a as Ob,b as tj,L as nj,c as Cu,F as up,M as cr,V as sj,C as Hr,d as lr,S as Br,e as ME,P as DE,D as Lb,f as dp,g as wo,I as RE,Q as aj,h as OE,O as rj,i as LE,j as IE,B as Au,k as PE,l as ij,N as BE,m as FE,n as zE,o as Ib,p as oj,R as Pb,q as $E,r as UE,s as HE,t as Jf,u as WE,v as Nx,w as lj,x as Fl,y as qE,z as cj,A as VE,E as Il,G as YE,H as GE,J as KE,K as QE,U as xg,W as uj,X as XE,Y as JE,Z as ZE,_ as eM,$ as tM,a0 as nM,a1 as dj,a2 as sM,a3 as Z0,a4 as ek,a5 as tk,a6 as nk,a7 as Bb,a8 as aM,a9 as rM,aa as iM,ab as oM,ac as lM,ad as cM,ae as uM,af as dM,ag as fM,ah as pM,ai as hM,aj as mM}from"./vendor-three-Chj50gSY.js";function gM(t,e){for(var n=0;n<e.length;n++){const s=e[n];if(typeof s!="string"&&!Array.isArray(s)){for(const a in s)if(a!=="default"&&!(a in t)){const r=Object.getOwnPropertyDescriptor(s,a);r&&Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:()=>s[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var yg={exports:{}},Jc={};/**
|
|
3
|
+
* @license React
|
|
4
|
+
* react-jsx-runtime.production.js
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/var sk;function bM(){if(sk)return Jc;sk=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(s,a,r){var i=null;if(r!==void 0&&(i=""+r),a.key!==void 0&&(i=""+a.key),"key"in a){r={};for(var c in a)c!=="key"&&(r[c]=a[c])}else r=a;return a=r.ref,{$$typeof:t,type:s,key:i,ref:a!==void 0?a:null,props:r}}return Jc.Fragment=e,Jc.jsx=n,Jc.jsxs=n,Jc}var ak;function xM(){return ak||(ak=1,yg.exports=bM()),yg.exports}var o=xM(),x=jx();const Ce=Xu(x),fj=gM({__proto__:null,default:Ce},[x]);var vg={exports:{}},Zc={},wg={exports:{}},kg={};/**
|
|
11
|
+
* @license React
|
|
12
|
+
* scheduler.production.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/var rk;function yM(){return rk||(rk=1,(function(t){function e(F,H){var V=F.length;F.push(H);e:for(;0<V;){var G=V-1>>>1,B=F[G];if(0<a(B,H))F[G]=H,F[V]=B,V=G;else break e}}function n(F){return F.length===0?null:F[0]}function s(F){if(F.length===0)return null;var H=F[0],V=F.pop();if(V!==H){F[0]=V;e:for(var G=0,B=F.length,K=B>>>1;G<K;){var ne=2*(G+1)-1,q=F[ne],xe=ne+1,Ae=F[xe];if(0>a(q,V))xe<B&&0>a(Ae,q)?(F[G]=Ae,F[xe]=V,G=xe):(F[G]=q,F[ne]=V,G=ne);else if(xe<B&&0>a(Ae,V))F[G]=Ae,F[xe]=V,G=xe;else break e}}return H}function a(F,H){var V=F.sortIndex-H.sortIndex;return V!==0?V:F.id-H.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;t.unstable_now=function(){return r.now()}}else{var i=Date,c=i.now();t.unstable_now=function(){return i.now()-c}}var d=[],f=[],h=1,m=null,b=3,y=!1,w=!1,C=!1,N=!1,k=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function T(F){for(var H=n(f);H!==null;){if(H.callback===null)s(f);else if(H.startTime<=F)s(f),H.sortIndex=H.expirationTime,e(d,H);else break;H=n(f)}}function D(F){if(C=!1,T(F),!w)if(n(d)!==null)w=!0,E||(E=!0,z());else{var H=n(f);H!==null&&L(D,H.startTime-F)}}var E=!1,I=-1,O=5,_=-1;function M(){return N?!0:!(t.unstable_now()-_<O)}function R(){if(N=!1,E){var F=t.unstable_now();_=F;var H=!0;try{e:{w=!1,C&&(C=!1,j(I),I=-1),y=!0;var V=b;try{t:{for(T(F),m=n(d);m!==null&&!(m.expirationTime>F&&M());){var G=m.callback;if(typeof G=="function"){m.callback=null,b=m.priorityLevel;var B=G(m.expirationTime<=F);if(F=t.unstable_now(),typeof B=="function"){m.callback=B,T(F),H=!0;break t}m===n(d)&&s(d),T(F)}else s(d);m=n(d)}if(m!==null)H=!0;else{var K=n(f);K!==null&&L(D,K.startTime-F),H=!1}}break e}finally{m=null,b=V,y=!1}H=void 0}}finally{H?z():E=!1}}}var z;if(typeof S=="function")z=function(){S(R)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,W=$.port2;$.port1.onmessage=R,z=function(){W.postMessage(null)}}else z=function(){k(R,0)};function L(F,H){I=k(function(){F(t.unstable_now())},H)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(F){F.callback=null},t.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<F?Math.floor(1e3/F):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(F){switch(b){case 1:case 2:case 3:var H=3;break;default:H=b}var V=b;b=H;try{return F()}finally{b=V}},t.unstable_requestPaint=function(){N=!0},t.unstable_runWithPriority=function(F,H){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var V=b;b=F;try{return H()}finally{b=V}},t.unstable_scheduleCallback=function(F,H,V){var G=t.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?G+V:G):V=G,F){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=V+B,F={id:h++,callback:H,priorityLevel:F,startTime:V,expirationTime:B,sortIndex:-1},V>G?(F.sortIndex=V,e(f,F),n(d)===null&&F===n(f)&&(C?(j(I),I=-1):C=!0,L(D,V-G))):(F.sortIndex=B,e(d,F),w||y||(w=!0,E||(E=!0,z()))),F},t.unstable_shouldYield=M,t.unstable_wrapCallback=function(F){var H=b;return function(){var V=b;b=H;try{return F.apply(this,arguments)}finally{b=V}}}})(kg)),kg}var ik;function vM(){return ik||(ik=1,wg.exports=yM()),wg.exports}/**
|
|
19
|
+
* @license React
|
|
20
|
+
* react-dom-client.production.js
|
|
21
|
+
*
|
|
22
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the MIT license found in the
|
|
25
|
+
* LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/var ok;function wM(){if(ok)return Zc;ok=1;var t=vM(),e=jx(),n=ej();function s(l){var u="https://react.dev/errors/"+l;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)u+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function r(l){var u=l,p=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,(u.flags&4098)!==0&&(p=u.return),l=u.return;while(l)}return u.tag===3?p:null}function i(l){if(l.tag===13){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function c(l){if(l.tag===31){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function d(l){if(r(l)!==l)throw Error(s(188))}function f(l){var u=l.alternate;if(!u){if(u=r(l),u===null)throw Error(s(188));return u!==l?null:l}for(var p=l,g=u;;){var v=p.return;if(v===null)break;var A=v.alternate;if(A===null){if(g=v.return,g!==null){p=g;continue}break}if(v.child===A.child){for(A=v.child;A;){if(A===p)return d(v),l;if(A===g)return d(v),u;A=A.sibling}throw Error(s(188))}if(p.return!==g.return)p=v,g=A;else{for(var P=!1,Y=v.child;Y;){if(Y===p){P=!0,p=v,g=A;break}if(Y===g){P=!0,g=v,p=A;break}Y=Y.sibling}if(!P){for(Y=A.child;Y;){if(Y===p){P=!0,p=A,g=v;break}if(Y===g){P=!0,g=A,p=v;break}Y=Y.sibling}if(!P)throw Error(s(189))}}if(p.alternate!==g)throw Error(s(190))}if(p.tag!==3)throw Error(s(188));return p.stateNode.current===p?l:u}function h(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l;for(l=l.child;l!==null;){if(u=h(l),u!==null)return u;l=l.sibling}return null}var m=Object.assign,b=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),S=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),R=Symbol.iterator;function z(l){return l===null||typeof l!="object"?null:(l=R&&l[R]||l["@@iterator"],typeof l=="function"?l:null)}var $=Symbol.for("react.client.reference");function W(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===$?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case C:return"Fragment";case k:return"Profiler";case N:return"StrictMode";case D:return"Suspense";case E:return"SuspenseList";case _:return"Activity"}if(typeof l=="object")switch(l.$$typeof){case w:return"Portal";case S:return l.displayName||"Context";case j:return(l._context.displayName||"Context")+".Consumer";case T:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case I:return u=l.displayName||null,u!==null?u:W(l.type)||"Memo";case O:u=l._payload,l=l._init;try{return W(l(u))}catch{}}return null}var L=Array.isArray,F=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},G=[],B=-1;function K(l){return{current:l}}function ne(l){0>B||(l.current=G[B],G[B]=null,B--)}function q(l,u){B++,G[B]=l.current,l.current=u}var xe=K(null),Ae=K(null),Z=K(null),ce=K(null);function me(l,u){switch(q(Z,u),q(Ae,l),q(xe,null),u.nodeType){case 9:case 11:l=(l=u.documentElement)&&(l=l.namespaceURI)?w0(l):0;break;default:if(l=u.tagName,u=u.namespaceURI)u=w0(u),l=k0(u,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}ne(xe),q(xe,l)}function ee(){ne(xe),ne(Ae),ne(Z)}function re(l){l.memoizedState!==null&&q(ce,l);var u=xe.current,p=k0(u,l.type);u!==p&&(q(Ae,l),q(xe,p))}function We(l){Ae.current===l&&(ne(xe),ne(Ae)),ce.current===l&&(ne(ce),Gc._currentValue=V)}var ze,Pe;function ge(l){if(ze===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);ze=u&&u[1]||"",Pe=-1<p.stack.indexOf(`
|
|
27
|
+
at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
28
|
+
`+ze+l+Pe}var Te=!1;function qe(l,u){if(!l||Te)return"";Te=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(u){var Qe=function(){throw Error()};if(Object.defineProperty(Qe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Qe,[])}catch(Ue){var Le=Ue}Reflect.construct(l,[],Qe)}else{try{Qe.call()}catch(Ue){Le=Ue}l.call(Qe.prototype)}}else{try{throw Error()}catch(Ue){Le=Ue}(Qe=l())&&typeof Qe.catch=="function"&&Qe.catch(function(){})}}catch(Ue){if(Ue&&Le&&typeof Ue.stack=="string")return[Ue.stack,Le.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var v=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");v&&v.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var A=g.DetermineComponentFrameRoot(),P=A[0],Y=A[1];if(P&&Y){var ae=P.split(`
|
|
29
|
+
`),Me=Y.split(`
|
|
30
|
+
`);for(v=g=0;g<ae.length&&!ae[g].includes("DetermineComponentFrameRoot");)g++;for(;v<Me.length&&!Me[v].includes("DetermineComponentFrameRoot");)v++;if(g===ae.length||v===Me.length)for(g=ae.length-1,v=Me.length-1;1<=g&&0<=v&&ae[g]!==Me[v];)v--;for(;1<=g&&0<=v;g--,v--)if(ae[g]!==Me[v]){if(g!==1||v!==1)do if(g--,v--,0>v||ae[g]!==Me[v]){var Ve=`
|
|
31
|
+
`+ae[g].replace(" at new "," at ");return l.displayName&&Ve.includes("<anonymous>")&&(Ve=Ve.replace("<anonymous>",l.displayName)),Ve}while(1<=g&&0<=v);break}}}finally{Te=!1,Error.prepareStackTrace=p}return(p=l?l.displayName||l.name:"")?ge(p):""}function it(l,u){switch(l.tag){case 26:case 27:case 5:return ge(l.type);case 16:return ge("Lazy");case 13:return l.child!==u&&u!==null?ge("Suspense Fallback"):ge("Suspense");case 19:return ge("SuspenseList");case 0:case 15:return qe(l.type,!1);case 11:return qe(l.type.render,!1);case 1:return qe(l.type,!0);case 31:return ge("Activity");default:return""}}function he(l){try{var u="",p=null;do u+=it(l,p),p=l,l=l.return;while(l);return u}catch(g){return`
|
|
32
|
+
Error generating stack: `+g.message+`
|
|
33
|
+
`+g.stack}}var Be=Object.prototype.hasOwnProperty,ie=t.unstable_scheduleCallback,de=t.unstable_cancelCallback,He=t.unstable_shouldYield,et=t.unstable_requestPaint,ct=t.unstable_now,fe=t.unstable_getCurrentPriorityLevel,X=t.unstable_ImmediatePriority,se=t.unstable_UserBlockingPriority,Se=t.unstable_NormalPriority,J=t.unstable_LowPriority,pe=t.unstable_IdlePriority,Re=t.log,$e=t.unstable_setDisableYieldValue,ye=null,Ie=null;function te(l){if(typeof Re=="function"&&$e(l),Ie&&typeof Ie.setStrictMode=="function")try{Ie.setStrictMode(ye,l)}catch{}}var be=Math.clz32?Math.clz32:Ke,we=Math.log,Fe=Math.LN2;function Ke(l){return l>>>=0,l===0?32:31-(we(l)/Fe|0)|0}var st=256,ft=262144,wt=4194304;function at(l){var u=l&42;if(u!==0)return u;switch(l&-l){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 l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function gt(l,u,p){var g=l.pendingLanes;if(g===0)return 0;var v=0,A=l.suspendedLanes,P=l.pingedLanes;l=l.warmLanes;var Y=g&134217727;return Y!==0?(g=Y&~A,g!==0?v=at(g):(P&=Y,P!==0?v=at(P):p||(p=Y&~l,p!==0&&(v=at(p))))):(Y=g&~A,Y!==0?v=at(Y):P!==0?v=at(P):p||(p=g&~l,p!==0&&(v=at(p)))),v===0?0:u!==0&&u!==v&&(u&A)===0&&(A=v&-v,p=u&-u,A>=p||A===32&&(p&4194048)!==0)?u:v}function ht(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function Gt(l,u){switch(l){case 1:case 2:case 4:case 8:case 64:return u+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 u+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 tn(){var l=wt;return wt<<=1,(wt&62914560)===0&&(wt=4194304),l}function je(l){for(var u=[],p=0;31>p;p++)u.push(l);return u}function Oe(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Ye(l,u,p,g,v,A){var P=l.pendingLanes;l.pendingLanes=p,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=p,l.entangledLanes&=p,l.errorRecoveryDisabledLanes&=p,l.shellSuspendCounter=0;var Y=l.entanglements,ae=l.expirationTimes,Me=l.hiddenUpdates;for(p=P&~p;0<p;){var Ve=31-be(p),Qe=1<<Ve;Y[Ve]=0,ae[Ve]=-1;var Le=Me[Ve];if(Le!==null)for(Me[Ve]=null,Ve=0;Ve<Le.length;Ve++){var Ue=Le[Ve];Ue!==null&&(Ue.lane&=-536870913)}p&=~Qe}g!==0&&Ze(l,g,0),A!==0&&v===0&&l.tag!==0&&(l.suspendedLanes|=A&~(P&~u))}function Ze(l,u,p){l.pendingLanes|=u,l.suspendedLanes&=~u;var g=31-be(u);l.entangledLanes|=u,l.entanglements[g]=l.entanglements[g]|1073741824|p&261930}function Ot(l,u){var p=l.entangledLanes|=u;for(l=l.entanglements;p;){var g=31-be(p),v=1<<g;v&u|l[g]&u&&(l[g]|=u),p&=~v}}function Ft(l,u){var p=u&-u;return p=(p&42)!==0?1:Lt(p),(p&(l.suspendedLanes|u))!==0?0:p}function Lt(l){switch(l){case 2:l=1;break;case 8:l=4;break;case 32:l=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:l=128;break;case 268435456:l=134217728;break;default:l=0}return l}function Vt(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function ln(){var l=H.p;return l!==0?l:(l=window.event,l===void 0?32:q0(l.type))}function bt(l,u){var p=H.p;try{return H.p=l,u()}finally{H.p=p}}var rt=Math.random().toString(36).slice(2),xt="__reactFiber$"+rt,$t="__reactProps$"+rt,En="__reactContainer$"+rt,nn="__reactEvents$"+rt,Un="__reactListeners$"+rt,Os="__reactHandles$"+rt,ps="__reactResources$"+rt,ks="__reactMarker$"+rt;function Qn(l){delete l[xt],delete l[$t],delete l[nn],delete l[Un],delete l[Os]}function Ss(l){var u=l[xt];if(u)return u;for(var p=l.parentNode;p;){if(u=p[En]||p[xt]){if(p=u.alternate,u.child!==null||p!==null&&p.child!==null)for(l=_0(l);l!==null;){if(p=l[xt])return p;l=_0(l)}return u}l=p,p=l.parentNode}return null}function Fn(l){if(l=l[xt]||l[En]){var u=l.tag;if(u===5||u===6||u===13||u===31||u===26||u===27||u===3)return l}return null}function Ls(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l.stateNode;throw Error(s(33))}function Is(l){var u=l[ps];return u||(u=l[ps]={hoistableStyles:new Map,hoistableScripts:new Map}),u}function wn(l){l[ks]=!0}var Po=new Set,Bo={};function Ps(l,u){Ua(l,u),Ua(l+"Capture",u)}function Ua(l,u){for(Bo[l]=u,l=0;l<u.length;l++)Po.add(u[l])}var Bi=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]*$"),Fi={},Bs={};function lc(l){return Be.call(Bs,l)?!0:Be.call(Fi,l)?!1:Bi.test(l)?Bs[l]=!0:(Fi[l]=!0,!1)}function Ma(l,u,p){if(lc(u))if(p===null)l.removeAttribute(u);else{switch(typeof p){case"undefined":case"function":case"symbol":l.removeAttribute(u);return;case"boolean":var g=u.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){l.removeAttribute(u);return}}l.setAttribute(u,""+p)}}function Ts(l,u,p){if(p===null)l.removeAttribute(u);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(u);return}l.setAttribute(u,""+p)}}function hs(l,u,p,g){if(g===null)l.removeAttribute(p);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(p);return}l.setAttributeNS(u,p,""+g)}}function Mn(l){switch(typeof l){case"bigint":case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function zi(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function Ne(l,u,p){var g=Object.getOwnPropertyDescriptor(l.constructor.prototype,u);if(!l.hasOwnProperty(u)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var v=g.get,A=g.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return v.call(this)},set:function(P){p=""+P,A.call(this,P)}}),Object.defineProperty(l,u,{enumerable:g.enumerable}),{getValue:function(){return p},setValue:function(P){p=""+P},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function Je(l){if(!l._valueTracker){var u=zi(l)?"checked":"value";l._valueTracker=Ne(l,u,""+l[u])}}function Ct(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var p=u.getValue(),g="";return l&&(g=zi(l)?l.checked?"true":"false":l.value),l=g,l!==p?(u.setValue(l),!0):!1}function ot(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var jn=/[\n"\\]/g;function Mt(l){return l.replace(jn,function(u){return"\\"+u.charCodeAt(0).toString(16)+" "})}function At(l,u,p,g,v,A,P,Y){l.name="",P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"?l.type=P:l.removeAttribute("type"),u!=null?P==="number"?(u===0&&l.value===""||l.value!=u)&&(l.value=""+Mn(u)):l.value!==""+Mn(u)&&(l.value=""+Mn(u)):P!=="submit"&&P!=="reset"||l.removeAttribute("value"),u!=null?ms(l,P,Mn(u)):p!=null?ms(l,P,Mn(p)):g!=null&&l.removeAttribute("value"),v==null&&A!=null&&(l.defaultChecked=!!A),v!=null&&(l.checked=v&&typeof v!="function"&&typeof v!="symbol"),Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?l.name=""+Mn(Y):l.removeAttribute("name")}function kn(l,u,p,g,v,A,P,Y){if(A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"&&(l.type=A),u!=null||p!=null){if(!(A!=="submit"&&A!=="reset"||u!=null)){Je(l);return}p=p!=null?""+Mn(p):"",u=u!=null?""+Mn(u):p,Y||u===l.value||(l.value=u),l.defaultValue=u}g=g??v,g=typeof g!="function"&&typeof g!="symbol"&&!!g,l.checked=Y?l.checked:!!g,l.defaultChecked=!!g,P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"&&(l.name=P),Je(l)}function ms(l,u,p){u==="number"&&ot(l.ownerDocument)===l||l.defaultValue===""+p||(l.defaultValue=""+p)}function Dn(l,u,p,g){if(l=l.options,u){u={};for(var v=0;v<p.length;v++)u["$"+p[v]]=!0;for(p=0;p<l.length;p++)v=u.hasOwnProperty("$"+l[p].value),l[p].selected!==v&&(l[p].selected=v),v&&g&&(l[p].defaultSelected=!0)}else{for(p=""+Mn(p),u=null,v=0;v<l.length;v++){if(l[v].value===p){l[v].selected=!0,g&&(l[v].defaultSelected=!0);return}u!==null||l[v].disabled||(u=l[v])}u!==null&&(u.selected=!0)}}function Fs(l,u,p){if(u!=null&&(u=""+Mn(u),u!==l.value&&(l.value=u),p==null)){l.defaultValue!==u&&(l.defaultValue=u);return}l.defaultValue=p!=null?""+Mn(p):""}function Qr(l,u,p,g){if(u==null){if(g!=null){if(p!=null)throw Error(s(92));if(L(g)){if(1<g.length)throw Error(s(93));g=g[0]}p=g}p==null&&(p=""),u=p}p=Mn(u),l.defaultValue=p,g=l.textContent,g===p&&g!==""&&g!==null&&(l.value=g),Je(l)}function pa(l,u){if(u){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=u;return}}l.textContent=u}var mh=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 ha(l,u,p){var g=u.indexOf("--")===0;p==null||typeof p=="boolean"||p===""?g?l.setProperty(u,""):u==="float"?l.cssFloat="":l[u]="":g?l.setProperty(u,p):typeof p!="number"||p===0||mh.has(u)?u==="float"?l.cssFloat=p:l[u]=(""+p).trim():l[u]=p+"px"}function $i(l,u,p){if(u!=null&&typeof u!="object")throw Error(s(62));if(l=l.style,p!=null){for(var g in p)!p.hasOwnProperty(g)||u!=null&&u.hasOwnProperty(g)||(g.indexOf("--")===0?l.setProperty(g,""):g==="float"?l.cssFloat="":l[g]="");for(var v in u)g=u[v],u.hasOwnProperty(v)&&p[v]!==g&&ha(l,v,g)}else for(var A in u)u.hasOwnProperty(A)&&ha(l,A,u[A])}function gr(l){if(l.indexOf("-")===-1)return!1;switch(l){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 Ui=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"]]),cc=/^[\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 Fo(l){return cc.test(""+l)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":l}function It(){}var Hn=null;function uc(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Xr=null,Jr=null;function ts(l){var u=Fn(l);if(u&&(l=u.stateNode)){var p=l[$t]||null;e:switch(l=u.stateNode,u.type){case"input":if(At(l,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name),u=p.name,p.type==="radio"&&u!=null){for(p=l;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll('input[name="'+Mt(""+u)+'"][type="radio"]'),u=0;u<p.length;u++){var g=p[u];if(g!==l&&g.form===l.form){var v=g[$t]||null;if(!v)throw Error(s(90));At(g,v.value,v.defaultValue,v.defaultValue,v.checked,v.defaultChecked,v.type,v.name)}}for(u=0;u<p.length;u++)g=p[u],g.form===l.form&&Ct(g)}break e;case"textarea":Fs(l,p.value,p.defaultValue);break e;case"select":u=p.value,u!=null&&Dn(l,!!p.multiple,u,!1)}}}var zo=!1;function cd(l,u,p){if(zo)return l(u,p);zo=!0;try{var g=l(u);return g}finally{if(zo=!1,(Xr!==null||Jr!==null)&&(tf(),Xr&&(u=Xr,l=Jr,Jr=Xr=null,ts(u),l)))for(u=0;u<l.length;u++)ts(l[u])}}function Ha(l,u){var p=l.stateNode;if(p===null)return null;var g=p[$t]||null;if(g===null)return null;p=g[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(l=l.type,g=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!g;break e;default:l=!1}if(l)return null;if(p&&typeof p!="function")throw Error(s(231,u,typeof p));return p}var zs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hi=!1;if(zs)try{var br={};Object.defineProperty(br,"passive",{get:function(){Hi=!0}}),window.addEventListener("test",br,br),window.removeEventListener("test",br,br)}catch{Hi=!1}var ma=null,$o=null,Uo=null;function ud(){if(Uo)return Uo;var l,u=$o,p=u.length,g,v="value"in ma?ma.value:ma.textContent,A=v.length;for(l=0;l<p&&u[l]===v[l];l++);var P=p-l;for(g=1;g<=P&&u[p-g]===v[A-g];g++);return Uo=v.slice(l,1<g?1-g:void 0)}function Wi(l){var u=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&u===13&&(l=13)):l=u,l===10&&(l=13),32<=l||l===13?l:0}function qi(){return!0}function Wa(){return!1}function Wn(l){function u(p,g,v,A,P){this._reactName=p,this._targetInst=v,this.type=g,this.nativeEvent=A,this.target=P,this.currentTarget=null;for(var Y in l)l.hasOwnProperty(Y)&&(p=l[Y],this[Y]=p?p(A):A[Y]);return this.isDefaultPrevented=(A.defaultPrevented!=null?A.defaultPrevented:A.returnValue===!1)?qi:Wa,this.isPropagationStopped=Wa,this}return m(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=qi)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=qi)},persist:function(){},isPersistent:qi}),u}var xr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ln=Wn(xr),Vi=m({},xr,{view:0,detail:0}),dd=Wn(Vi),Ho,Wo,Zr,qo=m({},Vi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Go,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Zr&&(Zr&&l.type==="mousemove"?(Ho=l.screenX-Zr.screenX,Wo=l.screenY-Zr.screenY):Wo=Ho=0,Zr=l),Ho)},movementY:function(l){return"movementY"in l?l.movementY:Wo}}),fd=Wn(qo),gh=m({},qo,{dataTransfer:0}),Vo=Wn(gh),pd=m({},Vi,{relatedTarget:0}),ei=Wn(pd),dc=m({},xr,{animationName:0,elapsedTime:0,pseudoElement:0}),fc=Wn(dc),Yi=m({},xr,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),pc=Wn(Yi),Yo=m({},xr,{data:0}),hd=Wn(Yo),bh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xh={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"},yh={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vh(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=yh[l])?!!u[l]:!1}function Go(){return vh}var wh=m({},Vi,{key:function(l){if(l.key){var u=bh[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=Wi(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?xh[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Go,charCode:function(l){return l.type==="keypress"?Wi(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?Wi(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),kh=Wn(wh),md=m({},qo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),qa=Wn(md),gd=m({},Vi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Go}),bd=Wn(gd),Gi=m({},xr,{propertyName:0,elapsedTime:0,pseudoElement:0}),hc=Wn(Gi),Sh=m({},qo,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),Ch=Wn(Sh),Ah=m({},xr,{newState:0,oldState:0}),jh=Wn(Ah),xd=[9,13,27,32],Ko=zs&&"CompositionEvent"in window,ti=null;zs&&"documentMode"in document&&(ti=document.documentMode);var yd=zs&&"TextEvent"in window&&!ti,mc=zs&&(!Ko||ti&&8<ti&&11>=ti),Q=" ",ue=!1;function le(l,u){switch(l){case"keyup":return xd.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ee(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var nt=!1;function ut(l,u){switch(l){case"compositionend":return Ee(u);case"keypress":return u.which!==32?null:(ue=!0,Q);case"textInput":return l=u.data,l===Q&&ue?null:l;default:return null}}function Nt(l,u){if(nt)return l==="compositionend"||!Ko&&le(l,u)?(l=ud(),Uo=$o=ma=null,nt=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return mc&&u.locale!=="ko"?null:u.data;default:return null}}var _t={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 sn(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!_t[l.type]:u==="textarea"}function gn(l,u,p,g){Xr?Jr?Jr.push(g):Jr=[g]:Xr=g,u=cf(u,"onChange"),0<u.length&&(p=new Ln("onChange","change",null,p,g),l.push({event:p,listeners:u}))}var qn=null,Va=null;function Qo(l){m0(l,0)}function Ki(l){var u=Ls(l);if(Ct(u))return l}function gc(l,u){if(l==="change")return u}var Xo=!1;if(zs){var Jo;if(zs){var bc="oninput"in document;if(!bc){var vd=document.createElement("div");vd.setAttribute("oninput","return;"),bc=typeof vd.oninput=="function"}Jo=bc}else Jo=!1;Xo=Jo&&(!document.documentMode||9<document.documentMode)}function Py(){qn&&(qn.detachEvent("onpropertychange",By),Va=qn=null)}function By(l){if(l.propertyName==="value"&&Ki(Va)){var u=[];gn(u,Va,l,uc(l)),cd(Qo,u)}}function n_(l,u,p){l==="focusin"?(Py(),qn=u,Va=p,qn.attachEvent("onpropertychange",By)):l==="focusout"&&Py()}function s_(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Ki(Va)}function a_(l,u){if(l==="click")return Ki(u)}function r_(l,u){if(l==="input"||l==="change")return Ki(u)}function i_(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var Js=typeof Object.is=="function"?Object.is:i_;function xc(l,u){if(Js(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var p=Object.keys(l),g=Object.keys(u);if(p.length!==g.length)return!1;for(g=0;g<p.length;g++){var v=p[g];if(!Be.call(u,v)||!Js(l[v],u[v]))return!1}return!0}function Fy(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function zy(l,u){var p=Fy(l);l=0;for(var g;p;){if(p.nodeType===3){if(g=l+p.textContent.length,l<=u&&g>=u)return{node:p,offset:u-l};l=g}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Fy(p)}}function $y(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?$y(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function Uy(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var u=ot(l.document);u instanceof l.HTMLIFrameElement;){try{var p=typeof u.contentWindow.location.href=="string"}catch{p=!1}if(p)l=u.contentWindow;else break;u=ot(l.document)}return u}function Nh(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}var o_=zs&&"documentMode"in document&&11>=document.documentMode,Zo=null,Th=null,yc=null,_h=!1;function Hy(l,u,p){var g=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;_h||Zo==null||Zo!==ot(g)||(g=Zo,"selectionStart"in g&&Nh(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),yc&&xc(yc,g)||(yc=g,g=cf(Th,"onSelect"),0<g.length&&(u=new Ln("onSelect","select",null,u,p),l.push({event:u,listeners:g}),u.target=Zo)))}function Qi(l,u){var p={};return p[l.toLowerCase()]=u.toLowerCase(),p["Webkit"+l]="webkit"+u,p["Moz"+l]="moz"+u,p}var el={animationend:Qi("Animation","AnimationEnd"),animationiteration:Qi("Animation","AnimationIteration"),animationstart:Qi("Animation","AnimationStart"),transitionrun:Qi("Transition","TransitionRun"),transitionstart:Qi("Transition","TransitionStart"),transitioncancel:Qi("Transition","TransitionCancel"),transitionend:Qi("Transition","TransitionEnd")},Eh={},Wy={};zs&&(Wy=document.createElement("div").style,"AnimationEvent"in window||(delete el.animationend.animation,delete el.animationiteration.animation,delete el.animationstart.animation),"TransitionEvent"in window||delete el.transitionend.transition);function Xi(l){if(Eh[l])return Eh[l];if(!el[l])return l;var u=el[l],p;for(p in u)if(u.hasOwnProperty(p)&&p in Wy)return Eh[l]=u[p];return l}var qy=Xi("animationend"),Vy=Xi("animationiteration"),Yy=Xi("animationstart"),l_=Xi("transitionrun"),c_=Xi("transitionstart"),u_=Xi("transitioncancel"),Gy=Xi("transitionend"),Ky=new Map,Mh="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(" ");Mh.push("scrollEnd");function Da(l,u){Ky.set(l,u),Ps(u,[l])}var wd=typeof reportError=="function"?reportError:function(l){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof l=="object"&&l!==null&&typeof l.message=="string"?String(l.message):String(l),error:l});if(!window.dispatchEvent(u))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",l);return}console.error(l)},ga=[],tl=0,Dh=0;function kd(){for(var l=tl,u=Dh=tl=0;u<l;){var p=ga[u];ga[u++]=null;var g=ga[u];ga[u++]=null;var v=ga[u];ga[u++]=null;var A=ga[u];if(ga[u++]=null,g!==null&&v!==null){var P=g.pending;P===null?v.next=v:(v.next=P.next,P.next=v),g.pending=v}A!==0&&Qy(p,v,A)}}function Sd(l,u,p,g){ga[tl++]=l,ga[tl++]=u,ga[tl++]=p,ga[tl++]=g,Dh|=g,l.lanes|=g,l=l.alternate,l!==null&&(l.lanes|=g)}function Rh(l,u,p,g){return Sd(l,u,p,g),Cd(l)}function Ji(l,u){return Sd(l,null,null,u),Cd(l)}function Qy(l,u,p){l.lanes|=p;var g=l.alternate;g!==null&&(g.lanes|=p);for(var v=!1,A=l.return;A!==null;)A.childLanes|=p,g=A.alternate,g!==null&&(g.childLanes|=p),A.tag===22&&(l=A.stateNode,l===null||l._visibility&1||(v=!0)),l=A,A=A.return;return l.tag===3?(A=l.stateNode,v&&u!==null&&(v=31-be(p),l=A.hiddenUpdates,g=l[v],g===null?l[v]=[u]:g.push(u),u.lane=p|536870912),A):null}function Cd(l){if(50<$c)throw $c=0,Um=null,Error(s(185));for(var u=l.return;u!==null;)l=u,u=l.return;return l.tag===3?l.stateNode:null}var nl={};function d_(l,u,p,g){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zs(l,u,p,g){return new d_(l,u,p,g)}function Oh(l){return l=l.prototype,!(!l||!l.isReactComponent)}function yr(l,u){var p=l.alternate;return p===null?(p=Zs(l.tag,u,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=u,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&65011712,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,u=l.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p.refCleanup=l.refCleanup,p}function Xy(l,u){l.flags&=65011714;var p=l.alternate;return p===null?(l.childLanes=0,l.lanes=u,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=p.childLanes,l.lanes=p.lanes,l.child=p.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=p.memoizedProps,l.memoizedState=p.memoizedState,l.updateQueue=p.updateQueue,l.type=p.type,u=p.dependencies,l.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),l}function Ad(l,u,p,g,v,A){var P=0;if(g=l,typeof l=="function")Oh(l)&&(P=1);else if(typeof l=="string")P=gE(l,p,xe.current)?26:l==="html"||l==="head"||l==="body"?27:5;else e:switch(l){case _:return l=Zs(31,p,u,v),l.elementType=_,l.lanes=A,l;case C:return Zi(p.children,v,A,u);case N:P=8,v|=24;break;case k:return l=Zs(12,p,u,v|2),l.elementType=k,l.lanes=A,l;case D:return l=Zs(13,p,u,v),l.elementType=D,l.lanes=A,l;case E:return l=Zs(19,p,u,v),l.elementType=E,l.lanes=A,l;default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case S:P=10;break e;case j:P=9;break e;case T:P=11;break e;case I:P=14;break e;case O:P=16,g=null;break e}P=29,p=Error(s(130,l===null?"null":typeof l,"")),g=null}return u=Zs(P,p,u,v),u.elementType=l,u.type=g,u.lanes=A,u}function Zi(l,u,p,g){return l=Zs(7,l,g,u),l.lanes=p,l}function Lh(l,u,p){return l=Zs(6,l,null,u),l.lanes=p,l}function Jy(l){var u=Zs(18,null,null,0);return u.stateNode=l,u}function Ih(l,u,p){return u=Zs(4,l.children!==null?l.children:[],l.key,u),u.lanes=p,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}var Zy=new WeakMap;function ba(l,u){if(typeof l=="object"&&l!==null){var p=Zy.get(l);return p!==void 0?p:(u={value:l,source:u,stack:he(u)},Zy.set(l,u),u)}return{value:l,source:u,stack:he(u)}}var sl=[],al=0,jd=null,vc=0,xa=[],ya=0,ni=null,Ya=1,Ga="";function vr(l,u){sl[al++]=vc,sl[al++]=jd,jd=l,vc=u}function ev(l,u,p){xa[ya++]=Ya,xa[ya++]=Ga,xa[ya++]=ni,ni=l;var g=Ya;l=Ga;var v=32-be(g)-1;g&=~(1<<v),p+=1;var A=32-be(u)+v;if(30<A){var P=v-v%5;A=(g&(1<<P)-1).toString(32),g>>=P,v-=P,Ya=1<<32-be(u)+v|p<<v|g,Ga=A+l}else Ya=1<<A|p<<v|g,Ga=l}function Ph(l){l.return!==null&&(vr(l,1),ev(l,1,0))}function Bh(l){for(;l===jd;)jd=sl[--al],sl[al]=null,vc=sl[--al],sl[al]=null;for(;l===ni;)ni=xa[--ya],xa[ya]=null,Ga=xa[--ya],xa[ya]=null,Ya=xa[--ya],xa[ya]=null}function tv(l,u){xa[ya++]=Ya,xa[ya++]=Ga,xa[ya++]=ni,Ya=u.id,Ga=u.overflow,ni=l}var gs=null,In=null,cn=!1,si=null,va=!1,Fh=Error(s(519));function ai(l){var u=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw wc(ba(u,l)),Fh}function nv(l){var u=l.stateNode,p=l.type,g=l.memoizedProps;switch(u[xt]=l,u[$t]=g,p){case"dialog":Qt("cancel",u),Qt("close",u);break;case"iframe":case"object":case"embed":Qt("load",u);break;case"video":case"audio":for(p=0;p<Hc.length;p++)Qt(Hc[p],u);break;case"source":Qt("error",u);break;case"img":case"image":case"link":Qt("error",u),Qt("load",u);break;case"details":Qt("toggle",u);break;case"input":Qt("invalid",u),kn(u,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":Qt("invalid",u);break;case"textarea":Qt("invalid",u),Qr(u,g.value,g.defaultValue,g.children)}p=g.children,typeof p!="string"&&typeof p!="number"&&typeof p!="bigint"||u.textContent===""+p||g.suppressHydrationWarning===!0||y0(u.textContent,p)?(g.popover!=null&&(Qt("beforetoggle",u),Qt("toggle",u)),g.onScroll!=null&&Qt("scroll",u),g.onScrollEnd!=null&&Qt("scrollend",u),g.onClick!=null&&(u.onclick=It),u=!0):u=!1,u||ai(l,!0)}function sv(l){for(gs=l.return;gs;)switch(gs.tag){case 5:case 31:case 13:va=!1;return;case 27:case 3:va=!0;return;default:gs=gs.return}}function rl(l){if(l!==gs)return!1;if(!cn)return sv(l),cn=!0,!1;var u=l.tag,p;if((p=u!==3&&u!==27)&&((p=u===5)&&(p=l.type,p=!(p!=="form"&&p!=="button")||sg(l.type,l.memoizedProps)),p=!p),p&&In&&ai(l),sv(l),u===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(s(317));In=T0(l)}else if(u===31){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(s(317));In=T0(l)}else u===27?(u=In,xi(l.type)?(l=lg,lg=null,In=l):In=u):In=gs?ka(l.stateNode.nextSibling):null;return!0}function eo(){In=gs=null,cn=!1}function zh(){var l=si;return l!==null&&(Ws===null?Ws=l:Ws.push.apply(Ws,l),si=null),l}function wc(l){si===null?si=[l]:si.push(l)}var $h=K(null),to=null,wr=null;function ri(l,u,p){q($h,u._currentValue),u._currentValue=p}function kr(l){l._currentValue=$h.current,ne($h)}function Uh(l,u,p){for(;l!==null;){var g=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,g!==null&&(g.childLanes|=u)):g!==null&&(g.childLanes&u)!==u&&(g.childLanes|=u),l===p)break;l=l.return}}function Hh(l,u,p,g){var v=l.child;for(v!==null&&(v.return=l);v!==null;){var A=v.dependencies;if(A!==null){var P=v.child;A=A.firstContext;e:for(;A!==null;){var Y=A;A=v;for(var ae=0;ae<u.length;ae++)if(Y.context===u[ae]){A.lanes|=p,Y=A.alternate,Y!==null&&(Y.lanes|=p),Uh(A.return,p,l),g||(P=null);break e}A=Y.next}}else if(v.tag===18){if(P=v.return,P===null)throw Error(s(341));P.lanes|=p,A=P.alternate,A!==null&&(A.lanes|=p),Uh(P,p,l),P=null}else P=v.child;if(P!==null)P.return=v;else for(P=v;P!==null;){if(P===l){P=null;break}if(v=P.sibling,v!==null){v.return=P.return,P=v;break}P=P.return}v=P}}function il(l,u,p,g){l=null;for(var v=u,A=!1;v!==null;){if(!A){if((v.flags&524288)!==0)A=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var P=v.alternate;if(P===null)throw Error(s(387));if(P=P.memoizedProps,P!==null){var Y=v.type;Js(v.pendingProps.value,P.value)||(l!==null?l.push(Y):l=[Y])}}else if(v===ce.current){if(P=v.alternate,P===null)throw Error(s(387));P.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(l!==null?l.push(Gc):l=[Gc])}v=v.return}l!==null&&Hh(u,l,p,g),u.flags|=262144}function Nd(l){for(l=l.firstContext;l!==null;){if(!Js(l.context._currentValue,l.memoizedValue))return!0;l=l.next}return!1}function no(l){to=l,wr=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function bs(l){return av(to,l)}function Td(l,u){return to===null&&no(l),av(l,u)}function av(l,u){var p=u._currentValue;if(u={context:u,memoizedValue:p,next:null},wr===null){if(l===null)throw Error(s(308));wr=u,l.dependencies={lanes:0,firstContext:u},l.flags|=524288}else wr=wr.next=u;return p}var f_=typeof AbortController<"u"?AbortController:function(){var l=[],u=this.signal={aborted:!1,addEventListener:function(p,g){l.push(g)}};this.abort=function(){u.aborted=!0,l.forEach(function(p){return p()})}},p_=t.unstable_scheduleCallback,h_=t.unstable_NormalPriority,ns={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Wh(){return{controller:new f_,data:new Map,refCount:0}}function kc(l){l.refCount--,l.refCount===0&&p_(h_,function(){l.controller.abort()})}var Sc=null,qh=0,ol=0,ll=null;function m_(l,u){if(Sc===null){var p=Sc=[];qh=0,ol=Gm(),ll={status:"pending",value:void 0,then:function(g){p.push(g)}}}return qh++,u.then(rv,rv),u}function rv(){if(--qh===0&&Sc!==null){ll!==null&&(ll.status="fulfilled");var l=Sc;Sc=null,ol=0,ll=null;for(var u=0;u<l.length;u++)(0,l[u])()}}function g_(l,u){var p=[],g={status:"pending",value:null,reason:null,then:function(v){p.push(v)}};return l.then(function(){g.status="fulfilled",g.value=u;for(var v=0;v<p.length;v++)(0,p[v])(u)},function(v){for(g.status="rejected",g.reason=v,v=0;v<p.length;v++)(0,p[v])(void 0)}),g}var iv=F.S;F.S=function(l,u){Hw=ct(),typeof u=="object"&&u!==null&&typeof u.then=="function"&&m_(l,u),iv!==null&&iv(l,u)};var so=K(null);function Vh(){var l=so.current;return l!==null?l:Nn.pooledCache}function _d(l,u){u===null?q(so,so.current):q(so,u.pool)}function ov(){var l=Vh();return l===null?null:{parent:ns._currentValue,pool:l}}var cl=Error(s(460)),Yh=Error(s(474)),Ed=Error(s(542)),Md={then:function(){}};function lv(l){return l=l.status,l==="fulfilled"||l==="rejected"}function cv(l,u,p){switch(p=l[p],p===void 0?l.push(u):p!==u&&(u.then(It,It),u=p),u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,dv(l),l;default:if(typeof u.status=="string")u.then(It,It);else{if(l=Nn,l!==null&&100<l.shellSuspendCounter)throw Error(s(482));l=u,l.status="pending",l.then(function(g){if(u.status==="pending"){var v=u;v.status="fulfilled",v.value=g}},function(g){if(u.status==="pending"){var v=u;v.status="rejected",v.reason=g}})}switch(u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,dv(l),l}throw ro=u,cl}}function ao(l){try{var u=l._init;return u(l._payload)}catch(p){throw p!==null&&typeof p=="object"&&typeof p.then=="function"?(ro=p,cl):p}}var ro=null;function uv(){if(ro===null)throw Error(s(459));var l=ro;return ro=null,l}function dv(l){if(l===cl||l===Ed)throw Error(s(483))}var ul=null,Cc=0;function Dd(l){var u=Cc;return Cc+=1,ul===null&&(ul=[]),cv(ul,l,u)}function Ac(l,u){u=u.props.ref,l.ref=u!==void 0?u:null}function Rd(l,u){throw u.$$typeof===b?Error(s(525)):(l=Object.prototype.toString.call(u),Error(s(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l)))}function fv(l){function u(ke,oe){if(l){var _e=ke.deletions;_e===null?(ke.deletions=[oe],ke.flags|=16):_e.push(oe)}}function p(ke,oe){if(!l)return null;for(;oe!==null;)u(ke,oe),oe=oe.sibling;return null}function g(ke){for(var oe=new Map;ke!==null;)ke.key!==null?oe.set(ke.key,ke):oe.set(ke.index,ke),ke=ke.sibling;return oe}function v(ke,oe){return ke=yr(ke,oe),ke.index=0,ke.sibling=null,ke}function A(ke,oe,_e){return ke.index=_e,l?(_e=ke.alternate,_e!==null?(_e=_e.index,_e<oe?(ke.flags|=67108866,oe):_e):(ke.flags|=67108866,oe)):(ke.flags|=1048576,oe)}function P(ke){return l&&ke.alternate===null&&(ke.flags|=67108866),ke}function Y(ke,oe,_e,Ge){return oe===null||oe.tag!==6?(oe=Lh(_e,ke.mode,Ge),oe.return=ke,oe):(oe=v(oe,_e),oe.return=ke,oe)}function ae(ke,oe,_e,Ge){var Tt=_e.type;return Tt===C?Ve(ke,oe,_e.props.children,Ge,_e.key):oe!==null&&(oe.elementType===Tt||typeof Tt=="object"&&Tt!==null&&Tt.$$typeof===O&&ao(Tt)===oe.type)?(oe=v(oe,_e.props),Ac(oe,_e),oe.return=ke,oe):(oe=Ad(_e.type,_e.key,_e.props,null,ke.mode,Ge),Ac(oe,_e),oe.return=ke,oe)}function Me(ke,oe,_e,Ge){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==_e.containerInfo||oe.stateNode.implementation!==_e.implementation?(oe=Ih(_e,ke.mode,Ge),oe.return=ke,oe):(oe=v(oe,_e.children||[]),oe.return=ke,oe)}function Ve(ke,oe,_e,Ge,Tt){return oe===null||oe.tag!==7?(oe=Zi(_e,ke.mode,Ge,Tt),oe.return=ke,oe):(oe=v(oe,_e),oe.return=ke,oe)}function Qe(ke,oe,_e){if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return oe=Lh(""+oe,ke.mode,_e),oe.return=ke,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case y:return _e=Ad(oe.type,oe.key,oe.props,null,ke.mode,_e),Ac(_e,oe),_e.return=ke,_e;case w:return oe=Ih(oe,ke.mode,_e),oe.return=ke,oe;case O:return oe=ao(oe),Qe(ke,oe,_e)}if(L(oe)||z(oe))return oe=Zi(oe,ke.mode,_e,null),oe.return=ke,oe;if(typeof oe.then=="function")return Qe(ke,Dd(oe),_e);if(oe.$$typeof===S)return Qe(ke,Td(ke,oe),_e);Rd(ke,oe)}return null}function Le(ke,oe,_e,Ge){var Tt=oe!==null?oe.key:null;if(typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint")return Tt!==null?null:Y(ke,oe,""+_e,Ge);if(typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case y:return _e.key===Tt?ae(ke,oe,_e,Ge):null;case w:return _e.key===Tt?Me(ke,oe,_e,Ge):null;case O:return _e=ao(_e),Le(ke,oe,_e,Ge)}if(L(_e)||z(_e))return Tt!==null?null:Ve(ke,oe,_e,Ge,null);if(typeof _e.then=="function")return Le(ke,oe,Dd(_e),Ge);if(_e.$$typeof===S)return Le(ke,oe,Td(ke,_e),Ge);Rd(ke,_e)}return null}function Ue(ke,oe,_e,Ge,Tt){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return ke=ke.get(_e)||null,Y(oe,ke,""+Ge,Tt);if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case y:return ke=ke.get(Ge.key===null?_e:Ge.key)||null,ae(oe,ke,Ge,Tt);case w:return ke=ke.get(Ge.key===null?_e:Ge.key)||null,Me(oe,ke,Ge,Tt);case O:return Ge=ao(Ge),Ue(ke,oe,_e,Ge,Tt)}if(L(Ge)||z(Ge))return ke=ke.get(_e)||null,Ve(oe,ke,Ge,Tt,null);if(typeof Ge.then=="function")return Ue(ke,oe,_e,Dd(Ge),Tt);if(Ge.$$typeof===S)return Ue(ke,oe,_e,Td(oe,Ge),Tt);Rd(oe,Ge)}return null}function yt(ke,oe,_e,Ge){for(var Tt=null,fn=null,kt=oe,Ht=oe=0,rn=null;kt!==null&&Ht<_e.length;Ht++){kt.index>Ht?(rn=kt,kt=null):rn=kt.sibling;var pn=Le(ke,kt,_e[Ht],Ge);if(pn===null){kt===null&&(kt=rn);break}l&&kt&&pn.alternate===null&&u(ke,kt),oe=A(pn,oe,Ht),fn===null?Tt=pn:fn.sibling=pn,fn=pn,kt=rn}if(Ht===_e.length)return p(ke,kt),cn&&vr(ke,Ht),Tt;if(kt===null){for(;Ht<_e.length;Ht++)kt=Qe(ke,_e[Ht],Ge),kt!==null&&(oe=A(kt,oe,Ht),fn===null?Tt=kt:fn.sibling=kt,fn=kt);return cn&&vr(ke,Ht),Tt}for(kt=g(kt);Ht<_e.length;Ht++)rn=Ue(kt,ke,Ht,_e[Ht],Ge),rn!==null&&(l&&rn.alternate!==null&&kt.delete(rn.key===null?Ht:rn.key),oe=A(rn,oe,Ht),fn===null?Tt=rn:fn.sibling=rn,fn=rn);return l&&kt.forEach(function(Si){return u(ke,Si)}),cn&&vr(ke,Ht),Tt}function Dt(ke,oe,_e,Ge){if(_e==null)throw Error(s(151));for(var Tt=null,fn=null,kt=oe,Ht=oe=0,rn=null,pn=_e.next();kt!==null&&!pn.done;Ht++,pn=_e.next()){kt.index>Ht?(rn=kt,kt=null):rn=kt.sibling;var Si=Le(ke,kt,pn.value,Ge);if(Si===null){kt===null&&(kt=rn);break}l&&kt&&Si.alternate===null&&u(ke,kt),oe=A(Si,oe,Ht),fn===null?Tt=Si:fn.sibling=Si,fn=Si,kt=rn}if(pn.done)return p(ke,kt),cn&&vr(ke,Ht),Tt;if(kt===null){for(;!pn.done;Ht++,pn=_e.next())pn=Qe(ke,pn.value,Ge),pn!==null&&(oe=A(pn,oe,Ht),fn===null?Tt=pn:fn.sibling=pn,fn=pn);return cn&&vr(ke,Ht),Tt}for(kt=g(kt);!pn.done;Ht++,pn=_e.next())pn=Ue(kt,ke,Ht,pn.value,Ge),pn!==null&&(l&&pn.alternate!==null&&kt.delete(pn.key===null?Ht:pn.key),oe=A(pn,oe,Ht),fn===null?Tt=pn:fn.sibling=pn,fn=pn);return l&&kt.forEach(function(NE){return u(ke,NE)}),cn&&vr(ke,Ht),Tt}function An(ke,oe,_e,Ge){if(typeof _e=="object"&&_e!==null&&_e.type===C&&_e.key===null&&(_e=_e.props.children),typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case y:e:{for(var Tt=_e.key;oe!==null;){if(oe.key===Tt){if(Tt=_e.type,Tt===C){if(oe.tag===7){p(ke,oe.sibling),Ge=v(oe,_e.props.children),Ge.return=ke,ke=Ge;break e}}else if(oe.elementType===Tt||typeof Tt=="object"&&Tt!==null&&Tt.$$typeof===O&&ao(Tt)===oe.type){p(ke,oe.sibling),Ge=v(oe,_e.props),Ac(Ge,_e),Ge.return=ke,ke=Ge;break e}p(ke,oe);break}else u(ke,oe);oe=oe.sibling}_e.type===C?(Ge=Zi(_e.props.children,ke.mode,Ge,_e.key),Ge.return=ke,ke=Ge):(Ge=Ad(_e.type,_e.key,_e.props,null,ke.mode,Ge),Ac(Ge,_e),Ge.return=ke,ke=Ge)}return P(ke);case w:e:{for(Tt=_e.key;oe!==null;){if(oe.key===Tt)if(oe.tag===4&&oe.stateNode.containerInfo===_e.containerInfo&&oe.stateNode.implementation===_e.implementation){p(ke,oe.sibling),Ge=v(oe,_e.children||[]),Ge.return=ke,ke=Ge;break e}else{p(ke,oe);break}else u(ke,oe);oe=oe.sibling}Ge=Ih(_e,ke.mode,Ge),Ge.return=ke,ke=Ge}return P(ke);case O:return _e=ao(_e),An(ke,oe,_e,Ge)}if(L(_e))return yt(ke,oe,_e,Ge);if(z(_e)){if(Tt=z(_e),typeof Tt!="function")throw Error(s(150));return _e=Tt.call(_e),Dt(ke,oe,_e,Ge)}if(typeof _e.then=="function")return An(ke,oe,Dd(_e),Ge);if(_e.$$typeof===S)return An(ke,oe,Td(ke,_e),Ge);Rd(ke,_e)}return typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint"?(_e=""+_e,oe!==null&&oe.tag===6?(p(ke,oe.sibling),Ge=v(oe,_e),Ge.return=ke,ke=Ge):(p(ke,oe),Ge=Lh(_e,ke.mode,Ge),Ge.return=ke,ke=Ge),P(ke)):p(ke,oe)}return function(ke,oe,_e,Ge){try{Cc=0;var Tt=An(ke,oe,_e,Ge);return ul=null,Tt}catch(kt){if(kt===cl||kt===Ed)throw kt;var fn=Zs(29,kt,null,ke.mode);return fn.lanes=Ge,fn.return=ke,fn}finally{}}}var io=fv(!0),pv=fv(!1),ii=!1;function Gh(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Kh(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function oi(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function li(l,u,p){var g=l.updateQueue;if(g===null)return null;if(g=g.shared,(hn&2)!==0){var v=g.pending;return v===null?u.next=u:(u.next=v.next,v.next=u),g.pending=u,u=Cd(l),Qy(l,null,p),u}return Sd(l,g,u,p),Cd(l)}function jc(l,u,p){if(u=u.updateQueue,u!==null&&(u=u.shared,(p&4194048)!==0)){var g=u.lanes;g&=l.pendingLanes,p|=g,u.lanes=p,Ot(l,p)}}function Qh(l,u){var p=l.updateQueue,g=l.alternate;if(g!==null&&(g=g.updateQueue,p===g)){var v=null,A=null;if(p=p.firstBaseUpdate,p!==null){do{var P={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};A===null?v=A=P:A=A.next=P,p=p.next}while(p!==null);A===null?v=A=u:A=A.next=u}else v=A=u;p={baseState:g.baseState,firstBaseUpdate:v,lastBaseUpdate:A,shared:g.shared,callbacks:g.callbacks},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=u}var Xh=!1;function Nc(){if(Xh){var l=ll;if(l!==null)throw l}}function Tc(l,u,p,g){Xh=!1;var v=l.updateQueue;ii=!1;var A=v.firstBaseUpdate,P=v.lastBaseUpdate,Y=v.shared.pending;if(Y!==null){v.shared.pending=null;var ae=Y,Me=ae.next;ae.next=null,P===null?A=Me:P.next=Me,P=ae;var Ve=l.alternate;Ve!==null&&(Ve=Ve.updateQueue,Y=Ve.lastBaseUpdate,Y!==P&&(Y===null?Ve.firstBaseUpdate=Me:Y.next=Me,Ve.lastBaseUpdate=ae))}if(A!==null){var Qe=v.baseState;P=0,Ve=Me=ae=null,Y=A;do{var Le=Y.lane&-536870913,Ue=Le!==Y.lane;if(Ue?(an&Le)===Le:(g&Le)===Le){Le!==0&&Le===ol&&(Xh=!0),Ve!==null&&(Ve=Ve.next={lane:0,tag:Y.tag,payload:Y.payload,callback:null,next:null});e:{var yt=l,Dt=Y;Le=u;var An=p;switch(Dt.tag){case 1:if(yt=Dt.payload,typeof yt=="function"){Qe=yt.call(An,Qe,Le);break e}Qe=yt;break e;case 3:yt.flags=yt.flags&-65537|128;case 0:if(yt=Dt.payload,Le=typeof yt=="function"?yt.call(An,Qe,Le):yt,Le==null)break e;Qe=m({},Qe,Le);break e;case 2:ii=!0}}Le=Y.callback,Le!==null&&(l.flags|=64,Ue&&(l.flags|=8192),Ue=v.callbacks,Ue===null?v.callbacks=[Le]:Ue.push(Le))}else Ue={lane:Le,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},Ve===null?(Me=Ve=Ue,ae=Qe):Ve=Ve.next=Ue,P|=Le;if(Y=Y.next,Y===null){if(Y=v.shared.pending,Y===null)break;Ue=Y,Y=Ue.next,Ue.next=null,v.lastBaseUpdate=Ue,v.shared.pending=null}}while(!0);Ve===null&&(ae=Qe),v.baseState=ae,v.firstBaseUpdate=Me,v.lastBaseUpdate=Ve,A===null&&(v.shared.lanes=0),pi|=P,l.lanes=P,l.memoizedState=Qe}}function hv(l,u){if(typeof l!="function")throw Error(s(191,l));l.call(u)}function mv(l,u){var p=l.callbacks;if(p!==null)for(l.callbacks=null,l=0;l<p.length;l++)hv(p[l],u)}var dl=K(null),Od=K(0);function gv(l,u){l=Mr,q(Od,l),q(dl,u),Mr=l|u.baseLanes}function Jh(){q(Od,Mr),q(dl,dl.current)}function Zh(){Mr=Od.current,ne(dl),ne(Od)}var ea=K(null),wa=null;function ci(l){var u=l.alternate;q(Xn,Xn.current&1),q(ea,l),wa===null&&(u===null||dl.current!==null||u.memoizedState!==null)&&(wa=l)}function em(l){q(Xn,Xn.current),q(ea,l),wa===null&&(wa=l)}function bv(l){l.tag===22?(q(Xn,Xn.current),q(ea,l),wa===null&&(wa=l)):ui()}function ui(){q(Xn,Xn.current),q(ea,ea.current)}function ta(l){ne(ea),wa===l&&(wa=null),ne(Xn)}var Xn=K(0);function Ld(l){for(var u=l;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||ig(p)||og(p)))return u}else if(u.tag===19&&(u.memoizedProps.revealOrder==="forwards"||u.memoizedProps.revealOrder==="backwards"||u.memoizedProps.revealOrder==="unstable_legacy-backwards"||u.memoizedProps.revealOrder==="together")){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var Sr=0,Ut=null,Sn=null,ss=null,Id=!1,fl=!1,oo=!1,Pd=0,_c=0,pl=null,b_=0;function Vn(){throw Error(s(321))}function tm(l,u){if(u===null)return!1;for(var p=0;p<u.length&&p<l.length;p++)if(!Js(l[p],u[p]))return!1;return!0}function nm(l,u,p,g,v,A){return Sr=A,Ut=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,F.H=l===null||l.memoizedState===null?ew:bm,oo=!1,A=p(g,v),oo=!1,fl&&(A=yv(u,p,g,v)),xv(l),A}function xv(l){F.H=Dc;var u=Sn!==null&&Sn.next!==null;if(Sr=0,ss=Sn=Ut=null,Id=!1,_c=0,pl=null,u)throw Error(s(300));l===null||as||(l=l.dependencies,l!==null&&Nd(l)&&(as=!0))}function yv(l,u,p,g){Ut=l;var v=0;do{if(fl&&(pl=null),_c=0,fl=!1,25<=v)throw Error(s(301));if(v+=1,ss=Sn=null,l.updateQueue!=null){var A=l.updateQueue;A.lastEffect=null,A.events=null,A.stores=null,A.memoCache!=null&&(A.memoCache.index=0)}F.H=tw,A=u(p,g)}while(fl);return A}function x_(){var l=F.H,u=l.useState()[0];return u=typeof u.then=="function"?Ec(u):u,l=l.useState()[0],(Sn!==null?Sn.memoizedState:null)!==l&&(Ut.flags|=1024),u}function sm(){var l=Pd!==0;return Pd=0,l}function am(l,u,p){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~p}function rm(l){if(Id){for(l=l.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}Id=!1}Sr=0,ss=Sn=Ut=null,fl=!1,_c=Pd=0,pl=null}function _s(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ss===null?Ut.memoizedState=ss=l:ss=ss.next=l,ss}function Jn(){if(Sn===null){var l=Ut.alternate;l=l!==null?l.memoizedState:null}else l=Sn.next;var u=ss===null?Ut.memoizedState:ss.next;if(u!==null)ss=u,Sn=l;else{if(l===null)throw Ut.alternate===null?Error(s(467)):Error(s(310));Sn=l,l={memoizedState:Sn.memoizedState,baseState:Sn.baseState,baseQueue:Sn.baseQueue,queue:Sn.queue,next:null},ss===null?Ut.memoizedState=ss=l:ss=ss.next=l}return ss}function Bd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ec(l){var u=_c;return _c+=1,pl===null&&(pl=[]),l=cv(pl,l,u),u=Ut,(ss===null?u.memoizedState:ss.next)===null&&(u=u.alternate,F.H=u===null||u.memoizedState===null?ew:bm),l}function Fd(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return Ec(l);if(l.$$typeof===S)return bs(l)}throw Error(s(438,String(l)))}function im(l){var u=null,p=Ut.updateQueue;if(p!==null&&(u=p.memoCache),u==null){var g=Ut.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(u={data:g.data.map(function(v){return v.slice()}),index:0})))}if(u==null&&(u={data:[],index:0}),p===null&&(p=Bd(),Ut.updateQueue=p),p.memoCache=u,p=u.data[u.index],p===void 0)for(p=u.data[u.index]=Array(l),g=0;g<l;g++)p[g]=M;return u.index++,p}function Cr(l,u){return typeof u=="function"?u(l):u}function zd(l){var u=Jn();return om(u,Sn,l)}function om(l,u,p){var g=l.queue;if(g===null)throw Error(s(311));g.lastRenderedReducer=p;var v=l.baseQueue,A=g.pending;if(A!==null){if(v!==null){var P=v.next;v.next=A.next,A.next=P}u.baseQueue=v=A,g.pending=null}if(A=l.baseState,v===null)l.memoizedState=A;else{u=v.next;var Y=P=null,ae=null,Me=u,Ve=!1;do{var Qe=Me.lane&-536870913;if(Qe!==Me.lane?(an&Qe)===Qe:(Sr&Qe)===Qe){var Le=Me.revertLane;if(Le===0)ae!==null&&(ae=ae.next={lane:0,revertLane:0,gesture:null,action:Me.action,hasEagerState:Me.hasEagerState,eagerState:Me.eagerState,next:null}),Qe===ol&&(Ve=!0);else if((Sr&Le)===Le){Me=Me.next,Le===ol&&(Ve=!0);continue}else Qe={lane:0,revertLane:Me.revertLane,gesture:null,action:Me.action,hasEagerState:Me.hasEagerState,eagerState:Me.eagerState,next:null},ae===null?(Y=ae=Qe,P=A):ae=ae.next=Qe,Ut.lanes|=Le,pi|=Le;Qe=Me.action,oo&&p(A,Qe),A=Me.hasEagerState?Me.eagerState:p(A,Qe)}else Le={lane:Qe,revertLane:Me.revertLane,gesture:Me.gesture,action:Me.action,hasEagerState:Me.hasEagerState,eagerState:Me.eagerState,next:null},ae===null?(Y=ae=Le,P=A):ae=ae.next=Le,Ut.lanes|=Qe,pi|=Qe;Me=Me.next}while(Me!==null&&Me!==u);if(ae===null?P=A:ae.next=Y,!Js(A,l.memoizedState)&&(as=!0,Ve&&(p=ll,p!==null)))throw p;l.memoizedState=A,l.baseState=P,l.baseQueue=ae,g.lastRenderedState=A}return v===null&&(g.lanes=0),[l.memoizedState,g.dispatch]}function lm(l){var u=Jn(),p=u.queue;if(p===null)throw Error(s(311));p.lastRenderedReducer=l;var g=p.dispatch,v=p.pending,A=u.memoizedState;if(v!==null){p.pending=null;var P=v=v.next;do A=l(A,P.action),P=P.next;while(P!==v);Js(A,u.memoizedState)||(as=!0),u.memoizedState=A,u.baseQueue===null&&(u.baseState=A),p.lastRenderedState=A}return[A,g]}function vv(l,u,p){var g=Ut,v=Jn(),A=cn;if(A){if(p===void 0)throw Error(s(407));p=p()}else p=u();var P=!Js((Sn||v).memoizedState,p);if(P&&(v.memoizedState=p,as=!0),v=v.queue,dm(Sv.bind(null,g,v,l),[l]),v.getSnapshot!==u||P||ss!==null&&ss.memoizedState.tag&1){if(g.flags|=2048,hl(9,{destroy:void 0},kv.bind(null,g,v,p,u),null),Nn===null)throw Error(s(349));A||(Sr&127)!==0||wv(g,u,p)}return p}function wv(l,u,p){l.flags|=16384,l={getSnapshot:u,value:p},u=Ut.updateQueue,u===null?(u=Bd(),Ut.updateQueue=u,u.stores=[l]):(p=u.stores,p===null?u.stores=[l]:p.push(l))}function kv(l,u,p,g){u.value=p,u.getSnapshot=g,Cv(u)&&Av(l)}function Sv(l,u,p){return p(function(){Cv(u)&&Av(l)})}function Cv(l){var u=l.getSnapshot;l=l.value;try{var p=u();return!Js(l,p)}catch{return!0}}function Av(l){var u=Ji(l,2);u!==null&&qs(u,l,2)}function cm(l){var u=_s();if(typeof l=="function"){var p=l;if(l=p(),oo){te(!0);try{p()}finally{te(!1)}}}return u.memoizedState=u.baseState=l,u.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cr,lastRenderedState:l},u}function jv(l,u,p,g){return l.baseState=p,om(l,Sn,typeof g=="function"?g:Cr)}function y_(l,u,p,g,v){if(Hd(l))throw Error(s(485));if(l=u.action,l!==null){var A={payload:v,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(P){A.listeners.push(P)}};F.T!==null?p(!0):A.isTransition=!1,g(A),p=u.pending,p===null?(A.next=u.pending=A,Nv(u,A)):(A.next=p.next,u.pending=p.next=A)}}function Nv(l,u){var p=u.action,g=u.payload,v=l.state;if(u.isTransition){var A=F.T,P={};F.T=P;try{var Y=p(v,g),ae=F.S;ae!==null&&ae(P,Y),Tv(l,u,Y)}catch(Me){um(l,u,Me)}finally{A!==null&&P.types!==null&&(A.types=P.types),F.T=A}}else try{A=p(v,g),Tv(l,u,A)}catch(Me){um(l,u,Me)}}function Tv(l,u,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(g){_v(l,u,g)},function(g){return um(l,u,g)}):_v(l,u,p)}function _v(l,u,p){u.status="fulfilled",u.value=p,Ev(u),l.state=p,u=l.pending,u!==null&&(p=u.next,p===u?l.pending=null:(p=p.next,u.next=p,Nv(l,p)))}function um(l,u,p){var g=l.pending;if(l.pending=null,g!==null){g=g.next;do u.status="rejected",u.reason=p,Ev(u),u=u.next;while(u!==g)}l.action=null}function Ev(l){l=l.listeners;for(var u=0;u<l.length;u++)(0,l[u])()}function Mv(l,u){return u}function Dv(l,u){if(cn){var p=Nn.formState;if(p!==null){e:{var g=Ut;if(cn){if(In){t:{for(var v=In,A=va;v.nodeType!==8;){if(!A){v=null;break t}if(v=ka(v.nextSibling),v===null){v=null;break t}}A=v.data,v=A==="F!"||A==="F"?v:null}if(v){In=ka(v.nextSibling),g=v.data==="F!";break e}}ai(g)}g=!1}g&&(u=p[0])}}return p=_s(),p.memoizedState=p.baseState=u,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mv,lastRenderedState:u},p.queue=g,p=Xv.bind(null,Ut,g),g.dispatch=p,g=cm(!1),A=gm.bind(null,Ut,!1,g.queue),g=_s(),v={state:u,dispatch:null,action:l,pending:null},g.queue=v,p=y_.bind(null,Ut,v,A,p),v.dispatch=p,g.memoizedState=l,[u,p,!1]}function Rv(l){var u=Jn();return Ov(u,Sn,l)}function Ov(l,u,p){if(u=om(l,u,Mv)[0],l=zd(Cr)[0],typeof u=="object"&&u!==null&&typeof u.then=="function")try{var g=Ec(u)}catch(P){throw P===cl?Ed:P}else g=u;u=Jn();var v=u.queue,A=v.dispatch;return p!==u.memoizedState&&(Ut.flags|=2048,hl(9,{destroy:void 0},v_.bind(null,v,p),null)),[g,A,l]}function v_(l,u){l.action=u}function Lv(l){var u=Jn(),p=Sn;if(p!==null)return Ov(u,p,l);Jn(),u=u.memoizedState,p=Jn();var g=p.queue.dispatch;return p.memoizedState=l,[u,g,!1]}function hl(l,u,p,g){return l={tag:l,create:p,deps:g,inst:u,next:null},u=Ut.updateQueue,u===null&&(u=Bd(),Ut.updateQueue=u),p=u.lastEffect,p===null?u.lastEffect=l.next=l:(g=p.next,p.next=l,l.next=g,u.lastEffect=l),l}function Iv(){return Jn().memoizedState}function $d(l,u,p,g){var v=_s();Ut.flags|=l,v.memoizedState=hl(1|u,{destroy:void 0},p,g===void 0?null:g)}function Ud(l,u,p,g){var v=Jn();g=g===void 0?null:g;var A=v.memoizedState.inst;Sn!==null&&g!==null&&tm(g,Sn.memoizedState.deps)?v.memoizedState=hl(u,A,p,g):(Ut.flags|=l,v.memoizedState=hl(1|u,A,p,g))}function Pv(l,u){$d(8390656,8,l,u)}function dm(l,u){Ud(2048,8,l,u)}function w_(l){Ut.flags|=4;var u=Ut.updateQueue;if(u===null)u=Bd(),Ut.updateQueue=u,u.events=[l];else{var p=u.events;p===null?u.events=[l]:p.push(l)}}function Bv(l){var u=Jn().memoizedState;return w_({ref:u,nextImpl:l}),function(){if((hn&2)!==0)throw Error(s(440));return u.impl.apply(void 0,arguments)}}function Fv(l,u){return Ud(4,2,l,u)}function zv(l,u){return Ud(4,4,l,u)}function $v(l,u){if(typeof u=="function"){l=l();var p=u(l);return function(){typeof p=="function"?p():u(null)}}if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function Uv(l,u,p){p=p!=null?p.concat([l]):null,Ud(4,4,$v.bind(null,u,l),p)}function fm(){}function Hv(l,u){var p=Jn();u=u===void 0?null:u;var g=p.memoizedState;return u!==null&&tm(u,g[1])?g[0]:(p.memoizedState=[l,u],l)}function Wv(l,u){var p=Jn();u=u===void 0?null:u;var g=p.memoizedState;if(u!==null&&tm(u,g[1]))return g[0];if(g=l(),oo){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[g,u],g}function pm(l,u,p){return p===void 0||(Sr&1073741824)!==0&&(an&261930)===0?l.memoizedState=u:(l.memoizedState=p,l=qw(),Ut.lanes|=l,pi|=l,p)}function qv(l,u,p,g){return Js(p,u)?p:dl.current!==null?(l=pm(l,p,g),Js(l,u)||(as=!0),l):(Sr&42)===0||(Sr&1073741824)!==0&&(an&261930)===0?(as=!0,l.memoizedState=p):(l=qw(),Ut.lanes|=l,pi|=l,u)}function Vv(l,u,p,g,v){var A=H.p;H.p=A!==0&&8>A?A:8;var P=F.T,Y={};F.T=Y,gm(l,!1,u,p);try{var ae=v(),Me=F.S;if(Me!==null&&Me(Y,ae),ae!==null&&typeof ae=="object"&&typeof ae.then=="function"){var Ve=g_(ae,g);Mc(l,u,Ve,aa(l))}else Mc(l,u,g,aa(l))}catch(Qe){Mc(l,u,{then:function(){},status:"rejected",reason:Qe},aa())}finally{H.p=A,P!==null&&Y.types!==null&&(P.types=Y.types),F.T=P}}function k_(){}function hm(l,u,p,g){if(l.tag!==5)throw Error(s(476));var v=Yv(l).queue;Vv(l,v,u,V,p===null?k_:function(){return Gv(l),p(g)})}function Yv(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cr,lastRenderedState:V},next:null};var p={};return u.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cr,lastRenderedState:p},next:null},l.memoizedState=u,l=l.alternate,l!==null&&(l.memoizedState=u),u}function Gv(l){var u=Yv(l);u.next===null&&(u=l.alternate.memoizedState),Mc(l,u.next.queue,{},aa())}function mm(){return bs(Gc)}function Kv(){return Jn().memoizedState}function Qv(){return Jn().memoizedState}function S_(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var p=aa();l=oi(p);var g=li(u,l,p);g!==null&&(qs(g,u,p),jc(g,u,p)),u={cache:Wh()},l.payload=u;return}u=u.return}}function C_(l,u,p){var g=aa();p={lane:g,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},Hd(l)?Jv(u,p):(p=Rh(l,u,p,g),p!==null&&(qs(p,l,g),Zv(p,u,g)))}function Xv(l,u,p){var g=aa();Mc(l,u,p,g)}function Mc(l,u,p,g){var v={lane:g,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(Hd(l))Jv(u,v);else{var A=l.alternate;if(l.lanes===0&&(A===null||A.lanes===0)&&(A=u.lastRenderedReducer,A!==null))try{var P=u.lastRenderedState,Y=A(P,p);if(v.hasEagerState=!0,v.eagerState=Y,Js(Y,P))return Sd(l,u,v,0),Nn===null&&kd(),!1}catch{}finally{}if(p=Rh(l,u,v,g),p!==null)return qs(p,l,g),Zv(p,u,g),!0}return!1}function gm(l,u,p,g){if(g={lane:2,revertLane:Gm(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},Hd(l)){if(u)throw Error(s(479))}else u=Rh(l,p,g,2),u!==null&&qs(u,l,2)}function Hd(l){var u=l.alternate;return l===Ut||u!==null&&u===Ut}function Jv(l,u){fl=Id=!0;var p=l.pending;p===null?u.next=u:(u.next=p.next,p.next=u),l.pending=u}function Zv(l,u,p){if((p&4194048)!==0){var g=u.lanes;g&=l.pendingLanes,p|=g,u.lanes=p,Ot(l,p)}}var Dc={readContext:bs,use:Fd,useCallback:Vn,useContext:Vn,useEffect:Vn,useImperativeHandle:Vn,useLayoutEffect:Vn,useInsertionEffect:Vn,useMemo:Vn,useReducer:Vn,useRef:Vn,useState:Vn,useDebugValue:Vn,useDeferredValue:Vn,useTransition:Vn,useSyncExternalStore:Vn,useId:Vn,useHostTransitionStatus:Vn,useFormState:Vn,useActionState:Vn,useOptimistic:Vn,useMemoCache:Vn,useCacheRefresh:Vn};Dc.useEffectEvent=Vn;var ew={readContext:bs,use:Fd,useCallback:function(l,u){return _s().memoizedState=[l,u===void 0?null:u],l},useContext:bs,useEffect:Pv,useImperativeHandle:function(l,u,p){p=p!=null?p.concat([l]):null,$d(4194308,4,$v.bind(null,u,l),p)},useLayoutEffect:function(l,u){return $d(4194308,4,l,u)},useInsertionEffect:function(l,u){$d(4,2,l,u)},useMemo:function(l,u){var p=_s();u=u===void 0?null:u;var g=l();if(oo){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[g,u],g},useReducer:function(l,u,p){var g=_s();if(p!==void 0){var v=p(u);if(oo){te(!0);try{p(u)}finally{te(!1)}}}else v=u;return g.memoizedState=g.baseState=v,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:v},g.queue=l,l=l.dispatch=C_.bind(null,Ut,l),[g.memoizedState,l]},useRef:function(l){var u=_s();return l={current:l},u.memoizedState=l},useState:function(l){l=cm(l);var u=l.queue,p=Xv.bind(null,Ut,u);return u.dispatch=p,[l.memoizedState,p]},useDebugValue:fm,useDeferredValue:function(l,u){var p=_s();return pm(p,l,u)},useTransition:function(){var l=cm(!1);return l=Vv.bind(null,Ut,l.queue,!0,!1),_s().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,p){var g=Ut,v=_s();if(cn){if(p===void 0)throw Error(s(407));p=p()}else{if(p=u(),Nn===null)throw Error(s(349));(an&127)!==0||wv(g,u,p)}v.memoizedState=p;var A={value:p,getSnapshot:u};return v.queue=A,Pv(Sv.bind(null,g,A,l),[l]),g.flags|=2048,hl(9,{destroy:void 0},kv.bind(null,g,A,p,u),null),p},useId:function(){var l=_s(),u=Nn.identifierPrefix;if(cn){var p=Ga,g=Ya;p=(g&~(1<<32-be(g)-1)).toString(32)+p,u="_"+u+"R_"+p,p=Pd++,0<p&&(u+="H"+p.toString(32)),u+="_"}else p=b_++,u="_"+u+"r_"+p.toString(32)+"_";return l.memoizedState=u},useHostTransitionStatus:mm,useFormState:Dv,useActionState:Dv,useOptimistic:function(l){var u=_s();u.memoizedState=u.baseState=l;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return u.queue=p,u=gm.bind(null,Ut,!0,p),p.dispatch=u,[l,u]},useMemoCache:im,useCacheRefresh:function(){return _s().memoizedState=S_.bind(null,Ut)},useEffectEvent:function(l){var u=_s(),p={impl:l};return u.memoizedState=p,function(){if((hn&2)!==0)throw Error(s(440));return p.impl.apply(void 0,arguments)}}},bm={readContext:bs,use:Fd,useCallback:Hv,useContext:bs,useEffect:dm,useImperativeHandle:Uv,useInsertionEffect:Fv,useLayoutEffect:zv,useMemo:Wv,useReducer:zd,useRef:Iv,useState:function(){return zd(Cr)},useDebugValue:fm,useDeferredValue:function(l,u){var p=Jn();return qv(p,Sn.memoizedState,l,u)},useTransition:function(){var l=zd(Cr)[0],u=Jn().memoizedState;return[typeof l=="boolean"?l:Ec(l),u]},useSyncExternalStore:vv,useId:Kv,useHostTransitionStatus:mm,useFormState:Rv,useActionState:Rv,useOptimistic:function(l,u){var p=Jn();return jv(p,Sn,l,u)},useMemoCache:im,useCacheRefresh:Qv};bm.useEffectEvent=Bv;var tw={readContext:bs,use:Fd,useCallback:Hv,useContext:bs,useEffect:dm,useImperativeHandle:Uv,useInsertionEffect:Fv,useLayoutEffect:zv,useMemo:Wv,useReducer:lm,useRef:Iv,useState:function(){return lm(Cr)},useDebugValue:fm,useDeferredValue:function(l,u){var p=Jn();return Sn===null?pm(p,l,u):qv(p,Sn.memoizedState,l,u)},useTransition:function(){var l=lm(Cr)[0],u=Jn().memoizedState;return[typeof l=="boolean"?l:Ec(l),u]},useSyncExternalStore:vv,useId:Kv,useHostTransitionStatus:mm,useFormState:Lv,useActionState:Lv,useOptimistic:function(l,u){var p=Jn();return Sn!==null?jv(p,Sn,l,u):(p.baseState=l,[l,p.queue.dispatch])},useMemoCache:im,useCacheRefresh:Qv};tw.useEffectEvent=Bv;function xm(l,u,p,g){u=l.memoizedState,p=p(g,u),p=p==null?u:m({},u,p),l.memoizedState=p,l.lanes===0&&(l.updateQueue.baseState=p)}var ym={enqueueSetState:function(l,u,p){l=l._reactInternals;var g=aa(),v=oi(g);v.payload=u,p!=null&&(v.callback=p),u=li(l,v,g),u!==null&&(qs(u,l,g),jc(u,l,g))},enqueueReplaceState:function(l,u,p){l=l._reactInternals;var g=aa(),v=oi(g);v.tag=1,v.payload=u,p!=null&&(v.callback=p),u=li(l,v,g),u!==null&&(qs(u,l,g),jc(u,l,g))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var p=aa(),g=oi(p);g.tag=2,u!=null&&(g.callback=u),u=li(l,g,p),u!==null&&(qs(u,l,p),jc(u,l,p))}};function nw(l,u,p,g,v,A,P){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(g,A,P):u.prototype&&u.prototype.isPureReactComponent?!xc(p,g)||!xc(v,A):!0}function sw(l,u,p,g){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(p,g),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(p,g),u.state!==l&&ym.enqueueReplaceState(u,u.state,null)}function lo(l,u){var p=u;if("ref"in u){p={};for(var g in u)g!=="ref"&&(p[g]=u[g])}if(l=l.defaultProps){p===u&&(p=m({},p));for(var v in l)p[v]===void 0&&(p[v]=l[v])}return p}function aw(l){wd(l)}function rw(l){console.error(l)}function iw(l){wd(l)}function Wd(l,u){try{var p=l.onUncaughtError;p(u.value,{componentStack:u.stack})}catch(g){setTimeout(function(){throw g})}}function ow(l,u,p){try{var g=l.onCaughtError;g(p.value,{componentStack:p.stack,errorBoundary:u.tag===1?u.stateNode:null})}catch(v){setTimeout(function(){throw v})}}function vm(l,u,p){return p=oi(p),p.tag=3,p.payload={element:null},p.callback=function(){Wd(l,u)},p}function lw(l){return l=oi(l),l.tag=3,l}function cw(l,u,p,g){var v=p.type.getDerivedStateFromError;if(typeof v=="function"){var A=g.value;l.payload=function(){return v(A)},l.callback=function(){ow(u,p,g)}}var P=p.stateNode;P!==null&&typeof P.componentDidCatch=="function"&&(l.callback=function(){ow(u,p,g),typeof v!="function"&&(hi===null?hi=new Set([this]):hi.add(this));var Y=g.stack;this.componentDidCatch(g.value,{componentStack:Y!==null?Y:""})})}function A_(l,u,p,g,v){if(p.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(u=p.alternate,u!==null&&il(u,p,v,!0),p=ea.current,p!==null){switch(p.tag){case 31:case 13:return wa===null?nf():p.alternate===null&&Yn===0&&(Yn=3),p.flags&=-257,p.flags|=65536,p.lanes=v,g===Md?p.flags|=16384:(u=p.updateQueue,u===null?p.updateQueue=new Set([g]):u.add(g),qm(l,g,v)),!1;case 22:return p.flags|=65536,g===Md?p.flags|=16384:(u=p.updateQueue,u===null?(u={transitions:null,markerInstances:null,retryQueue:new Set([g])},p.updateQueue=u):(p=u.retryQueue,p===null?u.retryQueue=new Set([g]):p.add(g)),qm(l,g,v)),!1}throw Error(s(435,p.tag))}return qm(l,g,v),nf(),!1}if(cn)return u=ea.current,u!==null?((u.flags&65536)===0&&(u.flags|=256),u.flags|=65536,u.lanes=v,g!==Fh&&(l=Error(s(422),{cause:g}),wc(ba(l,p)))):(g!==Fh&&(u=Error(s(423),{cause:g}),wc(ba(u,p))),l=l.current.alternate,l.flags|=65536,v&=-v,l.lanes|=v,g=ba(g,p),v=vm(l.stateNode,g,v),Qh(l,v),Yn!==4&&(Yn=2)),!1;var A=Error(s(520),{cause:g});if(A=ba(A,p),zc===null?zc=[A]:zc.push(A),Yn!==4&&(Yn=2),u===null)return!0;g=ba(g,p),p=u;do{switch(p.tag){case 3:return p.flags|=65536,l=v&-v,p.lanes|=l,l=vm(p.stateNode,g,l),Qh(p,l),!1;case 1:if(u=p.type,A=p.stateNode,(p.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(hi===null||!hi.has(A))))return p.flags|=65536,v&=-v,p.lanes|=v,v=lw(v),cw(v,l,p,g),Qh(p,v),!1}p=p.return}while(p!==null);return!1}var wm=Error(s(461)),as=!1;function xs(l,u,p,g){u.child=l===null?pv(u,null,p,g):io(u,l.child,p,g)}function uw(l,u,p,g,v){p=p.render;var A=u.ref;if("ref"in g){var P={};for(var Y in g)Y!=="ref"&&(P[Y]=g[Y])}else P=g;return no(u),g=nm(l,u,p,P,A,v),Y=sm(),l!==null&&!as?(am(l,u,v),Ar(l,u,v)):(cn&&Y&&Ph(u),u.flags|=1,xs(l,u,g,v),u.child)}function dw(l,u,p,g,v){if(l===null){var A=p.type;return typeof A=="function"&&!Oh(A)&&A.defaultProps===void 0&&p.compare===null?(u.tag=15,u.type=A,fw(l,u,A,g,v)):(l=Ad(p.type,null,g,u,u.mode,v),l.ref=u.ref,l.return=u,u.child=l)}if(A=l.child,!_m(l,v)){var P=A.memoizedProps;if(p=p.compare,p=p!==null?p:xc,p(P,g)&&l.ref===u.ref)return Ar(l,u,v)}return u.flags|=1,l=yr(A,g),l.ref=u.ref,l.return=u,u.child=l}function fw(l,u,p,g,v){if(l!==null){var A=l.memoizedProps;if(xc(A,g)&&l.ref===u.ref)if(as=!1,u.pendingProps=g=A,_m(l,v))(l.flags&131072)!==0&&(as=!0);else return u.lanes=l.lanes,Ar(l,u,v)}return km(l,u,p,g,v)}function pw(l,u,p,g){var v=g.children,A=l!==null?l.memoizedState:null;if(l===null&&u.stateNode===null&&(u.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((u.flags&128)!==0){if(A=A!==null?A.baseLanes|p:p,l!==null){for(g=u.child=l.child,v=0;g!==null;)v=v|g.lanes|g.childLanes,g=g.sibling;g=v&~A}else g=0,u.child=null;return hw(l,u,A,p,g)}if((p&536870912)!==0)u.memoizedState={baseLanes:0,cachePool:null},l!==null&&_d(u,A!==null?A.cachePool:null),A!==null?gv(u,A):Jh(),bv(u);else return g=u.lanes=536870912,hw(l,u,A!==null?A.baseLanes|p:p,p,g)}else A!==null?(_d(u,A.cachePool),gv(u,A),ui(),u.memoizedState=null):(l!==null&&_d(u,null),Jh(),ui());return xs(l,u,v,p),u.child}function Rc(l,u){return l!==null&&l.tag===22||u.stateNode!==null||(u.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.sibling}function hw(l,u,p,g,v){var A=Vh();return A=A===null?null:{parent:ns._currentValue,pool:A},u.memoizedState={baseLanes:p,cachePool:A},l!==null&&_d(u,null),Jh(),bv(u),l!==null&&il(l,u,g,!0),u.childLanes=v,null}function qd(l,u){return u=Yd({mode:u.mode,children:u.children},l.mode),u.ref=l.ref,l.child=u,u.return=l,u}function mw(l,u,p){return io(u,l.child,null,p),l=qd(u,u.pendingProps),l.flags|=2,ta(u),u.memoizedState=null,l}function j_(l,u,p){var g=u.pendingProps,v=(u.flags&128)!==0;if(u.flags&=-129,l===null){if(cn){if(g.mode==="hidden")return l=qd(u,g),u.lanes=536870912,Rc(null,l);if(em(u),(l=In)?(l=N0(l,va),l=l!==null&&l.data==="&"?l:null,l!==null&&(u.memoizedState={dehydrated:l,treeContext:ni!==null?{id:Ya,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},p=Jy(l),p.return=u,u.child=p,gs=u,In=null)):l=null,l===null)throw ai(u);return u.lanes=536870912,null}return qd(u,g)}var A=l.memoizedState;if(A!==null){var P=A.dehydrated;if(em(u),v)if(u.flags&256)u.flags&=-257,u=mw(l,u,p);else if(u.memoizedState!==null)u.child=l.child,u.flags|=128,u=null;else throw Error(s(558));else if(as||il(l,u,p,!1),v=(p&l.childLanes)!==0,as||v){if(g=Nn,g!==null&&(P=Ft(g,p),P!==0&&P!==A.retryLane))throw A.retryLane=P,Ji(l,P),qs(g,l,P),wm;nf(),u=mw(l,u,p)}else l=A.treeContext,In=ka(P.nextSibling),gs=u,cn=!0,si=null,va=!1,l!==null&&tv(u,l),u=qd(u,g),u.flags|=4096;return u}return l=yr(l.child,{mode:g.mode,children:g.children}),l.ref=u.ref,u.child=l,l.return=u,l}function Vd(l,u){var p=u.ref;if(p===null)l!==null&&l.ref!==null&&(u.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(s(284));(l===null||l.ref!==p)&&(u.flags|=4194816)}}function km(l,u,p,g,v){return no(u),p=nm(l,u,p,g,void 0,v),g=sm(),l!==null&&!as?(am(l,u,v),Ar(l,u,v)):(cn&&g&&Ph(u),u.flags|=1,xs(l,u,p,v),u.child)}function gw(l,u,p,g,v,A){return no(u),u.updateQueue=null,p=yv(u,g,p,v),xv(l),g=sm(),l!==null&&!as?(am(l,u,A),Ar(l,u,A)):(cn&&g&&Ph(u),u.flags|=1,xs(l,u,p,A),u.child)}function bw(l,u,p,g,v){if(no(u),u.stateNode===null){var A=nl,P=p.contextType;typeof P=="object"&&P!==null&&(A=bs(P)),A=new p(g,A),u.memoizedState=A.state!==null&&A.state!==void 0?A.state:null,A.updater=ym,u.stateNode=A,A._reactInternals=u,A=u.stateNode,A.props=g,A.state=u.memoizedState,A.refs={},Gh(u),P=p.contextType,A.context=typeof P=="object"&&P!==null?bs(P):nl,A.state=u.memoizedState,P=p.getDerivedStateFromProps,typeof P=="function"&&(xm(u,p,P,g),A.state=u.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof A.getSnapshotBeforeUpdate=="function"||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(P=A.state,typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount(),P!==A.state&&ym.enqueueReplaceState(A,A.state,null),Tc(u,g,A,v),Nc(),A.state=u.memoizedState),typeof A.componentDidMount=="function"&&(u.flags|=4194308),g=!0}else if(l===null){A=u.stateNode;var Y=u.memoizedProps,ae=lo(p,Y);A.props=ae;var Me=A.context,Ve=p.contextType;P=nl,typeof Ve=="object"&&Ve!==null&&(P=bs(Ve));var Qe=p.getDerivedStateFromProps;Ve=typeof Qe=="function"||typeof A.getSnapshotBeforeUpdate=="function",Y=u.pendingProps!==Y,Ve||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(Y||Me!==P)&&sw(u,A,g,P),ii=!1;var Le=u.memoizedState;A.state=Le,Tc(u,g,A,v),Nc(),Me=u.memoizedState,Y||Le!==Me||ii?(typeof Qe=="function"&&(xm(u,p,Qe,g),Me=u.memoizedState),(ae=ii||nw(u,p,ae,g,Le,Me,P))?(Ve||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(u.flags|=4194308)):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=g,u.memoizedState=Me),A.props=g,A.state=Me,A.context=P,g=ae):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),g=!1)}else{A=u.stateNode,Kh(l,u),P=u.memoizedProps,Ve=lo(p,P),A.props=Ve,Qe=u.pendingProps,Le=A.context,Me=p.contextType,ae=nl,typeof Me=="object"&&Me!==null&&(ae=bs(Me)),Y=p.getDerivedStateFromProps,(Me=typeof Y=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(P!==Qe||Le!==ae)&&sw(u,A,g,ae),ii=!1,Le=u.memoizedState,A.state=Le,Tc(u,g,A,v),Nc();var Ue=u.memoizedState;P!==Qe||Le!==Ue||ii||l!==null&&l.dependencies!==null&&Nd(l.dependencies)?(typeof Y=="function"&&(xm(u,p,Y,g),Ue=u.memoizedState),(Ve=ii||nw(u,p,Ve,g,Le,Ue,ae)||l!==null&&l.dependencies!==null&&Nd(l.dependencies))?(Me||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(g,Ue,ae),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(g,Ue,ae)),typeof A.componentDidUpdate=="function"&&(u.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof A.componentDidUpdate!="function"||P===l.memoizedProps&&Le===l.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||P===l.memoizedProps&&Le===l.memoizedState||(u.flags|=1024),u.memoizedProps=g,u.memoizedState=Ue),A.props=g,A.state=Ue,A.context=ae,g=Ve):(typeof A.componentDidUpdate!="function"||P===l.memoizedProps&&Le===l.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||P===l.memoizedProps&&Le===l.memoizedState||(u.flags|=1024),g=!1)}return A=g,Vd(l,u),g=(u.flags&128)!==0,A||g?(A=u.stateNode,p=g&&typeof p.getDerivedStateFromError!="function"?null:A.render(),u.flags|=1,l!==null&&g?(u.child=io(u,l.child,null,v),u.child=io(u,null,p,v)):xs(l,u,p,v),u.memoizedState=A.state,l=u.child):l=Ar(l,u,v),l}function xw(l,u,p,g){return eo(),u.flags|=256,xs(l,u,p,g),u.child}var Sm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Cm(l){return{baseLanes:l,cachePool:ov()}}function Am(l,u,p){return l=l!==null?l.childLanes&~p:0,u&&(l|=sa),l}function yw(l,u,p){var g=u.pendingProps,v=!1,A=(u.flags&128)!==0,P;if((P=A)||(P=l!==null&&l.memoizedState===null?!1:(Xn.current&2)!==0),P&&(v=!0,u.flags&=-129),P=(u.flags&32)!==0,u.flags&=-33,l===null){if(cn){if(v?ci(u):ui(),(l=In)?(l=N0(l,va),l=l!==null&&l.data!=="&"?l:null,l!==null&&(u.memoizedState={dehydrated:l,treeContext:ni!==null?{id:Ya,overflow:Ga}:null,retryLane:536870912,hydrationErrors:null},p=Jy(l),p.return=u,u.child=p,gs=u,In=null)):l=null,l===null)throw ai(u);return og(l)?u.lanes=32:u.lanes=536870912,null}var Y=g.children;return g=g.fallback,v?(ui(),v=u.mode,Y=Yd({mode:"hidden",children:Y},v),g=Zi(g,v,p,null),Y.return=u,g.return=u,Y.sibling=g,u.child=Y,g=u.child,g.memoizedState=Cm(p),g.childLanes=Am(l,P,p),u.memoizedState=Sm,Rc(null,g)):(ci(u),jm(u,Y))}var ae=l.memoizedState;if(ae!==null&&(Y=ae.dehydrated,Y!==null)){if(A)u.flags&256?(ci(u),u.flags&=-257,u=Nm(l,u,p)):u.memoizedState!==null?(ui(),u.child=l.child,u.flags|=128,u=null):(ui(),Y=g.fallback,v=u.mode,g=Yd({mode:"visible",children:g.children},v),Y=Zi(Y,v,p,null),Y.flags|=2,g.return=u,Y.return=u,g.sibling=Y,u.child=g,io(u,l.child,null,p),g=u.child,g.memoizedState=Cm(p),g.childLanes=Am(l,P,p),u.memoizedState=Sm,u=Rc(null,g));else if(ci(u),og(Y)){if(P=Y.nextSibling&&Y.nextSibling.dataset,P)var Me=P.dgst;P=Me,g=Error(s(419)),g.stack="",g.digest=P,wc({value:g,source:null,stack:null}),u=Nm(l,u,p)}else if(as||il(l,u,p,!1),P=(p&l.childLanes)!==0,as||P){if(P=Nn,P!==null&&(g=Ft(P,p),g!==0&&g!==ae.retryLane))throw ae.retryLane=g,Ji(l,g),qs(P,l,g),wm;ig(Y)||nf(),u=Nm(l,u,p)}else ig(Y)?(u.flags|=192,u.child=l.child,u=null):(l=ae.treeContext,In=ka(Y.nextSibling),gs=u,cn=!0,si=null,va=!1,l!==null&&tv(u,l),u=jm(u,g.children),u.flags|=4096);return u}return v?(ui(),Y=g.fallback,v=u.mode,ae=l.child,Me=ae.sibling,g=yr(ae,{mode:"hidden",children:g.children}),g.subtreeFlags=ae.subtreeFlags&65011712,Me!==null?Y=yr(Me,Y):(Y=Zi(Y,v,p,null),Y.flags|=2),Y.return=u,g.return=u,g.sibling=Y,u.child=g,Rc(null,g),g=u.child,Y=l.child.memoizedState,Y===null?Y=Cm(p):(v=Y.cachePool,v!==null?(ae=ns._currentValue,v=v.parent!==ae?{parent:ae,pool:ae}:v):v=ov(),Y={baseLanes:Y.baseLanes|p,cachePool:v}),g.memoizedState=Y,g.childLanes=Am(l,P,p),u.memoizedState=Sm,Rc(l.child,g)):(ci(u),p=l.child,l=p.sibling,p=yr(p,{mode:"visible",children:g.children}),p.return=u,p.sibling=null,l!==null&&(P=u.deletions,P===null?(u.deletions=[l],u.flags|=16):P.push(l)),u.child=p,u.memoizedState=null,p)}function jm(l,u){return u=Yd({mode:"visible",children:u},l.mode),u.return=l,l.child=u}function Yd(l,u){return l=Zs(22,l,null,u),l.lanes=0,l}function Nm(l,u,p){return io(u,l.child,null,p),l=jm(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function vw(l,u,p){l.lanes|=u;var g=l.alternate;g!==null&&(g.lanes|=u),Uh(l.return,u,p)}function Tm(l,u,p,g,v,A){var P=l.memoizedState;P===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:g,tail:p,tailMode:v,treeForkCount:A}:(P.isBackwards=u,P.rendering=null,P.renderingStartTime=0,P.last=g,P.tail=p,P.tailMode=v,P.treeForkCount=A)}function ww(l,u,p){var g=u.pendingProps,v=g.revealOrder,A=g.tail;g=g.children;var P=Xn.current,Y=(P&2)!==0;if(Y?(P=P&1|2,u.flags|=128):P&=1,q(Xn,P),xs(l,u,g,p),g=cn?vc:0,!Y&&l!==null&&(l.flags&128)!==0)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&vw(l,p,u);else if(l.tag===19)vw(l,p,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}switch(v){case"forwards":for(p=u.child,v=null;p!==null;)l=p.alternate,l!==null&&Ld(l)===null&&(v=p),p=p.sibling;p=v,p===null?(v=u.child,u.child=null):(v=p.sibling,p.sibling=null),Tm(u,!1,v,p,A,g);break;case"backwards":case"unstable_legacy-backwards":for(p=null,v=u.child,u.child=null;v!==null;){if(l=v.alternate,l!==null&&Ld(l)===null){u.child=v;break}l=v.sibling,v.sibling=p,p=v,v=l}Tm(u,!0,p,null,A,g);break;case"together":Tm(u,!1,null,null,void 0,g);break;default:u.memoizedState=null}return u.child}function Ar(l,u,p){if(l!==null&&(u.dependencies=l.dependencies),pi|=u.lanes,(p&u.childLanes)===0)if(l!==null){if(il(l,u,p,!1),(p&u.childLanes)===0)return null}else return null;if(l!==null&&u.child!==l.child)throw Error(s(153));if(u.child!==null){for(l=u.child,p=yr(l,l.pendingProps),u.child=p,p.return=u;l.sibling!==null;)l=l.sibling,p=p.sibling=yr(l,l.pendingProps),p.return=u;p.sibling=null}return u.child}function _m(l,u){return(l.lanes&u)!==0?!0:(l=l.dependencies,!!(l!==null&&Nd(l)))}function N_(l,u,p){switch(u.tag){case 3:me(u,u.stateNode.containerInfo),ri(u,ns,l.memoizedState.cache),eo();break;case 27:case 5:re(u);break;case 4:me(u,u.stateNode.containerInfo);break;case 10:ri(u,u.type,u.memoizedProps.value);break;case 31:if(u.memoizedState!==null)return u.flags|=128,em(u),null;break;case 13:var g=u.memoizedState;if(g!==null)return g.dehydrated!==null?(ci(u),u.flags|=128,null):(p&u.child.childLanes)!==0?yw(l,u,p):(ci(u),l=Ar(l,u,p),l!==null?l.sibling:null);ci(u);break;case 19:var v=(l.flags&128)!==0;if(g=(p&u.childLanes)!==0,g||(il(l,u,p,!1),g=(p&u.childLanes)!==0),v){if(g)return ww(l,u,p);u.flags|=128}if(v=u.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),q(Xn,Xn.current),g)break;return null;case 22:return u.lanes=0,pw(l,u,p,u.pendingProps);case 24:ri(u,ns,l.memoizedState.cache)}return Ar(l,u,p)}function kw(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps)as=!0;else{if(!_m(l,p)&&(u.flags&128)===0)return as=!1,N_(l,u,p);as=(l.flags&131072)!==0}else as=!1,cn&&(u.flags&1048576)!==0&&ev(u,vc,u.index);switch(u.lanes=0,u.tag){case 16:e:{var g=u.pendingProps;if(l=ao(u.elementType),u.type=l,typeof l=="function")Oh(l)?(g=lo(l,g),u.tag=1,u=bw(null,u,l,g,p)):(u.tag=0,u=km(null,u,l,g,p));else{if(l!=null){var v=l.$$typeof;if(v===T){u.tag=11,u=uw(null,u,l,g,p);break e}else if(v===I){u.tag=14,u=dw(null,u,l,g,p);break e}}throw u=W(l)||l,Error(s(306,u,""))}}return u;case 0:return km(l,u,u.type,u.pendingProps,p);case 1:return g=u.type,v=lo(g,u.pendingProps),bw(l,u,g,v,p);case 3:e:{if(me(u,u.stateNode.containerInfo),l===null)throw Error(s(387));g=u.pendingProps;var A=u.memoizedState;v=A.element,Kh(l,u),Tc(u,g,null,p);var P=u.memoizedState;if(g=P.cache,ri(u,ns,g),g!==A.cache&&Hh(u,[ns],p,!0),Nc(),g=P.element,A.isDehydrated)if(A={element:g,isDehydrated:!1,cache:P.cache},u.updateQueue.baseState=A,u.memoizedState=A,u.flags&256){u=xw(l,u,g,p);break e}else if(g!==v){v=ba(Error(s(424)),u),wc(v),u=xw(l,u,g,p);break e}else{switch(l=u.stateNode.containerInfo,l.nodeType){case 9:l=l.body;break;default:l=l.nodeName==="HTML"?l.ownerDocument.body:l}for(In=ka(l.firstChild),gs=u,cn=!0,si=null,va=!0,p=pv(u,null,g,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if(eo(),g===v){u=Ar(l,u,p);break e}xs(l,u,g,p)}u=u.child}return u;case 26:return Vd(l,u),l===null?(p=R0(u.type,null,u.pendingProps,null))?u.memoizedState=p:cn||(p=u.type,l=u.pendingProps,g=uf(Z.current).createElement(p),g[xt]=u,g[$t]=l,ys(g,p,l),wn(g),u.stateNode=g):u.memoizedState=R0(u.type,l.memoizedProps,u.pendingProps,l.memoizedState),null;case 27:return re(u),l===null&&cn&&(g=u.stateNode=E0(u.type,u.pendingProps,Z.current),gs=u,va=!0,v=In,xi(u.type)?(lg=v,In=ka(g.firstChild)):In=v),xs(l,u,u.pendingProps.children,p),Vd(l,u),l===null&&(u.flags|=4194304),u.child;case 5:return l===null&&cn&&((v=g=In)&&(g=sE(g,u.type,u.pendingProps,va),g!==null?(u.stateNode=g,gs=u,In=ka(g.firstChild),va=!1,v=!0):v=!1),v||ai(u)),re(u),v=u.type,A=u.pendingProps,P=l!==null?l.memoizedProps:null,g=A.children,sg(v,A)?g=null:P!==null&&sg(v,P)&&(u.flags|=32),u.memoizedState!==null&&(v=nm(l,u,x_,null,null,p),Gc._currentValue=v),Vd(l,u),xs(l,u,g,p),u.child;case 6:return l===null&&cn&&((l=p=In)&&(p=aE(p,u.pendingProps,va),p!==null?(u.stateNode=p,gs=u,In=null,l=!0):l=!1),l||ai(u)),null;case 13:return yw(l,u,p);case 4:return me(u,u.stateNode.containerInfo),g=u.pendingProps,l===null?u.child=io(u,null,g,p):xs(l,u,g,p),u.child;case 11:return uw(l,u,u.type,u.pendingProps,p);case 7:return xs(l,u,u.pendingProps,p),u.child;case 8:return xs(l,u,u.pendingProps.children,p),u.child;case 12:return xs(l,u,u.pendingProps.children,p),u.child;case 10:return g=u.pendingProps,ri(u,u.type,g.value),xs(l,u,g.children,p),u.child;case 9:return v=u.type._context,g=u.pendingProps.children,no(u),v=bs(v),g=g(v),u.flags|=1,xs(l,u,g,p),u.child;case 14:return dw(l,u,u.type,u.pendingProps,p);case 15:return fw(l,u,u.type,u.pendingProps,p);case 19:return ww(l,u,p);case 31:return j_(l,u,p);case 22:return pw(l,u,p,u.pendingProps);case 24:return no(u),g=bs(ns),l===null?(v=Vh(),v===null&&(v=Nn,A=Wh(),v.pooledCache=A,A.refCount++,A!==null&&(v.pooledCacheLanes|=p),v=A),u.memoizedState={parent:g,cache:v},Gh(u),ri(u,ns,v)):((l.lanes&p)!==0&&(Kh(l,u),Tc(u,null,null,p),Nc()),v=l.memoizedState,A=u.memoizedState,v.parent!==g?(v={parent:g,cache:g},u.memoizedState=v,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=v),ri(u,ns,g)):(g=A.cache,ri(u,ns,g),g!==v.cache&&Hh(u,[ns],p,!0))),xs(l,u,u.pendingProps.children,p),u.child;case 29:throw u.pendingProps}throw Error(s(156,u.tag))}function jr(l){l.flags|=4}function Em(l,u,p,g,v){if((u=(l.mode&32)!==0)&&(u=!1),u){if(l.flags|=16777216,(v&335544128)===v)if(l.stateNode.complete)l.flags|=8192;else if(Kw())l.flags|=8192;else throw ro=Md,Yh}else l.flags&=-16777217}function Sw(l,u){if(u.type!=="stylesheet"||(u.state.loading&4)!==0)l.flags&=-16777217;else if(l.flags|=16777216,!B0(u))if(Kw())l.flags|=8192;else throw ro=Md,Yh}function Gd(l,u){u!==null&&(l.flags|=4),l.flags&16384&&(u=l.tag!==22?tn():536870912,l.lanes|=u,xl|=u)}function Oc(l,u){if(!cn)switch(l.tailMode){case"hidden":u=l.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var g=null;p!==null;)p.alternate!==null&&(g=p),p=p.sibling;g===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:g.sibling=null}}function Pn(l){var u=l.alternate!==null&&l.alternate.child===l.child,p=0,g=0;if(u)for(var v=l.child;v!==null;)p|=v.lanes|v.childLanes,g|=v.subtreeFlags&65011712,g|=v.flags&65011712,v.return=l,v=v.sibling;else for(v=l.child;v!==null;)p|=v.lanes|v.childLanes,g|=v.subtreeFlags,g|=v.flags,v.return=l,v=v.sibling;return l.subtreeFlags|=g,l.childLanes=p,u}function T_(l,u,p){var g=u.pendingProps;switch(Bh(u),u.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pn(u),null;case 1:return Pn(u),null;case 3:return p=u.stateNode,g=null,l!==null&&(g=l.memoizedState.cache),u.memoizedState.cache!==g&&(u.flags|=2048),kr(ns),ee(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(l===null||l.child===null)&&(rl(u)?jr(u):l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,zh())),Pn(u),null;case 26:var v=u.type,A=u.memoizedState;return l===null?(jr(u),A!==null?(Pn(u),Sw(u,A)):(Pn(u),Em(u,v,null,g,p))):A?A!==l.memoizedState?(jr(u),Pn(u),Sw(u,A)):(Pn(u),u.flags&=-16777217):(l=l.memoizedProps,l!==g&&jr(u),Pn(u),Em(u,v,l,g,p)),null;case 27:if(We(u),p=Z.current,v=u.type,l!==null&&u.stateNode!=null)l.memoizedProps!==g&&jr(u);else{if(!g){if(u.stateNode===null)throw Error(s(166));return Pn(u),null}l=xe.current,rl(u)?nv(u):(l=E0(v,g,p),u.stateNode=l,jr(u))}return Pn(u),null;case 5:if(We(u),v=u.type,l!==null&&u.stateNode!=null)l.memoizedProps!==g&&jr(u);else{if(!g){if(u.stateNode===null)throw Error(s(166));return Pn(u),null}if(A=xe.current,rl(u))nv(u);else{var P=uf(Z.current);switch(A){case 1:A=P.createElementNS("http://www.w3.org/2000/svg",v);break;case 2:A=P.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;default:switch(v){case"svg":A=P.createElementNS("http://www.w3.org/2000/svg",v);break;case"math":A=P.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;case"script":A=P.createElement("div"),A.innerHTML="<script><\/script>",A=A.removeChild(A.firstChild);break;case"select":A=typeof g.is=="string"?P.createElement("select",{is:g.is}):P.createElement("select"),g.multiple?A.multiple=!0:g.size&&(A.size=g.size);break;default:A=typeof g.is=="string"?P.createElement(v,{is:g.is}):P.createElement(v)}}A[xt]=u,A[$t]=g;e:for(P=u.child;P!==null;){if(P.tag===5||P.tag===6)A.appendChild(P.stateNode);else if(P.tag!==4&&P.tag!==27&&P.child!==null){P.child.return=P,P=P.child;continue}if(P===u)break e;for(;P.sibling===null;){if(P.return===null||P.return===u)break e;P=P.return}P.sibling.return=P.return,P=P.sibling}u.stateNode=A;e:switch(ys(A,v,g),v){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&jr(u)}}return Pn(u),Em(u,u.type,l===null?null:l.memoizedProps,u.pendingProps,p),null;case 6:if(l&&u.stateNode!=null)l.memoizedProps!==g&&jr(u);else{if(typeof g!="string"&&u.stateNode===null)throw Error(s(166));if(l=Z.current,rl(u)){if(l=u.stateNode,p=u.memoizedProps,g=null,v=gs,v!==null)switch(v.tag){case 27:case 5:g=v.memoizedProps}l[xt]=u,l=!!(l.nodeValue===p||g!==null&&g.suppressHydrationWarning===!0||y0(l.nodeValue,p)),l||ai(u,!0)}else l=uf(l).createTextNode(g),l[xt]=u,u.stateNode=l}return Pn(u),null;case 31:if(p=u.memoizedState,l===null||l.memoizedState!==null){if(g=rl(u),p!==null){if(l===null){if(!g)throw Error(s(318));if(l=u.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(s(557));l[xt]=u}else eo(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Pn(u),l=!1}else p=zh(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=p),l=!0;if(!l)return u.flags&256?(ta(u),u):(ta(u),null);if((u.flags&128)!==0)throw Error(s(558))}return Pn(u),null;case 13:if(g=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(v=rl(u),g!==null&&g.dehydrated!==null){if(l===null){if(!v)throw Error(s(318));if(v=u.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(s(317));v[xt]=u}else eo(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Pn(u),v=!1}else v=zh(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=v),v=!0;if(!v)return u.flags&256?(ta(u),u):(ta(u),null)}return ta(u),(u.flags&128)!==0?(u.lanes=p,u):(p=g!==null,l=l!==null&&l.memoizedState!==null,p&&(g=u.child,v=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(v=g.alternate.memoizedState.cachePool.pool),A=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(A=g.memoizedState.cachePool.pool),A!==v&&(g.flags|=2048)),p!==l&&p&&(u.child.flags|=8192),Gd(u,u.updateQueue),Pn(u),null);case 4:return ee(),l===null&&Jm(u.stateNode.containerInfo),Pn(u),null;case 10:return kr(u.type),Pn(u),null;case 19:if(ne(Xn),g=u.memoizedState,g===null)return Pn(u),null;if(v=(u.flags&128)!==0,A=g.rendering,A===null)if(v)Oc(g,!1);else{if(Yn!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(A=Ld(l),A!==null){for(u.flags|=128,Oc(g,!1),l=A.updateQueue,u.updateQueue=l,Gd(u,l),u.subtreeFlags=0,l=p,p=u.child;p!==null;)Xy(p,l),p=p.sibling;return q(Xn,Xn.current&1|2),cn&&vr(u,g.treeForkCount),u.child}l=l.sibling}g.tail!==null&&ct()>Zd&&(u.flags|=128,v=!0,Oc(g,!1),u.lanes=4194304)}else{if(!v)if(l=Ld(A),l!==null){if(u.flags|=128,v=!0,l=l.updateQueue,u.updateQueue=l,Gd(u,l),Oc(g,!0),g.tail===null&&g.tailMode==="hidden"&&!A.alternate&&!cn)return Pn(u),null}else 2*ct()-g.renderingStartTime>Zd&&p!==536870912&&(u.flags|=128,v=!0,Oc(g,!1),u.lanes=4194304);g.isBackwards?(A.sibling=u.child,u.child=A):(l=g.last,l!==null?l.sibling=A:u.child=A,g.last=A)}return g.tail!==null?(l=g.tail,g.rendering=l,g.tail=l.sibling,g.renderingStartTime=ct(),l.sibling=null,p=Xn.current,q(Xn,v?p&1|2:p&1),cn&&vr(u,g.treeForkCount),l):(Pn(u),null);case 22:case 23:return ta(u),Zh(),g=u.memoizedState!==null,l!==null?l.memoizedState!==null!==g&&(u.flags|=8192):g&&(u.flags|=8192),g?(p&536870912)!==0&&(u.flags&128)===0&&(Pn(u),u.subtreeFlags&6&&(u.flags|=8192)):Pn(u),p=u.updateQueue,p!==null&&Gd(u,p.retryQueue),p=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==p&&(u.flags|=2048),l!==null&&ne(so),null;case 24:return p=null,l!==null&&(p=l.memoizedState.cache),u.memoizedState.cache!==p&&(u.flags|=2048),kr(ns),Pn(u),null;case 25:return null;case 30:return null}throw Error(s(156,u.tag))}function __(l,u){switch(Bh(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return kr(ns),ee(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return We(u),null;case 31:if(u.memoizedState!==null){if(ta(u),u.alternate===null)throw Error(s(340));eo()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 13:if(ta(u),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(s(340));eo()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return ne(Xn),null;case 4:return ee(),null;case 10:return kr(u.type),null;case 22:case 23:return ta(u),Zh(),l!==null&&ne(so),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return kr(ns),null;case 25:return null;default:return null}}function Cw(l,u){switch(Bh(u),u.tag){case 3:kr(ns),ee();break;case 26:case 27:case 5:We(u);break;case 4:ee();break;case 31:u.memoizedState!==null&&ta(u);break;case 13:ta(u);break;case 19:ne(Xn);break;case 10:kr(u.type);break;case 22:case 23:ta(u),Zh(),l!==null&&ne(so);break;case 24:kr(ns)}}function Lc(l,u){try{var p=u.updateQueue,g=p!==null?p.lastEffect:null;if(g!==null){var v=g.next;p=v;do{if((p.tag&l)===l){g=void 0;var A=p.create,P=p.inst;g=A(),P.destroy=g}p=p.next}while(p!==v)}}catch(Y){xn(u,u.return,Y)}}function di(l,u,p){try{var g=u.updateQueue,v=g!==null?g.lastEffect:null;if(v!==null){var A=v.next;g=A;do{if((g.tag&l)===l){var P=g.inst,Y=P.destroy;if(Y!==void 0){P.destroy=void 0,v=u;var ae=p,Me=Y;try{Me()}catch(Ve){xn(v,ae,Ve)}}}g=g.next}while(g!==A)}}catch(Ve){xn(u,u.return,Ve)}}function Aw(l){var u=l.updateQueue;if(u!==null){var p=l.stateNode;try{mv(u,p)}catch(g){xn(l,l.return,g)}}}function jw(l,u,p){p.props=lo(l.type,l.memoizedProps),p.state=l.memoizedState;try{p.componentWillUnmount()}catch(g){xn(l,u,g)}}function Ic(l,u){try{var p=l.ref;if(p!==null){switch(l.tag){case 26:case 27:case 5:var g=l.stateNode;break;case 30:g=l.stateNode;break;default:g=l.stateNode}typeof p=="function"?l.refCleanup=p(g):p.current=g}}catch(v){xn(l,u,v)}}function Ka(l,u){var p=l.ref,g=l.refCleanup;if(p!==null)if(typeof g=="function")try{g()}catch(v){xn(l,u,v)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(v){xn(l,u,v)}else p.current=null}function Nw(l){var u=l.type,p=l.memoizedProps,g=l.stateNode;try{e:switch(u){case"button":case"input":case"select":case"textarea":p.autoFocus&&g.focus();break e;case"img":p.src?g.src=p.src:p.srcSet&&(g.srcset=p.srcSet)}}catch(v){xn(l,l.return,v)}}function Mm(l,u,p){try{var g=l.stateNode;X_(g,l.type,p,u),g[$t]=u}catch(v){xn(l,l.return,v)}}function Tw(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&xi(l.type)||l.tag===4}function Dm(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Tw(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&xi(l.type)||l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function Rm(l,u,p){var g=l.tag;if(g===5||g===6)l=l.stateNode,u?(p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p).insertBefore(l,u):(u=p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p,u.appendChild(l),p=p._reactRootContainer,p!=null||u.onclick!==null||(u.onclick=It));else if(g!==4&&(g===27&&xi(l.type)&&(p=l.stateNode,u=null),l=l.child,l!==null))for(Rm(l,u,p),l=l.sibling;l!==null;)Rm(l,u,p),l=l.sibling}function Kd(l,u,p){var g=l.tag;if(g===5||g===6)l=l.stateNode,u?p.insertBefore(l,u):p.appendChild(l);else if(g!==4&&(g===27&&xi(l.type)&&(p=l.stateNode),l=l.child,l!==null))for(Kd(l,u,p),l=l.sibling;l!==null;)Kd(l,u,p),l=l.sibling}function _w(l){var u=l.stateNode,p=l.memoizedProps;try{for(var g=l.type,v=u.attributes;v.length;)u.removeAttributeNode(v[0]);ys(u,g,p),u[xt]=l,u[$t]=p}catch(A){xn(l,l.return,A)}}var Nr=!1,rs=!1,Om=!1,Ew=typeof WeakSet=="function"?WeakSet:Set,ds=null;function E_(l,u){if(l=l.containerInfo,tg=bf,l=Uy(l),Nh(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var g=p.getSelection&&p.getSelection();if(g&&g.rangeCount!==0){p=g.anchorNode;var v=g.anchorOffset,A=g.focusNode;g=g.focusOffset;try{p.nodeType,A.nodeType}catch{p=null;break e}var P=0,Y=-1,ae=-1,Me=0,Ve=0,Qe=l,Le=null;t:for(;;){for(var Ue;Qe!==p||v!==0&&Qe.nodeType!==3||(Y=P+v),Qe!==A||g!==0&&Qe.nodeType!==3||(ae=P+g),Qe.nodeType===3&&(P+=Qe.nodeValue.length),(Ue=Qe.firstChild)!==null;)Le=Qe,Qe=Ue;for(;;){if(Qe===l)break t;if(Le===p&&++Me===v&&(Y=P),Le===A&&++Ve===g&&(ae=P),(Ue=Qe.nextSibling)!==null)break;Qe=Le,Le=Qe.parentNode}Qe=Ue}p=Y===-1||ae===-1?null:{start:Y,end:ae}}else p=null}p=p||{start:0,end:0}}else p=null;for(ng={focusedElem:l,selectionRange:p},bf=!1,ds=u;ds!==null;)if(u=ds,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,ds=l;else for(;ds!==null;){switch(u=ds,A=u.alternate,l=u.flags,u.tag){case 0:if((l&4)!==0&&(l=u.updateQueue,l=l!==null?l.events:null,l!==null))for(p=0;p<l.length;p++)v=l[p],v.ref.impl=v.nextImpl;break;case 11:case 15:break;case 1:if((l&1024)!==0&&A!==null){l=void 0,p=u,v=A.memoizedProps,A=A.memoizedState,g=p.stateNode;try{var yt=lo(p.type,v);l=g.getSnapshotBeforeUpdate(yt,A),g.__reactInternalSnapshotBeforeUpdate=l}catch(Dt){xn(p,p.return,Dt)}}break;case 3:if((l&1024)!==0){if(l=u.stateNode.containerInfo,p=l.nodeType,p===9)rg(l);else if(p===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":rg(l);break;default:l.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((l&1024)!==0)throw Error(s(163))}if(l=u.sibling,l!==null){l.return=u.return,ds=l;break}ds=u.return}}function Mw(l,u,p){var g=p.flags;switch(p.tag){case 0:case 11:case 15:_r(l,p),g&4&&Lc(5,p);break;case 1:if(_r(l,p),g&4)if(l=p.stateNode,u===null)try{l.componentDidMount()}catch(P){xn(p,p.return,P)}else{var v=lo(p.type,u.memoizedProps);u=u.memoizedState;try{l.componentDidUpdate(v,u,l.__reactInternalSnapshotBeforeUpdate)}catch(P){xn(p,p.return,P)}}g&64&&Aw(p),g&512&&Ic(p,p.return);break;case 3:if(_r(l,p),g&64&&(l=p.updateQueue,l!==null)){if(u=null,p.child!==null)switch(p.child.tag){case 27:case 5:u=p.child.stateNode;break;case 1:u=p.child.stateNode}try{mv(l,u)}catch(P){xn(p,p.return,P)}}break;case 27:u===null&&g&4&&_w(p);case 26:case 5:_r(l,p),u===null&&g&4&&Nw(p),g&512&&Ic(p,p.return);break;case 12:_r(l,p);break;case 31:_r(l,p),g&4&&Ow(l,p);break;case 13:_r(l,p),g&4&&Lw(l,p),g&64&&(l=p.memoizedState,l!==null&&(l=l.dehydrated,l!==null&&(p=F_.bind(null,p),rE(l,p))));break;case 22:if(g=p.memoizedState!==null||Nr,!g){u=u!==null&&u.memoizedState!==null||rs,v=Nr;var A=rs;Nr=g,(rs=u)&&!A?Er(l,p,(p.subtreeFlags&8772)!==0):_r(l,p),Nr=v,rs=A}break;case 30:break;default:_r(l,p)}}function Dw(l){var u=l.alternate;u!==null&&(l.alternate=null,Dw(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&Qn(u)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}var zn=null,$s=!1;function Tr(l,u,p){for(p=p.child;p!==null;)Rw(l,u,p),p=p.sibling}function Rw(l,u,p){if(Ie&&typeof Ie.onCommitFiberUnmount=="function")try{Ie.onCommitFiberUnmount(ye,p)}catch{}switch(p.tag){case 26:rs||Ka(p,u),Tr(l,u,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:rs||Ka(p,u);var g=zn,v=$s;xi(p.type)&&(zn=p.stateNode,$s=!1),Tr(l,u,p),qc(p.stateNode),zn=g,$s=v;break;case 5:rs||Ka(p,u);case 6:if(g=zn,v=$s,zn=null,Tr(l,u,p),zn=g,$s=v,zn!==null)if($s)try{(zn.nodeType===9?zn.body:zn.nodeName==="HTML"?zn.ownerDocument.body:zn).removeChild(p.stateNode)}catch(A){xn(p,u,A)}else try{zn.removeChild(p.stateNode)}catch(A){xn(p,u,A)}break;case 18:zn!==null&&($s?(l=zn,A0(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,p.stateNode),jl(l)):A0(zn,p.stateNode));break;case 4:g=zn,v=$s,zn=p.stateNode.containerInfo,$s=!0,Tr(l,u,p),zn=g,$s=v;break;case 0:case 11:case 14:case 15:di(2,p,u),rs||di(4,p,u),Tr(l,u,p);break;case 1:rs||(Ka(p,u),g=p.stateNode,typeof g.componentWillUnmount=="function"&&jw(p,u,g)),Tr(l,u,p);break;case 21:Tr(l,u,p);break;case 22:rs=(g=rs)||p.memoizedState!==null,Tr(l,u,p),rs=g;break;default:Tr(l,u,p)}}function Ow(l,u){if(u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null))){l=l.dehydrated;try{jl(l)}catch(p){xn(u,u.return,p)}}}function Lw(l,u){if(u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null&&(l=l.dehydrated,l!==null))))try{jl(l)}catch(p){xn(u,u.return,p)}}function M_(l){switch(l.tag){case 31:case 13:case 19:var u=l.stateNode;return u===null&&(u=l.stateNode=new Ew),u;case 22:return l=l.stateNode,u=l._retryCache,u===null&&(u=l._retryCache=new Ew),u;default:throw Error(s(435,l.tag))}}function Qd(l,u){var p=M_(l);u.forEach(function(g){if(!p.has(g)){p.add(g);var v=z_.bind(null,l,g);g.then(v,v)}})}function Us(l,u){var p=u.deletions;if(p!==null)for(var g=0;g<p.length;g++){var v=p[g],A=l,P=u,Y=P;e:for(;Y!==null;){switch(Y.tag){case 27:if(xi(Y.type)){zn=Y.stateNode,$s=!1;break e}break;case 5:zn=Y.stateNode,$s=!1;break e;case 3:case 4:zn=Y.stateNode.containerInfo,$s=!0;break e}Y=Y.return}if(zn===null)throw Error(s(160));Rw(A,P,v),zn=null,$s=!1,A=v.alternate,A!==null&&(A.return=null),v.return=null}if(u.subtreeFlags&13886)for(u=u.child;u!==null;)Iw(u,l),u=u.sibling}var Ra=null;function Iw(l,u){var p=l.alternate,g=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:Us(u,l),Hs(l),g&4&&(di(3,l,l.return),Lc(3,l),di(5,l,l.return));break;case 1:Us(u,l),Hs(l),g&512&&(rs||p===null||Ka(p,p.return)),g&64&&Nr&&(l=l.updateQueue,l!==null&&(g=l.callbacks,g!==null&&(p=l.shared.hiddenCallbacks,l.shared.hiddenCallbacks=p===null?g:p.concat(g))));break;case 26:var v=Ra;if(Us(u,l),Hs(l),g&512&&(rs||p===null||Ka(p,p.return)),g&4){var A=p!==null?p.memoizedState:null;if(g=l.memoizedState,p===null)if(g===null)if(l.stateNode===null){e:{g=l.type,p=l.memoizedProps,v=v.ownerDocument||v;t:switch(g){case"title":A=v.getElementsByTagName("title")[0],(!A||A[ks]||A[xt]||A.namespaceURI==="http://www.w3.org/2000/svg"||A.hasAttribute("itemprop"))&&(A=v.createElement(g),v.head.insertBefore(A,v.querySelector("head > title"))),ys(A,g,p),A[xt]=l,wn(A),g=A;break e;case"link":var P=I0("link","href",v).get(g+(p.href||""));if(P){for(var Y=0;Y<P.length;Y++)if(A=P[Y],A.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&A.getAttribute("rel")===(p.rel==null?null:p.rel)&&A.getAttribute("title")===(p.title==null?null:p.title)&&A.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){P.splice(Y,1);break t}}A=v.createElement(g),ys(A,g,p),v.head.appendChild(A);break;case"meta":if(P=I0("meta","content",v).get(g+(p.content||""))){for(Y=0;Y<P.length;Y++)if(A=P[Y],A.getAttribute("content")===(p.content==null?null:""+p.content)&&A.getAttribute("name")===(p.name==null?null:p.name)&&A.getAttribute("property")===(p.property==null?null:p.property)&&A.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&A.getAttribute("charset")===(p.charSet==null?null:p.charSet)){P.splice(Y,1);break t}}A=v.createElement(g),ys(A,g,p),v.head.appendChild(A);break;default:throw Error(s(468,g))}A[xt]=l,wn(A),g=A}l.stateNode=g}else P0(v,l.type,l.stateNode);else l.stateNode=L0(v,g,l.memoizedProps);else A!==g?(A===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):A.count--,g===null?P0(v,l.type,l.stateNode):L0(v,g,l.memoizedProps)):g===null&&l.stateNode!==null&&Mm(l,l.memoizedProps,p.memoizedProps)}break;case 27:Us(u,l),Hs(l),g&512&&(rs||p===null||Ka(p,p.return)),p!==null&&g&4&&Mm(l,l.memoizedProps,p.memoizedProps);break;case 5:if(Us(u,l),Hs(l),g&512&&(rs||p===null||Ka(p,p.return)),l.flags&32){v=l.stateNode;try{pa(v,"")}catch(yt){xn(l,l.return,yt)}}g&4&&l.stateNode!=null&&(v=l.memoizedProps,Mm(l,v,p!==null?p.memoizedProps:v)),g&1024&&(Om=!0);break;case 6:if(Us(u,l),Hs(l),g&4){if(l.stateNode===null)throw Error(s(162));g=l.memoizedProps,p=l.stateNode;try{p.nodeValue=g}catch(yt){xn(l,l.return,yt)}}break;case 3:if(pf=null,v=Ra,Ra=df(u.containerInfo),Us(u,l),Ra=v,Hs(l),g&4&&p!==null&&p.memoizedState.isDehydrated)try{jl(u.containerInfo)}catch(yt){xn(l,l.return,yt)}Om&&(Om=!1,Pw(l));break;case 4:g=Ra,Ra=df(l.stateNode.containerInfo),Us(u,l),Hs(l),Ra=g;break;case 12:Us(u,l),Hs(l);break;case 31:Us(u,l),Hs(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,Qd(l,g)));break;case 13:Us(u,l),Hs(l),l.child.flags&8192&&l.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(Jd=ct()),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,Qd(l,g)));break;case 22:v=l.memoizedState!==null;var ae=p!==null&&p.memoizedState!==null,Me=Nr,Ve=rs;if(Nr=Me||v,rs=Ve||ae,Us(u,l),rs=Ve,Nr=Me,Hs(l),g&8192)e:for(u=l.stateNode,u._visibility=v?u._visibility&-2:u._visibility|1,v&&(p===null||ae||Nr||rs||co(l)),p=null,u=l;;){if(u.tag===5||u.tag===26){if(p===null){ae=p=u;try{if(A=ae.stateNode,v)P=A.style,typeof P.setProperty=="function"?P.setProperty("display","none","important"):P.display="none";else{Y=ae.stateNode;var Qe=ae.memoizedProps.style,Le=Qe!=null&&Qe.hasOwnProperty("display")?Qe.display:null;Y.style.display=Le==null||typeof Le=="boolean"?"":(""+Le).trim()}}catch(yt){xn(ae,ae.return,yt)}}}else if(u.tag===6){if(p===null){ae=u;try{ae.stateNode.nodeValue=v?"":ae.memoizedProps}catch(yt){xn(ae,ae.return,yt)}}}else if(u.tag===18){if(p===null){ae=u;try{var Ue=ae.stateNode;v?j0(Ue,!0):j0(ae.stateNode,!1)}catch(yt){xn(ae,ae.return,yt)}}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===l)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break e;for(;u.sibling===null;){if(u.return===null||u.return===l)break e;p===u&&(p=null),u=u.return}p===u&&(p=null),u.sibling.return=u.return,u=u.sibling}g&4&&(g=l.updateQueue,g!==null&&(p=g.retryQueue,p!==null&&(g.retryQueue=null,Qd(l,p))));break;case 19:Us(u,l),Hs(l),g&4&&(g=l.updateQueue,g!==null&&(l.updateQueue=null,Qd(l,g)));break;case 30:break;case 21:break;default:Us(u,l),Hs(l)}}function Hs(l){var u=l.flags;if(u&2){try{for(var p,g=l.return;g!==null;){if(Tw(g)){p=g;break}g=g.return}if(p==null)throw Error(s(160));switch(p.tag){case 27:var v=p.stateNode,A=Dm(l);Kd(l,A,v);break;case 5:var P=p.stateNode;p.flags&32&&(pa(P,""),p.flags&=-33);var Y=Dm(l);Kd(l,Y,P);break;case 3:case 4:var ae=p.stateNode.containerInfo,Me=Dm(l);Rm(l,Me,ae);break;default:throw Error(s(161))}}catch(Ve){xn(l,l.return,Ve)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function Pw(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var u=l;Pw(u),u.tag===5&&u.flags&1024&&u.stateNode.reset(),l=l.sibling}}function _r(l,u){if(u.subtreeFlags&8772)for(u=u.child;u!==null;)Mw(l,u.alternate,u),u=u.sibling}function co(l){for(l=l.child;l!==null;){var u=l;switch(u.tag){case 0:case 11:case 14:case 15:di(4,u,u.return),co(u);break;case 1:Ka(u,u.return);var p=u.stateNode;typeof p.componentWillUnmount=="function"&&jw(u,u.return,p),co(u);break;case 27:qc(u.stateNode);case 26:case 5:Ka(u,u.return),co(u);break;case 22:u.memoizedState===null&&co(u);break;case 30:co(u);break;default:co(u)}l=l.sibling}}function Er(l,u,p){for(p=p&&(u.subtreeFlags&8772)!==0,u=u.child;u!==null;){var g=u.alternate,v=l,A=u,P=A.flags;switch(A.tag){case 0:case 11:case 15:Er(v,A,p),Lc(4,A);break;case 1:if(Er(v,A,p),g=A,v=g.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(Me){xn(g,g.return,Me)}if(g=A,v=g.updateQueue,v!==null){var Y=g.stateNode;try{var ae=v.shared.hiddenCallbacks;if(ae!==null)for(v.shared.hiddenCallbacks=null,v=0;v<ae.length;v++)hv(ae[v],Y)}catch(Me){xn(g,g.return,Me)}}p&&P&64&&Aw(A),Ic(A,A.return);break;case 27:_w(A);case 26:case 5:Er(v,A,p),p&&g===null&&P&4&&Nw(A),Ic(A,A.return);break;case 12:Er(v,A,p);break;case 31:Er(v,A,p),p&&P&4&&Ow(v,A);break;case 13:Er(v,A,p),p&&P&4&&Lw(v,A);break;case 22:A.memoizedState===null&&Er(v,A,p),Ic(A,A.return);break;case 30:break;default:Er(v,A,p)}u=u.sibling}}function Lm(l,u){var p=null;l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),l=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(l=u.memoizedState.cachePool.pool),l!==p&&(l!=null&&l.refCount++,p!=null&&kc(p))}function Im(l,u){l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&kc(l))}function Oa(l,u,p,g){if(u.subtreeFlags&10256)for(u=u.child;u!==null;)Bw(l,u,p,g),u=u.sibling}function Bw(l,u,p,g){var v=u.flags;switch(u.tag){case 0:case 11:case 15:Oa(l,u,p,g),v&2048&&Lc(9,u);break;case 1:Oa(l,u,p,g);break;case 3:Oa(l,u,p,g),v&2048&&(l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&kc(l)));break;case 12:if(v&2048){Oa(l,u,p,g),l=u.stateNode;try{var A=u.memoizedProps,P=A.id,Y=A.onPostCommit;typeof Y=="function"&&Y(P,u.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(ae){xn(u,u.return,ae)}}else Oa(l,u,p,g);break;case 31:Oa(l,u,p,g);break;case 13:Oa(l,u,p,g);break;case 23:break;case 22:A=u.stateNode,P=u.alternate,u.memoizedState!==null?A._visibility&2?Oa(l,u,p,g):Pc(l,u):A._visibility&2?Oa(l,u,p,g):(A._visibility|=2,ml(l,u,p,g,(u.subtreeFlags&10256)!==0||!1)),v&2048&&Lm(P,u);break;case 24:Oa(l,u,p,g),v&2048&&Im(u.alternate,u);break;default:Oa(l,u,p,g)}}function ml(l,u,p,g,v){for(v=v&&((u.subtreeFlags&10256)!==0||!1),u=u.child;u!==null;){var A=l,P=u,Y=p,ae=g,Me=P.flags;switch(P.tag){case 0:case 11:case 15:ml(A,P,Y,ae,v),Lc(8,P);break;case 23:break;case 22:var Ve=P.stateNode;P.memoizedState!==null?Ve._visibility&2?ml(A,P,Y,ae,v):Pc(A,P):(Ve._visibility|=2,ml(A,P,Y,ae,v)),v&&Me&2048&&Lm(P.alternate,P);break;case 24:ml(A,P,Y,ae,v),v&&Me&2048&&Im(P.alternate,P);break;default:ml(A,P,Y,ae,v)}u=u.sibling}}function Pc(l,u){if(u.subtreeFlags&10256)for(u=u.child;u!==null;){var p=l,g=u,v=g.flags;switch(g.tag){case 22:Pc(p,g),v&2048&&Lm(g.alternate,g);break;case 24:Pc(p,g),v&2048&&Im(g.alternate,g);break;default:Pc(p,g)}u=u.sibling}}var Bc=8192;function gl(l,u,p){if(l.subtreeFlags&Bc)for(l=l.child;l!==null;)Fw(l,u,p),l=l.sibling}function Fw(l,u,p){switch(l.tag){case 26:gl(l,u,p),l.flags&Bc&&l.memoizedState!==null&&bE(p,Ra,l.memoizedState,l.memoizedProps);break;case 5:gl(l,u,p);break;case 3:case 4:var g=Ra;Ra=df(l.stateNode.containerInfo),gl(l,u,p),Ra=g;break;case 22:l.memoizedState===null&&(g=l.alternate,g!==null&&g.memoizedState!==null?(g=Bc,Bc=16777216,gl(l,u,p),Bc=g):gl(l,u,p));break;default:gl(l,u,p)}}function zw(l){var u=l.alternate;if(u!==null&&(l=u.child,l!==null)){u.child=null;do u=l.sibling,l.sibling=null,l=u;while(l!==null)}}function Fc(l){var u=l.deletions;if((l.flags&16)!==0){if(u!==null)for(var p=0;p<u.length;p++){var g=u[p];ds=g,Uw(g,l)}zw(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)$w(l),l=l.sibling}function $w(l){switch(l.tag){case 0:case 11:case 15:Fc(l),l.flags&2048&&di(9,l,l.return);break;case 3:Fc(l);break;case 12:Fc(l);break;case 22:var u=l.stateNode;l.memoizedState!==null&&u._visibility&2&&(l.return===null||l.return.tag!==13)?(u._visibility&=-3,Xd(l)):Fc(l);break;default:Fc(l)}}function Xd(l){var u=l.deletions;if((l.flags&16)!==0){if(u!==null)for(var p=0;p<u.length;p++){var g=u[p];ds=g,Uw(g,l)}zw(l)}for(l=l.child;l!==null;){switch(u=l,u.tag){case 0:case 11:case 15:di(8,u,u.return),Xd(u);break;case 22:p=u.stateNode,p._visibility&2&&(p._visibility&=-3,Xd(u));break;default:Xd(u)}l=l.sibling}}function Uw(l,u){for(;ds!==null;){var p=ds;switch(p.tag){case 0:case 11:case 15:di(8,p,u);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var g=p.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:kc(p.memoizedState.cache)}if(g=p.child,g!==null)g.return=p,ds=g;else e:for(p=l;ds!==null;){g=ds;var v=g.sibling,A=g.return;if(Dw(g),g===p){ds=null;break e}if(v!==null){v.return=A,ds=v;break e}ds=A}}}var D_={getCacheForType:function(l){var u=bs(ns),p=u.data.get(l);return p===void 0&&(p=l(),u.data.set(l,p)),p},cacheSignal:function(){return bs(ns).controller.signal}},R_=typeof WeakMap=="function"?WeakMap:Map,hn=0,Nn=null,Kt=null,an=0,bn=0,na=null,fi=!1,bl=!1,Pm=!1,Mr=0,Yn=0,pi=0,uo=0,Bm=0,sa=0,xl=0,zc=null,Ws=null,Fm=!1,Jd=0,Hw=0,Zd=1/0,ef=null,hi=null,ls=0,mi=null,yl=null,Dr=0,zm=0,$m=null,Ww=null,$c=0,Um=null;function aa(){return(hn&2)!==0&&an!==0?an&-an:F.T!==null?Gm():ln()}function qw(){if(sa===0)if((an&536870912)===0||cn){var l=ft;ft<<=1,(ft&3932160)===0&&(ft=262144),sa=l}else sa=536870912;return l=ea.current,l!==null&&(l.flags|=32),sa}function qs(l,u,p){(l===Nn&&(bn===2||bn===9)||l.cancelPendingCommit!==null)&&(vl(l,0),gi(l,an,sa,!1)),Oe(l,p),((hn&2)===0||l!==Nn)&&(l===Nn&&((hn&2)===0&&(uo|=p),Yn===4&&gi(l,an,sa,!1)),Qa(l))}function Vw(l,u,p){if((hn&6)!==0)throw Error(s(327));var g=!p&&(u&127)===0&&(u&l.expiredLanes)===0||ht(l,u),v=g?I_(l,u):Wm(l,u,!0),A=g;do{if(v===0){bl&&!g&&gi(l,u,0,!1);break}else{if(p=l.current.alternate,A&&!O_(p)){v=Wm(l,u,!1),A=!1;continue}if(v===2){if(A=u,l.errorRecoveryDisabledLanes&A)var P=0;else P=l.pendingLanes&-536870913,P=P!==0?P:P&536870912?536870912:0;if(P!==0){u=P;e:{var Y=l;v=zc;var ae=Y.current.memoizedState.isDehydrated;if(ae&&(vl(Y,P).flags|=256),P=Wm(Y,P,!1),P!==2){if(Pm&&!ae){Y.errorRecoveryDisabledLanes|=A,uo|=A,v=4;break e}A=Ws,Ws=v,A!==null&&(Ws===null?Ws=A:Ws.push.apply(Ws,A))}v=P}if(A=!1,v!==2)continue}}if(v===1){vl(l,0),gi(l,u,0,!0);break}e:{switch(g=l,A=v,A){case 0:case 1:throw Error(s(345));case 4:if((u&4194048)!==u)break;case 6:gi(g,u,sa,!fi);break e;case 2:Ws=null;break;case 3:case 5:break;default:throw Error(s(329))}if((u&62914560)===u&&(v=Jd+300-ct(),10<v)){if(gi(g,u,sa,!fi),gt(g,0,!0)!==0)break e;Dr=u,g.timeoutHandle=S0(Yw.bind(null,g,p,Ws,ef,Fm,u,sa,uo,xl,fi,A,"Throttled",-0,0),v);break e}Yw(g,p,Ws,ef,Fm,u,sa,uo,xl,fi,A,null,-0,0)}}break}while(!0);Qa(l)}function Yw(l,u,p,g,v,A,P,Y,ae,Me,Ve,Qe,Le,Ue){if(l.timeoutHandle=-1,Qe=u.subtreeFlags,Qe&8192||(Qe&16785408)===16785408){Qe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:It},Fw(u,A,Qe);var yt=(A&62914560)===A?Jd-ct():(A&4194048)===A?Hw-ct():0;if(yt=xE(Qe,yt),yt!==null){Dr=A,l.cancelPendingCommit=yt(t0.bind(null,l,u,A,p,g,v,P,Y,ae,Ve,Qe,null,Le,Ue)),gi(l,A,P,!Me);return}}t0(l,u,A,p,g,v,P,Y,ae)}function O_(l){for(var u=l;;){var p=u.tag;if((p===0||p===11||p===15)&&u.flags&16384&&(p=u.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var g=0;g<p.length;g++){var v=p[g],A=v.getSnapshot;v=v.value;try{if(!Js(A(),v))return!1}catch{return!1}}if(p=u.child,u.subtreeFlags&16384&&p!==null)p.return=u,u=p;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function gi(l,u,p,g){u&=~Bm,u&=~uo,l.suspendedLanes|=u,l.pingedLanes&=~u,g&&(l.warmLanes|=u),g=l.expirationTimes;for(var v=u;0<v;){var A=31-be(v),P=1<<A;g[A]=-1,v&=~P}p!==0&&Ze(l,p,u)}function tf(){return(hn&6)===0?(Uc(0),!1):!0}function Hm(){if(Kt!==null){if(bn===0)var l=Kt.return;else l=Kt,wr=to=null,rm(l),ul=null,Cc=0,l=Kt;for(;l!==null;)Cw(l.alternate,l),l=l.return;Kt=null}}function vl(l,u){var p=l.timeoutHandle;p!==-1&&(l.timeoutHandle=-1,eE(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),Dr=0,Hm(),Nn=l,Kt=p=yr(l.current,null),an=u,bn=0,na=null,fi=!1,bl=ht(l,u),Pm=!1,xl=sa=Bm=uo=pi=Yn=0,Ws=zc=null,Fm=!1,(u&8)!==0&&(u|=u&32);var g=l.entangledLanes;if(g!==0)for(l=l.entanglements,g&=u;0<g;){var v=31-be(g),A=1<<v;u|=l[v],g&=~A}return Mr=u,kd(),p}function Gw(l,u){Ut=null,F.H=Dc,u===cl||u===Ed?(u=uv(),bn=3):u===Yh?(u=uv(),bn=4):bn=u===wm?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,na=u,Kt===null&&(Yn=1,Wd(l,ba(u,l.current)))}function Kw(){var l=ea.current;return l===null?!0:(an&4194048)===an?wa===null:(an&62914560)===an||(an&536870912)!==0?l===wa:!1}function Qw(){var l=F.H;return F.H=Dc,l===null?Dc:l}function Xw(){var l=F.A;return F.A=D_,l}function nf(){Yn=4,fi||(an&4194048)!==an&&ea.current!==null||(bl=!0),(pi&134217727)===0&&(uo&134217727)===0||Nn===null||gi(Nn,an,sa,!1)}function Wm(l,u,p){var g=hn;hn|=2;var v=Qw(),A=Xw();(Nn!==l||an!==u)&&(ef=null,vl(l,u)),u=!1;var P=Yn;e:do try{if(bn!==0&&Kt!==null){var Y=Kt,ae=na;switch(bn){case 8:Hm(),P=6;break e;case 3:case 2:case 9:case 6:ea.current===null&&(u=!0);var Me=bn;if(bn=0,na=null,wl(l,Y,ae,Me),p&&bl){P=0;break e}break;default:Me=bn,bn=0,na=null,wl(l,Y,ae,Me)}}L_(),P=Yn;break}catch(Ve){Gw(l,Ve)}while(!0);return u&&l.shellSuspendCounter++,wr=to=null,hn=g,F.H=v,F.A=A,Kt===null&&(Nn=null,an=0,kd()),P}function L_(){for(;Kt!==null;)Jw(Kt)}function I_(l,u){var p=hn;hn|=2;var g=Qw(),v=Xw();Nn!==l||an!==u?(ef=null,Zd=ct()+500,vl(l,u)):bl=ht(l,u);e:do try{if(bn!==0&&Kt!==null){u=Kt;var A=na;t:switch(bn){case 1:bn=0,na=null,wl(l,u,A,1);break;case 2:case 9:if(lv(A)){bn=0,na=null,Zw(u);break}u=function(){bn!==2&&bn!==9||Nn!==l||(bn=7),Qa(l)},A.then(u,u);break e;case 3:bn=7;break e;case 4:bn=5;break e;case 7:lv(A)?(bn=0,na=null,Zw(u)):(bn=0,na=null,wl(l,u,A,7));break;case 5:var P=null;switch(Kt.tag){case 26:P=Kt.memoizedState;case 5:case 27:var Y=Kt;if(P?B0(P):Y.stateNode.complete){bn=0,na=null;var ae=Y.sibling;if(ae!==null)Kt=ae;else{var Me=Y.return;Me!==null?(Kt=Me,sf(Me)):Kt=null}break t}}bn=0,na=null,wl(l,u,A,5);break;case 6:bn=0,na=null,wl(l,u,A,6);break;case 8:Hm(),Yn=6;break e;default:throw Error(s(462))}}P_();break}catch(Ve){Gw(l,Ve)}while(!0);return wr=to=null,F.H=g,F.A=v,hn=p,Kt!==null?0:(Nn=null,an=0,kd(),Yn)}function P_(){for(;Kt!==null&&!He();)Jw(Kt)}function Jw(l){var u=kw(l.alternate,l,Mr);l.memoizedProps=l.pendingProps,u===null?sf(l):Kt=u}function Zw(l){var u=l,p=u.alternate;switch(u.tag){case 15:case 0:u=gw(p,u,u.pendingProps,u.type,void 0,an);break;case 11:u=gw(p,u,u.pendingProps,u.type.render,u.ref,an);break;case 5:rm(u);default:Cw(p,u),u=Kt=Xy(u,Mr),u=kw(p,u,Mr)}l.memoizedProps=l.pendingProps,u===null?sf(l):Kt=u}function wl(l,u,p,g){wr=to=null,rm(u),ul=null,Cc=0;var v=u.return;try{if(A_(l,v,u,p,an)){Yn=1,Wd(l,ba(p,l.current)),Kt=null;return}}catch(A){if(v!==null)throw Kt=v,A;Yn=1,Wd(l,ba(p,l.current)),Kt=null;return}u.flags&32768?(cn||g===1?l=!0:bl||(an&536870912)!==0?l=!1:(fi=l=!0,(g===2||g===9||g===3||g===6)&&(g=ea.current,g!==null&&g.tag===13&&(g.flags|=16384))),e0(u,l)):sf(u)}function sf(l){var u=l;do{if((u.flags&32768)!==0){e0(u,fi);return}l=u.return;var p=T_(u.alternate,u,Mr);if(p!==null){Kt=p;return}if(u=u.sibling,u!==null){Kt=u;return}Kt=u=l}while(u!==null);Yn===0&&(Yn=5)}function e0(l,u){do{var p=__(l.alternate,l);if(p!==null){p.flags&=32767,Kt=p;return}if(p=l.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!u&&(l=l.sibling,l!==null)){Kt=l;return}Kt=l=p}while(l!==null);Yn=6,Kt=null}function t0(l,u,p,g,v,A,P,Y,ae){l.cancelPendingCommit=null;do af();while(ls!==0);if((hn&6)!==0)throw Error(s(327));if(u!==null){if(u===l.current)throw Error(s(177));if(A=u.lanes|u.childLanes,A|=Dh,Ye(l,p,A,P,Y,ae),l===Nn&&(Kt=Nn=null,an=0),yl=u,mi=l,Dr=p,zm=A,$m=v,Ww=g,(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,$_(Se,function(){return i0(),null})):(l.callbackNode=null,l.callbackPriority=0),g=(u.flags&13878)!==0,(u.subtreeFlags&13878)!==0||g){g=F.T,F.T=null,v=H.p,H.p=2,P=hn,hn|=4;try{E_(l,u,p)}finally{hn=P,H.p=v,F.T=g}}ls=1,n0(),s0(),a0()}}function n0(){if(ls===1){ls=0;var l=mi,u=yl,p=(u.flags&13878)!==0;if((u.subtreeFlags&13878)!==0||p){p=F.T,F.T=null;var g=H.p;H.p=2;var v=hn;hn|=4;try{Iw(u,l);var A=ng,P=Uy(l.containerInfo),Y=A.focusedElem,ae=A.selectionRange;if(P!==Y&&Y&&Y.ownerDocument&&$y(Y.ownerDocument.documentElement,Y)){if(ae!==null&&Nh(Y)){var Me=ae.start,Ve=ae.end;if(Ve===void 0&&(Ve=Me),"selectionStart"in Y)Y.selectionStart=Me,Y.selectionEnd=Math.min(Ve,Y.value.length);else{var Qe=Y.ownerDocument||document,Le=Qe&&Qe.defaultView||window;if(Le.getSelection){var Ue=Le.getSelection(),yt=Y.textContent.length,Dt=Math.min(ae.start,yt),An=ae.end===void 0?Dt:Math.min(ae.end,yt);!Ue.extend&&Dt>An&&(P=An,An=Dt,Dt=P);var ke=zy(Y,Dt),oe=zy(Y,An);if(ke&&oe&&(Ue.rangeCount!==1||Ue.anchorNode!==ke.node||Ue.anchorOffset!==ke.offset||Ue.focusNode!==oe.node||Ue.focusOffset!==oe.offset)){var _e=Qe.createRange();_e.setStart(ke.node,ke.offset),Ue.removeAllRanges(),Dt>An?(Ue.addRange(_e),Ue.extend(oe.node,oe.offset)):(_e.setEnd(oe.node,oe.offset),Ue.addRange(_e))}}}}for(Qe=[],Ue=Y;Ue=Ue.parentNode;)Ue.nodeType===1&&Qe.push({element:Ue,left:Ue.scrollLeft,top:Ue.scrollTop});for(typeof Y.focus=="function"&&Y.focus(),Y=0;Y<Qe.length;Y++){var Ge=Qe[Y];Ge.element.scrollLeft=Ge.left,Ge.element.scrollTop=Ge.top}}bf=!!tg,ng=tg=null}finally{hn=v,H.p=g,F.T=p}}l.current=u,ls=2}}function s0(){if(ls===2){ls=0;var l=mi,u=yl,p=(u.flags&8772)!==0;if((u.subtreeFlags&8772)!==0||p){p=F.T,F.T=null;var g=H.p;H.p=2;var v=hn;hn|=4;try{Mw(l,u.alternate,u)}finally{hn=v,H.p=g,F.T=p}}ls=3}}function a0(){if(ls===4||ls===3){ls=0,et();var l=mi,u=yl,p=Dr,g=Ww;(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?ls=5:(ls=0,yl=mi=null,r0(l,l.pendingLanes));var v=l.pendingLanes;if(v===0&&(hi=null),Vt(p),u=u.stateNode,Ie&&typeof Ie.onCommitFiberRoot=="function")try{Ie.onCommitFiberRoot(ye,u,void 0,(u.current.flags&128)===128)}catch{}if(g!==null){u=F.T,v=H.p,H.p=2,F.T=null;try{for(var A=l.onRecoverableError,P=0;P<g.length;P++){var Y=g[P];A(Y.value,{componentStack:Y.stack})}}finally{F.T=u,H.p=v}}(Dr&3)!==0&&af(),Qa(l),v=l.pendingLanes,(p&261930)!==0&&(v&42)!==0?l===Um?$c++:($c=0,Um=l):$c=0,Uc(0)}}function r0(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,kc(u)))}function af(){return n0(),s0(),a0(),i0()}function i0(){if(ls!==5)return!1;var l=mi,u=zm;zm=0;var p=Vt(Dr),g=F.T,v=H.p;try{H.p=32>p?32:p,F.T=null,p=$m,$m=null;var A=mi,P=Dr;if(ls=0,yl=mi=null,Dr=0,(hn&6)!==0)throw Error(s(331));var Y=hn;if(hn|=4,$w(A.current),Bw(A,A.current,P,p),hn=Y,Uc(0,!1),Ie&&typeof Ie.onPostCommitFiberRoot=="function")try{Ie.onPostCommitFiberRoot(ye,A)}catch{}return!0}finally{H.p=v,F.T=g,r0(l,u)}}function o0(l,u,p){u=ba(p,u),u=vm(l.stateNode,u,2),l=li(l,u,2),l!==null&&(Oe(l,2),Qa(l))}function xn(l,u,p){if(l.tag===3)o0(l,l,p);else for(;u!==null;){if(u.tag===3){o0(u,l,p);break}else if(u.tag===1){var g=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(hi===null||!hi.has(g))){l=ba(p,l),p=lw(2),g=li(u,p,2),g!==null&&(cw(p,g,u,l),Oe(g,2),Qa(g));break}}u=u.return}}function qm(l,u,p){var g=l.pingCache;if(g===null){g=l.pingCache=new R_;var v=new Set;g.set(u,v)}else v=g.get(u),v===void 0&&(v=new Set,g.set(u,v));v.has(p)||(Pm=!0,v.add(p),l=B_.bind(null,l,u,p),u.then(l,l))}function B_(l,u,p){var g=l.pingCache;g!==null&&g.delete(u),l.pingedLanes|=l.suspendedLanes&p,l.warmLanes&=~p,Nn===l&&(an&p)===p&&(Yn===4||Yn===3&&(an&62914560)===an&&300>ct()-Jd?(hn&2)===0&&vl(l,0):Bm|=p,xl===an&&(xl=0)),Qa(l)}function l0(l,u){u===0&&(u=tn()),l=Ji(l,u),l!==null&&(Oe(l,u),Qa(l))}function F_(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),l0(l,p)}function z_(l,u){var p=0;switch(l.tag){case 31:case 13:var g=l.stateNode,v=l.memoizedState;v!==null&&(p=v.retryLane);break;case 19:g=l.stateNode;break;case 22:g=l.stateNode._retryCache;break;default:throw Error(s(314))}g!==null&&g.delete(u),l0(l,p)}function $_(l,u){return ie(l,u)}var rf=null,kl=null,Vm=!1,of=!1,Ym=!1,bi=0;function Qa(l){l!==kl&&l.next===null&&(kl===null?rf=kl=l:kl=kl.next=l),of=!0,Vm||(Vm=!0,H_())}function Uc(l,u){if(!Ym&&of){Ym=!0;do for(var p=!1,g=rf;g!==null;){if(l!==0){var v=g.pendingLanes;if(v===0)var A=0;else{var P=g.suspendedLanes,Y=g.pingedLanes;A=(1<<31-be(42|l)+1)-1,A&=v&~(P&~Y),A=A&201326741?A&201326741|1:A?A|2:0}A!==0&&(p=!0,f0(g,A))}else A=an,A=gt(g,g===Nn?A:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(A&3)===0||ht(g,A)||(p=!0,f0(g,A));g=g.next}while(p);Ym=!1}}function U_(){c0()}function c0(){of=Vm=!1;var l=0;bi!==0&&Z_()&&(l=bi);for(var u=ct(),p=null,g=rf;g!==null;){var v=g.next,A=u0(g,u);A===0?(g.next=null,p===null?rf=v:p.next=v,v===null&&(kl=p)):(p=g,(l!==0||(A&3)!==0)&&(of=!0)),g=v}ls!==0&&ls!==5||Uc(l),bi!==0&&(bi=0)}function u0(l,u){for(var p=l.suspendedLanes,g=l.pingedLanes,v=l.expirationTimes,A=l.pendingLanes&-62914561;0<A;){var P=31-be(A),Y=1<<P,ae=v[P];ae===-1?((Y&p)===0||(Y&g)!==0)&&(v[P]=Gt(Y,u)):ae<=u&&(l.expiredLanes|=Y),A&=~Y}if(u=Nn,p=an,p=gt(l,l===u?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g=l.callbackNode,p===0||l===u&&(bn===2||bn===9)||l.cancelPendingCommit!==null)return g!==null&&g!==null&&de(g),l.callbackNode=null,l.callbackPriority=0;if((p&3)===0||ht(l,p)){if(u=p&-p,u===l.callbackPriority)return u;switch(g!==null&&de(g),Vt(p)){case 2:case 8:p=se;break;case 32:p=Se;break;case 268435456:p=pe;break;default:p=Se}return g=d0.bind(null,l),p=ie(p,g),l.callbackPriority=u,l.callbackNode=p,u}return g!==null&&g!==null&&de(g),l.callbackPriority=2,l.callbackNode=null,2}function d0(l,u){if(ls!==0&&ls!==5)return l.callbackNode=null,l.callbackPriority=0,null;var p=l.callbackNode;if(af()&&l.callbackNode!==p)return null;var g=an;return g=gt(l,l===Nn?g:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),g===0?null:(Vw(l,g,u),u0(l,ct()),l.callbackNode!=null&&l.callbackNode===p?d0.bind(null,l):null)}function f0(l,u){if(af())return null;Vw(l,u,!0)}function H_(){tE(function(){(hn&6)!==0?ie(X,U_):c0()})}function Gm(){if(bi===0){var l=ol;l===0&&(l=st,st<<=1,(st&261888)===0&&(st=256)),bi=l}return bi}function p0(l){return l==null||typeof l=="symbol"||typeof l=="boolean"?null:typeof l=="function"?l:Fo(""+l)}function h0(l,u){var p=u.ownerDocument.createElement("input");return p.name=u.name,p.value=u.value,l.id&&p.setAttribute("form",l.id),u.parentNode.insertBefore(p,u),l=new FormData(l),p.parentNode.removeChild(p),l}function W_(l,u,p,g,v){if(u==="submit"&&p&&p.stateNode===v){var A=p0((v[$t]||null).action),P=g.submitter;P&&(u=(u=P[$t]||null)?p0(u.formAction):P.getAttribute("formAction"),u!==null&&(A=u,P=null));var Y=new Ln("action","action",null,g,v);l.push({event:Y,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(bi!==0){var ae=P?h0(v,P):new FormData(v);hm(p,{pending:!0,data:ae,method:v.method,action:A},null,ae)}}else typeof A=="function"&&(Y.preventDefault(),ae=P?h0(v,P):new FormData(v),hm(p,{pending:!0,data:ae,method:v.method,action:A},A,ae))},currentTarget:v}]})}}for(var Km=0;Km<Mh.length;Km++){var Qm=Mh[Km],q_=Qm.toLowerCase(),V_=Qm[0].toUpperCase()+Qm.slice(1);Da(q_,"on"+V_)}Da(qy,"onAnimationEnd"),Da(Vy,"onAnimationIteration"),Da(Yy,"onAnimationStart"),Da("dblclick","onDoubleClick"),Da("focusin","onFocus"),Da("focusout","onBlur"),Da(l_,"onTransitionRun"),Da(c_,"onTransitionStart"),Da(u_,"onTransitionCancel"),Da(Gy,"onTransitionEnd"),Ua("onMouseEnter",["mouseout","mouseover"]),Ua("onMouseLeave",["mouseout","mouseover"]),Ua("onPointerEnter",["pointerout","pointerover"]),Ua("onPointerLeave",["pointerout","pointerover"]),Ps("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ps("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ps("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ps("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ps("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ps("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Hc="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(" "),Y_=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Hc));function m0(l,u){u=(u&4)!==0;for(var p=0;p<l.length;p++){var g=l[p],v=g.event;g=g.listeners;e:{var A=void 0;if(u)for(var P=g.length-1;0<=P;P--){var Y=g[P],ae=Y.instance,Me=Y.currentTarget;if(Y=Y.listener,ae!==A&&v.isPropagationStopped())break e;A=Y,v.currentTarget=Me;try{A(v)}catch(Ve){wd(Ve)}v.currentTarget=null,A=ae}else for(P=0;P<g.length;P++){if(Y=g[P],ae=Y.instance,Me=Y.currentTarget,Y=Y.listener,ae!==A&&v.isPropagationStopped())break e;A=Y,v.currentTarget=Me;try{A(v)}catch(Ve){wd(Ve)}v.currentTarget=null,A=ae}}}}function Qt(l,u){var p=u[nn];p===void 0&&(p=u[nn]=new Set);var g=l+"__bubble";p.has(g)||(g0(u,l,2,!1),p.add(g))}function Xm(l,u,p){var g=0;u&&(g|=4),g0(p,l,g,u)}var lf="_reactListening"+Math.random().toString(36).slice(2);function Jm(l){if(!l[lf]){l[lf]=!0,Po.forEach(function(p){p!=="selectionchange"&&(Y_.has(p)||Xm(p,!1,l),Xm(p,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[lf]||(u[lf]=!0,Xm("selectionchange",!1,u))}}function g0(l,u,p,g){switch(q0(u)){case 2:var v=wE;break;case 8:v=kE;break;default:v=pg}p=v.bind(null,u,p,l),v=void 0,!Hi||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(v=!0),g?v!==void 0?l.addEventListener(u,p,{capture:!0,passive:v}):l.addEventListener(u,p,!0):v!==void 0?l.addEventListener(u,p,{passive:v}):l.addEventListener(u,p,!1)}function Zm(l,u,p,g,v){var A=g;if((u&1)===0&&(u&2)===0&&g!==null)e:for(;;){if(g===null)return;var P=g.tag;if(P===3||P===4){var Y=g.stateNode.containerInfo;if(Y===v)break;if(P===4)for(P=g.return;P!==null;){var ae=P.tag;if((ae===3||ae===4)&&P.stateNode.containerInfo===v)return;P=P.return}for(;Y!==null;){if(P=Ss(Y),P===null)return;if(ae=P.tag,ae===5||ae===6||ae===26||ae===27){g=A=P;continue e}Y=Y.parentNode}}g=g.return}cd(function(){var Me=A,Ve=uc(p),Qe=[];e:{var Le=Ky.get(l);if(Le!==void 0){var Ue=Ln,yt=l;switch(l){case"keypress":if(Wi(p)===0)break e;case"keydown":case"keyup":Ue=kh;break;case"focusin":yt="focus",Ue=ei;break;case"focusout":yt="blur",Ue=ei;break;case"beforeblur":case"afterblur":Ue=ei;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ue=fd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ue=Vo;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ue=bd;break;case qy:case Vy:case Yy:Ue=fc;break;case Gy:Ue=hc;break;case"scroll":case"scrollend":Ue=dd;break;case"wheel":Ue=Ch;break;case"copy":case"cut":case"paste":Ue=pc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ue=qa;break;case"toggle":case"beforetoggle":Ue=jh}var Dt=(u&4)!==0,An=!Dt&&(l==="scroll"||l==="scrollend"),ke=Dt?Le!==null?Le+"Capture":null:Le;Dt=[];for(var oe=Me,_e;oe!==null;){var Ge=oe;if(_e=Ge.stateNode,Ge=Ge.tag,Ge!==5&&Ge!==26&&Ge!==27||_e===null||ke===null||(Ge=Ha(oe,ke),Ge!=null&&Dt.push(Wc(oe,Ge,_e))),An)break;oe=oe.return}0<Dt.length&&(Le=new Ue(Le,yt,null,p,Ve),Qe.push({event:Le,listeners:Dt}))}}if((u&7)===0){e:{if(Le=l==="mouseover"||l==="pointerover",Ue=l==="mouseout"||l==="pointerout",Le&&p!==Hn&&(yt=p.relatedTarget||p.fromElement)&&(Ss(yt)||yt[En]))break e;if((Ue||Le)&&(Le=Ve.window===Ve?Ve:(Le=Ve.ownerDocument)?Le.defaultView||Le.parentWindow:window,Ue?(yt=p.relatedTarget||p.toElement,Ue=Me,yt=yt?Ss(yt):null,yt!==null&&(An=r(yt),Dt=yt.tag,yt!==An||Dt!==5&&Dt!==27&&Dt!==6)&&(yt=null)):(Ue=null,yt=Me),Ue!==yt)){if(Dt=fd,Ge="onMouseLeave",ke="onMouseEnter",oe="mouse",(l==="pointerout"||l==="pointerover")&&(Dt=qa,Ge="onPointerLeave",ke="onPointerEnter",oe="pointer"),An=Ue==null?Le:Ls(Ue),_e=yt==null?Le:Ls(yt),Le=new Dt(Ge,oe+"leave",Ue,p,Ve),Le.target=An,Le.relatedTarget=_e,Ge=null,Ss(Ve)===Me&&(Dt=new Dt(ke,oe+"enter",yt,p,Ve),Dt.target=_e,Dt.relatedTarget=An,Ge=Dt),An=Ge,Ue&&yt)t:{for(Dt=G_,ke=Ue,oe=yt,_e=0,Ge=ke;Ge;Ge=Dt(Ge))_e++;Ge=0;for(var Tt=oe;Tt;Tt=Dt(Tt))Ge++;for(;0<_e-Ge;)ke=Dt(ke),_e--;for(;0<Ge-_e;)oe=Dt(oe),Ge--;for(;_e--;){if(ke===oe||oe!==null&&ke===oe.alternate){Dt=ke;break t}ke=Dt(ke),oe=Dt(oe)}Dt=null}else Dt=null;Ue!==null&&b0(Qe,Le,Ue,Dt,!1),yt!==null&&An!==null&&b0(Qe,An,yt,Dt,!0)}}e:{if(Le=Me?Ls(Me):window,Ue=Le.nodeName&&Le.nodeName.toLowerCase(),Ue==="select"||Ue==="input"&&Le.type==="file")var fn=gc;else if(sn(Le))if(Xo)fn=r_;else{fn=s_;var kt=n_}else Ue=Le.nodeName,!Ue||Ue.toLowerCase()!=="input"||Le.type!=="checkbox"&&Le.type!=="radio"?Me&&gr(Me.elementType)&&(fn=gc):fn=a_;if(fn&&(fn=fn(l,Me))){gn(Qe,fn,p,Ve);break e}kt&&kt(l,Le,Me),l==="focusout"&&Me&&Le.type==="number"&&Me.memoizedProps.value!=null&&ms(Le,"number",Le.value)}switch(kt=Me?Ls(Me):window,l){case"focusin":(sn(kt)||kt.contentEditable==="true")&&(Zo=kt,Th=Me,yc=null);break;case"focusout":yc=Th=Zo=null;break;case"mousedown":_h=!0;break;case"contextmenu":case"mouseup":case"dragend":_h=!1,Hy(Qe,p,Ve);break;case"selectionchange":if(o_)break;case"keydown":case"keyup":Hy(Qe,p,Ve)}var Ht;if(Ko)e:{switch(l){case"compositionstart":var rn="onCompositionStart";break e;case"compositionend":rn="onCompositionEnd";break e;case"compositionupdate":rn="onCompositionUpdate";break e}rn=void 0}else nt?le(l,p)&&(rn="onCompositionEnd"):l==="keydown"&&p.keyCode===229&&(rn="onCompositionStart");rn&&(mc&&p.locale!=="ko"&&(nt||rn!=="onCompositionStart"?rn==="onCompositionEnd"&&nt&&(Ht=ud()):(ma=Ve,$o="value"in ma?ma.value:ma.textContent,nt=!0)),kt=cf(Me,rn),0<kt.length&&(rn=new hd(rn,l,null,p,Ve),Qe.push({event:rn,listeners:kt}),Ht?rn.data=Ht:(Ht=Ee(p),Ht!==null&&(rn.data=Ht)))),(Ht=yd?ut(l,p):Nt(l,p))&&(rn=cf(Me,"onBeforeInput"),0<rn.length&&(kt=new hd("onBeforeInput","beforeinput",null,p,Ve),Qe.push({event:kt,listeners:rn}),kt.data=Ht)),W_(Qe,l,Me,p,Ve)}m0(Qe,u)})}function Wc(l,u,p){return{instance:l,listener:u,currentTarget:p}}function cf(l,u){for(var p=u+"Capture",g=[];l!==null;){var v=l,A=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||A===null||(v=Ha(l,p),v!=null&&g.unshift(Wc(l,v,A)),v=Ha(l,u),v!=null&&g.push(Wc(l,v,A))),l.tag===3)return g;l=l.return}return[]}function G_(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5&&l.tag!==27);return l||null}function b0(l,u,p,g,v){for(var A=u._reactName,P=[];p!==null&&p!==g;){var Y=p,ae=Y.alternate,Me=Y.stateNode;if(Y=Y.tag,ae!==null&&ae===g)break;Y!==5&&Y!==26&&Y!==27||Me===null||(ae=Me,v?(Me=Ha(p,A),Me!=null&&P.unshift(Wc(p,Me,ae))):v||(Me=Ha(p,A),Me!=null&&P.push(Wc(p,Me,ae)))),p=p.return}P.length!==0&&l.push({event:u,listeners:P})}var K_=/\r\n?/g,Q_=/\u0000|\uFFFD/g;function x0(l){return(typeof l=="string"?l:""+l).replace(K_,`
|
|
34
|
+
`).replace(Q_,"")}function y0(l,u){return u=x0(u),x0(l)===u}function Cn(l,u,p,g,v,A){switch(p){case"children":typeof g=="string"?u==="body"||u==="textarea"&&g===""||pa(l,g):(typeof g=="number"||typeof g=="bigint")&&u!=="body"&&pa(l,""+g);break;case"className":Ts(l,"class",g);break;case"tabIndex":Ts(l,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Ts(l,p,g);break;case"style":$i(l,g,A);break;case"data":if(u!=="object"){Ts(l,"data",g);break}case"src":case"href":if(g===""&&(u!=="a"||p!=="href")){l.removeAttribute(p);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){l.removeAttribute(p);break}g=Fo(""+g),l.setAttribute(p,g);break;case"action":case"formAction":if(typeof g=="function"){l.setAttribute(p,"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 A=="function"&&(p==="formAction"?(u!=="input"&&Cn(l,u,"name",v.name,v,null),Cn(l,u,"formEncType",v.formEncType,v,null),Cn(l,u,"formMethod",v.formMethod,v,null),Cn(l,u,"formTarget",v.formTarget,v,null)):(Cn(l,u,"encType",v.encType,v,null),Cn(l,u,"method",v.method,v,null),Cn(l,u,"target",v.target,v,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){l.removeAttribute(p);break}g=Fo(""+g),l.setAttribute(p,g);break;case"onClick":g!=null&&(l.onclick=It);break;case"onScroll":g!=null&&Qt("scroll",l);break;case"onScrollEnd":g!=null&&Qt("scrollend",l);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(s(61));if(p=g.__html,p!=null){if(v.children!=null)throw Error(s(60));l.innerHTML=p}}break;case"multiple":l.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":l.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){l.removeAttribute("xlink:href");break}p=Fo(""+g),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",p);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,""+g):l.removeAttribute(p);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":g&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,""):l.removeAttribute(p);break;case"capture":case"download":g===!0?l.setAttribute(p,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?l.setAttribute(p,g):l.removeAttribute(p);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?l.setAttribute(p,g):l.removeAttribute(p);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?l.removeAttribute(p):l.setAttribute(p,g);break;case"popover":Qt("beforetoggle",l),Qt("toggle",l),Ma(l,"popover",g);break;case"xlinkActuate":hs(l,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":hs(l,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":hs(l,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":hs(l,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":hs(l,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":hs(l,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":hs(l,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":hs(l,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":hs(l,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":Ma(l,"is",g);break;case"innerText":case"textContent":break;default:(!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(p=Ui.get(p)||p,Ma(l,p,g))}}function eg(l,u,p,g,v,A){switch(p){case"style":$i(l,g,A);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(s(61));if(p=g.__html,p!=null){if(v.children!=null)throw Error(s(60));l.innerHTML=p}}break;case"children":typeof g=="string"?pa(l,g):(typeof g=="number"||typeof g=="bigint")&&pa(l,""+g);break;case"onScroll":g!=null&&Qt("scroll",l);break;case"onScrollEnd":g!=null&&Qt("scrollend",l);break;case"onClick":g!=null&&(l.onclick=It);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Bo.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(v=p.endsWith("Capture"),u=p.slice(2,v?p.length-7:void 0),A=l[$t]||null,A=A!=null?A[p]:null,typeof A=="function"&&l.removeEventListener(u,A,v),typeof g=="function")){typeof A!="function"&&A!==null&&(p in l?l[p]=null:l.hasAttribute(p)&&l.removeAttribute(p)),l.addEventListener(u,g,v);break e}p in l?l[p]=g:g===!0?l.setAttribute(p,""):Ma(l,p,g)}}}function ys(l,u,p){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Qt("error",l),Qt("load",l);var g=!1,v=!1,A;for(A in p)if(p.hasOwnProperty(A)){var P=p[A];if(P!=null)switch(A){case"src":g=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,u));default:Cn(l,u,A,P,p,null)}}v&&Cn(l,u,"srcSet",p.srcSet,p,null),g&&Cn(l,u,"src",p.src,p,null);return;case"input":Qt("invalid",l);var Y=A=P=v=null,ae=null,Me=null;for(g in p)if(p.hasOwnProperty(g)){var Ve=p[g];if(Ve!=null)switch(g){case"name":v=Ve;break;case"type":P=Ve;break;case"checked":ae=Ve;break;case"defaultChecked":Me=Ve;break;case"value":A=Ve;break;case"defaultValue":Y=Ve;break;case"children":case"dangerouslySetInnerHTML":if(Ve!=null)throw Error(s(137,u));break;default:Cn(l,u,g,Ve,p,null)}}kn(l,A,Y,ae,Me,P,v,!1);return;case"select":Qt("invalid",l),g=P=A=null;for(v in p)if(p.hasOwnProperty(v)&&(Y=p[v],Y!=null))switch(v){case"value":A=Y;break;case"defaultValue":P=Y;break;case"multiple":g=Y;default:Cn(l,u,v,Y,p,null)}u=A,p=P,l.multiple=!!g,u!=null?Dn(l,!!g,u,!1):p!=null&&Dn(l,!!g,p,!0);return;case"textarea":Qt("invalid",l),A=v=g=null;for(P in p)if(p.hasOwnProperty(P)&&(Y=p[P],Y!=null))switch(P){case"value":g=Y;break;case"defaultValue":v=Y;break;case"children":A=Y;break;case"dangerouslySetInnerHTML":if(Y!=null)throw Error(s(91));break;default:Cn(l,u,P,Y,p,null)}Qr(l,g,v,A);return;case"option":for(ae in p)if(p.hasOwnProperty(ae)&&(g=p[ae],g!=null))switch(ae){case"selected":l.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:Cn(l,u,ae,g,p,null)}return;case"dialog":Qt("beforetoggle",l),Qt("toggle",l),Qt("cancel",l),Qt("close",l);break;case"iframe":case"object":Qt("load",l);break;case"video":case"audio":for(g=0;g<Hc.length;g++)Qt(Hc[g],l);break;case"image":Qt("error",l),Qt("load",l);break;case"details":Qt("toggle",l);break;case"embed":case"source":case"link":Qt("error",l),Qt("load",l);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Me in p)if(p.hasOwnProperty(Me)&&(g=p[Me],g!=null))switch(Me){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,u));default:Cn(l,u,Me,g,p,null)}return;default:if(gr(u)){for(Ve in p)p.hasOwnProperty(Ve)&&(g=p[Ve],g!==void 0&&eg(l,u,Ve,g,p,void 0));return}}for(Y in p)p.hasOwnProperty(Y)&&(g=p[Y],g!=null&&Cn(l,u,Y,g,p,null))}function X_(l,u,p,g){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var v=null,A=null,P=null,Y=null,ae=null,Me=null,Ve=null;for(Ue in p){var Qe=p[Ue];if(p.hasOwnProperty(Ue)&&Qe!=null)switch(Ue){case"checked":break;case"value":break;case"defaultValue":ae=Qe;default:g.hasOwnProperty(Ue)||Cn(l,u,Ue,null,g,Qe)}}for(var Le in g){var Ue=g[Le];if(Qe=p[Le],g.hasOwnProperty(Le)&&(Ue!=null||Qe!=null))switch(Le){case"type":A=Ue;break;case"name":v=Ue;break;case"checked":Me=Ue;break;case"defaultChecked":Ve=Ue;break;case"value":P=Ue;break;case"defaultValue":Y=Ue;break;case"children":case"dangerouslySetInnerHTML":if(Ue!=null)throw Error(s(137,u));break;default:Ue!==Qe&&Cn(l,u,Le,Ue,g,Qe)}}At(l,P,Y,ae,Me,Ve,A,v);return;case"select":Ue=P=Y=Le=null;for(A in p)if(ae=p[A],p.hasOwnProperty(A)&&ae!=null)switch(A){case"value":break;case"multiple":Ue=ae;default:g.hasOwnProperty(A)||Cn(l,u,A,null,g,ae)}for(v in g)if(A=g[v],ae=p[v],g.hasOwnProperty(v)&&(A!=null||ae!=null))switch(v){case"value":Le=A;break;case"defaultValue":Y=A;break;case"multiple":P=A;default:A!==ae&&Cn(l,u,v,A,g,ae)}u=Y,p=P,g=Ue,Le!=null?Dn(l,!!p,Le,!1):!!g!=!!p&&(u!=null?Dn(l,!!p,u,!0):Dn(l,!!p,p?[]:"",!1));return;case"textarea":Ue=Le=null;for(Y in p)if(v=p[Y],p.hasOwnProperty(Y)&&v!=null&&!g.hasOwnProperty(Y))switch(Y){case"value":break;case"children":break;default:Cn(l,u,Y,null,g,v)}for(P in g)if(v=g[P],A=p[P],g.hasOwnProperty(P)&&(v!=null||A!=null))switch(P){case"value":Le=v;break;case"defaultValue":Ue=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(s(91));break;default:v!==A&&Cn(l,u,P,v,g,A)}Fs(l,Le,Ue);return;case"option":for(var yt in p)if(Le=p[yt],p.hasOwnProperty(yt)&&Le!=null&&!g.hasOwnProperty(yt))switch(yt){case"selected":l.selected=!1;break;default:Cn(l,u,yt,null,g,Le)}for(ae in g)if(Le=g[ae],Ue=p[ae],g.hasOwnProperty(ae)&&Le!==Ue&&(Le!=null||Ue!=null))switch(ae){case"selected":l.selected=Le&&typeof Le!="function"&&typeof Le!="symbol";break;default:Cn(l,u,ae,Le,g,Ue)}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 Dt in p)Le=p[Dt],p.hasOwnProperty(Dt)&&Le!=null&&!g.hasOwnProperty(Dt)&&Cn(l,u,Dt,null,g,Le);for(Me in g)if(Le=g[Me],Ue=p[Me],g.hasOwnProperty(Me)&&Le!==Ue&&(Le!=null||Ue!=null))switch(Me){case"children":case"dangerouslySetInnerHTML":if(Le!=null)throw Error(s(137,u));break;default:Cn(l,u,Me,Le,g,Ue)}return;default:if(gr(u)){for(var An in p)Le=p[An],p.hasOwnProperty(An)&&Le!==void 0&&!g.hasOwnProperty(An)&&eg(l,u,An,void 0,g,Le);for(Ve in g)Le=g[Ve],Ue=p[Ve],!g.hasOwnProperty(Ve)||Le===Ue||Le===void 0&&Ue===void 0||eg(l,u,Ve,Le,g,Ue);return}}for(var ke in p)Le=p[ke],p.hasOwnProperty(ke)&&Le!=null&&!g.hasOwnProperty(ke)&&Cn(l,u,ke,null,g,Le);for(Qe in g)Le=g[Qe],Ue=p[Qe],!g.hasOwnProperty(Qe)||Le===Ue||Le==null&&Ue==null||Cn(l,u,Qe,Le,g,Ue)}function v0(l){switch(l){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function J_(){if(typeof performance.getEntriesByType=="function"){for(var l=0,u=0,p=performance.getEntriesByType("resource"),g=0;g<p.length;g++){var v=p[g],A=v.transferSize,P=v.initiatorType,Y=v.duration;if(A&&Y&&v0(P)){for(P=0,Y=v.responseEnd,g+=1;g<p.length;g++){var ae=p[g],Me=ae.startTime;if(Me>Y)break;var Ve=ae.transferSize,Qe=ae.initiatorType;Ve&&v0(Qe)&&(ae=ae.responseEnd,P+=Ve*(ae<Y?1:(Y-Me)/(ae-Me)))}if(--g,u+=8*(A+P)/(v.duration/1e3),l++,10<l)break}}if(0<l)return u/l/1e6}return navigator.connection&&(l=navigator.connection.downlink,typeof l=="number")?l:5}var tg=null,ng=null;function uf(l){return l.nodeType===9?l:l.ownerDocument}function w0(l){switch(l){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function k0(l,u){if(l===0)switch(u){case"svg":return 1;case"math":return 2;default:return 0}return l===1&&u==="foreignObject"?0:l}function sg(l,u){return l==="textarea"||l==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.children=="bigint"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var ag=null;function Z_(){var l=window.event;return l&&l.type==="popstate"?l===ag?!1:(ag=l,!0):(ag=null,!1)}var S0=typeof setTimeout=="function"?setTimeout:void 0,eE=typeof clearTimeout=="function"?clearTimeout:void 0,C0=typeof Promise=="function"?Promise:void 0,tE=typeof queueMicrotask=="function"?queueMicrotask:typeof C0<"u"?function(l){return C0.resolve(null).then(l).catch(nE)}:S0;function nE(l){setTimeout(function(){throw l})}function xi(l){return l==="head"}function A0(l,u){var p=u,g=0;do{var v=p.nextSibling;if(l.removeChild(p),v&&v.nodeType===8)if(p=v.data,p==="/$"||p==="/&"){if(g===0){l.removeChild(v),jl(u);return}g--}else if(p==="$"||p==="$?"||p==="$~"||p==="$!"||p==="&")g++;else if(p==="html")qc(l.ownerDocument.documentElement);else if(p==="head"){p=l.ownerDocument.head,qc(p);for(var A=p.firstChild;A;){var P=A.nextSibling,Y=A.nodeName;A[ks]||Y==="SCRIPT"||Y==="STYLE"||Y==="LINK"&&A.rel.toLowerCase()==="stylesheet"||p.removeChild(A),A=P}}else p==="body"&&qc(l.ownerDocument.body);p=v}while(p);jl(u)}function j0(l,u){var p=l;l=0;do{var g=p.nextSibling;if(p.nodeType===1?u?(p._stashedDisplay=p.style.display,p.style.display="none"):(p.style.display=p._stashedDisplay||"",p.getAttribute("style")===""&&p.removeAttribute("style")):p.nodeType===3&&(u?(p._stashedText=p.nodeValue,p.nodeValue=""):p.nodeValue=p._stashedText||""),g&&g.nodeType===8)if(p=g.data,p==="/$"){if(l===0)break;l--}else p!=="$"&&p!=="$?"&&p!=="$~"&&p!=="$!"||l++;p=g}while(p)}function rg(l){var u=l.firstChild;for(u&&u.nodeType===10&&(u=u.nextSibling);u;){var p=u;switch(u=u.nextSibling,p.nodeName){case"HTML":case"HEAD":case"BODY":rg(p),Qn(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}l.removeChild(p)}}function sE(l,u,p,g){for(;l.nodeType===1;){var v=p;if(l.nodeName.toLowerCase()!==u.toLowerCase()){if(!g&&(l.nodeName!=="INPUT"||l.type!=="hidden"))break}else if(g){if(!l[ks])switch(u){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(A=l.getAttribute("rel"),A==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(A!==v.rel||l.getAttribute("href")!==(v.href==null||v.href===""?null:v.href)||l.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin)||l.getAttribute("title")!==(v.title==null?null:v.title))break;return l;case"style":if(l.hasAttribute("data-precedence"))break;return l;case"script":if(A=l.getAttribute("src"),(A!==(v.src==null?null:v.src)||l.getAttribute("type")!==(v.type==null?null:v.type)||l.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&A&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(u==="input"&&l.type==="hidden"){var A=v.name==null?null:""+v.name;if(v.type==="hidden"&&l.getAttribute("name")===A)return l}else return l;if(l=ka(l.nextSibling),l===null)break}return null}function aE(l,u,p){if(u==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!p||(l=ka(l.nextSibling),l===null))return null;return l}function N0(l,u){for(;l.nodeType!==8;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!u||(l=ka(l.nextSibling),l===null))return null;return l}function ig(l){return l.data==="$?"||l.data==="$~"}function og(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState!=="loading"}function rE(l,u){var p=l.ownerDocument;if(l.data==="$~")l._reactRetry=u;else if(l.data!=="$?"||p.readyState!=="loading")u();else{var g=function(){u(),p.removeEventListener("DOMContentLoaded",g)};p.addEventListener("DOMContentLoaded",g),l._reactRetry=g}}function ka(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"||u==="F!"||u==="F")break;if(u==="/$"||u==="/&")return null}}return l}var lg=null;function T0(l){l=l.nextSibling;for(var u=0;l;){if(l.nodeType===8){var p=l.data;if(p==="/$"||p==="/&"){if(u===0)return ka(l.nextSibling);u--}else p!=="$"&&p!=="$!"&&p!=="$?"&&p!=="$~"&&p!=="&"||u++}l=l.nextSibling}return null}function _0(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var p=l.data;if(p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"){if(u===0)return l;u--}else p!=="/$"&&p!=="/&"||u++}l=l.previousSibling}return null}function E0(l,u,p){switch(u=uf(p),l){case"html":if(l=u.documentElement,!l)throw Error(s(452));return l;case"head":if(l=u.head,!l)throw Error(s(453));return l;case"body":if(l=u.body,!l)throw Error(s(454));return l;default:throw Error(s(451))}}function qc(l){for(var u=l.attributes;u.length;)l.removeAttributeNode(u[0]);Qn(l)}var Sa=new Map,M0=new Set;function df(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var Rr=H.d;H.d={f:iE,r:oE,D:lE,C:cE,L:uE,m:dE,X:pE,S:fE,M:hE};function iE(){var l=Rr.f(),u=tf();return l||u}function oE(l){var u=Fn(l);u!==null&&u.tag===5&&u.type==="form"?Gv(u):Rr.r(l)}var Sl=typeof document>"u"?null:document;function D0(l,u,p){var g=Sl;if(g&&typeof u=="string"&&u){var v=Mt(u);v='link[rel="'+l+'"][href="'+v+'"]',typeof p=="string"&&(v+='[crossorigin="'+p+'"]'),M0.has(v)||(M0.add(v),l={rel:l,crossOrigin:p,href:u},g.querySelector(v)===null&&(u=g.createElement("link"),ys(u,"link",l),wn(u),g.head.appendChild(u)))}}function lE(l){Rr.D(l),D0("dns-prefetch",l,null)}function cE(l,u){Rr.C(l,u),D0("preconnect",l,u)}function uE(l,u,p){Rr.L(l,u,p);var g=Sl;if(g&&l&&u){var v='link[rel="preload"][as="'+Mt(u)+'"]';u==="image"&&p&&p.imageSrcSet?(v+='[imagesrcset="'+Mt(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(v+='[imagesizes="'+Mt(p.imageSizes)+'"]')):v+='[href="'+Mt(l)+'"]';var A=v;switch(u){case"style":A=Cl(l);break;case"script":A=Al(l)}Sa.has(A)||(l=m({rel:"preload",href:u==="image"&&p&&p.imageSrcSet?void 0:l,as:u},p),Sa.set(A,l),g.querySelector(v)!==null||u==="style"&&g.querySelector(Vc(A))||u==="script"&&g.querySelector(Yc(A))||(u=g.createElement("link"),ys(u,"link",l),wn(u),g.head.appendChild(u)))}}function dE(l,u){Rr.m(l,u);var p=Sl;if(p&&l){var g=u&&typeof u.as=="string"?u.as:"script",v='link[rel="modulepreload"][as="'+Mt(g)+'"][href="'+Mt(l)+'"]',A=v;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":A=Al(l)}if(!Sa.has(A)&&(l=m({rel:"modulepreload",href:l},u),Sa.set(A,l),p.querySelector(v)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(Yc(A)))return}g=p.createElement("link"),ys(g,"link",l),wn(g),p.head.appendChild(g)}}}function fE(l,u,p){Rr.S(l,u,p);var g=Sl;if(g&&l){var v=Is(g).hoistableStyles,A=Cl(l);u=u||"default";var P=v.get(A);if(!P){var Y={loading:0,preload:null};if(P=g.querySelector(Vc(A)))Y.loading=5;else{l=m({rel:"stylesheet",href:l,"data-precedence":u},p),(p=Sa.get(A))&&cg(l,p);var ae=P=g.createElement("link");wn(ae),ys(ae,"link",l),ae._p=new Promise(function(Me,Ve){ae.onload=Me,ae.onerror=Ve}),ae.addEventListener("load",function(){Y.loading|=1}),ae.addEventListener("error",function(){Y.loading|=2}),Y.loading|=4,ff(P,u,g)}P={type:"stylesheet",instance:P,count:1,state:Y},v.set(A,P)}}}function pE(l,u){Rr.X(l,u);var p=Sl;if(p&&l){var g=Is(p).hoistableScripts,v=Al(l),A=g.get(v);A||(A=p.querySelector(Yc(v)),A||(l=m({src:l,async:!0},u),(u=Sa.get(v))&&ug(l,u),A=p.createElement("script"),wn(A),ys(A,"link",l),p.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},g.set(v,A))}}function hE(l,u){Rr.M(l,u);var p=Sl;if(p&&l){var g=Is(p).hoistableScripts,v=Al(l),A=g.get(v);A||(A=p.querySelector(Yc(v)),A||(l=m({src:l,async:!0,type:"module"},u),(u=Sa.get(v))&&ug(l,u),A=p.createElement("script"),wn(A),ys(A,"link",l),p.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},g.set(v,A))}}function R0(l,u,p,g){var v=(v=Z.current)?df(v):null;if(!v)throw Error(s(446));switch(l){case"meta":case"title":return null;case"style":return typeof p.precedence=="string"&&typeof p.href=="string"?(u=Cl(p.href),p=Is(v).hoistableStyles,g=p.get(u),g||(g={type:"style",instance:null,count:0,state:null},p.set(u,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(p.rel==="stylesheet"&&typeof p.href=="string"&&typeof p.precedence=="string"){l=Cl(p.href);var A=Is(v).hoistableStyles,P=A.get(l);if(P||(v=v.ownerDocument||v,P={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},A.set(l,P),(A=v.querySelector(Vc(l)))&&!A._p&&(P.instance=A,P.state.loading=5),Sa.has(l)||(p={rel:"preload",as:"style",href:p.href,crossOrigin:p.crossOrigin,integrity:p.integrity,media:p.media,hrefLang:p.hrefLang,referrerPolicy:p.referrerPolicy},Sa.set(l,p),A||mE(v,l,p,P.state))),u&&g===null)throw Error(s(528,""));return P}if(u&&g!==null)throw Error(s(529,""));return null;case"script":return u=p.async,p=p.src,typeof p=="string"&&u&&typeof u!="function"&&typeof u!="symbol"?(u=Al(p),p=Is(v).hoistableScripts,g=p.get(u),g||(g={type:"script",instance:null,count:0,state:null},p.set(u,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,l))}}function Cl(l){return'href="'+Mt(l)+'"'}function Vc(l){return'link[rel="stylesheet"]['+l+"]"}function O0(l){return m({},l,{"data-precedence":l.precedence,precedence:null})}function mE(l,u,p,g){l.querySelector('link[rel="preload"][as="style"]['+u+"]")?g.loading=1:(u=l.createElement("link"),g.preload=u,u.addEventListener("load",function(){return g.loading|=1}),u.addEventListener("error",function(){return g.loading|=2}),ys(u,"link",p),wn(u),l.head.appendChild(u))}function Al(l){return'[src="'+Mt(l)+'"]'}function Yc(l){return"script[async]"+l}function L0(l,u,p){if(u.count++,u.instance===null)switch(u.type){case"style":var g=l.querySelector('style[data-href~="'+Mt(p.href)+'"]');if(g)return u.instance=g,wn(g),g;var v=m({},p,{"data-href":p.href,"data-precedence":p.precedence,href:null,precedence:null});return g=(l.ownerDocument||l).createElement("style"),wn(g),ys(g,"style",v),ff(g,p.precedence,l),u.instance=g;case"stylesheet":v=Cl(p.href);var A=l.querySelector(Vc(v));if(A)return u.state.loading|=4,u.instance=A,wn(A),A;g=O0(p),(v=Sa.get(v))&&cg(g,v),A=(l.ownerDocument||l).createElement("link"),wn(A);var P=A;return P._p=new Promise(function(Y,ae){P.onload=Y,P.onerror=ae}),ys(A,"link",g),u.state.loading|=4,ff(A,p.precedence,l),u.instance=A;case"script":return A=Al(p.src),(v=l.querySelector(Yc(A)))?(u.instance=v,wn(v),v):(g=p,(v=Sa.get(A))&&(g=m({},p),ug(g,v)),l=l.ownerDocument||l,v=l.createElement("script"),wn(v),ys(v,"link",g),l.head.appendChild(v),u.instance=v);case"void":return null;default:throw Error(s(443,u.type))}else u.type==="stylesheet"&&(u.state.loading&4)===0&&(g=u.instance,u.state.loading|=4,ff(g,p.precedence,l));return u.instance}function ff(l,u,p){for(var g=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=g.length?g[g.length-1]:null,A=v,P=0;P<g.length;P++){var Y=g[P];if(Y.dataset.precedence===u)A=Y;else if(A!==v)break}A?A.parentNode.insertBefore(l,A.nextSibling):(u=p.nodeType===9?p.head:p,u.insertBefore(l,u.firstChild))}function cg(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.title==null&&(l.title=u.title)}function ug(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.integrity==null&&(l.integrity=u.integrity)}var pf=null;function I0(l,u,p){if(pf===null){var g=new Map,v=pf=new Map;v.set(p,g)}else v=pf,g=v.get(p),g||(g=new Map,v.set(p,g));if(g.has(l))return g;for(g.set(l,null),p=p.getElementsByTagName(l),v=0;v<p.length;v++){var A=p[v];if(!(A[ks]||A[xt]||l==="link"&&A.getAttribute("rel")==="stylesheet")&&A.namespaceURI!=="http://www.w3.org/2000/svg"){var P=A.getAttribute(u)||"";P=l+P;var Y=g.get(P);Y?Y.push(A):g.set(P,[A])}}return g}function P0(l,u,p){l=l.ownerDocument||l,l.head.insertBefore(p,u==="title"?l.querySelector("head > title"):null)}function gE(l,u,p){if(p===1||u.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof u.precedence!="string"||typeof u.href!="string"||u.href==="")break;return!0;case"link":if(typeof u.rel!="string"||typeof u.href!="string"||u.href===""||u.onLoad||u.onError)break;switch(u.rel){case"stylesheet":return l=u.disabled,typeof u.precedence=="string"&&l==null;default:return!0}case"script":if(u.async&&typeof u.async!="function"&&typeof u.async!="symbol"&&!u.onLoad&&!u.onError&&u.src&&typeof u.src=="string")return!0}return!1}function B0(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function bE(l,u,p,g){if(p.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(p.state.loading&4)===0){if(p.instance===null){var v=Cl(g.href),A=u.querySelector(Vc(v));if(A){u=A._p,u!==null&&typeof u=="object"&&typeof u.then=="function"&&(l.count++,l=hf.bind(l),u.then(l,l)),p.state.loading|=4,p.instance=A,wn(A);return}A=u.ownerDocument||u,g=O0(g),(v=Sa.get(v))&&cg(g,v),A=A.createElement("link"),wn(A);var P=A;P._p=new Promise(function(Y,ae){P.onload=Y,P.onerror=ae}),ys(A,"link",g),p.instance=A}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(p,u),(u=p.state.preload)&&(p.state.loading&3)===0&&(l.count++,p=hf.bind(l),u.addEventListener("load",p),u.addEventListener("error",p))}}var dg=0;function xE(l,u){return l.stylesheets&&l.count===0&&gf(l,l.stylesheets),0<l.count||0<l.imgCount?function(p){var g=setTimeout(function(){if(l.stylesheets&&gf(l,l.stylesheets),l.unsuspend){var A=l.unsuspend;l.unsuspend=null,A()}},6e4+u);0<l.imgBytes&&dg===0&&(dg=62500*J_());var v=setTimeout(function(){if(l.waitingForImages=!1,l.count===0&&(l.stylesheets&&gf(l,l.stylesheets),l.unsuspend)){var A=l.unsuspend;l.unsuspend=null,A()}},(l.imgBytes>dg?50:800)+u);return l.unsuspend=p,function(){l.unsuspend=null,clearTimeout(g),clearTimeout(v)}}:null}function hf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)gf(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var mf=null;function gf(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,mf=new Map,u.forEach(yE,l),mf=null,hf.call(l))}function yE(l,u){if(!(u.state.loading&4)){var p=mf.get(l);if(p)var g=p.get(null);else{p=new Map,mf.set(l,p);for(var v=l.querySelectorAll("link[data-precedence],style[data-precedence]"),A=0;A<v.length;A++){var P=v[A];(P.nodeName==="LINK"||P.getAttribute("media")!=="not all")&&(p.set(P.dataset.precedence,P),g=P)}g&&p.set(null,g)}v=u.instance,P=v.getAttribute("data-precedence"),A=p.get(P)||g,A===g&&p.set(null,v),p.set(P,v),this.count++,g=hf.bind(this),v.addEventListener("load",g),v.addEventListener("error",g),A?A.parentNode.insertBefore(v,A.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(v,l.firstChild)),u.state.loading|=4}}var Gc={$$typeof:S,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function vE(l,u,p,g,v,A,P,Y,ae){this.tag=1,this.containerInfo=l,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=je(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=je(0),this.hiddenUpdates=je(null),this.identifierPrefix=g,this.onUncaughtError=v,this.onCaughtError=A,this.onRecoverableError=P,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ae,this.incompleteTransitions=new Map}function F0(l,u,p,g,v,A,P,Y,ae,Me,Ve,Qe){return l=new vE(l,u,p,P,ae,Me,Ve,Qe,Y),u=1,A===!0&&(u|=24),A=Zs(3,null,null,u),l.current=A,A.stateNode=l,u=Wh(),u.refCount++,l.pooledCache=u,u.refCount++,A.memoizedState={element:g,isDehydrated:p,cache:u},Gh(A),l}function z0(l){return l?(l=nl,l):nl}function $0(l,u,p,g,v,A){v=z0(v),g.context===null?g.context=v:g.pendingContext=v,g=oi(u),g.payload={element:p},A=A===void 0?null:A,A!==null&&(g.callback=A),p=li(l,g,u),p!==null&&(qs(p,l,u),jc(p,l,u))}function U0(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<u?p:u}}function fg(l,u){U0(l,u),(l=l.alternate)&&U0(l,u)}function H0(l){if(l.tag===13||l.tag===31){var u=Ji(l,67108864);u!==null&&qs(u,l,67108864),fg(l,67108864)}}function W0(l){if(l.tag===13||l.tag===31){var u=aa();u=Lt(u);var p=Ji(l,u);p!==null&&qs(p,l,u),fg(l,u)}}var bf=!0;function wE(l,u,p,g){var v=F.T;F.T=null;var A=H.p;try{H.p=2,pg(l,u,p,g)}finally{H.p=A,F.T=v}}function kE(l,u,p,g){var v=F.T;F.T=null;var A=H.p;try{H.p=8,pg(l,u,p,g)}finally{H.p=A,F.T=v}}function pg(l,u,p,g){if(bf){var v=hg(g);if(v===null)Zm(l,u,g,xf,p),V0(l,g);else if(CE(v,l,u,p,g))g.stopPropagation();else if(V0(l,g),u&4&&-1<SE.indexOf(l)){for(;v!==null;){var A=Fn(v);if(A!==null)switch(A.tag){case 3:if(A=A.stateNode,A.current.memoizedState.isDehydrated){var P=at(A.pendingLanes);if(P!==0){var Y=A;for(Y.pendingLanes|=2,Y.entangledLanes|=2;P;){var ae=1<<31-be(P);Y.entanglements[1]|=ae,P&=~ae}Qa(A),(hn&6)===0&&(Zd=ct()+500,Uc(0))}}break;case 31:case 13:Y=Ji(A,2),Y!==null&&qs(Y,A,2),tf(),fg(A,2)}if(A=hg(g),A===null&&Zm(l,u,g,xf,p),A===v)break;v=A}v!==null&&g.stopPropagation()}else Zm(l,u,g,null,p)}}function hg(l){return l=uc(l),mg(l)}var xf=null;function mg(l){if(xf=null,l=Ss(l),l!==null){var u=r(l);if(u===null)l=null;else{var p=u.tag;if(p===13){if(l=i(u),l!==null)return l;l=null}else if(p===31){if(l=c(u),l!==null)return l;l=null}else if(p===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null)}}return xf=l,null}function q0(l){switch(l){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(fe()){case X:return 2;case se:return 8;case Se:case J:return 32;case pe:return 268435456;default:return 32}default:return 32}}var gg=!1,yi=null,vi=null,wi=null,Kc=new Map,Qc=new Map,ki=[],SE="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 V0(l,u){switch(l){case"focusin":case"focusout":yi=null;break;case"dragenter":case"dragleave":vi=null;break;case"mouseover":case"mouseout":wi=null;break;case"pointerover":case"pointerout":Kc.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":Qc.delete(u.pointerId)}}function Xc(l,u,p,g,v,A){return l===null||l.nativeEvent!==A?(l={blockedOn:u,domEventName:p,eventSystemFlags:g,nativeEvent:A,targetContainers:[v]},u!==null&&(u=Fn(u),u!==null&&H0(u)),l):(l.eventSystemFlags|=g,u=l.targetContainers,v!==null&&u.indexOf(v)===-1&&u.push(v),l)}function CE(l,u,p,g,v){switch(u){case"focusin":return yi=Xc(yi,l,u,p,g,v),!0;case"dragenter":return vi=Xc(vi,l,u,p,g,v),!0;case"mouseover":return wi=Xc(wi,l,u,p,g,v),!0;case"pointerover":var A=v.pointerId;return Kc.set(A,Xc(Kc.get(A)||null,l,u,p,g,v)),!0;case"gotpointercapture":return A=v.pointerId,Qc.set(A,Xc(Qc.get(A)||null,l,u,p,g,v)),!0}return!1}function Y0(l){var u=Ss(l.target);if(u!==null){var p=r(u);if(p!==null){if(u=p.tag,u===13){if(u=i(p),u!==null){l.blockedOn=u,bt(l.priority,function(){W0(p)});return}}else if(u===31){if(u=c(p),u!==null){l.blockedOn=u,bt(l.priority,function(){W0(p)});return}}else if(u===3&&p.stateNode.current.memoizedState.isDehydrated){l.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}l.blockedOn=null}function yf(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var p=hg(l.nativeEvent);if(p===null){p=l.nativeEvent;var g=new p.constructor(p.type,p);Hn=g,p.target.dispatchEvent(g),Hn=null}else return u=Fn(p),u!==null&&H0(u),l.blockedOn=p,!1;u.shift()}return!0}function G0(l,u,p){yf(l)&&p.delete(u)}function AE(){gg=!1,yi!==null&&yf(yi)&&(yi=null),vi!==null&&yf(vi)&&(vi=null),wi!==null&&yf(wi)&&(wi=null),Kc.forEach(G0),Qc.forEach(G0)}function vf(l,u){l.blockedOn===u&&(l.blockedOn=null,gg||(gg=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,AE)))}var wf=null;function K0(l){wf!==l&&(wf=l,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){wf===l&&(wf=null);for(var u=0;u<l.length;u+=3){var p=l[u],g=l[u+1],v=l[u+2];if(typeof g!="function"){if(mg(g||p)===null)continue;break}var A=Fn(p);A!==null&&(l.splice(u,3),u-=3,hm(A,{pending:!0,data:v,method:p.method,action:g},g,v))}}))}function jl(l){function u(ae){return vf(ae,l)}yi!==null&&vf(yi,l),vi!==null&&vf(vi,l),wi!==null&&vf(wi,l),Kc.forEach(u),Qc.forEach(u);for(var p=0;p<ki.length;p++){var g=ki[p];g.blockedOn===l&&(g.blockedOn=null)}for(;0<ki.length&&(p=ki[0],p.blockedOn===null);)Y0(p),p.blockedOn===null&&ki.shift();if(p=(l.ownerDocument||l).$$reactFormReplay,p!=null)for(g=0;g<p.length;g+=3){var v=p[g],A=p[g+1],P=v[$t]||null;if(typeof A=="function")P||K0(p);else if(P){var Y=null;if(A&&A.hasAttribute("formAction")){if(v=A,P=A[$t]||null)Y=P.formAction;else if(mg(v)!==null)continue}else Y=P.action;typeof Y=="function"?p[g+1]=Y:(p.splice(g,3),g-=3),K0(p)}}}function Q0(){function l(A){A.canIntercept&&A.info==="react-transition"&&A.intercept({handler:function(){return new Promise(function(P){return v=P})},focusReset:"manual",scroll:"manual"})}function u(){v!==null&&(v(),v=null),g||setTimeout(p,20)}function p(){if(!g&&!navigation.transition){var A=navigation.currentEntry;A&&A.url!=null&&navigation.navigate(A.url,{state:A.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,v=null;return navigation.addEventListener("navigate",l),navigation.addEventListener("navigatesuccess",u),navigation.addEventListener("navigateerror",u),setTimeout(p,100),function(){g=!0,navigation.removeEventListener("navigate",l),navigation.removeEventListener("navigatesuccess",u),navigation.removeEventListener("navigateerror",u),v!==null&&(v(),v=null)}}}function bg(l){this._internalRoot=l}kf.prototype.render=bg.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(s(409));var p=u.current,g=aa();$0(p,g,l,u,null,null)},kf.prototype.unmount=bg.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;$0(l.current,2,null,l,null,null),tf(),u[En]=null}};function kf(l){this._internalRoot=l}kf.prototype.unstable_scheduleHydration=function(l){if(l){var u=ln();l={blockedOn:null,target:l,priority:u};for(var p=0;p<ki.length&&u!==0&&u<ki[p].priority;p++);ki.splice(p,0,l),p===0&&Y0(l)}};var X0=e.version;if(X0!=="19.2.4")throw Error(s(527,X0,"19.2.4"));H.findDOMNode=function(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(s(188)):(l=Object.keys(l).join(","),Error(s(268,l)));return l=f(u),l=l!==null?h(l):null,l=l===null?null:l.stateNode,l};var jE={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:F,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Sf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Sf.isDisabled&&Sf.supportsFiber)try{ye=Sf.inject(jE),Ie=Sf}catch{}}return Zc.createRoot=function(l,u){if(!a(l))throw Error(s(299));var p=!1,g="",v=aw,A=rw,P=iw;return u!=null&&(u.unstable_strictMode===!0&&(p=!0),u.identifierPrefix!==void 0&&(g=u.identifierPrefix),u.onUncaughtError!==void 0&&(v=u.onUncaughtError),u.onCaughtError!==void 0&&(A=u.onCaughtError),u.onRecoverableError!==void 0&&(P=u.onRecoverableError)),u=F0(l,1,!1,null,null,p,g,null,v,A,P,Q0),l[En]=u.current,Jm(l),new bg(u)},Zc.hydrateRoot=function(l,u,p){if(!a(l))throw Error(s(299));var g=!1,v="",A=aw,P=rw,Y=iw,ae=null;return p!=null&&(p.unstable_strictMode===!0&&(g=!0),p.identifierPrefix!==void 0&&(v=p.identifierPrefix),p.onUncaughtError!==void 0&&(A=p.onUncaughtError),p.onCaughtError!==void 0&&(P=p.onCaughtError),p.onRecoverableError!==void 0&&(Y=p.onRecoverableError),p.formState!==void 0&&(ae=p.formState)),u=F0(l,1,!0,u,p??null,g,v,ae,A,P,Y,Q0),u.context=z0(null),p=u.current,g=aa(),g=Lt(g),v=oi(g),v.callback=null,li(p,v,g),p=g,u.current.lanes=p,Oe(u,p),Qa(u),l[En]=u.current,Jm(l),new kf(u)},Zc.version="19.2.4",Zc}var lk;function kM(){if(lk)return vg.exports;lk=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),vg.exports=wM(),vg.exports}var SM=kM();const zt=t=>typeof t=="string",eu=()=>{let t,e;const n=new Promise((s,a)=>{t=s,e=a});return n.resolve=t,n.reject=e,n},ck=t=>t==null?"":String(t),CM=(t,e,n)=>{t.forEach(s=>{e[s]&&(n[s]=e[s])})},AM=/###/g,uk=t=>t&&t.includes("###")?t.replace(AM,"."):t,dk=t=>!t||zt(t),ju=(t,e,n)=>{const s=zt(e)?e.split("."):e;let a=0;for(;a<s.length-1;){if(dk(t))return{};const r=uk(s[a]);!t[r]&&n&&(t[r]=new n),Object.prototype.hasOwnProperty.call(t,r)?t=t[r]:t={},++a}return dk(t)?{}:{obj:t,k:uk(s[a])}},fk=(t,e,n)=>{const{obj:s,k:a}=ju(t,e,Object);if(s!==void 0||e.length===1){s[a]=n;return}let r=e[e.length-1],i=e.slice(0,e.length-1),c=ju(t,i,Object);for(;c.obj===void 0&&i.length;)r=`${i[i.length-1]}.${r}`,i=i.slice(0,i.length-1),c=ju(t,i,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${r}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${r}`]=n},jM=(t,e,n,s)=>{const{obj:a,k:r}=ju(t,e,Object);a[r]=a[r]||[],a[r].push(n)},fp=(t,e)=>{const{obj:n,k:s}=ju(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,s))return n[s]},NM=(t,e,n)=>{const s=fp(t,n);return s!==void 0?s:fp(e,n)},pj=(t,e,n)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in t?zt(t[s])||t[s]instanceof String||zt(e[s])||e[s]instanceof String?n&&(t[s]=e[s]):pj(t[s],e[s],n):t[s]=e[s]);return t},fo=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),TM={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},_M=t=>zt(t)?t.replace(/[&<>"'\/]/g,e=>TM[e]):t;class EM{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}const MM=[" ",",","?","!",";"],DM=new EM(20),RM=(t,e,n)=>{e=e||"",n=n||"";const s=MM.filter(i=>!e.includes(i)&&!n.includes(i));if(s.length===0)return!0;const a=DM.getRegExp(`(${s.map(i=>i==="?"?"\\?":i).join("|")})`);let r=!a.test(t);if(!r){const i=t.indexOf(n);i>0&&!a.test(t.substring(0,i))&&(r=!0)}return r},Fb=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const s=e.split(n);let a=t;for(let r=0;r<s.length;){if(!a||typeof a!="object")return;let i,c="";for(let d=r;d<s.length;++d)if(d!==r&&(c+=n),c+=s[d],i=a[c],i!==void 0){if(["string","number","boolean"].includes(typeof i)&&d<s.length-1)continue;r+=d-r+1;break}a=i}return a},Fu=t=>t==null?void 0:t.replace(/_/g,"-"),OM={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var n,s;(s=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||s.call(n,console,e)}};class pp{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||OM,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,s,a){return a&&!this.debug?null:(zt(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new pp(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new pp(this.logger,e)}}var nr=new pp;class Vp{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const a=this.observers[s].get(n)||0;this.observers[s].set(n,a+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}once(e,n){const s=(...a)=>{n(...a),this.off(e,s)};return this.on(e,s),this}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([a,r])=>{for(let i=0;i<r;i++)a(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([a,r])=>{for(let i=0;i<r;i++)a(e,...n)})}}class pk extends Vp{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,s,a={}){var f,h;const r=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,i=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.includes(".")?c=e.split("."):(c=[e,n],s&&(Array.isArray(s)?c.push(...s):zt(s)&&r?c.push(...s.split(r)):c.push(s)));const d=fp(this.data,c);return!d&&!n&&!s&&e.includes(".")&&(e=c[0],n=c[1],s=c.slice(2).join(".")),d||!i||!zt(s)?d:Fb((h=(f=this.data)==null?void 0:f[e])==null?void 0:h[n],s,r)}addResource(e,n,s,a,r={silent:!1}){const i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let c=[e,n];s&&(c=c.concat(i?s.split(i):s)),e.includes(".")&&(c=e.split("."),a=n,n=c[1]),this.addNamespaces(n),fk(this.data,c,a),r.silent||this.emit("added",e,n,s,a)}addResources(e,n,s,a={silent:!1}){for(const r in s)(zt(s[r])||Array.isArray(s[r]))&&this.addResource(e,n,r,s[r],{silent:!0});a.silent||this.emit("added",e,n,s)}addResourceBundle(e,n,s,a,r,i={silent:!1,skipCopy:!1}){let c=[e,n];e.includes(".")&&(c=e.split("."),a=s,s=n,n=c[1]),this.addNamespaces(n);let d=fp(this.data,c)||{};i.skipCopy||(s=JSON.parse(JSON.stringify(s))),a?pj(d,s,r):d={...d,...s},fk(this.data,c,d),i.silent||this.emit("added",e,n,s)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(a=>n[a]&&Object.keys(n[a]).length>0)}toJSON(){return this.data}}var hj={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,s,a){return t.forEach(r=>{var i;e=((i=this.processors[r])==null?void 0:i.process(e,n,s,a))??e}),e}};const mj=Symbol("i18next/PATH_KEY");function LM(){const t=[],e=Object.create(null);let n;return e.get=(s,a)=>{var r;return(r=n==null?void 0:n.revoke)==null||r.call(n),a===mj?t:(t.push(a),n=Proxy.revocable(s,e),n.proxy)},Proxy.revocable(Object.create(null),e).proxy}function $l(t,e){const{[mj]:n}=t(LM()),s=(e==null?void 0:e.keySeparator)??".",a=(e==null?void 0:e.nsSeparator)??":";if(n.length>1&&a){const r=e==null?void 0:e.ns,i=Array.isArray(r)?r:null;if(i&&i.length>1&&i.slice(1).includes(n[0]))return`${n[0]}${a}${n.slice(1).join(s)}`}return n.join(s)}const Sg=t=>!zt(t)&&typeof t!="boolean"&&typeof t!="number";class hp extends Vp{constructor(e,n={}){super(),CM(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=nr.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const s={...n};if(e==null)return!1;const a=this.resolve(e,s);if((a==null?void 0:a.res)===void 0)return!1;const r=Sg(a.res);return!(s.returnObjects===!1&&r)}extractFromKey(e,n){let s=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let r=n.ns||this.options.defaultNS||[];const i=s&&e.includes(s),c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!RM(e,s,a);if(i&&!c){const d=e.match(this.interpolator.nestingRegexp);if(d&&d.length>0)return{key:e,namespaces:zt(r)?[r]:r};const f=e.split(s);(s!==a||s===a&&this.options.ns.includes(f[0]))&&(r=f.shift()),e=f.join(a)}return{key:e,namespaces:zt(r)?[r]:r}}translate(e,n,s){let a=typeof n=="object"?{...n}:n;if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),e==null)return"";typeof e=="function"&&(e=$l(e,{...this.options,...a})),Array.isArray(e)||(e=[String(e)]),e=e.map($=>typeof $=="function"?$l($,{...this.options,...a}):String($));const r=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:c,namespaces:d}=this.extractFromKey(e[e.length-1],a),f=d[d.length-1];let h=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const m=a.lng||this.language,b=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((m==null?void 0:m.toLowerCase())==="cimode")return b?r?{res:`${f}${h}${c}`,usedKey:c,exactUsedKey:c,usedLng:m,usedNS:f,usedParams:this.getUsedParamsDetails(a)}:`${f}${h}${c}`:r?{res:c,usedKey:c,exactUsedKey:c,usedLng:m,usedNS:f,usedParams:this.getUsedParamsDetails(a)}:c;const y=this.resolve(e,a);let w=y==null?void 0:y.res;const C=(y==null?void 0:y.usedKey)||c,N=(y==null?void 0:y.exactUsedKey)||c,k=["[object Number]","[object Function]","[object RegExp]"],j=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,T=a.count!==void 0&&!zt(a.count),D=hp.hasDefaultValue(a),E=T?this.pluralResolver.getSuffix(m,a.count,a):"",I=a.ordinal&&T?this.pluralResolver.getSuffix(m,a.count,{ordinal:!1}):"",O=T&&!a.ordinal&&a.count===0,_=O&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${E}`]||a[`defaultValue${I}`]||a.defaultValue;let M=w;S&&!w&&D&&(M=_);const R=Sg(M),z=Object.prototype.toString.apply(M);if(S&&M&&R&&!k.includes(z)&&!(zt(j)&&Array.isArray(M))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const $=this.options.returnedObjectHandler?this.options.returnedObjectHandler(C,M,{...a,ns:d}):`key '${c} (${this.language})' returned an object instead of string.`;return r?(y.res=$,y.usedParams=this.getUsedParamsDetails(a),y):$}if(i){const $=Array.isArray(M),W=$?[]:{},L=$?N:C;for(const F in M)if(Object.prototype.hasOwnProperty.call(M,F)){const H=`${L}${i}${F}`;D&&!w?W[F]=this.translate(H,{...a,defaultValue:Sg(_)?_[F]:void 0,joinArrays:!1,ns:d}):W[F]=this.translate(H,{...a,joinArrays:!1,ns:d}),W[F]===H&&(W[F]=M[F])}w=W}}else if(S&&zt(j)&&Array.isArray(w))w=w.join(j),w&&(w=this.extendTranslation(w,e,a,s));else{let $=!1,W=!1;!this.isValidLookup(w)&&D&&($=!0,w=_),this.isValidLookup(w)||(W=!0,w=c);const F=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&W?void 0:w,H=D&&_!==w&&this.options.updateMissing;if(W||$||H){if(this.logger.log(H?"updateKey":"missingKey",m,f,c,H?_:w),i){const K=this.resolve(c,{...a,keySeparator:!1});K&&K.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let V=[];const G=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&G&&G[0])for(let K=0;K<G.length;K++)V.push(G[K]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(a.lng||this.language):V.push(a.lng||this.language);const B=(K,ne,q)=>{var Ae;const xe=D&&q!==w?q:F;this.options.missingKeyHandler?this.options.missingKeyHandler(K,f,ne,xe,H,a):(Ae=this.backendConnector)!=null&&Ae.saveMissing&&this.backendConnector.saveMissing(K,f,ne,xe,H,a),this.emit("missingKey",K,f,ne,w)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?V.forEach(K=>{const ne=this.pluralResolver.getSuffixes(K,a);O&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!ne.includes(`${this.options.pluralSeparator}zero`)&&ne.push(`${this.options.pluralSeparator}zero`),ne.forEach(q=>{B([K],c+q,a[`defaultValue${q}`]||_)})}):B(V,c,_))}w=this.extendTranslation(w,e,a,y,s),W&&w===c&&this.options.appendNamespaceToMissingKey&&(w=`${f}${h}${c}`),(W||$)&&this.options.parseMissingKeyHandler&&(w=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${f}${h}${c}`:c,$?w:void 0,a))}return r?(y.res=w,y.usedParams=this.getUsedParamsDetails(a),y):w}extendTranslation(e,n,s,a,r){var d,f;if((d=this.i18nFormat)!=null&&d.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const h=zt(e)&&(((f=s==null?void 0:s.interpolation)==null?void 0:f.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(h){const y=e.match(this.interpolator.nestingRegexp);m=y&&y.length}let b=s.replace&&!zt(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(b={...this.options.interpolation.defaultVariables,...b}),e=this.interpolator.interpolate(e,b,s.lng||this.language||a.usedLng,s),h){const y=e.match(this.interpolator.nestingRegexp),w=y&&y.length;m<w&&(s.nest=!1)}!s.lng&&a&&a.res&&(s.lng=this.language||a.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...y)=>(r==null?void 0:r[0])===y[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${y[0]} in key: ${n[0]}`),null):this.translate(...y,n),s)),s.interpolation&&this.interpolator.reset()}const i=s.postProcess||this.options.postProcess,c=zt(i)?[i]:i;return e!=null&&(c!=null&&c.length)&&s.applyPostProcessor!==!1&&(e=hj.handle(c,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e,n={}){let s,a,r,i,c;return zt(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(d=>typeof d=="function"?$l(d,{...this.options,...n}):d)),e.forEach(d=>{if(this.isValidLookup(s))return;const f=this.extractFromKey(d,n),h=f.key;a=h;let m=f.namespaces;this.options.fallbackNS&&(m=m.concat(this.options.fallbackNS));const b=n.count!==void 0&&!zt(n.count),y=b&&!n.ordinal&&n.count===0,w=n.context!==void 0&&(zt(n.context)||typeof n.context=="number")&&n.context!=="",C=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);m.forEach(N=>{var k,j;this.isValidLookup(s)||(c=N,!this.checkedLoadedFor[`${C[0]}-${N}`]&&((k=this.utils)!=null&&k.hasLoadedNamespace)&&!((j=this.utils)!=null&&j.hasLoadedNamespace(c))&&(this.checkedLoadedFor[`${C[0]}-${N}`]=!0,this.logger.warn(`key "${a}" for languages "${C.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),C.forEach(S=>{var E;if(this.isValidLookup(s))return;i=S;const T=[h];if((E=this.i18nFormat)!=null&&E.addLookupKeys)this.i18nFormat.addLookupKeys(T,h,S,N,n);else{let I;b&&(I=this.pluralResolver.getSuffix(S,n.count,n));const O=`${this.options.pluralSeparator}zero`,_=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(b&&(n.ordinal&&I.startsWith(_)&&T.push(h+I.replace(_,this.options.pluralSeparator)),T.push(h+I),y&&T.push(h+O)),w){const M=`${h}${this.options.contextSeparator||"_"}${n.context}`;T.push(M),b&&(n.ordinal&&I.startsWith(_)&&T.push(M+I.replace(_,this.options.pluralSeparator)),T.push(M+I),y&&T.push(M+O))}}let D;for(;D=T.pop();)this.isValidLookup(s)||(r=D,s=this.getResource(S,N,D,n))}))})}),{res:s,usedKey:a,exactUsedKey:r,usedLng:i,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,s,a={}){var r;return(r=this.i18nFormat)!=null&&r.getResource?this.i18nFormat.getResource(e,n,s,a):this.resourceStore.getResource(e,n,s,a)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!zt(e.replace);let a=s?e.replace:e;if(s&&typeof e.count<"u"&&(a.count=e.count),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!s){a={...a};for(const r of n)delete a[r]}return a}static hasDefaultValue(e){const n="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&s.startsWith(n)&&e[s]!==void 0)return!0;return!1}}class hk{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=nr.create("languageUtils")}getScriptPartFromCode(e){if(e=Fu(e),!e||!e.includes("-"))return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Fu(e),!e||!e.includes("-"))return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(zt(e)&&e.includes("-")){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(s=>{if(n)return;const a=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(a))&&(n=a)}),!n&&this.options.supportedLngs&&e.forEach(s=>{if(n)return;const a=this.getScriptPartFromCode(s);if(this.isSupportedCode(a))return n=a;const r=this.getLanguagePartFromCode(s);if(this.isSupportedCode(r))return n=r;n=this.options.supportedLngs.find(i=>i===r?!0:!i.includes("-")&&!r.includes("-")?!1:!!(i.includes("-")&&!r.includes("-")&&i.slice(0,i.indexOf("-"))===r||i.startsWith(r)&&r.length>1))}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),zt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let s=e[n];return s||(s=e[this.getScriptPartFromCode(n)]),s||(s=e[this.formatLanguageCode(n)]),s||(s=e[this.getLanguagePartFromCode(n)]),s||(s=e.default),s||[]}toResolveHierarchy(e,n){const s=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),a=[],r=i=>{i&&(this.isSupportedCode(i)?a.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return zt(e)&&(e.includes("-")||e.includes("_"))?(this.options.load!=="languageOnly"&&r(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&r(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&r(this.getLanguagePartFromCode(e))):zt(e)&&r(this.formatLanguageCode(e)),s.forEach(i=>{a.includes(i)||r(this.formatLanguageCode(i))}),a}}const mk={zero:0,one:1,two:2,few:3,many:4,other:5},gk={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class IM{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=nr.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const s=Fu(e==="dev"?"en":e),a=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:s,type:a});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];let i;try{i=new Intl.PluralRules(s,{type:a})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),gk;if(!e.match(/-|_/))return gk;const d=this.languageUtils.getLanguagePartFromCode(e);i=this.getRule(d,n)}return this.pluralRulesCache[r]=i,i}needsPlural(e,n={}){let s=this.getRule(e,n);return s||(s=this.getRule("dev",n)),(s==null?void 0:s.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n,s={}){return this.getSuffixes(e,s).map(a=>`${n}${a}`)}getSuffixes(e,n={}){let s=this.getRule(e,n);return s||(s=this.getRule("dev",n)),s?s.resolvedOptions().pluralCategories.sort((a,r)=>mk[a]-mk[r]).map(a=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(e,n,s={}){const a=this.getRule(e,s);return a?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${a.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,s))}}const bk=(t,e,n,s=".",a=!0)=>{let r=NM(t,e,n);return!r&&a&&zt(n)&&(r=Fb(t,n,s),r===void 0&&(r=Fb(e,n,s))),r},Cg=t=>t.replace(/\$/g,"$$$$");class xk{constructor(e={}){var n;this.logger=nr.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.format)||(s=>s),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:s,useRawValueToEscape:a,prefix:r,prefixEscaped:i,suffix:c,suffixEscaped:d,formatSeparator:f,unescapeSuffix:h,unescapePrefix:m,nestingPrefix:b,nestingPrefixEscaped:y,nestingSuffix:w,nestingSuffixEscaped:C,nestingOptionsSeparator:N,maxReplaces:k,alwaysFormat:j}=e.interpolation;this.escape=n!==void 0?n:_M,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=a!==void 0?a:!1,this.prefix=r?fo(r):i||"{{",this.suffix=c?fo(c):d||"}}",this.formatSeparator=f||",",this.unescapePrefix=h?"":m||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=b?fo(b):y||fo("$t("),this.nestingSuffix=w?fo(w):C||fo(")"),this.nestingOptionsSeparator=N||",",this.maxReplaces=k||1e3,this.alwaysFormat=j!==void 0?j:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,s)=>(n==null?void 0:n.source)===s?(n.lastIndex=0,n):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,s,a){var y;let r,i,c;const d=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},f=w=>{if(!w.includes(this.formatSeparator)){const j=bk(n,d,w,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(j,void 0,s,{...a,...n,interpolationkey:w}):j}const C=w.split(this.formatSeparator),N=C.shift().trim(),k=C.join(this.formatSeparator).trim();return this.format(bk(n,d,N,this.options.keySeparator,this.options.ignoreJSONStructure),k,s,{...a,...n,interpolationkey:N})};this.resetRegExp();const h=(a==null?void 0:a.missingInterpolationHandler)||this.options.missingInterpolationHandler,m=((y=a==null?void 0:a.interpolation)==null?void 0:y.skipOnVariables)!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:w=>Cg(w)},{regex:this.regexp,safeValue:w=>this.escapeValue?Cg(this.escape(w)):Cg(w)}].forEach(w=>{for(c=0;r=w.regex.exec(e);){const C=r[1].trim();if(i=f(C),i===void 0)if(typeof h=="function"){const k=h(e,r,a);i=zt(k)?k:""}else if(a&&Object.prototype.hasOwnProperty.call(a,C))i="";else if(m){i=r[0];continue}else this.logger.warn(`missed to pass in variable ${C} for interpolating ${e}`),i="";else!zt(i)&&!this.useRawValueToEscape&&(i=ck(i));const N=w.safeValue(i);if(e=e.replace(r[0],N),m?(w.regex.lastIndex+=i.length,w.regex.lastIndex-=r[0].length):w.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n,s={}){let a,r,i;const c=(d,f)=>{const h=this.nestingOptionsSeparator;if(!d.includes(h))return d;const m=d.split(new RegExp(`${fo(h)}[ ]*{`));let b=`{${m[1]}`;d=m[0],b=this.interpolate(b,i);const y=b.match(/'/g),w=b.match(/"/g);(((y==null?void 0:y.length)??0)%2===0&&!w||((w==null?void 0:w.length)??0)%2!==0)&&(b=b.replace(/'/g,'"'));try{i=JSON.parse(b),f&&(i={...f,...i})}catch(C){return this.logger.warn(`failed parsing options string in nesting for key ${d}`,C),`${d}${h}${b}`}return i.defaultValue&&i.defaultValue.includes(this.prefix)&&delete i.defaultValue,d};for(;a=this.nestingRegexp.exec(e);){let d=[];i={...s},i=i.replace&&!zt(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const f=/{.*}/.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(f!==-1&&(d=a[1].slice(f).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),a[1]=a[1].slice(0,f)),r=n(c.call(this,a[1].trim(),i),i),r&&a[0]===e&&!zt(r))return r;zt(r)||(r=ck(r)),r||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),r=""),d.length&&(r=d.reduce((h,m)=>this.format(h,m,s.lng,{...s,interpolationkey:a[1].trim()}),r.trim())),e=e.replace(a[0],r),this.regexp.lastIndex=0}return e}}const PM=t=>{let e=t.toLowerCase().trim();const n={};if(t.includes("(")){const s=t.split("(");e=s[0].toLowerCase().trim();const a=s[1].slice(0,-1);e==="currency"&&!a.includes(":")?n.currency||(n.currency=a.trim()):e==="relativetime"&&!a.includes(":")?n.range||(n.range=a.trim()):a.split(";").forEach(i=>{if(i){const[c,...d]=i.split(":"),f=d.join(":").trim().replace(/^'+|'+$/g,""),h=c.trim();n[h]||(n[h]=f),f==="false"&&(n[h]=!1),f==="true"&&(n[h]=!0),isNaN(f)||(n[h]=parseInt(f,10))}})}return{formatName:e,formatOptions:n}},yk=t=>{const e={};return(n,s,a)=>{let r=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(r={...r,[a.interpolationkey]:void 0});const i=s+JSON.stringify(r);let c=e[i];return c||(c=t(Fu(s),a),e[i]=c),c(n)}},BM=t=>(e,n,s)=>t(Fu(n),s)(e);class FM{constructor(e={}){this.logger=nr.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const s=n.cacheInBuiltFormats?yk:BM;this.formats={number:s((a,r)=>{const i=new Intl.NumberFormat(a,{...r});return c=>i.format(c)}),currency:s((a,r)=>{const i=new Intl.NumberFormat(a,{...r,style:"currency"});return c=>i.format(c)}),datetime:s((a,r)=>{const i=new Intl.DateTimeFormat(a,{...r});return c=>i.format(c)}),relativetime:s((a,r)=>{const i=new Intl.RelativeTimeFormat(a,{...r});return c=>i.format(c,r.range||"day")}),list:s((a,r)=>{const i=new Intl.ListFormat(a,{...r});return c=>i.format(c)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=yk(n)}format(e,n,s,a={}){if(!n||e==null)return e;const r=n.split(this.formatSeparator);if(r.length>1&&r[0].indexOf("(")>1&&!r[0].includes(")")&&r.find(c=>c.includes(")"))){const c=r.findIndex(d=>d.includes(")"));r[0]=[r[0],...r.splice(1,c)].join(this.formatSeparator)}return r.reduce((c,d)=>{var m;const{formatName:f,formatOptions:h}=PM(d);if(this.formats[f]){let b=c;try{const y=((m=a==null?void 0:a.formatParams)==null?void 0:m[a.interpolationkey])||{},w=y.locale||y.lng||a.locale||a.lng||s;b=this.formats[f](c,w,{...h,...a,...y})}catch(y){this.logger.warn(y)}return b}else this.logger.warn(`there was no format function for ${f}`);return c},e)}}const zM=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class $M extends Vp{constructor(e,n,s,a={}){var r,i;super(),this.backend=e,this.store=n,this.services=s,this.languageUtils=s.languageUtils,this.options=a,this.logger=nr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],(i=(r=this.backend)==null?void 0:r.init)==null||i.call(r,s,a.backend,a)}queueLoad(e,n,s,a){const r={},i={},c={},d={};return e.forEach(f=>{let h=!0;n.forEach(m=>{const b=`${f}|${m}`;!s.reload&&this.store.hasResourceBundle(f,m)?this.state[b]=2:this.state[b]<0||(this.state[b]===1?i[b]===void 0&&(i[b]=!0):(this.state[b]=1,h=!1,i[b]===void 0&&(i[b]=!0),r[b]===void 0&&(r[b]=!0),d[m]===void 0&&(d[m]=!0)))}),h||(c[f]=!0)}),(Object.keys(r).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(r),pending:Object.keys(i),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(d)}}loaded(e,n,s){const a=e.split("|"),r=a[0],i=a[1];n&&this.emit("failedLoading",r,i,n),!n&&s&&this.store.addResourceBundle(r,i,s,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&s&&(this.state[e]=0);const c={};this.queue.forEach(d=>{jM(d.loaded,[r],i),zM(d,e),n&&d.errors.push(n),d.pendingCount===0&&!d.done&&(Object.keys(d.loaded).forEach(f=>{c[f]||(c[f]={});const h=d.loaded[f];h.length&&h.forEach(m=>{c[f][m]===void 0&&(c[f][m]=!0)})}),d.done=!0,d.errors.length?d.callback(d.errors):d.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(d=>!d.done)}read(e,n,s,a=0,r=this.retryTimeout,i){if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:s,tried:a,wait:r,callback:i});return}this.readingCalls++;const c=(f,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const m=this.waitingReads.shift();this.read(m.lng,m.ns,m.fcName,m.tried,m.wait,m.callback)}if(f&&h&&a<this.maxRetries){setTimeout(()=>{this.read(e,n,s,a+1,r*2,i)},r);return}i(f,h)},d=this.backend[s].bind(this.backend);if(d.length===2){try{const f=d(e,n);f&&typeof f.then=="function"?f.then(h=>c(null,h)).catch(c):c(null,f)}catch(f){c(f)}return}return d(e,n,c)}prepareLoading(e,n,s={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();zt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),zt(n)&&(n=[n]);const r=this.queueLoad(e,n,s,a);if(!r.toLoad.length)return r.pending.length||a(),null;r.toLoad.forEach(i=>{this.loadOne(i)})}load(e,n,s){this.prepareLoading(e,n,{},s)}reload(e,n,s){this.prepareLoading(e,n,{reload:!0},s)}loadOne(e,n=""){const s=e.split("|"),a=s[0],r=s[1];this.read(a,r,"read",void 0,void 0,(i,c)=>{i&&this.logger.warn(`${n}loading namespace ${r} for language ${a} failed`,i),!i&&c&&this.logger.log(`${n}loaded namespace ${r} for language ${a}`,c),this.loaded(e,i,c)})}saveMissing(e,n,s,a,r,i={},c=()=>{}){var d,f,h,m,b;if((f=(d=this.services)==null?void 0:d.utils)!=null&&f.hasLoadedNamespace&&!((m=(h=this.services)==null?void 0:h.utils)!=null&&m.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${s}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if((b=this.backend)!=null&&b.create){const y={...i,isUpdate:r},w=this.backend.create.bind(this.backend);if(w.length<6)try{let C;w.length===5?C=w(e,n,s,a,y):C=w(e,n,s,a),C&&typeof C.then=="function"?C.then(N=>c(null,N)).catch(c):c(null,C)}catch(C){c(C)}else w(e,n,s,a,c,y)}!e||!e[0]||this.store.addResource(e[0],n,s,a)}}}const Ag=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),zt(t[1])&&(e.defaultValue=t[1]),zt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(s=>{e[s]=n[s]})}return e},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),vk=t=>(zt(t.ns)&&(t.ns=[t.ns]),zt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),zt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),Cf=()=>{},UM=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Nu extends Vp{constructor(e={},n){if(super(),this.options=vk(e),this.services={},this.logger=nr,this.modules={external:[]},UM(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(zt(e.ns)?e.defaultNS=e.ns:e.ns.includes("translation")||(e.defaultNS=e.ns[0]));const s=Ag();this.options={...s,...this.options,...vk(e)},this.options.interpolation={...s.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler);const a=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?nr.init(a(this.modules.logger),this.options):nr.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:f=FM;const h=new hk(this.options);this.store=new pk(this.options.resources,this.options);const m=this.services;m.logger=nr,m.resourceStore=this.store,m.languageUtils=h,m.pluralResolver=new IM(h,{prepend:this.options.pluralSeparator}),f&&(m.formatter=a(f),m.formatter.init&&m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new xk(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new $M(a(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",(b,...y)=>{this.emit(b,...y)}),this.modules.languageDetector&&(m.languageDetector=a(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=a(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new hp(this.services,this.options),this.translator.on("*",(b,...y)=>{this.emit(b,...y)}),this.modules.external.forEach(b=>{b.init&&b.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Cf),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(f=>{this[f]=(...h)=>this.store[f](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=(...h)=>(this.store[f](...h),this)});const c=eu(),d=()=>{const f=(h,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(m),n(h,m)};if(this.languages&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initAsync?d():setTimeout(d,0),c}loadResources(e,n=Cf){var r,i;let s=n;const a=zt(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if((a==null?void 0:a.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const c=[],d=f=>{if(!f||f==="cimode")return;this.services.languageUtils.toResolveHierarchy(f).forEach(m=>{m!=="cimode"&&(c.includes(m)||c.push(m))})};a?d(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(h=>d(h)),(i=(r=this.options.preload)==null?void 0:r.forEach)==null||i.call(r,f=>d(f)),this.services.backendConnector.load(c,this.options.ns,f=>{!f&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(f)})}else s(null)}reloadResources(e,n,s){const a=eu();return typeof e=="function"&&(s=e,e=void 0),typeof n=="function"&&(s=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),s||(s=Cf),this.services.backendConnector.reload(e,n,r=>{a.resolve(),s(r)}),a}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&hj.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!["cimode","dev"].includes(e)){for(let n=0;n<this.languages.length;n++){const s=this.languages[n];if(!["cimode","dev"].includes(s)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const s=eu();this.emit("languageChanging",e);const a=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},r=(c,d)=>{d?this.isLanguageChangingTo===e&&(a(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve((...f)=>this.t(...f)),n&&n(c,(...f)=>this.t(...f))},i=c=>{var h,m;!e&&!c&&this.services.languageDetector&&(c=[]);const d=zt(c)?c:c&&c[0],f=this.store.hasLanguageSomeTranslations(d)?d:this.services.languageUtils.getBestMatchFromCodes(zt(c)?[c]:c);f&&(this.language||a(f),this.translator.language||this.translator.changeLanguage(f),(m=(h=this.services.languageDetector)==null?void 0:h.cacheUserLanguage)==null||m.call(h,f)),this.loadResources(f,b=>{r(b,f)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(e),s}getFixedT(e,n,s){const a=(r,i,...c)=>{let d;typeof i!="object"?d=this.options.overloadTranslationOptionHandler([r,i].concat(c)):d={...i},d.lng=d.lng||a.lng,d.lngs=d.lngs||a.lngs,d.ns=d.ns||a.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||s||a.keyPrefix);const f={...this.options,...d};typeof d.keyPrefix=="function"&&(d.keyPrefix=$l(d.keyPrefix,f));const h=this.options.keySeparator||".";let m;return d.keyPrefix&&Array.isArray(r)?m=r.map(b=>(typeof b=="function"&&(b=$l(b,f)),`${d.keyPrefix}${h}${b}`)):(typeof r=="function"&&(r=$l(r,f)),m=d.keyPrefix?`${d.keyPrefix}${h}${r}`:r),this.t(m,d)};return zt(e)?a.lng=e:a.lngs=e,a.ns=n,a.keyPrefix=s,a}t(...e){var n;return(n=this.translator)==null?void 0:n.translate(...e)}exists(...e){var n;return(n=this.translator)==null?void 0:n.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=n.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:!1,r=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const i=(c,d)=>{const f=this.services.backendConnector.state[`${c}|${d}`];return f===-1||f===0||f===2};if(n.precheck){const c=n.precheck(this,i);if(c!==void 0)return c}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(s,e)&&(!a||i(r,e)))}loadNamespaces(e,n){const s=eu();return this.options.ns?(zt(e)&&(e=[e]),e.forEach(a=>{this.options.ns.includes(a)||this.options.ns.push(a)}),this.loadResources(a=>{s.resolve(),n&&n(a)}),s):(n&&n(),Promise.resolve())}loadLanguages(e,n){const s=eu();zt(e)&&(e=[e]);const a=this.options.preload||[],r=e.filter(i=>!a.includes(i)&&this.services.languageUtils.isSupportedCode(i));return r.length?(this.options.preload=a.concat(r),this.loadResources(i=>{s.resolve(),n&&n(i)}),s):(n&&n(),Promise.resolve())}dir(e){var a,r;if(e||(e=this.resolvedLanguage||(((a=this.languages)==null?void 0:a.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const c=i.getTextInfo();if(c&&c.direction)return c.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=((r=this.services)==null?void 0:r.languageUtils)||new hk(Ag());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.includes(s.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const s=new Nu(e,n);return s.createInstance=Nu.createInstance,s}cloneInstance(e={},n=Cf){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const a={...this.options,...e,isClone:!0},r=new Nu(a);if((e.debug!==void 0||e.prefix!==void 0)&&(r.logger=r.logger.clone(e)),["store","services","language"].forEach(c=>{r[c]=this[c]}),r.services={...this.services},r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},s){const c=Object.keys(this.store.data).reduce((d,f)=>(d[f]={...this.store.data[f]},d[f]=Object.keys(d[f]).reduce((h,m)=>(h[m]={...d[f][m]},h),d[f]),d),{});r.store=new pk(c,a),r.services.resourceStore=r.store}if(e.interpolation){const d={...Ag().interpolation,...this.options.interpolation,...e.interpolation},f={...a,interpolation:d};r.services.interpolator=new xk(f)}return r.translator=new hp(r.services,a),r.translator.on("*",(c,...d)=>{r.emit(c,...d)}),r.init(a,n),r.translator.options=a,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const On=Nu.createInstance();On.createInstance;On.dir;On.init;On.loadResources;On.reloadResources;On.use;On.changeLanguage;On.getFixedT;On.t;On.exists;On.setDefaultNamespace;On.hasLoadedNamespace;On.loadNamespaces;On.loadLanguages;const HM=(t,e,n,s)=>{var r,i,c,d;const a=[n,{code:e,...s||{}}];if((i=(r=t==null?void 0:t.services)==null?void 0:r.logger)!=null&&i.forward)return t.services.logger.forward(a,"warn","react-i18next::",!0);No(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),(d=(c=t==null?void 0:t.services)==null?void 0:c.logger)!=null&&d.warn?t.services.logger.warn(...a):console!=null&&console.warn&&console.warn(...a)},wk={},zb=(t,e,n,s)=>{No(n)&&wk[n]||(No(n)&&(wk[n]=new Date),HM(t,e,n,s))},gj=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},$b=(t,e,n)=>{t.loadNamespaces(e,gj(t,n))},kk=(t,e,n,s)=>{if(No(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return $b(t,n,s);n.forEach(a=>{t.options.ns.indexOf(a)<0&&t.options.ns.push(a)}),t.loadLanguages(e,gj(t,s))},WM=(t,e,n={})=>!e.languages||!e.languages.length?(zb(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:n.lng,precheck:(s,a)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!a(s.isLanguageChangingTo,t))return!1}}),No=t=>typeof t=="string",qM=t=>typeof t=="object"&&t!==null,VM=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,YM={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},GM=t=>YM[t],KM=t=>t.replace(VM,GM);let Ub={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:KM,transDefaultProps:void 0};const QM=(t={})=>{Ub={...Ub,...t}},XM=()=>Ub;let bj;const JM=t=>{bj=t},ZM=()=>bj,eD={type:"3rdParty",init(t){QM(t.options.react),JM(t)}},tD=x.createContext();class nD{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var jg={exports:{}},Ng={};/**
|
|
35
|
+
* @license React
|
|
36
|
+
* use-sync-external-store-shim.production.js
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the MIT license found in the
|
|
41
|
+
* LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/var Sk;function sD(){if(Sk)return Ng;Sk=1;var t=jx();function e(m,b){return m===b&&(m!==0||1/m===1/b)||m!==m&&b!==b}var n=typeof Object.is=="function"?Object.is:e,s=t.useState,a=t.useEffect,r=t.useLayoutEffect,i=t.useDebugValue;function c(m,b){var y=b(),w=s({inst:{value:y,getSnapshot:b}}),C=w[0].inst,N=w[1];return r(function(){C.value=y,C.getSnapshot=b,d(C)&&N({inst:C})},[m,y,b]),a(function(){return d(C)&&N({inst:C}),m(function(){d(C)&&N({inst:C})})},[m]),i(y),y}function d(m){var b=m.getSnapshot;m=m.value;try{var y=b();return!n(m,y)}catch{return!0}}function f(m,b){return b()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Ng.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Ng}var Ck;function aD(){return Ck||(Ck=1,jg.exports=sD()),jg.exports}var rD=aD();const iD=(t,e)=>{if(No(e))return e;if(qM(e)&&No(e.defaultValue))return e.defaultValue;if(typeof t=="function")return"";if(Array.isArray(t)){const n=t[t.length-1];return typeof n=="function"?"":n}return t},oD={t:iD,ready:!1},lD=()=>()=>{},dt=(t,e={})=>{var _,M,R;const{i18n:n}=e,{i18n:s,defaultNS:a}=x.useContext(tD)||{},r=n||s||ZM();r&&!r.reportNamespaces&&(r.reportNamespaces=new nD),r||zb(r,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=x.useMemo(()=>{var z;return{...XM(),...(z=r==null?void 0:r.options)==null?void 0:z.react,...e}},[r,e]),{useSuspense:c,keyPrefix:d}=i,f=t||a||((_=r==null?void 0:r.options)==null?void 0:_.defaultNS),h=No(f)?[f]:f||["translation"],m=x.useMemo(()=>h,h);(R=(M=r==null?void 0:r.reportNamespaces)==null?void 0:M.addUsedNamespaces)==null||R.call(M,m);const b=x.useRef(0),y=x.useCallback(z=>{if(!r)return lD;const{bindI18n:$,bindI18nStore:W}=i,L=()=>{b.current+=1,z()};return $&&r.on($,L),W&&r.store.on(W,L),()=>{$&&$.split(" ").forEach(F=>r.off(F,L)),W&&W.split(" ").forEach(F=>r.store.off(F,L))}},[r,i]),w=x.useRef(),C=x.useCallback(()=>{if(!r)return oD;const z=!!(r.isInitialized||r.initializedStoreOnce)&&m.every(V=>WM(V,r,i)),$=e.lng||r.language,W=b.current,L=w.current;if(L&&L.ready===z&&L.lng===$&&L.keyPrefix===d&&L.revision===W)return L;const H={t:r.getFixedT($,i.nsMode==="fallback"?m:m[0],d),ready:z,lng:$,keyPrefix:d,revision:W};return w.current=H,H},[r,m,d,i,e.lng]),[N,k]=x.useState(0),{t:j,ready:S}=rD.useSyncExternalStore(y,C,C);x.useEffect(()=>{if(r&&!S&&!c){const z=()=>k($=>$+1);e.lng?kk(r,e.lng,m,z):$b(r,m,z)}},[r,e.lng,m,S,c,N]);const T=r||{},D=x.useRef(null),E=x.useRef(),I=z=>{const $=Object.getOwnPropertyDescriptors(z);$.__original&&delete $.__original;const W=Object.create(Object.getPrototypeOf(z),$);if(!Object.prototype.hasOwnProperty.call(W,"__original"))try{Object.defineProperty(W,"__original",{value:z,writable:!1,enumerable:!1,configurable:!1})}catch{}return W},O=x.useMemo(()=>{const z=T,$=z==null?void 0:z.language;let W=z;z&&(D.current&&D.current.__original===z?E.current!==$?(W=I(z),D.current=W,E.current=$):W=D.current:(W=I(z),D.current=W,E.current=$));const L=!S&&!c?(...H)=>(zb(r,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),j(...H)):j,F=[L,W,S];return F.t=L,F.i18n=W,F.ready=S,F},[j,T,S,T.resolvedLanguage,T.language,T.languages]);if(r&&c&&!S)throw new Promise(z=>{const $=()=>z();e.lng?kk(r,e.lng,m,$):$b(r,m,$)});return O};function Hb(t){"@babel/helpers - typeof";return Hb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hb(t)}function xj(){return typeof XMLHttpRequest=="function"||(typeof XMLHttpRequest>"u"?"undefined":Hb(XMLHttpRequest))==="object"}function cD(t){return!!t&&typeof t.then=="function"}function uD(t){return cD(t)?t:Promise.resolve(t)}var dD=/\{\{(.+?)\}\}/g;function Ak(t,e){return t.replace(dD,function(n,s){var a=e[s.trim()];return a??n})}const fD="modulepreload",pD=function(t){return"/"+t},jk={},vt=function(e,n,s){let a=Promise.resolve();if(n&&n.length>0){let i=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=i(n.map(f=>{if(f=pD(f),f in jk)return;jk[f]=!0;const h=f.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const b=document.createElement("link");if(b.rel=h?"stylesheet":fD,h||(b.as="script"),b.crossOrigin="",b.href=f,d&&b.setAttribute("nonce",d),document.head.appendChild(b),h)return new Promise((y,w)=>{b.addEventListener("load",y),b.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function r(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return a.then(i=>{for(const c of i||[])c.status==="rejected"&&r(c.reason);return e().catch(r)})};function Nk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,s)}return n}function Tk(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Nk(Object(n),!0).forEach(function(s){hD(t,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Nk(Object(n)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(n,s))})}return t}function hD(t,e,n){return(e=mD(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mD(t){var e=gD(t,"string");return To(e)=="symbol"?e:e+""}function gD(t,e){if(To(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var s=n.call(t,e);if(To(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function To(t){"@babel/helpers - typeof";return To=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},To(t)}var Di=typeof fetch=="function"?fetch:void 0;typeof global<"u"&&global.fetch?Di=global.fetch:typeof window<"u"&&window.fetch&&(Di=window.fetch);var zu;xj()&&(typeof global<"u"&&global.XMLHttpRequest?zu=global.XMLHttpRequest:typeof window<"u"&&window.XMLHttpRequest&&(zu=window.XMLHttpRequest));var mp;typeof ActiveXObject=="function"&&(typeof global<"u"&&global.ActiveXObject?mp=global.ActiveXObject:typeof window<"u"&&window.ActiveXObject&&(mp=window.ActiveXObject));typeof Di!="function"&&(Di=void 0);if(!Di&&!zu&&!mp)try{vt(()=>import("./browser-ponyfill-DZOWXZ4K.js").then(t=>t.b),__vite__mapDeps([0,1])).then(function(t){Di=t.default}).catch(function(){})}catch{}var Wb=function(e,n){if(n&&To(n)==="object"){var s="";for(var a in n)s+="&"+encodeURIComponent(a)+"="+encodeURIComponent(n[a]);if(!s)return e;e=e+(e.indexOf("?")!==-1?"&":"?")+s.slice(1)}return e},_k=function(e,n,s,a){var r=function(d){if(!d.ok)return s(d.statusText||"Error",{status:d.status});d.text().then(function(f){s(null,{status:d.status,data:f})}).catch(s)};if(a){var i=a(e,n);if(i instanceof Promise){i.then(r).catch(s);return}}typeof fetch=="function"?fetch(e,n).then(r).catch(s):Di(e,n).then(r).catch(s)},Ek=!1,bD=function(e,n,s,a){e.queryStringParams&&(n=Wb(n,e.queryStringParams));var r=Tk({},typeof e.customHeaders=="function"?e.customHeaders():e.customHeaders);typeof window>"u"&&typeof global<"u"&&typeof global.process<"u"&&global.process.versions&&global.process.versions.node&&(r["User-Agent"]="i18next-http-backend (node/".concat(global.process.version,"; ").concat(global.process.platform," ").concat(global.process.arch,")")),s&&(r["Content-Type"]="application/json");var i=typeof e.requestOptions=="function"?e.requestOptions(s):e.requestOptions,c=Tk({method:s?"POST":"GET",body:s?e.stringify(s):void 0,headers:r},Ek?{}:i),d=typeof e.alternateFetch=="function"&&e.alternateFetch.length>=1?e.alternateFetch:void 0;try{_k(n,c,a,d)}catch(f){if(!i||Object.keys(i).length===0||!f.message||f.message.indexOf("not implemented")<0)return a(f);try{Object.keys(i).forEach(function(h){delete c[h]}),_k(n,c,a,d),Ek=!0}catch(h){a(h)}}},xD=function(e,n,s,a){s&&To(s)==="object"&&(s=Wb("",s).slice(1)),e.queryStringParams&&(n=Wb(n,e.queryStringParams));try{var r=zu?new zu:new mp("MSXML2.XMLHTTP.3.0");r.open(s?"POST":"GET",n,1),e.crossDomain||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.withCredentials=!!e.withCredentials,s&&r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),r.overrideMimeType&&r.overrideMimeType("application/json");var i=e.customHeaders;if(i=typeof i=="function"?i():i,i)for(var c in i)r.setRequestHeader(c,i[c]);r.onreadystatechange=function(){r.readyState>3&&a(r.status>=400?r.statusText:null,{status:r.status,data:r.responseText})},r.send(s)}catch(d){console&&console.log(d)}},yD=function(e,n,s,a){if(typeof s=="function"&&(a=s,s=void 0),a=a||function(){},Di&&n.indexOf("file:")!==0)return bD(e,n,s,a);if(xj()||typeof ActiveXObject=="function")return xD(e,n,s,a);a(new Error("No fetch and no xhr implementation found!"))};function Vl(t){"@babel/helpers - typeof";return Vl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vl(t)}function Mk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,s)}return n}function Tg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Mk(Object(n),!0).forEach(function(s){yj(t,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Mk(Object(n)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(n,s))})}return t}function vD(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function wD(t,e){for(var n=0;n<e.length;n++){var s=e[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,vj(s.key),s)}}function kD(t,e,n){return e&&wD(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function yj(t,e,n){return(e=vj(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vj(t){var e=SD(t,"string");return Vl(e)=="symbol"?e:e+""}function SD(t,e){if(Vl(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var s=n.call(t,e);if(Vl(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var CD=function(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",parse:function(n){return JSON.parse(n)},stringify:JSON.stringify,parsePayload:function(n,s,a){return yj({},s,a||"")},parseLoadPayload:function(n,s){},request:yD,reloadInterval:typeof window<"u"?!1:3600*1e3,customHeaders:{},queryStringParams:{},crossDomain:!1,withCredentials:!1,overrideMimeType:!1,requestOptions:{mode:"cors",credentials:"same-origin",cache:"default"}}},wj=(function(){function t(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};vD(this,t),this.services=e,this.options=n,this.allOptions=s,this.type="backend",this.init(e,n,s)}return kD(t,[{key:"init",value:function(n){var s=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.services=n,this.options=Tg(Tg(Tg({},CD()),this.options||{}),a),this.allOptions=r,this.services&&this.options.reloadInterval){var i=setInterval(function(){return s.reload()},this.options.reloadInterval);Vl(i)==="object"&&typeof i.unref=="function"&&i.unref()}}},{key:"readMulti",value:function(n,s,a){this._readAny(n,n,s,s,a)}},{key:"read",value:function(n,s,a){this._readAny([n],n,[s],s,a)}},{key:"_readAny",value:function(n,s,a,r,i){var c=this,d=this.options.loadPath;typeof this.options.loadPath=="function"&&(d=this.options.loadPath(n,a)),d=uD(d),d.then(function(f){if(!f)return i(null,{});var h=Ak(f,{lng:n.join("+"),ns:a.join("+")});c.loadUrl(h,i,s,r)})}},{key:"loadUrl",value:function(n,s,a,r){var i=this,c=typeof a=="string"?[a]:a,d=typeof r=="string"?[r]:r,f=this.options.parseLoadPayload(c,d);this.options.request(this.options,n,f,function(h,m){if(m&&(m.status>=500&&m.status<600||!m.status))return s("failed loading "+n+"; status code: "+m.status,!0);if(m&&m.status>=400&&m.status<500)return s("failed loading "+n+"; status code: "+m.status,!1);if(!m&&h&&h.message){var b=h.message.toLowerCase(),y=["failed","fetch","network","load"].find(function(N){return b.indexOf(N)>-1});if(y)return s("failed loading "+n+": "+h.message,!0)}if(h)return s(h,!1);var w,C;try{typeof m.data=="string"?w=i.options.parse(m.data,a,r):w=m.data}catch{C="failed parsing "+n+" to json"}if(C)return s(C,!1);s(null,w)})}},{key:"create",value:function(n,s,a,r,i){var c=this;if(this.options.addPath){typeof n=="string"&&(n=[n]);var d=this.options.parsePayload(s,a,r),f=0,h=[],m=[];n.forEach(function(b){var y=c.options.addPath;typeof c.options.addPath=="function"&&(y=c.options.addPath(b,s));var w=Ak(y,{lng:b,ns:s});c.options.request(c.options,w,d,function(C,N){f+=1,h.push(C),m.push(N),f===n.length&&typeof i=="function"&&i(h,m)})})}}},{key:"reload",value:function(){var n=this,s=this.services,a=s.backendConnector,r=s.languageUtils,i=s.logger,c=a.language;if(!(c&&c.toLowerCase()==="cimode")){var d=[],f=function(m){var b=r.toResolveHierarchy(m);b.forEach(function(y){d.indexOf(y)<0&&d.push(y)})};f(c),this.allOptions.preload&&this.allOptions.preload.forEach(function(h){return f(h)}),d.forEach(function(h){n.allOptions.ns.forEach(function(m){a.read(h,m,"read",null,null,function(b,y){b&&i.warn("loading namespace ".concat(m," for language ").concat(h," failed"),b),!b&&y&&i.log("loaded namespace ".concat(m," for language ").concat(h),y),a.loaded("".concat(h,"|").concat(m),b,y)})})})}}}])})();wj.type="backend";const{slice:AD,forEach:jD}=[];function ND(t){return jD.call(AD.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function TD(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(n=>n.test(t))}const Dk=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,_D=function(t,e){const s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},a=encodeURIComponent(e);let r=`${t}=${a}`;if(s.maxAge>0){const i=s.maxAge-0;if(Number.isNaN(i))throw new Error("maxAge should be a Number");r+=`; Max-Age=${Math.floor(i)}`}if(s.domain){if(!Dk.test(s.domain))throw new TypeError("option domain is invalid");r+=`; Domain=${s.domain}`}if(s.path){if(!Dk.test(s.path))throw new TypeError("option path is invalid");r+=`; Path=${s.path}`}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");r+=`; Expires=${s.expires.toUTCString()}`}if(s.httpOnly&&(r+="; HttpOnly"),s.secure&&(r+="; Secure"),s.sameSite)switch(typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite){case!0:r+="; SameSite=Strict";break;case"lax":r+="; SameSite=Lax";break;case"strict":r+="; SameSite=Strict";break;case"none":r+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return s.partitioned&&(r+="; Partitioned"),r},Rk={create(t,e,n,s){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+n*60*1e3)),s&&(a.domain=s),document.cookie=_D(t,e,a)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let s=0;s<n.length;s++){let a=n[s];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(e)===0)return a.substring(e.length,a.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var ED={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return Rk.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:s,cookieDomain:a,cookieOptions:r}=e;n&&typeof document<"u"&&Rk.create(n,t,s,a,r)}},MD={name:"querystring",lookup(t){var s;let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:a}=window.location;!window.location.search&&((s=window.location.hash)==null?void 0:s.indexOf("?"))>-1&&(a=window.location.hash.substring(window.location.hash.indexOf("?")));const i=a.substring(1).split("&");for(let c=0;c<i.length;c++){const d=i[c].indexOf("=");d>0&&i[c].substring(0,d)===e&&(n=i[c].substring(d+1))}}return n}},DD={name:"hash",lookup(t){var a;let{lookupHash:e,lookupFromHashIndex:n}=t,s;if(typeof window<"u"){const{hash:r}=window.location;if(r&&r.length>2){const i=r.substring(1);if(e){const c=i.split("&");for(let d=0;d<c.length;d++){const f=c[d].indexOf("=");f>0&&c[d].substring(0,f)===e&&(s=c[d].substring(f+1))}}if(s)return s;if(!s&&n>-1){const c=r.match(/\/([a-zA-Z-]*)/g);return Array.isArray(c)?(a=c[typeof n=="number"?n:0])==null?void 0:a.replace("/",""):void 0}}}return s}};let Nl=null;const Ok=()=>{if(Nl!==null)return Nl;try{if(Nl=typeof window<"u"&&window.localStorage!==null,!Nl)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Nl=!1}return Nl};var RD={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&Ok())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&Ok()&&window.localStorage.setItem(n,t)}};let Tl=null;const Lk=()=>{if(Tl!==null)return Tl;try{if(Tl=typeof window<"u"&&window.sessionStorage!==null,!Tl)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Tl=!1}return Tl};var OD={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&Lk())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&Lk()&&window.sessionStorage.setItem(n,t)}},LD={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:s,language:a}=navigator;if(n)for(let r=0;r<n.length;r++)e.push(n[r]);s&&e.push(s),a&&e.push(a)}return e.length>0?e:void 0}},ID={name:"htmlTag",lookup(t){let{htmlTag:e}=t,n;const s=e||(typeof document<"u"?document.documentElement:null);return s&&typeof s.getAttribute=="function"&&(n=s.getAttribute("lang")),n}},PD={name:"path",lookup(t){var a;let{lookupFromPathIndex:e}=t;if(typeof window>"u")return;const n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(n)?(a=n[typeof e=="number"?e:0])==null?void 0:a.replace("/",""):void 0}},BD={name:"subdomain",lookup(t){var a,r;let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,s=typeof window<"u"&&((r=(a=window.location)==null?void 0:a.hostname)==null?void 0:r.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(s)return s[n]}};let kj=!1;try{document.cookie,kj=!0}catch{}const Sj=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];kj||Sj.splice(1,1);const FD=()=>({order:Sj,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Cj{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,n)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=ND(n,this.options||{},FD()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=a=>a.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(ED),this.addDetector(MD),this.addDetector(RD),this.addDetector(OD),this.addDetector(LD),this.addDetector(ID),this.addDetector(PD),this.addDetector(BD),this.addDetector(DD)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,n=[];return e.forEach(s=>{if(this.detectors[s]){let a=this.detectors[s].lookup(this.options);a&&typeof a=="string"&&(a=[a]),a&&(n=n.concat(a))}}),n=n.filter(s=>s!=null&&!TD(s)).map(s=>this.options.convertDetectedLanguage(s)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?n:n.length>0?n[0]:null}cacheUserLanguage(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;n&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||n.forEach(s=>{this.detectors[s]&&this.detectors[s].cacheUserLanguage(e,this.options)}))}}Cj.type="languageDetector";const gp={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a",default:"#888888"},qb={running:"#4aff9e",stopped:"#888888",error:"#ff4a4a",unknown:"#ffaa00",starting:"#4a9eff",stopping:"#ffaa00"},zD={on_track:"#4aff9e",stalled:"#ff9e4a",blocked:"#ff4a4a",completed:"#4a9eff",idle:"#888888"},Sq=["#4a9eff","#4aff9e","#ff9e4a","#ff4a9e","#9e4aff","#ff4a4a","#4affff","#ffff4a","#4ad7ff","#00e6a8","#ff6b4a","#ff66cc","#b84aff","#ff4a7a","#00d9ff","#e6ff4a","#1a3a6e","#1a5e3a","#6e3a1a","#6e1a4a","#4a1a6e","#6e1a1a","#1a5e5e","#5e5e1a","#1a4a6e","#145a47","#6e2c1a","#6e1a5e","#3b1a6e","#6e1a33","#14566e","#4f5e1a"],Af={recent:"#50fa7b",short:"#f1fa8c",medium:"#ffb86c",long:"#ff5555"};function Tx(t){const n=Math.floor((Date.now()-t)/1e3)/60;return n<1?Af.recent:n<5?Af.short:n<30?Af.medium:Af.long}function _x(t){return gp[t]??gp.default}let Zf=null;function Aj(){if(!Zf)try{Zf=globalThis.__i18n}catch{}return Zf}function $D(t){Zf=t}function UD(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString()}function HD(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString()}function WD(t){var a;const e=Aj(),n=(a=e==null?void 0:e.t)==null?void 0:a.bind(e),s=Math.floor((Date.now()-t)/1e3);return s<60?n?n("common:time.seconds",{count:s}):`${s}s`:s<3600?n?n("common:time.minutes",{count:Math.floor(s/60)}):`${Math.floor(s/60)}m`:s<86400?n?n("common:time.hours",{count:Math.floor(s/3600)}):`${Math.floor(s/3600)}h`:n?n("common:time.days",{count:Math.floor(s/86400)}):`${Math.floor(s/86400)}d`}function Ex(t){var f;const e=Aj(),n=(f=e==null?void 0:e.t)==null?void 0:f.bind(e),s=Math.floor((Date.now()-t)/1e3);if(s<5)return n?n("common:time.justNow"):"just now";if(s<60)return n?n("common:time.secondsAgo",{count:s}):`${s}s ago`;const a=Math.floor(s/60);if(a<60){const h=s%60;return h>0?n?n("common:time.minutesSecondsAgo",{minutes:a,seconds:h}):`${a}m ${h}s ago`:n?n("common:time.minutesAgo",{count:a}):`${a}m ago`}const r=Math.floor(a/60),i=a%60;if(r<24)return i>0?n?n("common:time.hoursMinutesAgo",{hours:r,minutes:i}):`${r}h ${i}m ago`:n?n("common:time.hoursAgo",{count:r}):`${r}h ago`;const c=Math.floor(r/24),d=r%24;return d>0?n?n("common:time.daysHoursAgo",{days:c,hours:d}):`${c}d ${d}h ago`:n?n("common:time.daysAgo",{count:c}):`${c}d ago`}function Tu(t,e){return t?e?t.replace(/\s*\(?\s*~?\$[\d,.]+\s*\)?/g,"").replace(/\s*cost[:\s]+~?\$[\d,.]+/gi,"").replace(/\s*price[:\s]+~?\$[\d,.]+/gi,"").replace(/\s*\(~?\$[\d,.]+\s*(?:USD|cost|spent)?\)/gi,"").replace(/\s*-\s*~?\$[\d,.]+\s*$/g,"").replace(/[^\S\n]+/g," ").trim():t:""}On.use(wj).use(Cj).use(eD).init({fallbackLng:"en",ns:["common","tools","config","errors","notifications","dashboard","terminal"],defaultNS:"common",backend:{loadPath:"/locales/{{lng}}/{{ns}}.json"},detection:{order:["localStorage","navigator"],lookupLocalStorage:"tide-commander-language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!0}}).then(()=>{$D(On)});const pt={CONFIG:"tide-commander-config",SHOW_FPS:"tide-show-fps",SETTINGS:"tide-settings",SHORTCUTS:"tide-shortcuts",MOUSE_CONTROLS:"tide-mouse-controls",BACKEND_URL:"tide-backend-url",AUTH_TOKEN:"tide-auth-token",SCENE_VIEW_MODE:"tide-scene-view-mode",CAMERA_STATE:"tide-camera-state",CAMERA_STATE_2D:"tide-camera-state-2d",VIEW_MODE:"guake-view-mode",ADVANCED_VIEW:"guake-advanced-view",TERMINAL_HEIGHT:"guake-terminal-height",TERMINAL_FULLSCREEN:"guake-terminal-fullscreen",INPUT_TEXT_PREFIX:"guake-input-",PASTED_TEXTS_PREFIX:"guake-pasted-",COMMANDER_TAB:"commander-active-tab",COMMANDER_FILTERS:"commander-filters",LAST_CWD:"tide-last-cwd",GLOBAL_SUPERVISOR_COLLAPSED:"tide-global-supervisor-collapsed",TOOLS_COLLAPSED:"tide-tool-history-collapsed",FILES_COLLAPSED:"tide-file-history-collapsed",MOBILE_VIEW:"tide-mobile-view",TREE_PANEL_WIDTH:"tide-tree-panel-width",MOBILE_TREE_PANEL_HEIGHT:"tide-mobile-tree-panel-height",AGENT_ORDER:"tide-agent-order",AOP_CONFIG:"tide-aop-config",AOP_OPEN:"tide-aop-open",MOBILE_OVERVIEW_HEIGHT:"tide-mobile-overview-height",GIT_PANEL_OPEN:"guake-git-panel-open",GIT_PANEL_MODE:"guake-git-panel-mode",GIT_PANEL_VIEW_MODE:"guake-git-view-mode",GIT_PANEL_FOLDER_IDX:"guake-git-folder-idx",BUILDINGS_PANEL_OPEN:"guake-buildings-panel-open",WORKFLOW_PANEL_OPEN:"guake-workflow-panel-open",SIDE_PANEL_WIDTH:"guake-side-panel-width",UNSEEN_AGENTS:"tide-unseen-agents",PENDING_MESSAGES:"tide-pending-messages"},Vb="tide-backend-url-change";function Na(t,e){try{const n=localStorage.getItem(t);return n===null?e:JSON.parse(n)}catch{return e}}function Fa(t,e=""){try{return localStorage.getItem(t)??e}catch{return e}}function Ni(t,e=!1){try{const n=localStorage.getItem(t);return n===null?e:n==="true"}catch{return e}}function Mx(t,e){try{const n=localStorage.getItem(t);if(n===null)return e;const s=Number(n);return isNaN(s)?e:s}catch{return e}}function La(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Wr(t,e){try{localStorage.setItem(t,e)}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Ti(t,e){try{localStorage.setItem(t,String(e))}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Dx(t,e){try{localStorage.setItem(t,String(e))}catch(n){console.error(`Failed to save to localStorage: ${t}`,n)}}function Ik(t){try{localStorage.removeItem(t)}catch(e){console.error(`Failed to remove from localStorage: ${t}`,e)}}function Ea(){const t=Rx();return t?t.replace(/\/$/,""):`${window.location.protocol}//${window.location.host}`}function Ii(){return Fa(pt.AUTH_TOKEN,"")}function Rx(){return Fa(pt.BACKEND_URL,"")}function qD(t){const e=t.trim();Wr(pt.BACKEND_URL,e),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Vb,{detail:e}))}function VD(t){if(typeof window>"u")return()=>{};const e=s=>{t(s.detail)},n=s=>{s.key===pt.BACKEND_URL&&t(s.newValue??"")};return window.addEventListener(Vb,e),window.addEventListener("storage",n),()=>{window.removeEventListener(Vb,e),window.removeEventListener("storage",n)}}function Rt(t){return`${Ea()}${t}`}async function Bt(t,e){const n=Ii(),s=new Headers(e==null?void 0:e.headers);return n&&s.set("X-Auth-Token",n),fetch(t,{...e,headers:s,cache:"no-store"})}function Yb(t){const e=Ii();if(!e)return t;try{const n=!t.startsWith("http://")&&!t.startsWith("https://"),s=n?"http://dummy":void 0,a=new URL(t,s);return a.searchParams.set("token",e),n?a.pathname+a.search:a.toString()}catch{const n=t.includes("?")?"&":"?";return`${t}${n}token=${encodeURIComponent(e)}`}}function cs(t=!1,e){const[n,s]=x.useState(t),[a,r]=x.useState(e),i=x.useCallback(f=>{f!==void 0&&r(f),s(!0)},[]),c=x.useCallback(()=>{s(!1)},[]),d=x.useCallback(()=>{s(f=>!f)},[]);return{isOpen:n,data:a,open:i,close:c,toggle:d,setData:r}}function YD(){const[t,e]=x.useState(null),n=x.useCallback(a=>{e(a)},[]),s=x.useCallback(()=>{e(null)},[]);return{isOpen:t!==null,id:t,open:n,close:s}}function GD(){const[t,e]=x.useState(!1),[n,s]=x.useState({x:0,y:0}),[a,r]=x.useState({x:0,z:0}),[i,c]=x.useState({type:"ground"}),d=x.useCallback((h,m,b)=>{s(h),r(m),c(b),e(!0)},[]),f=x.useCallback(()=>{e(!1)},[]);return{isOpen:t,screenPosition:n,worldPosition:a,target:i,open:d,close:f}}const ca=[],KD=new Set;function bp(){KD.forEach(t=>t())}function QD(t,e){const n=ca.findIndex(s=>s.id===t);return n!==-1&&ca.splice(n,1),ca.push({id:t,close:e}),bp(),()=>{const s=ca.findIndex(a=>a.id===t);s!==-1&&(ca.splice(s,1),bp())}}function ep(){return ca.length===0?!1:(ca.pop().close(),bp(),!0)}function XD(t){const e=ca.findIndex(n=>n.id===t);return e===-1?!1:e<ca.length-1}function JD(...t){const e=new Set(t);for(;ca.length>0;){const n=ca[ca.length-1];if(e.has(n.id))break;ca.pop().close()}bp()}function Xt(t,e,n){const s=x.useRef(n);s.current=n,x.useEffect(()=>e?QD(t,()=>s.current()):void 0,[t,e])}const $u=5,_g={0:0,1:4,2:8,3:14,4:25,5:50};let _u=null,Pk=!1;async function ZD(){if(Pk)return _u;Pk=!0;try{const t=await vt(()=>import("./index-Bf3KKyiV.js"),__vite__mapDeps([2,3,1,4]));_u={Haptics:t.Haptics,ImpactStyle:t.ImpactStyle}}catch{}return _u}ZD();function xp(t){const e=Math.round(t),n=e<=0?0:e>=$u?$u:e;if(n!==0){if(_u){const{Haptics:s,ImpactStyle:a}=_u;if(n<=2&&typeof s.selectionChanged=="function"){s.selectionChanged().catch(()=>{navigator.vibrate&&navigator.vibrate(_g[n])});return}const i={3:"Light",4:"Medium",5:"Heavy"}[n];if(i&&a[i]){s.impact({style:a[i]}).catch(()=>{navigator.vibrate&&navigator.vibrate(_g[n])});return}}navigator.vibrate&&navigator.vibrate(_g[n])}}function Bk(t,e){const{threshold:n=80,maxVerticalMovement:s=50,enabled:a=!0,onSwipeLeft:r,onSwipeRight:i,onSwipeMove:c,onSwipeCancel:d,vibrationIntensity:f=1}=e,h=x.useRef({startX:0,startY:0,startTime:0,isTracking:!1,hasMovedEnough:!1}),m=x.useCallback(C=>{if(C.touches.length!==1)return;const N=C.touches[0];h.current={startX:N.clientX,startY:N.clientY,startTime:Date.now(),isTracking:!0,hasMovedEnough:!1}},[]),b=x.useCallback(C=>{if(!h.current.isTracking||C.touches.length!==1)return;const N=C.touches[0],k=N.clientX-h.current.startX;if(Math.abs(N.clientY-h.current.startY)>s){h.current.isTracking=!1,h.current.hasMovedEnough&&(d==null||d());return}const T=window.innerWidth*.4,D=Math.max(-1,Math.min(1,k/T));Math.abs(k)>=12&&(h.current.hasMovedEnough=!0,c==null||c(D))},[s,c,d]),y=x.useCallback(C=>{const N=h.current.isTracking,k=h.current.hasMovedEnough;if(!N)return;const j=C.changedTouches[0],S=j.clientX-h.current.startX,T=Math.abs(j.clientY-h.current.startY),D=Date.now()-h.current.startTime;h.current.isTracking=!1,h.current.hasMovedEnough=!1,Math.abs(S)>=n&&T<=s&&D<500?(xp(f),S>0?i==null||i():r==null||r()):k&&(d==null||d())},[n,s,f,r,i,d]),w=x.useCallback(()=>{const C=h.current.hasMovedEnough;h.current.isTracking=!1,h.current.hasMovedEnough=!1,C&&(d==null||d())},[d]);x.useEffect(()=>{const C=t.current;if(!(!C||!a||!(window.innerWidth<=768&&"ontouchstart"in window)))return C.addEventListener("touchstart",m,{passive:!0}),C.addEventListener("touchmove",b,{passive:!0}),C.addEventListener("touchend",y,{passive:!0}),C.addEventListener("touchcancel",w,{passive:!0}),()=>{C.removeEventListener("touchstart",m),C.removeEventListener("touchmove",b),C.removeEventListener("touchend",y),C.removeEventListener("touchcancel",w)}},[t,a,m,b,y,w])}const Fk=8,eR=.93,zk=.4;function tR(t){const{gestureRef:e,agentListRef:n,enabled:s,onSelect:a}=t,[r,i]=x.useState(!1),[c,d]=x.useState(null),f=x.useRef(!1),h=x.useRef(null),m=x.useRef(a);m.current=a;const b=x.useCallback(()=>{if(f.current)return;f.current=!0,i(!0);const N=n.current;if(N){const k=Math.round(N.clientHeight/2);N.style.paddingTop=`${k}px`,N.style.paddingBottom=`${k}px`}},[n]),y=x.useCallback(()=>{f.current=!1,h.current=null,i(!1),d(null);const N=n.current;N&&(N.style.paddingTop="",N.style.paddingBottom="")},[n]),w=x.useCallback(N=>{const k=n.current;if(!k)return;k.scrollTop+=N;const j=k.getBoundingClientRect(),S=j.top+j.height/2,T=j.left+j.width/2,D=document.elementFromPoint(T,S);let E=null;if(D){const I=D.closest("[data-agent-id]");I&&k.contains(I)&&(E=I.dataset.agentId)}if(E!==h.current&&(h.current=E,d(E),E)){const I=U.getState().settings.vibrationIntensity??1;xp(I)}},[n]),C=x.useCallback(()=>{const N=h.current;if(N){const k=U.getState().settings.vibrationIntensity??1,j=k<=0?0:Math.min(k+1,$u);xp(j),m.current(N)}y()},[y]);return x.useEffect(()=>{const N=e.current;if(!N||!s)return;const k=N.style.touchAction;N.style.touchAction="none";let j=!1,S=!1,T=0,D=0,E=0,I=0,O=0,_=0,M=0,R=0;const z=()=>{M&&(cancelAnimationFrame(M),M=0)},$=()=>{if(Math.abs(_)<zk){_=0;return}N.scrollTop+=_,_*=eR,M=requestAnimationFrame($)},W=V=>{if(z(),V.touches.length>=2){V.preventDefault(),j=!1,S=!1,R=(V.touches[0].clientY+V.touches[1].clientY)/2,b(),w(0);return}j=!0,S=!1,T=V.touches[0].clientX,D=V.touches[0].clientY,E=N.scrollTop,I=D,O=performance.now(),_=0},L=V=>{if(V.touches.length>=2){if(V.preventDefault(),(S||j)&&(S=!1,j=!1),!f.current){R=(V.touches[0].clientY+V.touches[1].clientY)/2,b(),w(0);return}const K=(V.touches[0].clientY+V.touches[1].clientY)/2,ne=R-K;R=K,w(ne);return}if(f.current&&V.touches.length===1){V.preventDefault();const K=V.touches[0].clientY,ne=R-K;R=K,w(ne);return}if(!j&&!S)return;const G=V.touches[0].clientX,B=V.touches[0].clientY;if(j&&!S){const K=Math.abs(G-T),ne=Math.abs(B-D);if(K<Fk&&ne<Fk)return;if(ne>=K)S=!0,j=!1,V.preventDefault();else{j=!1;return}}if(S){V.preventDefault();const K=performance.now(),ne=K-O;N.scrollTop=E+(D-B),ne>0&&(_=(I-B)/ne*16),I=B,O=K}},F=V=>{if(f.current&&V.touches.length===0){C();return}f.current||(S||j)&&V.touches.length===0&&(S&&Math.abs(_)>zk&&(M=requestAnimationFrame($)),S=!1,j=!1)},H=()=>{S=!1,j=!1,z(),f.current&&y()};return N.addEventListener("touchstart",W,{passive:!1}),N.addEventListener("touchmove",L,{passive:!1}),N.addEventListener("touchend",F,{passive:!0}),N.addEventListener("touchcancel",H,{passive:!0}),()=>{N.removeEventListener("touchstart",W),N.removeEventListener("touchmove",L),N.removeEventListener("touchend",F),N.removeEventListener("touchcancel",H),N.style.touchAction=k,z();const V=n.current;V&&(V.style.paddingTop="",V.style.paddingBottom="")}},[e,n,s,b,y,w,C]),{isActive:r,hoveredAgentId:c}}const nR={width:400,height:300,copyStyleSheets:!0,keepOnTop:"focus"};function sR(){return"documentPictureInPicture"in window}function aR(t,e){for(const r of t.styleSheets)try{if(r.cssRules){const i=e.createElement("style");for(const c of r.cssRules)i.appendChild(e.createTextNode(c.cssText));e.head.appendChild(i)}}catch{if(r.href){const i=e.createElement("link");i.rel="stylesheet",i.href=r.href,e.head.appendChild(i)}}const n=t.documentElement.style.cssText;n&&(e.documentElement.style.cssText=n);const s=getComputedStyle(t.documentElement),a=[];for(let r=0;r<s.length;r++){const i=s[r];i.startsWith("--")&&a.push(`${i}: ${s.getPropertyValue(i)}`)}if(a.length>0){const r=e.createElement("style");r.textContent=`:root { ${a.join("; ")} }`,e.head.appendChild(r)}}function rR(){const[t,e]=x.useState(!1),[n,s]=x.useState(null),[a,r]=x.useState(null),i=x.useRef(null),c=sR(),d=x.useCallback(()=>{if(i.current){const m=i.current.__cleanupFns;m&&m.forEach(b=>b()),i.current.close(),i.current=null}s(null),r(null),e(!1)},[]),f=x.useCallback(async m=>{if(!c)return console.warn("Document Picture-in-Picture is not supported in this browser"),!1;i.current&&d();const b={...nR,...m};try{const w=await window.documentPictureInPicture.requestWindow({width:b.width,height:b.height,disallowReturnToOpener:!0});i.current=w,b.copyStyleSheets&&aR(document,w.document);const C=w.document.createElement("div");C.id="pip-root",C.style.width="100%",C.style.height="100%",w.document.body.appendChild(C),w.document.body.style.margin="0",w.document.body.style.padding="0",w.document.body.style.overflow="hidden",w.addEventListener("pagehide",()=>{i.current=null,s(null),r(null),e(!1)});const N=[];if(b.keepOnTop&&b.keepOnTop!=="none"){const k=b.keepOnTop==="raise",j=()=>{i.current&&!i.current.closed&&setTimeout(()=>{i.current&&!i.current.closed&&(i.current.focus(),k&&setTimeout(()=>window.focus(),10))},50)},S=()=>{document.visibilityState==="visible"&&i.current&&!i.current.closed&&setTimeout(()=>{i.current&&!i.current.closed&&(i.current.focus(),k&&setTimeout(()=>window.focus(),10))},100)};window.addEventListener("focus",j),document.addEventListener("visibilitychange",S),N.push(()=>window.removeEventListener("focus",j),()=>document.removeEventListener("visibilitychange",S))}return w.__cleanupFns=N,s(w),r(C),e(!0),!0}catch(y){return console.error("Failed to open Picture-in-Picture window:",y),!1}},[c,d]),h=x.useCallback(async m=>{t?d():await f(m)},[t,f,d]);return x.useEffect(()=>()=>{i.current&&i.current.close()},[]),x.useMemo(()=>({isOpen:t,pipWindow:n,pipContainer:a,isSupported:c,open:f,close:d,toggle:h}),[t,n,a,c,f,d,h])}function tu(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}class iR{constructor(){Xe(this,"messages",new Map);Xe(this,"logs",[]);Xe(this,"maxMessagesPerAgent",200);Xe(this,"maxLogs",500);Xe(this,"enabled",!0);Xe(this,"listeners",new Set);Xe(this,"logListeners",new Set)}setEnabled(e){this.enabled=e,this.notifyListeners("all")}isEnabled(){return this.enabled}captureSent(e,n){try{const s=JSON.parse(n);console.log(`[AgentDebugger] SENT - agent: ${e.slice(0,4)}, type: ${s.type}, size: ${n.length}B`),this.addMessage(e,{id:tu(),agentId:e,direction:"sent",type:s.type||"unknown",payload:s.payload||s,timestamp:Date.now(),size:n.length,raw:n})}catch(s){console.error("[AgentDebugger] Failed to parse SENT message:",String(s).slice(0,80)),this.addMessage(e,{id:tu(),agentId:e,direction:"sent",type:"parse_error",payload:{error:String(s)},timestamp:Date.now(),size:n.length,raw:n})}}captureReceived(e,n){try{const s=JSON.parse(n);console.log(`[AgentDebugger] RECEIVED - agent: ${e.slice(0,4)}, type: ${s.type}, size: ${n.length}B`),this.addMessage(e,{id:tu(),agentId:e,direction:"received",type:s.type||"unknown",payload:s.payload||s,timestamp:Date.now(),size:n.length,raw:n})}catch(s){console.error("[AgentDebugger] Failed to parse RECEIVED message:",String(s).slice(0,80)),this.addMessage(e,{id:tu(),agentId:e,direction:"received",type:"parse_error",payload:{error:String(s)},timestamp:Date.now(),size:n.length,raw:n})}}addMessage(e,n){let s=this.messages.get(e);s||(s=[],this.messages.set(e,s)),s.push(n),console.log(`[AgentDebugger] Added message for ${e}, total: ${s.length}, type: ${n.type}, direction: ${n.direction}`),s.length>this.maxMessagesPerAgent&&s.shift(),this.notifyListeners(e)}getMessages(e){return this.messages.get(e)||[]}getStats(e){const n=this.getMessages(e),s=n.filter(i=>i.direction==="sent").length,a=n.filter(i=>i.direction==="received").length,r=[...new Set(n.map(i=>i.type))];return{total:n.length,sent:s,received:a,messageTypes:r}}clearMessages(e){this.messages.delete(e),this.notifyListeners(e)}clearAllMessages(){this.messages.clear(),this.notifyListeners("all")}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(e){this.listeners.forEach(n=>n(e))}getAgentIds(){return Array.from(this.messages.keys())}log(e,n,s,a){const r={id:tu(),level:e,message:n,data:s,timestamp:Date.now(),source:a};this.logs.push(r),this.logs.length>this.maxLogs&&this.logs.shift(),this.notifyLogListeners()}debug(e,n,s){this.log("debug",e,n,s)}info(e,n,s){this.log("info",e,n,s)}warn(e,n,s){this.log("warn",e,n,s)}error(e,n,s){this.log("error",e,n,s)}getLogs(){return this.logs}clearLogs(){this.logs=[],this.notifyLogListeners()}subscribeLogs(e){return this.logListeners.add(e),()=>this.logListeners.delete(e)}notifyLogListeners(){this.logListeners.forEach(e=>e())}}const vs=new iR,Uu={debug:(t,e,n)=>vs.debug(t,e,n),info:(t,e,n)=>vs.info(t,e,n),warn:(t,e,n)=>vs.warn(t,e,n),error:(t,e,n)=>vs.error(t,e,n)};/*! Capacitor: https://capacitorjs.com/ - MIT License */var Yl;(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(Yl||(Yl={}));class Eg extends Error{constructor(e,n,s){super(e),this.message=e,this.code=n,this.data=s}}const oR=t=>{var e,n;return t!=null&&t.androidBridge?"android":!((n=(e=t==null?void 0:t.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},lR=t=>{const e=t.CapacitorCustomPlatform||null,n=t.Capacitor||{},s=n.Plugins=n.Plugins||{},a=()=>e!==null?e.name:oR(t),r=()=>a()!=="web",i=m=>{const b=f.get(m);return!!(b!=null&&b.platforms.has(a())||c(m))},c=m=>{var b;return(b=n.PluginHeaders)===null||b===void 0?void 0:b.find(y=>y.name===m)},d=m=>t.console.error(m),f=new Map,h=(m,b={})=>{const y=f.get(m);if(y)return console.warn(`Capacitor plugin "${m}" already registered. Cannot register plugins twice.`),y.proxy;const w=a(),C=c(m);let N;const k=async()=>(!N&&w in b?N=typeof b[w]=="function"?N=await b[w]():N=b[w]:e!==null&&!N&&"web"in b&&(N=typeof b.web=="function"?N=await b.web():N=b.web),N),j=(O,_)=>{var M,R;if(C){const z=C==null?void 0:C.methods.find($=>_===$.name);if(z)return z.rtype==="promise"?$=>n.nativePromise(m,_.toString(),$):($,W)=>n.nativeCallback(m,_.toString(),$,W);if(O)return(M=O[_])===null||M===void 0?void 0:M.bind(O)}else{if(O)return(R=O[_])===null||R===void 0?void 0:R.bind(O);throw new Eg(`"${m}" plugin is not implemented on ${w}`,Yl.Unimplemented)}},S=O=>{let _;const M=(...R)=>{const z=k().then($=>{const W=j($,O);if(W){const L=W(...R);return _=L==null?void 0:L.remove,L}else throw new Eg(`"${m}.${O}()" is not implemented on ${w}`,Yl.Unimplemented)});return O==="addListener"&&(z.remove=async()=>_()),z};return M.toString=()=>`${O.toString()}() { [capacitor code] }`,Object.defineProperty(M,"name",{value:O,writable:!1,configurable:!1}),M},T=S("addListener"),D=S("removeListener"),E=(O,_)=>{const M=T({eventName:O},_),R=async()=>{const $=await M;D({eventName:O,callbackId:$},_)},z=new Promise($=>M.then(()=>$({remove:R})));return z.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await R()},z},I=new Proxy({},{get(O,_){switch(_){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return C?E:T;case"removeListener":return D;default:return S(_)}}});return s[m]=I,f.set(m,{name:m,proxy:I,platforms:new Set([...Object.keys(b),...C?[w]:[]])}),I};return n.convertFileSrc||(n.convertFileSrc=m=>m),n.getPlatform=a,n.handleError=d,n.isNativePlatform=r,n.isPluginAvailable=i,n.registerPlugin=h,n.Exception=Eg,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},cR=t=>t.Capacitor=lR(t),yp=cR(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Ju=yp.registerPlugin;class Ox{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,n){let s=!1;this.listeners[e]||(this.listeners[e]=[],s=!0),this.listeners[e].push(n);const r=this.windowListeners[e];r&&!r.registered&&this.addWindowListener(r),s&&this.sendRetainedArgumentsForEvent(e);const i=async()=>this.removeListener(e,n);return Promise.resolve({remove:i})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,n,s){const a=this.listeners[e];if(!a){if(s){let r=this.retainedEventArguments[e];r||(r=[]),r.push(n),this.retainedEventArguments[e]=r}return}a.forEach(r=>r(n))}hasListeners(e){var n;return!!(!((n=this.listeners[e])===null||n===void 0)&&n.length)}registerWindowListener(e,n){this.windowListeners[n]={registered:!1,windowEventName:e,pluginEventName:n,handler:s=>{this.notifyListeners(n,s)}}}unimplemented(e="not implemented"){return new yp.Exception(e,Yl.Unimplemented)}unavailable(e="not available"){return new yp.Exception(e,Yl.Unavailable)}async removeListener(e,n){const s=this.listeners[e];if(!s)return;const a=s.indexOf(n);this.listeners[e].splice(a,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const n=this.retainedEventArguments[e];n&&(delete this.retainedEventArguments[e],n.forEach(s=>{this.notifyListeners(e,s)}))}}const $k=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Uk=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class uR extends Ox{async getCookies(){const e=document.cookie,n={};return e.split(";").forEach(s=>{if(s.length<=0)return;let[a,r]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");a=Uk(a).trim(),r=Uk(r).trim(),n[a]=r}),n}async setCookie(e){try{const n=$k(e.key),s=$k(e.value),a=e.expires?`; expires=${e.expires.replace("expires=","")}`:"",r=(e.path||"/").replace("path=",""),i=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${n}=${s||""}${a}; path=${r}; ${i};`}catch(n){return Promise.reject(n)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const n of e)document.cookie=n.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}Ju("CapacitorCookies",{web:()=>new uR});const dR=async t=>new Promise((e,n)=>{const s=new FileReader;s.onload=()=>{const a=s.result;e(a.indexOf(",")>=0?a.split(",")[1]:a)},s.onerror=a=>n(a),s.readAsDataURL(t)}),fR=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(a=>a.toLocaleLowerCase()).reduce((a,r,i)=>(a[r]=t[e[i]],a),{})},pR=(t,e=!0)=>t?Object.entries(t).reduce((s,a)=>{const[r,i]=a;let c,d;return Array.isArray(i)?(d="",i.forEach(f=>{c=e?encodeURIComponent(f):f,d+=`${r}=${c}&`}),d.slice(0,-1)):(c=e?encodeURIComponent(i):i,d=`${r}=${c}`),`${s}&${d}`},"").substr(1):null,hR=(t,e={})=>{const n=Object.assign({method:t.method||"GET",headers:t.headers},e),a=fR(t.headers)["content-type"]||"";if(typeof t.data=="string")n.body=t.data;else if(a.includes("application/x-www-form-urlencoded")){const r=new URLSearchParams;for(const[i,c]of Object.entries(t.data||{}))r.set(i,c);n.body=r.toString()}else if(a.includes("multipart/form-data")||t.data instanceof FormData){const r=new FormData;if(t.data instanceof FormData)t.data.forEach((c,d)=>{r.append(d,c)});else for(const c of Object.keys(t.data))r.append(c,t.data[c]);n.body=r;const i=new Headers(n.headers);i.delete("content-type"),n.headers=i}else(a.includes("application/json")||typeof t.data=="object")&&(n.body=JSON.stringify(t.data));return n};class mR extends Ox{async request(e){const n=hR(e,e.webFetchExtra),s=pR(e.params,e.shouldEncodeUrlParams),a=s?`${e.url}?${s}`:e.url,r=await fetch(a,n),i=r.headers.get("content-type")||"";let{responseType:c="text"}=r.ok?e:{};i.includes("application/json")&&(c="json");let d,f;switch(c){case"arraybuffer":case"blob":f=await r.blob(),d=await dR(f);break;case"json":d=await r.json();break;case"document":case"text":default:d=await r.text()}const h={};return r.headers.forEach((m,b)=>{h[b]=m}),{data:d,headers:h,status:r.status,url:r.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}const Cq=Ju("CapacitorHttp",{web:()=>new mR});var Hk;(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(Hk||(Hk={}));var Wk;(function(t){t.StatusBar="StatusBar",t.NavigationBar="NavigationBar"})(Wk||(Wk={}));class gR extends Ox{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}}Ju("SystemBars",{web:()=>new gR});var qk;(function(t){t[t.Sunday=1]="Sunday",t[t.Monday=2]="Monday",t[t.Tuesday=3]="Tuesday",t[t.Wednesday=4]="Wednesday",t[t.Thursday=5]="Thursday",t[t.Friday=6]="Friday",t[t.Saturday=7]="Saturday"})(qk||(qk={}));const Lx=Ju("LocalNotifications",{web:()=>vt(()=>import("./web-C2JUUvGB.js"),__vite__mapDeps([5,3,1,4])).then(t=>new t.LocalNotificationsWeb)}),bR=Ju("ServerConfig");let xR=100;const yR="agent_alerts",Gb="tide-notification-tap";function vR(){return typeof window<"u"&&window.innerWidth<=768&&"ontouchstart"in window}function jj(t){if(vR()){U.openTerminalOnMobile(t);return}if(document.querySelector(".commander-overlay")){U.requestCommanderExpand(t);return}U.selectAgent(t),U.setTerminalOpen(!0)}function Zu(){try{return yp.isNativePlatform()}catch{return!1}}async function wR(){if(Zu())try{const t=await Lx.requestPermissions();return console.log("[Notifications] Permission result:",t.display),t.display==="granted"}catch(t){return console.error("[Notifications] Failed to request permissions:",t),!1}else return"Notification"in window?await Notification.requestPermission()==="granted":!1}async function kR(t){const{title:e,body:n,icon:s,data:a}=t;if(Zu())try{const r=xR++;console.log("[Notifications] Scheduling native notification id="+r,e),await Lx.schedule({notifications:[{id:r,title:e,body:n,extra:a,channelId:yR,smallIcon:"ic_launcher",autoCancel:!0}]}),console.log("[Notifications] Notification scheduled successfully")}catch(r){console.error("[Notifications] Failed to schedule notification:",r)}else if("Notification"in window&&Notification.permission==="granted"){const r=new Notification(e,{body:n,icon:s,data:a});r.onclick=()=>{window.focus(),a&&window.dispatchEvent(new CustomEvent(Gb,{detail:a}))}}}let Mg=!1;async function SR(t){const e=[];if(Mg)return()=>{};if(Mg=!0,t){const n=s=>{const a=s;a.detail&&t(a.detail)};window.addEventListener(Gb,n),e.push(()=>window.removeEventListener(Gb,n))}if(Zu())try{const n=await Lx.addListener("localNotificationActionPerformed",s=>{t&&s.notification.extra&&t(s.notification.extra)});e.push(()=>n.remove())}catch(n){console.error("[Notifications] Failed to add tap listener:",n)}return()=>{e.forEach(n=>n()),Mg=!1}}function CR(t,e){Zu()&&bR.syncConfig({url:t,token:e}).catch(n=>{console.warn("[Notifications] Failed to sync config to native service:",n)})}window.__tideWsState||(window.__tideWsState={ws:null,isConnecting:!1,reconnectAttempts:0,reconnectTimeout:null});const Yp=()=>window.__tideWsState.ws,Vk=t=>{window.__tideWsState.ws=t},AR=()=>window.__tideWsState.isConnecting,nu=t=>{window.__tideWsState.isConnecting=t},Kb=()=>window.__tideWsState.reconnectAttempts,Qb=t=>{window.__tideWsState.reconnectAttempts=t},Nj=()=>window.__tideWsState.reconnectTimeout,Tj=t=>{window.__tideWsState.reconnectTimeout=t},Yk=10,Ix="tide_ws_has_connected";function Gk(){return sessionStorage.getItem(Ix)==="true"}function jR(t){sessionStorage.setItem(Ix,"true")}function NR(){sessionStorage.removeItem(Ix)}let _j=null;const TR=t=>{_j=t},Kk=()=>_j,De={onToast:null,onAgentCreated:null,onAgentUpdated:null,onAgentDeleted:null,onAgentsSync:null,onAreasSync:null,onSpawnError:null,onSpawnSuccess:null,onToolUse:null,onDirectoryNotFound:null,onDelegation:null,onCustomClassesSync:null,onReconnect:null,onAgentNotification:null,onBuildingUpdated:null,onSubagentStarted:null,onSubagentCompleted:null};function Ej(t){t.onToast&&(De.onToast=t.onToast),t.onAgentCreated&&(De.onAgentCreated=t.onAgentCreated),t.onAgentUpdated&&(De.onAgentUpdated=t.onAgentUpdated),t.onAgentDeleted&&(De.onAgentDeleted=t.onAgentDeleted),t.onAgentsSync&&(De.onAgentsSync=t.onAgentsSync),t.onAreasSync&&(De.onAreasSync=t.onAreasSync),t.onSpawnError&&(De.onSpawnError=t.onSpawnError),t.onSpawnSuccess&&(De.onSpawnSuccess=t.onSpawnSuccess),t.onToolUse&&(De.onToolUse=t.onToolUse),t.onDirectoryNotFound&&(De.onDirectoryNotFound=t.onDirectoryNotFound),t.onDelegation&&(De.onDelegation=t.onDelegation),t.onCustomClassesSync&&(De.onCustomClassesSync=t.onCustomClassesSync),t.onReconnect&&(De.onReconnect=t.onReconnect),t.onAgentNotification&&(De.onAgentNotification=t.onAgentNotification),t.onBuildingUpdated&&(De.onBuildingUpdated=t.onBuildingUpdated),t.onSubagentStarted&&(De.onSubagentStarted=t.onSubagentStarted),t.onSubagentCompleted&&(De.onSubagentCompleted=t.onSubagentCompleted)}function _R(){De.onToast=null,De.onAgentCreated=null,De.onAgentUpdated=null,De.onAgentDeleted=null,De.onAgentsSync=null,De.onAreasSync=null,De.onSpawnError=null,De.onSpawnSuccess=null,De.onToolUse=null,De.onDirectoryNotFound=null,De.onDelegation=null,De.onCustomClassesSync=null,De.onReconnect=null,De.onAgentNotification=null,De.onSubagentStarted=null,De.onSubagentCompleted=null}function ER(){De.onAgentCreated=null,De.onAgentUpdated=null,De.onAgentDeleted=null,De.onAgentsSync=null,De.onAreasSync=null,De.onToolUse=null,De.onDelegation=null,De.onCustomClassesSync=null,De.onBuildingUpdated=null,De.onSubagentStarted=null,De.onSubagentCompleted=null}const jf=new Map,MR=new Map,Xb={start(t){},end(t){},async measure(t,e){this.start(t);try{return await e()}finally{this.end(t)}},measureSync(t,e){this.start(t);try{return e()}finally{this.end(t)}},getMetrics(t){const e={},n=t?jf.has(t)?[[t,jf.get(t)]]:[]:Array.from(jf.entries());for(const[s,a]of n){const r=[...a.samples].sort((f,h)=>f-h),i=Math.floor(r.length*.5),c=Math.floor(r.length*.95),d=Math.floor(r.length*.99);e[s]={count:a.count,avgMs:a.totalMs/a.count,minMs:a.minMs,maxMs:a.maxMs,lastMs:a.lastMs,p50Ms:r[i]||0,p95Ms:r[c]||0,p99Ms:r[d]||0}}return e},clear(){jf.clear(),MR.clear()},report(){}};class DR{constructor(){Xe(this,"frames",[]);Xe(this,"lastFrameTime",0);Xe(this,"frameCount",0);Xe(this,"fps",0);Xe(this,"minFps",1/0);Xe(this,"maxFps",0);Xe(this,"fpsHistory",[]);Xe(this,"maxHistorySize",60)}tick(e=200){const n=performance.now();if(this.lastFrameTime>0){const s=n-this.lastFrameTime;s<e&&(this.frames.push(s),this.frames.length>60&&this.frames.shift())}this.lastFrameTime=n,this.frameCount++}update(){if(this.frames.length===0)return;const e=this.frames.reduce((n,s)=>n+s,0)/this.frames.length;this.fps=1e3/e,this.minFps=Math.min(this.minFps,this.fps),this.maxFps=Math.max(this.maxFps,this.fps),this.fpsHistory.push(this.fps),this.fpsHistory.length>this.maxHistorySize&&this.fpsHistory.shift()}getFPS(){return Math.round(this.fps)}getStats(){const e=this.fpsHistory.length>0?this.fpsHistory.reduce((n,s)=>n+s,0)/this.fpsHistory.length:this.fps;return{current:Math.round(this.fps),min:Math.round(this.minFps===1/0?0:this.minFps),max:Math.round(this.maxFps),avg:Math.round(e)}}reset(){this.frames=[],this.lastFrameTime=0,this.frameCount=0,this.fps=0,this.minFps=1/0,this.maxFps=0,this.fpsHistory=[]}}const Nf=new DR;class RR{constructor(){Xe(this,"snapshots",[]);Xe(this,"maxSnapshots",120);Xe(this,"intervalId",null);Xe(this,"leakThresholdMB",50);Xe(this,"baselineUsedMB",0)}getUsage(){const e=performance.memory;return e?{usedMB:Math.round(e.usedJSHeapSize/1024/1024),totalMB:Math.round(e.totalJSHeapSize/1024/1024),limitMB:Math.round(e.jsHeapSizeLimit/1024/1024)}:null}log(){const e=this.getUsage();e&&console.log(`[Memory] Used: ${e.usedMB}MB / ${e.totalMB}MB (limit: ${e.limitMB}MB)`)}startMonitoring(e=1e3){if(this.intervalId)return;const n=this.getUsage();n&&(this.baselineUsedMB=n.usedMB),this.intervalId=setInterval(()=>{this.takeSnapshot()},e),console.log("[Memory] Monitoring started. Use memory.report() to see analysis.")}stopMonitoring(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null,console.log("[Memory] Monitoring stopped."))}takeSnapshot(){const e=this.getUsage();if(!e)return;const n={timestamp:Date.now(),heapUsedMB:e.usedMB,heapTotalMB:e.totalMB,heapLimitMB:e.limitMB};this.snapshots.push(n),this.snapshots.length>this.maxSnapshots&&this.snapshots.shift();const s=e.usedMB-this.baselineUsedMB;s>this.leakThresholdMB&&console.warn(`[Memory] Warning: Heap grew by ${s}MB since monitoring started (baseline: ${this.baselineUsedMB}MB, current: ${e.usedMB}MB)`)}getGrowthRate(){if(this.snapshots.length<10)return null;const e=this.snapshots[0],n=this.snapshots[this.snapshots.length-1],s=(n.timestamp-e.timestamp)/1e3/60;return s<.1?null:(n.heapUsedMB-e.heapUsedMB)/s}report(){const e=this.getUsage();if(!e){console.log("[Memory] Memory API not available (Chrome only)");return}console.group("%c[Memory Report]","color: #ff6600; font-weight: bold"),console.log(`Current: ${e.usedMB}MB / ${e.totalMB}MB (limit: ${e.limitMB}MB)`),console.log(`Baseline: ${this.baselineUsedMB}MB`),console.log(`Growth: ${e.usedMB-this.baselineUsedMB}MB since monitoring started`);const n=this.getGrowthRate();if(n!==null&&(console.log(`Growth Rate: ${n.toFixed(2)}MB/min`),n>5&&console.warn("POTENTIAL MEMORY LEAK: Growth rate exceeds 5MB/min")),this.snapshots.length>1){const s=Math.min(...this.snapshots.map(r=>r.heapUsedMB)),a=Math.max(...this.snapshots.map(r=>r.heapUsedMB));console.log(`Range: ${s}MB - ${a}MB (${a-s}MB variance)`)}console.groupEnd()}getThreeJsInfo(e){var n;return(n=e==null?void 0:e.info)!=null&&n.memory?{geometries:e.info.memory.geometries,textures:e.info.memory.textures}:null}reset(){this.snapshots=[];const e=this.getUsage();e&&(this.baselineUsedMB=e.usedMB),console.log("[Memory] Reset. New baseline:",this.baselineUsedMB,"MB")}}const su=new RR;function yu(t,e,n,s,a,r){}function Mj(t,e){x.useRef(0),x.useEffect(()=>{},[t,5e3,!0])}if(typeof window<"u"){setInterval(()=>{try{performance.clearMarks(),performance.clearMeasures(),performance.clearResourceTimings()}catch{}},6e4);try{performance.setResourceTimingBufferSize(0)}catch{}}const Jb=pt.PENDING_MESSAGES,OR=300*1e3;function Dj(){try{const t=localStorage.getItem(Jb);if(!t)return[];const e=JSON.parse(t),n=Date.now();return e.filter(s=>n-s.queuedAt<OR)}catch{return[]}}function Rj(t){try{t.length===0?localStorage.removeItem(Jb):localStorage.setItem(Jb,JSON.stringify(t))}catch{}}function Tf(t){const e=Dj();e.push({message:t,queuedAt:Date.now()}),Rj(e)}function LR(){var s;const t=Dj();if(t.length===0)return 0;let e=0;const n=[];for(const a of t)IR(a.message)?e++:n.push(a);if(Rj(n),e>0){const a=e===1?"queued message":"queued messages";(s=De.onToast)==null||s.call(De,"success","Messages Sent",`${e} ${a} delivered after reconnecting.`)}return e}function Px(t){if(t.payload&&typeof t.payload=="object"){const e=t.payload;if(e.agentId)return e.agentId;if(e.parentAgentId)return e.parentAgentId;if(e.bossId)return e.bossId;if(e.id)return e.id}return null}function IR(t){const e=Yp();if(!e||e.readyState!==WebSocket.OPEN)return!1;try{const n=JSON.stringify(t),s=Px(t);return console.log("[AgentDebugger] SENT - type:",t.type,"agentId:",s,"payload:",t.payload),s&&vs.captureSent(s,n),e.send(n),!0}catch{return!1}}function Bx(t){var n,s,a,r,i,c,d,f,h,m;const e=Yp();if(!e)return(n=Kk())==null||n(),t.type==="send_command"?(Tf(t),(s=De.onToast)==null||s.call(De,"warning","Message Queued","Connection lost. Your message will be sent when reconnected.")):(a=De.onToast)==null||a.call(De,"error","Not Connected","Connecting to server... Please try again in a moment."),!1;if(e.readyState!==WebSocket.OPEN)return e.readyState===WebSocket.CONNECTING?t.type==="send_command"?(Tf(t),(r=De.onToast)==null||r.call(De,"warning","Message Queued","Still connecting. Your message will be sent automatically.")):(i=De.onToast)==null||i.call(De,"warning","Connecting...","WebSocket is still connecting. Please wait a moment and try again."):(e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING)&&((c=Kk())==null||c(),t.type==="send_command"?(Tf(t),(d=De.onToast)==null||d.call(De,"warning","Message Queued","Connection lost. Your message will be sent when reconnected.")):(f=De.onToast)==null||f.call(De,"warning","Reconnecting...","Connection lost. Reconnecting to server...")),!1;try{const b=JSON.stringify(t),y=Px(t);return console.log("[AgentDebugger] SENT - type:",t.type,"agentId:",y,"payload:",t.payload),y&&vs.captureSent(y,b),e.send(b),!0}catch(b){return t.type==="send_command"?(Tf(t),(h=De.onToast)==null||h.call(De,"warning","Message Queued","Send failed. Your message will be retried when reconnected.")):(m=De.onToast)==null||m.call(De,"error","Send Failed",`Failed to send message: ${b}`),!1}}const vu=new Set,PR=5e3;function Qk(t){if(!t.isDetached||!t.sessionId){vu.delete(t.id);return}vu.has(t.id)||(vu.add(t.id),Bx({type:"reattach_agent",payload:{agentId:t.id}}),setTimeout(()=>{vu.delete(t.id)},PR))}function BR(t){var e,n,s,a,r,i,c,d,f,h,m,b,y,w,C,N,k,j,S,T,D,E,I,O;switch(Xb.start(`ws:${t.type}`),t.type){case"agents_update":{const _=t.payload,M=_.filter(R=>R.class==="boss"||R.isBoss);M.length>0&&console.log("[WS agents_update] Boss agents received:",M.map(R=>({id:R.id,name:R.name,subordinateIds:R.subordinateIds}))),U.setAgents(_),(e=De.onAgentsSync)==null||e.call(De,_),U.loadToolHistory();for(const R of _)Qk(R);break}case"agent_created":{const _=t.payload;console.log("[WebSocket] Agent created:",_),U.addAgent(_);const M=(n=window.__spawnModalAreaContext)==null?void 0:n.areaId;M&&(U.assignAgentToArea(_.id,M),window.__spawnModalAreaContext=null),U.selectAgent(_.id),(s=De.onAgentCreated)==null||s.call(De,_),(a=De.onSpawnSuccess)==null||a.call(De),window.__spawnModalSuccess&&(console.log("[WebSocket] Calling __spawnModalSuccess"),window.__spawnModalSuccess()),(r=De.onToast)==null||r.call(De,"success","Agent Deployed",`${_.name} is ready for commands`);break}case"agent_updated":{const _=t.payload,R=U.getState().agents.get(_.id),z=(R==null?void 0:R.status)!==_.status;console.log(`[Tide] Agent updated: ${_.name} (${_.id}) status=${_.status} (was ${R==null?void 0:R.status})${z?" ⚡ STATUS CHANGED":""}`),z&&console.log(`[Tide] 🔔 Status change for ${_.name}: ${R==null?void 0:R.status} → ${_.status}`),z&&(R==null?void 0:R.status)==="working"&&_.status==="idle"&&U.triggerHistoryRefresh(_.id);const $=R?R.position.x!==_.position.x||R.position.z!==_.position.z:!1;U.updateAgent(_),Qk(_),(i=De.onAgentUpdated)==null||i.call(De,_,$);break}case"agent_deleted":{const{id:_}=t.payload;vu.delete(_),U.removeAgent(_),(c=De.onAgentDeleted)==null||c.call(De,_);break}case"activity":{const _=t.payload;U.addActivity(_);break}case"event":{const _=t.payload;if(Uu.debug(`Event: ${_.type}`,{agentId:_.agentId,toolName:_.toolName},"ws:event"),_.type==="tool_start"&&_.toolName&&((d=De.onToolUse)==null||d.call(De,_.agentId,_.toolName,_.toolInput),U.addToolExecution(_.agentId,_.toolName,_.toolInput),_.toolInput)){const M=_.toolInput.file_path||_.toolInput.path;M&&(_.toolName==="Write"?U.addFileChange(_.agentId,"created",M):_.toolName==="Edit"?U.addFileChange(_.agentId,"modified",M):_.toolName==="Read"&&U.addFileChange(_.agentId,"read",M))}break}case"output":{const _=t.payload;Uu.debug(`Output: "${_.text.slice(0,80)}..."`,{agentId:_.agentId,isStreaming:_.isStreaming,length:_.text.length,hasSkillUpdate:!!_.skillUpdate,uuid:_.uuid,toolName:_.toolName},"ws:output"),U.addOutput(_.agentId,{text:_.text,isStreaming:_.isStreaming,timestamp:_.timestamp,isDelegation:_.isDelegation,skillUpdate:_.skillUpdate,subagentName:_.subagentName,uuid:_.uuid,toolName:_.toolName,toolInput:_.toolInput,toolOutput:_.toolOutput});break}case"context_stats":{const{agentId:_,stats:M}=t.payload;console.log(`[Tide] Received context stats for agent ${_}: ${M.usedPercent}% used`),U.updateAgentContextStats(_,M);break}case"context_update":{const{agentId:_,contextUsed:M,contextLimit:R}=t.payload;U.updateAgentContext(_,M,R);break}case"error":{const _=t.payload;console.error("[WebSocket] Error from server:",_.message),(f=De.onToast)==null||f.call(De,"error","Error",_.message),(h=De.onSpawnError)==null||h.call(De),window.__spawnModalError&&(console.log("[WebSocket] Calling __spawnModalError"),window.__spawnModalError());break}case"directory_not_found":{const{path:_}=t.payload;console.log("[WebSocket] Directory not found:",_),(m=De.onDirectoryNotFound)==null||m.call(De,_),window.__spawnModalDirNotFound&&(console.log("[WebSocket] Calling __spawnModalDirNotFound"),window.__spawnModalDirNotFound(_));break}case"command_started":{const{agentId:_,command:M}=t.payload,R=M.trim();if(R==="/context"||R==="/cost"||R==="/compact")break;U.addUserPromptToOutput(_,M);break}case"session_updated":{const{agentId:_}=t.payload;U.loadToolHistory(),U.triggerHistoryRefresh(_);const M=U.getState().agents.get(_);M&&U.updateAgent({...M});break}case"supervisor_report":{const _=t.payload;U.setSupervisorReport(_);break}case"narrative_update":{const{agentId:_,narrative:M}=t.payload;U.addNarrative(_,M);break}case"supervisor_status":{const _=t.payload;U.setSupervisorStatus(_);break}case"agent_supervisor_history":{const _=t.payload;U.setAgentSupervisorHistory(_);break}case"agent_analysis":{const{agentId:_,analysis:M}=t.payload;U.addAgentAnalysis(_,M);break}case"areas_update":{const _=t.payload;U.setAreasFromServer(_),(b=De.onAreasSync)==null||b.call(De);break}case"buildings_update":{const _=t.payload;U.setBuildingsFromServer(_);break}case"building_created":{const _=t.payload;U.addBuilding(_);break}case"building_updated":{const _=t.payload;U.updateBuildingFromServer(_),(y=De.onBuildingUpdated)==null||y.call(De,_);break}case"building_deleted":{const{id:_}=t.payload;U.removeBuildingFromServer(_);break}case"building_logs":{const{buildingId:_,logs:M}=t.payload;U.addBuildingLogs(_,M);break}case"pm2_logs_chunk":{const{buildingId:_,chunk:M}=t.payload;U.appendStreamingLogChunk(_,M);break}case"pm2_logs_streaming":{const{buildingId:_,streaming:M}=t.payload;U.setStreamingStatus(_,M);break}case"docker_logs_chunk":{const{buildingId:_,chunk:M}=t.payload;U.appendStreamingLogChunk(_,M);break}case"docker_logs_streaming":{const{buildingId:_,streaming:M}=t.payload;U.setStreamingStatus(_,M);break}case"docker_containers_list":{const{containers:_,composeProjects:M}=t.payload;console.log(`[WebSocket] Received ${_.length} containers, ${M.length} compose projects`),U.setDockerContainersList(_,M);break}case"boss_building_logs_chunk":{const{bossBuildingId:_,subordinateBuildingId:M,subordinateBuildingName:R,chunk:z,isError:$}=t.payload;U.appendBossStreamingLogChunk(_,M,R,z,$);break}case"boss_building_subordinates_updated":{const{bossBuildingId:_,subordinateBuildingIds:M}=t.payload;U.updateBuilding(_,{subordinateBuildingIds:M});break}case"permission_request":{const _=t.payload;U.addPermissionRequest(_);break}case"permission_resolved":{const{requestId:_,approved:M}=t.payload;U.resolvePermissionRequest(_,M);break}case"delegation_decision":{const _=t.payload;U.handleDelegationDecision(_),_.status==="sent"&&((w=De.onToast)==null||w.call(De,"info","Task Delegated",`Delegated to ${_.selectedAgentName}: ${_.reasoning.slice(0,80)}...`),_.bossId&&_.selectedAgentId&&((C=De.onDelegation)==null||C.call(De,_.bossId,_.selectedAgentId)));break}case"boss_subordinates_updated":{const{bossId:_,subordinateIds:M}=t.payload;U.updateBossSubordinates(_,M);break}case"delegation_history":{const{bossId:_,decisions:M}=t.payload;U.setDelegationHistory(_,M);break}case"boss_spawned_agent":{const{agent:_,bossPosition:M}=t.payload;console.log("[WebSocket] Boss spawned agent:",_.name,"- walking to boss at",M),U.addAgent(_),(N=De.onAgentCreated)==null||N.call(De,_),Bx({type:"move_agent",payload:{agentId:_.id,position:M}}),(k=De.onToast)==null||k.call(De,"success","Agent Deployed",`${_.name} spawned by boss, walking to position`);break}case"agent_task_started":{const{bossId:_,subordinateId:M,subordinateName:R,taskDescription:z}=t.payload;console.log(`[WebSocket] Agent ${R} started task for boss ${_}: ${z.slice(0,50)}...`),U.handleAgentTaskStarted(_,M,R,z);break}case"agent_task_output":{const{bossId:_,subordinateId:M,output:R,isStreaming:z,timestamp:$,subagentName:W,toolName:L,toolInput:F,toolOutput:H}=t.payload;U.handleAgentTaskOutput(_,M,{text:R,isStreaming:z||!1,timestamp:$||Date.now(),subagentName:W,toolName:L,toolInput:F,toolOutput:H});break}case"agent_task_completed":{const{bossId:_,subordinateId:M,success:R}=t.payload;console.log(`[WebSocket] Agent task completed for boss ${_}, subordinate ${M}, success: ${R}`),U.handleAgentTaskCompleted(_,M,R);break}case"skills_update":{const _=t.payload;U.setSkillsFromServer(_);break}case"skill_created":{const _=t.payload;U.addSkillFromServer(_),console.log(`[WebSocket] Skill created: ${_.name}`);break}case"skill_updated":{const _=t.payload;U.updateSkillFromServer(_),console.log(`[WebSocket] Skill updated: ${_.name}`);break}case"skill_deleted":{const{id:_}=t.payload;U.removeSkillFromServer(_),console.log(`[WebSocket] Skill deleted: ${_}`);break}case"agent_skills":{const{agentId:_,skills:M}=t.payload;console.log(`[WebSocket] Agent ${_} has ${M.length} skills`);break}case"custom_agent_classes_update":{const _=t.payload;U.setCustomAgentClassesFromServer(_),console.log(`[WebSocket] Received ${_.length} custom agent classes`);const M=new Map;for(const R of _)M.set(R.id,R);(j=De.onCustomClassesSync)==null||j.call(De,M);break}case"custom_agent_class_created":{const _=t.payload;U.addCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class created: ${_.name}`),(S=De.onCustomClassesSync)==null||S.call(De,U.getState().customAgentClasses);break}case"custom_agent_class_updated":{const _=t.payload;U.updateCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class updated: ${_.name}`),(T=De.onCustomClassesSync)==null||T.call(De,U.getState().customAgentClasses);break}case"custom_agent_class_deleted":{const{id:_}=t.payload;U.removeCustomAgentClassFromServer(_),console.log(`[WebSocket] Custom agent class deleted: ${_}`),(D=De.onCustomClassesSync)==null||D.call(De,U.getState().customAgentClasses);break}case"global_usage":{const _=t.payload;console.log("[WebSocket] Global usage update:",_),U.setGlobalUsage(_);break}case"agent_notification":{const _=t.payload;console.log(`[WebSocket] Agent notification from ${_.agentName}: ${_.title}`),(E=De.onAgentNotification)==null||E.call(De,_);break}case"focus_agent":{const{agentId:_,openTerminal:M}=t.payload;if(!U.getState().agents.get(_)){console.warn(`[WebSocket] focus_agent ignored - agent not found: ${_}`);break}U.selectAgent(_),M&&U.setTerminalOpen(!0);const z=[0,80,220,500,1e3];for(const $ of z)window.setTimeout(()=>{window.focus()},$);break}case"exec_task_started":{const{taskId:_,agentId:M,agentName:R,command:z,cwd:$}=t.payload;console.log(`[WebSocket] Exec task started: ${_} for agent ${R}: ${z.slice(0,50)}...`),U.handleExecTaskStarted(_,M,R,z,$);break}case"exec_task_output":{const{taskId:_,agentId:M,output:R,isError:z}=t.payload;U.handleExecTaskOutput(_,M,R,z);break}case"exec_task_completed":{const{taskId:_,agentId:M,exitCode:R,success:z}=t.payload;console.log(`[WebSocket] Exec task completed: ${_} for agent ${M}, success: ${z}`),U.handleExecTaskCompleted(_,M,R,z);break}case"subagent_started":{const _=t.payload;console.log(`[WebSocket] Subagent started: ${_.name} (${_.id}) for agent ${_.parentAgentId}`),U.addSubagent(_),(I=De.onSubagentStarted)==null||I.call(De,_);break}case"subagent_output":{const{subagentId:_,parentAgentId:M,text:R,timestamp:z}=t.payload,$=R.indexOf(":");if($>0){const W=R.slice(0,$).trim(),L=R.slice($+1).trim();U.addSubagentActivity(_,M,{toolName:W,description:L,timestamp:z})}else R.startsWith("Using ")&&U.addSubagentActivity(_,M,{toolName:R.slice(6).trim(),description:"",timestamp:z});break}case"subagent_completed":{const{subagentId:_,parentAgentId:M,success:R,resultPreview:z,subagentName:$,durationMs:W,tokensUsed:L,toolUseCount:F}=t.payload;console.log(`[WebSocket] Subagent completed: ${_} for agent ${M}, success: ${R}`),(W||L||F)&&U.updateSubagentStats(_,M,{durationMs:W||0,tokensUsed:L||0,toolUseCount:F||0}),U.completeSubagent(_,M,R),(O=De.onSubagentCompleted)==null||O.call(De,_);const H=U.getSubagent(_)||U.getSubagentByToolUseId(_),V=$||(H==null?void 0:H.name)||_,G=R?"✅":"❌",B=W?` (${(W/1e3).toFixed(0)}s · ${((L||0)/1e3).toFixed(1)}K tokens · ${F||0} tools)`:"";U.addOutput(M,{text:`${G} Subagent ${V} ${R?"completed":"failed"}${B}`,isStreaming:!1,timestamp:Date.now(),subagentName:V,toolOutput:z});break}case"subagent_stream":{const{toolUseId:_,parentAgentId:M,entries:R}=t.payload;U.addSubagentStreamEntries(_,M,R);break}case"secrets_update":{const _=t.payload;U.setSecretsFromServer(_),console.log(`[WebSocket] Received ${_.length} secrets`);break}case"secret_created":{const _=t.payload;U.addSecretFromServer(_),console.log(`[WebSocket] Secret created: ${_.name}`);break}case"secret_updated":{const _=t.payload;U.updateSecretFromServer(_),console.log(`[WebSocket] Secret updated: ${_.name}`);break}case"secret_deleted":{const{id:_}=t.payload;U.removeSecretFromServer(_),console.log(`[WebSocket] Secret deleted: ${_}`);break}case"database_connection_result":{const{buildingId:_,connectionId:M,success:R,error:z,serverVersion:$}=t.payload;U.setConnectionStatus(_,M,{connected:R,error:z,serverVersion:$}),console.log(`[WebSocket] Database connection ${R?"succeeded":"failed"}: ${M}`);break}case"databases_list":{const{buildingId:_,connectionId:M,databases:R}=t.payload;U.setDatabases(_,M,R),console.log(`[WebSocket] Received ${R.length} databases for ${M}`);break}case"tables_list":{const{buildingId:_,connectionId:M,database:R,tables:z}=t.payload;U.setTables(_,M,R,z),console.log(`[WebSocket] Received ${z.length} tables for ${R}`);break}case"table_schema":{const{buildingId:_,connectionId:M,database:R,table:z,columns:$,indexes:W,foreignKeys:L}=t.payload;U.setTableSchema(_,M,R,z,{columns:$,indexes:W||[],foreignKeys:L||[]}),console.log(`[WebSocket] Received schema for ${z}`);break}case"query_result":{const{buildingId:_,result:M}=t.payload;U.setQueryResult(_,M),console.log(`[WebSocket] Query ${M.status}: ${M.rowCount??M.affectedRows??0} rows in ${M.duration}ms`);break}case"silent_query_result":{const{buildingId:_,query:M,requestId:R,success:z,affectedRows:$,error:W}=t.payload;U.setSilentQueryResult(_,{query:M,requestId:R,success:z,affectedRows:$,error:W}),console.log(`[WebSocket] Silent query ${z?"succeeded":"failed"}: ${$??0} affected rows`);break}case"query_history_update":{const{buildingId:_,history:M}=t.payload;U.setQueryHistory(_,M),console.log(`[WebSocket] Received ${M.length} query history entries for ${_}`);break}}Xb.end(`ws:${t.type}`)}TR(()=>Hu());let Xk=!1;function Oj(){const t=Yp();t&&t.readyState===WebSocket.OPEN&&t.close(1e3,"Page unloading");const e=Nj();e&&clearTimeout(e),window.__tideWsState&&(window.__tideWsState.ws=null,window.__tideWsState.reconnectTimeout=null,window.__tideWsState.isConnecting=!1,window.__tideWsState.reconnectAttempts=0),NR()}function FR(){Xk||(window.addEventListener("beforeunload",Oj),Xk=!0)}function Lj(){Oj(),U.setConnected(!1),U.stopStatusPolling()}function zR(){Lj(),Qb(0),setTimeout(()=>Hu(),100)}function Hu(){FR();const t=Nj();t&&(clearTimeout(t),Tj(null));const e=Yp();if(AR()||e&&e.readyState===WebSocket.CONNECTING)return;if(e&&e.readyState===WebSocket.OPEN){Gk()&&De.onReconnect&&De.onReconnect();return}Qb(Kb()+1),nu(!0);const n=Rx(),s=Ii(),a=6200;let r;if(n){const c=n.replace(/^https:\/\//,"wss://").replace(/^http:\/\//,"ws://");r=c.endsWith("/ws")?c:`${c.replace(/\/$/,"")}/ws`}else r=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let i=null;try{s?i=new WebSocket(r,[`auth-${s}`]):i=new WebSocket(r)}catch{nu(!1),Jk();return}Vk(i),i.onopen=()=>{var d,f,h;const c=Gk();nu(!1),Qb(0),jR(),U.setConnected(!0),U.startStatusPolling(),U.clearAllPermissions(),c?((d=De.onToast)==null||d.call(De,"success","Reconnected","Connection restored - refreshing data..."),(f=De.onReconnect)==null||f.call(De)):(h=De.onToast)==null||h.call(De,"success","Connected","Connected to Tide Commander server"),CR(n,s),LR()},i.onmessage=c=>{try{const d=JSON.parse(c.data),f=Px(d);console.log("[AgentDebugger] RECEIVED - type:",d.type,"agentId:",f,"payload:",d.payload),f&&vs.captureReceived(f,c.data),BR(d)}catch(d){const f=c.data.substring(0,200);console.error("[WS] Failed to parse message:",d),console.error("[WS] Raw data (first 200 chars):",f),console.error("[WS] Full data length:",c.data.length),c.data.length<5e3&&console.error("[WS] Full malformed message:",c.data)}},i.onclose=()=>{var d,f;nu(!1),Vk(null),U.setConnected(!1),U.stopStatusPolling();const c=Kb();c<Yk?((d=De.onToast)==null||d.call(De,"warning","Disconnected",`Connection lost. Reconnecting... (attempt ${c+1}/${Yk})`),Jk()):(f=De.onToast)==null||f.call(De,"error","Connection Failed",`Could not connect to server. Please check if the backend is running on port ${a}.`)},i.onerror=()=>{nu(!1)},U.setSendMessage(Bx)}function Jk(){const t=Kb(),e=Math.min(1e3*Math.pow(2,t-1),3e4);Tj(setTimeout(Hu,e))}function $R(t,e){const n={position:t,target:e};La(pt.CAMERA_STATE,n)}function UR(){return Na(pt.CAMERA_STATE,null)}function Aq(t,e,n){const s={posX:t,posZ:e,zoom:n};La(pt.CAMERA_STATE_2D,s)}function jq(){return Na(pt.CAMERA_STATE_2D,null)}function sc(){return{Authorization:`Bearer ${Ii()}`,"Content-Type":"application/json"}}async function HR(){const t=await fetch(`${Ea()}/api/workspaces`,{headers:sc()});if(!t.ok)throw new Error(`Failed to fetch workspaces: ${t.statusText}`);return t.json()}async function WR(t,e){const n=await fetch(`${Ea()}/api/workspaces`,{method:"POST",headers:sc(),body:JSON.stringify({name:t,areaIds:e})});if(!n.ok)throw new Error(`Failed to create workspace: ${n.statusText}`);return n.json()}async function Zk(t,e){const n=await fetch(`${Ea()}/api/workspaces/${t}`,{method:"PUT",headers:sc(),body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to update workspace: ${n.statusText}`);return n.json()}async function qR(t){const e=await fetch(`${Ea()}/api/workspaces/${t}`,{method:"DELETE",headers:sc()});if(!e.ok)throw new Error(`Failed to delete workspace: ${e.statusText}`)}async function VR(){const t=await fetch(`${Ea()}/api/workspaces/active`,{headers:sc()});if(!t.ok)throw new Error(`Failed to get active workspace: ${t.statusText}`);return(await t.json()).activeWorkspaceId??null}async function eS(t){const e=await fetch(`${Ea()}/api/workspaces/active`,{method:"PUT",headers:sc(),body:JSON.stringify({workspaceId:t})});if(!e.ok)throw new Error(`Failed to set active workspace: ${e.statusText}`)}const Wu=new Set;let sr=null,xo=[],Ij=!1;const Zb=new Set;function Dg(t){Ij=t,Zb.forEach(e=>e(t))}const Pj="tide-commander-active-workspace";function tS(){return typeof window>"u"?null:localStorage.getItem(Pj)||null}function Rg(t){typeof window>"u"||localStorage.setItem(Pj,t||"")}function au(){Wu.forEach(t=>t())}function YR(){return sr}function Fx(t){return sr?t?sr.areaIds.includes(t):!1:!0}function Nq(t){return sr?sr.areaIds.includes(t):!0}function Bj(){const[,t]=x.useState(0);return x.useEffect(()=>{const e=()=>t(n=>n+1);return Wu.add(e),()=>{Wu.delete(e)}},[]),[sr,xo]}function GR(t){return Wu.add(t),()=>{Wu.delete(t)}}function KR(){const[t,e]=x.useState(Ij);return x.useEffect(()=>{const n=s=>e(s);return Zb.add(n),()=>{Zb.delete(n)}},[]),t}const Og=new Map,QR=Ce.memo(function(){const{t:e}=dt("common"),n=ur(),[s,a]=x.useState([]),[r,i]=x.useState(()=>tS()),[c,d]=x.useState(!1),[f,h]=x.useState(!1),[m,b]=x.useState(!0),[y,w]=x.useState(null),[C,N]=x.useState(""),[k,j]=x.useState([]),[S,T]=x.useState(!1),D=x.useRef(null);x.useEffect(()=>{let L=!1;return(async()=>{try{const F=tS(),[H,V]=await Promise.all([HR(),VR()]);if(L)return;const G=F&&H.some(B=>B.id===F)?F:V&&H.some(B=>B.id===V)?V:null;a(H),xo=H,i(G),Rg(G),sr=H.find(B=>B.id===G)??null,au()}catch(F){console.error("workspace error:",F)}finally{L||b(!1)}})(),()=>{L=!0}},[]),x.useEffect(()=>{if(!c&&!f)return;const L=F=>{D.current&&!D.current.contains(F.target)&&(d(!1),h(!1))};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[c,f]);const E=x.useMemo(()=>s.find(L=>L.id===r)??null,[s,r]),I=x.useCallback(async L=>{Dg(!0);const F=Date.now();if(r){const B=UR();B&&(Og.set(r,B),Zk(r,{cameraState:B}).then(K=>{a(ne=>{const q=ne.map(xe=>xe.id===r?K:xe);return xo=q,q})}).catch(K=>console.error("workspace error:",K)))}i(L),Rg(L),d(!1);const H=L?s.find(B=>B.id===L)??null:null;if(sr=H,xo=s,au(),L){const K=(H==null?void 0:H.cameraState)??Og.get(L);K&&($R(K.position,K.target),Og.set(L,K))}eS(L).catch(B=>console.error("workspace error:",B));const V=Date.now()-F,G=400;V<G?setTimeout(()=>Dg(!1),G-V):Dg(!1)},[r,s]),O=x.useMemo(()=>Array.from(n.values()).filter(L=>!L.archived),[n]),_=x.useCallback(async()=>{if(C.trim())try{const L=await WR(C.trim(),k),F=[...s,L];a(F),xo=F,au(),N(""),j([]),T(!1)}catch(L){console.error("workspace error:",L)}},[C,k,s]),M=x.useCallback(async()=>{if(!(!y||!C.trim()))try{const L=await Zk(y,{name:C.trim(),areaIds:k}),F=s.map(H=>H.id===y?L:H);a(F),xo=F,y===r&&(sr=L),au(),w(null),N(""),j([])}catch(L){console.error("workspace error:",L)}},[y,C,k,s,r]),R=x.useCallback(async L=>{try{await qR(L);const F=s.filter(H=>H.id!==L);a(F),xo=F,r===L&&(i(null),Rg(null),sr=null,await eS(null).catch(H=>console.error("workspace error:",H))),au()}catch(F){console.error("workspace error:",F)}},[s,r]),z=x.useCallback(L=>{w(L.id),N(L.name),j([...L.areaIds]),T(!1)},[]),$=x.useCallback(()=>{w(null),N(""),j([]),T(!0)},[]),W=x.useCallback(L=>{j(F=>F.includes(L)?F.filter(H=>H!==L):[...F,L])},[]);return m?null:o.jsxs("div",{className:"workspace-switcher",ref:D,children:[o.jsxs("button",{className:"workspace-switcher-trigger",onClick:()=>{d(!c),h(!1)},title:"Workspaces",children:[o.jsx("span",{className:"workspace-switcher-icon",children:"📂"}),o.jsx("span",{className:"workspace-switcher-label",children:E?E.name:e("agentBar.allWorkspaces",{defaultValue:"All"})}),o.jsx("span",{className:"workspace-switcher-arrow",children:c?"▲":"▼"})]}),c&&!f&&o.jsxs("div",{className:"workspace-switcher-dropdown",children:[o.jsx("button",{className:`workspace-switcher-option ${r?"":"active"}`,onClick:()=>I(null),children:e("agentBar.allWorkspaces",{defaultValue:"All"})}),s.map(L=>o.jsxs("button",{className:`workspace-switcher-option ${L.id===r?"active":""}`,onClick:()=>I(L.id),children:[L.name,o.jsx("span",{className:"workspace-switcher-option-count",children:L.areaIds.length})]},L.id)),o.jsx("div",{className:"workspace-switcher-divider"}),o.jsxs("button",{className:"workspace-switcher-option workspace-switcher-manage",onClick:()=>h(!0),children:["⚙ ",e("agentBar.manageWorkspaces",{defaultValue:"Manage"})]})]}),f&&o.jsxs("div",{className:"workspace-switcher-dropdown workspace-switcher-manager",children:[o.jsxs("div",{className:"workspace-switcher-manager-header",children:[o.jsx("span",{children:e("agentBar.workspaces",{defaultValue:"Workspaces"})}),o.jsx("button",{className:"workspace-switcher-close",onClick:()=>h(!1),children:"×"})]}),o.jsx("div",{className:"workspace-switcher-manager-list",children:s.map(L=>o.jsx("div",{className:"workspace-switcher-manager-item",children:y===L.id?o.jsxs("div",{className:"workspace-switcher-editor",children:[o.jsx("input",{type:"text",value:C,onChange:F=>N(F.target.value),className:"workspace-switcher-input",placeholder:"Workspace name",autoFocus:!0,onKeyDown:F=>{F.key==="Enter"&&M(),F.key==="Escape"&&w(null)}}),o.jsxs("div",{className:"workspace-switcher-area-list",children:[O.map(F=>o.jsxs("label",{className:"workspace-switcher-area-check",children:[o.jsx("input",{type:"checkbox",checked:k.includes(F.id),onChange:()=>W(F.id)}),o.jsx("span",{style:{color:F.color},children:F.name})]},F.id)),O.length===0&&o.jsx("span",{className:"workspace-switcher-empty",children:"No areas"})]}),o.jsxs("div",{className:"workspace-switcher-editor-actions",children:[o.jsx("button",{className:"workspace-switcher-btn-save",onClick:M,children:"Save"}),o.jsx("button",{className:"workspace-switcher-btn-cancel",onClick:()=>w(null),children:"Cancel"})]})]}):o.jsxs("div",{className:"workspace-switcher-manager-row",children:[o.jsx("span",{className:"workspace-switcher-manager-name",children:L.name}),o.jsxs("span",{className:"workspace-switcher-manager-count",children:[L.areaIds.length," areas"]}),o.jsx("button",{className:"workspace-switcher-btn-edit",onClick:()=>z(L),title:"Edit",children:"✏"}),o.jsx("button",{className:"workspace-switcher-btn-delete",onClick:()=>R(L.id),title:"Delete",children:"🗑"})]})},L.id))}),S?o.jsxs("div",{className:"workspace-switcher-editor workspace-switcher-create-form",children:[o.jsx("input",{type:"text",value:C,onChange:L=>N(L.target.value),className:"workspace-switcher-input",placeholder:"New workspace name",autoFocus:!0,onKeyDown:L=>{L.key==="Enter"&&_(),L.key==="Escape"&&T(!1)}}),o.jsxs("div",{className:"workspace-switcher-area-list",children:[O.map(L=>o.jsxs("label",{className:"workspace-switcher-area-check",children:[o.jsx("input",{type:"checkbox",checked:k.includes(L.id),onChange:()=>W(L.id)}),o.jsx("span",{style:{color:L.color},children:L.name})]},L.id)),O.length===0&&o.jsx("span",{className:"workspace-switcher-empty",children:"No areas"})]}),o.jsxs("div",{className:"workspace-switcher-editor-actions",children:[o.jsx("button",{className:"workspace-switcher-btn-save",onClick:_,children:"Create"}),o.jsx("button",{className:"workspace-switcher-btn-cancel",onClick:()=>T(!1),children:"Cancel"})]})]}):o.jsxs("button",{className:"workspace-switcher-option workspace-switcher-add",onClick:$,children:["+ ",e("agentBar.newWorkspace",{defaultValue:"New Workspace"})]})]})]})}),vp="tide_webgl_active";typeof window<"u"&&(window.__tidePersistedScene===void 0&&(window.__tidePersistedScene=null),window.__tidePersistedCanvas===void 0&&(window.__tidePersistedCanvas=null),window.__tideWsConnected===void 0&&(window.__tideWsConnected=!1),window.__tideIsPageUnloading===void 0&&(window.__tideIsPageUnloading=!1));function Gp(){return typeof window<"u"?window.__tidePersistedScene??null:null}function Fj(){return typeof window<"u"?window.__tidePersistedCanvas??null:null}function XR(){return typeof window<"u"?window.__tideWsConnected??!1:!1}function qu(t){typeof window<"u"&&(window.__tidePersistedScene=t)}function Eu(t){typeof window<"u"&&(window.__tidePersistedCanvas=t)}function zj(t){typeof window<"u"&&(window.__tideWsConnected=t)}function JR(t){typeof window<"u"&&(window.__tideIsPageUnloading=t)}function ZR(){sessionStorage.setItem(vp,"true")}function _f(t){JR(!0),sessionStorage.removeItem(vp),Lj(),_R(),window.__tideScene&&(window.__tideScene=null);const e=Gp();e?(console.log("[App] Calling persistedScene.dispose()"),e.dispose(),qu(null)):console.log("[App] No persistedScene to dispose"),Eu(null),zj(!1);const n=document.getElementById("battlefield");n&&n.remove();const s=document.getElementById("app");s&&(s.innerHTML="")}function eO(){var a,r;if(window.__tideAppInitialized)return;if(window.__tideAppInitialized=!0,sessionStorage.getItem(vp)==="true"&&console.log("[App] Detected unclean shutdown from previous session - forcing cleanup"),window.__tideScene){console.log("[App] Cleaning up stale __tideScene reference");try{(r=(a=window.__tideScene).dispose)==null||r.call(a)}catch{}window.__tideScene=null}const e=Gp();if(e){console.log("[App] Cleaning up stale persistedScene");try{e.dispose()}catch{}qu(null)}const n=document.getElementById("battlefield"),s=Fj();n&&n!==s&&n.remove(),sessionStorage.removeItem(vp)}function tO(){typeof window>"u"||(eO(),window.addEventListener("pageshow",t=>{t.persisted&&(console.log("[App] Page restored from bfcache - cleaning up"),_f(),window.location.reload())}),window.onunload=()=>_f(),window.onbeforeunload=t=>{_f()},window.addEventListener("pagehide",t=>{_f(`pagehide (persisted=${t.persisted})`)}))}tO();const nS={showTrees:!0,showBushes:!0,showHouse:!0,showLamps:!0,showGrass:!0,showClouds:!0,fogDensity:1,floorStyle:"metal",brightness:1,skyColor:null,battlefieldSize:50},sS={saturation:2,roughness:.5,metalness:-1,emissiveBoost:0,envMapIntensity:1,wireframe:!1,colorMode:"normal"},aS={idleAnimation:"sit",workingAnimation:"sprint"},nO=0;function $j(){const t={characterScale:2,scale2d:.7,scale3d:.7,show2DTaskLabels:!0,gridVisible:!1,timeMode:"day",terrain:nS,modelStyle:sS,animations:aS,fpsLimit:nO},e=Na(pt.CONFIG,null);if(e){const n=e.indicatorScale;return{characterScale:e.characterScale??t.characterScale,scale2d:e.scale2d??n??t.scale2d,scale3d:e.scale3d??n??t.scale3d,show2DTaskLabels:e.show2DTaskLabels??t.show2DTaskLabels,gridVisible:e.gridVisible??t.gridVisible,timeMode:e.timeMode??t.timeMode,terrain:{...nS,...e.terrain},modelStyle:{...sS,...e.modelStyle},animations:{...aS,...e.animations},fpsLimit:e.fpsLimit??t.fpsLimit}}return t}function sO(t){La(pt.CONFIG,t)}function aO(){return typeof window>"u"?!0:window.matchMedia("(max-width: 768px)").matches}typeof window<"u"&&!window.__tideHmrRefreshListeners&&(window.__tideHmrRefreshListeners=new Set);function Uj(){console.log("[Tide HMR] Manual scene refresh triggered");const t=Gp();if(t){try{t.dispose()}catch(n){console.warn("[Tide HMR] Error disposing scene:",n)}qu(null)}Eu(null),window.__tideScene&&(window.__tideScene=null);const e=document.getElementById("battlefield");if(e){const n=e.getContext("webgl2")||e.getContext("webgl");if(n){const s=n.getExtension("WEBGL_lose_context");s&&s.loseContext()}}window.__tideHmrPendingSceneChanges=!1,window.location.reload()}typeof window<"u"&&(window.__tideHmrSceneRefresh=Uj);function rO({canvasRef:t,selectionBoxRef:e,viewMode:n,sceneMountKey:s=0,showToast:a,showAgentNotification:r,toolboxModal:i,contextMenu:c,setHoveredAgentPopup:d,setBuildingPopup:f,getBuildingPopup:h,openBuildingModal:m,openPM2LogsModal:b,openBossLogsModal:y,openDatabasePanel:w,onSceneLoadingChange:C}){const N=x.useRef(null),k=x.useRef(null),j=x.useRef(null),S=x.useRef(null),T=x.useRef(null);return x.useEffect(()=>{if(n!=="3d"){C==null||C(!1);return}if(!t.current||!e.current)return;let D=!1;C==null||C(!0);const E=Gp(),O=Fj()===t.current;function _(){var R,z,$,W,L,F,H,V;(R=N.current)==null||R.setOnToast(a),(z=N.current)==null||z.setOnBuildingClick((G,B)=>{U.selectBuilding(G);const K=U.getState().buildings.get(G);(K==null?void 0:K.type)==="folder"&&K.folderPath?U.openFileExplorer(K.folderPath):(K==null?void 0:K.type)==="server"||(K==null?void 0:K.type)==="boss"||(K==null?void 0:K.type)==="database"?(k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{f({buildingId:G,screenPos:B,fromClick:!0}),k.current=null},150)):m(G)}),($=N.current)==null||$.setOnContextMenu((G,B,K)=>{c.open(G,B,K)}),(W=N.current)==null||W.setOnAgentHover(()=>{}),(L=N.current)==null||L.setOnBuildingHover((G,B)=>{const K=h();if(G&&B){const ne=U.getState().buildings.get(G);((ne==null?void 0:ne.type)==="server"||(ne==null?void 0:ne.type)==="boss"||(ne==null?void 0:ne.type)==="database")&&!(K!=null&&K.fromClick)&&f({buildingId:G,screenPos:B,fromClick:!1})}else K!=null&&K.fromClick||f(null)}),(F=N.current)==null||F.setOnGroundClick(()=>{f(null)}),(H=N.current)==null||H.setOnAreaDoubleClick(G=>{U.selectArea(G),i.open()}),(V=N.current)==null||V.setOnBuildingDoubleClick(G=>{var K;k.current&&(clearTimeout(k.current),k.current=null),f(null);const B=U.getState().buildings.get(G);(B==null?void 0:B.type)==="server"&&((K=B.pm2)!=null&&K.enabled)?b==null||b(G):(B==null?void 0:B.type)==="boss"?y==null||y(G):(B==null?void 0:B.type)==="database"?w==null||w(G):(B==null?void 0:B.type)==="folder"&&B.folderPath?U.openFileExplorer(B.folderPath):m(G)})}if(E)try{N.current=E,O?(console.log("[Tide] Reusing existing scene (StrictMode remount)"),E.ensureRenderLoopRunning()):(console.log("[Tide] Reattaching persisted scene to new canvas"),E.reattach(t.current,e.current),Eu(t.current));const R=U.getState();E.syncAreas(),E.syncBuildings(),R.agents.size>0&&(console.log("[Tide] Re-syncing agents from store after remount:",R.agents.size),E.syncAgents(Array.from(R.agents.values()))),_()}catch(R){console.error("[Tide] Failed to reattach persisted 3D scene:",R),C==null||C(!1)}finally{S.current=requestAnimationFrame(()=>{T.current=requestAnimationFrame(()=>{C==null||C(!1),T.current=null}),S.current=null})}else{const R=t.current,z=e.current,$=async()=>{if(D){console.log("[Tide] Effect cleaned up before scene init, skipping"),C==null||C(!1);return}if(!R.isConnected||!z.isConnected){console.warn("[Tide] Canvas disconnected before initialization"),C==null||C(!1);return}(!R.clientWidth||!R.clientHeight)&&(console.log("[Tide] Canvas has no CSS dimensions, using window fallback"),R.style.width="100%",R.style.height="100%",R.offsetHeight),(!R.clientWidth||!R.clientHeight)&&(R.width=window.innerWidth,R.height=window.innerHeight),ZR();try{const{SceneManager:W}=await vt(async()=>{const{SceneManager:H}=await import("./SceneManager-Do4NpOsy.js");return{SceneManager:H}},__vite__mapDeps([6,4,3,1]));if(D){C==null||C(!1);return}const L=new W(R,z);N.current=L,qu(L),Eu(R);const F=$j();L.setCharacterScale(F.characterScale),L.setScale3D(F.scale3d),L.setGridVisible(F.gridVisible),L.setTimeMode(F.timeMode),L.setTerrainConfig(F.terrain),L.setFloorStyle(F.terrain.floorStyle,!0),L.setAgentModelStyle(F.modelStyle),L.setIdleAnimation(F.animations.idleAnimation),L.setWorkingAnimation(F.animations.workingAnimation),L.setFpsLimit(F.fpsLimit),L.syncAreas(),L.syncBuildings(),L.loadCharacterModels().then(()=>{console.log("[Tide] Character models ready");const H=U.getState();H.customAgentClasses.size>0&&(console.log("[Tide] Applying custom classes from store:",H.customAgentClasses.size),L.setCustomAgentClasses(H.customAgentClasses)),H.agents.size>0&&(console.log("[Tide] Syncing agents from store:",H.agents.size),L.syncAgents(Array.from(H.agents.values()))),L.upgradeAgentModels()}).catch(H=>{console.warn("[Tide] Some models failed to load, using fallback:",H)}).finally(()=>{C==null||C(!1)}),_()}catch(W){console.error("[Tide] Failed to initialize 3D scene:",W),C==null||C(!1)}};j.current=requestAnimationFrame(()=>void $())}Ej({onAgentCreated:R=>{var z,$,W;(z=N.current)==null||z.addAgent(R),($=N.current)==null||$.refreshSelectionVisuals(),(W=window.__spawnModalSuccess)==null||W.call(window)},onAgentUpdated:(R,z)=>{var W;const $=U.getState().agents.get(R.id)||R;(W=N.current)==null||W.updateAgent($,z)},onAgentDeleted:R=>{var z;(z=N.current)==null||z.removeAgent(R)},onAgentsSync:R=>{var $;const z=Array.from(U.getState().agents.values());($=N.current)==null||$.syncAgents(z)},onAreasSync:()=>{var z,$;(z=N.current)==null||z.syncAreas();const R=Array.from(U.getState().agents.values());($=N.current)==null||$.syncAgents(R)},onSpawnError:()=>{var R;(R=window.__spawnModalError)==null||R.call(window)},onSpawnSuccess:()=>{var R;(R=window.__spawnModalSuccess)==null||R.call(window)},onDirectoryNotFound:R=>{var z;(z=window.__spawnModalDirNotFound)==null||z.call(window,R)},onToolUse:(R,z,$)=>{var W;(W=N.current)==null||W.showToolBubble(R,z,$)},onDelegation:(R,z)=>{var $;($=N.current)==null||$.showDelegationEffect(R,z)},onCustomClassesSync:R=>{var z,$;(z=N.current)==null||z.setCustomAgentClasses(R),($=N.current)==null||$.upgradeAgentModels()},onBuildingUpdated:R=>{var z;(z=N.current)==null||z.updateBuilding(R)},onSubagentStarted:R=>{var z;(z=N.current)==null||z.addSubagentEffect(R.id,R.parentAgentId,R.name,R.subagentType)},onSubagentCompleted:R=>{var W;const z=U.getSubagent(R)||U.getSubagentByToolUseId(R),$=(z==null?void 0:z.id)||R;(W=N.current)==null||W.completeSubagentEffect($),setTimeout(()=>{var L;(L=N.current)==null||L.removeSubagentEffect($)},3e4)}});const M=GR(()=>{if(N.current){N.current.syncAreas(),N.current.syncBuildings();const R=Array.from(U.getState().agents.values());N.current.syncAgents(R)}});return()=>{M(),D=!0,j.current!==null&&(cancelAnimationFrame(j.current),j.current=null),S.current!==null&&(cancelAnimationFrame(S.current),S.current=null),T.current!==null&&(cancelAnimationFrame(T.current),T.current=null),U.getState().viewMode!=="3d"&&aO()&&N.current&&(console.log("[Tide] 3D canvas unmounted - disposing scene to free memory"),ER(),N.current.dispose(),N.current=null,qu(null),Eu(null))}},[n,s]),N}function iO({showToast:t,showAgentNotification:e}){x.useEffect(()=>{Ej({onToast:t,onReconnect:()=>{U.triggerReconnect()},onAgentNotification:a=>{e(a)}}),XR()||(Hu(),zj(!0)),wR();let n;SR(a=>{a.type==="agent_notification"&&typeof a.agentId=="string"&&jj(a.agentId)}).then(a=>{n=a});const s=()=>{console.log("[Tide] App resumed from background, reconnecting..."),setTimeout(()=>Hu(),100)};return window.addEventListener("tideAppResume",s),()=>{window.removeEventListener("tideAppResume",s),n==null||n()}},[t,e])}function oO(t){x.useEffect(()=>{let e="",n="",s=new Map;const a=r=>{var d;let i=!1;const c=new Map;for(const[f,h]of r){const b=`${h.position.x.toFixed(2)},${h.position.z.toFixed(2)},${h.status},${h.class},${h.isBoss},${((d=h.subordinateIds)==null?void 0:d.length)??0}`.split("").reduce((y,w)=>(y<<5)-y+w.charCodeAt(0),0);c.set(f,b),s.get(f)!==b&&(i=!0)}return c.size!==s.size&&(i=!0),{newVersion:c,changed:i}};return U.subscribe(()=>{var b;const r=U.getState(),i=Array.from(r.selectedAgentIds).sort().join(","),c=Array.from(r.selectedBuildingIds).sort().join(","),d=i!==e,f=c!==n,{newVersion:h,changed:m}=a(r.agents);(d||f||m)&&(e=i,n=c,s=h,(b=t.current)==null||b.refreshSelectionVisuals())})},[t])}function lO(t){x.useEffect(()=>{var s;(s=t.current)==null||s.syncAreas();let e=0,n=0;return U.subscribe(()=>{var c,d;const r=U.getState().areas;if(r.size!==e){e=r.size,n=Date.now(),(c=t.current)==null||c.syncAreas();return}let i=0;for(const[f,h]of r){let m=f.charCodeAt(0);m+=(h.width??0)+(h.height??0)+(h.radius??0),m+=Math.floor(h.center.x*100)+Math.floor(h.center.z*100),m+=(h.zIndex??0)*1e3;for(let b=0;b<h.name.length;b++)m+=h.name.charCodeAt(b);for(let b=0;b<h.color.length;b++)m+=h.color.charCodeAt(b);if(h.directoryGitCounts)for(const b of h.directoryGitCounts)m+=(b+1)*7;if(h.logo){m+=Math.floor((h.logo.opacity??.8)*1e3),m+=Math.floor(h.logo.width*100)+Math.floor(h.logo.height*100);for(let b=0;b<h.logo.position.length;b++)m+=h.logo.position.charCodeAt(b);if(h.logo.filename)for(let b=0;b<h.logo.filename.length;b++)m+=h.logo.filename.charCodeAt(b)}i^=m|0}i!==n&&(n=i,(d=t.current)==null||d.syncAreas())})},[t])}function cO(t){x.useEffect(()=>{var s;(s=t.current)==null||s.syncBuildings();let e=0,n=0;return U.subscribe(()=>{var c,d;const r=U.getState().buildings;if(r.size!==e){e=r.size,n=Date.now(),(c=t.current)==null||c.syncBuildings();return}let i=0;for(const[f,h]of r){i^=h.position.x*1e3+h.position.z|0,i^=(h.scale||1)*1e4|0;const m=`${h.style||""}${h.name}${h.status}${h.gitChangesCount||0}`;for(let b=0;b<m.length;b++)i=(i<<5)-i+m.charCodeAt(b)|0}i!==n&&(n=i,(d=t.current)==null||d.syncBuildings())})},[t])}function uO(t,e){x.useEffect(()=>{var n;(n=t.current)==null||n.highlightArea(e)},[t,e])}function dO(t,e){x.useEffect(()=>{var n;(n=t.current)==null||n.setPowerSaving(e)},[t,e])}function Pt(t,e,n,s,a={},r="global"){return{id:t,name:e,description:n,key:s,modifiers:a,enabled:!0,context:r}}const Lg=[Pt("toggle-commander","Toggle Commander","Open/close Commander View","k",{ctrl:!0}),Pt("toggle-commander-tab","Toggle Commander (Tab)","Open/close Commander View with Tab","Tab",{}),Pt("spawn-agent","Spawn Agent","Open new agent spawn modal","n",{alt:!0}),Pt("select-agent-1","Select Agent 1","Select first agent","1",{ctrl:!0}),Pt("select-agent-2","Select Agent 2","Select second agent","2",{ctrl:!0}),Pt("select-agent-3","Select Agent 3","Select third agent","3",{ctrl:!0}),Pt("select-agent-4","Select Agent 4","Select fourth agent","4",{ctrl:!0}),Pt("select-agent-5","Select Agent 5","Select fifth agent","5",{ctrl:!0}),Pt("select-agent-6","Select Agent 6","Select sixth agent","6",{ctrl:!0}),Pt("select-agent-7","Select Agent 7","Select seventh agent","7",{ctrl:!0}),Pt("select-agent-8","Select Agent 8","Select eighth agent","8",{ctrl:!0}),Pt("select-agent-9","Select Agent 9","Select ninth agent","9",{ctrl:!0}),Pt("delete-selected","Delete Selected","Remove selected agents","Delete",{}),Pt("delete-selected-backspace","Delete Selected (Backspace)","Remove selected agents","Backspace",{}),Pt("deselect-all","Deselect All","Clear agent selection","Escape",{}),Pt("open-terminal","Open Terminal","Open terminal for selected agent","Space",{}),Pt("dashboard-selector-toggle","Dashboard Selector","Enable dashboard card selector",",",{}),Pt("dashboard-vim-left","Dashboard Left","Move dashboard selector left","h",{}),Pt("dashboard-vim-down","Dashboard Down","Move dashboard selector down","j",{}),Pt("dashboard-vim-up","Dashboard Up","Move dashboard selector up","k",{}),Pt("dashboard-vim-right","Dashboard Right","Move dashboard selector right","l",{}),Pt("next-agent","Next Agent","Select next agent on battlefield","l",{alt:!0}),Pt("prev-agent","Previous Agent","Select previous agent on battlefield","h",{alt:!0}),Pt("next-working-agent","Next Working Agent","Select next working agent on battlefield","l",{alt:!0,shift:!0}),Pt("prev-working-agent","Previous Working Agent","Select previous working agent on battlefield","h",{alt:!0,shift:!0}),Pt("next-message","Next Message","Navigate to next message in terminal","j",{alt:!0}),Pt("prev-message","Previous Message","Navigate to previous message in terminal","k",{alt:!0}),Pt("page-down-messages","Page Down Messages","Jump down 10 messages in terminal","d",{alt:!0,shift:!0}),Pt("page-up-messages","Page Up Messages","Jump up 10 messages in terminal","u",{alt:!0}),Pt("next-agent-terminal","Next Agent (Terminal)","Switch to next agent in terminal","l",{alt:!0}),Pt("prev-agent-terminal","Previous Agent (Terminal)","Switch to previous agent in terminal","h",{alt:!0}),Pt("activate-message","Activate Message","Click on interactive element in selected message","Space",{}),Pt("toggle-file-explorer","Toggle File Explorer","Open/close file explorer","e",{alt:!0}),Pt("file-explorer-close-tab","Close File Tab","Close active file tab in explorer","w",{alt:!0}),Pt("toggle-spotlight","Toggle Spotlight","Open/close global search","p",{alt:!0}),Pt("open-database","Open Database","Open last used database query builder","d",{alt:!0}),Pt("toggle-2d-view","Cycle View Mode","Cycle between 3D, 2D, and Dashboard views","2",{alt:!0}),Pt("clear-context","Clear Context","Clear context of the selected agent","c",{alt:!0,shift:!0}),Pt("commander-close","Close Commander","Close Commander View","Escape",{},"commander"),Pt("commander-vim-left","Navigate Left","Move focus left (Vim H)","h",{alt:!0},"commander"),Pt("commander-vim-down","Navigate Down","Move focus down (Vim J)","j",{alt:!0},"commander"),Pt("commander-vim-up","Navigate Up","Move focus up (Vim K)","k",{alt:!0},"commander"),Pt("commander-vim-right","Navigate Right","Move focus right (Vim L)","l",{alt:!0},"commander"),Pt("commander-expand","Expand/Collapse","Toggle agent expansion","o",{alt:!0},"commander"),Pt("commander-new-agent","New Agent","Open spawn form in commander","n",{alt:!0},"commander"),Pt("commander-next-tab","Next Tab","Switch to next area tab","Tab",{},"commander"),Pt("commander-prev-tab","Previous Tab","Switch to previous area tab","Tab",{shift:!0},"commander"),Pt("toolbox-close","Close Toolbox","Close Settings panel","Escape",{},"toolbox")];function Tn(t,e){if(!e||!e.enabled)return!1;const{ctrl:n,alt:s,shift:a}=e.modifiers,r=n?t.ctrlKey||t.metaKey:!t.ctrlKey&&!t.metaKey,i=s?t.altKey:!t.altKey,c=a?t.shiftKey:!t.shiftKey;let d;if(n?d=(t.ctrlKey||t.metaKey)&&i&&c:d=r&&i&&c,!d)return!1;const f=e.key;if(f.length===1&&/^[a-zA-Z]$/.test(f)){const m=`Key${f.toUpperCase()}`;return t.code===m}if(f.length===1&&/^[0-9]$/.test(f)){const m=`Digit${f}`;return t.code===m}return f==="Space"||f===" "?t.code==="Space":t.key===f}function Tq(t){const e=[];if(t.modifiers.ctrl){const s=navigator.platform.toUpperCase().indexOf("MAC")>=0;e.push(s?"⌘":"Ctrl")}if(t.modifiers.alt){const s=navigator.platform.toUpperCase().indexOf("MAC")>=0;e.push(s?"⌥":"Alt")}t.modifiers.shift&&e.push("Shift"),t.modifiers.meta&&e.push("⌘");let n=t.key;return n===" "?n="Space":n.length===1&&(n=n.toUpperCase()),e.push(n),e.join("+")}function _q(t,e,n,s){return t.filter(a=>{if(a.id===n||!a.enabled||s&&a.context!=="global"&&a.context!==s)return!1;const r=h=>h===" "||h==="Space"?"Space":h.length===1?h.toLowerCase():h,i=r(a.key),c=r(e.key);if(i!==c)return!1;const d=a.modifiers,f=e.modifiers;return(d.ctrl||!1)===(f.ctrl||!1)&&(d.alt||!1)===(f.alt||!1)&&(d.shift||!1)===(f.shift||!1)&&(d.meta||!1)===(f.meta||!1)})}function fO({sceneRef:t,spawnModal:e,commanderModal:n,explorerModal:s,spotlightModal:a,deleteConfirmModal:r,onRequestBuildingDelete:i,onOpenDatabasePanel:c,onCloseDatabasePanel:d,databasePanelOpen:f}){x.useEffect(()=>{const h=m=>{var R,z,$,W;const b=U.getShortcuts(),y=m.target,w=y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.getAttribute("contenteditable")==="true"||!!y.closest(".cm-editor"),C=b.find(L=>L.id==="deselect-all");if(Tn(m,C)){if(y.closest(".guake-bottom-terminal-embed"))return;if(ep()){m.preventDefault();return}const L=U.getState();if(L.activeTool==="rectangle"||L.activeTool==="circle"){(R=t.current)==null||R.setDrawingTool(null),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(null);return}e.isOpen?e.close():L.terminalOpen?(U.setTerminalOpen(!1),document.activeElement instanceof HTMLElement&&document.activeElement.blur()):(U.deselectAll(),(z=t.current)==null||z.refreshSelectionVisuals())}for(let L=1;L<=9;L++){const F=b.find(H=>H.id===`select-agent-${L}`);if(Tn(m,F)){m.preventDefault();const H=U.getState(),V=L-1,G=Array.from(H.agents.keys());V<G.length&&(U.selectAgent(G[V]),($=t.current)==null||$.refreshSelectionVisuals());return}}const N=b.find(L=>L.id==="spawn-agent");if(Tn(m,N)){m.preventDefault(),e.open();return}const k=b.find(L=>L.id==="toggle-commander-tab");if(Tn(m,k)&&!w){m.preventDefault(),n.toggle();return}const j=b.find(L=>L.id==="toggle-commander");if(Tn(m,j)){m.preventDefault(),n.toggle();return}const S=b.find(L=>L.id==="toggle-file-explorer");if(Tn(m,S)){m.preventDefault();const L=U.getState();if(s.isOpen||L.explorerFolderPath!==null||L.explorerAreaId!==null)s.close(),U.closeFileExplorer();else{const H=U.getLastExplorerState();if((H==null?void 0:H.type)==="folder")U.openFileExplorer(H.path);else if((H==null?void 0:H.type)==="area")if(L.areas.has(H.areaId))s.open(H.areaId);else{const V=Array.from(L.areas.values()).filter(G=>G.directories&&G.directories.length>0);V.length>0&&s.open(V[0].id)}else{const V=Array.from(L.areas.values()).filter(G=>G.directories&&G.directories.length>0);V.length>0&&s.open(V[0].id)}}return}if(m.altKey&&!m.ctrlKey&&!m.shiftKey&&!m.metaKey&&m.code==="KeyD"){if(m.preventDefault(),m.stopPropagation(),f){d();return}const L=localStorage.getItem("tide-commander-last-database-building"),F=U.getState();if(L){const H=F.buildings.get(L);if((H==null?void 0:H.type)==="database"){c(L);return}}for(const[H,V]of F.buildings)if(V.type==="database"){c(H);return}return}const T=b.find(L=>L.id==="toggle-spotlight");if(Tn(m,T)||m.altKey&&!m.ctrlKey&&!m.metaKey&&m.code==="KeyP"){console.log("[useKeyboardShortcuts] Spotlight shortcut matched!",{spotlightShortcut:T,altKey:m.altKey,code:m.code}),m.preventDefault(),a.toggle();return}const D=b.find(L=>L.id==="toggle-2d-view");if(Tn(m,D)){m.preventDefault();const L=U.getState().viewMode,F=L==="3d"?"2d":L==="2d"?"dashboard":"3d";U.setViewMode(F);return}const E=b.find(L=>L.id==="clear-context");if(Tn(m,E)){m.preventDefault();const L=U.getState(),F=L.selectedAgentIds.size===1?Array.from(L.selectedAgentIds)[0]:null;F&&U.clearContext(F);return}const I=b.find(L=>L.id==="next-working-agent"),O=b.find(L=>L.id==="prev-working-agent");if((Tn(m,I)||Tn(m,O))&&!w){const L=U.getState();if(L.terminalOpen)return;const F=Array.from(L.agents.values());let H=F.filter(K=>L.agentsWithUnseenOutput.has(K.id));if(H.length===0&&(H=F.filter(K=>K.status==="working")),H.length===0)return;m.preventDefault();const V=L.selectedAgentIds.size===1?Array.from(L.selectedAgentIds)[0]:null,G=V?H.findIndex(K=>K.id===V):-1;let B;Tn(m,I)?B=G===-1?0:(G+1)%H.length:B=G===-1?H.length-1:(G-1+H.length)%H.length,U.selectAgent(H[B].id),(W=t.current)==null||W.refreshSelectionVisuals();return}const _=b.find(L=>L.id==="delete-selected"),M=b.find(L=>L.id==="delete-selected-backspace");if((Tn(m,_)||Tn(m,M))&&!w){const L=U.getState();if(L.selectedAgentIds.size>0){m.preventDefault(),r.open();return}if(L.selectedBuildingIds.size>0){m.preventDefault(),i();return}return}};return document.addEventListener("keydown",h,!0),()=>document.removeEventListener("keydown",h,!0)},[t,e,n,s,a,r,i,c,d,f])}function pO(){const[t,e]=x.useState(!1);return window.__tideSetBackNavModal=e,x.useEffect(()=>{if(window.__tideBackNavSetup){window.location.hash.includes("app")||(window.location.hash="#app");return}window.__tideBackNavSetup=!0,window.location.hash.includes("app")||(window.location.hash="#app");const s=()=>window.innerWidth<=768;let a=0;const r=()=>{var c;Date.now()-a<200||window.location.hash.includes("app")||(window.location.hash="#app",s()&&(ep()||(c=window.__tideSetBackNavModal)==null||c.call(window,!0)))},i=()=>{var c;window.location.hash.includes("app")||(window.location.hash="#app"),window.location.hash==="#app"&&setTimeout(()=>{window.location.hash==="#app"&&!window.location.hash.includes("app2")&&(window.history.pushState(null,"","#app2"),window.history.pushState(null,"","#app"))},50),s()?ep()?a=Date.now():(c=window.__tideSetBackNavModal)==null||c.call(window,!0):(ep(),a=Date.now())};window.history.pushState(null,"","#app1"),window.history.pushState(null,"","#app2"),window.history.pushState(null,"","#app"),window.addEventListener("hashchange",r),window.addEventListener("popstate",i)},[]),{showBackNavModal:t,setShowBackNavModal:e,handleLeave:()=>{e(!1);const s=window.__tideHistoryDepth??2;window.history.go(-(s+1))}}}const Ig="agent-order-change";function hO(t){const e=x.useMemo(()=>new Set(t.map(d=>d.id)),[t]),[n,s]=x.useState(()=>Na(pt.AGENT_ORDER,[]));x.useEffect(()=>{const d=f=>{s(f.detail)};return window.addEventListener(Ig,d),()=>{window.removeEventListener(Ig,d)}},[]);const a=x.useMemo(()=>{const d=n.filter(b=>e.has(b)),f=t.filter(b=>!d.includes(b.id)).map(b=>b.id),h=[...d,...f],m=new Map(t.map(b=>[b.id,b]));return h.map(b=>m.get(b)).filter(b=>b!==void 0)},[t,n,e]),r=x.useCallback(d=>{s(d),La(pt.AGENT_ORDER,d),window.dispatchEvent(new CustomEvent(Ig,{detail:d}))},[]),i=x.useCallback((d,f)=>{const h=a.map(b=>b.id),[m]=h.splice(d,1);h.splice(f,0,m),r(h)},[a,r]),c=x.useCallback(()=>{s([]),La(pt.AGENT_ORDER,[])},[]);return x.useEffect(()=>{if(e.size===0)return;const d=n.filter(f=>e.has(f));d.length!==n.length&&r(d)},[e,n,r]),{orderedAgents:a,moveAgent:i,resetOrder:c}}function Ta(t){const e=x.useRef(null),n=x.useCallback(a=>{e.current=a.target,a.target===a.currentTarget&&a.stopPropagation()},[]),s=x.useCallback(a=>{a.target===a.currentTarget&&e.current===a.currentTarget&&(a.stopPropagation(),t()),e.current=null},[t]);return{handleMouseDown:n,handleClick:s}}const mO=3e4;function gO(){const t=x.useRef(null);x.useEffect(()=>{const e=async()=>{var i,c;const n=U.getState(),s=new Map,a=new Map;for(const[d,f]of n.buildings){const h=f.folderPath||f.cwd;h&&(a.has(h)||a.set(h,[]),a.get(h).push(d))}for(const[d,f]of a)try{const h=await Bt(Rt(`/api/files/git-status?path=${encodeURIComponent(d)}`));if(!h.ok)continue;const b=((i=(await h.json()).files)==null?void 0:i.length)||0;s.set(d,b);for(const y of f){const w=U.getState().buildings.get(y);w&&w.gitChangesCount!==b&&U.updateBuildingLocal(y,{gitChangesCount:b})}}catch{}const r=new Map;for(const[d,f]of n.areas)f.archived||!f.directories||f.directories.forEach((h,m)=>{h&&(r.has(h)||r.set(h,[]),r.get(h).push({areaId:d,dirIndex:m}))});if(r.size!==0)for(const[d,f]of r)try{let h;if(s.has(d))h=s.get(d);else{const b=await Bt(Rt(`/api/files/git-status?path=${encodeURIComponent(d)}`));if(!b.ok)continue;h=((c=(await b.json()).files)==null?void 0:c.length)||0,s.set(d,h)}const m=new Map;for(const b of f)m.has(b.areaId)||m.set(b.areaId,[]),m.get(b.areaId).push({dirIndex:b.dirIndex,count:h});for(const[b,y]of m){const w=U.getState().areas.get(b);if(!w)continue;const C=w.directoryGitCounts?[...w.directoryGitCounts]:new Array(w.directories.length).fill(0);let N=!1;for(const{dirIndex:k,count:j}of y)C[k]!==j&&(C[k]=j,N=!0);N&&U.updateAreaLocal(b,{directoryGitCounts:C})}}catch{}};return e(),t.current=setInterval(e,mO),()=>{t.current&&(clearInterval(t.current),t.current=null)}},[])}const Pg={historyLimit:500,hideCost:!0,showFPS:!1,powerSaving:!1,customAgentNames:[],experimental2DView:!1,experimentalVoiceAssistant:!1,experimentalTTS:!1,experimentalEchoPrompt:!1,externalEditorCommand:"",vibrationIntensity:1},rS=90,Bg=["simple","chat","advanced"],iS=55,oS=20,lS=95,bO=200,xO=12e4,yO=5,la=new Map;function vO(t){const e=la.get(t);e&&(la.delete(t),la.set(t,e))}function wO(){for(;la.size>yO;){const t=la.keys().next().value;if(t!==void 0)la.delete(t);else break}}function Hj(t){la.delete(t)}function kO(t){return t.trim().replace(/\r\n/g,`
|
|
43
|
+
`)}function ex(t,e){return`${t}:${kO(e)}`}function cS(t,e,n,s){if(t.uuid&&e.has(t.uuid))return!1;const a=t.isUserPrompt?"user":"assistant",r=ex(a,t.text),i=t.timestamp||0,c=n.get(r);return c!==void 0&&Math.abs(i-c)<=xO?!1:i>s}function Wj({selectedAgentId:t,hasSessionId:e,reconnectCount:n,historyRefreshTrigger:s,lastPrompts:a,outputScrollRef:r}){const[i,c]=x.useState([]),[d,f]=x.useState(!1),[h,m]=x.useState(!1),[b,y]=x.useState(0),[w,C]=x.useState(!1),[N,k]=x.useState(!1),[j,S]=x.useState(0),T=x.useRef(!0),D=x.useRef(0),E=x.useRef(0),I=x.useRef(!1),O=x.useRef(!1),_=x.useRef(null),M=x.useRef(!1),R=x.useRef(null),z=x.useRef(null);x.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]),x.useEffect(()=>{if(!t||!e){c([]),E.current=0,k(!1),O.current=!1,S(0),f(!1),m(!1),y(Z=>Z+1),M.current=!1,R.current=null;return}const V=`${t}:${n}:${s}`;if(R.current===V)return;const G=_.current!==null&&_.current!==t,B=n>0,K=G||B,ne=!G&&!M.current&&e;_.current=t,M.current=e,R.current=V;let q;if(B){const Z=U.getOutputs(t);Z.length>0&&(q=Z.map(ce=>({...ce})))}z.current&&(clearTimeout(z.current),z.current=null),B&&la.delete(t),D.current+=1;const xe=D.current;m(!0);const Ae=la.get(t);Ae?(vO(t),c(Ae.messages),E.current=Ae.messages.length,k(Ae.hasMore),O.current=Ae.hasMore,S(Ae.totalCount)):(c([]),E.current=0,k(!1),O.current=!1,S(0)),ne||(z.current=setTimeout(()=>{f(!0)},150)),Bt(Rt(`/api/agents/${t}/history?limit=${rS}&offset=0`)).then(Z=>{if(!Z.ok)throw new Error(`HTTP ${Z.status}: ${Z.statusText}`);return Z.json()}).then(Z=>{if(xe!==D.current)return;const ce=Array.isArray(Z.messages)?Z.messages:[],me=Array.isArray(Z.subagents)?Z.subagents:[];c(ce),E.current=ce.length;const ee=Z.hasMore||!1;if(k(ee),O.current=ee,S(Z.totalCount||0),me.length>0&&U.hydrateSubagentsFromHistory(t,me),la.set(t,{messages:ce,hasMore:ee,totalCount:Z.totalCount||0}),wO(),q&&q.length>0){const re=ce.length>0?Math.max(...ce.map(ge=>ge.timestamp?new Date(ge.timestamp).getTime():0)):0,We=new Set(ce.map(ge=>ge.uuid).filter(ge=>typeof ge=="string"&&ge.length>0)),ze=new Map;for(const ge of ce){if(ge.type!=="user"&&ge.type!=="assistant")continue;const Te=ex(ge.type,ge.content),qe=ge.timestamp?new Date(ge.timestamp).getTime():0,it=ze.get(Te)??0;qe>it&&ze.set(Te,qe)}const Pe=q.filter(ge=>cS(ge,We,ze,re));U.clearOutputs(t);for(const ge of Pe)U.addOutput(t,ge)}else if(ce.length>0){const re=Math.max(...ce.map(Te=>Te.timestamp?new Date(Te.timestamp).getTime():0)),We=new Set(ce.map(Te=>Te.uuid).filter(Te=>typeof Te=="string"&&Te.length>0)),ze=new Map;for(const Te of ce){if(Te.type!=="user"&&Te.type!=="assistant")continue;const qe=ex(Te.type,Te.content),it=Te.timestamp?new Date(Te.timestamp).getTime():0,he=ze.get(qe)??0;it>he&&ze.set(qe,it)}const Pe=U.getOutputs(t),ge=Pe.filter(Te=>{const qe=cS(Te,We,ze,re);return qe||console.warn(`[HISTORY-DEDUP] Removing live output: uuid=${Te.uuid||"none"} ts=${Te.timestamp} lastHistTs=${re} text="${Te.text.slice(0,80)}"`),qe});if(Pe.length!==ge.length){console.warn(`[HISTORY-DEDUP] Cleared ${Pe.length-ge.length}/${Pe.length} overlapping outputs for agent ${t}`),U.clearOutputs(t);for(const Te of ge)U.addOutput(t,Te)}}if(!a.get(t)){for(let re=ce.length-1;re>=0;re--)if(ce[re].type==="user"){U.setLastPrompt(t,ce[re].content);break}}}).catch(Z=>{if(console.error("Failed to load history:",Z),c([]),E.current=0,k(!1),O.current=!1,S(0),K&&q&&q.length>0){U.clearOutputs(t);for(const ce of q)U.addOutput(t,ce)}}).finally(()=>{T.current&&xe===D.current&&(z.current&&(clearTimeout(z.current),z.current=null),f(!1),m(!1),y(Z=>Z+1))})},[t,e,n,s]);const $=x.useCallback(async()=>{if(!t||I.current||!O.current)return;const V=r.current;if(!V){console.warn("loadMoreHistory: outputScrollRef not connected");return}const G=V.scrollHeight-V.scrollTop;I.current=!0,C(!0);const B=E.current;try{const ne=await(await Bt(Rt(`/api/agents/${t}/history?limit=${rS}&offset=${B}`))).json(),q=Array.isArray(ne.subagents)?ne.subagents:[];if(q.length>0&&U.hydrateSubagentsFromHistory(t,q),ne.messages&&ne.messages.length>0){if(!T.current)return;c(Ae=>{const Z=[...ne.messages,...Ae];return E.current=Z.length,Z});const xe=ne.hasMore||!1;O.current=xe,k(xe),requestAnimationFrame(()=>{requestAnimationFrame(()=>{T.current&&(r.current&&(r.current.scrollTop=r.current.scrollHeight-G),I.current=!1,C(!1))})})}else{if(!T.current)return;I.current=!1,C(!1)}}catch(K){if(console.error("Failed to load more history:",K),!T.current)return;I.current=!1,C(!1)}},[t,r]),W=x.useCallback(V=>{if(!r.current||V.current)return;const{scrollTop:G}=r.current;!I.current&&O.current&&G<bO&&$()},[$,r]),L=x.useCallback(()=>{c([]),E.current=0,t&&la.delete(t)},[t]),F=x.useRef(!1),H=x.useCallback(async()=>{var V,G;if(!(!t||!O.current)&&!(I.current||F.current)){F.current=!0,I.current=!0,C(!0);try{const K=await(await Bt(Rt(`/api/agents/${t}/history?limit=100000&offset=0`))).json();if(!T.current)return;const ne=Array.isArray(K.subagents)?K.subagents:[];ne.length>0&&U.hydrateSubagentsFromHistory(t,ne),K.messages&&K.messages.length>0&&(c(K.messages),E.current=K.messages.length),O.current=!1,k(!1),S(K.totalCount||((V=K.messages)==null?void 0:V.length)||0),la.set(t,{messages:K.messages||[],hasMore:!1,totalCount:K.totalCount||((G=K.messages)==null?void 0:G.length)||0})}catch(B){console.error("Failed to load all history:",B)}finally{T.current&&(I.current=!1,F.current=!1,C(!1))}}},[t]);return{history:i,loadingHistory:d,fetchingHistory:h,historyLoadVersion:b,loadingMore:w,hasMore:N,totalCount:j,isMountedRef:T,loadMoreHistory:$,loadAllHistory:H,allLoaded:!N,handleScroll:W,clearHistory:L,hasCachedHistory:x.useCallback(V=>la.has(V),[])}}function ru(...t){}function SO(t){return(t.tokensUsed??0)===0&&(t.contextUsed??0)===0&&!t.contextStats&&!t.sessionId&&!t.currentTask&&!t.lastAssignedTask}function uS(t,e){var r,i;if(!t||SO(e))return e;const n=((r=t.contextStats)==null?void 0:r.lastUpdated)??0,s=((i=e.contextStats)==null?void 0:i.lastUpdated)??0;return n>0&&n>s?{...e,contextUsed:t.contextUsed,contextLimit:t.contextLimit,contextStats:t.contextStats}:e}function CO(t,e,n,s,a){return{setAgents(r){const i=new Map,c=t().agents;for(const f of r){const h=c.get(f.id);i.set(f.id,uS(h,f)),(f.class==="boss"||f.isBoss)&&ru("[Store.setAgents] Boss agent:",f.name,"subordinateIds:",f.subordinateIds)}const d=r.find(f=>f.status==="working");e(f=>{f.agents=i,d&&f.selectedAgentIds.size===0&&(f.selectedAgentIds=new Set([d.id]),f.terminalOpen=!0)}),n()},addAgent(r){e(i=>{const c=new Map(i.agents);c.set(r.id,r),i.agents=c}),n()},updateAgent(r){var h;const c=t().agents.get(r.id),d=(c==null?void 0:c.status)!==r.status;d&&ru(`[Store] Agent ${r.name} status update: ${c==null?void 0:c.status} → ${r.status}`);let f=!1;e(m=>{const b=new Map(m.agents);b.set(r.id,uS(c,r)),m.agents=b,d&&(c==null?void 0:c.status)==="working"&&r.status==="idle"&&(m.terminalOpen&&m.selectedAgentIds.has(r.id)||(m.agentsWithUnseenOutput=new Set(m.agentsWithUnseenOutput),m.agentsWithUnseenOutput.add(r.id),ru(`[Store] Agent ${r.name} completed work - marked as unseen`),f=!0))}),f&&a&&a(),n(),d&&ru(`[Store] Agent ${r.name} status now in store: ${(h=t().agents.get(r.id))==null?void 0:h.status}`)},updateAgentContextStats(r,i){const d=t().agents.get(r);d&&(e(f=>{const h=new Map(f.agents);h.set(r,{...d,contextStats:i,contextUsed:i.totalTokens,contextLimit:i.contextWindow}),f.agents=h}),n())},updateAgentContext(r,i,c){const f=t().agents.get(r);if(f){const h=Math.max(1,c||2e5),m=Math.max(0,Math.min(100,Number((i/h*100).toFixed(1))));e(b=>{const y=new Map(b.agents),w=f.contextStats?{...f.contextStats,totalTokens:i,contextWindow:h,usedPercent:m,lastUpdated:Date.now()}:void 0;y.set(r,{...f,contextUsed:i,contextLimit:h,contextStats:w}),b.agents=y}),n()}},removeAgent(r){const i=t().agentsWithUnseenOutput.has(r);e(c=>{const d=new Map(c.agents);d.delete(r),c.agents=d;const f=new Set(c.selectedAgentIds);f.delete(r),c.selectedAgentIds=f,c.agentOutputs.delete(r),c.lastPrompts.delete(r),c.agentsWithUnseenOutput.has(r)&&(c.agentsWithUnseenOutput=new Set(c.agentsWithUnseenOutput),c.agentsWithUnseenOutput.delete(r)),c.delegationHistories.delete(r),c.lastDelegationReceived.delete(r),c.agentTaskProgress.delete(r),c.supervisor.narratives.delete(r),c.supervisor.agentHistories.delete(r),c.supervisor.historyFetchedForAgents.delete(r),c.subagents.delete(r)}),Hj(r),i&&a&&a(),n()},selectAgent(r){let i=!1;e(c=>{c.selectedAgentIds=new Set(r?[r]:[]),r&&(c.lastSelectedAgentId=r,c.agentsWithUnseenOutput.has(r)&&(c.agentsWithUnseenOutput=new Set(c.agentsWithUnseenOutput),c.agentsWithUnseenOutput.delete(r),i=!0)),c.currentSnapshot=null}),i&&a&&a(),n()},addToSelection(r){let i=!1;e(c=>{const d=new Set(c.selectedAgentIds);d.has(r)?d.delete(r):(d.add(r),c.agentsWithUnseenOutput.has(r)&&(c.agentsWithUnseenOutput=new Set(c.agentsWithUnseenOutput),c.agentsWithUnseenOutput.delete(r),i=!0)),c.selectedAgentIds=d}),i&&a&&a(),n()},selectMultiple(r){e(i=>{i.selectedAgentIds=new Set(r)}),n()},deselectAll(){e(r=>{r.selectedAgentIds=new Set}),n()},spawnAgent(r,i,c,d,f,h,m,b,y,w,C,N,k){ru("[Store] spawnAgent called with:",{name:r,agentClass:i,cwd:c,position:d,sessionId:f,useChrome:h,permissionMode:m,initialSkillIds:b,provider:y,codexConfig:w,codexModel:C,model:N,customInstructions:k?`${k.length} chars`:void 0});const j=d?{x:d.x,y:0,z:d.z}:void 0,S={type:"spawn_agent",payload:{name:r,class:i,cwd:c,position:j,sessionId:f,useChrome:h,permissionMode:m,initialSkillIds:b,provider:y,codexConfig:w,codexModel:C,model:N,customInstructions:k}},T=s();if(!T){console.error("[Store] sendMessage is not defined! WebSocket may not be connected");return}T(S)},createDirectoryAndSpawn(r,i,c){var d;(d=s())==null||d({type:"create_directory",payload:{path:r,name:i,class:c}})},sendCommand(r,i){var c;e(d=>{d.lastPrompts.set(r,{text:i,timestamp:Date.now()})}),n(),(c=s())==null||c({type:"send_command",payload:{agentId:r,command:i}})},refreshAgentContext(r){var i;(i=s())==null||i({type:"request_context_stats",payload:{agentId:r}})},moveAgentLocal(r,i){const d=t().agents.get(r);d&&(e(f=>{const h={...d,position:i},m=new Map(f.agents);m.set(r,h),f.agents=m}),n())},moveAgent(r,i){var f;const d=t().agents.get(r);d&&(e(h=>{const m={...d,position:i},b=new Map(h.agents);b.set(r,m),h.agents=b}),n()),(f=s())==null||f({type:"move_agent",payload:{agentId:r,position:i}})},killAgent(r){var i;(i=s())==null||i({type:"kill_agent",payload:{agentId:r}})},stopAgent(r){var i;(i=s())==null||i({type:"stop_agent",payload:{agentId:r}})},clearContext(r){var i;(i=s())==null||i({type:"clear_context",payload:{agentId:r}}),e(c=>{const d=c.agents.get(r);if(d){const y={...d,status:"idle",currentTask:void 0,taskLabel:void 0,currentTool:void 0,lastAssignedTask:void 0,lastAssignedTaskTime:void 0,sessionId:void 0,tokensUsed:0,contextUsed:0,contextStats:void 0},w=new Map(c.agents);w.set(r,y),c.agents=w}const f=new Map(c.agentOutputs);f.delete(r),c.agentOutputs=f;const h=new Map(c.lastPrompts);h.delete(r),c.lastPrompts=h;const m=new Map(c.subagents);let b=!1;for(const[y,w]of m)w.parentAgentId===r&&(m.delete(y),b=!0);b&&(c.subagents=m)}),n()},collapseContext(r){var i;(i=s())==null||i({type:"collapse_context",payload:{agentId:r}})},removeAgentFromServer(r){var i;(i=s())==null||i({type:"remove_agent",payload:{agentId:r}})},renameAgent(r,i){var f;const d=t().agents.get(r);d&&(e(h=>{const m={...d,name:i},b=new Map(h.agents);b.set(r,m),h.agents=b}),n()),(f=s())==null||f({type:"rename_agent",payload:{agentId:r,name:i}})},updateAgentProperties(r,i){var f;const d=t().agents.get(r);d&&(e(h=>{const m={...d};i.class!==void 0&&(m.class=i.class),i.permissionMode!==void 0&&(m.permissionMode=i.permissionMode),i.model!==void 0&&(m.model=i.model),i.provider!==void 0&&(m.provider=i.provider),i.codexConfig!==void 0&&(m.codexConfig=i.codexConfig),i.codexModel!==void 0&&(m.codexModel=i.codexModel),i.useChrome!==void 0&&(m.useChrome=i.useChrome),i.cwd!==void 0&&(m.cwd=i.cwd);const b=new Map(h.agents);b.set(r,m),h.agents=b}),n()),(f=s())==null||f({type:"update_agent_properties",payload:{agentId:r,updates:i}})},getTotalTokens(){let r=0;for(const i of t().agents.values())r+=i.tokensUsed;return r},getSelectedAgents(){const r=t(),i=[];for(const c of r.selectedAgentIds){const d=r.agents.get(c);d&&i.push(d)}return i},addActivity(r){e(i=>{i.activities.unshift(r),i.activities.length>100&&i.activities.pop()}),n()},addToolExecution(r,i,c){const f=t().agents.get(r);e(h=>{h.toolExecutions.unshift({agentId:r,agentName:(f==null?void 0:f.name)||"Unknown",toolName:i,toolInput:c,timestamp:Date.now()}),h.toolExecutions.length>200&&h.toolExecutions.pop()}),n()},addFileChange(r,i,c){const f=t().agents.get(r);e(h=>{h.fileChanges.unshift({agentId:r,agentName:(f==null?void 0:f.name)||"Unknown",action:i,filePath:c,timestamp:Date.now()}),h.fileChanges.length>200&&h.fileChanges.pop()}),n()},async loadToolHistory(){try{const i=await(await Bt(Rt("/api/agents/tool-history?limit=100"))).json();e(c=>{i.toolExecutions&&(c.toolExecutions=i.toolExecutions),i.fileChanges&&(c.fileChanges=i.fileChanges)}),n()}catch(r){console.error("[Store] Failed to load tool history:",r)}}}}const dS=200;function fS(t){return t.length<=dS?t:t.slice(-dS)}function AO(t,e,n,s){return{addOutput(a,r){const i=s();e(c=>{const d=c.agentOutputs.get(a)||[];if(r.uuid&&d.some(b=>b.uuid===r.uuid))return;const f=fS([...d,r]);Uu.info(`Store: ${d.length} -> ${f.length}`,{agentId:a,text:r.text.slice(0,60),isStreaming:r.isStreaming,listeners:i},"store:addOutput");const h=new Map(c.agentOutputs);h.set(a,f),c.agentOutputs=h}),n()},clearOutputs(a){e(r=>{const i=new Map(r.agentOutputs);i.delete(a),r.agentOutputs=i}),n()},getOutputs(a){return t().agentOutputs.get(a)||[]},addUserPromptToOutput(a,r){this.addOutput(a,{text:r,isStreaming:!1,timestamp:Date.now(),isUserPrompt:!0})},getLastPrompt(a){return t().lastPrompts.get(a)},setLastPrompt(a,r){e(i=>{i.lastPrompts.set(a,{text:r,timestamp:Date.now()})}),n()},preserveOutputs(){const a=t(),r=new Map;for(const[i,c]of a.agentOutputs)r.set(i,c.map(d=>({...d})));return r},mergeOutputsWithHistory(a,r,i){let c=[...r,...i];return c.sort((d,f)=>d.timestamp-f.timestamp),c=fS(c),e(d=>{const f=new Map(d.agentOutputs);f.set(a,c),d.agentOutputs=f}),n(),c}}}function jO(t,e,n,s){return{setSupervisorReport(a){e(r=>{r.supervisor.lastReport=a,r.supervisor.lastReportTime=a.timestamp;const i=new Map(r.supervisor.agentHistories);for(const c of a.agentSummaries){const d=i.get(c.agentId)||[],f={id:`${a.id}-${c.agentId}`,timestamp:a.timestamp,reportId:a.id,analysis:c};if(!d.some(h=>h.reportId===a.id)){const h=[f,...d];h.length>50&&h.pop(),i.set(c.agentId,h)}}r.supervisor.agentHistories=i,r.supervisor.generatingReport=!1}),n()},addNarrative(a,r){e(i=>{const c=i.supervisor.narratives.get(a)||[];c.unshift(r),c.length>50&&c.pop();const d=new Map(i.supervisor.narratives);d.set(a,c),i.supervisor.narratives=d}),n()},getNarratives(a){return t().supervisor.narratives.get(a)||[]},setSupervisorStatus(a){e(r=>{r.supervisor.enabled=a.enabled,a.autoReportOnComplete!==void 0&&(r.supervisor.autoReportOnComplete=a.autoReportOnComplete),r.supervisor.lastReportTime=a.lastReportTime,r.supervisor.nextReportTime=a.nextReportTime}),n()},setSupervisorConfig(a){var r;(r=s())==null||r({type:"set_supervisor_config",payload:a})},requestSupervisorReport(){var a;e(r=>{r.supervisor.generatingReport=!0}),n(),(a=s())==null||a({type:"request_supervisor_report",payload:{}})},requestAgentSupervisorHistory(a){var r;e(i=>{i.supervisor.loadingHistoryForAgent=a}),n(),(r=s())==null||r({type:"request_agent_supervisor_history",payload:{agentId:a}})},setAgentSupervisorHistory(a){e(r=>{const i=new Map(r.supervisor.agentHistories);i.set(a.agentId,a.entries),r.supervisor.agentHistories=i,r.supervisor.historyFetchedForAgents.add(a.agentId),r.supervisor.loadingHistoryForAgent===a.agentId&&(r.supervisor.loadingHistoryForAgent=null)}),n()},getAgentSupervisorHistory(a){return t().supervisor.agentHistories.get(a)||[]},addAgentAnalysis(a,r){e(i=>{const c=new Map(i.supervisor.agentHistories),d=c.get(a)||[],f={id:`single-${Date.now()}-${a}`,timestamp:Date.now(),reportId:`single-${Date.now()}`,analysis:r};if(!d.some(m=>Math.abs(m.timestamp-f.timestamp)<5e3&&m.analysis.statusDescription===r.statusDescription)){const m=[f,...d];m.length>50&&m.pop(),c.set(a,m),i.supervisor.agentHistories=c}}),n()},isLoadingHistoryForAgent(a){return t().supervisor.loadingHistoryForAgent===a},hasHistoryBeenFetched(a){return t().supervisor.historyFetchedForAgents.has(a)},setGlobalUsage(a){console.log("[Supervisor] setGlobalUsage called with:",a),e(r=>{r.supervisor.globalUsage=a,r.supervisor.refreshingUsage=!1}),n()},requestGlobalUsage(){console.log("[Supervisor] requestGlobalUsage called"),e(r=>{r.supervisor.refreshingUsage=!0}),n();const a=s();console.log("[Supervisor] sendMessage function:",a?"available":"null"),a?(console.log("[Supervisor] Sending request_global_usage message"),a({type:"request_global_usage",payload:{}})):console.warn("[Supervisor] Cannot send request_global_usage - no sendMessage function")},getGlobalUsage(){return t().supervisor.globalUsage}}}function NO(t,e,n,s){const a=()=>{var c;const i=Array.from(t().areas.values());(c=s())==null||c({type:"sync_areas",payload:i})},r=()=>{e(i=>{i.areas=new Map(i.areas)})};return{setActiveTool(i){e(c=>{c.activeTool=i,i!=="select"&&(c.selectedAreaId=null)}),n()},selectArea(i){e(c=>{c.selectedAreaId=i}),n()},addArea(i){if(i.zIndex===void 0||i.zIndex===null){const c=Array.from(t().areas.values()),d=c.length===0?-1:Math.max(...c.map(f=>f.zIndex??0));i.zIndex=d+1}e(c=>{c.areas.set(i.id,i)}),r(),a(),n()},updateArea(i,c){t().areas.get(i)&&(e(h=>{Object.assign(h.areas.get(i),c)}),r(),a(),n())},updateAreaLocal(i,c){t().areas.get(i)&&(e(h=>{Object.assign(h.areas.get(i),c)}),r(),n())},deleteArea(i){e(c=>{c.areas.delete(i),c.selectedAreaId===i&&(c.selectedAreaId=null)}),r(),a(),n()},assignAgentToArea(i,c){const f=t().areas.get(c);f&&!f.assignedAgentIds.includes(i)&&(e(h=>{for(const m of h.areas.values()){const b=m.assignedAgentIds.indexOf(i);b!==-1&&m.assignedAgentIds.splice(b,1)}h.areas.get(c).assignedAgentIds.push(i)}),r(),a(),n())},unassignAgentFromArea(i,c){const f=t().areas.get(c);if(f){const h=f.assignedAgentIds.indexOf(i);h!==-1&&(e(m=>{m.areas.get(c).assignedAgentIds.splice(h,1)}),r(),a(),n())}},addDirectoryToArea(i,c){const f=t().areas.get(i);f&&!f.directories.includes(c)&&(e(h=>{h.areas.get(i).directories.push(c)}),r(),a(),n())},removeDirectoryFromArea(i,c){const f=t().areas.get(i);if(f){const h=f.directories.indexOf(c);h!==-1&&(e(m=>{m.areas.get(i).directories.splice(h,1)}),r(),a(),n())}},getAreaDirectories(i){const c=t().areas.get(i);return(c==null?void 0:c.directories)||[]},isPositionInArea(i,c){if(c.type==="rectangle"&&c.width&&c.height){const d=c.width/2,f=c.height/2;return i.x>=c.center.x-d&&i.x<=c.center.x+d&&i.z>=c.center.z-f&&i.z<=c.center.z+f}else if(c.type==="circle"&&c.radius){const d=i.x-c.center.x,f=i.z-c.center.z;return d*d+f*f<=c.radius*c.radius}return!1},getAreaForAgent(i){const c=t(),d=c.agents.get(i);if(!d)return null;for(const f of c.areas.values())if(this.isPositionInArea({x:d.position.x,z:d.position.z},f))return f;return null},setAreasFromServer(i){e(c=>{const d=new Map;for(let f=0;f<i.length;f++){const h=i[f];h.directories||(h.directories=[]),(h.zIndex===void 0||h.zIndex===null)&&(h.zIndex=f),h.archived===void 0&&(h.archived=!1),d.set(h.id,h)}c.areas=d}),n()},getAreasInZOrder(){return Array.from(t().areas.values()).sort((c,d)=>(c.zIndex??0)-(d.zIndex??0))},getNextZIndex(){const i=Array.from(t().areas.values());return i.length===0?0:Math.max(...i.map(d=>d.zIndex??0))+1},bringAreaToFront(i){const c=t(),d=c.areas.get(i);if(!d)return;const f=Array.from(c.areas.values()),h=f.length===0?-1:Math.max(...f.map(w=>w.zIndex??0)),m=h+1,b=d.zIndex??0,y=f.filter(w=>(w.zIndex??0)===h);b===h&&y.length===1||(e(w=>{w.areas.get(i).zIndex=m}),r(),a(),n())},sendAreaToBack(i){const c=t(),d=c.areas.get(i);if(!d)return;const f=Array.from(c.areas.values()),h=Math.min(...f.map(y=>y.zIndex??0)),m=d.zIndex??0,b=f.filter(y=>(y.zIndex??0)===h);m===h&&b.length===1||(e(y=>{for(const w of y.areas.values())w.id!==i&&(w.zIndex=(w.zIndex??0)+1);y.areas.get(i).zIndex=0}),r(),a(),n())},setAreaZIndex(i,c){t().areas.get(i)&&(e(h=>{h.areas.get(i).zIndex=c}),r(),a(),n())},archiveArea(i,c){const f=t().areas.get(i);if(!(!f||f.archived)){if(c)for(const h of f.assignedAgentIds)c(h);e(h=>{const m=h.areas.get(i);m.archived=!0,m.archivedAt=Date.now(),m.originalCenter={...m.center},h.selectedAreaId===i&&(h.selectedAreaId=null)}),r(),a(),n()}},restoreArchivedArea(i,c){const d=t(),f=d.areas.get(i);if(!f||!f.archived)return;const h=f.center,m=c||f.originalCenter||f.center,b=m.x-h.x,y=m.z-h.z,w=Array.from(d.areas.values()),N=(w.length===0?-1:Math.max(...w.map(k=>k.zIndex??0)))+1;e(k=>{const j=k.areas.get(i);if(j.archived=!1,j.archivedAt=void 0,j.center=m,j.zIndex=N,b!==0||y!==0)for(const S of j.assignedAgentIds){const T=k.agents.get(S);T&&(T.position={x:T.position.x+b,y:T.position.y,z:T.position.z+y})}}),r(),a(),n()},getArchivedAreas(){return Array.from(t().areas.values()).filter(i=>i.archived===!0)},getVisibleAreas(){return Array.from(t().areas.values()).filter(i=>!i.archived)},isAgentInArchivedArea(i){const c=t();for(const d of c.areas.values())if(d.archived&&d.assignedAgentIds.includes(i))return!0;return!1}}}const qj="tide:bottom-pm2-log-retention",Fg=5e3,TO=[1e3,2500,5e3,1e4,null];function Vj(){if(typeof window>"u")return Fg;try{const t=window.localStorage.getItem(qj);if(!t)return Fg;if(t==="unlimited")return null;const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}catch{}return Fg}function _O(t){if(!(typeof window>"u"))try{window.localStorage.setItem(qj,t===null?"unlimited":String(t))}catch{}}function Yj(t,e){if(!t||e===null)return t;const n=t.split(`
|
|
44
|
+
`);return n.length<=e?t:n.slice(-e).join(`
|
|
45
|
+
`)}function EO(t,e,n,s){const a=()=>{var c;const i=Array.from(t().buildings.values());(c=s())==null||c({type:"sync_buildings",payload:i})},r={selectBuilding(i){e(c=>{c.selectedBuildingIds.clear(),i&&c.selectedBuildingIds.add(i)}),n()},selectMultipleBuildings(i){e(c=>{c.selectedBuildingIds.clear();for(const d of i)c.selectedBuildingIds.add(d)}),n()},toggleBuildingSelection(i){e(c=>{c.selectedBuildingIds.has(i)?c.selectedBuildingIds.delete(i):c.selectedBuildingIds.add(i)}),n()},isBuildingSelected(i){return t().selectedBuildingIds.has(i)},getSelectedBuildingIds(){return Array.from(t().selectedBuildingIds)},deleteSelectedBuildings(){var c,d,f;const i=t();for(const h of i.selectedBuildingIds){const m=i.buildings.get(h);((c=m==null?void 0:m.pm2)!=null&&c.enabled||(d=m==null?void 0:m.docker)!=null&&d.enabled)&&((f=s())==null||f({type:"building_command",payload:{buildingId:h,command:"delete"}}))}e(h=>{const m=new Map(h.buildings);for(const b of h.selectedBuildingIds)m.delete(b);h.buildings=m,h.selectedBuildingIds.clear()}),a(),n()},addBuilding(i){e(c=>{const d=new Map(c.buildings);d.set(i.id,i),c.buildings=d}),a(),n()},updateBuilding(i,c){const f=t().buildings.get(i);f&&(e(h=>{const m=new Map(h.buildings);m.set(i,{...f,...c}),h.buildings=m}),a(),n())},updateBuildingLocal(i,c){const f=t().buildings.get(i);f&&(e(h=>{const m=new Map(h.buildings);m.set(i,{...f,...c}),h.buildings=m}),n())},deleteBuilding(i){var f,h,m;const d=t().buildings.get(i);((f=d==null?void 0:d.pm2)!=null&&f.enabled||(h=d==null?void 0:d.docker)!=null&&h.enabled)&&((m=s())==null||m({type:"building_command",payload:{buildingId:i,command:"delete"}})),e(b=>{const y=new Map(b.buildings);y.delete(i),b.buildings=y,b.selectedBuildingIds.delete(i)}),a(),n()},moveBuilding(i,c){const f=t().buildings.get(i);f&&(e(h=>{const m=new Map(h.buildings);m.set(i,{...f,position:c}),h.buildings=m}),a(),n())},updateBuildingPosition(i,c){r.moveBuilding(i,c)},createBuilding(i){const c={...i,id:`building_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,status:"stopped",createdAt:Date.now()};r.addBuilding(c)},sendBuildingCommand(i,c){var d;(d=s())==null||d({type:"building_command",payload:{buildingId:i,command:c}})},addBuildingLogs(i,c){e(d=>{const h=[...d.buildingLogs.get(i)||[],c];h.length>500&&h.splice(0,h.length-500);const m=new Map(d.buildingLogs);m.set(i,h),d.buildingLogs=m}),n()},getBuildingLogs(i){return t().buildingLogs.get(i)||[]},clearBuildingLogs(i){e(c=>{const d=new Map(c.buildingLogs);d.delete(i),c.buildingLogs=d}),n()},setBuildingsFromServer(i){e(c=>{const d=new Map;for(const f of i)d.set(f.id,f);c.buildings=d}),n()},updateBuildingFromServer(i){e(c=>{const d=new Map(c.buildings);d.set(i.id,i),c.buildings=d}),n()},removeBuildingFromServer(i){e(c=>{const d=new Map(c.buildings);d.delete(i),c.buildings=d,c.selectedBuildingIds.delete(i)}),n()},startLogStreaming(i,c=100){var f,h,m;const d=t().buildings.get(i);e(b=>{const y=new Map(b.streamingBuildingLogs);y.set(i,""),b.streamingBuildingLogs=y}),(f=d==null?void 0:d.docker)!=null&&f.enabled?(h=s())==null||h({type:"docker_logs_start",payload:{buildingId:i,lines:c}}):(m=s())==null||m({type:"pm2_logs_start",payload:{buildingId:i,lines:c}})},stopLogStreaming(i){var d,f,h;const c=t().buildings.get(i);(d=c==null?void 0:c.docker)!=null&&d.enabled?(f=s())==null||f({type:"docker_logs_stop",payload:{buildingId:i}}):(h=s())==null||h({type:"pm2_logs_stop",payload:{buildingId:i}})},appendStreamingLogChunk(i,c){e(d=>{const f=d.streamingBuildingLogs.get(i)||"",h=Vj(),m=Yj(f+c,h),b=new Map(d.streamingBuildingLogs);b.set(i,m),d.streamingBuildingLogs=b}),n()},setStreamingStatus(i,c){e(d=>{const f=new Set(d.streamingBuildingIds);c?f.add(i):f.delete(i),d.streamingBuildingIds=f}),n()},getStreamingLogs(i){return t().streamingBuildingLogs.get(i)||""},clearStreamingLogs(i){e(c=>{const d=new Map(c.streamingBuildingLogs);d.delete(i),c.streamingBuildingLogs=d}),n()},isLogStreaming(i){return t().streamingBuildingIds.has(i)},sendBossBuildingCommand(i,c){var d;(d=s())==null||d({type:"boss_building_command",payload:{buildingId:i,command:c}})},assignBuildingsToBoSS(i,c){var h;const f=t().buildings.get(i);f&&(e(m=>{const b=new Map(m.buildings);b.set(i,{...f,subordinateBuildingIds:c}),m.buildings=b}),a(),n()),(h=s())==null||h({type:"assign_buildings",payload:{bossBuildingId:i,subordinateBuildingIds:c}})},startBossLogStreaming(i,c=50){var d;e(f=>{const h=new Map(f.bossStreamingLogs);h.set(i,[]),f.bossStreamingLogs=h}),(d=s())==null||d({type:"boss_building_logs_start",payload:{buildingId:i,lines:c}})},stopBossLogStreaming(i){var c;(c=s())==null||c({type:"boss_building_logs_stop",payload:{buildingId:i}})},appendBossStreamingLogChunk(i,c,d,f,h){e(m=>{const b=m.bossStreamingLogs.get(i)||[],y={subordinateId:c,subordinateName:d,chunk:f,timestamp:Date.now(),isError:h},w=[...b,y];w.length>1e3&&w.splice(0,w.length-1e3);const C=new Map(m.bossStreamingLogs);C.set(i,w),m.bossStreamingLogs=C}),n()},getBossStreamingLogs(i){return t().bossStreamingLogs.get(i)||[]},clearBossStreamingLogs(i){e(c=>{const d=new Map(c.bossStreamingLogs);d.delete(i),c.bossStreamingLogs=d}),n()},requestDockerContainersList(){var i;(i=s())==null||i({type:"docker_list_containers",payload:{}})},setDockerContainersList(i,c){e(d=>{d.dockerContainersList=i,d.dockerComposeProjectsList=c}),n()},getDockerContainersList(){return t().dockerContainersList},getDockerComposeProjectsList(){return t().dockerComposeProjectsList}};return r}function MO(t,e,n,s){return{addPermissionRequest(a){e(r=>{const i=new Map(r.permissionRequests);i.set(a.id,a),r.permissionRequests=i}),n()},resolvePermissionRequest(a,r){const c=t().permissionRequests.get(a);c&&(e(d=>{const f=new Map(d.permissionRequests);f.set(a,{...c,status:r?"approved":"denied"}),d.permissionRequests=f}),n(),setTimeout(()=>{e(d=>{const f=new Map(d.permissionRequests);f.delete(a),d.permissionRequests=f}),n()},2e3))},respondToPermissionRequest(a,r,i,c){var d;(d=s())==null||d({type:"permission_response",payload:{requestId:a,approved:r,reason:i,remember:c}})},getPendingPermissionsForAgent(a){return Array.from(t().permissionRequests.values()).filter(r=>r.agentId===a&&r.status==="pending")},clearAllPermissions(){e(a=>{a.permissionRequests=new Map}),n()}}}function DO(t,e,n,s){return{spawnBossAgent(a,r,i,c,d,f,h,m,b,y,w,C,N){var j;const k=c?{x:c.x,y:0,z:c.z}:void 0;(j=s())==null||j({type:"spawn_boss_agent",payload:{name:a,class:r,cwd:i,position:k,subordinateIds:d,useChrome:f,permissionMode:h,provider:m,codexConfig:b,codexModel:y,model:w,customInstructions:C,initialSkillIds:N}})},assignSubordinates(a,r){var i;(i=s())==null||i({type:"assign_subordinates",payload:{bossId:a,subordinateIds:r}})},removeSubordinate(a,r){var i;(i=s())==null||i({type:"remove_subordinate",payload:{bossId:a,subordinateId:r}})},sendBossCommand(a,r){var i;e(c=>{c.pendingDelegation={bossId:a,command:r}}),n(),(i=s())==null||i({type:"send_boss_command",payload:{bossId:a,command:r}})},requestDelegationHistory(a){var r;(r=s())==null||r({type:"request_delegation_history",payload:{bossId:a}})},handleDelegationDecision(a){e(r=>{var f;const i=new Map(r.delegationHistories),c=i.get(a.bossId)||[],d=c.findIndex(h=>h.id===a.id);if(d!==-1?c[d]=a:(c.unshift(a),c.length>100&&c.pop()),i.set(a.bossId,c),r.delegationHistories=i,a.status==="sent"&&a.selectedAgentId){const h=r.agents.get(a.bossId),m=new Map(r.lastDelegationReceived);m.set(a.selectedAgentId,{bossName:(h==null?void 0:h.name)||"Boss",taskCommand:a.userCommand,timestamp:Date.now()}),r.lastDelegationReceived=m}((f=r.pendingDelegation)==null?void 0:f.bossId)===a.bossId&&a.status!=="pending"&&(r.pendingDelegation=null)}),n()},setDelegationHistory(a,r){e(i=>{const c=new Map(i.delegationHistories);c.set(a,r),i.delegationHistories=c}),n()},getDelegationHistory(a){return t().delegationHistories.get(a)||[]},getLastDelegationReceived(a){return t().lastDelegationReceived.get(a)||null},clearLastDelegationReceived(a){t().lastDelegationReceived.has(a)&&(e(i=>{const c=new Map(i.lastDelegationReceived);c.delete(a),i.lastDelegationReceived=c}),n())},updateBossSubordinates(a,r){const c=t().agents.get(a);c&&(e(d=>{const f={...c,subordinateIds:r},h=new Map(d.agents);h.set(a,f),d.agents=h}),n())},getSubordinates(a){const r=t(),i=r.agents.get(a),c=(i==null?void 0:i.isBoss)===!0||(i==null?void 0:i.class)==="boss";return!i||!c||!i.subordinateIds?[]:i.subordinateIds.map(d=>r.agents.get(d)).filter(d=>d!==void 0)},isBossAgent(a){const r=t().agents.get(a);return(r==null?void 0:r.isBoss)===!0||(r==null?void 0:r.class)==="boss"},getBossForAgent(a){const r=t(),i=r.agents.get(a);return i!=null&&i.bossId&&r.agents.get(i.bossId)||null},getAvailableSubordinates(){return Array.from(t().agents.values()).filter(a=>a.class!=="boss")},handleAgentTaskStarted(a,r,i,c){e(d=>{const f=new Map(d.agentTaskProgress);let h=f.get(a);h||(h=new Map,f.set(a,h)),h.set(r,{agentId:r,agentName:i,taskDescription:c,status:"working",output:[],startedAt:Date.now()}),d.agentTaskProgress=f}),n()},handleAgentTaskOutput(a,r,i){e(c=>{const d=c.agentTaskProgress.get(a);if(!d)return;const f=d.get(r);if(!f)return;const h=200;let m=[...f.output,i];m.length>h&&(m=m.slice(-h));const b=new Map(c.agentTaskProgress),y=new Map(d);y.set(r,{...f,output:m}),b.set(a,y),c.agentTaskProgress=b}),n()},handleAgentTaskCompleted(a,r,i){e(c=>{const d=c.agentTaskProgress.get(a);if(!d)return;const f=d.get(r);if(!f)return;const h=f.output.length>20?f.output.slice(-20):f.output,m=new Map(c.agentTaskProgress),b=new Map(d);b.set(r,{...f,status:i?"completed":"failed",completedAt:Date.now(),output:h}),m.set(a,b),c.agentTaskProgress=m}),n()},getAgentTaskProgress(a){return t().agentTaskProgress.get(a)||new Map},clearAgentTaskProgress(a,r){e(i=>{if(r){const c=i.agentTaskProgress.get(a);if(c){const d=new Map(i.agentTaskProgress),f=new Map(c);f.delete(r),d.set(a,f),i.agentTaskProgress=d}}else{const c=new Map(i.agentTaskProgress);c.delete(a),i.agentTaskProgress=c}}),n()},clearAllSubordinatesContext(a){const i=t().agents.get(a),c=(i==null?void 0:i.isBoss)===!0||(i==null?void 0:i.class)==="boss";if(console.log("[Store] clearAllSubordinatesContext called:",{bossId:a,bossName:i==null?void 0:i.name,isBoss:c,subordinateIds:i==null?void 0:i.subordinateIds}),!i||!c||!i.subordinateIds||i.subordinateIds.length===0){console.log("[Store] clearAllSubordinatesContext: No boss or subordinates found, returning early");return}const d=s();console.log("[Store] clearAllSubordinatesContext: sendMessage available:",!!d);for(const f of i.subordinateIds)console.log("[Store] clearAllSubordinatesContext: Sending clear_context for subordinate:",f),d==null||d({type:"clear_context",payload:{agentId:f}});e(f=>{const h=new Map(f.agentOutputs);for(const m of i.subordinateIds||[])h.delete(m);f.agentOutputs=h}),n(),console.log("[Store] clearAllSubordinatesContext: Completed")}}}function RO(t,e,n,s){return{setSkillsFromServer(a){e(r=>{const i=new Map;for(const c of a)i.set(c.id,c);r.skills=i}),n()},addSkillFromServer(a){e(r=>{const i=new Map(r.skills);i.set(a.id,a),r.skills=i}),n()},updateSkillFromServer(a){e(r=>{const i=new Map(r.skills);i.set(a.id,a),r.skills=i}),n()},removeSkillFromServer(a){e(r=>{const i=new Map(r.skills);i.delete(a),r.skills=i}),n()},getSkill(a){return t().skills.get(a)},getAllSkills(){return Array.from(t().skills.values())},getSkillsForAgent(a){const r=t(),i=r.agents.get(a);return i?Array.from(r.skills.values()).filter(c=>c.enabled?!!(c.assignedAgentIds.includes(a)||c.assignedAgentClasses.includes(i.class)):!1):[]},createSkill(a){var r;(r=s())==null||r({type:"create_skill",payload:a})},updateSkill(a,r){var i;(i=s())==null||i({type:"update_skill",payload:{id:a,updates:r}})},deleteSkill(a){var r;(r=s())==null||r({type:"delete_skill",payload:{id:a}})},assignSkillToAgent(a,r){var i;(i=s())==null||i({type:"assign_skill",payload:{skillId:a,agentId:r}})},unassignSkillFromAgent(a,r){var i;(i=s())==null||i({type:"unassign_skill",payload:{skillId:a,agentId:r}})},requestAgentSkills(a){var r;(r=s())==null||r({type:"request_agent_skills",payload:{agentId:a}})},setCustomAgentClassesFromServer(a){e(r=>{const i=new Map;for(const c of a)i.set(c.id,c);r.customAgentClasses=i}),n()},addCustomAgentClassFromServer(a){e(r=>{const i=new Map(r.customAgentClasses);i.set(a.id,a),r.customAgentClasses=i}),n()},updateCustomAgentClassFromServer(a){e(r=>{const i=new Map(r.customAgentClasses);i.set(a.id,a),r.customAgentClasses=i}),n()},removeCustomAgentClassFromServer(a){e(r=>{const i=new Map(r.customAgentClasses);i.delete(a),r.customAgentClasses=i}),n()},getCustomAgentClass(a){return t().customAgentClasses.get(a)},getAllCustomAgentClasses(){return Array.from(t().customAgentClasses.values())},createCustomAgentClass(a){var r;(r=s())==null||r({type:"create_custom_agent_class",payload:a})},updateCustomAgentClass(a,r){var i;(i=s())==null||i({type:"update_custom_agent_class",payload:{id:a,updates:r}})},deleteCustomAgentClass(a){var r;(r=s())==null||r({type:"delete_custom_agent_class",payload:{id:a}})}}}function OO(t,e,n){return{handleExecTaskStarted(s,a,r,i,c){e(d=>{const f={taskId:s,agentId:a,agentName:r,command:i,cwd:c,status:"running",output:[],startedAt:Date.now()};d.execTasks||(d.execTasks=new Map),d.execTasks.set(s,f)}),n()},handleExecTaskOutput(s,a,r,i){e(c=>{var m;const d=(m=c.execTasks)==null?void 0:m.get(s);if(!d)return;const f=r.split(`
|
|
46
|
+
`),h=[...d.output];for(const b of f)b.length>0&&h.push(i?`[stderr] ${b}`:b);h.length>500&&h.splice(0,h.length-500),c.execTasks.set(s,{...d,output:h})}),n()},handleExecTaskCompleted(s,a,r,i){e(c=>{var f;const d=(f=c.execTasks)==null?void 0:f.get(s);d&&(d.status=i?"completed":"failed",d.exitCode=r,d.completedAt=Date.now())}),n()},async stopExecTask(s){try{return(await fetch(`/api/exec/tasks/${s}`,{method:"DELETE"})).ok?(e(r=>{var c;const i=(c=r.execTasks)==null?void 0:c.get(s);i&&i.status==="running"&&(i.status="failed",i.exitCode=-15,i.completedAt=Date.now(),i.output.push("[Task stopped by user]"))}),n(),!0):!1}catch(a){return console.error("Failed to stop exec task:",a),!1}},getExecTasks(s){const a=t();return a.execTasks?Array.from(a.execTasks.values()).filter(r=>r.agentId===s):[]},getAllExecTasks(){const s=t();return s.execTasks?Array.from(s.execTasks.values()):[]},getExecTask(s){var r;return(r=t().execTasks)==null?void 0:r.get(s)},clearCompletedExecTasks(s){e(a=>{if(a.execTasks)for(const[r,i]of a.execTasks.entries())i.agentId===s&&i.status!=="running"&&a.execTasks.delete(r)}),n()},clearAllExecTasks(s){e(a=>{if(a.execTasks)for(const[r,i]of a.execTasks.entries())i.agentId===s&&a.execTasks.delete(r)}),n()},removeExecTask(s){e(a=>{a.execTasks&&a.execTasks.delete(s)}),n()}}}function LO(t,e,n,s){return{setSecretsFromServer(a){e(r=>{const i=new Map;for(const c of a)i.set(c.id,c);r.secrets=i}),n()},addSecretFromServer(a){e(r=>{const i=new Map(r.secrets);i.set(a.id,a),r.secrets=i}),n()},updateSecretFromServer(a){e(r=>{const i=new Map(r.secrets);i.set(a.id,a),r.secrets=i}),n()},removeSecretFromServer(a){e(r=>{const i=new Map(r.secrets);i.delete(a),r.secrets=i}),n()},getSecret(a){return t().secrets.get(a)},getSecretByKey(a){return Array.from(t().secrets.values()).find(r=>r.key===a)},getAllSecrets(){return Array.from(t().secrets.values())},createSecret(a){var r;(r=s())==null||r({type:"create_secret",payload:a})},updateSecret(a,r){var i;(i=s())==null||i({type:"update_secret",payload:{id:a,updates:r}})},deleteSecret(a){var r;(r=s())==null||r({type:"delete_secret",payload:{id:a}})}}}function pS(){return{connectionStatus:new Map,databases:new Map,tables:new Map,tableSchemas:new Map,queryResults:[],queryHistory:[],executingQuery:!1,activeConnectionId:null,activeDatabase:null,lastSilentQueryResult:null}}function IO(t,e,n,s){const a=i=>{t().databaseState.has(i)||e(d=>{const f=new Map(d.databaseState);f.set(i,pS()),d.databaseState=f})};return{testDatabaseConnection(i,c){var d;(d=s())==null||d({type:"test_database_connection",payload:{buildingId:i,connectionId:c}})},setConnectionStatus(i,c,d){a(i),e(f=>{const h=f.databaseState.get(i);if(h){const m=new Map(h.connectionStatus);m.set(c,d);const b={...h,connectionStatus:m},y=new Map(f.databaseState);y.set(i,b),f.databaseState=y}}),n()},listDatabases(i,c){var d;(d=s())==null||d({type:"list_databases",payload:{buildingId:i,connectionId:c}})},setDatabases(i,c,d){a(i),e(f=>{const h=f.databaseState.get(i);if(h){const m=new Map(h.databases);m.set(c,d);const b={...h,databases:m},y=new Map(f.databaseState);y.set(i,b),f.databaseState=y}}),n()},listTables(i,c,d){var f;(f=s())==null||f({type:"list_tables",payload:{buildingId:i,connectionId:c,database:d}})},setTables(i,c,d,f){a(i);const h=`${c}:${d}`;e(m=>{const b=m.databaseState.get(i);if(b){const y=new Map(b.tables);y.set(h,f);const w={...b,tables:y},C=new Map(m.databaseState);C.set(i,w),m.databaseState=C}}),n()},getTableSchema(i,c,d,f){var h;(h=s())==null||h({type:"get_table_schema",payload:{buildingId:i,connectionId:c,database:d,table:f}})},setTableSchema(i,c,d,f,h){a(i);const m=`${c}:${d}:${f}`;e(b=>{const y=b.databaseState.get(i);if(y){const w=new Map(y.tableSchemas);w.set(m,h);const C={...y,tableSchemas:w},N=new Map(b.databaseState);N.set(i,C),b.databaseState=N}}),n()},executeQuery(i,c,d,f,h=1e3){var m;a(i),e(b=>{const y=b.databaseState.get(i);if(y){const w={...y,executingQuery:!0},C=new Map(b.databaseState);C.set(i,w),b.databaseState=C}}),n(),(m=s())==null||m({type:"execute_query",payload:{buildingId:i,connectionId:c,database:d,query:f,limit:h}})},executeSilentQuery(i,c,d,f,h){var m;(m=s())==null||m({type:"execute_query",payload:{buildingId:i,connectionId:c,database:d,query:f,limit:0,silent:!0,requestId:h}})},setSilentQueryResult(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,lastSilentQueryResult:{...c,timestamp:Date.now()}},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},setQueryResult(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h=[c,...f.queryResults].slice(0,20),m={...f,queryResults:h,executingQuery:!1},b=new Map(d.databaseState);b.set(i,m),d.databaseState=b}}),n()},setExecutingQuery(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,executingQuery:c},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},requestQueryHistory(i,c=100){var d;(d=s())==null||d({type:"request_query_history",payload:{buildingId:i,limit:c}})},setQueryHistory(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,queryHistory:c},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},toggleQueryFavorite(i,c){var d;(d=s())==null||d({type:"toggle_query_favorite",payload:{buildingId:i,queryId:c}})},deleteQueryFromHistory(i,c){var d;(d=s())==null||d({type:"delete_query_history",payload:{buildingId:i,queryId:c}})},clearQueryHistory(i){var c;(c=s())==null||c({type:"clear_query_history",payload:{buildingId:i}})},setActiveConnection(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,activeConnectionId:c,activeDatabase:null},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},setActiveDatabase(i,c){a(i),e(d=>{const f=d.databaseState.get(i);if(f){const h={...f,activeDatabase:c},m=new Map(d.databaseState);m.set(i,h),d.databaseState=m}}),n()},getDatabaseState(i){return t().databaseState.get(i)||pS()},clearDatabaseState(i){e(c=>{const d=new Map(c.databaseState);d.delete(i),c.databaseState=d}),n()}}}function PO(t,e,n){return{async fetchSnapshots(){e(s=>{s.snapshotsLoading=!0,s.snapshotsError=null}),n();try{const s=await Bt(Rt("/api/snapshots"));if(!s.ok)throw new Error(`Failed to fetch snapshots: ${s.statusText}`);const a=await s.json(),r=Array.isArray(a)?a:a.snapshots||[];this.setSnapshots(r)}catch(s){const a=s instanceof Error?s.message:"Failed to fetch snapshots";this.setError(a),console.error("Snapshot fetch error:",s)}finally{e(s=>{s.snapshotsLoading=!1}),n()}},setSnapshots(s){e(a=>{const r=new Map;s.forEach(i=>{r.set(i.id,i)}),a.snapshots=r}),n()},async createSnapshot(s,a,r,i,c,d){e(f=>{f.snapshotsLoading=!0,f.snapshotsError=null}),n();try{const f={agentId:s,agentName:a,title:r,description:i,outputs:c||[],files:d||[]},h=await Bt(Rt("/api/snapshots"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok)throw new Error(`Failed to create snapshot: ${h.statusText}`);const m=await h.json();return await this.fetchSnapshots(),m}catch(f){const h=f instanceof Error?f.message:"Failed to create snapshot";throw this.setError(h),console.error("Snapshot creation error:",f),f}finally{e(f=>{f.snapshotsLoading=!1}),n()}},async loadSnapshot(s){e(a=>{a.snapshotsLoading=!0,a.snapshotsError=null}),n();try{const a=await Bt(Rt(`/api/snapshots/${s}`));if(!a.ok)throw new Error(`Failed to load snapshot: ${a.statusText}`);const r=await a.json();this.setCurrentSnapshot(r)}catch(a){const r=a instanceof Error?a.message:"Failed to load snapshot";this.setError(r),console.error("Snapshot load error:",a)}finally{e(a=>{a.snapshotsLoading=!1}),n()}},setCurrentSnapshot(s){e(a=>{a.currentSnapshot=s}),n()},async deleteSnapshot(s){var a;e(r=>{r.snapshotsLoading=!0,r.snapshotsError=null}),n();try{const r=await Bt(Rt(`/api/snapshots/${s}`),{method:"DELETE"});if(!r.ok)throw new Error(`Failed to delete snapshot: ${r.statusText}`);await this.fetchSnapshots(),((a=t().currentSnapshot)==null?void 0:a.id)===s&&this.setCurrentSnapshot(null)}catch(r){const i=r instanceof Error?r.message:"Failed to delete snapshot";throw this.setError(i),console.error("Snapshot deletion error:",r),r}finally{e(r=>{r.snapshotsLoading=!1}),n()}},async restoreFiles(s,a){e(r=>{r.snapshotsLoading=!0,r.snapshotsError=null}),n();try{const r=a?{filePaths:a}:{},i=await Bt(Rt(`/api/snapshots/${s}/restore`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw new Error(`Failed to restore files: ${i.statusText}`)}catch(r){const i=r instanceof Error?r.message:"Failed to restore files";throw this.setError(i),console.error("File restoration error:",r),r}finally{e(r=>{r.snapshotsLoading=!1}),n()}},setLoading(s){e(a=>{a.snapshotsLoading=s}),n()},setError(s){e(a=>{a.snapshotsError=s}),n()},clearError(){this.setError(null)},reset(){e(s=>{s.snapshots=new Map,s.currentSnapshot=null,s.snapshotsLoading=!1,s.snapshotsError=null}),n()}}}const BO=3e4,zg=new Map;function Ef(t,e,n){let s=t.get(e);if(!s){for(const[,a]of t)if(a.toolUseId===e&&a.parentAgentId===n){s=a;break}}return s}function hS(t,e,n){const s=zg.get(t);s&&clearTimeout(s),zg.set(t,setTimeout(()=>{zg.delete(t),e(a=>{const r=a.subagents.get(t);if(r&&(r.status==="completed"||r.status==="failed")){const i=new Map(a.subagents);i.delete(t),a.subagents=i}}),n()},BO))}function FO(t,e,n){return{addSubagent(s){e(a=>{const r=new Map(a.subagents);r.set(s.id,s),a.subagents=r}),n(),console.log(`[Subagent] Added: ${s.name} (${s.id}) for agent ${s.parentAgentId}`)},completeSubagent(s,a,r){e(i=>{const c=Ef(i.subagents,s,a);if(c){const d=new Map(i.subagents);d.set(c.id,{...c,status:r?"completed":"failed",completedAt:Date.now()}),i.subagents=d,console.log(`[Subagent] Completed: ${c.name} (${c.id}) success=${r}`),hS(c.id,e,n)}}),n()},addSubagentActivity(s,a,r){e(i=>{const c=Ef(i.subagents,s,a);if(c){const d=[...c.activities||[],r].slice(-50),f=new Map(i.subagents);f.set(c.id,{...c,activities:d}),i.subagents=f}}),n()},updateSubagentStats(s,a,r){e(i=>{const c=Ef(i.subagents,s,a);if(c){const d=new Map(i.subagents);d.set(c.id,{...c,stats:r}),i.subagents=d}}),n()},getSubagentsForAgent(s){const a=t();return Array.from(a.subagents.values()).filter(r=>r.parentAgentId===s)},getSubagent(s){return t().subagents.get(s)},removeSubagent(s){e(a=>{const r=new Map(a.subagents);r.delete(s),a.subagents=r}),n()},addSubagentStreamEntries(s,a,r){e(i=>{const c=Ef(i.subagents,s,a);if(c){const f=[...c.streamEntries||[],...r].slice(-200),h=new Map(i.subagents);h.set(c.id,{...c,streamEntries:f}),i.subagents=h,(c.status==="completed"||c.status==="failed")&&hS(c.id,e,n)}}),n()},getSubagentByToolUseId(s){const a=t();for(const[,r]of a.subagents)if(r.toolUseId===s)return r},hydrateSubagentsFromHistory(s,a){!a||a.length===0||(e(r=>{const i=new Map(r.subagents);for(const c of a){let d=!1;for(const[,m]of i)if(m.toolUseId===c.toolUseId&&m.parentAgentId===s){d=!0;break}if(d)continue;const f=`hist_${c.toolUseId}`,h={id:f,parentAgentId:s,toolUseId:c.toolUseId,name:c.name||"Subagent",description:c.description||"",subagentType:c.subagentType||"general-purpose",model:c.model,status:"completed",startedAt:c.startedAt||0,completedAt:c.completedAt,streamEntries:c.streamEntries.slice(-200),stats:c.stats};i.set(f,h)}r.subagents=i}),n())}}}const zO={workflowDefinitions:new Map,workflowInstances:new Map,selectedWorkflowId:null,workflowDetailOpen:!1,workflowDetailLevel:{level:"overview"},workflowChatMessages:[],workflowChatScope:{level:"workflow"},workflowChatLoading:!1};function $O(t,e,n,s){const a=()=>{const i=t();return{workflowDefinitions:i.workflowDefinitions??new Map,workflowInstances:i.workflowInstances??new Map,selectedWorkflowId:i.selectedWorkflowId??null,workflowDetailOpen:i.workflowDetailOpen??!1,workflowDetailLevel:i.workflowDetailLevel??{level:"overview"},workflowChatMessages:i.workflowChatMessages??[],workflowChatScope:i.workflowChatScope??{level:"workflow"},workflowChatLoading:i.workflowChatLoading??!1}};return{setWorkflowDefinitionsFromServer(i){e(c=>{const d=new Map;for(const f of i)d.set(f.id,f);c.workflowDefinitions=d}),n()},addWorkflowDefinitionFromServer(i){e(c=>{const d=c,f=new Map(d.workflowDefinitions??new Map);f.set(i.id,i),d.workflowDefinitions=f}),n()},updateWorkflowDefinitionFromServer(i){e(c=>{const d=c,f=new Map(d.workflowDefinitions??new Map);f.set(i.id,i),d.workflowDefinitions=f}),n()},removeWorkflowDefinitionFromServer(i){e(c=>{const d=c,f=new Map(d.workflowDefinitions??new Map);f.delete(i),d.workflowDefinitions=f,d.selectedWorkflowId===i&&(d.selectedWorkflowId=null,d.workflowDetailOpen=!1)}),n()},createWorkflowDefinition(i){var c;(c=s())==null||c({type:"create_workflow_def",payload:i})},updateWorkflowDefinition(i,c){var d;(d=s())==null||d({type:"update_workflow_def",payload:{id:i,updates:c}})},deleteWorkflowDefinition(i){var c;(c=s())==null||c({type:"delete_workflow_def",payload:{id:i}})},moveWorkflow(i,c){var d;e(f=>{const h=f,m=new Map(h.workflowDefinitions??new Map),b=m.get(i);b&&(m.set(i,{...b,position:c}),h.workflowDefinitions=m)}),(d=s())==null||d({type:"update_workflow_def",payload:{id:i,updates:{position:c}}}),n()},setWorkflowInstancesFromServer(i){e(c=>{const d=c,f=new Map;for(const h of i)f.set(h.id,h);d.workflowInstances=f}),n()},updateWorkflowInstanceFromServer(i){e(c=>{const d=c,f=new Map(d.workflowInstances??new Map);f.set(i.id,i),d.workflowInstances=f}),n()},removeWorkflowInstanceFromServer(i){e(c=>{const d=c,f=new Map(d.workflowInstances??new Map);f.delete(i),d.workflowInstances=f}),n()},startWorkflow(i,c){var d;(d=s())==null||d({type:"start_workflow",payload:{workflowDefId:i,initialVariables:c}})},pauseWorkflow(i){var c;(c=s())==null||c({type:"pause_workflow",payload:{instanceId:i}})},resumeWorkflow(i){var c;(c=s())==null||c({type:"resume_workflow",payload:{instanceId:i}})},cancelWorkflow(i){var c;(c=s())==null||c({type:"cancel_workflow",payload:{instanceId:i}})},manualTransition(i,c){var d;(d=s())==null||d({type:"manual_transition",payload:{instanceId:i,transitionId:c}})},selectWorkflow(i){e(c=>{c.selectedWorkflowId=i}),n()},openWorkflowDetail(i){e(c=>{const d=c;d.selectedWorkflowId=i,d.workflowDetailOpen=!0,d.workflowDetailLevel={level:"overview"},d.workflowChatMessages=[],d.workflowChatScope={level:"workflow"}}),n()},closeWorkflowDetail(){e(i=>{const c=i;c.workflowDetailOpen=!1,c.workflowDetailLevel={level:"overview"},c.workflowChatMessages=[]}),n()},navigateToExecution(i){e(c=>{const d=c;d.workflowDetailLevel={level:"execution",instanceId:i},d.workflowChatScope={level:"instance",instanceId:i}}),n()},navigateToStep(i,c){e(d=>{const f=d;f.workflowDetailLevel={level:"step",instanceId:i,stepId:c},f.workflowChatScope={level:"step",instanceId:i,stepId:c}}),n()},navigateBack(){const c=a().workflowDetailLevel;e(d=>{const f=d;c.level==="step"?(f.workflowDetailLevel={level:"execution",instanceId:c.instanceId},f.workflowChatScope={level:"instance",instanceId:c.instanceId}):c.level==="execution"&&(f.workflowDetailLevel={level:"overview"},f.workflowChatScope={level:"workflow"})}),n()},getWorkflowModelStatus(i){const c=a(),d=Array.from(c.workflowInstances.values()).filter(m=>m.workflowDefId===i);if(d.length===0)return"idle";if(d.some(m=>m.status==="failed"))return"error";if(d.some(m=>m.status==="running"||m.status==="paused"))return"running";const f=Date.now()-300*1e3;return d.filter(m=>m.status==="completed"&&m.completedAt&&m.completedAt>f).length>0?"completed":"idle"},addWorkflowChatMessage(i){e(c=>{const d=c;d.workflowChatMessages=[...d.workflowChatMessages??[],i]}),n()},setWorkflowChatScope(i){e(c=>{c.workflowChatScope=i}),n()},setWorkflowChatLoading(i){e(c=>{c.workflowChatLoading=i}),n()},clearWorkflowChat(){e(i=>{const c=i;c.workflowChatMessages=[]}),n()},getWorkflowDefinition(i){return a().workflowDefinitions.get(i)},getWorkflowInstances(i){return Array.from(a().workflowInstances.values()).filter(c=>c.workflowDefId===i)},getAllWorkflowDefinitions(){return Array.from(a().workflowDefinitions.values())}}}const $g={panSpeed:1,orbitSpeed:1,zoomSpeed:1,smoothing:.3,invertPanX:!1,invertPanY:!1,invertOrbitX:!1,invertOrbitY:!1},Mf={enabled:!0,pinchToZoom:!0,twoFingerPan:!0,shiftTwoFingerOrbit:!0,sensitivity:{zoom:1,pan:1,orbit:1}};function po(t,e,n,s,a,r,i){return{id:t,name:e,description:n,button:s,modifiers:a,action:r,enabled:!0,sensitivity:i}}const Ug=[po("left-click-select","Select/Click","Select agents, click on buildings/areas","left",{},"primary-action"),po("left-drag-selection","Selection Box","Drag to select multiple agents","left",{},"selection-box"),po("right-click-context","Context Menu / Move","Show context menu or move selected agents","right",{},"context-menu"),po("alt-right-drag-pan","Camera Pan","Pan camera with Alt+Right-drag","right",{alt:!0},"camera-pan",1),po("middle-drag-orbit","Camera Orbit","Orbit camera with middle-drag","middle",{},"camera-orbit",1),po("shift-middle-drag-pan","Camera Pan (Alt)","Alternative pan with Shift+Middle-drag","middle",{shift:!0},"camera-pan",1),po("wheel-zoom","Zoom","Zoom camera with scroll wheel","middle",{},"camera-zoom",1)],Eq={0:"left",1:"middle",2:"right",3:"back",4:"forward"},UO={left:"Left Click",right:"Right Click",middle:"Middle Click",back:"Back Button",forward:"Forward Button"};function Mq(t,e){const n=[];if(t.modifiers.ctrl){const s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC");n.push(s?"⌘":"Ctrl")}if(t.modifiers.alt){const s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC");n.push(s?"⌥":"Alt")}return t.modifiers.shift&&n.push("Shift"),n.push(e?e(t.button):UO[t.button]),n.join("+")}function Dq(t,e){const n=e.ctrl?t.ctrlKey||t.metaKey:!t.ctrlKey&&!t.metaKey,s=e.alt?t.altKey:!t.altKey,a=e.shift?t.shiftKey:!t.shiftKey;return n&&s&&a}function Rq(t,e,n){return t.filter(s=>{if(s.id===n||!s.enabled||s.button!==e.button)return!1;const a=s.modifiers,r=e.modifiers;return(a.ctrl||!1)===(r.ctrl||!1)&&(a.alt||!1)===(r.alt||!1)&&(a.shift||!1)===(r.shift||!1)})}function Qs(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function $a(t,e){if(t===e)return!0;if(t.size!==e.size)return!1;for(const[n,s]of t)if(e.get(n)!==s)return!1;return!0}function zx(t,e){if(t===e)return!0;if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function jt(t,e=Object.is){const[n,s]=x.useState(()=>t(U.getState())),a=x.useRef(n);return x.useEffect(()=>{a.current=n},[n]),x.useEffect(()=>{const r=()=>{const i=t(U.getState());e(a.current,i)||(a.current=i,s(i))};return r(),U.subscribe(r)},[t,e]),n}function Rs(){const[,t]=x.useState({});return x.useEffect(()=>U.subscribe(()=>t({})),[]),U.getState()}function ed(){return jt(x.useCallback(t=>t.agents,[]),$a)}function Gj(){return jt(x.useCallback(t=>t.agents.size,[]))}function Kp(){const t=ed(),e=x.useRef([]),n=Array.from(t.values());return Qs(e.current,n)||(e.current=n),e.current}function Kj(t){return jt(x.useCallback(e=>t?e.agents.get(t):void 0,[t]))}function $x(){return jt(x.useCallback(t=>t.selectedAgentIds,[]),zx)}function HO(){return jt(x.useCallback(t=>t.lastSelectedAgentId,[]))}function Qj(t){const e=x.useRef([]),n=x.useRef(0),s=jt(x.useCallback(a=>t&&a.agentOutputs.get(t)||e.current,[t]),Qs);return s.length!==n.current&&(Uu.info(`Selector: ${n.current} -> ${s.length}`,{agentId:t,lastText:s.length>0?s[s.length-1].text.slice(0,40):null},"useAgentOutputs"),n.current=s.length),s}function Xj(t){return jt(x.useCallback(e=>t?e.lastPrompts.get(t):void 0,[t]))}function Ux(){return jt(x.useCallback(t=>t.lastPrompts,[]),$a)}function Jj(){return jt(x.useCallback(t=>t.isConnected,[]))}function ur(){return jt(x.useCallback(t=>t.areas,[]),$a)}function WO(){return jt(x.useCallback(t=>t.activeTool,[]))}function qO(){return jt(x.useCallback(t=>t.selectedAreaId,[]))}function Hx(){return jt(x.useCallback(t=>t.buildings,[]),$a)}function VO(){return jt(x.useCallback(t=>t.selectedBuildingIds,[]),zx)}function YO(){return jt(x.useCallback(t=>t.supervisor,[]))}function Oq(){return jt(x.useCallback(t=>t.supervisor.lastReport,[]))}function GO(){return jt(x.useCallback(t=>t.supervisor.generatingReport,[]))}function KO(){return jt(x.useCallback(t=>t.permissionRequests,[]),$a)}function Vr(){return jt(x.useCallback(t=>t.settings,[]))}function Zj(){return jt(x.useCallback(t=>t.settings.hideCost,[]))}function Lq(){return jt(x.useCallback(t=>t.settings.customAgentNames,[]),Qs)}function Iq(){return jt(x.useCallback(t=>t.shortcuts,[]),Qs)}function Pq(){return jt(x.useCallback(t=>t.mouseControls,[]))}function Bq(){return jt(x.useCallback(t=>t.mouseControls.trackpad,[]))}function e1(){return jt(x.useCallback(t=>t.terminalOpen,[]))}function t1(){return jt(x.useCallback(t=>t.mobileView,[]))}function Wx(){return jt(x.useCallback(t=>t.fileViewerPath,[]))}function QO(){return jt(x.useCallback(t=>t.fileViewerEditData,[]))}function XO(){return jt(x.useCallback(t=>t.fileViewerSearchRoot,[]))}function JO(){return jt(x.useCallback(t=>t.explorerFolderPath,[]))}function qx(){return jt(x.useCallback(t=>t.contextModalAgentId,[]))}function Fq(){return jt(x.useCallback(t=>t.commanderExpandRequest,[]))}function Vx(){return jt(x.useCallback(t=>t.toolExecutions,[]),Qs)}function n1(){return jt(x.useCallback(t=>t.fileChanges,[]),Qs)}function s1(){return jt(x.useCallback(t=>t.skills,[]),$a)}function ZO(){const t=s1(),e=x.useRef([]),n=Array.from(t.values());return Qs(e.current,n)||(e.current=n),e.current}function zq(t){return jt(x.useCallback(e=>t?e.skills.get(t):void 0,[t]))}function eL(t){const e=x.useRef([]),n=ed(),s=s1();if(!t)return e.current;const a=n.get(t);return a?Array.from(s.values()).filter(i=>i.enabled?!!(i.assignedAgentIds.includes(t)||i.assignedAgentClasses.includes(a.class)):!1):e.current}function tL(){return jt(x.useCallback(t=>t.customAgentClasses,[]),$a)}function dr(){const t=tL(),e=x.useRef([]),n=Array.from(t.values());return Qs(e.current,n)||(e.current=n),e.current}function a1(t){return jt(x.useCallback(e=>t?e.customAgentClasses.get(t):void 0,[t]))}function r1(){return jt(x.useCallback(t=>t.reconnectCount,[]))}function i1(){return jt(x.useCallback(t=>t.historyRefreshTrigger,[]))}function $q(){return jt(x.useCallback(t=>t.supervisor.globalUsage,[]))}function Uq(){return jt(x.useCallback(t=>t.supervisor.refreshingUsage,[]))}function nL(t){const e=x.useRef(new Map);return jt(x.useCallback(n=>t&&n.agentTaskProgress.get(t)||e.current,[t]),$a)}function sL(t){return jt(x.useCallback(e=>!t||!e.execTasks?[]:Array.from(e.execTasks.values()).filter(n=>n.agentId===t),[t]),Qs)}function aL(){return jt(x.useCallback(t=>t.secrets,[]),$a)}function Hq(){const t=aL(),e=x.useRef([]),n=Array.from(t.values());return Qs(e.current,n)||(e.current=n),e.current}const rL={connectionStatus:new Map,databases:new Map,tables:new Map,tableSchemas:new Map,queryResults:[],queryHistory:[],executingQuery:!1,activeConnectionId:null,activeDatabase:null,lastSilentQueryResult:null};function Yx(t){return jt(x.useCallback(e=>(t?e.databaseState.get(t):void 0)??rL,[t]))}function iL(t){return jt(x.useCallback(e=>{if(!t)return[];const n=e.databaseState.get(t);return(n==null?void 0:n.queryResults)??[]},[t]),Qs)}function Wq(t){return jt(x.useCallback(e=>{if(!t)return[];const n=e.databaseState.get(t);return(n==null?void 0:n.queryHistory)??[]},[t]),Qs)}function oL(t){return jt(x.useCallback(e=>{if(!t)return!1;const n=e.databaseState.get(t);return(n==null?void 0:n.executingQuery)??!1},[t]))}function qq(){return jt(t=>t.dockerContainersList,Qs)}function lL(){return jt(t=>t.currentSnapshot)}function cL(){return jt(t=>t.snapshotsLoading)}function uL(){return jt(t=>t.snapshotsError)}function dL(){return jt(t=>t.subagents,$a)}function fL(t){return jt(x.useCallback(e=>t?Array.from(e.subagents.values()).filter(n=>n.parentAgentId===t):[],[t]),Qs)}function pL(t){const e=x.useRef(new Map);return jt(x.useCallback(n=>{if(!t)return e.current;const s=new Map;for(const[a,r]of n.subagents)r.parentAgentId===t&&s.set(a,r);return s.size===0?e.current:s},[t]),$a)}function o1(){return jt(t=>t.viewMode)}function hL(){return jt(x.useCallback(t=>t.overviewPanelOpen,[]))}function l1(){return jt(x.useCallback(t=>t.agentsWithUnseenOutput,[]),zx)}class mS{constructor(){Xe(this,"state");Xe(this,"listeners",new Set);Xe(this,"sendMessage",null);Xe(this,"agentActions");Xe(this,"outputActions");Xe(this,"supervisorActions");Xe(this,"areaActions");Xe(this,"buildingActions");Xe(this,"permissionActions");Xe(this,"delegationActions");Xe(this,"skillActions");Xe(this,"execTaskActions");Xe(this,"secretActions");Xe(this,"databaseActions");Xe(this,"snapshotActions");Xe(this,"subagentActions");Xe(this,"workflowActions");Xe(this,"statusPollInterval",null);this.state={agents:new Map,selectedAgentIds:new Set,lastSelectedAgentId:null,activities:[],isConnected:!1,areas:new Map,activeTool:null,selectedAreaId:null,buildings:new Map,selectedBuildingIds:new Set,buildingLogs:new Map,streamingBuildingLogs:new Map,streamingBuildingIds:new Set,bossStreamingLogs:new Map,agentOutputs:new Map,lastPrompts:new Map,toolExecutions:[],fileChanges:[],terminalOpen:!1,terminalResizing:!1,mobileView:this.loadMobileView(),settings:this.loadSettings(),shortcuts:this.loadShortcuts(),mouseControls:this.loadMouseControls(),fileViewerPath:null,fileViewerSearchRoot:null,fileViewerEditData:null,explorerFolderPath:null,explorerAreaId:null,contextModalAgentId:null,supervisor:{enabled:!0,autoReportOnComplete:!1,lastReport:null,narratives:new Map,lastReportTime:null,nextReportTime:null,agentHistories:new Map,loadingHistoryForAgent:null,historyFetchedForAgents:new Set,generatingReport:!1,globalUsage:null,refreshingUsage:!1},permissionRequests:new Map,delegationHistories:new Map,pendingDelegation:null,lastDelegationReceived:new Map,agentTaskProgress:new Map,skills:new Map,customAgentClasses:new Map,reconnectCount:0,historyRefreshTrigger:0,execTasks:new Map,secrets:new Map,databaseState:new Map,dockerContainersList:[],dockerComposeProjectsList:[],snapshots:new Map,currentSnapshot:null,snapshotsLoading:!1,snapshotsError:null,lastSelectionViaSwipe:!1,lastSelectionViaDirectClickAt:null,subagents:new Map,viewMode:(()=>{const i=Fa(pt.SCENE_VIEW_MODE,"3d");return i==="2d"||i==="3d"||i==="dashboard"?i:"3d"})(),overviewPanelOpen:Ni(pt.AOP_OPEN,!1),agentsWithUnseenOutput:this.loadUnseenAgents(),commanderExpandRequest:null,latestNotificationAgentId:null,...zO};const e=()=>this.state,n=i=>{i(this.state)},s=()=>this.notify(),a=()=>this.sendMessage,r=()=>this.listeners.size;this.agentActions=CO(e,n,s,a,()=>this.saveUnseenAgents()),this.outputActions=AO(e,n,s,r),this.supervisorActions=jO(e,n,s,a),this.areaActions=NO(e,n,s,a),this.buildingActions=EO(e,n,s,a),this.permissionActions=MO(e,n,s,a),this.delegationActions=DO(e,n,s,a),this.skillActions=RO(e,n,s,a),this.execTaskActions=OO(e,n,s),this.secretActions=LO(e,n,s,a),this.databaseActions=IO(e,n,s,a),this.snapshotActions=PO(e,n,s),this.subagentActions=FO(e,n,s),this.workflowActions=$O(e,n,s,a)}loadSettings(){const e=Na(pt.SETTINGS,null);if(e){const n={...Pg,...e},s=Number(n.vibrationIntensity);return n.vibrationIntensity=Number.isFinite(s)?Math.max(0,Math.min($u,Math.round(s))):Pg.vibrationIntensity,n}return{...Pg}}loadShortcuts(){const e=Na(pt.SHORTCUTS,null);return e?Lg.map(s=>{const a=e.find(r=>r.id===s.id);return a?{...s,...a}:s}):[...Lg]}loadMouseControls(){var n;const e=Na(pt.MOUSE_CONTROLS,null);return e?{bindings:Ug.map(a=>{var i;const r=(i=e.bindings)==null?void 0:i.find(c=>c.id===a.id);return r?{...a,...r}:a}),sensitivity:{...$g,...e.sensitivity},trackpad:{...Mf,...e.trackpad,sensitivity:{...Mf.sensitivity,...(n=e.trackpad)==null?void 0:n.sensitivity}}}:{bindings:[...Ug],sensitivity:{...$g},trackpad:{...Mf}}}loadMobileView(){const e=Fa(pt.MOBILE_VIEW,"");return e==="terminal"||e==="3d"?e:typeof window<"u"&&window.innerWidth<=768&&"ontouchstart"in window?"3d":"terminal"}loadUnseenAgents(){const e=Na(pt.UNSEEN_AGENTS,[]);return new Set(e)}saveUnseenAgents(){const e=Array.from(this.state.agentsWithUnseenOutput);La(pt.UNSEEN_AGENTS,e)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}getState(){return this.state}setSendMessage(e){this.sendMessage=e}setConnected(e){this.state.isConnected=e,this.notify()}triggerReconnect(){this.state.reconnectCount++,this.notify()}triggerHistoryRefresh(e){Hj(e),this.state.selectedAgentIds.has(e)&&(this.state.historyRefreshTrigger++,this.notify())}toggleTerminal(e){e&&!this.state.selectedAgentIds.has(e)&&(this.state.selectedAgentIds=new Set([e])),this.state.terminalOpen=!this.state.terminalOpen,this.notify()}setTerminalOpen(e){if(this.state.terminalOpen=e,e){if(this.state.mobileView="terminal",this.state.selectedAgentIds.size===0&&this.state.agents.size>0&&!this.state.currentSnapshot){const s=Array.from(this.state.agents.keys())[0];this.state.selectedAgentIds=new Set([s])}let n=!1;for(const s of this.state.selectedAgentIds)this.state.agentsWithUnseenOutput.has(s)&&(n||(this.state.agentsWithUnseenOutput=new Set(this.state.agentsWithUnseenOutput),n=!0),this.state.agentsWithUnseenOutput.delete(s));n&&this.saveUnseenAgents()}else window.innerWidth<=768&&(this.state.mobileView="3d");this.notify()}setOverviewPanelOpen(e){this.state.overviewPanelOpen=e,Ti(pt.AOP_OPEN,e),this.notify()}setMobileView(e){if(this.state.mobileView=e,Wr(pt.MOBILE_VIEW,e),e==="terminal"&&this.state.selectedAgentIds.size===0&&this.state.agents.size>0&&!this.state.currentSnapshot){const n=Array.from(this.state.agents.keys())[0];this.state.selectedAgentIds=new Set([n]),this.state.terminalOpen=!0}this.notify()}setViewMode(e){this.state.viewMode=e,Wr(pt.SCENE_VIEW_MODE,e),this.state.settings.experimental2DView=e==="2d",this.notify()}openTerminalOnMobile(e){JD("terminal"),this.state.selectedAgentIds=new Set([e]),this.state.terminalOpen=!0,this.state.mobileView="terminal",this.state.agentsWithUnseenOutput.has(e)&&(this.state.agentsWithUnseenOutput=new Set(this.state.agentsWithUnseenOutput),this.state.agentsWithUnseenOutput.delete(e),this.saveUnseenAgents()),this.notify()}clearUnseenForAgent(e){this.state.agentsWithUnseenOutput.has(e)&&(this.state.agentsWithUnseenOutput=new Set(this.state.agentsWithUnseenOutput),this.state.agentsWithUnseenOutput.delete(e),this.saveUnseenAgents(),this.notify())}setTerminalResizing(e){this.state.terminalResizing=e,this.notify()}setLastSelectionViaSwipe(e){this.state.lastSelectionViaSwipe=e}consumeSwipeSelectionFlag(){const e=this.state.lastSelectionViaSwipe;return this.state.lastSelectionViaSwipe=!1,e}setLastSelectionViaDirectClick(e){this.state.lastSelectionViaDirectClickAt=e?Date.now():null}consumeDirectClickSelectionFlag(){const e=this.state.lastSelectionViaDirectClickAt;return this.state.lastSelectionViaDirectClickAt=null,e===null?!1:Date.now()-e<=1500}setFileViewerPath(e,n,s){this.state.fileViewerPath=e,this.state.fileViewerEditData=n||null,this.state.fileViewerSearchRoot=s||null,this.notify()}clearFileViewerPath(){this.state.fileViewerPath=null,this.state.fileViewerEditData=null,this.state.fileViewerSearchRoot=null,this.notify()}requestCommanderExpand(e){this.state.commanderExpandRequest=e,this.notify()}clearCommanderExpandRequest(){this.state.commanderExpandRequest=null,this.notify()}setLatestNotificationAgentId(e){this.state.latestNotificationAgentId=e,this.notify()}getLastExplorerState(){try{const e=localStorage.getItem("file-explorer-last-opened");return e?JSON.parse(e):null}catch{return null}}setExplorerFolderPath(e){this.state.explorerFolderPath=e,this.notify()}openFileExplorer(e){this.state.explorerFolderPath=e,this.state.explorerAreaId=null,this.notify()}closeFileExplorer(){this.state.explorerFolderPath=null,this.state.explorerAreaId=null,this.notify()}openFileExplorerForArea(e){this.state.explorerFolderPath=null,this.state.explorerAreaId=e,this.notify()}openFileExplorerForAreaFolder(e,n){this.state.explorerAreaId=e,this.state.explorerFolderPath=n,this.notify()}setContextModalAgentId(e){this.state.contextModalAgentId=e,this.notify()}closeContextModal(){this.state.contextModalAgentId=null,this.notify()}updateSettings(e){const n={...e};if(n.vibrationIntensity!==void 0){const s=Number(n.vibrationIntensity);n.vibrationIntensity=Number.isFinite(s)?Math.max(0,Math.min($u,Math.round(s))):this.state.settings.vibrationIntensity}this.state.settings={...this.state.settings,...n},La(pt.SETTINGS,this.state.settings),this.notify()}getSettings(){return this.state.settings}getShortcuts(){return this.state.shortcuts}getShortcut(e){return this.state.shortcuts.find(n=>n.id===e)}updateShortcut(e,n){const s=this.state.shortcuts.findIndex(a=>a.id===e);s!==-1&&(this.state.shortcuts=[...this.state.shortcuts.slice(0,s),{...this.state.shortcuts[s],...n},...this.state.shortcuts.slice(s+1)],this.saveShortcuts(),this.notify())}resetShortcuts(){this.state.shortcuts=[...Lg],this.saveShortcuts(),this.notify()}saveShortcuts(){La(pt.SHORTCUTS,this.state.shortcuts)}getMouseControls(){return this.state.mouseControls}getMouseBinding(e){return this.state.mouseControls.bindings.find(n=>n.id===e)}updateMouseBinding(e,n){const s=this.state.mouseControls.bindings.findIndex(a=>a.id===e);s!==-1&&(this.state.mouseControls.bindings=[...this.state.mouseControls.bindings.slice(0,s),{...this.state.mouseControls.bindings[s],...n},...this.state.mouseControls.bindings.slice(s+1)],this.saveMouseControls(),this.notify())}updateCameraSensitivity(e){this.state.mouseControls.sensitivity={...this.state.mouseControls.sensitivity,...e},this.saveMouseControls(),this.notify()}resetMouseControls(){this.state.mouseControls={bindings:[...Ug],sensitivity:{...$g},trackpad:{...Mf}},this.saveMouseControls(),this.notify()}getTrackpadConfig(){return this.state.mouseControls.trackpad}updateTrackpadConfig(e){this.state.mouseControls.trackpad={...this.state.mouseControls.trackpad,...e,sensitivity:{...this.state.mouseControls.trackpad.sensitivity,...e.sensitivity||{}}},this.saveMouseControls(),this.notify()}saveMouseControls(){La(pt.MOUSE_CONTROLS,this.state.mouseControls)}startStatusPolling(){}stopStatusPolling(){this.statusPollInterval&&(clearInterval(this.statusPollInterval),this.statusPollInterval=null)}setAgents(...e){return this.agentActions.setAgents(...e)}addAgent(...e){return this.agentActions.addAgent(...e)}updateAgent(...e){return this.agentActions.updateAgent(...e)}updateAgentContextStats(...e){return this.agentActions.updateAgentContextStats(...e)}updateAgentContext(...e){return this.agentActions.updateAgentContext(...e)}removeAgent(...e){return this.agentActions.removeAgent(...e)}selectAgent(...e){return this.agentActions.selectAgent(...e)}addToSelection(...e){return this.agentActions.addToSelection(...e)}selectMultiple(...e){return this.agentActions.selectMultiple(...e)}deselectAll(...e){return this.agentActions.deselectAll(...e)}spawnAgent(...e){return this.agentActions.spawnAgent(...e)}createDirectoryAndSpawn(...e){return this.agentActions.createDirectoryAndSpawn(...e)}sendCommand(...e){return this.agentActions.sendCommand(...e)}refreshAgentContext(...e){return this.agentActions.refreshAgentContext(...e)}moveAgentLocal(...e){return this.agentActions.moveAgentLocal(...e)}moveAgent(...e){return this.agentActions.moveAgent(...e)}killAgent(...e){return this.agentActions.killAgent(...e)}stopAgent(...e){return this.agentActions.stopAgent(...e)}clearContext(...e){return this.agentActions.clearContext(...e)}collapseContext(...e){return this.agentActions.collapseContext(...e)}removeAgentFromServer(...e){return this.agentActions.removeAgentFromServer(...e)}renameAgent(...e){return this.agentActions.renameAgent(...e)}updateAgentProperties(...e){return this.agentActions.updateAgentProperties(...e)}getTotalTokens(){return this.agentActions.getTotalTokens()}getSelectedAgents(){return this.agentActions.getSelectedAgents()}addActivity(...e){return this.agentActions.addActivity(...e)}addToolExecution(...e){return this.agentActions.addToolExecution(...e)}addFileChange(...e){return this.agentActions.addFileChange(...e)}loadToolHistory(){return this.agentActions.loadToolHistory()}addOutput(...e){return this.outputActions.addOutput(...e)}clearOutputs(...e){return this.outputActions.clearOutputs(...e)}getOutputs(...e){return this.outputActions.getOutputs(...e)}addUserPromptToOutput(...e){return this.outputActions.addUserPromptToOutput(...e)}getLastPrompt(...e){return this.outputActions.getLastPrompt(...e)}setLastPrompt(...e){return this.outputActions.setLastPrompt(...e)}preserveOutputs(){return this.outputActions.preserveOutputs()}mergeOutputsWithHistory(...e){return this.outputActions.mergeOutputsWithHistory(...e)}setSupervisorReport(...e){return this.supervisorActions.setSupervisorReport(...e)}addNarrative(...e){return this.supervisorActions.addNarrative(...e)}getNarratives(...e){return this.supervisorActions.getNarratives(...e)}setSupervisorStatus(...e){return this.supervisorActions.setSupervisorStatus(...e)}setSupervisorConfig(...e){return this.supervisorActions.setSupervisorConfig(...e)}requestSupervisorReport(){return this.supervisorActions.requestSupervisorReport()}requestAgentSupervisorHistory(...e){return this.supervisorActions.requestAgentSupervisorHistory(...e)}setAgentSupervisorHistory(...e){return this.supervisorActions.setAgentSupervisorHistory(...e)}getAgentSupervisorHistory(...e){return this.supervisorActions.getAgentSupervisorHistory(...e)}addAgentAnalysis(...e){return this.supervisorActions.addAgentAnalysis(...e)}isLoadingHistoryForAgent(...e){return this.supervisorActions.isLoadingHistoryForAgent(...e)}hasHistoryBeenFetched(...e){return this.supervisorActions.hasHistoryBeenFetched(...e)}setGlobalUsage(...e){return this.supervisorActions.setGlobalUsage(...e)}requestGlobalUsage(){return this.supervisorActions.requestGlobalUsage()}getGlobalUsage(){return this.supervisorActions.getGlobalUsage()}setActiveTool(...e){return this.areaActions.setActiveTool(...e)}selectArea(...e){return this.areaActions.selectArea(...e)}addArea(...e){return this.areaActions.addArea(...e)}updateArea(...e){return this.areaActions.updateArea(...e)}updateAreaLocal(...e){return this.areaActions.updateAreaLocal(...e)}deleteArea(...e){return this.areaActions.deleteArea(...e)}assignAgentToArea(...e){return this.areaActions.assignAgentToArea(...e)}unassignAgentFromArea(...e){return this.areaActions.unassignAgentFromArea(...e)}addDirectoryToArea(...e){return this.areaActions.addDirectoryToArea(...e)}removeDirectoryFromArea(...e){return this.areaActions.removeDirectoryFromArea(...e)}getAreaDirectories(...e){return this.areaActions.getAreaDirectories(...e)}isPositionInArea(...e){return this.areaActions.isPositionInArea(...e)}getAreaForAgent(...e){return this.areaActions.getAreaForAgent(...e)}setAreasFromServer(...e){return this.areaActions.setAreasFromServer(...e)}getAreasInZOrder(...e){return this.areaActions.getAreasInZOrder(...e)}getNextZIndex(...e){return this.areaActions.getNextZIndex(...e)}bringAreaToFront(...e){return this.areaActions.bringAreaToFront(...e)}sendAreaToBack(...e){return this.areaActions.sendAreaToBack(...e)}setAreaZIndex(...e){return this.areaActions.setAreaZIndex(...e)}archiveArea(...e){return this.areaActions.archiveArea(...e)}restoreArchivedArea(...e){return this.areaActions.restoreArchivedArea(...e)}getArchivedAreas(...e){return this.areaActions.getArchivedAreas(...e)}getVisibleAreas(...e){return this.areaActions.getVisibleAreas(...e)}isAgentInArchivedArea(...e){return this.areaActions.isAgentInArchivedArea(...e)}selectBuilding(...e){return this.buildingActions.selectBuilding(...e)}selectMultipleBuildings(...e){return this.buildingActions.selectMultipleBuildings(...e)}toggleBuildingSelection(...e){return this.buildingActions.toggleBuildingSelection(...e)}isBuildingSelected(...e){return this.buildingActions.isBuildingSelected(...e)}getSelectedBuildingIds(){return this.buildingActions.getSelectedBuildingIds()}deleteSelectedBuildings(){return this.buildingActions.deleteSelectedBuildings()}addBuilding(...e){return this.buildingActions.addBuilding(...e)}updateBuilding(...e){return this.buildingActions.updateBuilding(...e)}updateBuildingLocal(...e){return this.buildingActions.updateBuildingLocal(...e)}deleteBuilding(...e){return this.buildingActions.deleteBuilding(...e)}moveBuilding(...e){return this.buildingActions.moveBuilding(...e)}updateBuildingPosition(...e){return this.buildingActions.updateBuildingPosition(...e)}createBuilding(...e){return this.buildingActions.createBuilding(...e)}sendBuildingCommand(...e){return this.buildingActions.sendBuildingCommand(...e)}addBuildingLogs(...e){return this.buildingActions.addBuildingLogs(...e)}getBuildingLogs(...e){return this.buildingActions.getBuildingLogs(...e)}clearBuildingLogs(...e){return this.buildingActions.clearBuildingLogs(...e)}setBuildingsFromServer(...e){return this.buildingActions.setBuildingsFromServer(...e)}updateBuildingFromServer(...e){return this.buildingActions.updateBuildingFromServer(...e)}removeBuildingFromServer(...e){return this.buildingActions.removeBuildingFromServer(...e)}startLogStreaming(...e){return this.buildingActions.startLogStreaming(...e)}stopLogStreaming(...e){return this.buildingActions.stopLogStreaming(...e)}appendStreamingLogChunk(...e){return this.buildingActions.appendStreamingLogChunk(...e)}setStreamingStatus(...e){return this.buildingActions.setStreamingStatus(...e)}getStreamingLogs(...e){return this.buildingActions.getStreamingLogs(...e)}clearStreamingLogs(...e){return this.buildingActions.clearStreamingLogs(...e)}isLogStreaming(...e){return this.buildingActions.isLogStreaming(...e)}sendBossBuildingCommand(...e){return this.buildingActions.sendBossBuildingCommand(...e)}assignBuildingsToBoSS(...e){return this.buildingActions.assignBuildingsToBoSS(...e)}startBossLogStreaming(...e){return this.buildingActions.startBossLogStreaming(...e)}stopBossLogStreaming(...e){return this.buildingActions.stopBossLogStreaming(...e)}appendBossStreamingLogChunk(...e){return this.buildingActions.appendBossStreamingLogChunk(...e)}getBossStreamingLogs(...e){return this.buildingActions.getBossStreamingLogs(...e)}clearBossStreamingLogs(...e){return this.buildingActions.clearBossStreamingLogs(...e)}requestDockerContainersList(){return this.buildingActions.requestDockerContainersList()}setDockerContainersList(...e){return this.buildingActions.setDockerContainersList(...e)}getDockerContainersList(){return this.buildingActions.getDockerContainersList()}getDockerComposeProjectsList(){return this.buildingActions.getDockerComposeProjectsList()}setWorkflowDefinitionsFromServer(...e){return this.workflowActions.setWorkflowDefinitionsFromServer(...e)}addWorkflowDefinitionFromServer(...e){return this.workflowActions.addWorkflowDefinitionFromServer(...e)}updateWorkflowDefinitionFromServer(...e){return this.workflowActions.updateWorkflowDefinitionFromServer(...e)}removeWorkflowDefinitionFromServer(...e){return this.workflowActions.removeWorkflowDefinitionFromServer(...e)}createWorkflowDefinition(...e){return this.workflowActions.createWorkflowDefinition(...e)}updateWorkflowDefinition(...e){return this.workflowActions.updateWorkflowDefinition(...e)}deleteWorkflowDefinition(...e){return this.workflowActions.deleteWorkflowDefinition(...e)}moveWorkflow(...e){return this.workflowActions.moveWorkflow(...e)}setWorkflowInstancesFromServer(...e){return this.workflowActions.setWorkflowInstancesFromServer(...e)}updateWorkflowInstanceFromServer(...e){return this.workflowActions.updateWorkflowInstanceFromServer(...e)}removeWorkflowInstanceFromServer(...e){return this.workflowActions.removeWorkflowInstanceFromServer(...e)}startWorkflow(...e){return this.workflowActions.startWorkflow(...e)}pauseWorkflow(...e){return this.workflowActions.pauseWorkflow(...e)}resumeWorkflow(...e){return this.workflowActions.resumeWorkflow(...e)}cancelWorkflow(...e){return this.workflowActions.cancelWorkflow(...e)}manualTransition(...e){return this.workflowActions.manualTransition(...e)}selectWorkflow(...e){return this.workflowActions.selectWorkflow(...e)}openWorkflowDetail(...e){return this.workflowActions.openWorkflowDetail(...e)}closeWorkflowDetail(){return this.workflowActions.closeWorkflowDetail()}navigateToExecution(...e){return this.workflowActions.navigateToExecution(...e)}navigateToStep(...e){return this.workflowActions.navigateToStep(...e)}navigateBack(){return this.workflowActions.navigateBack()}getWorkflowModelStatus(...e){return this.workflowActions.getWorkflowModelStatus(...e)}addWorkflowChatMessage(...e){return this.workflowActions.addWorkflowChatMessage(...e)}setWorkflowChatScope(...e){return this.workflowActions.setWorkflowChatScope(...e)}setWorkflowChatLoading(...e){return this.workflowActions.setWorkflowChatLoading(...e)}clearWorkflowChat(){return this.workflowActions.clearWorkflowChat()}getWorkflowDefinition(...e){return this.workflowActions.getWorkflowDefinition(...e)}getWorkflowInstances(...e){return this.workflowActions.getWorkflowInstances(...e)}getAllWorkflowDefinitions(){return this.workflowActions.getAllWorkflowDefinitions()}addPermissionRequest(...e){return this.permissionActions.addPermissionRequest(...e)}resolvePermissionRequest(...e){return this.permissionActions.resolvePermissionRequest(...e)}respondToPermissionRequest(...e){return this.permissionActions.respondToPermissionRequest(...e)}getPendingPermissionsForAgent(...e){return this.permissionActions.getPendingPermissionsForAgent(...e)}clearAllPermissions(...e){return this.permissionActions.clearAllPermissions(...e)}spawnBossAgent(...e){return this.delegationActions.spawnBossAgent(...e)}assignSubordinates(...e){return this.delegationActions.assignSubordinates(...e)}removeSubordinate(...e){return this.delegationActions.removeSubordinate(...e)}sendBossCommand(...e){return this.delegationActions.sendBossCommand(...e)}requestDelegationHistory(...e){return this.delegationActions.requestDelegationHistory(...e)}handleDelegationDecision(...e){return this.delegationActions.handleDelegationDecision(...e)}setDelegationHistory(...e){return this.delegationActions.setDelegationHistory(...e)}getDelegationHistory(...e){return this.delegationActions.getDelegationHistory(...e)}getLastDelegationReceived(...e){return this.delegationActions.getLastDelegationReceived(...e)}clearLastDelegationReceived(...e){return this.delegationActions.clearLastDelegationReceived(...e)}updateBossSubordinates(...e){return this.delegationActions.updateBossSubordinates(...e)}getSubordinates(...e){return this.delegationActions.getSubordinates(...e)}isBossAgent(...e){return this.delegationActions.isBossAgent(...e)}getBossForAgent(...e){return this.delegationActions.getBossForAgent(...e)}getAvailableSubordinates(){return this.delegationActions.getAvailableSubordinates()}handleAgentTaskStarted(...e){return this.delegationActions.handleAgentTaskStarted(...e)}handleAgentTaskOutput(...e){return this.delegationActions.handleAgentTaskOutput(...e)}handleAgentTaskCompleted(...e){return this.delegationActions.handleAgentTaskCompleted(...e)}getAgentTaskProgress(...e){return this.delegationActions.getAgentTaskProgress(...e)}clearAgentTaskProgress(...e){return this.delegationActions.clearAgentTaskProgress(...e)}clearAllSubordinatesContext(...e){return this.delegationActions.clearAllSubordinatesContext(...e)}setSkillsFromServer(...e){return this.skillActions.setSkillsFromServer(...e)}addSkillFromServer(...e){return this.skillActions.addSkillFromServer(...e)}updateSkillFromServer(...e){return this.skillActions.updateSkillFromServer(...e)}removeSkillFromServer(...e){return this.skillActions.removeSkillFromServer(...e)}getSkill(...e){return this.skillActions.getSkill(...e)}getAllSkills(){return this.skillActions.getAllSkills()}getSkillsForAgent(...e){return this.skillActions.getSkillsForAgent(...e)}createSkill(...e){return this.skillActions.createSkill(...e)}updateSkill(...e){return this.skillActions.updateSkill(...e)}deleteSkill(...e){return this.skillActions.deleteSkill(...e)}assignSkillToAgent(...e){return this.skillActions.assignSkillToAgent(...e)}unassignSkillFromAgent(...e){return this.skillActions.unassignSkillFromAgent(...e)}requestAgentSkills(...e){return this.skillActions.requestAgentSkills(...e)}setCustomAgentClassesFromServer(...e){return this.skillActions.setCustomAgentClassesFromServer(...e)}addCustomAgentClassFromServer(...e){return this.skillActions.addCustomAgentClassFromServer(...e)}updateCustomAgentClassFromServer(...e){return this.skillActions.updateCustomAgentClassFromServer(...e)}removeCustomAgentClassFromServer(...e){return this.skillActions.removeCustomAgentClassFromServer(...e)}getCustomAgentClass(...e){return this.skillActions.getCustomAgentClass(...e)}getAllCustomAgentClasses(){return this.skillActions.getAllCustomAgentClasses()}createCustomAgentClass(...e){return this.skillActions.createCustomAgentClass(...e)}updateCustomAgentClass(...e){return this.skillActions.updateCustomAgentClass(...e)}deleteCustomAgentClass(...e){return this.skillActions.deleteCustomAgentClass(...e)}handleExecTaskStarted(...e){return this.execTaskActions.handleExecTaskStarted(...e)}handleExecTaskOutput(...e){return this.execTaskActions.handleExecTaskOutput(...e)}handleExecTaskCompleted(...e){return this.execTaskActions.handleExecTaskCompleted(...e)}stopExecTask(...e){return this.execTaskActions.stopExecTask(...e)}getExecTasks(...e){return this.execTaskActions.getExecTasks(...e)}getAllExecTasks(){return this.execTaskActions.getAllExecTasks()}getExecTask(...e){return this.execTaskActions.getExecTask(...e)}clearCompletedExecTasks(...e){return this.execTaskActions.clearCompletedExecTasks(...e)}clearAllExecTasks(...e){return this.execTaskActions.clearAllExecTasks(...e)}removeExecTask(...e){return this.execTaskActions.removeExecTask(...e)}setSecretsFromServer(...e){return this.secretActions.setSecretsFromServer(...e)}addSecretFromServer(...e){return this.secretActions.addSecretFromServer(...e)}updateSecretFromServer(...e){return this.secretActions.updateSecretFromServer(...e)}removeSecretFromServer(...e){return this.secretActions.removeSecretFromServer(...e)}getSecret(...e){return this.secretActions.getSecret(...e)}getSecretByKey(...e){return this.secretActions.getSecretByKey(...e)}getAllSecrets(){return this.secretActions.getAllSecrets()}createSecret(...e){return this.secretActions.createSecret(...e)}updateSecret(...e){return this.secretActions.updateSecret(...e)}deleteSecret(...e){return this.secretActions.deleteSecret(...e)}testDatabaseConnection(...e){return this.databaseActions.testDatabaseConnection(...e)}setConnectionStatus(...e){return this.databaseActions.setConnectionStatus(...e)}listDatabases(...e){return this.databaseActions.listDatabases(...e)}setDatabases(...e){return this.databaseActions.setDatabases(...e)}listTables(...e){return this.databaseActions.listTables(...e)}setTables(...e){return this.databaseActions.setTables(...e)}getTableSchema(...e){return this.databaseActions.getTableSchema(...e)}setTableSchema(...e){return this.databaseActions.setTableSchema(...e)}executeQuery(...e){return this.databaseActions.executeQuery(...e)}executeSilentQuery(...e){return this.databaseActions.executeSilentQuery(...e)}setSilentQueryResult(...e){return this.databaseActions.setSilentQueryResult(...e)}setQueryResult(...e){return this.databaseActions.setQueryResult(...e)}setExecutingQuery(...e){return this.databaseActions.setExecutingQuery(...e)}requestQueryHistory(...e){return this.databaseActions.requestQueryHistory(...e)}setQueryHistory(...e){return this.databaseActions.setQueryHistory(...e)}toggleQueryFavorite(...e){return this.databaseActions.toggleQueryFavorite(...e)}deleteQueryFromHistory(...e){return this.databaseActions.deleteQueryFromHistory(...e)}clearQueryHistory(...e){return this.databaseActions.clearQueryHistory(...e)}setActiveConnection(...e){return this.databaseActions.setActiveConnection(...e)}setActiveDatabase(...e){return this.databaseActions.setActiveDatabase(...e)}getDatabaseState(...e){return this.databaseActions.getDatabaseState(...e)}clearDatabaseState(...e){return this.databaseActions.clearDatabaseState(...e)}fetchSnapshots(...e){return this.snapshotActions.fetchSnapshots(...e)}setSnapshots(...e){return this.snapshotActions.setSnapshots(...e)}createSnapshot(...e){return this.snapshotActions.createSnapshot(...e)}loadSnapshot(...e){return this.snapshotActions.loadSnapshot(...e)}setCurrentSnapshot(...e){return this.snapshotActions.setCurrentSnapshot(...e)}deleteSnapshot(...e){return this.snapshotActions.deleteSnapshot(...e)}restoreFiles(...e){return this.snapshotActions.restoreFiles(...e)}setLoading(...e){return this.snapshotActions.setLoading(...e)}setError(...e){return this.snapshotActions.setError(...e)}clearError(...e){return this.snapshotActions.clearError(...e)}reset(...e){return this.snapshotActions.reset(...e)}addSubagent(...e){return this.subagentActions.addSubagent(...e)}completeSubagent(...e){return this.subagentActions.completeSubagent(...e)}getSubagentsForAgent(...e){return this.subagentActions.getSubagentsForAgent(...e)}getSubagent(...e){return this.subagentActions.getSubagent(...e)}removeSubagent(...e){return this.subagentActions.removeSubagent(...e)}getSubagentByToolUseId(...e){return this.subagentActions.getSubagentByToolUseId(...e)}addSubagentActivity(...e){return this.subagentActions.addSubagentActivity(...e)}updateSubagentStats(...e){return this.subagentActions.updateSubagentStats(...e)}addSubagentStreamEntries(...e){return this.subagentActions.addSubagentStreamEntries(...e)}hydrateSubagentsFromHistory(...e){return this.subagentActions.hydrateSubagentsFromHistory(...e)}}const gS=1;function mL(){return typeof window<"u"?(window.__tideStore&&window.__tideStoreVersion===gS||(window.__tideStore=new mS,window.__tideStoreVersion=gS),window.__tideStore):new mS}const U=mL(),c1=x.createContext(null),gL={error:"❌",success:"✅",warning:"⚠️",info:"ℹ️"};let bL=0;function xL({children:t}){const[e,n]=x.useState(null),s=x.useRef([]),a=x.useRef(null),r=x.useCallback(()=>{if(s.current.length>0&&!e){const d=s.current.shift();n(d)}},[e]);x.useEffect(()=>{e||r()},[e,r]),x.useEffect(()=>{if(e&&e.duration>0)return a.current=window.setTimeout(()=>{n(null)},e.duration),()=>{a.current&&clearTimeout(a.current)}},[e]);const i=x.useCallback((d,f,h,m=5e3)=>{const y={id:++bL,type:d,title:f,message:h,duration:m};if(s.current.push(y),!e){const w=s.current.shift();n(w)}},[e]),c=x.useCallback(()=>{a.current&&clearTimeout(a.current),n(null)},[]);return o.jsxs(c1.Provider,{value:{showToast:i},children:[t,o.jsx("div",{id:"toast-container",children:e&&o.jsxs("div",{className:`toast ${e.type}`,children:[o.jsx("span",{className:"toast-icon",children:gL[e.type]}),o.jsxs("div",{className:"toast-content",children:[o.jsx("div",{className:"toast-title",children:e.title}),o.jsx("div",{className:"toast-message",children:e.message})]}),o.jsx("button",{className:"toast-close",onClick:c,children:"×"})]},e.id)})]})}function u1(){const t=x.useContext(c1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const _o={scout:{icon:"🔍",color:"#4a9eff",description:"Codebase exploration, file discovery"},builder:{icon:"🔨",color:"#ff9e4a",description:"Feature implementation, writing code"},debugger:{icon:"🐛",color:"#ff4a4a",description:"Bug hunting, fixing issues"},architect:{icon:"📐",color:"#9e4aff",description:"Planning, design decisions"},warrior:{icon:"⚔️",color:"#ff4a9e",description:"Aggressive refactoring, migrations"},support:{icon:"💚",color:"#4aff9e",description:"Documentation, tests, cleanup"},boss:{icon:"👑",color:"#ffd700",description:"Team leader, delegates tasks to subordinates"}},Qp=_o,Mu={bypass:{label:"Permissionless",description:"Skip all permission prompts (less safe, faster)"},interactive:{label:"Interactive",description:"Ask for approval before sensitive operations"}},Df={"gpt-5.4":{label:"GPT-5.4",description:"Latest frontier model with advanced reasoning and coding",icon:"🌟"},"gpt-5.3-codex":{label:"GPT-5.3 Codex",description:"Latest frontier agentic coding model",icon:"⚙️"},"gpt-5.2-codex":{label:"GPT-5.2 Codex",description:"Frontier agentic coding model",icon:"🧠"},"gpt-5.1-codex-max":{label:"GPT-5.1 Codex Max",description:"Codex-optimized flagship for deep and fast reasoning",icon:"🚀"},"gpt-5.1-codex-mini":{label:"GPT-5.1 Codex Mini",description:"Optimized for codex, cheaper and faster",icon:"⚡"},"gpt-5.2":{label:"GPT-5.2",description:"General frontier model with strong reasoning and coding",icon:"🧩"}},Rf={sonnet:{label:"Sonnet",description:"Balanced performance and cost (recommended)",icon:"⚡"},opus:{label:"Opus",description:"Most capable, higher cost",icon:"🧠"},haiku:{label:"Haiku",description:"Fast and economical",icon:"🚀"}},tx="<<<BOSS_CONTEXT_START>>>",bS="<<<BOSS_CONTEXT_END>>>",yL={server:{icon:"🖥️",color:"#4aff9e",description:"Service with start/stop commands and logs"},link:{icon:"🔗",color:"#4a9eff",description:"Quick links to URLs"},database:{icon:"🗄️",color:"#ff9e4a",description:"Database connection and queries"},docker:{icon:"🐳",color:"#4ac1ff",description:"Docker container management"},monitor:{icon:"📊",color:"#ff4a9e",description:"System metrics and monitoring"},folder:{icon:"📁",color:"#ffd700",description:"Folder shortcut - opens file explorer on click"},boss:{icon:"👑",color:"#ffd700",description:"Boss building - manages multiple buildings with unified controls"},terminal:{icon:"💻",color:"#a855f7",description:"Interactive web terminal via ttyd"}},Vq={"server-rack":{label:"Server Rack",description:"Classic server rack with blinking LEDs"},tower:{label:"Control Tower",description:"Tall tower with rotating antenna"},dome:{label:"Data Dome",description:"Futuristic dome with energy ring"},pyramid:{label:"Power Pyramid",description:"Egyptian-style pyramid with glowing core"},desktop:{label:"Desktop PC",description:"Retro computer with monitor and keyboard"},"filing-cabinet":{label:"Filing Cabinet",description:"Office cabinet with sliding drawers"},satellite:{label:"Satellite Dish",description:"Communication dish with rotating receiver"},crystal:{label:"Data Crystal",description:"Floating crystal with energy particles"},factory:{label:"Mini Factory",description:"Industrial building with smoking chimney"},"command-center":{label:"Command Center",description:"Grand central hub for boss buildings with holographic rings"}},Yq={"":{label:"Auto-detect",description:"Let PM2 detect the interpreter"},node:{label:"Node.js",description:"JavaScript/TypeScript runtime"},bun:{label:"Bun",description:"Bun JavaScript runtime"},python3:{label:"Python 3",description:"Python 3 interpreter"},python:{label:"Python 2",description:"Python 2 interpreter (legacy)"},java:{label:"Java",description:"Java runtime (use with -jar args)"},php:{label:"PHP",description:"PHP interpreter"},bash:{label:"Bash",description:"Bash shell script"},none:{label:"None (Binary)",description:"Direct execution (compiled binaries)"}},Gq={no:{label:"No",description:"Do not automatically restart"},always:{label:"Always",description:"Always restart when stopped"},"unless-stopped":{label:"Unless Stopped",description:"Restart unless manually stopped"},"on-failure":{label:"On Failure",description:"Restart only on failure"}},Kq={always:{label:"Always",description:"Always pull the image"},missing:{label:"If Missing",description:"Pull only if image not present"},never:{label:"Never",description:"Never pull, use local only"}},vL={mysql:{label:"MySQL",icon:"🐬",defaultPort:3306},postgresql:{label:"PostgreSQL",icon:"🐘",defaultPort:5432},oracle:{label:"Oracle",icon:"🔶",defaultPort:1521},sqlite:{label:"SQLite",icon:"🪶",defaultPort:0},mssql:{label:"SQL Server",icon:"🔷",defaultPort:1433}},d1=x.createContext(null);function f1(t){const e=_o[t];if(e)return e.icon;const s=U.getState().customAgentClasses.get(t);return s?s.icon:"🤖"}function wL(t){const e=_o[t];if(e)return e.color;const s=U.getState().customAgentClasses.get(t);return s?s.color:"#888888"}const kL=3,xS=80;function SL({notification:t,onDismiss:e,onClick:n}){const s=x.useRef({startX:0,startY:0,locked:!1}),[a,r]=x.useState(0),[i,c]=x.useState(!1),d=x.useRef(!1),f="ontouchstart"in window||navigator.maxTouchPoints>0,h=f1(t.agentClass),m=wL(t.agentClass),b=x.useCallback(T=>{s.current={startX:T.touches[0].clientX,startY:T.touches[0].clientY,locked:!1},d.current=!1},[]),y=x.useCallback(T=>{const D=T.touches[0].clientX-s.current.startX,E=T.touches[0].clientY-s.current.startY;!s.current.locked&&(Math.abs(D)<10&&Math.abs(E)<10||(s.current.locked=!0,Math.abs(E)>Math.abs(D)))||D<0&&(d.current=!0,r(D))},[]),w=x.useCallback(()=>{a<-xS?(c(!0),xp(2),setTimeout(()=>e(t.id),200)):r(0),setTimeout(()=>{d.current=!1},50)},[a,e,t.id]),C=x.useCallback(()=>{d.current||n(t)},[n,t]),N=Math.min(Math.abs(a)/(xS*1.5),1),k=i?0:1-N*.6,j=i?"-120%":`${a}px`,S=d.current&&!i?"none":"transform 0.2s ease-out, opacity 0.2s ease-out";return o.jsxs("div",{className:`agent-notification${i?" is-dismissing":""}`,onClick:f?void 0:C,onTouchStart:b,onTouchMove:y,onTouchEnd:w,style:{"--agent-color":m,transform:`translateX(${j})`,opacity:k,transition:S},children:[o.jsxs("div",{className:"agent-notification-content",children:[o.jsxs("div",{className:"agent-notification-header",children:[o.jsx("span",{className:"agent-notification-icon",children:h}),o.jsx("span",{className:"agent-notification-name",children:t.agentName}),o.jsx("span",{className:"agent-notification-separator",children:"·"}),o.jsx("span",{className:"agent-notification-title",children:t.title})]}),o.jsx("div",{className:"agent-notification-message",children:t.message})]}),o.jsx("button",{className:"agent-notification-close",onClick:T=>{T.stopPropagation(),e(t.id)},children:"×"})]})}function CL({children:t}){const{t:e}=dt(["notifications"]),[n,s]=x.useState([]),a=x.useRef(new Map);x.useEffect(()=>()=>{a.current.forEach(d=>clearTimeout(d))},[]);const r=x.useCallback(d=>{s(h=>h.filter(m=>m.id!==d));const f=a.current.get(d);f&&(clearTimeout(f),a.current.delete(d))},[]),i=x.useCallback(d=>{U.setLatestNotificationAgentId(d.agentId),s(h=>{const m=[...h,d];if(m.length>kL){const b=m.shift();if(b){const y=a.current.get(b.id);y&&(clearTimeout(y),a.current.delete(b.id))}}return m});const f=window.setTimeout(()=>{r(d.id)},8e3);if(a.current.set(d.id,f),!Zu()){const h=f1(d.agentClass);kR({title:`${h} ${d.agentName}: ${d.title}`,body:d.message,data:{type:"agent_notification",agentId:d.agentId,notificationId:d.id}})}},[r]),c=x.useCallback(d=>{jj(d.agentId),r(d.id)},[r]);return o.jsxs(d1.Provider,{value:{showAgentNotification:i},children:[t,o.jsx("div",{id:"agent-notification-container",children:n.map(d=>o.jsx(SL,{notification:d,onDismiss:r,onClick:c},d.id))})]})}function AL(){const t=x.useContext(d1);if(!t)throw new Error("useAgentNotification must be used within AgentNotificationProvider");return t}const jL={scout:{icon:"🔍",color:4890367,description:"Explores and searches codebase"},builder:{icon:"🔨",color:16752202,description:"Creates and builds features"},debugger:{icon:"🐛",color:16730698,description:"Finds and fixes bugs"},architect:{icon:"📐",color:10373887,description:"Plans and designs systems"},warrior:{icon:"⚔️",color:16730782,description:"Tackles tough problems"},support:{icon:"💚",color:4915102,description:"Helps and assists others"},boss:{icon:"👑",color:16766720,description:"Manages and delegates to subordinates"}},NL=["Alex","Sam","Jordan","Taylor","Casey","Morgan","Riley","Quinn","Avery","Blake","Cameron","Drew","Emery","Finley","Harper","Jamie","Kai","Logan","Max","Nico","Parker","Reese","Sage","Sky"],Qq=NL,TL={scout:"character-male-a.glb",builder:"character-male-b.glb",debugger:"character-female-a.glb",architect:"character-male-c.glb",warrior:"character-female-b.glb",support:"character-female-c.glb",boss:"character-male-c.glb"},Xq=[{id:"scout",model:"character-male-a.glb",name:"Explorer",gender:"Male"},{id:"builder",model:"character-male-b.glb",name:"Crafter",gender:"Male"},{id:"architect",model:"character-male-c.glb",name:"Planner",gender:"Male"},{id:"debugger",model:"character-female-a.glb",name:"Analyst",gender:"Female"},{id:"warrior",model:"character-female-b.glb",name:"Fighter",gender:"Female"},{id:"support",model:"character-female-c.glb",name:"Healer",gender:"Female"}],Jq=[{file:"character-male-a.glb",name:"Male A (Explorer)",gender:"Male"},{file:"character-male-b.glb",name:"Male B (Crafter)",gender:"Male"},{file:"character-male-c.glb",name:"Male C (Planner)",gender:"Male"},{file:"character-male-d.glb",name:"Male D",gender:"Male"},{file:"character-male-e.glb",name:"Male E",gender:"Male"},{file:"character-male-f.glb",name:"Male F",gender:"Male"},{file:"character-female-a.glb",name:"Female A (Analyst)",gender:"Female"},{file:"character-female-b.glb",name:"Female B (Fighter)",gender:"Female"},{file:"character-female-c.glb",name:"Female C (Healer)",gender:"Female"},{file:"character-female-d.glb",name:"Female D",gender:"Female"},{file:"character-female-e.glb",name:"Female E",gender:"Female"},{file:"character-female-f.glb",name:"Female F",gender:"Female"}],Zq=3,eV=5,tV=1e3,nV=50,sV=1.2;function _L(t){return typeof t=="string"?t:"#"+t.toString(16).padStart(6,"0")}function fr(t,e){const n=jL[t];if(n)return{icon:n.icon,color:_L(n.color),description:n.description};const s=e.find(a=>a.id===t);return s?{icon:s.icon,color:s.color,description:s.description}:{icon:"🤖",color:"#888888"}}const EL=2e5,ML=258400;function iu(t){return Math.max(0,Math.min(100,t))}function yS(t){const e=t.provider==="codex"?ML:EL,n=Math.max(1,Math.round(t.contextLimit||e)),s=Math.max(0,Math.min(Math.round(t.contextUsed||0),n)),a=iu(Number((s/n*100).toFixed(1))),r=t.contextStats;if(!r)return{totalTokens:s,contextWindow:n,usedPercent:a,freePercent:iu(Number((100-a).toFixed(1)))};const i=Math.max(1,Math.round(r.contextWindow||n)),c=Math.max(0,Math.min(Math.round(r.totalTokens||0),i)),d=iu(Number((r.usedPercent??c/i*100).toFixed(1)));return n!==i||s!==c?{totalTokens:s,contextWindow:n,usedPercent:a,freePercent:iu(Number((100-a).toFixed(1)))}:{totalTokens:c,contextWindow:i,usedPercent:d,freePercent:iu(Number((100-d).toFixed(1)))}}function DL(t){const e=Math.floor((Date.now()-t)/1e3);if(e<60)return`${e}s`;const n=Math.floor(e/60);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function wp(t){const e=Math.floor((Date.now()-t)/1e3);if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Xp(t){if(t.contextStats){const n=yS(t);return{remainingPercent:n.freePercent,usedPercent:n.usedPercent,hasData:!0,totalTokens:n.totalTokens,contextWindow:n.contextWindow,freeTokens:n.contextWindow-n.totalTokens}}const e=yS(t);return{remainingPercent:e.freePercent,usedPercent:e.usedPercent,hasData:!1,totalTokens:e.totalTokens,contextWindow:e.contextWindow,freeTokens:e.contextWindow-e.totalTokens}}function p1(t){return t<20?"#c85858":t<50?"#c89858":"#6a9a78"}const vS={working:0,waiting_permission:1,waiting:2,error:3,orphaned:4,idle:5,offline:6};function RL(t){return[...t].sort((e,n)=>{const s=vS[e.status]??5,a=vS[n.status]??5;return s!==a?s-a:(n.lastActivity||0)-(e.lastActivity||0)})}function OL(t,e){const n=new Map;for(const s of t){const a=e(s.id),r=(a==null?void 0:a.id)||null;n.has(r)||n.set(r,[]),n.get(r).push(s)}return n}function LL(t,e){return[...t].sort((n,s)=>{if(n===null)return 1;if(s===null)return-1;const a=n?e(n):void 0,r=s?e(s):void 0;return((a==null?void 0:a.name)||"").localeCompare((r==null?void 0:r.name)||"")})}function wS(t,e){if(e===EE)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(e===Ob||e===tj){let n=t.getIndex();if(n===null){const i=[],c=t.getAttribute("position");if(c!==void 0){for(let d=0;d<c.count;d++)i.push(d);t.setIndex(i),n=t.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t}const s=n.count-2,a=[];if(e===Ob)for(let i=1;i<=s;i++)a.push(n.getX(0)),a.push(n.getX(i)),a.push(n.getX(i+1));else for(let i=0;i<s;i++)i%2===0?(a.push(n.getX(i)),a.push(n.getX(i+1)),a.push(n.getX(i+2))):(a.push(n.getX(i+2)),a.push(n.getX(i+1)),a.push(n.getX(i)));a.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=t.clone();return r.setIndex(a),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t}class IL extends nj{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new $L(n)}),this.register(function(n){return new UL(n)}),this.register(function(n){return new XL(n)}),this.register(function(n){return new JL(n)}),this.register(function(n){return new ZL(n)}),this.register(function(n){return new WL(n)}),this.register(function(n){return new qL(n)}),this.register(function(n){return new VL(n)}),this.register(function(n){return new YL(n)}),this.register(function(n){return new zL(n)}),this.register(function(n){return new GL(n)}),this.register(function(n){return new HL(n)}),this.register(function(n){return new QL(n)}),this.register(function(n){return new KL(n)}),this.register(function(n){return new BL(n)}),this.register(function(n){return new e2(n)}),this.register(function(n){return new t2(n)})}load(e,n,s,a){const r=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const f=Cu.extractUrlBase(e);i=Cu.resolveURL(f,this.path)}else i=Cu.extractUrlBase(e);this.manager.itemStart(e);const c=function(f){a?a(f):console.error(f),r.manager.itemError(e),r.manager.itemEnd(e)},d=new up(this.manager);d.setPath(this.path),d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setWithCredentials(this.withCredentials),d.load(e,function(f){try{r.parse(f,i,function(h){n(h),r.manager.itemEnd(e)},c)}catch(h){c(h)}},s,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,s,a){let r;const i={},c={},d=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(d.decode(new Uint8Array(e,0,4))===h1){try{i[Jt.KHR_BINARY_GLTF]=new n2(e)}catch(m){a&&a(m);return}r=JSON.parse(i[Jt.KHR_BINARY_GLTF].content)}else r=JSON.parse(d.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const f=new m2(r,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});f.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const m=this.pluginCallbacks[h](f);m.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[m.name]=m,i[m.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const m=r.extensionsUsed[h],b=r.extensionsRequired||[];switch(m){case Jt.KHR_MATERIALS_UNLIT:i[m]=new FL;break;case Jt.KHR_DRACO_MESH_COMPRESSION:i[m]=new s2(r,this.dracoLoader);break;case Jt.KHR_TEXTURE_TRANSFORM:i[m]=new a2;break;case Jt.KHR_MESH_QUANTIZATION:i[m]=new r2;break;default:b.indexOf(m)>=0&&c[m]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+m+'".')}}f.setExtensions(i),f.setPlugins(c),f.parse(s,a)}parseAsync(e,n){const s=this;return new Promise(function(a,r){s.parse(e,n,a,r)})}}function PL(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Jt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class BL{constructor(e){this.parser=e,this.name=Jt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let s=0,a=n.length;s<a;s++){const r=n[s];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const n=this.parser,s="light:"+e;let a=n.cache.get(s);if(a)return a;const r=n.json,d=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let f;const h=new Hr(16777215);d.color!==void 0&&h.setRGB(d.color[0],d.color[1],d.color[2],lr);const m=d.range!==void 0?d.range:0;switch(d.type){case"directional":f=new Lb(h),f.target.position.set(0,0,-1),f.add(f.target);break;case"point":f=new DE(h),f.distance=m;break;case"spot":f=new ME(h),f.distance=m,d.spot=d.spot||{},d.spot.innerConeAngle=d.spot.innerConeAngle!==void 0?d.spot.innerConeAngle:0,d.spot.outerConeAngle=d.spot.outerConeAngle!==void 0?d.spot.outerConeAngle:Math.PI/4,f.angle=d.spot.outerConeAngle,f.penumbra=1-d.spot.innerConeAngle/d.spot.outerConeAngle,f.target.position.set(0,0,-1),f.add(f.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+d.type)}return f.position.set(0,0,0),f.decay=2,Ir(f,d),d.intensity!==void 0&&(f.intensity=d.intensity),f.name=n.createUniqueName(d.name||"light_"+e),a=Promise.resolve(f),n.cache.add(s,a),a}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,s=this.parser,r=s.json.nodes[e],c=(r.extensions&&r.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(d){return s._getNodeRef(n.cache,c,d)})}}class FL{constructor(){this.name=Jt.KHR_MATERIALS_UNLIT}getMaterialType(){return Fl}extendParams(e,n,s){const a=[];e.color=new Hr(1,1,1),e.opacity=1;const r=n.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const i=r.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],lr),e.opacity=i[3]}r.baseColorTexture!==void 0&&a.push(s.assignTexture(e,"map",r.baseColorTexture,Br))}return Promise.all(a)}}class zL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name].emissiveStrength;return r!==void 0&&(n.emissiveIntensity=r),Promise.resolve()}}class $L{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];if(i.clearcoatFactor!==void 0&&(n.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&r.push(s.assignTexture(n,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&r.push(s.assignTexture(n,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(r.push(s.assignTexture(n,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const c=i.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new sj(c,c)}return Promise.all(r)}}class UL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name];return n.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class HL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return i.iridescenceFactor!==void 0&&(n.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&r.push(s.assignTexture(n,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(n.iridescenceIOR=i.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&r.push(s.assignTexture(n,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class WL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[];n.sheenColor=new Hr(0,0,0),n.sheenRoughness=0,n.sheen=1;const i=a.extensions[this.name];if(i.sheenColorFactor!==void 0){const c=i.sheenColorFactor;n.sheenColor.setRGB(c[0],c[1],c[2],lr)}return i.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&r.push(s.assignTexture(n,"sheenColorMap",i.sheenColorTexture,Br)),i.sheenRoughnessTexture!==void 0&&r.push(s.assignTexture(n,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(r)}}class qL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return i.transmissionFactor!==void 0&&(n.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&r.push(s.assignTexture(n,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class VL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];n.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&r.push(s.assignTexture(n,"thicknessMap",i.thicknessTexture)),n.attenuationDistance=i.attenuationDistance||1/0;const c=i.attenuationColor||[1,1,1];return n.attenuationColor=new Hr().setRGB(c[0],c[1],c[2],lr),Promise.all(r)}}class YL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name];return n.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class GL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];n.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&r.push(s.assignTexture(n,"specularIntensityMap",i.specularTexture));const c=i.specularColorFactor||[1,1,1];return n.specularColor=new Hr().setRGB(c[0],c[1],c[2],lr),i.specularColorTexture!==void 0&&r.push(s.assignTexture(n,"specularColorMap",i.specularColorTexture,Br)),Promise.all(r)}}class KL{constructor(e){this.parser=e,this.name=Jt.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return n.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&r.push(s.assignTexture(n,"bumpMap",i.bumpTexture)),Promise.all(r)}}class QL{constructor(e){this.parser=e,this.name=Jt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:cr}extendMaterialParams(e,n){const s=this.parser,a=s.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],i=a.extensions[this.name];return i.anisotropyStrength!==void 0&&(n.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(n.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&r.push(s.assignTexture(n,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}}class XL{constructor(e){this.parser=e,this.name=Jt.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,s=n.json,a=s.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const r=a.extensions[this.name],i=n.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,r.source,i)}}class JL{constructor(e){this.parser=e,this.name=Jt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,s=this.parser,a=s.json,r=a.textures[e];if(!r.extensions||!r.extensions[n])return null;const i=r.extensions[n],c=a.images[i.source];let d=s.textureLoader;if(c.uri){const f=s.options.manager.getHandler(c.uri);f!==null&&(d=f)}return this.detectSupport().then(function(f){if(f)return s.loadTextureImage(e,i.source,d);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class ZL{constructor(e){this.parser=e,this.name=Jt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,s=this.parser,a=s.json,r=a.textures[e];if(!r.extensions||!r.extensions[n])return null;const i=r.extensions[n],c=a.images[i.source];let d=s.textureLoader;if(c.uri){const f=s.options.manager.getHandler(c.uri);f!==null&&(d=f)}return this.detectSupport().then(function(f){if(f)return s.loadTextureImage(e,i.source,d);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class e2{constructor(e){this.name=Jt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,s=n.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const a=s.extensions[this.name],r=this.parser.getDependency("buffer",a.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(c){const d=a.byteOffset||0,f=a.byteLength||0,h=a.count,m=a.byteStride,b=new Uint8Array(c,d,f);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(h,m,b,a.mode,a.filter).then(function(y){return y.buffer}):i.ready.then(function(){const y=new ArrayBuffer(h*m);return i.decodeGltfBuffer(new Uint8Array(y),h,m,b,a.mode,a.filter),y})})}else return null}}class t2{constructor(e){this.name=Jt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,s=n.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const a=n.meshes[s.mesh];for(const f of a.primitives)if(f.mode!==Ca.TRIANGLES&&f.mode!==Ca.TRIANGLE_STRIP&&f.mode!==Ca.TRIANGLE_FAN&&f.mode!==void 0)return null;const i=s.extensions[this.name].attributes,c=[],d={};for(const f in i)c.push(this.parser.getDependency("accessor",i[f]).then(h=>(d[f]=h,d[f])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(f=>{const h=f.pop(),m=h.isGroup?h.children:[h],b=f[0].count,y=[];for(const w of m){const C=new dp,N=new wo,k=new aj,j=new wo(1,1,1),S=new RE(w.geometry,w.material,b);for(let T=0;T<b;T++)d.TRANSLATION&&N.fromBufferAttribute(d.TRANSLATION,T),d.ROTATION&&k.fromBufferAttribute(d.ROTATION,T),d.SCALE&&j.fromBufferAttribute(d.SCALE,T),S.setMatrixAt(T,C.compose(N,k,j));for(const T in d)if(T==="_COLOR_0"){const D=d[T];S.instanceColor=new OE(D.array,D.itemSize,D.normalized)}else T!=="TRANSLATION"&&T!=="ROTATION"&&T!=="SCALE"&&w.geometry.setAttribute(T,d[T]);rj.prototype.copy.call(S,w),this.parser.assignFinalMaterial(S),y.push(S)}return h.isGroup?(h.clear(),h.add(...y),h):y[0]}))}}const h1="glTF",ou=12,kS={JSON:1313821514,BIN:5130562};class n2{constructor(e){this.name=Jt.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,ou),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==h1)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-ou,r=new DataView(e,ou);let i=0;for(;i<a;){const c=r.getUint32(i,!0);i+=4;const d=r.getUint32(i,!0);if(i+=4,d===kS.JSON){const f=new Uint8Array(e,ou+i,c);this.content=s.decode(f)}else if(d===kS.BIN){const f=ou+i;this.body=e.slice(f,f+c)}i+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class s2{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Jt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const s=this.json,a=this.dracoLoader,r=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,c={},d={},f={};for(const h in i){const m=nx[h]||h.toLowerCase();c[m]=i[h]}for(const h in e.attributes){const m=nx[h]||h.toLowerCase();if(i[h]!==void 0){const b=s.accessors[e.attributes[h]],y=Ul[b.componentType];f[m]=y.name,d[m]=b.normalized===!0}}return n.getDependency("bufferView",r).then(function(h){return new Promise(function(m,b){a.decodeDracoFile(h,function(y){for(const w in y.attributes){const C=y.attributes[w],N=d[w];N!==void 0&&(C.normalized=N)}m(y)},c,f,lr,b)})})}}class a2{constructor(){this.name=Jt.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class r2{constructor(){this.name=Jt.KHR_MESH_QUANTIZATION}}class m1 extends rM{constructor(e,n,s,a){super(e,n,s,a)}copySampleValue_(e){const n=this.resultBuffer,s=this.sampleValues,a=this.valueSize,r=e*a*3+a;for(let i=0;i!==a;i++)n[i]=s[r+i];return n}interpolate_(e,n,s,a){const r=this.resultBuffer,i=this.sampleValues,c=this.valueSize,d=c*2,f=c*3,h=a-n,m=(s-n)/h,b=m*m,y=b*m,w=e*f,C=w-f,N=-2*y+3*b,k=y-b,j=1-N,S=k-b+m;for(let T=0;T!==c;T++){const D=i[C+T+c],E=i[C+T+d]*h,I=i[w+T+c],O=i[w+T]*h;r[T]=j*D+S*E+N*I+k*O}return r}}const i2=new aj;class o2 extends m1{interpolate_(e,n,s,a){const r=super.interpolate_(e,n,s,a);return i2.fromArray(r).normalize().toArray(r),r}}const Ca={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ul={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},SS={9728:oj,9729:Ib,9984:zE,9985:FE,9986:BE,9987:ij},CS={33071:UE,33648:$E,10497:Pb},Hg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},nx={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ci={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},l2={CUBICSPLINE:void 0,LINEAR:dj,STEP:nM},Wg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function c2(t){return t.DefaultMaterial===void 0&&(t.DefaultMaterial=new Nx({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:aM})),t.DefaultMaterial}function ho(t,e,n){for(const s in n.extensions)t[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=n.extensions[s])}function Ir(t,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function u2(t,e,n){let s=!1,a=!1,r=!1;for(let f=0,h=e.length;f<h;f++){const m=e[f];if(m.POSITION!==void 0&&(s=!0),m.NORMAL!==void 0&&(a=!0),m.COLOR_0!==void 0&&(r=!0),s&&a&&r)break}if(!s&&!a&&!r)return Promise.resolve(t);const i=[],c=[],d=[];for(let f=0,h=e.length;f<h;f++){const m=e[f];if(s){const b=m.POSITION!==void 0?n.getDependency("accessor",m.POSITION):t.attributes.position;i.push(b)}if(a){const b=m.NORMAL!==void 0?n.getDependency("accessor",m.NORMAL):t.attributes.normal;c.push(b)}if(r){const b=m.COLOR_0!==void 0?n.getDependency("accessor",m.COLOR_0):t.attributes.color;d.push(b)}}return Promise.all([Promise.all(i),Promise.all(c),Promise.all(d)]).then(function(f){const h=f[0],m=f[1],b=f[2];return s&&(t.morphAttributes.position=h),a&&(t.morphAttributes.normal=m),r&&(t.morphAttributes.color=b),t.morphTargetsRelative=!0,t})}function d2(t,e){if(t.updateMorphTargets(),e.weights!==void 0)for(let n=0,s=e.weights.length;n<s;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let s=0,a=n.length;s<a;s++)t.morphTargetDictionary[n[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function f2(t){let e;const n=t.extensions&&t.extensions[Jt.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+qg(n.attributes):e=t.indices+":"+qg(t.attributes)+":"+t.mode,t.targets!==void 0)for(let s=0,a=t.targets.length;s<a;s++)e+=":"+qg(t.targets[s]);return e}function qg(t){let e="";const n=Object.keys(t).sort();for(let s=0,a=n.length;s<a;s++)e+=n[s]+":"+t[n[s]]+";";return e}function sx(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function p2(t){return t.search(/\.jpe?g($|\?)/i)>0||t.search(/^data\:image\/jpeg/)===0?"image/jpeg":t.search(/\.webp($|\?)/i)>0||t.search(/^data\:image\/webp/)===0?"image/webp":t.search(/\.ktx2($|\?)/i)>0||t.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const h2=new dp;class m2{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new PL,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,a=-1,r=!1,i=-1;if(typeof navigator<"u"){const c=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(c)===!0;const d=c.match(/Version\/(\d+)/);a=s&&d?parseInt(d[1],10):-1,r=c.indexOf("Firefox")>-1,i=r?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&a<17||r&&i<98?this.textureLoader=new LE(this.options.manager):this.textureLoader=new IE(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new up(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const s=this,a=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(i){const c={scene:i[0][a.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:a.asset,parser:s,userData:{}};return ho(r,c,a),Ir(c,a),Promise.all(s._invokeAll(function(d){return d.afterRoot&&d.afterRoot(c)})).then(function(){for(const d of c.scenes)d.updateMatrixWorld();e(c)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],s=this.json.meshes||[];for(let a=0,r=n.length;a<r;a++){const i=n[a].joints;for(let c=0,d=i.length;c<d;c++)e[i[c]].isBone=!0}for(let a=0,r=e.length;a<r;a++){const i=e[a];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(s[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,s){if(e.refs[n]<=1)return s;const a=s.clone(),r=(i,c)=>{const d=this.associations.get(i);d!=null&&this.associations.set(c,d);for(const[f,h]of i.children.entries())r(h,c.children[f])};return r(s,a),a.name+="_instance_"+e.uses[n]++,a}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let s=0;s<n.length;s++){const a=e(n[s]);if(a)return a}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const s=[];for(let a=0;a<n.length;a++){const r=e(n[a]);r&&s.push(r)}return s}getDependency(e,n){const s=e+":"+n;let a=this.cache.get(s);if(!a){switch(e){case"scene":a=this.loadScene(n);break;case"node":a=this._invokeOne(function(r){return r.loadNode&&r.loadNode(n)});break;case"mesh":a=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(n)});break;case"accessor":a=this.loadAccessor(n);break;case"bufferView":a=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(n)});break;case"buffer":a=this.loadBuffer(n);break;case"material":a=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(n)});break;case"texture":a=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(n)});break;case"skin":a=this.loadSkin(n);break;case"animation":a=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(n)});break;case"camera":a=this.loadCamera(n);break;default:if(a=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,n)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(s,a)}return a}getDependencies(e){let n=this.cache.get(e);if(!n){const s=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(a.map(function(r,i){return s.getDependency(e,i)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],s=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[Jt.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(r,i){s.load(Cu.resolveURL(n.uri,a.path),r,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(s){const a=n.byteLength||0,r=n.byteOffset||0;return s.slice(r,r+a)})}loadAccessor(e){const n=this,s=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const i=Hg[a.type],c=Ul[a.componentType],d=a.normalized===!0,f=new c(a.count*i);return Promise.resolve(new Au(f,i,d))}const r=[];return a.bufferView!==void 0?r.push(this.getDependency("bufferView",a.bufferView)):r.push(null),a.sparse!==void 0&&(r.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(r).then(function(i){const c=i[0],d=Hg[a.type],f=Ul[a.componentType],h=f.BYTES_PER_ELEMENT,m=h*d,b=a.byteOffset||0,y=a.bufferView!==void 0?s.bufferViews[a.bufferView].byteStride:void 0,w=a.normalized===!0;let C,N;if(y&&y!==m){const k=Math.floor(b/y),j="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+k+":"+a.count;let S=n.cache.get(j);S||(C=new f(c,k*y,a.count*y/h),S=new PE(C,y/h),n.cache.add(j,S)),N=new sM(S,d,b%y/h,w)}else c===null?C=new f(a.count*d):C=new f(c,b,a.count*d),N=new Au(C,d,w);if(a.sparse!==void 0){const k=Hg.SCALAR,j=Ul[a.sparse.indices.componentType],S=a.sparse.indices.byteOffset||0,T=a.sparse.values.byteOffset||0,D=new j(i[1],S,a.sparse.count*k),E=new f(i[2],T,a.sparse.count*d);c!==null&&(N=new Au(N.array.slice(),N.itemSize,N.normalized)),N.normalized=!1;for(let I=0,O=D.length;I<O;I++){const _=D[I];if(N.setX(_,E[I*d]),d>=2&&N.setY(_,E[I*d+1]),d>=3&&N.setZ(_,E[I*d+2]),d>=4&&N.setW(_,E[I*d+3]),d>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}N.normalized=w}return N})}loadTexture(e){const n=this.json,s=this.options,r=n.textures[e].source,i=n.images[r];let c=this.textureLoader;if(i.uri){const d=s.manager.getHandler(i.uri);d!==null&&(c=d)}return this.loadTextureImage(e,r,c)}loadTextureImage(e,n,s){const a=this,r=this.json,i=r.textures[e],c=r.images[n],d=(c.uri||c.bufferView)+":"+i.sampler;if(this.textureCache[d])return this.textureCache[d];const f=this.loadImageSource(n,s).then(function(h){h.flipY=!1,h.name=i.name||c.name||"",h.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(h.name=c.uri);const b=(r.samplers||{})[i.sampler]||{};return h.magFilter=SS[b.magFilter]||Ib,h.minFilter=SS[b.minFilter]||ij,h.wrapS=CS[b.wrapS]||Pb,h.wrapT=CS[b.wrapT]||Pb,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==oj&&h.minFilter!==Ib,a.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[d]=f,f}loadImageSource(e,n){const s=this,a=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(m=>m.clone());const i=a.images[e],c=self.URL||self.webkitURL;let d=i.uri||"",f=!1;if(i.bufferView!==void 0)d=s.getDependency("bufferView",i.bufferView).then(function(m){f=!0;const b=new Blob([m],{type:i.mimeType});return d=c.createObjectURL(b),d});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(d).then(function(m){return new Promise(function(b,y){let w=b;n.isImageBitmapLoader===!0&&(w=function(C){const N=new Z0(C);N.needsUpdate=!0,b(N)}),n.load(Cu.resolveURL(m,r.path),w,void 0,y)})}).then(function(m){return f===!0&&c.revokeObjectURL(d),Ir(m,i),m.userData.mimeType=i.mimeType||p2(i.uri),m}).catch(function(m){throw console.error("THREE.GLTFLoader: Couldn't load texture",d),m});return this.sourceCache[e]=h,h}assignTexture(e,n,s,a){const r=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),r.extensions[Jt.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[Jt.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const d=r.associations.get(i);i=r.extensions[Jt.KHR_TEXTURE_TRANSFORM].extendTexture(i,c),r.associations.set(i,d)}}return a!==void 0&&(i.colorSpace=a),e[n]=i,i})}assignFinalMaterial(e){const n=e.geometry;let s=e.material;const a=n.attributes.tangent===void 0,r=n.attributes.color!==void 0,i=n.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+s.uuid;let d=this.cache.get(c);d||(d=new HE,Jf.prototype.copy.call(d,s),d.color.copy(s.color),d.map=s.map,d.sizeAttenuation=!1,this.cache.add(c,d)),s=d}else if(e.isLine){const c="LineBasicMaterial:"+s.uuid;let d=this.cache.get(c);d||(d=new WE,Jf.prototype.copy.call(d,s),d.color.copy(s.color),d.map=s.map,this.cache.add(c,d)),s=d}if(a||r||i){let c="ClonedMaterial:"+s.uuid+":";a&&(c+="derivative-tangents:"),r&&(c+="vertex-colors:"),i&&(c+="flat-shading:");let d=this.cache.get(c);d||(d=s.clone(),r&&(d.vertexColors=!0),i&&(d.flatShading=!0),a&&(d.normalScale&&(d.normalScale.y*=-1),d.clearcoatNormalScale&&(d.clearcoatNormalScale.y*=-1)),this.cache.add(c,d),this.associations.set(d,this.associations.get(s))),s=d}e.material=s}getMaterialType(){return Nx}loadMaterial(e){const n=this,s=this.json,a=this.extensions,r=s.materials[e];let i;const c={},d=r.extensions||{},f=[];if(d[Jt.KHR_MATERIALS_UNLIT]){const m=a[Jt.KHR_MATERIALS_UNLIT];i=m.getMaterialType(),f.push(m.extendParams(c,r,n))}else{const m=r.pbrMetallicRoughness||{};if(c.color=new Hr(1,1,1),c.opacity=1,Array.isArray(m.baseColorFactor)){const b=m.baseColorFactor;c.color.setRGB(b[0],b[1],b[2],lr),c.opacity=b[3]}m.baseColorTexture!==void 0&&f.push(n.assignTexture(c,"map",m.baseColorTexture,Br)),c.metalness=m.metallicFactor!==void 0?m.metallicFactor:1,c.roughness=m.roughnessFactor!==void 0?m.roughnessFactor:1,m.metallicRoughnessTexture!==void 0&&(f.push(n.assignTexture(c,"metalnessMap",m.metallicRoughnessTexture)),f.push(n.assignTexture(c,"roughnessMap",m.metallicRoughnessTexture))),i=this._invokeOne(function(b){return b.getMaterialType&&b.getMaterialType(e)}),f.push(Promise.all(this._invokeAll(function(b){return b.extendMaterialParams&&b.extendMaterialParams(e,c)})))}r.doubleSided===!0&&(c.side=lj);const h=r.alphaMode||Wg.OPAQUE;if(h===Wg.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,h===Wg.MASK&&(c.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==Fl&&(f.push(n.assignTexture(c,"normalMap",r.normalTexture)),c.normalScale=new sj(1,1),r.normalTexture.scale!==void 0)){const m=r.normalTexture.scale;c.normalScale.set(m,m)}if(r.occlusionTexture!==void 0&&i!==Fl&&(f.push(n.assignTexture(c,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==Fl){const m=r.emissiveFactor;c.emissive=new Hr().setRGB(m[0],m[1],m[2],lr)}return r.emissiveTexture!==void 0&&i!==Fl&&f.push(n.assignTexture(c,"emissiveMap",r.emissiveTexture,Br)),Promise.all(f).then(function(){const m=new i(c);return r.name&&(m.name=r.name),Ir(m,r),n.associations.set(m,{materials:e}),r.extensions&&ho(a,m,r),m})}createUniqueName(e){const n=qE.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,s=this.extensions,a=this.primitiveCache;function r(c){return s[Jt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,n).then(function(d){return AS(d,c,n)})}const i=[];for(let c=0,d=e.length;c<d;c++){const f=e[c],h=f2(f),m=a[h];if(m)i.push(m.promise);else{let b;f.extensions&&f.extensions[Jt.KHR_DRACO_MESH_COMPRESSION]?b=r(f):b=AS(new cj,f,n),a[h]={primitive:f,promise:b},i.push(b)}}return Promise.all(i)}loadMesh(e){const n=this,s=this.json,a=this.extensions,r=s.meshes[e],i=r.primitives,c=[];for(let d=0,f=i.length;d<f;d++){const h=i[d].material===void 0?c2(this.cache):this.getDependency("material",i[d].material);c.push(h)}return c.push(n.loadGeometries(i)),Promise.all(c).then(function(d){const f=d.slice(0,d.length-1),h=d[d.length-1],m=[];for(let y=0,w=h.length;y<w;y++){const C=h[y],N=i[y];let k;const j=f[y];if(N.mode===Ca.TRIANGLES||N.mode===Ca.TRIANGLE_STRIP||N.mode===Ca.TRIANGLE_FAN||N.mode===void 0)k=r.isSkinnedMesh===!0?new VE(C,j):new Il(C,j),k.isSkinnedMesh===!0&&k.normalizeSkinWeights(),N.mode===Ca.TRIANGLE_STRIP?k.geometry=wS(k.geometry,tj):N.mode===Ca.TRIANGLE_FAN&&(k.geometry=wS(k.geometry,Ob));else if(N.mode===Ca.LINES)k=new YE(C,j);else if(N.mode===Ca.LINE_STRIP)k=new GE(C,j);else if(N.mode===Ca.LINE_LOOP)k=new KE(C,j);else if(N.mode===Ca.POINTS)k=new QE(C,j);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+N.mode);Object.keys(k.geometry.morphAttributes).length>0&&d2(k,r),k.name=n.createUniqueName(r.name||"mesh_"+e),Ir(k,r),N.extensions&&ho(a,k,N),n.assignFinalMaterial(k),m.push(k)}for(let y=0,w=m.length;y<w;y++)n.associations.set(m[y],{meshes:e,primitives:y});if(m.length===1)return r.extensions&&ho(a,m[0],r),m[0];const b=new xg;r.extensions&&ho(a,b,r),n.associations.set(b,{meshes:e});for(let y=0,w=m.length;y<w;y++)b.add(m[y]);return b})}loadCamera(e){let n;const s=this.json.cameras[e],a=s[s.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?n=new uj(XE.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):s.type==="orthographic"&&(n=new JE(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),s.name&&(n.name=this.createUniqueName(s.name)),Ir(n,s),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],s=[];for(let a=0,r=n.joints.length;a<r;a++)s.push(this._loadNodeShallow(n.joints[a]));return n.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",n.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(a){const r=a.pop(),i=a,c=[],d=[];for(let f=0,h=i.length;f<h;f++){const m=i[f];if(m){c.push(m);const b=new dp;r!==null&&b.fromArray(r.array,f*16),d.push(b)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[f])}return new ZE(c,d)})}loadAnimation(e){const n=this.json,s=this,a=n.animations[e],r=a.name?a.name:"animation_"+e,i=[],c=[],d=[],f=[],h=[];for(let m=0,b=a.channels.length;m<b;m++){const y=a.channels[m],w=a.samplers[y.sampler],C=y.target,N=C.node,k=a.parameters!==void 0?a.parameters[w.input]:w.input,j=a.parameters!==void 0?a.parameters[w.output]:w.output;C.node!==void 0&&(i.push(this.getDependency("node",N)),c.push(this.getDependency("accessor",k)),d.push(this.getDependency("accessor",j)),f.push(w),h.push(C))}return Promise.all([Promise.all(i),Promise.all(c),Promise.all(d),Promise.all(f),Promise.all(h)]).then(function(m){const b=m[0],y=m[1],w=m[2],C=m[3],N=m[4],k=[];for(let j=0,S=b.length;j<S;j++){const T=b[j],D=y[j],E=w[j],I=C[j],O=N[j];if(T===void 0)continue;T.updateMatrix&&T.updateMatrix();const _=s._createAnimationTracks(T,D,E,I,O);if(_)for(let M=0;M<_.length;M++)k.push(_[M])}return new eM(r,void 0,k)})}createNodeMesh(e){const n=this.json,s=this,a=n.nodes[e];return a.mesh===void 0?null:s.getDependency("mesh",a.mesh).then(function(r){const i=s._getNodeRef(s.meshCache,a.mesh,r);return a.weights!==void 0&&i.traverse(function(c){if(c.isMesh)for(let d=0,f=a.weights.length;d<f;d++)c.morphTargetInfluences[d]=a.weights[d]}),i})}loadNode(e){const n=this.json,s=this,a=n.nodes[e],r=s._loadNodeShallow(e),i=[],c=a.children||[];for(let f=0,h=c.length;f<h;f++)i.push(s.getDependency("node",c[f]));const d=a.skin===void 0?Promise.resolve(null):s.getDependency("skin",a.skin);return Promise.all([r,Promise.all(i),d]).then(function(f){const h=f[0],m=f[1],b=f[2];b!==null&&h.traverse(function(y){y.isSkinnedMesh&&y.bind(b,h2)});for(let y=0,w=m.length;y<w;y++)h.add(m[y]);return h})}_loadNodeShallow(e){const n=this.json,s=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=n.nodes[e],i=r.name?a.createUniqueName(r.name):"",c=[],d=a._invokeOne(function(f){return f.createNodeMesh&&f.createNodeMesh(e)});return d&&c.push(d),r.camera!==void 0&&c.push(a.getDependency("camera",r.camera).then(function(f){return a._getNodeRef(a.cameraCache,r.camera,f)})),a._invokeAll(function(f){return f.createNodeAttachment&&f.createNodeAttachment(e)}).forEach(function(f){c.push(f)}),this.nodeCache[e]=Promise.all(c).then(function(f){let h;if(r.isBone===!0?h=new tM:f.length>1?h=new xg:f.length===1?h=f[0]:h=new rj,h!==f[0])for(let m=0,b=f.length;m<b;m++)h.add(f[m]);if(r.name&&(h.userData.name=r.name,h.name=i),Ir(h,r),r.extensions&&ho(s,h,r),r.matrix!==void 0){const m=new dp;m.fromArray(r.matrix),h.applyMatrix4(m)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return a.associations.has(h)||a.associations.set(h,{}),a.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const n=this.extensions,s=this.json.scenes[e],a=this,r=new xg;s.name&&(r.name=a.createUniqueName(s.name)),Ir(r,s),s.extensions&&ho(n,r,s);const i=s.nodes||[],c=[];for(let d=0,f=i.length;d<f;d++)c.push(a.getDependency("node",i[d]));return Promise.all(c).then(function(d){for(let h=0,m=d.length;h<m;h++)r.add(d[h]);const f=h=>{const m=new Map;for(const[b,y]of a.associations)(b instanceof Jf||b instanceof Z0)&&m.set(b,y);return h.traverse(b=>{const y=a.associations.get(b);y!=null&&m.set(b,y)}),m};return a.associations=f(r),r})}_createAnimationTracks(e,n,s,a,r){const i=[],c=e.name?e.name:e.uuid,d=[];Ci[r.path]===Ci.weights?e.traverse(function(b){b.morphTargetInfluences&&d.push(b.name?b.name:b.uuid)}):d.push(c);let f;switch(Ci[r.path]){case Ci.weights:f=tk;break;case Ci.rotation:f=nk;break;case Ci.position:case Ci.scale:f=ek;break;default:switch(s.itemSize){case 1:f=tk;break;case 2:case 3:default:f=ek;break}break}const h=a.interpolation!==void 0?l2[a.interpolation]:dj,m=this._getArrayFromAccessor(s);for(let b=0,y=d.length;b<y;b++){const w=new f(d[b]+"."+Ci[r.path],n.array,m,h);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(w),i.push(w)}return i}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const s=sx(n.constructor),a=new Float32Array(n.length);for(let r=0,i=n.length;r<i;r++)a[r]=n[r]*s;n=a}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const a=this instanceof nk?o2:m1;return new a(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function g2(t,e,n){const s=e.attributes,a=new iM;if(s.POSITION!==void 0){const c=n.json.accessors[s.POSITION],d=c.min,f=c.max;if(d!==void 0&&f!==void 0){if(a.set(new wo(d[0],d[1],d[2]),new wo(f[0],f[1],f[2])),c.normalized){const h=sx(Ul[c.componentType]);a.min.multiplyScalar(h),a.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const c=new wo,d=new wo;for(let f=0,h=r.length;f<h;f++){const m=r[f];if(m.POSITION!==void 0){const b=n.json.accessors[m.POSITION],y=b.min,w=b.max;if(y!==void 0&&w!==void 0){if(d.setX(Math.max(Math.abs(y[0]),Math.abs(w[0]))),d.setY(Math.max(Math.abs(y[1]),Math.abs(w[1]))),d.setZ(Math.max(Math.abs(y[2]),Math.abs(w[2]))),b.normalized){const C=sx(Ul[b.componentType]);d.multiplyScalar(C)}c.max(d)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(c)}t.boundingBox=a;const i=new oM;a.getCenter(i.center),i.radius=a.min.distanceTo(a.max)/2,t.boundingSphere=i}function AS(t,e,n){const s=e.attributes,a=[];function r(i,c){return n.getDependency("accessor",i).then(function(d){t.setAttribute(c,d)})}for(const i in s){const c=nx[i]||i.toLowerCase();c in t.attributes||a.push(r(s[i],c))}if(e.indices!==void 0&&!t.index){const i=n.getDependency("accessor",e.indices).then(function(c){t.setIndex(c)});a.push(i)}return Bb.workingColorSpace!==lr&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Bb.workingColorSpace}" not supported.`),Ir(t,e),g2(t,e,n),Promise.all(a).then(function(){return e.targets!==void 0?u2(t,e.targets,n):t})}const Vg=new WeakMap;class b2 extends nj{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,n,s,a){const r=new up(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,i=>{this.parse(i,n,a)},s,a)}parse(e,n,s=()=>{}){this.decodeDracoFile(e,n,null,null,Br,s).catch(s)}decodeDracoFile(e,n,s,a,r=lr,i=()=>{}){const c={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:a||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:r};return this.decodeGeometry(e,c).then(n).catch(i)}decodeGeometry(e,n){const s=JSON.stringify(n);if(Vg.has(e)){const d=Vg.get(e);if(d.key===s)return d.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let a;const r=this.workerNextTaskID++,i=e.byteLength,c=this._getWorker(r,i).then(d=>(a=d,new Promise((f,h)=>{a._callbacks[r]={resolve:f,reject:h},a.postMessage({type:"decode",id:r,taskConfig:n,buffer:e},[e])}))).then(d=>this._createGeometry(d.geometry));return c.catch(()=>!0).then(()=>{a&&r&&this._releaseTask(a,r)}),Vg.set(e,{key:s,promise:c}),c}_createGeometry(e){const n=new cj;e.index&&n.setIndex(new Au(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const a=e.attributes[s],r=a.name,i=a.array,c=a.itemSize,d=new Au(i,c);r==="color"&&(this._assignVertexColorSpace(d,a.vertexColorSpace),d.normalized=!(i instanceof Float32Array)),n.setAttribute(r,d)}return n}_assignVertexColorSpace(e,n){if(n!==Br)return;const s=new Hr;for(let a=0,r=e.count;a<r;a++)s.fromBufferAttribute(e,a),Bb.toWorkingColorSpace(s,Br),e.setXYZ(a,s.r,s.g,s.b)}_loadLibrary(e,n){const s=new up(this.manager);return s.setPath(this.decoderPath),s.setResponseType(n),s.setWithCredentials(this.withCredentials),new Promise((a,r)=>{s.load(e,a,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",n=[];return e?n.push(this._loadLibrary("draco_decoder.js","text")):(n.push(this._loadLibrary("draco_wasm_wrapper.js","text")),n.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(n).then(s=>{const a=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const r=x2.toString(),i=["/* draco decoder */",a,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
47
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,n){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const a=new Worker(this.workerSourceURL);a._callbacks={},a._taskCosts={},a._taskLoad=0,a.postMessage({type:"init",decoderConfig:this.decoderConfig}),a.onmessage=function(r){const i=r.data;switch(i.type){case"decode":a._callbacks[i.id].resolve(i);break;case"error":a._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(a)}else this.workerPool.sort(function(a,r){return a._taskLoad>r._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=n,s._taskLoad+=n,s})}_releaseTask(e,n){e._taskLoad-=e._taskCosts[n],delete e._callbacks[n],delete e._taskCosts[n]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function x2(){let t,e;onmessage=function(i){const c=i.data;switch(c.type){case"init":t=c.decoderConfig,e=new Promise(function(h){t.onModuleLoaded=function(m){h({draco:m})},DracoDecoderModule(t)});break;case"decode":const d=c.buffer,f=c.taskConfig;e.then(h=>{const m=h.draco,b=new m.Decoder;try{const y=n(m,b,new Int8Array(d),f),w=y.attributes.map(C=>C.array.buffer);y.index&&w.push(y.index.array.buffer),self.postMessage({type:"decode",id:c.id,geometry:y},w)}catch(y){console.error(y),self.postMessage({type:"error",id:c.id,error:y.message})}finally{m.destroy(b)}});break}};function n(i,c,d,f){const h=f.attributeIDs,m=f.attributeTypes;let b,y;const w=c.GetEncodedGeometryType(d);if(w===i.TRIANGULAR_MESH)b=new i.Mesh,y=c.DecodeArrayToMesh(d,d.byteLength,b);else if(w===i.POINT_CLOUD)b=new i.PointCloud,y=c.DecodeArrayToPointCloud(d,d.byteLength,b);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!y.ok()||b.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());const C={index:null,attributes:[]};for(const N in h){const k=self[m[N]];let j,S;if(f.useUniqueIDs)S=h[N],j=c.GetAttributeByUniqueId(b,S);else{if(S=c.GetAttributeId(b,i[h[N]]),S===-1)continue;j=c.GetAttribute(b,S)}const T=a(i,c,b,N,k,j);N==="color"&&(T.vertexColorSpace=f.vertexColorSpace),C.attributes.push(T)}return w===i.TRIANGULAR_MESH&&(C.index=s(i,c,b)),i.destroy(b),C}function s(i,c,d){const h=d.num_faces()*3,m=h*4,b=i._malloc(m);c.GetTrianglesUInt32Array(d,m,b);const y=new Uint32Array(i.HEAPF32.buffer,b,h).slice();return i._free(b),{array:y,itemSize:1}}function a(i,c,d,f,h,m){const b=m.num_components(),w=d.num_points()*b,C=w*h.BYTES_PER_ELEMENT,N=r(i,h),k=i._malloc(C);c.GetAttributeDataArrayForAllPoints(d,m,N,C,k);const j=new h(i.HEAPF32.buffer,k,w).slice();return i._free(k),{name:f,array:j,itemSize:b}}function r(i,c){switch(c){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}var y2=(function(){var t="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),s=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var a=WebAssembly.validate(n)?e:t,r,i=WebAssembly.instantiate(c(a),{}).then(function(k){r=k.instance,r.exports.__wasm_call_ctors()});function c(k){for(var j=new Uint8Array(k.length),S=0;S<k.length;++S){var T=k.charCodeAt(S);j[S]=T>96?T-97:T>64?T-39:T+4}for(var D=0,S=0;S<k.length;++S)j[D++]=j[S]<60?s[j[S]]:(j[S]-60)*64+j[++S];return j.buffer.slice(0,D)}function d(k,j,S,T,D,E){var I=r.exports.sbrk,O=S+3&-4,_=I(O*T),M=I(D.length),R=new Uint8Array(r.exports.memory.buffer);R.set(D,M);var z=k(_,S,T,M,D.length);if(z==0&&E&&E(_,O,T),j.set(R.subarray(_,_+S*T)),I(_-I(0)),z!=0)throw new Error("Malformed buffer data: "+z)}var f={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},m=[],b=0;function y(k){var j={object:new Worker(k),pending:0,requests:{}};return j.object.onmessage=function(S){var T=S.data;j.pending-=T.count,j.requests[T.id][T.action](T.value),delete j.requests[T.id]},j}function w(k){for(var j="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(c(a))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+d.toString()+N.toString(),S=new Blob([j],{type:"text/javascript"}),T=URL.createObjectURL(S),D=0;D<k;++D)m[D]=y(T);URL.revokeObjectURL(T)}function C(k,j,S,T,D){for(var E=m[0],I=1;I<m.length;++I)m[I].pending<E.pending&&(E=m[I]);return new Promise(function(O,_){var M=new Uint8Array(S),R=b++;E.pending+=k,E.requests[R]={resolve:O,reject:_},E.object.postMessage({id:R,count:k,size:j,source:M,mode:T,filter:D},[M.buffer])})}function N(k){i.then(function(){var j=k.data;try{var S=new Uint8Array(j.count*j.size);d(r.exports[j.mode],S,j.count,j.size,j.source,r.exports[j.filter]),self.postMessage({id:j.id,count:j.count,action:"resolve",value:S},[S.buffer])}catch(T){self.postMessage({id:j.id,count:j.count,action:"reject",value:T})}})}return{ready:i,supported:!0,useWorkers:function(k){w(k)},decodeVertexBuffer:function(k,j,S,T,D){d(r.exports.meshopt_decodeVertexBuffer,k,j,S,T,r.exports[f[D]])},decodeIndexBuffer:function(k,j,S,T){d(r.exports.meshopt_decodeIndexBuffer,k,j,S,T)},decodeIndexSequence:function(k,j,S,T){d(r.exports.meshopt_decodeIndexSequence,k,j,S,T)},decodeGltfBuffer:function(k,j,S,T,D,E){d(r.exports[h[D]],k,j,S,T,r.exports[f[E]])},decodeGltfBufferAsync:function(k,j,S,T,D){return m.length>0?C(k,j,S,h[T],f[D]):i.then(function(){var E=new Uint8Array(k*j);return d(r.exports[h[T]],E,k,j,S,r.exports[f[D]]),E})}}})();const v2={idle:"idle",working:"walk",waiting:"sit",waiting_permission:"idle",error:"emote-no",offline:"static",orphaned:"idle"},jS={idle:4915102,working:4890367,waiting:16752202,waiting_permission:16763904,error:16730698,offline:8947848,orphaned:16752202};function g1({agentClass:t,modelFile:e,customModelFile:n,customModelUrl:s,modelScale:a=1,modelOffset:r,idleAnimation:i,status:c="idle",width:d=150,height:f=200}){const h=x.useRef(null),m=x.useRef(null),b=x.useRef(null),y=x.useRef(null),w=x.useRef(null),C=x.useRef(null),N=x.useRef(new Map),k=x.useRef(null),j=x.useRef(null),S=x.useRef(0),T=x.useRef(new lM),[D,E]=x.useState(!1),[I,O]=x.useState(!1),_=x.useRef(!1),M=x.useRef(0),R=x.useRef(new wo),z=x.useRef(!1),$=x.useRef({x:0,y:0}),W=x.useRef({x:0,y:0});x.useEffect(()=>{const F=h.current;if(!F)return;O(!1);const H=new cM;H.background=new Hr(1710628),b.current=H;const V=new uj(45,d/f,.1,100);V.position.set(0,1.2,1.4),V.lookAt(0,.4,0),y.current=V;let G;try{G=new uM({antialias:!0,alpha:!0})}catch{console.warn("[ModelPreview] WebGL context creation failed — too many active contexts"),O(!0);return}G.setSize(d,f),G.setPixelRatio(Math.min(window.devicePixelRatio,2)),G.setClearColor(1710628,1),F.appendChild(G.domElement),m.current=G;const B=new dM(16777215,1);H.add(B);const K=new Lb(16777215,1.5);K.position.set(2,3,2),H.add(K);const ne=new Lb(4890367,.6);ne.position.set(-2,1,-1),H.add(ne);const q=new fM(1,32),xe=new Nx({color:2763322,roughness:.8}),Ae=new Il(q,xe);Ae.rotation.x=-Math.PI/2,Ae.position.y=0,H.add(Ae);const Z=new pM(.35,.42,32),ce=new Fl({color:jS.idle,side:lj,transparent:!0,opacity:.8}),me=new Il(Z,ce);me.rotation.x=-Math.PI/2,me.position.y=.01,H.add(me),j.current=me,E(!0);const ee=ge=>{z.current=!0,$.current={x:ge.clientX,y:ge.clientY},F.style.cursor="grabbing"},re=ge=>{if(!z.current||!w.current)return;const Te=ge.clientX-$.current.x,qe=ge.clientY-$.current.y;W.current.y+=Te*.01,W.current.x+=qe*.01,W.current.x=Math.max(-Math.PI/4,Math.min(Math.PI/4,W.current.x)),w.current.rotation.y=W.current.y,w.current.rotation.x=W.current.x,$.current={x:ge.clientX,y:ge.clientY}},We=()=>{z.current=!1,F.style.cursor="grab"},ze=()=>{z.current=!1,F.style.cursor="grab"};F.addEventListener("mousedown",ee),window.addEventListener("mousemove",re),window.addEventListener("mouseup",We),F.addEventListener("mouseleave",ze),F.style.cursor="grab";const Pe=()=>{S.current=requestAnimationFrame(Pe);const ge=T.current.getDelta();if(C.current)C.current.update(ge);else if(w.current&&!_.current){M.current+=ge;const Te=M.current,he=Math.sin(Te*1.5)*.02,de=Math.sin(Te*.8)*.01;w.current.position.set(R.current.x+de,R.current.y+he,R.current.z)}m.current&&b.current&&y.current&&m.current.render(b.current,y.current)};return Pe(),()=>{if(cancelAnimationFrame(S.current),F.removeEventListener("mousedown",ee),window.removeEventListener("mousemove",re),window.removeEventListener("mouseup",We),F.removeEventListener("mouseleave",ze),w.current&&b.current&&(b.current.remove(w.current),w.current.traverse(ge=>{var Te,qe;ge instanceof Il&&((Te=ge.geometry)==null||Te.dispose(),Array.isArray(ge.material)?ge.material.forEach(it=>{it.map&&it.map.dispose(),it.dispose()}):ge.material&&(ge.material.map&&((qe=ge.material.map)==null||qe.dispose()),ge.material.dispose()))}),w.current=null),j.current&&b.current&&(b.current.remove(j.current),j.current.geometry.dispose(),j.current.material.dispose(),j.current=null),b.current&&(b.current.traverse(ge=>{var Te;ge instanceof Il&&((Te=ge.geometry)==null||Te.dispose(),ge.material instanceof Jf&&ge.material.dispose())}),b.current.clear()),C.current=null,k.current=null,N.current.clear(),m.current){try{const Te=m.current.getContext().getExtension("WEBGL_lose_context");Te&&Te.loseContext()}catch{}m.current.dispose(),F.contains(m.current.domElement)&&F.removeChild(m.current.domElement),m.current=null}b.current=null,y.current=null,E(!1)}},[d,f]),x.useEffect(()=>{if(!D||!b.current)return;const F=new IL,H=new b2;H.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.7/"),F.setDRACOLoader(H),F.setMeshoptDecoder(y2);let V=null;const G=B=>{w.current&&b.current&&(b.current.remove(w.current),w.current=null,C.current=null,k.current=null);const K=B.scene;K.scale.setScalar(a);const ne=(r==null?void 0:r.x)??0,q=(r==null?void 0:r.y)??0,xe=(r==null?void 0:r.z)??0;if(K.position.set(ne,xe,q),K.visible=!0,W.current={x:0,y:0},K.rotation.set(0,0,0),K.traverse(Ae=>{if(Ae instanceof Il&&(Ae.castShadow=!0,Ae.receiveShadow=!0,Ae.material)){const Z=Ae.material;Z.map&&(Z.map.colorSpace=Br)}}),b.current)if(b.current.add(K),w.current=K,R.current.copy(K.position),B.animations.length>0){_.current=!0;const Ae=new hM(K);C.current=Ae,N.current.clear();for(const Z of B.animations)N.current.set(Z.name.toLowerCase(),Z);if(i!==""){const Z=i?N.current.get(i.toLowerCase())||B.animations[0]:N.current.get("idle")||B.animations[0];if(Z){const ce=Ae.clipAction(Z);ce.reset().play(),k.current=ce}}}else _.current=!1,C.current=null,N.current.clear()};if(n)V=URL.createObjectURL(n),console.log("[ModelPreview] Loading custom model from file:",n.name,"blob URL:",V),F.load(V,B=>{console.log("[ModelPreview] Successfully loaded custom model file, animations:",B.animations.length),G(B)},void 0,B=>{console.error("[ModelPreview] Failed to load custom model file:",B)});else if(s){const B=Yb(s);console.log("[ModelPreview] Loading custom model from URL:",s),F.load(B,K=>{console.log("[ModelPreview] Successfully loaded custom model URL, animations:",K.animations.length),G(K)},void 0,K=>{console.error("[ModelPreview] Failed to load custom model URL:",s,K)})}else{const B=e||(t?TL[t]:void 0)||"character-male-a.glb";F.load(`/assets/characters/${B}`,G,void 0,K=>{console.error("[ModelPreview] Failed to load model:",B,K)})}return()=>{V&&URL.revokeObjectURL(V),H.dispose()}},[t,e,n,s,a,r,D]);const L=F=>{if(!C.current)return;const H=v2[F],V=N.current.get(H);if(!V){const B=N.current.get("idle");if(B){const K=C.current.clipAction(B);K.reset().play(),k.current=K}return}const G=C.current.clipAction(V);F==="working"?G.timeScale=1.5:F==="error"&&(G.setLoop(mM,1),G.clampWhenFinished=!0),k.current&&k.current!==G?(k.current.fadeOut(.3),G.reset().fadeIn(.3).play()):G.reset().play(),k.current=G};return x.useEffect(()=>{if(D){if(j.current){const F=j.current.material;F.color.setHex(jS[c]),c==="working"?F.opacity=.6+Math.sin(Date.now()*.005)*.4:F.opacity=.8}L(c)}},[c,D]),x.useEffect(()=>{if(!D||!C.current||c!=="idle")return;if(i===""){k.current&&(k.current.stop(),k.current=null);return}const F=i?i.toLowerCase():"idle",H=N.current.get(F);if(H){const V=C.current.clipAction(H);k.current&&k.current!==V?(k.current.fadeOut(.3),V.reset().fadeIn(.3).play()):V.reset().play(),k.current=V}else k.current&&(k.current.stop(),k.current=null)},[i,D,c]),I?o.jsx("div",{className:"model-preview",style:{width:d,height:f,borderRadius:8,overflow:"hidden",background:"#1a1a24",display:"flex",alignItems:"center",justifyContent:"center",color:"#666",fontSize:12,textAlign:"center",padding:8},children:"3D preview unavailable"}):o.jsx("div",{ref:h,className:"model-preview",style:{width:d,height:f,borderRadius:8,overflow:"hidden",background:"#1a1a24"}})}function w2({value:t,onChange:e,onSubmit:n,placeholder:s="/path/to/folder",className:a="",directoriesOnly:r=!0,autoFocus:i=!1,hasError:c=!1,disabled:d=!1}){const[f,h]=x.useState([]),[m,b]=x.useState(-1),[y,w]=x.useState(!1),[C,N]=x.useState(!1),k=x.useRef(null),j=x.useRef(null),S=x.useRef(null),T=x.useCallback(async R=>{if(!R){h([]);return}N(!0);try{const z=new URLSearchParams({path:R,dirs:r?"true":"false",limit:"15"}),$=await Bt(Rt(`/api/files/autocomplete?${z}`));if($.ok){const W=await $.json();h(W.suggestions||[]),b(-1)}}catch(z){console.error("Failed to fetch path suggestions:",z)}finally{N(!1)}},[r]);x.useEffect(()=>(S.current&&clearTimeout(S.current),t&&y?S.current=setTimeout(()=>{T(t)},150):h([]),()=>{S.current&&clearTimeout(S.current)}),[t,y,T]);const D=R=>{e(R.target.value),w(!0)},E=x.useCallback(R=>{var $;const z=R.isDirectory?R.path+"/":R.path;e(z),w(R.isDirectory),b(-1),($=k.current)==null||$.focus(),R.isDirectory&&T(z)},[e,T]),I=R=>{if(!y||f.length===0){R.key==="Enter"&&n&&(R.preventDefault(),n()),R.key==="Escape"&&w(!1);return}switch(R.key){case"ArrowDown":R.preventDefault(),b(z=>z<f.length-1?z+1:z);break;case"ArrowUp":R.preventDefault(),b(z=>z>0?z-1:-1);break;case"Tab":if(R.preventDefault(),f.length>0){const z=m>=0?m:0;E(f[z])}break;case"Enter":R.preventDefault(),m>=0&&f[m]?E(f[m]):n&&(w(!1),n());break;case"Escape":R.preventDefault(),w(!1),b(-1);break}},O=()=>{w(!0),t&&T(t)},_=()=>{setTimeout(()=>{w(!1),b(-1)},200)};x.useEffect(()=>{if(m>=0&&j.current){const z=j.current.querySelectorAll(".folder-input-suggestion")[m];z&&z.scrollIntoView({block:"nearest"})}},[m]);const M=["folder-input",a,c?"error":""].filter(Boolean).join(" ");return o.jsxs("div",{className:"folder-input-container",children:[o.jsx("input",{ref:k,type:"text",className:M,value:t,onChange:D,onKeyDown:I,onFocus:O,onBlur:_,placeholder:s,autoFocus:i,disabled:d,autoComplete:"off",spellCheck:!1}),y&&(f.length>0||C)&&o.jsx("div",{ref:j,className:"folder-input-suggestions",children:C&&f.length===0?o.jsx("div",{className:"folder-input-loading",children:"Loading..."}):f.map((R,z)=>o.jsxs("div",{className:`folder-input-suggestion ${z===m?"selected":""}`,onClick:()=>E(R),onMouseEnter:()=>b(z),children:[o.jsx("span",{className:"folder-input-suggestion-icon",children:R.isDirectory?"📁":"📄"}),o.jsx("span",{className:"folder-input-suggestion-name",children:R.name}),R.isDirectory&&o.jsx("span",{className:"folder-input-suggestion-hint",children:"/"})]},R.path))})]})}function b1({agent:t,isOpen:e,onClose:n}){const{t:s}=dt(["terminal","common","tools"]),a=ZO(),r=dr(),[i,c]=x.useState(t.name),[d,f]=x.useState(t.class),[h,m]=x.useState(t.permissionMode),[b,y]=x.useState(t.provider||"claude"),[w,C]=x.useState(t.codexConfig||{fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[N,k]=x.useState(t.model||"sonnet"),[j,S]=x.useState(t.codexModel||"gpt-5.3-codex"),[T,D]=x.useState(t.useChrome||!1),[E,I]=x.useState(t.cwd),[O,_]=x.useState(new Set),[M,R]=x.useState(""),[z,$]=x.useState(!1),[W,L]=x.useState("");x.useMemo(()=>a.filter(ee=>ee.enabled&&(ee.assignedAgentIds.includes(t.id)||ee.assignedAgentClasses.includes(t.class))),[a,t.id,t.class]),x.useEffect(()=>{const ee=a.filter(re=>re.assignedAgentIds.includes(t.id)).map(re=>re.id);_(new Set(ee))},[a,t.id]),x.useEffect(()=>{if(e){c(t.name),f(t.class),m(t.permissionMode),y(t.provider||"claude"),C(t.codexConfig||{fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),k(t.model||"sonnet"),S(t.codexModel||"gpt-5.3-codex"),D(t.useChrome||!1),I(t.cwd);const ee=a.filter(re=>re.assignedAgentIds.includes(t.id)).map(re=>re.id);_(new Set(ee))}},[e,t,a]);const F=x.useMemo(()=>a.filter(ee=>ee.enabled),[a]),H=x.useMemo(()=>{if(!M.trim())return F;const ee=M.toLowerCase();return F.filter(re=>re.name.toLowerCase().includes(ee)||re.description.toLowerCase().includes(ee)||re.slug.toLowerCase().includes(ee))},[F,M]),V=x.useMemo(()=>F.filter(ee=>ee.assignedAgentClasses.includes(d)),[F,d]),G=x.useCallback(ee=>{_(re=>{const We=new Set(re);return We.has(ee)?We.delete(ee):We.add(ee),We})},[]),B=x.useMemo(()=>{const ee=r.find(re=>re.id===d);if(ee!=null&&ee.model)return ee.model},[r,d]),K=x.useMemo(()=>{const ee=r.find(re=>re.id===d);if(ee!=null&&ee.customModelPath)return Rt(`/api/custom-models/${ee.id}`)},[r,d]),ne=x.useMemo(()=>{const ee=r.find(re=>re.id===d);return ee==null?void 0:ee.modelScale},[r,d]),q=x.useMemo(()=>r.find(ee=>ee.id===d),[r,d]);x.useEffect(()=>{q&&(L(q.instructions||""),$(!1))},[q==null?void 0:q.id]);const xe=x.useMemo(()=>r.find(re=>re.id===d)?"scout":d,[r,d]),Ae=x.useMemo(()=>{const ee=i.trim();if(ee&&ee!==t.name||d!==t.class||h!==t.permissionMode||b!==(t.provider||"claude")||b==="claude"&&N!==(t.model||"sonnet")||b==="codex"&&j!==(t.codexModel||"gpt-5.3-codex")||b==="codex"&&JSON.stringify(w||{})!==JSON.stringify(t.codexConfig||{})||T!==(t.useChrome||!1)||E!==t.cwd)return!0;const re=a.filter(ze=>ze.assignedAgentIds.includes(t.id)).map(ze=>ze.id).sort().join(","),We=Array.from(O).sort().join(",");return re!==We},[i,d,h,b,N,j,w,T,E,O,t,a]),Z=()=>{const ee=i.trim(),re={};ee&&ee!==t.name&&U.renameAgent(t.id,ee),d!==t.class&&(re.class=d),h!==t.permissionMode&&(re.permissionMode=h),b!==(t.provider||"claude")&&(re.provider=b),b==="codex"&&JSON.stringify(w||{})!==JSON.stringify(t.codexConfig||{})&&(re.codexConfig=w),b==="codex"&&j!==(t.codexModel||"gpt-5.3-codex")&&(re.codexModel=j),b==="claude"&&N!==(t.model||"sonnet")&&(re.model=N),T!==(t.useChrome||!1)&&(re.useChrome=T),E!==t.cwd&&(re.cwd=E);const We=a.filter(Pe=>Pe.assignedAgentIds.includes(t.id)).map(Pe=>Pe.id).sort().join(","),ze=Array.from(O).sort().join(",");We!==ze&&(re.skillIds=Array.from(O)),Object.keys(re).length>0&&U.updateAgentProperties(t.id,re),n()},{handleMouseDown:ce,handleClick:me}=Ta(n);return e?o.jsx("div",{className:"modal-overlay visible",onMouseDown:ce,onClick:me,children:o.jsxs("div",{className:"modal agent-edit-modal",children:[o.jsxs("div",{className:"modal-header",children:[s("terminal:spawn.editAgentTitle"),": ",i.trim()||t.name]}),o.jsxs("div",{className:"modal-body spawn-modal-body",children:[o.jsxs("div",{className:"spawn-top-section",children:[o.jsx("div",{className:"spawn-preview-compact",children:o.jsx(g1,{agentClass:xe,modelFile:B,customModelUrl:K,modelScale:ne,width:100,height:120})}),o.jsxs("div",{className:"spawn-class-section",children:[o.jsx("div",{className:"spawn-class-label",children:s("terminal:spawn.agentClass")}),o.jsxs("div",{className:"class-selector-inline",children:[r.map(ee=>o.jsxs("button",{className:`class-chip ${d===ee.id?"selected":""}`,onClick:()=>f(ee.id),title:ee.description,children:[o.jsx("span",{className:"class-chip-icon",children:ee.icon}),o.jsx("span",{className:"class-chip-name",children:ee.name})]},ee.id)),Object.entries(_o).filter(([ee])=>ee!=="boss").map(([ee,re])=>o.jsxs("button",{className:`class-chip ${d===ee?"selected":""}`,onClick:()=>f(ee),title:re.description,children:[o.jsx("span",{className:"class-chip-icon",children:re.icon}),o.jsx("span",{className:"class-chip-name",children:ee.charAt(0).toUpperCase()+ee.slice(1)})]},ee))]})]})]}),q&&o.jsxs("div",{className:"custom-class-notice",children:[o.jsxs("div",{className:"custom-class-notice-header",onClick:()=>$(!z),style:{cursor:"pointer"},children:[o.jsx("span",{children:"📋"}),o.jsx("span",{children:q.instructions?s("terminal:spawn.hasCustomInstructions"):"Add custom instructions"}),o.jsx("span",{style:{marginLeft:"auto",fontSize:11,opacity:.6},children:z?"▲":"▼"})]}),!z&&q.instructions&&o.jsx("div",{className:"custom-class-notice-info",children:s("terminal:spawn.instructionsInjected",{count:q.instructions.length})}),z&&o.jsxs("div",{className:"custom-class-instructions-editor",children:[o.jsx("textarea",{value:W,onChange:ee=>L(ee.target.value),placeholder:"CLAUDE.md instructions for this agent class...",rows:6,style:{width:"100%",resize:"vertical",fontFamily:"monospace",fontSize:12,background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:4,color:"var(--text-primary)",padding:"6px 8px",outline:"none"}}),o.jsxs("div",{style:{display:"flex",gap:6,marginTop:4,justifyContent:"flex-end"},children:[o.jsx("button",{onClick:()=>{U.updateCustomAgentClass(q.id,{instructions:W}),$(!1)},style:{padding:"2px 10px",borderRadius:4,fontSize:11,cursor:"pointer",background:"rgba(0,200,200,0.2)",color:"var(--accent-cyan)",border:"1px solid rgba(0,200,200,0.3)"},children:"Save"}),o.jsx("button",{onClick:()=>{L(q.instructions||""),$(!1)},style:{padding:"2px 10px",borderRadius:4,fontSize:11,cursor:"pointer",background:"transparent",color:"var(--text-secondary)",border:"1px solid rgba(255,255,255,0.1)"},children:"Cancel"})]}),o.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:"These instructions are injected as system prompt for all agents of this class."})]})]}),o.jsxs("div",{className:"spawn-form-section",children:[o.jsx("div",{className:"spawn-form-row",children:o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("common:labels.name")}),o.jsx("input",{type:"text",className:"spawn-input",value:i,onChange:ee=>c(ee.target.value),placeholder:s("terminal:spawn.agentNamePlaceholder")})]})}),o.jsxs("div",{className:"spawn-form-row",children:[o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("common:labels.runtime")}),o.jsxs("div",{className:"spawn-select-row",children:[o.jsxs("button",{className:`spawn-select-btn ${b==="claude"?"selected":""}`,onClick:()=>y("claude"),children:[o.jsx("span",{children:"🧠"}),o.jsx("span",{children:"Claude"})]}),o.jsxs("button",{className:`spawn-select-btn ${b==="codex"?"selected":""}`,onClick:()=>y("codex"),children:[o.jsx("span",{children:"⚙️"}),o.jsx("span",{children:"Codex"})]})]})]}),o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("common:labels.permissions")}),o.jsx("div",{className:"spawn-select-row",children:Object.keys(Mu).map(ee=>o.jsxs("button",{className:`spawn-select-btn ${h===ee?"selected":""}`,onClick:()=>m(ee),title:Mu[ee].description,children:[o.jsx("span",{children:ee==="bypass"?"⚡":"🔐"}),o.jsx("span",{children:Mu[ee].label})]},ee))})]})]}),o.jsx("div",{className:"spawn-form-row",children:o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("common:labels.model")}),b==="claude"?o.jsx("div",{className:"spawn-select-row",children:Object.keys(Rf).map(ee=>o.jsxs("button",{className:`spawn-select-btn ${N===ee?"selected":""}`,onClick:()=>k(ee),title:Rf[ee].description,children:[o.jsx("span",{children:Rf[ee].icon}),o.jsx("span",{children:Rf[ee].label})]},ee))}):b==="codex"?o.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(Df).map(ee=>o.jsxs("button",{className:`spawn-select-btn ${j===ee?"selected":""}`,onClick:()=>S(ee),title:Df[ee].description,children:[o.jsx("span",{children:Df[ee].icon}),o.jsx("span",{children:Df[ee].label})]},ee))}):o.jsx("div",{className:"spawn-inline-hint",children:s("terminal:spawn.codex.configuration")})]})}),b==="codex"&&o.jsx("div",{className:"spawn-form-row",children:o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("terminal:spawn.codex.config")}),o.jsxs("div",{className:"spawn-options-row",style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("label",{className:"spawn-checkbox",children:[o.jsx("input",{type:"checkbox",checked:w.fullAuto!==!1,onChange:ee=>C(re=>({...re,fullAuto:ee.target.checked}))}),o.jsx("span",{children:s("terminal:spawn.codex.useFullAuto")})]}),o.jsxs("label",{className:"spawn-checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!w.search,onChange:ee=>C(re=>({...re,search:ee.target.checked}))}),o.jsx("span",{children:s("terminal:spawn.codex.enableSearch")})]}),w.fullAuto===!1&&o.jsxs(o.Fragment,{children:[o.jsxs("select",{className:"spawn-input",value:w.sandbox||"workspace-write",onChange:ee=>C(re=>({...re,sandbox:ee.target.value})),children:[o.jsx("option",{value:"read-only",children:s("terminal:spawn.codex.sandboxReadOnly")}),o.jsx("option",{value:"workspace-write",children:s("terminal:spawn.codex.sandboxWorkspaceWrite")}),o.jsx("option",{value:"danger-full-access",children:s("terminal:spawn.codex.sandboxDangerFullAccess")})]}),o.jsxs("select",{className:"spawn-input",value:w.approvalMode||"on-request",onChange:ee=>C(re=>({...re,approvalMode:ee.target.value})),children:[o.jsx("option",{value:"untrusted",children:s("terminal:spawn.codex.approvalsUntrusted")}),o.jsx("option",{value:"on-failure",children:s("terminal:spawn.codex.approvalsOnFailure")}),o.jsx("option",{value:"on-request",children:s("terminal:spawn.codex.approvalsOnRequest")}),o.jsx("option",{value:"never",children:s("terminal:spawn.codex.approvalsNever")})]})]}),o.jsx("input",{type:"text",className:"spawn-input",placeholder:s("terminal:spawn.codex.profileOptional"),value:w.profile||"",onChange:ee=>C(re=>({...re,profile:ee.target.value||void 0}))})]})]})}),b==="claude"&&N!==(t.model||"sonnet")&&o.jsx("div",{className:"model-change-notice",children:s("terminal:spawn.contextPreserved")}),o.jsx("div",{className:"spawn-form-row spawn-options-row",children:o.jsxs("label",{className:"spawn-checkbox",children:[o.jsx("input",{type:"checkbox",checked:T,onChange:ee=>D(ee.target.checked),disabled:b!=="claude"}),o.jsx("span",{children:s("terminal:spawn.chromeBrowser")})]})}),o.jsx("div",{className:"spawn-form-row",children:o.jsxs("div",{className:"spawn-field",children:[o.jsx("label",{className:"spawn-label",children:s("terminal:spawn.workingDir")}),o.jsx(w2,{value:E,onChange:I,placeholder:s("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",directoriesOnly:!0})]})}),E!==t.cwd&&o.jsx("div",{className:"model-change-notice warning",children:s("terminal:spawn.newSessionWarning")}),o.jsxs("div",{className:"spawn-skills-section",children:[o.jsxs("label",{className:"spawn-label",children:[s("terminal:spawn.skills")," ",o.jsxs("span",{className:"spawn-label-hint",children:["(",s("terminal:spawn.clickToToggle"),")"]})]}),F.length>6&&o.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:s("terminal:spawn.filterSkills"),value:M,onChange:ee=>R(ee.target.value)}),o.jsx("div",{className:"skills-chips-compact",children:F.length===0?o.jsx("div",{className:"skills-empty",children:s("terminal:spawn.noEnabledSkills")}):H.length===0?o.jsx("div",{className:"skills-empty",children:s("terminal:spawn.noSkillsMatch",{query:M})}):H.map(ee=>{const re=V.includes(ee),ze=O.has(ee.id)||re;return o.jsxs("button",{className:`skill-chip ${ze?"selected":""} ${re?"class-based":""}`,onClick:()=>!re&&G(ee.id),title:re?s("terminal:spawn.assignedViaClass"):ee.name,children:[ze&&o.jsx("span",{className:"skill-check",children:"✓"}),o.jsx("span",{className:"skill-chip-name",children:ee.name}),ee.builtin&&o.jsx("span",{className:"skill-chip-badge builtin",children:"TC"}),re&&o.jsx("span",{className:"skill-chip-badge",children:"class"})]},ee.id)})})]})]})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:n,children:s("common:buttons.cancel")}),o.jsx("button",{className:"btn btn-primary",onClick:Z,disabled:!Ae,children:s("common:buttons2.saveChanges")})]})]})}):null}const k2=Object.freeze(Object.defineProperty({__proto__:null,AgentEditModal:b1},Symbol.toStringTag,{value:"Module"}));var ac=ej();const S2=Xu(ac);function pr({children:t}){return typeof document>"u"?null:ac.createPortal(t,document.body)}function lu(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function NS(t){return`${t.toFixed(1)}%`}function C2(t){return t>=80?"#ff4a4a":t>=60?"#ff9e4a":t>=40?"#ffd700":"#4aff9e"}const A2={systemPrompt:"#4a9eff",systemTools:"#9e4aff",messages:"#4aff9e",freeSpace:"rgba(255,255,255,0.1)",autocompactBuffer:"#ff9e4a"},j2={systemPrompt:"terminal:context.systemPrompt",systemTools:"terminal:context.systemTools",messages:"terminal:context.messagesCategory",freeSpace:"terminal:context.freeSpace",autocompactBuffer:"terminal:context.autocompactBuffer"},N2={systemPrompt:"terminal:context.systemPromptDesc",systemTools:"terminal:context.systemToolsDesc",messages:"terminal:context.messagesDesc",freeSpace:"terminal:context.freeSpaceDesc",autocompactBuffer:"terminal:context.autocompactBufferDesc"};function x1({agent:t,isOpen:e,onClose:n,onRefresh:s}){const{t:a}=dt(["terminal","common"]),r=t.contextStats,[i,c]=x.useState(!1),d=()=>{s&&!i&&(c(!0),s(),setTimeout(()=>c(!1),3e3))},f=["systemPrompt","systemTools","messages","autocompactBuffer","freeSpace"],h=x.useMemo(()=>r?f.map(w=>({key:w,...r.categories[w],label:a(j2[w]),description:a(N2[w]),color:A2[w]})):[],[r]),m=x.useMemo(()=>h.filter(w=>w.key!=="freeSpace"),[h]),{handleMouseDown:b,handleClick:y}=Ta(n);return e?o.jsx(pr,{children:o.jsx("div",{className:"modal-overlay visible",onMouseDown:b,onClick:y,children:o.jsxs("div",{className:"modal context-view-modal",style:{maxWidth:"520px"},children:[o.jsxs("div",{className:"modal-header",style:{display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx("span",{style:{flex:1},children:a("terminal:context.contextWindow",{name:t.name})}),s&&o.jsxs("button",{className:"btn btn-primary",onClick:d,disabled:i||t.status!=="idle",style:{padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"},title:t.status!=="idle"?a("terminal:context.agentMustBeIdle"):a("terminal:context.fetchContextStats"),children:[o.jsx("span",{style:{display:"inline-block",animation:i?"spin 1s linear infinite":"none"},children:i?"⟳":"↻"}),a(i?"common:status.loading":"common:buttons.refresh")]})]}),o.jsx("div",{className:"modal-body",style:{padding:"16px"},children:r?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px",padding:"8px 12px",background:"var(--bg-secondary)",borderRadius:"6px"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:a("terminal:context.model")}),o.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:r.model})]}),o.jsxs("div",{style:{textAlign:"right"},children:[o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:a("terminal:context.contextWindowLabel")}),o.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:lu(r.contextWindow)})]})]}),o.jsxs("div",{style:{marginBottom:"24px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px",fontSize:"13px"},children:[o.jsx("span",{children:a("terminal:context.contextUsage")}),o.jsxs("span",{style:{color:C2(r.usedPercent)},children:[lu(r.totalTokens)," / ",lu(r.contextWindow)," (",r.usedPercent,"%)"]})]}),o.jsx("div",{style:{height:"28px",background:"var(--bg-tertiary)",borderRadius:"6px",overflow:"hidden",display:"flex"},children:m.map(w=>w.percent>0&&o.jsx("div",{style:{width:`${w.percent}%`,background:w.color,height:"100%",minWidth:w.percent>.5?"2px":"0",transition:"width 0.3s ease"},title:`${w.label}: ${lu(w.tokens)} (${NS(w.percent)})`},w.key))})]}),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px",textTransform:"uppercase",letterSpacing:"0.5px"},children:a("terminal:context.tokenBreakdown")}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:h.map(w=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",background:w.key==="freeSpace"?"transparent":"var(--bg-secondary)",borderRadius:"6px",borderLeft:w.key==="freeSpace"?"3px dashed rgba(255,255,255,0.2)":`3px solid ${w.color}`,opacity:w.key==="freeSpace"?.7:1},children:[o.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"3px",background:w.color,flexShrink:0,border:w.key==="freeSpace"?"1px dashed rgba(255,255,255,0.3)":"none"}}),o.jsxs("div",{style:{flex:1},children:[o.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:w.label}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:w.description})]}),o.jsxs("div",{style:{textAlign:"right"},children:[o.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:lu(w.tokens)}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:NS(w.percent)})]})]},w.key))})]}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",textAlign:"center"},children:a("terminal:context.lastUpdated",{time:new Date(r.lastUpdated).toLocaleTimeString()})})]}):o.jsxs("div",{style:{textAlign:"center",color:"var(--text-secondary)",padding:"32px"},children:[o.jsx("div",{style:{fontSize:"48px",marginBottom:"16px",opacity:.5},children:"📊"}),o.jsx("div",{style:{fontSize:"14px",marginBottom:"8px"},children:a("terminal:context.noContextData")}),o.jsx("div",{style:{fontSize:"12px",marginBottom:"20px",opacity:.7},children:a("terminal:context.clickRefresh")}),s&&o.jsxs("button",{className:"btn btn-primary",onClick:d,disabled:i||t.status!=="idle",style:{padding:"10px 24px",fontSize:"14px",display:"inline-flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{style:{display:"inline-block",animation:i?"spin 1s linear infinite":"none"},children:i?"⟳":"↻"}),a(i?"terminal:context.fetchingStats":"terminal:context.fetchContextStats")]}),t.status!=="idle"&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",marginTop:"12px"},children:a("terminal:context.agentMustBeIdle")})]})}),o.jsx("div",{className:"modal-footer",style:{display:"flex",justifyContent:"flex-end",padding:"12px 16px",borderTop:"1px solid var(--border-color)"},children:o.jsx("button",{className:"btn btn-secondary",onClick:n,children:a("common:buttons.close")})})]})})}):null}const T2=x.memo(function({tokensUsed:e,createdAt:n}){const{t:s}=dt(["common"]);return o.jsxs("div",{className:"unit-stats",children:[o.jsxs("div",{className:"unit-stat",children:[o.jsx("div",{className:"unit-stat-label",children:s("labels.tokens")}),o.jsx("div",{className:"unit-stat-value",children:HD(e)})]}),o.jsxs("div",{className:"unit-stat",children:[o.jsx("div",{className:"unit-stat-label",children:s("labels.uptime")}),o.jsx("div",{className:"unit-stat-value",children:WD(n)})]})]})}),y1=x.memo(function({contextInfo:e,onClick:n}){const{t:s}=dt(["common"]),{remainingPercent:a,hasData:r}=e;return o.jsxs("div",{className:"unit-context unit-context-clickable",onClick:n,title:s(r?"unitPanel.remainingContext":"unitPanel.notRetrievedYet"),style:{cursor:"pointer"},children:[o.jsxs("div",{className:"unit-stat-label",style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx("span",{children:s("unitPanel.remainingContext")}),r?o.jsx("span",{style:{fontSize:"10px",opacity:.6},children:"📊"}):o.jsx("span",{style:{fontSize:"9px",color:"#ff9e4a",opacity:.8},title:s("unitPanel.notRetrievedYet"),children:"⚠️"})]}),r?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"unit-context-bar",children:o.jsx("div",{className:"unit-context-fill",style:{width:`${a}%`,background:p1(a)}})}),o.jsxs("span",{className:"unit-context-value",children:[Math.round(a),"%"]})]}):o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",fontStyle:"italic"},children:s("unitPanel.notRetrievedYet")})]})}),_2=x.memo(function({lastActivity:e}){const{t:n}=dt(["common"]);return o.jsxs("div",{className:"unit-idle-timer",title:n("unitPanel.timeSinceActivity"),style:{color:Tx(e)},children:["⏱ ",Ex(e)]})}),E2=x.memo(function({task:e}){const{t:n}=dt(["common"]);return o.jsxs("div",{className:"unit-task",children:[o.jsx("div",{className:"unit-stat-label",children:n("labels.task")}),o.jsx("div",{className:"unit-task-text",children:e})]})}),M2=x.memo(function({cwd:e}){const{t:n}=dt(["common"]);return o.jsxs("div",{className:"unit-cwd",children:[o.jsx("div",{className:"unit-stat-label",children:n("labels.cwd")}),o.jsx("div",{className:"unit-cwd-path",title:e,children:e})]})}),D2=x.memo(function({text:e,maxLength:n=150}){const{t:s}=dt(["common"]);return o.jsxs("div",{className:"unit-last-prompt",children:[o.jsx("div",{className:"unit-stat-label",children:s("unitPanel.lastPrompt")}),o.jsx("div",{className:"unit-last-prompt-text",children:e.length>n?e.slice(0,n)+"...":e})]})}),R2=x.memo(function({text:e,maxLength:n=200}){const{t:s}=dt(["common"]);return o.jsxs("div",{className:"unit-last-message",children:[o.jsx("div",{className:"unit-stat-label",children:s("unitPanel.lastResponse")}),o.jsx("div",{className:"unit-last-message-text",children:e.length>n?e.slice(0,n)+"...":e})]})});function O2({agent:t,onFocusAgent:e,onKillAgent:n,onCallSubordinates:s,onOpenAreaExplorer:a}){var ee,re;const{t:r}=dt(["common"]),i=Rs(),c=dr(),{showToast:d}=u1(),f=i.agents.get(t.id)||t,h=fr(f.class,c),m=c.find(We=>We.id===f.class),b=m==null?void 0:m.model,y=m!=null&&m.customModelPath?Rt(`/api/custom-models/${m.id}`):void 0,w=m==null?void 0:m.modelScale,[C,N]=x.useState(!1),[k,j]=x.useState(f.name),S=x.useRef(null),[,T]=x.useState(0),[D,E]=x.useState(!0),[I,O]=x.useState(!1),[_,M]=x.useState([]),[R,z]=x.useState(null),[$,W]=x.useState(!1),[L,F]=x.useState(!1),H=U.getAgentSupervisorHistory(f.id),V=U.isLoadingHistoryForAgent(f.id);x.useEffect(()=>{!U.hasHistoryBeenFetched(f.id)&&!V&&U.requestAgentSupervisorHistory(f.id)},[f.id,V]),x.useEffect(()=>{j(f.name)},[f.name]),x.useEffect(()=>{C&&S.current&&(S.current.focus(),S.current.select())},[C]),x.useEffect(()=>{if(f.status==="idle"){const We=setInterval(()=>{T(ze=>ze+1)},15e3);return()=>clearInterval(We)}},[f.status]),x.useEffect(()=>{f.permissionMode==="interactive"&&Bt(Rt("/api/remembered-patterns")).then(We=>We.json()).then(M).catch(We=>console.error("Failed to fetch remembered patterns:",We))},[f.permissionMode]);const G=x.useMemo(()=>Xp(f),[f.contextStats,f.contextUsed,f.contextLimit]),B=U.getAreaForAgent(f.id),K=i.agentOutputs.get(f.id)||[],ne=K.length>0?K[K.length-1]:null,q=i.lastPrompts.get(f.id),xe=async(We,ze)=>{try{(await Bt(Rt(`/api/remembered-patterns/${We}/${encodeURIComponent(ze)}`),{method:"DELETE"})).ok&&M(ge=>ge.filter(Te=>!(Te.tool===We&&Te.pattern===ze)))}catch(Pe){console.error("Failed to remove pattern:",Pe)}},Ae=async()=>{if(confirm(r("confirm.clearPatterns")))try{(await Bt(Rt("/api/remembered-patterns"),{method:"DELETE"})).ok&&M([])}catch(We){console.error("Failed to clear patterns:",We)}},Z=()=>{confirm(r("confirm.terminateAgent"))&&n(f.id)},ce=()=>{const We=k.trim();We&&We!==f.name?U.renameAgent(f.id,We):j(f.name),N(!1)},me=We=>{We.key==="Enter"?ce():We.key==="Escape"&&(j(f.name),N(!1))};return o.jsxs("div",{className:"unit-panel",children:[o.jsx("div",{className:"unit-model-preview",children:o.jsx(g1,{agentClass:f.class,modelFile:b,customModelUrl:y,modelScale:w,status:f.status,width:80,height:80})}),o.jsxs("div",{className:"unit-panel-header",children:[o.jsx("div",{className:"unit-class-icon",style:{background:`${h.color}20`},children:h.icon}),o.jsxs("div",{className:"unit-header-info",children:[C?o.jsx("input",{ref:S,type:"text",className:"unit-name-input",value:k,onChange:We=>j(We.target.value),onBlur:ce,onKeyDown:me}):o.jsx("div",{className:"unit-name unit-name-editable",onClick:()=>N(!0),title:r("unitPanel.clickToRename"),children:f.name}),o.jsxs("div",{className:"unit-status",children:[o.jsx("span",{style:{color:gp[f.status]||gp.default},children:f.status}),o.jsxs("span",{children:[" • ",f.class," • ",f.provider]})]}),f.status==="idle"&&f.lastActivity>0&&o.jsx(_2,{lastActivity:f.lastActivity})]}),o.jsxs("div",{className:"unit-header-actions",children:[o.jsx("button",{className:"unit-action-icon",onClick:()=>e(f.id),title:r("unitPanel.focusOnAgent"),children:"🎯"}),o.jsx("button",{className:"unit-action-icon",onClick:()=>W(!0),title:r("unitPanel.editProperties"),children:"✏️"}),(f.isBoss||f.class==="boss")&&f.subordinateIds&&f.subordinateIds.length>0&&o.jsx("button",{className:"unit-action-icon",onClick:()=>s==null?void 0:s(f.id),title:r("unitPanel.callSubordinates"),children:"📢"}),o.jsx("button",{className:"unit-action-icon",onClick:()=>z("collapse"),title:r("unitPanel.collapseContext"),disabled:f.status!=="idle",children:"📦"}),o.jsx("button",{className:"unit-action-icon warning",onClick:()=>z("clear"),title:r("unitPanel.clearContext"),children:"🧹"}),o.jsx("button",{className:"unit-action-icon danger",onClick:Z,title:r("unitPanel.killAgent"),children:"☠️"})]})]}),B&&o.jsxs("div",{className:"unit-area",children:[o.jsx("span",{className:"unit-area-dot",style:{background:B.color}}),o.jsx("span",{className:"unit-area-name",children:B.name})]}),q&&o.jsx(D2,{text:q.text}),ne&&o.jsx(R2,{text:ne.text}),o.jsx(T2,{tokensUsed:f.tokensUsed,createdAt:f.createdAt}),o.jsx(y1,{contextInfo:G,onClick:()=>F(!0)}),f.taskLabel&&o.jsxs("div",{className:"unit-task-label",children:[o.jsx("div",{className:"unit-stat-label",children:"📋 Task"}),o.jsx("div",{className:"unit-task-label-value",children:f.taskLabel})]}),f.currentTask&&o.jsx(E2,{task:f.currentTask}),o.jsx(M2,{cwd:f.cwd}),o.jsx(L2,{currentAgentId:f.id}),o.jsxs("div",{className:"unit-permission-mode",children:[o.jsx("div",{className:"unit-stat-label",children:r("unitPanel.permissions")}),o.jsxs("div",{className:"unit-permission-mode-value",title:(ee=Mu[f.permissionMode])==null?void 0:ee.description,children:[o.jsx("span",{className:"unit-permission-mode-icon",children:f.permissionMode==="bypass"?"⚡":"🔐"}),o.jsx("span",{className:"unit-permission-mode-label",children:((re=Mu[f.permissionMode])==null?void 0:re.label)||f.permissionMode})]})]}),f.permissionMode==="interactive"&&o.jsx(I2,{patterns:_,showPatterns:I,onToggle:()=>O(!I),onRemovePattern:xe,onClearAll:Ae}),f.sessionId?o.jsxs("div",{className:"unit-resume-cmd",children:[o.jsx("div",{className:"unit-stat-label",children:r("unitPanel.resumeSession")}),o.jsxs("div",{className:"unit-resume-cmd-text",title:r("unitPanel.clickToCopy"),onClick:async()=>{const We=f.provider==="codex"?`codex resume ${f.sessionId}`:`claude --resume ${f.sessionId}`;try{await navigator.clipboard.writeText(We),d("success",r("toast.copied"),r("toast.resumeCommandCopied"),2e3)}catch{d("error",r("toast.errorTitle"),r("toast.failedToCopy"),3e3)}},children:[f.provider==="codex"?"codex resume":"claude --resume"," ",f.sessionId]})]}):o.jsxs("div",{className:"unit-resume-cmd",children:[o.jsx("div",{className:"unit-stat-label",children:r("unitPanel.session")}),o.jsx("div",{className:"unit-new-session-indicator",children:r("unitPanel.newSession")})]}),o.jsxs("div",{className:"unit-supervisor-history",children:[o.jsxs("div",{className:"unit-supervisor-history-header",onClick:()=>E(!D),children:[o.jsx("div",{className:"unit-stat-label",children:r("unitPanel.supervisorHistory")}),o.jsxs("span",{className:"unit-supervisor-history-toggle",children:[H.length>0&&o.jsx("span",{className:"unit-supervisor-history-count",children:H.length}),D?"▼":"▶"]})]}),D&&o.jsx("div",{className:"unit-supervisor-history-list",children:V?o.jsx("div",{className:"unit-supervisor-history-loading",children:r("status.loading")}):H.length===0?o.jsx("div",{className:"unit-supervisor-history-empty",children:r("unitPanel.noSupervisorReports")}):H.slice(0,10).map((We,ze)=>o.jsx(v1,{entry:We,defaultExpanded:ze===0},We.id))})]}),(f.isBoss||f.class==="boss")&&o.jsx(B2,{agent:f}),f.bossId&&o.jsx(z2,{agentId:f.id,bossId:f.bossId}),f.class!=="boss"&&!f.isBoss&&!f.bossId&&o.jsx($2,{agentId:f.id}),R&&o.jsx(P2,{action:R,agentName:f.name,onClose:()=>z(null),onConfirm:()=>{R==="collapse"?U.collapseContext(f.id):U.clearContext(f.id),z(null)}}),o.jsx(b1,{agent:f,isOpen:$,onClose:()=>W(!1)}),o.jsx(x1,{agent:f,isOpen:L,onClose:()=>F(!1),onRefresh:()=>{U.refreshAgentContext(f.id)}})]})}const L2=x.memo(function({currentAgentId:e}){const{t:n}=dt(["common"]),s=Rs(),a=dr(),[r,i]=x.useState(!1),c=x.useMemo(()=>[...Array.from(s.agents.values()).filter(f=>f.id!==e)].sort((f,h)=>(h.lastActivity||0)-(f.lastActivity||0)),[s.agents,e]);return c.length===0?null:o.jsxs("div",{className:"unit-other-agents",children:[o.jsxs("div",{className:"unit-other-agents-header",onClick:()=>i(!r),children:[o.jsxs("div",{className:"unit-stat-label",children:[n("unitPanel.otherAgents")," (",c.length,")"]}),o.jsx("span",{className:"unit-other-agents-toggle",children:r?"▶":"▼"})]}),!r&&o.jsx("div",{className:"unit-other-agents-list",children:c.map(d=>{const f=fr(d.class,a);return o.jsxs("div",{className:`unit-other-agent-item ${d.status}`,onClick:()=>{U.selectAgent(d.id),U.setTerminalOpen(!0)},children:[o.jsx("span",{className:"unit-other-agent-icon",style:{background:`${f.color}20`},children:f.icon}),o.jsxs("div",{className:"unit-other-agent-info",children:[o.jsx("span",{className:"unit-other-agent-name",children:d.name}),d.taskLabel&&o.jsx("span",{className:"unit-other-agent-task",children:d.taskLabel})]}),o.jsx("div",{className:`agent-status-dot ${d.status}`})]},d.id)})})]})}),I2=x.memo(function({patterns:e,showPatterns:n,onToggle:s,onRemovePattern:a,onClearAll:r}){const{t:i}=dt(["common"]);return o.jsxs("div",{className:"unit-remembered-patterns",children:[o.jsxs("div",{className:"unit-remembered-patterns-header",onClick:s,children:[o.jsx("div",{className:"unit-stat-label",children:i("unitPanel.allowedPatterns")}),o.jsxs("span",{className:"unit-remembered-patterns-toggle",children:[e.length>0&&o.jsx("span",{className:"unit-remembered-patterns-count",children:e.length}),n?"▼":"▶"]})]}),n&&o.jsx("div",{className:"unit-remembered-patterns-list",children:e.length===0?o.jsx("div",{className:"unit-remembered-patterns-empty",children:i("unitPanel.noPatterns")}):o.jsxs(o.Fragment,{children:[e.map((c,d)=>o.jsxs("div",{className:"unit-remembered-pattern-item",children:[o.jsx("span",{className:"unit-pattern-tool",children:c.tool}),o.jsx("span",{className:"unit-pattern-desc",title:c.pattern,children:c.description}),o.jsx("button",{className:"unit-pattern-remove",onClick:()=>a(c.tool,c.pattern),title:i("unitPanel.removePattern"),children:"×"})]},d)),o.jsx("button",{className:"unit-patterns-clear-all",onClick:r,children:i("buttons.clearAll")})]})})]})}),P2=x.memo(function({action:e,agentName:n,onClose:s,onConfirm:a}){const{t:r}=dt(["common"]),{handleMouseDown:i,handleClick:c}=Ta(s);return o.jsx("div",{className:"modal-overlay visible",onMouseDown:i,onClick:c,children:o.jsxs("div",{className:"modal confirm-modal",children:[o.jsx("div",{className:"modal-header",children:r(e==="collapse"?"unitPanel.collapseContextTitle":"unitPanel.clearContextTitle")}),o.jsx("div",{className:"modal-body confirm-modal-body",children:e==="collapse"?o.jsxs(o.Fragment,{children:[o.jsx("p",{dangerouslySetInnerHTML:{__html:r("unitPanel.collapseContextMsg",{name:n})}}),o.jsx("p",{className:"confirm-modal-note",children:r("unitPanel.collapseContextNote")})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{dangerouslySetInnerHTML:{__html:r("unitPanel.clearContextMsg",{name:n})}}),o.jsx("p",{className:"confirm-modal-note",children:r("unitPanel.clearContextNote")})]})}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:s,children:r("buttons.cancel")}),o.jsx("button",{className:`btn ${e==="clear"?"btn-danger":"btn-primary"}`,onClick:a,autoFocus:!0,children:r(e==="collapse"?"unitPanel.collapseBtn":"unitPanel.clearContextBtn")})]})]})})}),v1=x.memo(function({entry:e,defaultExpanded:n=!1,agent:s,onAgentClick:a}){var k;const{t:r}=dt(["common"]),[i,c]=x.useState(n),d=Rs(),f=dr(),{analysis:h}=e,m=d.settings.hideCost,b=Tu(h.statusDescription,m),y=Tu(h.recentWorkSummary,m),w=(k=h.concerns)==null?void 0:k.map(j=>Tu(j,m)).filter(j=>j.length>0),C=s?fr(s.class,f):null,N=j=>{s&&a&&(j.stopPropagation(),a(s.id))};return o.jsxs("div",{className:"supervisor-history-item",children:[o.jsxs("div",{className:"supervisor-history-item-header",onClick:()=>c(!i),children:[o.jsx("span",{className:"supervisor-history-progress-dot",style:{background:zD[h.progress]||"#888"},title:h.progress}),o.jsxs("div",{className:"supervisor-history-item-content",children:[s&&C&&o.jsxs("div",{className:"supervisor-history-agent-line",onClick:N,children:[o.jsx("span",{className:"supervisor-history-agent-icon",children:C.icon}),o.jsx("span",{className:"supervisor-history-agent-name",children:s.name}),o.jsx("span",{className:"supervisor-history-time",children:wp(e.timestamp)})]}),o.jsx("div",{className:"supervisor-history-status",children:b})]}),!s&&o.jsx("span",{className:"supervisor-history-time",children:wp(e.timestamp)})]}),i&&o.jsxs("div",{className:"supervisor-history-item-details",children:[o.jsxs("div",{className:"supervisor-history-summary",children:[o.jsxs("strong",{children:[r("labels.summary"),":"]})," ",y]}),w&&w.length>0&&o.jsxs("div",{className:"supervisor-history-concerns",children:[o.jsxs("strong",{children:[r("labels.concerns"),":"]}),o.jsx("ul",{children:w.map((j,S)=>o.jsx("li",{children:j},S))})]})]})]})}),B2=x.memo(function({agent:e}){const{t:n}=dt(["common"]),s=Rs(),a=dr(),[r,i]=x.useState(!0),[c,d]=x.useState(!0),f=x.useMemo(()=>{const w=s.agents.get(e.id);return!w||!w.isBoss&&w.class!=="boss"||!w.subordinateIds?[]:w.subordinateIds.map(C=>s.agents.get(C)).filter(C=>C!==void 0)},[s.agents,e.id]),h=U.getDelegationHistory(e.id),m=s.pendingDelegation,b=(m==null?void 0:m.bossId)===e.id;x.useEffect(()=>{U.requestDelegationHistory(e.id)},[e.id]);const y=Qp.boss;return o.jsxs("div",{className:"boss-section",children:[o.jsxs("div",{className:"boss-header",children:[o.jsx("span",{className:"boss-crown-icon",style:{color:y.color},children:y.icon}),o.jsx("span",{className:"boss-title",children:n("unitPanel.bossAgent")})]}),o.jsxs("div",{className:"boss-subordinates",children:[o.jsxs("div",{className:"boss-subordinates-header",onClick:()=>i(!r),children:[o.jsxs("div",{className:"unit-stat-label",children:[n("labels.team")," (",f.length,")"]}),o.jsx("span",{className:"boss-toggle",children:r?"▼":"▶"})]}),r&&o.jsx("div",{className:"boss-subordinates-list",children:f.length===0?o.jsx("div",{className:"boss-subordinates-empty",children:n("unitPanel.noSubordinates")}):f.map(w=>{const C=fr(w.class,a),N=Xp(w),k=Math.max(0,Math.min(100,Math.round(N.usedPercent))),j=Math.round((1-k/100)*120),S={width:`${k}%`,"--boss-context-hue":`${j}`};return o.jsxs("div",{className:"boss-subordinate-item",onClick:()=>{U.selectAgent(w.id),U.setTerminalOpen(!0)},children:[o.jsx("span",{className:"boss-subordinate-icon",style:{color:C.color},children:C.icon}),o.jsxs("div",{className:"boss-subordinate-meta",children:[o.jsx("span",{className:"boss-subordinate-name",children:w.name}),o.jsxs("div",{className:"boss-subordinate-context",title:`${k}% context used`,children:[o.jsx("div",{className:"boss-subordinate-context-track",children:o.jsx("div",{className:"boss-subordinate-context-fill",style:S})}),o.jsxs("span",{className:"boss-subordinate-context-value",children:[k,"%"]})]})]}),o.jsx("span",{className:`boss-subordinate-status status-${w.status}`,children:w.status}),o.jsx("button",{className:"boss-subordinate-unlink",onClick:T=>{T.stopPropagation(),U.removeSubordinate(e.id,w.id)},title:n("unitPanel.unlinkSubordinate"),children:"✕"})]},w.id)})})]}),o.jsxs("div",{className:"boss-delegation-history",children:[o.jsxs("div",{className:"boss-delegation-history-header",onClick:()=>d(!c),children:[o.jsxs("div",{className:"unit-stat-label",children:[n("unitPanel.delegationHistory")," (",h.length,")"]}),o.jsx("span",{className:"boss-toggle",children:c?"▼":"▶"})]}),c&&o.jsxs("div",{className:"boss-delegation-history-list",children:[b&&o.jsxs("div",{className:"boss-delegation-pending",children:[o.jsx("span",{className:"delegation-spinner",children:"⏳"}),n("unitPanel.analyzingRequest")]}),h.length===0&&!b?o.jsx("div",{className:"boss-delegation-empty",children:n("unitPanel.noDelegationHistory")}):h.slice(0,10).map(w=>o.jsx(F2,{decision:w},w.id))]})]})]})}),F2=x.memo(function({decision:e}){const{t:n}=dt(["common"]),[s,a]=x.useState(!1),i=Rs().agents.get(e.selectedAgentId),c=i?Qp[i.class]:null,d={high:"#4aff9e",medium:"#ff9e4a",low:"#ff4a4a"};return o.jsxs("div",{className:"delegation-decision-item",children:[o.jsxs("div",{className:"delegation-decision-header",onClick:()=>a(!s),children:[o.jsx("span",{className:"delegation-decision-arrow",children:s?"▼":"▶"}),c&&o.jsx("span",{className:"delegation-decision-icon",style:{color:c.color},children:c.icon}),o.jsxs("span",{className:"delegation-decision-agent",children:["→ ",e.selectedAgentName]}),o.jsx("span",{className:"delegation-decision-confidence",style:{color:d[e.confidence]},title:n("unitPanel.confidence",{level:e.confidence}),children:e.confidence==="high"?"●●●":e.confidence==="medium"?"●●○":"●○○"}),o.jsx("span",{className:"delegation-decision-time",children:wp(e.timestamp)})]}),s&&o.jsxs("div",{className:"delegation-decision-details",children:[o.jsxs("div",{className:"delegation-decision-command",children:[o.jsxs("strong",{children:[n("labels.command"),":"]}),o.jsx("div",{className:"delegation-command-text",children:e.userCommand.length>200?e.userCommand.slice(0,200)+"...":e.userCommand})]}),o.jsxs("div",{className:"delegation-decision-reasoning",children:[o.jsxs("strong",{children:[n("labels.reasoning"),":"]})," ",e.reasoning]}),e.alternativeAgents.length>0&&o.jsxs("div",{className:"delegation-decision-alternatives",children:[o.jsxs("strong",{children:[n("labels.alternatives"),":"]})," ",e.alternativeAgents.join(", ")]})]})]})}),z2=x.memo(function({agentId:e,bossId:n}){const{t:s}=dt(["common"]),r=Rs().agents.get(n);if(!r)return null;const i=Qp.boss,c=d=>{d.stopPropagation(),U.removeSubordinate(n,e)};return o.jsxs("div",{className:"subordinate-badge",children:[o.jsx("span",{className:"subordinate-badge-icon",style:{color:i.color},children:i.icon}),o.jsxs("span",{className:"subordinate-badge-text",children:[s("labels.reportsTo"),": ",o.jsx("strong",{children:r.name})]}),o.jsx("button",{className:"subordinate-badge-goto",onClick:()=>U.selectAgent(n),title:s("unitPanel.goToBoss"),children:"→"}),o.jsx("button",{className:"subordinate-badge-unlink",onClick:c,title:s("unitPanel.unlinkFromBoss"),children:"✕"})]})}),$2=x.memo(function({agentId:e}){const{t:n}=dt(["common"]),s=Rs(),[a,r]=x.useState(!1),i=Array.from(s.agents.values()).filter(f=>f.isBoss===!0||f.class==="boss");if(i.length===0)return null;const c=Qp.boss,d=f=>{const h=s.agents.get(f);if(!h)return;const m=h.subordinateIds||[];U.assignSubordinates(f,[...m,e]),r(!1)};return o.jsx("div",{className:"link-to-boss-section",children:a?o.jsxs("div",{className:"link-to-boss-dropdown",children:[o.jsxs("div",{className:"link-to-boss-header",children:[o.jsx("span",{children:n("unitPanel.selectBoss")}),o.jsx("button",{className:"link-to-boss-close",onClick:()=>r(!1),children:"✕"})]}),o.jsx("div",{className:"link-to-boss-list",children:i.map(f=>{var h;return o.jsxs("div",{className:"link-to-boss-item",onClick:()=>d(f.id),children:[o.jsx("span",{className:"link-to-boss-item-icon",style:{color:c.color},children:c.icon}),o.jsx("span",{className:"link-to-boss-item-name",children:f.name}),o.jsx("span",{className:"link-to-boss-item-count",children:n("unitPanel.agentsCount",{count:((h=f.subordinateIds)==null?void 0:h.length)||0})})]},f.id)})})]}):o.jsxs("button",{className:"link-to-boss-btn",onClick:()=>r(!0),children:[o.jsx("span",{className:"link-to-boss-icon",style:{color:c.color},children:c.icon}),o.jsx("span",{children:n("unitPanel.linkToBoss")})]})})});function TS({onOpenAreaExplorer:t}){const{t:e}=dt(["common"]),n=Rs(),s=Array.from(n.agents.values()),a=Array.from(n.areas.values()),[r,i]=x.useState(""),[c,d]=x.useState(()=>{const I=Fa(pt.COMMANDER_FILTERS,"all");return I==="working"?"active":I||"all"}),f=x.useRef(null),h=x.useMemo(()=>s.map(I=>I.id).sort().join(","),[s]),m=x.useRef(new Set);x.useEffect(()=>{for(const I of s){if(m.current.has(I.id))continue;U.getAgentSupervisorHistory(I.id).length===0&&!U.isLoadingHistoryForAgent(I.id)&&(m.current.add(I.id),U.requestAgentSupervisorHistory(I.id))}},[h]);const b=n.agentsWithUnseenOutput,y=x.useMemo(()=>{const I={all:0,active:0,idle:0,error:0,waiting:0};for(const O of s)I.all++,(O.status==="working"||b.has(O.id))&&I.active++,O.status==="idle"&&!b.has(O.id)&&I.idle++,(O.status==="error"||O.status==="orphaned"||O.status==="offline")&&I.error++,(O.status==="waiting"||O.status==="waiting_permission")&&I.waiting++;return I},[s,b]),w=x.useMemo(()=>{const I=r.toLowerCase().trim();return s.filter(O=>{var _,M;if(c!=="all"&&(c==="active"&&O.status!=="working"&&!b.has(O.id)||c==="idle"&&(O.status!=="idle"||b.has(O.id))||c==="error"&&O.status!=="error"&&O.status!=="orphaned"&&O.status!=="offline"||c==="waiting"&&O.status!=="waiting"&&O.status!=="waiting_permission"))return!1;if(I){const R=O.name.toLowerCase().includes(I),z=((_=O.taskLabel)==null?void 0:_.toLowerCase().includes(I))||!1,$=O.class.toLowerCase().includes(I),W=((M=O.currentTool)==null?void 0:M.toLowerCase().includes(I))||!1;return R||z||$||W}return!0})},[s,r,c,b]),C=x.useMemo(()=>RL(w),[w]),N=OL(C,I=>U.getAreaForAgent(I));if(!r&&c==="all")for(const I of a)N.has(I.id)||N.set(I.id,[]);const k=LL(Array.from(N.keys()),I=>n.areas.get(I)),j=x.useCallback(I=>{d(I),Wr(pt.COMMANDER_FILTERS,I)},[]),S=x.useCallback(()=>{var I;i(""),(I=f.current)==null||I.focus()},[]);if(s.length===0&&a.length===0)return o.jsxs("div",{className:"empty-state",children:[o.jsx("div",{className:"empty-state-icon",children:"⚔️"}),o.jsx("div",{className:"empty-state-title",children:e("agentsList.noAgentsDeployed")}),o.jsx("div",{className:"empty-state-desc",children:e("agentsList.clickNewAgent")})]});const T=r||c!=="all",D=w.length,E=s.length;return o.jsxs("div",{className:"agents-list",children:[o.jsxs("div",{className:"agents-stats-bar",children:[o.jsxs("div",{className:"agents-stats-item",children:[o.jsx("span",{className:"agents-stats-count",children:E}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.total")})]}),y.active>0&&o.jsxs("div",{className:"agents-stats-item working",children:[o.jsx("span",{className:"agents-stats-count",children:y.active}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.statusActive")})]}),y.idle>0&&o.jsxs("div",{className:"agents-stats-item idle",children:[o.jsx("span",{className:"agents-stats-count",children:y.idle}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.statusIdle")})]}),y.waiting>0&&o.jsxs("div",{className:"agents-stats-item waiting",children:[o.jsx("span",{className:"agents-stats-count",children:y.waiting}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.statusWaiting")})]}),y.error>0&&o.jsxs("div",{className:"agents-stats-item error",children:[o.jsx("span",{className:"agents-stats-count",children:y.error}),o.jsx("span",{className:"agents-stats-label",children:e("agentsList.statusError")})]})]}),o.jsxs("div",{className:"agents-search-bar",children:[o.jsx("span",{className:"agents-search-icon",children:"🔍"}),o.jsx("input",{ref:f,type:"text",className:"agents-search-input",placeholder:e("agentsList.searchPlaceholder"),value:r,onChange:I=>i(I.target.value)}),r&&o.jsx("button",{className:"agents-search-clear",onClick:S,children:"×"})]}),o.jsx("div",{className:"agents-filter-chips",children:["all","active","idle","waiting","error"].map(I=>{const O=y[I];return I!=="all"&&O===0?null:o.jsxs("button",{className:`agents-filter-chip ${I} ${c===I?"selected":""}`,onClick:()=>j(I),children:[e(`agentsList.filter_${I}`),o.jsx("span",{className:"agents-filter-chip-count",children:O})]},I)})}),T&&o.jsxs("div",{className:"agents-filter-info",children:[e("agentsList.showing",{count:D,total:E}),o.jsx("button",{className:"agents-filter-clear",onClick:()=>{i(""),j("all")},children:e("agentsList.clearFilters")})]}),o.jsxs("div",{className:"agents-list-scroll",children:[k.map(I=>{const O=N.get(I),_=I?n.areas.get(I):null;return T&&O.length===0?null:o.jsxs("div",{className:"agents-group",children:[o.jsxs("div",{className:"agents-group-header",style:_?{borderLeftColor:_.color,background:`${_.color}15`}:void 0,children:[_?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"agents-group-dot",style:{background:_.color}}),o.jsx("span",{className:"agents-group-name",children:_.name}),_.directories.length>0&&o.jsx("button",{className:"area-browse-btn",onClick:()=>t==null?void 0:t(_.id),title:e("agentsList.browseFiles"),children:"📂"})]}):o.jsx("span",{className:"agents-group-name unassigned",children:e("agentsList.unassigned")}),o.jsx("span",{className:"agents-group-count",children:O.length})]}),O.length>0&&o.jsx("div",{className:"agents-group-items",style:_?{background:`${_.color}08`}:void 0,children:O.map(M=>o.jsx(U2,{agent:M,area:_,searchQuery:r},M.id))})]},I||"unassigned")}),T&&D===0&&o.jsxs("div",{className:"agents-no-results",children:[o.jsx("span",{className:"agents-no-results-icon",children:"🔎"}),o.jsx("span",{children:e("agentsList.noResults")})]}),s.length>0&&o.jsx(H2,{agents:s})]})]})}const U2=x.memo(function({agent:e,area:n,searchQuery:s=""}){const a=Rs(),r=dr(),i=fr(e.class,r),c=a.selectedAgentIds.has(e.id),d=a.agentsWithUnseenOutput.has(e.id),[,f]=x.useState(0);x.useEffect(()=>{if(e.status==="idle"){const j=setInterval(()=>{f(S=>S+1)},15e3);return()=>clearInterval(j)}},[e.status]);const h=()=>{U.selectAgent(e.id)},m=e.status==="idle"&&e.lastActivity>0,b=e.lastActivity>0?Tx(e.lastActivity):void 0,y=Xp(e),w=p1(y.remainingPercent),C=e.provider==="codex"?"CX":"CL",N=e.provider==="codex"?"OpenAI Codex":"Claude",k=j=>{if(!s.trim())return j;const S=s.trim(),T=j.toLowerCase().indexOf(S.toLowerCase());return T===-1?j:o.jsxs(o.Fragment,{children:[j.slice(0,T),o.jsx("span",{className:"agents-search-highlight",children:j.slice(T,T+S.length)}),j.slice(T+S.length)]})};return o.jsxs("div",{className:`agent-item ${c?"selected":""} ${d?"unread":""} ${e.status}`,onClick:h,children:[o.jsxs("div",{className:"agent-item-icon",style:{background:`${i.color}20`},children:[i.icon,d&&o.jsx("span",{className:"agent-item-unread-dot"})]}),o.jsxs("div",{className:"agent-item-info",children:[o.jsxs("div",{className:"agent-item-top-row",children:[o.jsx("span",{className:"agent-item-name",children:k(e.name)}),o.jsx("span",{className:`agent-item-provider ${e.provider}`,title:N,children:C})]}),e.taskLabel&&o.jsx("div",{className:"agent-item-task",children:k(e.taskLabel)}),o.jsxs("div",{className:"agent-item-status",children:[o.jsx("span",{className:`agent-item-status-badge ${e.status}`,children:e.status}),m&&o.jsxs("span",{className:"agent-item-idle",style:{color:b},title:Ex(e.lastActivity),children:["⏱ ",DL(e.lastActivity)]}),e.isBoss&&o.jsx("span",{className:"agent-item-boss-badge",title:"Boss agent",children:"B"})]}),o.jsx("div",{className:"agent-item-context-bar",title:`Context: ${Math.round(y.usedPercent)}% used`,children:o.jsx("div",{className:"agent-item-context-fill",style:{width:`${y.usedPercent}%`,background:w}})})]}),o.jsx("div",{className:`agent-status-dot ${e.status}`})]})}),H2=x.memo(function({agents:e}){const{t:n}=dt(["common"]),s=Rs(),[a,r]=x.useState(()=>Ni(pt.GLOBAL_SUPERVISOR_COLLAPSED)),i=()=>{const h=!a;r(h),Ti(pt.GLOBAL_SUPERVISOR_COLLAPSED,h)},c=x.useMemo(()=>{const h=[];for(const m of e){const b=U.getAgentSupervisorHistory(m.id);for(const y of b)h.push({agent:m,entry:y})}return h.sort((m,b)=>b.entry.timestamp-m.entry.timestamp),h.slice(0,30)},[e,s.supervisor.agentHistories]),d=x.useCallback(h=>{U.selectAgent(h)},[]),f=c.length>0?c[0].entry.timestamp:Date.now();return o.jsxs("div",{className:"global-supervisor-status",children:[o.jsxs("div",{className:"global-supervisor-header",onClick:i,children:[o.jsx("span",{className:"global-supervisor-toggle",children:a?"▶":"▼"}),o.jsx("span",{className:"global-supervisor-title",children:n("agentsList.supervisorStatus")}),c.length>0&&o.jsx("span",{className:"global-supervisor-count",children:c.length}),c.length>0&&o.jsx("span",{className:"global-supervisor-time",children:wp(f)})]}),!a&&o.jsx("div",{className:"global-supervisor-list global-supervisor-timeline",children:c.length===0?o.jsx("div",{className:"global-supervisor-empty",children:n("unitPanel.noSupervisorReports")}):c.map(({agent:h,entry:m})=>o.jsx(v1,{entry:m,agent:h,onAgentClick:d,defaultExpanded:!1},m.id))})]})}),W2=x.memo(function({agents:e}){const{t:n}=dt(["common"]),s=dr(),a=e.reduce((i,c)=>i+c.tokensUsed,0),r=e.filter(i=>i.status==="working").length;return o.jsxs("div",{className:"unit-panel",children:[o.jsxs("div",{className:"unit-panel-header",children:[o.jsx("div",{className:"unit-class-icon",style:{background:"#4a9eff20"},children:"👥"}),o.jsxs("div",{children:[o.jsx("div",{className:"unit-name",children:n("multiAgent.agentsSelected",{count:e.length})}),o.jsx("div",{className:"unit-status",children:n("multiAgent.groupSelection")})]})]}),o.jsxs("div",{className:"unit-stats",children:[o.jsxs("div",{className:"unit-stat",children:[o.jsx("div",{className:"unit-stat-label",children:n("multiAgent.totalTokens")}),o.jsx("div",{className:"unit-stat-value",children:UD(a)})]}),o.jsxs("div",{className:"unit-stat",children:[o.jsx("div",{className:"unit-stat-label",children:n("multiAgent.working")}),o.jsx("div",{className:"unit-stat-value",children:r})]})]}),o.jsx("div",{style:{padding:"8px 0",maxHeight:100,overflowY:"auto"},children:e.map(i=>o.jsx(q2,{agent:i,customClasses:s},i.id))}),o.jsx("div",{className:"unit-actions",children:o.jsx("button",{className:"unit-action-btn",onClick:()=>U.deselectAll(),children:n("buttons.deselectAll")})})]})}),q2=x.memo(function({agent:e,customClasses:n}){const s=fr(e.class,n);return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0",fontSize:12},children:[o.jsx("span",{children:s.icon}),o.jsx("span",{style:{flex:1},children:e.name}),o.jsx("span",{style:{color:"var(--text-secondary)"},children:e.status})]})});function _S({onFocusAgent:t,onKillAgent:e,onCallSubordinates:n,onOpenAreaExplorer:s}){const a=Rs(),r=U.getSelectedAgents();if(a.selectedAgentIds.size===0)return o.jsx(TS,{onOpenAreaExplorer:s});if(a.selectedAgentIds.size===1){const i=r[0];return i?o.jsx(O2,{agent:i,onFocusAgent:t,onKillAgent:e,onCallSubordinates:n,onOpenAreaExplorer:s}):o.jsx(TS,{onOpenAreaExplorer:s})}return o.jsx(W2,{agents:r})}function V2(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Y2=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,G2=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,K2={};function ES(t,e){return(K2.jsx?G2:Y2).test(t)}const Q2=/[ \t\n\f\r]/g;function X2(t){return typeof t=="object"?t.type==="text"?MS(t.value):!1:MS(t)}function MS(t){return t.replace(Q2,"")===""}class td{constructor(e,n,s){this.normal=n,this.property=e,s&&(this.space=s)}}td.prototype.normal={};td.prototype.property={};td.prototype.space=void 0;function w1(t,e){const n={},s={};for(const a of t)Object.assign(n,a.property),Object.assign(s,a.normal);return new td(n,s,e)}function ax(t){return t.toLowerCase()}class Xs{constructor(e,n){this.attribute=n,this.property=e}}Xs.prototype.attribute="";Xs.prototype.booleanish=!1;Xs.prototype.boolean=!1;Xs.prototype.commaOrSpaceSeparated=!1;Xs.prototype.commaSeparated=!1;Xs.prototype.defined=!1;Xs.prototype.mustUseProperty=!1;Xs.prototype.number=!1;Xs.prototype.overloadedBoolean=!1;Xs.prototype.property="";Xs.prototype.spaceSeparated=!1;Xs.prototype.space=void 0;let J2=0;const Wt=Lo(),is=Lo(),rx=Lo(),tt=Lo(),Rn=Lo(),Hl=Lo(),ra=Lo();function Lo(){return 2**++J2}const ix=Object.freeze(Object.defineProperty({__proto__:null,boolean:Wt,booleanish:is,commaOrSpaceSeparated:ra,commaSeparated:Hl,number:tt,overloadedBoolean:rx,spaceSeparated:Rn},Symbol.toStringTag,{value:"Module"})),Yg=Object.keys(ix);class Gx extends Xs{constructor(e,n,s,a){let r=-1;if(super(e,n),DS(this,"space",a),typeof s=="number")for(;++r<Yg.length;){const i=Yg[r];DS(this,Yg[r],(s&ix[i])===ix[i])}}}Gx.prototype.defined=!0;function DS(t,e,n){n&&(t[e]=n)}function rc(t){const e={},n={};for(const[s,a]of Object.entries(t.properties)){const r=new Gx(s,t.transform(t.attributes||{},s),a,t.space);t.mustUseProperty&&t.mustUseProperty.includes(s)&&(r.mustUseProperty=!0),e[s]=r,n[ax(s)]=s,n[ax(r.attribute)]=s}return new td(e,n,t.space)}const k1=rc({properties:{ariaActiveDescendant:null,ariaAtomic:is,ariaAutoComplete:null,ariaBusy:is,ariaChecked:is,ariaColCount:tt,ariaColIndex:tt,ariaColSpan:tt,ariaControls:Rn,ariaCurrent:null,ariaDescribedBy:Rn,ariaDetails:null,ariaDisabled:is,ariaDropEffect:Rn,ariaErrorMessage:null,ariaExpanded:is,ariaFlowTo:Rn,ariaGrabbed:is,ariaHasPopup:null,ariaHidden:is,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Rn,ariaLevel:tt,ariaLive:null,ariaModal:is,ariaMultiLine:is,ariaMultiSelectable:is,ariaOrientation:null,ariaOwns:Rn,ariaPlaceholder:null,ariaPosInSet:tt,ariaPressed:is,ariaReadOnly:is,ariaRelevant:null,ariaRequired:is,ariaRoleDescription:Rn,ariaRowCount:tt,ariaRowIndex:tt,ariaRowSpan:tt,ariaSelected:is,ariaSetSize:tt,ariaSort:null,ariaValueMax:tt,ariaValueMin:tt,ariaValueNow:tt,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function S1(t,e){return e in t?t[e]:e}function C1(t,e){return S1(t,e.toLowerCase())}const Z2=rc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Hl,acceptCharset:Rn,accessKey:Rn,action:null,allow:null,allowFullScreen:Wt,allowPaymentRequest:Wt,allowUserMedia:Wt,alt:null,as:null,async:Wt,autoCapitalize:null,autoComplete:Rn,autoFocus:Wt,autoPlay:Wt,blocking:Rn,capture:null,charSet:null,checked:Wt,cite:null,className:Rn,cols:tt,colSpan:null,content:null,contentEditable:is,controls:Wt,controlsList:Rn,coords:tt|Hl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Wt,defer:Wt,dir:null,dirName:null,disabled:Wt,download:rx,draggable:is,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Wt,formTarget:null,headers:Rn,height:tt,hidden:rx,high:tt,href:null,hrefLang:null,htmlFor:Rn,httpEquiv:Rn,id:null,imageSizes:null,imageSrcSet:null,inert:Wt,inputMode:null,integrity:null,is:null,isMap:Wt,itemId:null,itemProp:Rn,itemRef:Rn,itemScope:Wt,itemType:Rn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Wt,low:tt,manifest:null,max:null,maxLength:tt,media:null,method:null,min:null,minLength:tt,multiple:Wt,muted:Wt,name:null,nonce:null,noModule:Wt,noValidate:Wt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Wt,optimum:tt,pattern:null,ping:Rn,placeholder:null,playsInline:Wt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Wt,referrerPolicy:null,rel:Rn,required:Wt,reversed:Wt,rows:tt,rowSpan:tt,sandbox:Rn,scope:null,scoped:Wt,seamless:Wt,selected:Wt,shadowRootClonable:Wt,shadowRootDelegatesFocus:Wt,shadowRootMode:null,shape:null,size:tt,sizes:null,slot:null,span:tt,spellCheck:is,src:null,srcDoc:null,srcLang:null,srcSet:null,start:tt,step:null,style:null,tabIndex:tt,target:null,title:null,translate:null,type:null,typeMustMatch:Wt,useMap:null,value:is,width:tt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Rn,axis:null,background:null,bgColor:null,border:tt,borderColor:null,bottomMargin:tt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Wt,declare:Wt,event:null,face:null,frame:null,frameBorder:null,hSpace:tt,leftMargin:tt,link:null,longDesc:null,lowSrc:null,marginHeight:tt,marginWidth:tt,noResize:Wt,noHref:Wt,noShade:Wt,noWrap:Wt,object:null,profile:null,prompt:null,rev:null,rightMargin:tt,rules:null,scheme:null,scrolling:is,standby:null,summary:null,text:null,topMargin:tt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:tt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Wt,disableRemotePlayback:Wt,prefix:null,property:null,results:tt,security:null,unselectable:null},space:"html",transform:C1}),eI=rc({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:ra,accentHeight:tt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:tt,amplitude:tt,arabicForm:null,ascent:tt,attributeName:null,attributeType:null,azimuth:tt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:tt,by:null,calcMode:null,capHeight:tt,className:Rn,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:tt,diffuseConstant:tt,direction:null,display:null,dur:null,divisor:tt,dominantBaseline:null,download:Wt,dx:null,dy:null,edgeMode:null,editable:null,elevation:tt,enableBackground:null,end:null,event:null,exponent:tt,externalResourcesRequired:null,fill:null,fillOpacity:tt,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:Hl,g2:Hl,glyphName:Hl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:tt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:tt,horizOriginX:tt,horizOriginY:tt,id:null,ideographic:tt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:tt,k:tt,k1:tt,k2:tt,k3:tt,k4:tt,kernelMatrix:ra,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:tt,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:tt,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:tt,overlineThickness:tt,paintOrder:null,panose1:null,path:null,pathLength:tt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Rn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:tt,pointsAtY:tt,pointsAtZ:tt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ra,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ra,rev:ra,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ra,requiredFeatures:ra,requiredFonts:ra,requiredFormats:ra,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:tt,specularExponent:tt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:tt,strikethroughThickness:tt,string:null,stroke:null,strokeDashArray:ra,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:tt,strokeOpacity:tt,strokeWidth:null,style:null,surfaceScale:tt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ra,tabIndex:tt,tableValues:null,target:null,targetX:tt,targetY:tt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ra,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:tt,underlineThickness:tt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:tt,values:null,vAlphabetic:tt,vMathematical:tt,vectorEffect:null,vHanging:tt,vIdeographic:tt,version:null,vertAdvY:tt,vertOriginX:tt,vertOriginY:tt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:tt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:S1}),A1=rc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),j1=rc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:C1}),N1=rc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),tI={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"},nI=/[A-Z]/g,RS=/-[a-z]/g,sI=/^data[-\w.:]+$/i;function aI(t,e){const n=ax(e);let s=e,a=Xs;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&sI.test(e)){if(e.charAt(4)==="-"){const r=e.slice(5).replace(RS,iI);s="data"+r.charAt(0).toUpperCase()+r.slice(1)}else{const r=e.slice(4);if(!RS.test(r)){let i=r.replace(nI,rI);i.charAt(0)!=="-"&&(i="-"+i),e="data"+i}}a=Gx}return new a(s,e)}function rI(t){return"-"+t.toLowerCase()}function iI(t){return t.charAt(1).toUpperCase()}const oI=w1([k1,Z2,A1,j1,N1],"html"),Kx=w1([k1,eI,A1,j1,N1],"svg");function lI(t){return t.join(" ").trim()}var _l={},Gg,OS;function cI(){if(OS)return Gg;OS=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,r=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
|
|
48
|
+
`,f="/",h="*",m="",b="comment",y="declaration";function w(N,k){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];k=k||{};var j=1,S=1;function T(W){var L=W.match(e);L&&(j+=L.length);var F=W.lastIndexOf(d);S=~F?W.length-F:S+W.length}function D(){var W={line:j,column:S};return function(L){return L.position=new E(W),_(),L}}function E(W){this.start=W,this.end={line:j,column:S},this.source=k.source}E.prototype.content=N;function I(W){var L=new Error(k.source+":"+j+":"+S+": "+W);if(L.reason=W,L.filename=k.source,L.line=j,L.column=S,L.source=N,!k.silent)throw L}function O(W){var L=W.exec(N);if(L){var F=L[0];return T(F),N=N.slice(F.length),L}}function _(){O(n)}function M(W){var L;for(W=W||[];L=R();)L!==!1&&W.push(L);return W}function R(){var W=D();if(!(f!=N.charAt(0)||h!=N.charAt(1))){for(var L=2;m!=N.charAt(L)&&(h!=N.charAt(L)||f!=N.charAt(L+1));)++L;if(L+=2,m===N.charAt(L-1))return I("End of comment missing");var F=N.slice(2,L-2);return S+=2,T(F),N=N.slice(L),S+=2,W({type:b,comment:F})}}function z(){var W=D(),L=O(s);if(L){if(R(),!O(a))return I("property missing ':'");var F=O(r),H=W({type:y,property:C(L[0].replace(t,m)),value:F?C(F[0].replace(t,m)):m});return O(i),H}}function $(){var W=[];M(W);for(var L;L=z();)L!==!1&&(W.push(L),M(W));return W}return _(),$()}function C(N){return N?N.replace(c,m):m}return Gg=w,Gg}var LS;function uI(){if(LS)return _l;LS=1;var t=_l&&_l.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(_l,"__esModule",{value:!0}),_l.default=n;const e=t(cI());function n(s,a){let r=null;if(!s||typeof s!="string")return r;const i=(0,e.default)(s),c=typeof a=="function";return i.forEach(d=>{if(d.type!=="declaration")return;const{property:f,value:h}=d;c?a(f,h,d):h&&(r=r||{},r[f]=h)}),r}return _l}var cu={},IS;function dI(){if(IS)return cu;IS=1,Object.defineProperty(cu,"__esModule",{value:!0}),cu.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,r=function(f){return!f||n.test(f)||t.test(f)},i=function(f,h){return h.toUpperCase()},c=function(f,h){return"".concat(h,"-")},d=function(f,h){return h===void 0&&(h={}),r(f)?f:(f=f.toLowerCase(),h.reactCompat?f=f.replace(a,c):f=f.replace(s,c),f.replace(e,i))};return cu.camelCase=d,cu}var uu,PS;function fI(){if(PS)return uu;PS=1;var t=uu&&uu.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},e=t(uI()),n=dI();function s(a,r){var i={};return!a||typeof a!="string"||(0,e.default)(a,function(c,d){c&&d&&(i[(0,n.camelCase)(c,r)]=d)}),i}return s.default=s,uu=s,uu}var pI=fI();const hI=Xu(pI),T1=_1("end"),Qx=_1("start");function _1(t){return e;function e(n){const s=n&&n.position&&n.position[t]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function mI(t){const e=Qx(t),n=T1(t);if(e&&n)return{start:e,end:n}}function Du(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?BS(t.position):"start"in t||"end"in t?BS(t):"line"in t||"column"in t?ox(t):""}function ox(t){return FS(t&&t.line)+":"+FS(t&&t.column)}function BS(t){return ox(t&&t.start)+"-"+ox(t&&t.end)}function FS(t){return t&&typeof t=="number"?t:1}class Ns extends Error{constructor(e,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",r={},i=!1;if(n&&("line"in n&&"column"in n?r={place:n}:"start"in n&&"end"in n?r={place:n}:"type"in n?r={ancestors:[n],place:n.position}:r={...n}),typeof e=="string"?a=e:!r.cause&&e&&(i=!0,a=e.message,r.cause=e),!r.ruleId&&!r.source&&typeof s=="string"){const d=s.indexOf(":");d===-1?r.ruleId=s:(r.source=s.slice(0,d),r.ruleId=s.slice(d+1))}if(!r.place&&r.ancestors&&r.ancestors){const d=r.ancestors[r.ancestors.length-1];d&&(r.place=d.position)}const c=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Du(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=i&&r.cause&&typeof r.cause.stack=="string"?r.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ns.prototype.file="";Ns.prototype.name="";Ns.prototype.reason="";Ns.prototype.message="";Ns.prototype.stack="";Ns.prototype.column=void 0;Ns.prototype.line=void 0;Ns.prototype.ancestors=void 0;Ns.prototype.cause=void 0;Ns.prototype.fatal=void 0;Ns.prototype.place=void 0;Ns.prototype.ruleId=void 0;Ns.prototype.source=void 0;const Xx={}.hasOwnProperty,gI=new Map,bI=/[A-Z]/g,xI=new Set(["table","tbody","thead","tfoot","tr"]),yI=new Set(["td","th"]),E1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function vI(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let s;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=TI(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=NI(n,e.jsx,e.jsxs)}const a={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:s,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?Kx:oI,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},r=M1(a,t,void 0);return r&&typeof r!="string"?r:a.create(t,a.Fragment,{children:r||void 0},void 0)}function M1(t,e,n){if(e.type==="element")return wI(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return kI(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return CI(t,e,n);if(e.type==="mdxjsEsm")return SI(t,e);if(e.type==="root")return AI(t,e,n);if(e.type==="text")return jI(t,e)}function wI(t,e,n){const s=t.schema;let a=s;e.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Kx,t.schema=a),t.ancestors.push(e);const r=R1(t,e.tagName,!1),i=_I(t,e);let c=Zx(t,e);return xI.has(e.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!X2(d):!0})),D1(t,i,r,e),Jx(i,c),t.ancestors.pop(),t.schema=s,t.create(e,r,i,n)}function kI(t,e){if(e.data&&e.data.estree&&t.evaluater){const s=e.data.estree.body[0];return s.type,t.evaluater.evaluateExpression(s.expression)}Vu(t,e.position)}function SI(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Vu(t,e.position)}function CI(t,e,n){const s=t.schema;let a=s;e.name==="svg"&&s.space==="html"&&(a=Kx,t.schema=a),t.ancestors.push(e);const r=e.name===null?t.Fragment:R1(t,e.name,!0),i=EI(t,e),c=Zx(t,e);return D1(t,i,r,e),Jx(i,c),t.ancestors.pop(),t.schema=s,t.create(e,r,i,n)}function AI(t,e,n){const s={};return Jx(s,Zx(t,e)),t.create(e,t.Fragment,s,n)}function jI(t,e){return e.value}function D1(t,e,n,s){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=s)}function Jx(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function NI(t,e,n){return s;function s(a,r,i,c){const f=Array.isArray(i.children)?n:e;return c?f(r,i,c):f(r,i)}}function TI(t,e){return n;function n(s,a,r,i){const c=Array.isArray(r.children),d=Qx(s);return e(a,r,i,c,{columnNumber:d?d.column-1:void 0,fileName:t,lineNumber:d?d.line:void 0},void 0)}}function _I(t,e){const n={};let s,a;for(a in e.properties)if(a!=="children"&&Xx.call(e.properties,a)){const r=MI(t,a,e.properties[a]);if(r){const[i,c]=r;t.tableCellAlignToStyle&&i==="align"&&typeof c=="string"&&yI.has(e.tagName)?s=c:n[i]=c}}if(s){const r=n.style||(n.style={});r[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function EI(t,e){const n={};for(const s of e.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&t.evaluater){const r=s.data.estree.body[0];r.type;const i=r.expression;i.type;const c=i.properties[0];c.type,Object.assign(n,t.evaluater.evaluateExpression(c.argument))}else Vu(t,e.position);else{const a=s.name;let r;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&t.evaluater){const c=s.value.data.estree.body[0];c.type,r=t.evaluater.evaluateExpression(c.expression)}else Vu(t,e.position);else r=s.value===null?!0:s.value;n[a]=r}return n}function Zx(t,e){const n=[];let s=-1;const a=t.passKeys?new Map:gI;for(;++s<e.children.length;){const r=e.children[s];let i;if(t.passKeys){const d=r.type==="element"?r.tagName:r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement"?r.name:void 0;if(d){const f=a.get(d)||0;i=d+"-"+f,a.set(d,f+1)}}const c=M1(t,r,i);c!==void 0&&n.push(c)}return n}function MI(t,e,n){const s=aI(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?V2(n):lI(n)),s.property==="style"){let a=typeof n=="object"?n:DI(t,String(n));return t.stylePropertyNameCase==="css"&&(a=RI(a)),["style",a]}return[t.elementAttributeNameCase==="react"&&s.space?tI[s.property]||s.property:s.attribute,n]}}function DI(t,e){try{return hI(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const s=n,a=new Ns("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=t.filePath||void 0,a.url=E1+"#cannot-parse-style-attribute",a}}function R1(t,e,n){let s;if(!n)s={type:"Literal",value:e};else if(e.includes(".")){const a=e.split(".");let r=-1,i;for(;++r<a.length;){const c=ES(a[r])?{type:"Identifier",name:a[r]}:{type:"Literal",value:a[r]};i=i?{type:"MemberExpression",object:i,property:c,computed:!!(r&&c.type==="Literal"),optional:!1}:c}s=i}else s=ES(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(s.type==="Literal"){const a=s.value;return Xx.call(t.components,a)?t.components[a]:a}if(t.evaluater)return t.evaluater.evaluateExpression(s);Vu(t)}function Vu(t,e){const n=new Ns("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=E1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function RI(t){const e={};let n;for(n in t)Xx.call(t,n)&&(e[OI(n)]=t[n]);return e}function OI(t){let e=t.replace(bI,LI);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function LI(t){return"-"+t.toLowerCase()}const Kg={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"]},II={};function ey(t,e){const n=II,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return O1(t,s,a)}function O1(t,e,n){if(PI(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return zS(t.children,e,n)}return Array.isArray(t)?zS(t,e,n):""}function zS(t,e,n){const s=[];let a=-1;for(;++a<t.length;)s[a]=O1(t[a],e,n);return s.join("")}function PI(t){return!!(t&&typeof t=="object")}const $S=document.createElement("i");function ty(t){const e="&"+t+";";$S.innerHTML=e;const n=$S.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function ua(t,e,n,s){const a=t.length;let r=0,i;if(e<0?e=-e>a?0:a+e:e=e>a?a:e,n=n>0?n:0,s.length<1e4)i=Array.from(s),i.unshift(e,n),t.splice(...i);else for(n&&t.splice(e,n);r<s.length;)i=s.slice(r,r+1e4),i.unshift(e,0),t.splice(...i),r+=1e4,e+=1e4}function Aa(t,e){return t.length>0?(ua(t,t.length,0,e),t):e}const US={}.hasOwnProperty;function L1(t){const e={};let n=-1;for(;++n<t.length;)BI(e,t[n]);return e}function BI(t,e){let n;for(n in e){const a=(US.call(t,n)?t[n]:void 0)||(t[n]={}),r=e[n];let i;if(r)for(i in r){US.call(a,i)||(a[i]=[]);const c=r[i];FI(a[i],Array.isArray(c)?c:c?[c]:[])}}}function FI(t,e){let n=-1;const s=[];for(;++n<e.length;)(e[n].add==="after"?t:s).push(e[n]);ua(t,0,0,s)}function I1(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ia(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ms=Pi(/[A-Za-z]/),js=Pi(/[\dA-Za-z]/),zI=Pi(/[#-'*+\--9=?A-Z^-~]/);function kp(t){return t!==null&&(t<32||t===127)}const lx=Pi(/\d/),$I=Pi(/[\dA-Fa-f]/),UI=Pi(/[!-/:-@[-`{-~]/);function Et(t){return t!==null&&t<-2}function _n(t){return t!==null&&(t<0||t===32)}function en(t){return t===-2||t===-1||t===32}const Jp=Pi(new RegExp("\\p{P}|\\p{S}","u")),Eo=Pi(/\s/);function Pi(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function ic(t){const e=[];let n=-1,s=0,a=0;for(;++n<t.length;){const r=t.charCodeAt(n);let i="";if(r===37&&js(t.charCodeAt(n+1))&&js(t.charCodeAt(n+2)))a=2;else if(r<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(r))||(i=String.fromCharCode(r));else if(r>55295&&r<57344){const c=t.charCodeAt(n+1);r<56320&&c>56319&&c<57344?(i=String.fromCharCode(r,c),a=1):i="�"}else i=String.fromCharCode(r);i&&(e.push(t.slice(s,n),encodeURIComponent(i)),s=n+a+1,i=""),a&&(n+=a,a=0)}return e.join("")+t.slice(s)}function un(t,e,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let r=0;return i;function i(d){return en(d)?(t.enter(n),c(d)):e(d)}function c(d){return en(d)&&r++<a?(t.consume(d),c):(t.exit(n),e(d))}}const HI={tokenize:WI};function WI(t){const e=t.attempt(this.parser.constructs.contentInitial,s,a);let n;return e;function s(c){if(c===null){t.consume(c);return}return t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),un(t,e,"linePrefix")}function a(c){return t.enter("paragraph"),r(c)}function r(c){const d=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,i(c)}function i(c){if(c===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(c);return}return Et(c)?(t.consume(c),t.exit("chunkText"),r):(t.consume(c),i)}}const qI={tokenize:VI},HS={tokenize:YI};function VI(t){const e=this,n=[];let s=0,a,r,i;return c;function c(S){if(s<n.length){const T=n[s];return e.containerState=T[1],t.attempt(T[0].continuation,d,f)(S)}return f(S)}function d(S){if(s++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,a&&j();const T=e.events.length;let D=T,E;for(;D--;)if(e.events[D][0]==="exit"&&e.events[D][1].type==="chunkFlow"){E=e.events[D][1].end;break}k(s);let I=T;for(;I<e.events.length;)e.events[I][1].end={...E},I++;return ua(e.events,D+1,0,e.events.slice(T)),e.events.length=I,f(S)}return c(S)}function f(S){if(s===n.length){if(!a)return b(S);if(a.currentConstruct&&a.currentConstruct.concrete)return w(S);e.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(HS,h,m)(S)}function h(S){return a&&j(),k(s),b(S)}function m(S){return e.parser.lazy[e.now().line]=s!==n.length,i=e.now().offset,w(S)}function b(S){return e.containerState={},t.attempt(HS,y,w)(S)}function y(S){return s++,n.push([e.currentConstruct,e.containerState]),b(S)}function w(S){if(S===null){a&&j(),k(0),t.consume(S);return}return a=a||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:r}),C(S)}function C(S){if(S===null){N(t.exit("chunkFlow"),!0),k(0),t.consume(S);return}return Et(S)?(t.consume(S),N(t.exit("chunkFlow")),s=0,e.interrupt=void 0,c):(t.consume(S),C)}function N(S,T){const D=e.sliceStream(S);if(T&&D.push(null),S.previous=r,r&&(r.next=S),r=S,a.defineSkip(S.start),a.write(D),e.parser.lazy[S.start.line]){let E=a.events.length;for(;E--;)if(a.events[E][1].start.offset<i&&(!a.events[E][1].end||a.events[E][1].end.offset>i))return;const I=e.events.length;let O=I,_,M;for(;O--;)if(e.events[O][0]==="exit"&&e.events[O][1].type==="chunkFlow"){if(_){M=e.events[O][1].end;break}_=!0}for(k(s),E=I;E<e.events.length;)e.events[E][1].end={...M},E++;ua(e.events,O+1,0,e.events.slice(I)),e.events.length=E}}function k(S){let T=n.length;for(;T-- >S;){const D=n[T];e.containerState=D[1],D[0].exit.call(e,t)}n.length=S}function j(){a.write([null]),r=void 0,a=void 0,e.containerState._closeFlow=void 0}}function YI(t,e,n){return un(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Gl(t){if(t===null||_n(t)||Eo(t))return 1;if(Jp(t))return 2}function Zp(t,e,n){const s=[];let a=-1;for(;++a<t.length;){const r=t[a].resolveAll;r&&!s.includes(r)&&(e=r(e,n),s.push(r))}return e}const cx={name:"attention",resolveAll:GI,tokenize:KI};function GI(t,e){let n=-1,s,a,r,i,c,d,f,h;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(s=n;s--;)if(t[s][0]==="exit"&&t[s][1].type==="attentionSequence"&&t[s][1]._open&&e.sliceSerialize(t[s][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[s][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[s][1].end.offset-t[s][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;d=t[s][1].end.offset-t[s][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;const m={...t[s][1].end},b={...t[n][1].start};WS(m,-d),WS(b,d),i={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...t[s][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:b},r={type:d>1?"strongText":"emphasisText",start:{...t[s][1].end},end:{...t[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...i.start},end:{...c.end}},t[s][1].end={...i.start},t[n][1].start={...c.end},f=[],t[s][1].end.offset-t[s][1].start.offset&&(f=Aa(f,[["enter",t[s][1],e],["exit",t[s][1],e]])),f=Aa(f,[["enter",a,e],["enter",i,e],["exit",i,e],["enter",r,e]]),f=Aa(f,Zp(e.parser.constructs.insideSpan.null,t.slice(s+1,n),e)),f=Aa(f,[["exit",r,e],["enter",c,e],["exit",c,e],["exit",a,e]]),t[n][1].end.offset-t[n][1].start.offset?(h=2,f=Aa(f,[["enter",t[n][1],e],["exit",t[n][1],e]])):h=0,ua(t,s-1,n-s+3,f),n=s+f.length-h-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function KI(t,e){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,a=Gl(s);let r;return i;function i(d){return r=d,t.enter("attentionSequence"),c(d)}function c(d){if(d===r)return t.consume(d),c;const f=t.exit("attentionSequence"),h=Gl(d),m=!h||h===2&&a||n.includes(d),b=!a||a===2&&h||n.includes(s);return f._open=!!(r===42?m:m&&(a||!b)),f._close=!!(r===42?b:b&&(h||!m)),e(d)}}function WS(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const QI={name:"autolink",tokenize:XI};function XI(t,e,n){let s=0;return a;function a(y){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),r}function r(y){return Ms(y)?(t.consume(y),i):y===64?n(y):f(y)}function i(y){return y===43||y===45||y===46||js(y)?(s=1,c(y)):f(y)}function c(y){return y===58?(t.consume(y),s=0,d):(y===43||y===45||y===46||js(y))&&s++<32?(t.consume(y),c):(s=0,f(y))}function d(y){return y===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.exit("autolink"),e):y===null||y===32||y===60||kp(y)?n(y):(t.consume(y),d)}function f(y){return y===64?(t.consume(y),h):zI(y)?(t.consume(y),f):n(y)}function h(y){return js(y)?m(y):n(y)}function m(y){return y===46?(t.consume(y),s=0,h):y===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(y),t.exit("autolinkMarker"),t.exit("autolink"),e):b(y)}function b(y){if((y===45||js(y))&&s++<63){const w=y===45?b:m;return t.consume(y),w}return n(y)}}const nd={partial:!0,tokenize:JI};function JI(t,e,n){return s;function s(r){return en(r)?un(t,a,"linePrefix")(r):a(r)}function a(r){return r===null||Et(r)?e(r):n(r)}}const P1={continuation:{tokenize:eP},exit:tP,name:"blockQuote",tokenize:ZI};function ZI(t,e,n){const s=this;return a;function a(i){if(i===62){const c=s.containerState;return c.open||(t.enter("blockQuote",{_container:!0}),c.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(i),t.exit("blockQuoteMarker"),r}return n(i)}function r(i){return en(i)?(t.enter("blockQuotePrefixWhitespace"),t.consume(i),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(i))}}function eP(t,e,n){const s=this;return a;function a(i){return en(i)?un(t,r,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):r(i)}function r(i){return t.attempt(P1,e,n)(i)}}function tP(t){t.exit("blockQuote")}const B1={name:"characterEscape",tokenize:nP};function nP(t,e,n){return s;function s(r){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(r),t.exit("escapeMarker"),a}function a(r){return UI(r)?(t.enter("characterEscapeValue"),t.consume(r),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(r)}}const F1={name:"characterReference",tokenize:sP};function sP(t,e,n){const s=this;let a=0,r,i;return c;function c(m){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(m),t.exit("characterReferenceMarker"),d}function d(m){return m===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(m),t.exit("characterReferenceMarkerNumeric"),f):(t.enter("characterReferenceValue"),r=31,i=js,h(m))}function f(m){return m===88||m===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(m),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),r=6,i=$I,h):(t.enter("characterReferenceValue"),r=7,i=lx,h(m))}function h(m){if(m===59&&a){const b=t.exit("characterReferenceValue");return i===js&&!ty(s.sliceSerialize(b))?n(m):(t.enter("characterReferenceMarker"),t.consume(m),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return i(m)&&a++<r?(t.consume(m),h):n(m)}}const qS={partial:!0,tokenize:rP},VS={concrete:!0,name:"codeFenced",tokenize:aP};function aP(t,e,n){const s=this,a={partial:!0,tokenize:D};let r=0,i=0,c;return d;function d(E){return f(E)}function f(E){const I=s.events[s.events.length-1];return r=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,c=E,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),h(E)}function h(E){return E===c?(i++,t.consume(E),h):i<3?n(E):(t.exit("codeFencedFenceSequence"),en(E)?un(t,m,"whitespace")(E):m(E))}function m(E){return E===null||Et(E)?(t.exit("codeFencedFence"),s.interrupt?e(E):t.check(qS,C,T)(E)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),b(E))}function b(E){return E===null||Et(E)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),m(E)):en(E)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),un(t,y,"whitespace")(E)):E===96&&E===c?n(E):(t.consume(E),b)}function y(E){return E===null||Et(E)?m(E):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),w(E))}function w(E){return E===null||Et(E)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),m(E)):E===96&&E===c?n(E):(t.consume(E),w)}function C(E){return t.attempt(a,T,N)(E)}function N(E){return t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),k}function k(E){return r>0&&en(E)?un(t,j,"linePrefix",r+1)(E):j(E)}function j(E){return E===null||Et(E)?t.check(qS,C,T)(E):(t.enter("codeFlowValue"),S(E))}function S(E){return E===null||Et(E)?(t.exit("codeFlowValue"),j(E)):(t.consume(E),S)}function T(E){return t.exit("codeFenced"),e(E)}function D(E,I,O){let _=0;return M;function M(L){return E.enter("lineEnding"),E.consume(L),E.exit("lineEnding"),R}function R(L){return E.enter("codeFencedFence"),en(L)?un(E,z,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):z(L)}function z(L){return L===c?(E.enter("codeFencedFenceSequence"),$(L)):O(L)}function $(L){return L===c?(_++,E.consume(L),$):_>=i?(E.exit("codeFencedFenceSequence"),en(L)?un(E,W,"whitespace")(L):W(L)):O(L)}function W(L){return L===null||Et(L)?(E.exit("codeFencedFence"),I(L)):O(L)}}}function rP(t,e,n){const s=this;return a;function a(i){return i===null?n(i):(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),r)}function r(i){return s.parser.lazy[s.now().line]?n(i):e(i)}}const Qg={name:"codeIndented",tokenize:oP},iP={partial:!0,tokenize:lP};function oP(t,e,n){const s=this;return a;function a(f){return t.enter("codeIndented"),un(t,r,"linePrefix",5)(f)}function r(f){const h=s.events[s.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?i(f):n(f)}function i(f){return f===null?d(f):Et(f)?t.attempt(iP,i,d)(f):(t.enter("codeFlowValue"),c(f))}function c(f){return f===null||Et(f)?(t.exit("codeFlowValue"),i(f)):(t.consume(f),c)}function d(f){return t.exit("codeIndented"),e(f)}}function lP(t,e,n){const s=this;return a;function a(i){return s.parser.lazy[s.now().line]?n(i):Et(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),a):un(t,r,"linePrefix",5)(i)}function r(i){const c=s.events[s.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?e(i):Et(i)?a(i):n(i)}}const cP={name:"codeText",previous:dP,resolve:uP,tokenize:fP};function uP(t){let e=t.length-4,n=3,s,a;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(s=n;++s<e;)if(t[s][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(s=n-1,e++;++s<=e;)a===void 0?s!==e&&t[s][1].type!=="lineEnding"&&(a=s):(s===e||t[s][1].type==="lineEnding")&&(t[a][1].type="codeTextData",s!==a+2&&(t[a][1].end=t[s-1][1].end,t.splice(a+2,s-a-2),e-=s-a-2,s=a+2),a=void 0);return t}function dP(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function fP(t,e,n){let s=0,a,r;return i;function i(m){return t.enter("codeText"),t.enter("codeTextSequence"),c(m)}function c(m){return m===96?(t.consume(m),s++,c):(t.exit("codeTextSequence"),d(m))}function d(m){return m===null?n(m):m===32?(t.enter("space"),t.consume(m),t.exit("space"),d):m===96?(r=t.enter("codeTextSequence"),a=0,h(m)):Et(m)?(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),d):(t.enter("codeTextData"),f(m))}function f(m){return m===null||m===32||m===96||Et(m)?(t.exit("codeTextData"),d(m)):(t.consume(m),f)}function h(m){return m===96?(t.consume(m),a++,h):a===s?(t.exit("codeTextSequence"),t.exit("codeText"),e(m)):(r.type="codeTextData",f(m))}}class pP{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(e,s):e>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(e,n,s){const a=n||0;this.setCursor(Math.trunc(e));const r=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&du(this.left,s),r.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),du(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),du(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);du(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);du(this.left,n.reverse())}}}function du(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function z1(t){const e={};let n=-1,s,a,r,i,c,d,f;const h=new pP(t);for(;++n<h.length;){for(;n in e;)n=e[n];if(s=h.get(n),n&&s[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(d=s[1]._tokenizer.events,r=0,r<d.length&&d[r][1].type==="lineEndingBlank"&&(r+=2),r<d.length&&d[r][1].type==="content"))for(;++r<d.length&&d[r][1].type!=="content";)d[r][1].type==="chunkText"&&(d[r][1]._isInFirstContentOfListItem=!0,r++);if(s[0]==="enter")s[1].contentType&&(Object.assign(e,hP(h,n)),n=e[n],f=!0);else if(s[1]._container){for(r=n,a=void 0;r--;)if(i=h.get(r),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank")i[0]==="enter"&&(a&&(h.get(a)[1].type="lineEndingBlank"),i[1].type="lineEnding",a=r);else if(!(i[1].type==="linePrefix"||i[1].type==="listItemIndent"))break;a&&(s[1].end={...h.get(a)[1].start},c=h.slice(a,n),c.unshift(s),h.splice(a,n-a+1,c))}}return ua(t,0,Number.POSITIVE_INFINITY,h.slice(0)),!f}function hP(t,e){const n=t.get(e)[1],s=t.get(e)[2];let a=e-1;const r=[];let i=n._tokenizer;i||(i=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const c=i.events,d=[],f={};let h,m,b=-1,y=n,w=0,C=0;const N=[C];for(;y;){for(;t.get(++a)[1]!==y;);r.push(a),y._tokenizer||(h=s.sliceStream(y),y.next||h.push(null),m&&i.defineSkip(y.start),y._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(h),y._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),m=y,y=y.next}for(y=n;++b<c.length;)c[b][0]==="exit"&&c[b-1][0]==="enter"&&c[b][1].type===c[b-1][1].type&&c[b][1].start.line!==c[b][1].end.line&&(C=b+1,N.push(C),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(i.events=[],y?(y._tokenizer=void 0,y.previous=void 0):N.pop(),b=N.length;b--;){const k=c.slice(N[b],N[b+1]),j=r.pop();d.push([j,j+k.length-1]),t.splice(j,2,k)}for(d.reverse(),b=-1;++b<d.length;)f[w+d[b][0]]=w+d[b][1],w+=d[b][1]-d[b][0]-1;return f}const mP={resolve:bP,tokenize:xP},gP={partial:!0,tokenize:yP};function bP(t){return z1(t),t}function xP(t,e){let n;return s;function s(c){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?r(c):Et(c)?t.check(gP,i,r)(c):(t.consume(c),a)}function r(c){return t.exit("chunkContent"),t.exit("content"),e(c)}function i(c){return t.consume(c),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function yP(t,e,n){const s=this;return a;function a(i){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),un(t,r,"linePrefix")}function r(i){if(i===null||Et(i))return n(i);const c=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?e(i):t.interrupt(s.parser.constructs.flow,n,e)(i)}}function $1(t,e,n,s,a,r,i,c,d){const f=d||Number.POSITIVE_INFINITY;let h=0;return m;function m(k){return k===60?(t.enter(s),t.enter(a),t.enter(r),t.consume(k),t.exit(r),b):k===null||k===32||k===41||kp(k)?n(k):(t.enter(s),t.enter(i),t.enter(c),t.enter("chunkString",{contentType:"string"}),C(k))}function b(k){return k===62?(t.enter(r),t.consume(k),t.exit(r),t.exit(a),t.exit(s),e):(t.enter(c),t.enter("chunkString",{contentType:"string"}),y(k))}function y(k){return k===62?(t.exit("chunkString"),t.exit(c),b(k)):k===null||k===60||Et(k)?n(k):(t.consume(k),k===92?w:y)}function w(k){return k===60||k===62||k===92?(t.consume(k),y):y(k)}function C(k){return!h&&(k===null||k===41||_n(k))?(t.exit("chunkString"),t.exit(c),t.exit(i),t.exit(s),e(k)):h<f&&k===40?(t.consume(k),h++,C):k===41?(t.consume(k),h--,C):k===null||k===32||k===40||kp(k)?n(k):(t.consume(k),k===92?N:C)}function N(k){return k===40||k===41||k===92?(t.consume(k),C):C(k)}}function U1(t,e,n,s,a,r){const i=this;let c=0,d;return f;function f(y){return t.enter(s),t.enter(a),t.consume(y),t.exit(a),t.enter(r),h}function h(y){return c>999||y===null||y===91||y===93&&!d||y===94&&!c&&"_hiddenFootnoteSupport"in i.parser.constructs?n(y):y===93?(t.exit(r),t.enter(a),t.consume(y),t.exit(a),t.exit(s),e):Et(y)?(t.enter("lineEnding"),t.consume(y),t.exit("lineEnding"),h):(t.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===null||y===91||y===93||Et(y)||c++>999?(t.exit("chunkString"),h(y)):(t.consume(y),d||(d=!en(y)),y===92?b:m)}function b(y){return y===91||y===92||y===93?(t.consume(y),c++,m):m(y)}}function H1(t,e,n,s,a,r){let i;return c;function c(b){return b===34||b===39||b===40?(t.enter(s),t.enter(a),t.consume(b),t.exit(a),i=b===40?41:b,d):n(b)}function d(b){return b===i?(t.enter(a),t.consume(b),t.exit(a),t.exit(s),e):(t.enter(r),f(b))}function f(b){return b===i?(t.exit(r),d(i)):b===null?n(b):Et(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),un(t,f,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),h(b))}function h(b){return b===i||b===null||Et(b)?(t.exit("chunkString"),f(b)):(t.consume(b),b===92?m:h)}function m(b){return b===i||b===92?(t.consume(b),h):h(b)}}function Ru(t,e){let n;return s;function s(a){return Et(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),n=!0,s):en(a)?un(t,s,n?"linePrefix":"lineSuffix")(a):e(a)}}const vP={name:"definition",tokenize:kP},wP={partial:!0,tokenize:SP};function kP(t,e,n){const s=this;let a;return r;function r(y){return t.enter("definition"),i(y)}function i(y){return U1.call(s,t,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return a=Ia(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),d):n(y)}function d(y){return _n(y)?Ru(t,f)(y):f(y)}function f(y){return $1(t,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function h(y){return t.attempt(wP,m,m)(y)}function m(y){return en(y)?un(t,b,"whitespace")(y):b(y)}function b(y){return y===null||Et(y)?(t.exit("definition"),s.parser.defined.push(a),e(y)):n(y)}}function SP(t,e,n){return s;function s(c){return _n(c)?Ru(t,a)(c):n(c)}function a(c){return H1(t,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function r(c){return en(c)?un(t,i,"whitespace")(c):i(c)}function i(c){return c===null||Et(c)?e(c):n(c)}}const CP={name:"hardBreakEscape",tokenize:AP};function AP(t,e,n){return s;function s(r){return t.enter("hardBreakEscape"),t.consume(r),a}function a(r){return Et(r)?(t.exit("hardBreakEscape"),e(r)):n(r)}}const jP={name:"headingAtx",resolve:NP,tokenize:TP};function NP(t,e){let n=t.length-2,s=3,a,r;return t[s][1].type==="whitespace"&&(s+=2),n-2>s&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&t[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:t[s][1].start,end:t[n][1].end},r={type:"chunkText",start:t[s][1].start,end:t[n][1].end,contentType:"text"},ua(t,s,n-s+1,[["enter",a,e],["enter",r,e],["exit",r,e],["exit",a,e]])),t}function TP(t,e,n){let s=0;return a;function a(h){return t.enter("atxHeading"),r(h)}function r(h){return t.enter("atxHeadingSequence"),i(h)}function i(h){return h===35&&s++<6?(t.consume(h),i):h===null||_n(h)?(t.exit("atxHeadingSequence"),c(h)):n(h)}function c(h){return h===35?(t.enter("atxHeadingSequence"),d(h)):h===null||Et(h)?(t.exit("atxHeading"),e(h)):en(h)?un(t,c,"whitespace")(h):(t.enter("atxHeadingText"),f(h))}function d(h){return h===35?(t.consume(h),d):(t.exit("atxHeadingSequence"),c(h))}function f(h){return h===null||h===35||_n(h)?(t.exit("atxHeadingText"),c(h)):(t.consume(h),f)}}const _P=["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"],YS=["pre","script","style","textarea"],EP={concrete:!0,name:"htmlFlow",resolveTo:RP,tokenize:OP},MP={partial:!0,tokenize:IP},DP={partial:!0,tokenize:LP};function RP(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function OP(t,e,n){const s=this;let a,r,i,c,d;return f;function f(q){return h(q)}function h(q){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(q),m}function m(q){return q===33?(t.consume(q),b):q===47?(t.consume(q),r=!0,C):q===63?(t.consume(q),a=3,s.interrupt?e:B):Ms(q)?(t.consume(q),i=String.fromCharCode(q),N):n(q)}function b(q){return q===45?(t.consume(q),a=2,y):q===91?(t.consume(q),a=5,c=0,w):Ms(q)?(t.consume(q),a=4,s.interrupt?e:B):n(q)}function y(q){return q===45?(t.consume(q),s.interrupt?e:B):n(q)}function w(q){const xe="CDATA[";return q===xe.charCodeAt(c++)?(t.consume(q),c===xe.length?s.interrupt?e:z:w):n(q)}function C(q){return Ms(q)?(t.consume(q),i=String.fromCharCode(q),N):n(q)}function N(q){if(q===null||q===47||q===62||_n(q)){const xe=q===47,Ae=i.toLowerCase();return!xe&&!r&&YS.includes(Ae)?(a=1,s.interrupt?e(q):z(q)):_P.includes(i.toLowerCase())?(a=6,xe?(t.consume(q),k):s.interrupt?e(q):z(q)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(q):r?j(q):S(q))}return q===45||js(q)?(t.consume(q),i+=String.fromCharCode(q),N):n(q)}function k(q){return q===62?(t.consume(q),s.interrupt?e:z):n(q)}function j(q){return en(q)?(t.consume(q),j):M(q)}function S(q){return q===47?(t.consume(q),M):q===58||q===95||Ms(q)?(t.consume(q),T):en(q)?(t.consume(q),S):M(q)}function T(q){return q===45||q===46||q===58||q===95||js(q)?(t.consume(q),T):D(q)}function D(q){return q===61?(t.consume(q),E):en(q)?(t.consume(q),D):S(q)}function E(q){return q===null||q===60||q===61||q===62||q===96?n(q):q===34||q===39?(t.consume(q),d=q,I):en(q)?(t.consume(q),E):O(q)}function I(q){return q===d?(t.consume(q),d=null,_):q===null||Et(q)?n(q):(t.consume(q),I)}function O(q){return q===null||q===34||q===39||q===47||q===60||q===61||q===62||q===96||_n(q)?D(q):(t.consume(q),O)}function _(q){return q===47||q===62||en(q)?S(q):n(q)}function M(q){return q===62?(t.consume(q),R):n(q)}function R(q){return q===null||Et(q)?z(q):en(q)?(t.consume(q),R):n(q)}function z(q){return q===45&&a===2?(t.consume(q),F):q===60&&a===1?(t.consume(q),H):q===62&&a===4?(t.consume(q),K):q===63&&a===3?(t.consume(q),B):q===93&&a===5?(t.consume(q),G):Et(q)&&(a===6||a===7)?(t.exit("htmlFlowData"),t.check(MP,ne,$)(q)):q===null||Et(q)?(t.exit("htmlFlowData"),$(q)):(t.consume(q),z)}function $(q){return t.check(DP,W,ne)(q)}function W(q){return t.enter("lineEnding"),t.consume(q),t.exit("lineEnding"),L}function L(q){return q===null||Et(q)?$(q):(t.enter("htmlFlowData"),z(q))}function F(q){return q===45?(t.consume(q),B):z(q)}function H(q){return q===47?(t.consume(q),i="",V):z(q)}function V(q){if(q===62){const xe=i.toLowerCase();return YS.includes(xe)?(t.consume(q),K):z(q)}return Ms(q)&&i.length<8?(t.consume(q),i+=String.fromCharCode(q),V):z(q)}function G(q){return q===93?(t.consume(q),B):z(q)}function B(q){return q===62?(t.consume(q),K):q===45&&a===2?(t.consume(q),B):z(q)}function K(q){return q===null||Et(q)?(t.exit("htmlFlowData"),ne(q)):(t.consume(q),K)}function ne(q){return t.exit("htmlFlow"),e(q)}}function LP(t,e,n){const s=this;return a;function a(i){return Et(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),r):n(i)}function r(i){return s.parser.lazy[s.now().line]?n(i):e(i)}}function IP(t,e,n){return s;function s(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),t.attempt(nd,e,n)}}const PP={name:"htmlText",tokenize:BP};function BP(t,e,n){const s=this;let a,r,i;return c;function c(B){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(B),d}function d(B){return B===33?(t.consume(B),f):B===47?(t.consume(B),D):B===63?(t.consume(B),S):Ms(B)?(t.consume(B),O):n(B)}function f(B){return B===45?(t.consume(B),h):B===91?(t.consume(B),r=0,w):Ms(B)?(t.consume(B),j):n(B)}function h(B){return B===45?(t.consume(B),y):n(B)}function m(B){return B===null?n(B):B===45?(t.consume(B),b):Et(B)?(i=m,H(B)):(t.consume(B),m)}function b(B){return B===45?(t.consume(B),y):m(B)}function y(B){return B===62?F(B):B===45?b(B):m(B)}function w(B){const K="CDATA[";return B===K.charCodeAt(r++)?(t.consume(B),r===K.length?C:w):n(B)}function C(B){return B===null?n(B):B===93?(t.consume(B),N):Et(B)?(i=C,H(B)):(t.consume(B),C)}function N(B){return B===93?(t.consume(B),k):C(B)}function k(B){return B===62?F(B):B===93?(t.consume(B),k):C(B)}function j(B){return B===null||B===62?F(B):Et(B)?(i=j,H(B)):(t.consume(B),j)}function S(B){return B===null?n(B):B===63?(t.consume(B),T):Et(B)?(i=S,H(B)):(t.consume(B),S)}function T(B){return B===62?F(B):S(B)}function D(B){return Ms(B)?(t.consume(B),E):n(B)}function E(B){return B===45||js(B)?(t.consume(B),E):I(B)}function I(B){return Et(B)?(i=I,H(B)):en(B)?(t.consume(B),I):F(B)}function O(B){return B===45||js(B)?(t.consume(B),O):B===47||B===62||_n(B)?_(B):n(B)}function _(B){return B===47?(t.consume(B),F):B===58||B===95||Ms(B)?(t.consume(B),M):Et(B)?(i=_,H(B)):en(B)?(t.consume(B),_):F(B)}function M(B){return B===45||B===46||B===58||B===95||js(B)?(t.consume(B),M):R(B)}function R(B){return B===61?(t.consume(B),z):Et(B)?(i=R,H(B)):en(B)?(t.consume(B),R):_(B)}function z(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(t.consume(B),a=B,$):Et(B)?(i=z,H(B)):en(B)?(t.consume(B),z):(t.consume(B),W)}function $(B){return B===a?(t.consume(B),a=void 0,L):B===null?n(B):Et(B)?(i=$,H(B)):(t.consume(B),$)}function W(B){return B===null||B===34||B===39||B===60||B===61||B===96?n(B):B===47||B===62||_n(B)?_(B):(t.consume(B),W)}function L(B){return B===47||B===62||_n(B)?_(B):n(B)}function F(B){return B===62?(t.consume(B),t.exit("htmlTextData"),t.exit("htmlText"),e):n(B)}function H(B){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(B),t.exit("lineEnding"),V}function V(B){return en(B)?un(t,G,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):G(B)}function G(B){return t.enter("htmlTextData"),i(B)}}const ny={name:"labelEnd",resolveAll:UP,resolveTo:HP,tokenize:WP},FP={tokenize:qP},zP={tokenize:VP},$P={tokenize:YP};function UP(t){let e=-1;const n=[];for(;++e<t.length;){const s=t[e][1];if(n.push(t[e]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const a=s.type==="labelImage"?4:2;s.type="data",e+=a}}return t.length!==n.length&&ua(t,0,t.length,n),t}function HP(t,e){let n=t.length,s=0,a,r,i,c;for(;n--;)if(a=t[n][1],r){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;t[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(i){if(t[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(r=n,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(i=n);const d={type:t[r][1].type==="labelLink"?"link":"image",start:{...t[r][1].start},end:{...t[t.length-1][1].end}},f={type:"label",start:{...t[r][1].start},end:{...t[i][1].end}},h={type:"labelText",start:{...t[r+s+2][1].end},end:{...t[i-2][1].start}};return c=[["enter",d,e],["enter",f,e]],c=Aa(c,t.slice(r+1,r+s+3)),c=Aa(c,[["enter",h,e]]),c=Aa(c,Zp(e.parser.constructs.insideSpan.null,t.slice(r+s+4,i-3),e)),c=Aa(c,[["exit",h,e],t[i-2],t[i-1],["exit",f,e]]),c=Aa(c,t.slice(i+1)),c=Aa(c,[["exit",d,e]]),ua(t,r,t.length,c),t}function WP(t,e,n){const s=this;let a=s.events.length,r,i;for(;a--;)if((s.events[a][1].type==="labelImage"||s.events[a][1].type==="labelLink")&&!s.events[a][1]._balanced){r=s.events[a][1];break}return c;function c(b){return r?r._inactive?m(b):(i=s.parser.defined.includes(Ia(s.sliceSerialize({start:r.end,end:s.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(b),t.exit("labelMarker"),t.exit("labelEnd"),d):n(b)}function d(b){return b===40?t.attempt(FP,h,i?h:m)(b):b===91?t.attempt(zP,h,i?f:m)(b):i?h(b):m(b)}function f(b){return t.attempt($P,h,m)(b)}function h(b){return e(b)}function m(b){return r._balanced=!0,n(b)}}function qP(t,e,n){return s;function s(m){return t.enter("resource"),t.enter("resourceMarker"),t.consume(m),t.exit("resourceMarker"),a}function a(m){return _n(m)?Ru(t,r)(m):r(m)}function r(m){return m===41?h(m):$1(t,i,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function i(m){return _n(m)?Ru(t,d)(m):h(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?H1(t,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):h(m)}function f(m){return _n(m)?Ru(t,h)(m):h(m)}function h(m){return m===41?(t.enter("resourceMarker"),t.consume(m),t.exit("resourceMarker"),t.exit("resource"),e):n(m)}}function VP(t,e,n){const s=this;return a;function a(c){return U1.call(s,t,r,i,"reference","referenceMarker","referenceString")(c)}function r(c){return s.parser.defined.includes(Ia(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?e(c):n(c)}function i(c){return n(c)}}function YP(t,e,n){return s;function s(r){return t.enter("reference"),t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),a}function a(r){return r===93?(t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),t.exit("reference"),e):n(r)}}const GP={name:"labelStartImage",resolveAll:ny.resolveAll,tokenize:KP};function KP(t,e,n){const s=this;return a;function a(c){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(c),t.exit("labelImageMarker"),r}function r(c){return c===91?(t.enter("labelMarker"),t.consume(c),t.exit("labelMarker"),t.exit("labelImage"),i):n(c)}function i(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(c):e(c)}}const QP={name:"labelStartLink",resolveAll:ny.resolveAll,tokenize:XP};function XP(t,e,n){const s=this;return a;function a(i){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(i),t.exit("labelMarker"),t.exit("labelLink"),r}function r(i){return i===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(i):e(i)}}const Xg={name:"lineEnding",tokenize:JP};function JP(t,e){return n;function n(s){return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),un(t,e,"linePrefix")}}const tp={name:"thematicBreak",tokenize:ZP};function ZP(t,e,n){let s=0,a;return r;function r(f){return t.enter("thematicBreak"),i(f)}function i(f){return a=f,c(f)}function c(f){return f===a?(t.enter("thematicBreakSequence"),d(f)):s>=3&&(f===null||Et(f))?(t.exit("thematicBreak"),e(f)):n(f)}function d(f){return f===a?(t.consume(f),s++,d):(t.exit("thematicBreakSequence"),en(f)?un(t,c,"whitespace")(f):c(f))}}const Vs={continuation:{tokenize:sB},exit:rB,name:"list",tokenize:nB},eB={partial:!0,tokenize:iB},tB={partial:!0,tokenize:aB};function nB(t,e,n){const s=this,a=s.events[s.events.length-1];let r=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,i=0;return c;function c(y){const w=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:lx(y)){if(s.containerState.type||(s.containerState.type=w,t.enter(w,{_container:!0})),w==="listUnordered")return t.enter("listItemPrefix"),y===42||y===45?t.check(tp,n,f)(y):f(y);if(!s.interrupt||y===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),d(y)}return n(y)}function d(y){return lx(y)&&++i<10?(t.consume(y),d):(!s.interrupt||i<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(t.exit("listItemValue"),f(y)):n(y)}function f(y){return t.enter("listItemMarker"),t.consume(y),t.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,t.check(nd,s.interrupt?n:h,t.attempt(eB,b,m))}function h(y){return s.containerState.initialBlankLine=!0,r++,b(y)}function m(y){return en(y)?(t.enter("listItemPrefixWhitespace"),t.consume(y),t.exit("listItemPrefixWhitespace"),b):n(y)}function b(y){return s.containerState.size=r+s.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(y)}}function sB(t,e,n){const s=this;return s.containerState._closeFlow=void 0,t.check(nd,a,r);function a(c){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,un(t,e,"listItemIndent",s.containerState.size+1)(c)}function r(c){return s.containerState.furtherBlankLines||!en(c)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,i(c)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,t.attempt(tB,e,i)(c))}function i(c){return s.containerState._closeFlow=!0,s.interrupt=void 0,un(t,t.attempt(Vs,e,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function aB(t,e,n){const s=this;return un(t,a,"listItemIndent",s.containerState.size+1);function a(r){const i=s.events[s.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===s.containerState.size?e(r):n(r)}}function rB(t){t.exit(this.containerState.type)}function iB(t,e,n){const s=this;return un(t,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(r){const i=s.events[s.events.length-1];return!en(r)&&i&&i[1].type==="listItemPrefixWhitespace"?e(r):n(r)}}const GS={name:"setextUnderline",resolveTo:oB,tokenize:lB};function oB(t,e){let n=t.length,s,a,r;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){s=n;break}t[n][1].type==="paragraph"&&(a=n)}else t[n][1].type==="content"&&t.splice(n,1),!r&&t[n][1].type==="definition"&&(r=n);const i={type:"setextHeading",start:{...t[s][1].start},end:{...t[t.length-1][1].end}};return t[a][1].type="setextHeadingText",r?(t.splice(a,0,["enter",i,e]),t.splice(r+1,0,["exit",t[s][1],e]),t[s][1].end={...t[r][1].end}):t[s][1]=i,t.push(["exit",i,e]),t}function lB(t,e,n){const s=this;let a;return r;function r(f){let h=s.events.length,m;for(;h--;)if(s.events[h][1].type!=="lineEnding"&&s.events[h][1].type!=="linePrefix"&&s.events[h][1].type!=="content"){m=s.events[h][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||m)?(t.enter("setextHeadingLine"),a=f,i(f)):n(f)}function i(f){return t.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===a?(t.consume(f),c):(t.exit("setextHeadingLineSequence"),en(f)?un(t,d,"lineSuffix")(f):d(f))}function d(f){return f===null||Et(f)?(t.exit("setextHeadingLine"),e(f)):n(f)}}const cB={tokenize:uB};function uB(t){const e=this,n=t.attempt(nd,s,t.attempt(this.parser.constructs.flowInitial,a,un(t,t.attempt(this.parser.constructs.flow,a,t.attempt(mP,a)),"linePrefix")));return n;function s(r){if(r===null){t.consume(r);return}return t.enter("lineEndingBlank"),t.consume(r),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function a(r){if(r===null){t.consume(r);return}return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const dB={resolveAll:q1()},fB=W1("string"),pB=W1("text");function W1(t){return{resolveAll:q1(t==="text"?hB:void 0),tokenize:e};function e(n){const s=this,a=this.parser.constructs[t],r=n.attempt(a,i,c);return i;function i(h){return f(h)?r(h):c(h)}function c(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),d}function d(h){return f(h)?(n.exit("data"),r(h)):(n.consume(h),d)}function f(h){if(h===null)return!0;const m=a[h];let b=-1;if(m)for(;++b<m.length;){const y=m[b];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function q1(t){return e;function e(n,s){let a=-1,r;for(;++a<=n.length;)r===void 0?n[a]&&n[a][1].type==="data"&&(r=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==r+2&&(n[r][1].end=n[a-1][1].end,n.splice(r+2,a-r-2),a=r+2),r=void 0);return t?t(n,s):n}}function hB(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const s=t[n-1][1],a=e.sliceStream(s);let r=a.length,i=-1,c=0,d;for(;r--;){const f=a[r];if(typeof f=="string"){for(i=f.length;f.charCodeAt(i-1)===32;)c++,i--;if(i)break;i=-1}else if(f===-2)d=!0,c++;else if(f!==-1){r++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(c=0),c){const f={type:n===t.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:r?i:s.start._bufferIndex+i,_index:s.start._index+r,line:s.end.line,column:s.end.column-c,offset:s.end.offset-c},end:{...s.end}};s.end={...f.start},s.start.offset===s.end.offset?Object.assign(s,f):(t.splice(n,0,["enter",f,e],["exit",f,e]),n+=2)}n++}return t}const mB={42:Vs,43:Vs,45:Vs,48:Vs,49:Vs,50:Vs,51:Vs,52:Vs,53:Vs,54:Vs,55:Vs,56:Vs,57:Vs,62:P1},gB={91:vP},bB={[-2]:Qg,[-1]:Qg,32:Qg},xB={35:jP,42:tp,45:[GS,tp],60:EP,61:GS,95:tp,96:VS,126:VS},yB={38:F1,92:B1},vB={[-5]:Xg,[-4]:Xg,[-3]:Xg,33:GP,38:F1,42:cx,60:[QI,PP],91:QP,92:[CP,B1],93:ny,95:cx,96:cP},wB={null:[cx,dB]},kB={null:[42,95]},SB={null:[]},CB=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kB,contentInitial:gB,disable:SB,document:mB,flow:xB,flowInitial:bB,insideSpan:wB,string:yB,text:vB},Symbol.toStringTag,{value:"Module"}));function AB(t,e,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},r=[];let i=[],c=[];const d={attempt:I(D),check:I(E),consume:j,enter:S,exit:T,interrupt:I(E,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:t,previous:null,sliceSerialize:b,sliceStream:y,write:m};let h=e.tokenize.call(f,d);return e.resolveAll&&r.push(e),f;function m(R){return i=Aa(i,R),N(),i[i.length-1]!==null?[]:(O(e,0),f.events=Zp(r,f.events,f),f.events)}function b(R,z){return NB(y(R),z)}function y(R){return jB(i,R)}function w(){const{_bufferIndex:R,_index:z,line:$,column:W,offset:L}=s;return{_bufferIndex:R,_index:z,line:$,column:W,offset:L}}function C(R){a[R.line]=R.column,M()}function N(){let R;for(;s._index<i.length;){const z=i[s._index];if(typeof z=="string")for(R=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===R&&s._bufferIndex<z.length;)k(z.charCodeAt(s._bufferIndex));else k(z)}}function k(R){h=h(R)}function j(R){Et(R)?(s.line++,s.column=1,s.offset+=R===-3?2:1,M()):R!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===i[s._index].length&&(s._bufferIndex=-1,s._index++)),f.previous=R}function S(R,z){const $=z||{};return $.type=R,$.start=w(),f.events.push(["enter",$,f]),c.push($),$}function T(R){const z=c.pop();return z.end=w(),f.events.push(["exit",z,f]),z}function D(R,z){O(R,z.from)}function E(R,z){z.restore()}function I(R,z){return $;function $(W,L,F){let H,V,G,B;return Array.isArray(W)?ne(W):"tokenize"in W?ne([W]):K(W);function K(Z){return ce;function ce(me){const ee=me!==null&&Z[me],re=me!==null&&Z.null,We=[...Array.isArray(ee)?ee:ee?[ee]:[],...Array.isArray(re)?re:re?[re]:[]];return ne(We)(me)}}function ne(Z){return H=Z,V=0,Z.length===0?F:q(Z[V])}function q(Z){return ce;function ce(me){return B=_(),G=Z,Z.partial||(f.currentConstruct=Z),Z.name&&f.parser.constructs.disable.null.includes(Z.name)?Ae():Z.tokenize.call(z?Object.assign(Object.create(f),z):f,d,xe,Ae)(me)}}function xe(Z){return R(G,B),L}function Ae(Z){return B.restore(),++V<H.length?q(H[V]):F}}}function O(R,z){R.resolveAll&&!r.includes(R)&&r.push(R),R.resolve&&ua(f.events,z,f.events.length-z,R.resolve(f.events.slice(z),f)),R.resolveTo&&(f.events=R.resolveTo(f.events,f))}function _(){const R=w(),z=f.previous,$=f.currentConstruct,W=f.events.length,L=Array.from(c);return{from:W,restore:F};function F(){s=R,f.previous=z,f.currentConstruct=$,f.events.length=W,c=L,M()}}function M(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function jB(t,e){const n=e.start._index,s=e.start._bufferIndex,a=e.end._index,r=e.end._bufferIndex;let i;if(n===a)i=[t[n].slice(s,r)];else{if(i=t.slice(n,a),s>-1){const c=i[0];typeof c=="string"?i[0]=c.slice(s):i.shift()}r>0&&i.push(t[a].slice(0,r))}return i}function NB(t,e){let n=-1;const s=[];let a;for(;++n<t.length;){const r=t[n];let i;if(typeof r=="string")i=r;else switch(r){case-5:{i="\r";break}case-4:{i=`
|
|
49
|
+
`;break}case-3:{i=`\r
|
|
50
|
+
`;break}case-2:{i=e?" ":" ";break}case-1:{if(!e&&a)continue;i=" ";break}default:i=String.fromCharCode(r)}a=r===-2,s.push(i)}return s.join("")}function TB(t){const s={constructs:L1([CB,...(t||{}).extensions||[]]),content:a(HI),defined:[],document:a(qI),flow:a(cB),lazy:{},string:a(fB),text:a(pB)};return s;function a(r){return i;function i(c){return AB(s,r,c)}}}function _B(t){for(;!z1(t););return t}const KS=/[\0\t\n\r]/g;function EB(){let t=1,e="",n=!0,s;return a;function a(r,i,c){const d=[];let f,h,m,b,y;for(r=e+(typeof r=="string"?r.toString():new TextDecoder(i||void 0).decode(r)),m=0,e="",n&&(r.charCodeAt(0)===65279&&m++,n=void 0);m<r.length;){if(KS.lastIndex=m,f=KS.exec(r),b=f&&f.index!==void 0?f.index:r.length,y=r.charCodeAt(b),!f){e=r.slice(m);break}if(y===10&&m===b&&s)d.push(-3),s=void 0;else switch(s&&(d.push(-5),s=void 0),m<b&&(d.push(r.slice(m,b)),t+=b-m),y){case 0:{d.push(65533),t++;break}case 9:{for(h=Math.ceil(t/4)*4,d.push(-2);t++<h;)d.push(-1);break}case 10:{d.push(-4),t=1;break}default:s=!0,t=1}m=b+1}return c&&(s&&d.push(-5),e&&d.push(e),d.push(null)),d}}const MB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function DB(t){return t.replace(MB,RB)}function RB(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),r=a===120||a===88;return I1(n.slice(r?2:1),r?16:10)}return ty(n)||t}const V1={}.hasOwnProperty;function OB(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),LB(n)(_B(TB(n).document().write(EB()(t,e,!0))))}function LB(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(Be),autolinkProtocol:_,autolinkEmail:_,atxHeading:r(Te),blockQuote:r(re),characterEscape:_,characterReference:_,codeFenced:r(We),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(We,i),codeText:r(ze,i),codeTextData:_,data:_,codeFlowValue:_,definition:r(Pe),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(ge),hardBreakEscape:r(qe),hardBreakTrailing:r(qe),htmlFlow:r(it,i),htmlFlowData:_,htmlText:r(it,i),htmlTextData:_,image:r(he),label:i,link:r(Be),listItem:r(de),listItemValue:b,listOrdered:r(ie,m),listUnordered:r(ie),paragraph:r(He),reference:q,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(Te),strong:r(et),thematicBreak:r(fe)},exit:{atxHeading:d(),atxHeadingSequence:D,autolink:d(),autolinkEmail:ee,autolinkProtocol:me,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:Ae,characterReferenceMarkerNumeric:Ae,characterReferenceValue:Z,characterReference:ce,codeFenced:d(N),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:M,codeIndented:d(k),codeText:d(L),codeTextData:M,data:M,definition:d(),definitionDestinationString:T,definitionLabelString:j,definitionTitleString:S,emphasis:d(),hardBreakEscape:d(z),hardBreakTrailing:d(z),htmlFlow:d($),htmlFlowData:M,htmlText:d(W),htmlTextData:M,image:d(H),label:G,labelText:V,lineEnding:R,link:d(F),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:xe,resourceDestinationString:B,resourceTitleString:K,resource:ne,setextHeading:d(O),setextHeadingLineSequence:I,setextHeadingText:E,strong:d(),thematicBreak:d()}};Y1(e,(t||{}).mdastExtensions||[]);const n={};return s;function s(X){let se={type:"root",children:[]};const Se={stack:[se],tokenStack:[],config:e,enter:c,exit:f,buffer:i,resume:h,data:n},J=[];let pe=-1;for(;++pe<X.length;)if(X[pe][1].type==="listOrdered"||X[pe][1].type==="listUnordered")if(X[pe][0]==="enter")J.push(pe);else{const Re=J.pop();pe=a(X,Re,pe)}for(pe=-1;++pe<X.length;){const Re=e[X[pe][0]];V1.call(Re,X[pe][1].type)&&Re[X[pe][1].type].call(Object.assign({sliceSerialize:X[pe][2].sliceSerialize},Se),X[pe][1])}if(Se.tokenStack.length>0){const Re=Se.tokenStack[Se.tokenStack.length-1];(Re[1]||QS).call(Se,void 0,Re[0])}for(se.position={start:Ai(X.length>0?X[0][1].start:{line:1,column:1,offset:0}),end:Ai(X.length>0?X[X.length-2][1].end:{line:1,column:1,offset:0})},pe=-1;++pe<e.transforms.length;)se=e.transforms[pe](se)||se;return se}function a(X,se,Se){let J=se-1,pe=-1,Re=!1,$e,ye,Ie,te;for(;++J<=Se;){const be=X[J];switch(be[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{be[0]==="enter"?pe++:pe--,te=void 0;break}case"lineEndingBlank":{be[0]==="enter"&&($e&&!te&&!pe&&!Ie&&(Ie=J),te=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:te=void 0}if(!pe&&be[0]==="enter"&&be[1].type==="listItemPrefix"||pe===-1&&be[0]==="exit"&&(be[1].type==="listUnordered"||be[1].type==="listOrdered")){if($e){let we=J;for(ye=void 0;we--;){const Fe=X[we];if(Fe[1].type==="lineEnding"||Fe[1].type==="lineEndingBlank"){if(Fe[0]==="exit")continue;ye&&(X[ye][1].type="lineEndingBlank",Re=!0),Fe[1].type="lineEnding",ye=we}else if(!(Fe[1].type==="linePrefix"||Fe[1].type==="blockQuotePrefix"||Fe[1].type==="blockQuotePrefixWhitespace"||Fe[1].type==="blockQuoteMarker"||Fe[1].type==="listItemIndent"))break}Ie&&(!ye||Ie<ye)&&($e._spread=!0),$e.end=Object.assign({},ye?X[ye][1].start:be[1].end),X.splice(ye||J,0,["exit",$e,be[2]]),J++,Se++}if(be[1].type==="listItemPrefix"){const we={type:"listItem",_spread:!1,start:Object.assign({},be[1].start),end:void 0};$e=we,X.splice(J,0,["enter",we,be[2]]),J++,Se++,Ie=void 0,te=!0}}}return X[se][1]._spread=Re,Se}function r(X,se){return Se;function Se(J){c.call(this,X(J),J),se&&se.call(this,J)}}function i(){this.stack.push({type:"fragment",children:[]})}function c(X,se,Se){this.stack[this.stack.length-1].children.push(X),this.stack.push(X),this.tokenStack.push([se,Se||void 0]),X.position={start:Ai(se.start),end:void 0}}function d(X){return se;function se(Se){X&&X.call(this,Se),f.call(this,Se)}}function f(X,se){const Se=this.stack.pop(),J=this.tokenStack.pop();if(J)J[0].type!==X.type&&(se?se.call(this,X,J[0]):(J[1]||QS).call(this,X,J[0]));else throw new Error("Cannot close `"+X.type+"` ("+Du({start:X.start,end:X.end})+"): it’s not open");Se.position.end=Ai(X.end)}function h(){return ey(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function b(X){if(this.data.expectingFirstListItemValue){const se=this.stack[this.stack.length-2];se.start=Number.parseInt(this.sliceSerialize(X),10),this.data.expectingFirstListItemValue=void 0}}function y(){const X=this.resume(),se=this.stack[this.stack.length-1];se.lang=X}function w(){const X=this.resume(),se=this.stack[this.stack.length-1];se.meta=X}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const X=this.resume(),se=this.stack[this.stack.length-1];se.value=X.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const X=this.resume(),se=this.stack[this.stack.length-1];se.value=X.replace(/(\r?\n|\r)$/g,"")}function j(X){const se=this.resume(),Se=this.stack[this.stack.length-1];Se.label=se,Se.identifier=Ia(this.sliceSerialize(X)).toLowerCase()}function S(){const X=this.resume(),se=this.stack[this.stack.length-1];se.title=X}function T(){const X=this.resume(),se=this.stack[this.stack.length-1];se.url=X}function D(X){const se=this.stack[this.stack.length-1];if(!se.depth){const Se=this.sliceSerialize(X).length;se.depth=Se}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function I(X){const se=this.stack[this.stack.length-1];se.depth=this.sliceSerialize(X).codePointAt(0)===61?1:2}function O(){this.data.setextHeadingSlurpLineEnding=void 0}function _(X){const Se=this.stack[this.stack.length-1].children;let J=Se[Se.length-1];(!J||J.type!=="text")&&(J=ct(),J.position={start:Ai(X.start),end:void 0},Se.push(J)),this.stack.push(J)}function M(X){const se=this.stack.pop();se.value+=this.sliceSerialize(X),se.position.end=Ai(X.end)}function R(X){const se=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Se=se.children[se.children.length-1];Se.position.end=Ai(X.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(se.type)&&(_.call(this,X),M.call(this,X))}function z(){this.data.atHardBreak=!0}function $(){const X=this.resume(),se=this.stack[this.stack.length-1];se.value=X}function W(){const X=this.resume(),se=this.stack[this.stack.length-1];se.value=X}function L(){const X=this.resume(),se=this.stack[this.stack.length-1];se.value=X}function F(){const X=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";X.type+="Reference",X.referenceType=se,delete X.url,delete X.title}else delete X.identifier,delete X.label;this.data.referenceType=void 0}function H(){const X=this.stack[this.stack.length-1];if(this.data.inReference){const se=this.data.referenceType||"shortcut";X.type+="Reference",X.referenceType=se,delete X.url,delete X.title}else delete X.identifier,delete X.label;this.data.referenceType=void 0}function V(X){const se=this.sliceSerialize(X),Se=this.stack[this.stack.length-2];Se.label=DB(se),Se.identifier=Ia(se).toLowerCase()}function G(){const X=this.stack[this.stack.length-1],se=this.resume(),Se=this.stack[this.stack.length-1];if(this.data.inReference=!0,Se.type==="link"){const J=X.children;Se.children=J}else Se.alt=se}function B(){const X=this.resume(),se=this.stack[this.stack.length-1];se.url=X}function K(){const X=this.resume(),se=this.stack[this.stack.length-1];se.title=X}function ne(){this.data.inReference=void 0}function q(){this.data.referenceType="collapsed"}function xe(X){const se=this.resume(),Se=this.stack[this.stack.length-1];Se.label=se,Se.identifier=Ia(this.sliceSerialize(X)).toLowerCase(),this.data.referenceType="full"}function Ae(X){this.data.characterReferenceType=X.type}function Z(X){const se=this.sliceSerialize(X),Se=this.data.characterReferenceType;let J;Se?(J=I1(se,Se==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):J=ty(se);const pe=this.stack[this.stack.length-1];pe.value+=J}function ce(X){const se=this.stack.pop();se.position.end=Ai(X.end)}function me(X){M.call(this,X);const se=this.stack[this.stack.length-1];se.url=this.sliceSerialize(X)}function ee(X){M.call(this,X);const se=this.stack[this.stack.length-1];se.url="mailto:"+this.sliceSerialize(X)}function re(){return{type:"blockquote",children:[]}}function We(){return{type:"code",lang:null,meta:null,value:""}}function ze(){return{type:"inlineCode",value:""}}function Pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ge(){return{type:"emphasis",children:[]}}function Te(){return{type:"heading",depth:0,children:[]}}function qe(){return{type:"break"}}function it(){return{type:"html",value:""}}function he(){return{type:"image",title:null,url:"",alt:null}}function Be(){return{type:"link",title:null,url:"",children:[]}}function ie(X){return{type:"list",ordered:X.type==="listOrdered",start:null,spread:X._spread,children:[]}}function de(X){return{type:"listItem",spread:X._spread,checked:null,children:[]}}function He(){return{type:"paragraph",children:[]}}function et(){return{type:"strong",children:[]}}function ct(){return{type:"text",value:""}}function fe(){return{type:"thematicBreak"}}}function Ai(t){return{line:t.line,column:t.column,offset:t.offset}}function Y1(t,e){let n=-1;for(;++n<e.length;){const s=e[n];Array.isArray(s)?Y1(t,s):IB(t,s)}}function IB(t,e){let n;for(n in e)if(V1.call(e,n))switch(n){case"canContainEols":{const s=e[n];s&&t[n].push(...s);break}case"transforms":{const s=e[n];s&&t[n].push(...s);break}case"enter":case"exit":{const s=e[n];s&&Object.assign(t[n],s);break}}}function QS(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Du({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Du({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Du({start:e.start,end:e.end})+") is still open")}function PB(t){const e=this;e.parser=n;function n(s){return OB(s,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function BB(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function FB(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
|
|
51
|
+
`}]}function zB(t,e){const n=e.value?e.value+`
|
|
52
|
+
`:"",s={},a=e.lang?e.lang.split(/\s+/):[];a.length>0&&(s.className=["language-"+a[0]]);let r={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return e.meta&&(r.data={meta:e.meta}),t.patch(e,r),r=t.applyData(e,r),r={type:"element",tagName:"pre",properties:{},children:[r]},t.patch(e,r),r}function $B(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function UB(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function HB(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",s=String(e.identifier).toUpperCase(),a=ic(s.toLowerCase()),r=t.footnoteOrder.indexOf(s);let i,c=t.footnoteCounts.get(s);c===void 0?(c=0,t.footnoteOrder.push(s),i=t.footnoteOrder.length):i=r+1,c+=1,t.footnoteCounts.set(s,c);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};t.patch(e,d);const f={type:"element",tagName:"sup",properties:{},children:[d]};return t.patch(e,f),t.applyData(e,f)}function WB(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function qB(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function G1(t,e){const n=e.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+s}];const a=t.all(e),r=a[0];r&&r.type==="text"?r.value="["+r.value:a.unshift({type:"text",value:"["});const i=a[a.length-1];return i&&i.type==="text"?i.value+=s:a.push({type:"text",value:s}),a}function VB(t,e){const n=String(e.identifier).toUpperCase(),s=t.definitionById.get(n);if(!s)return G1(t,e);const a={src:ic(s.url||""),alt:e.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const r={type:"element",tagName:"img",properties:a,children:[]};return t.patch(e,r),t.applyData(e,r)}function YB(t,e){const n={src:ic(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const s={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,s),t.applyData(e,s)}function GB(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,s),t.applyData(e,s)}function KB(t,e){const n=String(e.identifier).toUpperCase(),s=t.definitionById.get(n);if(!s)return G1(t,e);const a={href:ic(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const r={type:"element",tagName:"a",properties:a,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function QB(t,e){const n={href:ic(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const s={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,s),t.applyData(e,s)}function XB(t,e,n){const s=t.all(e),a=n?JB(n):K1(e),r={},i=[];if(typeof e.checked=="boolean"){const h=s[0];let m;h&&h.type==="element"&&h.tagName==="p"?m=h:(m={type:"element",tagName:"p",properties:{},children:[]},s.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),r.className=["task-list-item"]}let c=-1;for(;++c<s.length;){const h=s[c];(a||c!==0||h.type!=="element"||h.tagName!=="p")&&i.push({type:"text",value:`
|
|
53
|
+
`}),h.type==="element"&&h.tagName==="p"&&!a?i.push(...h.children):i.push(h)}const d=s[s.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&i.push({type:"text",value:`
|
|
54
|
+
`});const f={type:"element",tagName:"li",properties:r,children:i};return t.patch(e,f),t.applyData(e,f)}function JB(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let s=-1;for(;!e&&++s<n.length;)e=K1(n[s])}return e}function K1(t){const e=t.spread;return e??t.children.length>1}function ZB(t,e){const n={},s=t.all(e);let a=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++a<s.length;){const i=s[a];if(i.type==="element"&&i.tagName==="li"&&i.properties&&Array.isArray(i.properties.className)&&i.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const r={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(s,!0)};return t.patch(e,r),t.applyData(e,r)}function eF(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function tF(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function nF(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function sF(t,e){const n=t.all(e),s=n.shift(),a=[];if(s){const i={type:"element",tagName:"thead",properties:{},children:t.wrap([s],!0)};t.patch(e.children[0],i),a.push(i)}if(n.length>0){const i={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},c=Qx(e.children[1]),d=T1(e.children[e.children.length-1]);c&&d&&(i.position={start:c,end:d}),a.push(i)}const r={type:"element",tagName:"table",properties:{},children:t.wrap(a,!0)};return t.patch(e,r),t.applyData(e,r)}function aF(t,e,n){const s=n?n.children:void 0,r=(s?s.indexOf(e):1)===0?"th":"td",i=n&&n.type==="table"?n.align:void 0,c=i?i.length:e.children.length;let d=-1;const f=[];for(;++d<c;){const m=e.children[d],b={},y=i?i[d]:void 0;y&&(b.align=y);let w={type:"element",tagName:r,properties:b,children:[]};m&&(w.children=t.all(m),t.patch(m,w),w=t.applyData(m,w)),f.push(w)}const h={type:"element",tagName:"tr",properties:{},children:t.wrap(f,!0)};return t.patch(e,h),t.applyData(e,h)}function rF(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const XS=9,JS=32;function iF(t){const e=String(t),n=/\r?\n|\r/g;let s=n.exec(e),a=0;const r=[];for(;s;)r.push(ZS(e.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=n.exec(e);return r.push(ZS(e.slice(a),a>0,!1)),r.join("")}function ZS(t,e,n){let s=0,a=t.length;if(e){let r=t.codePointAt(s);for(;r===XS||r===JS;)s++,r=t.codePointAt(s)}if(n){let r=t.codePointAt(a-1);for(;r===XS||r===JS;)a--,r=t.codePointAt(a-1)}return a>s?t.slice(s,a):""}function oF(t,e){const n={type:"text",value:iF(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function lF(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const cF={blockquote:BB,break:FB,code:zB,delete:$B,emphasis:UB,footnoteReference:HB,heading:WB,html:qB,imageReference:VB,image:YB,inlineCode:GB,linkReference:KB,link:QB,listItem:XB,list:ZB,paragraph:eF,root:tF,strong:nF,table:sF,tableCell:rF,tableRow:aF,text:oF,thematicBreak:lF,toml:Of,yaml:Of,definition:Of,footnoteDefinition:Of};function Of(){}const Q1=-1,eh=0,Ou=1,Sp=2,sy=3,ay=4,ry=5,iy=6,X1=7,J1=8,eC=typeof self=="object"?self:globalThis,uF=(t,e)=>{const n=(a,r)=>(t.set(r,a),a),s=a=>{if(t.has(a))return t.get(a);const[r,i]=e[a];switch(r){case eh:case Q1:return n(i,a);case Ou:{const c=n([],a);for(const d of i)c.push(s(d));return c}case Sp:{const c=n({},a);for(const[d,f]of i)c[s(d)]=s(f);return c}case sy:return n(new Date(i),a);case ay:{const{source:c,flags:d}=i;return n(new RegExp(c,d),a)}case ry:{const c=n(new Map,a);for(const[d,f]of i)c.set(s(d),s(f));return c}case iy:{const c=n(new Set,a);for(const d of i)c.add(s(d));return c}case X1:{const{name:c,message:d}=i;return n(new eC[c](d),a)}case J1:return n(BigInt(i),a);case"BigInt":return n(Object(BigInt(i)),a);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:c}=new Uint8Array(i);return n(new DataView(c),i)}}return n(new eC[r](i),a)};return s},tC=t=>uF(new Map,t)(0),El="",{toString:dF}={},{keys:fF}=Object,fu=t=>{const e=typeof t;if(e!=="object"||!t)return[eh,e];const n=dF.call(t).slice(8,-1);switch(n){case"Array":return[Ou,El];case"Object":return[Sp,El];case"Date":return[sy,El];case"RegExp":return[ay,El];case"Map":return[ry,El];case"Set":return[iy,El];case"DataView":return[Ou,n]}return n.includes("Array")?[Ou,n]:n.includes("Error")?[X1,n]:[Sp,n]},Lf=([t,e])=>t===eh&&(e==="function"||e==="symbol"),pF=(t,e,n,s)=>{const a=(i,c)=>{const d=s.push(i)-1;return n.set(c,d),d},r=i=>{if(n.has(i))return n.get(i);let[c,d]=fu(i);switch(c){case eh:{let h=i;switch(d){case"bigint":c=J1,h=i.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+d);h=null;break;case"undefined":return a([Q1],i)}return a([c,h],i)}case Ou:{if(d){let b=i;return d==="DataView"?b=new Uint8Array(i.buffer):d==="ArrayBuffer"&&(b=new Uint8Array(i)),a([d,[...b]],i)}const h=[],m=a([c,h],i);for(const b of i)h.push(r(b));return m}case Sp:{if(d)switch(d){case"BigInt":return a([d,i.toString()],i);case"Boolean":case"Number":case"String":return a([d,i.valueOf()],i)}if(e&&"toJSON"in i)return r(i.toJSON());const h=[],m=a([c,h],i);for(const b of fF(i))(t||!Lf(fu(i[b])))&&h.push([r(b),r(i[b])]);return m}case sy:return a([c,i.toISOString()],i);case ay:{const{source:h,flags:m}=i;return a([c,{source:h,flags:m}],i)}case ry:{const h=[],m=a([c,h],i);for(const[b,y]of i)(t||!(Lf(fu(b))||Lf(fu(y))))&&h.push([r(b),r(y)]);return m}case iy:{const h=[],m=a([c,h],i);for(const b of i)(t||!Lf(fu(b)))&&h.push(r(b));return m}}const{message:f}=i;return a([c,{name:d,message:f}],i)};return r},nC=(t,{json:e,lossy:n}={})=>{const s=[];return pF(!(e||n),!!e,new Map,s)(t),s},Cp=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?tC(nC(t,e)):structuredClone(t):(t,e)=>tC(nC(t,e));function hF(t,e){const n=[{type:"text",value:"↩"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function mF(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function gF(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||hF,s=t.options.footnoteBackLabel||mF,a=t.options.footnoteLabel||"Footnotes",r=t.options.footnoteLabelTagName||"h2",i=t.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d<t.footnoteOrder.length;){const f=t.footnoteById.get(t.footnoteOrder[d]);if(!f)continue;const h=t.all(f),m=String(f.identifier).toUpperCase(),b=ic(m.toLowerCase());let y=0;const w=[],C=t.footnoteCounts.get(m);for(;C!==void 0&&++y<=C;){w.length>0&&w.push({type:"text",value:" "});let j=typeof n=="string"?n:n(d,y);typeof j=="string"&&(j={type:"text",value:j}),w.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(d,y),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const N=h[h.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const j=N.children[N.children.length-1];j&&j.type==="text"?j.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...w)}else h.push(...w);const k={type:"element",tagName:"li",properties:{id:e+"fn-"+b},children:t.wrap(h,!0)};t.patch(f,k),c.push(k)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:r,properties:{...Cp(i),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
|
|
55
|
+
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(c,!0)},{type:"text",value:`
|
|
56
|
+
`}]}}const th=(function(t){if(t==null)return vF;if(typeof t=="function")return nh(t);if(typeof t=="object")return Array.isArray(t)?bF(t):xF(t);if(typeof t=="string")return yF(t);throw new Error("Expected function, string, or object as test")});function bF(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=th(t[n]);return nh(s);function s(...a){let r=-1;for(;++r<e.length;)if(e[r].apply(this,a))return!0;return!1}}function xF(t){const e=t;return nh(n);function n(s){const a=s;let r;for(r in t)if(a[r]!==e[r])return!1;return!0}}function yF(t){return nh(e);function e(n){return n&&n.type===t}}function nh(t){return e;function e(n,s,a){return!!(wF(n)&&t.call(this,n,typeof s=="number"?s:void 0,a||void 0))}}function vF(){return!0}function wF(t){return t!==null&&typeof t=="object"&&"type"in t}const Z1=[],kF=!0,ux=!1,SF="skip";function eN(t,e,n,s){let a;typeof e=="function"&&typeof n!="function"?(s=n,n=e):a=e;const r=th(a),i=s?-1:1;c(t,void 0,[])();function c(d,f,h){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const y=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return b;function b(){let y=Z1,w,C,N;if((!e||r(d,f,h[h.length-1]||void 0))&&(y=CF(n(d,h)),y[0]===ux))return y;if("children"in d&&d.children){const k=d;if(k.children&&y[0]!==SF)for(C=(s?k.children.length:-1)+i,N=h.concat(k);C>-1&&C<k.children.length;){const j=k.children[C];if(w=c(j,C,N)(),w[0]===ux)return w;C=typeof w[1]=="number"?w[1]:C+i}}return y}}}function CF(t){return Array.isArray(t)?t:typeof t=="number"?[kF,t]:t==null?Z1:[t]}function oy(t,e,n,s){let a,r,i;typeof e=="function"&&typeof n!="function"?(r=void 0,i=e,a=n):(r=e,i=n,a=s),eN(t,r,c,a);function c(d,f){const h=f[f.length-1],m=h?h.children.indexOf(d):void 0;return i(d,m,h)}}const dx={}.hasOwnProperty,AF={};function jF(t,e){const n=e||AF,s=new Map,a=new Map,r=new Map,i={...cF,...n.handlers},c={all:f,applyData:TF,definitionById:s,footnoteById:a,footnoteCounts:r,footnoteOrder:[],handlers:i,one:d,options:n,patch:NF,wrap:EF};return oy(t,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const m=h.type==="definition"?s:a,b=String(h.identifier).toUpperCase();m.has(b)||m.set(b,h)}}),c;function d(h,m){const b=h.type,y=c.handlers[b];if(dx.call(c.handlers,b)&&y)return y(c,h,m);if(c.options.passThrough&&c.options.passThrough.includes(b)){if("children"in h){const{children:C,...N}=h,k=Cp(N);return k.children=c.all(h),k}return Cp(h)}return(c.options.unknownHandler||_F)(c,h,m)}function f(h){const m=[];if("children"in h){const b=h.children;let y=-1;for(;++y<b.length;){const w=c.one(b[y],h);if(w){if(y&&b[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=sC(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=sC(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function NF(t,e){t.position&&(e.position=mI(t))}function TF(t,e){let n=e;if(t&&t.data){const s=t.data.hName,a=t.data.hChildren,r=t.data.hProperties;if(typeof s=="string")if(n.type==="element")n.tagName=s;else{const i="children"in n?n.children:[n];n={type:"element",tagName:s,properties:{},children:i}}n.type==="element"&&r&&Object.assign(n.properties,Cp(r)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function _F(t,e){const n=e.data||{},s="value"in e&&!(dx.call(n,"hProperties")||dx.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,s),t.applyData(e,s)}function EF(t,e){const n=[];let s=-1;for(e&&n.push({type:"text",value:`
|
|
57
|
+
`});++s<t.length;)s&&n.push({type:"text",value:`
|
|
58
|
+
`}),n.push(t[s]);return e&&t.length>0&&n.push({type:"text",value:`
|
|
59
|
+
`}),n}function sC(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function aC(t,e){const n=jF(t,e),s=n.one(t,void 0),a=gF(n),r=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&r.children.push({type:"text",value:`
|
|
60
|
+
`},a),r}function MF(t,e){return t&&"run"in t?async function(n,s){const a=aC(n,{file:s,...e});await t.run(a,s)}:function(n,s){return aC(n,{file:s,...t||e})}}function rC(t){if(t)throw t}var Jg,iC;function DF(){if(iC)return Jg;iC=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):e.call(f)==="[object Array]"},r=function(f){if(!f||e.call(f)!=="[object Object]")return!1;var h=t.call(f,"constructor"),m=f.constructor&&f.constructor.prototype&&t.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!h&&!m)return!1;var b;for(b in f);return typeof b>"u"||t.call(f,b)},i=function(f,h){n&&h.name==="__proto__"?n(f,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):f[h.name]=h.newValue},c=function(f,h){if(h==="__proto__")if(t.call(f,h)){if(s)return s(f,h).value}else return;return f[h]};return Jg=function d(){var f,h,m,b,y,w,C=arguments[0],N=1,k=arguments.length,j=!1;for(typeof C=="boolean"&&(j=C,C=arguments[1]||{},N=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});N<k;++N)if(f=arguments[N],f!=null)for(h in f)m=c(C,h),b=c(f,h),C!==b&&(j&&b&&(r(b)||(y=a(b)))?(y?(y=!1,w=m&&a(m)?m:[]):w=m&&r(m)?m:{},i(C,{name:h,newValue:d(j,w,b)})):typeof b<"u"&&i(C,{name:h,newValue:b}));return C},Jg}var RF=DF();const Zg=Xu(RF);function fx(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function OF(){const t=[],e={run:n,use:s};return e;function n(...a){let r=-1;const i=a.pop();if(typeof i!="function")throw new TypeError("Expected function as last argument, not "+i);c(null,...a);function c(d,...f){const h=t[++r];let m=-1;if(d){i(d);return}for(;++m<a.length;)(f[m]===null||f[m]===void 0)&&(f[m]=a[m]);a=f,h?LF(h,c)(...f):i(null,...f)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return t.push(a),e}}function LF(t,e){let n;return s;function s(...i){const c=t.length>i.length;let d;c&&i.push(a);try{d=t.apply(this,i)}catch(f){const h=f;if(c&&n)throw h;return a(h)}c||(d&&d.then&&typeof d.then=="function"?d.then(r,a):d instanceof Error?a(d):r(d))}function a(i,...c){n||(n=!0,e(i,...c))}function r(i){a(null,i)}}const Xa={basename:IF,dirname:PF,extname:BF,join:FF,sep:"/"};function IF(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');sd(t);let n=0,s=-1,a=t.length,r;if(e===void 0||e.length===0||e.length>t.length){for(;a--;)if(t.codePointAt(a)===47){if(r){n=a+1;break}}else s<0&&(r=!0,s=a+1);return s<0?"":t.slice(n,s)}if(e===t)return"";let i=-1,c=e.length-1;for(;a--;)if(t.codePointAt(a)===47){if(r){n=a+1;break}}else i<0&&(r=!0,i=a+1),c>-1&&(t.codePointAt(a)===e.codePointAt(c--)?c<0&&(s=a):(c=-1,s=i));return n===s?s=i:s<0&&(s=t.length),t.slice(n,s)}function PF(t){if(sd(t),t.length===0)return".";let e=-1,n=t.length,s;for(;--n;)if(t.codePointAt(n)===47){if(s){e=n;break}}else s||(s=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function BF(t){sd(t);let e=t.length,n=-1,s=0,a=-1,r=0,i;for(;e--;){const c=t.codePointAt(e);if(c===47){if(i){s=e+1;break}continue}n<0&&(i=!0,n=e+1),c===46?a<0?a=e:r!==1&&(r=1):a>-1&&(r=-1)}return a<0||n<0||r===0||r===1&&a===n-1&&a===s+1?"":t.slice(a,n)}function FF(...t){let e=-1,n;for(;++e<t.length;)sd(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":zF(n)}function zF(t){sd(t);const e=t.codePointAt(0)===47;let n=$F(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function $F(t,e){let n="",s=0,a=-1,r=0,i=-1,c,d;for(;++i<=t.length;){if(i<t.length)c=t.codePointAt(i);else{if(c===47)break;c=47}if(c===47){if(!(a===i-1||r===1))if(a!==i-1&&r===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",s=0):(n=n.slice(0,d),s=n.length-1-n.lastIndexOf("/")),a=i,r=0;continue}}else if(n.length>0){n="",s=0,a=i,r=0;continue}}e&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+t.slice(a+1,i):n=t.slice(a+1,i),s=i-a-1;a=i,r=0}else c===46&&r>-1?r++:r=-1}return n}function sd(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const UF={cwd:HF};function HF(){return"/"}function px(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function WF(t){if(typeof t=="string")t=new URL(t);else if(!px(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return qF(t)}function qF(t){if(t.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const s=e.codePointAt(n+2);if(s===70||s===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(e)}const eb=["history","path","basename","stem","extname","dirname"];class tN{constructor(e){let n;e?px(e)?n={path:e}:typeof e=="string"||VF(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":UF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<eb.length;){const r=eb[s];r in n&&n[r]!==void 0&&n[r]!==null&&(this[r]=r==="history"?[...n[r]]:n[r])}let a;for(a in n)eb.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Xa.basename(this.path):void 0}set basename(e){nb(e,"basename"),tb(e,"basename"),this.path=Xa.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Xa.dirname(this.path):void 0}set dirname(e){oC(this.basename,"dirname"),this.path=Xa.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Xa.extname(this.path):void 0}set extname(e){if(tb(e,"extname"),oC(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Xa.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){px(e)&&(e=WF(e)),nb(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Xa.basename(this.path,this.extname):void 0}set stem(e){nb(e,"stem"),tb(e,"stem"),this.path=Xa.join(this.dirname||"",e+(this.extname||""))}fail(e,n,s){const a=this.message(e,n,s);throw a.fatal=!0,a}info(e,n,s){const a=this.message(e,n,s);return a.fatal=void 0,a}message(e,n,s){const a=new Ns(e,n,s);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function tb(t,e){if(t&&t.includes(Xa.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Xa.sep+"`")}function nb(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function oC(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function VF(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const YF=(function(t){const s=this.constructor.prototype,a=s[t],r=function(){return a.apply(r,arguments)};return Object.setPrototypeOf(r,s),r}),GF={}.hasOwnProperty;class ly extends YF{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=OF()}copy(){const e=new ly;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];e.use(...s)}return e.data(Zg(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(rb("data",this.frozen),this.namespace[e]=n,this):GF.call(this.namespace,e)&&this.namespace[e]||void 0:e?(rb("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const a=n.call(e,...s);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=If(e),s=this.parser||this.Parser;return sb("parse",s),s(String(n),n)}process(e,n){const s=this;return this.freeze(),sb("process",this.parser||this.Parser),ab("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(r,i){const c=If(e),d=s.parse(c);s.run(d,c,function(h,m,b){if(h||!m||!b)return f(h);const y=m,w=s.stringify(y,b);XF(w)?b.value=w:b.result=w,f(h,b)});function f(h,m){h||!m?i(h):r?r(m):n(void 0,m)}}}processSync(e){let n=!1,s;return this.freeze(),sb("processSync",this.parser||this.Parser),ab("processSync",this.compiler||this.Compiler),this.process(e,a),cC("processSync","process",n),s;function a(r,i){n=!0,rC(r),s=i}}run(e,n,s){lC(e),this.freeze();const a=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?r(void 0,s):new Promise(r);function r(i,c){const d=If(n);a.run(e,d,f);function f(h,m,b){const y=m||e;h?c(h):i?i(y):s(void 0,y,b)}}}runSync(e,n){let s=!1,a;return this.run(e,n,r),cC("runSync","run",s),a;function r(i,c){rC(i),a=c,s=!0}}stringify(e,n){this.freeze();const s=If(n),a=this.compiler||this.Compiler;return ab("stringify",a),lC(e),a(e,s)}use(e,...n){const s=this.attachers,a=this.namespace;if(rb("use",this.frozen),e!=null)if(typeof e=="function")d(e,n);else if(typeof e=="object")Array.isArray(e)?c(e):i(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function r(f){if(typeof f=="function")d(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[h,...m]=f;d(h,m)}else i(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function i(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");c(f.plugins),f.settings&&(a.settings=Zg(!0,a.settings,f.settings))}function c(f){let h=-1;if(f!=null)if(Array.isArray(f))for(;++h<f.length;){const m=f[h];r(m)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function d(f,h){let m=-1,b=-1;for(;++m<s.length;)if(s[m][0]===f){b=m;break}if(b===-1)s.push([f,...h]);else if(h.length>0){let[y,...w]=h;const C=s[b][1];fx(C)&&fx(y)&&(y=Zg(!0,C,y)),s[b]=[f,y,...w]}}}}const KF=new ly().freeze();function sb(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function ab(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function rb(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function lC(t){if(!fx(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function cC(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function If(t){return QF(t)?t:new tN(t)}function QF(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function XF(t){return typeof t=="string"||JF(t)}function JF(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const ZF="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",uC=[],dC={allowDangerousHtml:!0},e8=/^(https?|ircs?|mailto|xmpp)$/i,t8=[{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 Fr(t){const e=n8(t),n=s8(t);return a8(e.runSync(e.parse(n),n),t)}function n8(t){const e=t.rehypePlugins||uC,n=t.remarkPlugins||uC,s=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...dC}:dC;return KF().use(PB).use(n).use(MF,s).use(e)}function s8(t){const e=t.children||"",n=new tN;return typeof e=="string"&&(n.value=e),n}function a8(t,e){const n=e.allowedElements,s=e.allowElement,a=e.components,r=e.disallowedElements,i=e.skipHtml,c=e.unwrapDisallowed,d=e.urlTransform||r8;for(const h of t8)Object.hasOwn(e,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+ZF+h.id,void 0);return oy(t,f),vI(t,{Fragment:o.Fragment,components:a,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function f(h,m,b){if(h.type==="raw"&&b&&typeof m=="number")return i?b.children.splice(m,1):b.children[m]={type:"text",value:h.value},m;if(h.type==="element"){let y;for(y in Kg)if(Object.hasOwn(Kg,y)&&Object.hasOwn(h.properties,y)){const w=h.properties[y],C=Kg[y];(C===null||C.includes(h.tagName))&&(h.properties[y]=d(String(w||""),y,h))}}if(h.type==="element"){let y=n?!n.includes(h.tagName):r?r.includes(h.tagName):!1;if(!y&&s&&typeof m=="number"&&(y=!s(h,m,b)),y&&b&&typeof m=="number")return c&&h.children?b.children.splice(m,1,...h.children):b.children.splice(m,1),m}}}function r8(t){const e=t.indexOf(":"),n=t.indexOf("?"),s=t.indexOf("#"),a=t.indexOf("/");return e===-1||a!==-1&&e>a||n!==-1&&e>n||s!==-1&&e>s||e8.test(t.slice(0,e))?t:""}function fC(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let s=0,a=n.indexOf(e);for(;a!==-1;)s++,a=n.indexOf(e,a+e.length);return s}function i8(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function o8(t,e,n){const a=th((n||{}).ignore||[]),r=l8(e);let i=-1;for(;++i<r.length;)eN(t,"text",c);function c(f,h){let m=-1,b;for(;++m<h.length;){const y=h[m],w=b?b.children:void 0;if(a(y,w?w.indexOf(y):void 0,b))return;b=y}if(b)return d(f,h)}function d(f,h){const m=h[h.length-1],b=r[i][0],y=r[i][1];let w=0;const N=m.children.indexOf(f);let k=!1,j=[];b.lastIndex=0;let S=b.exec(f.value);for(;S;){const T=S.index,D={index:S.index,input:S.input,stack:[...h,f]};let E=y(...S,D);if(typeof E=="string"&&(E=E.length>0?{type:"text",value:E}:void 0),E===!1?b.lastIndex=T+1:(w!==T&&j.push({type:"text",value:f.value.slice(w,T)}),Array.isArray(E)?j.push(...E):E&&j.push(E),w=T+S[0].length,k=!0),!b.global)break;S=b.exec(f.value)}return k?(w<f.value.length&&j.push({type:"text",value:f.value.slice(w)}),m.children.splice(N,1,...j)):j=[f],N+j.length}}function l8(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!t[0]||Array.isArray(t[0])?t:[t];let s=-1;for(;++s<n.length;){const a=n[s];e.push([c8(a[0]),u8(a[1])])}return e}function c8(t){return typeof t=="string"?new RegExp(i8(t),"g"):t}function u8(t){return typeof t=="function"?t:function(){return t}}const ib="phrasing",ob=["autolink","link","image","label"];function d8(){return{transforms:[x8],enter:{literalAutolink:p8,literalAutolinkEmail:lb,literalAutolinkHttp:lb,literalAutolinkWww:lb},exit:{literalAutolink:b8,literalAutolinkEmail:g8,literalAutolinkHttp:h8,literalAutolinkWww:m8}}}function f8(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ib,notInConstruct:ob},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ib,notInConstruct:ob},{character:":",before:"[ps]",after:"\\/",inConstruct:ib,notInConstruct:ob}]}}function p8(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function lb(t){this.config.enter.autolinkProtocol.call(this,t)}function h8(t){this.config.exit.autolinkProtocol.call(this,t)}function m8(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function g8(t){this.config.exit.autolinkEmail.call(this,t)}function b8(t){this.exit(t)}function x8(t){o8(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,y8],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),v8]],{ignore:["link","linkReference"]})}function y8(t,e,n,s,a){let r="";if(!nN(a)||(/^w/i.test(e)&&(n=e+n,e="",r="http://"),!w8(n)))return!1;const i=k8(n+s);if(!i[0])return!1;const c={type:"link",title:null,url:r+e+i[0],children:[{type:"text",value:e+i[0]}]};return i[1]?[c,{type:"text",value:i[1]}]:c}function v8(t,e,n,s){return!nN(s,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function w8(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function k8(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let n=e[0],s=n.indexOf(")");const a=fC(t,"(");let r=fC(t,")");for(;s!==-1&&a>r;)t+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),r++;return[t,n]}function nN(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Eo(n)||Jp(n))&&(!e||n!==47)}sN.peek=M8;function S8(){this.buffer()}function C8(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function A8(){this.buffer()}function j8(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function N8(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ia(this.sliceSerialize(t)).toLowerCase(),n.label=e}function T8(t){this.exit(t)}function _8(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ia(this.sliceSerialize(t)).toLowerCase(),n.label=e}function E8(t){this.exit(t)}function M8(){return"["}function sN(t,e,n,s){const a=n.createTracker(s);let r=a.move("[^");const i=n.enter("footnoteReference"),c=n.enter("reference");return r+=a.move(n.safe(n.associationId(t),{after:"]",before:r})),c(),i(),r+=a.move("]"),r}function D8(){return{enter:{gfmFootnoteCallString:S8,gfmFootnoteCall:C8,gfmFootnoteDefinitionLabelString:A8,gfmFootnoteDefinition:j8},exit:{gfmFootnoteCallString:N8,gfmFootnoteCall:T8,gfmFootnoteDefinitionLabelString:_8,gfmFootnoteDefinition:E8}}}function R8(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:sN},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,r,i){const c=r.createTracker(i);let d=c.move("[^");const f=r.enter("footnoteDefinition"),h=r.enter("label");return d+=c.move(r.safe(r.associationId(s),{before:d,after:"]"})),h(),d+=c.move("]:"),s.children&&s.children.length>0&&(c.shift(4),d+=c.move((e?`
|
|
61
|
+
`:" ")+r.indentLines(r.containerFlow(s,c.current()),e?aN:O8))),f(),d}}function O8(t,e,n){return e===0?t:aN(t,e,n)}function aN(t,e,n){return(n?"":" ")+t}const L8=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];rN.peek=z8;function I8(){return{canContainEols:["delete"],enter:{strikethrough:B8},exit:{strikethrough:F8}}}function P8(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:L8}],handlers:{delete:rN}}}function B8(t){this.enter({type:"delete",children:[]},t)}function F8(t){this.exit(t)}function rN(t,e,n,s){const a=n.createTracker(s),r=n.enter("strikethrough");let i=a.move("~~");return i+=n.containerPhrasing(t,{...a.current(),before:i,after:"~"}),i+=a.move("~~"),r(),i}function z8(){return"~"}function $8(t){return t.length}function U8(t,e){const n=e||{},s=(n.align||[]).concat(),a=n.stringLength||$8,r=[],i=[],c=[],d=[];let f=0,h=-1;for(;++h<t.length;){const C=[],N=[];let k=-1;for(t[h].length>f&&(f=t[h].length);++k<t[h].length;){const j=H8(t[h][k]);if(n.alignDelimiters!==!1){const S=a(j);N[k]=S,(d[k]===void 0||S>d[k])&&(d[k]=S)}C.push(j)}i[h]=C,c[h]=N}let m=-1;if(typeof s=="object"&&"length"in s)for(;++m<f;)r[m]=pC(s[m]);else{const C=pC(s);for(;++m<f;)r[m]=C}m=-1;const b=[],y=[];for(;++m<f;){const C=r[m];let N="",k="";C===99?(N=":",k=":"):C===108?N=":":C===114&&(k=":");let j=n.alignDelimiters===!1?1:Math.max(1,d[m]-N.length-k.length);const S=N+"-".repeat(j)+k;n.alignDelimiters!==!1&&(j=N.length+j+k.length,j>d[m]&&(d[m]=j),y[m]=j),b[m]=S}i.splice(1,0,b),c.splice(1,0,y),h=-1;const w=[];for(;++h<i.length;){const C=i[h],N=c[h];m=-1;const k=[];for(;++m<f;){const j=C[m]||"";let S="",T="";if(n.alignDelimiters!==!1){const D=d[m]-(N[m]||0),E=r[m];E===114?S=" ".repeat(D):E===99?D%2?(S=" ".repeat(D/2+.5),T=" ".repeat(D/2-.5)):(S=" ".repeat(D/2),T=S):T=" ".repeat(D)}n.delimiterStart!==!1&&!m&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&j==="")&&(n.delimiterStart!==!1||m)&&k.push(" "),n.alignDelimiters!==!1&&k.push(S),k.push(j),n.alignDelimiters!==!1&&k.push(T),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||m!==f-1)&&k.push("|")}w.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return w.join(`
|
|
62
|
+
`)}function H8(t){return t==null?"":String(t)}function pC(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function W8(t,e,n,s){const a=n.enter("blockquote"),r=n.createTracker(s);r.move("> "),r.shift(2);const i=n.indentLines(n.containerFlow(t,r.current()),q8);return a(),i}function q8(t,e,n){return">"+(n?"":" ")+t}function V8(t,e){return hC(t,e.inConstruct,!0)&&!hC(t,e.notInConstruct,!1)}function hC(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let s=-1;for(;++s<e.length;)if(t.includes(e[s]))return!0;return!1}function mC(t,e,n,s){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
63
|
+
`&&V8(n.stack,n.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
|
|
64
|
+
`}function Y8(t,e){const n=String(t);let s=n.indexOf(e),a=s,r=0,i=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;s!==-1;)s===a?++r>i&&(i=r):r=1,a=s+e.length,s=n.indexOf(e,a);return i}function G8(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function K8(t){const e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function Q8(t,e,n,s){const a=K8(n),r=t.value||"",i=a==="`"?"GraveAccent":"Tilde";if(G8(t,n)){const m=n.enter("codeIndented"),b=n.indentLines(r,X8);return m(),b}const c=n.createTracker(s),d=a.repeat(Math.max(Y8(r,a)+1,3)),f=n.enter("codeFenced");let h=c.move(d);if(t.lang){const m=n.enter(`codeFencedLang${i}`);h+=c.move(n.safe(t.lang,{before:h,after:" ",encode:["`"],...c.current()})),m()}if(t.lang&&t.meta){const m=n.enter(`codeFencedMeta${i}`);h+=c.move(" "),h+=c.move(n.safe(t.meta,{before:h,after:`
|
|
65
|
+
`,encode:["`"],...c.current()})),m()}return h+=c.move(`
|
|
66
|
+
`),r&&(h+=c.move(r+`
|
|
67
|
+
`)),h+=c.move(d),f(),h}function X8(t,e,n){return(n?"":" ")+t}function cy(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function J8(t,e,n,s){const a=cy(n),r=a==='"'?"Quote":"Apostrophe",i=n.enter("definition");let c=n.enter("label");const d=n.createTracker(s);let f=d.move("[");return f+=d.move(n.safe(n.associationId(t),{before:f,after:"]",...d.current()})),f+=d.move("]: "),c(),!t.url||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(t.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(t.url,{before:f,after:t.title?" ":`
|
|
68
|
+
`,...d.current()}))),c(),t.title&&(c=n.enter(`title${r}`),f+=d.move(" "+a),f+=d.move(n.safe(t.title,{before:f,after:a,...d.current()})),f+=d.move(a),c()),i(),f}function Z8(t){const e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Yu(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Ap(t,e,n){const s=Gl(t),a=Gl(e);return s===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}iN.peek=e9;function iN(t,e,n,s){const a=Z8(n),r=n.enter("emphasis"),i=n.createTracker(s),c=i.move(a);let d=i.move(n.containerPhrasing(t,{after:a,before:c,...i.current()}));const f=d.charCodeAt(0),h=Ap(s.before.charCodeAt(s.before.length-1),f,a);h.inside&&(d=Yu(f)+d.slice(1));const m=d.charCodeAt(d.length-1),b=Ap(s.after.charCodeAt(0),m,a);b.inside&&(d=d.slice(0,-1)+Yu(m));const y=i.move(a);return r(),n.attentionEncodeSurroundingInfo={after:b.outside,before:h.outside},c+d+y}function e9(t,e,n){return n.options.emphasis||"*"}function t9(t,e){let n=!1;return oy(t,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,ux}),!!((!t.depth||t.depth<3)&&ey(t)&&(e.options.setext||n))}function n9(t,e,n,s){const a=Math.max(Math.min(6,t.depth||1),1),r=n.createTracker(s);if(t9(t,n)){const h=n.enter("headingSetext"),m=n.enter("phrasing"),b=n.containerPhrasing(t,{...r.current(),before:`
|
|
69
|
+
`,after:`
|
|
70
|
+
`});return m(),h(),b+`
|
|
71
|
+
`+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(`
|
|
72
|
+
`))+1))}const i="#".repeat(a),c=n.enter("headingAtx"),d=n.enter("phrasing");r.move(i+" ");let f=n.containerPhrasing(t,{before:"# ",after:`
|
|
73
|
+
`,...r.current()});return/^[\t ]/.test(f)&&(f=Yu(f.charCodeAt(0))+f.slice(1)),f=f?i+" "+f:i,n.options.closeAtx&&(f+=" "+i),d(),c(),f}oN.peek=s9;function oN(t){return t.value||""}function s9(){return"<"}lN.peek=a9;function lN(t,e,n,s){const a=cy(n),r=a==='"'?"Quote":"Apostrophe",i=n.enter("image");let c=n.enter("label");const d=n.createTracker(s);let f=d.move("![");return f+=d.move(n.safe(t.alt,{before:f,after:"]",...d.current()})),f+=d.move("]("),c(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(t.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(t.url,{before:f,after:t.title?" ":")",...d.current()}))),c(),t.title&&(c=n.enter(`title${r}`),f+=d.move(" "+a),f+=d.move(n.safe(t.title,{before:f,after:a,...d.current()})),f+=d.move(a),c()),f+=d.move(")"),i(),f}function a9(){return"!"}cN.peek=r9;function cN(t,e,n,s){const a=t.referenceType,r=n.enter("imageReference");let i=n.enter("label");const c=n.createTracker(s);let d=c.move("![");const f=n.safe(t.alt,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),i();const h=n.stack;n.stack=[],i=n.enter("reference");const m=n.safe(n.associationId(t),{before:d,after:"]",...c.current()});return i(),n.stack=h,r(),a==="full"||!f||f!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function r9(){return"!"}uN.peek=i9;function uN(t,e,n){let s=t.value||"",a="`",r=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++r<n.unsafe.length;){const i=n.unsafe[r],c=n.compilePattern(i);let d;if(i.atBreak)for(;d=c.exec(s);){let f=d.index;s.charCodeAt(f)===10&&s.charCodeAt(f-1)===13&&f--,s=s.slice(0,f)+" "+s.slice(d.index+1)}}return a+s+a}function i9(){return"`"}function dN(t,e){const n=ey(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}fN.peek=o9;function fN(t,e,n,s){const a=cy(n),r=a==='"'?"Quote":"Apostrophe",i=n.createTracker(s);let c,d;if(dN(t,n)){const h=n.stack;n.stack=[],c=n.enter("autolink");let m=i.move("<");return m+=i.move(n.containerPhrasing(t,{before:m,after:">",...i.current()})),m+=i.move(">"),c(),n.stack=h,m}c=n.enter("link"),d=n.enter("label");let f=i.move("[");return f+=i.move(n.containerPhrasing(t,{before:f,after:"](",...i.current()})),f+=i.move("]("),d(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(d=n.enter("destinationLiteral"),f+=i.move("<"),f+=i.move(n.safe(t.url,{before:f,after:">",...i.current()})),f+=i.move(">")):(d=n.enter("destinationRaw"),f+=i.move(n.safe(t.url,{before:f,after:t.title?" ":")",...i.current()}))),d(),t.title&&(d=n.enter(`title${r}`),f+=i.move(" "+a),f+=i.move(n.safe(t.title,{before:f,after:a,...i.current()})),f+=i.move(a),d()),f+=i.move(")"),c(),f}function o9(t,e,n){return dN(t,n)?"<":"["}pN.peek=l9;function pN(t,e,n,s){const a=t.referenceType,r=n.enter("linkReference");let i=n.enter("label");const c=n.createTracker(s);let d=c.move("[");const f=n.containerPhrasing(t,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),i();const h=n.stack;n.stack=[],i=n.enter("reference");const m=n.safe(n.associationId(t),{before:d,after:"]",...c.current()});return i(),n.stack=h,r(),a==="full"||!f||f!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function l9(){return"["}function uy(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function c9(t){const e=uy(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function u9(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function hN(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function d9(t,e,n,s){const a=n.enter("list"),r=n.bulletCurrent;let i=t.ordered?u9(n):uy(n);const c=t.ordered?i==="."?")":".":c9(n);let d=e&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!t.ordered){const h=t.children?t.children[0]:void 0;if((i==="*"||i==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),hN(n)===i&&h){let m=-1;for(;++m<t.children.length;){const b=t.children[m];if(b&&b.type==="listItem"&&b.children&&b.children[0]&&b.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(i=c),n.bulletCurrent=i;const f=n.containerFlow(t,s);return n.bulletLastUsed=i,n.bulletCurrent=r,a(),f}function f9(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function p9(t,e,n,s){const a=f9(n);let r=n.bulletCurrent||uy(n);e&&e.type==="list"&&e.ordered&&(r=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+r);let i=r.length+1;(a==="tab"||a==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(i=Math.ceil(i/4)*4);const c=n.createTracker(s);c.move(r+" ".repeat(i-r.length)),c.shift(i);const d=n.enter("listItem"),f=n.indentLines(n.containerFlow(t,c.current()),h);return d(),f;function h(m,b,y){return b?(y?"":" ".repeat(i))+m:(y?r:r+" ".repeat(i-r.length))+m}}function h9(t,e,n,s){const a=n.enter("paragraph"),r=n.enter("phrasing"),i=n.containerPhrasing(t,s);return r(),a(),i}const m9=th(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function g9(t,e,n,s){return(t.children.some(function(i){return m9(i)})?n.containerPhrasing:n.containerFlow).call(n,t,s)}function b9(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}mN.peek=x9;function mN(t,e,n,s){const a=b9(n),r=n.enter("strong"),i=n.createTracker(s),c=i.move(a+a);let d=i.move(n.containerPhrasing(t,{after:a,before:c,...i.current()}));const f=d.charCodeAt(0),h=Ap(s.before.charCodeAt(s.before.length-1),f,a);h.inside&&(d=Yu(f)+d.slice(1));const m=d.charCodeAt(d.length-1),b=Ap(s.after.charCodeAt(0),m,a);b.inside&&(d=d.slice(0,-1)+Yu(m));const y=i.move(a+a);return r(),n.attentionEncodeSurroundingInfo={after:b.outside,before:h.outside},c+d+y}function x9(t,e,n){return n.options.strong||"*"}function y9(t,e,n,s){return n.safe(t.value,s)}function v9(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function w9(t,e,n){const s=(hN(n)+(n.options.ruleSpaces?" ":"")).repeat(v9(n));return n.options.ruleSpaces?s.slice(0,-1):s}const gN={blockquote:W8,break:mC,code:Q8,definition:J8,emphasis:iN,hardBreak:mC,heading:n9,html:oN,image:lN,imageReference:cN,inlineCode:uN,link:fN,linkReference:pN,list:d9,listItem:p9,paragraph:h9,root:g9,strong:mN,text:y9,thematicBreak:w9};function k9(){return{enter:{table:S9,tableData:gC,tableHeader:gC,tableRow:A9},exit:{codeText:j9,table:C9,tableData:cb,tableHeader:cb,tableRow:cb}}}function S9(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function C9(t){this.exit(t),this.data.inTable=void 0}function A9(t){this.enter({type:"tableRow",children:[]},t)}function cb(t){this.exit(t)}function gC(t){this.enter({type:"tableCell",children:[]},t)}function j9(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,N9));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function N9(t,e){return e==="|"?e:t}function T9(t){const e=t||{},n=e.tableCellPadding,s=e.tablePipeAlign,a=e.stringLength,r=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
74
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:i,tableCell:d,tableRow:c}};function i(y,w,C,N){return f(h(y,C,N),y.align)}function c(y,w,C,N){const k=m(y,C,N),j=f([k]);return j.slice(0,j.indexOf(`
|
|
75
|
+
`))}function d(y,w,C,N){const k=C.enter("tableCell"),j=C.enter("phrasing"),S=C.containerPhrasing(y,{...N,before:r,after:r});return j(),k(),S}function f(y,w){return U8(y,{align:w,alignDelimiters:s,padding:n,stringLength:a})}function h(y,w,C){const N=y.children;let k=-1;const j=[],S=w.enter("table");for(;++k<N.length;)j[k]=m(N[k],w,C);return S(),j}function m(y,w,C){const N=y.children;let k=-1;const j=[],S=w.enter("tableRow");for(;++k<N.length;)j[k]=d(N[k],y,w,C);return S(),j}function b(y,w,C){let N=gN.inlineCode(y,w,C);return C.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function _9(){return{exit:{taskListCheckValueChecked:bC,taskListCheckValueUnchecked:bC,paragraph:M9}}}function E9(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:D9}}}function bC(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function M9(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const s=n.children[0];if(s&&s.type==="text"){const a=e.children;let r=-1,i;for(;++r<a.length;){const c=a[r];if(c.type==="paragraph"){i=c;break}}i===n&&(s.value=s.value.slice(1),s.value.length===0?n.children.shift():n.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,n.position.start=Object.assign({},s.position.start)))}}this.exit(t)}function D9(t,e,n,s){const a=t.children[0],r=typeof t.checked=="boolean"&&a&&a.type==="paragraph",i="["+(t.checked?"x":" ")+"] ",c=n.createTracker(s);r&&c.move(i);let d=gN.listItem(t,e,n,{...s,...c.current()});return r&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),d;function f(h){return h+i}}function R9(){return[d8(),D8(),I8(),k9(),_9()]}function O9(t){return{extensions:[f8(),R8(t),P8(),T9(t),E9()]}}const L9={tokenize:$9,partial:!0},bN={tokenize:U9,partial:!0},xN={tokenize:H9,partial:!0},yN={tokenize:W9,partial:!0},I9={tokenize:q9,partial:!0},vN={name:"wwwAutolink",tokenize:F9,previous:kN},wN={name:"protocolAutolink",tokenize:z9,previous:SN},Yr={name:"emailAutolink",tokenize:B9,previous:CN},hr={};function P9(){return{text:hr}}let mo=48;for(;mo<123;)hr[mo]=Yr,mo++,mo===58?mo=65:mo===91&&(mo=97);hr[43]=Yr;hr[45]=Yr;hr[46]=Yr;hr[95]=Yr;hr[72]=[Yr,wN];hr[104]=[Yr,wN];hr[87]=[Yr,vN];hr[119]=[Yr,vN];function B9(t,e,n){const s=this;let a,r;return i;function i(m){return!hx(m)||!CN.call(s,s.previous)||dy(s.events)?n(m):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(m))}function c(m){return hx(m)?(t.consume(m),c):m===64?(t.consume(m),d):n(m)}function d(m){return m===46?t.check(I9,h,f)(m):m===45||m===95||js(m)?(r=!0,t.consume(m),d):h(m)}function f(m){return t.consume(m),a=!0,d}function h(m){return r&&a&&Ms(s.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(m)):n(m)}}function F9(t,e,n){const s=this;return a;function a(i){return i!==87&&i!==119||!kN.call(s,s.previous)||dy(s.events)?n(i):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(L9,t.attempt(bN,t.attempt(xN,r),n),n)(i))}function r(i){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(i)}}function z9(t,e,n){const s=this;let a="",r=!1;return i;function i(m){return(m===72||m===104)&&SN.call(s,s.previous)&&!dy(s.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),t.consume(m),c):n(m)}function c(m){if(Ms(m)&&a.length<5)return a+=String.fromCodePoint(m),t.consume(m),c;if(m===58){const b=a.toLowerCase();if(b==="http"||b==="https")return t.consume(m),d}return n(m)}function d(m){return m===47?(t.consume(m),r?f:(r=!0,d)):n(m)}function f(m){return m===null||kp(m)||_n(m)||Eo(m)||Jp(m)?n(m):t.attempt(bN,t.attempt(xN,h),n)(m)}function h(m){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(m)}}function $9(t,e,n){let s=0;return a;function a(i){return(i===87||i===119)&&s<3?(s++,t.consume(i),a):i===46&&s===3?(t.consume(i),r):n(i)}function r(i){return i===null?n(i):e(i)}}function U9(t,e,n){let s,a,r;return i;function i(f){return f===46||f===95?t.check(yN,d,c)(f):f===null||_n(f)||Eo(f)||f!==45&&Jp(f)?d(f):(r=!0,t.consume(f),i)}function c(f){return f===95?s=!0:(a=s,s=void 0),t.consume(f),i}function d(f){return a||s||!r?n(f):e(f)}}function H9(t,e){let n=0,s=0;return a;function a(i){return i===40?(n++,t.consume(i),a):i===41&&s<n?r(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?t.check(yN,e,r)(i):i===null||_n(i)||Eo(i)?e(i):(t.consume(i),a)}function r(i){return i===41&&s++,t.consume(i),a}}function W9(t,e,n){return s;function s(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(t.consume(c),s):c===38?(t.consume(c),r):c===93?(t.consume(c),a):c===60||c===null||_n(c)||Eo(c)?e(c):n(c)}function a(c){return c===null||c===40||c===91||_n(c)||Eo(c)?e(c):s(c)}function r(c){return Ms(c)?i(c):n(c)}function i(c){return c===59?(t.consume(c),s):Ms(c)?(t.consume(c),i):n(c)}}function q9(t,e,n){return s;function s(r){return t.consume(r),a}function a(r){return js(r)?n(r):e(r)}}function kN(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||_n(t)}function SN(t){return!Ms(t)}function CN(t){return!(t===47||hx(t))}function hx(t){return t===43||t===45||t===46||t===95||js(t)}function dy(t){let e=t.length,n=!1;for(;e--;){const s=t[e][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){n=!0;break}if(s._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const V9={tokenize:e4,partial:!0};function Y9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:X9,continuation:{tokenize:J9},exit:Z9}},text:{91:{name:"gfmFootnoteCall",tokenize:Q9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:G9,resolveTo:K9}}}}function G9(t,e,n){const s=this;let a=s.events.length;const r=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let i;for(;a--;){const d=s.events[a][1];if(d.type==="labelImage"){i=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!i||!i._balanced)return n(d);const f=Ia(s.sliceSerialize({start:i.end,end:s.now()}));return f.codePointAt(0)!==94||!r.includes(f.slice(1))?n(d):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),e(d))}}function K9(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const r={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},t[t.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},r.start),end:Object.assign({},r.end)},c=[t[n+1],t[n+2],["enter",s,e],t[n+3],t[n+4],["enter",a,e],["exit",a,e],["enter",r,e],["enter",i,e],["exit",i,e],["exit",r,e],t[t.length-2],t[t.length-1],["exit",s,e]];return t.splice(n,t.length-n+1,...c),t}function Q9(t,e,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let r=0,i;return c;function c(m){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(t.enter("gfmFootnoteCallMarker"),t.consume(m),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",f)}function f(m){if(r>999||m===93&&!i||m===null||m===91||_n(m))return n(m);if(m===93){t.exit("chunkString");const b=t.exit("gfmFootnoteCallString");return a.includes(Ia(s.sliceSerialize(b)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(m)}return _n(m)||(i=!0),r++,t.consume(m),m===92?h:f}function h(m){return m===91||m===92||m===93?(t.consume(m),r++,f):f(m)}}function X9(t,e,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let r,i=0,c;return d;function d(w){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",h):n(w)}function h(w){if(i>999||w===93&&!c||w===null||w===91||_n(w))return n(w);if(w===93){t.exit("chunkString");const C=t.exit("gfmFootnoteDefinitionLabelString");return r=Ia(s.sliceSerialize(C)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),b}return _n(w)||(c=!0),i++,t.consume(w),w===92?m:h}function m(w){return w===91||w===92||w===93?(t.consume(w),i++,h):h(w)}function b(w){return w===58?(t.enter("definitionMarker"),t.consume(w),t.exit("definitionMarker"),a.includes(r)||a.push(r),un(t,y,"gfmFootnoteDefinitionWhitespace")):n(w)}function y(w){return e(w)}}function J9(t,e,n){return t.check(nd,e,t.attempt(V9,e,n))}function Z9(t){t.exit("gfmFootnoteDefinition")}function e4(t,e,n){const s=this;return un(t,a,"gfmFootnoteDefinitionIndent",5);function a(r){const i=s.events[s.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?e(r):n(r)}}function t4(t){let n=(t||{}).singleTilde;const s={name:"strikethrough",tokenize:r,resolveAll:a};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(i,c){let d=-1;for(;++d<i.length;)if(i[d][0]==="enter"&&i[d][1].type==="strikethroughSequenceTemporary"&&i[d][1]._close){let f=d;for(;f--;)if(i[f][0]==="exit"&&i[f][1].type==="strikethroughSequenceTemporary"&&i[f][1]._open&&i[d][1].end.offset-i[d][1].start.offset===i[f][1].end.offset-i[f][1].start.offset){i[d][1].type="strikethroughSequence",i[f][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},i[f][1].start),end:Object.assign({},i[d][1].end)},m={type:"strikethroughText",start:Object.assign({},i[f][1].end),end:Object.assign({},i[d][1].start)},b=[["enter",h,c],["enter",i[f][1],c],["exit",i[f][1],c],["enter",m,c]],y=c.parser.constructs.insideSpan.null;y&&ua(b,b.length,0,Zp(y,i.slice(f+1,d),c)),ua(b,b.length,0,[["exit",m,c],["enter",i[d][1],c],["exit",i[d][1],c],["exit",h,c]]),ua(i,f-1,d-f+3,b),d=f+b.length-2;break}}for(d=-1;++d<i.length;)i[d][1].type==="strikethroughSequenceTemporary"&&(i[d][1].type="data");return i}function r(i,c,d){const f=this.previous,h=this.events;let m=0;return b;function b(w){return f===126&&h[h.length-1][1].type!=="characterEscape"?d(w):(i.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const C=Gl(f);if(w===126)return m>1?d(w):(i.consume(w),m++,y);if(m<2&&!n)return d(w);const N=i.exit("strikethroughSequenceTemporary"),k=Gl(w);return N._open=!k||k===2&&!!C,N._close=!C||C===2&&!!k,c(w)}}}class n4{constructor(){this.map=[]}add(e,n,s){s4(this,e,n,s)}consume(e){if(this.map.sort(function(r,i){return r[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];s.push(e.slice()),e.length=0;let a=s.pop();for(;a;){for(const r of a)e.push(r);a=s.pop()}this.map.length=0}}function s4(t,e,n,s){let a=0;if(!(n===0&&s.length===0)){for(;a<t.map.length;){if(t.map[a][0]===e){t.map[a][1]+=n,t.map[a][2].push(...s);return}a+=1}t.map.push([e,n,s])}}function a4(t,e){let n=!1;const s=[];for(;e<t.length;){const a=t[e];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&s.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const r=s.length-1;s[r]=s[r]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return s}function r4(){return{flow:{null:{name:"table",tokenize:i4,resolveAll:o4}}}}function i4(t,e,n){const s=this;let a=0,r=0,i;return c;function c(M){let R=s.events.length-1;for(;R>-1;){const W=s.events[R][1].type;if(W==="lineEnding"||W==="linePrefix")R--;else break}const z=R>-1?s.events[R][1].type:null,$=z==="tableHead"||z==="tableRow"?E:d;return $===E&&s.parser.lazy[s.now().line]?n(M):$(M)}function d(M){return t.enter("tableHead"),t.enter("tableRow"),f(M)}function f(M){return M===124||(i=!0,r+=1),h(M)}function h(M){return M===null?n(M):Et(M)?r>1?(r=0,s.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(M),t.exit("lineEnding"),y):n(M):en(M)?un(t,h,"whitespace")(M):(r+=1,i&&(i=!1,a+=1),M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),i=!0,h):(t.enter("data"),m(M)))}function m(M){return M===null||M===124||_n(M)?(t.exit("data"),h(M)):(t.consume(M),M===92?b:m)}function b(M){return M===92||M===124?(t.consume(M),m):m(M)}function y(M){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(M):(t.enter("tableDelimiterRow"),i=!1,en(M)?un(t,w,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):w(M))}function w(M){return M===45||M===58?N(M):M===124?(i=!0,t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),C):D(M)}function C(M){return en(M)?un(t,N,"whitespace")(M):N(M)}function N(M){return M===58?(r+=1,i=!0,t.enter("tableDelimiterMarker"),t.consume(M),t.exit("tableDelimiterMarker"),k):M===45?(r+=1,k(M)):M===null||Et(M)?T(M):D(M)}function k(M){return M===45?(t.enter("tableDelimiterFiller"),j(M)):D(M)}function j(M){return M===45?(t.consume(M),j):M===58?(i=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(M),t.exit("tableDelimiterMarker"),S):(t.exit("tableDelimiterFiller"),S(M))}function S(M){return en(M)?un(t,T,"whitespace")(M):T(M)}function T(M){return M===124?w(M):M===null||Et(M)?!i||a!==r?D(M):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(M)):D(M)}function D(M){return n(M)}function E(M){return t.enter("tableRow"),I(M)}function I(M){return M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),I):M===null||Et(M)?(t.exit("tableRow"),e(M)):en(M)?un(t,I,"whitespace")(M):(t.enter("data"),O(M))}function O(M){return M===null||M===124||_n(M)?(t.exit("data"),I(M)):(t.consume(M),M===92?_:O)}function _(M){return M===92||M===124?(t.consume(M),O):O(M)}}function o4(t,e){let n=-1,s=!0,a=0,r=[0,0,0,0],i=[0,0,0,0],c=!1,d=0,f,h,m;const b=new n4;for(;++n<t.length;){const y=t[n],w=y[1];y[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(xC(b,e,d,f,h),h=void 0,d=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},b.add(n,0,[["enter",f,e]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(s=!0,m=void 0,r=[0,0,0,0],i=[0,n+1,0,0],c&&(c=!1,h={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},b.add(n,0,[["enter",h,e]])),a=w.type==="tableDelimiterRow"?2:h?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(s=!1,i[2]===0&&(r[1]!==0&&(i[0]=i[1],m=Pf(b,e,r,a,void 0,m),r=[0,0,0,0]),i[2]=n)):w.type==="tableCellDivider"&&(s?s=!1:(r[1]!==0&&(i[0]=i[1],m=Pf(b,e,r,a,void 0,m)),r=i,i=[r[1],n,0,0])):w.type==="tableHead"?(c=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,r[1]!==0?(i[0]=i[1],m=Pf(b,e,r,a,n,m)):i[1]!==0&&(m=Pf(b,e,i,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(i[3]=n)}for(d!==0&&xC(b,e,d,f,h),b.consume(e.events),n=-1;++n<e.events.length;){const y=e.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=a4(e.events,n))}return t}function Pf(t,e,n,s,a,r){const i=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(r.end=Object.assign({},Pl(e.events,n[0])),t.add(n[0],0,[["exit",r,e]]));const d=Pl(e.events,n[1]);if(r={type:i,start:Object.assign({},d),end:Object.assign({},d)},t.add(n[1],0,[["enter",r,e]]),n[2]!==0){const f=Pl(e.events,n[2]),h=Pl(e.events,n[3]),m={type:c,start:Object.assign({},f),end:Object.assign({},h)};if(t.add(n[2],0,[["enter",m,e]]),s!==2){const b=e.events[n[2]],y=e.events[n[3]];if(b[1].end=Object.assign({},y[1].end),b[1].type="chunkText",b[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;t.add(w,C,[])}}t.add(n[3]+1,0,[["exit",m,e]])}return a!==void 0&&(r.end=Object.assign({},Pl(e.events,a)),t.add(a,0,[["exit",r,e]]),r=void 0),r}function xC(t,e,n,s,a){const r=[],i=Pl(e.events,n);a&&(a.end=Object.assign({},i),r.push(["exit",a,e])),s.end=Object.assign({},i),r.push(["exit",s,e]),t.add(n+1,0,r)}function Pl(t,e){const n=t[e],s=n[0]==="enter"?"start":"end";return n[1][s]}const l4={name:"tasklistCheck",tokenize:u4};function c4(){return{text:{91:l4}}}function u4(t,e,n){const s=this;return a;function a(d){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(d):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(d),t.exit("taskListCheckMarker"),r)}function r(d){return _n(d)?(t.enter("taskListCheckValueUnchecked"),t.consume(d),t.exit("taskListCheckValueUnchecked"),i):d===88||d===120?(t.enter("taskListCheckValueChecked"),t.consume(d),t.exit("taskListCheckValueChecked"),i):n(d)}function i(d){return d===93?(t.enter("taskListCheckMarker"),t.consume(d),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),c):n(d)}function c(d){return Et(d)?e(d):en(d)?t.check({tokenize:d4},e,n)(d):n(d)}}function d4(t,e,n){return un(t,s,"whitespace");function s(a){return a===null?n(a):e(a)}}function f4(t){return L1([P9(),Y9(),t4(t),r4(),c4()])}const p4={};function zr(t){const e=this,n=t||p4,s=e.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),r=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),i=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(f4(n)),r.push(R9()),i.push(O9(n))}var ub={exports:{}},yC;function h4(){return yC||(yC=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
|
|
76
|
+
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
77
|
+
*
|
|
78
|
+
* @license MIT <https://opensource.org/licenses/MIT>
|
|
79
|
+
* @author Lea Verou <https://lea.verou.me>
|
|
80
|
+
* @namespace
|
|
81
|
+
* @public
|
|
82
|
+
*/var n=(function(s){var a=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,r=0,i={},c={manual:s.Prism&&s.Prism.manual,disableWorkerMessageHandler:s.Prism&&s.Prism.disableWorkerMessageHandler,util:{encode:function j(S){return S instanceof d?new d(S.type,j(S.content),S.alias):Array.isArray(S)?S.map(j):S.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(j){return Object.prototype.toString.call(j).slice(8,-1)},objId:function(j){return j.__id||Object.defineProperty(j,"__id",{value:++r}),j.__id},clone:function j(S,T){T=T||{};var D,E;switch(c.util.type(S)){case"Object":if(E=c.util.objId(S),T[E])return T[E];D={},T[E]=D;for(var I in S)S.hasOwnProperty(I)&&(D[I]=j(S[I],T));return D;case"Array":return E=c.util.objId(S),T[E]?T[E]:(D=[],T[E]=D,S.forEach(function(O,_){D[_]=j(O,T)}),D);default:return S}},getLanguage:function(j){for(;j;){var S=a.exec(j.className);if(S)return S[1].toLowerCase();j=j.parentElement}return"none"},setLanguage:function(j,S){j.className=j.className.replace(RegExp(a,"gi"),""),j.classList.add("language-"+S)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(D){var j=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(D.stack)||[])[1];if(j){var S=document.getElementsByTagName("script");for(var T in S)if(S[T].src==j)return S[T]}return null}},isActive:function(j,S,T){for(var D="no-"+S;j;){var E=j.classList;if(E.contains(S))return!0;if(E.contains(D))return!1;j=j.parentElement}return!!T}},languages:{plain:i,plaintext:i,text:i,txt:i,extend:function(j,S){var T=c.util.clone(c.languages[j]);for(var D in S)T[D]=S[D];return T},insertBefore:function(j,S,T,D){D=D||c.languages;var E=D[j],I={};for(var O in E)if(E.hasOwnProperty(O)){if(O==S)for(var _ in T)T.hasOwnProperty(_)&&(I[_]=T[_]);T.hasOwnProperty(O)||(I[O]=E[O])}var M=D[j];return D[j]=I,c.languages.DFS(c.languages,function(R,z){z===M&&R!=j&&(this[R]=I)}),I},DFS:function j(S,T,D,E){E=E||{};var I=c.util.objId;for(var O in S)if(S.hasOwnProperty(O)){T.call(S,O,S[O],D||O);var _=S[O],M=c.util.type(_);M==="Object"&&!E[I(_)]?(E[I(_)]=!0,j(_,T,null,E)):M==="Array"&&!E[I(_)]&&(E[I(_)]=!0,j(_,T,O,E))}}},plugins:{},highlightAll:function(j,S){c.highlightAllUnder(document,j,S)},highlightAllUnder:function(j,S,T){var D={callback:T,container:j,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};c.hooks.run("before-highlightall",D),D.elements=Array.prototype.slice.apply(D.container.querySelectorAll(D.selector)),c.hooks.run("before-all-elements-highlight",D);for(var E=0,I;I=D.elements[E++];)c.highlightElement(I,S===!0,D.callback)},highlightElement:function(j,S,T){var D=c.util.getLanguage(j),E=c.languages[D];c.util.setLanguage(j,D);var I=j.parentElement;I&&I.nodeName.toLowerCase()==="pre"&&c.util.setLanguage(I,D);var O=j.textContent,_={element:j,language:D,grammar:E,code:O};function M(z){_.highlightedCode=z,c.hooks.run("before-insert",_),_.element.innerHTML=_.highlightedCode,c.hooks.run("after-highlight",_),c.hooks.run("complete",_),T&&T.call(_.element)}if(c.hooks.run("before-sanity-check",_),I=_.element.parentElement,I&&I.nodeName.toLowerCase()==="pre"&&!I.hasAttribute("tabindex")&&I.setAttribute("tabindex","0"),!_.code){c.hooks.run("complete",_),T&&T.call(_.element);return}if(c.hooks.run("before-highlight",_),!_.grammar){M(c.util.encode(_.code));return}if(S&&s.Worker){var R=new Worker(c.filename);R.onmessage=function(z){M(z.data)},R.postMessage(JSON.stringify({language:_.language,code:_.code,immediateClose:!0}))}else M(c.highlight(_.code,_.grammar,_.language))},highlight:function(j,S,T){var D={code:j,grammar:S,language:T};if(c.hooks.run("before-tokenize",D),!D.grammar)throw new Error('The language "'+D.language+'" has no grammar.');return D.tokens=c.tokenize(D.code,D.grammar),c.hooks.run("after-tokenize",D),d.stringify(c.util.encode(D.tokens),D.language)},tokenize:function(j,S){var T=S.rest;if(T){for(var D in T)S[D]=T[D];delete S.rest}var E=new m;return b(E,E.head,j),h(j,E,S,E.head,0),w(E)},hooks:{all:{},add:function(j,S){var T=c.hooks.all;T[j]=T[j]||[],T[j].push(S)},run:function(j,S){var T=c.hooks.all[j];if(!(!T||!T.length))for(var D=0,E;E=T[D++];)E(S)}},Token:d};s.Prism=c;function d(j,S,T,D){this.type=j,this.content=S,this.alias=T,this.length=(D||"").length|0}d.stringify=function j(S,T){if(typeof S=="string")return S;if(Array.isArray(S)){var D="";return S.forEach(function(M){D+=j(M,T)}),D}var E={type:S.type,content:j(S.content,T),tag:"span",classes:["token",S.type],attributes:{},language:T},I=S.alias;I&&(Array.isArray(I)?Array.prototype.push.apply(E.classes,I):E.classes.push(I)),c.hooks.run("wrap",E);var O="";for(var _ in E.attributes)O+=" "+_+'="'+(E.attributes[_]||"").replace(/"/g,""")+'"';return"<"+E.tag+' class="'+E.classes.join(" ")+'"'+O+">"+E.content+"</"+E.tag+">"};function f(j,S,T,D){j.lastIndex=S;var E=j.exec(T);if(E&&D&&E[1]){var I=E[1].length;E.index+=I,E[0]=E[0].slice(I)}return E}function h(j,S,T,D,E,I){for(var O in T)if(!(!T.hasOwnProperty(O)||!T[O])){var _=T[O];_=Array.isArray(_)?_:[_];for(var M=0;M<_.length;++M){if(I&&I.cause==O+","+M)return;var R=_[M],z=R.inside,$=!!R.lookbehind,W=!!R.greedy,L=R.alias;if(W&&!R.pattern.global){var F=R.pattern.toString().match(/[imsuy]*$/)[0];R.pattern=RegExp(R.pattern.source,F+"g")}for(var H=R.pattern||R,V=D.next,G=E;V!==S.tail&&!(I&&G>=I.reach);G+=V.value.length,V=V.next){var B=V.value;if(S.length>j.length)return;if(!(B instanceof d)){var K=1,ne;if(W){if(ne=f(H,G,j,$),!ne||ne.index>=j.length)break;var Z=ne.index,q=ne.index+ne[0].length,xe=G;for(xe+=V.value.length;Z>=xe;)V=V.next,xe+=V.value.length;if(xe-=V.value.length,G=xe,V.value instanceof d)continue;for(var Ae=V;Ae!==S.tail&&(xe<q||typeof Ae.value=="string");Ae=Ae.next)K++,xe+=Ae.value.length;K--,B=j.slice(G,xe),ne.index-=G}else if(ne=f(H,0,B,$),!ne)continue;var Z=ne.index,ce=ne[0],me=B.slice(0,Z),ee=B.slice(Z+ce.length),re=G+B.length;I&&re>I.reach&&(I.reach=re);var We=V.prev;me&&(We=b(S,We,me),G+=me.length),y(S,We,K);var ze=new d(O,z?c.tokenize(ce,z):ce,L,ce);if(V=b(S,We,ze),ee&&b(S,V,ee),K>1){var Pe={cause:O+","+M,reach:re};h(j,S,T,V.prev,G,Pe),I&&Pe.reach>I.reach&&(I.reach=Pe.reach)}}}}}}function m(){var j={value:null,prev:null,next:null},S={value:null,prev:j,next:null};j.next=S,this.head=j,this.tail=S,this.length=0}function b(j,S,T){var D=S.next,E={value:T,prev:S,next:D};return S.next=E,D.prev=E,j.length++,E}function y(j,S,T){for(var D=S.next,E=0;E<T&&D!==j.tail;E++)D=D.next;S.next=D,D.prev=S,j.length-=E}function w(j){for(var S=[],T=j.head.next;T!==j.tail;)S.push(T.value),T=T.next;return S}if(!s.document)return s.addEventListener&&(c.disableWorkerMessageHandler||s.addEventListener("message",function(j){var S=JSON.parse(j.data),T=S.language,D=S.code,E=S.immediateClose;s.postMessage(c.highlight(D,c.languages[T],T)),E&&s.close()},!1)),c;var C=c.util.currentScript();C&&(c.filename=C.src,C.hasAttribute("data-manual")&&(c.manual=!0));function N(){c.manual||c.highlightAll()}if(!c.manual){var k=document.readyState;k==="loading"||k==="interactive"&&C&&C.defer?document.addEventListener("DOMContentLoaded",N):window.requestAnimationFrame?window.requestAnimationFrame(N):window.setTimeout(N,16)}return c})(e);t.exports&&(t.exports=n),typeof J0<"u"&&(J0.Prism=n),n.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},n.languages.markup.tag.inside["attr-value"].inside.entity=n.languages.markup.entity,n.languages.markup.doctype.inside["internal-subset"].inside=n.languages.markup,n.hooks.add("wrap",function(s){s.type==="entity"&&(s.attributes.title=s.content.replace(/&/,"&"))}),Object.defineProperty(n.languages.markup.tag,"addInlined",{value:function(a,r){var i={};i["language-"+r]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:n.languages[r]},i.cdata=/^<!\[CDATA\[|\]\]>$/i;var c={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:i}};c["language-"+r]={pattern:/[\s\S]+/,inside:n.languages[r]};var d={};d[a]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return a}),"i"),lookbehind:!0,greedy:!0,inside:c},n.languages.insertBefore("markup","cdata",d)}}),Object.defineProperty(n.languages.markup.tag,"addAttribute",{value:function(s,a){n.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+s+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[a,"language-"+a],inside:n.languages[a]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.xml=n.languages.extend("markup",{}),n.languages.ssml=n.languages.xml,n.languages.atom=n.languages.xml,n.languages.rss=n.languages.xml,(function(s){var a=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;s.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+a.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+a.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+a.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+a.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:a,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},s.languages.css.atrule.inside.rest=s.languages.css;var r=s.languages.markup;r&&(r.tag.addInlined("style","css"),r.tag.addAttribute("style","css"))})(n),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{"class-name":[n.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),n.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,n.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:n.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:n.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:n.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:n.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:n.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),n.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),n.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),n.languages.markup&&(n.languages.markup.tag.addInlined("script","javascript"),n.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),n.languages.js=n.languages.javascript,(function(){if(typeof n>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var s="Loading…",a=function(C,N){return"✖ Error "+C+" while fetching file: "+N},r="✖ Error: File does not exist or is empty",i={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},c="data-src-status",d="loading",f="loaded",h="failed",m="pre[data-src]:not(["+c+'="'+f+'"]):not(['+c+'="'+d+'"])';function b(C,N,k){var j=new XMLHttpRequest;j.open("GET",C,!0),j.onreadystatechange=function(){j.readyState==4&&(j.status<400&&j.responseText?N(j.responseText):j.status>=400?k(a(j.status,j.statusText)):k(r))},j.send(null)}function y(C){var N=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(C||"");if(N){var k=Number(N[1]),j=N[2],S=N[3];return j?S?[k,Number(S)]:[k,void 0]:[k,k]}}n.hooks.add("before-highlightall",function(C){C.selector+=", "+m}),n.hooks.add("before-sanity-check",function(C){var N=C.element;if(N.matches(m)){C.code="",N.setAttribute(c,d);var k=N.appendChild(document.createElement("CODE"));k.textContent=s;var j=N.getAttribute("data-src"),S=C.language;if(S==="none"){var T=(/\.(\w+)$/.exec(j)||[,"none"])[1];S=i[T]||T}n.util.setLanguage(k,S),n.util.setLanguage(N,S);var D=n.plugins.autoloader;D&&D.loadLanguages(S),b(j,function(E){N.setAttribute(c,f);var I=y(N.getAttribute("data-range"));if(I){var O=E.split(/\r\n?|\n/g),_=I[0],M=I[1]==null?O.length:I[1];_<0&&(_+=O.length),_=Math.max(0,Math.min(_-1,O.length)),M<0&&(M+=O.length),M=Math.max(0,Math.min(M,O.length)),E=O.slice(_,M).join(`
|
|
83
|
+
`),N.hasAttribute("data-start")||N.setAttribute("data-start",String(_+1))}k.textContent=E,n.highlightElement(k)},function(E){N.setAttribute(c,h),k.textContent=E})}}),n.plugins.fileHighlight={highlight:function(N){for(var k=(N||document).querySelectorAll(m),j=0,S;S=k[j++];)n.highlightElement(S)}};var w=!1;n.fileHighlight=function(){w||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),w=!0),n.plugins.fileHighlight.highlight.apply(this,arguments)}})()})(ub)),ub.exports}var m4=h4();const da=Xu(m4);Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));Prism.languages.js=Prism.languages.javascript;var vC={},wC;function g4(){return wC||(wC=1,(function(t){t.languages.typescript=t.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),t.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete t.languages.typescript.parameter,delete t.languages.typescript["literal-property"];var e=t.languages.extend("typescript",{});delete e["class-name"],t.languages.typescript["class-name"].inside=e,t.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e}}}}),t.languages.ts=t.languages.typescript})(Prism)),vC}g4();(function(t){var e=t.util.clone(t.languages.javascript),n=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,s=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,a=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function r(d,f){return d=d.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return s}).replace(/<SPREAD>/g,function(){return a}),RegExp(d,f)}a=r(a).source,t.languages.jsx=t.languages.extend("markup",e),t.languages.jsx.tag.pattern=r(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source),t.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,t.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,t.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,t.languages.jsx.tag.inside.comment=e.comment,t.languages.insertBefore("inside","attr-name",{spread:{pattern:r(/<SPREAD>/.source),inside:t.languages.jsx}},t.languages.jsx.tag),t.languages.insertBefore("inside","special-attr",{script:{pattern:r(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:t.languages.jsx}}},t.languages.jsx.tag);var i=function(d){return d?typeof d=="string"?d:typeof d.content=="string"?d.content:d.content.map(i).join(""):""},c=function(d){for(var f=[],h=0;h<d.length;h++){var m=d[h],b=!1;if(typeof m!="string"&&(m.type==="tag"&&m.content[0]&&m.content[0].type==="tag"?m.content[0].content[0].content==="</"?f.length>0&&f[f.length-1].tagName===i(m.content[0].content[1])&&f.pop():m.content[m.content.length-1].content==="/>"||f.push({tagName:i(m.content[0].content[1]),openedBraces:0}):f.length>0&&m.type==="punctuation"&&m.content==="{"?f[f.length-1].openedBraces++:f.length>0&&f[f.length-1].openedBraces>0&&m.type==="punctuation"&&m.content==="}"?f[f.length-1].openedBraces--:b=!0),(b||typeof m=="string")&&f.length>0&&f[f.length-1].openedBraces===0){var y=i(m);h<d.length-1&&(typeof d[h+1]=="string"||d[h+1].type==="plain-text")&&(y+=i(d[h+1]),d.splice(h+1,1)),h>0&&(typeof d[h-1]=="string"||d[h-1].type==="plain-text")&&(y=i(d[h-1])+y,d.splice(h-1,1),h--),d[h]=new t.Token("plain-text",y,null,y)}m.content&&typeof m.content!="string"&&c(m.content)}};t.hooks.add("after-tokenize",function(d){d.language!=="jsx"&&d.language!=="tsx"||c(d.tokens)})})(Prism);(function(t){var e=t.util.clone(t.languages.typescript);t.languages.tsx=t.languages.extend("jsx",e),delete t.languages.tsx.parameter,delete t.languages.tsx["literal-property"];var n=t.languages.tsx.tag;n.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+n.pattern.source+")",n.pattern.flags),n.lookbehind=!0})(Prism);(function(t){var e=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;t.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+e.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+e.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+e.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+e.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:e,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},t.languages.css.atrule.inside.rest=t.languages.css;var n=t.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(Prism);Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}};Prism.languages.webmanifest=Prism.languages.json;(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,s="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",a=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),r=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function i(c,d){d=(d||"").replace(/m/g,"")+"m";var f=/([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g,function(){return s}).replace(/<<value>>/g,function(){return c});return RegExp(f,d)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g,function(){return s})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g,function(){return s}).replace(/<<key>>/g,function(){return"(?:"+a+"|"+r+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:i(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:i(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:i(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:i(r),lookbehind:!0,greedy:!0},number:{pattern:i(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism);var kC={},SC;function b4(){return SC||(SC=1,Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),kC}b4();(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},s={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:s},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:s},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:s.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:s.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var a=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],r=s.variable[1].inside,i=0;i<a.length;i++)r[a[i]]=t.languages.bash[a[i]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(Prism);(function(t){var e=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function n(h){return h=h.replace(/<inner>/g,function(){return e}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+h+")")}var s=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,a=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return s}),r=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;t.languages.markdown=t.languages.extend("markup",{}),t.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:t.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+a+r+"(?:"+a+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+a+r+")(?:"+a+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(s),inside:t.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+a+")"+r+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+a+"$"),inside:{"table-header":{pattern:RegExp(s),alias:"important",inside:t.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:n(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(/(~~?)(?:(?!~)<inner>)+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:n(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach(function(h){["url","bold","italic","strike","code-snippet"].forEach(function(m){h!==m&&(t.languages.markdown[h].inside.content.inside[m]=t.languages.markdown[m])})}),t.hooks.add("after-tokenize",function(h){if(h.language!=="markdown"&&h.language!=="md")return;function m(b){if(!(!b||typeof b=="string"))for(var y=0,w=b.length;y<w;y++){var C=b[y];if(C.type!=="code"){m(C.content);continue}var N=C.content[1],k=C.content[3];if(N&&k&&N.type==="code-language"&&k.type==="code-block"&&typeof N.content=="string"){var j=N.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");j=(/[a-z][\w-]*/i.exec(j)||[""])[0].toLowerCase();var S="language-"+j;k.alias?typeof k.alias=="string"?k.alias=[k.alias,S]:k.alias.push(S):k.alias=[S]}}}m(h.tokens)}),t.hooks.add("wrap",function(h){if(h.type==="code-block"){for(var m="",b=0,y=h.classes.length;b<y;b++){var w=h.classes[b],C=/language-(.+)/.exec(w);if(C){m=C[1];break}}var N=t.languages[m];if(N)h.content=t.highlight(f(h.content),N,m);else if(m&&m!=="none"&&t.plugins.autoloader){var k="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);h.attributes.id=k,t.plugins.autoloader.loadLanguages(m,function(){var j=document.getElementById(k);j&&(j.innerHTML=t.highlight(j.textContent,t.languages[m],m))})}}});var i=RegExp(t.languages.markup.tag.pattern.source,"gi"),c={amp:"&",lt:"<",gt:">",quot:'"'},d=String.fromCodePoint||String.fromCharCode;function f(h){var m=h.replace(i,"");return m=m.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(b,y){if(y=y.toLowerCase(),y[0]==="#"){var w;return y[1]==="x"?w=parseInt(y.slice(2),16):w=Number(y.slice(1)),d(w)}else{var C=c[y];return C||b}}),m}t.languages.md=t.languages.markdown})(Prism);Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/});Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}});delete Prism.languages.go["class-name"];var CC={},AC;function x4(){return AC||(AC=1,(function(t){for(var e=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source,n=0;n<2;n++)e=e.replace(/<self>/g,function(){return e});e=e.replace(/<self>/g,function(){return/[^\s\S]/.source}),t.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+e),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},t.languages.rust["closure-params"].inside.rest=t.languages.rust,t.languages.rust.attribute.inside.string=t.languages.rust.string})(Prism)),CC}x4();Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/};const y4={".ts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"jsx",".mjs":"javascript",".cjs":"javascript",".css":"css",".scss":"scss",".sass":"scss",".less":"css",".html":"markup",".xml":"markup",".svg":"markup",".graphql":"graphql",".gql":"graphql",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".groovy":"groovy",".gradle":"groovy",".clj":"clojure",".cljs":"clojure",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hxx":"cpp",".cs":"csharp",".py":"python",".rb":"ruby",".php":"php",".lua":"lua",".pl":"perl",".pm":"perl",".r":"r",".R":"r",".hs":"haskell",".lhs":"haskell",".ex":"elixir",".exs":"elixir",".erl":"erlang",".hrl":"erlang",".rs":"rust",".go":"go",".swift":"swift",".sh":"bash",".bash":"bash",".zsh":"bash",".fish":"bash",".ps1":"powershell",".psm1":"powershell",".psd1":"powershell",".json":"json",".yaml":"yaml",".yml":"yaml",".toml":"toml",".ini":"ini",".cfg":"ini",".conf":"ini",".md":"markdown",".mdx":"markdown",".sql":"sql",".dockerfile":"docker",".nginx":"nginx",".vim":"vim",".vimrc":"vim",".diff":"diff",".patch":"diff",".makefile":"makefile",".mk":"makefile"},ve="/assets/vscode-icons/",jp={".7z":`${ve}file_type_zip.svg`,".R":`${ve}file_type_r.svg`,".adoc":`${ve}file_type_asciidoc.svg`,".asciidoc":`${ve}file_type_asciidoc.svg`,".astro":`${ve}file_type_astro.svg`,".avi":`${ve}file_type_video.svg`,".babelrc":`${ve}file_type_babel.svg`,".bash":`${ve}file_type_shell.svg`,".bat":`${ve}file_type_bat.svg`,".bmp":`${ve}file_type_image.svg`,".c":`${ve}file_type_c.svg`,".cc":`${ve}file_type_cpp.svg`,".cfg":`${ve}file_type_ini.svg`,".circleci":`${ve}file_type_circleci.svg`,".cjs":`${ve}file_type_js_official.svg`,".clj":`${ve}file_type_clojure.svg`,".cljs":`${ve}file_type_clojure.svg`,".cmd":`${ve}file_type_bat.svg`,".conf":`${ve}file_type_ini.svg`,".cpp":`${ve}file_type_cpp.svg`,".cs":`${ve}file_type_csharp.svg`,".css":`${ve}file_type_css.svg`,".csv":`${ve}file_type_csv.svg`,".cxx":`${ve}file_type_cpp.svg`,".dart":`${ve}file_type_dart.svg`,".diff":`${ve}file_type_diff.svg`,".dockerfile":`${ve}file_type_docker.svg`,".dockerignore":`${ve}file_type_docker.svg`,".env":`${ve}file_type_dotenv.svg`,".env.development":`${ve}file_type_dotenv.svg`,".env.local":`${ve}file_type_dotenv.svg`,".env.production":`${ve}file_type_dotenv.svg`,".env.test":`${ve}file_type_dotenv.svg`,".erb":`${ve}file_type_ruby.svg`,".erl":`${ve}file_type_erlang.svg`,".eslintrc":`${ve}file_type_eslint.svg`,".eslintrc.js":`${ve}file_type_eslint.svg`,".eslintrc.json":`${ve}file_type_eslint.svg`,".ex":`${ve}file_type_elixir.svg`,".exs":`${ve}file_type_elixir.svg`,".fish":`${ve}file_type_shell.svg`,".gif":`${ve}file_type_image.svg`,".git":`${ve}file_type_git.svg`,".gitattributes":`${ve}file_type_git.svg`,".github":`${ve}file_type_github.svg`,".gitignore":`${ve}file_type_git.svg`,".gitlab-ci.yml":`${ve}file_type_gitlab.svg`,".gitmodules":`${ve}file_type_git.svg`,".go":`${ve}file_type_go.svg`,".gql":`${ve}file_type_graphql.svg`,".gradle":`${ve}file_type_gradle.svg`,".graphql":`${ve}file_type_graphql.svg`,".groovy":`${ve}file_type_groovy.svg`,".gz":`${ve}file_type_zip.svg`,".h":`${ve}file_type_c.svg`,".hpp":`${ve}file_type_cpp.svg`,".hrl":`${ve}file_type_erlang.svg`,".hs":`${ve}file_type_haskell.svg`,".htm":`${ve}file_type_html.svg`,".html":`${ve}file_type_html.svg`,".ico":`${ve}file_type_image.svg`,".ini":`${ve}file_type_ini.svg`,".java":`${ve}file_type_java.svg`,".jl":`${ve}file_type_julia.svg`,".jpeg":`${ve}file_type_image.svg`,".jpg":`${ve}file_type_image.svg`,".js":`${ve}file_type_js_official.svg`,".json":`${ve}file_type_json_official.svg`,".json5":`${ve}file_type_json5.svg`,".jsonc":`${ve}file_type_json_official.svg`,".jsx":`${ve}file_type_reactjs.svg`,".kt":`${ve}file_type_kotlin.svg`,".kts":`${ve}file_type_kotlin.svg`,".kubernetes.yaml":`${ve}file_type_kubernetes.svg`,".less":`${ve}file_type_less.svg`,".lhs":`${ve}file_type_haskell.svg`,".lock":`${ve}file_type_lock.svg`,".log":`${ve}file_type_log.svg`,".lua":`${ve}file_type_lua.svg`,".markdown":`${ve}file_type_markdown.svg`,".md":`${ve}file_type_markdown.svg`,".mdown":`${ve}file_type_markdown.svg`,".mdx":`${ve}file_type_markdown.svg`,".mjs":`${ve}file_type_js_official.svg`,".mk":`${ve}file_type_makefile.svg`,".mov":`${ve}file_type_video.svg`,".mp3":`${ve}file_type_audio.svg`,".mp4":`${ve}file_type_video.svg`,".nim":`${ve}file_type_nim.svg`,".nims":`${ve}file_type_nim.svg`,".patch":`${ve}file_type_diff.svg`,".pdf":`${ve}file_type_pdf.svg`,".php":`${ve}file_type_php.svg`,".pl":`${ve}file_type_perl.svg`,".pm":`${ve}file_type_perl.svg`,".png":`${ve}file_type_image.svg`,".prettier.json":`${ve}file_type_prettier.svg`,".prettierrc":`${ve}file_type_prettier.svg`,".ps1":`${ve}file_type_powershell.svg`,".psd1":`${ve}file_type_powershell.svg`,".psm1":`${ve}file_type_powershell.svg`,".py":`${ve}file_type_python.svg`,".pyw":`${ve}file_type_python.svg`,".r":`${ve}file_type_r.svg`,".rar":`${ve}file_type_zip.svg`,".rb":`${ve}file_type_ruby.svg`,".rs":`${ve}file_type_rust.svg`,".rst":`${ve}file_type_rst.svg`,".sass":`${ve}file_type_scss.svg`,".scala":`${ve}file_type_scala.svg`,".scss":`${ve}file_type_scss.svg`,".sh":`${ve}file_type_shell.svg`,".sql":`${ve}file_type_sql.svg`,".sty":`${ve}file_type_latex.svg`,".svelte":`${ve}file_type_svelte.svg`,".svg":`${ve}file_type_svg.svg`,".swift":`${ve}file_type_swift.svg`,".tar":`${ve}file_type_tar.svg`,".tar.bz2":`${ve}file_type_zip.svg`,".tar.gz":`${ve}file_type_zip.svg`,".terraform":`${ve}file_type_terraform.svg`,".tex":`${ve}file_type_latex.svg`,".toml":`${ve}file_type_toml.svg`,".travis.yml":`${ve}file_type_travis.svg`,".ts":`${ve}file_type_typescript_official.svg`,".tsv":`${ve}file_type_tsv.svg`,".tsx":`${ve}file_type_typescript_official.svg`,".txt":`${ve}file_type_text.svg`,".vue":`${ve}file_type_vue.svg`,".webm":`${ve}file_type_video.svg`,".webp":`${ve}file_type_image.svg`,".xml":`${ve}file_type_xml.svg`,".yaml":`${ve}file_type_yaml_official.svg`,".yml":`${ve}file_type_yaml_official.svg`,".zig":`${ve}file_type_zig.svg`,".zip":`${ve}file_type_zip.svg`,".zsh":`${ve}file_type_shell.svg`,"CMakeLists.txt":`${ve}file_type_cmake.svg`,"Cargo.lock":`${ve}file_type_cargo.svg`,"Cargo.toml":`${ve}file_type_cargo.svg`,Dockerfile:`${ve}file_type_docker.svg`,Gemfile:`${ve}file_type_ruby.svg`,"Gemfile.lock":`${ve}file_type_ruby.svg`,Justfile:`${ve}file_type_just.svg`,Makefile:`${ve}file_type_makefile.svg`,Pipfile:`${ve}file_type_python.svg`,"Pipfile.lock":`${ve}file_type_python.svg`,Procfile:`${ve}file_type_procfile.svg`,Vagrantfile:`${ve}file_type_vagrant.svg`,"azure-pipelines.yml":`${ve}file_type_azurepipelines.svg`,"build.gradle":`${ve}file_type_gradle.svg`,"build.sbt":`${ve}file_type_scala.svg`,"docker-compose.yaml":`${ve}file_type_docker.svg`,"docker-compose.yml":`${ve}file_type_docker.svg`,dune:`${ve}file_type_dune.svg`,"gatsby-config.js":`${ve}file_type_gatsby.svg`,"go.mod":`${ve}file_type_go.svg`,"go.sum":`${ve}file_type_go.svg`,"heroku.yml":`${ve}file_type_heroku.svg`,"jsconfig.json":`${ve}file_type_jsconfig.svg`,"kubernetes.yaml":`${ve}file_type_kubernetes.svg`,makefile:`${ve}file_type_makefile.svg`,"meson.build":`${ve}file_type_meson.svg`,"mix.exs":`${ve}file_type_elixir.svg`,"next.config.js":`${ve}file_type_nextjs.svg`,"nuxt.config.js":`${ve}file_type_nuxtjs.svg`,"package-lock.json":`${ve}file_type_npm.svg`,"package.json":`${ve}file_type_npm.svg`,"pnpm-lock.yaml":`${ve}file_type_pnpm.svg`,"pom.xml":`${ve}file_type_maven.svg`,"pubspec.lock":`${ve}file_type_dart.svg`,"pubspec.yaml":`${ve}file_type_dart.svg`,"pyproject.toml":`${ve}file_type_python.svg`,"rebar.config":`${ve}file_type_erlang.svg`,"requirements.txt":`${ve}file_type_python.svg`,"terraform.tfvars":`${ve}file_type_terraform.svg`,"tox.ini":`${ve}file_type_tox.svg`,"tsconfig.json":`${ve}file_type_tsconfig.svg`,"vite.config.js":`${ve}file_type_vite.svg`,"vite.config.ts":`${ve}file_type_vite.svg`,"webpack.config.js":`${ve}file_type_webpack.svg`,"yarn.lock":`${ve}file_type_yarn.svg`,default:`${ve}default_file.svg`},AN={conflict:{icon:"C",color:"#ff5555",label:"Conflicts"},modified:{icon:"M",color:"#c89a5a",label:"Modified"},added:{icon:"A",color:"#5cb88a",label:"Added"},deleted:{icon:"D",color:"#c85a5a",label:"Deleted"},untracked:{icon:"U",color:"#6ab8c8",label:"Untracked"},renamed:{icon:"R",color:"#9a80c0",label:"Renamed"}},v4={c:()=>vt(()=>import("./prism-c-BI05wwL9.js"),[]),cpp:()=>vt(()=>import("./prism-c-BI05wwL9.js"),[]).then(()=>vt(()=>import("./prism-cpp-CK2Ly5dS.js").then(t=>t.p),__vite__mapDeps([7,1]))),java:()=>vt(()=>import("./prism-java-CK6tws4L.js").then(t=>t.p),__vite__mapDeps([8,1])),scala:()=>vt(()=>import("./prism-java-CK6tws4L.js").then(t=>t.p),__vite__mapDeps([8,1])).then(()=>vt(()=>import("./prism-scala-BjNo2HkN.js"),[])),csharp:()=>vt(()=>import("./prism-csharp-ByDDDiWW.js").then(t=>t.p),__vite__mapDeps([9,1])),kotlin:()=>vt(()=>import("./prism-kotlin-B1uvbSyh.js"),[]),groovy:()=>vt(()=>import("./prism-groovy-CGzo1uDg.js"),[]),ruby:()=>vt(()=>import("./prism-ruby-CQBUuZIF.js").then(t=>t.p),__vite__mapDeps([10,1])),php:()=>vt(()=>import("./prism-markup-templating-Ct1xsyfA.js"),[]).then(()=>vt(()=>import("./prism-php-Dt9698bA.js").then(t=>t.p),__vite__mapDeps([11,1]))),scss:()=>vt(()=>import("./prism-scss-CeN16CFC.js").then(t=>t.p),__vite__mapDeps([12,1])),toml:()=>vt(()=>import("./prism-toml-BrQIw_NO.js"),[]),docker:()=>vt(()=>import("./prism-docker-MnIa7k-I.js"),[]),swift:()=>vt(()=>import("./prism-swift--kriB360.js"),[]),lua:()=>vt(()=>import("./prism-lua-Cp_o7ONA.js"),[]),perl:()=>vt(()=>import("./prism-perl-UZfqnD51.js").then(t=>t.p),__vite__mapDeps([13,1])),r:()=>vt(()=>import("./prism-r-TxsGuNZJ.js"),[]),haskell:()=>vt(()=>import("./prism-haskell-Ce8aBmia.js").then(t=>t.p),__vite__mapDeps([14,1])),elixir:()=>vt(()=>import("./prism-elixir-df27OMMQ.js").then(t=>t.p),__vite__mapDeps([15,1])),erlang:()=>vt(()=>import("./prism-erlang-C3Aahqfa.js"),[]),clojure:()=>vt(()=>import("./prism-clojure-u3w_tjfy.js"),[]),graphql:()=>vt(()=>import("./prism-graphql-DJ177lJj.js"),[]),nginx:()=>vt(()=>import("./prism-nginx-43e5TboO.js"),[]),vim:()=>vt(()=>import("./prism-vim-uciLQ2PQ.js"),[]),diff:()=>vt(()=>import("./prism-diff-jN23ddHu.js"),[]),ini:()=>vt(()=>import("./prism-ini-DX5Euru7.js"),[]),powershell:()=>vt(()=>import("./prism-powershell-Ud14i9UV.js"),[]),makefile:()=>vt(()=>import("./prism-makefile-Dk8DMwhC.js"),[])},db=new Map;async function jN(t){if(t in da.languages)return!0;const e=v4[t];if(!e)return!1;let n=db.get(t);n||(n=e(),db.set(t,n));try{return await n,t in da.languages}catch{return!1}finally{db.delete(t)}}function aV(t){da.highlightElement(t)}function np(t){return y4[t]||"plaintext"}function w4(t){return t in da.languages}function jC(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Mo(t,e){if(!t)return"";const n=da.languages[e];if(!n)return jC(t);try{return da.highlight(t,n,e)}catch{return jC(t)}}function k4(t){if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.top="-9999px",e.style.left="-9999px",document.body.appendChild(e),e.select(),e.setSelectionRange(0,e.value.length);const n=document.execCommand("copy");if(document.body.removeChild(e),!n)throw new Error("Legacy clipboard copy failed")}async function Lu(t){var e;if(typeof navigator<"u"&&((e=navigator.clipboard)!=null&&e.writeText)){await navigator.clipboard.writeText(t);return}k4(t)}function NN(t){const e=document.createElement("div");e.innerHTML=t;const n=e.firstElementChild;n&&(n.style.cssText+='font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;font-size:14px;color:#1f2328;line-height:1.6');const s={table:"border-collapse:collapse;width:100%;border:1px solid #d1d9e0;margin:12px 0;font-size:13px",th:"background:#f6f8fa;color:#1f2328;padding:6px 12px;border:1px solid #d1d9e0;font-weight:600;text-align:left;white-space:nowrap",td:"padding:6px 12px;border:1px solid #d1d9e0;color:#1f2328;vertical-align:top",h1:"font-size:2em;font-weight:700;margin:24px 0 12px;padding-bottom:6px;border-bottom:2px solid #d1d9e0;color:#1f2328",h2:"font-size:1.5em;font-weight:700;margin:20px 0 10px;padding-bottom:4px;border-bottom:1px solid #d1d9e0;color:#1f2328",h3:"font-size:1.25em;font-weight:600;margin:16px 0 8px;color:#1f2328",h4:"font-size:1.1em;font-weight:600;margin:12px 0 6px;color:#1f2328",h5:"font-size:1em;font-weight:600;margin:10px 0 4px;color:#1f2328",h6:"font-size:0.85em;font-weight:600;margin:10px 0 4px;color:#656d76",pre:'background:#f6f8fa;padding:16px;border-radius:6px;overflow:auto;border:1px solid #d1d9e0;font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:1.5;margin:12px 0;color:#1f2328',blockquote:"border-left:4px solid #d1d9e0;padding:4px 16px;color:#656d76;margin:12px 0;background:#f6f8fa",a:"color:#0969da;text-decoration:underline",ul:"padding-left:28px;margin:8px 0",ol:"padding-left:28px;margin:8px 0",li:"margin:4px 0;color:#1f2328",hr:"border:none;border-top:2px solid #d1d9e0;margin:20px 0",strong:"font-weight:700;color:#1f2328",em:"font-style:italic",p:"margin:8px 0;line-height:1.6"};for(const[r,i]of Object.entries(s))for(const c of Array.from(e.querySelectorAll(r)))c.style.cssText+=i;for(const r of Array.from(e.querySelectorAll("code"))){const i=r.parentElement;i&&i.tagName.toLowerCase()==="pre"?r.style.cssText+='font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,monospace;background:transparent;padding:0;font-size:inherit;color:inherit':r.style.cssText+='background:#eff1f3;padding:2px 6px;border-radius:4px;font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,monospace;font-size:0.85em;color:#cf222e'}for(const r of Array.from(e.querySelectorAll("table"))){r.setAttribute("width","100%"),r.querySelectorAll("tbody tr").forEach((S,T)=>{T%2===0?S.style.cssText+="background:#ffffff":S.style.cssText+="background:#f6f8fa"});const c=Array.from(r.querySelectorAll("thead th, thead td, tr:first-child th, tr:first-child td")),d=c.length;if(d<2)continue;const f=Array.from(r.querySelectorAll("tr")),h=new Array(d).fill(0),m=new Array(d).fill(0);c.forEach((S,T)=>{const D=(S.textContent||"").trim();D.length,h[T]=D.length});for(const S of f)Array.from(S.children).forEach((D,E)=>{if(E<d){const I=(D.textContent||"").trim();m[E]=Math.max(m[E],I.length);const O=I.split(/\s+/);for(const _ of O)h[E]=Math.max(h[E],_.length)}});const b=h.reduce((S,T)=>S+T,0)||1,y=h.map(S=>{const T=S<=3?3:S<=6?5:8;return Math.max(T,Math.round(S/b*50))}),w=y.reduce((S,T)=>S+T,0),C=Math.max(0,100-w),N=m.reduce((S,T)=>S+T,0)||1,k=y.map((S,T)=>S+Math.round(m[T]/N*C)),j=k.reduce((S,T)=>S+T,0);k[k.length-1]+=100-j;for(const S of f)Array.from(S.children).forEach((D,E)=>{if(E<d){const I=`${k[E]}%`;D.setAttribute("width",I),D.style.cssText+=`;width:${I}`}})}const a={"hljs-keyword":"color:#cf222e;font-weight:600","hljs-built_in":"color:#8250df","hljs-type":"color:#8250df","hljs-literal":"color:#0550ae","hljs-number":"color:#0550ae","hljs-string":"color:#0a3069","hljs-comment":"color:#6e7781;font-style:italic","hljs-doctag":"color:#cf222e","hljs-meta":"color:#6e7781","hljs-attr":"color:#8250df","hljs-attribute":"color:#0550ae","hljs-name":"color:#116329","hljs-tag":"color:#116329","hljs-title":"color:#8250df;font-weight:600","hljs-variable":"color:#953800","hljs-params":"color:#1f2328","hljs-function":"color:#8250df","hljs-selector-tag":"color:#116329","hljs-selector-class":"color:#8250df","hljs-selector-id":"color:#0550ae","hljs-property":"color:#0550ae","hljs-regexp":"color:#0a3069","hljs-symbol":"color:#0550ae","hljs-addition":"color:#116329;background:#dafbe1","hljs-deletion":"color:#cf222e;background:#ffebe9"};for(const[r,i]of Object.entries(a))for(const c of Array.from(e.querySelectorAll(`.${r}`)))c.style.cssText+=i;return e.innerHTML}async function TN(t,e){const n=document.createElement("div");n.innerHTML=t,n.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0;color:#1f2328;background:#ffffff;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.6',document.body.appendChild(n);const s=document.createRange();s.selectNodeContents(n);const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(s));const r=document.execCommand("copy");if(document.body.removeChild(n),a&&a.removeAllRanges(),!r)throw new Error("Rich text copy failed")}function os({content:t,children:e,position:n="top",delay:s=150,maxWidth:a=280,disabled:r=!1,className:i=""}){const[c,d]=x.useState(!1),[f,h]=x.useState(!1),[m,b]=x.useState({top:0,left:0}),y=x.useRef(null),w=x.useRef(null),C=x.useRef(null),N=x.useRef(null),k=x.useCallback(()=>{if(!y.current||!w.current)return;const D=y.current.getBoundingClientRect(),E=w.current.getBoundingClientRect(),I=window.scrollY,O=window.scrollX,_=8;let M=0,R=0;switch(n){case"top":M=D.top+I-E.height-_,R=D.left+O+(D.width-E.width)/2;break;case"bottom":M=D.bottom+I+_,R=D.left+O+(D.width-E.width)/2;break;case"left":M=D.top+I+(D.height-E.height)/2,R=D.left+O-E.width-_;break;case"right":M=D.top+I+(D.height-E.height)/2,R=D.right+O+_;break}const z=window.innerWidth,$=window.innerHeight;R<_&&(R=_),R+E.width>z-_&&(R=z-E.width-_),M<_&&(M=_),M+E.height>$+I-_&&(M=$+I-E.height-_),b({top:M,left:R})},[n]),j=x.useCallback(()=>{r||(N.current&&(clearTimeout(N.current),N.current=null),C.current=setTimeout(()=>{h(!0),d(!0)},s))},[s,r]),S=x.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null),d(!1),N.current=setTimeout(()=>{h(!1)},100)},[]);x.useEffect(()=>{f&&c&&requestAnimationFrame(k)},[f,c,k]),x.useEffect(()=>()=>{C.current&&clearTimeout(C.current),N.current&&clearTimeout(N.current)},[]);const T=f&&t&&ac.createPortal(o.jsxs("div",{ref:w,className:`tide-tooltip tide-tooltip--${n} ${c?"tide-tooltip--visible":"tide-tooltip--hiding"} ${i}`,style:{position:"absolute",top:m.top,left:m.left,maxWidth:a,zIndex:1e4},role:"tooltip",children:[o.jsx("div",{className:"tide-tooltip__content",children:t}),o.jsx("div",{className:"tide-tooltip__arrow"})]}),document.body);return o.jsxs(o.Fragment,{children:[o.jsx("span",{ref:y,className:"tide-tooltip-trigger",onMouseEnter:j,onMouseLeave:S,onFocus:j,onBlur:S,style:{display:"inline-flex"},children:e}),T]})}function rV({text:t,title:e,position:n="top",size:s="md"}){const a=o.jsxs(o.Fragment,{children:[e&&o.jsx("div",{className:"tide-tooltip__title",children:e}),o.jsx("div",{className:"tide-tooltip__text",children:t})]});return o.jsx(os,{content:a,position:n,children:o.jsx("span",{className:`tide-help-icon tide-help-icon--${s}`,tabIndex:0,children:"?"})})}function fb(t,e){return t?Mo(t,e):""}function S4(t,e,n){const s=t.split(`
|
|
84
|
+
`),a=e.split(`
|
|
85
|
+
`),r=n||"plaintext",i=s.length,c=a.length,d=Array(i+1).fill(null).map(()=>Array(c+1).fill(0));for(let D=1;D<=i;D++)for(let E=1;E<=c;E++)s[D-1]===a[E-1]?d[D][E]=d[D-1][E-1]+1:d[D][E]=Math.max(d[D-1][E],d[D][E-1]);const f=[];let h=i,m=c;for(;h>0||m>0;)h>0&&m>0&&s[h-1]===a[m-1]?(f.push({type:"equal",origIdx:h-1,modIdx:m-1}),h--,m--):m>0&&(h===0||d[h][m-1]>=d[h-1][m])?(f.push({type:"insert",modIdx:m-1}),m--):h>0&&(f.push({type:"delete",origIdx:h-1}),h--);f.reverse();const b=[],y=[],w=[],C=[];w.push({leftLine:0,rightLine:0});let N=-1,k=0,j=-1,S=0;const T=()=>{(k>0||S>0)&&C.push({leftStart:N>=0?N:b.length,leftCount:k,rightStart:j>=0?j:y.length,rightCount:S,type:k>0&&S>0?"modified":k>0?"removed":"added"}),N=-1,k=0,j=-1,S=0};for(const D of f)if(D.type==="equal"){T();const E=s[D.origIdx],I=fb(E,r);b.push({num:D.origIdx+1,text:E,highlighted:I,type:"unchanged"}),y.push({num:D.modIdx+1,text:E,highlighted:I,type:"unchanged"}),w.push({leftLine:b.length,rightLine:y.length})}else if(D.type==="delete"){N<0&&(N=b.length),k++;const E=s[D.origIdx],I=fb(E,r);b.push({num:D.origIdx+1,text:E,highlighted:I,type:"removed"})}else{j<0&&(j=y.length),S++;const E=a[D.modIdx],I=fb(E,r);y.push({num:D.modIdx+1,text:E,highlighted:I,type:"added"})}return T(),w.push({leftLine:b.length,rightLine:y.length}),{leftLines:b,rightLines:y,alignments:w,changeBlocks:C}}function C4(t,e,n,s,a,r){if(e<=0||n<=0)return 0;const i=t/a;let c=null,d=null;for(let k=0;k<s.length-1;k++){const j=s[k],S=s[k+1],T=r?j.leftLine:j.rightLine,D=r?S.leftLine:S.rightLine;if(i>=T&&i<D){c=j,d=S;break}}if(!c||!d)return t/Math.max(1,e-1)*n;const f=r?c.leftLine:c.rightLine,h=r?d.leftLine:d.rightLine,m=r?c.rightLine:c.leftLine,b=r?d.rightLine:d.leftLine,y=h-f,w=b-m;if(y===0)return m*a;const C=(i-f)/y;return(m+C*w)*a}const A4=[".md",".mdx",".markdown"];function mx({originalContent:t,modifiedContent:e,filename:n,language:s,initialModifiedOnly:a=!1}){const{t:r}=dt(["terminal","common"]),i=x.useRef(null),c=x.useRef(null),d=x.useRef(null),f=x.useRef(null),h=x.useRef(null),m=x.useRef(null),b=x.useRef(null),[y,w]=x.useState("idle"),[C,N]=x.useState("idle"),[k,j]=x.useState(a),[S,T]=x.useState(0);x.useEffect(()=>{s&&s!=="plaintext"&&jN(s).then(()=>T(Z=>Z+1))},[s]);const D=!t,E=!e,I=x.useMemo(()=>{const Z=n.substring(n.lastIndexOf(".")).toLowerCase();return A4.includes(Z)},[n]),O=x.useCallback(async()=>{try{if(I&&k&&d.current){const Z=d.current.innerHTML,ce=NN(Z),me=d.current.innerText;await TN(ce,me)}else await Lu(e);w("copied"),setTimeout(()=>w("idle"),2e3)}catch(Z){console.error("Copy modified content failed:",Z),w("error"),setTimeout(()=>w("idle"),2e3)}},[e,I,k]),_=x.useCallback(async()=>{if(!d.current){console.error("Copy HTML: markdown content ref is not available"),N("error"),setTimeout(()=>N("idle"),2e3);return}try{const Z=d.current.innerHTML;await Lu(Z),N("copied"),setTimeout(()=>N("idle"),2e3)}catch(Z){console.error("Copy HTML failed:",Z),N("error"),setTimeout(()=>N("idle"),2e3)}},[]),{leftLines:M,rightLines:R,alignments:z,changeBlocks:$}=x.useMemo(()=>S4(t,e,s),[t,e,s,S]),W=x.useCallback(()=>{const Z=f.current,ce=i.current,me=c.current;if(!Z||!ce||!me)return;const ee=window.devicePixelRatio||1,re=Z.parentElement;if(!re)return;const We=re.clientWidth,ze=re.clientHeight;if(We===0||ze===0)return;const Pe=Math.round(We*ee),ge=Math.round(ze*ee);(Z.width!==Pe||Z.height!==ge)&&(Z.width=Pe,Z.height=ge);const Te=Z.getContext("2d");if(!Te)return;Te.setTransform(ee,0,0,ee,0,0),Te.clearRect(0,0,We,ze);const qe=re.getBoundingClientRect(),it=ce.getBoundingClientRect(),he=me.getBoundingClientRect(),Be=it.top-qe.top,ie=he.top-qe.top,de=ce.scrollTop,He=me.scrollTop,et=ce.clientHeight,ct=me.clientHeight;for(const fe of $){const X=Be+fe.leftStart*K-de,se=Be+(fe.leftStart+Math.max(fe.leftCount,.5))*K-de,Se=ie+fe.rightStart*K-He,J=ie+(fe.rightStart+Math.max(fe.rightCount,.5))*K-He;if(se<Be&&J<ie||X>Be+et+20&&Se>ie+ct+20)continue;fe.type==="modified"?(Te.fillStyle="rgba(90, 130, 180, 0.2)",Te.strokeStyle="rgba(90, 130, 180, 0.45)"):fe.type==="removed"?(Te.fillStyle="rgba(200, 90, 90, 0.2)",Te.strokeStyle="rgba(200, 90, 90, 0.45)"):(Te.fillStyle="rgba(92, 184, 138, 0.2)",Te.strokeStyle="rgba(92, 184, 138, 0.45)");const pe=We*.5;Te.lineWidth=1,Te.save(),Te.beginPath(),Te.rect(0,Be,We,ze-Be),Te.clip(),Te.beginPath(),Te.moveTo(0,X),Te.bezierCurveTo(pe,X,pe,Se,We,Se),Te.lineTo(We,J),Te.bezierCurveTo(pe,J,pe,se,0,se),Te.closePath(),Te.fill(),Te.stroke(),Te.restore()}},[$]);x.useEffect(()=>{if(k||D||E)return;const Z=f.current,ce=i.current,me=c.current;if(!Z||!ce||!me)return;const ee=Z.parentElement;if(!ee)return;const re=new ResizeObserver(()=>{W()});return re.observe(ee),requestAnimationFrame(()=>W()),()=>{re.disconnect(),h.current&&cancelAnimationFrame(h.current)}},[k,D,E,W]);const{leftBoundaries:L,rightBoundaries:F}=x.useMemo(()=>{const Z=new Map,ce=new Map;for(const me of $){if(me.leftCount>0){const ee=me.leftStart,re=me.leftStart+me.leftCount-1;Z.set(ee,Z.has(ee)?"both":"top"),ee===re?Z.set(ee,"both"):Z.set(re,Z.has(re)?"both":"bottom")}if(me.rightCount>0){const ee=me.rightStart,re=me.rightStart+me.rightCount-1;ce.set(ee,ce.has(ee)?"both":"top"),ee===re?ce.set(ee,"both"):ce.set(re,ce.has(re)?"both":"bottom")}}return{leftBoundaries:Z,rightBoundaries:ce}},[$]),H=x.useMemo(()=>{const Z=R.filter(me=>me.type==="added").length,ce=M.filter(me=>me.type==="removed").length;return{added:Z,removed:ce}},[M,R]),V=x.useMemo(()=>{const Z=[];let ce=!1;R.forEach((ee,re)=>{ee.type==="added"?ce||(Z.push(re),ce=!0):ce=!1});let me=!1;return M.forEach((ee,re)=>{if(ee.type==="removed"){if(!me){const We=Math.min(re,R.length-1);Z.includes(We)||Z.push(We),me=!0}}else me=!1}),Z.sort((ee,re)=>ee-re)},[M,R]),[G,B]=x.useState(0),K=20,ne=x.useCallback(Z=>{const ce=i.current,me=c.current;if(!ce||!me||m.current&&m.current!==Z)return;m.current=Z,b.current&&cancelAnimationFrame(b.current);const ee=Z==="left"?ce:me,re=Z==="left"?me:ce;re.scrollLeft=ee.scrollLeft;const We=C4(ee.scrollTop,ee.scrollHeight-ee.clientHeight,re.scrollHeight-re.clientHeight,z,K,Z==="left");re.scrollTop=We,h.current&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame(()=>{W(),h.current=null}),b.current=requestAnimationFrame(()=>{m.current=null})},[z,W]);x.useEffect(()=>{const Z=i.current,ce=c.current;if(!Z||!ce)return;const me=()=>ne("left"),ee=()=>ne("right");return Z.addEventListener("scroll",me),ce.addEventListener("scroll",ee),()=>{Z.removeEventListener("scroll",me),ce.removeEventListener("scroll",ee),b.current&&cancelAnimationFrame(b.current)}},[ne]);const q=x.useCallback(Z=>{if(Z<0||Z>=V.length)return;const me=V[Z]*K;c.current&&(c.current.scrollTop=me),B(Z)},[V]),xe=x.useCallback(()=>{const Z=Math.min(G+1,V.length-1);q(Z)},[G,V.length,q]),Ae=x.useCallback(()=>{const Z=Math.max(G-1,0);q(Z)},[G,q]);return x.useEffect(()=>{V.length>0&&setTimeout(()=>{q(0),requestAnimationFrame(()=>W())},100)},[V,q,W]),o.jsxs("div",{className:"diff-viewer",children:[o.jsxs("div",{className:"diff-viewer-header",children:[o.jsx("div",{className:"diff-viewer-filename",children:n}),o.jsx("div",{className:"diff-viewer-nav",children:V.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(os,{content:"Previous change (Up)",position:"bottom",children:o.jsx("button",{className:"diff-nav-btn",onClick:Ae,disabled:G===0,children:"↑"})}),o.jsxs("span",{className:"diff-nav-counter",children:[G+1," / ",V.length]}),o.jsx(os,{content:"Next change (Down)",position:"bottom",children:o.jsx("button",{className:"diff-nav-btn",onClick:xe,disabled:G===V.length-1,children:"↓"})})]})}),o.jsxs("div",{className:"diff-viewer-stats",children:[H.added>0&&o.jsxs("span",{className:"diff-stat added",children:["+",H.added]}),H.removed>0&&o.jsxs("span",{className:"diff-stat removed",children:["-",H.removed]})]}),o.jsxs("div",{className:"diff-viewer-actions",children:[!D&&!E&&o.jsx(os,{content:k?"Show diff view":"View only modified",position:"bottom",children:o.jsx("button",{className:`diff-toggle-btn ${k?"active":""}`,onClick:()=>j(!k),children:r(k?"terminal:diffViewer.showDiff":"terminal:diffViewer.modifiedOnly")})}),o.jsx(os,{content:I&&k?"Copy as rich text":"Copy modified content",position:"bottom",children:o.jsx("button",{className:`diff-copy-btn ${y}`,onClick:O,children:y==="copied"?`✓ ${r("terminal:diffViewer.copied")}`:y==="error"?`✗ ${r("terminal:diffViewer.errorCopy")}`:r(I&&k?"terminal:diffViewer.copyRichText":"common:buttons.copy")})}),I&&k&&o.jsx(os,{content:"Copy as HTML tags (for Google Docs, HTML editors)",position:"bottom",children:o.jsx("button",{className:`diff-copy-btn ${C}`,onClick:_,children:C==="copied"?`✓ ${r("terminal:diffViewer.copied")}`:C==="error"?`✗ ${r("terminal:diffViewer.errorCopy")}`:r("terminal:diffViewer.copyHtml")})})]})]}),o.jsxs("div",{className:`diff-viewer-panels ${k||D||E?"modified-only":""}`,children:[!k&&!D&&o.jsxs("div",{className:"diff-panel diff-panel-original",children:[o.jsx("div",{className:"diff-panel-header",children:o.jsx("span",{className:"diff-panel-label",children:r("terminal:diffViewer.originalHead")})}),o.jsx("div",{className:"diff-panel-content",ref:i,children:M.map((Z,ce)=>{const me=L.get(ce),ee=me==="both"?"diff-hunk-top diff-hunk-bottom":me==="top"?"diff-hunk-top":me==="bottom"?"diff-hunk-bottom":"";return o.jsxs("div",{className:`diff-line diff-line-${Z.type} ${ee}`,children:[o.jsx("span",{className:"diff-line-num",children:Z.num}),o.jsx("span",{className:"diff-line-content",dangerouslySetInnerHTML:{__html:Z.highlighted||" "}})]},ce)})})]}),!k&&!D&&!E&&o.jsx("div",{className:"diff-connector-gutter",children:o.jsx("canvas",{ref:f})}),!E&&o.jsxs("div",{className:"diff-panel diff-panel-modified",children:[o.jsx("div",{className:"diff-panel-header",children:o.jsx("span",{className:"diff-panel-label",children:r(k||D?"terminal:diffViewer.modifiedContent":"terminal:diffViewer.modifiedWorking")})}),k&&I?o.jsx("div",{className:"diff-panel-content diff-markdown-content",ref:d,children:o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],children:e})})}):o.jsx("div",{className:"diff-panel-content",ref:c,children:R.map((Z,ce)=>{const me=F.get(ce),ee=me==="both"?"diff-hunk-top diff-hunk-bottom":me==="top"?"diff-hunk-top":me==="bottom"?"diff-hunk-bottom":"";return o.jsxs("div",{className:`diff-line diff-line-${Z.type} ${ee}`,children:[o.jsx("span",{className:"diff-line-num",children:Z.num}),o.jsx("span",{className:"diff-line-content",dangerouslySetInnerHTML:{__html:Z.highlighted||" "}})]},ce)})})]})]})]})}function j4(t,e){if(!t||t.startsWith("/")||!e||!e.startsWith("/"))return t;const n=t.replace(/^\.\//,""),s=e.split("/").filter(Boolean),a=n.split("/").filter(Boolean),r=[...s];for(const i of a)if(i!=="."){if(i===".."){r.length>0&&r.pop();continue}r.push(i)}return`/${r.join("/")}`}function _N(t){if(!t)return{path:t};const e=t.trim().replace(/^`|`$/g,"").replace(/[),.;]+$/g,""),n=e.match(/^(.*)#L(\d+)(?:C\d+)?$/i);if(n)return{path:n[1],line:Number(n[2])};const s=e.match(/^(.+?\.[^:\s]+):(\d+)(?::\d+)?$/);return s&&s[1].includes(".")?{path:s[1],line:Number(s[2])}:{path:e}}function sh(t,e){const n=_N(t);return{path:j4(n.path,e),line:n.line}}function N4(t,e){try{const n=t.split(`
|
|
86
|
+
`),s=e.split(`
|
|
87
|
+
`),a=[];let r=0;for(let i=0;i<s.length;i++){const d=s[i].match(/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/);if(!d)continue;const f=parseInt(d[3],10),h=parseInt(d[4]??"1",10),m=f-1;for(;r<m&&r<n.length;)a.push(n[r]),r++;let b=0;for(let y=i+1;y<s.length;y++){const w=s[y];if(w.startsWith("@@")||w.startsWith("diff "))break;w.startsWith("---")||w.startsWith("+++")||w.startsWith("index ")||w.startsWith("new file")||w.startsWith("deleted file")||w.startsWith("\\")||(w.startsWith("-")?a.push(w.slice(1)):w.startsWith("+")?(b++,r++):(a.push(w.startsWith(" ")?w.slice(1):w),b++,r++))}}for(;r<n.length;)a.push(n[r]),r++;return a.join(`
|
|
88
|
+
`)}catch{return null}}const NC=[".md",".mdx",".markdown"],TC=[".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".svg"],_C=[".pdf"];function EN({isOpen:t,onClose:e,filePath:n,action:s,editData:a,searchRoot:r}){const{t:i}=dt(["terminal","common"]),[c,d]=x.useState(null),[f,h]=x.useState(!1),[m,b]=x.useState(null),[y,w]=x.useState([]),[C,N]=x.useState([]),[k,j]=x.useState("idle"),[S,T]=x.useState("idle"),[D,E]=x.useState("idle"),[I,O]=x.useState("idle"),[_,M]=x.useState(null),[R,z]=x.useState(null),[$,W]=x.useState(!1),L=x.useRef(null),F=x.useRef(null),H=x.useRef(null),V=x.useMemo(()=>_N(n),[n]),G=V.path,B=(a==null?void 0:a.targetLine)??V.line,K=(a==null?void 0:a.highlightRange)||void 0;x.useEffect(()=>{t&&G?(w([]),N([]),M(null),z(null),Te()):(d(null),b(null),w([]),N([]),M(null),z(null))},[t,G]),x.useEffect(()=>{t&&H.current&&H.current.focus()},[t]),x.useEffect(()=>{if(!t)return;const ye=Ie=>{if(!(Ie.target instanceof HTMLInputElement||Ie.target instanceof HTMLTextAreaElement)){if(Ie.key==="Escape"){Ie.preventDefault(),Ie.stopPropagation(),e();return}if(Ie.key==="j"||Ie.key==="k"){Ie.preventDefault(),Ie.stopPropagation();const te=Ie.key==="j"?100:-100;if(F.current){const be=F.current.querySelectorAll(".diff-panel-content");if(be.length>0)be.forEach(we=>{we.scrollBy({top:te,behavior:"smooth"})});else{const we=F.current.querySelector(".file-viewer-code-with-lines");we?we.scrollBy({top:te,behavior:"smooth"}):F.current.scrollBy({top:te,behavior:"smooth"})}}return}Ie.stopPropagation()}};return window.addEventListener("keydown",ye,{capture:!0}),()=>window.removeEventListener("keydown",ye,{capture:!0})},[t,e]);const ne=x.useMemo(()=>{if(!c||!a||a.highlightRange)return null;const{oldString:ye="",newString:Ie="",operation:te}=a;if(!ye&&!Ie)return null;if(te==="append"&&Ie){if(c.content.endsWith(Ie))return c.content.slice(0,c.content.length-Ie.length);const be=c.content.lastIndexOf(Ie);return be!==-1?c.content.slice(0,be)+c.content.slice(be+Ie.length):null}if(Ie){const be=c.content.indexOf(Ie);return be!==-1?c.content.slice(0,be)+ye+c.content.slice(be+Ie.length):null}return null},[c,a]),q=!!a&&!a.highlightRange&&(!!a.oldString||!!a.newString),xe=(a==null?void 0:a.unifiedDiff)||_,Ae=!!xe,Z=x.useMemo(()=>ne!==null||!c||!xe?null:N4(c.content,xe),[ne,c,xe]),ce=ne??Z??R,me=ce!==null&&(q||Ae),ee=Ae&&!me,re=K!==void 0;x.useEffect(()=>{if(!c||!a||a.highlightRange||me||a.unifiedDiff||_!==null)return;(async()=>{try{const Ie=c.path||G,te=await Bt(Rt(`/api/files/git-diff?path=${encodeURIComponent(Ie)}`));if(te.ok){const be=await te.json();if(be.diff&&be.diff.trim()){M(be.diff);return}}}catch{}M("")})()},[c,a,me,G,_]),x.useEffect(()=>{if(!c||!a||a.highlightRange||ne!==null||Z!==null||R!==null||!q&&!Ae)return;(async()=>{try{const Ie=c.path||G,te=await Bt(Rt(`/api/files/git-original?path=${encodeURIComponent(Ie)}`));if(te.ok){const be=await te.json();if(be.content!==void 0&&be.content!==c.content){z(be.content);return}}}catch{}z("")})()},[c,a,ne,Z,R,q,Ae,G]),x.useEffect(()=>{if(!c)return;const ye=np(c.extension);if(ye==="plaintext"||ye in da.languages){W(!0);return}W(!1),jN(ye).then(()=>W(!0))},[c]);const We=x.useMemo(()=>{if(!c||me||ee||NC.includes(c.extension))return[];const ye=np(c.extension),Ie=da.languages[ye],te=be=>be.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return c.content.split(`
|
|
89
|
+
`).map(be=>Ie?da.highlight(be||" ",Ie,ye):te(be||" "))},[c,me,ee,$]);x.useEffect(()=>{if(!t||!c||!F.current)return;const ye=window.setTimeout(()=>{const Ie=()=>{if(!F.current)return;const te=F.current.querySelector(".file-line-highlighted");if(te){te.scrollIntoView({block:"center",behavior:"auto"});return}if(B){const be=F.current.querySelector(`.file-viewer-line-num[data-line="${B}"]`);be==null||be.scrollIntoView({block:"center",behavior:"auto"})}};window.requestAnimationFrame(()=>window.requestAnimationFrame(Ie))},0);return()=>window.clearTimeout(ye)},[t,c,re,K==null?void 0:K.offset,B]);const ze=async ye=>{const Ie=ye.substring(ye.lastIndexOf(".")).toLowerCase(),te=_C.includes(Ie),be=TC.includes(Ie),we=te||be?`/api/files/info?path=${encodeURIComponent(ye)}`:`/api/files/read?path=${encodeURIComponent(ye)}`,Fe=await Bt(Rt(we)),Ke=await Fe.json();if(!Fe.ok){const st=Ke.error==="Path is a directory";return{ok:!1,error:Ke.error,isDirectory:st}}return(te||be)&&(Ke.content=""),{ok:!0,data:Ke}},Pe=async(ye,Ie)=>{var te;try{const be=await Bt(Rt(`/api/files/resolve?name=${encodeURIComponent(ye)}&root=${encodeURIComponent(Ie)}`)),we=await be.json();if(be.ok&&((te=we.results)==null?void 0:te.length)>0)return we.results}catch{}return[]},ge=async ye=>{var Ie;try{const te=await Bt(Rt(`/api/files/list?path=${encodeURIComponent(ye)}`)),be=await te.json();if(te.ok&&((Ie=be.files)==null?void 0:Ie.length)>0)return be.files.slice(0,20).map(we=>({name:we.name,path:we.path,isDirectory:we.isDirectory,size:we.size||0,extension:we.extension||""}))}catch{}return[]},Te=async()=>{h(!0),b(null),w([]),N([]);try{const ye=await ze(G);if(ye.ok){d(ye.data);return}if(ye.isDirectory){const be=await ge(G);if(be.length>0){N(be);return}b(ye.error||i("terminal:fileExplorer.failedToLoad"));return}const Ie=G.split("/").pop()||G,te=r||(G.startsWith("/")?G.split("/").slice(0,-1).join("/"):"");if(te&&Ie){const be=await Pe(Ie,te);if(be.length===1&&!be[0].isDirectory){const we=await ze(be[0].path);if(we.ok){d(we.data);return}}else if(be.length>0){w(be);return}}b(ye.error||i("terminal:fileExplorer.failedToLoad"))}catch(ye){b(ye.message||i("terminal:fileExplorer.failedToLoad"))}finally{h(!1)}},qe=async ye=>{if(ye.isDirectory){h(!0),w([]),N([]),b(null);try{const Ie=await ge(ye.path);Ie.length>0?N(Ie):b("Empty directory")}catch{b("Failed to load directory")}finally{h(!1)}return}h(!0),w([]),N([]),b(null);try{const Ie=await ze(ye.path);Ie.ok?d(Ie.data):b(Ie.error||i("terminal:fileExplorer.failedToLoad"))}catch(Ie){b(Ie.message||i("terminal:fileExplorer.failedToLoad"))}finally{h(!1)}},{handleMouseDown:it,handleClick:he}=Ta(e),Be=()=>{switch(s){case"created":return i("common:status.created");case"modified":return i("common:status.modified");case"deleted":return i("common:status.deleted");case"read":return i("common:status.read")}},ie=()=>{switch(s){case"created":return"var(--accent-green)";case"modified":return"var(--accent-orange)";case"deleted":return"var(--accent-red)";case"read":return"var(--text-secondary)"}},de=x.useCallback(async()=>{if(!L.current){console.error("Copy Rich Text: markdown content ref is not available"),j("error"),setTimeout(()=>j("idle"),2e3);return}try{const ye=L.current.innerHTML,Ie=NN(ye),te=L.current.innerText;await TN(Ie,te),j("copied"),setTimeout(()=>j("idle"),2e3)}catch(ye){console.error("Copy Rich Text failed:",ye),j("error"),setTimeout(()=>j("idle"),2e3)}},[]),He=x.useCallback(async()=>{if(!L.current){console.error("Copy HTML: markdown content ref is not available"),T("error"),setTimeout(()=>T("idle"),2e3);return}try{const ye=L.current.innerHTML;await Lu(ye),T("copied"),setTimeout(()=>T("idle"),2e3)}catch(ye){console.error("Copy HTML failed:",ye),T("error"),setTimeout(()=>T("idle"),2e3)}},[]),et=x.useCallback(async()=>{if(!c){E("error"),setTimeout(()=>E("idle"),2e3);return}try{await Lu(c.content),E("copied"),setTimeout(()=>E("idle"),2e3)}catch{E("error"),setTimeout(()=>E("idle"),2e3)}},[c]),ct=x.useCallback(async()=>{if(!c){O("error"),setTimeout(()=>O("idle"),2e3);return}try{await Lu(c.content),O("copied"),setTimeout(()=>O("idle"),2e3)}catch{O("error"),setTimeout(()=>O("idle"),2e3)}},[c]),fe=ye=>ye<1024?`${ye} B`:ye<1024*1024?`${(ye/1024).toFixed(1)} KB`:`${(ye/(1024*1024)).toFixed(1)} MB`,X=c&&NC.includes(c.extension),se=c&&TC.includes(c.extension),Se=c&&_C.includes(c.extension),J=se?"Image":Se?"PDF":c?np(c.extension):"text",pe=Ii(),Re=se?Rt(`/api/files/binary?path=${encodeURIComponent(G)}${pe?`&token=${encodeURIComponent(pe)}`:""}`):null,$e=Se?Rt(`/api/files/binary?path=${encodeURIComponent(G)}${pe?`&token=${encodeURIComponent(pe)}`:""}`):null;return t?o.jsx(pr,{children:o.jsx("div",{ref:H,className:"file-viewer-overlay",onMouseDown:it,onClick:he,tabIndex:-1,children:o.jsxs("div",{className:"file-viewer-modal",children:[o.jsxs("div",{className:"file-viewer-header",children:[o.jsxs("div",{className:"file-viewer-title",children:[o.jsx("span",{className:"file-viewer-action",style:{color:ie()},children:Be()}),o.jsx("span",{className:"file-viewer-filename",children:(c==null?void 0:c.filename)||G.split("/").pop()})]}),o.jsxs("div",{className:"file-viewer-header-buttons",children:[X&&c&&!me&&!ee&&!re&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:`file-viewer-copy-html-btn ${k}`,onClick:de,title:i("terminal:fileExplorer.copyRichTextTitle"),children:i(k==="copied"?"common:status.copied":k==="error"?"common:status.error":"terminal:fileExplorer.copyRichText")}),o.jsx("button",{className:`file-viewer-copy-html-btn ${S}`,onClick:He,title:i("terminal:fileExplorer.copyHtmlTitle"),children:i(S==="copied"?"common:status.copied":S==="error"?"common:status.error":"terminal:fileExplorer.copyHtml")}),o.jsx("button",{className:`file-viewer-copy-html-btn ${D}`,onClick:et,title:i("terminal:fileExplorer.copyMarkdownTitle"),children:i(D==="copied"?"common:status.copied":D==="error"?"common:status.error":"terminal:fileExplorer.copyMarkdown")}),o.jsx("button",{className:`file-viewer-copy-html-btn ${I}`,onClick:ct,title:i("terminal:fileExplorer.copyOriginalTitle"),children:i(I==="copied"?"common:status.copied":I==="error"?"common:status.error":"terminal:fileExplorer.copyOriginal")})]}),se&&Re||Se&&$e?o.jsx("a",{className:"file-viewer-copy-html-btn",href:`${se?Re:$e}&download=true`,download:c==null?void 0:c.filename,title:i(se?"terminal:fileExplorer.downloadImage":"terminal:fileExplorer.downloadPdf"),children:i("common:buttons.download")}):null,o.jsx("button",{className:"file-viewer-close",onClick:e,children:"×"})]})]}),o.jsx("div",{className:"file-viewer-path",children:(c==null?void 0:c.path)||G}),c&&o.jsxs("div",{className:"file-viewer-meta",children:[o.jsx("span",{children:fe(c.size)}),o.jsx("span",{children:"•"}),o.jsx("span",{children:J}),c.content&&!se&&!Se&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"•"}),o.jsx("span",{children:i("terminal:fileViewer.lineCount",{count:c.content.split(`
|
|
90
|
+
`).length})})]})]}),o.jsxs("div",{className:"file-viewer-content",ref:F,children:[f&&o.jsx("div",{className:"file-viewer-loading",children:i("terminal:fileExplorer.loadingFile")}),m&&!y.length&&!C.length&&o.jsx("div",{className:"file-viewer-error",children:m}),y.length>0&&o.jsxs("div",{className:"file-viewer-resolve-results",children:[o.jsxs("div",{className:"file-viewer-resolve-header",children:["Found ",y.length," matching file",y.length>1?"s":""," in project:"]}),o.jsx("div",{className:"file-viewer-resolve-list",children:y.map(ye=>o.jsxs("button",{className:"file-viewer-resolve-item",onClick:()=>qe(ye),children:[o.jsx("span",{className:"file-viewer-resolve-icon",children:ye.isDirectory?"📁":"📄"}),o.jsxs("span",{className:"file-viewer-resolve-info",children:[o.jsx("span",{className:"file-viewer-resolve-name",children:ye.name}),o.jsx("span",{className:"file-viewer-resolve-path",children:ye.path})]}),!ye.isDirectory&&ye.size>0&&o.jsx("span",{className:"file-viewer-resolve-size",children:fe(ye.size)})]},ye.path))})]}),C.length>0&&o.jsxs("div",{className:"file-viewer-resolve-results",children:[o.jsxs("div",{className:"file-viewer-resolve-header",children:["Directory contents (",C.length," items):"]}),o.jsx("div",{className:"file-viewer-resolve-list",children:C.map(ye=>o.jsxs("button",{className:"file-viewer-resolve-item",onClick:()=>qe(ye),children:[o.jsx("span",{className:"file-viewer-resolve-icon",children:ye.isDirectory?"📁":"📄"}),o.jsxs("span",{className:"file-viewer-resolve-info",children:[o.jsx("span",{className:"file-viewer-resolve-name",children:ye.name}),o.jsx("span",{className:"file-viewer-resolve-path",children:ye.path})]}),!ye.isDirectory&&ye.size>0&&o.jsx("span",{className:"file-viewer-resolve-size",children:fe(ye.size)})]},ye.path))})]}),c&&!f&&!m&&(se&&Re?o.jsx("div",{className:"file-viewer-image-wrapper",children:o.jsx("img",{src:Re,alt:c.filename,className:"file-viewer-image"})}):Se&&$e?o.jsx("div",{className:"file-viewer-pdf-embed",children:o.jsx("iframe",{src:$e,title:c.filename,className:"file-viewer-pdf-iframe"})}):me?o.jsx(mx,{originalContent:ce,modifiedContent:c.content,filename:c.filename,language:J}):ee?o.jsx("pre",{className:"file-viewer-code file-viewer-unified-diff",children:xe.split(`
|
|
91
|
+
`).map((ye,Ie)=>{let te="diff-ctx";return ye.startsWith("+")&&!ye.startsWith("+++")?te="diff-add":ye.startsWith("-")&&!ye.startsWith("---")?te="diff-del":ye.startsWith("@@")?te="diff-hdr":(ye.startsWith("diff ")||ye.startsWith("index ")||ye.startsWith("---")||ye.startsWith("+++"))&&(te="diff-meta"),o.jsxs("div",{className:`file-line file-line-${te}`,children:[o.jsx("span",{className:"file-line-num",children:Ie+1}),o.jsx("code",{children:ye||" "})]},Ie)})}):re?o.jsx("pre",{className:"file-viewer-code file-viewer-code-highlighted",children:c.content.split(`
|
|
92
|
+
`).map((ye,Ie)=>{const te=Ie+1,be=K,we=be&&te>=be.offset&&te<be.offset+be.limit;return o.jsxs("div",{className:`file-line ${we?"file-line-highlighted":""}`,children:[o.jsx("span",{className:"file-line-num",children:te}),o.jsx("code",{className:`language-${J}`,dangerouslySetInnerHTML:{__html:We[Ie]||ye||" "}})]},Ie)})}):X?o.jsx("div",{className:"file-viewer-markdown markdown-content",ref:L,children:o.jsx(Fr,{remarkPlugins:[zr],children:c.content})}):o.jsx("pre",{className:`file-viewer-code file-viewer-code-lines language-${J}`,children:We.map((ye,Ie)=>o.jsxs("div",{className:`file-line ${B===Ie+1?"file-line-highlighted":""}`,children:[o.jsx("span",{className:`file-line-num ${B===Ie+1?"file-viewer-line-num-target":""}`,"data-line":Ie+1,children:Ie+1}),o.jsx("code",{className:`language-${J}`,dangerouslySetInnerHTML:{__html:ye}})]},Ie+1))}))]})]})})}):null}function T4({agentIds:t}){const{t:e}=dt(["terminal"]),n=Vx(),s=n1(),[a,r]=x.useState(null),[i,c]=x.useState(null),[d,f]=x.useState(()=>Ni(pt.TOOLS_COLLAPSED)),[h,m]=x.useState(()=>Ni(pt.FILES_COLLAPSED)),b=()=>{const O=!d;f(O),Ti(pt.TOOLS_COLLAPSED,O)},y=()=>{const O=!h;m(O),Ti(pt.FILES_COLLAPSED,O)},w=x.useMemo(()=>new Set(t),[t]),C=x.useMemo(()=>n.filter(O=>w.has(O.agentId)),[n,w]),N=x.useMemo(()=>s.filter(O=>w.has(O.agentId)),[s,w]),k=t.length>1,j=O=>new Date(O).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),S=O=>{const _=O.split("/");return _.length>2?".../"+_.slice(-2).join("/"):O},T=O=>{switch(O){case"created":return"+";case"modified":return"~";case"deleted":return"-";case"read":return">"}},D=O=>{switch(O){case"created":return"var(--accent-green)";case"modified":return"var(--accent-orange)";case"deleted":return"var(--accent-red)";case"read":return"var(--text-secondary)"}},E=O=>O==="Read"?"📖":O==="Write"?"📝":O==="Edit"?"✏️":O==="Bash"?"💻":O==="Grep"?"🔍":O==="Glob"?"📁":O==="Task"||O==="Agent"?"🤖":O==="WebFetch"?"🌐":O==="WebSearch"?"🔎":"🔧",I=(O,_)=>{r({path:O,action:_})};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"tool-history-stacked",children:[o.jsxs("div",{className:`tool-history-panel ${d?"collapsed":""}`,children:[o.jsxs("div",{className:"tool-history-panel-header",onClick:b,children:[o.jsx("span",{className:"tool-history-panel-toggle",children:d?"▶":"▼"}),e("terminal:toolHistory.tools")," (",C.length,")"]}),!d&&o.jsx("div",{className:"tool-history-panel-content",children:C.length===0?o.jsx("div",{className:"tool-history-empty",children:e("terminal:toolHistory.noToolsYet")}):o.jsx("div",{className:"tool-history-list",children:C.slice(0,50).map((O,_)=>o.jsx(E4,{execution:O,formatTime:j,formatPath:S,getToolIcon:E,showAgentName:k,isExpanded:i===_,onToggle:()=>c(i===_?null:_),onViewFile:M=>r({path:M,action:"modified"})},_))})})]}),o.jsxs("div",{className:`tool-history-panel ${h?"collapsed":""}`,children:[o.jsxs("div",{className:"tool-history-panel-header",onClick:y,children:[o.jsx("span",{className:"tool-history-panel-toggle",children:h?"▶":"▼"}),e("terminal:toolHistory.filesSection")," (",N.length,")"]}),!h&&o.jsx("div",{className:"tool-history-panel-content",children:N.length===0?o.jsx("div",{className:"tool-history-empty",children:e("terminal:toolHistory.noFileChangesYet")}):o.jsx("div",{className:"tool-history-list",children:N.slice(0,50).map((O,_)=>o.jsx(D4,{change:O,formatTime:j,formatPath:S,getActionIcon:T,getActionColor:D,onClick:()=>I(O.filePath,O.action),showAgentName:k},_))})})]})]}),o.jsx(EN,{isOpen:a!==null,onClose:()=>r(null),filePath:(a==null?void 0:a.path)||"",action:(a==null?void 0:a.action)||"read"})]})}function _4(t,e){if(!e)return null;switch(t){case"WebSearch":return e.query||null;case"WebFetch":const n=e.url;return n&&n.length>50?n.slice(0,47)+"...":n||null;case"Read":case"Write":case"Edit":const s=e.file_path||e.path;return s?s.length>40?".../"+s.split("/").slice(-2).join("/"):s:null;case"Bash":const a=e.command;return a?a.length>50?a.slice(0,47)+"...":a:null;case"Grep":return e.pattern?`"${e.pattern}"`:null;case"Glob":return e.pattern||null;case"Task":const r=e.description;return r?r.length>40?r.slice(0,37)+"...":r:null;case"TodoWrite":const i=e.todos;return i!=null&&i.length?`${i.length} item${i.length>1?"s":""}`:null;default:for(const[,c]of Object.entries(e))if(typeof c=="string"&&c.length>0&&c.length<80)return c.length>50?c.slice(0,47)+"...":c;return null}}function E4({execution:t,formatTime:e,formatPath:n,getToolIcon:s,showAgentName:a,isExpanded:r,onToggle:i,onViewFile:c}){const{t:d}=dt(["terminal"]),f=_4(t.toolName,t.toolInput),h=t.toolInput&&Object.keys(t.toolInput).length>0,m=t.toolInput?t.toolInput.file_path||t.toolInput.path:void 0,b=["Write","Edit","Read"].includes(t.toolName)&&m;return o.jsxs("div",{className:`tool-history-item tool-compact ${r?"expanded":""} ${h?"clickable":""}`,children:[o.jsxs("div",{className:"tool-row",onClick:h?i:void 0,title:t.toolName,children:[o.jsx("span",{className:"tool-expand-icon",children:h?r?"▼":"▶":" "}),o.jsx("span",{className:"tool-icon",title:t.toolName,children:s(t.toolName)}),o.jsx("div",{className:"tool-input-inline",title:f||t.toolName,children:f||t.toolName}),a&&o.jsx("span",{className:"tool-agent-compact",children:t.agentName}),o.jsx("span",{className:"tool-time",children:e(t.timestamp)})]}),r&&t.toolInput&&o.jsxs("div",{className:"tool-expanded-details",children:[o.jsxs("div",{className:"tool-expanded-header",children:[o.jsx("span",{className:"tool-expanded-name",children:t.toolName}),b&&o.jsx("button",{className:"tool-view-file-btn",onClick:y=>{y.stopPropagation(),c(m)},children:d("terminal:toolHistory.viewFile")})]}),o.jsx("pre",{className:"tool-input-json",children:M4(t.toolName,t.toolInput)})]})]})}function M4(t,e){if(t==="Write"&&e.content){const n=e.content,s=e.file_path||e.path,a=n.length>2e3?n.slice(0,2e3)+`
|
|
93
|
+
|
|
94
|
+
... (truncated)`:n;return`file: ${s}
|
|
95
|
+
|
|
96
|
+
${a}`}if(t==="Edit"){const n=[];if(e.file_path&&n.push(`file: ${e.file_path}`),e.old_string){const s=e.old_string;n.push(`
|
|
97
|
+
- old:
|
|
98
|
+
${s.slice(0,500)}${s.length>500?"...":""}`)}if(e.new_string){const s=e.new_string;n.push(`
|
|
99
|
+
+ new:
|
|
100
|
+
${s.slice(0,500)}${s.length>500?"...":""}`)}return n.join(`
|
|
101
|
+
`)}return t==="Bash"&&e.command?e.command:t==="TodoWrite"&&e.todos?e.todos.map((s,a)=>`${s.status==="completed"?"✓":s.status==="in_progress"?"→":"○"} ${s.content}`).join(`
|
|
102
|
+
`):JSON.stringify(e,null,2)}function D4({change:t,formatTime:e,formatPath:n,getActionIcon:s,getActionColor:a,onClick:r,showAgentName:i}){return o.jsxs("div",{className:"tool-history-item file-change clickable",onClick:r,children:[o.jsx("span",{className:"file-action",style:{color:a(t.action)},children:s(t.action)}),o.jsx("span",{className:"file-path",title:t.filePath,children:n(t.filePath)}),i&&o.jsx("span",{className:"tool-agent-compact",children:t.agentName}),o.jsx("span",{className:"tool-time",children:e(t.timestamp)})]})}function Ml(t,e,n){let s=n.initialDeps??[],a,r=!0;function i(){var c,d,f;let h;n.key&&((c=n.debug)!=null&&c.call(n))&&(h=Date.now());const m=t();if(!(m.length!==s.length||m.some((w,C)=>s[C]!==w)))return a;s=m;let y;if(n.key&&((d=n.debug)!=null&&d.call(n))&&(y=Date.now()),a=e(...m),n.key&&((f=n.debug)!=null&&f.call(n))){const w=Math.round((Date.now()-h)*100)/100,C=Math.round((Date.now()-y)*100)/100,N=C/16,k=(j,S)=>{for(j=String(j);j.length<S;)j=" "+j;return j};console.info(`%c⏱ ${k(C,5)} /${k(w,5)} ms`,`
|
|
103
|
+
font-size: .6rem;
|
|
104
|
+
font-weight: bold;
|
|
105
|
+
color: hsl(${Math.max(0,Math.min(120-120*N,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(r&&n.skipInitialOnChange)&&n.onChange(a),r=!1,a}return i.updateDeps=c=>{s=c},i}function EC(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const R4=(t,e)=>Math.abs(t-e)<1.01,O4=(t,e,n)=>{let s;return function(...a){t.clearTimeout(s),s=t.setTimeout(()=>e.apply(this,a),n)}},MC=t=>{const{offsetWidth:e,offsetHeight:n}=t;return{width:e,height:n}},L4=t=>t,I4=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),s=[];for(let a=e;a<=n;a++)s.push(a);return s},P4=(t,e)=>{const n=t.scrollElement;if(!n)return;const s=t.targetWindow;if(!s)return;const a=i=>{const{width:c,height:d}=i;e({width:Math.round(c),height:Math.round(d)})};if(a(MC(n)),!s.ResizeObserver)return()=>{};const r=new s.ResizeObserver(i=>{const c=()=>{const d=i[0];if(d!=null&&d.borderBoxSize){const f=d.borderBoxSize[0];if(f){a({width:f.inlineSize,height:f.blockSize});return}}a(MC(n))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return r.observe(n,{box:"border-box"}),()=>{r.unobserve(n)}},DC={passive:!0},RC=typeof window>"u"?!0:"onscrollend"in window,B4=(t,e)=>{const n=t.scrollElement;if(!n)return;const s=t.targetWindow;if(!s)return;let a=0;const r=t.options.useScrollendEvent&&RC?()=>{}:O4(s,()=>{e(a,!1)},t.options.isScrollingResetDelay),i=h=>()=>{const{horizontal:m,isRtl:b}=t.options;a=m?n.scrollLeft*(b&&-1||1):n.scrollTop,r(),e(a,h)},c=i(!0),d=i(!1);n.addEventListener("scroll",c,DC);const f=t.options.useScrollendEvent&&RC;return f&&n.addEventListener("scrollend",d,DC),()=>{n.removeEventListener("scroll",c),f&&n.removeEventListener("scrollend",d)}},F4=(t,e,n)=>{if(e!=null&&e.borderBoxSize){const s=e.borderBoxSize[0];if(s)return Math.round(s[n.options.horizontal?"inlineSize":"blockSize"])}return t[n.options.horizontal?"offsetWidth":"offsetHeight"]},z4=(t,{adjustments:e=0,behavior:n},s)=>{var a,r;const i=t+e;(r=(a=s.scrollElement)==null?void 0:a.scrollTo)==null||r.call(a,{[s.options.horizontal?"left":"top"]:i,behavior:n})};class $4{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,s,a;return((a=(s=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:s.now)==null?void 0:a.call(s))??Date.now()},this.observer=(()=>{let n=null;const s=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(a=>{a.forEach(r=>{const i=()=>{const c=r.target,d=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(c,r,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var a;(a=s())==null||a.disconnect(),n=null},observe:a=>{var r;return(r=s())==null?void 0:r.observe(a,{box:"border-box"})},unobserve:a=>{var r;return(r=s())==null?void 0:r.unobserve(a)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([s,a])=>{typeof a>"u"&&delete n[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:L4,rangeExtractor:I4,onChange:()=>{},measureElement:F4,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var s,a;(a=(s=this.options).onChange)==null||a.call(s,this,n)},this.maybeNotify=Ml(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=r,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,s)=>{const a=new Map,r=new Map;for(let i=s-1;i>=0;i--){const c=n[i];if(a.has(c.lane))continue;const d=r.get(c.lane);if(d==null||c.end>d.end?r.set(c.lane,c):c.end<d.end&&a.set(c.lane,!0),a.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((i,c)=>i.end===c.end?i.index-c.index:i.end-c.end)[0]:void 0},this.getMeasurementOptions=Ml(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,s,a,r,i,c)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:s,scrollMargin:a,getItemKey:r,enabled:i,lanes:c}),{key:!1}),this.getMeasurements=Ml(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:s,scrollMargin:a,getItemKey:r,enabled:i,lanes:c},d)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const b of this.laneAssignments.keys())b>=n&&this.laneAssignments.delete(b);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(b=>{this.itemSizeCache.set(b.key,b.size)}));const f=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const h=this.measurementsCache.slice(0,f),m=new Array(c).fill(void 0);for(let b=0;b<f;b++){const y=h[b];y&&(m[y.lane]=b)}for(let b=f;b<n;b++){const y=r(b),w=this.laneAssignments.get(b);let C,N;if(w!==void 0&&this.options.lanes>1){C=w;const T=m[C],D=T!==void 0?h[T]:void 0;N=D?D.end+this.options.gap:s+a}else{const T=this.options.lanes===1?h[b-1]:this.getFurthestMeasurement(h,b);N=T?T.end+this.options.gap:s+a,C=T?T.lane:b%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(b,C)}const k=d.get(y),j=typeof k=="number"?k:this.options.estimateSize(b),S=N+j;h[b]={index:b,start:N,size:j,end:S,key:y,lane:C},m[C]=b}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ml(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,s,a,r)=>this.range=n.length>0&&s>0?U4({measurements:n,outerSize:s,scrollOffset:a,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ml(()=>{let n=null,s=null;const a=this.calculateRange();return a&&(n=a.startIndex,s=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,s]},(n,s,a,r,i)=>r===null||i===null?[]:n({startIndex:r,endIndex:i,overscan:s,count:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const s=this.options.indexAttribute,a=n.getAttribute(s);return a?parseInt(a,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(a!==void 0&&this.range){const r=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,a-r),c=Math.min(this.options.count-1,a+r);return n>=i&&n<=c}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((i,c)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(c))});return}const s=this.indexFromElement(n),a=this.options.getItemKey(s),r=this.elementsCache.get(a);r!==n&&(r&&this.observer.unobserve(r),this.observer.observe(n),this.elementsCache.set(a,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,s)=>{var a;const r=this.measurementsCache[n];if(!r)return;const i=this.itemSizeCache.get(r.key)??r.size,c=s-i;c!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(r,c,this):r.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=c,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(r.index),this.itemSizeCache=new Map(this.itemSizeCache.set(r.key,s)),this.notify(!1))},this.getVirtualItems=Ml(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,s)=>{const a=[];for(let r=0,i=n.length;r<i;r++){const c=n[r],d=s[c];a.push(d)}return a},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const s=this.getMeasurements();if(s.length!==0)return EC(s[MN(0,s.length-1,a=>EC(s[a]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,s,a=0)=>{if(!this.scrollElement)return 0;const r=this.getSize(),i=this.getScrollOffset();s==="auto"&&(s=n>=i+r?"end":"start"),s==="center"?n+=(a-r)/2:s==="end"&&(n-=r);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,n),0)},this.getOffsetForIndex=(n,s="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[n];if(!i)return;if(s==="auto")if(i.end>=r+a-this.options.scrollPaddingEnd)s="end";else if(i.start<=r+this.options.scrollPaddingStart)s="start";else return[r,s];if(s==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),s];const c=s==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,s,i.size),s]},this.scrollToOffset=(n,{align:s="start",behavior:a="auto"}={})=>{const r=this.getOffsetForAlignment(n,s),i=this.now();this.scrollState={index:null,align:s,behavior:a,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:s="auto",behavior:a="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getOffsetForIndex(n,s);if(!r)return;const[i,c]=r,d=this.now();this.scrollState={index:n,align:c,behavior:a,startedAt:d,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:s="auto"}={})=>{const a=this.getScrollOffset()+n,r=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:r,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const s=this.getMeasurements();let a;if(s.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=s[s.length-1])==null?void 0:n.end)??0;else{const r=Array(this.options.lanes).fill(null);let i=s.length-1;for(;i>=0&&r.some(c=>c===null);){const c=s[i];r[c.lane]===null&&(r[c.lane]=c.end),i--}a=Math.max(...r.filter(c=>c!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:s,behavior:a})=>{this.options.scrollToFn(n,{behavior:a,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=s?s[0]:this.scrollState.lastTargetOffset,r=1,i=a!==this.scrollState.lastTargetOffset;if(!i&&R4(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=r){this.scrollState=null;return}}else this.scrollState.stableFrames=0,i&&(this.scrollState.lastTargetOffset=a,this.scrollState.behavior="auto",this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const MN=(t,e,n,s)=>{for(;t<=e;){const a=(t+e)/2|0,r=n(a);if(r<s)t=a+1;else if(r>s)e=a-1;else return a}return t>0?t-1:0};function U4({measurements:t,outerSize:e,scrollOffset:n,lanes:s}){const a=t.length-1,r=d=>t[d].start;if(t.length<=s)return{startIndex:0,endIndex:a};let i=MN(0,a,r,n),c=i;if(s===1)for(;c<a&&t[c].end<n+e;)c++;else if(s>1){const d=Array(s).fill(0);for(;c<a&&d.some(h=>h<n+e);){const h=t[c];d[h.lane]=h.end,c++}const f=Array(s).fill(n+e);for(;i>=0&&f.some(h=>h>=n);){const h=t[i];f[h.lane]=h.start,i--}i=Math.max(0,i-i%s),c=Math.min(a,c+(s-1-c%s))}return{startIndex:i,endIndex:c}}const OC=typeof document<"u"?x.useLayoutEffect:x.useEffect;function H4({useFlushSync:t=!0,...e}){const n=x.useReducer(()=>({}),{})[1],s={...e,onChange:(r,i)=>{var c;t&&i?ac.flushSync(n):n(),(c=e.onChange)==null||c.call(e,r,i)}},[a]=x.useState(()=>new $4(s));return a.setOptions(s),OC(()=>a._didMount(),[]),OC(()=>a._willUpdate()),a}function DN(t){return H4({observeElementRect:P4,observeElementOffset:B4,scrollToFn:z4,...t})}const LC={30:"#000000",31:"#ef4444",32:"#22c55e",33:"#eab308",34:"#3b82f6",35:"#a855f7",36:"#06b6d4",37:"#e5e5e5",90:"#666666",91:"#f87171",92:"#4ade80",93:"#facc15",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"},IC={40:"#000000",41:"#ef4444",42:"#22c55e",43:"#eab308",44:"#3b82f6",45:"#a855f7",46:"#06b6d4",47:"#e5e5e5",100:"#666666",101:"#f87171",102:"#4ade80",103:"#facc15",104:"#60a5fa",105:"#c084fc",106:"#22d3ee",107:"#ffffff"};function PC(t){const e=[];return t.color&&e.push(`color:${t.color}`),t.bgColor&&e.push(`background-color:${t.bgColor}`),t.bold&&e.push("font-weight:bold"),t.dim&&e.push("opacity:0.6"),t.italic&&e.push("font-style:italic"),t.underline&&e.push("text-decoration:underline"),e.join(";")}function W4(t,e){const n={...t};return e===0?{}:(e===1?n.bold=!0:e===2?n.dim=!0:e===3?n.italic=!0:e===4?n.underline=!0:e===7?n.inverse=!0:e===22?(n.bold=!1,n.dim=!1):e===23?n.italic=!1:e===24?n.underline=!1:e===27?n.inverse=!1:e===39?delete n.color:e===49?delete n.bgColor:e>=30&&e<=37?n.color=LC[e]:e>=40&&e<=47?n.bgColor=IC[e]:e>=90&&e<=97?n.color=LC[e]:e>=100&&e<=107&&(n.bgColor=IC[e]),n)}function Kl(t){const e=/(?:\x1b|\u001b)?\[([0-9;]*)m/g;let n="",s=0,a={},r;for(;(r=e.exec(t))!==null;){const c=t.slice(s,r.index);if(c){const f=PC(a);f?n+=`<span style="${f}">${Bf(c)}</span>`:n+=Bf(c)}const d=r[1].split(";").filter(Boolean).map(Number);if(d.length===0)a={};else for(const f of d)a=W4(a,f);s=r.index+r[0].length}const i=t.slice(s);if(i){const c=PC(a);c?n+=`<span style="${c}">${Bf(i)}</span>`:n+=Bf(i)}return n}function Bf(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Do=x.memo(function({isOpen:e,position:n,actions:s,onClose:a}){const r=x.useRef(null),i=x.useRef(null);x.useEffect(()=>{if(!e)return;const d=setTimeout(()=>{const f=b=>{r.current&&!r.current.contains(b.target)&&a()},h=b=>{b.key==="Escape"&&a()},m=b=>{var w,C;const y=b.target;y&&y!==document&&y!==document.documentElement&&((w=y.classList)!=null&&w.contains("xterm-viewport")||(C=y.closest)!=null&&C.call(y,".guake-bottom-terminal-embed"))||a()};document.addEventListener("mousedown",f),document.addEventListener("touchstart",f,{passive:!0}),document.addEventListener("keydown",h),window.addEventListener("scroll",m,!0),i.current=()=>{document.removeEventListener("mousedown",f),document.removeEventListener("touchstart",f),document.removeEventListener("keydown",h),window.removeEventListener("scroll",m,!0)}},100);return()=>{var f;clearTimeout(d),(f=i.current)==null||f.call(i),i.current=null}},[e,a]),x.useEffect(()=>{if(!e||!r.current)return;const d=r.current,f=d.getBoundingClientRect(),h=window.innerWidth,m=window.innerHeight;let b=n.x,y=n.y;n.x+f.width>h-10&&(b=h-f.width-10),n.y+f.height>m-10&&(y=m-f.height-10),d.style.left=`${Math.max(10,b)}px`,d.style.top=`${Math.max(10,y)}px`},[e,n]);const c=x.useCallback(d=>{d.disabled||(d.onClick(),a())},[a]);return e?o.jsx("div",{ref:r,className:"context-menu",style:{left:n.x,top:n.y},onClick:d=>d.stopPropagation(),children:s.map((d,f)=>d.divider?o.jsx("div",{className:"context-menu-divider"},`divider-${f}`):o.jsxs("button",{className:`context-menu-item ${d.disabled?"disabled":""} ${d.danger?"danger":""}`,onClick:()=>c(d),onTouchEnd:h=>{h.preventDefault(),h.stopPropagation(),c(d)},disabled:d.disabled,children:[d.icon&&o.jsx("span",{className:"context-menu-icon",children:d.icon}),o.jsx("span",{className:"context-menu-label",children:d.label}),d.shortcut&&o.jsx("span",{className:"context-menu-shortcut",children:d.shortcut})]},d.id))}):null});function RN(t){var e,n,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;e<a;e++)t[e]&&(n=RN(t[e]))&&(s&&(s+=" "),s+=n)}else for(n in t)t[n]&&(s&&(s+=" "),s+=n);return s}function us(){for(var t,e,n=0,s="",a=arguments.length;n<a;n++)(t=arguments[n])&&(e=RN(t))&&(s&&(s+=" "),s+=e);return s}const ON=6048e5,q4=864e5,ah=6e4,rh=36e5,V4=1e3,BC=Symbol.for("constructDateFrom");function vn(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&BC in t?t[BC](e):t instanceof Date?new t.constructor(e):new Date(e)}function St(t,e){return vn(e||t,t)}function Pa(t,e,n){const s=St(t,n==null?void 0:n.in);return isNaN(e)?vn((n==null?void 0:n.in)||t,NaN):(e&&s.setDate(s.getDate()+e),s)}function za(t,e,n){const s=St(t,n==null?void 0:n.in);if(isNaN(e))return vn(t,NaN);if(!e)return s;const a=s.getDate(),r=vn(t,s.getTime());r.setMonth(s.getMonth()+e+1,0);const i=r.getDate();return a>=i?r:(s.setFullYear(r.getFullYear(),r.getMonth(),a),s)}function LN(t,e,n){return vn(t,+St(t)+e)}function Y4(t,e,n){return LN(t,e*rh)}let G4={};function Io(){return G4}function qr(t,e){var c,d,f,h;const n=Io(),s=(e==null?void 0:e.weekStartsOn)??((d=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??n.weekStartsOn??((h=(f=n.locale)==null?void 0:f.options)==null?void 0:h.weekStartsOn)??0,a=St(t,e==null?void 0:e.in),r=a.getDay(),i=(r<s?7:0)+r-s;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function Ql(t,e){return qr(t,{...e,weekStartsOn:1})}function IN(t,e){const n=St(t,e==null?void 0:e.in),s=n.getFullYear(),a=vn(n,0);a.setFullYear(s+1,0,4),a.setHours(0,0,0,0);const r=Ql(a),i=vn(n,0);i.setFullYear(s,0,4),i.setHours(0,0,0,0);const c=Ql(i);return n.getTime()>=r.getTime()?s+1:n.getTime()>=c.getTime()?s:s-1}function Np(t){const e=St(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function Gr(t,...e){const n=vn.bind(null,e.find(s=>typeof s=="object"));return e.map(n)}function Ro(t,e){const n=St(t,e==null?void 0:e.in);return n.setHours(0,0,0,0),n}function Xl(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=Ro(s),i=Ro(a),c=+r-Np(r),d=+i-Np(i);return Math.round((c-d)/q4)}function K4(t,e){const n=IN(t,e),s=vn(t,0);return s.setFullYear(n,0,4),s.setHours(0,0,0,0),Ql(s)}function Gu(t,e,n){const s=St(t,n==null?void 0:n.in);return s.setTime(s.getTime()+e*ah),s}function fy(t,e,n){return za(t,e*3,n)}function Q4(t,e,n){return LN(t,e*1e3)}function Tp(t,e,n){return Pa(t,e*7,n)}function Ba(t,e,n){return za(t,e*12,n)}function FC(t,e){let n,s=e==null?void 0:e.in;return t.forEach(a=>{!s&&typeof a=="object"&&(s=vn.bind(null,a));const r=St(a,s);(!n||n<r||isNaN(+r))&&(n=r)}),vn(s,n||NaN)}function zC(t,e){let n,s=e==null?void 0:e.in;return t.forEach(a=>{!s&&typeof a=="object"&&(s=vn.bind(null,a));const r=St(a,s);(!n||n>r||isNaN(+r))&&(n=r)}),vn(s,n||NaN)}function X4(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return+Ro(s)==+Ro(a)}function ir(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Jl(t){return!(!ir(t)&&typeof t!="number"||isNaN(+St(t)))}function _p(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=s.getFullYear()-a.getFullYear(),i=s.getMonth()-a.getMonth();return r*12+i}function _i(t,e){const n=St(t,e==null?void 0:e.in);return Math.trunc(n.getMonth()/3)+1}function Ep(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=s.getFullYear()-a.getFullYear(),i=_i(s)-_i(a);return r*4+i}function Mp(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return s.getFullYear()-a.getFullYear()}function J4(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e),r=$C(s,a),i=Math.abs(Xl(s,a));s.setDate(s.getDate()-r*i);const c=+($C(s,a)===-r),d=r*(i-c);return d===0?0:d}function $C(t,e){const n=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return n<0?-1:n>0?1:n}function PN(t,e){const n=St(t,e==null?void 0:e.in);return n.setHours(23,59,59,999),n}function BN(t,e){const n=St(t,e==null?void 0:e.in),s=n.getMonth();return n.setFullYear(n.getFullYear(),s+1,0),n.setHours(23,59,59,999),n}function gx(t,e){const n=St(t,e==null?void 0:e.in),s=n.getMonth(),a=s-s%3;return n.setMonth(a,1),n.setHours(0,0,0,0),n}function FN(t,e){const n=St(t,e==null?void 0:e.in);return n.setDate(1),n.setHours(0,0,0,0),n}function zN(t,e){const n=St(t,e==null?void 0:e.in),s=n.getFullYear();return n.setFullYear(s+1,0,0),n.setHours(23,59,59,999),n}function ih(t,e){const n=St(t,e==null?void 0:e.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Z4(t,e){var c,d;const n=Io(),s=n.weekStartsOn??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??0,a=St(t,e==null?void 0:e.in),r=a.getDay(),i=(r<s?-7:0)+6-(r-s);return a.setDate(a.getDate()+i),a.setHours(23,59,59,999),a}const ez={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},tz=(t,e,n)=>{let s;const a=ez[t];return typeof a=="string"?s=a:e===1?s=a.one:s=a.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+s:s+" ago":s};function pb(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const nz={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},sz={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},az={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},rz={date:pb({formats:nz,defaultWidth:"full"}),time:pb({formats:sz,defaultWidth:"full"}),dateTime:pb({formats:az,defaultWidth:"full"})},iz={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},oz=(t,e,n,s)=>iz[t];function pu(t){return(e,n)=>{const s=n!=null&&n.context?String(n.context):"standalone";let a;if(s==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,c=n!=null&&n.width?String(n.width):i;a=t.formattingValues[c]||t.formattingValues[i]}else{const i=t.defaultWidth,c=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[c]||t.values[i]}const r=t.argumentCallback?t.argumentCallback(e):e;return a[r]}}const lz={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},cz={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},uz={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},dz={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},fz={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},pz={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},hz=(t,e)=>{const n=Number(t),s=n%100;if(s>20||s<10)switch(s%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},mz={ordinalNumber:hz,era:pu({values:lz,defaultWidth:"wide"}),quarter:pu({values:cz,defaultWidth:"wide",argumentCallback:t=>t-1}),month:pu({values:uz,defaultWidth:"wide"}),day:pu({values:dz,defaultWidth:"wide"}),dayPeriod:pu({values:fz,defaultWidth:"wide",formattingValues:pz,defaultFormattingWidth:"wide"})};function hu(t){return(e,n={})=>{const s=n.width,a=s&&t.matchPatterns[s]||t.matchPatterns[t.defaultMatchWidth],r=e.match(a);if(!r)return null;const i=r[0],c=s&&t.parsePatterns[s]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(c)?bz(c,m=>m.test(i)):gz(c,m=>m.test(i));let f;f=t.valueCallback?t.valueCallback(d):d,f=n.valueCallback?n.valueCallback(f):f;const h=e.slice(i.length);return{value:f,rest:h}}}function gz(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function bz(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function xz(t){return(e,n={})=>{const s=e.match(t.matchPattern);if(!s)return null;const a=s[0],r=e.match(t.parsePattern);if(!r)return null;let i=t.valueCallback?t.valueCallback(r[0]):r[0];i=n.valueCallback?n.valueCallback(i):i;const c=e.slice(a.length);return{value:i,rest:c}}}const yz=/^(\d+)(th|st|nd|rd)?/i,vz=/\d+/i,wz={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},kz={any:[/^b/i,/^(a|c)/i]},Sz={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Cz={any:[/1/i,/2/i,/3/i,/4/i]},Az={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},jz={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Nz={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Tz={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},_z={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ez={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Mz={ordinalNumber:xz({matchPattern:yz,parsePattern:vz,valueCallback:t=>parseInt(t,10)}),era:hu({matchPatterns:wz,defaultMatchWidth:"wide",parsePatterns:kz,defaultParseWidth:"any"}),quarter:hu({matchPatterns:Sz,defaultMatchWidth:"wide",parsePatterns:Cz,defaultParseWidth:"any",valueCallback:t=>t+1}),month:hu({matchPatterns:Az,defaultMatchWidth:"wide",parsePatterns:jz,defaultParseWidth:"any"}),day:hu({matchPatterns:Nz,defaultMatchWidth:"wide",parsePatterns:Tz,defaultParseWidth:"any"}),dayPeriod:hu({matchPatterns:_z,defaultMatchWidth:"any",parsePatterns:Ez,defaultParseWidth:"any"})},$N={code:"en-US",formatDistance:tz,formatLong:rz,formatRelative:oz,localize:mz,match:Mz,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Dz(t,e){const n=St(t,e==null?void 0:e.in);return Xl(n,ih(n))+1}function py(t,e){const n=St(t,e==null?void 0:e.in),s=+Ql(n)-+K4(n);return Math.round(s/ON)+1}function hy(t,e){var h,m,b,y;const n=St(t,e==null?void 0:e.in),s=n.getFullYear(),a=Io(),r=(e==null?void 0:e.firstWeekContainsDate)??((m=(h=e==null?void 0:e.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??a.firstWeekContainsDate??((y=(b=a.locale)==null?void 0:b.options)==null?void 0:y.firstWeekContainsDate)??1,i=vn((e==null?void 0:e.in)||t,0);i.setFullYear(s+1,0,r),i.setHours(0,0,0,0);const c=qr(i,e),d=vn((e==null?void 0:e.in)||t,0);d.setFullYear(s,0,r),d.setHours(0,0,0,0);const f=qr(d,e);return+n>=+c?s+1:+n>=+f?s:s-1}function Rz(t,e){var c,d,f,h;const n=Io(),s=(e==null?void 0:e.firstWeekContainsDate)??((d=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??n.firstWeekContainsDate??((h=(f=n.locale)==null?void 0:f.options)==null?void 0:h.firstWeekContainsDate)??1,a=hy(t,e),r=vn((e==null?void 0:e.in)||t,0);return r.setFullYear(a,0,s),r.setHours(0,0,0,0),qr(r,e)}function UN(t,e){const n=St(t,e==null?void 0:e.in),s=+qr(n,e)-+Rz(n,e);return Math.round(s/ON)+1}function yn(t,e){const n=t<0?"-":"",s=Math.abs(t).toString().padStart(e,"0");return n+s}const ji={y(t,e){const n=t.getFullYear(),s=n>0?n:1-n;return yn(e==="yy"?s%100:s,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):yn(n+1,2)},d(t,e){return yn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return yn(t.getHours()%12||12,e.length)},H(t,e){return yn(t.getHours(),e.length)},m(t,e){return yn(t.getMinutes(),e.length)},s(t,e){return yn(t.getSeconds(),e.length)},S(t,e){const n=e.length,s=t.getMilliseconds(),a=Math.trunc(s*Math.pow(10,n-3));return yn(a,e.length)}},Dl={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},UC={G:function(t,e,n){const s=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(s,{width:"abbreviated"});case"GGGGG":return n.era(s,{width:"narrow"});case"GGGG":default:return n.era(s,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const s=t.getFullYear(),a=s>0?s:1-s;return n.ordinalNumber(a,{unit:"year"})}return ji.y(t,e)},Y:function(t,e,n,s){const a=hy(t,s),r=a>0?a:1-a;if(e==="YY"){const i=r%100;return yn(i,2)}return e==="Yo"?n.ordinalNumber(r,{unit:"year"}):yn(r,e.length)},R:function(t,e){const n=IN(t);return yn(n,e.length)},u:function(t,e){const n=t.getFullYear();return yn(n,e.length)},Q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(s);case"QQ":return yn(s,2);case"Qo":return n.ordinalNumber(s,{unit:"quarter"});case"QQQ":return n.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(s,{width:"wide",context:"formatting"})}},q:function(t,e,n){const s=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(s);case"qq":return yn(s,2);case"qo":return n.ordinalNumber(s,{unit:"quarter"});case"qqq":return n.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(s,{width:"wide",context:"standalone"})}},M:function(t,e,n){const s=t.getMonth();switch(e){case"M":case"MM":return ji.M(t,e);case"Mo":return n.ordinalNumber(s+1,{unit:"month"});case"MMM":return n.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(s,{width:"wide",context:"formatting"})}},L:function(t,e,n){const s=t.getMonth();switch(e){case"L":return String(s+1);case"LL":return yn(s+1,2);case"Lo":return n.ordinalNumber(s+1,{unit:"month"});case"LLL":return n.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(s,{width:"wide",context:"standalone"})}},w:function(t,e,n,s){const a=UN(t,s);return e==="wo"?n.ordinalNumber(a,{unit:"week"}):yn(a,e.length)},I:function(t,e,n){const s=py(t);return e==="Io"?n.ordinalNumber(s,{unit:"week"}):yn(s,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):ji.d(t,e)},D:function(t,e,n){const s=Dz(t);return e==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):yn(s,e.length)},E:function(t,e,n){const s=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(s,{width:"short",context:"formatting"});case"EEEE":default:return n.day(s,{width:"wide",context:"formatting"})}},e:function(t,e,n,s){const a=t.getDay(),r=(a-s.weekStartsOn+8)%7||7;switch(e){case"e":return String(r);case"ee":return yn(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(t,e,n,s){const a=t.getDay(),r=(a-s.weekStartsOn+8)%7||7;switch(e){case"c":return String(r);case"cc":return yn(r,e.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,e,n){const s=t.getDay(),a=s===0?7:s;switch(e){case"i":return String(a);case"ii":return yn(a,e.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(s,{width:"short",context:"formatting"});case"iiii":default:return n.day(s,{width:"wide",context:"formatting"})}},a:function(t,e,n){const a=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,e,n){const s=t.getHours();let a;switch(s===12?a=Dl.noon:s===0?a=Dl.midnight:a=s/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,e,n){const s=t.getHours();let a;switch(s>=17?a=Dl.evening:s>=12?a=Dl.afternoon:s>=4?a=Dl.morning:a=Dl.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let s=t.getHours()%12;return s===0&&(s=12),n.ordinalNumber(s,{unit:"hour"})}return ji.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):ji.H(t,e)},K:function(t,e,n){const s=t.getHours()%12;return e==="Ko"?n.ordinalNumber(s,{unit:"hour"}):yn(s,e.length)},k:function(t,e,n){let s=t.getHours();return s===0&&(s=24),e==="ko"?n.ordinalNumber(s,{unit:"hour"}):yn(s,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):ji.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):ji.s(t,e)},S:function(t,e){return ji.S(t,e)},X:function(t,e,n){const s=t.getTimezoneOffset();if(s===0)return"Z";switch(e){case"X":return WC(s);case"XXXX":case"XX":return yo(s);case"XXXXX":case"XXX":default:return yo(s,":")}},x:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"x":return WC(s);case"xxxx":case"xx":return yo(s);case"xxxxx":case"xxx":default:return yo(s,":")}},O:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+HC(s,":");case"OOOO":default:return"GMT"+yo(s,":")}},z:function(t,e,n){const s=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+HC(s,":");case"zzzz":default:return"GMT"+yo(s,":")}},t:function(t,e,n){const s=Math.trunc(+t/1e3);return yn(s,e.length)},T:function(t,e,n){return yn(+t,e.length)}};function HC(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),a=Math.trunc(s/60),r=s%60;return r===0?n+String(a):n+String(a)+e+yn(r,2)}function WC(t,e){return t%60===0?(t>0?"-":"+")+yn(Math.abs(t)/60,2):yo(t,e)}function yo(t,e=""){const n=t>0?"-":"+",s=Math.abs(t),a=yn(Math.trunc(s/60),2),r=yn(s%60,2);return n+a+e+r}const qC=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},HN=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Oz=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],s=n[1],a=n[2];if(!a)return qC(t,e);let r;switch(s){case"P":r=e.dateTime({width:"short"});break;case"PP":r=e.dateTime({width:"medium"});break;case"PPP":r=e.dateTime({width:"long"});break;case"PPPP":default:r=e.dateTime({width:"full"});break}return r.replace("{{date}}",qC(s,e)).replace("{{time}}",HN(a,e))},bx={p:HN,P:Oz},Lz=/^D+$/,Iz=/^Y+$/,Pz=["D","DD","YY","YYYY"];function Bz(t){return Lz.test(t)}function Fz(t){return Iz.test(t)}function zz(t,e,n){const s=$z(t,e,n);if(console.warn(s),Pz.includes(t))throw new RangeError(s)}function $z(t,e,n){const s=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${s} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Uz=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Hz=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Wz=/^'([^]*?)'?$/,qz=/''/g,Vz=/[a-zA-Z]/;function VC(t,e,n){var h,m,b,y,w,C,N,k;const s=Io(),a=(n==null?void 0:n.locale)??s.locale??$N,r=(n==null?void 0:n.firstWeekContainsDate)??((m=(h=n==null?void 0:n.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??s.firstWeekContainsDate??((y=(b=s.locale)==null?void 0:b.options)==null?void 0:y.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((C=(w=n==null?void 0:n.locale)==null?void 0:w.options)==null?void 0:C.weekStartsOn)??s.weekStartsOn??((k=(N=s.locale)==null?void 0:N.options)==null?void 0:k.weekStartsOn)??0,c=St(t,n==null?void 0:n.in);if(!Jl(c))throw new RangeError("Invalid time value");let d=e.match(Hz).map(j=>{const S=j[0];if(S==="p"||S==="P"){const T=bx[S];return T(j,a.formatLong)}return j}).join("").match(Uz).map(j=>{if(j==="''")return{isToken:!1,value:"'"};const S=j[0];if(S==="'")return{isToken:!1,value:Yz(j)};if(UC[S])return{isToken:!0,value:j};if(S.match(Vz))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:j}});a.localize.preprocessor&&(d=a.localize.preprocessor(c,d));const f={firstWeekContainsDate:r,weekStartsOn:i,locale:a};return d.map(j=>{if(!j.isToken)return j.value;const S=j.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&Fz(S)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&Bz(S))&&zz(S,e,String(t));const T=UC[S[0]];return T(c,S,a.localize,f)}).join("")}function Yz(t){const e=t.match(Wz);return e?e[1].replace(qz,"'"):t}function YC(t,e){return St(t,e==null?void 0:e.in).getDate()}function Gz(t,e){return St(t,e==null?void 0:e.in).getDay()}function Kz(t,e){const n=St(t,e==null?void 0:e.in),s=n.getFullYear(),a=n.getMonth(),r=vn(n,0);return r.setFullYear(s,a+1,0),r.setHours(0,0,0,0),r.getDate()}function Qz(){return Object.assign({},Io())}function Cs(t,e){return St(t,e==null?void 0:e.in).getHours()}function Xz(t,e){const n=St(t,e==null?void 0:e.in).getDay();return n===0?7:n}function As(t,e){return St(t,e==null?void 0:e.in).getMinutes()}function Ks(t,e){return St(t,e==null?void 0:e.in).getMonth()}function Ei(t){return St(t).getSeconds()}function xx(t){return+St(t)}function Zt(t,e){return St(t,e==null?void 0:e.in).getFullYear()}function $r(t,e){return+St(t)>+St(e)}function ar(t,e){return+St(t)<+St(e)}function Jz(t,e){return+St(t)==+St(e)}function Zz(t,e){const n=e3(e)?new e(0):vn(e,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),n}function e3(t){var e;return typeof t=="function"&&((e=t.prototype)==null?void 0:e.constructor)===t}const t3=10;class WN{constructor(){Xe(this,"subPriority",0)}validate(e,n){return!0}}class n3 extends WN{constructor(e,n,s,a,r){super(),this.value=e,this.validateValue=n,this.setValue=s,this.priority=a,r&&(this.subPriority=r)}validate(e,n){return this.validateValue(e,this.value,n)}set(e,n,s){return this.setValue(e,n,this.value,s)}}class s3 extends WN{constructor(n,s){super();Xe(this,"priority",t3);Xe(this,"subPriority",-1);this.context=n||(a=>vn(s,a))}set(n,s){return s.timestampIsSet?n:vn(n,Zz(n,this.context))}}class mn{run(e,n,s,a){const r=this.parse(e,n,s,a);return r?{setter:new n3(r.value,this.validate,this.set,this.priority,this.subPriority),rest:r.rest}:null}validate(e,n,s){return!0}}class a3 extends mn{constructor(){super(...arguments);Xe(this,"priority",140);Xe(this,"incompatibleTokens",["R","u","t","T"])}parse(n,s,a){switch(s){case"G":case"GG":case"GGG":return a.era(n,{width:"abbreviated"})||a.era(n,{width:"narrow"});case"GGGGG":return a.era(n,{width:"narrow"});case"GGGG":default:return a.era(n,{width:"wide"})||a.era(n,{width:"abbreviated"})||a.era(n,{width:"narrow"})}}set(n,s,a){return s.era=a,n.setFullYear(a,0,1),n.setHours(0,0,0,0),n}}const Zn={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},er={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function es(t,e){return t&&{value:e(t.value),rest:t.rest}}function $n(t,e){const n=e.match(t);return n?{value:parseInt(n[0],10),rest:e.slice(n[0].length)}:null}function tr(t,e){const n=e.match(t);if(!n)return null;if(n[0]==="Z")return{value:0,rest:e.slice(1)};const s=n[1]==="+"?1:-1,a=n[2]?parseInt(n[2],10):0,r=n[3]?parseInt(n[3],10):0,i=n[5]?parseInt(n[5],10):0;return{value:s*(a*rh+r*ah+i*V4),rest:e.slice(n[0].length)}}function qN(t){return $n(Zn.anyDigitsSigned,t)}function Kn(t,e){switch(t){case 1:return $n(Zn.singleDigit,e);case 2:return $n(Zn.twoDigits,e);case 3:return $n(Zn.threeDigits,e);case 4:return $n(Zn.fourDigits,e);default:return $n(new RegExp("^\\d{1,"+t+"}"),e)}}function Dp(t,e){switch(t){case 1:return $n(Zn.singleDigitSigned,e);case 2:return $n(Zn.twoDigitsSigned,e);case 3:return $n(Zn.threeDigitsSigned,e);case 4:return $n(Zn.fourDigitsSigned,e);default:return $n(new RegExp("^-?\\d{1,"+t+"}"),e)}}function my(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function VN(t,e){const n=e>0,s=n?e:1-e;let a;if(s<=50)a=t||100;else{const r=s+50,i=Math.trunc(r/100)*100,c=t>=r%100;a=t+i-(c?100:0)}return n?a:1-a}function YN(t){return t%400===0||t%4===0&&t%100!==0}class r3 extends mn{constructor(){super(...arguments);Xe(this,"priority",130);Xe(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(n,s,a){const r=i=>({year:i,isTwoDigitYear:s==="yy"});switch(s){case"y":return es(Kn(4,n),r);case"yo":return es(a.ordinalNumber(n,{unit:"year"}),r);default:return es(Kn(s.length,n),r)}}validate(n,s){return s.isTwoDigitYear||s.year>0}set(n,s,a){const r=n.getFullYear();if(a.isTwoDigitYear){const c=VN(a.year,r);return n.setFullYear(c,0,1),n.setHours(0,0,0,0),n}const i=!("era"in s)||s.era===1?a.year:1-a.year;return n.setFullYear(i,0,1),n.setHours(0,0,0,0),n}}class i3 extends mn{constructor(){super(...arguments);Xe(this,"priority",130);Xe(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(n,s,a){const r=i=>({year:i,isTwoDigitYear:s==="YY"});switch(s){case"Y":return es(Kn(4,n),r);case"Yo":return es(a.ordinalNumber(n,{unit:"year"}),r);default:return es(Kn(s.length,n),r)}}validate(n,s){return s.isTwoDigitYear||s.year>0}set(n,s,a,r){const i=hy(n,r);if(a.isTwoDigitYear){const d=VN(a.year,i);return n.setFullYear(d,0,r.firstWeekContainsDate),n.setHours(0,0,0,0),qr(n,r)}const c=!("era"in s)||s.era===1?a.year:1-a.year;return n.setFullYear(c,0,r.firstWeekContainsDate),n.setHours(0,0,0,0),qr(n,r)}}class o3 extends mn{constructor(){super(...arguments);Xe(this,"priority",130);Xe(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(n,s){return Dp(s==="R"?4:s.length,n)}set(n,s,a){const r=vn(n,0);return r.setFullYear(a,0,4),r.setHours(0,0,0,0),Ql(r)}}class l3 extends mn{constructor(){super(...arguments);Xe(this,"priority",130);Xe(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(n,s){return Dp(s==="u"?4:s.length,n)}set(n,s,a){return n.setFullYear(a,0,1),n.setHours(0,0,0,0),n}}class c3 extends mn{constructor(){super(...arguments);Xe(this,"priority",120);Xe(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(n,s,a){switch(s){case"Q":case"QQ":return Kn(s.length,n);case"Qo":return a.ordinalNumber(n,{unit:"quarter"});case"QQQ":return a.quarter(n,{width:"abbreviated",context:"formatting"})||a.quarter(n,{width:"narrow",context:"formatting"});case"QQQQQ":return a.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(n,{width:"wide",context:"formatting"})||a.quarter(n,{width:"abbreviated",context:"formatting"})||a.quarter(n,{width:"narrow",context:"formatting"})}}validate(n,s){return s>=1&&s<=4}set(n,s,a){return n.setMonth((a-1)*3,1),n.setHours(0,0,0,0),n}}class u3 extends mn{constructor(){super(...arguments);Xe(this,"priority",120);Xe(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(n,s,a){switch(s){case"q":case"qq":return Kn(s.length,n);case"qo":return a.ordinalNumber(n,{unit:"quarter"});case"qqq":return a.quarter(n,{width:"abbreviated",context:"standalone"})||a.quarter(n,{width:"narrow",context:"standalone"});case"qqqqq":return a.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(n,{width:"wide",context:"standalone"})||a.quarter(n,{width:"abbreviated",context:"standalone"})||a.quarter(n,{width:"narrow",context:"standalone"})}}validate(n,s){return s>=1&&s<=4}set(n,s,a){return n.setMonth((a-1)*3,1),n.setHours(0,0,0,0),n}}class d3 extends mn{constructor(){super(...arguments);Xe(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Xe(this,"priority",110)}parse(n,s,a){const r=i=>i-1;switch(s){case"M":return es($n(Zn.month,n),r);case"MM":return es(Kn(2,n),r);case"Mo":return es(a.ordinalNumber(n,{unit:"month"}),r);case"MMM":return a.month(n,{width:"abbreviated",context:"formatting"})||a.month(n,{width:"narrow",context:"formatting"});case"MMMMM":return a.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(n,{width:"wide",context:"formatting"})||a.month(n,{width:"abbreviated",context:"formatting"})||a.month(n,{width:"narrow",context:"formatting"})}}validate(n,s){return s>=0&&s<=11}set(n,s,a){return n.setMonth(a,1),n.setHours(0,0,0,0),n}}class f3 extends mn{constructor(){super(...arguments);Xe(this,"priority",110);Xe(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(n,s,a){const r=i=>i-1;switch(s){case"L":return es($n(Zn.month,n),r);case"LL":return es(Kn(2,n),r);case"Lo":return es(a.ordinalNumber(n,{unit:"month"}),r);case"LLL":return a.month(n,{width:"abbreviated",context:"standalone"})||a.month(n,{width:"narrow",context:"standalone"});case"LLLLL":return a.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(n,{width:"wide",context:"standalone"})||a.month(n,{width:"abbreviated",context:"standalone"})||a.month(n,{width:"narrow",context:"standalone"})}}validate(n,s){return s>=0&&s<=11}set(n,s,a){return n.setMonth(a,1),n.setHours(0,0,0,0),n}}function p3(t,e,n){const s=St(t,n==null?void 0:n.in),a=UN(s,n)-e;return s.setDate(s.getDate()-a*7),St(s,n==null?void 0:n.in)}class h3 extends mn{constructor(){super(...arguments);Xe(this,"priority",100);Xe(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(n,s,a){switch(s){case"w":return $n(Zn.week,n);case"wo":return a.ordinalNumber(n,{unit:"week"});default:return Kn(s.length,n)}}validate(n,s){return s>=1&&s<=53}set(n,s,a,r){return qr(p3(n,a,r),r)}}function m3(t,e,n){const s=St(t,n==null?void 0:n.in),a=py(s,n)-e;return s.setDate(s.getDate()-a*7),s}class g3 extends mn{constructor(){super(...arguments);Xe(this,"priority",100);Xe(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(n,s,a){switch(s){case"I":return $n(Zn.week,n);case"Io":return a.ordinalNumber(n,{unit:"week"});default:return Kn(s.length,n)}}validate(n,s){return s>=1&&s<=53}set(n,s,a){return Ql(m3(n,a))}}const b3=[31,28,31,30,31,30,31,31,30,31,30,31],x3=[31,29,31,30,31,30,31,31,30,31,30,31];class y3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"subPriority",1);Xe(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(n,s,a){switch(s){case"d":return $n(Zn.date,n);case"do":return a.ordinalNumber(n,{unit:"date"});default:return Kn(s.length,n)}}validate(n,s){const a=n.getFullYear(),r=YN(a),i=n.getMonth();return r?s>=1&&s<=x3[i]:s>=1&&s<=b3[i]}set(n,s,a){return n.setDate(a),n.setHours(0,0,0,0),n}}class v3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"subpriority",1);Xe(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(n,s,a){switch(s){case"D":case"DD":return $n(Zn.dayOfYear,n);case"Do":return a.ordinalNumber(n,{unit:"date"});default:return Kn(s.length,n)}}validate(n,s){const a=n.getFullYear();return YN(a)?s>=1&&s<=366:s>=1&&s<=365}set(n,s,a){return n.setMonth(0,a),n.setHours(0,0,0,0),n}}function gy(t,e,n){var m,b,y,w;const s=Io(),a=(n==null?void 0:n.weekStartsOn)??((b=(m=n==null?void 0:n.locale)==null?void 0:m.options)==null?void 0:b.weekStartsOn)??s.weekStartsOn??((w=(y=s.locale)==null?void 0:y.options)==null?void 0:w.weekStartsOn)??0,r=St(t,n==null?void 0:n.in),i=r.getDay(),d=(e%7+7)%7,f=7-a,h=e<0||e>6?e-(i+f)%7:(d+f)%7-(i+f)%7;return Pa(r,h,n)}class w3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(n,s,a){switch(s){case"E":case"EE":case"EEE":return a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"});case"EEEEE":return a.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"});case"EEEE":default:return a.day(n,{width:"wide",context:"formatting"})||a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"})}}validate(n,s){return s>=0&&s<=6}set(n,s,a,r){return n=gy(n,a,r),n.setHours(0,0,0,0),n}}class k3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(n,s,a,r){const i=c=>{const d=Math.floor((c-1)/7)*7;return(c+r.weekStartsOn+6)%7+d};switch(s){case"e":case"ee":return es(Kn(s.length,n),i);case"eo":return es(a.ordinalNumber(n,{unit:"day"}),i);case"eee":return a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"});case"eeeee":return a.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"});case"eeee":default:return a.day(n,{width:"wide",context:"formatting"})||a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"})}}validate(n,s){return s>=0&&s<=6}set(n,s,a,r){return n=gy(n,a,r),n.setHours(0,0,0,0),n}}class S3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(n,s,a,r){const i=c=>{const d=Math.floor((c-1)/7)*7;return(c+r.weekStartsOn+6)%7+d};switch(s){case"c":case"cc":return es(Kn(s.length,n),i);case"co":return es(a.ordinalNumber(n,{unit:"day"}),i);case"ccc":return a.day(n,{width:"abbreviated",context:"standalone"})||a.day(n,{width:"short",context:"standalone"})||a.day(n,{width:"narrow",context:"standalone"});case"ccccc":return a.day(n,{width:"narrow",context:"standalone"});case"cccccc":return a.day(n,{width:"short",context:"standalone"})||a.day(n,{width:"narrow",context:"standalone"});case"cccc":default:return a.day(n,{width:"wide",context:"standalone"})||a.day(n,{width:"abbreviated",context:"standalone"})||a.day(n,{width:"short",context:"standalone"})||a.day(n,{width:"narrow",context:"standalone"})}}validate(n,s){return s>=0&&s<=6}set(n,s,a,r){return n=gy(n,a,r),n.setHours(0,0,0,0),n}}function C3(t,e,n){const s=St(t,n==null?void 0:n.in),a=Xz(s,n),r=e-a;return Pa(s,r,n)}class A3 extends mn{constructor(){super(...arguments);Xe(this,"priority",90);Xe(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(n,s,a){const r=i=>i===0?7:i;switch(s){case"i":case"ii":return Kn(s.length,n);case"io":return a.ordinalNumber(n,{unit:"day"});case"iii":return es(a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"}),r);case"iiiii":return es(a.day(n,{width:"narrow",context:"formatting"}),r);case"iiiiii":return es(a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"}),r);case"iiii":default:return es(a.day(n,{width:"wide",context:"formatting"})||a.day(n,{width:"abbreviated",context:"formatting"})||a.day(n,{width:"short",context:"formatting"})||a.day(n,{width:"narrow",context:"formatting"}),r)}}validate(n,s){return s>=1&&s<=7}set(n,s,a){return n=C3(n,a),n.setHours(0,0,0,0),n}}class j3 extends mn{constructor(){super(...arguments);Xe(this,"priority",80);Xe(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(n,s,a){switch(s){case"a":case"aa":case"aaa":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaaa":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})||a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,s,a){return n.setHours(my(a),0,0,0),n}}class N3 extends mn{constructor(){super(...arguments);Xe(this,"priority",80);Xe(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(n,s,a){switch(s){case"b":case"bb":case"bbb":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbbb":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})||a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,s,a){return n.setHours(my(a),0,0,0),n}}class T3 extends mn{constructor(){super(...arguments);Xe(this,"priority",80);Xe(this,"incompatibleTokens",["a","b","t","T"])}parse(n,s,a){switch(s){case"B":case"BB":case"BBB":return a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBBB":return a.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(n,{width:"wide",context:"formatting"})||a.dayPeriod(n,{width:"abbreviated",context:"formatting"})||a.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,s,a){return n.setHours(my(a),0,0,0),n}}class _3 extends mn{constructor(){super(...arguments);Xe(this,"priority",70);Xe(this,"incompatibleTokens",["H","K","k","t","T"])}parse(n,s,a){switch(s){case"h":return $n(Zn.hour12h,n);case"ho":return a.ordinalNumber(n,{unit:"hour"});default:return Kn(s.length,n)}}validate(n,s){return s>=1&&s<=12}set(n,s,a){const r=n.getHours()>=12;return r&&a<12?n.setHours(a+12,0,0,0):!r&&a===12?n.setHours(0,0,0,0):n.setHours(a,0,0,0),n}}class E3 extends mn{constructor(){super(...arguments);Xe(this,"priority",70);Xe(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(n,s,a){switch(s){case"H":return $n(Zn.hour23h,n);case"Ho":return a.ordinalNumber(n,{unit:"hour"});default:return Kn(s.length,n)}}validate(n,s){return s>=0&&s<=23}set(n,s,a){return n.setHours(a,0,0,0),n}}class M3 extends mn{constructor(){super(...arguments);Xe(this,"priority",70);Xe(this,"incompatibleTokens",["h","H","k","t","T"])}parse(n,s,a){switch(s){case"K":return $n(Zn.hour11h,n);case"Ko":return a.ordinalNumber(n,{unit:"hour"});default:return Kn(s.length,n)}}validate(n,s){return s>=0&&s<=11}set(n,s,a){return n.getHours()>=12&&a<12?n.setHours(a+12,0,0,0):n.setHours(a,0,0,0),n}}class D3 extends mn{constructor(){super(...arguments);Xe(this,"priority",70);Xe(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(n,s,a){switch(s){case"k":return $n(Zn.hour24h,n);case"ko":return a.ordinalNumber(n,{unit:"hour"});default:return Kn(s.length,n)}}validate(n,s){return s>=1&&s<=24}set(n,s,a){const r=a<=24?a%24:a;return n.setHours(r,0,0,0),n}}class R3 extends mn{constructor(){super(...arguments);Xe(this,"priority",60);Xe(this,"incompatibleTokens",["t","T"])}parse(n,s,a){switch(s){case"m":return $n(Zn.minute,n);case"mo":return a.ordinalNumber(n,{unit:"minute"});default:return Kn(s.length,n)}}validate(n,s){return s>=0&&s<=59}set(n,s,a){return n.setMinutes(a,0,0),n}}class O3 extends mn{constructor(){super(...arguments);Xe(this,"priority",50);Xe(this,"incompatibleTokens",["t","T"])}parse(n,s,a){switch(s){case"s":return $n(Zn.second,n);case"so":return a.ordinalNumber(n,{unit:"second"});default:return Kn(s.length,n)}}validate(n,s){return s>=0&&s<=59}set(n,s,a){return n.setSeconds(a,0),n}}class L3 extends mn{constructor(){super(...arguments);Xe(this,"priority",30);Xe(this,"incompatibleTokens",["t","T"])}parse(n,s){const a=r=>Math.trunc(r*Math.pow(10,-s.length+3));return es(Kn(s.length,n),a)}set(n,s,a){return n.setMilliseconds(a),n}}class I3 extends mn{constructor(){super(...arguments);Xe(this,"priority",10);Xe(this,"incompatibleTokens",["t","T","x"])}parse(n,s){switch(s){case"X":return tr(er.basicOptionalMinutes,n);case"XX":return tr(er.basic,n);case"XXXX":return tr(er.basicOptionalSeconds,n);case"XXXXX":return tr(er.extendedOptionalSeconds,n);case"XXX":default:return tr(er.extended,n)}}set(n,s,a){return s.timestampIsSet?n:vn(n,n.getTime()-Np(n)-a)}}class P3 extends mn{constructor(){super(...arguments);Xe(this,"priority",10);Xe(this,"incompatibleTokens",["t","T","X"])}parse(n,s){switch(s){case"x":return tr(er.basicOptionalMinutes,n);case"xx":return tr(er.basic,n);case"xxxx":return tr(er.basicOptionalSeconds,n);case"xxxxx":return tr(er.extendedOptionalSeconds,n);case"xxx":default:return tr(er.extended,n)}}set(n,s,a){return s.timestampIsSet?n:vn(n,n.getTime()-Np(n)-a)}}class B3 extends mn{constructor(){super(...arguments);Xe(this,"priority",40);Xe(this,"incompatibleTokens","*")}parse(n){return qN(n)}set(n,s,a){return[vn(n,a*1e3),{timestampIsSet:!0}]}}class F3 extends mn{constructor(){super(...arguments);Xe(this,"priority",20);Xe(this,"incompatibleTokens","*")}parse(n){return qN(n)}set(n,s,a){return[vn(n,a),{timestampIsSet:!0}]}}const z3={G:new a3,y:new r3,Y:new i3,R:new o3,u:new l3,Q:new c3,q:new u3,M:new d3,L:new f3,w:new h3,I:new g3,d:new y3,D:new v3,E:new w3,e:new k3,c:new S3,i:new A3,a:new j3,b:new N3,B:new T3,h:new _3,H:new E3,K:new M3,k:new D3,m:new R3,s:new O3,S:new L3,X:new I3,x:new P3,t:new B3,T:new F3},$3=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,U3=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,H3=/^'([^]*?)'?$/,W3=/''/g,q3=/\S/,V3=/[a-zA-Z]/;function Y3(t,e,n,s){var N,k,j,S,T,D,E,I;const a=()=>vn((s==null?void 0:s.in)||n,NaN),r=Qz(),i=(s==null?void 0:s.locale)??r.locale??$N,c=(s==null?void 0:s.firstWeekContainsDate)??((k=(N=s==null?void 0:s.locale)==null?void 0:N.options)==null?void 0:k.firstWeekContainsDate)??r.firstWeekContainsDate??((S=(j=r.locale)==null?void 0:j.options)==null?void 0:S.firstWeekContainsDate)??1,d=(s==null?void 0:s.weekStartsOn)??((D=(T=s==null?void 0:s.locale)==null?void 0:T.options)==null?void 0:D.weekStartsOn)??r.weekStartsOn??((I=(E=r.locale)==null?void 0:E.options)==null?void 0:I.weekStartsOn)??0;if(!e)return t?a():St(n,s==null?void 0:s.in);const f={firstWeekContainsDate:c,weekStartsOn:d,locale:i},h=[new s3(s==null?void 0:s.in,n)],m=e.match(U3).map(O=>{const _=O[0];if(_ in bx){const M=bx[_];return M(O,i.formatLong)}return O}).join("").match($3),b=[];for(let O of m){const _=O[0],M=z3[_];if(M){const{incompatibleTokens:R}=M;if(Array.isArray(R)){const $=b.find(W=>R.includes(W.token)||W.token===_);if($)throw new RangeError(`The format string mustn't contain \`${$.fullToken}\` and \`${O}\` at the same time`)}else if(M.incompatibleTokens==="*"&&b.length>0)throw new RangeError(`The format string mustn't contain \`${O}\` and any other token at the same time`);b.push({token:_,fullToken:O});const z=M.run(t,O,i.match,f);if(!z)return a();h.push(z.setter),t=z.rest}else{if(_.match(V3))throw new RangeError("Format string contains an unescaped latin alphabet character `"+_+"`");if(O==="''"?O="'":_==="'"&&(O=G3(O)),t.indexOf(O)===0)t=t.slice(O.length);else return a()}}if(t.length>0&&q3.test(t))return a();const y=h.map(O=>O.priority).sort((O,_)=>_-O).filter((O,_,M)=>M.indexOf(O)===_).map(O=>h.filter(_=>_.priority===O).sort((_,M)=>M.subPriority-_.subPriority)).map(O=>O[0]);let w=St(n,s==null?void 0:s.in);if(isNaN(+w))return a();const C={};for(const O of y){if(!O.validate(w,f))return a();const _=O.set(w,C,f);Array.isArray(_)?(w=_[0],Object.assign(C,_[1])):w=_}return w}function G3(t){return t.match(H3)[1].replace(W3,"'")}function K3(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return s.getFullYear()===a.getFullYear()&&s.getMonth()===a.getMonth()}function Q3(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return+gx(s)==+gx(a)}function X3(t,e,n){const[s,a]=Gr(n==null?void 0:n.in,t,e);return s.getFullYear()===a.getFullYear()}function Ku(t,e,n){const s=+St(t,n==null?void 0:n.in),[a,r]=[+St(e.start,n==null?void 0:n.in),+St(e.end,n==null?void 0:n.in)].sort((i,c)=>i-c);return s>=a&&s<=r}function J3(t,e,n){return Pa(t,-1,n)}function Z3(t,e){const n=()=>vn(e==null?void 0:e.in,NaN),a=s$(t);let r;if(a.date){const f=a$(a.date,2);r=r$(f.restDateString,f.year)}if(!r||isNaN(+r))return n();const i=+r;let c=0,d;if(a.time&&(c=i$(a.time),isNaN(c)))return n();if(a.timezone){if(d=o$(a.timezone),isNaN(d))return n()}else{const f=new Date(i+c),h=St(0,e==null?void 0:e.in);return h.setFullYear(f.getUTCFullYear(),f.getUTCMonth(),f.getUTCDate()),h.setHours(f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds()),h}return St(i+c+d,e==null?void 0:e.in)}const Ff={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},e$=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,t$=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,n$=/^([+-])(\d{2})(?::?(\d{2}))?$/;function s$(t){const e={},n=t.split(Ff.dateTimeDelimiter);let s;if(n.length>2)return e;if(/:/.test(n[0])?s=n[0]:(e.date=n[0],s=n[1],Ff.timeZoneDelimiter.test(e.date)&&(e.date=t.split(Ff.timeZoneDelimiter)[0],s=t.substr(e.date.length,t.length))),s){const a=Ff.timezone.exec(s);a?(e.time=s.replace(a[1],""),e.timezone=a[1]):e.time=s}return e}function a$(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),s=t.match(n);if(!s)return{year:NaN,restDateString:""};const a=s[1]?parseInt(s[1]):null,r=s[2]?parseInt(s[2]):null;return{year:r===null?a:r*100,restDateString:t.slice((s[1]||s[2]).length)}}function r$(t,e){if(e===null)return new Date(NaN);const n=t.match(e$);if(!n)return new Date(NaN);const s=!!n[4],a=mu(n[1]),r=mu(n[2])-1,i=mu(n[3]),c=mu(n[4]),d=mu(n[5])-1;if(s)return f$(e,c,d)?l$(e,c,d):new Date(NaN);{const f=new Date(0);return!u$(e,r,i)||!d$(e,a)?new Date(NaN):(f.setUTCFullYear(e,r,Math.max(a,i)),f)}}function mu(t){return t?parseInt(t):1}function i$(t){const e=t.match(t$);if(!e)return NaN;const n=hb(e[1]),s=hb(e[2]),a=hb(e[3]);return p$(n,s,a)?n*rh+s*ah+a*1e3:NaN}function hb(t){return t&&parseFloat(t.replace(",","."))||0}function o$(t){if(t==="Z")return 0;const e=t.match(n$);if(!e)return 0;const n=e[1]==="+"?-1:1,s=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return h$(s,a)?n*(s*rh+a*ah):NaN}function l$(t,e,n){const s=new Date(0);s.setUTCFullYear(t,0,4);const a=s.getUTCDay()||7,r=(e-1)*7+n+1-a;return s.setUTCDate(s.getUTCDate()+r),s}const c$=[31,null,31,30,31,30,31,31,30,31,30,31];function GN(t){return t%400===0||t%4===0&&t%100!==0}function u$(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(c$[e]||(GN(t)?29:28))}function d$(t,e){return e>=1&&e<=(GN(t)?366:365)}function f$(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function p$(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function h$(t,e){return e>=0&&e<=59}function oa(t,e,n){const s=St(t,n==null?void 0:n.in),a=s.getFullYear(),r=s.getDate(),i=vn(t,0);i.setFullYear(a,e,15),i.setHours(0,0,0,0);const c=Kz(i);return s.setMonth(e,Math.min(r,c)),s}function sp(t,e,n){const s=St(t,n==null?void 0:n.in);return s.setHours(e),s}function ap(t,e,n){const s=St(t,n==null?void 0:n.in);return s.setMinutes(e),s}function Bl(t,e,n){const s=St(t,n==null?void 0:n.in),a=Math.trunc(s.getMonth()/3)+1,r=e-a;return oa(s,s.getMonth()+r*3)}function rp(t,e,n){const s=St(t,n==null?void 0:n.in);return s.setSeconds(e),s}function Ja(t,e,n){const s=St(t,n==null?void 0:n.in);return isNaN(+s)?vn(t,NaN):(s.setFullYear(e),s)}function Ao(t,e,n){return za(t,-e,n)}function KN(t,e,n){return fy(t,-1,n)}function GC(t,e,n){return Tp(t,-1,n)}function Ri(t,e,n){return Ba(t,-e,n)}function oh(){return typeof window<"u"}function oc(t){return QN(t)?(t.nodeName||"").toLowerCase():"#document"}function fa(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function mr(t){var e;return(e=(QN(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function QN(t){return oh()?t instanceof Node||t instanceof fa(t).Node:!1}function Ds(t){return oh()?t instanceof Element||t instanceof fa(t).Element:!1}function Kr(t){return oh()?t instanceof HTMLElement||t instanceof fa(t).HTMLElement:!1}function KC(t){return!oh()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof fa(t).ShadowRoot}function ad(t){const{overflow:e,overflowX:n,overflowY:s,display:a}=_a(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&a!=="inline"&&a!=="contents"}function m$(t){return/^(table|td|th)$/.test(oc(t))}function lh(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const g$=/transform|translate|scale|rotate|perspective|filter/,b$=/paint|layout|strict|content/,go=t=>!!t&&t!=="none";let mb;function by(t){const e=Ds(t)?_a(t):t;return go(e.transform)||go(e.translate)||go(e.scale)||go(e.rotate)||go(e.perspective)||!xy()&&(go(e.backdropFilter)||go(e.filter))||g$.test(e.willChange||"")||b$.test(e.contain||"")}function x$(t){let e=Oi(t);for(;Kr(e)&&!Zl(e);){if(by(e))return e;if(lh(e))return null;e=Oi(e)}return null}function xy(){return mb==null&&(mb=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),mb}function Zl(t){return/^(html|body|#document)$/.test(oc(t))}function _a(t){return fa(t).getComputedStyle(t)}function ch(t){return Ds(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Oi(t){if(oc(t)==="html")return t;const e=t.assignedSlot||t.parentNode||KC(t)&&t.host||mr(t);return KC(e)?e.host:e}function XN(t){const e=Oi(t);return Zl(e)?t.ownerDocument?t.ownerDocument.body:t.body:Kr(e)&&ad(e)?e:XN(e)}function Qu(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const a=XN(t),r=a===((s=t.ownerDocument)==null?void 0:s.body),i=fa(a);if(r){const c=yx(i);return e.concat(i,i.visualViewport||[],ad(a)?a:[],c&&n?Qu(c):[])}else return e.concat(a,Qu(a,[],n))}function yx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const ec=Math.min,jo=Math.max,Rp=Math.round,zf=Math.floor,or=t=>({x:t,y:t}),y$={left:"right",right:"left",bottom:"top",top:"bottom"};function v$(t,e,n){return jo(t,ec(e,n))}function uh(t,e){return typeof t=="function"?t(e):t}function tc(t){return t.split("-")[0]}function rd(t){return t.split("-")[1]}function w$(t){return t==="x"?"y":"x"}function yy(t){return t==="y"?"height":"width"}function ko(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function vy(t){return w$(ko(t))}function k$(t,e,n){n===void 0&&(n=!1);const s=rd(t),a=vy(t),r=yy(a);let i=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(i=Op(i)),[i,Op(i)]}function S$(t){const e=Op(t);return[vx(t),e,vx(e)]}function vx(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const QC=["left","right"],XC=["right","left"],C$=["top","bottom"],A$=["bottom","top"];function j$(t,e,n){switch(t){case"top":case"bottom":return n?e?XC:QC:e?QC:XC;case"left":case"right":return e?C$:A$;default:return[]}}function N$(t,e,n,s){const a=rd(t);let r=j$(tc(t),n==="start",s);return a&&(r=r.map(i=>i+"-"+a),e&&(r=r.concat(r.map(vx)))),r}function Op(t){const e=tc(t);return y$[e]+t.slice(e.length)}function T$(t){return{top:0,right:0,bottom:0,left:0,...t}}function JN(t){return typeof t!="number"?T$(t):{top:t,right:t,bottom:t,left:t}}function Lp(t){const{x:e,y:n,width:s,height:a}=t;return{width:s,height:a,top:n,left:e,right:e+s,bottom:n+a,x:e,y:n}}var _$=typeof document<"u",E$=function(){},Ip=_$?x.useLayoutEffect:E$;const M$={...fj},D$=M$.useInsertionEffect,R$=D$||(t=>t());function O$(t){const e=x.useRef(()=>{});return R$(()=>{e.current=t}),x.useCallback(function(){for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];return e.current==null?void 0:e.current(...s)},[])}function JC(t,e,n){let{reference:s,floating:a}=t;const r=ko(e),i=vy(e),c=yy(i),d=tc(e),f=r==="y",h=s.x+s.width/2-a.width/2,m=s.y+s.height/2-a.height/2,b=s[c]/2-a[c]/2;let y;switch(d){case"top":y={x:h,y:s.y-a.height};break;case"bottom":y={x:h,y:s.y+s.height};break;case"right":y={x:s.x+s.width,y:m};break;case"left":y={x:s.x-a.width,y:m};break;default:y={x:s.x,y:s.y}}switch(rd(e)){case"start":y[i]-=b*(n&&f?-1:1);break;case"end":y[i]+=b*(n&&f?-1:1);break}return y}async function L$(t,e){var n;e===void 0&&(e={});const{x:s,y:a,platform:r,rects:i,elements:c,strategy:d}=t,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:m="floating",altBoundary:b=!1,padding:y=0}=uh(e,t),w=JN(y),N=c[b?m==="floating"?"reference":"floating":m],k=Lp(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(N)))==null||n?N:N.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:f,rootBoundary:h,strategy:d})),j=m==="floating"?{x:s,y:a,width:i.floating.width,height:i.floating.height}:i.reference,S=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),T=await(r.isElement==null?void 0:r.isElement(S))?await(r.getScale==null?void 0:r.getScale(S))||{x:1,y:1}:{x:1,y:1},D=Lp(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:j,offsetParent:S,strategy:d}):j);return{top:(k.top-D.top+w.top)/T.y,bottom:(D.bottom-k.bottom+w.bottom)/T.y,left:(k.left-D.left+w.left)/T.x,right:(D.right-k.right+w.right)/T.x}}const I$=50,P$=async(t,e,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:L$},d=await(i.isRTL==null?void 0:i.isRTL(e));let f=await i.getElementRects({reference:t,floating:e,strategy:a}),{x:h,y:m}=JC(f,s,d),b=s,y=0;const w={};for(let C=0;C<r.length;C++){const N=r[C];if(!N)continue;const{name:k,fn:j}=N,{x:S,y:T,data:D,reset:E}=await j({x:h,y:m,initialPlacement:s,placement:b,strategy:a,middlewareData:w,rects:f,platform:c,elements:{reference:t,floating:e}});h=S??h,m=T??m,w[k]={...w[k],...D},E&&y<I$&&(y++,typeof E=="object"&&(E.placement&&(b=E.placement),E.rects&&(f=E.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:a}):E.rects),{x:h,y:m}=JC(f,b,d)),C=-1)}return{x:h,y:m,placement:b,strategy:a,middlewareData:w}},B$=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:s,placement:a,rects:r,platform:i,elements:c,middlewareData:d}=e,{element:f,padding:h=0}=uh(t,e)||{};if(f==null)return{};const m=JN(h),b={x:n,y:s},y=vy(a),w=yy(y),C=await i.getDimensions(f),N=y==="y",k=N?"top":"left",j=N?"bottom":"right",S=N?"clientHeight":"clientWidth",T=r.reference[w]+r.reference[y]-b[y]-r.floating[w],D=b[y]-r.reference[y],E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(f));let I=E?E[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(E)))&&(I=c.floating[S]||r.floating[w]);const O=T/2-D/2,_=I/2-C[w]/2-1,M=ec(m[k],_),R=ec(m[j],_),z=M,$=I-C[w]-R,W=I/2-C[w]/2+O,L=v$(z,W,$),F=!d.arrow&&rd(a)!=null&&W!==L&&r.reference[w]/2-(W<z?M:R)-C[w]/2<0,H=F?W<z?W-z:W-$:0;return{[y]:b[y]+H,data:{[y]:L,centerOffset:W-L-H,...F&&{alignmentOffset:H}},reset:F}}}),F$=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,s;const{placement:a,middlewareData:r,rects:i,initialPlacement:c,platform:d,elements:f}=e,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:b,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:C=!0,...N}=uh(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const k=tc(a),j=ko(c),S=tc(c)===c,T=await(d.isRTL==null?void 0:d.isRTL(f.floating)),D=b||(S||!C?[Op(c)]:S$(c)),E=w!=="none";!b&&E&&D.push(...N$(c,C,w,T));const I=[c,...D],O=await d.detectOverflow(e,N),_=[];let M=((s=r.flip)==null?void 0:s.overflows)||[];if(h&&_.push(O[k]),m){const W=k$(a,i,T);_.push(O[W[0]],O[W[1]])}if(M=[...M,{placement:a,overflows:_}],!_.every(W=>W<=0)){var R,z;const W=(((R=r.flip)==null?void 0:R.index)||0)+1,L=I[W];if(L&&(!(m==="alignment"?j!==ko(L):!1)||M.every(V=>ko(V.placement)===j?V.overflows[0]>0:!0)))return{data:{index:W,overflows:M},reset:{placement:L}};let F=(z=M.filter(H=>H.overflows[0]<=0).sort((H,V)=>H.overflows[1]-V.overflows[1])[0])==null?void 0:z.placement;if(!F)switch(y){case"bestFit":{var $;const H=($=M.filter(V=>{if(E){const G=ko(V.placement);return G===j||G==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(G=>G>0).reduce((G,B)=>G+B,0)]).sort((V,G)=>V[1]-G[1])[0])==null?void 0:$[0];H&&(F=H);break}case"initialPlacement":F=c;break}if(a!==F)return{reset:{placement:F}}}return{}}}},z$=new Set(["left","top"]);async function $$(t,e){const{placement:n,platform:s,elements:a}=t,r=await(s.isRTL==null?void 0:s.isRTL(a.floating)),i=tc(n),c=rd(n),d=ko(n)==="y",f=z$.has(i)?-1:1,h=r&&d?-1:1,m=uh(e,t);let{mainAxis:b,crossAxis:y,alignmentAxis:w}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof w=="number"&&(y=c==="end"?w*-1:w),d?{x:y*h,y:b*f}:{x:b*f,y:y*h}}const U$=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,s;const{x:a,y:r,placement:i,middlewareData:c}=e,d=await $$(e,t);return i===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:a+d.x,y:r+d.y,data:{...d,placement:i}}}}};function ZN(t){const e=_a(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const a=Kr(t),r=a?t.offsetWidth:n,i=a?t.offsetHeight:s,c=Rp(n)!==r||Rp(s)!==i;return c&&(n=r,s=i),{width:n,height:s,$:c}}function wy(t){return Ds(t)?t:t.contextElement}function Wl(t){const e=wy(t);if(!Kr(e))return or(1);const n=e.getBoundingClientRect(),{width:s,height:a,$:r}=ZN(e);let i=(r?Rp(n.width):n.width)/s,c=(r?Rp(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const H$=or(0);function eT(t){const e=fa(t);return!xy()||!e.visualViewport?H$:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function W$(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==fa(t)?!1:e}function Oo(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const a=t.getBoundingClientRect(),r=wy(t);let i=or(1);e&&(s?Ds(s)&&(i=Wl(s)):i=Wl(t));const c=W$(r,n,s)?eT(r):or(0);let d=(a.left+c.x)/i.x,f=(a.top+c.y)/i.y,h=a.width/i.x,m=a.height/i.y;if(r){const b=fa(r),y=s&&Ds(s)?fa(s):s;let w=b,C=yx(w);for(;C&&s&&y!==w;){const N=Wl(C),k=C.getBoundingClientRect(),j=_a(C),S=k.left+(C.clientLeft+parseFloat(j.paddingLeft))*N.x,T=k.top+(C.clientTop+parseFloat(j.paddingTop))*N.y;d*=N.x,f*=N.y,h*=N.x,m*=N.y,d+=S,f+=T,w=fa(C),C=yx(w)}}return Lp({width:h,height:m,x:d,y:f})}function dh(t,e){const n=ch(t).scrollLeft;return e?e.left+n:Oo(mr(t)).left+n}function tT(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-dh(t,n),a=n.top+e.scrollTop;return{x:s,y:a}}function q$(t){let{elements:e,rect:n,offsetParent:s,strategy:a}=t;const r=a==="fixed",i=mr(s),c=e?lh(e.floating):!1;if(s===i||c&&r)return n;let d={scrollLeft:0,scrollTop:0},f=or(1);const h=or(0),m=Kr(s);if((m||!m&&!r)&&((oc(s)!=="body"||ad(i))&&(d=ch(s)),m)){const y=Oo(s);f=Wl(s),h.x=y.x+s.clientLeft,h.y=y.y+s.clientTop}const b=i&&!m&&!r?tT(i,d):or(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+h.x+b.x,y:n.y*f.y-d.scrollTop*f.y+h.y+b.y}}function V$(t){return Array.from(t.getClientRects())}function Y$(t){const e=mr(t),n=ch(t),s=t.ownerDocument.body,a=jo(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),r=jo(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+dh(t);const c=-n.scrollTop;return _a(s).direction==="rtl"&&(i+=jo(e.clientWidth,s.clientWidth)-a),{width:a,height:r,x:i,y:c}}const ZC=25;function G$(t,e){const n=fa(t),s=mr(t),a=n.visualViewport;let r=s.clientWidth,i=s.clientHeight,c=0,d=0;if(a){r=a.width,i=a.height;const h=xy();(!h||h&&e==="fixed")&&(c=a.offsetLeft,d=a.offsetTop)}const f=dh(s);if(f<=0){const h=s.ownerDocument,m=h.body,b=getComputedStyle(m),y=h.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,w=Math.abs(s.clientWidth-m.clientWidth-y);w<=ZC&&(r-=w)}else f<=ZC&&(r+=f);return{width:r,height:i,x:c,y:d}}function K$(t,e){const n=Oo(t,!0,e==="fixed"),s=n.top+t.clientTop,a=n.left+t.clientLeft,r=Kr(t)?Wl(t):or(1),i=t.clientWidth*r.x,c=t.clientHeight*r.y,d=a*r.x,f=s*r.y;return{width:i,height:c,x:d,y:f}}function eA(t,e,n){let s;if(e==="viewport")s=G$(t,n);else if(e==="document")s=Y$(mr(t));else if(Ds(e))s=K$(e,n);else{const a=eT(t);s={x:e.x-a.x,y:e.y-a.y,width:e.width,height:e.height}}return Lp(s)}function nT(t,e){const n=Oi(t);return n===e||!Ds(n)||Zl(n)?!1:_a(n).position==="fixed"||nT(n,e)}function Q$(t,e){const n=e.get(t);if(n)return n;let s=Qu(t,[],!1).filter(c=>Ds(c)&&oc(c)!=="body"),a=null;const r=_a(t).position==="fixed";let i=r?Oi(t):t;for(;Ds(i)&&!Zl(i);){const c=_a(i),d=by(i);!d&&c.position==="fixed"&&(a=null),(r?!d&&!a:!d&&c.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||ad(i)&&!d&&nT(t,i))?s=s.filter(h=>h!==i):a=c,i=Oi(i)}return e.set(t,s),s}function X$(t){let{element:e,boundary:n,rootBoundary:s,strategy:a}=t;const i=[...n==="clippingAncestors"?lh(e)?[]:Q$(e,this._c):[].concat(n),s],c=eA(e,i[0],a);let d=c.top,f=c.right,h=c.bottom,m=c.left;for(let b=1;b<i.length;b++){const y=eA(e,i[b],a);d=jo(y.top,d),f=ec(y.right,f),h=ec(y.bottom,h),m=jo(y.left,m)}return{width:f-m,height:h-d,x:m,y:d}}function J$(t){const{width:e,height:n}=ZN(t);return{width:e,height:n}}function Z$(t,e,n){const s=Kr(e),a=mr(e),r=n==="fixed",i=Oo(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const d=or(0);function f(){d.x=dh(a)}if(s||!s&&!r)if((oc(e)!=="body"||ad(a))&&(c=ch(e)),s){const y=Oo(e,!0,r,e);d.x=y.x+e.clientLeft,d.y=y.y+e.clientTop}else a&&f();r&&!s&&a&&f();const h=a&&!s&&!r?tT(a,c):or(0),m=i.left+c.scrollLeft-d.x-h.x,b=i.top+c.scrollTop-d.y-h.y;return{x:m,y:b,width:i.width,height:i.height}}function gb(t){return _a(t).position==="static"}function tA(t,e){if(!Kr(t)||_a(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return mr(t)===n&&(n=n.ownerDocument.body),n}function sT(t,e){const n=fa(t);if(lh(t))return n;if(!Kr(t)){let a=Oi(t);for(;a&&!Zl(a);){if(Ds(a)&&!gb(a))return a;a=Oi(a)}return n}let s=tA(t,e);for(;s&&m$(s)&&gb(s);)s=tA(s,e);return s&&Zl(s)&&gb(s)&&!by(s)?n:s||x$(t)||n}const eU=async function(t){const e=this.getOffsetParent||sT,n=this.getDimensions,s=await n(t.floating);return{reference:Z$(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function tU(t){return _a(t).direction==="rtl"}const nU={convertOffsetParentRelativeRectToViewportRelativeRect:q$,getDocumentElement:mr,getClippingRect:X$,getOffsetParent:sT,getElementRects:eU,getClientRects:V$,getDimensions:J$,getScale:Wl,isElement:Ds,isRTL:tU};function aT(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function sU(t,e){let n=null,s;const a=mr(t);function r(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function i(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),r();const f=t.getBoundingClientRect(),{left:h,top:m,width:b,height:y}=f;if(c||e(),!b||!y)return;const w=zf(m),C=zf(a.clientWidth-(h+b)),N=zf(a.clientHeight-(m+y)),k=zf(h),S={rootMargin:-w+"px "+-C+"px "+-N+"px "+-k+"px",threshold:jo(0,ec(1,d))||1};let T=!0;function D(E){const I=E[0].intersectionRatio;if(I!==d){if(!T)return i();I?i(!1,I):s=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!aT(f,t.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(D,{...S,root:a.ownerDocument})}catch{n=new IntersectionObserver(D,S)}n.observe(t)}return i(!0),r}function aU(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,f=wy(t),h=a||r?[...f?Qu(f):[],...e?Qu(e):[]]:[];h.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),r&&k.addEventListener("resize",n)});const m=f&&c?sU(f,n):null;let b=-1,y=null;i&&(y=new ResizeObserver(k=>{let[j]=k;j&&j.target===f&&y&&e&&(y.unobserve(e),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var S;(S=y)==null||S.observe(e)})),n()}),f&&!d&&y.observe(f),e&&y.observe(e));let w,C=d?Oo(t):null;d&&N();function N(){const k=Oo(t);C&&!aT(C,k)&&n(),C=k,w=requestAnimationFrame(N)}return n(),()=>{var k;h.forEach(j=>{a&&j.removeEventListener("scroll",n),r&&j.removeEventListener("resize",n)}),m==null||m(),(k=y)==null||k.disconnect(),y=null,d&&cancelAnimationFrame(w)}}const rU=U$,iU=F$,nA=B$,oU=(t,e,n)=>{const s=new Map,a={platform:nU,...n},r={...a.platform,_c:s};return P$(t,e,{...a,platform:r})};var lU=typeof document<"u",cU=function(){},ip=lU?x.useLayoutEffect:cU;function Pp(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,s,a;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(s=n;s--!==0;)if(!Pp(t[s],e[s]))return!1;return!0}if(a=Object.keys(t),n=a.length,n!==Object.keys(e).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(e,a[s]))return!1;for(s=n;s--!==0;){const r=a[s];if(!(r==="_owner"&&t.$$typeof)&&!Pp(t[r],e[r]))return!1}return!0}return t!==t&&e!==e}function rT(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function sA(t,e){const n=rT(t);return Math.round(e*n)/n}function bb(t){const e=x.useRef(t);return ip(()=>{e.current=t}),e}function uU(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:r,floating:i}={},transform:c=!0,whileElementsMounted:d,open:f}=t,[h,m]=x.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[b,y]=x.useState(s);Pp(b,s)||y(s);const[w,C]=x.useState(null),[N,k]=x.useState(null),j=x.useCallback(V=>{V!==E.current&&(E.current=V,C(V))},[]),S=x.useCallback(V=>{V!==I.current&&(I.current=V,k(V))},[]),T=r||w,D=i||N,E=x.useRef(null),I=x.useRef(null),O=x.useRef(h),_=d!=null,M=bb(d),R=bb(a),z=bb(f),$=x.useCallback(()=>{if(!E.current||!I.current)return;const V={placement:e,strategy:n,middleware:b};R.current&&(V.platform=R.current),oU(E.current,I.current,V).then(G=>{const B={...G,isPositioned:z.current!==!1};W.current&&!Pp(O.current,B)&&(O.current=B,ac.flushSync(()=>{m(B)}))})},[b,e,n,R,z]);ip(()=>{f===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,m(V=>({...V,isPositioned:!1})))},[f]);const W=x.useRef(!1);ip(()=>(W.current=!0,()=>{W.current=!1}),[]),ip(()=>{if(T&&(E.current=T),D&&(I.current=D),T&&D){if(M.current)return M.current(T,D,$);$()}},[T,D,$,M,_]);const L=x.useMemo(()=>({reference:E,floating:I,setReference:j,setFloating:S}),[j,S]),F=x.useMemo(()=>({reference:T,floating:D}),[T,D]),H=x.useMemo(()=>{const V={position:n,left:0,top:0};if(!F.floating)return V;const G=sA(F.floating,h.x),B=sA(F.floating,h.y);return c?{...V,transform:"translate("+G+"px, "+B+"px)",...rT(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:B}},[n,c,F.floating,h.x,h.y]);return x.useMemo(()=>({...h,update:$,refs:L,elements:F,floatingStyles:H}),[h,$,L,F,H])}const dU=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:s,padding:a}=typeof t=="function"?t(n):t;return s&&e(s)?s.current!=null?nA({element:s.current,padding:a}).fn(n):{}:s?nA({element:s,padding:a}).fn(n):{}}}},fU=(t,e)=>{const n=rU(t);return{name:n.name,fn:n.fn,options:[t,e]}},pU=(t,e)=>{const n=iU(t);return{name:n.name,fn:n.fn,options:[t,e]}},hU=(t,e)=>{const n=dU(t);return{name:n.name,fn:n.fn,options:[t,e]}},mU={...fj};let aA=!1,gU=0;const rA=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+gU++;function bU(){const[t,e]=x.useState(()=>aA?rA():void 0);return Ip(()=>{t==null&&e(rA())},[]),x.useEffect(()=>{aA=!0},[]),t}const xU=mU.useId,iT=xU||bU,yU=x.forwardRef(function(e,n){const{context:{placement:s,elements:{floating:a},middlewareData:{arrow:r,shift:i}},width:c=14,height:d=7,tipRadius:f=0,strokeWidth:h=0,staticOffset:m,stroke:b,d:y,style:{transform:w,...C}={},...N}=e,k=iT(),[j,S]=x.useState(!1);if(Ip(()=>{if(!a)return;_a(a).direction==="rtl"&&S(!0)},[a]),!a)return null;const[T,D]=s.split("-"),E=T==="top"||T==="bottom";let I=m;(E&&i!=null&&i.x||!E&&i!=null&&i.y)&&(I=null);const O=h*2,_=O/2,M=c/2*(f/-8+1),R=d/2*f/4,z=!!y,$=I&&D==="end"?"bottom":"top";let W=I&&D==="end"?"right":"left";I&&j&&(W=D==="end"?"left":"right");const L=(r==null?void 0:r.x)!=null?I||r.x:"",F=(r==null?void 0:r.y)!=null?I||r.y:"",H=y||"M0,0"+(" H"+c)+(" L"+(c-M)+","+(d-R))+(" Q"+c/2+","+d+" "+M+","+(d-R))+" Z",V={top:z?"rotate(180deg)":"",left:z?"rotate(90deg)":"rotate(-90deg)",bottom:z?"":"rotate(180deg)",right:z?"rotate(-90deg)":"rotate(90deg)"}[T];return o.jsxs("svg",{...N,"aria-hidden":!0,ref:n,width:z?c:c+O,height:c,viewBox:"0 0 "+c+" "+(d>c?d:c),style:{position:"absolute",pointerEvents:"none",[W]:L,[$]:F,[T]:E||z?"100%":"calc(100% - "+O/2+"px)",transform:[V,w].filter(G=>!!G).join(" "),...C},children:[O>0&&o.jsx("path",{clipPath:"url(#"+k+")",fill:"none",stroke:b,strokeWidth:O+(y?0:1),d:H}),o.jsx("path",{stroke:O&&!y?N.fill:"none",d:H}),o.jsx("clipPath",{id:k,children:o.jsx("rect",{x:-_,y:_*(z?-1:1),width:c+O,height:c})})]})});function vU(){const t=new Map;return{emit(e,n){var s;(s=t.get(e))==null||s.forEach(a=>a(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var s;(s=t.get(e))==null||s.delete(n)}}}const wU=x.createContext(null),kU=x.createContext(null),SU=()=>{var t;return((t=x.useContext(wU))==null?void 0:t.id)||null},CU=()=>x.useContext(kU);function AU(t){const{open:e=!1,onOpenChange:n,elements:s}=t,a=iT(),r=x.useRef({}),[i]=x.useState(()=>vU()),c=SU()!=null,[d,f]=x.useState(s.reference),h=O$((y,w,C)=>{r.current.openEvent=y?w:void 0,i.emit("openchange",{open:y,event:w,reason:C,nested:c}),n==null||n(y,w,C)}),m=x.useMemo(()=>({setPositionReference:f}),[]),b=x.useMemo(()=>({reference:d||s.reference||null,floating:s.floating||null,domReference:s.reference}),[d,s.reference,s.floating]);return x.useMemo(()=>({dataRef:r,open:e,onOpenChange:h,elements:b,events:i,floatingId:a,refs:m}),[e,h,b,i,a,m])}function jU(t){t===void 0&&(t={});const{nodeId:e}=t,n=AU({...t,elements:{reference:null,floating:null,...t.elements}}),s=t.rootContext||n,a=s.elements,[r,i]=x.useState(null),[c,d]=x.useState(null),h=(a==null?void 0:a.domReference)||r,m=x.useRef(null),b=CU();Ip(()=>{h&&(m.current=h)},[h]);const y=uU({...t,elements:{...a,...c&&{reference:c}}}),w=x.useCallback(S=>{const T=Ds(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;d(T),y.refs.setReference(T)},[y.refs]),C=x.useCallback(S=>{(Ds(S)||S===null)&&(m.current=S,i(S)),(Ds(y.refs.reference.current)||y.refs.reference.current===null||S!==null&&!Ds(S))&&y.refs.setReference(S)},[y.refs]),N=x.useMemo(()=>({...y.refs,setReference:C,setPositionReference:w,domReference:m}),[y.refs,C,w]),k=x.useMemo(()=>({...y.elements,domReference:h}),[y.elements,h]),j=x.useMemo(()=>({...y,...s,refs:N,elements:k,nodeId:e}),[y,N,k,e,s]);return Ip(()=>{s.dataRef.current.floatingContext=j;const S=b==null?void 0:b.nodesRef.current.find(T=>T.id===e);S&&(S.context=j)}),x.useMemo(()=>({...y,context:j,refs:N,elements:k}),[y,N,k,j])}/*!
|
|
106
|
+
react-datepicker v9.1.0
|
|
107
|
+
https://github.com/Hacker0x01/react-datepicker
|
|
108
|
+
Released under the MIT License.
|
|
109
|
+
*/var wx=function(e,n){return wx=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,a){s.__proto__=a}||function(s,a){for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(s[r]=a[r])},wx(e,n)};function ws(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");wx(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var qt=function(){return qt=Object.assign||function(n){for(var s,a=1,r=arguments.length;a<r;a++){s=arguments[a];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(n[i]=s[i])}return n},qt.apply(this,arguments)};function rr(t,e,n){if(n||arguments.length===2)for(var s=0,a=e.length,r;s<a;s++)(r||!(s in e))&&(r||(r=Array.prototype.slice.call(e,0,s)),r[s]=e[s]);return t.concat(r||Array.prototype.slice.call(e))}var NU=function(t){var e=t.showTimeSelectOnly,n=e===void 0?!1:e,s=t.showTime,a=s===void 0?!1:s,r=t.className,i=t.children,c=t.inline,d=n?"Choose Time":"Choose Date".concat(a?" and Time":"");return Ce.createElement("div",{className:r,"aria-label":d,role:c?void 0:"dialog","aria-modal":c?void 0:"true",translate:"no"},i)},TU=function(t,e){var n=x.useRef(null),s=x.useRef(t);x.useEffect(function(){s.current=t},[t]);var a=x.useCallback(function(r){var i,c=r.composed&&r.composedPath&&r.composedPath().find(function(d){return d instanceof Node})||r.target;n.current&&!n.current.contains(c)&&(e&&c instanceof HTMLElement&&c.classList.contains(e)||(i=s.current)===null||i===void 0||i.call(s,r))},[e]);return x.useEffect(function(){return document.addEventListener("mousedown",a),function(){document.removeEventListener("mousedown",a)}},[a]),n},fh=function(t){var e=t.children,n=t.onClickOutside,s=t.className,a=t.containerRef,r=t.style,i=t.ignoreClass,c=TU(n,i);return Ce.createElement("div",{className:s,style:r,ref:function(d){c.current=d,a&&(a.current=d)}},e)},$f=null,iA=!1;function oT(){if(iA)return $f;iA=!0;try{var t="date-fns-tz";$f=require(t)}catch{$f=null}return $f}function oA(t,e){if(!e)return t;var n=oT();return n?n.toZonedTime(t,e):t}function Or(t,e){if(!e)return t;var n=oT();return n?n.fromZonedTime(t,e):t}var lt;(function(t){t.ArrowUp="ArrowUp",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.PageUp="PageUp",t.PageDown="PageDown",t.Home="Home",t.End="End",t.Enter="Enter",t.Space=" ",t.Tab="Tab",t.Escape="Escape",t.Backspace="Backspace",t.X="x"})(lt||(lt={}));function lT(){var t=typeof window<"u"?window:globalThis;return t}var id=12;function dn(t){if(t==null)return new Date;var e=typeof t=="string"?Z3(t):St(t);return Gs(e)?e:new Date}function bo(t,e,n,s,a){a===void 0&&(a=dn());for(var r=nc(n)||nc(ky()),i=Array.isArray(e)?e:[e],c=0,d=i;c<d.length;c++){var f=d[c],h=Y3(t,f,a,{locale:r});if(Gs(h)&&(!s||t===Bn(h,f,n)))return h}if(!s&&t&&t.length>=8){var m=new Date(t);if(Jl(m))return m}return null}function _U(t,e){if(e===void 0&&(e=dn()),!t)return null;var n=t.match(/\b(1\d{3}|2\d{3})\b/);if(!n||!n[1])return null;var s=parseInt(n[1],10),a=t.match(/(?:^|[/\-\s])?(0?[1-9]|1[0-2])(?:[/\-\s]|$)/),r=a&&a[1]?parseInt(a[1],10)-1:e.getMonth();return new Date(s,r,1)}function Gs(t){return Jl(t)}function So(t){return t==null?null:ir(t)&&Jl(t)?t:null}function Bn(t,e,n){if(n==="en")return VC(t,e,{useAdditionalWeekYearTokens:!0,useAdditionalDayOfYearTokens:!0});var s=n?nc(n):void 0;return n&&!s&&console.warn('A locale object was not found for the provided string ["'.concat(n,'"].')),s=s||nc(ky()),VC(t,e,{locale:s,useAdditionalWeekYearTokens:!0,useAdditionalDayOfYearTokens:!0})}function Ys(t,e){var n=e.dateFormat,s=e.locale,a=Array.isArray(n)&&n.length>0?n[0]:n;return t&&Bn(t,a,s)||""}var cT=" - ";function EU(t,e,n){if(!t&&!e)return"";var s=t?Ys(t,n):"",a=e?Ys(e,n):"",r=n.rangeSeparator||cT;return"".concat(s).concat(r).concat(a)}function MU(t,e){if(!(t!=null&&t.length))return"";var n=t[0]?Ys(t[0],e):"";if(t.length===1)return n;if(t.length===2&&t[1]){var s=Ys(t[1],e);return"".concat(n,", ").concat(s)}var a=t.length-1;return"".concat(n," (+").concat(a,")")}function Lr(t,e){var n=e.hour,s=n===void 0?0:n,a=e.minute,r=a===void 0?0:a,i=e.second,c=i===void 0?0:i;return sp(ap(rp(t,c),r),s)}function DU(t){return py(t)}function RU(t,e){return Bn(t,"ddd",e)}function wu(t){return Ro(t)}function Mi(t,e,n){var s=nc(e||ky());return qr(t,{locale:s,weekStartsOn:n})}function Ur(t){return FN(t)}function ku(t){return ih(t)}function lA(t){return gx(t)}function cA(){return Ro(dn())}function uA(t){return PN(t)}function OU(t){return Z4(t)}function LU(t){return BN(t)}function Za(t,e){return t&&e?X3(t,e):!t&&!e}function Es(t,e){return t&&e?K3(t,e):!t&&!e}function Bp(t,e){return t&&e?Q3(t,e):!t&&!e}function on(t,e){return t&&e?X4(t,e):!t&&!e}function Co(t,e){return t&&e?Jz(t,e):!t&&!e}function vo(t,e,n){var s,a=Ro(e),r=PN(n);try{s=Ku(t,{start:a,end:r})}catch{s=!1}return s}function ky(){var t=lT();return t.__localeId__}function nc(t){if(typeof t=="string"){var e=lT();return e.__localeData__?e.__localeData__[t]:void 0}else return t}function IU(t,e,n){return e(Bn(t,"EEEE",n))}function PU(t,e){return Bn(t,"EEEEEE",e)}function BU(t,e){return Bn(t,"EEE",e)}function Sy(t,e){return Bn(oa(dn(),t),"LLLL",e)}function uT(t,e){return Bn(oa(dn(),t),"LLL",e)}function FU(t,e){return Bn(Bl(dn(),t),"QQQ",e)}function ja(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.excludeDateIntervals,c=n.includeDates,d=n.includeDateIntervals,f=n.filterDate,h=n.disabled;return h?!0:od(t,{minDate:s,maxDate:a})||r&&r.some(function(m){return m instanceof Date?on(t,m):on(t,m.date)})||i&&i.some(function(m){var b=m.start,y=m.end;return Ku(t,{start:b,end:y})})||c&&!c.some(function(m){return on(t,m)})||d&&!d.some(function(m){var b=m.start,y=m.end;return Ku(t,{start:b,end:y})})||f&&!f(dn(t))||!1}function Cy(t,e){var n=e===void 0?{}:e,s=n.excludeDates,a=n.excludeDateIntervals;return a&&a.length>0?a.some(function(r){var i=r.start,c=r.end;return Ku(t,{start:i,end:c})}):s&&s.some(function(r){var i;return r instanceof Date?on(t,r):on(t,(i=r.date)!==null&&i!==void 0?i:new Date)})||!1}function dT(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates,c=n.filterDate;return od(t,{minDate:s?FN(s):void 0,maxDate:a?BN(a):void 0})||(r==null?void 0:r.some(function(d){return Es(t,d instanceof Date?d:d.date)}))||i&&!i.some(function(d){return Es(t,d)})||c&&!c(dn(t))||!1}function Uf(t,e,n,s){var a=Zt(t),r=Ks(t),i=Zt(e),c=Ks(e),d=Zt(s);return a===i&&a===d?r<=n&&n<=c:a<i?d===a&&r<=n||d===i&&c>=n||d<i&&d>a:!1}function zU(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates;return od(t,{minDate:s,maxDate:a})||r&&r.some(function(c){return Es(c instanceof Date?c:c.date,t)})||i&&!i.some(function(c){return Es(c,t)})||!1}function Hf(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates,c=n.filterDate,d=n.disabled;return d?!0:od(t,{minDate:s,maxDate:a})||(r==null?void 0:r.some(function(f){return Bp(t,f instanceof Date?f:f.date)}))||i&&!i.some(function(f){return Bp(t,f)})||c&&!c(dn(t))||!1}function Wf(t,e,n){if(!e||!n||!Jl(e)||!Jl(n))return!1;var s=Zt(e),a=Zt(n);return s<=t&&a>=t}function op(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.maxDate,r=n.excludeDates,i=n.includeDates,c=n.filterDate,d=n.disabled;if(d)return!0;var f=new Date(t,0,1);return od(f,{minDate:s?ih(s):void 0,maxDate:a?zN(a):void 0})||(r==null?void 0:r.some(function(h){return Za(f,h instanceof Date?h:h.date)}))||i&&!i.some(function(h){return Za(f,h)})||c&&!c(dn(f))||!1}function qf(t,e,n,s){var a=Zt(t),r=_i(t),i=Zt(e),c=_i(e),d=Zt(s);return a===i&&a===d?r<=n&&n<=c:a<i?d===a&&r<=n||d===i&&c>=n||d<i&&d>a:!1}function od(t,e){var n,s=e===void 0?{}:e,a=s.minDate,r=s.maxDate;return(n=a&&Xl(t,a)<0||r&&Xl(t,r)>0)!==null&&n!==void 0?n:!1}function dA(t,e){return e.some(function(n){return Cs(n)===Cs(t)&&As(n)===As(t)&&Ei(n)===Ei(t)})}function fA(t,e){var n=e===void 0?{}:e,s=n.excludeTimes,a=n.includeTimes,r=n.filterTime;return s&&dA(t,s)||a&&!dA(t,a)||r&&!r(t)||!1}function pA(t,e){var n=e.minTime,s=e.maxTime;if(!n||!s)throw new Error("Both minTime and maxTime props required");var a=dn();a=sp(a,Cs(t)),a=ap(a,As(t)),a=rp(a,Ei(t));var r=dn();r=sp(r,Cs(n)),r=ap(r,As(n)),r=rp(r,Ei(n));var i=dn();i=sp(i,Cs(s)),i=ap(i,As(s)),i=rp(i,Ei(s));var c;try{c=!Ku(a,{start:r,end:i})}catch{c=!1}return c}function hA(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.includeDates,r=Ao(t,1);return s&&_p(s,r)>0||a&&a.every(function(i){return _p(i,r)>0})||!1}function mA(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.includeDates,r=za(t,1);return s&&_p(r,s)>0||a&&a.every(function(i){return _p(r,i)>0})||!1}function $U(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.includeDates,r=ih(t),i=KN(r);return s&&Ep(s,i)>0||a&&a.every(function(c){return Ep(c,i)>0})||!1}function UU(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.includeDates,r=zN(t),i=fy(r,1);return s&&Ep(i,s)>0||a&&a.every(function(c){return Ep(i,c)>0})||!1}function gA(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.includeDates,r=Ri(t,1);return s&&Mp(s,r)>0||a&&a.every(function(i){return Mp(i,r)>0})||!1}function HU(t,e){var n=e===void 0?{}:e,s=n.minDate,a=n.yearItemNumber,r=a===void 0?id:a,i=ku(Ri(t,r)),c=Pr(i,r).endPeriod,d=s&&Zt(s);return d&&d>c||!1}function bA(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.includeDates,r=Ba(t,1);return s&&Mp(r,s)>0||a&&a.every(function(i){return Mp(r,i)>0})||!1}function WU(t,e){var n=e===void 0?{}:e,s=n.maxDate,a=n.yearItemNumber,r=a===void 0?id:a,i=Ba(t,r),c=Pr(i,r).startPeriod,d=s&&Zt(s);return d&&d<c||!1}function fT(t){var e=t.minDate,n=t.includeDates;if(n&&e){var s=n.filter(function(a){return Xl(a,e)>=0});return zC(s)}else return n?zC(n):e}function pT(t){var e=t.maxDate,n=t.includeDates;if(n&&e){var s=n.filter(function(a){return Xl(a,e)<=0});return FC(s)}else return n?FC(n):e}function xA(t,e){var n;t===void 0&&(t=[]),e===void 0&&(e="react-datepicker__day--highlighted");for(var s=new Map,a=0,r=t.length;a<r;a++){var i=t[a];if(ir(i)){var c=Bn(i,"MM.dd.yyyy"),d=s.get(c)||[];d.includes(e)||(d.push(e),s.set(c,d))}else if(typeof i=="object"){var f=Object.keys(i),h=(n=f[0])!==null&&n!==void 0?n:"",m=i[h];if(typeof h=="string"&&Array.isArray(m))for(var b=0,y=m.length;b<y;b++){var w=m[b];if(w){var c=Bn(w,"MM.dd.yyyy"),d=s.get(c)||[];d.includes(h)||(d.push(h),s.set(c,d))}}}}return s}function qU(t,e){return t.length!==e.length?!1:t.every(function(n,s){return n===e[s]})}function VU(t,e){t===void 0&&(t=[]),e===void 0&&(e="react-datepicker__day--holidays");var n=new Map;return t.forEach(function(s){var a=s.date,r=s.holidayName;if(ir(a)){var i=Bn(a,"MM.dd.yyyy"),c=n.get(i)||{className:"",holidayNames:[]};if(!("className"in c&&c.className===e&&qU(c.holidayNames,[r]))){c.className=e;var d=c.holidayNames;c.holidayNames=d?rr(rr([],d,!0),[r],!1):[r],n.set(i,c)}}}),n}function YU(t,e,n,s,a){for(var r=a.length,i=[],c=0;c<r;c++){var d=t,f=a[c];f&&(d=Y4(d,Cs(f)),d=Gu(d,As(f)),d=Q4(d,Ei(f)));var h=Gu(t,(n+1)*s);$r(d,e)&&ar(d,h)&&f!=null&&i.push(f)}return i}function Rl(t){return t<10?"0".concat(t):"".concat(t)}function Pr(t,e){e===void 0&&(e=id);var n=Math.ceil(Zt(t)/e)*e,s=n-(e-1);return{startPeriod:s,endPeriod:n}}function GU(t){var e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=new Date(t.getFullYear(),t.getMonth(),t.getDate(),24);return Math.round((+n-+e)/36e5)}function yA(t){var e=t.getSeconds(),n=t.getMilliseconds();return St(t.getTime()-e*1e3-n)}function hT(t,e){return yA(t).getTime()===yA(e).getTime()}function vA(t){if(!ir(t))throw new Error("Invalid date");var e=new Date(t);return e.setHours(0,0,0,0),e}function xb(t,e){if(!ir(t)||!ir(e))throw new Error("Invalid date received");var n=vA(t),s=vA(e);return ar(n,s)}function mT(t){return t.key===lt.Space}var yb=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.inputRef=Ce.createRef(),s.onTimeChange=function(a){var r,i;s.setState({time:a});var c=s.props.date,d=c instanceof Date&&!isNaN(+c),f=d?c:new Date;if(a!=null&&a.includes(":")){var h=a.split(":"),m=h[0],b=h[1];f.setHours(Number(m)),f.setMinutes(Number(b))}(i=(r=s.props).onChange)===null||i===void 0||i.call(r,f)},s.renderTimeInput=function(){var a=s.state.time,r=s.props,i=r.date,c=r.timeString,d=r.customTimeInput;return d?x.cloneElement(d,{date:i,value:a,onChange:s.onTimeChange}):Ce.createElement("input",{type:"time",className:"react-datepicker-time__input",placeholder:"Time",name:"time-input",ref:s.inputRef,onClick:function(){var f;(f=s.inputRef.current)===null||f===void 0||f.focus()},required:!0,value:a,onChange:function(f){s.onTimeChange(f.target.value||c)}})},s.state={time:s.props.timeString},s}return e.getDerivedStateFromProps=function(n,s){return n.timeString!==s.time?{time:n.timeString}:null},e.prototype.render=function(){return Ce.createElement("div",{className:"react-datepicker__input-time-container"},Ce.createElement("div",{className:"react-datepicker-time__caption"},this.props.timeInputLabel),Ce.createElement("div",{className:"react-datepicker-time__input-container"},Ce.createElement("div",{className:"react-datepicker-time__input"},this.renderTimeInput())))},e})(x.Component),KU=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.dayEl=x.createRef(),n.handleClick=function(s){!n.isDisabled()&&n.props.onClick&&n.props.onClick(s)},n.handleMouseEnter=function(s){!n.isDisabled()&&n.props.onMouseEnter&&n.props.onMouseEnter(s)},n.handleOnKeyDown=function(s){var a,r,i=s.key;i===lt.Space&&(s.preventDefault(),s.key=lt.Enter),(r=(a=n.props).handleOnKeyDown)===null||r===void 0||r.call(a,s)},n.isSameDay=function(s){return on(n.props.day,s)},n.isKeyboardSelected=function(){var s;if(n.props.disabledKeyboardNavigation)return!1;var a=n.props.selectsMultiple?(s=n.props.selectedDates)===null||s===void 0?void 0:s.some(function(i){return n.isSameDayOrWeek(i)}):n.isSameDayOrWeek(n.props.selected),r=n.props.preSelection&&n.isDisabled(n.props.preSelection);return!a&&n.isSameDayOrWeek(n.props.preSelection)&&!r},n.isDisabled=function(s){return s===void 0&&(s=n.props.day),ja(s,{minDate:n.props.minDate,maxDate:n.props.maxDate,excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals,includeDateIntervals:n.props.includeDateIntervals,includeDates:n.props.includeDates,filterDate:n.props.filterDate,disabled:n.props.disabled})},n.isExcluded=function(){return Cy(n.props.day,{excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals})},n.isStartOfWeek=function(){return on(n.props.day,Mi(n.props.day,n.props.locale,n.props.calendarStartDay))},n.isSameWeek=function(s){return n.props.showWeekPicker&&on(s,Mi(n.props.day,n.props.locale,n.props.calendarStartDay))},n.isSameDayOrWeek=function(s){return n.isSameDay(s)||n.isSameWeek(s)},n.getHighLightedClass=function(){var s=n.props,a=s.day,r=s.highlightDates;if(!r)return!1;var i=Bn(a,"MM.dd.yyyy");return r.get(i)},n.getHolidaysClass=function(){var s,a=n.props,r=a.day,i=a.holidays;if(!i)return[void 0];var c=Bn(r,"MM.dd.yyyy");return i.has(c)?[(s=i.get(c))===null||s===void 0?void 0:s.className]:[void 0]},n.isInRange=function(){var s=n.props,a=s.day,r=s.startDate,i=s.endDate;return!r||!i?!1:vo(a,r,i)},n.isInSelectingRange=function(){var s,a=n.props,r=a.day,i=a.selectsStart,c=a.selectsEnd,d=a.selectsRange,f=a.selectsDisabledDaysInRange,h=a.startDate,m=a.swapRange,b=a.endDate,y=(s=n.props.selectingDate)!==null&&s!==void 0?s:n.props.preSelection;if(n.isAfterMonth()||n.isBeforeMonth()||!(i||c||d)||!y||!f&&n.isDisabled())return!1;if(i&&b&&(ar(y,b)||Co(y,b)))return vo(r,y,b);if(c&&h&&($r(y,h)||Co(y,h)))return vo(r,h,y);if(d&&h&&!b){if(Co(y,h)||$r(y,h))return vo(r,h,y);if(m&&ar(y,h))return vo(r,y,h)}return!1},n.isSelectingRangeStart=function(){var s;if(!n.isInSelectingRange())return!1;var a=n.props,r=a.day,i=a.startDate,c=a.selectsStart,d=a.swapRange,f=a.selectsRange,h=(s=n.props.selectingDate)!==null&&s!==void 0?s:n.props.preSelection;return c?on(r,h):f&&d&&i&&h?on(r,ar(h,i)?h:i):on(r,i)},n.isSelectingRangeEnd=function(){var s;if(!n.isInSelectingRange())return!1;var a=n.props,r=a.day,i=a.endDate,c=a.selectsEnd,d=a.selectsRange,f=a.swapRange,h=a.startDate,m=(s=n.props.selectingDate)!==null&&s!==void 0?s:n.props.preSelection;return c?on(r,m):d&&f&&h&&m?on(r,ar(m,h)?h:m):d?on(r,m):on(r,i)},n.isRangeStart=function(){var s=n.props,a=s.day,r=s.startDate,i=s.endDate;return!r||!i?!1:on(r,a)},n.isRangeEnd=function(){var s=n.props,a=s.day,r=s.startDate,i=s.endDate;return!r||!i?!1:on(i,a)},n.isWeekend=function(){var s=Gz(n.props.day);return s===0||s===6},n.isAfterMonth=function(){return n.props.month!==void 0&&(n.props.month+1)%12===Ks(n.props.day)},n.isBeforeMonth=function(){return n.props.month!==void 0&&(Ks(n.props.day)+1)%12===n.props.month},n.isCurrentDay=function(){return n.isSameDay(dn())},n.isSelected=function(){var s;return n.props.selectsMultiple?(s=n.props.selectedDates)===null||s===void 0?void 0:s.some(function(a){return n.isSameDayOrWeek(a)}):n.isSameDayOrWeek(n.props.selected)},n.getClassNames=function(s){var a=n.props.dayClassName?n.props.dayClassName(s):void 0;return us("react-datepicker__day",a,"react-datepicker__day--"+RU(n.props.day),{"react-datepicker__day--disabled":n.isDisabled(),"react-datepicker__day--excluded":n.isExcluded(),"react-datepicker__day--selected":n.isSelected(),"react-datepicker__day--keyboard-selected":n.isKeyboardSelected(),"react-datepicker__day--range-start":n.isRangeStart(),"react-datepicker__day--range-end":n.isRangeEnd(),"react-datepicker__day--in-range":n.isInRange(),"react-datepicker__day--in-selecting-range":n.isInSelectingRange(),"react-datepicker__day--selecting-range-start":n.isSelectingRangeStart(),"react-datepicker__day--selecting-range-end":n.isSelectingRangeEnd(),"react-datepicker__day--today":n.isCurrentDay(),"react-datepicker__day--weekend":n.isWeekend(),"react-datepicker__day--outside-month":n.isAfterMonth()||n.isBeforeMonth()},n.getHighLightedClass(),n.getHolidaysClass())},n.getAriaLabel=function(){var s=n.props,a=s.day,r=s.ariaLabelPrefixWhenEnabled,i=r===void 0?"Choose":r,c=s.ariaLabelPrefixWhenDisabled,d=c===void 0?"Not available":c,f=n.isDisabled()||n.isExcluded()?d:i;return"".concat(f," ").concat(Bn(a,"PPPP",n.props.locale))},n.getTitle=function(){var s=n.props,a=s.day,r=s.holidays,i=r===void 0?new Map:r,c=s.excludeDates,d=Bn(a,"MM.dd.yyyy"),f=[];return i.has(d)&&f.push.apply(f,i.get(d).holidayNames),n.isExcluded()&&f.push(c==null?void 0:c.filter(function(h){return h instanceof Date?on(h,a):on(h==null?void 0:h.date,a)}).map(function(h){if(!(h instanceof Date))return h==null?void 0:h.message})),f.join(", ")},n.getTabIndex=function(){var s=n.props.selected,a=n.props.preSelection,r=!(n.props.showWeekPicker&&(n.props.showWeekNumber||!n.isStartOfWeek()))&&(n.isKeyboardSelected()||n.isSameDay(s)&&on(a,s))?0:-1;return r},n.handleFocusDay=function(){var s;n.shouldFocusDay()&&((s=n.dayEl.current)===null||s===void 0||s.focus({preventScroll:!0}))},n.renderDayContents=function(){return n.props.monthShowsDuplicateDaysEnd&&n.isAfterMonth()||n.props.monthShowsDuplicateDaysStart&&n.isBeforeMonth()?null:n.props.renderDayContents?n.props.renderDayContents(YC(n.props.day),n.props.day):YC(n.props.day)},n.render=function(){return Ce.createElement("div",{ref:n.dayEl,className:n.getClassNames(n.props.day),onKeyDown:n.handleOnKeyDown,onClick:n.handleClick,onMouseEnter:n.props.usePointerEvent?void 0:n.handleMouseEnter,onPointerEnter:n.props.usePointerEvent?n.handleMouseEnter:void 0,tabIndex:n.getTabIndex(),"aria-label":n.getAriaLabel(),role:"gridcell",title:n.getTitle(),"aria-disabled":n.isDisabled(),"aria-current":n.isCurrentDay()?"date":void 0,"aria-selected":n.isSelected()||n.isInRange()},n.renderDayContents(),n.getTitle()!==""&&Ce.createElement("span",{className:"overlay"},n.getTitle()))},n}return e.prototype.componentDidMount=function(){this.handleFocusDay()},e.prototype.componentDidUpdate=function(){this.handleFocusDay()},e.prototype.shouldFocusDay=function(){var n=!1;return this.getTabIndex()===0&&this.isSameDay(this.props.preSelection)&&((!document.activeElement||document.activeElement===document.body)&&(n=!0),this.props.inline&&!this.props.shouldFocusDayInline&&(n=!1),this.isDayActiveElement()&&(n=!0),this.isDuplicateDay()&&(n=!1)),n},e.prototype.isDayActiveElement=function(){var n,s,a;return((s=(n=this.props.containerRef)===null||n===void 0?void 0:n.current)===null||s===void 0?void 0:s.contains(document.activeElement))&&((a=document.activeElement)===null||a===void 0?void 0:a.classList.contains("react-datepicker__day"))},e.prototype.isDuplicateDay=function(){return this.props.monthShowsDuplicateDaysEnd&&this.isAfterMonth()||this.props.monthShowsDuplicateDaysStart&&this.isBeforeMonth()},e})(x.Component),QU=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.weekNumberEl=x.createRef(),n.handleClick=function(s){n.props.onClick&&n.props.onClick(s)},n.handleOnKeyDown=function(s){var a,r,i=s.key;i===lt.Space&&(s.preventDefault(),s.key=lt.Enter),(r=(a=n.props).handleOnKeyDown)===null||r===void 0||r.call(a,s)},n.isKeyboardSelected=function(){return!n.props.disabledKeyboardNavigation&&!on(n.props.date,n.props.selected)&&on(n.props.date,n.props.preSelection)},n.getTabIndex=function(){return n.props.showWeekPicker&&n.props.showWeekNumber&&(n.isKeyboardSelected()||on(n.props.date,n.props.selected)&&on(n.props.preSelection,n.props.selected))?0:-1},n.handleFocusWeekNumber=function(s){var a=!1;n.getTabIndex()===0&&!(s!=null&&s.isInputFocused)&&on(n.props.date,n.props.preSelection)&&((!document.activeElement||document.activeElement===document.body)&&(a=!0),n.props.inline&&!n.props.shouldFocusDayInline&&(a=!1),n.props.containerRef&&n.props.containerRef.current&&n.props.containerRef.current.contains(document.activeElement)&&document.activeElement&&document.activeElement.classList.contains("react-datepicker__week-number")&&(a=!0)),a&&n.weekNumberEl.current&&n.weekNumberEl.current.focus({preventScroll:!0})},n}return Object.defineProperty(e,"defaultProps",{get:function(){return{ariaLabelPrefix:"week "}},enumerable:!1,configurable:!0}),e.prototype.componentDidMount=function(){this.handleFocusWeekNumber()},e.prototype.componentDidUpdate=function(n){this.handleFocusWeekNumber(n)},e.prototype.render=function(){var n=this.props,s=n.weekNumber,a=n.isWeekDisabled,r=n.ariaLabelPrefix,i=r===void 0?e.defaultProps.ariaLabelPrefix:r,c=n.onClick,d={"react-datepicker__week-number":!0,"react-datepicker__week-number--clickable":!!c&&!a,"react-datepicker__week-number--selected":!!c&&on(this.props.date,this.props.selected)};return Ce.createElement("div",{ref:this.weekNumberEl,className:us(d),"aria-label":"".concat(i," ").concat(this.props.weekNumber),onClick:this.handleClick,onKeyDown:this.handleOnKeyDown,tabIndex:this.getTabIndex(),role:"gridcell"},s)},e})(x.Component),XU=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.isDisabled=function(s){return ja(s,{minDate:n.props.minDate,maxDate:n.props.maxDate,excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals,includeDateIntervals:n.props.includeDateIntervals,includeDates:n.props.includeDates,filterDate:n.props.filterDate})},n.handleDayClick=function(s,a){n.props.onDayClick&&n.props.onDayClick(s,a)},n.handleDayMouseEnter=function(s){n.props.onDayMouseEnter&&n.props.onDayMouseEnter(s)},n.handleWeekClick=function(s,a,r){for(var i,c,d,f=new Date(s),h=0;h<7;h++){var m=new Date(s);m.setDate(m.getDate()+h);var b=!n.isDisabled(m);if(b){f=m;break}}typeof n.props.onWeekSelect=="function"&&n.props.onWeekSelect(f,a,r),n.props.showWeekPicker&&n.handleDayClick(f,r),((i=n.props.shouldCloseOnSelect)!==null&&i!==void 0?i:e.defaultProps.shouldCloseOnSelect)&&((d=(c=n.props).setOpen)===null||d===void 0||d.call(c,!1))},n.formatWeekNumber=function(s){return n.props.formatWeekNumber?n.props.formatWeekNumber(s):DU(s)},n.isWeekDisabled=function(){for(var s=n.startOfWeek(),a=Pa(s,6),r=new Date(s);r<=a;){if(!n.isDisabled(r))return!1;r=Pa(r,1)}return!0},n.renderDays=function(){var s=n.startOfWeek(),a=[],r=n.formatWeekNumber(s);if(n.props.showWeekNumber){var i=n.props.onWeekSelect||n.props.showWeekPicker?n.handleWeekClick.bind(n,s,r):void 0;a.push(Ce.createElement(QU,qt({key:"W"},e.defaultProps,n.props,{weekNumber:r,isWeekDisabled:n.isWeekDisabled(),date:s,onClick:i})))}return a.concat([0,1,2,3,4,5,6].map(function(c){var d=Pa(s,c);return Ce.createElement(KU,qt({},e.defaultProps,n.props,{ariaLabelPrefixWhenEnabled:n.props.chooseDayAriaLabelPrefix,ariaLabelPrefixWhenDisabled:n.props.disabledDayAriaLabelPrefix,key:d.valueOf(),day:d,onClick:n.handleDayClick.bind(n,d),onMouseEnter:n.handleDayMouseEnter.bind(n,d)}))}))},n.startOfWeek=function(){return Mi(n.props.day,n.props.locale,n.props.calendarStartDay)},n.isKeyboardSelected=function(){return!n.props.disabledKeyboardNavigation&&!on(n.startOfWeek(),n.props.selected)&&on(n.startOfWeek(),n.props.preSelection)},n}return Object.defineProperty(e,"defaultProps",{get:function(){return{shouldCloseOnSelect:!0}},enumerable:!1,configurable:!0}),e.prototype.render=function(){var n={"react-datepicker__week":!0,"react-datepicker__week--selected":on(this.startOfWeek(),this.props.selected),"react-datepicker__week--keyboard-selected":this.isKeyboardSelected()},s=this.props.weekClassName?this.props.weekClassName(this.startOfWeek()):void 0;return Ce.createElement("div",{className:us(n,s),role:"row"},this.renderDays())},e})(x.Component),gu,JU=6,ql={TWO_COLUMNS:"two_columns",THREE_COLUMNS:"three_columns",FOUR_COLUMNS:"four_columns"},vb=(gu={},gu[ql.TWO_COLUMNS]={grid:[[0,1],[2,3],[4,5],[6,7],[8,9],[10,11]],verticalNavigationOffset:2},gu[ql.THREE_COLUMNS]={grid:[[0,1,2],[3,4,5],[6,7,8],[9,10,11]],verticalNavigationOffset:3},gu[ql.FOUR_COLUMNS]={grid:[[0,1,2,3],[4,5,6,7],[8,9,10,11]],verticalNavigationOffset:4},gu),Vf=1;function wA(t,e){return t?ql.FOUR_COLUMNS:e?ql.TWO_COLUMNS:ql.THREE_COLUMNS}var ZU=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.MONTH_REFS=rr([],Array(12),!0).map(function(){return x.createRef()}),n.QUARTER_REFS=rr([],Array(4),!0).map(function(){return x.createRef()}),n.isDisabled=function(s){return ja(s,{minDate:n.props.minDate,maxDate:n.props.maxDate,excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals,includeDateIntervals:n.props.includeDateIntervals,includeDates:n.props.includeDates,filterDate:n.props.filterDate,disabled:n.props.disabled})},n.isExcluded=function(s){return Cy(s,{excludeDates:n.props.excludeDates,excludeDateIntervals:n.props.excludeDateIntervals})},n.handleDayClick=function(s,a){var r,i;(i=(r=n.props).onDayClick)===null||i===void 0||i.call(r,s,a,n.props.orderInDisplay)},n.handleDayMouseEnter=function(s){var a,r;(r=(a=n.props).onDayMouseEnter)===null||r===void 0||r.call(a,s)},n.handleMouseLeave=function(){var s,a;(a=(s=n.props).onMouseLeave)===null||a===void 0||a.call(s)},n.isRangeStartMonth=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Es(oa(r,s),i)},n.isRangeStartQuarter=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Bp(Bl(r,s),i)},n.isRangeEndMonth=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Es(oa(r,s),c)},n.isRangeEndQuarter=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate;return!i||!c?!1:Bp(Bl(r,s),c)},n.isInSelectingRangeMonth=function(s){var a,r=n.props,i=r.day,c=r.selectsStart,d=r.selectsEnd,f=r.selectsRange,h=r.startDate,m=r.endDate,b=(a=n.props.selectingDate)!==null&&a!==void 0?a:n.props.preSelection;return!(c||d||f)||!b?!1:c&&m?Uf(b,m,s,i):d&&h||f&&h&&!m?Uf(h,b,s,i):!1},n.isSelectingMonthRangeStart=function(s){var a;if(!n.isInSelectingRangeMonth(s))return!1;var r=n.props,i=r.day,c=r.startDate,d=r.selectsStart,f=oa(i,s),h=(a=n.props.selectingDate)!==null&&a!==void 0?a:n.props.preSelection;return d?Es(f,h):Es(f,c)},n.isSelectingMonthRangeEnd=function(s){var a;if(!n.isInSelectingRangeMonth(s))return!1;var r=n.props,i=r.day,c=r.endDate,d=r.selectsEnd,f=r.selectsRange,h=oa(i,s),m=(a=n.props.selectingDate)!==null&&a!==void 0?a:n.props.preSelection;return d||f?Es(h,m):Es(h,c)},n.isInSelectingRangeQuarter=function(s){var a,r=n.props,i=r.day,c=r.selectsStart,d=r.selectsEnd,f=r.selectsRange,h=r.startDate,m=r.endDate,b=(a=n.props.selectingDate)!==null&&a!==void 0?a:n.props.preSelection;return!(c||d||f)||!b?!1:c&&m?qf(b,m,s,i):d&&h||f&&h&&!m?qf(h,b,s,i):!1},n.isWeekInMonth=function(s){var a=n.props.day,r=Pa(s,6);return Es(s,a)||Es(r,a)},n.isCurrentMonth=function(s,a){return Zt(s)===Zt(dn())&&a===Ks(dn())},n.isCurrentQuarter=function(s,a){return Zt(s)===Zt(dn())&&a===_i(dn())},n.isSelectedMonth=function(s,a,r){return Ks(r)===a&&Zt(s)===Zt(r)},n.isSelectMonthInList=function(s,a,r){return r.some(function(i){return n.isSelectedMonth(s,a,i)})},n.isSelectedQuarter=function(s,a,r){return _i(r)===a&&Zt(s)===Zt(r)},n.isSelectQuarterInList=function(s,a,r){return r.some(function(i){return n.isSelectedQuarter(s,a,i)})},n.isMonthSelected=function(){var s=n.props,a=s.day,r=s.selected,i=s.selectedDates,c=s.selectsMultiple,d=Ks(a);return c?i==null?void 0:i.some(function(f){return n.isSelectedMonth(a,d,f)}):!!r&&n.isSelectedMonth(a,d,r)},n.isQuarterSelected=function(){var s=n.props,a=s.day,r=s.selected,i=s.selectedDates,c=s.selectsMultiple,d=_i(a);return c?i==null?void 0:i.some(function(f){return n.isSelectedQuarter(a,d,f)}):!!r&&n.isSelectedQuarter(a,d,r)},n.renderWeeks=function(){if(!Gs(n.props.day))return[];for(var s=[],a=n.props.fixedHeight,r=0,i=!1,c=Mi(Ur(n.props.day),n.props.locale,n.props.calendarStartDay),d=function(w){return n.props.showWeekPicker?Mi(w,n.props.locale,n.props.calendarStartDay):n.props.preSelection},f=function(w){return n.props.showWeekPicker?Mi(w,n.props.locale,n.props.calendarStartDay):n.props.selected},h=n.props.selected?f(n.props.selected):void 0,m=n.props.preSelection?d(n.props.preSelection):void 0;s.push(Ce.createElement(XU,qt({},n.props,{ariaLabelPrefix:n.props.weekAriaLabelPrefix,key:r,day:c,month:Ks(n.props.day),onDayClick:n.handleDayClick,onDayMouseEnter:n.handleDayMouseEnter,selected:h,preSelection:m,showWeekNumber:n.props.showWeekNumbers}))),!i;){r++,c=Tp(c,1);var b=a&&r>=JU,y=!a&&!n.isWeekInMonth(c);if(b||y)if(n.props.peekNextMonth)i=!0;else break}return s},n.onMonthClick=function(s,a){var r=n.isMonthDisabledForLabelDate(a),i=r.isDisabled,c=r.labelDate;i||n.handleDayClick(Ur(c),s)},n.onMonthMouseEnter=function(s){var a=n.isMonthDisabledForLabelDate(s),r=a.isDisabled,i=a.labelDate;r||n.handleDayMouseEnter(Ur(i))},n.handleMonthNavigation=function(s,a){var r,i,c,d;(i=(r=n.props).setPreSelection)===null||i===void 0||i.call(r,a),(d=(c=n.MONTH_REFS[s])===null||c===void 0?void 0:c.current)===null||d===void 0||d.focus()},n.handleKeyboardNavigation=function(s,a,r){var i,c=n.props,d=c.selected,f=c.preSelection,h=c.setPreSelection,m=c.minDate,b=c.maxDate,y=c.showFourColumnMonthYearPicker,w=c.showTwoColumnMonthYearPicker;if(f){var C=wA(y,w),N=n.getVerticalOffset(C),k=(i=vb[C])===null||i===void 0?void 0:i.grid,j=function(I,O,_){var M,R,z=O,$=_;switch(I){case lt.ArrowRight:z=za(O,Vf),$=_===11?0:_+Vf;break;case lt.ArrowLeft:z=Ao(O,Vf),$=_===0?11:_-Vf;break;case lt.ArrowUp:z=Ao(O,N),$=!((M=k==null?void 0:k[0])===null||M===void 0)&&M.includes(_)?_+12-N:_-N;break;case lt.ArrowDown:z=za(O,N),$=!((R=k==null?void 0:k[k.length-1])===null||R===void 0)&&R.includes(_)?_-12+N:_+N;break}return{newCalculatedDate:z,newCalculatedMonth:$}},S=function(I,O,_){for(var M=40,R=I,z=!1,$=0,W=j(R,O,_),L=W.newCalculatedDate,F=W.newCalculatedMonth;!z;){if($>=M){L=O,F=_;break}if(m&&L<m){R=lt.ArrowRight;var H=j(R,L,F);L=H.newCalculatedDate,F=H.newCalculatedMonth}if(b&&L>b){R=lt.ArrowLeft;var H=j(R,L,F);L=H.newCalculatedDate,F=H.newCalculatedMonth}if(zU(L,n.props)){var H=j(R,L,F);L=H.newCalculatedDate,F=H.newCalculatedMonth}else z=!0;$++}return{newCalculatedDate:L,newCalculatedMonth:F}};if(a===lt.Enter){n.isMonthDisabled(r)||(n.onMonthClick(s,r),h==null||h(d));return}var T=S(a,f,r),D=T.newCalculatedDate,E=T.newCalculatedMonth;switch(a){case lt.ArrowRight:case lt.ArrowLeft:case lt.ArrowUp:case lt.ArrowDown:n.handleMonthNavigation(E,D);break}}},n.getVerticalOffset=function(s){var a,r;return(r=(a=vb[s])===null||a===void 0?void 0:a.verticalNavigationOffset)!==null&&r!==void 0?r:0},n.onMonthKeyDown=function(s,a){var r=n.props,i=r.disabledKeyboardNavigation,c=r.handleOnMonthKeyDown,d=s.key;d!==lt.Tab&&s.preventDefault(),i||n.handleKeyboardNavigation(s,d,a),c&&c(s)},n.onQuarterClick=function(s,a){var r=Bl(n.props.day,a);Hf(r,n.props)||n.handleDayClick(lA(r),s)},n.onQuarterMouseEnter=function(s){var a=Bl(n.props.day,s);Hf(a,n.props)||n.handleDayMouseEnter(lA(a))},n.handleQuarterNavigation=function(s,a){var r,i,c,d;n.isDisabled(a)||n.isExcluded(a)||((i=(r=n.props).setPreSelection)===null||i===void 0||i.call(r,a),(d=(c=n.QUARTER_REFS[s-1])===null||c===void 0?void 0:c.current)===null||d===void 0||d.focus())},n.onQuarterKeyDown=function(s,a){var r,i,c=s.key;if(!n.props.disabledKeyboardNavigation)switch(c){case lt.Enter:n.onQuarterClick(s,a),(i=(r=n.props).setPreSelection)===null||i===void 0||i.call(r,n.props.selected);break;case lt.ArrowRight:if(!n.props.preSelection)break;n.handleQuarterNavigation(a===4?1:a+1,fy(n.props.preSelection,1));break;case lt.ArrowLeft:if(!n.props.preSelection)break;n.handleQuarterNavigation(a===1?4:a-1,KN(n.props.preSelection));break}},n.isMonthDisabledForLabelDate=function(s){var a,r=n.props,i=r.day,c=r.disabled,d=r.minDate,f=r.maxDate,h=r.excludeDates,m=r.includeDates,b=oa(i,s);return c?{isDisabled:!0,labelDate:oa(i,s)}:{isDisabled:(a=(d||f||h||m)&&dT(b,n.props))!==null&&a!==void 0?a:!1,labelDate:b}},n.isMonthDisabled=function(s){var a=n.isMonthDisabledForLabelDate(s).isDisabled;return a},n.getMonthClassNames=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate,d=a.preSelection,f=a.monthClassName,h=f?f(oa(r,s)):void 0,m=n.getSelection();return us("react-datepicker__month-text","react-datepicker__month-".concat(s),h,{"react-datepicker__month-text--disabled":n.isMonthDisabled(s),"react-datepicker__month-text--selected":m?n.isSelectMonthInList(r,s,m):void 0,"react-datepicker__month-text--keyboard-selected":!n.props.disabledKeyboardNavigation&&d&&n.isSelectedMonth(r,s,d)&&!n.isMonthSelected()&&!n.isMonthDisabled(s),"react-datepicker__month-text--in-selecting-range":n.isInSelectingRangeMonth(s),"react-datepicker__month-text--in-range":i&&c?Uf(i,c,s,r):void 0,"react-datepicker__month-text--range-start":n.isRangeStartMonth(s),"react-datepicker__month-text--range-end":n.isRangeEndMonth(s),"react-datepicker__month-text--selecting-range-start":n.isSelectingMonthRangeStart(s),"react-datepicker__month-text--selecting-range-end":n.isSelectingMonthRangeEnd(s),"react-datepicker__month-text--today":n.isCurrentMonth(r,s)})},n.getTabIndex=function(s){if(n.props.preSelection==null)return"-1";var a=Ks(n.props.preSelection),r=n.isMonthDisabledForLabelDate(a).isDisabled,i=s===a&&!(r||n.props.disabledKeyboardNavigation)?"0":"-1";return i},n.getQuarterTabIndex=function(s){if(n.props.preSelection==null)return"-1";var a=_i(n.props.preSelection),r=Hf(n.props.day,n.props),i=s===a&&!(r||n.props.disabledKeyboardNavigation)?"0":"-1";return i},n.getAriaLabel=function(s){var a=n.props,r=a.chooseDayAriaLabelPrefix,i=r===void 0?"Choose":r,c=a.disabledDayAriaLabelPrefix,d=c===void 0?"Not available":c,f=a.day,h=a.locale,m=oa(f,s),b=n.isDisabled(m)||n.isExcluded(m)?d:i;return"".concat(b," ").concat(Bn(m,"MMMM yyyy",h))},n.getQuarterClassNames=function(s){var a=n.props,r=a.day,i=a.startDate,c=a.endDate,d=a.minDate,f=a.maxDate,h=a.excludeDates,m=a.includeDates,b=a.filterDate,y=a.preSelection,w=a.disabledKeyboardNavigation,C=a.disabled,N=(d||f||h||m||b||C)&&Hf(Bl(r,s),n.props),k=n.getSelection();return us("react-datepicker__quarter-text","react-datepicker__quarter-".concat(s),{"react-datepicker__quarter-text--disabled":N,"react-datepicker__quarter-text--selected":k?n.isSelectQuarterInList(r,s,k):void 0,"react-datepicker__quarter-text--keyboard-selected":!w&&y&&n.isSelectedQuarter(r,s,y)&&!n.isQuarterSelected()&&!N,"react-datepicker__quarter-text--in-selecting-range":n.isInSelectingRangeQuarter(s),"react-datepicker__quarter-text--in-range":i&&c?qf(i,c,s,r):void 0,"react-datepicker__quarter-text--range-start":n.isRangeStartQuarter(s),"react-datepicker__quarter-text--range-end":n.isRangeEndQuarter(s),"react-datepicker__quarter-text--today":n.isCurrentQuarter(r,s)})},n.getMonthContent=function(s){var a=n.props,r=a.showFullMonthYearPicker,i=a.renderMonthContent,c=a.locale,d=a.day,f=uT(s,c),h=Sy(s,c);return i?i(s,f,h,d):r?h:f},n.getQuarterContent=function(s){var a,r=n.props,i=r.renderQuarterContent,c=r.locale,d=FU(s,c);return(a=i==null?void 0:i(s,d))!==null&&a!==void 0?a:d},n.renderMonths=function(){var s,a=n.props,r=a.showTwoColumnMonthYearPicker,i=a.showFourColumnMonthYearPicker,c=a.day,d=a.selected,f=(s=vb[wA(i,r)])===null||s===void 0?void 0:s.grid;return f==null?void 0:f.map(function(h,m){return Ce.createElement("div",{className:"react-datepicker__month-wrapper",key:m},h.map(function(b,y){return Ce.createElement("div",{ref:n.MONTH_REFS[b],key:y,onClick:function(w){n.onMonthClick(w,b)},onKeyDown:function(w){mT(w)&&(w.preventDefault(),w.key=lt.Enter),n.onMonthKeyDown(w,b)},onMouseEnter:n.props.usePointerEvent?void 0:function(){return n.onMonthMouseEnter(b)},onPointerEnter:n.props.usePointerEvent?function(){return n.onMonthMouseEnter(b)}:void 0,tabIndex:Number(n.getTabIndex(b)),className:n.getMonthClassNames(b),"aria-disabled":n.isMonthDisabled(b),role:"option","aria-label":n.getAriaLabel(b),"aria-current":n.isCurrentMonth(c,b)?"date":void 0,"aria-selected":d?n.isSelectedMonth(c,b,d):void 0},n.getMonthContent(b))}))})},n.renderQuarters=function(){var s=n.props,a=s.day,r=s.selected,i=[1,2,3,4];return Ce.createElement("div",{className:"react-datepicker__quarter-wrapper"},i.map(function(c,d){return Ce.createElement("div",{key:d,ref:n.QUARTER_REFS[d],role:"option",onClick:function(f){n.onQuarterClick(f,c)},onKeyDown:function(f){n.onQuarterKeyDown(f,c)},onMouseEnter:n.props.usePointerEvent?void 0:function(){return n.onQuarterMouseEnter(c)},onPointerEnter:n.props.usePointerEvent?function(){return n.onQuarterMouseEnter(c)}:void 0,className:n.getQuarterClassNames(c),"aria-selected":r?n.isSelectedQuarter(a,c,r):void 0,tabIndex:Number(n.getQuarterTabIndex(c)),"aria-current":n.isCurrentQuarter(a,c)?"date":void 0},n.getQuarterContent(c))}))},n.getClassNames=function(){var s=n.props,a=s.selectingDate,r=s.selectsStart,i=s.selectsEnd,c=s.showMonthYearPicker,d=s.showQuarterYearPicker,f=s.showWeekPicker;return us("react-datepicker__month",{"react-datepicker__month--selecting-range":a&&(r||i)},{"react-datepicker__monthPicker":c},{"react-datepicker__quarterPicker":d},{"react-datepicker__weekPicker":f})},n}return e.prototype.getSelection=function(){var n=this.props,s=n.selected,a=n.selectedDates,r=n.selectsMultiple;if(r)return a;if(s)return[s]},e.prototype.render=function(){var n=this.props,s=n.showMonthYearPicker,a=n.showQuarterYearPicker,r=n.day,i=n.ariaLabelPrefix,c=i===void 0?"Month ":i,d=c?c.trim()+" ":"",f=Gs(r)?"".concat(d).concat(Bn(r,"MMMM, yyyy",this.props.locale)):"",h=s||a;return h?Ce.createElement("div",{className:this.getClassNames(),onMouseLeave:this.props.usePointerEvent?void 0:this.handleMouseLeave,onPointerLeave:this.props.usePointerEvent?this.handleMouseLeave:void 0,"aria-label":f,role:"listbox"},s?this.renderMonths():this.renderQuarters()):Ce.createElement("div",{role:"table"},this.props.dayNamesHeader&&Ce.createElement("div",{role:"rowgroup"},this.props.dayNamesHeader),this.props.monthHeader&&Ce.createElement("div",{role:"rowgroup"},this.props.monthHeader),Ce.createElement("div",{className:this.getClassNames(),onMouseLeave:this.props.usePointerEvent?void 0:this.handleMouseLeave,onPointerLeave:this.props.usePointerEvent?this.handleMouseLeave:void 0,"aria-label":f,role:"rowgroup"},this.renderWeeks()),this.props.monthFooter&&Ce.createElement("div",{role:"rowgroup"},this.props.monthFooter))},e})(x.Component),eH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.monthOptionButtonsRef={},n.isSelectedMonth=function(s){return n.props.month===s},n.handleOptionKeyDown=function(s,a){var r;switch(a.key){case"Enter":a.preventDefault(),n.onChange(s);break;case"Escape":a.preventDefault(),n.props.onCancel();break;case"ArrowUp":case"ArrowDown":{a.preventDefault();var i=(s+(a.key==="ArrowUp"?-1:1)+n.props.monthNames.length)%n.props.monthNames.length;(r=n.monthOptionButtonsRef[i])===null||r===void 0||r.focus();break}}},n.renderOptions=function(){return n.monthOptionButtonsRef={},n.props.monthNames.map(function(s,a){return Ce.createElement("div",{ref:function(r){n.monthOptionButtonsRef[a]=r,n.isSelectedMonth(a)&&(r==null||r.focus())},role:"button",tabIndex:0,className:n.isSelectedMonth(a)?"react-datepicker__month-option react-datepicker__month-option--selected_month":"react-datepicker__month-option",key:s,onClick:n.onChange.bind(n,a),onKeyDown:n.handleOptionKeyDown.bind(n,a),"aria-selected":n.isSelectedMonth(a)?"true":void 0},n.isSelectedMonth(a)?Ce.createElement("span",{className:"react-datepicker__month-option--selected"},"✓"):"",s)})},n.onChange=function(s){return n.props.onChange(s)},n.handleClickOutside=function(){return n.props.onCancel()},n}return e.prototype.render=function(){return Ce.createElement(fh,{className:"react-datepicker__month-dropdown",onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),tH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.state={dropdownVisible:!1},n.renderSelectOptions=function(s){return s.map(function(a,r){return Ce.createElement("option",{key:a,value:r},a)})},n.renderSelectMode=function(s){return Ce.createElement("select",{value:n.props.month,className:"react-datepicker__month-select",onChange:function(a){return n.onChange(parseInt(a.target.value))}},n.renderSelectOptions(s))},n.renderReadView=function(s,a){return Ce.createElement("button",{key:"read",type:"button",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__month-read-view",onClick:n.toggleDropdown},Ce.createElement("span",{className:"react-datepicker__month-read-view--down-arrow"}),Ce.createElement("span",{className:"react-datepicker__month-read-view--selected-month"},a[n.props.month]))},n.renderDropdown=function(s){return Ce.createElement(eH,qt({key:"dropdown"},n.props,{monthNames:s,onChange:n.onChange,onCancel:n.toggleDropdown}))},n.renderScrollMode=function(s){var a=n.state.dropdownVisible,r=[n.renderReadView(!a,s)];return a&&r.unshift(n.renderDropdown(s)),r},n.onChange=function(s){n.toggleDropdown(),s!==n.props.month&&n.props.onChange(s)},n.toggleDropdown=function(){return n.setState({dropdownVisible:!n.state.dropdownVisible})},n}return e.prototype.render=function(){var n=this,s=[0,1,2,3,4,5,6,7,8,9,10,11].map(this.props.useShortMonthInDropdown?function(r){return uT(r,n.props.locale)}:function(r){return Sy(r,n.props.locale)}),a;switch(this.props.dropdownMode){case"scroll":a=this.renderScrollMode(s);break;case"select":a=this.renderSelectMode(s);break}return Ce.createElement("div",{className:"react-datepicker__month-dropdown-container react-datepicker__month-dropdown-container--".concat(this.props.dropdownMode)},a)},e})(x.Component),kA=5;function nH(t,e,n){for(var s=[],a=t??Ri(n,kA),r=e??Ba(n,kA),i=Ur(a),c=Ur(r);!$r(i,c);)s.push(dn(i)),i=za(i,1);return s}var sH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.renderOptions=function(){return s.state.monthYearsList.map(function(a){var r=xx(a),i=Za(s.props.date,a)&&Es(s.props.date,a);return Ce.createElement("div",{className:i?"react-datepicker__month-year-option--selected_month-year":"react-datepicker__month-year-option",key:r,onClick:s.onChange.bind(s,r),"aria-selected":i?"true":void 0},i?Ce.createElement("span",{className:"react-datepicker__month-year-option--selected"},"✓"):"",Bn(a,s.props.dateFormat,s.props.locale))})},s.onChange=function(a){return s.props.onChange(a)},s.handleClickOutside=function(){s.props.onCancel()},s.state={monthYearsList:nH(s.props.minDate,s.props.maxDate,s.props.date)},s}return e.prototype.render=function(){var n=us({"react-datepicker__month-year-dropdown":!0,"react-datepicker__month-year-dropdown--scrollable":this.props.scrollableMonthYearDropdown});return Ce.createElement(fh,{className:n,onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),SA=5,aH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.state={dropdownVisible:!1},n.renderSelectOptions=function(){for(var s,a,r=(s=n.props.minDate)!==null&&s!==void 0?s:Ri(n.props.date,SA),i=(a=n.props.maxDate)!==null&&a!==void 0?a:Ba(n.props.date,SA),c=Ur(r),d=Ur(i),f=[];!$r(c,d);){var h=xx(c);f.push(Ce.createElement("option",{key:h,value:h},Bn(c,n.props.dateFormat,n.props.locale))),c=za(c,1)}return f},n.onSelectChange=function(s){n.onChange(parseInt(s.target.value))},n.renderSelectMode=function(){return Ce.createElement("select",{value:xx(Ur(n.props.date)),className:"react-datepicker__month-year-select",onChange:n.onSelectChange},n.renderSelectOptions())},n.renderReadView=function(s){var a=Bn(n.props.date,n.props.dateFormat,n.props.locale);return Ce.createElement("div",{key:"read",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__month-year-read-view",onClick:n.toggleDropdown},Ce.createElement("span",{className:"react-datepicker__month-year-read-view--down-arrow"}),Ce.createElement("span",{className:"react-datepicker__month-year-read-view--selected-month-year"},a))},n.renderDropdown=function(){return Ce.createElement(sH,qt({key:"dropdown"},n.props,{onChange:n.onChange,onCancel:n.toggleDropdown}))},n.renderScrollMode=function(){var s=n.state.dropdownVisible,a=[n.renderReadView(!s)];return s&&a.unshift(n.renderDropdown()),a},n.onChange=function(s){n.toggleDropdown();var a=dn(s);Za(n.props.date,a)&&Es(n.props.date,a)||n.props.onChange(a)},n.toggleDropdown=function(){return n.setState({dropdownVisible:!n.state.dropdownVisible})},n}return e.prototype.render=function(){var n;switch(this.props.dropdownMode){case"scroll":n=this.renderScrollMode();break;case"select":n=this.renderSelectMode();break}return Ce.createElement("div",{className:"react-datepicker__month-year-dropdown-container react-datepicker__month-year-dropdown-container--".concat(this.props.dropdownMode)},n)},e})(x.Component),rH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.state={height:null},n.scrollToTheSelectedTime=function(){requestAnimationFrame(function(){var s,a,r;n.list&&(n.list.scrollTop=(r=n.centerLi&&e.calcCenterPosition(n.props.monthRef?n.props.monthRef.clientHeight-((a=(s=n.header)===null||s===void 0?void 0:s.clientHeight)!==null&&a!==void 0?a:0):n.list.clientHeight,n.centerLi))!==null&&r!==void 0?r:0)})},n.handleClick=function(s){var a,r;(n.props.minTime||n.props.maxTime)&&pA(s,n.props)||(n.props.excludeTimes||n.props.includeTimes||n.props.filterTime)&&fA(s,n.props)||(r=(a=n.props).onChange)===null||r===void 0||r.call(a,s)},n.isSelectedTime=function(s){var a=So(n.props.selected);return a&&hT(a,s)},n.isDisabledTime=function(s){return(n.props.minTime||n.props.maxTime)&&pA(s,n.props)||(n.props.excludeTimes||n.props.includeTimes||n.props.filterTime)&&fA(s,n.props)},n.liClasses=function(s){var a,r=["react-datepicker__time-list-item",n.props.timeClassName?n.props.timeClassName(s):void 0];return n.isSelectedTime(s)&&r.push("react-datepicker__time-list-item--selected"),n.isDisabledTime(s)&&r.push("react-datepicker__time-list-item--disabled"),n.props.injectTimes&&(Cs(s)*3600+As(s)*60+Ei(s))%(((a=n.props.intervals)!==null&&a!==void 0?a:e.defaultProps.intervals)*60)!==0&&r.push("react-datepicker__time-list-item--injected"),r.join(" ")},n.handleOnKeyDown=function(s,a){var r,i;s.key===lt.Space&&(s.preventDefault(),s.key=lt.Enter),(s.key===lt.ArrowUp||s.key===lt.ArrowLeft)&&s.target instanceof HTMLElement&&s.target.previousSibling&&(s.preventDefault(),s.target.previousSibling instanceof HTMLElement&&s.target.previousSibling.focus()),(s.key===lt.ArrowDown||s.key===lt.ArrowRight)&&s.target instanceof HTMLElement&&s.target.nextSibling&&(s.preventDefault(),s.target.nextSibling instanceof HTMLElement&&s.target.nextSibling.focus()),s.key===lt.Enter&&n.handleClick(a),(i=(r=n.props).handleOnKeyDown)===null||i===void 0||i.call(r,s)},n.renderTimes=function(){for(var s,a=[],r=typeof n.props.format=="string"?n.props.format:"p",i=(s=n.props.intervals)!==null&&s!==void 0?s:e.defaultProps.intervals,c=So(n.props.selected)||So(n.props.openToDate)||dn(),d=wu(c),f=n.props.injectTimes&&n.props.injectTimes.sort(function(N,k){return N.getTime()-k.getTime()}),h=60*GU(c),m=h/i,b=0;b<m;b++){var y=Gu(d,b*i);if(a.push(y),f){var w=YU(d,y,b,i,f);a=a.concat(w)}}var C=a.reduce(function(N,k){return k.getTime()<=c.getTime()?k:N},a[0]);return a.map(function(N){return Ce.createElement("li",{key:N.valueOf(),onClick:n.handleClick.bind(n,N),className:n.liClasses(N),ref:function(k){N===C&&(n.centerLi=k)},onKeyDown:function(k){n.handleOnKeyDown(k,N)},tabIndex:N===C?0:-1,role:"option","aria-selected":n.isSelectedTime(N)?"true":void 0,"aria-disabled":n.isDisabledTime(N)?"true":void 0},Bn(N,r,n.props.locale))})},n.renderTimeCaption=function(){return n.props.showTimeCaption===!1?Ce.createElement(Ce.Fragment,null):Ce.createElement("div",{className:"react-datepicker__header react-datepicker__header--time ".concat(n.props.showTimeSelectOnly?"react-datepicker__header--time--only":""),ref:function(s){n.header=s}},Ce.createElement("div",{className:"react-datepicker-time__header"},n.props.timeCaption))},n}return Object.defineProperty(e,"defaultProps",{get:function(){return{intervals:30,todayButton:null,timeCaption:"Time",showTimeCaption:!0}},enumerable:!1,configurable:!0}),e.prototype.componentDidMount=function(){this.scrollToTheSelectedTime(),this.observeDatePickerHeightChanges()},e.prototype.componentWillUnmount=function(){var n;(n=this.resizeObserver)===null||n===void 0||n.disconnect()},e.prototype.observeDatePickerHeightChanges=function(){var n=this,s=this.props.monthRef;this.updateContainerHeight(),s&&(this.resizeObserver=new ResizeObserver(function(){n.updateContainerHeight()}),this.resizeObserver.observe(s))},e.prototype.updateContainerHeight=function(){if(this.props.monthRef&&this.header){var n=this.props.monthRef.clientHeight-this.header.clientHeight;this.state.height!==n&&this.setState({height:n})}},e.prototype.render=function(){var n=this,s,a=this.state.height;return Ce.createElement("div",{className:"react-datepicker__time-container ".concat(((s=this.props.todayButton)!==null&&s!==void 0?s:e.defaultProps.todayButton)?"react-datepicker__time-container--with-today-button":"")},this.renderTimeCaption(),Ce.createElement("div",{className:"react-datepicker__time"},Ce.createElement("div",{className:"react-datepicker__time-box"},Ce.createElement("ul",{className:"react-datepicker__time-list",ref:function(r){n.list=r},style:a?{height:a}:{},role:"listbox","aria-label":this.props.timeCaption},this.renderTimes()))))},e.calcCenterPosition=function(n,s){return s.offsetTop-(n/2-s.clientHeight/2)},e})(x.Component),CA=3,iH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.YEAR_REFS=rr([],Array(s.props.yearItemNumber),!0).map(function(){return x.createRef()}),s.isDisabled=function(a){return ja(a,{minDate:s.props.minDate,maxDate:s.props.maxDate,excludeDates:s.props.excludeDates,includeDates:s.props.includeDates,filterDate:s.props.filterDate})},s.isExcluded=function(a){return Cy(a,{excludeDates:s.props.excludeDates})},s.selectingDate=function(){var a;return(a=s.props.selectingDate)!==null&&a!==void 0?a:s.props.preSelection},s.updateFocusOnPaginate=function(a){var r=function(){var i,c;(c=(i=s.YEAR_REFS[a])===null||i===void 0?void 0:i.current)===null||c===void 0||c.focus()};window.requestAnimationFrame(r)},s.handleYearClick=function(a,r){s.props.onDayClick&&s.props.onDayClick(a,r)},s.handleYearNavigation=function(a,r){var i,c,d,f,h=s.props,m=h.date,b=h.yearItemNumber;if(!(m===void 0||b===void 0)){var y=Pr(m,b).startPeriod;s.isDisabled(r)||s.isExcluded(r)||((c=(i=s.props).setPreSelection)===null||c===void 0||c.call(i,r),a-y<0?s.updateFocusOnPaginate(b-(y-a)):a-y>=b?s.updateFocusOnPaginate(Math.abs(b-(a-y))):(f=(d=s.YEAR_REFS[a-y])===null||d===void 0?void 0:d.current)===null||f===void 0||f.focus())}},s.isSameDay=function(a,r){return on(a,r)},s.isCurrentYear=function(a){return a===Zt(dn())},s.isRangeStart=function(a){return s.props.startDate&&s.props.endDate&&Za(Ja(dn(),a),s.props.startDate)},s.isRangeEnd=function(a){return s.props.startDate&&s.props.endDate&&Za(Ja(dn(),a),s.props.endDate)},s.isInRange=function(a){return Wf(a,s.props.startDate,s.props.endDate)},s.isInSelectingRange=function(a){var r=s.props,i=r.selectsStart,c=r.selectsEnd,d=r.selectsRange,f=r.startDate,h=r.endDate;return!(i||c||d)||!s.selectingDate()?!1:i&&h?Wf(a,s.selectingDate(),h):c&&f||d&&f&&!h?Wf(a,f,s.selectingDate()):!1},s.isSelectingRangeStart=function(a){var r;if(!s.isInSelectingRange(a))return!1;var i=s.props,c=i.startDate,d=i.selectsStart,f=Ja(dn(),a);return d?Za(f,(r=s.selectingDate())!==null&&r!==void 0?r:null):Za(f,c??null)},s.isSelectingRangeEnd=function(a){var r;if(!s.isInSelectingRange(a))return!1;var i=s.props,c=i.endDate,d=i.selectsEnd,f=i.selectsRange,h=Ja(dn(),a);return d||f?Za(h,(r=s.selectingDate())!==null&&r!==void 0?r:null):Za(h,c??null)},s.isKeyboardSelected=function(a){if(!(s.props.disabledKeyboardNavigation||s.props.date===void 0||s.props.preSelection==null)){var r=s.props,i=r.minDate,c=r.maxDate,d=r.excludeDates,f=r.includeDates,h=r.filterDate,m=r.selected,b=ku(Ja(s.props.date,a)),y=(i||c||d||f||h)&&op(a,s.props),w=!!m&&on(b,ku(m)),C=on(b,ku(s.props.preSelection));return!s.props.inline&&!w&&C&&!y}},s.isSelectedYear=function(a){var r=s.props,i=r.selectsMultiple,c=r.selected,d=r.selectedDates;return i?d==null?void 0:d.some(function(f){return a===Zt(f)}):!!c&&a===Zt(c)},s.onYearClick=function(a,r){var i=s.props.date;i!==void 0&&s.handleYearClick(ku(Ja(i,r)),a)},s.onYearKeyDown=function(a,r){var i,c,d=a.key,f=s.props,h=f.date,m=f.yearItemNumber,b=f.handleOnKeyDown;if(d!==lt.Tab&&a.preventDefault(),!s.props.disabledKeyboardNavigation)switch(d){case lt.Enter:if(s.props.selected==null)break;s.onYearClick(a,r),(c=(i=s.props).setPreSelection)===null||c===void 0||c.call(i,s.props.selected);break;case lt.ArrowRight:if(s.props.preSelection==null)break;s.handleYearNavigation(r+1,Ba(s.props.preSelection,1));break;case lt.ArrowLeft:if(s.props.preSelection==null)break;s.handleYearNavigation(r-1,Ri(s.props.preSelection,1));break;case lt.ArrowUp:{if(h===void 0||m===void 0||s.props.preSelection==null)break;var y=Pr(h,m).startPeriod,w=CA,C=r-w;if(C<y){var N=m%w;r>=y&&r<y+N?w=N:w+=N,C=r-w}s.handleYearNavigation(C,Ri(s.props.preSelection,w));break}case lt.ArrowDown:{if(h===void 0||m===void 0||s.props.preSelection==null)break;var k=Pr(h,m).endPeriod,w=CA,C=r+w;if(C>k){var N=m%w;r<=k&&r>k-N?w=N:w+=N,C=r+w}s.handleYearNavigation(C,Ba(s.props.preSelection,w));break}}b&&b(a)},s.getYearClassNames=function(a){var r=s.props,i=r.date,c=r.disabled,d=r.minDate,f=r.maxDate,h=r.excludeDates,m=r.includeDates,b=r.filterDate,y=r.yearClassName;return us("react-datepicker__year-text","react-datepicker__year-".concat(a),i?y==null?void 0:y(Ja(i,a)):void 0,{"react-datepicker__year-text--selected":s.isSelectedYear(a),"react-datepicker__year-text--disabled":(d||f||h||m||b||c)&&op(a,s.props),"react-datepicker__year-text--keyboard-selected":s.isKeyboardSelected(a),"react-datepicker__year-text--range-start":s.isRangeStart(a),"react-datepicker__year-text--range-end":s.isRangeEnd(a),"react-datepicker__year-text--in-range":s.isInRange(a),"react-datepicker__year-text--in-selecting-range":s.isInSelectingRange(a),"react-datepicker__year-text--selecting-range-start":s.isSelectingRangeStart(a),"react-datepicker__year-text--selecting-range-end":s.isSelectingRangeEnd(a),"react-datepicker__year-text--today":s.isCurrentYear(a)})},s.getYearTabIndex=function(a){if(s.props.disabledKeyboardNavigation||s.props.preSelection==null)return"-1";var r=Zt(s.props.preSelection),i=op(a,s.props);return a===r&&!i?"0":"-1"},s.getYearContent=function(a){return s.props.renderYearContent?s.props.renderYearContent(a):a},s}return e.prototype.render=function(){var n=this,s=[],a=this.props,r=a.date,i=a.yearItemNumber,c=a.onYearMouseEnter,d=a.onYearMouseLeave;if(r===void 0)return null;for(var f=Pr(r,i),h=f.startPeriod,m=f.endPeriod,b=function(C){s.push(Ce.createElement("div",{ref:y.YEAR_REFS[C-h],onClick:function(N){n.onYearClick(N,C)},onKeyDown:function(N){mT(N)&&(N.preventDefault(),N.key=lt.Enter),n.onYearKeyDown(N,C)},tabIndex:Number(y.getYearTabIndex(C)),className:y.getYearClassNames(C),onMouseEnter:y.props.usePointerEvent?void 0:function(N){return c(N,C)},onPointerEnter:y.props.usePointerEvent?function(N){return c(N,C)}:void 0,onMouseLeave:y.props.usePointerEvent?void 0:function(N){return d(N,C)},onPointerLeave:y.props.usePointerEvent?function(N){return d(N,C)}:void 0,key:C,"aria-current":y.isCurrentYear(C)?"date":void 0},y.getYearContent(C)))},y=this,w=h;w<=m;w++)b(w);return Ce.createElement("div",{className:"react-datepicker__year"},Ce.createElement("div",{className:"react-datepicker__year-wrapper",onMouseLeave:this.props.usePointerEvent?void 0:this.props.clearSelectingDate,onPointerLeave:this.props.usePointerEvent?this.props.clearSelectingDate:void 0},s))},e})(x.Component);function oH(t,e,n,s){for(var a=[],r=0;r<2*e+1;r++){var i=t+e-r,c=!0;n&&(c=Zt(n)<=i),s&&c&&(c=Zt(s)>=i),c&&a.push(i)}return a}var lH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;s.yearOptionButtonsRef={},s.handleOptionKeyDown=function(c,d){var f;switch(d.key){case"Enter":d.preventDefault(),s.onChange(c);break;case"Escape":d.preventDefault(),s.props.onCancel();break;case"ArrowUp":case"ArrowDown":{d.preventDefault();var h=c+(d.key==="ArrowUp"?1:-1);s.yearOptionButtonsRef[h]&&((f=s.yearOptionButtonsRef[h])===null||f===void 0||f.focus());break}}},s.renderOptions=function(){s.yearOptionButtonsRef={};var c=s.props.year,d=s.state.yearsList.map(function(m){return Ce.createElement("div",{ref:function(b){s.yearOptionButtonsRef[m]=b,m===c&&(b==null||b.focus())},role:"button",tabIndex:0,className:c===m?"react-datepicker__year-option react-datepicker__year-option--selected_year":"react-datepicker__year-option",key:m,onClick:s.onChange.bind(s,m),onKeyDown:s.handleOptionKeyDown.bind(s,m),"aria-selected":c===m?"true":void 0},c===m?Ce.createElement("span",{className:"react-datepicker__year-option--selected"},"✓"):"",m)}),f=s.props.minDate?Zt(s.props.minDate):null,h=s.props.maxDate?Zt(s.props.maxDate):null;return(!h||!s.state.yearsList.find(function(m){return m===h}))&&d.unshift(Ce.createElement("div",{className:"react-datepicker__year-option",key:"upcoming",onClick:s.incrementYears},Ce.createElement("a",{className:"react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-upcoming"}))),(!f||!s.state.yearsList.find(function(m){return m===f}))&&d.push(Ce.createElement("div",{className:"react-datepicker__year-option",key:"previous",onClick:s.decrementYears},Ce.createElement("a",{className:"react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-previous"}))),d},s.onChange=function(c){s.props.onChange(c)},s.handleClickOutside=function(){s.props.onCancel()},s.shiftYears=function(c){var d=s.state.yearsList.map(function(f){return f+c});s.setState({yearsList:d})},s.incrementYears=function(){return s.shiftYears(1)},s.decrementYears=function(){return s.shiftYears(-1)};var a=n.yearDropdownItemNumber,r=n.scrollableYearDropdown,i=a||(r?10:5);return s.state={yearsList:oH(s.props.year,i,s.props.minDate,s.props.maxDate)},s.dropdownRef=x.createRef(),s}return e.prototype.componentDidMount=function(){var n=this.dropdownRef.current;if(n){var s=n.children?Array.from(n.children):null,a=s?s.find(function(r){return r.ariaSelected}):null;n.scrollTop=a&&a instanceof HTMLElement?a.offsetTop+(a.clientHeight-n.clientHeight)/2:(n.scrollHeight-n.clientHeight)/2}},e.prototype.render=function(){var n=us({"react-datepicker__year-dropdown":!0,"react-datepicker__year-dropdown--scrollable":this.props.scrollableYearDropdown});return Ce.createElement(fh,{className:n,containerRef:this.dropdownRef,onClickOutside:this.handleClickOutside},this.renderOptions())},e})(x.Component),cH=(function(t){ws(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.state={dropdownVisible:!1},n.renderSelectOptions=function(){for(var s=n.props.minDate?Zt(n.props.minDate):1900,a=n.props.maxDate?Zt(n.props.maxDate):2100,r=[],i=s;i<=a;i++)r.push(Ce.createElement("option",{key:i,value:i},i));return r},n.onSelectChange=function(s){n.onChange(parseInt(s.target.value))},n.renderSelectMode=function(){return Ce.createElement("select",{value:n.props.year,className:"react-datepicker__year-select",onChange:n.onSelectChange},n.renderSelectOptions())},n.renderReadView=function(s){return Ce.createElement("button",{key:"read",type:"button",style:{visibility:s?"visible":"hidden"},className:"react-datepicker__year-read-view",onClick:n.toggleDropdown},Ce.createElement("span",{className:"react-datepicker__year-read-view--down-arrow"}),Ce.createElement("span",{className:"react-datepicker__year-read-view--selected-year"},n.props.year))},n.renderDropdown=function(){return Ce.createElement(lH,qt({key:"dropdown"},n.props,{onChange:n.onChange,onCancel:n.toggleDropdown}))},n.renderScrollMode=function(){var s=n.state.dropdownVisible,a=[n.renderReadView(!s)];return s&&a.unshift(n.renderDropdown()),a},n.onChange=function(s){n.toggleDropdown(),s!==n.props.year&&n.props.onChange(s)},n.toggleDropdown=function(s){n.setState({dropdownVisible:!n.state.dropdownVisible},function(){n.props.adjustDateOnChange&&n.handleYearChange(n.props.date,s)})},n.handleYearChange=function(s,a){var r;(r=n.onSelect)===null||r===void 0||r.call(n,s,a),n.setOpen()},n.onSelect=function(s,a){var r,i;(i=(r=n.props).onSelect)===null||i===void 0||i.call(r,s,a)},n.setOpen=function(){var s,a;(a=(s=n.props).setOpen)===null||a===void 0||a.call(s,!0)},n}return e.prototype.render=function(){var n;switch(this.props.dropdownMode){case"scroll":n=this.renderScrollMode();break;case"select":n=this.renderSelectMode();break}return Ce.createElement("div",{className:"react-datepicker__year-dropdown-container react-datepicker__year-dropdown-container--".concat(this.props.dropdownMode)},n)},e})(x.Component),uH=["react-datepicker__year-select","react-datepicker__month-select","react-datepicker__month-year-select"],gT="react-datepicker-ignore-onclickoutside",dH=function(t){var e=(t.className||"").split(/\s+/);return uH.some(function(n){return e.indexOf(n)>=0})},fH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.monthContainer=void 0,s.handleClickOutside=function(a){s.props.onClickOutside(a)},s.setClickOutsideRef=function(){return s.containerRef.current},s.handleDropdownFocus=function(a){var r,i;dH(a.target)&&((i=(r=s.props).onDropdownFocus)===null||i===void 0||i.call(r,a))},s.getDateInView=function(){var a=s.props,r=a.preSelection,i=a.selected,c=a.openToDate,d=fT(s.props),f=pT(s.props),h=dn(),m=c||i||r;return m||(d&&ar(h,d)?d:f&&$r(h,f)?f:h)},s.increaseMonth=function(){s.setState(function(a){var r=a.date;return{date:za(r,1)}},function(){return s.handleMonthChange(s.state.date)})},s.decreaseMonth=function(){s.setState(function(a){var r=a.date;return{date:Ao(r,1)}},function(){return s.handleMonthChange(s.state.date)})},s.handleDayClick=function(a,r,i){s.props.onSelect(a,r,i),s.props.setPreSelection&&s.props.setPreSelection(a)},s.handleDayMouseEnter=function(a){s.setState({selectingDate:a}),s.props.onDayMouseEnter&&s.props.onDayMouseEnter(a)},s.handleMonthMouseLeave=function(){s.setState({selectingDate:void 0}),s.props.onMonthMouseLeave&&s.props.onMonthMouseLeave()},s.handleYearMouseEnter=function(a,r){s.setState({selectingDate:Ja(dn(),r)}),s.props.onYearMouseEnter&&s.props.onYearMouseEnter(a,r)},s.handleYearMouseLeave=function(a,r){s.props.onYearMouseLeave&&s.props.onYearMouseLeave(a,r)},s.handleYearChange=function(a){var r,i,c,d;(i=(r=s.props).onYearChange)===null||i===void 0||i.call(r,a),s.setState({isRenderAriaLiveMessage:!0}),s.props.adjustDateOnChange&&(s.props.onSelect(a),(d=(c=s.props).setOpen)===null||d===void 0||d.call(c,!0)),s.props.setPreSelection&&s.props.setPreSelection(a)},s.getEnabledPreSelectionDateForMonth=function(a){if(!ja(a,s.props))return a;for(var r=Ur(a),i=LU(a),c=J4(i,r),d=null,f=0;f<=c;f++){var h=Pa(r,f);if(!ja(h,s.props)){d=h;break}}return d},s.handleMonthChange=function(a){var r,i,c,d=(r=s.getEnabledPreSelectionDateForMonth(a))!==null&&r!==void 0?r:a;s.handleCustomMonthChange(d),s.props.adjustDateOnChange&&(s.props.onSelect(d),(c=(i=s.props).setOpen)===null||c===void 0||c.call(i,!0)),s.props.setPreSelection&&s.props.setPreSelection(d)},s.handleCustomMonthChange=function(a){var r,i;(i=(r=s.props).onMonthChange)===null||i===void 0||i.call(r,a),s.setState({isRenderAriaLiveMessage:!0})},s.handleMonthYearChange=function(a){s.handleYearChange(a),s.handleMonthChange(a)},s.changeYear=function(a){s.setState(function(r){var i=r.date;return{date:Ja(i,Number(a))}},function(){return s.handleYearChange(s.state.date)})},s.changeMonth=function(a){s.setState(function(r){var i=r.date;return{date:oa(i,Number(a))}},function(){var r,i;s.handleMonthChange(s.state.date),(i=(r=s.props).onMonthSelectedInChange)===null||i===void 0||i.call(r,0)})},s.changeMonthYear=function(a){s.setState(function(r){var i=r.date;return{date:Ja(oa(i,Ks(a)),Zt(a))}},function(){return s.handleMonthYearChange(s.state.date)})},s.header=function(a,r){if(a===void 0&&(a=s.state.date),r===void 0&&(r=0),!Gs(a))return[];var i=s.props.disabled,c=Mi(a,s.props.locale,s.props.calendarStartDay),d=[];return s.props.showWeekNumbers&&d.push(Ce.createElement("div",{key:"W",className:"react-datepicker__day-name ".concat(i?"react-datepicker__day-name--disabled":""),role:"columnheader"},Ce.createElement("span",{className:"react-datepicker__sr-only"},"Week number"),Ce.createElement("span",{"aria-hidden":"true"},s.props.weekLabel||"#"))),d.concat([0,1,2,3,4,5,6].map(function(f){var h=Pa(c,f),m=s.formatWeekday(h,s.props.locale),b=Bn(h,"EEEE",s.props.locale),y=s.props.weekDayClassName?s.props.weekDayClassName(h):void 0;if(s.props.renderCustomDayName){var w=s.props.renderCustomDayName({day:h,shortName:m,fullName:b,locale:s.props.locale,customDayNameCount:r});return Ce.createElement("div",{key:f,role:"columnheader",className:us("react-datepicker__day-name",y,i?"react-datepicker__day-name--disabled":"")},w)}return Ce.createElement("div",{key:f,role:"columnheader",className:us("react-datepicker__day-name",y,i?"react-datepicker__day-name--disabled":"")},Ce.createElement("span",{className:"react-datepicker__sr-only"},b),Ce.createElement("span",{"aria-hidden":"true"},m))}))},s.formatWeekday=function(a,r){return s.props.formatWeekDay?IU(a,s.props.formatWeekDay,r):s.props.useWeekdaysShort?BU(a,r):PU(a,r)},s.decreaseYear=function(){s.setState(function(a){var r,i=a.date;return{date:Ri(i,s.props.showYearPicker?(r=s.props.yearItemNumber)!==null&&r!==void 0?r:e.defaultProps.yearItemNumber:1)}},function(){return s.handleYearChange(s.state.date)})},s.clearSelectingDate=function(){s.setState({selectingDate:void 0})},s.renderPreviousButton=function(){var a,r,i;if(!s.props.renderCustomHeader){var c=(a=s.props.monthsShown)!==null&&a!==void 0?a:e.defaultProps.monthsShown,d=s.props.showPreviousMonths?c-1:0,f=(r=s.props.monthSelectedIn)!==null&&r!==void 0?r:d,h=Ao(s.state.date,f),m;switch(!0){case s.props.disabled:m=!0;break;case s.props.showMonthYearPicker:m=gA(s.state.date,s.props);break;case s.props.showYearPicker:m=HU(s.state.date,s.props);break;case s.props.showQuarterYearPicker:m=$U(s.state.date,s.props);break;default:m=hA(h,s.props);break}if(!(!((i=s.props.forceShowMonthNavigation)!==null&&i!==void 0?i:e.defaultProps.forceShowMonthNavigation)&&!s.props.showDisabledMonthNavigation&&m||s.props.showTimeSelectOnly)){var b=["react-datepicker__navigation-icon","react-datepicker__navigation-icon--previous"],y=["react-datepicker__navigation","react-datepicker__navigation--previous"],w=s.decreaseMonth;(s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker)&&(w=s.decreaseYear),m&&s.props.showDisabledMonthNavigation&&(y.push("react-datepicker__navigation--previous--disabled"),w=void 0);var C=s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker,N=s.props,k=N.previousMonthButtonLabel,j=k===void 0?e.defaultProps.previousMonthButtonLabel:k,S=N.previousYearButtonLabel,T=S===void 0?e.defaultProps.previousYearButtonLabel:S,D=s.props,E=D.previousMonthAriaLabel,I=E===void 0?typeof j=="string"?j:"Previous Month":E,O=D.previousYearAriaLabel,_=O===void 0?typeof T=="string"?T:"Previous Year":O;return Ce.createElement("button",{type:"button",className:y.join(" "),onClick:w,onKeyDown:s.props.handleOnKeyDown,"aria-label":C?_:I},Ce.createElement("span",{className:b.join(" ")},C?T:j))}}},s.increaseYear=function(){s.setState(function(a){var r,i=a.date;return{date:Ba(i,s.props.showYearPicker?(r=s.props.yearItemNumber)!==null&&r!==void 0?r:e.defaultProps.yearItemNumber:1)}},function(){return s.handleYearChange(s.state.date)})},s.renderNextButton=function(){var a;if(!s.props.renderCustomHeader){var r;switch(!0){case s.props.disabled:r=!0;break;case s.props.showMonthYearPicker:r=bA(s.state.date,s.props);break;case s.props.showYearPicker:r=WU(s.state.date,s.props);break;case s.props.showQuarterYearPicker:r=UU(s.state.date,s.props);break;default:r=mA(s.state.date,s.props);break}if(!(!((a=s.props.forceShowMonthNavigation)!==null&&a!==void 0?a:e.defaultProps.forceShowMonthNavigation)&&!s.props.showDisabledMonthNavigation&&r||s.props.showTimeSelectOnly)){var i=["react-datepicker__navigation","react-datepicker__navigation--next"],c=["react-datepicker__navigation-icon","react-datepicker__navigation-icon--next"];s.props.showTimeSelect&&i.push("react-datepicker__navigation--next--with-time"),s.props.todayButton&&i.push("react-datepicker__navigation--next--with-today-button");var d=s.increaseMonth;(s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker)&&(d=s.increaseYear),r&&s.props.showDisabledMonthNavigation&&(i.push("react-datepicker__navigation--next--disabled"),d=void 0);var f=s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker,h=s.props,m=h.nextMonthButtonLabel,b=m===void 0?e.defaultProps.nextMonthButtonLabel:m,y=h.nextYearButtonLabel,w=y===void 0?e.defaultProps.nextYearButtonLabel:y,C=s.props,N=C.nextMonthAriaLabel,k=N===void 0?typeof b=="string"?b:"Next Month":N,j=C.nextYearAriaLabel,S=j===void 0?typeof w=="string"?w:"Next Year":j;return Ce.createElement("button",{type:"button",className:i.join(" "),onClick:d,onKeyDown:s.props.handleOnKeyDown,"aria-label":f?S:k},Ce.createElement("span",{className:c.join(" ")},f?w:b))}}},s.renderCurrentMonth=function(a){a===void 0&&(a=s.state.date);var r=["react-datepicker__current-month"];return s.props.showYearDropdown&&r.push("react-datepicker__current-month--hasYearDropdown"),s.props.showMonthDropdown&&r.push("react-datepicker__current-month--hasMonthDropdown"),s.props.showMonthYearDropdown&&r.push("react-datepicker__current-month--hasMonthYearDropdown"),Ce.createElement("h2",{className:r.join(" ")},Gs(a)?Bn(a,s.props.dateFormat,s.props.locale):"")},s.renderYearDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showYearDropdown||a))return Ce.createElement(cH,qt({},e.defaultProps,s.props,{date:s.state.date,onChange:s.changeYear,year:Zt(s.state.date)}))},s.renderMonthDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showMonthDropdown||a))return Ce.createElement(tH,qt({},e.defaultProps,s.props,{month:Ks(s.state.date),onChange:s.changeMonth}))},s.renderMonthYearDropdown=function(a){if(a===void 0&&(a=!1),!(!s.props.showMonthYearDropdown||a))return Ce.createElement(aH,qt({},e.defaultProps,s.props,{date:s.state.date,onChange:s.changeMonthYear}))},s.handleTodayButtonClick=function(a){s.props.onSelect(cA(),a),s.props.setPreSelection&&s.props.setPreSelection(cA())},s.renderTodayButton=function(){if(!(!s.props.todayButton||s.props.showTimeSelectOnly))return Ce.createElement("div",{className:"react-datepicker__today-button",onClick:s.handleTodayButtonClick},s.props.todayButton)},s.renderDayNamesHeader=function(a,r){return r===void 0&&(r=0),Ce.createElement("div",{className:"react-datepicker__day-names",role:"row"},s.header(a,r))},s.renderDefaultHeader=function(a){var r=a.monthDate,i=a.i,c=Ce.createElement("div",{className:us("react-datepicker__header",{"react-datepicker__header--has-time-select":s.props.showTimeSelect,"react-datepicker__header--middle":s.props.monthHeaderPosition==="middle","react-datepicker__header--bottom":s.props.monthHeaderPosition==="bottom"})},s.renderCurrentMonth(r),Ce.createElement("div",{className:"react-datepicker__header__dropdown react-datepicker__header__dropdown--".concat(s.props.dropdownMode),onFocus:s.handleDropdownFocus},s.renderMonthDropdown(i!==0),s.renderMonthYearDropdown(i!==0),s.renderYearDropdown(i!==0)));return s.props.monthHeaderPosition==="top"?c:Ce.createElement("div",{className:"react-datepicker__header-wrapper"},s.renderPreviousButton()||null,s.renderNextButton()||null,c)},s.renderCustomHeader=function(a){var r,i,c=a.monthDate,d=a.i;if(s.props.showTimeSelect&&!s.state.monthContainer||s.props.showTimeSelectOnly)return null;var f=s.props,h=f.showYearPicker,m=f.yearItemNumber,b;if(h){var y=Pr(c,m),w=y.startPeriod,C=y.endPeriod;b={startYear:w,endYear:C}}var N=hA(s.state.date,s.props),k=mA(s.state.date,s.props),j=gA(s.state.date,s.props),S=bA(s.state.date,s.props);return Ce.createElement("div",{className:"react-datepicker__header react-datepicker__header--custom",onFocus:s.props.onDropdownFocus},(i=(r=s.props).renderCustomHeader)===null||i===void 0?void 0:i.call(r,qt(qt(qt({},s.state),h&&{visibleYearsRange:b}),{customHeaderCount:d,monthDate:c,changeMonth:s.changeMonth,changeYear:s.changeYear,decreaseMonth:s.decreaseMonth,increaseMonth:s.increaseMonth,decreaseYear:s.decreaseYear,increaseYear:s.increaseYear,prevMonthButtonDisabled:N,nextMonthButtonDisabled:k,prevYearButtonDisabled:j,nextYearButtonDisabled:S})))},s.renderYearHeader=function(a){var r=a.monthDate,i=s.props,c=i.showYearPicker,d=i.yearItemNumber,f=d===void 0?e.defaultProps.yearItemNumber:d,h=Pr(r,f),m=h.startPeriod,b=h.endPeriod;return Ce.createElement("div",{className:"react-datepicker__header react-datepicker-year-header"},c?"".concat(m," - ").concat(b):Zt(r))},s.renderHeader=function(a){var r=a.monthDate,i=a.i,c=i===void 0?0:i,d={monthDate:r,i:c};switch(!0){case s.props.renderCustomHeader!==void 0:return s.renderCustomHeader(d);case(s.props.showMonthYearPicker||s.props.showQuarterYearPicker||s.props.showYearPicker):return s.renderYearHeader(d);default:return s.renderDefaultHeader(d)}},s.renderMonths=function(){var a,r;if(!(s.props.showTimeSelectOnly||s.props.showYearPicker)){for(var i=[],c=(a=s.props.monthsShown)!==null&&a!==void 0?a:e.defaultProps.monthsShown,d=s.props.showPreviousMonths?c-1:0,f=s.props.showMonthYearPicker||s.props.showQuarterYearPicker?Ba(s.state.date,d):Ao(s.state.date,d),h=(r=s.props.monthSelectedIn)!==null&&r!==void 0?r:d,m=0;m<c;++m){var b=m-h+d,y=s.props.showMonthYearPicker||s.props.showQuarterYearPicker?Ba(f,b):za(f,b),w="month-".concat(m),C=m<c-1,N=m>0;i.push(Ce.createElement("div",{key:w,ref:function(k){s.monthContainer=k??void 0},className:"react-datepicker__month-container"},s.props.monthHeaderPosition==="top"&&s.renderHeader({monthDate:y,i:m}),Ce.createElement(ZU,qt({},e.defaultProps,s.props,{containerRef:s.containerRef,ariaLabelPrefix:s.props.monthAriaLabelPrefix,day:y,onDayClick:s.handleDayClick,handleOnKeyDown:s.props.handleOnDayKeyDown,handleOnMonthKeyDown:s.props.handleOnKeyDown,onDayMouseEnter:s.handleDayMouseEnter,onMouseLeave:s.handleMonthMouseLeave,orderInDisplay:m,selectingDate:s.state.selectingDate,monthShowsDuplicateDaysEnd:C,monthShowsDuplicateDaysStart:N,dayNamesHeader:s.renderDayNamesHeader(y,m),monthHeader:s.props.monthHeaderPosition==="middle"?s.renderHeader({monthDate:y,i:m}):void 0,monthFooter:s.props.monthHeaderPosition==="bottom"?s.renderHeader({monthDate:y,i:m}):void 0}))))}return i}},s.renderYears=function(){if(!s.props.showTimeSelectOnly&&s.props.showYearPicker)return Ce.createElement("div",{className:"react-datepicker__year--container"},s.renderHeader({monthDate:s.state.date}),Ce.createElement(iH,qt({},e.defaultProps,s.props,{selectingDate:s.state.selectingDate,date:s.state.date,onDayClick:s.handleDayClick,clearSelectingDate:s.clearSelectingDate,onYearMouseEnter:s.handleYearMouseEnter,onYearMouseLeave:s.handleYearMouseLeave})))},s.renderTimeSection=function(){if(s.props.showTimeSelect&&(s.state.monthContainer||s.props.showTimeSelectOnly))return Ce.createElement(rH,qt({},e.defaultProps,s.props,{onChange:s.props.onTimeChange,format:s.props.timeFormat,intervals:s.props.timeIntervals,monthRef:s.state.monthContainer}))},s.renderInputTimeSection=function(){var a,r;if(s.props.showTimeInput){if(s.props.selectsRange){var i=s.props,c=i.startDate,d=i.endDate,f=c?new Date(c):void 0,h=f&&Gs(f)&&!!c,m=h?"".concat(Rl(f.getHours()),":").concat(Rl(f.getMinutes())):"",b=d?new Date(d):void 0,y=b&&Gs(b)&&!!d,w=y?"".concat(Rl(b.getHours()),":").concat(Rl(b.getMinutes())):"";return Ce.createElement(Ce.Fragment,null,Ce.createElement(yb,qt({},e.defaultProps,s.props,{date:f,timeString:m,onChange:function(j){var S,T;(T=(S=s.props).onTimeChange)===null||T===void 0||T.call(S,j,"start")},timeInputLabel:((a=s.props.timeInputLabel)!==null&&a!==void 0?a:"Time")+" (Start)"})),Ce.createElement(yb,qt({},e.defaultProps,s.props,{date:b,timeString:w,onChange:function(j){var S,T;(T=(S=s.props).onTimeChange)===null||T===void 0||T.call(S,j,"end")},timeInputLabel:((r=s.props.timeInputLabel)!==null&&r!==void 0?r:"Time")+" (End)"})))}var C=s.props.selected?new Date(s.props.selected):void 0,N=C&&Gs(C)&&!!s.props.selected,k=N?"".concat(Rl(C.getHours()),":").concat(Rl(C.getMinutes())):"";return Ce.createElement(yb,qt({},e.defaultProps,s.props,{date:C,timeString:k,onChange:function(j){var S,T;(T=(S=s.props).onTimeChange)===null||T===void 0||T.call(S,j)}}))}},s.renderAriaLiveRegion=function(){var a;if(!Gs(s.state.date))return Ce.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"});var r=Pr(s.state.date,(a=s.props.yearItemNumber)!==null&&a!==void 0?a:e.defaultProps.yearItemNumber),i=r.startPeriod,c=r.endPeriod,d;return s.props.showYearPicker?d="".concat(i," - ").concat(c):s.props.showMonthYearPicker||s.props.showQuarterYearPicker?d=Zt(s.state.date):d="".concat(Sy(Ks(s.state.date),s.props.locale)," ").concat(Zt(s.state.date)),Ce.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"},s.state.isRenderAriaLiveMessage&&d)},s.renderChildren=function(){if(s.props.children)return Ce.createElement("div",{className:"react-datepicker__children-container"},s.props.children)},s.containerRef=x.createRef(),s.state={date:s.getDateInView(),selectingDate:void 0,monthContainer:void 0,isRenderAriaLiveMessage:!1},s}return Object.defineProperty(e,"defaultProps",{get:function(){return{monthsShown:1,forceShowMonthNavigation:!1,outsideClickIgnoreClass:gT,timeCaption:"Time",previousYearButtonLabel:"Previous Year",nextYearButtonLabel:"Next Year",previousMonthButtonLabel:"Previous Month",nextMonthButtonLabel:"Next Month",yearItemNumber:id,monthHeaderPosition:"top"}},enumerable:!1,configurable:!0}),e.prototype.componentDidMount=function(){var n=this;this.props.showTimeSelect&&(this.assignMonthContainer=(function(){n.setState({monthContainer:n.monthContainer})})())},e.prototype.componentDidUpdate=function(n){var s=this;if(this.props.preSelection&&Gs(this.props.preSelection)&&(!on(this.props.preSelection,n.preSelection)||this.props.monthSelectedIn!==n.monthSelectedIn)){var a=!Es(this.state.date,this.props.preSelection);this.setState({date:this.props.preSelection},function(){return a&&s.handleCustomMonthChange(s.state.date)})}else this.props.openToDate&&!on(this.props.openToDate,n.openToDate)&&this.setState({date:this.props.openToDate})},e.prototype.render=function(){var n=this.props.container||NU;return Ce.createElement(fh,{onClickOutside:this.handleClickOutside,style:{display:"contents"},ignoreClass:this.props.outsideClickIgnoreClass},Ce.createElement("div",{style:{display:"contents"},ref:this.containerRef},Ce.createElement(n,{className:us("react-datepicker",this.props.className,{"react-datepicker--time-only":this.props.showTimeSelectOnly}),showTime:this.props.showTimeSelect||this.props.showTimeInput,showTimeSelectOnly:this.props.showTimeSelectOnly,inline:this.props.inline},this.renderAriaLiveRegion(),this.props.monthHeaderPosition==="top"&&this.renderPreviousButton(),this.props.monthHeaderPosition==="top"&&this.renderNextButton(),this.renderMonths(),this.renderYears(),this.renderTodayButton(),this.renderTimeSection(),this.renderInputTimeSection(),this.renderChildren())))},e})(x.Component),pH=function(t){var e=t.icon,n=t.className,s=n===void 0?"":n,a=t.onClick,r="react-datepicker__calendar-icon";if(typeof e=="string")return Ce.createElement("i",{className:"".concat(r," ").concat(e," ").concat(s),"aria-hidden":"true",onClick:a});if(Ce.isValidElement(e)){var i=e;return Ce.cloneElement(i,{className:"".concat(i.props.className||""," ").concat(r," ").concat(s),onClick:function(c){typeof i.props.onClick=="function"&&i.props.onClick(c),typeof a=="function"&&a(c)}})}return Ce.createElement("svg",{className:"".concat(r," ").concat(s),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",onClick:a},Ce.createElement("path",{d:"M96 32V64H48C21.5 64 0 85.5 0 112v48H448V112c0-26.5-21.5-48-48-48H352V32c0-17.7-14.3-32-32-32s-32 14.3-32 32V64H160V32c0-17.7-14.3-32-32-32S96 14.3 96 32zM448 192H0V464c0 26.5 21.5 48 48 48H400c26.5 0 48-21.5 48-48V192z"}))},bT=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.portalRoot=null,s.el=document.createElement("div"),s}return e.prototype.componentDidMount=function(){this.portalRoot=(this.props.portalHost||document).getElementById(this.props.portalId),this.portalRoot||(this.portalRoot=document.createElement("div"),this.portalRoot.setAttribute("id",this.props.portalId),(this.props.portalHost||document.body).appendChild(this.portalRoot)),this.portalRoot.appendChild(this.el)},e.prototype.componentWillUnmount=function(){this.portalRoot&&this.portalRoot.removeChild(this.el)},e.prototype.render=function(){return S2.createPortal(this.props.children,this.el)},e})(x.Component),hH="[tabindex], a, button, input, select, textarea",mH=function(t){return(t instanceof HTMLAnchorElement||!t.disabled)&&t.tabIndex!==-1},xT=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.getTabChildren=function(){var a;return Array.prototype.slice.call((a=s.tabLoopRef.current)===null||a===void 0?void 0:a.querySelectorAll(hH),1,-1).filter(mH)},s.handleFocusStart=function(){var a=s.getTabChildren();a&&a.length>1&&a[a.length-1].focus()},s.handleFocusEnd=function(){var a=s.getTabChildren();a&&a.length>1&&a[0].focus()},s.tabLoopRef=x.createRef(),s}return e.prototype.render=function(){var n;return((n=this.props.enableTabLoop)!==null&&n!==void 0?n:e.defaultProps.enableTabLoop)?Ce.createElement("div",{className:"react-datepicker__tab-loop",ref:this.tabLoopRef},Ce.createElement("div",{className:"react-datepicker__tab-loop__start",tabIndex:0,onFocus:this.handleFocusStart}),this.props.children,Ce.createElement("div",{className:"react-datepicker__tab-loop__end",tabIndex:0,onFocus:this.handleFocusEnd})):this.props.children},e.defaultProps={enableTabLoop:!0},e})(x.Component);function gH(t){function e(n){var s,a=typeof n.hidePopper=="boolean"?n.hidePopper:!0,r=x.useRef(null),i=jU(qt({open:!a,whileElementsMounted:aU,placement:n.popperPlacement,middleware:rr([pU({padding:15}),fU(10),hU({element:r})],(s=n.popperModifiers)!==null&&s!==void 0?s:[],!0)},n.popperProps)),c=qt(qt({},n),{hidePopper:a,popperProps:qt(qt({},i),{arrowRef:r})});return Ce.createElement(t,qt({},c))}return e.displayName="withFloating(".concat(t.displayName||t.name||"Component",")"),e}var bH=function(t){var e=t.className,n=t.wrapperClassName,s=t.hidePopper,a=s===void 0?!0:s,r=t.popperComponent,i=t.targetComponent,c=t.enableTabLoop,d=t.popperOnKeyDown,f=t.portalId,h=t.portalHost,m=t.popperProps,b=t.showArrow,y=t.popperTargetRef,w=t.monthHeaderPosition;x.useEffect(function(){y!=null&&y.current&&m.refs.setPositionReference(y.current)},[y,m.refs]);var C=void 0;if(!a){var N=us("react-datepicker-popper",!b&&"react-datepicker-popper-offset",w==="middle"&&"react-datepicker-popper--header-middle",w==="bottom"&&"react-datepicker-popper--header-bottom",e);C=Ce.createElement(xT,{enableTabLoop:c},Ce.createElement("div",{ref:m.refs.setFloating,style:m.floatingStyles,className:N,"data-placement":m.placement,onKeyDown:d},r,b&&Ce.createElement(yU,{ref:m.arrowRef,context:m.context,fill:"currentColor",strokeWidth:1,height:8,width:16,style:{transform:"translateY(-1px)"},className:"react-datepicker__triangle"})))}t.popperContainer&&(C=x.createElement(t.popperContainer,{},C)),f&&!a&&(C=Ce.createElement(bT,{portalId:f,portalHost:h},C));var k=us("react-datepicker-wrapper",n);return Ce.createElement(Ce.Fragment,null,Ce.createElement("div",{ref:m.refs.setReference,className:k},i),C)},xH=gH(bH);function AA(t,e){return t&&e?Ks(t)!==Ks(e)||Zt(t)!==Zt(e):t!==e}var wb="Date input not valid.",yH=(function(t){ws(e,t);function e(n){var s=t.call(this,n)||this;return s.calendar=null,s.input=null,s.getPreSelection=function(){var a=s.props.timeZone,r=s.props.openToDate?s.props.openToDate:s.props.selectsEnd&&s.props.startDate?s.props.startDate:s.props.selectsStart&&s.props.endDate?s.props.endDate:dn();return a?oA(r,a):r},s.modifyHolidays=function(){var a;return(a=s.props.holidays)===null||a===void 0?void 0:a.reduce(function(r,i){var c=bo(i.date,"yyyy-MM-dd",void 0,!1);return c?rr(rr([],r,!0),[qt(qt({},i),{date:c})],!1):r},[])},s.calcInitialState=function(){var a=s.props.timeZone,r=s.getPreSelection(),i=fT(s.props),c=pT(s.props),d=i&&ar(r,wu(i))?i:c&&$r(r,uA(c))?c:r,f=s.props.selectsRange?s.props.startDate:s.props.selected;return f&&a&&(f=oA(f,a)),{open:s.props.startOpen||!1,preventFocus:!1,inputValue:null,preSelection:f??d,highlightDates:xA(s.props.highlightDates),focused:!1,shouldFocusDayInline:!1,isRenderAriaLiveMessage:!1,wasHidden:!1}},s.getInputValue=function(){var a,r=s.props,i=r.locale,c=r.startDate,d=r.endDate,f=r.rangeSeparator,h=r.selected,m=r.selectedDates,b=r.selectsMultiple,y=r.selectsRange,w=r.formatMultipleDates,C=r.value,N=(a=s.props.dateFormat)!==null&&a!==void 0?a:e.defaultProps.dateFormat,k=s.state.inputValue;if(typeof C=="string")return C;if(typeof k=="string")return k;if(y)return EU(c,d,{dateFormat:N,locale:i,rangeSeparator:f});if(b){if(w){var j=function(S){return Ys(S,{dateFormat:N,locale:i})};return w(m??[],j)}return MU(m??[],{dateFormat:N,locale:i})}return Ys(h,{dateFormat:N,locale:i})},s.resetHiddenStatus=function(){s.setState(qt(qt({},s.state),{wasHidden:!1}))},s.setHiddenStatus=function(){s.setState(qt(qt({},s.state),{wasHidden:!0}))},s.setHiddenStateOnVisibilityHidden=function(){document.visibilityState==="hidden"&&s.setHiddenStatus()},s.clearPreventFocusTimeout=function(){s.preventFocusTimeout&&clearTimeout(s.preventFocusTimeout)},s.setFocus=function(){var a,r;(r=(a=s.input)===null||a===void 0?void 0:a.focus)===null||r===void 0||r.call(a,{preventScroll:!0})},s.setBlur=function(){var a,r;(r=(a=s.input)===null||a===void 0?void 0:a.blur)===null||r===void 0||r.call(a),s.cancelFocusInput()},s.deferBlur=function(){requestAnimationFrame(function(){s.setBlur()})},s.setOpen=function(a,r){r===void 0&&(r=!1),s.setState({open:a,preSelection:a&&s.state.open?s.state.preSelection:s.calcInitialState().preSelection,lastPreSelectChange:kb},function(){a||s.setState(function(i){return{focused:r?i.focused:!1}},function(){!r&&s.deferBlur(),s.setState({inputValue:null})})})},s.inputOk=function(){return ir(s.state.preSelection)},s.isCalendarOpen=function(){return s.props.open===void 0?s.state.open&&!s.props.disabled&&!s.props.readOnly:s.props.open},s.handleFocus=function(a){var r,i,c=s.state.wasHidden,d=c?s.state.open:!0;c&&s.resetHiddenStatus(),s.state.preventFocus||((i=(r=s.props).onFocus)===null||i===void 0||i.call(r,a),d&&!s.props.preventOpenOnFocus&&!s.props.readOnly&&s.setOpen(!0)),s.setState({focused:!0})},s.sendFocusBackToInput=function(){s.preventFocusTimeout&&s.clearPreventFocusTimeout(),s.setState({preventFocus:!0},function(){s.preventFocusTimeout=setTimeout(function(){s.setFocus(),s.setState({preventFocus:!1})})})},s.cancelFocusInput=function(){clearTimeout(s.inputFocusTimeout),s.inputFocusTimeout=void 0},s.deferFocusInput=function(){s.cancelFocusInput(),s.inputFocusTimeout=setTimeout(function(){return s.setFocus()},1)},s.handleDropdownFocus=function(){s.cancelFocusInput()},s.resetInputValue=function(){s.setState(qt(qt({},s.state),{inputValue:null}))},s.handleBlur=function(a){var r,i;(!s.state.open||s.props.withPortal||s.props.showTimeInput)&&((i=(r=s.props).onBlur)===null||i===void 0||i.call(r,a));var c=s.state.inputValue;if(typeof c=="string"&&c.length>0){var d=/[a-zA-Z0-9]/.test(c);!d&&s.props.selected&&s.setSelected(null,void 0,!0)}s.resetInputValue(),s.state.open&&s.props.open===!1&&s.setOpen(!1),s.setState({focused:!1})},s.handleCalendarClickOutside=function(a){var r,i;(i=(r=s.props).onClickOutside)===null||i===void 0||i.call(r,a),!s.props.inline&&!a.defaultPrevented&&s.setOpen(!1),s.props.withPortal&&a.preventDefault()},s.handleChange=function(){for(var a,r,i,c,d,f,h,m,b=[],y=0;y<arguments.length;y++)b[y]=arguments[y];var w=b[0];if(!(s.props.onChangeRaw&&(s.props.onChangeRaw.apply(s,b),!w||typeof w.isDefaultPrevented!="function"||w.isDefaultPrevented()))){s.setState({inputValue:(w==null?void 0:w.target)instanceof HTMLInputElement?w.target.value:null,lastPreSelectChange:vH});var C=s.props,N=C.selectsRange,k=C.startDate,j=C.endDate,S=(a=s.props.dateFormat)!==null&&a!==void 0?a:e.defaultProps.dateFormat,T=(r=s.props.strictParsing)!==null&&r!==void 0?r:e.defaultProps.strictParsing,D=(w==null?void 0:w.target)instanceof HTMLInputElement?w.target.value:"";if(N){var E=s.props.rangeSeparator,I=E.trim(),O=D.split(S.includes(I)?E:I,2).map(function(H){return H.trim()}),_=O[0],M=O[1],R=bo(_??"",S,s.props.locale,T),z=R?bo(M??"",S,s.props.locale,T):null,$=((i=So(k))===null||i===void 0?void 0:i.getTime())!==(R==null?void 0:R.getTime()),W=((c=So(j))===null||c===void 0?void 0:c.getTime())!==(z==null?void 0:z.getTime());if(!$&&!W||R&&ja(R,s.props)||z&&ja(z,s.props))return;R&&s.setState({preSelection:R}),(f=(d=s.props).onChange)===null||f===void 0||f.call(d,[R,z],w)}else{var L=bo(D,S,s.props.locale,T,(h=s.props.selected)!==null&&h!==void 0?h:void 0);if(L||!D)s.setSelected(L,w,!0);else if(!s.props.inline){var F=_U(D,(m=s.state.preSelection)!==null&&m!==void 0?m:void 0);F&&(!s.props.minDate||!ar(F,s.props.minDate))&&(!s.props.maxDate||!$r(F,s.props.maxDate))&&s.setState({preSelection:F})}}}},s.handleSelect=function(a,r,i){var c;if(!s.props.readOnly){var d=s.props,f=d.selectsRange,h=d.startDate,m=d.endDate,b=d.locale,y=d.swapRange,w=(c=s.props.dateFormat)!==null&&c!==void 0?c:e.defaultProps.dateFormat,C=!f||h&&!m&&(y||!xb(a,h));if(s.props.shouldCloseOnSelect&&!s.props.showTimeSelect&&C&&s.sendFocusBackToInput(),s.props.onChangeRaw){var N=Ys(a,{dateFormat:w,locale:b});s.props.onChangeRaw(r,{date:a,formattedDate:N})}s.setSelected(a,r,!1,i),s.props.showDateSelect&&s.setState({isRenderAriaLiveMessage:!0}),!s.props.shouldCloseOnSelect||s.props.showTimeSelect?s.setPreSelection(a):C&&s.setOpen(!1)}},s.setSelected=function(a,r,i,c){var d,f,h=s.props.timeZone,m=a;if(m&&h&&(m=Or(m,h)),s.props.showYearPicker){if(m!==null&&op(Zt(m),s.props))return}else if(s.props.showMonthYearPicker){if(m!==null&&dT(m,s.props))return}else if(m!==null&&ja(m,s.props))return;var b=s.props,y=b.onChange,w=b.selectsRange,C=b.startDate,N=b.endDate,k=b.selectsMultiple,j=b.selectedDates,S=b.minTime,T=b.swapRange;if(!Co(s.props.selected,m)||s.props.allowSameDay||w||k)if(m!==null&&(s.props.selected&&(!i||!s.props.showTimeSelect&&!s.props.showTimeSelectOnly&&!s.props.showTimeInput)&&(m=Lr(m,{hour:Cs(s.props.selected),minute:As(s.props.selected),second:Ei(s.props.selected)})),!i&&(s.props.showTimeSelect||s.props.showTimeSelectOnly)&&S&&(m=Lr(m,{hour:S.getHours(),minute:S.getMinutes(),second:S.getSeconds()})),s.props.inline||s.setState({preSelection:m}),s.props.focusSelectedMonth||s.setState({monthSelectedIn:c})),w){var D=y,E=!C&&!N,I=C&&!N,O=!C&&!!N,_=C&&N;E?D==null||D([m,null],r):I?m===null?D==null||D([null,null],r):xb(m,C)?T?D==null||D([m,C],r):D==null||D([m,null],r):D==null||D([C,m],r):O&&(m&&xb(m,N)?D==null||D([m,N],r):D==null||D([m,null],r)),_&&(D==null||D([m,null],r))}else if(k){var M=y;if(m!==null)if(!(j!=null&&j.length))M==null||M([m],r);else{var R=j.some(function($){return on($,m)});if(R){var z=j.filter(function($){return!on($,m)});M==null||M(z,r)}else M==null||M(rr(rr([],j,!0),[m],!1),r)}}else y==null||y(m,r);i||((f=(d=s.props).onSelect)===null||f===void 0||f.call(d,m,r),s.setState({inputValue:null}))},s.setPreSelection=function(a){if(!s.props.readOnly){var r=ir(s.props.minDate),i=ir(s.props.maxDate),c=!0;if(a){var d=wu(a);if(r&&i)c=vo(a,s.props.minDate,s.props.maxDate);else if(r){var f=wu(s.props.minDate);c=$r(a,f)||Co(d,f)}else if(i){var h=uA(s.props.maxDate);c=ar(a,h)||Co(d,h)}}c&&s.setState({preSelection:a})}},s.toggleCalendar=function(){s.setOpen(!s.state.open)},s.handleTimeChange=function(a,r){var i,c;if(!s.props.selectsMultiple){var d=s.props,f=d.selectsRange,h=d.startDate,m=d.endDate,b=d.onChange,y=d.timeZone;if(f){var w=b;if(r==="start"){if(h){var C=Lr(h,{hour:Cs(a),minute:As(a)});s.setState({preSelection:C}),y&&(C=Or(C,y)),w==null||w([C,m?y?Or(m,y):m:null],void 0)}}else if(r==="end"){if(m){var N=Lr(m,{hour:Cs(a),minute:As(a)});s.setState({preSelection:N}),y&&(N=Or(N,y)),w==null||w([h?y?Or(h,y):h:null,N],void 0)}}else{var k=h&&!m;if(k){var C=Lr(h,{hour:Cs(a),minute:As(a)});s.setState({preSelection:C}),y&&(C=Or(C,y)),w==null||w([C,null],void 0)}else if(h&&m){var N=Lr(m,{hour:Cs(a),minute:As(a)});s.setState({preSelection:N}),y&&(N=Or(N,y)),w==null||w([y?Or(h,y):h,N],void 0)}else{var j=Lr(s.getPreSelection(),{hour:Cs(a),minute:As(a)});s.setState({preSelection:j})}}}else{var S=s.props.selected?s.props.selected:s.getPreSelection(),j=s.props.selected?a:Lr(S,{hour:Cs(a),minute:As(a)});s.setState({preSelection:j}),j&&y&&(j=Or(j,y)),(c=(i=s.props).onChange)===null||c===void 0||c.call(i,j)}s.props.shouldCloseOnSelect&&!s.props.showTimeInput&&(s.sendFocusBackToInput(),s.setOpen(!1)),s.props.showTimeInput&&s.setOpen(!0),(s.props.showTimeSelectOnly||s.props.showTimeSelect)&&s.setState({isRenderAriaLiveMessage:!0}),s.setState({inputValue:null})}},s.onInputClick=function(){var a,r;!s.props.disabled&&!s.props.readOnly&&s.setOpen(!0),(r=(a=s.props).onInputClick)===null||r===void 0||r.call(a)},s.handleTimeOnlyArrowKey=function(a){var r,i,c,d,f=So(s.props.selected)||s.state.preSelection||dn(),h=(r=s.props.timeIntervals)!==null&&r!==void 0?r:30,m=(i=s.props.dateFormat)!==null&&i!==void 0?i:e.defaultProps.dateFormat,b=Array.isArray(m)?m[0]:m,y=wu(f),w=Cs(f)*60+As(f),C=1440-h,N;if(a===lt.ArrowUp){var k=Math.max(0,w-h);N=Gu(y,k)}else{var k=Math.min(C,w+h);N=Gu(y,k)}var j=Bn(N,b||e.defaultProps.dateFormat,s.props.locale);if(s.setState({preSelection:N,inputValue:j}),!(s.props.selectsRange||s.props.selectsMultiple)){var S=s.props.selected?s.props.selected:s.getPreSelection(),T=s.props.selected?N:Lr(S,{hour:Cs(N),minute:As(N)});(d=(c=s.props).onChange)===null||d===void 0||d.call(c,T),(s.props.showTimeSelectOnly||s.props.showTimeSelect)&&s.setState({isRenderAriaLiveMessage:!0}),requestAnimationFrame(function(){s.scrollToTimeOption(N)})}},s.handleTimeOnlyEnterKey=function(a){var r,i,c,d,f=a.target,h=f.value,m=(r=s.props.dateFormat)!==null&&r!==void 0?r:e.defaultProps.dateFormat,b=s.props.timeFormat||"p",y=s.state.preSelection||So(s.props.selected)||dn(),w=bo(h,m,s.props.locale,(i=s.props.strictParsing)!==null&&i!==void 0?i:!1,y),C=y;if(w&&Gs(w))C=w;else{var N=((c=s.calendar)===null||c===void 0?void 0:c.containerRef.current)instanceof Element&&s.calendar.containerRef.current.querySelector(".react-datepicker__time-list-item[tabindex='0']");if(N instanceof HTMLElement){var k=(d=N.textContent)===null||d===void 0?void 0:d.trim();if(k){var j=bo(k,b,s.props.locale,!1,y);j&&Gs(j)&&(C=j)}}}s.handleTimeChange(C),s.setOpen(!1),s.sendFocusBackToInput()},s.scrollToTimeOption=function(a){var r,i;if(!((r=s.calendar)===null||r===void 0)&&r.containerRef.current){for(var c=s.calendar.containerRef.current,d=Array.from(c.querySelectorAll(".react-datepicker__time-list-item")),f=null,h=1/0,m=s.props.timeFormat||"p",b=0,y=d;b<y.length;b++){var w=y[b],C=(i=w.textContent)===null||i===void 0?void 0:i.trim();if(C){var N=bo(C,m,s.props.locale,!1,a);if(N&&Gs(N)){if(hT(N,a)){f=w;break}var k=Math.abs(N.getTime()-a.getTime());k<h&&(h=k,f=w)}}}f&&(d.forEach(function(j){j.setAttribute("tabindex","-1")}),f.setAttribute("tabindex","0"),f.scrollIntoView({behavior:"smooth",block:"center"}))}},s.onInputKeyDown=function(a){var r,i,c,d,f,h;(i=(r=s.props).onKeyDown)===null||i===void 0||i.call(r,a);var m=a.key;if(!s.state.open&&!s.props.inline&&!s.props.preventOpenOnFocus){(m===lt.ArrowDown||m===lt.ArrowUp||m===lt.Enter)&&((c=s.onInputClick)===null||c===void 0||c.call(s));return}if(s.state.open&&s.props.showTimeSelectOnly){if(m===lt.ArrowDown||m===lt.ArrowUp){a.preventDefault(),s.handleTimeOnlyArrowKey(m);return}if(m===lt.Enter){a.preventDefault(),s.handleTimeOnlyEnterKey(a);return}}if(s.state.open){if(m===lt.ArrowDown||m===lt.ArrowUp){a.preventDefault();var b=s.props.showTimeSelectOnly?".react-datepicker__time-list-item[tabindex='0']":s.props.showWeekPicker&&s.props.showWeekNumbers?'.react-datepicker__week-number[tabindex="0"]':s.props.showFullMonthYearPicker||s.props.showMonthYearPicker?'.react-datepicker__month-text[tabindex="0"]':'.react-datepicker__day[tabindex="0"]',y=((d=s.calendar)===null||d===void 0?void 0:d.containerRef.current)instanceof Element&&s.calendar.containerRef.current.querySelector(b);y instanceof HTMLElement&&y.focus({preventScroll:!0});return}var w=dn(s.state.preSelection);m===lt.Enter?(a.preventDefault(),a.target.blur(),s.inputOk()&&s.state.lastPreSelectChange===kb?(s.handleSelect(w,a),!s.props.shouldCloseOnSelect&&s.setPreSelection(w)):s.setOpen(!1)):m===lt.Escape?(a.preventDefault(),a.target.blur(),s.sendFocusBackToInput(),s.setOpen(!1)):m===lt.Tab&&s.setOpen(!1),s.inputOk()||(h=(f=s.props).onInputError)===null||h===void 0||h.call(f,{code:1,msg:wb})}},s.onPortalKeyDown=function(a){var r=a.key;r===lt.Escape&&(a.preventDefault(),s.setState({preventFocus:!0},function(){s.setOpen(!1),setTimeout(function(){s.setFocus(),s.setState({preventFocus:!1})})}))},s.onDayKeyDown=function(a){var r,i,c,d,f,h,m=s.props,b=m.minDate,y=m.maxDate,w=m.disabledKeyboardNavigation,C=m.showWeekPicker,N=m.shouldCloseOnSelect,k=m.locale,j=m.calendarStartDay,S=m.adjustDateOnChange,T=m.inline;if((i=(r=s.props).onKeyDown)===null||i===void 0||i.call(r,a),!w){var D=a.key,E=a.shiftKey,I=dn(s.state.preSelection),O=function(R,z){var $=z;switch(R){case lt.ArrowRight:$=C?Tp(z,1):Pa(z,1);break;case lt.ArrowLeft:$=C?GC(z):J3(z);break;case lt.ArrowUp:$=GC(z);break;case lt.ArrowDown:$=Tp(z,1);break;case lt.PageUp:$=E?Ri(z,1):Ao(z,1);break;case lt.PageDown:$=E?Ba(z,1):za(z,1);break;case lt.Home:$=Mi(z,k,j);break;case lt.End:$=OU(z);break}return $},_=function(R,z){for(var $=40,W=R,L=!1,F=0,H=O(R,z);!L;){if(F>=$){H=z;break}b&&H<b&&(W=lt.ArrowRight,H=ja(b,s.props)?O(W,H):b),y&&H>y&&(W=lt.ArrowLeft,H=ja(y,s.props)?O(W,H):y),ja(H,s.props)?((W===lt.PageUp||W===lt.Home)&&(W=lt.ArrowRight),(W===lt.PageDown||W===lt.End)&&(W=lt.ArrowLeft),H=O(W,H)):L=!0,F++}return H};if(D===lt.Enter){a.preventDefault(),s.handleSelect(I,a),!N&&s.setPreSelection(I);return}else if(D===lt.Escape){a.preventDefault(),s.setOpen(!1),s.inputOk()||(d=(c=s.props).onInputError)===null||d===void 0||d.call(c,{code:1,msg:wb});return}var M=null;switch(D){case lt.ArrowLeft:case lt.ArrowRight:case lt.ArrowUp:case lt.ArrowDown:case lt.PageUp:case lt.PageDown:case lt.Home:case lt.End:M=_(D,I);break}if(!M){(h=(f=s.props).onInputError)===null||h===void 0||h.call(f,{code:1,msg:wb});return}a.preventDefault(),s.setState({lastPreSelectChange:kb}),S&&s.setSelected(M),s.setPreSelection(M),T&&s.setState({shouldFocusDayInline:!0})}},s.onPopperKeyDown=function(a){var r=a.key;r===lt.Escape&&(a.preventDefault(),s.sendFocusBackToInput(),s.setOpen(!1))},s.onClearClick=function(a){a&&a.preventDefault&&a.preventDefault(),s.sendFocusBackToInput();var r=s.props,i=r.selectsRange,c=r.onChange;i?c==null||c([null,null],a):c==null||c(null,a),s.setState({inputValue:null})},s.clear=function(){s.onClearClick()},s.onScroll=function(a){typeof s.props.closeOnScroll=="boolean"&&s.props.closeOnScroll?(a.target===document||a.target===document.documentElement||a.target===document.body)&&s.setOpen(!1):typeof s.props.closeOnScroll=="function"&&s.props.closeOnScroll(a)&&s.setOpen(!1)},s.handleMonthSelectedInChange=function(a){s.setState({monthSelectedIn:a})},s.renderCalendar=function(){var a,r;return!s.props.inline&&!s.isCalendarOpen()?null:Ce.createElement(fH,qt({showMonthYearDropdown:void 0,ref:function(i){s.calendar=i}},s.props,s.state,{setOpen:s.setOpen,dateFormat:(a=s.props.dateFormatCalendar)!==null&&a!==void 0?a:e.defaultProps.dateFormatCalendar,onSelect:s.handleSelect,onClickOutside:s.handleCalendarClickOutside,holidays:VU(s.modifyHolidays()),outsideClickIgnoreClass:s.props.outsideClickIgnoreClass,onDropdownFocus:s.handleDropdownFocus,onTimeChange:s.handleTimeChange,className:s.props.calendarClassName,container:s.props.calendarContainer,handleOnKeyDown:s.props.onKeyDown,handleOnDayKeyDown:s.onDayKeyDown,setPreSelection:s.setPreSelection,dropdownMode:(r=s.props.dropdownMode)!==null&&r!==void 0?r:e.defaultProps.dropdownMode,onMonthSelectedInChange:s.handleMonthSelectedInChange}),s.props.children)},s.renderAriaLiveRegion=function(){var a,r=s.props.locale,i=(a=s.props.dateFormat)!==null&&a!==void 0?a:e.defaultProps.dateFormat,c=s.props.showTimeInput||s.props.showTimeSelect,d=c?"PPPPp":"PPPP",f;return s.props.selectsRange?f="Selected start date: ".concat(Ys(s.props.startDate,{dateFormat:d,locale:r}),". ").concat(s.props.endDate?"End date: "+Ys(s.props.endDate,{dateFormat:d,locale:r}):""):s.props.showTimeSelectOnly?f="Selected time: ".concat(Ys(s.props.selected,{dateFormat:i,locale:r})):s.props.showYearPicker?f="Selected year: ".concat(Ys(s.props.selected,{dateFormat:"yyyy",locale:r})):s.props.showMonthYearPicker?f="Selected month: ".concat(Ys(s.props.selected,{dateFormat:"MMMM yyyy",locale:r})):s.props.showQuarterYearPicker?f="Selected quarter: ".concat(Ys(s.props.selected,{dateFormat:"yyyy, QQQ",locale:r})):f="Selected date: ".concat(Ys(s.props.selected,{dateFormat:d,locale:r})),Ce.createElement("span",{role:"alert","aria-live":"polite",className:"react-datepicker__aria-live"},f)},s.renderDateInput=function(){var a,r,i,c,d,f,h,m=us(s.props.className,(a={},a[s.props.outsideClickIgnoreClass||e.defaultProps.outsideClickIgnoreClass]=s.state.open,a)),b=s.props.customInput||Ce.createElement("input",{type:"text"}),y=s.props.customInputRef||"ref",w={},C=(i=s.props["aria-describedby"])!==null&&i!==void 0?i:s.props.ariaDescribedBy,N=(c=s.props["aria-invalid"])!==null&&c!==void 0?c:s.props.ariaInvalid,k=(d=s.props["aria-label"])!==null&&d!==void 0?d:s.props.ariaLabel,j=(f=s.props["aria-labelledby"])!==null&&f!==void 0?f:s.props.ariaLabelledBy,S=(h=s.props["aria-required"])!==null&&h!==void 0?h:s.props.ariaRequired;return C!=null&&(w["aria-describedby"]=C),N!=null&&(w["aria-invalid"]=N),k!=null&&(w["aria-label"]=k),j!=null&&(w["aria-labelledby"]=j),S!=null&&(w["aria-required"]=S),x.cloneElement(b,qt((r={},r[y]=function(T){s.input=T},r.value=s.getInputValue(),r.onBlur=s.handleBlur,r.onChange=s.handleChange,r.onClick=s.onInputClick,r.onFocus=s.handleFocus,r.onKeyDown=s.onInputKeyDown,r.id=s.props.id,r.name=s.props.name,r.form=s.props.form,r.autoFocus=s.props.autoFocus,r.placeholder=s.props.placeholderText,r.disabled=s.props.disabled,r.autoComplete=s.props.autoComplete,r.className=us(b.props.className,m),r.title=s.props.title,r.readOnly=s.props.readOnly,r.required=s.props.required,r.tabIndex=s.props.tabIndex,r),w))},s.renderClearButton=function(){var a=s.props,r=a.isClearable,i=a.disabled,c=a.selected,d=a.startDate,f=a.endDate,h=a.clearButtonTitle,m=a.clearButtonClassName,b=m===void 0?"":m,y=a.ariaLabelClose,w=y===void 0?"Close":y,C=a.selectedDates,N=a.readOnly;return r&&!N&&(c!=null||d!=null||f!=null||C!=null&&C.length)?Ce.createElement("button",{type:"button",className:us("react-datepicker__close-icon",b,{"react-datepicker__close-icon--disabled":i}),disabled:i,"aria-label":w,onClick:s.onClearClick,title:h,tabIndex:-1}):null},s.state=s.calcInitialState(),s.preventFocusTimeout=void 0,s}return Object.defineProperty(e,"defaultProps",{get:function(){return{allowSameDay:!1,dateFormat:"MM/dd/yyyy",dateFormatCalendar:"LLLL yyyy",disabled:!1,disabledKeyboardNavigation:!1,dropdownMode:"scroll",preventOpenOnFocus:!1,monthsShown:1,outsideClickIgnoreClass:gT,readOnly:!1,rangeSeparator:cT,withPortal:!1,selectsDisabledDaysInRange:!1,shouldCloseOnSelect:!0,showTimeSelect:!1,showTimeInput:!1,showPreviousMonths:!1,showMonthYearPicker:!1,showFullMonthYearPicker:!1,showTwoColumnMonthYearPicker:!1,showFourColumnMonthYearPicker:!1,showYearPicker:!1,showQuarterYearPicker:!1,showWeekPicker:!1,strictParsing:!1,swapRange:!1,timeIntervals:30,timeCaption:"Time",previousMonthAriaLabel:"Previous Month",previousMonthButtonLabel:"Previous Month",nextMonthAriaLabel:"Next Month",nextMonthButtonLabel:"Next Month",previousYearAriaLabel:"Previous Year",previousYearButtonLabel:"Previous Year",nextYearAriaLabel:"Next Year",nextYearButtonLabel:"Next Year",timeInputLabel:"Time",enableTabLoop:!0,yearItemNumber:id,focusSelectedMonth:!1,showPopperArrow:!0,excludeScrollbar:!0,customTimeInput:null,calendarStartDay:void 0,toggleCalendarOnIconClick:!1,usePointerEvent:!1}},enumerable:!1,configurable:!0}),e.prototype.componentDidMount=function(){window.addEventListener("scroll",this.onScroll,!0),document.addEventListener("visibilitychange",this.setHiddenStateOnVisibilityHidden)},e.prototype.componentDidUpdate=function(n,s){var a,r,i,c;this.props.selectsRange&&AA(n.startDate,this.props.startDate)?this.setPreSelection(this.props.startDate):AA(n.selected,this.props.selected)&&this.setPreSelection(this.props.selected),this.state.monthSelectedIn!==void 0&&n.monthsShown!==this.props.monthsShown&&this.setState({monthSelectedIn:0}),this.props.selectsRange&&s.open===!1&&this.state.open===!0&&this.state.monthSelectedIn!==0&&this.setState({monthSelectedIn:0}),n.highlightDates!==this.props.highlightDates&&this.setState({highlightDates:xA(this.props.highlightDates)}),!s.focused&&!Co(n.selected,this.props.selected)&&this.setState({inputValue:null}),s.open!==this.state.open&&(s.open===!1&&this.state.open===!0&&((r=(a=this.props).onCalendarOpen)===null||r===void 0||r.call(a)),s.open===!0&&this.state.open===!1&&((c=(i=this.props).onCalendarClose)===null||c===void 0||c.call(i)))},e.prototype.componentWillUnmount=function(){this.clearPreventFocusTimeout(),window.removeEventListener("scroll",this.onScroll,!0),document.removeEventListener("visibilitychange",this.setHiddenStateOnVisibilityHidden)},e.prototype.renderInputContainer=function(){var n=this.props,s=n.showIcon,a=n.icon,r=n.calendarIconClassname,i=n.calendarIconClassName,c=n.toggleCalendarOnIconClick,d=this.state.open;return r&&console.warn("calendarIconClassname props is deprecated. should use calendarIconClassName props."),Ce.createElement("div",{className:"react-datepicker__input-container".concat(s?" react-datepicker__view-calendar-icon":"")},s&&Ce.createElement(pH,qt({icon:a,className:us(i,!i&&r,d&&"react-datepicker-ignore-onclickoutside")},c?{onClick:this.toggleCalendar}:null)),this.state.isRenderAriaLiveMessage&&this.renderAriaLiveRegion(),this.renderDateInput(),this.renderClearButton())},e.prototype.render=function(){var n=this.renderCalendar();if(this.props.inline)return n;if(this.props.withPortal){var s=this.state.open?Ce.createElement(xT,{enableTabLoop:this.props.enableTabLoop},Ce.createElement("div",{className:"react-datepicker__portal",tabIndex:-1,onKeyDown:this.onPortalKeyDown},n)):null;return this.state.open&&this.props.portalId&&(s=Ce.createElement(bT,qt({portalId:this.props.portalId},this.props),s)),Ce.createElement(Ce.Fragment,null,this.renderInputContainer(),s)}return Ce.createElement(xH,qt({},this.props,{className:this.props.popperClassName,hidePopper:!this.isCalendarOpen(),targetComponent:this.renderInputContainer(),popperComponent:n,popperOnKeyDown:this.onPopperKeyDown,showArrow:this.props.showPopperArrow,monthHeaderPosition:this.props.monthHeaderPosition}))},e})(x.Component),vH="input",kb="navigate";const wH=[25,50,100,250,500,1e3],kH=250,bu=t=>String(t).padStart(2,"0"),Yf=t=>t?/(datetime|timestamp|timestamptz|datetime2|smalldatetime)/i.test(t):!1,jA=t=>`${t.getFullYear()}-${bu(t.getMonth()+1)}-${bu(t.getDate())} ${bu(t.getHours())}:${bu(t.getMinutes())}:${bu(t.getSeconds())}`,NA=t=>{if(t==null)return null;if(t instanceof Date)return t;const e=String(t).trim();if(!e)return null;if(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?(\.\d+)?$/.test(e)){const s=e.replace(" ","T"),a=new Date(s);return Number.isNaN(a.getTime())?null:a}if(/^\d{4}-\d{2}-\d{2}T/.test(e)){const s=new Date(e.replace(/Z$/,""));return Number.isNaN(s.getTime())?null:s}const n=new Date(e);return Number.isNaN(n.getTime())?null:n},SH=t=>t===null?"NULL":t===void 0?"undefined":typeof t=="object"?JSON.stringify(t,null,2):String(t),CH=t=>t==null?"":typeof t=="object"?JSON.stringify(t):String(t),AH=t=>{const e=t.match(/FROM\s+(?:`?[\w]+`?\.)?`?([\w]+)`?(?:\s+(?:AS\s+)?\w+)?(?=\s|;|$)/i);return e!=null&&e[1]?e[1]:null},Sb=t=>!t||!t.columns?[]:t.columns.filter(e=>e.primaryKey).map(e=>e.name),jH=(t,e,n,s,a,r,i=!0)=>{const c=b=>t==="mysql"?`\`${b}\``:t==="postgres"?`"${b}"`:b,d=b=>b===null?"NULL":typeof b=="boolean"?b?"1":"0":typeof b=="number"?String(b):typeof b=="object"?`'${JSON.stringify(b).replace(/'/g,"''")}'`:`'${String(b).replace(/'/g,"''")}'`,f=`${c(n)} = ${d(r)}`,h=[];for(const[b,y]of Object.entries(s))h.push(`${c(b)} = ${d(y)}`);i&&(a===null?h.push(`${c(n)} IS NULL`):typeof a=="object"||h.push(`${c(n)} = ${d(a)}`));const m=h.join(" AND ");return`UPDATE ${c(e)} SET ${f} WHERE ${m}`},NH=({result:t,buildingId:e,building:n})=>{var se,Se;const{t:s}=dt(["terminal"]),a=Yx(e),[r,i]=x.useState(0),[c,d]=x.useState(kH),[f,h]=x.useState(null),[m,b]=x.useState("asc"),[y,w]=x.useState(null),[C,N]=x.useState(!1),[k,j]=x.useState({}),[S,T]=x.useState(null),[D,E]=x.useState(null),[I,O]=x.useState(null),[_,M]=x.useState(!1),[R,z]=x.useState(null),[$,W]=x.useState(null),[L,F]=x.useState(new Map),[H,V]=x.useState(null),[G,B]=x.useState(null),K=x.useRef(null),ne=x.useRef(null),q=x.useRef(null),xe=x.useRef(!1),Ae=t.status==="error",Z=!t.rows||t.rows.length===0;x.useEffect(()=>{var pe,Re;const J=AH(t.query||"");if(E(J),M(!1),O(null),F(new Map),J&&a.activeConnectionId&&a.activeDatabase){const $e=`${a.activeConnectionId}:${a.activeDatabase}:${J}`,ye=(Re=(pe=a.tableSchemas)==null?void 0:pe.get)==null?void 0:Re.call(pe,$e);if(ye){O(ye);const Ie=Sb(ye);M(Ie.length>0)}else U.getTableSchema(e,a.activeConnectionId,a.activeDatabase,J)}},[t.query,t.rows,e,a.activeConnectionId,a.activeDatabase]),x.useEffect(()=>{var J,pe;if(D&&a.activeConnectionId&&a.activeDatabase){const Re=`${a.activeConnectionId}:${a.activeDatabase}:${D}`,$e=(pe=(J=a.tableSchemas)==null?void 0:J.get)==null?void 0:pe.call(J,Re);if($e){O(Ie=>Ie===$e?Ie:$e);const ye=Sb($e);M(ye.length>0)}}},[a.tableSchemas,D,a.activeConnectionId,a.activeDatabase]);const ce=x.useMemo(()=>!f||!t.rows?t.rows:[...t.rows].sort((J,pe)=>{const Re=J[f],$e=pe[f];if(Re===null&&$e===null)return 0;if(Re===null)return m==="asc"?-1:1;if($e===null)return m==="asc"?1:-1;if(typeof Re=="number"&&typeof $e=="number")return m==="asc"?Re-$e:$e-Re;const ye=String(Re),Ie=String($e);return m==="asc"?ye.localeCompare(Ie):Ie.localeCompare(ye)}),[t.rows,f,m]),me=x.useMemo(()=>{if(!ce)return[];const J=r*c;return ce.slice(J,J+c)},[ce,r,c]),ee=Math.ceil(((ce==null?void 0:ce.length)??0)/c),re=((se=t.fields)==null?void 0:se.map(J=>J.name))??Object.keys(((Se=t.rows)==null?void 0:Se[0])||{}),We=x.useMemo(()=>{const J=new Map;return(t.fields??[]).forEach(pe=>{pe!=null&&pe.name&&J.set(pe.name,String(pe.type??""))}),J},[t.fields]),ze=x.useMemo(()=>Sb(I),[I]),Pe=x.useCallback((J,pe)=>{const Re=We.get(J);if(Yf(Re)){const $e=NA(pe);return $e?jA($e):""}return CH(pe)},[We]),ge=x.useMemo(()=>_?"Editable":!a.activeConnectionId||!a.activeDatabase?"Read-only: no active connection or database":D?I?ze.length===0?"Read-only: table has no primary key":"Read-only: editing unavailable":"Read-only: loading table schema":"Read-only: query is not a single-table SELECT",[_,a.activeConnectionId,a.activeDatabase,D,I,ze.length]),Te=x.useCallback(J=>{if(xe.current){xe.current=!1;return}f===J?b(pe=>pe==="asc"?"desc":"asc"):(h(J),b("asc"))},[f]),qe=x.useCallback((J,pe,Re,$e)=>{!_||S||G||T({rowIndex:Re,rowKey:$e,columnName:J,originalValue:pe,currentValue:Pe(J,pe),isUpdating:!1})},[_,S,G,Pe]),it=x.useCallback((J,pe)=>{w({column:J,value:pe})},[]),he=x.useCallback(J=>{var tn,je;if(!D||!I||!a.activeConnectionId||!a.activeDatabase)return;const{rowIndex:pe,columnName:Re,originalValue:$e,currentValue:ye}=J,Ie=String(ye??"");if(ye!==null&&Ie===Pe(Re,$e)){T(null);return}const te=r*c+pe,be=ce==null?void 0:ce[te];if(!be)return;const we=ze;if(we.length===0){T(Oe=>Oe?{...Oe,error:"No primary key found"}:null);return}const Fe={};for(const Oe of we)Fe[Oe]=be[Oe];let Ke=Ie;const st=We.get(Re);if(ye===null)Ke=null;else if(Yf(st))Ke=Ie.trim()===""?null:Ie.trim();else if(typeof $e=="number")if(Ie.trim()==="")Ke=null;else{const Oe=Number(Ie);if(Number.isNaN(Oe)){T(Ye=>Ye?{...Ye,isUpdating:!1,error:"Invalid number value"}:null);return}Ke=Oe}else if(typeof $e=="boolean"){const Oe=Ie.trim().toLowerCase();if(Oe==="true"||Oe==="1")Ke=!0;else if(Oe==="false"||Oe==="0")Ke=!1;else{T(Ye=>Ye?{...Ye,isUpdating:!1,error:"Invalid boolean value"}:null);return}}else if($e!==null&&typeof $e=="object")try{Ke=JSON.parse(Ie)}catch{T(Oe=>Oe?{...Oe,isUpdating:!1,error:"Invalid JSON value"}:null);return}T(Oe=>Oe?{...Oe,isUpdating:!0}:null);const ft=(tn=n.database)==null?void 0:tn.connections.find(Oe=>Oe.id===a.activeConnectionId),wt=(ft==null?void 0:ft.engine)||"mysql",at=jH(wt,D,Re,Fe,$e,Ke,!Yf(st));W(at);const gt=JSON.stringify(Fe),ht=((je=t.query)==null?void 0:je.trim())||"",Gt=`${Date.now()}-${Math.random().toString(36).slice(2,10)}`;B({requestId:Gt,query:at,rowKey:gt,columnName:Re,parsedValue:Ke,startedAt:Date.now(),originalQuery:ht}),U.executeSilentQuery(e,a.activeConnectionId,a.activeDatabase,at,Gt)},[D,I,r,c,ce,ze,e,a.activeConnectionId,a.activeDatabase,t.query,Pe,We]);x.useEffect(()=>{const J=a.lastSilentQueryResult;if(!(!G||!J)&&!(J.requestId&&J.requestId!==G.requestId)&&!(J.timestamp<G.startedAt)){if(!J.success){z({message:J.error||"Update failed on backend",type:"error"}),setTimeout(()=>z(null),5e3),T(pe=>pe&&{...pe,isUpdating:!1,error:J.error||"Update failed on backend"}),B(null);return}if(J.affectedRows===0){z({message:"No rows were updated",type:"error"}),setTimeout(()=>z(null),5e3),T(pe=>pe&&{...pe,isUpdating:!1,error:"No rows were updated"}),B(null);return}F(pe=>{const Re=new Map(pe),$e=Re.get(G.rowKey)||{};return $e[G.columnName]=G.parsedValue,Re.set(G.rowKey,$e),Re}),T(null),z({message:"Row updated successfully",type:"success"}),setTimeout(()=>z(null),3e3),G.originalQuery&&a.activeConnectionId&&a.activeDatabase&&setTimeout(()=>{U.executeQuery(e,a.activeConnectionId,a.activeDatabase,G.originalQuery)},200),B(null)}},[G,a.lastSilentQueryResult,a.activeConnectionId,a.activeDatabase,e]),x.useEffect(()=>{if(!G)return;const J=window.setTimeout(()=>{z({message:"Update timed out waiting for backend",type:"error"}),setTimeout(()=>z(null),5e3),T(pe=>pe&&{...pe,isUpdating:!1,error:"Update timed out waiting for backend"}),B(null)},1e4);return()=>window.clearTimeout(J)},[G]);const Be=x.useCallback(()=>{S&&he(S)},[S,he]),ie=x.useCallback((J,pe,Re,$e,ye)=>{J.preventDefault(),J.stopPropagation(),V({position:{x:J.clientX,y:J.clientY},rowIndex:$e,rowKey:ye,columnName:pe,value:Re})},[S,D,I,r,c,ce,ze,e,a.activeConnectionId,a.activeDatabase]),de=x.useMemo(()=>{if(!H)return[];const J=!_||!!S||!!G||!D||!I||!a.activeConnectionId||!a.activeDatabase;return[{id:"editability",label:_?"Cell actions":ge,icon:_?"▣":"ℹ",disabled:!0,onClick:()=>{}},{id:"divider-1",label:"",divider:!0,onClick:()=>{}},{id:"edit-cell",label:"Edit Cell",icon:"✏️",disabled:J,onClick:()=>{T({rowIndex:H.rowIndex,rowKey:H.rowKey,columnName:H.columnName,originalValue:H.value,currentValue:Pe(H.columnName,H.value),isUpdating:!1})}},{id:"set-null",label:"Set NULL",icon:"∅",disabled:J||H.value===null,onClick:()=>{he({rowIndex:H.rowIndex,rowKey:H.rowKey,columnName:H.columnName,originalValue:H.value,currentValue:null,isUpdating:!1})}}]},[H,_,S,G,D,I,a.activeConnectionId,a.activeDatabase,ge,he,Pe]),He=x.useCallback(J=>{J.key==="Enter"?(J.preventDefault(),Be()):J.key==="Escape"&&(J.preventDefault(),J.stopPropagation(),T(null))},[Be]),et=x.useCallback((J,pe)=>{J.preventDefault(),J.stopPropagation();const Re=J.target.closest("th");if(!Re)return;const $e=Re.getBoundingClientRect().width;q.current={column:pe,startX:J.clientX,startWidth:$e};const ye=te=>{if(!q.current)return;const be=te.clientX-q.current.startX,we=Math.max(50,q.current.startWidth+be);j(Fe=>({...Fe,[q.current.column]:we}))},Ie=()=>{q.current=null,xe.current=!0,document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",Ie),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",ye),document.addEventListener("mouseup",Ie),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);x.useEffect(()=>{if(!y)return;const J=Re=>{Re.key==="Escape"&&(Re.stopPropagation(),w(null))},pe=Re=>{K.current&&!K.current.contains(Re.target)&&w(null)};return document.addEventListener("keydown",J),document.addEventListener("mousedown",pe),()=>{document.removeEventListener("keydown",J),document.removeEventListener("mousedown",pe)}},[y]);const ct=S?`${S.rowKey}:${S.columnName}`:null;x.useEffect(()=>{ne.current&&ct&&(ne.current.focus(),ne.current.select())},[ct]);const fe=x.useCallback(async()=>{var ye;if(!t.rows||t.rows.length===0)return;const J=((ye=t.fields)==null?void 0:ye.map(Ie=>Ie.name))??Object.keys(t.rows[0]||{}),pe=ce??t.rows,Re=["<table><thead><tr>"];J.forEach(Ie=>Re.push(`<th>${Ie}</th>`)),Re.push("</tr></thead><tbody>"),pe.forEach(Ie=>{Re.push("<tr>"),J.forEach(te=>{const be=Ie[te];Re.push(`<td>${be===null?"NULL":typeof be=="object"?JSON.stringify(be):String(be)}</td>`)}),Re.push("</tr>")}),Re.push("</tbody></table>");const $e=[J.join(" ")];pe.forEach(Ie=>{$e.push(J.map(te=>{const be=Ie[te];return be===null?"NULL":typeof be=="object"?JSON.stringify(be):String(be)}).join(" "))});try{const Ie=new Blob([Re.join("")],{type:"text/html"}),te=new Blob([$e.join(`
|
|
110
|
+
`)],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/html":Ie,"text/plain":te})]),N(!0),setTimeout(()=>N(!1),2e3)}catch{await navigator.clipboard.writeText($e.join(`
|
|
111
|
+
`)),N(!0),setTimeout(()=>N(!1),2e3)}},[t,ce]),X=J=>{if(J===null)return o.jsx("span",{className:"results-table__null",children:"NULL"});if(J===void 0)return o.jsx("span",{className:"results-table__null",children:"undefined"});if(typeof J=="boolean")return o.jsx("span",{className:`results-table__bool results-table__bool--${J}`,children:String(J)});if(typeof J=="number")return o.jsx("span",{className:"results-table__number",children:J.toLocaleString()});if(J instanceof Date)return o.jsx("span",{className:"results-table__date",children:J.toISOString()});if(typeof J=="object")return o.jsx("span",{className:"results-table__json",title:JSON.stringify(J,null,2),children:JSON.stringify(J)});const pe=String(J);return pe.length>100?o.jsxs("span",{className:"results-table__long",title:pe,children:[pe.substring(0,100),"..."]}):pe};return Ae?o.jsx("div",{className:"results-table results-table--error",children:o.jsxs("div",{className:"results-table__error",children:[o.jsxs("div",{className:"results-table__error-header",children:[o.jsx("span",{className:"results-table__error-icon",children:"✗"}),s("terminal:database.queryError")]}),o.jsx("div",{className:"results-table__error-message",children:t.error}),t.errorCode&&o.jsx("div",{className:"results-table__error-code",children:s("terminal:database.errorCode",{code:t.errorCode})}),o.jsx("div",{className:"results-table__error-query",children:o.jsx("code",{children:t.query})})]})}):Z?o.jsx("div",{className:"results-table results-table--success",children:o.jsxs("div",{className:"results-table__success",children:[o.jsx("span",{className:"results-table__success-icon",children:"✓"}),s("terminal:database.querySuccess"),t.affectedRows!==void 0&&o.jsx("span",{className:"results-table__affected",children:s("terminal:database.rowsAffected",{count:t.affectedRows})}),o.jsxs("span",{className:"results-table__duration",children:[t.duration,"ms"]})]})}):o.jsxs("div",{className:"results-table",children:[o.jsxs("div",{className:"results-table__status-bar",children:[o.jsxs("div",{className:"results-table__status-info",children:[o.jsx("span",{className:"results-table__row-count",children:s("terminal:database.rowCount",{count:t.rowCount})}),o.jsxs("span",{className:"results-table__duration",children:[t.duration,"ms"]}),o.jsx("span",{className:`results-table__edit-status ${_?"results-table__edit-status--editable":"results-table__edit-status--readonly"}`,title:ge,children:ge}),o.jsx("button",{className:`results-table__copy-btn ${C?"results-table__copy-btn--success":""}`,onClick:fe,title:s("terminal:database.copyAllResults"),children:s(C?"terminal:database.copied":"terminal:database.copyAll")})]}),o.jsxs("div",{className:"results-table__pagination",children:[o.jsx("select",{className:"results-table__page-size",value:c,onChange:J=>{d(Number(J.target.value)),i(0)},children:wH.map(J=>o.jsx("option",{value:J,children:s("terminal:database.rowsPerPage",{count:J})},J))}),o.jsx("button",{className:"results-table__page-btn",disabled:r===0,onClick:()=>i(0),title:s("terminal:database.firstPage"),children:"«"}),o.jsx("button",{className:"results-table__page-btn",disabled:r===0,onClick:()=>i(J=>J-1),title:s("terminal:database.previousPage"),children:"‹"}),o.jsx("span",{className:"results-table__page-info",children:s("terminal:database.pageInfo",{current:r+1,total:ee})}),o.jsx("button",{className:"results-table__page-btn",disabled:r>=ee-1,onClick:()=>i(J=>J+1),title:s("terminal:database.nextPage"),children:"›"}),o.jsx("button",{className:"results-table__page-btn",disabled:r>=ee-1,onClick:()=>i(ee-1),title:s("terminal:database.lastPage"),children:"»"})]})]}),o.jsx("div",{className:"results-table__wrapper",children:o.jsxs("table",{className:`results-table__table ${Object.keys(k).length>0?"results-table__table--resized":""}`,children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{className:"results-table__row-num",children:"#"}),re.map(J=>{var $e;const pe=($e=t.fields)==null?void 0:$e.find(ye=>ye.name===J),Re=f===J;return o.jsxs("th",{className:`results-table__header ${Re?"results-table__header--sorted":""}`,onClick:()=>Te(J),title:pe!=null&&pe.type?`Type: ${pe.type}`:void 0,style:k[J]?{width:k[J],minWidth:k[J],maxWidth:k[J]}:void 0,children:[o.jsx("span",{className:"results-table__header-name",children:J}),Re&&o.jsx("span",{className:"results-table__sort-indicator",children:m==="asc"?"▲":"▼"}),o.jsx("span",{className:"results-table__resize-handle",onMouseDown:ye=>et(ye,J)})]},J)})]})}),o.jsx("tbody",{children:me.map((J,pe)=>o.jsxs("tr",{className:"results-table__row",children:[o.jsx("td",{className:"results-table__row-num",children:r*c+pe+1}),re.map(Re=>{const $e=JSON.stringify(Object.fromEntries(ze.map(be=>[be,J[be]]))),ye=(S==null?void 0:S.rowKey)===$e&&(S==null?void 0:S.columnName)===Re,Ie=L.get($e),te=Ie?Ie[Re]:J[Re];return o.jsx("td",{className:`results-table__cell ${ye?"results-table__cell--editing":""} ${_?"results-table__cell--editable":""} ${Ie&&Ie[Re]!==J[Re]?"results-table__cell--updated":""}`,onClick:()=>qe(Re,te,pe,$e),onDoubleClick:()=>it(Re,te),onContextMenu:be=>ie(be,Re,te,pe,$e),children:ye?o.jsxs("div",{className:"results-table__cell-input-wrapper",children:[Yf(We.get(S.columnName))?o.jsx(yH,{selected:NA(S.currentValue),onChange:be=>{const we=Array.isArray(be)?be[0]:be;T(Fe=>Fe?{...Fe,currentValue:we?jA(we):""}:null)},onCalendarClose:Be,showTimeSelect:!0,showTimeInput:!0,timeIntervals:1,timeFormat:"HH:mm:ss",dateFormat:"yyyy-MM-dd HH:mm:ss",className:"results-table__cell-input results-table__cell-input--datetime",disabled:S.isUpdating,placeholderText:"Select date and time",autoFocus:!0}):o.jsx("input",{ref:ne,type:"text",className:"results-table__cell-input",value:String(S.currentValue??""),onChange:be=>T(we=>we?{...we,currentValue:be.target.value}:null),onBlur:Be,onKeyDown:He,disabled:S.isUpdating,autoFocus:!0}),S.isUpdating&&o.jsx("span",{className:"results-table__cell-feedback results-table__cell-feedback--loading",children:"⏳"}),S.error&&o.jsx("button",{type:"button",className:"results-table__cell-feedback results-table__cell-feedback--error results-table__cell-feedback-btn",title:`${S.error}. Click to cancel editing.`,onMouseDown:be=>{be.preventDefault(),be.stopPropagation()},onClick:be=>{be.preventDefault(),be.stopPropagation(),T(null)},children:"✕"})]}):X(te)},Re)})]},pe))})]})}),y&&o.jsx("div",{className:"results-table__detail-backdrop",children:o.jsxs("div",{className:"results-table__detail",ref:K,children:[o.jsxs("div",{className:"results-table__detail-header",children:[o.jsx("span",{className:"results-table__detail-column",children:y.column}),o.jsxs("div",{className:"results-table__detail-actions",children:[_&&o.jsx("button",{className:"results-table__detail-edit-btn",onClick:()=>{w(null);const J=me.find(pe=>re.some(Re=>pe[Re]===y.value&&Re===y.column));if(J){const pe=me.indexOf(J),Re=JSON.stringify(Object.fromEntries(ze.map($e=>[$e,J[$e]])));T({rowIndex:pe,rowKey:Re,columnName:y.column,originalValue:y.value,currentValue:Pe(y.column,y.value),isUpdating:!1})}},title:"Edit this cell",children:"✏️"}),o.jsx("button",{className:"results-table__detail-close",onClick:()=>w(null),children:"✕"})]})]}),o.jsx("textarea",{className:"results-table__detail-textarea",value:SH(y.value),readOnly:!0,onFocus:J=>J.target.select()})]})}),R&&o.jsx("div",{className:`results-table__toast results-table__toast--${R.type}`,children:R.message}),$&&o.jsxs("div",{className:"results-table__query-log",children:[o.jsx("div",{className:"results-table__query-log-label",children:"Executed Query:"}),o.jsx("code",{className:"results-table__query-log-code",children:$})]}),o.jsx(Do,{isOpen:H!==null,position:(H==null?void 0:H.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:de,onClose:()=>V(null)})]})};function Ay(t){const e=[];let n=!1,s=!1,a=!1,r=!1,i=0;for(let d=0;d<t.length;d++){const f=t[d],h=t[d+1];if(a){f===`
|
|
112
|
+
`&&(a=!1);continue}if(r){f==="*"&&h==="/"&&(r=!1,d++);continue}if(n){if(f==="'"&&h==="'"){d++;continue}f==="'"&&(n=!1);continue}if(s){if(f==='"'&&h==='"'){d++;continue}f==='"'&&(s=!1);continue}if(f==="-"&&h==="-"){a=!0,d++;continue}if(f==="/"&&h==="*"){r=!0,d++;continue}if(f==="'"){n=!0;continue}if(f==='"'){s=!0;continue}if(f===";"){const m=t.slice(i,d).trim();m&&e.push({sql:m,start:i,end:d}),i=d+1}}const c=t.slice(i).trim();return c&&e.push({sql:c,start:i,end:t.length}),e}function TH(t,e){const n=Ay(t);if(n.length===0)return null;for(const s of n)if(e>=s.start&&e<=s.end)return s.sql;return n[n.length-1].sql}const iV=({query:t,onChange:e,onExecute:n,isExecuting:s,disabled:a,autoFocus:r=!0})=>{const{t:i}=dt(["terminal"]),c=x.useRef(null),d=x.useRef(null),f=x.useRef(!1),h="query-editor-height",m=80,b=800,[y,w]=x.useState(()=>{try{const I=localStorage.getItem(h);if(I){const O=Number(I);if(O>=m&&O<=b)return O}}catch{}return 150}),C=x.useCallback(I=>{try{localStorage.setItem(h,String(I))}catch{}},[]),N=x.useCallback(I=>{I.preventDefault(),f.current=!0;const O=I.clientY,_=y,M=z=>{const $=z.clientY-O,W=Math.max(m,Math.min(b,_+$));w(W)},R=()=>{var $;f.current=!1,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",R),document.body.style.cursor="",document.body.style.userSelect="";const z=($=c.current)==null?void 0:$.parentElement;z&&C(z.getBoundingClientRect().height)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",R),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[y,C]);x.useEffect(()=>{if(r&&!a&&c.current){const I=setTimeout(()=>{var O;(O=c.current)==null||O.focus()},100);return()=>clearTimeout(I)}},[r,a]);const k=x.useCallback(I=>{const O=I.currentTarget;d.current&&(d.current.scrollLeft=O.scrollLeft,d.current.scrollTop=O.scrollTop)},[]),j=x.useMemo(()=>Ay(t).length>1,[t]),S=x.useCallback(I=>{if((I.ctrlKey||I.metaKey)&&I.shiftKey&&I.key==="Enter"){I.preventDefault(),!a&&!s&&n("all");return}if((I.ctrlKey||I.metaKey)&&I.key==="Enter"&&(I.preventDefault(),!a&&!s&&n("cursor")),I.key==="Tab"){I.preventDefault();const O=I.currentTarget,_=O.selectionStart,M=O.selectionEnd,R=t.substring(0,_)+" "+t.substring(M);e(R),setTimeout(()=>{O.selectionStart=O.selectionEnd=_+2},0)}},[t,e,n,a,s]),T=x.useMemo(()=>{if(!t)return"";try{return da.highlight(t,da.languages.sql,"sql")}catch{return t}},[t]),D=x.useMemo(()=>t.split(`
|
|
113
|
+
`).map((O,_)=>_+1),[t]),E=x.useCallback(()=>{var I;return((I=c.current)==null?void 0:I.selectionStart)??0},[]);return o.jsxs("div",{className:"query-editor",children:[o.jsxs("div",{className:"query-editor__toolbar",children:[o.jsxs("div",{className:"query-editor__buttons",children:[o.jsx("button",{className:"query-editor__execute",onClick:()=>n("cursor"),disabled:a||s||!t.trim(),title:i("terminal:database.executeShortcut"),children:s?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"query-editor__spinner"}),i("common:status.running")]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"query-editor__play-icon",children:"▶"}),i(j?"terminal:database.runAtCursor":"terminal:database.runQuery")]})}),j&&o.jsxs("button",{className:"query-editor__execute-cursor",onClick:()=>n("all"),disabled:a||s||!t.trim(),title:i("terminal:database.executeCursorShortcut"),children:[o.jsx("span",{className:"query-editor__cursor-icon",children:"▶▶"}),i("terminal:database.runAll")]})]}),o.jsx("div",{className:"query-editor__hint",children:i(j?"terminal:database.pressCtrlEnterMulti":"terminal:database.pressCtrlEnter")})]}),o.jsxs("div",{className:"query-editor__input-wrapper",children:[o.jsx("div",{className:"query-editor__line-numbers",children:D.map(I=>o.jsx("span",{children:I},I))}),o.jsxs("div",{className:"query-editor__editor",style:{height:y},children:[o.jsx("pre",{ref:d,className:"query-editor__highlight","aria-hidden":"true",dangerouslySetInnerHTML:{__html:T+`
|
|
114
|
+
`}}),o.jsx("textarea",{ref:c,className:"query-editor__textarea",value:t,onChange:I=>e(I.target.value),onKeyDown:S,onScroll:k,placeholder:i(a?"terminal:database.selectDbPlaceholder":"terminal:database.enterQueryPlaceholder"),disabled:a,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off","data-cursor-pos":E()})]})]}),o.jsx("div",{className:"query-editor__resize-handle",onMouseDown:N})]})},TA=t=>`db-panel-${t}`,_H=({building:t})=>{var O,_,M,R,z,$;const e=Yx(t.id),n=iL(t.id),s=oL(t.id),a=((O=t.database)==null?void 0:O.connections)??[],[r,i]=x.useState(""),[c,d]=x.useState(!1),f=x.useRef(null),h=x.useRef(null),m=x.useMemo(()=>{if(!r)return"";try{return da.highlight(r,da.languages.sql,"sql")}catch{return r}},[r]),b=x.useCallback(()=>{h.current&&f.current&&(h.current.scrollLeft=f.current.scrollLeft,h.current.scrollTop=f.current.scrollTop)},[]),y=e.activeConnectionId??((_=t.database)==null?void 0:_.activeConnectionId)??((M=a[0])==null?void 0:M.id),w=e.activeDatabase??((R=t.database)==null?void 0:R.activeDatabase),C=a.find(W=>W.id===y),N=y?((z=e.databases)==null?void 0:z.get(y))??[]:[],k=y&&w?(($=e.tables)==null?void 0:$.get(`${y}:${w}`))??[]:[];x.useEffect(()=>{if(!c&&a.length>0){try{const W=localStorage.getItem(TA(t.id));if(W){const L=JSON.parse(W);L.connectionId&&a.some(F=>F.id===L.connectionId)&&(U.setActiveConnection(t.id,L.connectionId),U.listDatabases(t.id,L.connectionId),L.database&&(U.setActiveDatabase(t.id,L.database),U.listTables(t.id,L.connectionId,L.database)),L.lastQuery&&i(L.lastQuery))}}catch{}!e.activeConnectionId&&a[0]&&(U.setActiveConnection(t.id,a[0].id),U.listDatabases(t.id,a[0].id)),d(!0)}},[t.id,a,c,e.activeConnectionId]),x.useEffect(()=>{if(c)try{const W=TA(t.id),L=JSON.parse(localStorage.getItem(W)||"{}");L.lastQuery=r,y&&(L.connectionId=y),w&&(L.database=w),localStorage.setItem(W,JSON.stringify(L))}catch{}},[t.id,r,y,w,c]);const j=x.useCallback(W=>{U.setActiveConnection(t.id,W),U.listDatabases(t.id,W)},[t.id]),S=x.useCallback(W=>{y&&(U.setActiveDatabase(t.id,W),U.listTables(t.id,y,W))},[t.id,y]),T=x.useCallback(()=>{var F;if(!y||!w||!r.trim()||s)return;const W=((F=f.current)==null?void 0:F.selectionStart)??0;if(Ay(r).length<=1)U.executeQuery(t.id,y,w,r.trim());else{const H=TH(r,W);H?U.executeQuery(t.id,y,w,H):U.executeQuery(t.id,y,w,r.trim())}},[t.id,y,w,r,s]),D=x.useCallback(W=>{(W.ctrlKey||W.metaKey)&&W.key==="Enter"&&(W.preventDefault(),T())},[T]),E=x.useCallback(W=>{const L=`SELECT * FROM ${W} LIMIT 100`;i(L),y&&w&&U.executeQuery(t.id,y,w,L)},[t.id,y,w]),I=n[0];return a.length===0?o.jsx("div",{className:"db-inline",children:o.jsx("div",{className:"db-inline__empty",children:"🔌 No connections configured"})}):o.jsxs("div",{className:"db-inline",children:[o.jsxs("div",{className:"db-inline__toolbar",children:[a.length>1&&o.jsx("select",{className:"db-inline__select",value:y??"",onChange:W=>j(W.target.value),title:"Connection",children:a.map(W=>o.jsxs("option",{value:W.id,children:[W.engine==="mysql"?"🐬":"🐘"," ",W.name]},W.id))}),a.length===1&&C&&o.jsxs("span",{className:"db-inline__connection-badge",title:`${C.host}:${C.port}`,children:[C.engine==="mysql"?"🐬":"🐘"," ",C.name]}),o.jsxs("select",{className:"db-inline__select",value:w??"",onChange:W=>S(W.target.value),title:"Database",children:[o.jsx("option",{value:"",children:"Select database..."}),N.map(W=>o.jsx("option",{value:W,children:W},W))]}),k.length>0&&o.jsxs("select",{className:"db-inline__select db-inline__select--tables",value:"",onChange:W=>{W.target.value&&E(W.target.value)},title:"Quick query table",children:[o.jsxs("option",{value:"",children:["Tables (",k.length,")"]}),k.map(W=>o.jsx("option",{value:W.name,children:W.name},W.name))]}),o.jsx("button",{className:"db-inline__run",onClick:T,disabled:s||!w||!r.trim(),title:"Execute (Ctrl+Enter)",children:s?"⏳":"▶"})]}),o.jsxs("div",{className:"db-inline__editor",children:[o.jsx("pre",{ref:h,className:"db-inline__highlight","aria-hidden":"true",dangerouslySetInnerHTML:{__html:m+`
|
|
115
|
+
`}}),o.jsx("textarea",{ref:f,className:"db-inline__textarea",value:r,onChange:W=>i(W.target.value),onKeyDown:D,onScroll:b,placeholder:"SELECT * FROM ...",spellCheck:!1,rows:2})]}),o.jsx("div",{className:"db-inline__results",children:I?o.jsx(NH,{result:I,buildingId:t.id,building:t}):o.jsx("div",{className:"db-inline__empty",children:w?"Run a query or select a table above":"Select a database to get started"})})]})};function EH(){const t=x.useRef(!1),e=x.useRef(!1),n=x.useRef(null),s=x.useRef(0),a=x.useRef(!1),r=x.useRef(0),i=x.useRef(0),c=x.useRef(0),d=x.useCallback((w,C)=>{const N=document.querySelector(".app");N&&(N.style.setProperty("--keyboard-height",`${w}px`),N.style.setProperty("--keyboard-visible",C?"1":"0"),N.classList.toggle("keyboard-visible",C)),s.current=w,a.current=C},[]),f=x.useCallback(()=>{d(0,!1),e.current=!1},[d]),h=x.useCallback(()=>{r.current&&(cancelAnimationFrame(r.current),r.current=0),window.visualViewport&&n.current&&(window.visualViewport.removeEventListener("resize",n.current),window.visualViewport.removeEventListener("scroll",n.current),n.current=null)},[]),m=x.useCallback(()=>{if(t.current=!0,!(window.innerWidth<=768))return;if(h(),e.current=!0,!(typeof window.__nativeKeyboardHeight=="number")&&window.visualViewport){i.current=Math.max(0,window.innerHeight-(window.visualViewport.height+window.visualViewport.offsetTop)),c.current=window.innerHeight;const N=()=>{const k=window.visualViewport;k&&(r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{if(!t.current){f();return}const j=k.height+k.offsetTop,S=Math.max(0,window.innerHeight-j),T=Math.max(0,c.current-window.innerHeight),D=S>=120||T>=120;D||(i.current=S,c.current=window.innerHeight);const E=T>=120?0:D?Math.max(0,S):0;(E!==s.current||D!==a.current)&&d(E,D),D&&setTimeout(()=>{e.current=!1},300)}))};n.current=N,window.visualViewport.addEventListener("resize",N),window.visualViewport.addEventListener("scroll",N),N()}},[h,f,d]),b=x.useCallback(()=>{t.current=!1,window.innerWidth<=768&&setTimeout(()=>{t.current||(f(),h())},100)},[f,h]),y=x.useCallback(()=>{window.innerWidth<=768&&s.current>0&&(t.current=!1,f(),h())},[f,h]);return{isInputFocusedRef:t,keyboardScrollLockRef:e,handleInputFocus:m,handleInputBlur:b,cleanup:y}}function MH(){const[t,e]=x.useState(()=>{const d=Mx(pt.TERMINAL_HEIGHT,iS);return d>=oS&&d<=lS?d:iS}),n=x.useRef(!1),s=x.useRef(0),a=x.useRef(0),r=x.useRef(null),i=x.useRef(t);i.current=t;const c=x.useCallback(d=>{d.preventDefault(),n.current=!0,s.current=d.clientY,a.current=t,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0)},[t]);return x.useEffect(()=>{const d=h=>{if(!n.current)return;const m=h.clientY-s.current,b=window.innerHeight,y=m/b*100,w=Math.min(lS,Math.max(oS,a.current+y));e(w)},f=()=>{n.current&&(n.current=!1,document.body.style.cursor="",document.body.style.userSelect="",Dx(pt.TERMINAL_HEIGHT,i.current),U.setTerminalResizing(!1))};return document.addEventListener("mousemove",d),document.addEventListener("mouseup",f),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",f)}},[]),{terminalHeight:t,terminalRef:r,handleResizeStart:c}}const DH=120,RH=.7;function OH(){const[t,e]=x.useState(()=>Mx(pt.MOBILE_OVERVIEW_HEIGHT,0)),n=x.useRef(t);n.current=t;const s=x.useRef(0),a=x.useRef(0),r=()=>Math.floor(window.innerHeight*RH),i=m=>Math.min(r(),Math.max(DH,m)),c=x.useCallback(m=>{e(m);const b=document.querySelector(".guake-terminal");b&&b.style.setProperty("--guake-mobile-overview-height",`${m}px`)},[]),d=x.useCallback(()=>{document.body.style.cursor="",document.body.style.userSelect="",Dx(pt.MOBILE_OVERVIEW_HEIGHT,n.current),U.setTerminalResizing(!1)},[]),f=x.useCallback(m=>{m.preventDefault();const b=document.querySelector(".agent-overview-panel"),y=n.current>0?n.current:(b==null?void 0:b.getBoundingClientRect().height)??240;s.current=m.clientY,a.current=y,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0);const w=N=>{const k=N.clientY-s.current;c(i(a.current+k))},C=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",C),d()};document.addEventListener("mousemove",w),document.addEventListener("mouseup",C)},[c,d]),h=x.useCallback(m=>{if(m.touches.length!==1)return;const b=document.querySelector(".agent-overview-panel"),y=n.current>0?n.current:(b==null?void 0:b.getBoundingClientRect().height)??240;s.current=m.touches[0].clientY,a.current=y,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0);const w=N=>{if(N.touches.length!==1)return;N.preventDefault();const k=N.touches[0].clientY-s.current;c(i(a.current+k))},C=()=>{document.removeEventListener("touchmove",w),document.removeEventListener("touchend",C),document.removeEventListener("touchcancel",C),d()};document.addEventListener("touchmove",w,{passive:!1}),document.addEventListener("touchend",C),document.addEventListener("touchcancel",C)},[c,d]);return{mobileOverviewHeight:t,handleResizeMouseDown:f,handleResizeTouchStart:h}}function LH({agents:t,selectedAgentId:e,isOpen:n,overviewPanelOpen:s,loadingHistory:a,hasModalOpen:r=!1,outputRef:i}){const c=ur(),d=Vx(),h=Vr().vibrationIntensity??1,m=()=>{if(typeof document>"u")return!1;const z=document.querySelector(".agent-bar");if(!z)return!1;const $=window.getComputedStyle(z);if($.display==="none"||$.visibility==="hidden")return!1;const W=z.getBoundingClientRect();return W.width>0&&W.height>0},b=x.useMemo(()=>{const z=Array.from(t.values());if(!s&&m()){const ne=YR(),q=z.filter(Pe=>{if(U.isAgentInArchivedArea(Pe.id))return!1;if(ne){const ge=U.getAreaForAgent(Pe.id);if(!Fx((ge==null?void 0:ge.id)??null))return!1}return!0}).sort((Pe,ge)=>(Pe.createdAt||0)-(ge.createdAt||0)),xe=Na(pt.AGENT_ORDER,[]),Ae=new Set(q.map(Pe=>Pe.id)),Z=xe.filter(Pe=>Ae.has(Pe)),ce=q.filter(Pe=>!Z.includes(Pe.id)).map(Pe=>Pe.id),me=[...Z,...ce],ee=new Map(q.map(Pe=>[Pe.id,Pe])),re=me.map(Pe=>ee.get(Pe)).filter(Pe=>Pe!==void 0),We=new Map;for(const Pe of re){const ge=U.getAreaForAgent(Pe.id),Te=(ge==null?void 0:ge.id)??null;We.has(Te)||We.set(Te,{name:(ge==null?void 0:ge.name)??"",agents:[]}),We.get(Te).agents.push(Pe)}const ze=Array.from(We.entries());return ze.sort(([Pe,ge],[Te,qe])=>Pe===null&&Te!==null?1:Pe!==null&&Te===null?-1:Pe===null&&Te===null?0:ge.name.localeCompare(qe.name)),ze.flatMap(([,Pe])=>Pe.agents)}const $=Na(pt.AOP_CONFIG,{groupByArea:!0,sortMode:"recent",filterMode:"all",sameAreaOnly:!1}),W=U.getState(),L=new Map;for(const ne of d)L.has(ne.agentId)||L.set(ne.agentId,ne.timestamp);const F=new Map;for(const ne of z){const q=U.getAreaForAgent(ne.id);!q||q.archived||F.set(ne.id,q.id)}let H=z.filter(ne=>{if($.filterMode==="working"&&ne.status!=="working"||$.filterMode==="idle"&&ne.status!=="idle"||$.filterMode==="error"&&ne.status!=="error")return!1;if($.sameAreaOnly&&e){const q=F.get(e)??null,xe=F.get(ne.id)??null;if(q!==xe)return!1}return!0});const V=ne=>[...ne].sort((q,xe)=>{const Ae=!!(q.isBoss||q.class==="boss"),Z=!!(xe.isBoss||xe.class==="boss");if(Ae!==Z)return Ae?-1:1;if($.sortMode==="name")return q.name.localeCompare(xe.name);if($.sortMode==="status"){const ee=["working","waiting_input","waiting_permission","error","idle","stopped"],re=ee.indexOf(q.status)-ee.indexOf(xe.status);if(re!==0)return re;const We=W.agentsWithUnseenOutput.has(q.id),ze=W.agentsWithUnseenOutput.has(xe.id);if(We!==ze)return We?-1:1;if(q.status==="working"&&xe.status==="working")return q.name.localeCompare(xe.name);if(q.status==="idle"&&xe.status==="idle"){const Pe=!!q.taskLabel,ge=!!xe.taskLabel;return Pe!==ge?Pe?-1:1:(xe.lastActivity||0)-(q.lastActivity||0)}return(xe.lastActivity||0)-(q.lastActivity||0)}const ce=L.get(q.id)||0;return(L.get(xe.id)||0)-ce});if(!$.groupByArea)return V(H);const G=[],B=new Set;for(const[ne,q]of c){if(q.archived)continue;const xe=H.filter(Ae=>F.get(Ae.id)===ne);if(xe.length>0){const Ae=V(xe);G.push(...Ae);for(const Z of Ae)B.add(Z.id)}}const K=V(H.filter(ne=>!B.has(ne.id)));return G.push(...K),H=G,H},[t,c,d,e,s]),[y,w]=x.useState(0),[C,N]=x.useState(""),k=x.useRef(null),[j,S]=x.useState(null),T=e?b.findIndex(z=>z.id===e):-1,D=T>0?b[T-1]:b[b.length-1],E=T<b.length-1?b[T+1]:b[0],I=x.useRef(null),O=x.useCallback(()=>{if(!e||b.length<=1)return;const z=b.findIndex(W=>W.id===e);if(z===-1)return;const $=(z-1+b.length)%b.length;S("left"),w(0),N(""),U.setLastSelectionViaSwipe(!0),U.selectAgent(b[$].id)},[e,b]),_=x.useCallback(()=>{if(!e||b.length<=1)return;const z=b.findIndex(W=>W.id===e);if(z===-1)return;const $=(z+1)%b.length;S("right"),w(0),N(""),U.setLastSelectionViaSwipe(!0),U.selectAgent(b[$].id)},[e,b]),M=x.useCallback(z=>{w(z),N("is-swiping")},[]),R=x.useCallback(()=>{N("is-animating"),w(0),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{N("")},100)},[]);return x.useEffect(()=>{if(!j||a)return;const z=j;S(null),requestAnimationFrame(()=>{N(z==="left"?"swipe-in-left":"swipe-in-right"),k.current=setTimeout(()=>{N("")},120)})},[j,a]),x.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),Bk(I,{enabled:n&&b.length>1,onSwipeLeft:_,onSwipeRight:O,onSwipeMove:M,onSwipeCancel:R,threshold:40,maxVerticalMovement:50,vibrationIntensity:h}),Bk(i,{enabled:n&&b.length>1,onSwipeLeft:_,onSwipeRight:O,onSwipeMove:M,onSwipeCancel:R,threshold:50,maxVerticalMovement:35,vibrationIntensity:h}),x.useEffect(()=>{const z=$=>{if(!n||b.length<=1||r)return;const W=U.getShortcuts(),L=W.find(K=>K.id==="prev-working-agent"),F=W.find(K=>K.id==="next-working-agent"),H=W.find(K=>K.id==="prev-agent-terminal"),V=W.find(K=>K.id==="next-agent-terminal"),G=$.altKey&&$.shiftKey&&!$.ctrlKey&&!$.metaKey&&$.code==="KeyJ",B=$.altKey&&$.shiftKey&&!$.ctrlKey&&!$.metaKey&&$.code==="KeyK";if(Tn($,L)){$.preventDefault();const K=U.getState();let ne=b.filter(Ae=>K.agentsWithUnseenOutput.has(Ae.id));if(ne.length===0&&(ne=b.filter(Ae=>Ae.status==="working")),ne.length===0)return;const q=e?ne.findIndex(Ae=>Ae.id===e):-1,xe=q===-1?ne.length-1:(q-1+ne.length)%ne.length;U.selectAgent(ne[xe].id);return}if(Tn($,F)){$.preventDefault();const K=U.getState();let ne=b.filter(Ae=>K.agentsWithUnseenOutput.has(Ae.id));if(ne.length===0&&(ne=b.filter(Ae=>Ae.status==="working")),ne.length===0)return;const q=e?ne.findIndex(Ae=>Ae.id===e):-1,xe=q===-1?0:(q+1)%ne.length;U.selectAgent(ne[xe].id);return}if(Tn($,H)||B){$.preventDefault(),O();return}if(Tn($,V)||G){$.preventDefault(),_();return}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[n,b,e,O,_,r]),{sortedAgents:b,swipeOffset:y,swipeAnimationClass:C,currentAgentIndex:T,prevAgent:D,nextAgent:E,headerRef:I,outputRef:i,handleSwipeLeft:O,handleSwipeRight:_}}function IH(t){if("type"in t&&"content"in t){const n=t;let s=n.content||"";return n._bashOutput&&(s+=" "+n._bashOutput),n._bashCommand&&(s+=" "+n._bashCommand),n.toolName&&(s+=" "+n.toolName),s}return t.text||""}function PH(t,e){if(e==="advanced")return!0;if("type"in t&&"content"in t){const a=t,r=a.content||"";return!(a.type==="user"&&(r.includes("<command-name>/cost</command-name>")||r.includes("<command-name>/compact</command-name>"))||a.type==="tool_result")}const n=t;if(e==="chat"){if(n.isUserPrompt)return!0;const a=n.text||"";return!(a.startsWith("Using tool:")||a.startsWith("Tool result:")||a.startsWith("Tool error:"))}return!(n.text||"").startsWith("Tool result:")}function BH({selectedAgentId:t,isOpen:e,allItems:n,viewMode:s,hasMoreHistory:a,loadAllHistory:r,loadingMore:i}){const[c,d]=x.useState(!1),[f,h]=x.useState(""),[m,b]=x.useState(0),[y,w]=x.useState(null),[C,N]=x.useState(!1),k=x.useRef(null),j=x.useRef(!1);x.useEffect(()=>{if(!c){j.current=!1;return}if(!a){N(!1);return}i||j.current||(j.current=!0,N(!0),r().finally(()=>{N(!1)}))},[c,a,i,r]);const S=x.useMemo(()=>{if(!f.trim()||f.trim().length<2)return[];const _=f.trim().toLowerCase(),M=[];for(let R=0;R<n.length;R++)IH(n[R]).toLowerCase().includes(_)&&PH(n[R],s)&&M.push(R);return M},[n,f,s]);x.useEffect(()=>{if(S.length>0){const _=S.length-1;b(_),w(S[_])}else b(0),w(null)},[S]),x.useEffect(()=>{c&&k.current&&requestAnimationFrame(()=>{var _;(_=k.current)==null||_.focus()})},[c]);const T=x.useCallback(()=>{if(S.length===0)return;const _=(m+1)%S.length;b(_),w(S[_])},[m,S]),D=x.useCallback(()=>{if(S.length===0)return;const _=(m-1+S.length)%S.length;b(_),w(S[_])},[m,S]),E=x.useCallback(()=>{d(_=>(_&&(h(""),b(0),w(null),N(!1)),!_))},[]),I=x.useCallback(()=>{d(!1),h(""),b(0),w(null),N(!1)},[]);x.useEffect(()=>{c&&(h(""),b(0),w(null))},[t]),x.useEffect(()=>{const _=M=>{var R;(M.ctrlKey||M.metaKey)&&M.key==="f"&&e&&(M.preventDefault(),c?(R=k.current)==null||R.focus():d(!0))};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[e,c]);const O=c&&f.trim().length>=2&&S.length>0?f.trim():void 0;return{searchMode:c,searchQuery:f,setSearchQuery:h,searchInputRef:k,toggleSearch:E,closeSearch:I,highlightQuery:O,matchIndices:S,currentMatch:m,navigateNext:T,navigatePrev:D,scrollToIndex:y,loadingFullHistory:C}}const FH=new Map,zH=[];function $H({selectedAgentId:t}){const[e,n]=x.useState(new Map),[s,a]=x.useState(new Map),[r,i]=x.useState(new Map),[c,d]=x.useState(new Map),f=x.useRef(new Map),h=x.useRef(0);x.useEffect(()=>{if(!t||e.has(t))return;const z=Fa(`${pt.INPUT_TEXT_PREFIX}${t}`);z&&n(W=>new Map(W).set(t,z));const $=Fa(`${pt.PASTED_TEXTS_PREFIX}${t}`);if($)try{const W=JSON.parse($),L=new Map(W);i(H=>new Map(H).set(t,L));const F=Math.max(0,...W.map(([H])=>H));f.current.set(t,F)}catch{}},[t,e]);const m=t&&e.get(t)||"",b=t&&s.get(t)||!1,y=(t?r.get(t):void 0)||FH,w=(t?c.get(t):void 0)||zH,C=m.includes(`
|
|
116
|
+
`),k=typeof window<"u"&&window.innerWidth<=768||b||C||m.length>50,j=x.useCallback(z=>{t&&(n($=>new Map($).set(t,z)),z?Wr(`${pt.INPUT_TEXT_PREFIX}${t}`,z):Ik(`${pt.INPUT_TEXT_PREFIX}${t}`))},[t]),S=x.useCallback(z=>{t&&a($=>new Map($).set(t,z))},[t]),T=x.useCallback(z=>{t&&i($=>{const W=new Map($),L=$.get(t)||new Map,F=typeof z=="function"?z(L):z;if(W.set(t,F),F.size>0){const H=JSON.stringify(Array.from(F.entries()));Wr(`${pt.PASTED_TEXTS_PREFIX}${t}`,H)}else Ik(`${pt.PASTED_TEXTS_PREFIX}${t}`);return W})},[t]),D=x.useCallback(z=>{t&&d($=>{const W=new Map($),L=$.get(t)||[],F=typeof z=="function"?z(L):z;return W.set(t,F),W})},[t]),E=x.useCallback(()=>{if(!t)return 0;const $=(f.current.get(t)||0)+1;return f.current.set(t,$),$},[t]),I=x.useCallback(()=>{t&&f.current.set(t,0)},[t]),O=x.useCallback(z=>{D($=>$.filter(W=>W.id!==z))},[D]),_=x.useCallback(async(z,$)=>{try{const W=$||(z instanceof File?z.name:""),L=encodeURIComponent(W),F=await Bt(Rt("/api/files/upload"),{method:"POST",headers:{"Content-Type":z.type||"application/octet-stream","X-Filename":L},body:z});if(!F.ok)return console.error("Upload failed:",await F.text()),null;const H=await F.json();return h.current+=1,{id:h.current,name:H.filename,path:H.absolutePath,isImage:H.isImage,size:H.size}}catch(W){return console.error("Upload error:",W),null}},[]),M=x.useCallback(z=>{let $=z;for(const[W,L]of y){const F=new RegExp(`\\[Pasted text #${W} \\+\\d+ lines\\]`,"g");$=$.replace(F,L)}return $},[y]),R=x.useCallback(()=>{const z=(m.match(/\n/g)||[]).length+1,$=Math.ceil(m.length/60),W=Math.max(z,$,2);return Math.min(W,10)},[m]);return x.useMemo(()=>({command:m,setCommand:j,forceTextarea:b,setForceTextarea:S,useTextarea:k,pastedTexts:y,setPastedTexts:T,incrementPastedCount:E,resetPastedCount:I,attachedFiles:w,setAttachedFiles:D,removeAttachedFile:O,uploadFile:_,expandPastedTexts:M,getTextareaRows:R}),[m,j,b,S,k,y,T,E,I,w,D,O,_,M,R])}const Cb=10;function UH({totalMessages:t,isOpen:e,hasModalOpen:n=!1,scrollContainerRef:s,selectedAgentId:a,inputRef:r,textareaRef:i,useTextarea:c=!1}){const[d,f]=x.useState(-1),h=x.useRef(null);x.useEffect(()=>{h.current!==a&&(f(-1),h.current=a)},[a]);const m=x.useCallback(()=>{f(-1)},[]),b=x.useRef(null),y=D=>1-Math.pow(1-D,3),w=x.useCallback((D,E,I=200)=>{b.current&&cancelAnimationFrame(b.current);const O=D.scrollTop,_=E-O,M=performance.now(),R=z=>{const $=z-M,W=Math.min($/I,1),L=y(W);D.scrollTop=O+_*L,W<1?b.current=requestAnimationFrame(R):b.current=null};b.current=requestAnimationFrame(R)},[]),C=x.useCallback(D=>{if(!s.current)return;const E=s.current,I=E.querySelector(`[data-message-index="${D}"]`);if(I){const O=E.getBoundingClientRect(),_=I.getBoundingClientRect(),M=20;if(_.top<O.top+M){const R=E.scrollTop+(_.top-O.top)-M;w(E,R,180)}else if(_.bottom>O.bottom-M){const R=E.scrollTop+(_.bottom-O.bottom)+M;w(E,R,180)}}},[s,w]);x.useEffect(()=>()=>{b.current&&cancelAnimationFrame(b.current)},[]);const N=x.useCallback(()=>{t!==0&&f(D=>{let E;return D===-1?E=t-1:D>0?E=D-1:E=0,requestAnimationFrame(()=>C(E)),E})},[t,C]),k=x.useCallback(()=>{t!==0&&f(D=>{let E;if(D===-1)E=t-1;else if(D<t-1)E=D+1;else return-1;return requestAnimationFrame(()=>C(E)),E})},[t,C]),j=x.useCallback(()=>{t!==0&&f(D=>{let E;return D===-1?E=t-1:E=Math.max(0,D-Cb),requestAnimationFrame(()=>C(E)),E})},[t,C]),S=x.useCallback(()=>{t!==0&&f(D=>{let E;if(D===-1)E=t-1;else{if(D+Cb>=t)return-1;E=D+Cb}return requestAnimationFrame(()=>C(E)),E})},[t,C]),T=x.useCallback(D=>d===D,[d]);return x.useEffect(()=>{const D=E=>{if(!e||n)return;const I=U.getShortcuts(),O=I.find(L=>L.id==="prev-message"),_=I.find(L=>L.id==="next-message"),M=I.find(L=>L.id==="page-up-messages"),R=I.find(L=>L.id==="page-down-messages"),z=I.find(L=>L.id==="activate-message");if(Tn(E,O)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),N();return}if(Tn(E,_)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),k();return}if(Tn(E,M)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),j();return}if(Tn(E,R)){E.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),S();return}if(E.key==="Escape"&&d!==-1){E.preventDefault(),m();return}const $=E.target,W=$.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable;if(Tn(E,z)&&d!==-1&&!W){E.preventDefault();const L=s.current;if(!L)return;const F=L.querySelector(`[data-message-index="${d}"]`);if(!F)return;const H=[".clickable-path",".output-tool-use.bash-clickable",".clickable-bash",".history-view-md-btn"];for(const G of H){const B=F.querySelector(G);if(B){B.click();return}}const V=F.querySelector(".output-tool-use");V!=null&&V.classList.contains("bash-clickable")&&V.click();return}if(d!==-1&&!W){const L=Tn(E,O)||Tn(E,_)||Tn(E,M)||Tn(E,R),F=["Escape","Tab","Shift","Control","Alt","Meta","CapsLock"].includes(E.key),H=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(E.key),V=E.key.startsWith("F")&&E.key.length<=3;if(!L&&!F&&!H&&!V&&!E.ctrlKey&&!E.metaKey){const G=c?i==null?void 0:i.current:r==null?void 0:r.current;if(G){G.focus(),f(-1);return}}}};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[e,n,N,k,j,S,m,d,r,i,c]),x.useEffect(()=>{d>=t&&t>0?f(t-1):t===0&&f(-1)},[t,d]),{selectedIndex:d,setSelectedIndex:f,clearSelection:m,navigatePrev:N,navigateNext:k,navigatePageUp:j,navigatePageDown:S,isSelected:T}}const HH=3e4;function WH(t){const[e,n]=x.useState(new Map),[s,a]=x.useState(new Set),r=x.useRef(null),i=x.useMemo(()=>!t||t.length===0?null:[...new Set(t.map(h=>h.dir))].sort(),[t]),c=i?i.join(`
|
|
117
|
+
`):"",d=x.useCallback(async()=>{if(!i||i.length===0){n(new Map);return}const h=Ii(),m={};h&&(m.Authorization=`Bearer ${h}`);const b=Ea(),y=new Map;await Promise.all(i.map(async w=>{try{const C=await fetch(`${b}/api/files/git-branch?path=${encodeURIComponent(w)}`,{headers:m});if(C.ok){const N=await C.json();N.branch&&y.set(w,{branch:N.branch,ahead:N.ahead||0,behind:N.behind||0})}}catch{}})),n(y)},[i]);x.useEffect(()=>{if(!i||i.length===0){n(new Map);return}return d(),r.current=setInterval(d,HH),()=>{r.current&&clearInterval(r.current)}},[c,d]);const f=x.useCallback(async h=>{a(m=>new Set(m).add(h));try{await Bt(Rt("/api/files/git-fetch"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:h})}),await d()}catch{}finally{a(m=>{const b=new Set(m);return b.delete(h),b})}},[d]);return{branches:e,fetchRemote:f,fetchingDirs:s,refetch:d}}const fs={Read:"📖",Write:"✏️",Edit:"📝",Bash:"💻",Glob:"🔍",Grep:"🔎",Task:"📋",Agent:"🤖",WebFetch:"🌐",WebSearch:"🌍",TodoWrite:"✅",NotebookEdit:"📓",AskFollowupQuestion:"❓",AskUserQuestion:"❓",AttemptCompletion:"✨",ListFiles:"📂",SearchFiles:"🔎",ExecuteCommand:"⚙️",spawn_agent:"🧬",send_input:"📨",wait:"⏳",default:"⚡"},qH={Read:"tools:display.toolNames.read",Write:"tools:display.toolNames.write",Edit:"tools:display.toolNames.edit",Bash:"tools:display.toolNames.bash",Glob:"tools:display.toolNames.glob",Grep:"tools:display.toolNames.grep",Task:"tools:display.toolNames.task",Agent:"tools:display.toolNames.agent",WebFetch:"tools:display.toolNames.webFetch",WebSearch:"tools:display.toolNames.webSearch",TodoWrite:"tools:display.toolNames.todoWrite",NotebookEdit:"tools:display.toolNames.notebookEdit",AskFollowupQuestion:"tools:display.toolNames.askFollowupQuestion",AskUserQuestion:"tools:display.toolNames.askUserQuestion",AttemptCompletion:"tools:display.toolNames.attemptCompletion",ListFiles:"tools:display.toolNames.listFiles",SearchFiles:"tools:display.toolNames.searchFiles",ExecuteCommand:"tools:display.toolNames.executeCommand",spawn_agent:"tools:display.toolNames.spawnAgent",send_input:"tools:display.toolNames.sendInput",wait:"tools:display.toolNames.wait"};function yT(t,e){const n=qH[t];return n&&e(n,{defaultValue:t})||t}function Fp(t){return(typeof t=="string"?new Date(t):new Date(t)).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function vT(t,e){var n;try{const s=JSON.parse(e);switch(t){case"Read":case"Write":case"Edit":case"NotebookEdit":{const a=s.file_path||s.path||s.notebook_path;if(a)return a;break}case"Bash":{const a=s.command;if(a)return kT(a);break}case"Grep":{const a=s.pattern,r=s.path;if(a&&r)return`"${a}" in ${r}`;if(a)return`"${a}"`;break}case"Glob":{const a=s.pattern,r=s.path;if(a&&r)return`${a} in ${r}`;if(a)return a;break}case"WebFetch":{const a=s.url;if(a)return a;break}case"WebSearch":{const a=s.query;if(a)return`"${a}"`;break}case"Task":case"Agent":{const a=s.description,r=s.subagent_type;if(a)return r?`[${r}] ${a}`:a;if(s.prompt)return s.prompt;break}case"ExitPlanMode":case"EnterPlanMode":{const a=s.allowedPrompts;return Array.isArray(a)&&a.length>0?a.map(r=>r.prompt||r.tool||"").filter(Boolean).join(", "):t==="ExitPlanMode"&&typeof s.plan=="string"&&s.plan.trim().length>0?s.plan.trim():t==="ExitPlanMode"?"Plan ready":"Entering plan mode"}case"TodoWrite":{const a=s.todos;if(Array.isArray(a)&&a.length>0){const r=a.filter(f=>f.status==="completed").length,i=a.filter(f=>f.status==="in_progress").length,c=a.filter(f=>f.status==="pending").length,d=[];return r>0&&d.push(`${r} done`),i>0&&d.push(`${i} active`),c>0&&d.push(`${c} pending`),`${a.length} items (${d.join(", ")})`}break}case"AskUserQuestion":case"AskFollowupQuestion":{const a=s.questions||s.question;if(a){const r=Array.isArray(a)?(n=a[0])==null?void 0:n.question:a;if(r)return r}break}default:{for(const[,a]of Object.entries(s))if(typeof a=="string"&&a.length>0)return a;break}}}catch{}return null}function wT(t){if(!t.includes("curl")||!t.includes("/api/exec"))return null;const e=[],n=[/(?:-d|--data|--data-raw)\s+'((?:\\'|[^'])*)'/g,/(?:-d|--data|--data-raw)\s+"((?:\\"|[^"])*)"/g];for(const s of n){let a;for(;(a=s.exec(t))!==null;)a[1]&&e.push(a[1])}for(const s of e){const a=[s,s.replace(/\\"/g,'"'),s.replace(/\\'/g,"'"),s.replace(/\\"/g,'"').replace(/\\\\/g,"\\")];for(const r of a){const i=r.trim();if(!(!i.startsWith("{")||!i.endsWith("}")))try{const c=JSON.parse(i);if(typeof c.command=="string"&&c.command.length>0)return c.command}catch{}}}return null}function kT(t){return wT(t)||t}const _A=/(^|[\s("'`])((?:\.{1,2}\/|~\/|\/)?[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*\.[A-Za-z0-9._-]+(?::\d+(?::\d+)?)?)/g;function VH(t){return!t||t.startsWith("-")||t.includes("://")||t.includes("*")?!1:t.includes(".")&&!t.endsWith(".")}function ST(t){if(!t)return[{text:""}];const e=[];let n=0;_A.lastIndex=0;let s;for(;(s=_A.exec(t))!==null;){const a=s[0],r=s[1]||"",i=s[2]||"",c=s.index;c>n&&e.push({text:t.slice(n,c)}),r&&e.push({text:r}),VH(i)?e.push({text:i,fileRef:i}):e.push({text:i}),n=c+a.length}return n<t.length&&e.push({text:t.slice(n)}),e.length>0?e:[{text:t}]}const zp="tide-file://",YH=/(^|[\s(>])((?:\.\.?\/|\/)?(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)+(?:#L\d+(?:C\d+)?)?(?::\d+(?::\d+)?)?)(?=$|[\s),.;])/g,GH=/`((?:\.\.?\/|\/)?(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)+(?:#L\d+(?:C\d+)?)?(?::\d+(?::\d+)?)?)`/g,KH=/\.(com|org|net|io|dev|app|co|me|info|biz|us|uk|de|fr|jp|cn|ru|edu|gov|mil|int|xyz|tech|online|site|store|blog|cloud|ai|gg|tv|cc|sh|fm|to|ly|gl|so|is|it|at|nl|ch|se|no|fi|dk|be|cz|pl|pt|br|mx|ar|cl|in|au|nz|za|sg|hk|tw|kr|id|ph|th|vn|my)(?:[:/\s#?]|$)/i;function EA(t){if(!t||t.includes("://")||t.startsWith("www.")||t.includes("@"))return!1;const e=t.split("/")[0];return KH.test(e)?!1:t.includes(".")&&!t.endsWith(".")}function lp(t){if(!t||!t.includes("."))return t;const e=t.split(`
|
|
118
|
+
`);let n=!1;return e.map(a=>{if(a.trimStart().startsWith("```"))return n=!n,a;if(n)return a;const i=a.replace(GH,(c,d)=>{if(!EA(d))return c;const f=encodeURIComponent(d);return`[\`${d}\`](${zp}${f})`});return i.replace(YH,(c,d,f,h)=>{const m=h+d.length,b=m>0?i[m-1]:"",y=m+f.length<i.length?i[m+f.length]:"";if(b==="("&&m>1&&i[m-2]==="]"||b==="["||y==="]"||!EA(f))return c;const w=encodeURIComponent(f);return`${d}[${f}](${zp}${w})`})}).join(`
|
|
119
|
+
`)}function QH(t){if(!t||!t.startsWith(zp))return null;const e=t.slice(zp.length);if(!e)return null;try{return decodeURIComponent(e)}catch{return e}}function Li(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function CT(t){const e=t.trim();if(!e)return null;let n,s=e;const a=e.match(/^(\S+)\s+-lc\s+([\s\S]+)$/);if(a&&(n=`${a[1]} -lc`,s=Li(a[2].trim())),!/\brg\s+--files\b/.test(s)||!/\|\s*rg\b/.test(s))return null;const r=s.match(/\|\s*rg\b\s+(.+)$/);if(!r)return null;const i=r[1].trim();if(!i)return null;const c=i.replace(/^(?:-\S+\s+)*/,"").trim(),d=Li(c||i);return d?{shellPrefix:n,commandBody:s,searchTerm:d}:null}function AT(t){const e=t.trim();if(!e)return null;let n,s=e;const a=e.match(/^(\S+)\s+-lc\s+([\s\S]+)$/);a&&(n=`${a[1]} -lc`,s=Li(a[2].trim()));const r=/\bcurl\b[\s\S]*\/api\/notify\b/.test(s),i=/\bgdbus\b[\s\S]*org\.freedesktop\.Notifications\.Notify\b/.test(s);if(!r&&!i)return null;let c,d;const f=s.match(/-d\s+((['"])([\s\S]*?)\2)/);if(f){const h=Li(f[1]).replace(/\\"/g,'"'),m=h.match(/"title"\s*:\s*"([^"]*)"/),b=h.match(/"message"\s*:\s*"([^"]*)"/);m!=null&&m[1]&&(c=m[1]),b!=null&&b[1]&&(d=b[1])}if(!c||!d){const h=s.match(/Notifications\.Notify[\s\S]*?\s'[^']*'\s+\d+\s+'[^']*'\s+'([^']*)'\s+'([^']*)'/);!c&&(h!=null&&h[1])&&(c=h[1]),!d&&(h!=null&&h[2])&&(d=h[2])}return{shellPrefix:n,commandBody:s,title:c,message:d,viaCurl:r,viaGdbus:i}}function jT(t){const e=t.trim();if(!e)return null;let n,s=e;const a=e.match(/^(\S+)\s+-lc\s+([\s\S]+)$/);if(a&&(n=`${a[1]} -lc`,s=Li(a[2].trim())),!/\bcurl\b/.test(s)||!/PATCH/.test(s)||!/\/api\/agents\//.test(s))return null;const r=s.match(/-d\s+((['"])([\s\S]*?)\2)/);if(!r)return null;const c=Li(r[1]).replace(/\\"/g,'"').match(/"taskLabel"\s*:\s*"([^"]*)"/);return c!=null&&c[1]?{shellPrefix:n,commandBody:s,taskLabel:c[1]}:null}function NT(t){const e=t.trim();if(!e)return null;let n,s=e;const a=e.match(/^(\S+)\s+-lc\s+([\s\S]+)$/);if(a&&(n=`${a[1]} -lc`,s=Li(a[2].trim())),!/\bcurl\b/.test(s)||!/\/api\/agents\/.*\/report-task\b/.test(s))return null;let r="",i="completed";const c=s.match(/<<'?EOF'?\s*\n([\s\S]*?)\nEOF/);if(c)try{const d=JSON.parse(c[1].trim());r=d.summary||"",i=d.status==="failed"?"failed":"completed"}catch{}else{const d=s.match(/-d\s+((['"])([\s\S]*?)\2)/);if(d){const f=Li(d[1]).replace(/\\"/g,'"'),h=f.match(/"summary"\s*:\s*"([^"]*)"/),m=f.match(/"status"\s*:\s*"([^"]*)"/);h&&(r=h[1]),(m==null?void 0:m[1])==="failed"&&(i="failed")}}return{shellPrefix:n,commandBody:s,summary:r,status:i}}const MA=300;function XH(t){if(!t)return!1;if(t.startsWith("Using tool:"))return!0;if(t.startsWith("Tool input:")||t.startsWith("Tool result:")||t.startsWith("Bash output:")||t.startsWith("Tokens:")||t.startsWith("Cost:"))return!1;if(t.startsWith("[thinking]"))return!0;if(t.startsWith("[raw]")||t.startsWith("Session started:")||t.startsWith("Session initialized"))return!1;const e=t.trim();return!(e.startsWith("{")&&['"file_path"','"command"','"pattern"','"path"','"content"','"old_string"','"new_string"','"query"','"url"','"prompt"','"notebook_path"','"description"','"offset"','"limit"'].some(s=>e.includes(s)))}function JH(t){if(!t||t.startsWith("Using tool:")||t.startsWith("Tool input:")||t.startsWith("Tool result:")||t.startsWith("Tokens:")||t.startsWith("Cost:")||t.startsWith("[thinking]")||t.startsWith("[raw]")||t.startsWith("Session started:")||t.startsWith("Session initialized"))return!1;const e=t.trim();return!(e.startsWith("{")&&['"file_path"','"command"','"pattern"','"path"','"content"','"old_string"','"new_string"','"query"','"url"','"prompt"','"notebook_path"','"description"','"offset"','"limit"'].some(a=>e.includes(a))||[/^(let me|i'll|i will|now i|first,? i|i need to|i should|i'm going to)/i,/^(looking at|reading|checking|searching|exploring|examining|investigating)/i,/^(based on|from what|according to|it (looks|seems|appears))/i,/^(this (shows|indicates|suggests|means|is))/i,/^(the (code|file|function|class|component|implementation))/i,/^(now (let|i))/i].some(s=>s.test(e)))}function TT({outputs:t,viewMode:e}){return x.useMemo(()=>{if(e==="advanced")return t;if(e==="chat")return t.filter(s=>s.isUserPrompt?!0:s.text?JH(s.text):!1);const n=[];for(let s=0;s<t.length;s++){const a=t[s];if(a.isUserPrompt){n.push(a);continue}if(!a.text){n.push(a);continue}if(a.text.startsWith("Using tool:")){const r=a.text.replace("Using tool:","").trim();let i=null,c,d,f,h;for(let b=s+1;b<t.length&&b<=s+5;b++){const y=t[b];if(y.text.startsWith("Tool input:")){const w=y.text.replace("Tool input:","").trim();if(i=vT(r,w),r==="Edit")try{const C=JSON.parse(w);(C.old_string!==void 0||C.new_string!==void 0||C.unified_diff!==void 0)&&(c={oldString:C.old_string||"",newString:C.new_string||"",operation:typeof C.operation=="string"?C.operation:void 0,unifiedDiff:typeof C.unified_diff=="string"?C.unified_diff:void 0})}catch{}if(r==="TodoWrite")try{const C=JSON.parse(w);Array.isArray(C.todos)&&(d=w)}catch{}if(r==="Bash")try{const C=JSON.parse(w);C.command&&(h=C.command)}catch{}}if(r==="Bash"&&y.text.startsWith("Bash output:")&&(f=y.text.replace("Bash output:","").trim()),y.text.startsWith("Using tool:"))break}r==="Bash"&&i&&i.length>MA&&(i=i.substring(0,MA-3)+"...");const m=r==="Bash"&&!f;n.push({...a,_toolKeyParam:i||void 0,_editData:c,_todoInput:d,_bashOutput:f,_bashCommand:h,_isRunning:m});continue}XH(a.text)&&n.push(a)}return n},[t,e])}function _T({outputs:t,viewMode:e}){const n=x.useRef(0),s=x.useRef(0),a=TT({outputs:t,viewMode:e});if(t.length!==n.current||a.length!==s.current){const r=t.length>0?t[t.length-1]:null,i=r!=null&&r.text?r.text.slice(0,40):null;Uu.info(`Filter: in=${t.length} out=${a.length} mode=${e}`,{inputLen:t.length,outputLen:a.length,viewMode:e,lastInput:i},"useFilteredOutputs"),n.current=t.length,s.current=a.length}return a}function ZH(t){const e=t.replace(/^[\p{Emoji_Presentation}\p{Extended_Pictographic}\uFE0F]+\s*/u,"").trim();if(!e)return null;const n=U.getState().agents;for(const[s,a]of n)if(a.name===e)return s;return null}function Iu(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(Iu).join(""):Ce.isValidElement(t)?Iu(t.props.children):""}const e6=/\.(com|org|net|io|dev|app|co|me|info|biz|us|uk|de|fr|jp|cn|ru|edu|gov|mil|int|xyz|tech|online|site|store|blog|cloud|ai|gg|tv|cc|sh|fm|to|ly|gl|so|is|it|at|nl|ch|se|no|fi|dk|be|cz|pl|pt|br|mx|ar|cl|in|au|nz|za|sg|hk|tw|kr|id|ph|th|vn|my)$/i;function jy(t){const e=t.split("/")[0].split("?")[0].split("#")[0];return e6.test(e)}function t6(t){return!t||t.startsWith("#")||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(t)||jy(t)?!1:t.includes(".")||t.startsWith("/")||t.startsWith("./")||t.startsWith("../")}function n6(t){if(!t||t.includes(`
|
|
120
|
+
`))return!1;const e=t.trim();return!e||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)||jy(e)?!1:e.includes(".")&&(e.includes("/")||/^[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+$/.test(e))}const ld=({onFileClick:t}={})=>({h1:({children:e})=>o.jsx("h1",{style:{fontSize:"1.4em",color:"var(--accent-pink)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h2:({children:e})=>o.jsx("h2",{style:{fontSize:"1.25em",color:"var(--accent-purple)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h3:({children:e})=>o.jsx("h3",{style:{fontSize:"1.15em",color:"var(--accent-cyan)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h4:({children:e})=>o.jsx("h4",{style:{fontSize:"1.1em",color:"var(--accent-green)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h5:({children:e})=>o.jsx("h5",{style:{fontSize:"1.05em",color:"var(--accent-yellow)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),h6:({children:e})=>o.jsx("h6",{style:{fontSize:"1em",color:"var(--accent-orange)",fontWeight:600,margin:"0.6em 0 0.3em"},children:e}),p:({children:e})=>o.jsx("p",{style:{margin:"0.4em 0"},children:e}),strong:({children:e})=>{const n=Iu(e),s=ZH(n);return s?o.jsx("strong",{className:"clickable-agent-name",style:{color:"var(--accent-orange)",fontWeight:600,cursor:"pointer"},onClick:a=>{a.stopPropagation(),U.selectAgent(s),U.setTerminalOpen(!0)},children:e}):o.jsx("strong",{style:{color:"var(--accent-orange)",fontWeight:600},children:e})},em:({children:e})=>o.jsx("em",{style:{color:"var(--accent-yellow)",fontStyle:"italic"},children:e}),del:({children:e})=>o.jsx("del",{style:{color:"var(--accent-red)",textDecoration:"line-through"},children:e}),code:({children:e,className:n})=>{if(n==null?void 0:n.includes("language-")){const a=(n==null?void 0:n.replace("language-",""))??"",r=Iu(e);if(a&&w4(a)){const i=Mo(r,a);return o.jsx("code",{className:n,style:{background:"none",padding:0,fontSize:"12px",lineHeight:1.5},dangerouslySetInnerHTML:{__html:i}})}return o.jsx("code",{style:{background:"none",padding:0,color:"var(--text-primary)",fontSize:"12px",lineHeight:1.5},children:e})}return o.jsx("code",{style:{background:"color-mix(in srgb, var(--bg-tertiary) 80%, transparent)",color:"var(--accent-green)",padding:"0.15em 0.4em",borderRadius:"3px",fontSize:"0.9em"},children:e})},pre:({children:e})=>o.jsx("pre",{style:{background:"color-mix(in srgb, var(--bg-primary) 90%, transparent)",border:"1px solid var(--border-color)",borderRadius:"6px",padding:"12px",margin:"0.6em 0",overflowX:"auto"},children:e}),ul:({children:e})=>o.jsx("ul",{style:{margin:"0.5em 0",paddingLeft:"1.5em",lineHeight:1.5},children:e}),ol:({children:e})=>o.jsx("ol",{style:{margin:"0.5em 0",paddingLeft:"1.5em",lineHeight:1.5},children:e}),li:({children:e})=>o.jsx("li",{style:{margin:"0.2em 0",paddingLeft:"0.3em"},children:e}),blockquote:({children:e})=>o.jsx("blockquote",{style:{borderLeft:"3px solid var(--accent-purple)",margin:"0.5em 0",padding:"0.5em 1em",background:"color-mix(in srgb, var(--accent-purple) 10%, transparent)",borderRadius:"0 4px 4px 0"},children:e}),a:({children:e,href:n})=>{const s=typeof n=="string"?n.trim():"",a=QH(s),r=Iu(e).trim(),i=a||(s&&t6(s)?s:null)||((!s||s==="#")&&n6(r)?r:null);if(i&&t)return o.jsx("a",{href:"#",onClick:d=>{d.preventDefault(),d.stopPropagation(),t(i)},className:"clickable-path",title:`Open ${i}`,children:e});if(!s)return o.jsx("span",{children:e});const c=!s.includes("://")&&jy(s)?`https://${s}`:s;return o.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent-cyan)",textDecoration:"underline"},children:e})},hr:()=>o.jsx("hr",{style:{border:"none",borderTop:"1px solid var(--border-color)",margin:"1em 0"}}),table:({children:e})=>o.jsx("table",{style:{width:"100%",borderCollapse:"collapse",margin:"0.6em 0",fontSize:"12px"},children:e}),th:({children:e})=>o.jsx("th",{style:{border:"1px solid var(--border-color)",padding:"6px 10px",textAlign:"left",background:"color-mix(in srgb, var(--bg-tertiary) 80%, transparent)",fontWeight:600,color:"var(--accent-pink)"},children:e}),td:({children:e})=>o.jsx("td",{style:{border:"1px solid var(--border-color)",padding:"6px 10px",textAlign:"left",background:"color-mix(in srgb, var(--bg-secondary) 50%, transparent)"},children:e}),input:({checked:e,type:n})=>n==="checkbox"?o.jsx("input",{type:"checkbox",checked:e,readOnly:!0,style:{marginRight:"0.5em",accentColor:"var(--accent-green)"}}):null});ld();function Ny(t){const e=t.trimStart();if(!e.startsWith(tx))return{hasContext:!1,context:null,userMessage:t};const n=e.lastIndexOf(bS);if(n===-1)return{hasContext:!1,context:null,userMessage:t};const s=e.slice(tx.length,n).trim(),a=e.slice(n+bS.length).trim();return{hasContext:!0,context:s,userMessage:a}}function Ty(t){const e=t.replace(/\r\n/g,`
|
|
121
|
+
`).trim(),n="Follow all instructions below for this task.",s="## User Request",a=e.lastIndexOf(s);if(a!==-1){const h=e.slice(0,a).trim(),m=e.slice(a+s.length).trim();if(m)return{hasInstructions:h.length>0,instructions:h.length>0?h:null,userMessage:m}}let r=e;const i=[],c=[/^(?:You)?# AGENTS\.md instructions[^\n]*\n[\s\S]*?<\/INSTRUCTIONS>\s*/i,/^(?:You)?<environment_context>\s*[\s\S]*?<\/environment_context>\s*/i,/^(?:You)?Follow all instructions below for this task\.\s*/i];let d=!1,f=!0;for(;f;){f=!1;for(const h of c){const m=r.match(h);if(m){i.push(m[0].trim()),r=r.slice(m[0].length).trimStart(),d=!0,f=!0;break}}}return d&&r?{hasInstructions:!0,instructions:i.join(`
|
|
122
|
+
|
|
123
|
+
`),userMessage:r.trim()}:e.includes(n)?{hasInstructions:!1,instructions:null,userMessage:t}:{hasInstructions:!1,instructions:null,userMessage:t}}function ET(t){const e=t.match(/^\[DELEGATED TASK from boss "([^"]+)" \(([^)]+)\)\]\s*\n\n([\s\S]*?)\n\n---\nThis task was delegated by your boss agent\./);return e?{isDelegatedTask:!0,bossName:e[1],bossId:e[2],taskCommand:e[3].trim()}:{isDelegatedTask:!1,bossName:"",bossId:"",taskCommand:""}}function MT(t){const e=t.match(/^\[TASK REPORT from ([^(]+?)\s*\(([^)]+)\)\]\s*\n\nStatus:\s*(\w+)\nOriginal task:\s*([\s\S]*?)\n(?:\nSummary:\s*([\s\S]*?))?\n\nYou may review/);return e?{isTaskReport:!0,agentName:e[1].trim(),agentId:e[2].trim(),status:e[3].trim(),originalTask:e[4].trim(),summary:(e[5]||"").trim()}:{isTaskReport:!1,agentName:"",agentId:"",status:"",originalTask:"",summary:""}}function DT(t){const e=t.match(/<subagent_notification>\s*([\s\S]*?)\s*<\/subagent_notification>/);if(!e)return{hasNotification:!1,agentId:"",status:{},contentWithoutNotification:t};try{const n=JSON.parse(e[1].trim()),s=n.agent_id||"",a={};if(n.status&&typeof n.status=="object")for(const[i,c]of Object.entries(n.status))a[i]=typeof c=="string"?c:JSON.stringify(c);const r=t.replace(/<subagent_notification>\s*[\s\S]*?<\/subagent_notification>\s*/g,"").trim();return{hasNotification:!0,agentId:s,status:a,contentWithoutNotification:r}}catch{return{hasNotification:!1,agentId:"",status:{},contentWithoutNotification:t}}}function RT(t){const e=t.match(/```delegation\s*\n([\s\S]*?)\n```/);if(!e)return{hasDelegation:!1,delegations:[],contentWithoutBlock:t};try{const n=JSON.parse(e[1].trim()),a=(Array.isArray(n)?n:[n]).map(i=>({selectedAgentId:i.selectedAgentId||"",selectedAgentName:i.selectedAgentName||"Unknown",taskCommand:i.taskCommand||"",reasoning:i.reasoning||"",alternativeAgents:i.alternativeAgents||[],confidence:i.confidence||"medium"})),r=t.replace(/```delegation\s*\n[\s\S]*?\n```/,"").trim();return{hasDelegation:!0,delegations:a,contentWithoutBlock:r}}catch{return{hasDelegation:!1,delegations:[],contentWithoutBlock:t}}}function OT(t){const e=t.match(/```work-plan\s*\n([\s\S]*?)\n```/);if(!e)return{hasWorkPlan:!1,workPlan:null,contentWithoutBlock:t};try{const n=JSON.parse(e[1].trim()),s={name:n.name||"Unnamed Plan",description:n.description||"",phases:(n.phases||[]).map(r=>({id:r.id||"",name:r.name||"",execution:r.execution||"sequential",dependsOn:r.dependsOn||[],tasks:(r.tasks||[]).map(i=>({id:i.id||"",description:i.description||"",suggestedClass:i.suggestedClass||"builder",assignToAgent:i.assignToAgent||null,assignToAgentName:i.assignToAgentName||null,priority:i.priority||"medium",blockedBy:i.blockedBy||[]}))}))},a=t.replace(/```work-plan\s*\n[\s\S]*?\n```/,"").trim();return{hasWorkPlan:!0,workPlan:s,contentWithoutBlock:a}}catch{return{hasWorkPlan:!1,workPlan:null,contentWithoutBlock:t}}}function $p({context:t,defaultCollapsed:e=!0,onFileClick:n}){const{t:s}=dt(["tools"]),[a,r]=x.useState(e),i=ld({onFileClick:n}),c=t.match(/# YOUR TEAM \((\d+) agents?\)/),d=c?parseInt(c[1],10):0;return o.jsxs("div",{className:`boss-context ${a?"collapsed":"expanded"}`,children:[o.jsxs("div",{className:"boss-context-header",onClick:()=>r(!a),children:[o.jsx("span",{className:"boss-context-icon",children:"👑"}),o.jsx("span",{className:"boss-context-label",children:s("tools:bossContext.teamContext",{count:d})}),o.jsx("span",{className:"boss-context-toggle",children:a?"▶":"▼"})]}),!a&&o.jsx("div",{className:"boss-context-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:i,children:t})})]})}function LT({delegation:t}){const{t:e}=dt(["tools"]),n={high:"#22c55e",medium:"#f59e0b",low:"#ef4444"},s={high:"✅",medium:"⚠️",low:"❓"};return o.jsxs("div",{className:"delegation-block",children:[o.jsxs("div",{className:"delegation-header",children:[o.jsx("span",{className:"delegation-icon",children:"📨"}),o.jsx("span",{className:"delegation-title",children:e("tools:delegation.taskDelegated")}),o.jsxs("span",{className:"delegation-confidence",style:{color:n[t.confidence]},children:[s[t.confidence]," ",t.confidence]})]}),o.jsxs("div",{className:"delegation-details",children:[o.jsxs("div",{className:"delegation-target",children:[o.jsx("span",{className:"delegation-label",children:e("tools:delegation.to")}),o.jsx("span",{className:"delegation-agent-name clickable-agent-name",onClick:()=>{U.selectAgent(t.selectedAgentId),U.setTerminalOpen(!0)},children:t.selectedAgentName})]}),t.taskCommand&&o.jsxs("div",{className:"delegation-task-command",children:[o.jsx("span",{className:"delegation-label",children:e("tools:delegation.task")}),o.jsx("span",{className:"delegation-command-text",children:t.taskCommand})]}),t.reasoning&&o.jsxs("div",{className:"delegation-reasoning",children:[o.jsx("span",{className:"delegation-label",children:e("tools:delegation.why")}),o.jsx("span",{className:"delegation-reason-text",children:t.reasoning})]}),t.alternativeAgents.length>0&&o.jsxs("div",{className:"delegation-alternatives",children:[o.jsx("span",{className:"delegation-label",children:e("tools:delegation.alternatives")}),o.jsx("span",{className:"delegation-alt-list",children:t.alternativeAgents.map((a,r)=>o.jsxs("span",{className:"delegation-alt-agent",children:[a.name,a.reason?` (${a.reason})`:""]},a.id||r))})]})]}),o.jsx("div",{className:"delegation-footer",children:o.jsxs("span",{className:"delegation-auto-forward",children:["↗️ ",e("tools:delegation.autoForwarding",{name:t.selectedAgentName})]})})]})}function s6({bossName:t,taskCommand:e}){const{t:n}=dt(["tools"]),[s,a]=x.useState(!1),r=e.length>60?e.slice(0,60)+"...":e;return o.jsxs("div",{className:`delegated-task-header ${s?"expanded":"compact"}`,children:[o.jsxs("div",{className:"delegated-task-badge",onClick:()=>a(!s),children:[o.jsx("span",{className:"delegated-task-icon",children:"👑"}),o.jsxs("span",{className:"delegated-task-label",children:[n("tools:delegation.via")," ",o.jsx("strong",{children:t})]}),o.jsx("span",{className:"delegated-task-toggle",children:s?"▼":"▶"})]}),s&&o.jsx("div",{className:"delegated-task-command",children:e}),!s&&o.jsx("div",{className:"delegated-task-preview",children:r})]})}function IT({bossName:t,bossId:e,taskCommand:n}){const[s,a]=x.useState(!0),r=n.length>80?n.slice(0,80)+"...":n;return o.jsxs("div",{className:`delegated-task-message ${s?"expanded":"compact"}`,children:[o.jsxs("div",{className:"delegated-task-message-badge",onClick:()=>a(!s),children:[o.jsx("span",{className:"delegated-task-message-icon",children:"📋"}),o.jsxs("span",{className:"delegated-task-message-label",children:["Delegated by ",o.jsx("strong",{className:"clickable-agent-name",onClick:i=>{i.stopPropagation(),U.selectAgent(e),U.setTerminalOpen(!0)},children:t})]}),o.jsx("span",{className:"delegated-task-message-id",children:e.slice(0,8)}),o.jsx("span",{className:"delegated-task-message-toggle",children:s?"▼":"▶"})]}),s?o.jsx("div",{className:"delegated-task-message-command",children:n}):o.jsx("div",{className:"delegated-task-message-preview",children:r})]})}function PT({agentName:t,agentId:e,status:n,originalTask:s,summary:a}){const[r,i]=x.useState(!1),c=n==="COMPLETED";return o.jsxs("div",{className:`task-report-header ${r?"expanded":"compact"} status-${c?"completed":"failed"}`,children:[o.jsxs("div",{className:"task-report-badge",onClick:()=>i(!r),children:[o.jsx("span",{className:"task-report-icon",children:c?"✅":"❌"}),o.jsxs("span",{className:"task-report-label",children:[o.jsx("strong",{className:"clickable-agent-name",onClick:d=>{d.stopPropagation(),U.selectAgent(e),U.setTerminalOpen(!0)},children:t})," — Task ",c?"Completed":"Failed"]}),o.jsx("span",{className:"task-report-id",children:e.slice(0,8)}),o.jsx("span",{className:"task-report-toggle",children:r?"▼":"▶"})]}),a&&o.jsx("div",{className:"task-report-summary",children:a}),r&&o.jsx("div",{className:"task-report-details",children:o.jsxs("div",{className:"task-report-original-task",children:[o.jsx("span",{className:"task-report-detail-label",children:"Original task:"}),o.jsx("span",{className:"task-report-detail-value",children:s})]})})]})}function BT({agentId:t,status:e}){const n=Object.entries(e),s=n.some(([d])=>d==="errored"||d==="error"||d==="failed"),a=n.some(([d])=>d==="completed"),r=t.slice(-12),i=n.map(([,d])=>d).join("; "),c=i.replace(/Visit https?:\/\/[^\s]+/g,"").replace(/\s+/g," ").trim();return o.jsxs("div",{className:`subagent-notification ${s?"subagent-notification--error":a?"subagent-notification--completed":"subagent-notification--info"}`,children:[o.jsx("span",{className:"subagent-notification__icon",children:s?"⚠":a?"✓":"🧬"}),o.jsx("span",{className:"subagent-notification__label",children:"Subagent"}),o.jsx("span",{className:"subagent-notification__id",children:r}),o.jsx("span",{className:"subagent-notification__status",children:n.map(([d])=>d).join(", ")}),c&&o.jsx("span",{className:"subagent-notification__message",title:i,children:c})]})}const a6={high:"🔴",medium:"🟡",low:"🟢"},r6={scout:"🔍",builder:"🔨",debugger:"🐛",architect:"📐",warrior:"⚔️",support:"🛡️"};function FT({workPlan:t}){const{t:e}=dt(["tools"]),[n,s]=x.useState(new Set(t.phases.map(i=>i.id))),a=i=>{s(c=>{const d=new Set(c);return d.has(i)?d.delete(i):d.add(i),d})},r=t.phases.reduce((i,c)=>i+c.tasks.length,0);return o.jsxs("div",{className:"work-plan-block",children:[o.jsxs("div",{className:"work-plan-header",children:[o.jsx("span",{className:"work-plan-icon",children:"📋"}),o.jsx("span",{className:"work-plan-title",children:t.name}),o.jsxs("span",{className:"work-plan-stats",children:[e("tools:workPlan.phases",{count:t.phases.length})," · ",e("tools:workPlan.tasks",{count:r})]})]}),t.description&&o.jsx("div",{className:"work-plan-description",children:t.description}),o.jsx("div",{className:"work-plan-phases",children:t.phases.map((i,c)=>o.jsxs("div",{className:`work-plan-phase ${n.has(i.id)?"expanded":"collapsed"}`,children:[o.jsxs("div",{className:"work-plan-phase-header",onClick:()=>a(i.id),children:[o.jsx("span",{className:"work-plan-phase-number",children:c+1}),o.jsx("span",{className:"work-plan-phase-name",children:i.name}),o.jsx("span",{className:`work-plan-phase-execution ${i.execution}`,children:i.execution==="parallel"?`⚡ ${e("tools:workPlan.parallel")}`:`→ ${e("tools:workPlan.sequential")}`}),i.dependsOn.length>0&&o.jsxs("span",{className:"work-plan-phase-depends",children:[e("tools:workPlan.dependsOn")," ",i.dependsOn.join(", ")]}),o.jsx("span",{className:"work-plan-phase-toggle",children:n.has(i.id)?"▼":"▶"})]}),n.has(i.id)&&o.jsx("div",{className:"work-plan-tasks",children:i.tasks.map(d=>o.jsxs("div",{className:`work-plan-task priority-${d.priority}`,children:[o.jsxs("div",{className:"work-plan-task-header",children:[o.jsx("span",{className:"work-plan-task-id",children:d.id}),o.jsx("span",{className:"work-plan-task-priority",title:`Priority: ${d.priority}`,children:a6[d.priority]}),o.jsxs("span",{className:"work-plan-task-class",title:`Suggested: ${d.suggestedClass}`,children:[r6[d.suggestedClass]||"👤"," ",d.suggestedClass]})]}),o.jsx("div",{className:"work-plan-task-description",children:d.description}),o.jsxs("div",{className:"work-plan-task-assignment",children:[o.jsx("span",{className:"work-plan-task-assignment-label",children:e("tools:workPlan.assignedTo")}),o.jsx("span",{className:`work-plan-task-agent ${d.assignToAgentName?"assigned":"auto"}`,children:d.assignToAgentName||e("tools:workPlan.autoAssign")})]}),d.blockedBy.length>0&&o.jsxs("div",{className:"work-plan-task-blocked",children:["⏳ ",e("tools:workPlan.blockedBy")," ",d.blockedBy.join(", ")]})]},d.id))})]},i.id))}),o.jsx("div",{className:"work-plan-footer",children:o.jsxs("span",{className:"work-plan-approval-hint",children:["💡 ",e("tools:workPlan.reviewHint")]})})]})}const i6={id:"dracula",name:"Dracula",description:"Vampire purple with fangs pink",colors:{bgPrimary:"#282a36",bgSecondary:"#21222c",bgTertiary:"#343746",borderColor:"#44475a",textPrimary:"#f8f8f2",textSecondary:"#bfbfbf",textMuted:"#6272a4",accentBlue:"#8be9fd",accentGreen:"#50fa7b",accentOrange:"#ffb86c",accentRed:"#ff5555",accentPurple:"#bd93f9",accentCyan:"#8be9fd",accentClaude:"#50fa7b",accentClaudeLight:"#69ff94",accentPink:"#ff79c6",accentYellow:"#f1fa8c",msgUserBg:"rgba(189, 147, 249, 0.12)",msgUserBorder:"#bd93f9",msgUserText:"#bd93f9",msgAssistantBg:"rgba(255, 121, 198, 0.12)",msgAssistantBorder:"#ff79c6",msgAssistantText:"#ff79c6",toolUseBg:"rgba(255, 184, 108, 0.08)",toolUseBorder:"#ffb86c",toolUseText:"#ffb86c",toolUseName:"#8be9fd",toolResultBg:"rgba(80, 250, 123, 0.08)",toolResultBorder:"#50fa7b",toolResultText:"#50fa7b",outputLineBg:"rgba(189, 147, 249, 0.04)",contextBarBg:"rgba(189, 147, 249, 0.25)",contextBarFill:"#bd93f9",taskLabelColor:"#ff79c6"}},zT={id:"muted",name:"Muted",description:"Foggy dawn through frosted glass",colors:{bgPrimary:"#16181c",bgSecondary:"#1c1f24",bgTertiary:"#24282e",borderColor:"#33393f",textPrimary:"#c8ccd4",textSecondary:"#9099a4",textMuted:"#5c6670",accentBlue:"#7aa8c8",accentGreen:"#8ab898",accentOrange:"#c8a878",accentRed:"#c88888",accentPurple:"#a898b8",accentCyan:"#88b8c0",accentClaude:"#8ab898",accentClaudeLight:"#9ac8a8",accentPink:"#b898a8",accentYellow:"#c8c098",msgUserBg:"rgba(138, 184, 152, 0.06)",msgUserBorder:"rgba(138, 184, 152, 0.3)",msgUserText:"#8ab898",msgAssistantBg:"rgba(168, 152, 184, 0.06)",msgAssistantBorder:"rgba(168, 152, 184, 0.3)",msgAssistantText:"#a898b8",toolUseBg:"rgba(200, 168, 120, 0.05)",toolUseBorder:"rgba(200, 168, 120, 0.3)",toolUseText:"#c8a878",toolUseName:"#88b8c0",toolResultBg:"rgba(136, 184, 192, 0.05)",toolResultBorder:"rgba(136, 184, 192, 0.3)",toolResultText:"#88b8c0",outputLineBg:"rgba(144, 153, 164, 0.03)",contextBarBg:"rgba(168, 152, 184, 0.2)",contextBarFill:"#a898b8",taskLabelColor:"#c8a878"}},o6={id:"muted-red",name:"Rosewood",description:"Aged wine by candlelight",colors:{bgPrimary:"#1a1014",bgSecondary:"#221418",bgTertiary:"#2c1c20",borderColor:"#482830",textPrimary:"#f0e4e8",textSecondary:"#c8b0b8",textMuted:"#8c6878",accentBlue:"#8898c8",accentGreen:"#78a890",accentOrange:"#d8a068",accentRed:"#c85868",accentPurple:"#a878a0",accentCyan:"#88a8b0",accentClaude:"#78a890",accentClaudeLight:"#88b8a0",accentPink:"#d88898",accentYellow:"#d8c088",msgUserBg:"rgba(216, 136, 152, 0.10)",msgUserBorder:"#d88898",msgUserText:"#d88898",msgAssistantBg:"rgba(200, 88, 104, 0.10)",msgAssistantBorder:"#c85868",msgAssistantText:"#c85868",toolUseBg:"rgba(216, 160, 104, 0.08)",toolUseBorder:"#d8a068",toolUseText:"#d8a068",toolUseName:"#d8c088",toolResultBg:"rgba(168, 120, 160, 0.08)",toolResultBorder:"#a878a0",toolResultText:"#a878a0",outputLineBg:"rgba(200, 88, 104, 0.03)",contextBarBg:"rgba(216, 136, 152, 0.25)",contextBarFill:"#d88898",taskLabelColor:"#d8c088"}},l6={id:"nord",name:"Nord",description:"Polar night with aurora",colors:{bgPrimary:"#2e3440",bgSecondary:"#3b4252",bgTertiary:"#434c5e",borderColor:"#4c566a",textPrimary:"#eceff4",textSecondary:"#d8dee9",textMuted:"#7b88a1",accentBlue:"#81a1c1",accentGreen:"#a3be8c",accentOrange:"#d08770",accentRed:"#bf616a",accentPurple:"#b48ead",accentCyan:"#88c0d0",accentClaude:"#a3be8c",accentClaudeLight:"#b3ce9c",accentPink:"#b48ead",accentYellow:"#ebcb8b",msgUserBg:"rgba(136, 192, 208, 0.10)",msgUserBorder:"#88c0d0",msgUserText:"#88c0d0",msgAssistantBg:"rgba(163, 190, 140, 0.10)",msgAssistantBorder:"#a3be8c",msgAssistantText:"#a3be8c",toolUseBg:"rgba(208, 135, 112, 0.08)",toolUseBorder:"#d08770",toolUseText:"#d08770",toolUseName:"#ebcb8b",toolResultBg:"rgba(180, 142, 173, 0.08)",toolResultBorder:"#b48ead",toolResultText:"#b48ead",outputLineBg:"rgba(67, 76, 94, 0.3)",contextBarBg:"rgba(129, 161, 193, 0.25)",contextBarFill:"#81a1c1",taskLabelColor:"#ebcb8b"}},c6={id:"solarized-dark",name:"Solarized",description:"Precision-engineered contrast",colors:{bgPrimary:"#002b36",bgSecondary:"#073642",bgTertiary:"#094652",borderColor:"#586e75",textPrimary:"#93a1a1",textSecondary:"#839496",textMuted:"#657b83",accentBlue:"#268bd2",accentGreen:"#859900",accentOrange:"#cb4b16",accentRed:"#dc322f",accentPurple:"#6c71c4",accentCyan:"#2aa198",accentClaude:"#859900",accentClaudeLight:"#95a910",accentPink:"#d33682",accentYellow:"#b58900",msgUserBg:"rgba(42, 161, 152, 0.12)",msgUserBorder:"#2aa198",msgUserText:"#2aa198",msgAssistantBg:"rgba(133, 153, 0, 0.12)",msgAssistantBorder:"#859900",msgAssistantText:"#859900",toolUseBg:"rgba(203, 75, 22, 0.10)",toolUseBorder:"#cb4b16",toolUseText:"#cb4b16",toolUseName:"#b58900",toolResultBg:"rgba(108, 113, 196, 0.10)",toolResultBorder:"#6c71c4",toolResultText:"#6c71c4",outputLineBg:"rgba(7, 54, 66, 0.5)",contextBarBg:"rgba(38, 139, 210, 0.25)",contextBarFill:"#268bd2",taskLabelColor:"#b58900"}},u6={id:"monokai",name:"Monokai",description:"Neon jungle on warm charcoal",colors:{bgPrimary:"#272822",bgSecondary:"#1e1f1a",bgTertiary:"#3e3d32",borderColor:"#49483e",textPrimary:"#f8f8f2",textSecondary:"#cfcfc2",textMuted:"#75715e",accentBlue:"#66d9ef",accentGreen:"#a6e22e",accentOrange:"#fd971f",accentRed:"#f92672",accentPurple:"#ae81ff",accentCyan:"#66d9ef",accentClaude:"#a6e22e",accentClaudeLight:"#b6f23e",accentPink:"#f92672",accentYellow:"#e6db74",msgUserBg:"rgba(249, 38, 114, 0.10)",msgUserBorder:"#f92672",msgUserText:"#f92672",msgAssistantBg:"rgba(166, 226, 46, 0.10)",msgAssistantBorder:"#a6e22e",msgAssistantText:"#a6e22e",toolUseBg:"rgba(253, 151, 31, 0.08)",toolUseBorder:"#fd971f",toolUseText:"#fd971f",toolUseName:"#66d9ef",toolResultBg:"rgba(174, 129, 255, 0.08)",toolResultBorder:"#ae81ff",toolResultText:"#ae81ff",outputLineBg:"rgba(62, 61, 50, 0.3)",contextBarBg:"rgba(249, 38, 114, 0.25)",contextBarFill:"#f92672",taskLabelColor:"#fd971f"}},d6={id:"gruvbox",name:"Gruvbox",description:"Retro coffee shop warmth",colors:{bgPrimary:"#282828",bgSecondary:"#1d2021",bgTertiary:"#3c3836",borderColor:"#504945",textPrimary:"#ebdbb2",textSecondary:"#d5c4a1",textMuted:"#928374",accentBlue:"#83a598",accentGreen:"#b8bb26",accentOrange:"#fe8019",accentRed:"#fb4934",accentPurple:"#d3869b",accentCyan:"#8ec07c",accentClaude:"#b8bb26",accentClaudeLight:"#c8cb36",accentPink:"#d3869b",accentYellow:"#fabd2f",msgUserBg:"rgba(254, 128, 25, 0.10)",msgUserBorder:"#fe8019",msgUserText:"#fe8019",msgAssistantBg:"rgba(142, 192, 124, 0.10)",msgAssistantBorder:"#8ec07c",msgAssistantText:"#8ec07c",toolUseBg:"rgba(250, 189, 47, 0.08)",toolUseBorder:"#fabd2f",toolUseText:"#fabd2f",toolUseName:"#83a598",toolResultBg:"rgba(211, 134, 155, 0.08)",toolResultBorder:"#d3869b",toolResultText:"#d3869b",outputLineBg:"rgba(60, 56, 54, 0.4)",contextBarBg:"rgba(254, 128, 25, 0.25)",contextBarFill:"#fe8019",taskLabelColor:"#fabd2f"}},f6={id:"atom",name:"Atom",description:"Deep space exploration",colors:{bgPrimary:"#0c1014",bgSecondary:"#121820",bgTertiary:"#1a222c",borderColor:"#283040",textPrimary:"#d8e0f0",textSecondary:"#9ca8c0",textMuted:"#5a6880",accentBlue:"#5dade2",accentGreen:"#58d68d",accentOrange:"#f0b060",accentRed:"#ec7063",accentPurple:"#af7ac5",accentCyan:"#48c9b0",accentClaude:"#58d68d",accentClaudeLight:"#68e69d",accentPink:"#f1948a",accentYellow:"#f7dc6f",msgUserBg:"rgba(93, 173, 226, 0.10)",msgUserBorder:"#5dade2",msgUserText:"#5dade2",msgAssistantBg:"rgba(88, 214, 141, 0.10)",msgAssistantBorder:"#58d68d",msgAssistantText:"#58d68d",toolUseBg:"rgba(240, 176, 96, 0.08)",toolUseBorder:"#f0b060",toolUseText:"#f0b060",toolUseName:"#48c9b0",toolResultBg:"rgba(175, 122, 197, 0.08)",toolResultBorder:"#af7ac5",toolResultText:"#af7ac5",outputLineBg:"rgba(26, 34, 44, 0.5)",contextBarBg:"rgba(175, 122, 197, 0.25)",contextBarFill:"#af7ac5",taskLabelColor:"#f7dc6f"}},p6={id:"cyberpunk",name:"Cyberpunk",description:"Neon noir dystopia",colors:{bgPrimary:"#030308",bgSecondary:"#08080f",bgTertiary:"#101018",borderColor:"#181828",textPrimary:"#e8e8ff",textSecondary:"#a0a0c8",textMuted:"#5050a0",accentBlue:"#00f0ff",accentGreen:"#00ff9f",accentOrange:"#ff6600",accentRed:"#ff003c",accentPurple:"#bf00ff",accentCyan:"#00f0ff",accentClaude:"#00ff9f",accentClaudeLight:"#50ffbf",accentPink:"#ff00aa",accentYellow:"#fff000",msgUserBg:"rgba(255, 0, 170, 0.12)",msgUserBorder:"#ff00aa",msgUserText:"#ff00aa",msgAssistantBg:"rgba(0, 255, 159, 0.10)",msgAssistantBorder:"#00ff9f",msgAssistantText:"#00ff9f",toolUseBg:"rgba(191, 0, 255, 0.10)",toolUseBorder:"#bf00ff",toolUseText:"#bf00ff",toolUseName:"#00f0ff",toolResultBg:"rgba(0, 240, 255, 0.08)",toolResultBorder:"#00f0ff",toolResultText:"#00f0ff",outputLineBg:"rgba(191, 0, 255, 0.03)",contextBarBg:"rgba(255, 0, 170, 0.30)",contextBarFill:"#ff00aa",taskLabelColor:"#fff000"}},h6={id:"synthwave",name:"Synthwave",description:"Sunset over chrome horizon",colors:{bgPrimary:"#241b30",bgSecondary:"#1a1424",bgTertiary:"#2e2540",borderColor:"#4a3860",textPrimary:"#f8e8f8",textSecondary:"#c8a8d0",textMuted:"#7860a0",accentBlue:"#2de2e6",accentGreen:"#0abdc6",accentOrange:"#ff9e64",accentRed:"#ff3864",accentPurple:"#9d4edd",accentCyan:"#2de2e6",accentClaude:"#0abdc6",accentClaudeLight:"#2ad0d8",accentPink:"#f706cf",accentYellow:"#fede5d",msgUserBg:"rgba(247, 6, 207, 0.12)",msgUserBorder:"#f706cf",msgUserText:"#f706cf",msgAssistantBg:"rgba(45, 226, 230, 0.10)",msgAssistantBorder:"#2de2e6",msgAssistantText:"#2de2e6",toolUseBg:"rgba(255, 158, 100, 0.10)",toolUseBorder:"#ff9e64",toolUseText:"#ff9e64",toolUseName:"#fede5d",toolResultBg:"rgba(157, 78, 221, 0.10)",toolResultBorder:"#9d4edd",toolResultText:"#9d4edd",outputLineBg:"rgba(157, 78, 221, 0.05)",contextBarBg:"rgba(247, 6, 207, 0.25)",contextBarFill:"#f706cf",taskLabelColor:"#fede5d"}},m6={id:"abyss",name:"Abyss",description:"Pitch-black void, vivid accents",colors:{bgPrimary:"#08090c",bgSecondary:"#0e1014",bgTertiary:"#16181e",borderColor:"#242830",textPrimary:"#b0b4bc",textSecondary:"#808690",textMuted:"#4c5058",accentBlue:"#3d8ab8",accentGreen:"#3ea868",accentOrange:"#c07848",accentRed:"#b84848",accentPurple:"#8060b0",accentCyan:"#3ca8a8",accentClaude:"#3ea868",accentClaudeLight:"#50b878",accentPink:"#a85880",accentYellow:"#b8a840",msgUserBg:"#181c24",msgUserBorder:"#6a4e96",msgUserText:"#d0d4dc",msgAssistantBg:"#12161e",msgAssistantBorder:"#1c3838",msgAssistantText:"#a0a8b4",toolUseBg:"#161a22",toolUseBorder:"#3a2820",toolUseText:"#989ea8",toolUseName:"#c07848",toolResultBg:"#121824",toolResultBorder:"#202038",toolResultText:"#989ea8",outputLineBg:"#0a0c10",contextBarBg:"rgba(60, 68, 76, 0.25)",contextBarFill:"#4c5460",taskLabelColor:"#c07848"}},g6={id:"obsidian-bloom",name:"Obsidian Bloom",description:"Ultra-dark graphite with subtle cool borders",colors:{bgPrimary:"#050608",bgSecondary:"#0a0b0f",bgTertiary:"#111319",borderColor:"#2a2f3a",textPrimary:"#c4cad4",textSecondary:"#9aa3b1",textMuted:"#67707d",accentBlue:"#8aa3c7",accentGreen:"#82a39a",accentOrange:"#b39479",accentRed:"#ad7d8a",accentPurple:"#9a8fbd",accentCyan:"#86a8b7",accentClaude:"#9ca6c9",accentClaudeLight:"#bcc3df",accentPink:"#aa92bb",accentYellow:"#b8ac8f",msgUserBg:"rgba(21, 26, 35, 0.92)",msgUserBorder:"#4c627f",msgUserText:"#b8c8df",msgAssistantBg:"rgba(22, 20, 32, 0.92)",msgAssistantBorder:"#5d5479",msgAssistantText:"#c2bcdb",toolUseBg:"rgba(28, 23, 20, 0.9)",toolUseBorder:"#6b5646",toolUseText:"#c8b3a1",toolUseName:"#b8ac8f",toolResultBg:"rgba(20, 23, 30, 0.9)",toolResultBorder:"#4e5a73",toolResultText:"#b0bdd2",outputLineBg:"rgba(10, 11, 15, 0.7)",contextBarBg:"rgba(94, 106, 126, 0.22)",contextBarFill:"#6f7f99",taskLabelColor:"#9ea6b8"}},b6={id:"catppuccin",name:"Catppuccin",description:"Cozy pastel mocha cafe",colors:{bgPrimary:"#1e1e2e",bgSecondary:"#181825",bgTertiary:"#313244",borderColor:"#45475a",textPrimary:"#cdd6f4",textSecondary:"#bac2de",textMuted:"#6c7086",accentBlue:"#89b4fa",accentGreen:"#a6e3a1",accentOrange:"#fab387",accentRed:"#f38ba8",accentPurple:"#cba6f7",accentCyan:"#94e2d5",accentClaude:"#a6e3a1",accentClaudeLight:"#b6f3b1",accentPink:"#f5c2e7",accentYellow:"#f9e2af",msgUserBg:"rgba(180, 190, 254, 0.10)",msgUserBorder:"#b4befe",msgUserText:"#b4befe",msgAssistantBg:"rgba(148, 226, 213, 0.10)",msgAssistantBorder:"#94e2d5",msgAssistantText:"#94e2d5",toolUseBg:"rgba(250, 179, 135, 0.08)",toolUseBorder:"#fab387",toolUseText:"#fab387",toolUseName:"#f9e2af",toolResultBg:"rgba(203, 166, 247, 0.08)",toolResultBorder:"#cba6f7",toolResultText:"#cba6f7",outputLineBg:"rgba(49, 50, 68, 0.4)",contextBarBg:"rgba(245, 194, 231, 0.25)",contextBarFill:"#f5c2e7",taskLabelColor:"#fab387"}},x6={id:"github-dark",name:"GitHub Dark",description:"Developer professional minimal",colors:{bgPrimary:"#0d1117",bgSecondary:"#161b22",bgTertiary:"#21262d",borderColor:"#30363d",textPrimary:"#c9d1d9",textSecondary:"#8b949e",textMuted:"#484f58",accentBlue:"#58a6ff",accentGreen:"#3fb950",accentOrange:"#d29922",accentRed:"#f85149",accentPurple:"#a371f7",accentCyan:"#79c0ff",accentClaude:"#3fb950",accentClaudeLight:"#56d364",accentPink:"#f778ba",accentYellow:"#e3b341",msgUserBg:"rgba(88, 166, 255, 0.08)",msgUserBorder:"#58a6ff",msgUserText:"#58a6ff",msgAssistantBg:"rgba(63, 185, 80, 0.08)",msgAssistantBorder:"#3fb950",msgAssistantText:"#3fb950",toolUseBg:"rgba(210, 153, 34, 0.08)",toolUseBorder:"#d29922",toolUseText:"#d29922",toolUseName:"#79c0ff",toolResultBg:"rgba(163, 113, 247, 0.08)",toolResultBorder:"#a371f7",toolResultText:"#a371f7",outputLineBg:"rgba(33, 38, 45, 0.5)",contextBarBg:"rgba(88, 166, 255, 0.25)",contextBarFill:"#58a6ff",taskLabelColor:"#d29922"}},y6={id:"one-dark",name:"One Dark",description:"Moonlit late night coding",colors:{bgPrimary:"#282c34",bgSecondary:"#21252b",bgTertiary:"#2c323c",borderColor:"#3e4451",textPrimary:"#abb2bf",textSecondary:"#828997",textMuted:"#5c6370",accentBlue:"#61afef",accentGreen:"#98c379",accentOrange:"#d19a66",accentRed:"#e06c75",accentPurple:"#c678dd",accentCyan:"#56b6c2",accentClaude:"#98c379",accentClaudeLight:"#a8d389",accentPink:"#e06c75",accentYellow:"#e5c07b",msgUserBg:"rgba(86, 182, 194, 0.10)",msgUserBorder:"#56b6c2",msgUserText:"#56b6c2",msgAssistantBg:"rgba(152, 195, 121, 0.10)",msgAssistantBorder:"#98c379",msgAssistantText:"#98c379",toolUseBg:"rgba(209, 154, 102, 0.08)",toolUseBorder:"#d19a66",toolUseText:"#d19a66",toolUseName:"#e5c07b",toolResultBg:"rgba(198, 120, 221, 0.08)",toolResultBorder:"#c678dd",toolResultText:"#c678dd",outputLineBg:"rgba(44, 50, 60, 0.5)",contextBarBg:"rgba(97, 175, 239, 0.25)",contextBarFill:"#61afef",taskLabelColor:"#d19a66"}},v6={id:"midnight-harbor",name:"Midnight Harbor",description:"Low-glare ocean twilight",colors:{bgPrimary:"#0e141d",bgSecondary:"#151d28",bgTertiary:"#1f2a38",borderColor:"#33465a",textPrimary:"#d9e2ed",textSecondary:"#aebdce",textMuted:"#7f93a8",accentBlue:"#7baed6",accentGreen:"#7fc3b8",accentOrange:"#cfa77f",accentRed:"#c9879c",accentPurple:"#9b9fd1",accentCyan:"#79bccc",accentClaude:"#8ea8d9",accentClaudeLight:"#b2c2e8",accentPink:"#c79fbe",accentYellow:"#d7c28f",msgUserBg:"rgba(123, 174, 214, 0.12)",msgUserBorder:"#7baed6",msgUserText:"#9cc3e2",msgAssistantBg:"rgba(142, 168, 217, 0.12)",msgAssistantBorder:"#8ea8d9",msgAssistantText:"#b2c2e8",toolUseBg:"rgba(207, 167, 127, 0.10)",toolUseBorder:"#cfa77f",toolUseText:"#ddbf9f",toolUseName:"#d7c28f",toolResultBg:"rgba(155, 159, 209, 0.10)",toolResultBorder:"#9b9fd1",toolResultText:"#b9bbe2",outputLineBg:"rgba(31, 42, 56, 0.5)",contextBarBg:"rgba(123, 174, 214, 0.24)",contextBarFill:"#7baed6",taskLabelColor:"#d7c28f"}},w6={id:"ember-noir",name:"Ember Noir",description:"Soft plum dusk with rose-indigo accents",colors:{bgPrimary:"#151118",bgSecondary:"#1d1723",bgTertiary:"#292132",borderColor:"#473b56",textPrimary:"#e7deed",textSecondary:"#c4b4d0",textMuted:"#93839f",accentBlue:"#88a9d6",accentGreen:"#8ab9ad",accentOrange:"#cf9b79",accentRed:"#cb8a9b",accentPurple:"#ae8ec8",accentCyan:"#86b8c6",accentClaude:"#9ca7df",accentClaudeLight:"#bcc3ea",accentPink:"#cd9fbc",accentYellow:"#d5bf93",msgUserBg:"rgba(203, 138, 155, 0.12)",msgUserBorder:"#cb8a9b",msgUserText:"#d7a6b3",msgAssistantBg:"rgba(156, 167, 223, 0.12)",msgAssistantBorder:"#9ca7df",msgAssistantText:"#bcc3ea",toolUseBg:"rgba(213, 191, 147, 0.10)",toolUseBorder:"#d5bf93",toolUseText:"#e0cfad",toolUseName:"#88a9d6",toolResultBg:"rgba(174, 142, 200, 0.10)",toolResultBorder:"#ae8ec8",toolResultText:"#c6aed8",outputLineBg:"rgba(41, 33, 50, 0.52)",contextBarBg:"rgba(203, 138, 155, 0.24)",contextBarFill:"#cb8a9b",taskLabelColor:"#d5bf93"}},k6={id:"classic",name:"Classic",description:"Original transparent style",colors:{bgPrimary:"#0d0d14",bgSecondary:"#14141e",bgTertiary:"#1c1c28",borderColor:"#2a2a3a",textPrimary:"#d0d0d8",textSecondary:"#8a8a98",textMuted:"#5a6a8a",accentBlue:"#5a8fd4",accentGreen:"#50fa7b",accentOrange:"#c89a5a",accentRed:"#c85a5a",accentPurple:"#9a80c0",accentCyan:"#8be9fd",accentClaude:"#50fa7b",accentClaudeLight:"#69ff94",accentPink:"#c87a9a",accentYellow:"#c8c87a",msgUserBg:"rgba(139, 233, 253, 0.12)",msgUserBorder:"transparent",msgUserText:"#8be9fd",msgAssistantBg:"rgba(80, 250, 123, 0.12)",msgAssistantBorder:"transparent",msgAssistantText:"#50fa7b",toolUseBg:"rgba(255, 184, 108, 0.05)",toolUseBorder:"transparent",toolUseText:"#8be9fd",toolUseName:"#ffb86c",toolResultBg:"rgba(80, 250, 123, 0.06)",toolResultBorder:"transparent",toolResultText:"#50fa7b",outputLineBg:"transparent",contextBarBg:"rgba(106, 154, 120, 0.25)",contextBarFill:"#6a9a78",taskLabelColor:"#8be9fd"}},ia=[k6,m6,g6,i6,zT,o6,l6,c6,u6,d6,f6,p6,h6,b6,x6,y6,v6,w6];function Pu(t){return ia.find(e=>e.id===t)||zT}const S6="classic";function Up(t){const e=document.documentElement,{colors:n}=t;e.style.setProperty("--bg-primary",n.bgPrimary),e.style.setProperty("--bg-secondary",n.bgSecondary),e.style.setProperty("--bg-tertiary",n.bgTertiary),e.style.setProperty("--border-color",n.borderColor),e.style.setProperty("--text-primary",n.textPrimary),e.style.setProperty("--text-secondary",n.textSecondary),e.style.setProperty("--text-muted",n.textMuted),e.style.setProperty("--accent-blue",n.accentBlue),e.style.setProperty("--accent-green",n.accentGreen),e.style.setProperty("--accent-orange",n.accentOrange),e.style.setProperty("--accent-red",n.accentRed),e.style.setProperty("--accent-purple",n.accentPurple),e.style.setProperty("--accent-cyan",n.accentCyan),e.style.setProperty("--accent-claude",n.accentClaude),e.style.setProperty("--accent-claude-light",n.accentClaudeLight),e.style.setProperty("--accent-pink",n.accentPink),e.style.setProperty("--accent-yellow",n.accentYellow),e.style.setProperty("--msg-user-bg",n.msgUserBg),e.style.setProperty("--msg-user-border",n.msgUserBorder),e.style.setProperty("--msg-user-text",n.msgUserText),e.style.setProperty("--msg-assistant-bg",n.msgAssistantBg),e.style.setProperty("--msg-assistant-border",n.msgAssistantBorder),e.style.setProperty("--msg-assistant-text",n.msgAssistantText),e.style.setProperty("--tool-use-bg",n.toolUseBg),e.style.setProperty("--tool-use-border",n.toolUseBorder),e.style.setProperty("--tool-use-text",n.toolUseText),e.style.setProperty("--tool-use-name",n.toolUseName),e.style.setProperty("--tool-result-bg",n.toolResultBg),e.style.setProperty("--tool-result-border",n.toolResultBorder),e.style.setProperty("--tool-result-text",n.toolResultText),e.style.setProperty("--output-line-bg",n.outputLineBg),e.style.setProperty("--context-bar-bg",n.contextBarBg),e.style.setProperty("--context-bar-fill",n.contextBarFill),e.style.setProperty("--task-label-color",n.taskLabelColor);try{localStorage.setItem("tide-theme",t.id)}catch{}}function _y(){try{const t=localStorage.getItem("tide-theme");if(t&&ia.some(e=>e.id===t))return t}catch{}return S6}function C6(){const t=_y(),e=Pu(t);Up(e)}const A6=x.memo(function({selectedAgent:e,selectedAgentId:n,sortedAgents:s,swipeOffset:a,viewMode:r,setViewMode:i,searchMode:c,toggleSearch:d,closeSearch:f,debugPanelOpen:h,setDebugPanelOpen:m,debuggerEnabled:b,setDebuggerEnabled:y,outputsLength:w,setContextConfirm:C,headerRef:N,isSnapshotView:k=!1,onSaveSnapshot:j,overviewPanelOpen:S=!1,setOverviewPanelOpen:T,agentInfoOpen:D=!1,onToggleAgentInfo:E,isFullscreen:I=!1,onToggleFullscreen:O,onNavigateBack:_,onNavigateForward:M,canNavigateBack:R=!1,canNavigateForward:z=!1,gitPanelOpen:$=!1,setGitPanelOpen:W,buildingsPanelOpen:L=!1,setBuildingsPanelOpen:F,workflowPanelOpen:H=!1,setWorkflowPanelOpen:V,hasWorkflow:G=!1}){var ye,Ie;const{t:B}=dt(["terminal","common"]),K=YO();Vr();const ne=Xj(n),q=()=>{const te=Bg.indexOf(r),be=Bg[(te+1)%Bg.length];i(be),Wr(pt.VIEW_MODE,be)},xe=()=>{const te=!h;m(te),te&&!b&&(y(!0),vs.setEnabled(!0))},Ae=()=>{c?f():d()},Z=()=>{window.confirm(B("common:confirm.removeAgent",{name:e.name}))&&U.removeAgentFromServer(n)},ce=e.currentTask||e.lastAssignedTask||(ne==null?void 0:ne.text),me=e.taskLabel||ce,ee=(ye=K.lastReport)==null?void 0:ye.agentSummaries.find(te=>te.agentId===e.id||te.agentName===e.name),re={on_track:"#4aff9e",stalled:"#ff9e4a",blocked:"#ff4a4a",completed:"#4a9eff",idle:"#888"},ze=(e.class==="boss"||e.isBoss)&&e.subordinateIds&&e.subordinateIds.length>0,Pe=fL(n),ge=a1(e.class in _o?null:e.class),Te=(ge==null?void 0:ge.icon)||((Ie=_o[e.class])==null?void 0:Ie.icon)||"🤖",qe=ur(),it=Ce.useMemo(()=>{var te;for(const be of qe.values())if((te=be.assignedAgentIds)!=null&&te.includes(n))return be;return null},[qe,n]),[he,Be]=x.useState(!1),ie=x.useRef(null),[de,He]=x.useState(!1),[et,ct]=x.useState(!1),[fe,X]=x.useState(()=>_y()),se=x.useRef(null),Se=B(r==="simple"?"terminal:header.simpleView":r==="chat"?"terminal:header.chatView":"terminal:header.advancedView"),J=r==="simple"?"○":r==="chat"?"◐":"◉",pe=x.useCallback(()=>{Be(!1)},[]),Re=x.useCallback(()=>{He(!1),ct(!1)},[]),$e=te=>{const be=Pu(te);Up(be),X(te)};return x.useEffect(()=>{if(!he)return;const te=be=>{ie.current&&!ie.current.contains(be.target)&&pe()};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[he,pe]),x.useEffect(()=>{if(!de)return;const te=be=>{se.current&&!se.current.contains(be.target)&&Re()};return document.addEventListener("mousedown",te),document.addEventListener("touchstart",te),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("touchstart",te)}},[de,Re]),o.jsxs("div",{className:`guake-header ${s.length>1?"has-multiple-agents":""} ${a>.1?"swiping-right":""} ${a<-.1?"swiping-left":""}`,ref:N,style:it?{borderBottomColor:`color-mix(in srgb, ${it.color} 50%, var(--border-color))`}:void 0,children:[o.jsxs("div",{className:"guake-header-left",children:[o.jsxs("div",{className:"guake-header-title-row",children:[e.isDetached&&o.jsx(os,{content:o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"tide-tooltip__title",children:"🔄 Reattaching Session..."}),o.jsxs("div",{className:"tide-tooltip__text",children:["This agent's Claude process is running independently. Tide Commander is automatically attempting to reattach to the existing session. If reattachment fails, send a new message to manually resume the session.",o.jsx("br",{}),o.jsx("br",{}),o.jsx("strong",{children:"Status:"})," Recovering session context and output history..."]})]}),position:"bottom",className:"tide-tooltip--detached",children:o.jsx("span",{className:"guake-detached-badge",title:"Agent is detached - reattaching...",children:o.jsx("span",{className:"guake-detached-spinner",children:"🔄"})})}),E?o.jsxs("button",{className:`guake-title-btn ${D?"active":""}`,onClick:E,title:B("terminal:header.showAgentInfo"),children:[o.jsx("span",{className:"guake-agent-avatar",children:Te}),o.jsxs("span",{className:"guake-title-block",children:[o.jsxs("span",{className:"guake-title-main-row",children:[o.jsx("span",{className:"guake-title",children:e.name}),(e.taskLabel||ce)&&o.jsx("span",{className:"guake-title-task-chip",children:e.taskLabel||ce})]}),me&&o.jsx("span",{className:"guake-mobile-title-context",children:me})]}),o.jsx("span",{className:"guake-title-accessory",children:o.jsx("img",{src:e.provider==="codex"?"/assets/codex.png":"/assets/claude.png",alt:e.provider,className:"guake-provider-icon",title:e.provider==="codex"?"Codex Agent":"Claude Agent"})})]}):o.jsxs("div",{className:"guake-title-with-provider",children:[o.jsx("span",{className:"guake-agent-avatar",children:Te}),o.jsxs("span",{className:"guake-title-block",children:[o.jsxs("span",{className:"guake-title-main-row",children:[o.jsx("span",{className:"guake-title",children:e.name}),(e.taskLabel||ce)&&o.jsx("span",{className:"guake-title-task-chip",children:e.taskLabel||ce})]}),me&&o.jsx("span",{className:"guake-mobile-title-context",children:me})]}),o.jsx("span",{className:"guake-title-accessory",children:o.jsx("img",{src:e.provider==="codex"?"/assets/codex.png":"/assets/claude.png",alt:e.provider,className:"guake-provider-icon",title:e.provider==="codex"?"Codex Agent":"Claude Agent"})})]})]}),o.jsxs("div",{className:"guake-header-meta",children:[ee&&o.jsx("span",{className:"guake-status-line",title:`${ee.statusDescription}
|
|
124
|
+
${ee.recentWorkSummary}`,children:o.jsx("span",{className:"guake-supervisor-badge",style:{color:re[ee.progress]||"#888"},children:ee.progress.replace("_"," ")})}),Pe.filter(te=>te.status==="spawning"||te.status==="working").length>0&&o.jsx("span",{className:"guake-subagents-indicator",children:Pe.filter(te=>te.status==="spawning"||te.status==="working").map(te=>o.jsxs("span",{className:"guake-subagent-badge active",title:`${te.name} (${te.subagentType}) - ${te.status}`,children:[o.jsx("span",{className:"guake-subagent-icon",children:"⑂"}),o.jsx("span",{className:"guake-subagent-name",children:te.name})]},te.id))})]})]}),o.jsxs("div",{className:"guake-actions",children:[o.jsxs("div",{className:"guake-action-cluster guake-action-cluster--compact hide-on-mobile",children:[!k&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"guake-icon-action guake-nav-btn",onClick:_,title:"Back (Alt+Left)",disabled:!R,children:o.jsx("span",{className:"guake-action-icon",children:"←"})}),o.jsx("button",{className:"guake-icon-action guake-nav-btn",onClick:M,title:"Forward (Alt+Right)",disabled:!z,children:o.jsx("span",{className:"guake-action-icon",children:"→"})})]}),!k&&T&&o.jsx("button",{className:`guake-icon-action guake-overview-toggle ${S?"active":""}`,onClick:()=>T(!S),title:B(S?"terminal:header.hideOverview":"terminal:header.showOverview"),children:o.jsx("span",{className:"guake-action-icon",children:"📊"})}),!k&&W&&o.jsx("button",{className:`guake-icon-action guake-git-toggle ${$?"active":""}`,onClick:()=>W(!$),title:$?"Hide Git Changes":"Show Git Changes",children:o.jsx("span",{className:"guake-action-icon",children:"🌿"})}),!k&&G&&V&&o.jsx("button",{className:`guake-icon-action guake-workflow-toggle ${H?"active":""}`,onClick:()=>V(!H),title:H?"Hide Workflow":"Show Workflow",children:o.jsx("span",{className:"guake-action-icon",children:"🔄"})}),o.jsx("button",{className:`guake-icon-action guake-fullscreen-toggle ${I?"active":""}`,onClick:O,title:B(I?"terminal:header.exitFullscreen":"terminal:header.enterFullscreen"),children:o.jsx("span",{className:"guake-action-icon",children:I?"🗗":"⛶"})}),o.jsx("button",{className:`guake-icon-action guake-search-toggle ${c?"active":""}`,onClick:Ae,title:B("terminal:header.search"),children:o.jsx("span",{className:"guake-action-icon",children:"🔍"})})]}),!k&&o.jsxs("div",{className:"guake-desktop-more hide-on-mobile",ref:ie,children:[o.jsx("button",{className:`guake-desktop-more-btn ${he?"active":""}`,onClick:()=>Be(!he),title:B("terminal:header.moreActions","More actions"),children:"⋮"}),he&&o.jsxs("div",{className:"guake-desktop-menu",children:[o.jsxs("button",{className:"guake-desktop-menu-item",onClick:()=>{q(),pe()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:J}),"View: ",Se]}),j&&w>0&&o.jsxs("button",{className:"guake-desktop-menu-item",onClick:()=>{j(),pe()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"⭐"}),B("terminal:header.saveSnapshot")]}),F&&o.jsxs("button",{className:`guake-desktop-menu-item ${L?"active":""}`,onClick:()=>{F(!L),pe()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"🏗️"}),L?"Hide Buildings":"Show Buildings"]}),o.jsxs("button",{className:`guake-desktop-menu-item ${h?"active":""}`,onClick:()=>{xe(),pe()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"🐛"}),B(h?"terminal:header.hideDebug":"terminal:header.showDebug")]}),o.jsx("div",{className:"guake-desktop-menu-divider"}),o.jsxs("button",{className:"guake-desktop-menu-item",onClick:()=>{C("collapse"),pe()},disabled:e.status!=="idle",children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"📦"}),B("terminal:header.collapseContext")]}),o.jsxs("button",{className:"guake-desktop-menu-item danger",onClick:()=>{C("clear"),pe()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"🧹"}),B("terminal:header.clearContext")]}),ze&&o.jsxs("button",{className:"guake-desktop-menu-item danger",onClick:()=>{C("clear-subordinates"),pe()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"👑"}),B("terminal:header.clearAllSubordinates")]}),o.jsx("div",{className:"guake-desktop-menu-divider"}),o.jsxs("button",{className:"guake-desktop-menu-item danger",onClick:()=>{Z(),pe()},children:[o.jsx("span",{className:"guake-desktop-menu-icon",children:"❌"}),B("terminal:header.removeAgent")]})]})]}),!k&&o.jsxs("div",{className:"guake-mobile-more show-on-mobile",ref:se,children:[o.jsx("button",{className:`guake-mobile-more-btn ${de?"active":""}`,onClick:()=>He(!de),title:B("terminal:header.moreActions","More actions"),children:"⋮"}),de&&o.jsxs("div",{className:"guake-mobile-menu",children:[o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{_==null||_(),Re()},disabled:!R,children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"←"}),"Back"]}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{M==null||M(),Re()},disabled:!z,children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"→"}),"Forward"]}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{q(),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:r==="simple"?"○":r==="chat"?"◐":"◉"}),B(r==="simple"?"terminal:header.simpleView":r==="chat"?"terminal:header.chatView":"terminal:header.advancedView")]}),w>0&&o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{U.clearOutputs(n),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🗑"}),B("terminal:header.clearOutput")]}),j&&w>0&&o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{j(),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"⭐"}),B("terminal:header.saveSnapshot")]}),o.jsxs("button",{className:`guake-mobile-menu-item ${I?"active":""}`,onClick:()=>{O==null||O(),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:I?"🗗":"⛶"}),B(I?"terminal:header.exitFullscreen":"terminal:header.enterFullscreen")]}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{Ae(),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:c?"✕":"🔍"}),B("terminal:header.search")]}),T&&o.jsxs("button",{className:`guake-mobile-menu-item ${S?"active":""}`,onClick:()=>{T(!S),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"📊"}),B(S?"terminal:header.hideOverview":"terminal:header.showOverview")]}),W&&o.jsxs("button",{className:`guake-mobile-menu-item ${$?"active":""}`,onClick:()=>{W(!$),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🌿"}),$?"Hide Git Changes":"Show Git Changes"]}),G&&V&&o.jsxs("button",{className:`guake-mobile-menu-item ${H?"active":""}`,onClick:()=>{V(!H),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🔄"}),H?"Hide Workflow":"Show Workflow"]}),F&&o.jsxs("button",{className:`guake-mobile-menu-item ${L?"active":""}`,onClick:()=>{F(!L),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🏗️"}),L?"Hide Buildings":"Show Buildings"]}),o.jsxs("button",{className:`guake-mobile-menu-item ${h?"active":""}`,onClick:()=>{xe(),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🐛"}),B(h?"terminal:header.hideDebug":"terminal:header.showDebug")]}),o.jsxs("button",{className:`guake-mobile-menu-item ${et?"active":""}`,onClick:()=>ct(!et),children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🎨"}),B("terminal:themeSelector.selectTheme"),o.jsx("span",{className:"guake-mobile-theme-arrow",children:et?"▲":"▼"})]}),et&&o.jsx("div",{className:"guake-mobile-theme-list",children:ia.map(te=>o.jsxs("button",{className:`guake-mobile-theme-option ${te.id===fe?"active":""}`,onClick:()=>$e(te.id),children:[o.jsx("span",{className:"guake-mobile-theme-preview",style:{background:`linear-gradient(135deg, ${te.colors.bgPrimary} 0%, ${te.colors.bgSecondary} 50%, ${te.colors.accentPurple} 100%)`}}),o.jsx("span",{className:"guake-mobile-theme-name",children:te.name}),te.id===fe&&o.jsx("span",{className:"guake-mobile-theme-check",children:"✓"})]},te.id))}),o.jsx("div",{className:"guake-mobile-menu-divider"}),o.jsxs("button",{className:"guake-mobile-menu-item",onClick:()=>{C("collapse"),Re()},disabled:e.status!=="idle",children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"📦"}),B("terminal:header.collapseContext")]}),o.jsxs("button",{className:"guake-mobile-menu-item danger",onClick:()=>{C("clear"),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"🧹"}),B("terminal:header.clearContext")]}),ze&&o.jsxs("button",{className:"guake-mobile-menu-item danger",onClick:()=>{C("clear-subordinates"),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"👑🗑️"}),B("terminal:header.clearAllSubordinates")]}),o.jsx("div",{className:"guake-mobile-menu-divider"}),o.jsxs("button",{className:"guake-mobile-menu-item danger",onClick:()=>{Z(),Re()},children:[o.jsx("span",{className:"guake-mobile-menu-icon",children:"❌"}),B("terminal:header.removeAgent")]})]})]}),o.jsx("button",{className:"guake-close-btn show-on-mobile",onClick:()=>U.setMobileView("3d"),title:B("terminal:header.closeTerminal"),children:"✕"})]})]})});function j6({searchInputRef:t,searchQuery:e,setSearchQuery:n,closeSearch:s,matchCount:a,currentMatch:r,navigateNext:i,navigatePrev:c,loadingFullHistory:d}){const{t:f}=dt(["terminal","common"]);return o.jsxs("div",{className:"guake-search",children:[o.jsx("input",{ref:t,type:"text",placeholder:f("terminal:header.searchPlaceholder"),value:e,onChange:h=>n(h.target.value),onKeyDown:h=>{h.key==="Escape"?(h.preventDefault(),s()):h.key==="Enter"&&(h.preventDefault(),h.shiftKey?c():i())}}),e.trim().length>=2&&o.jsx("span",{className:"guake-search-count",children:d?`${a>0?`${r+1} / ${a}`:"..."} loading`:a>0?`${r+1} / ${a}`:f("terminal:header.searchNoResults","No results")}),o.jsx("button",{className:"guake-search-nav",onClick:c,disabled:a===0,title:"Previous match (Shift+Enter)",children:"▲"}),o.jsx("button",{className:"guake-search-nav",onClick:i,disabled:a===0,title:"Next match (Enter)",children:"▼"}),o.jsx("button",{className:"guake-search-close",onClick:s,title:"Close search (Escape)",children:"✕"})]})}function N6({request:t,onApprove:e,onDeny:n}){const{t:s}=dt(["tools"]),a=fs[t.tool]||fs.default,r=c=>t.tool==="Bash"&&c.command?String(c.command):(t.tool==="Write"||t.tool==="Edit"||t.tool==="Read")&&c.file_path?String(c.file_path):t.tool==="WebFetch"&&c.url?String(c.url):t.tool,i=()=>{if(t.tool==="Write"||t.tool==="Edit"){const d=String(t.toolInput.file_path||"").split("/").slice(0,-1).join("/");return s("tools:permission.rememberAllowDir",{dir:d})}if(t.tool==="Bash"){const d=String(t.toolInput.command||"").split(/\s+/)[0];return s("tools:permission.rememberAllowCmd",{cmd:d})}return s("tools:permission.rememberAllowTool",{tool:t.tool})};return t.status!=="pending"?null:o.jsxs("div",{className:"permission-inline",children:[o.jsx("span",{className:"permission-inline-icon",children:a}),o.jsx("span",{className:"permission-inline-tool",children:t.tool}),o.jsx("span",{className:"permission-inline-target",children:r(t.toolInput)}),o.jsx("button",{className:"permission-inline-btn approve-remember",onClick:()=>e(!0),title:i(),children:"✓+"}),o.jsx("button",{className:"permission-inline-btn approve",onClick:()=>e(!1),title:s("tools:permission.approveOnce"),children:"✓"}),o.jsx("button",{className:"permission-inline-btn deny",onClick:n,title:s("tools:permission.deny"),children:"✕"})]})}function Ol(t,e){return e?t.split(new RegExp(`(${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi")).map((s,a)=>s.toLowerCase()===e.toLowerCase()?o.jsx("mark",{className:"search-highlight",children:s},a):s):t}function Ey(t){const e=Ea();if(t.startsWith("http"))return t;if(t.startsWith("/uploads/"))return`${e}${t}`;if(t.includes("tide-commander-uploads")){const n=t.split("/").pop()||"image";return`${e}/uploads/${n}`}else return t}function $T(t){var s;const e=((s=t.split(".").pop())==null?void 0:s.toLowerCase())||"",n={pdf:"file_type_pdf.svg",doc:"file_type_word.svg",docx:"file_type_word.svg",xls:"file_type_excel.svg",xlsx:"file_type_excel.svg",ppt:"file_type_powerpoint.svg",pptx:"file_type_powerpoint.svg",txt:"file_type_text.svg",md:"file_type_markdown.svg",js:"file_type_javascript_official.svg",jsx:"file_type_javascript_official.svg",ts:"file_type_typescript_official.svg",tsx:"file_type_typescript_official.svg",py:"file_type_python.svg",java:"file_type_java.svg",cpp:"file_type_cpp.svg",c:"file_type_cpp.svg",h:"file_type_cpp.svg",hpp:"file_type_cpp.svg",cs:"file_type_csharp.svg",go:"file_type_go.svg",rs:"file_type_rust.svg",php:"file_type_php.svg",rb:"file_type_ruby.svg",swift:"file_type_swift.svg",kt:"file_type_kotlin.svg",scala:"file_type_scala.svg",r:"file_type_r.svg",html:"file_type_html.svg",htm:"file_type_html.svg",css:"file_type_css.svg",scss:"file_type_scss.svg",sass:"file_type_sass.svg",less:"file_type_less.svg",json:"file_type_json_official.svg",yaml:"file_type_yaml_official.svg",yml:"file_type_yaml_official.svg",xml:"file_type_xml.svg",toml:"file_type_toml.svg",ini:"file_type_ini.svg",env:"file_type_dotenv.svg",sh:"file_type_shell.svg",bash:"file_type_shell.svg",zsh:"file_type_shell.svg",fish:"file_type_shell.svg",png:"file_type_image.svg",jpg:"file_type_image.svg",jpeg:"file_type_image.svg",gif:"file_type_image.svg",svg:"file_type_image.svg",webp:"file_type_image.svg",zip:"file_type_zip.svg",tar:"file_type_tar.svg",gz:"file_type_gzip.svg",rar:"file_type_rar.svg","7z":"file_type_zip.svg",mp3:"file_type_audio.svg",mp4:"file_type_video.svg",wav:"file_type_audio.svg",mov:"file_type_video.svg",mkv:"file_type_video.svg",flv:"file_type_video.svg",avi:"file_type_video.svg",default:"default_file.svg"};return n[e]||n.default}function zl(t,e,n){const s=/\[(Image|File):\s*([^\]]+)\]/g,a=[];let r=0,i;const c=ld({onFileClick:n});for(;(i=s.exec(t))!==null;){if(i.index>r){const m=lp(t.slice(r,i.index));a.push(o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:c,children:m})},`text-${r}`))}const d=i[1]==="Image",f=i[2].trim(),h=f.split("/").pop()||(d?"image":"file");if(d){const m=Ey(f);a.push(o.jsxs("span",{className:"image-reference clickable",onClick:()=>e==null?void 0:e(m,h),title:On.t("terminal:content.clickToViewImage"),children:[o.jsx("img",{src:m,alt:h,className:"image-reference-thumb"}),h]},`img-${i.index}`))}else{const m=$T(h);a.push(o.jsxs("span",{className:"file-reference clickable",onClick:()=>n==null?void 0:n(f),title:On.t("terminal:content.clickToViewFile",{path:f}),children:[o.jsx("img",{src:`/assets/vscode-icons/${m}`,alt:h,style:{width:"12px",height:"12px",display:"inline",marginRight:"4px"}}),h]},`file-${i.index}`))}r=i.index+i[0].length}if(r<t.length){const d=lp(t.slice(r));a.push(o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:c,children:d})},`text-${r}`))}return a.length===0?o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:c,children:lp(t)})}):o.jsx(o.Fragment,{children:a})}function Bu(t,e,n){const s=/\[(Image|File):\s*([^\]]+)\]/g,a=[];let r=0,i;for(;(i=s.exec(t))!==null;){if(i.index>r){const h=t.slice(r,i.index);a.push(o.jsx("span",{className:"user-prompt-text",children:h},`text-${r}`))}const c=i[1]==="Image",d=i[2].trim(),f=d.split("/").pop()||(c?"image":"file");if(c){const h=Ey(d);a.push(o.jsxs("span",{className:"image-reference clickable",onClick:()=>e==null?void 0:e(h,f),title:On.t("terminal:content.clickToViewImage"),children:[o.jsx("img",{src:h,alt:f,className:"image-reference-thumb"}),f]},`img-${i.index}`))}else{const h=$T(f);a.push(o.jsxs("span",{className:"file-reference clickable",onClick:()=>n==null?void 0:n(d),title:On.t("terminal:content.clickToViewFile",{path:d}),children:[o.jsx("img",{src:`/assets/vscode-icons/${h}`,alt:f,style:{width:"12px",height:"12px",display:"inline",marginRight:"4px"}}),f]},`file-${i.index}`))}r=i.index+i[0].length}if(r<t.length){const c=t.slice(r);a.push(o.jsx("span",{className:"user-prompt-text",children:c},`text-${r}`))}return a.length===0?o.jsx("span",{className:"user-prompt-text",children:t}):o.jsx(o.Fragment,{children:a})}function T6({id:t,lineCount:e,fullText:n,onRemove:s}){const{t:a}=dt(["tools","common"]),[r,i]=x.useState(!1),c=d=>{d.stopPropagation(),i(!0)};return o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"pasted-text-chip",onClick:c,title:a("tools:pastedText.clickToView"),children:[o.jsx("span",{className:"pasted-text-chip-icon",children:"📋"}),o.jsx("span",{className:"pasted-text-chip-label",children:a("tools:pastedText.pastedNumber",{id:t})}),o.jsx("span",{className:"pasted-text-chip-count",children:a("tools:pastedText.lineCount",{count:e})}),o.jsx("button",{className:"pasted-text-chip-remove",onClick:d=>{d.stopPropagation(),s()},title:a("common:buttons.remove"),children:"×"})]}),r&&o.jsx(_6,{id:t,lineCount:e,content:n,onClose:()=>i(!1)})]})}function _6({id:t,lineCount:e,content:n,onClose:s}){const{t:a}=dt(["tools","common"]),{handleMouseDown:r,handleClick:i}=Ta(s),[c,d]=x.useState(!1),f=async()=>{try{await navigator.clipboard.writeText(n),d(!0),setTimeout(()=>d(!1),2e3)}catch(h){console.error("Failed to copy:",h)}};return o.jsx("div",{className:"modal-overlay visible pasted-text-modal-overlay",onMouseDown:r,onClick:i,children:o.jsxs("div",{className:"modal pasted-text-modal",children:[o.jsxs("div",{className:"pasted-text-modal-header",children:[o.jsxs("div",{className:"pasted-text-modal-title",children:[o.jsx("span",{className:"pasted-text-modal-icon",children:"📋"}),o.jsx("span",{children:a("tools:pastedText.pastedTextTitle",{id:t})}),o.jsx("span",{className:"pasted-text-modal-count",children:a("tools:pastedText.lineCountFull",{count:e})})]}),o.jsxs("div",{className:"pasted-text-modal-actions",children:[o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:f,children:c?`✓ ${a("common:toast.copied")}`:a("common:buttons.copy")}),o.jsx("button",{className:"pasted-text-modal-close",onClick:s,children:"×"})]})]}),o.jsx("div",{className:"pasted-text-modal-body",children:o.jsx("pre",{className:"pasted-text-content",children:n})})]})})}const E6={language:"Spanish",model:"medium"};function UT(t={}){var w;const[e,n]=x.useState(!1),[s,a]=x.useState(!1),[r,i]=x.useState(null),c=x.useRef(null),d=x.useRef([]),f=x.useRef(null),h={...E6,...t},m=x.useCallback(async()=>{i(null);try{if(!window.isSecureContext){console.error("[STT] Not in secure context - microphone requires HTTPS"),i("Microphone requires HTTPS");return}const C=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:16e3}});f.current=C,d.current=[];const N=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg",""];let k="";for(const T of N)if(!T||MediaRecorder.isTypeSupported(T)){k=T;break}console.log("[STT] Using MIME type:",k||"browser default");const j={};k&&(j.mimeType=k);const S=new MediaRecorder(C,j);S.ondataavailable=T=>{T.data.size>0&&d.current.push(T.data)},c.current=S,S.start(100),n(!0),console.log("[STT] Recording started")}catch(C){console.error("[STT] Failed to start recording:",C),C instanceof Error?C.name==="NotAllowedError"||C.name==="PermissionDeniedError"?i("Microphone permission denied"):C.name==="NotFoundError"||C.name==="DevicesNotFoundError"?i("No microphone found"):C.name==="NotReadableError"||C.name==="TrackStartError"?i("Microphone in use by another app"):C.name==="OverconstrainedError"?i("Microphone constraints not supported"):i(`Microphone error: ${C.message}`):i("Failed to access microphone")}},[]),b=x.useCallback(async()=>!c.current||!e?null:new Promise(C=>{const N=c.current;N.onstop=async()=>{var S,T;f.current&&(f.current.getTracks().forEach(D=>D.stop()),f.current=null);const k=((S=d.current[0])==null?void 0:S.type)||"audio/webm",j=new Blob(d.current,{type:k});if(d.current=[],console.log("[STT] Recording stopped, audio size:",j.size),j.size<1e3){i("Recording too short"),n(!1),C(null);return}a(!0);try{const D=await M6(j);console.log("[STT] Sending audio for transcription...");const I=await(await Bt(Rt("/api/stt/transcribe"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({audio:D,language:h.language,model:h.model})})).json();I.success&&I.text?(console.log("[STT] Transcription:",I.text),(T=h.onTranscription)==null||T.call(h,I.text),C(I.text)):(console.error("[STT] Transcription failed:",I.error),i(I.error||"Transcription failed"),C(null))}catch(D){console.error("[STT] Failed to transcribe:",D),i("Failed to transcribe audio"),C(null)}finally{a(!1)}n(!1)},N.stop()}),[e,h]),y=x.useCallback(async()=>e?b():(await m(),null),[e,m,b]);return{recording:e,transcribing:s,error:r,startRecording:m,stopRecording:b,toggleRecording:y,supported:typeof navigator<"u"&&!!((w=navigator.mediaDevices)!=null&&w.getUserMedia)&&typeof MediaRecorder<"u"}}function M6(t){return new Promise((e,n)=>{const s=new FileReader;s.onloadend=()=>{const a=s.result.split(",")[1];e(a)},s.onerror=n,s.readAsDataURL(t)})}const D6=x.memo(function({agentId:e,isWorking:n,timestamp:s}){const{t:a}=dt(["terminal"]),[r,i]=x.useState(0);return x.useEffect(()=>{if(!n||!s){i(0);return}i(Date.now()-s);const c=setInterval(()=>{i(Date.now()-s)},1e3);return()=>clearInterval(c)},[n,s]),n?o.jsxs("div",{className:"guake-stop-bar",children:[o.jsx("span",{className:"guake-elapsed-timer",children:HT(r)}),o.jsxs("button",{className:"guake-stop-btn",onClick:()=>U.stopAgent(e),title:a("terminal:input.stopOperation"),children:[o.jsx("span",{className:"stop-icon",children:"■"}),o.jsx("span",{className:"stop-label",children:a("terminal:input.stop")})]})]}):null});function DA(t){const e={pdf:"file_type_pdf.svg",doc:"file_type_word.svg",docx:"file_type_word.svg",xls:"file_type_excel.svg",xlsx:"file_type_excel.svg",ppt:"file_type_powerpoint.svg",pptx:"file_type_powerpoint.svg",txt:"file_type_text.svg",md:"file_type_markdown.svg",js:"file_type_javascript_official.svg",jsx:"file_type_javascript_official.svg",ts:"file_type_typescript_official.svg",tsx:"file_type_typescript_official.svg",py:"file_type_python.svg",java:"file_type_java.svg",cpp:"file_type_cpp.svg",c:"file_type_cpp.svg",h:"file_type_cpp.svg",hpp:"file_type_cpp.svg",cs:"file_type_csharp.svg",go:"file_type_go.svg",rs:"file_type_rust.svg",php:"file_type_php.svg",rb:"file_type_ruby.svg",swift:"file_type_swift.svg",kt:"file_type_kotlin.svg",scala:"file_type_scala.svg",r:"file_type_r.svg",html:"file_type_html.svg",htm:"file_type_html.svg",css:"file_type_css.svg",scss:"file_type_scss.svg",sass:"file_type_sass.svg",less:"file_type_less.svg",json:"file_type_json_official.svg",yaml:"file_type_yaml_official.svg",yml:"file_type_yaml_official.svg",xml:"file_type_xml.svg",toml:"file_type_toml.svg",ini:"file_type_ini.svg",env:"file_type_dotenv.svg",sh:"file_type_shell.svg",bash:"file_type_shell.svg",zsh:"file_type_shell.svg",fish:"file_type_shell.svg",png:"file_type_image.svg",jpg:"file_type_image.svg",jpeg:"file_type_image.svg",gif:"file_type_image.svg",svg:"file_type_image.svg",webp:"file_type_image.svg",zip:"file_type_zip.svg",tar:"file_type_tar.svg",gz:"file_type_gzip.svg",rar:"file_type_rar.svg","7z":"file_type_zip.svg",mp3:"file_type_audio.svg",mp4:"file_type_video.svg",wav:"file_type_audio.svg",mov:"file_type_video.svg",mkv:"file_type_video.svg",flv:"file_type_video.svg",avi:"file_type_video.svg",default:"default_file.svg"};return e[t.toLowerCase()]||e.default}function HT(t){const e=Math.floor(t/1e3),n=Math.floor(e/60),s=e%60;return`${n}:${s.toString().padStart(2,"0")}`}const RA=72,R6=128,O6=x.memo(function({selectedAgent:e,selectedAgentId:n,isOpen:s,command:a,setCommand:r,forceTextarea:i,setForceTextarea:c,useTextarea:d,attachedFiles:f,setAttachedFiles:h,removeAttachedFile:m,uploadFile:b,pastedTexts:y,expandPastedTexts:w,incrementPastedCount:C,setPastedTexts:N,resetPastedCount:k,handleInputFocus:j,handleInputBlur:S,pendingPermissions:T,showCompletion:D,completionElapsed:E,onImageClick:I,inputRef:O,textareaRef:_,isSnapshotView:M=!1,onClearHistory:R,onSendCommand:z,canSwipeClose:$=!1,onSwipeCloseOffsetChange:W,onSwipeClose:L}){const{t:F}=dt(["terminal","common"]),H=x.useRef(null),V=x.useRef(null),G=O||H,B=_||V,K=x.useRef(null),ne=x.useRef(null),q=x.useRef(d),xe=x.useRef(0),Ae=x.useRef(null),Z=x.useRef({isTracking:!1,startY:0,startX:0}),[ce,me]=x.useState(0),[ee,re]=x.useState("idle"),We=Vr(),ze=Xj(n),Pe=e.status==="working",ge=x.useCallback(()=>{const te=K.current,be=d?B.current:G.current;te==null||te.focus({preventScroll:!0}),be==null||be.focus({preventScroll:!0})},[G,B,d]),{recording:Te,transcribing:qe,toggleRecording:it}=UT({language:"Spanish",model:"medium",onTranscription:te=>{te.trim()&&n&&U.sendCommand(n,te.trim())}}),he=x.useCallback(()=>{Ae.current&&(clearTimeout(Ae.current),Ae.current=null)},[]),Be=x.useCallback((te="idle")=>{he(),me(0),re(te),W==null||W(0),te==="returning"&&(Ae.current=setTimeout(()=>{re("idle"),Ae.current=null},160))},[he,W]),ie=x.useCallback(te=>{if(!$||!L||window.innerWidth>768||te.touches.length!==1)return;he();const be=te.touches[0];Z.current={isTracking:!0,startY:be.clientY,startX:be.clientX},re("idle"),me(0),W==null||W(0)},[$,L,he,W]),de=x.useCallback(te=>{if(!Z.current.isTracking)return;const be=te.touches[0],we=be.clientY-Z.current.startY,Fe=Math.abs(be.clientX-Z.current.startX);if(Fe>48&&Fe>Math.abs(we)){Z.current.isTracking=!1,Be("returning");return}if(we>=0){me(0),re("idle");return}const Ke=Math.min(R6,Math.abs(we));Ke>8&&te.preventDefault(),me(Ke),re("dragging"),W==null||W(Ke)},[Be,W]),He=x.useCallback(()=>{if(Z.current.isTracking){if(Z.current.isTracking=!1,!$||!L){Be("returning");return}if(ce>=RA){L();return}Be("returning")}},[$,L,ce,Be,W]),et=x.useCallback(()=>{Z.current.isTracking=!1,Be("returning")},[Be]);x.useEffect(()=>()=>he(),[he]),x.useEffect(()=>{$||(Z.current.isTracking=!1,Be("idle"))},[$,Be]);const ct=te=>{xe.current=te.target.selectionStart||te.target.value.length,r(te.target.value)};x.useEffect(()=>{const te=B.current;if(!te||!d)return;const we=window.innerWidth<=768?200:180;requestAnimationFrame(()=>{te.style.height="0px",te.style.overflow="hidden";const Fe=te.scrollHeight,Ke=Math.max(46,Math.min(Fe,we));te.style.height=`${Ke}px`,te.style.overflow=Ke>=we?"auto":"hidden"})},[a,d]),x.useEffect(()=>{q.current!==d&&(q.current=d,requestAnimationFrame(()=>{const te=xe.current;d&&B.current?(ge(),B.current.setSelectionRange(te,te)):!d&&G.current&&(ge(),G.current.setSelectionRange(te,te))}))},[ge,G,B,d]);const fe=x.useRef(!1);x.useEffect(()=>{const te=fe.current;fe.current=s;const be=typeof window<"u"&&window.matchMedia("(pointer: coarse)").matches,we=U.consumeSwipeSelectionFlag(),Fe=U.consumeDirectClickSelectionFlag();if(s&&(!te||n)&&!(be&&(we||Fe))){const st=setTimeout(()=>{ge()},50);return()=>clearTimeout(st)}},[s,ge,n]);const X=te=>{const be=new RegExp(`\\[Pasted text #${te} \\+\\d+ lines\\]\\s*`,"g");r(a.replace(be,"").trim()),N(we=>{const Fe=new Map(we);return Fe.delete(te),Fe})},Se=(()=>{const te=/\[Pasted text #(\d+) \+(\d+) lines\]/g,be=[];let we;for(;(we=te.exec(a))!==null;)be.push({id:parseInt(we[1],10),lineCount:parseInt(we[2],10)});return be})(),J=()=>{var we,Fe;if(!a.trim()&&f.length===0||!n)return;if(a.trim()==="/clear"&&f.length===0){U.clearContext(n),R(),r(""),c(!1),N(new Map),h([]),k();return}let te=w(a.trim());if(f.length>0){const Ke=f.map(st=>st.isImage?`[Image: ${st.path}]`:`[File: ${st.path}]`).join(`
|
|
125
|
+
`);te?te=`${te}
|
|
126
|
+
|
|
127
|
+
${Ke}`:te=Ke}U.sendCommand(n,te),z==null||z(),r(""),c(!1),N(new Map),h([]),k(),window.innerWidth<=768&&((we=G.current)==null||we.blur(),(Fe=B.current)==null||Fe.blur())},pe=te=>{const be=window.innerWidth<=768;if(te.key==="Enter"){if(be){d||(te.preventDefault(),c(!0),setTimeout(()=>{r(a+`
|
|
128
|
+
`)},0));return}if(te.shiftKey){d||(te.preventDefault(),c(!0));return}te.preventDefault(),J()}},Re=te=>{},$e=te=>{te.button===1&&(te.preventDefault(),te.stopPropagation())},ye=async te=>{const be=te.clipboardData.items;for(const at of be){if(at.type.startsWith("image/")){te.preventDefault();const gt=at.getAsFile();if(gt){const ht=await b(gt);ht&&h(Gt=>[...Gt,ht])}return}if(at.kind==="file"){te.preventDefault();const gt=at.getAsFile();if(gt){const ht=await b(gt);ht&&h(Gt=>[...Gt,ht])}return}}const we=te.clipboardData.files;if(we.length>0){te.preventDefault();for(const at of we){const gt=await b(at);gt&&h(ht=>[...ht,gt])}return}const Fe=te.clipboardData.getData("text"),Ke=!Fe.includes(`
|
|
129
|
+
`),st=/^[/~][^\s]*$|^[A-Za-z]:\\[^\s]*$/.test(Fe.trim()),ft=/\.[a-zA-Z0-9]{1,5}$/.test(Fe.trim());if(Ke&&st&&ft){te.preventDefault();try{const at=await fetch("/api/files/by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Fe.trim()})});if(at.ok){const gt=await at.blob(),ht=Fe.trim().split(/[/\\]/).pop()||"file",Gt=await b(gt,ht);Gt&&h(tn=>[...tn,Gt]);return}}catch{}r(a+Fe);return}const wt=(Fe.match(/\n/g)||[]).length+1;if(wt>5){te.preventDefault();const at=C();N(Ye=>new Map(Ye).set(at,Fe));const gt=`[Pasted text #${at} +${wt} lines]`,ht=te.target,Gt=ht.selectionStart||0,tn=ht.selectionEnd||0,je=a.slice(0,Gt)+gt+a.slice(tn),Oe=Gt+gt.length;xe.current=Oe,r(je),d?requestAnimationFrame(()=>{B.current&&B.current.setSelectionRange(Oe,Oe)}):c(!0)}},Ie=async te=>{const be=te.target.files;if(be){for(const we of be){const Fe=await b(we);Fe&&h(Ke=>[...Ke,Fe])}ne.current&&(ne.current.value="")}};return o.jsxs(o.Fragment,{children:[T.length>0&&o.jsx("div",{className:"permission-bar",children:T.map(te=>o.jsx(N6,{request:te,onApprove:be=>U.respondToPermissionRequest(te.id,!0,void 0,be),onDeny:()=>U.respondToPermissionRequest(te.id,!1)},te.id))}),Se.length>0&&o.jsx("div",{className:"guake-pasted-texts",children:Se.map(({id:te,lineCount:be})=>{const we=y.get(te)||"";return o.jsx(T6,{id:te,lineCount:be,fullText:we,onRemove:()=>X(te)},te)})}),f.length>0&&o.jsx("div",{className:"guake-attachments",children:f.map(te=>{var Ke;const be=te.isImage?Ey(te.path):null,we=((Ke=te.name.split(".").pop())==null?void 0:Ke.toLowerCase())||"",Fe=["pdf","doc","docx","xls","xlsx","ppt","pptx"].includes(we);return o.jsxs("div",{className:`guake-attachment ${te.isImage?"is-image clickable":""} ${Fe?"is-document":""}`,onClick:()=>{te.isImage&&I(be,te.name)},children:[te.isImage&&be?o.jsx("img",{src:be,alt:te.name,className:"guake-attachment-thumb"}):o.jsx("img",{src:`/assets/vscode-icons/${DA(we)}`,alt:te.name,className:"guake-attachment-icon",style:{width:"24px",height:"24px"}}),o.jsxs("div",{className:"guake-attachment-info",children:[o.jsxs("div",{className:"guake-attachment-name-row",children:[o.jsx("img",{src:`/assets/vscode-icons/${DA(we)}`,alt:we,className:"guake-attachment-type-icon",style:{width:"11px",height:"11px"}}),o.jsx("span",{className:"guake-attachment-name",title:te.path,children:te.name})]}),o.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(te.size/1024),"KB)"]})]}),o.jsx("button",{className:"guake-attachment-remove",onClick:st=>{st.stopPropagation(),m(te.id)},title:F("terminal:input.removeAttachment"),children:"×"})]},te.id)})}),o.jsx("div",{className:`guake-input-wrapper ${e.status==="working"?"has-stop-btn is-working":""} ${D?"is-completed":""} ${M?"is-snapshot-view":""}`,children:o.jsxs("div",{className:`guake-input-swipe-shell ${ee!=="idle"?"swipe-close-active":""} ${ce>=RA?"swipe-close-ready":""}`,onTouchStart:ie,onTouchMove:de,onTouchEnd:He,onTouchCancel:et,children:[!M&&(()=>{const te=e.contextStats,be=te?te.totalTokens:e.contextUsed||0,we=te?te.contextWindow:e.contextLimit||2e5,Fe=te?te.usedPercent:Math.round(be/we*100),Ke=Math.max(0,Math.min(100,Fe)),st=Math.max(0,100-Ke),ft=Ke>=80?"#ff4a4a":Ke>=60?"#ff9e4a":Ke>=40?"#ffd700":"#4aff9e",wt=(be/1e3).toFixed(1),at=(we/1e3).toFixed(1);return o.jsxs("div",{className:"mobile-context-bar show-on-mobile",onClick:()=>U.setContextModalAgentId(n),children:[o.jsx("span",{className:"mobile-context-bar-fill",style:{width:`${Math.min(100,Ke)}%`,backgroundColor:ft}}),o.jsxs("span",{className:"mobile-context-bar-text",children:[o.jsxs("span",{style:{color:ft},children:[wt,"k/",at,"k"]}),o.jsxs("span",{className:"mobile-context-bar-pct",children:["(",st,"% free)"]})]})]})})(),o.jsx(D6,{agentId:n,isWorking:Pe,timestamp:ze==null?void 0:ze.timestamp}),D&&E!==null&&o.jsx("div",{className:"guake-completion-time",children:HT(E)}),o.jsxs("div",{className:`guake-input ${d?"guake-input-expanded":""}`,children:[o.jsx("input",{ref:ne,type:"file",multiple:!0,onChange:Ie,style:{display:"none"},accept:"*"}),o.jsxs("div",{ref:K,className:"guake-input-container",tabIndex:-1,onAuxClick:$e,children:[o.jsx("button",{className:"guake-attach-btn",onClick:()=>{var te;return(te=ne.current)==null?void 0:te.click()},title:F("terminal:input.attachOrPaste"),children:"📎"}),We.experimentalTTS&&o.jsx("button",{className:`guake-mic-btn ${Te?"recording":""} ${qe?"transcribing":""}`,onClick:it,title:F(Te?"terminal:input.stopRecording":qe?"terminal:input.transcribing":"terminal:input.voiceInput"),disabled:qe,children:qe?"⏳":Te?"🔴":"🎤"}),d?o.jsx("textarea",{ref:B,placeholder:F("terminal:input.placeholder",{agent:e.name}),value:a,onChange:ct,onKeyDown:pe,onPaste:ye,onMouseDown:Re,onFocus:j,onBlur:S}):o.jsx("input",{ref:G,type:"text",placeholder:F("terminal:input.placeholder",{agent:e.name}),value:a,onChange:ct,onKeyDown:pe,onPaste:ye,onMouseDown:Re,onFocus:j,onBlur:S}),o.jsx("button",{onClick:J,disabled:!a.trim()&&f.length===0,title:F("terminal:input.send"),children:"➤"})]})]})]})})]})});function L6({agent:t,content:e,isOpen:n,onClose:s}){const{t:a}=dt(["tools","common","terminal"]),r=x.useCallback(()=>{navigator.clipboard.writeText(e)},[e]),{handleMouseDown:i,handleClick:c}=Ta(s);return n?o.jsx(pr,{children:o.jsx("div",{className:"modal-overlay visible",onMouseDown:i,onClick:c,children:o.jsxs("div",{className:"modal agent-response-modal",children:[o.jsxs("div",{className:"modal-header agent-response-modal-header",children:[o.jsxs("div",{className:"agent-response-modal-title",children:[o.jsx("span",{className:"agent-response-modal-icon",children:"📝"}),o.jsxs("span",{children:[t.name," - ",a("terminal:modals.rawOutput")]})]}),o.jsx("button",{className:"agent-response-modal-close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),o.jsx("div",{className:"modal-body agent-response-modal-body",children:e?o.jsx("pre",{className:"agent-response-raw",children:e}):o.jsxs("div",{className:"agent-response-empty",children:[o.jsx("span",{className:"agent-response-empty-icon",children:"📭"}),o.jsx("span",{children:a("tools:response.noContent")})]})}),o.jsxs("div",{className:"modal-footer agent-response-modal-footer",children:[o.jsx("button",{className:"btn btn-primary",onClick:r,children:a("common:buttons.copy")}),o.jsx("button",{className:"btn btn-secondary",onClick:s,children:a("common:buttons.close")})]})]})})}):null}function I6({url:t,name:e,onClose:n}){const{handleMouseDown:s,handleClick:a}=Ta(n);return o.jsx(pr,{children:o.jsx("div",{className:"image-modal-overlay",onMouseDown:s,onClick:a,children:o.jsxs("div",{className:"image-modal",children:[o.jsxs("div",{className:"image-modal-header",children:[o.jsx("span",{className:"image-modal-title",children:e}),o.jsx("button",{className:"image-modal-close",onClick:n,children:"×"})]}),o.jsx("div",{className:"image-modal-content",children:o.jsx("img",{src:t,alt:e})})]})})})}function P6({state:t,onClose:e}){const{t:n}=dt(["terminal","common"]),{handleMouseDown:s,handleClick:a}=Ta(e);return o.jsx(pr,{children:o.jsx("div",{className:"bash-modal-overlay",onMouseDown:s,onClick:a,children:o.jsxs("div",{className:"bash-modal",children:[o.jsxs("div",{className:"bash-modal-header",children:[o.jsx("span",{className:"bash-modal-icon",children:"$"}),o.jsx("span",{className:"bash-modal-title",children:n("terminal:modals.terminalOutput")}),o.jsx("button",{className:"bash-modal-close",onClick:e,children:"×"})]}),o.jsx("div",{className:"bash-modal-command",children:o.jsx("pre",{dangerouslySetInnerHTML:{__html:Mo(t.command,"bash")}})}),o.jsx("div",{className:`bash-modal-content ${t.isLive?"is-loading":""}`,children:o.jsx("pre",{dangerouslySetInnerHTML:{__html:Kl(t.output)}})})]})})})}function B6({action:t,selectedAgentId:e,subordinateCount:n,onClose:s,onClearHistory:a}){const{t:r}=dt(["terminal","common"]),{handleMouseDown:i,handleClick:c}=Ta(s),d=()=>{e&&(t==="collapse"?U.collapseContext(e):t==="clear-subordinates"?U.clearAllSubordinatesContext(e):(U.clearContext(e),a())),s()},f=()=>r(t==="collapse"?"terminal:modals.collapseContext":t==="clear-subordinates"?"terminal:modals.clearAllSubordinatesContext":"terminal:modals.clearContext");return o.jsx(pr,{children:o.jsx("div",{className:"modal-overlay visible guake-context-confirm-overlay",onMouseDown:i,onClick:c,children:o.jsxs("div",{className:"modal confirm-modal guake-context-confirm-modal",children:[o.jsx("div",{className:"modal-header",children:f()}),o.jsx("div",{className:"modal-body confirm-modal-body",children:t==="collapse"?o.jsxs(o.Fragment,{children:[o.jsx("p",{children:r("terminal:modals.collapseConfirm")}),o.jsx("p",{className:"confirm-modal-note",children:r("terminal:modals.collapseNote")})]}):t==="clear-subordinates"?o.jsxs(o.Fragment,{children:[o.jsx("p",{children:r("terminal:modals.clearSubordinatesConfirm",{count:n})}),o.jsx("p",{className:"confirm-modal-note",children:r("terminal:modals.clearSubordinatesNote")})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{children:r("terminal:modals.clearConfirm")}),o.jsx("p",{className:"confirm-modal-note",children:r("terminal:modals.clearNote")})]})}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:s,children:r("common:buttons.cancel")}),o.jsx("button",{className:`btn ${t==="clear"||t==="clear-subordinates"?"btn-danger":"btn-primary"}`,onClick:d,autoFocus:!0,children:r(t==="collapse"?"common:buttons.collapse":t==="clear-subordinates"?"terminal:modals.clearAll":"terminal:modals.clearContext")})]})]})})})}function F6(){const t=qx(),e=ed(),n=t?e.get(t):null;return n?o.jsx(x1,{agent:n,isOpen:!!t,onClose:()=>U.closeContextModal(),onRefresh:()=>{t&&U.refreshAgentContext(t)}}):null}function z6(){const t=Wx(),e=QO(),n=XO();return t?o.jsx(EN,{isOpen:!!t,onClose:()=>U.clearFileViewerPath(),filePath:t,action:e?"modified":"read",editData:e||void 0,searchRoot:n||void 0}):null}function $6({agent:t,content:e,onClose:n}){return t?o.jsx(L6,{agent:t,content:e||"",isOpen:!!e,onClose:n}):null}function OA(t){if(!t)return"N/A";try{return new Date(t).toLocaleString()}catch{return"N/A"}}function U6({agent:t,isOpen:e,onClose:n}){var S,T,D,E,I;const{t:s}=dt(["terminal","common"]),{handleMouseDown:a,handleClick:r}=Ta(n),i=eL((t==null?void 0:t.id)||null),c=a1((t==null?void 0:t.class)||null);if(!e||!t)return null;const d=t.provider==="codex"?t.codexModel||"gpt-5.3-codex":t.model||"sonnet",f=((S=c==null?void 0:c.instructions)==null?void 0:S.trim())||"",h=((T=t.customInstructions)==null?void 0:T.trim())||"",m=f.length>0,b=h.length>0,y=m||b,w=m&&b,C=[f,h].filter(Boolean).join(`
|
|
130
|
+
|
|
131
|
+
`),N=Math.max(1,((D=t.contextStats)==null?void 0:D.contextWindow)||t.contextLimit||2e5),k=((E=t.contextStats)==null?void 0:E.totalTokens)||t.contextUsed||0,j=((I=t.contextStats)==null?void 0:I.usedPercent)||Math.round(k/N*100);return o.jsx(pr,{children:o.jsx("div",{className:"agent-info-modal-overlay",onMouseDown:a,onClick:r,children:o.jsxs("div",{className:"agent-info-modal",children:[o.jsxs("div",{className:"agent-info-modal-header",children:[o.jsxs("div",{className:"agent-info-modal-title",children:[o.jsx("span",{className:"icon",children:"ℹ️"}),o.jsx("span",{children:s("terminal:agentInfo.title",{name:t.name})})]}),o.jsx("button",{className:"agent-info-modal-close",onClick:n,children:"×"})]}),o.jsxs("div",{className:"agent-info-modal-body",children:[o.jsxs("section",{className:"agent-info-section",children:[o.jsx("h4",{children:s("terminal:agentInfo.runtime")}),o.jsxs("div",{className:"agent-info-grid",children:[o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.backend")}),o.jsxs("strong",{children:[o.jsx("img",{src:t.provider==="codex"?"/assets/codex.png":"/assets/claude.png",alt:t.provider,className:"agent-info-provider-icon",title:t.provider==="codex"?"Codex Agent":"Claude Agent"}),t.provider==="codex"?"Codex":"Claude"]})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.model")}),o.jsx("strong",{children:d})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.status")}),o.jsx("strong",{children:t.status})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.class")}),o.jsx("strong",{children:t.class})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.permission")}),o.jsx("strong",{children:t.permissionMode})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.session")}),o.jsx("strong",{children:t.sessionId||s("terminal:agentInfo.notStarted")})]})]})]}),o.jsxs("section",{className:"agent-info-section",children:[o.jsx("h4",{children:s("terminal:agentInfo.promptAndInstructions")}),o.jsxs("div",{className:"agent-info-prompts",children:[w&&o.jsxs("div",{className:"agent-info-prompt-block",children:[o.jsx("span",{children:s("terminal:agentInfo.customPrompt")}),o.jsx("pre",{children:C})]}),!y&&o.jsxs("div",{className:"agent-info-prompt-block",children:[o.jsx("span",{children:s("terminal:agentInfo.customPrompt")}),o.jsx("strong",{className:"warn",children:s("terminal:agentInfo.notConfigured")})]}),o.jsxs("div",{className:"agent-info-prompt-block",children:[o.jsx("span",{children:s("terminal:agentInfo.classPrompt")}),m?o.jsx("pre",{children:f}):o.jsx("strong",{children:s("terminal:agentInfo.none")})]}),o.jsxs("div",{className:"agent-info-prompt-block",children:[o.jsx("span",{children:s("terminal:agentInfo.agentPrompt")}),b?o.jsx("pre",{children:h}):o.jsx("strong",{children:s("terminal:agentInfo.none")})]})]})]}),o.jsxs("section",{className:"agent-info-section",children:[o.jsx("h4",{children:s("terminal:agentInfo.skills",{count:i.length})}),i.length===0?o.jsx("div",{className:"agent-info-empty",children:s("terminal:agentInfo.noSkills")}):o.jsx("div",{className:"agent-info-skills",children:i.map(O=>o.jsxs("div",{className:"agent-info-skill",children:[o.jsx("div",{className:"agent-info-skill-name",children:O.name}),o.jsx("div",{className:"agent-info-skill-desc",children:O.description})]},O.id))})]}),o.jsxs("section",{className:"agent-info-section",children:[o.jsx("h4",{children:s("terminal:agentInfo.diagnostics")}),o.jsxs("div",{className:"agent-info-grid",children:[o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.context")}),o.jsxs("strong",{children:[k.toLocaleString()," / ",N.toLocaleString()," (",j,"%)"]})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.tasksSent")}),o.jsx("strong",{children:t.taskCount})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.workingDir")}),o.jsx("strong",{children:t.cwd})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.lastActivity")}),o.jsx("strong",{children:OA(t.lastActivity)})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.created")}),o.jsx("strong",{children:OA(t.createdAt)})]}),o.jsxs("div",{className:"agent-info-item",children:[o.jsx("span",{children:s("terminal:agentInfo.detached")}),o.jsx("strong",{children:t.isDetached?s("terminal:agentInfo.yes"):s("terminal:agentInfo.no")})]})]})]})]})]})})})}function H6(t){return t.isDirectory?"":jp[t.extension]||jp.default}function ph(t){return jp[t]||jp.default}function oV(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function W6(t,e){if(!e)return null;const n=t.toLowerCase().indexOf(e.toLowerCase());return n===-1?null:{start:n,end:n+e.length}}function Ab(t){if(t.length===0)return[];const e={isDirectory:!0,children:[],fileCount:0};for(const r of t){const i=r.path.split("/");let c=e;for(let d=0;d<i.length-1;d++){const f=i[d],h=i.slice(0,d+1).join("/");let m=c.children.find(b=>b.isDirectory&&b.name===f);m||(m={name:f,path:h,isDirectory:!0,children:[],fileCount:0},c.children.push(m)),c=m}c.children.push({name:r.name,path:r.path,isDirectory:!1,file:r,children:[],fileCount:1})}function n(r){for(r.children=r.children.map(n);r.isDirectory&&r.children.length===1&&r.children[0].isDirectory;){const i=r.children[0];r.name=r.name?r.name+"/"+i.name:i.name,r.path=i.path,r.children=i.children}return r}function s(r){return r.isDirectory?(r.fileCount=r.children.reduce((i,c)=>i+s(c),0),r.fileCount):1}function a(r){return[...r].sort((i,c)=>i.isDirectory&&!c.isDirectory?-1:!i.isDirectory&&c.isDirectory?1:i.name.toLowerCase().localeCompare(c.name.toLowerCase())).map(i=>(i.isDirectory&&(i.children=a(i.children)),i))}return e.children=e.children.map(n),s(e),e.children=a(e.children),e.children}function q6(t,e){for(const n of t)n.isDirectory&&(e.add(n.path),q6(n.children,e))}function V6(t){var i;const e=t.split(`
|
|
132
|
+
`),n=[];let s=null,a=0,r=0;for(const c of e){if(c.startsWith("diff --git")||c.startsWith("index ")||c.startsWith("--- ")||c.startsWith("+++ ")||c.startsWith("new file mode")||c.startsWith("deleted file mode")||c.startsWith("old mode")||c.startsWith("new mode")||c.startsWith("similarity index")||c.startsWith("rename from")||c.startsWith("rename to")||c.startsWith("Binary files"))continue;const d=c.match(/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@(.*)$/);if(d){s={header:((i=d[5])==null?void 0:i.trim())||"",oldStart:parseInt(d[1],10),oldCount:parseInt(d[2]??"1",10),newStart:parseInt(d[3],10),newCount:parseInt(d[4]??"1",10),lines:[]},a=s.oldStart,r=s.newStart,n.push(s);continue}if(s){if(c.startsWith("+"))s.lines.push({type:"added",content:c.slice(1),newNum:r}),r++;else if(c.startsWith("-"))s.lines.push({type:"removed",content:c.slice(1),oldNum:a}),a++;else if(c.startsWith(" ")||c==="")s.lines.push({type:"context",content:c.startsWith(" ")?c.slice(1):c,oldNum:a,newNum:r}),a++,r++;else if(c.startsWith("\\"))continue}}return n}function Y6(t,e){const n=t.split(`
|
|
133
|
+
`),s=e.split(`
|
|
134
|
+
`),a=n.length,r=s.length,i=Array(a+1).fill(null).map(()=>Array(r+1).fill(0));for(let w=1;w<=a;w++)for(let C=1;C<=r;C++)n[w-1]===s[C-1]?i[w][C]=i[w-1][C-1]+1:i[w][C]=Math.max(i[w-1][C],i[w][C-1]);const c=[];let d=a,f=r;for(;d>0||f>0;)d>0&&f>0&&n[d-1]===s[f-1]?(c.push({type:"equal",origIdx:d-1,modIdx:f-1}),d--,f--):f>0&&(d===0||i[d][f-1]>=i[d-1][f])?(c.push({type:"insert",modIdx:f-1}),f--):d>0&&(c.push({type:"delete",origIdx:d-1}),d--);c.reverse();const h=[],m=[];let b=0,y=0;for(const w of c)if(w.type==="equal"){const C=n[w.origIdx];h.push({num:w.origIdx+1,text:C,type:"unchanged"}),m.push({num:w.modIdx+1,text:C,type:"unchanged"})}else if(w.type==="delete"){const C=n[w.origIdx];h.push({num:w.origIdx+1,text:C,type:"removed"}),y++}else{const C=s[w.modIdx];m.push({num:w.modIdx+1,text:C,type:"added"}),b++}return{leftLines:h,rightLines:m,stats:{added:b,removed:y}}}function WT({content:t,onFileClick:e}){const{t:n}=dt(["tools","common","terminal"]),s=x.useRef(null),a=x.useRef(null),r=x.useRef(null),i=x.useCallback(c=>{const d=s.current,f=a.current;if(!d||!f||r.current&&r.current!==c)return;r.current=c;const h=c==="left"?d:f,m=c==="left"?f:d;m.scrollTop=h.scrollTop,m.scrollLeft=h.scrollLeft,requestAnimationFrame(()=>{r.current=null})},[]);x.useEffect(()=>{const c=s.current,d=a.current;if(!c||!d)return;const f=()=>i("left"),h=()=>i("right");return c.addEventListener("scroll",f),d.addEventListener("scroll",h),()=>{c.removeEventListener("scroll",f),d.removeEventListener("scroll",h)}},[i]);try{const c=JSON.parse(t),{file_path:d,old_string:f,new_string:h,replace_all:m,unified_diff:b}=c;if(!d)return o.jsx("pre",{className:"output-input-content",children:t});const y=d.split("/").pop()||d;if(b){const k=V6(b),j={added:0,removed:0};for(const S of k)for(const T of S.lines)T.type==="added"&&j.added++,T.type==="removed"&&j.removed++;return o.jsxs("div",{className:"edit-tool-diff",children:[o.jsxs("div",{className:"edit-tool-header",children:[o.jsx("span",{className:"edit-tool-file clickable",onClick:()=>e==null?void 0:e(d,{oldString:f||"",newString:h||"",unifiedDiff:b}),title:n("terminal:history.openFileWithDiff",{path:d}),children:y}),o.jsx("span",{className:"edit-tool-path",children:d}),o.jsxs("div",{className:"edit-tool-stats",children:[j.added>0&&o.jsxs("span",{className:"edit-stat added",children:["+",j.added]}),j.removed>0&&o.jsxs("span",{className:"edit-stat removed",children:["-",j.removed]})]}),m&&o.jsx("span",{className:"edit-tool-badge",children:n("tools:diff.replaceAll")})]}),o.jsxs("div",{className:"edit-tool-unified",children:[k.map((S,T)=>o.jsxs("div",{className:"diff-hunk",children:[o.jsxs("div",{className:"diff-hunk-header",children:[o.jsxs("span",{className:"diff-hunk-range",children:["@@ -",S.oldStart,",",S.oldCount," +",S.newStart,",",S.newCount," @@"]}),S.header&&o.jsx("span",{className:"diff-hunk-context",children:S.header})]}),S.lines.map((D,E)=>o.jsxs("div",{className:`diff-line diff-line-${D.type}`,children:[o.jsx("span",{className:"diff-line-num diff-line-num-old",children:D.type!=="added"?D.oldNum:""}),o.jsx("span",{className:"diff-line-num diff-line-num-new",children:D.type!=="removed"?D.newNum:""}),o.jsx("span",{className:"diff-line-marker",children:D.type==="added"?"+":D.type==="removed"?"-":" "}),o.jsx("span",{className:"diff-line-content",children:D.content||" "})]},E))]},T)),k.length===0&&o.jsx("div",{className:"diff-empty",children:"No changes detected"})]})]})}const{leftLines:w,rightLines:C,stats:N}=Y6(f||"",h||"");return o.jsxs("div",{className:"edit-tool-diff",children:[o.jsxs("div",{className:"edit-tool-header",children:[o.jsx("span",{className:"edit-tool-file clickable",onClick:()=>e==null?void 0:e(d,{oldString:f||"",newString:h||""}),title:n("terminal:history.openFileWithDiff",{path:d}),children:y}),o.jsx("span",{className:"edit-tool-path",children:d}),o.jsxs("div",{className:"edit-tool-stats",children:[N.added>0&&o.jsxs("span",{className:"edit-stat added",children:["+",N.added]}),N.removed>0&&o.jsxs("span",{className:"edit-stat removed",children:["-",N.removed]})]}),m&&o.jsx("span",{className:"edit-tool-badge",children:n("tools:diff.replaceAll")})]}),o.jsxs("div",{className:"edit-tool-panels",children:[o.jsxs("div",{className:"edit-panel edit-panel-original",children:[o.jsx("div",{className:"edit-panel-header",children:o.jsx("span",{className:"edit-panel-label",children:n("tools:diff.original")})}),o.jsxs("div",{className:"edit-panel-content",ref:s,children:[w.map((k,j)=>o.jsxs("div",{className:`edit-line edit-line-${k.type}`,children:[o.jsx("span",{className:"edit-line-num",children:k.num}),o.jsx("span",{className:"edit-line-content",children:k.text||" "})]},j)),w.length===0&&o.jsxs("div",{className:"edit-line edit-line-empty",children:[o.jsx("span",{className:"edit-line-num",children:"-"}),o.jsx("span",{className:"edit-line-content edit-empty-text",children:n("common:status.empty")})]})]})]}),o.jsxs("div",{className:"edit-panel edit-panel-modified",children:[o.jsx("div",{className:"edit-panel-header",children:o.jsx("span",{className:"edit-panel-label",children:n("tools:diff.modified")})}),o.jsxs("div",{className:"edit-panel-content",ref:a,children:[C.map((k,j)=>o.jsxs("div",{className:`edit-line edit-line-${k.type}`,children:[o.jsx("span",{className:"edit-line-num",children:k.num}),o.jsx("span",{className:"edit-line-content",children:k.text||" "})]},j)),C.length===0&&o.jsxs("div",{className:"edit-line edit-line-empty",children:[o.jsx("span",{className:"edit-line-num",children:"-"}),o.jsx("span",{className:"edit-line-content edit-empty-text",children:n("common:status.empty")})]})]})]})]})]})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function qT({content:t,onFileClick:e}){try{const n=JSON.parse(t),{file_path:s,offset:a,limit:r}=n;if(!s)return o.jsx("pre",{className:"output-input-content",children:t});const i=s.split("/").pop()||s,c=a!==void 0&&r!==void 0,d=()=>{c?e==null||e(s,{highlightRange:{offset:a,limit:r}}):e==null||e(s)};return o.jsxs("div",{className:"read-tool-input",children:[o.jsxs("span",{className:"read-tool-file clickable",onClick:d,title:`Open ${s}${c?" (with highlighted lines)":""}`,children:["📄 ",i]}),o.jsx("span",{className:"read-tool-path",children:s}),(a!==void 0||r!==void 0)&&o.jsxs("span",{className:"read-tool-range",children:[a!==void 0&&`offset: ${a}`,a!==void 0&&r!==void 0&&", ",r!==void 0&&`limit: ${r}`]})]})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function Hp({content:t}){const{t:e}=dt(["tools"]);try{const s=JSON.parse(t).todos;if(!Array.isArray(s)||s.length===0)return o.jsx("pre",{className:"output-input-content",children:t});const a={completed:s.filter(r=>r.status==="completed").length,in_progress:s.filter(r=>r.status==="in_progress").length,pending:s.filter(r=>r.status==="pending").length};return o.jsxs("div",{className:"todo-tool-input",children:[o.jsxs("div",{className:"todo-tool-header",children:[o.jsxs("span",{className:"todo-tool-title",children:["📋 ",e("tools:todoList.title")]}),o.jsxs("div",{className:"todo-tool-stats",children:[a.completed>0&&o.jsxs("span",{className:"todo-stat completed",children:["✓ ",a.completed]}),a.in_progress>0&&o.jsxs("span",{className:"todo-stat in-progress",children:["► ",a.in_progress]}),a.pending>0&&o.jsxs("span",{className:"todo-stat pending",children:["○ ",a.pending]})]})]}),o.jsx("div",{className:"todo-tool-list",children:s.map((r,i)=>o.jsxs("div",{className:`todo-item todo-${r.status}`,children:[o.jsx("span",{className:"todo-status-icon",children:r.status==="completed"?"✓":r.status==="in_progress"?"►":"○"}),o.jsx("span",{className:"todo-content",children:r.content})]},i))})]})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function VT({content:t}){const[e,n]=x.useState(null);try{const a=JSON.parse(t).questions;return!Array.isArray(a)||a.length===0?o.jsx("pre",{className:"output-input-content",children:t}):o.jsx("div",{className:"ask-question-input",children:a.map((r,i)=>o.jsxs("div",{className:"ask-question-block",children:[o.jsxs("div",{className:"ask-question-header",children:[r.header&&o.jsx("span",{className:"ask-question-badge",children:r.header}),o.jsx("span",{className:"ask-question-text",children:r.question}),r.multiSelect&&o.jsx("span",{className:"ask-question-multi",children:"multi"})]}),r.options&&r.options.length>0&&o.jsx("div",{className:"ask-question-options",children:r.options.map((c,d)=>{const f=i*100+d,h=e===f;return o.jsxs("div",{className:`ask-question-option ${h?"expanded":""}`,onClick:()=>n(h?null:f),children:[o.jsxs("div",{className:"ask-option-row",children:[o.jsx("span",{className:"ask-option-number",children:d+1}),o.jsx("span",{className:"ask-option-label",children:c.label}),c.markdown&&o.jsx("span",{className:"ask-option-preview-hint",children:h?"▼":"▶"})]}),c.description&&o.jsx("div",{className:"ask-option-desc",children:c.description}),c.markdown&&h&&o.jsx("pre",{className:"ask-option-markdown",children:c.markdown})]},d)})})]},i))})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function kx({content:t}){const[e,n]=x.useState(!1);try{const s=JSON.parse(t),a=typeof s.plan=="string"?s.plan.trim():"";if(!a)return o.jsx("pre",{className:"output-input-content",children:t});const r=a.match(/^#+\s+(.+)$/m),i=((r==null?void 0:r[1])||a.split(`
|
|
135
|
+
`).find(c=>c.trim().length>0)||"Plan ready").trim();return o.jsxs("div",{className:"plan-tool-input",children:[o.jsxs("div",{className:"plan-tool-header",children:[o.jsx("span",{className:"plan-tool-title",children:"🗺 Plan"}),o.jsx("button",{type:"button",className:"plan-tool-toggle",onClick:()=>n(c=>!c),title:e?"Collapse plan":"Expand plan",children:e?"▼ Hide":"▶ Show"})]}),e?o.jsx("div",{className:"plan-tool-markdown markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],children:a})}):o.jsx("div",{className:"plan-tool-collapsed-preview",children:i})]})}catch{return o.jsx("pre",{className:"output-input-content",children:t})}}function G6(t){return Array.isArray(t)?t.map(e=>String(e).trim()).filter(e=>e.length>0):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(e=>e.length>0):[]}function K6(t){return Object.entries(t).filter(([,e])=>e!==void 0).map(([e,n])=>({key:e,value:typeof n=="string"?n:JSON.stringify(n)}))}function YT(t){const e=t.match(/(?:^|[\s,;])select\s*:\s*([^\n;]+)/i),n=t.match(/(?:^|[\s,;])fallback\s*:\s*([^\n;]+)/i),s=t.match(/(?:^|[\s,;])(?:show|show_hide|hide)\s*:\s*([^\n;]+)/i);return{selectedTools:e?e[1].split(",").map(r=>r.trim()).filter(Boolean):[],fallback:n?n[1].trim():null,showHide:s?s[1].trim():null}}function Q6(t){const e=typeof t.tool=="string"?t.tool.toLowerCase():"",n=typeof t.type=="string"?t.type.toLowerCase():"",s=typeof t.label=="string"?t.label.toLowerCase():"";let a=G6(t.select??t.selected??t.selected_tools??t.tools),r=t.fallback??t.use_fallback??t.fallbackMode,i=t.show??t.show_hide??t.showHidden??t.hide;const c=t.query_params??t.query??t.params??t.arguments,d=Object.values(t).filter(b=>typeof b=="string").map(b=>b).join(" ; "),f=YT(d);if(a.length===0&&f.selectedTools.length>0&&(a=f.selectedTools),r===void 0&&f.fallback!==null&&(r=f.fallback),i===void 0&&f.showHide!==null&&(i=f.showHide),!(e.includes("toolsearch")||n.includes("toolsearch")||s.includes("toolsearch")||a.length>0||c!==void 0))return null;const m=c&&typeof c=="object"&&!Array.isArray(c)?K6(c):[];return{selectedTools:a,fallback:r!==void 0?String(r):null,showHide:i!==void 0?String(i):null,queryParams:m}}function X6(t){const e=YT(t),n=t.match(/(?:^|\s)(?:query|params|query_params)\s*:\s*(.+)$/i);if(e.selectedTools.length===0&&!n)return null;const s=[];return n&&n[1].split(/[;,]/).map(a=>a.trim()).filter(Boolean).forEach(a=>{const r=a.match(/^([^:=]+)\s*[:=]\s*(.+)$/);r?s.push({key:r[1].trim(),value:r[2].trim()}):s.push({key:"query",value:a})}),{selectedTools:e.selectedTools,fallback:e.fallback,showHide:e.showHide,queryParams:s}}function GT(t){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Q6(e)}catch{}return X6(t)}function KT(t){return GT(t)!==null}function Wp({content:t,agentName:e}){const[n,s]=x.useState(!1),a=GT(t);if(!a)return o.jsx("pre",{className:"output-input-content",children:t});const r=a.selectedTools.length>0?a.selectedTools.slice(0,4).join(", "):"-",c=a.selectedTools.length>4?`${r} +${a.selectedTools.length-4}`:r;return o.jsxs("div",{className:"toolsearch-input",children:[o.jsxs("div",{className:"toolsearch-header",children:[o.jsx("span",{className:"toolsearch-badge",children:"⚡ ToolSearch"}),e&&o.jsx("span",{className:"toolsearch-agent",children:e}),o.jsxs("span",{className:"toolsearch-meta-pill",children:["Tools: ",c]}),o.jsxs("span",{className:"toolsearch-meta-pill",children:["Fallback: ",a.fallback??"-"]}),o.jsxs("span",{className:"toolsearch-meta-pill",children:["Show/Hide: ",a.showHide??"-"]}),o.jsx("button",{type:"button",className:"toolsearch-toggle",onClick:()=>s(d=>!d),title:n?"Hide details":"Show details",children:n?"▼ Hide":"▶ Show"})]}),n?o.jsxs("div",{className:"toolsearch-query-block",children:[o.jsx("div",{className:"toolsearch-tools",children:a.selectedTools.length>0?a.selectedTools.map(d=>o.jsx("span",{className:"toolsearch-tool-chip",children:d},d)):o.jsx("span",{className:"toolsearch-empty",children:"No selected tools"})}),o.jsx("div",{className:"toolsearch-query-title",children:"Query Parameters"}),a.queryParams.length>0?o.jsx("div",{className:"toolsearch-query-list",children:a.queryParams.map((d,f)=>o.jsxs("div",{className:"toolsearch-query-row",children:[o.jsx("span",{className:"toolsearch-query-key",children:d.key}),o.jsx("span",{className:"toolsearch-query-value",children:d.value})]},`${d.key}-${f}`))}):o.jsx("div",{className:"toolsearch-empty",children:"No query parameters provided"})]}):o.jsx("div",{className:"toolsearch-preview",children:"Collapsed"})]})}function LA({toolName:t,content:e}){const[n,s]=x.useState(!1);if(!e||e.trim()==="{}")return null;const a=e.length>220?`${e.slice(0,220)}...`:e;return o.jsxs("div",{className:"unknown-tool-input",children:[o.jsx("div",{className:"unknown-tool-header",children:o.jsx("button",{type:"button",className:"unknown-tool-toggle",onClick:()=>s(r=>!r),title:n?"Collapse details":"Expand details",children:n?"▼ Hide":"▶ Show"})}),n?o.jsx("pre",{className:"output-input-content",children:e}):o.jsx("pre",{className:"unknown-tool-preview",children:a})]})}function My(){const[t,e]=x.useState(!1),n=x.useRef(null),s=x.useCallback(async i=>{if(!i.trim()){console.warn("[TTS] No text to speak");return}n.current&&(n.current.pause(),n.current=null),console.log("[TTS] Requesting audio from server (auto-detect language):",i.substring(0,100)+"..."),e(!0);try{const c=await Bt(Rt("/api/tts/speak"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:i})});if(!c.ok){const m=await c.json();console.error("[TTS] Server error:",m),e(!1);return}const d=await c.blob(),f=URL.createObjectURL(d),h=new Audio(f);n.current=h,h.onended=()=>{e(!1),URL.revokeObjectURL(f),n.current=null},h.onerror=m=>{console.error("[TTS] Audio playback error:",m),e(!1),URL.revokeObjectURL(f),n.current=null},await h.play(),console.log("[TTS] Playing audio in browser")}catch(c){console.error("[TTS] Failed to get audio:",c),e(!1)}},[]),a=x.useCallback(()=>{n.current&&(n.current.pause(),n.current=null),e(!1)},[]),r=x.useCallback(i=>{console.log("[TTS] Toggle called, currently speaking:",t),t?a():s(i)},[t,s,a]);return{speak:s,stop:a,toggle:r,speaking:t,supported:!0}}function J6(t){const e=t.split("/").pop()||t,n=e.lastIndexOf(".");return n<=0?"":e.slice(n).toLowerCase()}function Z6(t){const e=t.content.slice(0,50),n=`H${t.type[0].toUpperCase()}`;let s=0;for(let a=0;a<e.length;a++)s=(s<<5)-s+e.charCodeAt(a),s|=0;return`${n}:${(s>>>0).toString(16).slice(0,6)}`}const QT=x.memo(function({message:e,agentId:n,highlight:s,simpleView:a,onImageClick:r,onFileClick:i,onBashClick:c,onViewMarkdown:d}){var re,We;const{t:f}=dt(["tools","common","terminal"]),[h,m]=x.useState(new Set),[b,y]=x.useState(!1),w=Zj(),C=Vr(),{type:N,content:k,toolName:j,timestamp:S,_bashOutput:T,_bashCommand:D}=e,E=Tu(k,w),{toggle:I,speaking:O}=My(),_=ld({onFileClick:i?ze=>i(ze):void 0}),M=n?(re=U.getState().agents.get(n))==null?void 0:re.name:null,R=n?(We=U.getState().agents.get(n))==null?void 0:We.provider:void 0,z=R==="codex"?"Codex":"Claude",W=N==="tool_use"&&(j==="Task"||j==="Agent")&&e.toolInput&&(e.toolInput.name||e.toolInput.description)||null||M,L=S?Fp(new Date(S).getTime()):"",F=S?new Date(S).getTime():0,H=Z6(e);if(N==="assistant"&&!E.trim())return o.jsxs("div",{className:"output-line output-empty-message",children:[L&&o.jsx("span",{className:"output-timestamp",title:`${F} | ${H}`,children:L}),o.jsxs("span",{className:"history-role",children:[R&&o.jsx("img",{src:R==="codex"?"/assets/codex.png":"/assets/claude.png",alt:R,className:"history-role-icon"}),z]}),o.jsx("span",{className:"empty-message-label",children:f("terminal:history.emptyMessage","empty message")})]});if(E.startsWith("This session is being continued from a previous conversation that ran out of context"))return o.jsxs("div",{className:`output-line output-session-continuation ${b?"expanded":""}`,onClick:()=>y(!b),title:f("terminal:history.clickToExpandCollapse"),children:[L&&o.jsx("span",{className:"output-timestamp",title:`${F} | ${H}`,children:L}),o.jsx("span",{className:"session-continuation-icon",children:"🔗"}),o.jsx("span",{className:"session-continuation-label",children:f("tools:display.sessionContinued")}),o.jsx("span",{className:"session-continuation-toggle",children:b?"▼":"▶"}),b&&o.jsx("div",{className:"session-continuation-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:_,children:E})})]});const G=E.trimStart().startsWith(tx),B=!G&&E.includes("<local-command-stdout>")&&E.includes("Context Usage");if(!G&&(E.includes("## Context Usage")||E.includes("Context Usage")&&E.includes("Tokens:")&&E.includes("Free space")||B)){const ze=E.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/),Pe=ze?ze[1]:E,ge=Pe.match(/\*?\*?Tokens:\*?\*?\s*([\d.]+)k?\s*\/\s*([\d.]+)k?\s*\((\d+)%\)/),qe=(ie=>{const de=new RegExp(`\\|\\s*${ie}\\s*\\|\\s*([\\d.]+)k?\\s*\\|\\s*([\\d.]+)%`,"i"),He=Pe.match(de);if(He)return{tokens:He[1]+"k",percent:He[2]+"%"};const et=new RegExp(`${ie}\\s+([\\d.]+)k?\\s+([\\d.]+)%`,"i"),ct=Pe.match(et);return ct?{tokens:ct[1]+"k",percent:ct[2]+"%"}:null})("Messages"),it=ge?parseInt(ge[3]):0,he=100-it,Be=()=>{n&&U.setContextModalAgentId(n)};return o.jsxs("div",{className:"output-line output-context-stats",style:{cursor:n?"pointer":"default"},onClick:Be,title:n?f("terminal:history.clickForContextStats"):void 0,children:[L&&o.jsxs("span",{className:"output-timestamp context-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{className:"context-debug-hash",children:["[",H,"]"]})]}),o.jsx("span",{className:"context-icon",children:"📊"}),o.jsx("span",{className:"context-label",children:f("terminal:history.contextLabel")}),o.jsx("div",{className:"context-bar",children:o.jsx("div",{className:"context-bar-fill",style:{width:`${it}%`}})}),o.jsx("span",{className:"context-tokens",children:ge?`${ge[1]}k/${ge[2]}k`:"?"}),o.jsxs("span",{className:"context-free",children:["(",f("terminal:history.percentFree",{percent:he.toFixed(0)}),")"]}),qe&&o.jsx("span",{className:"context-msgs",children:f("terminal:history.msgsLabel",{tokens:qe.tokens})})]})}if(!G&&(E.includes("<local-command-caveat>")||E.includes("<command-name>/context</command-name>")||E.includes("<command-name>/cost</command-name>")||E.includes("<command-name>/compact</command-name>")))return null;const ne=N==="user"?Ny(E):null,q=ze=>{if(!ze)return null;let Pe=ze;if(Pe.includes("<persisted-output>")){Pe=Pe.replace(/<\/?persisted-output>/g,"").trim();const Be=Pe.match(/Preview \(first [^)]+\):\s*([\s\S]*)/);if(Be)Pe=Be[1].trim();else{const ie=Pe.indexOf("{");ie!==-1&&(Pe=Pe.slice(ie))}}const ge=Be=>{try{const ie=JSON.parse(Be);if(ie&&typeof ie=="object"&&typeof ie.output=="string")return ie.output.split(`
|
|
136
|
+
`).filter(de=>de.length>0)}catch{}return null},Te=ge(Pe);if(Te)return Te;const qe=Pe.indexOf("{"),it=Pe.lastIndexOf("}");if(qe!==-1&&it>qe){const Be=ge(Pe.slice(qe,it+1));if(Be)return Be}const he=Pe.match(/"output"\s*:\s*"([\s\S]*)/);if(he){let Be=he[1];const ie=Be.match(/","(?:duration|exitCode|taskId|success)":/);ie&&ie.index!==void 0&&(Be=Be.slice(0,ie.index)),Be=Be.replace(/\.\.\.\s*$/,"");try{Be=JSON.parse(`"${Be}"`)}catch{Be=Be.replace(/\\u([0-9a-fA-F]{4})/g,(He,et)=>String.fromCharCode(parseInt(et,16))).replace(/\\n/g,`
|
|
137
|
+
`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}const de=Be.split(`
|
|
138
|
+
`).filter(He=>He.length>0);if(de.length>0)return de}return null};if(N==="tool_use"){const ze=fs[j||""]||fs.default,Pe=j?yT(j,f):"",ge=e.toolInput?JSON.stringify(e.toolInput):E;if(a){let Te=j&&ge?vT(j,ge):null;j==="Bash"&&Te&&Te.length>300&&(Te=Te.substring(0,297)+"...");const it=["Read","Edit","Write","Glob","Grep","NotebookEdit"].includes(j||""),he=Te&&(it||Te.startsWith("/")||Te.includes("/")),Be=it&&he&&i,ie=j==="Bash"&&c,de=D||Te||"",He=ie&&de?CT(de):null,et=ie&&de?AT(de):null,ct=ie&&de?jT(de):null,fe=ie&&de?NT(de):null,X=()=>{if(Be&&Te){if(j==="Edit"&&ge)try{const $e=JSON.parse(ge);if($e.old_string!==void 0||$e.new_string!==void 0||$e.unified_diff!==void 0){i(Te,{oldString:$e.old_string||"",newString:$e.new_string||"",operation:typeof $e.operation=="string"?$e.operation:void 0,unifiedDiff:typeof $e.unified_diff=="string"?$e.unified_diff:void 0});return}}catch{}if(j==="Read"&&ge)try{const $e=JSON.parse(ge);if($e.offset!==void 0&&$e.limit!==void 0){i(Te,{highlightRange:{offset:$e.offset,limit:$e.limit}});return}}catch{}i(Te)}},se=()=>{ie&&de&&c(de,T||f("tools:display.noOutputAvailable"))},Se=()=>{var Ie;if(!Te)return null;if(!i)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Mo(Te,"bash")}});const $e=n?(Ie=U.getState().agents.get(n))==null?void 0:Ie.cwd:void 0;return ST(Te).map((te,be)=>{if(!te.fileRef)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Mo(te.text,"bash")}},`cmd-${be}`);const we=sh(te.fileRef,$e);return o.jsx("span",{className:"clickable-path",onClick:Fe=>{Fe.stopPropagation(),i(we.path)},title:f("tools:display.clickToViewFile"),style:{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"},children:te.text},`cmd-file-${be}`)})},J=ie?f("tools:display.clickToViewOutput"):Be?f("tools:display.clickToViewFile"):void 0,pe=/\bcurl\b[\s\S]*\/api\/exec\b/.test(de);let Re=null;if(pe&&T){const $e=q(T);$e&&$e.length>0&&(Re={output:$e})}if(j==="TodoWrite"&&ge)return o.jsxs("div",{className:"output-line output-tool-use output-tool-simple output-todo-inline",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe}),o.jsx(Hp,{content:ge})]});if((j==="AskUserQuestion"||j==="AskFollowupQuestion")&&ge){let $e=!1;try{const ye=JSON.parse(ge);$e=Array.isArray(ye.questions)&&ye.questions.length>0}catch{}if($e)return o.jsxs("div",{className:"output-line output-tool-use output-tool-simple output-ask-question-inline",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe}),o.jsx(VT,{content:ge})]})}return j==="ExitPlanMode"&&ge?o.jsxs("div",{className:"output-line output-tool-use output-tool-simple output-plan-inline",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe}),o.jsx(kx,{content:ge})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`output-line output-tool-use output-tool-simple ${ie?"clickable-bash":""} ${et?"bash-notify-use":""}`,onClick:ie?se:void 0,style:ie?{cursor:"pointer"}:void 0,title:ie?f("tools:display.clickToViewOutput"):void 0,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe}),ie&&et?o.jsxs("span",{className:"output-tool-param bash-command bash-notify-param",onClick:se,title:et.commandBody,style:{cursor:"pointer"},children:[et.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:et.shellPrefix}),o.jsx("span",{className:"bash-notify-chip",children:"notify"}),et.title&&o.jsx("span",{className:"bash-notify-title",children:et.title}),et.message&&o.jsx("span",{className:"bash-notify-message",children:et.message})]}):ie&&ct?o.jsxs("span",{className:"output-tool-param bash-command bash-task-label-param",onClick:se,title:ct.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:"bash-task-label-chip",children:"📋 task"}),o.jsx("span",{className:"bash-task-label-value",children:ct.taskLabel})]}):ie&&fe?o.jsxs("span",{className:"output-tool-param bash-command bash-report-task-param",onClick:se,title:fe.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:`bash-report-task-chip ${fe.status==="failed"?"status-failed":"status-completed"}`,children:fe.status==="failed"?"❌ report":"✅ report"}),fe.summary&&o.jsx("span",{className:"bash-report-task-summary",children:fe.summary})]}):ie&&He?o.jsxs("span",{className:"output-tool-param bash-command bash-search-param",onClick:se,title:He.commandBody,style:{cursor:"pointer"},children:[He.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:He.shellPrefix}),o.jsx("span",{className:"bash-search-chip",children:"search"}),o.jsx("span",{className:"bash-search-term",children:He.searchTerm})]}):Te&&o.jsxs("span",{className:`output-tool-param ${Be?"clickable-path":""}`,onClick:Be?X:void 0,title:J,style:Be?{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"}:void 0,children:[it&&he&&(()=>{const $e=J6(Te),ye=$e?ph($e):"";return ye?o.jsx("img",{className:"output-tool-file-icon",src:ye,alt:""}):null})(),ie?Se():Te]})]}),pe&&Re&&o.jsx("div",{className:"exec-task-output-container",children:o.jsx("div",{className:"exec-task-inline status-completed",children:(()=>{const $e=`history-curl-${S}`,ye=h.has($e),Ie=Re.output.slice(-6),te=Re.output.length>6,be=ye?Re.output:Ie;return o.jsxs(o.Fragment,{children:[te&&o.jsxs("div",{className:"exec-task-toggle",onClick:()=>m(we=>{const Fe=new Set(we);return Fe.has($e)?Fe.delete($e):Fe.add($e),Fe}),children:[o.jsx("span",{className:"exec-task-toggle-arrow",children:ye?"▼":"▶"}),o.jsx("span",{className:"exec-task-toggle-text",children:ye?f("tools:skills.hide"):f("tools:skills.showAll",{count:Re.output.length})})]}),o.jsx("div",{className:"exec-task-inline-terminal",children:o.jsx("pre",{className:"exec-task-inline-output",children:be.map((we,Fe)=>o.jsx("div",{dangerouslySetInnerHTML:{__html:Kl(we)}},Fe))})})]})})()})})]})}return j==="Edit"&&ge?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(WT,{content:ge,onFileClick:i})})]}):j==="Read"&&ge?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(qT,{content:ge,onFileClick:i})})]}):j==="TodoWrite"&&ge?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(Hp,{content:ge})})]}):j==="ExitPlanMode"&&ge?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(kx,{content:ge})})]}):j==="ToolSearch"&&ge?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:"⚡"}),o.jsx("span",{className:"output-tool-name",children:"ToolSearch"})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(Wp,{content:ge,agentName:W})})]}):ge&&KT(ge)?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:"⚡"}),o.jsx("span",{className:"output-tool-name",children:"ToolSearch"})]}),o.jsx("div",{className:"output-line output-tool-input",children:o.jsx(Wp,{content:ge,agentName:W})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"output-line output-tool-use",children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),W&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${W}`,children:W}),o.jsx("span",{className:"output-tool-icon",children:ze}),o.jsx("span",{className:"output-tool-name",children:Pe})]}),ge&&o.jsx("div",{className:"output-line output-tool-input",children:o.jsx("pre",{className:"output-input-content",children:Ol(ge,s)})})]})}if(N==="tool_result"){if(a)return null;const ze=E.toLowerCase().includes("error")||E.toLowerCase().includes("failed");if(j==="Bash"){const Pe=ze||E.toLowerCase().includes("command not found")||E.toLowerCase().includes("permission denied"),ge=E.includes("... (truncated,");return o.jsxs("div",{className:`output-line output-bash-result ${Pe?"is-error":""}`,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("div",{className:"bash-output-container",children:[o.jsxs("div",{className:"bash-output-header",children:[o.jsx("span",{className:"bash-output-icon",children:"$"}),o.jsx("span",{className:"bash-output-label",children:f("tools:display.terminalOutput")}),ge&&o.jsx("span",{className:"bash-output-truncated",children:f("tools:display.truncated")})]}),o.jsx("pre",{className:"bash-output-content",dangerouslySetInnerHTML:{__html:Kl(E)}})]})]})}return o.jsxs("div",{className:`output-line output-tool-result ${ze?"is-error":""}`,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsx("span",{className:"output-result-icon",children:ze?"❌":"✓"}),o.jsx("pre",{className:"output-result-content",children:Ol(E,s)})]})}const xe=N==="user",Ae=!xe&&/^\s*(?:[\u{1F300}-\u{1FAFF}\u2600-\u27BF]\s*)?\[System\]/u.test(E),Z=xe?"history-line history-user":Ae?"history-line history-system":"history-line history-assistant",ce=Ae?f("tools:display.system"):z;if(xe&&ne){const Pe=Ty(ne.userMessage).userMessage,ge=ET(Pe.trim());if(ge.isDelegatedTask)return o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsx("span",{className:"history-content",children:o.jsx(IT,{bossName:ge.bossName,bossId:ge.bossId,taskCommand:ge.taskCommand})})]});const Te=MT(Pe.trim());if(Te.isTaskReport)return o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("span",{className:"history-content",children:[ne.hasContext&&ne.context&&o.jsx($p,{context:ne.context,onFileClick:i?it=>i(it):void 0},`boss-${S||E.slice(0,50)}`),o.jsx(PT,{agentName:Te.agentName,agentId:Te.agentId,status:Te.status,originalTask:Te.originalTask,summary:Te.summary})]})]});const qe=DT(Pe.trim());return qe.hasNotification?o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("span",{className:"history-content",children:[o.jsx(BT,{agentId:qe.agentId,status:qe.status}),qe.contentWithoutNotification&&o.jsx("span",{className:"user-prompt-text",children:s?o.jsx("div",{children:Ol(qe.contentWithoutNotification,s)}):Bu(qe.contentWithoutNotification,r,i)})]})]}):o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsx("span",{className:"history-role history-role-chip",children:f("common:labels.you")}),o.jsxs("span",{className:"history-content user-prompt-text",children:[ne.hasContext&&ne.context&&o.jsx($p,{context:ne.context,onFileClick:i?it=>i(it):void 0},`boss-${S||E.slice(0,50)}`),s?o.jsx("div",{children:Ol(Pe,s)}):Bu(Pe,r,i)]})]})}const me=RT(E),ee=OT(me.contentWithoutBlock);return me.hasDelegation||ee.hasWorkPlan?o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("span",{className:"history-role",children:[!Ae&&R&&o.jsx("img",{src:R==="codex"?"/assets/codex.png":"/assets/claude.png",alt:R,className:"history-role-icon",title:f(R==="codex"?"terminal:history.codexAgent":"terminal:history.claudeAgent")}),ce]}),o.jsxs("span",{className:"history-content markdown-content",children:[s?o.jsx("div",{children:Ol(ee.contentWithoutBlock,s)}):zl(ee.contentWithoutBlock,r,i),ee.hasWorkPlan&&ee.workPlan&&o.jsx(FT,{workPlan:ee.workPlan}),me.hasDelegation&&me.delegations.map((ze,Pe)=>o.jsx(LT,{delegation:ze},`del-${Pe}`))]}),o.jsxs("div",{className:"message-action-btns",children:[C.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:ze=>{ze.stopPropagation(),I(E)},title:f(O?"terminal:history.stopSpeaking":"terminal:history.speakSpanish"),children:O?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:ze=>{ze.stopPropagation(),d(E)},title:f("terminal:history.viewAsMarkdown"),children:"📄"})]})]}):o.jsxs("div",{className:Z,children:[L&&o.jsxs("span",{className:"output-timestamp",title:`${F} | ${H}`,children:[L," ",o.jsxs("span",{style:{fontSize:"9px",color:"#888",fontFamily:"monospace"},children:["[",H,"]"]})]}),o.jsxs("span",{className:`history-role ${xe?"history-role-chip":""}`,children:[!xe&&!Ae&&R&&o.jsx("img",{src:R==="codex"?"/assets/codex.png":"/assets/claude.png",alt:R,className:"history-role-icon",title:f(R==="codex"?"terminal:history.codexAgent":"terminal:history.claudeAgent")}),xe?f("common:labels.you"):ce]}),o.jsx("span",{className:`history-content ${xe?"user-prompt-text":"markdown-content"}`,children:s?o.jsx("div",{children:Ol(E,s)}):xe?Bu(E,r,i):zl(E,r,i)}),!xe&&o.jsxs("div",{className:"message-action-btns",children:[C.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:ze=>{ze.stopPropagation(),I(E)},title:f(O?"terminal:history.stopSpeaking":"terminal:history.speakSpanish"),children:O?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:ze=>{ze.stopPropagation(),d(E)},title:f("terminal:history.viewAsMarkdown"),children:"📄"})]})]})});function e5(t){const e=t.split("/").pop()||t,n=e.lastIndexOf(".");return n<=0?"":e.slice(n).toLowerCase()}const t5=x.memo(function({entries:e,isWorking:n}){const[s,a]=x.useState(!1),r=x.useRef(null);x.useEffect(()=>{n&&s&&r.current&&(r.current.scrollTop=r.current.scrollHeight)},[e.length,n,s]);const i=s?e:e.slice(-3);return o.jsxs("div",{className:"subagent-stream-panel",children:[o.jsxs("div",{className:"subagent-stream-toggle",onClick:()=>a(!s),children:[o.jsx("span",{className:"stream-toggle-arrow",children:s?"▼":"▶"}),o.jsx("span",{children:s?"Hide stream":`Stream (${e.length} events)`})]}),(s||e.length<=3)&&o.jsxs("div",{className:"subagent-stream-list",ref:r,children:[i.map((c,d)=>o.jsxs("div",{className:`subagent-stream-entry entry-${c.type}${c.isError?" entry-error":""}`,children:[c.type==="text"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"stream-entry-icon",children:"🤖"}),o.jsx("span",{className:"stream-entry-text",children:c.text})]}),c.type==="tool_use"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"stream-entry-icon",children:fs[c.toolName||""]||fs.default}),o.jsx("span",{className:"stream-entry-tool",children:c.toolName}),c.toolKeyParam&&o.jsx("span",{className:"stream-entry-param",children:c.toolKeyParam})]}),c.type==="tool_result"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"stream-entry-icon",children:c.isError?"✗":"✓"}),o.jsx("span",{className:"stream-entry-result",children:c.resultPreview})]})]},d)),n&&o.jsx("span",{className:"subagent-cursor",children:"▌"})]})]})});function n5(t){const e=t.text.slice(0,50),n=`${t.isUserPrompt?"U":""}${t.isStreaming?"S":"F"}${t.isDelegation?"D":""}`;let s=0;for(let a=0;a<e.length;a++)s=(s<<5)-s+e.charCodeAt(a),s|=0;return`${n}:${(s>>>0).toString(16).slice(0,6)}`}function s5({output:t,debugHash:e,agentId:n,onClose:s}){const{t:a}=dt(["tools","common"]),r=x.useRef(null);x.useEffect(()=>{const N=k=>{r.current&&!r.current.contains(k.target)&&s()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[s]);const i=N=>{navigator.clipboard.writeText(N)},d=new Date(t.timestamp).toISOString();let f="assistant";t.isUserPrompt?f="user":t.text.startsWith("Using tool:")?f="tool_use":t.text.startsWith("Tool input:")?f="tool_input":t.text.startsWith("Tool result:")?f="tool_result":t.text.startsWith("Bash output:")?f="bash_output":t.text.startsWith("Tokens:")||t.text.startsWith("Cost:")?f="stats":t.text.startsWith("[thinking]")?f="thinking":t.skillUpdate&&(f="skill_update");const h=t.uuid?"server":t.isUserPrompt?"client (user)":"client/system",m=()=>{const N={uuid:t.uuid||null,hash:e,type:f,timestamp:t.timestamp,iso:d,agentId:n||null,isStreaming:t.isStreaming,source:h,textLen:t.text.length,textPreview:t.text.slice(0,120)};t.isDelegation&&(N.isDelegation=!0),t.toolName&&(N.toolName=t.toolName),t.toolInput&&(N.toolInput=t.toolInput),t.toolOutput&&(N.toolOutputLen=t.toolOutput.length),t.subagentName&&(N.subagentName=t.subagentName),t.isUserPrompt&&(N.isUserPrompt=!0),t.skillUpdate&&(N.skillUpdate=t.skillUpdate),navigator.clipboard.writeText(JSON.stringify(N,null,2))},b=n?U.getState().agentOutputs.get(n):null,y=b?b.indexOf(t):-1,w=b?b.length:0,C=[{label:"UUID",value:t.uuid||"(none)",mono:!0},{label:"Hash",value:e,mono:!0},{label:"Type",value:f},{label:"Source",value:h},{label:"Agent",value:n||"(none)",mono:!0},{label:"Time",value:d,mono:!0},{label:"Epoch",value:String(t.timestamp),mono:!0},{label:"Index",value:y>=0?`${y} / ${w}`:"(unknown)",mono:!0},{label:"Text",value:`[${t.text.length} chars] ${t.text.slice(0,120)}`,mono:!0}];return t.isStreaming&&C.push({label:"State",value:"streaming"}),t.isDelegation&&C.push({label:"Flag",value:"delegation"}),t.toolName&&C.push({label:"Tool",value:t.toolName}),t.toolInput&&C.push({label:"ToolIn",value:JSON.stringify(t.toolInput).slice(0,200),mono:!0}),t.toolOutput&&C.push({label:"ToolOut",value:`[${t.toolOutput.length} chars] ${t.toolOutput.slice(0,120)}`,mono:!0}),t.subagentName&&C.push({label:"Subagent",value:t.subagentName}),o.jsxs("div",{className:"msg-meta-tooltip",ref:r,children:[o.jsxs("div",{className:"msg-meta-tooltip__header",children:[o.jsx("span",{children:a("tools:metadata.messageInfo")}),o.jsxs("div",{className:"msg-meta-tooltip__actions",children:[o.jsx("button",{className:"msg-meta-tooltip__copy-all",onClick:m,title:a("tools:metadata.copyAllAsJSON"),children:"JSON"}),o.jsx("button",{className:"msg-meta-tooltip__close",onClick:s,children:"×"})]})]}),o.jsx("div",{className:"msg-meta-tooltip__body",children:C.map(({label:N,value:k,mono:j})=>o.jsxs("div",{className:"msg-meta-tooltip__row",children:[o.jsx("span",{className:"msg-meta-tooltip__label",children:N}),o.jsx("span",{className:`msg-meta-tooltip__value ${j?"mono":""}`,onClick:()=>i(k),title:a("tools:metadata.clickToCopy"),children:k})]},N))})]})}function Gn({output:t,timeStr:e,debugHash:n,agentId:s}){const{t:a}=dt(["tools"]),[r,i]=x.useState(!1),c=x.useCallback(f=>{f.stopPropagation(),i(h=>!h)},[]),d=x.useCallback(()=>i(!1),[]);return o.jsxs("span",{className:"output-timestamp-wrapper",children:[o.jsx("span",{className:"output-timestamp output-timestamp--clickable",onClick:c,title:a("tools:metadata.clickForMessageInfo"),children:e}),r&&o.jsx(s5,{output:t,debugHash:n,agentId:s||null,onClose:d})]})}const Dy=x.memo(function({output:e,agentId:n,execTasks:s=[],subagents:a,onImageClick:r,onFileClick:i,onBashClick:c,onViewMarkdown:d}){var he,Be,ie;const{t:f}=dt(["tools","common"]),h=Zj(),m=Vr(),[b,y]=x.useState(new Set),{text:w,isStreaming:C,isUserPrompt:N,timestamp:k,skillUpdate:j,_toolKeyParam:S,_editData:T,_todoInput:D,_bashOutput:E,_bashCommand:I,_isRunning:O}=e,_=Tu(w,h),M=e.toolName,R=e.toolInput,z=e.toolOutput;let $=S;if(!$&&R&&typeof R=="object"){const de=R;if(M==="Glob"&&de.pattern)$=de.path?`${de.pattern} in ${de.path}`:de.pattern;else if(M==="Grep"&&de.pattern)$=de.path?`"${de.pattern}" in ${de.path}`:`"${de.pattern}"`;else if((M==="AskUserQuestion"||M==="AskFollowupQuestion")&&de.questions){const He=de.questions;Array.isArray(He)&&((he=He[0])!=null&&he.question)&&($=He[0].question)}else if((M==="Task"||M==="Agent")&&typeof de.description=="string"){const He=de.description,et=de.subagent_type;$=et?`[${et}] ${He}`:He}else if(M==="ExitPlanMode"||M==="EnterPlanMode"){const He=de.allowedPrompts;Array.isArray(He)&&He.length>0?$=He.map(et=>et.prompt||et.tool||"").filter(Boolean).join(", "):M==="ExitPlanMode"&&typeof de.plan=="string"&&de.plan.trim().length>0?$=de.plan.trim():$=M==="ExitPlanMode"?"Plan ready":"Entering plan mode"}else if(M==="spawn_agent"||M==="send_input"||M==="wait"){const He=de.prompt,et=de.receiver_thread_ids;He?$=He.length>100?He.slice(0,97)+"...":He:et&&et.length>0?$=`waiting on ${et.length} thread(s)`:M==="wait"&&($="waiting for subagents")}else if(M==="TodoWrite"&&Array.isArray(de.todos)){const He=de.todos,et=He.filter(se=>se.status==="completed").length,ct=He.filter(se=>se.status==="in_progress").length,fe=He.filter(se=>se.status==="pending").length,X=[];et>0&&X.push(`${et} done`),ct>0&&X.push(`${ct} active`),fe>0&&X.push(`${fe} pending`),$=`${He.length} items (${X.join(", ")})`}else if($=de.file_path||de.path||de.notebook_path||de.command||de.pattern||de.url||de.query||de.description,!$)try{const He=JSON.stringify(de);He&&He!=="{}"&&($=He.length>200?He.slice(0,197)+"...":He)}catch{}}const W=n?(Be=U.getState().agents.get(n))==null?void 0:Be.name:null,L=e.subagentName||W,F=n?(ie=U.getState().agents.get(n))==null?void 0:ie.provider:void 0,H=F==="codex"?"Codex":"Claude",[V,G]=x.useState(!1),[B,K]=x.useState(!1),{toggle:ne,speaking:q}=My(),xe=Fp(k||Date.now()),Ae=n5(e);if(j)return o.jsxs("div",{className:"output-line output-skill-update",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx("span",{className:"skill-update-icon",children:"🔄"}),o.jsx("span",{className:"skill-update-label",children:f("tools:skills.skillsUpdated")}),o.jsx("span",{className:"skill-update-list",children:j.skills.map((de,He)=>o.jsxs("span",{className:"skill-update-item",title:de.description,children:[de.name,He<j.skills.length-1?", ":""]},de.name))})]});if(_.startsWith("This session is being continued from a previous conversation that ran out of context"))return o.jsxs("div",{className:`output-line output-session-continuation ${V?"expanded":""}`,onClick:()=>G(!V),title:"Click to expand/collapse",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx("span",{className:"session-continuation-icon",children:"🔗"}),o.jsx("span",{className:"session-continuation-label",children:f("tools:display.sessionContinued")}),o.jsx("span",{className:"session-continuation-toggle",children:V?"▼":"▶"}),V&&o.jsx("div",{className:"session-continuation-content",children:zl(_,r,i)})]});const ce=n?U.getLastDelegationReceived(n):null;if(N){const de=_.trim();if(de==="/context"||de==="/cost"||de==="/compact")return null;const He=Ny(_),et=Ty(He.userMessage),ct=et.userMessage,fe=ET(ct.trim());if(fe.isDelegatedTask)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx(IT,{bossName:fe.bossName,bossId:fe.bossId,taskCommand:fe.taskCommand})]});const X=MT(ct.trim());if(X.isTaskReport)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),He.hasContext&&He.context&&o.jsx($p,{context:He.context,onFileClick:i},`boss-stream-${_.slice(0,50)}`),o.jsx(PT,{agentName:X.agentName,agentId:X.agentId,status:X.status,originalTask:X.originalTask,summary:X.summary})]});const se=DT(ct.trim());if(se.hasNotification)return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx(BT,{agentId:se.agentId,status:se.status}),se.contentWithoutNotification&&o.jsx("span",{className:"history-content user-prompt-text",children:Bu(se.contentWithoutNotification,r,i)})]});const Se=ce&&_.trim()===ce.taskCommand.trim();return o.jsxs("div",{className:"output-line output-user",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),Se?o.jsx(s6,{bossName:ce.bossName,taskCommand:ce.taskCommand}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"output-role output-role-chip output-role-user-chip",children:f("common:labels.you")}),He.hasContext&&He.context&&o.jsx($p,{context:He.context,onFileClick:i},`boss-stream-${_.slice(0,50)}`),Bu(et.userMessage,r,i)]})]})}if(_.startsWith("Using tool:")){const de=_.replace("Using tool:","").trim(),He=yT(de,f),et=fs[de]||fs.default,ct=new Set(["Bash","Read","Write","Edit","Glob","Grep","NotebookEdit","Task","Agent","TodoWrite","AskUserQuestion","AskFollowupQuestion","ExitPlanMode","EnterPlanMode","web_search","ToolSearch","spawn_agent","send_input","wait"]),fe=D||(de==="TodoWrite"&&R&&typeof R=="object"&&Array.isArray(R.todos)?JSON.stringify(R):void 0);if(de==="TodoWrite"&&fe)return o.jsxs("div",{className:`output-line output-tool-use output-todo-inline ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name",children:He}),o.jsx(Hp,{content:fe})]});const X=(de==="AskUserQuestion"||de==="AskFollowupQuestion")&&R&&typeof R=="object"&&Array.isArray(R.questions)?JSON.stringify(R):void 0;if((de==="AskUserQuestion"||de==="AskFollowupQuestion")&&X)return o.jsxs("div",{className:`output-line output-tool-use output-ask-question-inline ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name",children:He}),o.jsx(VT,{content:X})]});const se=de==="ExitPlanMode"&&R&&typeof R=="object"&&typeof R.plan=="string"?JSON.stringify(R):void 0;if(de==="ExitPlanMode"&&se)return o.jsxs("div",{className:`output-line output-tool-use output-plan-inline ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name",children:He}),o.jsx(kx,{content:se})]});const Se=de==="ToolSearch"&&R&&typeof R=="object"?JSON.stringify(R):void 0;if(de==="ToolSearch"&&Se)return o.jsxs("div",{className:`output-line output-tool-use output-toolsearch-inline ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx("span",{className:"output-tool-icon",children:"⚡"}),o.jsx("span",{className:"output-tool-name",children:"ToolSearch"}),o.jsx(Wp,{content:Se,agentName:L})]});if(["spawn_agent","send_input","wait"].includes(de)){const bt=R,rt=bt==null?void 0:bt.prompt,xt=bt==null?void 0:bt.receiver_thread_ids,$t=rt?rt.length>120?rt.slice(0,117)+"...":rt:void 0,En=de==="spawn_agent"?"Spawn Agent":de==="send_input"?"Send Input":"Wait";return o.jsxs("div",{className:`output-line output-tool-use output-collab-tool output-collab-${de} ${C?"output-streaming":""}`,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name collab-tool-name",children:En}),xt&&xt.length>0&&o.jsx("span",{className:"collab-thread-ids",children:xt.map(nn=>nn.slice(-8)).join(", ")}),$t&&o.jsx("span",{className:"collab-prompt-preview",title:rt,children:$t})]})}const pe=R&&typeof R=="object"?JSON.stringify(R,null,2):void 0,$e=["Read","Edit","Write","Glob","Grep","NotebookEdit"].includes(de),ye=R&&typeof R=="object"?R:null,Ie=ye?(typeof ye.file_path=="string"?ye.file_path:void 0)||(typeof ye.path=="string"?ye.path:void 0)||(typeof ye.notebook_path=="string"?ye.notebook_path:void 0):void 0,te=S||Ie,be=!!te&&($e||te.startsWith("/")||te.includes("/")),we=$e&&be&&i,Fe=de==="Edit"&&ye?{oldString:String(ye.old_string??""),newString:String(ye.new_string??""),operation:typeof ye.operation=="string"?ye.operation:void 0}:void 0,Ke=de==="Read"&&ye&&typeof ye.offset=="number"&&typeof ye.limit=="number"?{highlightRange:{offset:ye.offset,limit:ye.limit}}:void 0,st=de==="Bash"&&c,ft=!!E||!!z,wt=I||S||$||"",at=kT(wt),gt=/\bcurl\b[\s\S]*\/api\/exec\b/.test(wt),ht=k?new Date(k).getTime():0,Gt=gt?wT(wt):null,tn=gt&&s.length>0?(()=>{if(Gt){const rt=s.filter(xt=>xt.command===Gt);if(rt.length>0)return[rt.reduce(($t,En)=>En.startedAt>$t.startedAt?En:$t)]}const bt=s.filter(rt=>rt.startedAt>=ht&&rt.startedAt<=ht+5e3);return bt.length>0?[bt.reduce((xt,$t)=>$t.startedAt>xt.startedAt?$t:xt)]:[]})():[],je=!!(st&>&&tn.length>0),Oe=(de==="Task"||de==="Agent")&&a&&e.uuid?(()=>{for(const[,bt]of a)if(bt.toolUseId===e.uuid)return bt})():void 0,Ye=st&&wt?CT(wt):null,Ze=st&&wt?AT(wt):null,Ot=st&&wt?jT(wt):null,Ft=st&&wt?NT(wt):null,Lt=bt=>{if(bt.stopPropagation(),we&&te){const rt=T||Fe;de==="Edit"&&rt?i(te,rt):de==="Read"&&Ke?i(te,Ke):i(te)}},Vt=()=>{if(st&&wt){const bt=O?f("tools:display.running"):E||f("tools:display.noOutputCaptured");c(wt,bt)}},ln=()=>{var xt;if(!at)return null;if(!i)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Mo(at,"bash")}});const bt=n?(xt=U.getState().agents.get(n))==null?void 0:xt.cwd:void 0;return ST(at).map(($t,En)=>{if(!$t.fileRef)return o.jsx("span",{dangerouslySetInnerHTML:{__html:Mo($t.text,"bash")}},`cmd-${En}`);const nn=sh($t.fileRef,bt);return o.jsx("span",{className:"clickable-path",onClick:Un=>{Un.stopPropagation(),i(nn.path)},title:f("tools:display.clickToViewFile"),style:{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"},children:$t.text},`cmd-file-${En}`)})};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`output-line output-tool-use ${C?"output-streaming":""} ${st?"bash-clickable":""} ${Ze?"bash-notify-use":""}`,onClick:st?Vt:void 0,title:st?f("tools:display.clickToViewOutput"):void 0,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-icon",children:et}),o.jsx("span",{className:"output-tool-name",children:He}),st&&wt&&(Ze?o.jsxs("span",{className:"output-tool-param bash-command bash-notify-param",onClick:Vt,title:Ze.commandBody,style:{cursor:"pointer"},children:[Ze.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:Ze.shellPrefix}),o.jsx("span",{className:"bash-notify-chip",children:"notify"}),Ze.title&&o.jsx("span",{className:"bash-notify-title",children:Ze.title}),Ze.message&&o.jsx("span",{className:"bash-notify-message",children:Ze.message})]}):Ot?o.jsxs("span",{className:"output-tool-param bash-command bash-task-label-param",onClick:Vt,title:Ot.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:"bash-task-label-chip",children:"📋 task"}),o.jsx("span",{className:"bash-task-label-value",children:Ot.taskLabel})]}):Ft?o.jsxs("span",{className:"output-tool-param bash-command bash-report-task-param",onClick:Vt,title:Ft.commandBody,style:{cursor:"pointer"},children:[o.jsx("span",{className:`bash-report-task-chip ${Ft.status==="failed"?"status-failed":"status-completed"}`,children:Ft.status==="failed"?"❌ report":"✅ report"}),Ft.summary&&o.jsx("span",{className:"bash-report-task-summary",children:Ft.summary})]}):Ye?o.jsxs("span",{className:"output-tool-param bash-command bash-search-param",onClick:Vt,title:Ye.commandBody,style:{cursor:"pointer"},children:[Ye.shellPrefix&&o.jsx("span",{className:"bash-search-shell",children:Ye.shellPrefix}),o.jsx("span",{className:"bash-search-chip",children:"search"}),o.jsx("span",{className:"bash-search-term",children:Ye.searchTerm})]}):o.jsx("span",{className:"output-tool-param bash-command",onClick:Vt,title:f("tools:display.clickToViewOutput"),style:{cursor:"pointer",fontFamily:"monospace",fontSize:"0.9em",color:"#888"},children:ln()})),!st&&$&&o.jsxs("span",{className:`output-tool-param ${we?"clickable-path":""}`,onClick:we?Lt:void 0,title:we?f(de==="Edit"&&(T||Fe)?"tools:display.clickToViewDiff":"tools:display.clickToViewFile"):void 0,style:we?{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted"}:void 0,children:[$e&&be&&(()=>{const bt=e5(te),rt=bt?ph(bt):"";return rt?o.jsx("img",{className:"output-tool-file-icon",src:rt,alt:""}):null})(),$]}),st&&!O&&o.jsx("span",{className:"bash-output-indicator",children:s.some(bt=>bt.status==="completed")?"✅":ft?"📄":"💻"}),C&&o.jsx("span",{className:"output-tool-loading",children:"..."})]}),!ct.has(de)&&pe&&o.jsxs("div",{className:"output-line output-tool-input output-tool-input-fallback",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx(LA,{toolName:de,content:pe})]}),je&&o.jsx("div",{className:"exec-task-output-container",children:tn.map(bt=>{const rt=b.has(bt.taskId),xt=bt.output.slice(-6),$t=bt.output.length>6,En=rt?bt.output:xt;return o.jsxs("div",{className:`exec-task-inline status-${bt.status}`,children:[$t&&o.jsxs("div",{className:"exec-task-toggle",onClick:()=>y(nn=>{const Un=new Set(nn);return Un.has(bt.taskId)?Un.delete(bt.taskId):Un.add(bt.taskId),Un}),children:[o.jsx("span",{className:"exec-task-toggle-arrow",children:rt?"▼":"▶"}),o.jsx("span",{className:"exec-task-toggle-text",children:rt?f("tools:skills.hide"):f("tools:skills.showAll",{count:bt.output.length})})]}),o.jsx("div",{className:"exec-task-inline-terminal",children:o.jsxs("pre",{className:"exec-task-inline-output",children:[En.map((nn,Un)=>o.jsx("div",{dangerouslySetInnerHTML:{__html:Kl(nn)}},Un)),bt.status==="running"&&o.jsx("span",{className:"exec-task-cursor",children:"▌"})]})})]},bt.taskId)})}),Oe&&(Oe.status==="working"||Oe.activities&&Oe.activities.length>0||Oe.stats)&&o.jsx("div",{className:"subagent-activity-container",children:o.jsxs("div",{className:`subagent-activity-inline status-${Oe.status}`,children:[o.jsxs("div",{className:"subagent-activity-header",children:[o.jsx("span",{className:"subagent-type-badge",children:Oe.subagentType}),o.jsx("span",{className:"subagent-elapsed",children:Oe.completedAt?`${((Oe.completedAt-Oe.startedAt)/1e3).toFixed(0)}s`:`${((Date.now()-Oe.startedAt)/1e3).toFixed(0)}s`})]}),Oe.activities&&Oe.activities.length>0&&o.jsxs("div",{className:"subagent-activity-list",children:[Oe.activities.slice(-8).map((bt,rt)=>o.jsxs("div",{className:"subagent-activity-item",children:[o.jsx("span",{className:"activity-icon",children:fs[bt.toolName]||fs.default}),o.jsx("span",{className:"activity-tool",children:bt.toolName}),o.jsx("span",{className:"activity-desc",children:bt.description.length>80?bt.description.slice(0,77)+"...":bt.description})]},rt)),Oe.status==="working"&&o.jsx("span",{className:"subagent-cursor",children:"▌"})]}),Oe.stats&&o.jsxs("div",{className:"subagent-stats-bar",children:[o.jsxs("span",{children:[(Oe.stats.durationMs/1e3).toFixed(0),"s"]}),o.jsxs("span",{children:[(Oe.stats.tokensUsed/1e3).toFixed(1),"K tokens"]}),o.jsxs("span",{children:[Oe.stats.toolUseCount," tools"]})]}),Oe.streamEntries&&Oe.streamEntries.length>0&&o.jsx(t5,{entries:Oe.streamEntries,isWorking:Oe.status==="working"})]})})]})}if(_.startsWith("Tool input:")){const de=_.replace("Tool input:","").trim();if(KT(de))return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx(Wp,{content:de,agentName:L})]});try{const He=JSON.parse(de);if(He.file_path&&(He.old_string!==void 0||He.new_string!==void 0))return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx(WT,{content:de,onFileClick:i})]});if(He.file_path&&He.old_string===void 0&&He.new_string===void 0)return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx(qT,{content:de,onFileClick:i})]});if(Array.isArray(He.todos))return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx(Hp,{content:de})]})}catch{}return o.jsxs("div",{className:"output-line output-tool-input",children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx(LA,{toolName:M||"UnknownTool",content:de})]})}if(_.startsWith("Tool result:")){const de=_.replace("Tool result:","").trim(),He=de.toLowerCase().includes("error")||de.toLowerCase().includes("failed");return o.jsxs("div",{className:`output-line output-tool-result ${He?"is-error":""}`,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsx("span",{className:"output-result-icon",children:He?"❌":"✓"}),o.jsx("pre",{className:"output-result-content",children:de})]})}if(_.startsWith("Bash output:")){const de=_.replace("Bash output:","").trim(),He=de.toLowerCase().includes("error")||de.toLowerCase().includes("failed")||de.toLowerCase().includes("command not found")||de.toLowerCase().includes("permission denied"),et=de.includes("... (truncated,");return o.jsxs("div",{className:`output-line output-bash-result ${He?"is-error":""}`,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsxs("div",{className:"bash-output-container",children:[o.jsxs("div",{className:"bash-output-header",children:[o.jsx("span",{className:"bash-output-icon",children:"$"}),o.jsx("span",{className:"bash-output-label",children:f("tools:display.terminalOutput")}),et&&o.jsx("span",{className:"bash-output-truncated",children:f("tools:display.truncated")})]}),o.jsx("pre",{className:"bash-output-content",dangerouslySetInnerHTML:{__html:Kl(de)}})]})]})}if(_.includes("## Context Usage")||_.includes("Context Usage")&&_.includes("Tokens:")&&_.includes("Free space")||_.includes("<local-command-caveat>")||_.includes("<command-name>/context</command-name>")||_.includes("<command-name>/cost</command-name>")||_.includes("<command-name>/compact</command-name>"))return null;const ee=_.startsWith("[thinking]"),re=ee?_.replace(/^\[thinking\]\s*/,""):"",We=ee?(re||"(processing)").replace(/\*+/g,"").replace(/\s+/g," ").trim():"",ze=/^\s*(?:[\u{1F300}-\u{1FAFF}\u2600-\u27BF]\s*)?\[System\]/u.test(_),Pe=!!(e.subagentName&&z&&/^[✅❌]\s*Subagent\s/.test(_));let ge="output-line",Te=!0,qe=!1;if(_.startsWith("Session started:")||_.startsWith("Session initialized")?(ge+=" output-session",Te=!1):_.startsWith("Tokens:")||_.startsWith("Cost:")?(ge+=" output-stats",Te=!1):ee?(ge+=" output-thinking output-tool-use",Te=!1):_.startsWith("[raw]")?(ge+=" output-raw",Te=!1):ze?ge+=" output-text output-system markdown-content":(ge+=" output-text output-claude markdown-content",qe=!0),C&&(ge+=" output-streaming"),qe&&!C){const de=RT(_),He=OT(de.contentWithoutBlock);if(de.hasDelegation||He.hasWorkPlan)return o.jsxs("div",{className:ge,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),o.jsxs("span",{className:"output-role",children:[F&&o.jsx("img",{src:F==="codex"?"/assets/codex.png":"/assets/claude.png",alt:F,className:"output-role-icon",title:F==="codex"?"Codex Agent":"Claude Agent"}),H]}),o.jsx("div",{className:"markdown-content",children:zl(He.contentWithoutBlock,r,i)}),He.hasWorkPlan&&He.workPlan&&o.jsx(FT,{workPlan:He.workPlan}),de.hasDelegation&&de.delegations.map((et,ct)=>o.jsx(LT,{delegation:et},`del-${ct}`)),o.jsxs("div",{className:"message-action-btns",children:[m.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:et=>{et.stopPropagation(),ne(_)},title:q?"Stop speaking":"Speak (Spanish)",children:q?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:et=>{et.stopPropagation(),d(z||_)},title:"View as Markdown",children:"📄"})]})]})}const it=qe?H:ze?f("tools:display.system"):null;return o.jsxs("div",{className:ge,children:[o.jsx(Gn,{output:e,timeStr:xe,debugHash:Ae,agentId:n}),it&&o.jsxs("span",{className:"output-role",children:[qe&&F&&o.jsx("img",{src:F==="codex"?"/assets/codex.png":"/assets/claude.png",alt:F,className:"output-role-icon",title:F==="codex"?"Codex Agent":"Claude Agent"}),it]}),Te?o.jsx("div",{className:"markdown-content",children:zl(_,r,i)}):ee?o.jsxs(o.Fragment,{children:[L&&o.jsx("span",{className:"output-agent-badge",title:`Agent: ${L}`,children:L}),o.jsx("span",{className:"output-tool-name output-thinking-label",children:f(F==="codex"?"tools:display.codexThinking":"tools:display.thinking")}),o.jsx("span",{className:"output-tool-param output-thinking-content",title:We,children:We})]}):_,Pe&&z&&o.jsxs("div",{className:"subagent-result-section",children:[o.jsxs("button",{className:"subagent-result-toggle",onClick:de=>{de.stopPropagation(),K(!B)},children:[o.jsx("span",{className:"subagent-result-arrow",children:B?"▼":"▶"}),B?"Hide result":"Show result"]}),B&&o.jsx("div",{className:"subagent-result-content markdown-content",children:zl(z,r,i)})]}),qe&&!C&&o.jsxs("div",{className:"message-action-btns",children:[m.experimentalTTS&&o.jsx("button",{className:"history-speak-btn",onClick:de=>{de.stopPropagation(),ne(_)},title:q?"Stop speaking":"Speak (Spanish)",children:q?"🔊":"🔈"}),d&&o.jsx("button",{className:"history-view-md-btn",onClick:de=>{de.stopPropagation(),d(z||_)},title:"View as Markdown",children:"📄"})]})]})}),Ll={user:60,assistant:120,tool_use:40,tool_result:80,default:60};function a5(t){var n,s;if("type"in t)return Ll[t.type]||Ll.default;const e=t;return e.isUserPrompt?Ll.user:(n=e.text)!=null&&n.startsWith("Using tool:")?Ll.tool_use:(s=e.text)!=null&&s.startsWith("Tool result:")?Ll.tool_result:Ll.assistant}const r5=x.memo(function({item:e,isHistory:n,agentId:s,execTasks:a,subagents:r,simpleView:i,isSelected:c,messageIndex:d,searchHighlight:f,onImageClick:h,onFileClick:m,onBashClick:b,onViewMarkdown:y}){return o.jsx("div",{"data-message-index":d,className:`message-nav-wrapper ${c?"message-selected":""}`,children:n?o.jsx(QT,{message:e,agentId:s,simpleView:i,highlight:f,onImageClick:h,onFileClick:m,onBashClick:b,onViewMarkdown:y}):o.jsx(Dy,{output:e,agentId:s,execTasks:a,subagents:r,onImageClick:h,onFileClick:m,onBashClick:b,onViewMarkdown:y})})}),i5=x.memo(function({historyMessages:e,liveOutputs:n,agentId:s,execTasks:a=[],subagents:r,viewMode:i,searchHighlight:c,searchActiveIndex:d,selectedMessageIndex:f,isMessageSelected:h,onImageClick:m,onFileClick:b,onBashClick:y,onViewMarkdown:w,scrollContainerRef:C,onScrollTopReached:N,isLoadingMore:k,hasMore:j,shouldAutoScroll:S,onUserScroll:T,pinToBottom:D=!1,onPinCancel:E,isLoadingHistory:I}){const O=x.useMemo(()=>[...e,...n],[e,n]),_=e.length,M=x.useRef(!1),R=x.useRef(O.length),z=x.useRef(!1),$=x.useRef(O.length);$.current=O.length;const W=x.useRef(0),L=DN({count:O.length,getScrollElement:()=>C.current,estimateSize:K=>a5(O[K]),overscan:10,initialRect:{width:500,height:800},measureElement:K=>K.getBoundingClientRect().height});x.useEffect(()=>()=>{L.elementsCache.clear()},[L]);const F=x.useCallback(()=>{const K=C.current;if(!K)return;const ne=$.current;ne<=0||(L.scrollToIndex(ne-1,{align:"end"}),K.scrollTop=K.scrollHeight)},[C,L]);x.useLayoutEffect(()=>{D&&(I||O.length!==0&&(M.current=!0,z.current=!0,F()))},[D,I,O.length,F]),x.useEffect(()=>{if(!D){M.current=!1,z.current=!1;return}if(I||O.length===0)return;let K;const ne=()=>{M.current=!0,F(),K=requestAnimationFrame(ne)};return K=requestAnimationFrame(ne),()=>cancelAnimationFrame(K)},[D,I,O.length,F]),x.useEffect(()=>{if(S&&O.length!==0){if(O.length<=R.current){R.current=O.length;return}R.current=O.length,M.current=!0,F(),requestAnimationFrame(()=>{M.current=!1})}},[O.length,S,F]);const H=L.getTotalSize();x.useEffect(()=>{const K=W.current;W.current=H,S&&(D||H<=K||H-K<2||(M.current=!0,F(),requestAnimationFrame(()=>{M.current=!1})))},[H,S,D,F]);const V=x.useCallback(()=>{if(!C.current)return;const{scrollTop:K,scrollHeight:ne,clientHeight:q}=C.current;D&&!M.current&&(E==null||E()),!(ne-K-q<150)&&!M.current&&!z.current&&T&&T(),K<200&&j&&!k&&N&&N()},[j,k,N,T,C,D,E]);x.useEffect(()=>{const K=C.current;if(K)return K.addEventListener("scroll",V,{passive:!0}),()=>K.removeEventListener("scroll",V)},[V,C]),x.useEffect(()=>{const K=C.current;if(!K)return;const ne=new ResizeObserver(()=>{M.current=!0,K.dispatchEvent(new Event("scroll")),requestAnimationFrame(()=>{M.current=!1})});return ne.observe(K),()=>ne.disconnect()},[C]),x.useEffect(()=>{if(f!==null&&f>=0&&f<O.length){M.current=!0,L.scrollToIndex(f,{align:"center"});const K=setTimeout(()=>{M.current=!1},100);return()=>clearTimeout(K)}},[f,L,O.length]),x.useEffect(()=>{if(d!=null&&d>=0&&d<O.length){M.current=!0,L.scrollToIndex(d,{align:"center"});const K=setTimeout(()=>{M.current=!1},100);return()=>clearTimeout(K)}},[d,L,O.length]);const G=L.getVirtualItems(),B=i!=="advanced";return o.jsx("div",{style:{height:`${L.getTotalSize()}px`,width:"100%",position:"relative"},children:G.map(K=>{const ne=O[K.index],q=K.index<_;return o.jsx("div",{"data-index":K.index,ref:L.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${K.start}px)`},children:o.jsx(r5,{item:ne,isHistory:q,agentId:s,execTasks:a,subagents:r,simpleView:B,isSelected:h(K.index),messageIndex:K.index,searchHighlight:c,onImageClick:m,onFileClick:b,onBashClick:y,onViewMarkdown:w})},K.key)})})});function IA(t){const e=[];let n=0;try{JSON.parse(t)}catch(i){return e.push(o.jsxs("span",{className:"json-error",children:["[Invalid JSON: ",String(i).slice(0,50),"]"]},n++)),e.push(o.jsx("span",{children:t},n++)),e}const s=/("(?:\\.|[^"\\])*")\s*:|("(?:\\.|[^"\\])*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(\btrue\b|\bfalse\b)|(\bnull\b)|([{}[\],:])/g;let a=0,r;for(;(r=s.exec(t))!==null;){r.index>a&&e.push(o.jsx("span",{children:t.slice(a,r.index)},n++));const[i,c,d,f,h,m,b]=r;c?(e.push(o.jsx("span",{className:"json-key",children:c.slice(0,-1)},n++)),e.push(o.jsx("span",{className:"json-punct",children:":"},n++))):d?e.push(o.jsx("span",{className:"json-string",children:d},n++)):f?e.push(o.jsx("span",{className:"json-number",children:f},n++)):h?e.push(o.jsx("span",{className:"json-boolean",children:h},n++)):m?e.push(o.jsx("span",{className:"json-null",children:m},n++)):b&&e.push(o.jsx("span",{className:"json-punct",children:b},n++)),a=r.index+i.length}return a<t.length&&e.push(o.jsx("span",{children:t.slice(a)},n++)),e}function PA(t){const e=[],n=/\u001b\[([0-9;]*)m/g;let s={bold:!1,dim:!1},a=0,r=0;const i=f=>{if(f===0){s={bold:!1,dim:!1};return}if(f===1){s.bold=!0;return}if(f===2){s.dim=!0;return}if(f===22){s.bold=!1,s.dim=!1;return}if(f===39){s.color=void 0;return}const h={30:"black",31:"red",32:"green",33:"yellow",34:"blue",35:"magenta",36:"cyan",37:"white",90:"bright-black",91:"bright-red",92:"bright-green",93:"bright-yellow",94:"bright-blue",95:"bright-magenta",96:"bright-cyan",97:"bright-white"};h[f]&&(s.color=h[f])},c=()=>{const f=["ansi"];return s.color&&f.push(`ansi-fg-${s.color}`),s.bold&&f.push("ansi-bold"),s.dim&&f.push("ansi-dim"),f.join(" ")};let d;for(;(d=n.exec(t))!==null;){if(d.index>a){const h=t.slice(a,d.index);e.push(o.jsx("span",{className:c(),children:h},r++))}const f=(d[1]||"0").split(";").map(h=>h===""?0:Number(h)).filter(h=>Number.isFinite(h));f.length===0?i(0):f.forEach(i),a=n.lastIndex}return a<t.length&&e.push(o.jsx("span",{className:c(),children:t.slice(a)},r++)),e}const o5=({agentId:t,onClose:e})=>{const{t:n}=dt(["terminal","common","tools"]),[s,a]=x.useState("messages"),[r,i]=x.useState([]),[c,d]=x.useState([]),[f,h]=x.useState(null),[m,b]=x.useState(""),[y,w]=x.useState(!1),[C,N]=x.useState(!1),[k,j]=x.useState({total:0,sent:0,received:0,messageTypes:[]}),[S,T]=x.useState(new Set),[D,E]=x.useState(new Set),[I,O]=x.useState("all"),[_,M]=x.useState("all"),[R,z]=x.useState("all"),[$,W]=x.useState(!1),[L,F]=x.useState(""),[H,V]=x.useState(!0),G=x.useRef(null),B=x.useRef(null),K=x.useCallback(()=>{const he=vs.getMessages(t);i([...he]),j(vs.getStats(t))},[t]),ne=x.useCallback(()=>{const he=vs.getLogs();d([...he])},[]),q=x.useCallback(async()=>{w(!0),b("");try{const he=await Bt(Rt(`/api/agents/${encodeURIComponent(t)}/process-output`)),Be=await he.json();if(!he.ok){h(null),b((Be==null?void 0:Be.error)||"Failed to load process output");return}h(Be)}catch(he){h(null),b(he instanceof Error?he.message:"Failed to load process output")}finally{w(!1),N(!0)}},[t]);x.useEffect(()=>(K(),vs.subscribe(Be=>{(Be===t||Be==="all")&&K()})),[t,K]),x.useEffect(()=>(ne(),vs.subscribeLogs(()=>{ne()})),[ne]);const xe=x.useMemo(()=>r.filter(he=>{if($){const Be=he.payload;if(!(Be!=null&&Be.text)||typeof Be.text!="string")return!1}if(I!=="all"&&he.direction!==I||_!=="all"&&he.type!==_)return!1;if(L){const Be=L.toLowerCase(),ie=he.type.toLowerCase().includes(Be),de=JSON.stringify(he.payload).toLowerCase().includes(Be);return ie||de}return!0}),[r,I,_,$,L]),Ae=x.useMemo(()=>c.filter(he=>{var Be;if(R!=="all"&&he.level!==R)return!1;if(L){const ie=L.toLowerCase(),de=he.message.toLowerCase().includes(ie),He=((Be=he.source)==null?void 0:Be.toLowerCase().includes(ie))||!1,et=he.data?JSON.stringify(he.data).toLowerCase().includes(ie):!1;return de||He||et}return!0}),[c,R,L]);x.useEffect(()=>{H&&G.current&&s==="messages"&&(G.current.scrollTop=G.current.scrollHeight)},[xe,H,s]),x.useEffect(()=>{H&&B.current&&s==="logs"&&(B.current.scrollTop=B.current.scrollHeight)},[Ae,H,s]),x.useEffect(()=>{s==="process"&&!C&&!y&&q()},[s,C,y,q]),x.useEffect(()=>{h(null),b(""),w(!1),N(!1)},[t]);const Z=he=>{T(Be=>{const ie=new Set(Be);return ie.has(he)?ie.delete(he):ie.add(he),ie})},ce=()=>{T(new Set(xe.map(he=>he.id)))},me=()=>{T(new Set)},ee=he=>{navigator.clipboard.writeText(he.raw)},re=()=>{const he=xe.map(Be=>Be.raw).join(`
|
|
139
|
+
|
|
140
|
+
`);navigator.clipboard.writeText(he)},We=()=>{vs.clearMessages(t)},ze=()=>{vs.clearLogs()},Pe=()=>{if(!f)return;const he=[`agentId: ${f.agentId}`,`pid: ${f.pid}`,`source: ${f.source}`,`command: ${f.command}`,`exitCode: ${f.exitCode??"null"}`,`fetchedAt: ${new Date(f.fetchedAt).toISOString()}`,"","[stdout]",f.output||"(empty)","","[stderr]",f.errorOutput||"(empty)"].join(`
|
|
141
|
+
`);navigator.clipboard.writeText(he)},ge=he=>{E(Be=>{const ie=new Set(Be);return ie.has(he)?ie.delete(he):ie.add(he),ie})},Te=he=>{switch(he){case"debug":return{icon:"🔍",className:"log-debug"};case"info":return{icon:"ℹ️",className:"log-info"};case"warn":return{icon:"⚠️",className:"log-warn"};case"error":return{icon:"❌",className:"log-error"}}},qe=he=>new Date(he).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),it=he=>he<1024?`${he}B`:he<1024*1024?`${(he/1024).toFixed(1)}KB`:`${(he/(1024*1024)).toFixed(1)}MB`;return o.jsxs("div",{className:"agent-debug-panel",children:[o.jsxs("div",{className:"agent-debug-header",children:[o.jsxs("div",{className:"agent-debug-title",children:[o.jsx("span",{className:"icon",children:"🐛"}),n("terminal:debug.title")]}),o.jsx("button",{className:"close-btn",onClick:e,title:n("common:buttons.close"),children:"✕"})]}),o.jsxs("div",{className:"agent-debug-tabs",children:[o.jsxs("button",{className:`tab ${s==="messages"?"active":""}`,onClick:()=>a("messages"),children:["📨 ",n("terminal:debug.messages")," (",k.total,")"]}),o.jsxs("button",{className:`tab ${s==="logs"?"active":""}`,onClick:()=>a("logs"),children:["📋 ",n("terminal:debug.logs")," (",c.length,")"]}),o.jsxs("button",{className:`tab ${s==="process"?"active":""}`,onClick:()=>a("process"),children:["🧪 ",n("terminal:debug.processOutput")]})]}),s==="messages"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"agent-debug-stats",children:[o.jsxs("span",{className:"stat stat-sent",children:["↑ ",k.sent]}),o.jsxs("span",{className:"stat stat-received",children:["↓ ",k.received]}),o.jsxs("span",{className:"stat",children:["Types: ",k.messageTypes.length]}),o.jsxs("button",{className:`text-only-toggle ${$?"active":""}`,onClick:()=>W(!$),title:n($?"terminal:debug.allMessages":"terminal:debug.textOnly"),children:["💬 ",n($?"terminal:debug.textOnly":"terminal:debug.allMessages")]})]}),o.jsxs("div",{className:"agent-debug-controls",children:[o.jsxs("select",{value:I,onChange:he=>O(he.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:n("terminal:debug.allDirections")}),o.jsx("option",{value:"sent",children:n("terminal:debug.sentOnly")}),o.jsx("option",{value:"received",children:n("terminal:debug.receivedOnly")})]}),o.jsxs("select",{value:_,onChange:he=>M(he.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:n("terminal:debug.allTypes")}),k.messageTypes.map(he=>o.jsx("option",{value:he,children:he},he))]}),o.jsx("input",{type:"text",placeholder:n("terminal:debug.search"),value:L,onChange:he=>F(he.target.value),className:"search-input"})]}),o.jsxs("div",{className:"agent-debug-actions",children:[o.jsx("button",{onClick:ce,className:"action-btn",title:n("tools:display.expandAll"),children:n("tools:display.expandAll")}),o.jsx("button",{onClick:me,className:"action-btn",title:n("tools:display.collapseAll"),children:n("tools:display.collapseAll")}),o.jsx("button",{onClick:re,className:"action-btn",title:n("terminal:debug.copyAll"),children:n("terminal:debug.copyAll")}),o.jsx("button",{onClick:We,className:"action-btn clear-btn",title:n("common:buttons.clear"),children:n("common:buttons.clear")}),o.jsxs("label",{className:"auto-scroll-label",children:[o.jsx("input",{type:"checkbox",checked:H,onChange:he=>V(he.target.checked)}),o.jsx("span",{className:"toggle-switch"}),n("terminal:debug.autoScroll")]})]}),o.jsx("div",{className:"agent-debug-messages",ref:G,children:xe.length===0?o.jsx("div",{className:"no-messages",children:r.length===0?n("terminal:debug.noMessagesCaptured"):n("terminal:debug.noMessagesMatch")}):xe.map(he=>{const Be=S.has(he.id),ie=he.payload,de=ie!=null&&ie.text&&typeof ie.text=="string"?ie.text:"",He=he.type==="event"&&(ie==null?void 0:ie.type)==="tool_start",et=he.type==="event"&&(ie==null?void 0:ie.type)==="tool_result",ct=he.type==="output"&&(de.startsWith("Using tool:")||de.startsWith("Tool input:")||de.startsWith("Tool result:")),fe=de.startsWith("Using tool:"),X=de.startsWith("Tool input:"),se=de.startsWith("Tool result:");let Se="",J=null,pe="";if(fe)Se=de.replace("Using tool:","").trim();else if(X)try{const gt=de.replace("Tool input:","").trim();J=JSON.parse(gt)}catch{}else se&&(pe=de.replace("Tool result:","").trim());const $e=He||et||ct,ye=He||fe||X,Ie=et||se,te=(ie==null?void 0:ie.toolName)||Se,be=(ie==null?void 0:ie.toolInput)||J,we=(ie==null?void 0:ie.toolOutput)||pe,Fe=de&&!ct,Ke=he.type==="event"?ie==null?void 0:ie.type:null,ft=(()=>{var gt;if(he.type!=="event"||!ie)return null;switch(Ke){case"init":return ie.model?`model: ${ie.model}`:null;case"text":return ie.text?ie.text.slice(0,50)+(ie.text.length>50?"...":""):null;case"step_complete":const ht=ie.tokens;return ht?`${ht.input||0} in / ${ht.output||0} out`:null;case"error":return((gt=ie.errorMessage)==null?void 0:gt.slice(0,40))||null;case"thinking":return ie.text?`"${ie.text.slice(0,30)}..."`:null;default:return null}})(),at=ye&&be?(()=>{if(!be)return null;const gt=Object.keys(be);if(gt.length===0)return null;const ht=["file_path","path","pattern","command","content","query"];return gt.sort((tn,je)=>{const Oe=ht.indexOf(tn),Ye=ht.indexOf(je);return Oe===-1&&Ye===-1?0:Oe===-1?1:Ye===-1?-1:Oe-Ye}).slice(0,3).map(tn=>{let je=be[tn];return typeof je=="string"?je.length>60&&(je=je.slice(0,60)+"..."):typeof je=="object"&&(je=JSON.stringify(je).slice(0,40)+"..."),{key:tn,value:je}})})():null;return o.jsxs("div",{className:`debug-message debug-message-${he.direction} ${Fe?"has-text-preview":""} ${$e?"is-tool-event":""} ${ye?"tool-start":""} ${Ie?"tool-result":""}`,children:[o.jsxs("div",{className:"message-header",onClick:()=>Z(he.id),children:[o.jsx("span",{className:"expand-icon",children:Be?"▼":"▶"}),o.jsx("span",{className:`direction direction-${he.direction}`,children:he.direction==="sent"?"↑ SENT":"↓ RECEIVED"}),o.jsx("span",{className:"message-type",children:$e?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"tool-icon",children:ye?"🔧":"✅"}),ye?"tool_start":"tool_result"]}):Ke?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"event-base",children:he.type}),o.jsx("span",{className:"event-subtype",children:Ke})]}):he.type}),$e&&te&&o.jsx("span",{className:"tool-name-inline",children:te}),!$e&&ft&&o.jsx("span",{className:"event-summary",children:ft}),o.jsx("span",{className:"message-time",children:qe(he.timestamp)}),o.jsx("span",{className:"message-size",children:it(he.size)}),o.jsx("button",{className:"copy-btn",onClick:gt=>{gt.stopPropagation(),ee(he)},title:"Copy message",children:"📋"})]}),Be&&o.jsxs("div",{className:"message-body",children:[ye&&(be||X&&!J)&&o.jsxs("div",{className:"tool-preview",children:[at&&at.length>0&&o.jsx("div",{className:"tool-inputs",children:at.map(({key:gt,value:ht})=>o.jsxs("div",{className:"tool-input-item",children:[o.jsxs("span",{className:"tool-input-key",children:[gt,":"]}),o.jsx("span",{className:"tool-input-value",children:String(ht)})]},gt))}),X&&!J&&o.jsx("div",{className:"tool-raw-input",children:de.replace("Tool input:","").trim().slice(0,200)})]}),Ie&&we&&o.jsx("div",{className:"tool-preview tool-result-preview",children:o.jsx("div",{className:"tool-output-preview",children:typeof we=="string"?we.slice(0,200)+(we.length>200?"...":""):JSON.stringify(we).slice(0,200)})}),Fe&&!$e&&o.jsx("div",{className:"message-text-preview expanded",children:o.jsx("span",{className:"text-content",children:ie.text})}),o.jsx("pre",{children:IA(JSON.stringify(he.payload,(gt,ht)=>ht===void 0?null:typeof ht=="object"&&ht!==null&&!(ht instanceof Date)&&!Array.isArray(ht)&&typeof ht[Symbol.iterator]=="function"?Array.from(ht):typeof ht=="function"?`[Function: ${ht.name||"anonymous"}]`:ht,2))})]})]},he.id)})})]}),s==="logs"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"agent-debug-controls",children:[o.jsxs("select",{value:R,onChange:he=>z(he.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:n("terminal:debug.allLevels")}),o.jsx("option",{value:"debug",children:n("terminal:debug.debug")}),o.jsx("option",{value:"info",children:n("terminal:debug.info")}),o.jsx("option",{value:"warn",children:n("terminal:debug.warning")}),o.jsx("option",{value:"error",children:n("terminal:debug.error")})]}),o.jsx("input",{type:"text",placeholder:n("terminal:debug.searchLogs"),value:L,onChange:he=>F(he.target.value),className:"search-input"})]}),o.jsxs("div",{className:"agent-debug-actions",children:[o.jsx("button",{onClick:ze,className:"action-btn clear-btn",title:n("terminal:debug.clearLogs"),children:n("terminal:debug.clearLogs")}),o.jsxs("label",{className:"auto-scroll-label",children:[o.jsx("input",{type:"checkbox",checked:H,onChange:he=>V(he.target.checked)}),o.jsx("span",{className:"toggle-switch"}),n("terminal:debug.autoScroll")]})]}),o.jsx("div",{className:"agent-debug-messages agent-debug-logs",ref:B,children:Ae.length===0?o.jsx("div",{className:"no-messages",children:c.length===0?n("terminal:debug.noLogsYet"):n("terminal:debug.noLogsMatch")}):Ae.map(he=>{const Be=D.has(he.id),ie=Te(he.level);return o.jsxs("div",{className:`debug-message debug-log ${ie.className}`,children:[o.jsxs("div",{className:"message-header",onClick:()=>ge(he.id),children:[o.jsx("span",{className:"expand-icon",children:Be?"▼":"▶"}),o.jsx("span",{className:"log-level-icon",children:ie.icon}),o.jsx("span",{className:"log-level",children:he.level.toUpperCase()}),he.source&&o.jsxs("span",{className:"log-source",children:["[",he.source,"]"]}),o.jsx("span",{className:"log-message",children:he.message}),o.jsx("span",{className:"message-time",children:qe(he.timestamp)})]}),Be&&he.data!==void 0?o.jsx("div",{className:"message-body",children:o.jsx("pre",{children:o.jsx(o.Fragment,{children:IA(JSON.stringify(he.data,(de,He)=>He===void 0?null:typeof He=="object"&&He!==null&&!(He instanceof Date)&&!Array.isArray(He)&&typeof He[Symbol.iterator]=="function"?Array.from(He):typeof He=="function"?`[Function: ${He.name||"anonymous"}]`:He,2))})})}):null]},he.id)})})]}),s==="process"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"agent-debug-actions process-actions",children:[o.jsx("button",{onClick:()=>{q()},className:"action-btn",title:"Refresh process output",disabled:y,children:n(y?"common:status.loading":"common:buttons.refresh")}),o.jsx("button",{onClick:Pe,className:"action-btn",title:"Copy process output",disabled:!f,children:n("terminal:debug.copyOutput")})]}),o.jsx("div",{className:"agent-debug-messages agent-debug-process-output",children:m?o.jsx("div",{className:"process-error",children:m}):f?o.jsxs("div",{className:"process-output-block",children:[o.jsxs("div",{className:"process-meta-grid",children:[o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-label",children:n("terminal:debug.pid")}),o.jsx("span",{className:"meta-value",children:f.pid})]}),o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-label",children:n("tools:metadata.source")}),o.jsx("span",{className:"meta-value",children:f.source})]}),o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-label",children:n("terminal:debug.exit")}),o.jsx("span",{className:"meta-value",children:f.exitCode??"null"})]}),o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-label",children:n("terminal:debug.fetched")}),o.jsx("span",{className:"meta-value",children:new Date(f.fetchedAt).toLocaleString("en-US",{hour12:!1})})]})]}),o.jsxs("div",{className:"process-command",children:[o.jsx("span",{className:"meta-label",children:n("terminal:debug.command")}),o.jsx("code",{children:f.command})]}),o.jsx("div",{className:"process-stream-label",children:"stdout"}),o.jsx("pre",{className:"ansi-output",children:PA(f.output||"(empty)")}),o.jsx("div",{className:"process-stream-label",children:"stderr"}),o.jsx("pre",{className:"ansi-output",children:PA(f.errorOutput||"(empty)")})]}):o.jsx("div",{className:"no-messages",children:n(y?"terminal:debug.loadingProcessOutput":"terminal:debug.noProcessOutput")})})]})]})},l5=3,c5=3;function u5(t){const[e,n]=x.useState([]),[s,a]=x.useState(!1),[r,i]=x.useState(new Set),[c,d]=x.useState(new Set),f=x.useRef(e),h=x.useRef(c),m=x.useRef(r);x.useEffect(()=>{f.current=e},[e]),x.useEffect(()=>{h.current=c},[c]),x.useEffect(()=>{m.current=r},[r]);const b=x.useCallback(async()=>{if(t){a(!0);try{const j=await Bt(Rt(`/api/files/tree?path=${encodeURIComponent(t)}&depth=${l5}`)),S=await j.json();if(j.ok&&S.tree){const T=cp(S.tree),D={name:S.name,path:t,isDirectory:!0,size:0,extension:"",children:T};n([D]);const E=new Set([t]);Sx(T,E),d(E),i(new Set([t]))}}catch(j){console.error("[FileExplorer] Failed to load tree:",j),n([])}a(!1)}},[t]),y=x.useCallback(async j=>{try{const S=await Bt(Rt(`/api/files/tree?path=${encodeURIComponent(j)}&depth=${c5}`)),T=await S.json();if(S.ok&&T.tree){const D=cp(T.tree);return n(E=>{const I=JSON.parse(JSON.stringify(E)),O=Su(I,j);return O&&(O.children=D),I}),d(E=>{const I=new Set(E);return I.add(j),Sx(T.tree,I),I}),D}}catch(S){console.error("[FileExplorer] Failed to load children:",S)}return null},[]),w=x.useCallback(async j=>{await y(j)},[y]),C=x.useCallback((j,S)=>{if(!j||!S||j===S)return;const T=E=>E===j?S:E.startsWith(`${j}/`)?`${S}${E.slice(j.length)}`:E,D=E=>{const I=E.map(O=>{const _=T(O.path),M=O.children?D(O.children):void 0;return{...O,path:_,name:_.split("/").pop()||O.name,extension:O.isDirectory?"":d5(_),children:M}});return cp(I)};n(E=>D(E)),d(E=>{const I=new Set;for(const O of E)I.add(T(O));return I})},[]),N=x.useCallback(async j=>{if(m.current.has(j))i(T=>{const D=new Set(T);return D.delete(j),D});else{i(D=>{const E=new Set(D);return E.add(j),E});let T=Su(f.current,j);for(;T&&T.isDirectory;){let D=T.children;if((!D||D.length===0)&&!h.current.has(T.path)&&(D=await y(T.path)||[]),!D||D.length===0)break;const E=D.filter(_=>_.isDirectory);if(D.some(_=>!_.isDirectory)||E.length!==1)break;const O=E[0];i(_=>{const M=new Set(_);return M.add(O.path),M}),T=O}}},[y]),k=x.useCallback(async j=>{var _;if(!j)return;const S=(t==null?void 0:t.replace(/\/+$/,""))||null,T=()=>new Promise(M=>{requestAnimationFrame(()=>M())}),D=async(M,R=20)=>{for(let z=0;z<R;z++){const $=Su(f.current,M);if($)return $;await T()}return null},E=[];if(S&&j.startsWith(S)){E.push(S);const R=j.substring(S.length).split("/").filter(Boolean);let z=S;for(const $ of R)z=`${z}/${$}`,E.push(z)}else E.push(j);for(const M of E){const R=await D(M);R!=null&&R.isDirectory&&(h.current.has(R.path)||(await y(R.path),await T()))}const I=new Set(m.current);let O=0;for(;O<E.length;){const M=E[O],R=Su(f.current,M);if(!(R!=null&&R.isDirectory)){O++;continue}let z=R;for(;z.children&&z.children.length===1&&((_=z.children[0])!=null&&_.isDirectory);)z=z.children[0];for(I.add(z.path);O<E.length;){if(E[O]===z.path){O++;break}O++}}i(I),await T()},[t,y]);return{tree:e,loading:s,expandedPaths:r,loadTree:b,reloadDirectory:w,renamePathInTree:C,togglePath:N,expandToPath:k,setExpandedPaths:i}}function d5(t){const e=t.lastIndexOf(".");return e===-1?"":t.slice(e).toLowerCase()}function Su(t,e){for(const n of t){if(n.path===e)return n;if(n.children){const s=Su(n.children,e);if(s)return s}}return null}function Sx(t,e){for(const n of t)n.isDirectory&&n.children&&n.children.length>0&&(e.add(n.path),Sx(n.children,e))}function f5(t){return[...t].sort((e,n)=>e.isDirectory&&!n.isDirectory?-1:!e.isDirectory&&n.isDirectory?1:e.name.toLowerCase().localeCompare(n.name.toLowerCase()))}function cp(t){return f5(t).map(n=>n.isDirectory&&n.children?{...n,children:cp(n.children)}:n)}function BA(t){switch(t){case"modified":return"#c89a5a";case"added":return"#5cb88a";case"deleted":return"#c85a5a";case"untracked":return"#6ab8c8";case"renamed":return"#9a80c0";default:return}}function p5(t){return[...t].sort((e,n)=>e.isDirectory&&!n.isDirectory?-1:!e.isDirectory&&n.isDirectory?1:e.name.toLowerCase().localeCompare(n.name.toLowerCase()))}function Cx(t){var s;if(!t.isDirectory)return{displayName:t.name,terminalNode:t,expansionPath:t.path};const e=[t.name];let n=t;for(;n.children&&n.children.length===1&&((s=n.children[0])!=null&&s.isDirectory);)n=n.children[0],e.push(n.name);return{displayName:e.join("/"),terminalNode:n,expansionPath:n.path}}function h5({text:t,query:e}){const n=W6(t,e);return n?o.jsxs(o.Fragment,{children:[t.slice(0,n.start),o.jsx("mark",{className:"search-highlight",children:t.slice(n.start,n.end)}),t.slice(n.end)]}):o.jsx(o.Fragment,{children:t})}function m5({node:t,depth:e,selectedPath:n,expandedPaths:s,onSelect:a,onToggle:r,onContextMenu:i,searchQuery:c}){const d=x.useMemo(()=>Cx(t),[t]),f=s.has(d.expansionPath),h=n===t.path||n===d.expansionPath,m=BA(t.gitStatus),b=x.useMemo(()=>d.terminalNode.children?p5(d.terminalNode.children):[],[d]),y=C=>{C.stopPropagation(),t.isDirectory?r(d.expansionPath):a(t)},w=C=>{i&&(C.preventDefault(),C.stopPropagation(),i(C,d.terminalNode))};return o.jsxs("div",{className:"tree-node-wrapper",children:[o.jsxs("div",{className:`tree-node ${h?"selected":""} ${t.isDirectory?"directory":"file"} ${f?"expanded":""}`,style:{paddingLeft:`${e*16}px`},onClick:y,onContextMenu:w,"data-path":t.path,children:[t.isDirectory?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`tree-arrow ${f?"expanded":""}`,children:"▸"}),o.jsxs("span",{className:"tree-folder-icon-wrapper",children:[o.jsx("span",{className:"tree-folder-icon",style:{backgroundImage:`url('${f?"/assets/vscode-icons/default_folder_opened.svg":"/assets/vscode-icons/default_folder.svg"}')`},role:"img","aria-label":"folder"}),t.hasGitChanges&&o.jsx("span",{className:"tree-folder-git-dot",style:{backgroundColor:BA(t.gitStatus)||"#c89a5a"}})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"tree-arrow-spacer"}),o.jsx("span",{className:"tree-icon",style:{backgroundImage:`url('${H6(t)}')`},role:"img","aria-label":"file"})]}),o.jsx("span",{className:"tree-name",style:m?{color:m}:void 0,children:o.jsx(h5,{text:d.displayName,query:c})})]}),t.isDirectory&&f&&b.length>0&&o.jsx("div",{className:"tree-children",children:b.map(C=>o.jsx(Ry,{node:C,depth:e+1,selectedPath:n,expandedPaths:s,onSelect:a,onToggle:r,onContextMenu:i,searchQuery:c},C.path))})]})}const Ry=x.memo(m5,(t,e)=>{if(t.node!==e.node||t.depth!==e.depth||t.searchQuery!==e.searchQuery||t.onContextMenu!==e.onContextMenu)return!1;const n=Cx(t.node).expansionPath,s=Cx(e.node).expansionPath,a=t.selectedPath===t.node.path||t.selectedPath===n,r=e.selectedPath===e.node.path||e.selectedPath===s;if(a!==r)return!1;if(t.node.isDirectory){const i=t.expandedPaths.has(n),c=e.expandedPaths.has(s);if(i!==c||c&&(t.expandedPaths!==e.expandedPaths||t.selectedPath!==e.selectedPath))return!1}return!0});Ry.displayName="TreeNodeItem";function jb(t){const e=t.lastIndexOf(".")>=0?t.substring(t.lastIndexOf(".")):"";return np(e)}function g5(t,e){if(e.type==="circle"){const a=t.x-e.center.x,r=t.z-e.center.z,i=Math.max(e.width,e.height)/2;return a*a+r*r<=i*i}const n=e.width/2,s=e.height/2;return t.x>=e.center.x-n&&t.x<=e.center.x+n&&t.z>=e.center.z-s&&t.z<=e.center.z+s}function Gf(t){return t==="modified"||t==="renamed"||t==="deleted"||t==="conflict"}function XT({node:t,depth:e,expandedDirs:n,onToggleDir:s,onFileClick:a,onContextMenu:r,onDiscard:i,repoDir:c}){if(t.isDirectory){const m=n.has(t.path),b=m?"/assets/vscode-icons/default_folder_opened.svg":"/assets/vscode-icons/default_folder.svg";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"guake-git-file guake-git-tree-dir",style:{paddingLeft:`${12+e*20}px`},onClick:()=>s(t.path),children:[o.jsx("span",{className:"guake-git-repo-arrow",style:{marginRight:4},children:m?"▼":"▶"}),o.jsx("img",{src:b,alt:"",className:"guake-git-file-icon guake-git-folder-icon"}),o.jsx("span",{className:"guake-git-file-name",children:t.name}),o.jsx("span",{className:"guake-git-repo-count",style:{marginLeft:"auto"},children:t.fileCount})]}),m&&t.children.map(y=>o.jsx(XT,{node:y,depth:e+1,expandedDirs:n,onToggleDir:s,onFileClick:a,onContextMenu:r,onDiscard:i,repoDir:c},y.path))]})}const d=t.file,f=AN[d.status],h=ph(d.name);return o.jsxs("div",{className:"guake-git-file","data-status":d.status,style:{paddingLeft:`${28+e*20}px`},onClick:()=>a(d,c),onContextMenu:r?m=>r(m,d,c):void 0,title:d.path,children:[h&&o.jsx("img",{src:h,alt:"",className:"guake-git-file-icon"}),o.jsx("span",{className:"guake-git-file-name",children:d.name}),o.jsx("span",{className:"guake-git-file-status",style:{color:f.color,marginLeft:"auto"},title:f.label,children:f.icon}),i&&o.jsx("button",{className:"guake-git-discard-btn",title:d.status==="untracked"||d.status==="added"?"Delete file":"Discard changes",onClick:m=>i(m,d,c),children:"↩"})]})}function b5({agentId:t,agents:e,onClose:n,branchInfoMap:s,fetchRemote:a,fetchingDirs:r}){const{t:i}=dt(["terminal","common"]),c=ur(),[d,f]=x.useState([]),[h,m]=x.useState(!1),[b,y]=x.useState(new Set),[w,C]=x.useState(new Set),[N,k]=x.useState(null),[j,S]=x.useState(!1),[T,D]=x.useState(()=>Fa(pt.GIT_PANEL_VIEW_MODE,"flat")==="tree"?"tree":"flat"),[E,I]=x.useState(()=>Fa(pt.GIT_PANEL_MODE,"changes")==="explorer"?"explorer":"changes"),[O,_]=x.useState(()=>Na(pt.GIT_PANEL_FOLDER_IDX,0)),M=x.useCallback(fe=>{D(fe),Wr(pt.GIT_PANEL_VIEW_MODE,fe)},[]),R=x.useCallback(fe=>{I(fe),Wr(pt.GIT_PANEL_MODE,fe)},[]),z=x.useCallback(fe=>{_(fe),La(pt.GIT_PANEL_FOLDER_IDX,fe)},[]),[$,W]=x.useState(null),[L,F]=x.useState(null),[H,V]=x.useState(null),G=Ce.useRef(!1),B=Ce.useRef(t),K=x.useMemo(()=>{const fe=new Set,X=[];for(const Se of c.values())if(!(Se.archived||Se.directories.length===0)&&Se.assignedAgentIds.includes(t)){fe.add(Se.id);for(const J of Se.directories)J&&J.trim()&&X.push(J)}const se=e.get(t);if(se){for(const Se of c.values())if(!(Se.archived||Se.directories.length===0||fe.has(Se.id))&&g5({x:se.position.x,z:se.position.z},Se))for(const J of Se.directories)J&&J.trim()&&X.push(J)}return se!=null&&se.cwd&&!X.includes(se.cwd)&&X.unshift(se.cwd),[...new Set(X)]},[t,e,c]),ne=K.length>0?K[O]||K[0]:null,q=u5(E==="explorer"?ne:null);x.useEffect(()=>{E==="explorer"&&ne&&q.loadTree()},[E,ne]);const xe=x.useMemo(()=>{if(q.tree.length===0||d.length===0||!ne)return q.tree;const fe=new Map;for(const se of d)for(const Se of se.gitStatus.files){const J=Se.path.startsWith("/")?Se.path:`${se.dir.replace(/\/$/,"")}/${Se.path}`;fe.set(J,Se.status)}if(fe.size===0)return q.tree;const X=se=>se.map(Se=>{if(Se.isDirectory){const pe=Se.children?X(Se.children):void 0,Re=pe?pe.some($e=>$e.gitStatus||$e.hasGitChanges):!1;return Re||pe!==Se.children?{...Se,children:pe,hasGitChanges:Re}:Se}const J=fe.get(Se.path);return J?{...Se,gitStatus:J}:Se});return X(q.tree)},[q.tree,d,ne]);x.useEffect(()=>{B.current!==t&&(B.current=t,G.current=!1,f([]),y(new Set),C(new Set),k(null),z(0),W(null))},[t]);const Ae=Ce.useRef(0),Z=x.useCallback(async()=>{if(K.length===0)return;const fe=++Ae.current;m(!0);try{const X=[];if(await Promise.all(K.map(async se=>{try{const Se=await Bt(Rt(`/api/files/git-status?path=${encodeURIComponent(se)}`));if(Se.ok){const J=await Se.json();if(J.isGitRepo&&J.files.length>0){const pe=se.split("/").filter(Boolean).pop()||se;X.push({dir:se,dirName:pe,gitStatus:J})}}}catch{}})),fe!==Ae.current)return;X.sort((se,Se)=>se.dirName.localeCompare(Se.dirName)),f(X),!G.current&&X.length>0&&(G.current=!0,y(new Set(X.map(se=>se.dir))))}finally{fe===Ae.current&&m(!1)}},[K]);x.useEffect(()=>{Z();const fe=setInterval(Z,15e3);return()=>clearInterval(fe)},[Z]);const ce=x.useCallback(async()=>{K.length!==0&&(await Promise.all(K.map(fe=>a(fe))),await Z())},[K,a,Z]),me=x.useCallback(fe=>{y(X=>{const se=new Set(X);return se.has(fe)?se.delete(fe):se.add(fe),se})},[]),ee=x.useCallback(fe=>{C(X=>{const se=new Set(X);return se.has(fe)?se.delete(fe):se.add(fe),se})},[]),re=x.useCallback(async(fe,X)=>{const se=fe.path.startsWith("/")?fe.path:`${X.replace(/\/$/,"")}/${fe.path}`;S(!0);try{if(Gf(fe.status)){let Se="",J="";if(fe.status!=="deleted")try{const pe=await Bt(Rt(`/api/files/read?path=${encodeURIComponent(se)}`));if(pe.ok){const Re=await pe.json();Re.content!=null&&(J=Re.content)}}catch{}try{const pe=await Bt(Rt(`/api/files/git-original?path=${encodeURIComponent(se)}`));if(pe.ok){const Re=await pe.json();Re.content!=null&&(Se=Re.content)}}catch{}k({type:"diff",data:{filePath:se,fileName:fe.name,originalContent:Se,modifiedContent:J,language:jb(fe.name)}})}else{let Se="";try{const J=await Bt(Rt(`/api/files/read?path=${encodeURIComponent(se)}`));if(J.ok){const pe=await J.json();pe.content!=null&&(Se=pe.content)}}catch{}k({type:"content",data:{filePath:se,fileName:fe.name,content:Se,language:jb(fe.name)},isNewFile:!0})}}catch{}finally{S(!1)}},[]),We=x.useCallback(async fe=>{if(!fe.isDirectory){W(fe.path),S(!0);try{const X=fe.name,se=jb(X);if(fe.gitStatus&&Gf(fe.gitStatus)){let Se="",J="";if(fe.gitStatus!=="deleted")try{const pe=await Bt(Rt(`/api/files/read?path=${encodeURIComponent(fe.path)}`));if(pe.ok){const Re=await pe.json();Re.content!=null&&(J=Re.content)}}catch{}try{const pe=await Bt(Rt(`/api/files/git-original?path=${encodeURIComponent(fe.path)}`));if(pe.ok){const Re=await pe.json();Re.content!=null&&(Se=Re.content)}}catch{}k({type:"diff",data:{filePath:fe.path,fileName:X,originalContent:Se,modifiedContent:J,language:se}})}else{let Se="";try{const J=await Bt(Rt(`/api/files/read?path=${encodeURIComponent(fe.path)}`));if(J.ok){const pe=await J.json();pe.content!=null&&(Se=pe.content)}}catch{}k({type:"content",data:{filePath:fe.path,fileName:X,content:Se,language:se},isNewFile:fe.gitStatus==="added"||fe.gitStatus==="untracked"})}}finally{S(!1)}}},[]),ze=x.useMemo(()=>{const fe=[],X=(se,Se,J)=>{for(const pe of se)if(pe.isDirectory)X(pe.children,Se,J);else{const Re=Se.find($e=>$e.path===pe.path);Re&&fe.push({file:Re,repoDir:J})}};for(const se of d)if(b.has(se.dir))if(T==="tree"){const Se=Ab(se.gitStatus.files);X(Se,se.gitStatus.files,se.dir)}else for(const Se of se.gitStatus.files)fe.push({file:Se,repoDir:se.dir});return fe},[d,T,b]),Pe=x.useCallback(async fe=>{if(!N)return;const X=N.data.filePath,se=ze.findIndex(({file:Re,repoDir:$e})=>(Re.path.startsWith("/")?Re.path:`${$e.replace(/\/$/,"")}/${Re.path}`)===X);if(se<0)return;const Se=se+fe;if(Se<0||Se>=ze.length)return;const{file:J,repoDir:pe}=ze[Se];await re(J,pe)},[N,ze,re]),ge=x.useMemo(()=>{if(!N)return-1;const fe=N.data.filePath;return ze.findIndex(({file:X,repoDir:se})=>(X.path.startsWith("/")?X.path:`${se.replace(/\/$/,"")}/${X.path}`)===fe)},[N,ze]),Te=x.useCallback(()=>k(null),[]),qe=x.useCallback(()=>F(null),[]),it=x.useCallback(async fe=>{try{const X=await Bt(Rt("/api/files/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:fe.path})});if(X.ok){if(fe.status==="added")try{await Bt(Rt("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:fe.path,status:"added"}],directory:fe.repoDir})})}catch{}}else{const se=await X.json().catch(()=>({error:"Unknown error"}));console.error("Delete failed:",se.error)}Z(),E==="explorer"&&q.loadTree()}catch(X){console.error("Delete request failed:",X)}finally{V(null)}},[Z,E,q]),[he,Be]=x.useState(null),ie=x.useCallback(async fe=>{try{await Bt(Rt("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:fe.path,status:fe.status}],directory:fe.repoDir})}),Z()}catch{}finally{Be(null)}},[Z]),de=x.useCallback((fe,X,se)=>{fe.stopPropagation();const Se=X.path.startsWith("/")?X.path:`${se.replace(/\/$/,"")}/${X.path}`;X.status==="untracked"||X.status==="added"?V({path:Se,name:X.name,status:X.status,repoDir:se}):Be({path:Se,name:X.name,status:X.status,repoDir:se})},[]),He=x.useCallback((fe,X,se)=>{fe.preventDefault(),fe.stopPropagation();const Se=X.path.startsWith("/")?X.path:`${se.replace(/\/$/,"")}/${X.path}`,J=[];J.push({id:"view",label:Gf(X.status)?"View Diff":"View File",icon:Gf(X.status)?"📊":"📄",onClick:()=>re(X,se)}),J.push({id:"div1",label:"",divider:!0,onClick:()=>{}}),J.push({id:"copy-path",label:"Copy Full Path",icon:"🧷",onClick:()=>{navigator.clipboard.writeText(Se)}}),J.push({id:"copy-rel",label:"Copy Relative Path",icon:"📋",onClick:()=>{navigator.clipboard.writeText(X.path)}}),X.status!=="deleted"&&(J.push({id:"div2",label:"",divider:!0,onClick:()=>{}}),J.push({id:"open-editor",label:"Open in Editor",icon:"✏️",onClick:async()=>{try{await Bt(Rt("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Se})})}catch{}}})),(X.status==="modified"||X.status==="deleted"||X.status==="renamed")&&(J.push({id:"div3",label:"",divider:!0,onClick:()=>{}}),J.push({id:"discard",label:"Discard Changes",icon:"↩️",danger:!0,onClick:async()=>{try{await Bt(Rt("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:Se,status:X.status}],directory:se})}),Z()}catch{}}})),X.status!=="deleted"&&(X.status==="modified"||X.status==="renamed"||J.push({id:"div-del",label:"",divider:!0,onClick:()=>{}}),J.push({id:"delete",label:"Delete File",icon:"🗑️",danger:!0,onClick:()=>V({path:Se,name:X.name,status:X.status,repoDir:se})})),F({isOpen:!0,position:{x:fe.clientX,y:fe.clientY},actions:J})},[re]),et=x.useCallback((fe,X)=>{fe.preventDefault(),fe.stopPropagation();const se=[];if(X.isDirectory||(se.push({id:"view",label:"View File",icon:"📄",onClick:()=>We(X)}),se.push({id:"div1",label:"",divider:!0,onClick:()=>{}})),se.push({id:"copy-path",label:"Copy Full Path",icon:"🧷",onClick:()=>{navigator.clipboard.writeText(X.path)}}),ne){const Se=X.path.startsWith(ne)?X.path.slice(ne.replace(/\/$/,"").length+1):X.path;se.push({id:"copy-rel",label:"Copy Relative Path",icon:"📋",onClick:()=>{navigator.clipboard.writeText(Se)}})}X.isDirectory||(se.push({id:"div2",label:"",divider:!0,onClick:()=>{}}),se.push({id:"open-editor",label:"Open in Editor",icon:"✏️",onClick:async()=>{try{await Bt(Rt("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:X.path})})}catch{}}}),se.push({id:"div-del",label:"",divider:!0,onClick:()=>{}}),se.push({id:"delete",label:"Delete File",icon:"🗑️",danger:!0,onClick:()=>V({path:X.path,name:X.name,status:X.gitStatus||"untracked",repoDir:ne||""})})),F({isOpen:!0,position:{x:fe.clientX,y:fe.clientY},actions:se})},[We,ne]),ct=d.reduce((fe,X)=>fe+X.gitStatus.files.length,0);return x.useEffect(()=>{if(!N&&!H&&!he)return;const fe=X=>{X.key==="Escape"&&(X.stopImmediatePropagation(),X.preventDefault(),he?Be(null):H?V(null):Te())};return document.addEventListener("keydown",fe,!0),()=>document.removeEventListener("keydown",fe,!0)},[N,Te,H,he]),Xt("guake-git-diff-modal",N!==null,Te),Xt("guake-git-delete-confirm",H!==null,()=>V(null)),Xt("guake-git-discard-confirm",he!==null,()=>Be(null)),x.useEffect(()=>{if(T==="tree"&&w.size===0&&d.length>0){const fe=new Set;for(const X of d){const se=Ab(X.gitStatus.files),Se=J=>{for(const pe of J)pe.isDirectory&&(fe.add(pe.path),Se(pe.children))};Se(se)}C(fe)}},[T,d]),o.jsxs(o.Fragment,{children:[H&&o.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:()=>V(null),children:o.jsxs("div",{className:"guake-git-delete-confirm",onClick:fe=>fe.stopPropagation(),children:[o.jsxs("p",{children:["Delete ",o.jsx("strong",{children:H.name}),"?"]}),o.jsx("p",{className:"guake-git-delete-path",children:H.path}),o.jsxs("div",{className:"guake-git-delete-actions",children:[o.jsx("button",{className:"guake-git-delete-cancel",onClick:()=>V(null),children:"Cancel"}),o.jsx("button",{className:"guake-git-delete-btn",onClick:()=>it(H),children:"Delete"})]})]})}),he&&o.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:()=>Be(null),children:o.jsxs("div",{className:"guake-git-delete-confirm",onClick:fe=>fe.stopPropagation(),children:[o.jsxs("p",{children:["Discard changes to ",o.jsx("strong",{children:he.name}),"?"]}),o.jsx("p",{className:"guake-git-delete-path",children:he.path}),o.jsxs("div",{className:"guake-git-delete-actions",children:[o.jsx("button",{className:"guake-git-delete-cancel",onClick:()=>Be(null),children:"Cancel"}),o.jsx("button",{className:"guake-git-delete-btn",onClick:()=>ie(he),children:"Discard"})]})]})}),N&&o.jsx("div",{className:"guake-git-diff-modal-overlay",onClick:Te,children:o.jsxs("div",{className:"guake-git-diff-modal",onClick:fe=>fe.stopPropagation(),children:[o.jsxs("div",{className:"guake-git-diff-modal-header",children:[E==="changes"&&o.jsxs("div",{className:"guake-git-diff-nav",children:[o.jsx("button",{className:"guake-git-diff-nav-btn",onClick:()=>Pe(-1),disabled:ge<=0,title:"Previous file",children:"‹"}),o.jsx("button",{className:"guake-git-diff-nav-btn",onClick:()=>Pe(1),disabled:ge<0||ge>=ze.length-1,title:"Next file",children:"›"}),ge>=0&&o.jsxs("span",{className:"guake-git-diff-nav-counter",children:[ge+1," / ",ze.length]})]}),o.jsxs("span",{className:"guake-git-diff-filename",title:N.data.filePath,children:[N.data.filePath,N.type==="content"&&N.isNewFile&&o.jsx("span",{className:"guake-git-content-badge",children:"new file"})]}),o.jsx("button",{className:"guake-git-close",onClick:Te,title:"Close (Esc)",children:"×"})]}),o.jsx("div",{className:"guake-git-diff-content",children:N.type==="diff"?o.jsx(mx,{originalContent:N.data.originalContent,modifiedContent:N.data.modifiedContent,filename:N.data.fileName,language:N.data.language}):o.jsx(mx,{originalContent:"",modifiedContent:N.data.content,filename:N.data.fileName,language:N.data.language,initialModifiedOnly:!0})})]})}),o.jsxs("div",{className:"guake-git-panel",children:[o.jsxs("div",{className:"guake-git-header",children:[o.jsx("div",{className:"guake-git-title",children:o.jsxs("div",{className:"guake-git-tabs",children:[o.jsxs("button",{className:`guake-git-tab ${E==="changes"?"active":""}`,onClick:()=>R("changes"),children:["🌿 Changes",ct>0&&o.jsx("span",{className:"guake-git-badge",children:ct})]}),o.jsx("button",{className:`guake-git-tab ${E==="explorer"?"active":""}`,onClick:()=>R("explorer"),children:"📁 Files"})]})}),o.jsxs("div",{className:"guake-git-header-actions",children:[o.jsx("button",{className:`guake-git-fetch-btn ${r.size>0?"fetching":""}`,onClick:ce,title:"Git fetch",disabled:r.size>0,children:r.size>0?"⏳":"⇣"}),E==="changes"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:`guake-git-view-toggle ${T==="flat"?"active":""}`,onClick:()=>M("flat"),title:"Flat view",children:"☰"}),o.jsx("button",{className:`guake-git-view-toggle ${T==="tree"?"active":""}`,onClick:()=>M("tree"),title:"Tree view",children:"🌲"}),o.jsx("button",{className:"guake-git-refresh",onClick:Z,title:"Refresh",disabled:h,children:h?"⏳":"↻"})]}),E==="explorer"&&o.jsx("button",{className:"guake-git-refresh",onClick:()=>q.loadTree(),title:"Refresh",disabled:q.loading,children:q.loading?"⏳":"↻"}),o.jsx("button",{className:"guake-git-close",onClick:n,title:"Close",children:"×"})]})]}),o.jsxs("div",{className:"guake-git-body",children:[E==="changes"&&o.jsxs(o.Fragment,{children:[h&&d.length===0&&o.jsx("div",{className:"guake-git-loading",children:"Loading git status..."}),!h&&d.length===0&&o.jsx("div",{className:"guake-git-empty",children:"No git changes found"}),d.map(({dir:fe,dirName:X,gitStatus:se})=>{const Se=s.get(fe);return o.jsxs("div",{className:"guake-git-repo",children:[o.jsxs("div",{className:`guake-git-repo-header ${b.has(fe)?"expanded":""}`,onClick:()=>me(fe),children:[o.jsx("span",{className:"guake-git-repo-arrow",children:b.has(fe)?"▼":"▶"}),o.jsx("span",{className:"guake-git-repo-name",children:X}),se.branch&&o.jsxs("span",{className:"guake-git-repo-branch",children:["⎇ ",se.branch]}),Se&&Se.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",children:["↑",Se.ahead]}),Se&&Se.behind>0&&o.jsxs("span",{className:"guake-branch-behind",children:["↓",Se.behind]}),o.jsx("span",{className:"guake-git-repo-count",children:se.files.length})]}),b.has(fe)&&T==="flat"&&o.jsx("div",{className:"guake-git-file-list",children:se.files.map(J=>{const pe=AN[J.status],Re=ph(J.name);return o.jsxs("div",{className:"guake-git-file","data-status":J.status,onClick:()=>re(J,fe),onContextMenu:$e=>He($e,J,fe),title:J.path,children:[Re&&o.jsx("img",{src:Re,alt:"",className:"guake-git-file-icon"}),o.jsx("span",{className:"guake-git-file-name",children:J.name}),o.jsx("span",{className:"guake-git-file-dir",children:J.path.includes("/")?J.path.substring(0,J.path.lastIndexOf("/")):""}),o.jsx("span",{className:"guake-git-file-status",style:{color:pe.color},title:pe.label,children:pe.icon}),o.jsx("button",{className:"guake-git-discard-btn",title:J.status==="untracked"||J.status==="added"?"Delete file":"Discard changes",onClick:$e=>de($e,J,fe),children:"↩"})]},J.path)})}),b.has(fe)&&T==="tree"&&o.jsx("div",{className:"guake-git-file-list",children:Ab(se.files).map(J=>o.jsx(XT,{node:J,depth:0,expandedDirs:w,onToggleDir:ee,onFileClick:re,onContextMenu:He,onDiscard:de,repoDir:fe},J.path))})]},fe)})]}),E==="explorer"&&o.jsxs(o.Fragment,{children:[K.length>1&&o.jsx("div",{className:"guake-git-folder-selector",children:K.map((fe,X)=>{const se=fe.split("/").filter(Boolean).pop()||fe,Se=s.get(fe);return o.jsxs("button",{className:`guake-git-folder-btn ${X===O?"active":""}`,onClick:()=>z(X),title:fe,children:["📂 ",se,Se&&o.jsxs("span",{className:"guake-git-folder-branch",children:[" ⎇ ",Se.branch]}),Se&&Se.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",children:["↑",Se.ahead]}),Se&&Se.behind>0&&o.jsxs("span",{className:"guake-branch-behind",children:["↓",Se.behind]})]},fe)})}),q.loading&&q.tree.length===0&&o.jsx("div",{className:"guake-git-loading",children:"Loading files..."}),!q.loading&&q.tree.length===0&&o.jsx("div",{className:"guake-git-empty",children:"No files found"}),o.jsx("div",{className:"guake-git-explorer-tree",children:xe.map(fe=>o.jsx(Ry,{node:fe,depth:0,selectedPath:$,expandedPaths:q.expandedPaths,onSelect:We,onToggle:q.togglePath,onContextMenu:et,searchQuery:""},fe.path))})]})]})]}),L&&o.jsx(Do,{isOpen:L.isOpen,position:L.position,worldPosition:{x:0,z:0},actions:L.actions,onClose:qe})]})}async function hh(t,e){const n=Ii(),s=await fetch(`${Ea()}${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-Auth-Token":n},body:JSON.stringify(e)});if(!s.ok)throw new Error(`Bulk action failed: ${s.statusText}`);const a=await s.json(),r=a.failed||[];return{succeeded:a.deleted||a.stopped||a.cleared||a.moved||[],failed:r}}async function x5(t){return hh("/api/agents/bulk/delete",{agentIds:t})}async function y5(t){return hh("/api/agents/bulk/stop",{agentIds:t})}async function v5(t){return hh("/api/agents/bulk/clear-context",{agentIds:t})}async function w5(t,e){return hh("/api/agents/bulk/move-area",{agentIds:t,areaId:e})}function k5(t){return Array.from(t.values())}const S5={">1h":3600*1e3,">6h":360*60*1e3,">1d":1440*60*1e3,">3d":4320*60*1e3,">7d":10080*60*1e3,">30d":720*60*60*1e3};function C5(t){const e=Date.now()-t;return e<6e4?"<1m":e<36e5?`${Math.floor(e/6e4)}m`:e<864e5?`${Math.floor(e/36e5)}h`:`${Math.floor(e/864e5)}d`}function FA(t,e){for(const n of e)if(n.assignedAgentIds.includes(t.id))return n;return null}function A5({isOpen:t,onClose:e}){const n=Kp(),s=ur(),a=k5(s),[r,i]=x.useState("all"),[c,d]=x.useState("any"),[f,h]=x.useState("all"),[m,b]=x.useState("all"),[y,w]=x.useState("all"),[C,N]=x.useState(""),[k,j]=x.useState(new Set),[S,T]=x.useState(null),[D,E]=x.useState(""),[I,O]=x.useState(null),[_,M]=x.useState(null),[R,z]=x.useState(!1);x.useEffect(()=>{t&&(j(new Set),O(null),M(null),T(null))},[t]);const $=x.useMemo(()=>{const G=Date.now(),B=C.toLowerCase().trim();return n.filter(K=>{if(r!=="all"&&K.status!==r||c!=="any"&&G-K.lastActivity<S5[c])return!1;if(f!=="all"){const ne=FA(K,a);if(f==="unassigned"){if(ne!==null)return!1}else if(!ne||ne.id!==f)return!1}if(m!=="all"&&K.provider!==m||y!=="all"&&(K.model||"sonnet")!==y)return!1;if(B){const ne=K.name.toLowerCase().includes(B),q=K.class.toLowerCase().includes(B);if(!ne&&!q)return!1}return!0})},[n,a,r,c,f,m,y,C]);x.useEffect(()=>{const G=new Set($.map(B=>B.id));j(B=>{const K=new Set;for(const ne of B)G.has(ne)&&K.add(ne);return K.size!==B.size?K:B})},[$]);const W=x.useCallback(G=>{j(B=>{const K=new Set(B);return K.has(G)?K.delete(G):K.add(G),K})},[]),L=x.useCallback(()=>{j(new Set($.map(G=>G.id)))},[$]),F=x.useCallback(()=>{j(new Set)},[]),H=x.useCallback(async G=>{const B=Array.from(k);if(B.length!==0){z(!0),O(null),M(null);try{let K,ne="";switch(G){case"delete":K=await x5(B),ne="Deleted",K.failed.length===0&&j(new Set);break;case"stop":K=await y5(B),ne="Stopped";break;case"clear-context":K=await v5(B),ne="Cleared context for";break;case"move-area":K=await w5(B,D||null),ne="Moved";break}K&&(K.failed.length>0?M(`${ne} ${K.succeeded.length} agent(s). Failed: ${K.failed.length}`):M(`${ne} ${K.succeeded.length} agent(s)`))}catch(K){O(K instanceof Error?K.message:"Action failed")}finally{z(!1),T(null)}}},[k,D]),V=x.useCallback(G=>{G.key==="Escape"&&(S?T(null):e())},[S,e]);return t?o.jsx(pr,{children:o.jsx("div",{className:`modal-overlay ${t?"visible":""}`,onClick:e,children:o.jsxs("div",{className:"bulk-manage-modal",onClick:G=>G.stopPropagation(),onKeyDown:V,children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h2",{children:"Bulk Agent Management"}),o.jsx("button",{className:"modal-close",onClick:e,"aria-label":"Close",children:"✕"})]}),o.jsx("div",{className:"bulk-filters",children:o.jsxs("div",{className:"filter-row",children:[o.jsxs("select",{value:r,onChange:G=>i(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"all",children:"All Status"}),o.jsx("option",{value:"idle",children:"Idle"}),o.jsx("option",{value:"working",children:"Working"}),o.jsx("option",{value:"error",children:"Error"}),o.jsx("option",{value:"stopped",children:"Stopped"})]}),o.jsxs("select",{value:c,onChange:G=>d(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"any",children:"Any Idle Time"}),o.jsx("option",{value:">1h",children:"> 1 hour"}),o.jsx("option",{value:">6h",children:"> 6 hours"}),o.jsx("option",{value:">1d",children:"> 1 day"}),o.jsx("option",{value:">3d",children:"> 3 days"}),o.jsx("option",{value:">7d",children:"> 7 days"}),o.jsx("option",{value:">30d",children:"> 30 days"})]}),o.jsxs("select",{value:f,onChange:G=>h(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"all",children:"All Areas"}),o.jsx("option",{value:"unassigned",children:"Unassigned"}),a.map(G=>o.jsx("option",{value:G.id,children:G.name},G.id))]}),o.jsxs("select",{value:m,onChange:G=>b(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"all",children:"All Providers"}),o.jsx("option",{value:"claude",children:"Claude"}),o.jsx("option",{value:"codex",children:"Codex"})]}),o.jsxs("select",{value:y,onChange:G=>w(G.target.value),className:"bulk-filter-select",children:[o.jsx("option",{value:"all",children:"All Models"}),o.jsx("option",{value:"opus",children:"Opus"}),o.jsx("option",{value:"sonnet",children:"Sonnet"}),o.jsx("option",{value:"haiku",children:"Haiku"})]}),o.jsx("input",{type:"text",placeholder:"Search name/class...",value:C,onChange:G=>N(G.target.value),className:"bulk-filter-search"})]})}),o.jsxs("div",{className:"bulk-count-bar",children:[o.jsxs("span",{className:"bulk-count",children:[$.length," matched, ",k.size," selected"]}),o.jsxs("div",{className:"bulk-select-controls",children:[o.jsx("button",{className:"bulk-link-btn",onClick:L,children:"Select all"}),o.jsx("button",{className:"bulk-link-btn",onClick:F,children:"Select none"})]})]}),I&&o.jsxs("div",{className:"bulk-alert bulk-alert-error",children:[o.jsx("span",{className:"alert-icon",children:"!"}),I]}),_&&o.jsxs("div",{className:"bulk-alert bulk-alert-success",children:[o.jsx("span",{className:"alert-icon",children:"✓"}),_]}),o.jsx("div",{className:"bulk-agent-list",children:$.length===0?o.jsx("div",{className:"bulk-empty",children:"No agents match the current filters"}):o.jsxs("table",{className:"bulk-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{className:"col-check",children:o.jsx("input",{type:"checkbox",checked:k.size===$.length&&$.length>0,onChange:()=>k.size===$.length?F():L()})}),o.jsx("th",{className:"col-name",children:"Name"}),o.jsx("th",{className:"col-class",children:"Class"}),o.jsx("th",{className:"col-status",children:"Status"}),o.jsx("th",{className:"col-idle",children:"Idle"}),o.jsx("th",{className:"col-area",children:"Area"})]})}),o.jsx("tbody",{children:$.map(G=>{const B=FA(G,a);return o.jsxs("tr",{className:k.has(G.id)?"selected":"",onClick:()=>W(G.id),children:[o.jsx("td",{className:"col-check",children:o.jsx("input",{type:"checkbox",checked:k.has(G.id),onChange:()=>W(G.id),onClick:K=>K.stopPropagation()})}),o.jsx("td",{className:"col-name",children:G.name}),o.jsx("td",{className:"col-class",children:G.class}),o.jsx("td",{className:"col-status",children:o.jsx("span",{className:`bulk-status bulk-status-${G.status}`,children:G.status})}),o.jsx("td",{className:"col-idle",children:C5(G.lastActivity)}),o.jsx("td",{className:"col-area",children:B?o.jsx("span",{className:"bulk-area-badge",style:{borderColor:B.color},children:B.name}):o.jsx("span",{className:"bulk-area-none",children:"--"})})]},G.id)})})]})}),S&&o.jsx("div",{className:"bulk-confirm-overlay",children:o.jsxs("div",{className:"bulk-confirm-box",children:[o.jsx("p",{children:S==="delete"?`Delete ${k.size} agent(s)? This cannot be undone.`:`Clear context for ${k.size} agent(s)? This will restart their sessions.`}),o.jsxs("div",{className:"bulk-confirm-actions",children:[o.jsx("button",{className:"btn btn-secondary",onClick:()=>T(null),disabled:R,children:"Cancel"}),o.jsx("button",{className:"btn btn-danger",onClick:()=>H(S),disabled:R,children:R?"Working...":"Confirm"})]})]})}),o.jsxs("div",{className:"modal-footer bulk-footer",children:[o.jsxs("div",{className:"footer-buttons-left",children:[o.jsx("button",{className:"btn btn-danger",disabled:k.size===0||R,onClick:()=>T("delete"),children:"Delete Selected"}),o.jsx("button",{className:"btn btn-secondary",disabled:k.size===0||R,onClick:()=>T("clear-context"),children:"Clear Context"})]}),o.jsxs("div",{className:"footer-buttons-right",children:[o.jsx("button",{className:"btn btn-secondary",disabled:k.size===0||R,onClick:()=>H("stop"),children:"Stop Selected"}),o.jsxs("select",{value:D,onChange:G=>E(G.target.value),className:"bulk-filter-select",disabled:k.size===0||R,children:[o.jsx("option",{value:"",children:"Unassign area"}),a.map(G=>o.jsx("option",{value:G.id,children:G.name},G.id))]}),o.jsx("button",{className:"btn btn-primary",disabled:k.size===0||R,onClick:()=>H("move-area"),children:"Move to Area"})]})]})]})})}):null}const j5={working:"🟢",idle:"💤",waiting_input:"🟡",waiting_permission:"🟠",error:"🔴",stopped:"⚫"},zA={working:"overview.statusLabels.working",idle:"overview.statusLabels.idle",waiting_input:"overview.statusLabels.waitingInput",waiting_permission:"overview.statusLabels.waitingPermission",error:"overview.statusLabels.error",stopped:"overview.statusLabels.stopped"};function N5(t){const e=U.getState().agentOutputs.get(t);if(!e||e.length===0)return null;for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.isStreaming)continue;const a=s.text;if(!(a.startsWith("Using tool:")||a.startsWith("Tool input:")||a.startsWith("Tool result:")||a.startsWith("Bash output:"))&&!(a.startsWith("Tokens:")||a.startsWith("Cost:")||a.startsWith("Context:"))&&a.trim().length!==0)return s}return null}function T5(t){const e=U.getState().agentOutputs.get(t);if(!e)return 0;let n=0;for(const s of e){if(s.isStreaming)continue;const a=s.text;a.startsWith("Using tool:")||a.startsWith("Tool input:")||a.startsWith("Tool result:")||a.startsWith("Bash output:")||a.startsWith("Tokens:")||a.startsWith("Cost:")||a.startsWith("Context:")||a.trim().length!==0&&n++}return n}function Kf(t,e){const n=t.split(`
|
|
142
|
+
`)[0];return n.length>e?n.slice(0,e)+"...":n}function _5({activeAgentId:t,onClose:e,onSelectAgent:n,agentListRef:s,twoFingerState:a}){const{t:r}=dt(["terminal","common"]),i=Kp(),[c]=Bj(),d=x.useMemo(()=>c?i.filter(je=>{const Oe=U.getAreaForAgent(je.id);return Fx((Oe==null?void 0:Oe.id)??null)}):i,[i,c]),f=l1(),h=Vx(),m=dL(),b=ur(),y=n1();x.useEffect(()=>{for(const je of d)!U.hasHistoryBeenFetched(je.id)&&!U.isLoadingHistoryForAgent(je.id)&&U.requestAgentSupervisorHistory(je.id)},[d]);const w=x.useMemo(()=>Na(pt.AOP_CONFIG,{groupByArea:!0,sortMode:"recent",filterMode:"all",allExpanded:!1,sameAreaOnly:!1,showSubagents:!0,showRecentActivity:!0,visibleAreaIds:null}),[]),[C,N]=x.useState(()=>w.allExpanded?new Set(d.map(je=>je.id)):new Set),[k,j]=x.useState(new Set),[S,T]=x.useState(null),[D,E]=x.useState(""),[I,O]=x.useState(w.sortMode),[_,M]=x.useState(w.filterMode),[R,z]=x.useState(""),[$,W]=x.useState(w.groupByArea),[L,F]=x.useState(w.allExpanded),[H,V]=x.useState(w.sameAreaOnly),[G,B]=x.useState(w.showSubagents),[K,ne]=x.useState(w.showRecentActivity),[q,xe]=x.useState(w.visibleAreaIds?new Set(w.visibleAreaIds):null),[Ae,Z]=x.useState(!1),[ce,me]=x.useState(""),[ee,re]=x.useState(!1),We=x.useRef(null),[ze,Pe]=x.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 768px)").matches:!1),[ge,Te]=x.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 768px)").matches:!1),[qe,it]=x.useState(null),[he,Be]=x.useState(null),ie=x.useRef(null),de=x.useRef(null),He=s||de,et=x.useRef(!1),ct=x.useRef(new Map),fe=a||{hoveredAgentId:null};x.useEffect(()=>{if(typeof window>"u")return;const je=window.matchMedia("(max-width: 768px)"),Oe=Ze=>{Pe(Ze),Te(Ze)};Oe(je.matches);const Ye=Ze=>Oe(Ze.matches);return je.addEventListener("change",Ye),()=>je.removeEventListener("change",Ye)},[]),x.useEffect(()=>{if(!Ae){me("");return}const je=Oe=>{We.current&&!We.current.contains(Oe.target)&&(Z(!1),me(""))};return document.addEventListener("mousedown",je),()=>document.removeEventListener("mousedown",je)},[Ae]),x.useEffect(()=>{const je=Oe=>{var Ze,Ot;Oe.altKey&&Oe.shiftKey&&!Oe.ctrlKey&&!Oe.metaKey&&Oe.code==="KeyF"&&(Oe.preventDefault(),(Ze=ie.current)==null||Ze.focus(),(Ot=ie.current)==null||Ot.select())};return document.addEventListener("keydown",je,!0),()=>document.removeEventListener("keydown",je,!0)},[]),x.useEffect(()=>{La(pt.AOP_CONFIG,{groupByArea:$,sortMode:I,filterMode:_,allExpanded:L,sameAreaOnly:H,showSubagents:G,showRecentActivity:K,visibleAreaIds:q?Array.from(q):null})},[$,I,_,L,H,G,K,q]);const X=x.useMemo(()=>{const je=[];for(const[,Oe]of b)Oe.archived||je.push({id:Oe.id,name:Oe.name,color:Oe.color});return je.sort((Oe,Ye)=>Oe.name.localeCompare(Ye.name,void 0,{sensitivity:"base"})),je},[b]),se=q===null,Se=x.useCallback(je=>{xe(Oe=>{if(Oe===null){const Ze=new Set(X.map(Ot=>Ot.id));return Ze.add("__unassigned__"),Ze.delete(je),Ze}const Ye=new Set(Oe);return Ye.has(je)?Ye.delete(je):Ye.add(je),Ye.size>=X.length+1?null:Ye})},[X]),J=x.useCallback(()=>xe(null),[]),pe=x.useMemo(()=>{const je=new Map;for(const Oe of d){const Ye=U.getAreaForAgent(Oe.id);!Ye||Ye.archived||je.set(Oe.id,{color:Ye.color,name:Ye.name})}return je},[d,b]),Re=x.useMemo(()=>{const je=new Map;for(const Oe of h){const Ye=je.get(Oe.agentId)||[];Ye.push(Oe),je.set(Oe.agentId,Ye)}return je},[h]),$e=x.useMemo(()=>{const je=new Map;for(const[,Oe]of m){const Ye=je.get(Oe.parentAgentId)||[];Ye.push(Oe),je.set(Oe.parentAgentId,Ye)}return je},[m]),ye=x.useMemo(()=>{const je=new Map;for(const Oe of d){const Ye=U.getAreaForAgent(Oe.id);!Ye||Ye.archived||je.set(Oe.id,Ye.id)}return je},[d,b]),[Ie,te]=x.useMemo(()=>{const je=ye.get(t)??null,Oe=new Map;return[d.filter(Ze=>{if(_==="working"&&Ze.status!=="working"||_==="idle"&&Ze.status!=="idle"||_==="error"&&Ze.status!=="error"||H&&(ye.get(Ze.id)??null)!==je)return!1;if(R){const Ot=R.toLowerCase();if(Ze.name.toLowerCase().includes(Ot)||Ze.id.includes(Ot)||(Ze.class||"").toLowerCase().includes(Ot)||(Ze.taskLabel||"").toLowerCase().includes(Ot))return!0;const Ft=Ze.lastAssignedTask||"";if(Ft.toLowerCase().includes(Ot))return Oe.set(Ze.id,{type:"task",text:Ft}),!0;const Lt=U.getAgentSupervisorHistory(Ze.id);for(const Vt of Lt){const ln=Vt.analysis.recentWorkSummary,bt=Vt.analysis.statusDescription;if(ln.toLowerCase().includes(Ot))return Oe.set(Ze.id,{type:"history",text:ln}),!0;if(bt.toLowerCase().includes(Ot))return Oe.set(Ze.id,{type:"history",text:bt}),!0}for(const Vt of y)if(Vt.agentId===Ze.id&&Vt.filePath.toLowerCase().includes(Ot))return Oe.set(Ze.id,{type:"file",text:Vt.filePath}),!0;return!1}return!0}),Oe]},[d,_,R,H,ye,t,y]),be=x.useCallback((je,Oe="__default__")=>{const Ye=new Set(je.map(rt=>rt.id)),Ze=ct.current.get(Oe),Ot=!Ze||Ze.length!==je.length||Ze.some(rt=>!Ye.has(rt)),Ft=rt=>{const xt=!!(rt.isBoss||rt.class==="boss");if(I==="name")return`${xt?"0":"1"}`;if(I==="status"){const En=["working","waiting_input","waiting_permission","error","idle","stopped"].indexOf(rt.status),nn=f.has(rt.id)?"0":"1";return`${xt?"0":"1"}-${En}-${nn}`}return`${xt?"0":"1"}`};let Lt=!1;if(Ze&&!Ot){const rt=ct.current.get(Oe+"__buckets");if(rt)for(const xt of je){const $t=Ze.indexOf(xt.id);if($t>=0&&rt[$t]!==Ft(xt)){Lt=!0;break}}else Lt=!0}let Vt;if(Ot||Lt||I==="recent")Vt=[...je].sort((rt,xt)=>{var Os,ps;const $t=!!(rt.isBoss||rt.class==="boss"),En=!!(xt.isBoss||xt.class==="boss");if($t!==En)return $t?-1:1;if(I==="name")return rt.name.localeCompare(xt.name);if(I==="status"){const ks=["working","waiting_input","waiting_permission","error","idle","stopped"],Qn=ks.indexOf(rt.status)-ks.indexOf(xt.status);if(Qn!==0)return Qn;const Ss=f.has(rt.id),Fn=f.has(xt.id);if(Ss!==Fn)return Ss?-1:1;if(rt.status==="working"&&xt.status==="working")return rt.name.localeCompare(xt.name);if(rt.status==="idle"&&xt.status==="idle"){const Ls=!!rt.taskLabel,Is=!!xt.taskLabel;return Ls!==Is?Ls?-1:1:(xt.lastActivity||0)-(rt.lastActivity||0)}return(xt.lastActivity||0)-(rt.lastActivity||0)}const nn=((Os=(Re.get(rt.id)||[])[0])==null?void 0:Os.timestamp)||rt.lastActivity||0;return(((ps=(Re.get(xt.id)||[])[0])==null?void 0:ps.timestamp)||xt.lastActivity||0)-nn});else{const rt=new Map(je.map(xt=>[xt.id,xt]));Vt=Ze.map(xt=>rt.get(xt)).filter(Boolean)}const ln=Vt.map(rt=>rt.id),bt=Vt.map(rt=>Ft(rt));return ct.current.set(Oe,ln),ct.current.set(Oe+"__buckets",bt),Vt},[I,Re,f]),we=x.useMemo(()=>{if(!$)return[{area:null,agents:be(Ie,"__flat__")}];const je=new Map,Oe=[];for(const Ze of Ie){const Ot=U.getAreaForAgent(Ze.id);if(!Ot||Ot.archived){Oe.push(Ze);continue}const Ft=je.get(Ot.id);Ft?Ft.push(Ze):je.set(Ot.id,[Ze])}const Ye=[];for(const[Ze,Ot]of b){if(Ot.archived||q&&!q.has(Ze))continue;const Ft=je.get(Ze)||[];Ft.length>0&&Ye.push({area:Ot,agents:be(Ft,`area_${Ze}`)})}return Oe.length>0&&(!q||q.has("__unassigned__"))&&Ye.push({area:null,agents:be(Oe,"__unassigned__")}),Ye},[b,Ie,be,$,q]),Fe=x.useCallback(je=>{const Oe=Lt=>f.has(Lt.id),Ye=je.findIndex(Lt=>Oe(Lt)&&Lt.status!=="working"),Ze=Ye>=0,Ot=je.findIndex(Lt=>Lt.status==="idle"&&!Oe(Lt)),Ft=Ot>=0&&je.slice(0,Ot).some(Lt=>Lt.status==="working"||Oe(Lt));return je.map((Lt,Vt)=>o.jsxs(Ce.Fragment,{children:[Ze&&Vt===Ye&&o.jsx("div",{className:"aop-status-separator aop-status-separator--unread",role:"separator","aria-label":"unread notifications",children:o.jsx("span",{children:"Unread notifications"})}),Ft&&Vt===Ot&&o.jsx("div",{className:"aop-status-separator",role:"separator","aria-label":"idle agents",children:o.jsx("span",{children:r("terminal:overview.statusLabels.idle")})}),o.jsx(E5,{agent:Lt,isActive:Lt.id===t,isExpanded:C.has(Lt.id),isMobile:ze,hasPendingRead:f.has(Lt.id),isTwoFingerHovered:fe.hoveredAgentId===Lt.id,showSubagents:G,showRecentActivity:K,showAreaChip:!$,toolExecs:Re.get(Lt.id)||[],subagents:$e.get(Lt.id)||[],areaInfo:pe.get(Lt.id),matchContext:te.get(Lt.id),onToggle:()=>st(Lt.id),onSelect:()=>n(Lt.id),onClearContext:()=>U.clearContext(Lt.id),onContextMenu:ln=>Be({agentId:Lt.id,position:ln})})]},Lt.id))},[r,t,C,f,fe.hoveredAgentId,G,K,$,Re,$e,pe,te,n]),Ke=x.useMemo(()=>{const je={total:d.length,working:0,idle:0,error:0};for(const Oe of d)Oe.status==="working"?je.working++:Oe.status==="error"?je.error++:Oe.status==="idle"&&je.idle++;return je},[d]),st=je=>{N(Oe=>{const Ye=new Set(Oe);return Ye.has(je)?Ye.delete(je):Ye.add(je),Ye})},ft=je=>{j(Oe=>{const Ye=new Set(Oe);return Ye.has(je)?Ye.delete(je):Ye.add(je),Ye})},wt=()=>{N(new Set(d.map(je=>je.id))),F(!0)},at=()=>{N(new Set),F(!1)},gt=x.useCallback(je=>{window.dispatchEvent(new CustomEvent("tide:open-spawn-modal",{detail:{areaId:je.id,position:{x:je.center.x,z:je.center.z}}}))},[]),ht=x.useCallback((je,Oe)=>{it({areaId:je.id,position:Oe})},[]),Gt=x.useMemo(()=>{if(!qe)return[];const je=b.get(qe.areaId);return je?[{id:"spawn-agent",label:r("common:agentBar.newAgent"),icon:"+",onClick:()=>gt(je)}]:[]},[qe,b,gt,r]),tn=x.useMemo(()=>{if(!he)return[];const je=d.find(Ye=>Ye.id===he.agentId);if(!je)return[];const Oe=C.has(je.id);return[{id:"toggle-expand",label:Oe?r("terminal:overview.collapse",{defaultValue:"Collapse"}):r("terminal:overview.expand",{defaultValue:"Expand"}),icon:Oe?"▾":"▸",onClick:()=>st(je.id)},{id:"clear-context",label:r("terminal:overview.clearContext",{defaultValue:"Clear context"}),icon:"🧹",onClick:()=>U.clearContext(je.id)},{id:"remove-agent",label:r("terminal:overview.removeAgent",{defaultValue:"Remove agent"}),icon:"🗑",danger:!0,onClick:()=>U.removeAgent(je.id)}]},[he,d,C,r]);return x.useEffect(()=>{const je=He.current;if(!je)return;const Oe=requestAnimationFrame(()=>{const Ye=je.querySelector(".aop-agent-card.active");if(!Ye)return;const Ze=je.getBoundingClientRect(),Ot=Ye.getBoundingClientRect(),Ft=Ot.top-Ze.top,Lt=je.scrollTop+Ft-(Ze.height-Ot.height)/2,Vt=Math.max(0,Lt);Math.abs(je.scrollTop-Vt)<2||(je.scrollTo({top:Vt,behavior:et.current?"smooth":"auto"}),et.current=!0)});return()=>cancelAnimationFrame(Oe)},[t]),o.jsxs("div",{className:`agent-overview-panel${ze&&ge?" mobile-filters-collapsed":""}`,children:[o.jsxs("div",{className:"aop-stats-row",children:[o.jsx("span",{className:"stat",children:r("terminal:overview.agents",{count:Ke.total})}),Ke.working>0&&o.jsxs("span",{className:"stat stat-working",children:["🟢 ",Ke.working]}),Ke.idle>0&&o.jsxs("span",{className:"stat stat-idle",children:["💤 ",Ke.idle]}),Ke.error>0&&o.jsxs("span",{className:"stat stat-error",children:["🔴 ",Ke.error]}),o.jsxs("div",{className:"aop-row-controls",children:[o.jsx("button",{type:"button",className:"aop-search-toggle",onClick:()=>{Te(!1),requestAnimationFrame(()=>{var je;return(je=ie.current)==null?void 0:je.focus()})},title:"Search agents",children:"🔍"}),o.jsx("button",{type:"button",className:`aop-filters-toggle${ge?" collapsed":""}`,onClick:()=>Te(je=>!je),title:ge?"Show filters":"Hide filters",children:ge?"Filters":"Hide filters"}),o.jsxs("select",{value:_,onChange:je=>M(je.target.value),className:"filter-select",children:[o.jsx("option",{value:"all",children:r("terminal:overview.allStatus")}),o.jsx("option",{value:"working",children:r("terminal:overview.statusLabels.working")}),o.jsx("option",{value:"idle",children:r("terminal:overview.statusLabels.idle")}),o.jsx("option",{value:"error",children:r("terminal:overview.statusLabels.error")})]}),o.jsxs("select",{value:I,onChange:je=>O(je.target.value),className:"filter-select",children:[o.jsx("option",{value:"recent",children:r("terminal:overview.mostRecent")}),o.jsx("option",{value:"status",children:r("terminal:overview.byStatus")}),o.jsx("option",{value:"name",children:r("terminal:overview.byName")})]}),o.jsx("input",{ref:ie,type:"text",placeholder:r("terminal:overview.searchAgents"),value:R,onChange:je=>z(je.target.value),onKeyDown:je=>{je.key==="Enter"&&(je.nativeEvent.isComposing||R.trim().length!==0&&Ie.length!==0&&(je.preventDefault(),n(Ie[0].id),z("")))},className:"search-input"}),o.jsx("button",{className:"close-btn",onClick:e,title:r("common:buttons.close"),children:"✕"})]})]}),o.jsxs("div",{className:"aop-actions",children:[o.jsx("button",{onClick:wt,className:"action-btn",title:r("common:buttons.expand"),children:r("common:buttons.expand")}),o.jsx("button",{onClick:at,className:"action-btn",title:r("common:buttons.collapse"),children:r("common:buttons.collapse")}),o.jsx("button",{onClick:()=>W(je=>!je),className:`action-btn action-btn--toggle${$?" active":""}`,title:r("terminal:overview.areas"),children:r("terminal:overview.areas")}),$&&X.length>0&&o.jsxs("div",{className:"aop-area-filter",ref:We,children:[o.jsxs("button",{className:`action-btn action-btn--toggle${se?"":" active"}`,onClick:()=>Z(je=>!je),title:"Filter areas",children:[se?"All areas":`${q.size} areas`,o.jsx("span",{className:"aop-area-filter-caret",children:Ae?"▴":"▾"})]}),Ae&&o.jsxs("div",{className:"aop-area-filter-dropdown",children:[X.length>=5&&o.jsx("div",{className:"aop-area-filter-search",children:o.jsx("input",{type:"text",placeholder:"Filter areas...",value:ce,onChange:je=>me(je.target.value),onClick:je=>je.stopPropagation(),autoFocus:!0})}),(()=>{const je=ce.toLowerCase().trim(),Oe=je?X.filter(Ze=>Ze.name.toLowerCase().includes(je)):X,Ye=!je||"unassigned".includes(je);return o.jsxs(o.Fragment,{children:[!je&&o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"aop-area-filter-option",onClick:J,children:[o.jsx("input",{type:"checkbox",checked:se,readOnly:!0}),o.jsx("span",{className:"aop-area-filter-color",style:{background:"#6272a4"}}),o.jsx("span",{children:"All"})]}),o.jsx("div",{className:"aop-area-filter-divider"})]}),Oe.map(Ze=>{const Ot=se||((q==null?void 0:q.has(Ze.id))??!1);return o.jsxs("label",{className:"aop-area-filter-option",onClick:Ft=>{Ft.preventDefault(),Se(Ze.id)},children:[o.jsx("input",{type:"checkbox",checked:Ot,readOnly:!0}),o.jsx("span",{className:"aop-area-filter-color",style:{background:Ze.color}}),o.jsx("span",{className:"aop-area-filter-name",children:Ze.name})]},Ze.id)}),Ye&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"aop-area-filter-divider"}),o.jsxs("label",{className:"aop-area-filter-option",onClick:Ze=>{Ze.preventDefault(),Se("__unassigned__")},children:[o.jsx("input",{type:"checkbox",checked:se||((q==null?void 0:q.has("__unassigned__"))??!1),readOnly:!0}),o.jsx("span",{className:"aop-area-filter-color",style:{background:"#6272a4"}}),o.jsx("span",{className:"aop-area-filter-name",children:"Unassigned"})]})]}),je&&Oe.length===0&&!Ye&&o.jsx("div",{className:"aop-area-filter-empty",children:"No matching areas"})]})})()]})]}),o.jsx("button",{onClick:()=>V(je=>!je),className:`action-btn action-btn--toggle${H?" active":""}`,title:r("terminal:overview.sameAreaOnly"),children:r("terminal:overview.sameAreaOnly")}),o.jsx("button",{onClick:()=>B(je=>!je),className:`action-btn action-btn--toggle${G?" active":""}`,title:"Subagents",children:"Subagents"}),o.jsx("button",{onClick:()=>ne(je=>!je),className:`action-btn action-btn--toggle${K?" active":""}`,title:r("terminal:overview.recentActivity"),children:"Activity"}),o.jsx("button",{onClick:()=>re(!0),className:"action-btn",title:"Bulk manage agents",children:"Bulk Manage"})]}),o.jsx("div",{className:"aop-agent-list",ref:He,children:we.length===0?o.jsx("div",{className:"aop-empty",children:d.length===0?r("terminal:overview.noAgentsDeployed"):r("terminal:overview.noAgentsMatch")}):we.map(je=>{var Ft,Lt,Vt;const Oe=((Ft=je.area)==null?void 0:Ft.id)||"__unassigned__",Ye=((Lt=je.area)==null?void 0:Lt.name)||($?r("terminal:overview.unassigned"):""),Ze=((Vt=je.area)==null?void 0:Vt.color)||"#6272a4",Ot=k.has(Oe);return o.jsxs("div",{className:"aop-area-group",children:[$&&o.jsxs("div",{className:"aop-area-header",onClick:()=>ft(Oe),style:{borderLeftColor:Ze},children:[o.jsx("span",{className:"aop-area-expand",children:Ot?"▸":"▾"}),o.jsx("span",{className:"aop-area-color",style:{background:Ze}}),o.jsx("span",{className:"aop-area-name",onContextMenu:ln=>{je.area&&(ln.preventDefault(),ln.stopPropagation(),ht(je.area,{x:ln.clientX,y:ln.clientY}))},children:Ye}),o.jsx("button",{type:"button",className:"aop-area-eye-btn",title:"Hide area",onClick:ln=>{ln.preventDefault(),ln.stopPropagation(),Se(Oe)},children:"◉"}),je.area&&o.jsx("button",{type:"button",className:"aop-area-eye-btn",title:"Edit area prompt",onClick:ln=>{ln.preventDefault(),ln.stopPropagation();const bt=je.area;S===bt.id?T(null):(E(bt.prompt||""),T(bt.id))},children:"✎"}),je.area&&(()=>{const ln=je.area;return o.jsx("button",{type:"button",className:"aop-area-add-btn",title:r("common:agentBar.newAgent"),onClick:bt=>{bt.preventDefault(),bt.stopPropagation();const rt=bt.currentTarget.getBoundingClientRect();ht(ln,{x:rt.left,y:rt.bottom+6})},children:"+"})})(),o.jsx("span",{className:"aop-area-count",children:je.agents.length})]}),S===Oe&&je.area&&o.jsxs("div",{className:"aop-area-prompt-editor",onClick:ln=>ln.stopPropagation(),children:[o.jsx("textarea",{className:"aop-area-prompt-textarea",value:D,onChange:ln=>E(ln.target.value),placeholder:"System prompt for agents in this area...",rows:3,autoFocus:!0}),o.jsxs("div",{className:"aop-area-prompt-actions",children:[o.jsx("button",{className:"aop-area-prompt-save",onClick:()=>{U.updateArea(je.area.id,{prompt:D}),T(null)},children:"Save"}),o.jsx("button",{className:"aop-area-prompt-cancel",onClick:()=>T(null),children:"Cancel"})]})]}),(!$||!Ot)&&o.jsx("div",{className:$?"aop-area-content":void 0,children:Fe(je.agents)})]},Oe)})}),o.jsx(Do,{isOpen:qe!==null,position:(qe==null?void 0:qe.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Gt,onClose:()=>it(null)}),o.jsx(Do,{isOpen:he!==null,position:(he==null?void 0:he.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:tn,onClose:()=>Be(null)}),o.jsx(A5,{isOpen:ee,onClose:()=>re(!1)})]})}function E5({agent:t,isActive:e,isExpanded:n,isMobile:s,hasPendingRead:a,isTwoFingerHovered:r,showSubagents:i,showRecentActivity:c,showAreaChip:d,toolExecs:f,subagents:h,areaInfo:m,matchContext:b,onToggle:y,onSelect:w,onClearContext:C,onContextMenu:N}){const{t:k}=dt(["terminal","common"]),j=dr(),S=fr(t.class,j),T=t.isBoss||t.class==="boss",D=j5[t.status]||"❓",E=zA[t.status]?k(`terminal:${zA[t.status]}`):t.status,I=f.slice(0,s?4:8),O=N5(t.id),_=T5(t.id),M=s?40:80,R=x.useMemo(()=>{var He,et,ct,fe,X,se,Se;const ie=[],de=new Set;for(const J of h)ie.push({id:J.id,name:J.name,type:J.subagentType,description:J.description,status:J.status,timestamp:J.startedAt}),de.add(J.name);for(const J of f){if(J.toolName!=="Task"&&J.toolName!=="Agent")continue;const Re=((He=J.toolInput)==null?void 0:He.description)||((et=J.toolInput)==null?void 0:et.name)||""||((fe=(ct=J.toolInput)==null?void 0:ct.prompt)==null?void 0:fe.slice(0,40))||"Task";de.has(Re)||(de.add(Re),ie.push({id:`task-${J.timestamp}`,name:Re,type:((X=J.toolInput)==null?void 0:X.subagent_type)||"unknown",description:(Se=(se=J.toolInput)==null?void 0:se.prompt)==null?void 0:Se.slice(0,100),status:"completed",timestamp:J.timestamp}))}return ie.sort((J,pe)=>pe.timestamp-J.timestamp),ie},[h,f]),z=R.filter(ie=>ie.status==="working"||ie.status==="spawning"),$=i&&R.length>0,W=c&&I.length>0,L=$||W,F=t.contextLimit>0?t.contextUsed/t.contextLimit:0,H=Math.min(100,F*100),V=Math.min(1,Math.max(0,F)),B=`hsl(${Math.round((1-V)*120)} 80% 45% / 0.55)`,K=112,ne=56,[q,xe]=x.useState(0),[Ae,Z]=x.useState(!1),[ce,me]=x.useState(!1),ee=x.useRef(0),re=x.useRef(0),We=x.useRef(0),ze=x.useRef(!1),Pe=x.useRef(!1),ge=x.useRef(!1);x.useEffect(()=>{s||(xe(0),Z(!1),me(!1))},[s]);const Te=x.useCallback(()=>{if(ge.current){ge.current=!1;return}if(Ae){xe(0),Z(!1),ge.current=!0;return}w()},[w,Ae]),qe=x.useCallback(ie=>{if(!s||ie.touches.length!==1)return;const de=ie.touches[0];ee.current=de.clientX,re.current=de.clientY,We.current=Ae?K:0,ze.current=!1,Pe.current=!1,me(!0)},[s,Ae]),it=x.useCallback(ie=>{if(!s||!ce||ie.touches.length!==1)return;const de=ie.touches[0],He=de.clientX-ee.current,et=de.clientY-re.current;if(!ze.current){if(Math.abs(He)<8&&Math.abs(et)<8)return;ze.current=!0,Pe.current=Math.abs(He)>Math.abs(et)}if(!Pe.current)return;ie.preventDefault();const ct=Math.max(0,Math.min(K,We.current-He));xe(ct)},[s,ce]),he=x.useCallback(()=>{if(!s||!ce)return;if(me(!1),!Pe.current){Ae||xe(0);return}const ie=q>=ne,de=ie!==Ae||q!==(ie?K:0);Z(ie),xe(ie?K:0),de&&(ge.current=!0)},[s,ce,q,Ae]),Be=x.useCallback(ie=>{ie.stopPropagation(),C(),Z(!1),xe(0),ge.current=!0},[C]);return o.jsxs("div",{className:`aop-agent-swipe${s?" swipe-enabled":""}${Ae?" revealed":""}`,children:[s&&o.jsxs("button",{type:"button",className:"aop-swipe-clear-action",onClick:Be,title:k("terminal:overview.clearContext",{defaultValue:"Clear context"}),children:["🧹 ",k("terminal:overview.clearContext",{defaultValue:"Clear"})]}),o.jsxs("div",{className:`aop-agent-card ${T?"boss":""} ${e?"active":""} ${t.status} ${a?"unread":""}${r?" two-finger-hover":""}`,"data-agent-id":t.id,onClick:Te,onTouchStart:qe,onTouchMove:it,onTouchEnd:he,onTouchCancel:he,style:s?{transform:`translateX(-${q}px)`,transition:ce?"none":"transform 0.18s ease"}:void 0,children:[o.jsxs("div",{className:"aop-agent-header",onContextMenu:ie=>{ie.preventDefault(),ie.stopPropagation(),N({x:ie.clientX,y:ie.clientY})},children:[o.jsx("button",{type:"button",className:"aop-expand-icon","aria-label":n?"Collapse agent":"Expand agent",onClick:ie=>{ie.stopPropagation(),y()},children:n?"▾":"▸"}),o.jsx("span",{className:"aop-agent-status",title:E,children:D}),t.status==="working"&&o.jsx("span",{className:"aop-working-indicator","aria-label":k("terminal:overview.statusLabels.working"),title:k("terminal:overview.statusLabels.working")}),o.jsx("img",{src:t.provider==="codex"?"/assets/codex.png":"/assets/claude.png",alt:t.provider,className:"aop-provider-icon",title:t.provider==="codex"?"Codex Agent":"Claude Agent"}),o.jsxs("span",{className:"aop-agent-name",title:k("terminal:overview.clickToSwitch"),style:m?{background:`${m.color}12`,borderColor:`${m.color}28`}:void 0,children:[T&&o.jsx("span",{className:"aop-boss-crown","aria-hidden":"true",children:"👑"}),t.name]}),o.jsx("span",{className:"aop-agent-class-icon",style:{color:`color-mix(in srgb, ${S.color} 60%, var(--text-muted))`},title:t.class||"agent",children:S.icon}),a&&o.jsx("span",{className:"aop-pending-read-indicator",title:"Pending read",children:"!"}),_>0&&o.jsx("span",{className:"aop-msg-count",title:k("terminal:overview.messages",{count:_}),children:_}),z.length>0&&o.jsxs("span",{className:"aop-subagent-count",title:z.map(ie=>`${ie.name}: ${ie.description||ie.type}`).join(`
|
|
143
|
+
`),children:["⑂",z.length]}),R.length>0&&z.length===0&&o.jsxs("span",{className:"aop-subagent-count",title:k("terminal:overview.subagentsCompleted",{count:R.length}),style:{opacity:.5},children:["⑂",R.length]}),t.class&&o.jsx("span",{className:"aop-agent-class",style:{color:`color-mix(in srgb, ${S.color} 65%, var(--text-muted))`,background:`${S.color}10`,borderColor:`${S.color}25`},children:t.class}),d&&m&&o.jsx("span",{className:"aop-area-chip",style:{background:`${m.color}10`,borderColor:`${m.color}25`,color:`color-mix(in srgb, ${m.color} 65%, var(--text-muted))`},children:m.name})]}),t.taskLabel&&o.jsxs("div",{className:"aop-task-label",title:t.taskLabel,children:[o.jsx("span",{className:"task-prefix",children:"📋"}),o.jsx("span",{className:"task-text",children:Kf(t.taskLabel,M)})]}),O&&(n||O.isUserPrompt)&&o.jsxs("div",{className:`aop-last-message ${O.isUserPrompt?"user":"assistant"}`,title:O.text.split(`
|
|
144
|
+
`)[0],children:[o.jsx("span",{className:"lm-prefix",children:O.isUserPrompt?"▶":"◀"}),o.jsx("span",{className:"lm-text",children:Kf(O.text,M)}),o.jsx("span",{className:"lm-time",children:Fp(O.timestamp)})]}),b&&o.jsxs("div",{className:`aop-match-context aop-match-context--${b.type}`,title:b.text,children:[o.jsx("span",{className:"match-icon",children:b.type==="history"?"📜":b.type==="file"?"📄":"💬"}),o.jsx("span",{className:"match-label",children:b.type==="history"?"history":b.type==="file"?"file":"task"}),o.jsx("span",{className:"match-text",children:Kf(b.text,M)})]}),n&&o.jsxs("div",{className:"aop-agent-body",children:[$&&o.jsxs("div",{className:"aop-subagents",children:[o.jsx("div",{className:"aop-section-label",children:k("terminal:overview.subagents",{count:R.length})}),R.map(ie=>o.jsxs("div",{className:`aop-subagent-item ${ie.status}`,children:[o.jsx("span",{className:"sub-icon",children:ie.status==="completed"?"✅":ie.status==="failed"?"❌":ie.status==="unknown"?"⬜":"⑂"}),o.jsx("span",{className:"sub-name",children:ie.name}),o.jsx("span",{className:"sub-type",children:ie.type}),ie.description&&o.jsx("span",{className:"sub-desc",title:ie.description,children:Kf(ie.description,s?30:50)})]},ie.id))]}),W&&o.jsxs("div",{className:"aop-tool-timeline",children:[o.jsx("div",{className:"aop-section-label",children:k("terminal:overview.recentActivity")}),I.map((ie,de)=>{var et,ct;const He=ie.toolInput&&(ie.toolInput.file_path||((et=ie.toolInput.command)==null?void 0:et.slice(0,40))||ie.toolInput.pattern||ie.toolInput.description||((ct=ie.toolInput.prompt)==null?void 0:ct.slice(0,50)))||"";return o.jsxs("div",{className:"aop-timeline-entry",children:[o.jsx("span",{className:"tl-time",children:Fp(ie.timestamp)}),o.jsx("span",{className:"tl-icon",children:fs[ie.toolName]||fs.default}),o.jsx("span",{className:"tl-tool",children:ie.toolName}),He&&o.jsx("span",{className:"tl-param",children:He})]},`${ie.timestamp}-${de}`)})]}),!L&&(i||c)&&o.jsx("div",{className:"aop-no-activity",children:k("terminal:overview.noToolActivity")})]}),t.contextLimit>0&&o.jsx("div",{className:"aop-context-bar",title:`${Math.round(F*100)}% context used (${Math.round(t.contextUsed/1e3)}k / ${Math.round(t.contextLimit/1e3)}k)`,children:o.jsx("div",{className:"aop-context-fill",style:{width:`${H}%`,backgroundColor:B}})})]})]})}const M5={running:"🟢",stopped:"⚫",error:"🔴",unknown:"❓",starting:"🟡",stopping:"🟠"};function Nb(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(0)}KB`:t<1024*1024*1024?`${(t/1024/1024).toFixed(0)}MB`:`${(t/1024/1024/1024).toFixed(1)}GB`}function $A(t){const e=t.replace(/\/$/,"").split("/");return e.length<=2?t:`.../${e.slice(-2).join("/")}`}function Tb(t){const e=window.location.protocol,n=window.location.hostname;return`${e}//${n}:${t}`}function D5({agentId:t,onClose:e}){const{t:n}=dt(["terminal","common"]),s=Hx(),a=ur(),[r,i]=x.useState(null),c=x.useMemo(()=>U.getAreaForAgent(t),[t,a]),d=x.useMemo(()=>{if(!c)return[];const k=[];for(const j of s.values())U.isPositionInArea(j.position,c)&&k.push(j);return k.sort((j,S)=>j.status==="running"&&S.status!=="running"?-1:j.status!=="running"&&S.status==="running"?1:j.name.localeCompare(S.name)),k},[c,s]),f=x.useCallback(k=>{U.selectBuilding(k),window.dispatchEvent(new CustomEvent("tide:building-action",{detail:{buildingId:k}}))},[]),h=x.useCallback((k,j)=>{U.sendBuildingCommand(k,j)},[]),m=x.useCallback((k,j)=>{k.preventDefault(),k.stopPropagation(),i({buildingId:j,position:{x:k.clientX,y:k.clientY}})},[]),b=x.useCallback(()=>{i(null)},[]),y=x.useCallback(()=>{if(!c)return{x:0,z:0};const k=()=>(Math.random()-.5)*2;return{x:c.center.x+k(),z:c.center.z+k()}},[c]),w=x.useCallback(()=>{if(!c)return;const k=y();window.dispatchEvent(new CustomEvent("tide:building-create",{detail:{position:k}}))},[c,y]),C=x.useMemo(()=>{var E;if(!r)return[];const k=U.getState().buildings.get(r.buildingId);if(!k)return[];const j=[],S=k.type==="server"||k.type==="docker"||k.type==="terminal",T=k.status==="running",D=k.type==="boss";if(j.push({id:"open",label:k.type==="database"?"Open Database":k.type==="folder"?"Open Folder":k.type==="boss"?"View Boss Logs":k.type==="terminal"?"Open Terminal":k.type==="server"&&((E=k.pm2)!=null&&E.enabled)?"View PM2 Logs":"Open",icon:k.type==="database"?"🗄️":k.type==="folder"?"📁":k.type==="terminal"?"💻":"👁️",onClick:()=>f(k.id)}),S&&(T||j.push({id:"start",label:"Start",icon:"▶",onClick:()=>U.sendBuildingCommand(k.id,"start")}),T&&(j.push({id:"restart",label:"Restart",icon:"🔄",onClick:()=>U.sendBuildingCommand(k.id,"restart")}),j.push({id:"stop",label:"Stop",icon:"⏹",onClick:()=>U.sendBuildingCommand(k.id,"stop")}))),D&&k.subordinateBuildingIds&&k.subordinateBuildingIds.length>0&&(j.push({id:"start-all",label:"Start All Subordinates",icon:"🚀",onClick:()=>{for(const I of k.subordinateBuildingIds)U.sendBuildingCommand(I,"start")}}),j.push({id:"stop-all",label:"Stop All Subordinates",icon:"⏸️",onClick:()=>{for(const I of k.subordinateBuildingIds)U.sendBuildingCommand(I,"stop")}}),j.push({id:"restart-all",label:"Restart All Subordinates",icon:"♻️",onClick:()=>{for(const I of k.subordinateBuildingIds)U.sendBuildingCommand(I,"restart")}})),S&&j.push({id:"health-check",label:"Health Check",icon:"🩺",onClick:()=>U.sendBuildingCommand(k.id,"healthCheck")}),j.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),j.push({id:"edit",label:"Edit Building",icon:"✏️",onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:k.id}}))}}),j.push({id:"clone",label:"Clone Building",icon:"📋",onClick:()=>{const I=y();U.createBuilding({name:`${k.name} (Copy)`,type:k.type,style:k.style,color:k.color,scale:k.scale,position:I,cwd:k.cwd,folderPath:k.folderPath,commands:k.commands,pm2:k.pm2,docker:k.docker,database:k.database,terminal:k.terminal,urls:k.urls,subordinateBuildingIds:k.subordinateBuildingIds})}}),k.urls&&k.urls.length>0)for(const I of k.urls)j.push({id:`url-${I.label}`,label:I.label,icon:"🔗",onClick:()=>window.open(I.url,"_blank","noopener,noreferrer")});return j.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),j.push({id:"delete",label:"Delete Building",icon:"🗑️",danger:!0,onClick:()=>U.deleteBuilding(k.id)}),j},[r,s,f,y]),N=x.useCallback(k=>{const j=[];if(k.pm2Status){const S=k.pm2Status;S.ports&&S.ports.length>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Ports"}),o.jsx("span",{className:"detail-value detail-ports",children:S.ports.map((T,D)=>o.jsxs("a",{className:"guake-building-port-link",href:Tb(T),target:"_blank",rel:"noopener noreferrer",onClick:E=>E.stopPropagation(),title:`Open :${T} in browser`,children:[":",T,D<S.ports.length-1?" ":""]},T))})]},"pm2-ports"))}if(k.dockerStatus){const S=k.dockerStatus,T=[];if(S.status&&T.push(o.jsx("span",{className:"detail-value",children:S.status},"st")),S.health&&S.health!=="none"){const D=S.health==="healthy"?"detail-ok":S.health==="unhealthy"?"detail-err":"";T.push(o.jsx("span",{className:`detail-value ${D}`,children:S.health},"h"))}if(S.memory!==void 0){const D=S.memoryLimit?`${Nb(S.memory)}/${Nb(S.memoryLimit)}`:Nb(S.memory);T.push(o.jsx("span",{className:"detail-value",children:D},"mem"))}S.cpu!==void 0&&T.push(o.jsxs("span",{className:"detail-value",children:[S.cpu.toFixed(1),"%"]},"cpu")),T.length>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Docker"}),T]},"docker")),S.image&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Image"}),o.jsx("span",{className:"detail-value detail-mono",children:S.image})]},"docker-img")),S.ports&&S.ports.length>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Ports"}),o.jsx("span",{className:"detail-value detail-ports",children:S.ports.map((D,E)=>o.jsxs("a",{className:"guake-building-port-link",href:Tb(D.host),target:"_blank",rel:"noopener noreferrer",onClick:I=>I.stopPropagation(),title:`Open :${D.host} in browser`,children:[D.host,":",D.container,E<S.ports.length-1?" ":""]},`${D.host}-${D.container}`))})]},"docker-ports")),S.services&&S.services.length>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Services"}),o.jsxs("span",{className:"detail-value",children:[S.services.length," svc"]})]},"docker-svc"))}if(k.type==="database"&&k.database){const S=k.database,T=S.activeConnectionId?S.connections.find(D=>D.id===S.activeConnectionId):S.connections[0];T&&(j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:T.engine.toUpperCase()}),o.jsxs("span",{className:"detail-value detail-mono",children:[T.host,":",T.port]})]},"db-conn")),(S.activeDatabase||T.database)&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"DB"}),o.jsx("span",{className:"detail-value",children:S.activeDatabase||T.database})]},"db-name"))),S.connections.length>1&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Connections"}),o.jsx("span",{className:"detail-value",children:S.connections.length})]},"db-count"))}if(k.type==="boss"&&k.subordinateBuildingIds&&k.subordinateBuildingIds.length>0){const S=k.subordinateBuildingIds;let T=0,D=0;for(const I of S){const O=s.get(I);(O==null?void 0:O.status)==="running"&&T++,(O==null?void 0:O.status)==="error"&&D++}const E=[];E.push(`${T}/${S.length} up`),D>0&&E.push(`${D} err`),j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Subs"}),o.jsx("span",{className:`detail-value ${D>0?"detail-err":T===S.length?"detail-ok":""}`,children:E.join(", ")})]},"boss-subs"))}if(k.terminalStatus){const S=k.terminalStatus;j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Terminal"}),o.jsx("span",{className:"detail-value detail-ports",children:S.port?o.jsxs("a",{className:"guake-building-port-link",href:Tb(S.port),target:"_blank",rel:"noopener noreferrer",onClick:T=>T.stopPropagation(),title:`Open :${S.port} in browser`,children:[":",S.port]}):o.jsx("span",{children:"—"})})]},"terminal")),S.tmuxSession&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Session"}),o.jsx("span",{className:"detail-value detail-mono",children:S.tmuxSession})]},"terminal-session"))}return k.type==="folder"&&k.folderPath&&(j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Path"}),o.jsx("span",{className:"detail-value detail-mono",title:k.folderPath,children:$A(k.folderPath)})]},"folder-path")),k.gitChangesCount!==void 0&&k.gitChangesCount>0&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Git"}),o.jsxs("span",{className:"detail-value detail-warn",children:[k.gitChangesCount," changes"]})]},"folder-git"))),k.cwd&&k.type!=="folder"&&!k.pm2Status&&!k.dockerStatus&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label",children:"Dir"}),o.jsx("span",{className:"detail-value detail-mono",title:k.cwd,children:$A(k.cwd)})]},"cwd")),k.lastError&&k.status==="error"&&j.push(o.jsxs("div",{className:"guake-building-detail",children:[o.jsx("span",{className:"detail-label detail-err",children:"Err"}),o.jsx("span",{className:"detail-value detail-err detail-ellipsis",title:k.lastError,children:k.lastError.length>40?k.lastError.slice(0,40)+"...":k.lastError})]},"error")),j},[s]);return o.jsxs("div",{className:"guake-buildings-panel",children:[o.jsxs("div",{className:"guake-buildings-header",children:[o.jsxs("div",{className:"guake-buildings-title",children:[o.jsx("span",{className:"guake-buildings-icon",children:"🏗️"}),o.jsx("span",{children:(c==null?void 0:c.name)||n("terminal:buildings.title",{defaultValue:"Buildings"})}),o.jsx("span",{className:"guake-buildings-count",children:d.length})]}),o.jsxs("div",{className:"guake-buildings-header-actions",children:[c&&o.jsx("button",{className:"guake-buildings-add",onClick:w,title:"Add building to area",children:"+"}),o.jsx("button",{className:"guake-buildings-close",onClick:e,title:n("common:buttons.close"),children:"✕"})]})]}),o.jsx("div",{className:"guake-buildings-body",children:c?d.length===0?o.jsx("div",{className:"guake-buildings-empty",children:n("terminal:buildings.noBuildings",{defaultValue:"No buildings in this area"})}):d.map(k=>{var E,I;const j=yL[k.type],S=M5[k.status]||"❓",T=k.type==="server"||k.type==="docker"||k.type==="terminal",D=k.status==="running";return o.jsxs("div",{className:`guake-building-item ${k.status}`,onClick:()=>f(k.id),onContextMenu:O=>m(O,k.id),children:[o.jsxs("div",{className:"guake-building-row",children:[o.jsx("span",{className:"guake-building-type-icon",title:j.description,children:j.icon}),o.jsx("span",{className:"guake-building-name",children:k.name}),o.jsx("span",{className:"guake-building-status",title:k.status,children:S})]}),N(k),k.urls&&k.urls.length>0&&o.jsx("div",{className:"guake-building-urls",children:k.urls.map((O,_)=>o.jsxs("a",{className:"guake-building-link",href:O.url,target:"_blank",rel:"noopener noreferrer",onClick:M=>M.stopPropagation(),children:["🔗 ",O.label]},_))}),T&&o.jsxs("div",{className:"guake-building-actions",children:[!D&&o.jsx("button",{className:"guake-building-action start",onClick:O=>{O.stopPropagation(),h(k.id,"start")},title:"Start",children:"▶"}),D&&o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"guake-building-action restart",onClick:O=>{O.stopPropagation(),h(k.id,"restart")},title:"Restart",children:"🔄"}),o.jsx("button",{className:"guake-building-action stop",onClick:O=>{O.stopPropagation(),h(k.id,"stop")},title:"Stop",children:"⏹"}),k.type==="terminal"&&((E=k.terminalStatus)==null?void 0:E.url)&&o.jsx("button",{className:"guake-building-action terminal-below",onClick:O=>{O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:k.id}}))},onContextMenu:O=>{O.preventDefault(),O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:split-bottom-panel",{detail:{buildingId:k.id,type:"terminal",direction:"horizontal"}}))},title:"Open terminal below (right-click to split)",children:"⬇"}),k.type==="server"&&((I=k.pm2)==null?void 0:I.enabled)&&o.jsx("button",{className:"guake-building-action terminal-below",onClick:O=>{O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:open-bottom-pm2-logs",{detail:{buildingId:k.id}}))},onContextMenu:O=>{O.preventDefault(),O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:split-bottom-panel",{detail:{buildingId:k.id,type:"pm2-logs",direction:"horizontal"}}))},title:"Show logs below (right-click to split)",children:"📜"}),k.type==="database"&&k.database&&o.jsx("button",{className:"guake-building-action-btn",onClick:O=>{O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:open-bottom-database",{detail:{buildingId:k.id}}))},onContextMenu:O=>{O.preventDefault(),O.stopPropagation(),window.dispatchEvent(new CustomEvent("tide:split-bottom-panel",{detail:{buildingId:k.id,type:"database",direction:"horizontal"}}))},title:"Show database below (right-click to split)",children:"🗄️"})]})]})]},k.id)}):o.jsx("div",{className:"guake-buildings-empty",children:n("terminal:buildings.noArea",{defaultValue:"Agent is not in an area"})})}),o.jsx(Do,{isOpen:r!==null,position:(r==null?void 0:r.position)||{x:0,y:0},worldPosition:{x:0,z:0},actions:C,onClose:b})]})}const _b={action:"#cba6f7",wait:"#f9e2af",decision:"#89b4fa",end:"#a6e3a1"},qp={running:"#a6e3a1",paused:"#f9e2af",completed:"#89b4fa",failed:"#f38ba8",cancelled:"#6c7086"};function R5(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function O5(t){return new Date(t).toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function L5({agentId:t,onClose:e}){const[n,s]=x.useState([]),[a,r]=x.useState([]),[i,c]=x.useState(!0),[d,f]=x.useState(null),h=x.useRef(null),m=x.useCallback(async()=>{try{const[k,j]=await Promise.all([Bt(Rt("/api/workflows/definitions")),Bt(Rt("/api/workflows/instances"))]);if(k.ok){const S=await k.json();s(S)}if(j.ok){const S=await j.json();r(S.instances||S||[])}}catch{}finally{c(!1)}},[]);x.useEffect(()=>(m(),h.current=setInterval(m,1e4),()=>{h.current&&clearInterval(h.current)}),[m]);const b=n.filter(k=>k.states.some(j=>{var S;return((S=j.action)==null?void 0:S.type)==="agent_task"&&j.action.agentId===t})),y=new Set(b.map(k=>k.id)),w=a.filter(k=>y.has(k.workflowDefId)||k.agentId===t).sort((k,j)=>k.status==="running"&&j.status!=="running"?-1:j.status==="running"&&k.status!=="running"?1:j.updatedAt-k.updatedAt);x.useEffect(()=>{if(w.length===0){f(null);return}w.find(j=>j.id===d)||f(w[0].id)},[w,d]);const C=w.find(k=>k.id===d)??null,N=C?n.find(k=>k.id===C.workflowDefId)??null:null;return o.jsxs("div",{className:"guake-git-panel",children:[o.jsxs("div",{className:"guake-git-header",children:[o.jsxs("div",{className:"guake-git-title",children:[o.jsx("span",{style:{padding:"0 12px",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:"Workflow"}),w.length>0&&o.jsx("span",{style:mt.headerBadge,children:w.length})]}),o.jsxs("div",{className:"guake-git-header-actions",children:[o.jsx("button",{className:"guake-git-refresh",onClick:m,title:"Refresh",disabled:i,children:i?"⏳":"↻"}),o.jsx("button",{className:"guake-git-close",onClick:e,title:"Close",children:"×"})]})]}),o.jsxs("div",{className:"guake-git-body",style:{display:"flex",flexDirection:"column",gap:0},children:[i&&w.length===0&&o.jsx("div",{style:mt.emptyState,children:o.jsx("span",{style:mt.loadingText,children:"Loading workflows..."})}),!i&&w.length===0&&o.jsxs("div",{style:mt.emptyState,children:[o.jsx("span",{style:mt.emptyIcon,children:"⊘"}),o.jsx("span",{children:"No workflow instances for this agent"})]}),w.length>0&&o.jsx("div",{style:mt.instanceList,children:w.map(k=>{const j=k.id===d,S=n.find(D=>D.id===k.workflowDefId),T=S==null?void 0:S.states.find(D=>D.id===k.currentStateId);return o.jsxs("button",{onClick:()=>f(k.id),style:{...mt.instanceRow,...j?mt.instanceRowSelected:{}},children:[o.jsxs("div",{style:mt.instanceRowTop,children:[o.jsx("span",{style:{...mt.statusDot,backgroundColor:qp[k.status]||"#6c7086"}}),o.jsx("span",{style:mt.instanceName,children:k.workflowName}),o.jsx("span",{style:{...mt.instanceStatus,color:qp[k.status]||"#6c7086"},children:k.status})]}),o.jsxs("div",{style:mt.instanceRowBottom,children:[o.jsx("span",{style:mt.instanceState,children:(T==null?void 0:T.name)||k.currentStateId}),o.jsx("span",{style:mt.instanceTime,children:O5(k.updatedAt)})]})]},k.id)})}),C&&N&&o.jsx(I5,{definition:N,instance:C,onRefresh:m})]})]})}function I5({definition:t,instance:e,onRefresh:n}){const s=t.states.find(i=>i.id===e.currentStateId),[a,r]=x.useState("states");return o.jsxs("div",{style:mt.instanceView,children:[o.jsxs("div",{style:mt.statusBar,children:[o.jsx("span",{style:{...mt.statusBadge,color:qp[e.status]||"#6c7086",borderColor:qp[e.status]||"#6c7086"},children:e.status}),o.jsxs("span",{style:mt.currentLabel,children:["Current: ",o.jsx("strong",{children:(s==null?void 0:s.name)||e.currentStateId})]})]}),o.jsx(P5,{definition:t,instance:e,onRefresh:n}),o.jsx("div",{style:mt.tabs,children:["states","timeline","variables"].map(i=>o.jsx("button",{onClick:()=>r(i),style:{...mt.tab,...a===i?mt.tabActive:{}},children:i==="states"?"States":i==="timeline"?"Timeline":"Variables"},i))}),o.jsxs("div",{style:mt.tabContent,children:[a==="states"&&o.jsx(B5,{definition:t,currentStateId:e.currentStateId}),a==="timeline"&&o.jsx(F5,{definition:t,instance:e}),a==="variables"&&o.jsx(z5,{variables:e.variables})]})]})}function P5({definition:t,instance:e,onRefresh:n}){const[s,a]=x.useState([]),[r,i]=x.useState(!1),[c,d]=x.useState(null),[f,h]=x.useState(null),m=x.useCallback(async()=>{if(e.status!=="running"){a([]);return}i(!0);try{const y=await Bt(Rt(`/api/workflows/instances/${e.id}/available-transitions`));if(y.ok){const C=((await y.json()).transitions||[]).map(N=>{const k=t.states.find(j=>j.id===N.targetStateId);return{...N,targetStateName:k==null?void 0:k.name}});a(C)}}catch{}finally{i(!1)}},[e.id,e.status,t]);x.useEffect(()=>{m()},[m,e.currentStateId]);const b=x.useCallback(async y=>{d(y),h(null);try{const w=await Bt(Rt(`/api/workflows/instances/${e.id}/transition`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetStateId:y,reason:"Transitioned via UI panel"})});if(w.ok)setTimeout(()=>{m(),n()},500);else{const C=await w.json().catch(()=>({error:"Transition failed"}));h(C.error||"Transition failed")}}catch{h("Network error")}finally{d(null)}},[e.id,m,n]);return e.status!=="running"?null:r&&s.length===0?o.jsx("div",{style:mt.transitionSection,children:o.jsx("span",{style:mt.loadingText,children:"Loading transitions..."})}):s.length===0?null:o.jsxs("div",{style:mt.transitionSection,children:[o.jsx("div",{style:mt.transitionLabel,children:"Available Transitions"}),o.jsx("div",{style:mt.transitionButtons,children:s.map(y=>o.jsxs("button",{onClick:()=>b(y.targetStateId),disabled:c!==null,style:{...mt.transitionBtn,opacity:c===y.targetStateId?.6:1},title:`${y.name} → ${y.targetStateName||y.targetStateId}`,children:[c===y.targetStateId?"...":y.name,o.jsxs("span",{style:mt.transitionArrow,children:["→"," ",y.targetStateName||y.targetStateId]})]},y.id))}),f&&o.jsx("div",{style:mt.transitionError,children:f})]})}function B5({definition:t,currentStateId:e}){return o.jsx("div",{style:mt.stateList,children:t.states.map(n=>{const s=n.id===e;return o.jsxs("div",{style:{...mt.stateItem,...s?mt.stateItemCurrent:{}},children:[o.jsxs("div",{style:mt.stateHeader,children:[o.jsx("span",{style:{...mt.stateTypeBadge,backgroundColor:`${_b[n.type]}22`,color:_b[n.type],borderColor:`${_b[n.type]}44`},children:n.type}),o.jsx("span",{style:mt.stateName,children:n.name}),s&&o.jsx("span",{style:mt.currentBadge,children:"CURRENT"})]}),n.description&&o.jsx("div",{style:mt.stateDescription,children:n.description}),n.transitions.length>0&&o.jsx("div",{style:mt.stateTransitions,children:n.transitions.map(a=>{var r;return o.jsxs("span",{style:mt.transitionChip,children:[a.name," ","→"," ",((r=t.states.find(i=>i.id===a.targetStateId))==null?void 0:r.name)||a.targetStateId]},a.id)})})]},n.id)})})}function F5({definition:t,instance:e}){return!e.history||e.history.length===0?o.jsx("div",{style:mt.emptyState,children:"No timeline events yet"}):o.jsx("div",{style:mt.timeline,children:(e.history??[]).map((n,s)=>{const a=t.states.find(i=>i.id===n.toStateId),r=n.fromStateId?t.states.find(i=>i.id===n.fromStateId):null;return o.jsxs("div",{style:mt.timelineEntry,children:[o.jsx("div",{style:mt.timelineDot}),o.jsxs("div",{style:mt.timelineContent,children:[o.jsxs("div",{style:mt.timelineHeader,children:[o.jsx("span",{style:mt.timelineTime,children:R5(n.timestamp)}),n.transitionName&&o.jsxs("span",{style:mt.timelineTransition,children:["via ",n.transitionName]})]}),o.jsxs("div",{style:mt.timelineStates,children:[r&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:mt.timelineStateName,children:r.name}),o.jsx("span",{style:mt.timelineArrow,children:"→"})]}),o.jsx("span",{style:{...mt.timelineStateName,fontWeight:600},children:(a==null?void 0:a.name)||n.toStateId})]}),n.details&&o.jsx("div",{style:mt.timelineDetails,children:n.details})]})]},s)})})}function z5({variables:t}){const e=Object.entries(t);if(e.length===0)return o.jsx("div",{style:mt.emptyState,children:"No variables set"});const n=e.filter(([a])=>!a.startsWith("wi_")),s=e.filter(([a])=>a.startsWith("wi_"));return o.jsxs("div",{style:mt.variablesSection,children:[n.length>0&&o.jsxs("div",{style:mt.varGroup,children:[o.jsx("div",{style:mt.varGroupLabel,children:"Variables"}),n.map(([a,r])=>o.jsxs("div",{style:mt.varRow,children:[o.jsx("span",{style:mt.varKey,children:a}),o.jsx("span",{style:mt.varValue,children:typeof r=="object"?JSON.stringify(r):String(r??"")})]},a))]}),s.length>0&&o.jsxs("div",{style:mt.varGroup,children:[o.jsx("div",{style:mt.varGroupLabel,children:"Internal"}),s.map(([a,r])=>o.jsxs("div",{style:mt.varRow,children:[o.jsx("span",{style:{...mt.varKey,opacity:.6},children:a}),o.jsx("span",{style:{...mt.varValue,opacity:.6},children:typeof r=="object"?JSON.stringify(r):String(r??"")})]},a))]})]})}const mt={headerBadge:{fontSize:10,fontWeight:700,background:"var(--accent-color, #cba6f7)",color:"#1e1e2e",borderRadius:8,padding:"0 5px",marginLeft:6,minWidth:16,textAlign:"center",lineHeight:"16px"},instanceList:{display:"flex",flexDirection:"column",gap:2,padding:"4px 4px 0",maxHeight:180,overflowY:"auto",flexShrink:0,borderBottom:"1px solid var(--border-color, #313244)"},instanceRow:{display:"flex",flexDirection:"column",gap:2,padding:"5px 8px",border:"1px solid transparent",borderRadius:4,background:"transparent",cursor:"pointer",textAlign:"left",width:"100%",color:"inherit"},instanceRowSelected:{background:"rgba(203, 166, 247, 0.08)",border:"1px solid var(--accent-color, #cba6f7)"},instanceRowTop:{display:"flex",alignItems:"center",gap:6},instanceRowBottom:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:12},statusDot:{display:"inline-block",width:7,height:7,borderRadius:"50%",flexShrink:0},instanceName:{fontSize:11,fontWeight:600,color:"var(--text-primary, #cdd6f4)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},instanceStatus:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.3px",flexShrink:0},instanceState:{fontSize:10,color:"var(--text-secondary, #a6adc8)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},instanceTime:{fontSize:9,color:"var(--text-secondary, #a6adc8)",opacity:.7,flexShrink:0,whiteSpace:"nowrap"},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--text-secondary, #a6adc8)",fontSize:12},emptyIcon:{fontSize:20,opacity:.5},loadingText:{fontSize:11,color:"var(--text-secondary, #a6adc8)",fontStyle:"italic"},instanceView:{display:"flex",flexDirection:"column",flex:1,minHeight:0},statusBar:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--border-color, #313244)",flexShrink:0},statusBadge:{fontSize:10,fontWeight:700,textTransform:"uppercase",border:"1px solid",borderRadius:4,padding:"1px 6px",letterSpacing:"0.5px"},currentLabel:{fontSize:12,color:"var(--text-secondary, #a6adc8)"},transitionSection:{padding:"8px 12px",borderBottom:"1px solid var(--border-color, #313244)",flexShrink:0},transitionLabel:{fontSize:10,fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary, #a6adc8)",marginBottom:6,letterSpacing:"0.5px"},transitionButtons:{display:"flex",flexDirection:"column",gap:4},transitionBtn:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"6px 10px",border:"1px solid var(--accent-color, #cba6f7)",borderRadius:4,background:"transparent",color:"var(--accent-color, #cba6f7)",cursor:"pointer",fontSize:12,fontWeight:500,transition:"background 0.15s"},transitionArrow:{fontSize:10,opacity:.7,fontWeight:400},transitionError:{fontSize:11,color:"#f38ba8",marginTop:4},tabs:{display:"flex",borderBottom:"1px solid var(--border-color, #313244)",flexShrink:0},tab:{flex:1,padding:"6px 8px",border:"none",borderBottom:"2px solid transparent",background:"transparent",color:"var(--text-secondary, #a6adc8)",cursor:"pointer",fontSize:11,fontWeight:500,textAlign:"center"},tabActive:{color:"var(--text-primary, #cdd6f4)",borderBottomColor:"var(--accent-color, #cba6f7)"},tabContent:{flex:1,overflow:"auto",minHeight:0},stateList:{display:"flex",flexDirection:"column",gap:2,padding:4},stateItem:{padding:"6px 8px",borderRadius:4,border:"1px solid transparent"},stateItemCurrent:{border:"1px solid var(--accent-color, #cba6f7)",background:"rgba(203, 166, 247, 0.08)",boxShadow:"0 0 8px rgba(203, 166, 247, 0.15)"},stateHeader:{display:"flex",alignItems:"center",gap:6},stateTypeBadge:{fontSize:9,fontWeight:700,textTransform:"uppercase",border:"1px solid",borderRadius:3,padding:"0 4px",letterSpacing:"0.3px"},stateName:{fontSize:12,fontWeight:500,color:"var(--text-primary, #cdd6f4)"},currentBadge:{fontSize:8,fontWeight:700,color:"#cba6f7",background:"rgba(203, 166, 247, 0.15)",borderRadius:3,padding:"1px 4px",marginLeft:"auto",letterSpacing:"0.5px"},stateDescription:{fontSize:11,color:"var(--text-secondary, #a6adc8)",marginTop:3,paddingLeft:2},stateTransitions:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},transitionChip:{fontSize:9,color:"var(--text-secondary, #a6adc8)",background:"var(--surface-1, #313244)",borderRadius:3,padding:"1px 5px"},timeline:{padding:"4px 8px"},timelineEntry:{display:"flex",gap:8,paddingBottom:10,position:"relative"},timelineDot:{width:8,height:8,borderRadius:"50%",background:"var(--accent-color, #cba6f7)",flexShrink:0,marginTop:3},timelineContent:{flex:1,minWidth:0},timelineHeader:{display:"flex",alignItems:"center",gap:6,marginBottom:2},timelineTime:{fontSize:10,color:"var(--text-secondary, #a6adc8)",fontFamily:"monospace"},timelineTransition:{fontSize:10,color:"#89b4fa",fontStyle:"italic"},timelineStates:{display:"flex",alignItems:"center",gap:4,fontSize:11,color:"var(--text-primary, #cdd6f4)"},timelineStateName:{fontWeight:400},timelineArrow:{color:"var(--text-secondary, #a6adc8)",fontSize:10},timelineDetails:{fontSize:10,color:"var(--text-secondary, #a6adc8)",marginTop:2,whiteSpace:"pre-wrap",wordBreak:"break-word"},variablesSection:{padding:4},varGroup:{marginBottom:8},varGroupLabel:{fontSize:10,fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary, #a6adc8)",padding:"4px 8px",letterSpacing:"0.5px"},varRow:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:8,padding:"3px 8px",borderRadius:3},varKey:{fontSize:11,fontFamily:"monospace",color:"#cba6f7",flexShrink:0},varValue:{fontSize:11,fontFamily:"monospace",color:"var(--text-primary, #cdd6f4)",textAlign:"right",wordBreak:"break-all"}};function $5({progress:t,defaultExpanded:e=!1,onAgentClick:n,onDismiss:s,onFileClick:a,onBashClick:r}){const[i,c]=x.useState(null),d=x.useRef(t.status),f=i!==null?!i:e;x.useEffect(()=>{d.current!==t.status&&(d.current==="working"&&(t.status==="completed"||t.status==="failed")&&c(!1),d.current=t.status)},[t.status]);const h={working:"#4a9eff",completed:"#22c55e",failed:"#ef4444"},m={working:"⚙️",completed:"✅",failed:"❌"},{t:b}=dt(["tools"]),y=x.useMemo(()=>ld({onFileClick:a?j=>a(j):void 0}),[a]),w={working:b("tools:progress.workingOn"),completed:b("tools:progress.taskFinished"),failed:b("tools:progress.taskFailed")},C=t.taskDescription.length>80?t.taskDescription.slice(0,80)+"...":t.taskDescription,N=()=>{const j=t.completedAt||Date.now(),S=Math.floor((j-t.startedAt)/1e3);if(S<60)return`${S}s`;const T=Math.floor(S/60),D=S%60;return`${T}m ${D}s`},k=()=>{c(f)};return o.jsxs("div",{className:`agent-progress-indicator status-${t.status} ${f?"expanded":"collapsed"}`,children:[o.jsxs("div",{className:"agent-progress-header",onClick:k,children:[o.jsx("span",{className:"agent-progress-status-icon",style:{color:h[t.status]},children:m[t.status]}),o.jsx("span",{className:"agent-progress-agent-name",onClick:j=>{n&&(j.stopPropagation(),n(t.agentId))},children:t.agentName}),o.jsx("span",{className:"agent-progress-status-text",style:{color:h[t.status]},children:w[t.status]}),o.jsx("span",{className:"agent-progress-elapsed",children:N()}),s&&o.jsx("span",{className:"agent-progress-dismiss",title:"Dismiss",onClick:j=>{j.stopPropagation(),s(t.agentId)},children:"×"}),o.jsx("span",{className:"agent-progress-toggle",children:f?"▼":"▶"})]}),!f&&o.jsx("div",{className:"agent-progress-task-preview",children:C}),f&&o.jsxs("div",{className:"agent-progress-expanded",children:[o.jsx("div",{className:"agent-progress-task-full",children:o.jsx("div",{className:"markdown-content",children:o.jsx(Fr,{remarkPlugins:[zr],components:y,children:lp(t.taskDescription)})})}),t.output.length>0&&o.jsx("div",{className:"agent-progress-output-section",children:o.jsx(U5,{output:t.output,agentId:t.agentId,maxHeight:200,onFileClick:a,onBashClick:r})})]})]})}function U5({output:t,agentId:e,maxHeight:n=200,onFileClick:s,onBashClick:a}){const r=x.useRef(null),c=TT({outputs:t,viewMode:"simple"});return x.useEffect(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[c]),c.length===0?null:o.jsx("div",{ref:r,className:"agent-progress-output",style:{maxHeight:`${n}px`},children:c.map((d,f)=>o.jsx(Dy,{output:d,agentId:e,onFileClick:s,onBashClick:a},`progress-${f}`))})}const H5=x.memo(function(){const{t:e}=dt(["terminal"]),[n,s]=x.useState(!1),[a,r]=x.useState(()=>_y()),[i,c]=x.useState(-1),d=x.useRef(null),f=x.useRef(null),h=ia.findIndex(C=>C.id===a);x.useEffect(()=>{if(!n)return;const C=N=>{d.current&&!d.current.contains(N.target)&&s(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[n]),x.useEffect(()=>{n&&c(h)},[n,h]);const m=C=>{const N=C==="next"?(h+1)%ia.length:(h-1+ia.length)%ia.length,k=ia[N],j=Pu(k.id);Up(j),r(k.id)},b=C=>{n||(C.key==="ArrowUp"||C.key==="ArrowLeft"?(C.preventDefault(),m("prev")):C.key==="ArrowDown"||C.key==="ArrowRight"?(C.preventDefault(),m("next")):(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),s(!0)))};x.useEffect(()=>{if(!n)return;const C=N=>{var k,j;N.key==="Escape"?(s(!1),(k=f.current)==null||k.focus()):N.key==="ArrowDown"?(N.preventDefault(),c(S=>(S+1)%ia.length)):N.key==="ArrowUp"?(N.preventDefault(),c(S=>(S-1+ia.length)%ia.length)):N.key==="Enter"&&i>=0&&(N.preventDefault(),y(ia[i].id),(j=f.current)==null||j.focus())};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[n,i]);const y=C=>{const N=Pu(C);Up(N),r(C),s(!1)},w=Pu(a);return o.jsxs("div",{className:"theme-selector",ref:d,children:[o.jsxs("button",{ref:f,className:"theme-selector-trigger",onClick:()=>s(!n),onKeyDown:b,title:e("terminal:themeSelector.themeTitle",{name:w.name}),children:[o.jsx("span",{className:"theme-selector-icon",children:"🎨"}),o.jsx("span",{className:"theme-selector-name",children:w.name}),o.jsx("span",{className:"theme-selector-arrow",children:n?"▲":"▼"})]}),n&&o.jsxs("div",{className:"theme-selector-dropdown",onMouseDown:C=>C.stopPropagation(),onClick:C=>C.stopPropagation(),children:[o.jsx("div",{className:"theme-selector-header",children:e("terminal:themeSelector.selectTheme")}),o.jsx("div",{className:"theme-selector-list",children:ia.map((C,N)=>o.jsxs("button",{className:`theme-selector-option ${C.id===a?"active":""} ${N===i?"highlighted":""}`,onClick:k=>{k.stopPropagation(),y(C.id)},onMouseDown:k=>k.stopPropagation(),onMouseEnter:()=>c(N),children:[o.jsx("span",{className:"theme-option-preview",style:{background:`linear-gradient(135deg, ${C.colors.bgPrimary} 0%, ${C.colors.bgSecondary} 50%, ${C.colors.accentPurple} 100%)`}}),o.jsxs("span",{className:"theme-option-info",children:[o.jsx("span",{className:"theme-option-name",children:C.name}),o.jsx("span",{className:"theme-option-desc",children:C.description})]}),C.id===a&&o.jsx("span",{className:"theme-option-check",children:"✓"})]},C.id))})]})]})}),UA=48,W5=49,q5=50,HA=48,V5={background:"#1a1a2e",foreground:"#f8f8f2",cursor:"#f8f8f2",cursorAccent:"#1a1a2e",selectionBackground:"#44475a",black:"#21222c",red:"#ff5555",green:"#50fa7b",yellow:"#f1fa8c",blue:"#bd93f9",magenta:"#ff79c6",cyan:"#8be9fd",white:"#f8f8f2",brightBlack:"#6272a4",brightRed:"#ff6e6e",brightGreen:"#69ff94",brightYellow:"#ffffa5",brightBlue:"#d6acff",brightMagenta:"#ff92df",brightCyan:"#a4ffff",brightWhite:"#ffffff"};function Y5(t,e){let n=null;const s=(...a)=>{n&&clearTimeout(n),n=setTimeout(()=>t(...a),e)};return s.cancel=()=>{n&&clearTimeout(n)},s}const Yt=(...t)=>console.log("[TerminalEmbed]",...t);function WA(t){var e;Yt("copyToClipboard called, text:",t.slice(0,50)),Yt("navigator.clipboard available:",!!navigator.clipboard),Yt("document.hasFocus:",document.hasFocus()),(e=navigator.clipboard)!=null&&e.writeText?navigator.clipboard.writeText(t).then(()=>Yt("clipboard.writeText SUCCESS"),n=>{Yt("clipboard.writeText FAILED:",(n==null?void 0:n.message)||n),qA(t)}):(Yt("navigator.clipboard not available, using fallback"),qA(t))}function qA(t){const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();try{const n=document.execCommand("copy");Yt("execCommand fallback:",n?"SUCCESS":"FAILED")}catch(n){Yt("execCommand fallback error",n)}document.body.removeChild(e)}const Ax=x.memo(function({terminalUrl:e,visible:n}){const s=x.useRef(null),a=x.useRef(null),r=x.useRef(null),i=x.useRef(null),c=x.useRef(!1),d=x.useRef(new TextEncoder),f=x.useCallback(m=>{const b=i.current;if(!b||b.readyState!==WebSocket.OPEN)return;const y=d.current.encode(m),w=new Uint8Array(y.length+1);w[0]=HA,w.set(y,1),b.send(w)},[]),h=x.useCallback((m,b)=>{const y=i.current;!y||y.readyState!==WebSocket.OPEN||y.send("1"+JSON.stringify({columns:m,rows:b}))},[]);return x.useEffect(()=>{if(Yt("useEffect fired",{visible:n,init:c.current,hasContainer:!!s.current,terminalUrl:e}),!n||c.current||!s.current)return;c.current=!0;let m=!1,b=null,y=null,w=null,C=null,N=null,k=null;return(async()=>{Yt("Lazy-loading xterm.js modules...");const[j,S,T,D]=await Promise.all([vt(()=>import("./xterm-BqvuqXEL.js"),[]),vt(()=>import("./addon-fit-YJmn1quW.js"),[]),vt(()=>import("./addon-clipboard-Ckztrdv4.js"),[]),vt(()=>import("./addon-web-links-BWjmmSgS.js"),[])]);if(m){Yt("Destroyed after module load, aborting");return}if(await vt(()=>Promise.resolve({}),__vite__mapDeps([16])),Yt("Modules loaded, xterm exports:",Object.keys(j)),m||!s.current)return;const E=j.Terminal,I=S.FitAddon,O=T.ClipboardAddon,_=D.WebLinksAddon;b=new E({theme:V5,fontSize:13,scrollback:5e3,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Menlo', 'Monaco', 'Courier New', monospace",cursorBlink:!0,allowProposedApi:!0,disableStdin:!1,rightClickSelectsWord:!1}),a.current=b,y=new I,r.current=y,b.loadAddon(y),b.loadAddon(new O),b.loadAddon(new _),b.attachCustomKeyEventHandler(V=>!(V.ctrlKey&&V.key==="c"&&b.hasSelection()||V.ctrlKey&&V.key==="v"||V.ctrlKey&&V.shiftKey&&V.key==="C"||V.ctrlKey&&V.shiftKey&&V.key==="V"));const M=s.current.getBoundingClientRect();Yt("Container dimensions before open:",{w:M.width,h:M.height}),b.open(s.current),y.fit(),Yt("Terminal opened, cols:",b.cols,"rows:",b.rows),b.onSelectionChange(()=>{Yt(">>> onSelectionChange FIRED",{hasSelection:b.hasSelection()});const V=b.hasSelection()?b.getSelection():"";V&&(Yt("onSelectionChange copying text:",V.slice(0,50)),WA(V))}),s.current.addEventListener("mousedown",V=>{Yt("mousedown",{button:V.button,shiftKey:V.shiftKey,metaKey:V.metaKey,ctrlKey:V.ctrlKey})}),s.current.addEventListener("mouseup",V=>{Yt("mouseup",{button:V.button,shiftKey:V.shiftKey,hasSel:b.hasSelection()})}),Yt("Registering OSC 52 handler"),b.parser.registerOscHandler(52,V=>{Yt(">>> OSC 52 received",{dataLength:V.length,data:V.slice(0,80)});const G=V.split(";"),B=G.length>1?G.slice(1).join(";"):G[0];if(B)try{const K=Uint8Array.from(atob(B),q=>q.charCodeAt(0)),ne=new TextDecoder().decode(K);Yt("OSC 52 decoded:",ne.slice(0,50)),WA(ne)}catch{}return!1}),k=V=>V.preventDefault(),s.current.addEventListener("contextmenu",k),b.onData(V=>f(V)),b.onBinary(V=>{const G=i.current;if(!G||G.readyState!==WebSocket.OPEN)return;const B=new Uint8Array(V.length+1);B[0]=HA;for(let K=0;K<V.length;K++)B[K+1]=V.charCodeAt(K);G.send(B)}),C=Y5(()=>{y&&b&&(y.fit(),h(b.cols,b.rows))},100),N=new ResizeObserver(()=>C()),N.observe(s.current);const R=e.endsWith("/")?e.slice(0,-1):e,z=Yb(`${R}/token`);Yt("Fetching ttyd token from:",z);let $="";try{const V=await fetch(z);if(Yt("Token response status:",V.status,"content-type:",V.headers.get("content-type")),V.ok){const G=await V.text();Yt("Token raw response:",G);try{$=JSON.parse(G).token||""}catch{$=G.trim()}Yt("Parsed ttyd token:",$?$.slice(0,16)+"...":"(empty)")}else Yt("Token fetch failed:",V.status,V.statusText)}catch(V){Yt("Token fetch error:",V)}if(m)return;const W=window.location.protocol==="https:"?"wss:":"ws:",L=Yb(`${R}/ws`),F=`${W}//${window.location.host}${L}`;Yt("Connecting WebSocket to:",F),w=new WebSocket(F,["tty"]),w.binaryType="arraybuffer",i.current=w,w.onopen=()=>{if(Yt("WebSocket OPEN"),b&&y){y.fit();const V=JSON.stringify({AuthToken:$,columns:b.cols,rows:b.rows});Yt("Sending init message (as binary):",V),w.send(d.current.encode(V))}};let H=0;w.onmessage=V=>{if(b){if(H++,H<=5){const G=V.data instanceof ArrayBuffer?"ArrayBuffer":typeof V.data,B=V.data instanceof ArrayBuffer?V.data.byteLength:V.data.length;if(Yt(`WS message #${H}: type=${G} size=${B}`),V.data instanceof ArrayBuffer){const K=new Uint8Array(V.data).slice(0,20);Yt(` First bytes: [${Array.from(K).join(", ")}]`)}}if(V.data instanceof ArrayBuffer){const G=new Uint8Array(V.data);if(G.length<1)return;const B=G[0];B===UA?b.write(G.subarray(1)):B===W5?Yt("Received SET_TITLE"):B===q5?Yt("Received SET_PREFS:",new TextDecoder().decode(G.subarray(1))):Yt("Unknown binary cmd:",B,"char:",String.fromCharCode(B))}else typeof V.data=="string"&&(H<=5&&Yt("String message, first char code:",V.data.charCodeAt(0)),V.data.charCodeAt(0)===UA&&b.write(V.data.slice(1)))}},w.onclose=V=>{Yt("WebSocket CLOSED, code:",V.code,"reason:",V.reason,"wasClean:",V.wasClean,"totalMessages:",H),b&&!m&&b.write(`\r
|
|
145
|
+
\x1B[90m[Terminal disconnected]\x1B[0m\r
|
|
146
|
+
`)},w.onerror=V=>{Yt("WebSocket ERROR:",V)},b.onResize(({cols:V,rows:G})=>h(V,G))})(),()=>{var j;m=!0,c.current=!1,C==null||C.cancel(),N==null||N.disconnect(),k&&((j=s.current)==null||j.removeEventListener("contextmenu",k)),w&&w.readyState<=WebSocket.OPEN&&w.close(),i.current=null,b==null||b.dispose(),a.current=null,r.current=null}},[n,e,f,h]),x.useEffect(()=>{n&&r.current&&a.current&&requestAnimationFrame(()=>{var m;(m=r.current)==null||m.fit(),a.current&&h(a.current.cols,a.current.rows)})},[n,h]),o.jsx("div",{ref:s,className:"guake-bottom-terminal-embed",style:{display:n?void 0:"none"}})}),VA=1e4,G5=3e4,K5=12e4,Q5=128,X5=95;function Eb(t){const e=Ny(t);return Ty(e.userMessage).userMessage.trim().replace(/\r\n/g,`
|
|
147
|
+
`)}function Qf(t){return t.trim().replace(/\r\n/g,`
|
|
148
|
+
`)}function J5(t){return t.startsWith("Using tool:")||t.startsWith("Tool input:")||t.startsWith("Tool result:")||t.startsWith("Bash output:")||t.startsWith("Session started:")||t.startsWith("[thinking]")||t.startsWith("Tokens:")||t.startsWith("Cost:")||t.startsWith("Context (estimated from Codex turn usage):")||t.startsWith("🔄 [System]")||t.startsWith("📋 [System]")||t.startsWith("[System]")}function Z5(t,e){if(e.type==="rectangle"&&e.width&&e.height){const n=e.width/2,s=e.height/2;return t.x>=e.center.x-n&&t.x<=e.center.x+n&&t.z>=e.center.z-s&&t.z<=e.center.z+s}if(e.type==="circle"&&e.radius){const n=t.x-e.center.x,s=t.z-e.center.z;return n*n+s*s<=e.radius*e.radius}return!1}let eW=1;function Xf(){return`bp-${eW++}`}const tW=x.memo(function({buildingId:e,filterText:n,maxRetention:s}){const{streamingBuildingLogs:a}=Rs(),r=a.get(e)||"",i=x.useRef(null),c=x.useRef(!1),d=x.useRef(0),f=n.trim().toLowerCase(),h=30,m=x.useCallback(()=>{const S=i.current;if(!S)return;const T=S.scrollTop+S.clientHeight>=S.scrollHeight-h;c.current=!T},[]),b=x.useMemo(()=>Yj(r,s),[r,s]);x.useLayoutEffect(()=>{const S=i.current;if(!S)return;const T=d.current,D=S.scrollHeight;if(c.current){const E=T-D;E>0&&(S.scrollTop=Math.max(0,S.scrollTop-E))}else S.scrollTop=D;d.current=S.scrollHeight},[b,f]);const y=x.useMemo(()=>b?f?b.split(`
|
|
149
|
+
`).filter(S=>S.toLowerCase().includes(f)).join(`
|
|
150
|
+
`):b:"",[b,f]),w=x.useMemo(()=>y?y.split(`
|
|
151
|
+
`):[],[y]),C=x.useMemo(()=>w.map(S=>Kl(S||" ")),[w]),N=x.useMemo(()=>b?f&&!y?"No log lines match the current filter.":null:"Waiting for logs...",[b,f,y]),k=DN({count:C.length,getScrollElement:()=>i.current,estimateSize:()=>20,overscan:12,measureElement:S=>S.getBoundingClientRect().height}),j=k.getVirtualItems();return o.jsx("div",{ref:i,className:"guake-bottom-pm2-logs",onScroll:m,children:N?o.jsx("div",{className:"guake-bottom-pm2-logs-empty",children:N}):o.jsx("div",{className:"guake-bottom-pm2-logs-inner",style:{height:k.getTotalSize()},children:j.map(S=>o.jsx("div",{ref:k.measureElement,className:"guake-bottom-pm2-log-line","data-index":S.index,style:{transform:`translateY(${S.start}px)`},dangerouslySetInnerHTML:{__html:C[S.index]}},S.key))})})});x.memo(function({src:e,title:n}){const s=x.useRef(null),[a,r]=x.useState(!1),[i,c]=x.useState(null);x.useEffect(()=>{r(!1),c(null);const h=setTimeout(()=>c(e),400);return()=>clearTimeout(h)},[e]);const d=x.useCallback(()=>{var m;const h=s.current;if(h){document.activeElement===h&&h.blur();try{(m=h.contentWindow)==null||m.blur()}catch{}}},[]),f=x.useCallback(()=>{const h=document.querySelector(".guake-input-container"),m=h==null?void 0:h.querySelector("textarea, input");h==null||h.focus({preventScroll:!0}),m==null||m.focus({preventScroll:!0})},[]);return x.useEffect(()=>{if(!i)return;const h=Date.now(),m=()=>{Date.now()-h>1500||(d(),f())};return window.addEventListener("focus",m,!0),document.addEventListener("focusin",m,!0),()=>{window.removeEventListener("focus",m,!0),document.removeEventListener("focusin",m,!0)}},[f,d,i]),o.jsxs(o.Fragment,{children:[!a&&o.jsx("div",{className:"guake-bottom-terminal-starting",children:o.jsx("span",{children:"Loading terminal..."})}),o.jsx("iframe",{ref:s,src:i??void 0,className:`guake-bottom-terminal-iframe${a?"":" iframe-loading"}`,title:n,allow:"clipboard-read; clipboard-write",loading:"lazy",tabIndex:-1,onLoad:()=>{r(!0),d(),f()}})]})});const nW=x.memo(function({onSaveSnapshot:e}={}){var xd,Ko,ti,yd,mc;const{t:n}=dt(["terminal","common"]),s=ed(),a=$x(),r=e1(),i=Ux(),c=r1(),d=i1(),f=t1(),h=Wx(),m=qx(),b=lL(),y=!!b,w=x.useMemo(()=>b?{id:b.agentId,name:b.agentName,class:b.agentClass,status:"idle",provider:"claude",position:{x:0,y:0,z:0},cwd:b.cwd,permissionMode:"interactive",tokensUsed:0,contextUsed:0,contextLimit:2e5,taskCount:0,createdAt:b.createdAt,lastActivity:b.createdAt}:null,[b]),C=Array.from(a),k=C.length===1?C[0]:null,S=(Kj(k)||null)??(y?w:null),T=k??(y?(b==null?void 0:b.agentId)??null:null),D=!!(S!=null&&S.sessionId)&&!y,E=ur(),I=Hx(),O=x.useMemo(()=>{if(!T)return null;const Q=new Set,ue=[];for(const Ee of E.values())Ee.archived||Ee.directories.length===0||Ee.assignedAgentIds.includes(T)&&(Q.add(Ee.id),ue.push(Ee));const le=s.get(T);if(le)for(const Ee of E.values())Ee.archived||Ee.directories.length===0||Q.has(Ee.id)||Z5({x:le.position.x,z:le.position.z},Ee)&&(Q.add(Ee.id),ue.push(Ee));return ue.length===0?null:ue.flatMap(Ee=>Ee.directories.filter(nt=>nt&&nt.trim().length>0).map(nt=>({areaId:Ee.id,areaName:Ee.name,dir:nt})))},[T,E,s]),_=x.useMemo(()=>{var le;if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const Ee of I.values())Ee.type==="terminal"&&U.isPositionInArea(Ee.position,Q)&&ue.push({id:Ee.id,name:Ee.name,hasUrl:!!((le=Ee.terminalStatus)!=null&&le.url)});return ue},[T,I,E]),M=x.useMemo(()=>{var le;if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const Ee of I.values())Ee.type==="server"&&((le=Ee.pm2)!=null&&le.enabled)&&U.isPositionInArea(Ee.position,Q)&&ue.push({id:Ee.id,name:Ee.name});return ue},[T,I,E]),R=x.useMemo(()=>{if(!T)return[];const Q=U.getAreaForAgent(T);if(!Q)return[];const ue=[];for(const le of I.values())le.type==="database"&&le.database&&U.isPositionInArea(le.position,Q)&&ue.push({id:le.id,name:le.name});return ue},[T,I,E]),{branches:z,fetchRemote:$,fetchingDirs:W}=WH(O),{terminalHeight:L,terminalRef:F,handleResizeStart:H}=MH(),{mobileOverviewHeight:V,handleResizeMouseDown:G,handleResizeTouchStart:B}=OH(),K=EH(),[ne,q]=x.useState(()=>{const Q=Mx(pt.SIDE_PANEL_WIDTH,420);return Math.max(280,Math.min(700,Q))}),xe=x.useRef(null),Ae=x.useCallback((Q,ue)=>{Q.preventDefault(),xe.current={startX:Q.clientX,startW:ne},document.body.style.cursor="ew-resize",document.body.style.userSelect="none",U.setTerminalResizing(!0);let le=ne;const Ee=ut=>{if(!xe.current)return;const Nt=ut.clientX-xe.current.startX,_t=ue==="left"?-Nt:Nt;le=Math.max(280,Math.min(700,xe.current.startW+_t)),q(le)},nt=()=>{xe.current=null,document.body.style.cursor="",document.body.style.userSelect="",U.setTerminalResizing(!1),document.removeEventListener("mousemove",Ee),document.removeEventListener("mouseup",nt),Dx(pt.SIDE_PANEL_WIDTH,le)};document.addEventListener("mousemove",Ee),document.addEventListener("mouseup",nt)},[ne]),Z=Qj(T),ce=x.useMemo(()=>y&&b?b.outputs.map(Q=>({text:Q.text||"",timestamp:Q.timestamp,isStreaming:!1,isUserPrompt:!1})):Z,[y,b,Z]),me=x.useRef(null),ee=x.useRef(null),re=x.useRef(null),We=x.useRef(null),[ze,Pe]=x.useState(()=>{const Q=Fa(pt.VIEW_MODE);return Q==="simple"||Q==="chat"||Q==="advanced"?Q:Fa(pt.ADVANCED_VIEW)==="true"?"advanced":"simple"}),[ge,Te]=x.useState(()=>Ni(pt.TERMINAL_FULLSCREEN,!1)),[qe,it]=x.useState(null),[he,Be]=x.useState(null),[ie,de]=x.useState(null),[He,et]=x.useState(null),[ct,fe]=x.useState(!1);Xt("guake-image-modal",qe!==null,()=>it(null)),Xt("guake-bash-modal",he!==null,()=>Be(null)),Xt("guake-response-modal",He!==null,()=>et(null)),Xt("guake-context-confirm",ie!==null,()=>de(null)),Xt("guake-agent-info",ct,()=>fe(!1));const[X,se]=x.useState(!1),[Se,J]=x.useState(()=>vs.isEnabled()),[pe,Re]=x.useState(()=>Ni(pt.GIT_PANEL_OPEN,!1)),$e=x.useCallback(Q=>{Re(Q),Ti(pt.GIT_PANEL_OPEN,Q)},[]),[ye,Ie]=x.useState(()=>Ni(pt.BUILDINGS_PANEL_OPEN,!1)),te=x.useCallback(Q=>{Ie(Q),Ti(pt.BUILDINGS_PANEL_OPEN,Q)},[]),[be,we]=x.useState(()=>Ni(pt.WORKFLOW_PANEL_OPEN,!1)),Fe=x.useCallback(Q=>{we(Q),Ti(pt.WORKFLOW_PANEL_OPEN,Q)},[]),[Ke,st]=x.useState(!1);x.useEffect(()=>{if(!T){st(!1);return}let Q=!1;return(async()=>{try{const ue=await Bt(Rt("/api/workflows/definitions"));if(Q||!ue.ok)return;const Ee=(await ue.json()).some(nt=>nt.states.some(ut=>{var Nt,_t;return((Nt=ut.action)==null?void 0:Nt.type)==="agent_task"&&((_t=ut.action)==null?void 0:_t.agentId)===T}));Q||st(Ee)}catch{Q||st(!1)}})(),()=>{Q=!0}},[T]);const ft=hL(),wt=x.useCallback(Q=>U.setOverviewPanelOpen(Q),[]),[at,gt]=x.useState([]),[ht,Gt]=x.useState({}),[tn,je]=x.useState(()=>Vj()),[Oe,Ye]=x.useState(()=>{try{return localStorage.getItem("tide:bottom-split-direction")==="vertical"?"vertical":"horizontal"}catch{return"horizontal"}}),[Ze,Ot]=x.useState(()=>{try{const Q=localStorage.getItem("tide:bottom-terminal-height");return Q?Math.max(120,Math.min(600,Number(Q))):250}catch{return 250}}),Ft=x.useRef(null),[Lt,Vt]=x.useState([1]),ln=x.useRef(null),bt=x.useRef(null),[rt,xt]=x.useState(null),[$t,En]=x.useState(null),nn=x.useMemo(()=>at.filter(Q=>Q.areaId===$t),[at,$t]),Un=x.useMemo(()=>new Set(nn.map(Q=>Q.buildingId)),[nn]),Os=x.useRef(new Map);x.useEffect(()=>{try{const Q=localStorage.getItem("tide:bottom-panels-v2");if(Q){const ue=JSON.parse(Q);Os.current=new Map(ue.map(([le,Ee])=>[le,Ee.map(nt=>({id:nt.id??Xf(),type:nt.type,buildingId:nt.buildingId}))]))}else{const ue=localStorage.getItem("tide:bottom-terminals");if(ue){const le=JSON.parse(ue);for(const[Ee,nt]of le)Os.current.set(Ee,[{id:Xf(),type:"terminal",buildingId:nt}])}}}catch{}},[]);const ps=x.useCallback(Q=>{if(!T)return;const ue=U.getAreaForAgent(T);if(ue)try{Q.length>0?Os.current.set(ue.id,Q.map(Ee=>({id:Ee.id,type:Ee.type,buildingId:Ee.buildingId}))):Os.current.delete(ue.id);const le=Array.from(Os.current.entries());localStorage.setItem("tide:bottom-panels-v2",JSON.stringify(le))}catch{}},[T]),ks=x.useCallback(()=>{if(!T)return null;const Q=U.getAreaForAgent(T);return(Q==null?void 0:Q.id)??null},[T]),Qn=x.useCallback((Q,ue)=>{const le=ks();Gt({}),gt(Ee=>{for(const _t of Ee)_t.areaId===le&&_t.type==="pm2-logs"&&U.stopLogStreaming(_t.buildingId);const nt=Ee.filter(_t=>_t.areaId!==le),ut={id:Xf(),type:ue,buildingId:Q,areaId:le??void 0},Nt=[...nt,ut];return ps([ut]),Nt})},[ps,ks]),Ss=x.useCallback((Q,ue,le)=>{const Ee=ks();Ye(le);try{localStorage.setItem("tide:bottom-split-direction",le)}catch{}gt(nt=>{const ut=nt.filter(sn=>sn.areaId===Ee);if(ut.length>=4||ut.some(sn=>sn.buildingId===Q))return nt;const Nt={id:Xf(),type:ue,buildingId:Q,areaId:Ee??void 0},_t=[...nt,Nt];return ps(ut.concat(Nt)),_t})},[ps,ks]),Fn=x.useCallback(Q=>{Gt(ue=>{if(!(Q in ue))return ue;const le={...ue};return delete le[Q],le}),gt(ue=>{const le=ue.find(ut=>ut.id===Q);(le==null?void 0:le.type)==="pm2-logs"&&U.stopLogStreaming(le.buildingId);const Ee=ue.filter(ut=>ut.id!==Q),nt=le==null?void 0:le.areaId;return nt&&ps(Ee.filter(ut=>ut.areaId===nt)),Ee})},[ps]);x.useCallback(()=>{Gt({}),gt(Q=>{for(const ue of Q)ue.type==="pm2-logs"&&U.stopLogStreaming(ue.buildingId);return ps([]),[]})},[ps]),x.useEffect(()=>{if(!T){En(null);return}const Q=U.getAreaForAgent(T);if(!Q){En(null);return}En(Q.id),gt(ue=>{if(ue.filter(ut=>ut.areaId===Q.id).length>0)return ue;const Ee=Os.current.get(Q.id);if(!Ee||Ee.length===0)return ue;const nt=Ee.map(ut=>({id:ut.id,type:ut.type,buildingId:ut.buildingId,areaId:Q.id}));return[...ue,...nt]})},[T]),x.useEffect(()=>{const Q=ue=>{const le=ue.detail;le!=null&&le.buildingId&&Qn(le.buildingId,"terminal")};return window.addEventListener("tide:open-bottom-terminal",Q),()=>window.removeEventListener("tide:open-bottom-terminal",Q)},[Qn]),x.useEffect(()=>{const Q=ue=>{const le=ue.detail;le!=null&&le.buildingId&&Qn(le.buildingId,"pm2-logs")};return window.addEventListener("tide:open-bottom-pm2-logs",Q),()=>window.removeEventListener("tide:open-bottom-pm2-logs",Q)},[Qn]),x.useEffect(()=>{const Q=ue=>{const le=ue.detail;le!=null&&le.buildingId&&Qn(le.buildingId,"database")};return window.addEventListener("tide:open-bottom-database",Q),()=>window.removeEventListener("tide:open-bottom-database",Q)},[Qn]),x.useEffect(()=>{const Q=ue=>{const le=ue.detail;le!=null&&le.buildingId&&(le!=null&&le.type)&&(le!=null&&le.direction)&&(nn.length===0?Qn(le.buildingId,le.type):Ss(le.buildingId,le.type,le.direction))};return window.addEventListener("tide:split-bottom-panel",Q),()=>window.removeEventListener("tide:split-bottom-panel",Q)},[nn.length,Qn,Ss]),x.useEffect(()=>{Vt(Q=>Q.length===nn.length?Q:nn.length<=1?[1]:(nn.length>Q.length,Array(nn.length).fill(1)))},[nn.length]);const Ls=x.useCallback((Q,ue)=>{var sn;Q.preventDefault();const le=Oe==="horizontal";ln.current={index:ue,startPos:le?Q.clientX:Q.clientY,startRatios:[...Lt]},document.body.style.cursor=le?"col-resize":"row-resize",document.body.style.userSelect="none";const Ee=(sn=bt.current)==null?void 0:sn.querySelectorAll("iframe");Ee==null||Ee.forEach(gn=>gn.style.pointerEvents="none");const nt=bt.current,ut=nt?le?nt.offsetWidth:nt.offsetHeight:1,Nt=gn=>{const qn=ln.current;if(!qn||!nt)return;const Qo=(le?gn.clientX:gn.clientY)-qn.startPos,Ki=qn.startRatios.reduce((bc,vd)=>bc+vd,0),gc=Qo/ut*Ki,Xo=[...qn.startRatios],Jo=.1*Ki;Xo[ue]=Math.max(Jo,qn.startRatios[ue]+gc),Xo[ue+1]=Math.max(Jo,qn.startRatios[ue+1]-gc),Vt(Xo)},_t=()=>{ln.current=null,document.body.style.cursor="",document.body.style.userSelect="",Ee==null||Ee.forEach(gn=>gn.style.pointerEvents=""),document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",_t)};document.addEventListener("mousemove",Nt),document.addEventListener("mouseup",_t)},[Oe,Lt]),Is=x.useRef(new Set);x.useEffect(()=>{const Q=new Set(at.filter(ue=>ue.type==="pm2-logs").map(ue=>ue.buildingId));for(const ue of Q)Is.current.has(ue)||U.startLogStreaming(ue,200);Is.current=Q},[at]);const wn=x.useRef(new Set);x.useEffect(()=>{var le;const Q=at.filter(Ee=>Ee.type==="terminal");for(const Ee of Q){const nt=I.get(Ee.buildingId);!!((le=nt==null?void 0:nt.terminalStatus)!=null&&le.url)?wn.current.add(Ee.buildingId):wn.current.has(Ee.buildingId)&&(wn.current.delete(Ee.buildingId),Fn(Ee.id))}const ue=new Set(Q.map(Ee=>Ee.buildingId));for(const Ee of wn.current)ue.has(Ee)||wn.current.delete(Ee)},[at,I,Fn]);const Po=x.useCallback(Q=>{Q.preventDefault(),Ft.current={startY:Q.clientY,startH:Ze};let ue=Ze;const le=nt=>{if(!Ft.current)return;const ut=Ft.current.startY-nt.clientY;ue=Math.max(120,Math.min(600,Ft.current.startH+ut)),Ot(ue)},Ee=()=>{Ft.current=null,document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",Ee);try{localStorage.setItem("tide:bottom-terminal-height",String(ue))}catch{}};document.addEventListener("mousemove",le),document.addEventListener("mouseup",Ee)},[Ze]),[Bo,Ps]=x.useState(!1),[Ua,Bi]=x.useState(null),Fi=x.useRef(null),Bs=x.useRef(null),[lc,Ma]=x.useState(!1),[Ts,hs]=x.useState(!1),[Mn,zi]=x.useState(!1),[Ne,Je]=x.useState(!1),Ct=x.useRef(0),ot=r&&S!==null,jn=x.useRef([]),Mt=x.useRef(-1),At=x.useRef(!1),kn=x.useRef(!1),ms=x.useRef(!1),Dn=x.useRef(null),[Fs,Qr]=x.useState(!1),[pa,mh]=x.useState(!1),ha=x.useCallback(()=>{const Q=jn.current,ue=Mt.current;Qr(ue>0),mh(ue>=0&&ue<Q.length-1)},[]),$i=x.useCallback(Q=>{const ue=jn.current;if(ue.length===0)return;let le=Mt.current+Q;for(;le>=0&&le<ue.length;){const Ee=ue[le];if(s.has(Ee)){At.current=!0,Mt.current=le,ha(),U.selectAgent(Ee);return}le+=Q}},[s,ha]),gr=x.useCallback(()=>{$i(-1)},[$i]),Ui=x.useCallback(()=>{$i(1)},[$i]),cc=x.useCallback((Q,ue)=>{if(typeof window>"u")return;const le=window.history.state,nt={...typeof le=="object"&&le!==null?le:{},__guakeAgentNav:{agentId:Q}};ue==="replace"?window.history.replaceState(nt,"",window.location.href):window.history.pushState(nt,"",window.location.href)},[]),Fo=x.useCallback(()=>{Te(Q=>{const ue=!Q;return Ti(pt.TERMINAL_FULLSCREEN,ue),ue})},[]),It=Wj({selectedAgentId:T,hasSessionId:D,reconnectCount:c,historyRefreshTrigger:d,lastPrompts:i,outputScrollRef:me}),Hn=LH({agents:s,selectedAgentId:T,isOpen:ot,overviewPanelOpen:ft,loadingHistory:It.fetchingHistory,hasModalOpen:!!(qe||he||He||h||m),outputRef:me});x.useEffect(()=>{const Q=F.current;if(!Q||!ot)return;const ue=Ee=>{Ee.button===3?(Ee.preventDefault(),Ee.stopPropagation(),gr()):Ee.button===4&&(Ee.preventDefault(),Ee.stopPropagation(),Ui())},le=Ee=>{(Ee.button===3||Ee.button===4)&&Ee.preventDefault()};return Q.addEventListener("mouseup",ue),Q.addEventListener("mousedown",le),()=>{Q.removeEventListener("mouseup",ue),Q.removeEventListener("mousedown",le)}},[ot,gr,Ui]);const uc=x.useCallback(Q=>{U.setLastSelectionViaDirectClick(!0),U.selectAgent(Q)},[]),Xr=typeof window<"u"&&window.innerWidth<=768&&ft&&ot,Jr=tR({gestureRef:me,agentListRef:ee,enabled:Xr,onSelect:uc}),ts=$H({selectedAgentId:k}),zo=KO(),cd=x.useMemo(()=>y||!T?[]:Array.from(zo.values()).filter(Q=>Q.agentId===T&&Q.status==="pending"),[y,T,zo]),Ha=(S==null?void 0:S.class)==="boss"||(S==null?void 0:S.isBoss),zs=nL(!y&&Ha?T:null),Hi=x.useMemo(()=>Array.from(zs.values()).filter(Q=>Q.status==="working"),[zs]),br=x.useMemo(()=>Array.from(zs.values()).filter(Q=>Q.status==="completed"||Q.status==="failed").map(Q=>Q.agentId),[zs]),[ma,$o]=x.useState(!0),Uo=sL(y?null:T),ud=pL(y?null:T);x.useEffect(()=>{X&&!Se&&(J(!0),vs.setEnabled(!0))},[X,Se]),x.useEffect(()=>{ot||fe(!1)},[ot]),x.useEffect(()=>{if(!T||!Ha||y||br.length===0)return;const Q=window.setTimeout(()=>{br.forEach(ue=>{U.clearAgentTaskProgress(T,ue)})},300);return()=>window.clearTimeout(Q)},[T,Ha,y,br]),x.useEffect(()=>{const Q=S==null?void 0:S.status;if(Fi.current==="working"&&Q==="idle"){Bs.current&&clearTimeout(Bs.current);const le=T?i.get(T):void 0;Bi(le!=null&&le.timestamp?Date.now()-le.timestamp:null),Ps(!0),Bs.current=setTimeout(()=>{Ps(!1),Bi(null),Bs.current=null},4e3)}else Q==="working"&&(Bs.current&&(clearTimeout(Bs.current),Bs.current=null),Ps(!1),Bi(null));return Fi.current=Q||null,()=>{Bs.current&&clearTimeout(Bs.current)}},[S==null?void 0:S.status]);const Wi=x.useMemo(()=>{const{history:Q}=It,ue=new Map;for(const Ee of Q)Ee.type==="tool_result"&&Ee.toolUseId&&ue.set(Ee.toolUseId,Ee.content);return(Ee=>Ee.map(nt=>{if(nt.type==="tool_use"&&nt.toolName==="Bash"&&nt.toolUseId){const ut=ue.get(nt.toolUseId);let Nt;try{Nt=(nt.toolInput||(nt.content?JSON.parse(nt.content):{})).command}catch{}return{...nt,_bashOutput:ut,_bashCommand:Nt}}return nt}))(Q)},[It.history,ze]),qi=_T({outputs:ce,viewMode:ze}),Wa=x.useMemo(()=>{const Q=[],ue=new Set,le=new Set;let Ee=null,nt=0;for(const ut of Wi){if(ut.type==="assistant"){const gn=ut.uuid?`uuid:${ut.uuid}:${Qf(ut.content)}`:`sig:${ut.timestamp}:${Qf(ut.content)}`;if(ue.has(gn))continue;ue.add(gn),Q.push(ut);continue}if(ut.type!=="user"){Q.push(ut);continue}const Nt=Eb(ut.content),_t=ut.uuid?`uuid:${ut.uuid}:${Nt}`:null;if(_t&&le.has(_t))continue;const sn=ut.timestamp?new Date(ut.timestamp).getTime():0;Ee===Nt&&Math.abs(sn-nt)<=VA||(Q.push(ut),_t&&le.add(_t),Ee=Nt,nt=sn)}return Q},[Wi]),Wn=x.useMemo(()=>{const Q=new Map,ue=new Set,le=new Map;for(const Nt of Wa){const _t=Nt.timestamp?new Date(Nt.timestamp).getTime():0;if(Nt.type==="user"){const qn=Eb(Nt.content),Va=Q.get(qn)??0;_t>Va&&Q.set(qn,_t);continue}if(Nt.type!=="assistant")continue;Nt.uuid&&ue.add(Nt.uuid);const sn=Qf(Nt.content),gn=le.get(sn)??0;_t>gn&&le.set(sn,_t)}const Ee=[];let nt=null,ut=0;for(const Nt of qi){if(!Nt.isUserPrompt){if(!Nt.isStreaming&&!J5(Nt.text)){if(Nt.uuid&&ue.has(Nt.uuid))continue;const qn=Qf(Nt.text),Va=Nt.timestamp||0,Qo=le.get(qn);if(Qo&&Math.abs(Va-Qo)<=K5)continue}Ee.push(Nt);continue}const _t=Eb(Nt.text),sn=Nt.timestamp||0,gn=Q.get(_t);gn&&sn>=gn&&sn-gn<=G5||nt===_t&&Math.abs(sn-ut)<=VA||(Ee.push(Nt),nt=_t,ut=sn)}return Ee},[qi,Wa]),xr=x.useMemo(()=>[...Wa,...Wn],[Wa,Wn]),Ln=BH({selectedAgentId:T,isOpen:ot,allItems:xr,viewMode:ze,hasMoreHistory:It.hasMore,loadAllHistory:It.loadAllHistory,loadingMore:It.loadingMore}),Vi=Wa.length+Wn.length,dd=UH({totalMessages:Vi,isOpen:ot,hasModalOpen:!!(qe||he||He||h),scrollContainerRef:me,selectedAgentId:T,inputRef:re,textareaRef:We,useTextarea:ts.useTextarea});x.useEffect(()=>{if(!(!(he!=null&&he.isLive)||!he.command)){for(const Q of Wn)if(Q._bashCommand===he.command&&Q._bashOutput){Be({command:he.command,output:Q._bashOutput,isLive:!1});return}}},[he,Wn]);const Ho=x.useCallback((Q,ue)=>{it({url:Q,name:ue})},[]),Wo=x.useCallback((Q,ue)=>{const le=sh(Q,S==null?void 0:S.cwd),Ee=le.line?{...ue||{},targetLine:le.line}:ue;U.setFileViewerPath(le.path,Ee,S==null?void 0:S.cwd)},[S==null?void 0:S.cwd]),Zr=x.useCallback((Q,ue)=>{Be({command:Q,output:ue,isLive:ue==="Running..."})},[]),qo=x.useCallback(Q=>{et(Q)},[]),fd=x.useCallback(()=>{fe(Q=>!Q)},[]),[gh,Vo]=x.useState(!0),[pd,ei]=x.useState(0),[dc,fc]=x.useState(!1),Yi=x.useRef(!1),pc=x.useRef(!1),Yo=x.useRef(!1),hd=x.useCallback(()=>{Yo.current||(Yi.current=!0,Vo(!1))},[]),bh=x.useCallback(()=>hs(!1),[]),xh=x.useCallback(()=>{Yi.current=!1,Vo(!0)},[]),yh=x.useCallback(()=>{typeof window>"u"||window.innerWidth>768||(fc(!0),ei(Q5),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),setTimeout(()=>{U.setMobileView("3d"),fc(!1),ei(0)},X5))},[]),vh=x.useCallback(Q=>{dc||ei(Q)},[dc]);x.useEffect(()=>{Vo(!0),ei(0),fc(!1),Yi.current=!1,pc.current=!0,Yo.current=!0;const Q=setTimeout(()=>{Yo.current=!1},3e3);return()=>clearTimeout(Q)},[T]),x.useEffect(()=>{if(!T){jn.current=[],Mt.current=-1,ha(),ms.current=!1,Dn.current=null;return}const Q=jn.current;if(At.current){At.current=!1,ha();return}const ue=Mt.current;if(ue>=0&&Q[ue]===T){ha();return}const le=ue<Q.length-1?Q.slice(0,ue+1):Q.slice();le.push(T),le.length>100&&le.shift(),jn.current=le,Mt.current=le.length-1,ha()},[T,ha]),x.useEffect(()=>{if(!(!ot||!T)){if(!ms.current){cc(T,"replace"),ms.current=!0,Dn.current=T;return}if(kn.current){kn.current=!1,Dn.current=T;return}Dn.current!==T&&(cc(T,"push"),Dn.current=T)}},[ot,T,cc]),x.useEffect(()=>{if(!ot)return;const Q=ue=>{var ut,Nt;const le=(Nt=(ut=ue.state)==null?void 0:ut.__guakeAgentNav)==null?void 0:Nt.agentId;if(!le||typeof le!="string"||!s.has(le)||le===k)return;kn.current=!0,At.current=!0;const Ee=jn.current,nt=Ee.lastIndexOf(le);nt>=0?Mt.current=nt:(Ee.push(le),Mt.current=Ee.length-1),ha(),U.selectAgent(le)};return window.addEventListener("popstate",Q),()=>window.removeEventListener("popstate",Q)},[ot,s,k,ha]),x.useEffect(()=>{if(!pc.current||!T||Mn||It.fetchingHistory)return;let Q=0,ue=0;return Q=requestAnimationFrame(()=>{ue=requestAnimationFrame(()=>{me.current&&(me.current.scrollTop=me.current.scrollHeight),pc.current=!1})}),()=>{cancelAnimationFrame(Q),cancelAnimationFrame(ue)}},[T,Mn,It.fetchingHistory,It.historyLoadVersion]);const Go=x.useRef(It.handleScroll);Go.current=It.handleScroll;const wh=x.useCallback(()=>{if(!me.current||K.keyboardScrollLockRef.current)return;const{scrollTop:Q,scrollHeight:ue,clientHeight:le}=me.current,Ee=ue-Q-le<150;Yo.current||(Yi.current=!Ee,Ee&&Vo(!0)),Go.current(K.keyboardScrollLockRef)},[me,K.keyboardScrollLockRef]),kh=Z.length>0&&((Ko=(xd=Z[Z.length-1])==null?void 0:xd.text)==null?void 0:Ko.length)||0;x.useEffect(()=>{K.keyboardScrollLockRef.current||Yi.current||requestAnimationFrame(()=>{me.current&&(me.current.scrollTop=me.current.scrollHeight)})},[Z.length,kh,K.keyboardScrollLockRef,me]);const md=x.useRef(null);x.useLayoutEffect(()=>{const Q=md.current;Q!==null&&Q!==k?(Ma(!1),k&&It.hasCachedHistory(k)||zi(!0),U.getState().currentSnapshot&&U.setCurrentSnapshot(null)):k||Ma(!1),md.current=k},[k]),x.useEffect(()=>{if(!Mn||It.fetchingHistory)return;const Q=requestAnimationFrame(()=>{me.current&&(me.current.scrollTop=me.current.scrollHeight),zi(!1)});return()=>cancelAnimationFrame(Q)},[Mn,It.fetchingHistory,It.historyLoadVersion]);const qa=x.useRef(!1);x.useEffect(()=>{ot&&k&&U.clearUnseenForAgent(k)},[ot,k]),x.useEffect(()=>{qa.current=!0,hs(!0)},[T,c]),x.useEffect(()=>{It.fetchingHistory&&(qa.current=!0,hs(!0))},[It.fetchingHistory]),x.useEffect(()=>{if(!Ts||!ot||It.fetchingHistory)return;const Q=me.current;if(!Q)return;let ue=null;const le=performance.now();let Ee=0,nt=-1;const ut=()=>{const{scrollTop:_t,scrollHeight:sn,clientHeight:gn}=Q;return sn-_t-gn<=2},Nt=()=>{const _t=performance.now(),sn=Q.scrollHeight,gn=Math.abs(sn-nt)<=1,qn=ut();if(gn&&qn?Ee+=1:Ee=0,nt=sn,Ee>=3){hs(!1),ue=null;return}if(_t-le>8e3){hs(!1),ue=null;return}ue=requestAnimationFrame(Nt)};return ue=requestAnimationFrame(Nt),()=>{ue!==null&&cancelAnimationFrame(ue)}},[Ts,ot,It.fetchingHistory,It.historyLoadVersion]);const gd=x.useRef(!1);x.useEffect(()=>{gd.current&&!Ts&&qa.current&&(qa.current=!1,Ma(!0)),gd.current=Ts},[Ts]),x.useEffect(()=>{if(!ot||!qa.current||Ts||It.fetchingHistory)return;const Q=requestAnimationFrame(()=>{qa.current&&(qa.current=!1,Ma(!0))});return()=>cancelAnimationFrame(Q)},[It.historyLoadVersion,ot,Ts,It.fetchingHistory]),x.useEffect(()=>{const Q=ue=>{if(ue.key==="`"&&!ue.ctrlKey&&!ue.altKey&&S){const le=ue.target;le.tagName!=="INPUT"&&le.tagName!=="TEXTAREA"&&(ue.preventDefault(),U.toggleTerminal())}};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[S]),x.useEffect(()=>{if(!ot)return;const Q=ue=>{ue.altKey&&(ue.key!=="ArrowLeft"&&ue.key!=="ArrowRight"||(ue.key==="ArrowLeft"&&Fs?(ue.preventDefault(),gr()):ue.key==="ArrowRight"&&pa&&(ue.preventDefault(),Ui())))};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[ot,Fs,pa,gr,Ui]),x.useEffect(()=>{const Q=ue=>{ue.key==="Escape"&&(h?(ue.stopImmediatePropagation(),U.clearFileViewerPath()):m?(ue.stopImmediatePropagation(),U.closeContextModal()):He?(ue.stopImmediatePropagation(),et(null)):he?(ue.stopImmediatePropagation(),Be(null)):qe?(ue.stopImmediatePropagation(),it(null)):Ln.searchMode&&(ue.stopImmediatePropagation(),Ln.closeSearch()))};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[qe,he,He,Ln,h,m]);const bd=x.useRef(ot),Gi=x.useRef(!1);x.useEffect(()=>{bd.current=ot},[ot]),x.useEffect(()=>{if(window.innerWidth<=768)return;const ue=nt=>{var sn;if(!(nt instanceof Element))return!1;const ut=(sn=F.current)==null?void 0:sn.contains(nt),Nt=nt.closest(".agent-bar"),_t=!!nt.closest(".modal-overlay, .modal, .image-modal-overlay, .image-modal, .bash-modal-overlay, .bash-modal, .agent-info-modal-overlay, .agent-info-modal, .agent-response-modal, .pasted-text-modal-overlay, .pasted-text-modal, .file-viewer-overlay, .file-viewer-modal, .context-view-modal, .guake-context-confirm-overlay, .guake-context-confirm-modal, .pm2-logs-modal-overlay, .pm2-logs-modal, .database-panel-modal, .context-menu, .guake-git-diff-modal-overlay, .guake-git-delete-confirm");return!!ut||!!Nt||_t},le=nt=>{if(!bd.current){Gi.current=!1;return}if(XD("terminal")){Gi.current=!1;return}Gi.current=!ue(nt.target)},Ee=nt=>{Gi.current&&(ue(nt.target)||U.setTerminalOpen(!1),Gi.current=!1)};return document.addEventListener("mousedown",le,!0),document.addEventListener("mouseup",Ee,!0),()=>{document.removeEventListener("mousedown",le,!0),document.removeEventListener("mouseup",Ee,!0)}},[]),x.useEffect(()=>{const Q=()=>{document.hidden&&K.cleanup()};return document.addEventListener("visibilitychange",Q),()=>document.removeEventListener("visibilitychange",Q)},[K]),x.useEffect(()=>()=>K.cleanup(),[T,K]);const hc=typeof window<"u"&&window.innerWidth<=768;if(!S)return hc&&f==="terminal"&&a.size===0?o.jsx("div",{ref:F,className:`guake-terminal open ${ge?"fullscreen":""}`,style:{"--terminal-height":`${L}%`},children:o.jsx("div",{className:"guake-content",children:o.jsx("div",{className:"guake-output",style:{display:"flex",alignItems:"center",justifyContent:"center",color:"#6272a4"},children:o.jsxs("div",{style:{textAlign:"center"},children:[o.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"👆"}),o.jsx("div",{style:{fontSize:"16px"},children:n("terminal:empty.tapAgent")}),o.jsx("div",{style:{fontSize:"14px",marginTop:"8px",opacity:.7},children:n("terminal:empty.switchTo3D")})]})})})}):hc&&f==="terminal"&&a.size>0?o.jsx("div",{ref:F,className:`guake-terminal open ${ge?"fullscreen":""}`,style:{"--terminal-height":`${L}%`},children:o.jsx("div",{className:"guake-content",children:o.jsx("div",{className:"guake-output",style:{display:"flex",alignItems:"center",justifyContent:"center",color:"#6272a4"},children:o.jsxs("div",{className:"guake-empty loading",children:[n("terminal:empty.loadingTerminal"),o.jsxs("span",{className:"loading-dots",children:[o.jsx("span",{}),o.jsx("span",{}),o.jsx("span",{})]})]})})})}):null;if(!T)return null;const Sh=Q=>{Q.preventDefault(),Q.stopPropagation(),Ct.current++,Q.dataTransfer.types.includes("Files")&&Je(!0)},Ch=Q=>{Q.preventDefault(),Q.stopPropagation()},Ah=Q=>{Q.preventDefault(),Q.stopPropagation(),Ct.current--,Ct.current===0&&Je(!1)},jh=async Q=>{Q.preventDefault(),Q.stopPropagation(),Ct.current=0,Je(!1);const ue=Q.dataTransfer.files;if(ue.length)for(const le of ue){const Ee=await ts.uploadFile(le);Ee&&ts.setAttachedFiles(nt=>[...nt,Ee])}};return o.jsxs("div",{ref:F,className:`guake-terminal ${ot?"open":"collapsed"} ${ge&&ot?"fullscreen":""} ${X&&ot?"with-debug-panel":""} ${pe&&ot?"with-git-panel":""} ${ye&&ot?"with-buildings-panel":""} ${be&&ot?"with-workflow-panel":""} ${ft&&ot?"with-overview-panel":""} ${Ne?"drag-over":""} ${pd>0?"mobile-swipe-close-active":""} ${dc?"mobile-swipe-close-closing":""}`,style:{"--terminal-height":`${L}%`,"--mobile-swipe-close-offset":`${pd}px`,"--guake-side-panel-width":`${ne}px`,...V>0?{"--guake-mobile-overview-height":`${V}px`}:{}},onDragEnter:Sh,onDragOver:Ch,onDragLeave:Ah,onDrop:jh,children:[o.jsxs("div",{className:"guake-drop-overlay",children:[o.jsx("div",{className:"drop-border"}),o.jsx("span",{className:"drop-icon",children:"📎"}),o.jsx("span",{className:"drop-label",children:n("terminal:input.dropToAttach")})]}),!y&&X&&ot&&T&&o.jsx(o5,{agentId:T,onClose:()=>se(!1)}),!y&&pe&&ot&&T&&o.jsx(b5,{agentId:T,agents:s,onClose:()=>$e(!1),branchInfoMap:z,fetchRemote:$,fetchingDirs:W}),!y&&ye&&ot&&T&&o.jsx(D5,{agentId:T,onClose:()=>te(!1)}),!y&&be&&ot&&T&&o.jsx(L5,{agentId:T,onClose:()=>Fe(!1)}),!y&&(X||pe||ye||be)&&ot&&o.jsx("div",{className:"guake-side-panel-resize right",onMouseDown:Q=>Ae(Q,"right")}),!y&&ft&&ot&&T&&o.jsx(_5,{activeAgentId:T,onClose:()=>wt(!1),onSelectAgent:Q=>{U.setLastSelectionViaDirectClick(!0),U.selectAgent(Q)},agentListRef:ee,twoFingerState:Jr}),!y&&ft&&ot&&T&&o.jsx("div",{className:"guake-side-panel-resize left",onMouseDown:Q=>Ae(Q,"left")}),!y&&ft&&ot&&T&&o.jsx("div",{className:"aop-resize-handle",onMouseDown:G,onTouchStart:B}),o.jsxs("div",{className:"guake-content",children:[o.jsx(A6,{selectedAgent:S,selectedAgentId:T,sortedAgents:Hn.sortedAgents,swipeOffset:Hn.swipeOffset,viewMode:ze,setViewMode:Pe,searchMode:Ln.searchMode,toggleSearch:Ln.toggleSearch,closeSearch:Ln.closeSearch,debugPanelOpen:X,setDebugPanelOpen:se,debuggerEnabled:Se,setDebuggerEnabled:J,gitPanelOpen:pe,setGitPanelOpen:$e,buildingsPanelOpen:ye,setBuildingsPanelOpen:te,workflowPanelOpen:be,setWorkflowPanelOpen:Fe,hasWorkflow:Ke,overviewPanelOpen:ft,setOverviewPanelOpen:wt,agentInfoOpen:ct,onToggleAgentInfo:fd,isFullscreen:ge,onToggleFullscreen:Fo,onNavigateBack:gr,onNavigateForward:Ui,canNavigateBack:Fs,canNavigateForward:pa,outputsLength:Wa.length+Wn.length,setContextConfirm:de,headerRef:Hn.headerRef,onSaveSnapshot:y?void 0:e,isSnapshotView:y}),Ln.searchMode&&o.jsx(j6,{searchInputRef:Ln.searchInputRef,searchQuery:Ln.searchQuery,setSearchQuery:Ln.setSearchQuery,closeSearch:Ln.closeSearch,matchCount:Ln.matchIndices.length,currentMatch:Ln.currentMatch,navigateNext:Ln.navigateNext,navigatePrev:Ln.navigatePrev,loadingFullHistory:Ln.loadingFullHistory}),o.jsxs("div",{className:`guake-swipe-container ${Hn.swipeAnimationClass}`,style:Hn.swipeOffset!==0?{transform:`translateX(${Hn.swipeOffset*40}%)`}:void 0,children:[Hn.sortedAgents.length>1&&Hn.swipeOffset!==0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`swipe-indicator left ${Hn.swipeOffset>.3?"visible":""}`,children:[o.jsx("span",{className:"indicator-icon",children:"←"}),o.jsx("span",{className:"indicator-name",children:(ti=Hn.nextAgent)==null?void 0:ti.name})]}),o.jsxs("div",{className:`swipe-indicator right ${Hn.swipeOffset<-.3?"visible":""}`,children:[o.jsx("span",{className:"indicator-name",children:(yd=Hn.prevAgent)==null?void 0:yd.name}),o.jsx("span",{className:"indicator-icon",children:"→"})]})]}),Hn.sortedAgents.length>1&&Hn.sortedAgents.length<=8&&Hn.swipeOffset!==0&&o.jsx("div",{className:`swipe-dots ${Math.abs(Hn.swipeOffset)>.1?"visible":""}`,children:Hn.sortedAgents.map((Q,ue)=>o.jsx("div",{className:`swipe-dot ${ue===Hn.currentAgentIndex?"active":""}`},Q.id))}),o.jsx("div",{className:"guake-output",ref:me,onScroll:wh,children:o.jsxs("div",{className:`guake-history-content ${lc?"fade-in":""}`,children:[Mn&&o.jsxs("div",{className:"guake-empty loading",children:[n("terminal:empty.loadingConversation"),o.jsxs("span",{className:"loading-dots",children:[o.jsx("span",{}),o.jsx("span",{}),o.jsx("span",{})]})]}),!Mn&&It.loadingHistory&&It.history.length===0&&Z.length===0&&o.jsxs("div",{className:"guake-empty loading",children:[n("terminal:empty.loadingConversation"),o.jsxs("span",{className:"loading-dots",children:[o.jsx("span",{}),o.jsx("span",{}),o.jsx("span",{})]})]}),!Mn&&!It.loadingHistory&&It.history.length===0&&ce.length===0&&S.status!=="working"&&o.jsx("div",{className:"guake-empty",children:n("terminal:empty.noOutput")}),!Mn&&It.hasMore&&!Ln.searchMode&&o.jsx("div",{className:"guake-load-more",children:It.loadingMore?o.jsx("span",{children:n("terminal:empty.loadingOlder")}):o.jsx("button",{onClick:It.loadMoreHistory,children:n("terminal:empty.loadMore",{count:It.totalCount-It.history.length})})}),!Mn&&o.jsx(i5,{historyMessages:Wa,liveOutputs:Wn,agentId:T,execTasks:Uo,subagents:ud,viewMode:ze,searchHighlight:Ln.highlightQuery,searchActiveIndex:Ln.scrollToIndex,selectedMessageIndex:dd.selectedIndex,isMessageSelected:dd.isSelected,onImageClick:Ho,onFileClick:Wo,onBashClick:Zr,onViewMarkdown:qo,scrollContainerRef:me,onScrollTopReached:It.loadMoreHistory,isLoadingMore:It.loadingMore,hasMore:It.hasMore,shouldAutoScroll:gh,onUserScroll:hd,pinToBottom:Ts,onPinCancel:bh,isLoadingHistory:It.fetchingHistory},T),!Mn&&Ha&&Hi.length>0&&o.jsxs("div",{className:`agent-progress-container ${ma?"collapsed":"expanded"}`,children:[o.jsxs("div",{className:"agent-progress-container-header",onClick:()=>$o(Q=>!Q),role:"button",tabIndex:0,onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),$o(ue=>!ue))},children:[o.jsx("span",{className:"progress-crown",children:"👑"}),o.jsx("span",{children:n("terminal:empty.subordinateProgress")}),o.jsx("span",{className:"progress-count",children:n("terminal:empty.activeCount",{count:Hi.length})}),o.jsx("span",{className:"agent-progress-container-toggle",children:ma?"▶":"▼"})]}),!ma&&Hi.map(Q=>o.jsx($5,{progress:Q,defaultExpanded:Q.status==="working",onAgentClick:ue=>{U.selectAgent(ue),U.setTerminalOpen(!0)},onDismiss:ue=>{T&&U.clearAgentTaskProgress(T,ue)},onFileClick:Wo,onBashClick:Zr},Q.agentId))]})]})})]}),o.jsx(O6,{selectedAgent:S,selectedAgentId:T,isOpen:ot,command:ts.command,setCommand:ts.setCommand,forceTextarea:ts.forceTextarea,setForceTextarea:ts.setForceTextarea,useTextarea:ts.useTextarea,attachedFiles:ts.attachedFiles,setAttachedFiles:ts.setAttachedFiles,removeAttachedFile:ts.removeAttachedFile,uploadFile:ts.uploadFile,pastedTexts:ts.pastedTexts,expandPastedTexts:ts.expandPastedTexts,incrementPastedCount:ts.incrementPastedCount,setPastedTexts:ts.setPastedTexts,resetPastedCount:ts.resetPastedCount,handleInputFocus:K.handleInputFocus,handleInputBlur:K.handleInputBlur,pendingPermissions:cd,showCompletion:Bo,completionElapsed:Ua,onImageClick:Ho,inputRef:re,textareaRef:We,isSnapshotView:y,onClearHistory:It.clearHistory,onSendCommand:xh,canSwipeClose:hc&&f==="terminal"&&!Mn&&!Ln.searchMode&&!It.fetchingHistory,onSwipeCloseOffsetChange:vh,onSwipeClose:yh}),o.jsxs("div",{className:"guake-agent-status-bar",children:[!y&&(S==null?void 0:S.isDetached)&&o.jsx(os,{content:o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"tide-tooltip__title",children:["🔄 ",n("terminal:empty.reattachingSessionTitle")]}),o.jsxs("div",{className:"tide-tooltip__text",children:[n("terminal:empty.reattachingSessionDesc"),o.jsx("br",{}),o.jsx("br",{}),o.jsxs("strong",{children:[n("common:labels.status"),":"]})," ",n("terminal:empty.reattachingSessionStatus")]})]}),position:"top",className:"tide-tooltip--detached",children:o.jsxs("span",{className:"guake-detached-badge",title:n("terminal:empty.reattachingBadge"),children:[o.jsx("span",{className:"guake-detached-spinner",children:"🔄"})," ",n("terminal:empty.reattaching")]})}),(S==null?void 0:S.cwd)&&o.jsxs("span",{className:"guake-agent-cwd",title:S.cwd,children:["📁 ",S.cwd.split("/").filter(Boolean).slice(-2).join("/")||S.cwd]}),O&&O.map(({areaId:Q,areaName:ue,dir:le})=>{const Ee=z.get(le),nt=W.has(le);return o.jsxs("span",{className:"guake-agent-area-dir",title:`${ue}: ${le}${Ee?` (${Ee.branch}${Ee.ahead?` ↑${Ee.ahead}`:""}${Ee.behind?` ↓${Ee.behind}`:""})`:""}`,onClick:()=>U.openFileExplorerForAreaFolder(Q,le),children:["📂 ",le.split("/").filter(Boolean).pop()||le,Ee&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"guake-agent-area-branch",children:[" ⎇ ",Ee.branch]}),Ee.ahead>0&&o.jsxs("span",{className:"guake-branch-ahead",title:`${Ee.ahead} ahead`,children:["↑",Ee.ahead]}),Ee.behind>0&&o.jsxs("span",{className:"guake-branch-behind",title:`${Ee.behind} behind`,children:["↓",Ee.behind]}),o.jsx("span",{className:`guake-area-fetch-btn ${nt?"fetching":""}`,title:"Git fetch",onClick:ut=>{ut.stopPropagation(),$(le)},children:nt?"⏳":"⇣"})]})]},`${Q}:${le}`)}),!y&&S&&(()=>{const Q=S.contextStats,ue=!!Q,le=Q?Q.totalTokens:S.contextUsed||0,Ee=Q?Q.contextWindow:S.contextLimit||2e5,nt=Q?Q.usedPercent:Math.round(le/Ee*100),ut=Math.max(0,Math.min(100,nt)),Nt=Math.max(0,100-ut),_t=ut>=80?"#ff4a4a":ut>=60?"#ff9e4a":ut>=40?"#ffd700":"#4aff9e",sn=(le/1e3).toFixed(1),gn=(Ee/1e3).toFixed(1);return o.jsxs("span",{className:"guake-agent-context",onClick:()=>U.setContextModalAgentId(T),title:n(ue?"terminal:context.clickToViewStats":"terminal:context.clickToFetchStats"),children:[o.jsx("span",{className:"context-icon",children:"📊"}),o.jsxs("span",{className:"context-label",children:[n("terminal:agentInfo.context"),":"]}),o.jsx("span",{className:"context-bar-mini",children:o.jsx("span",{className:"context-bar-mini-fill",style:{width:`${Math.min(100,ut)}%`,backgroundColor:_t}})}),o.jsxs("span",{className:"context-tokens",style:{color:_t},children:[sn,"k/",gn,"k"]}),o.jsxs("span",{className:"context-free",children:["(",n("terminal:context.percentFree",{percent:Nt}),")"]}),!ue&&o.jsx("span",{className:"context-warning",title:n("terminal:context.clickToFetchStats"),children:"⚠️"})]})})(),o.jsxs("span",{className:"guake-status-right",children:[_.length>0&&o.jsx("span",{className:"guake-status-terminals",children:_.map(Q=>{const ue=Un.has(Q.id);return o.jsx("button",{className:`guake-status-terminal-btn ${ue?"active":""} ${Q.hasUrl?"":"offline"}`,title:`${ue?"Hide":"Show"} terminal: ${Q.name}${Q.hasUrl?"":" (starting...)"}`,onClick:()=>{if(ue){const le=at.find(Ee=>Ee.buildingId===Q.id);le&&Fn(le.id)}else Q.hasUrl||U.sendBuildingCommand(Q.id,"start"),Qn(Q.id,"terminal")},onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),Un.has(Q.id)||xt({position:{x:le.clientX,y:le.clientY},buildingId:Q.id,type:"terminal"})},children:"💻"},Q.id)})}),M.length>0&&o.jsx("span",{className:"guake-status-terminals",children:M.map(Q=>{const ue=Un.has(Q.id);return o.jsx("button",{className:`guake-status-terminal-btn ${ue?"active":""}`,title:`${ue?"Hide":"Show"} logs: ${Q.name}`,onClick:()=>{if(ue){const le=at.find(Ee=>Ee.buildingId===Q.id);le&&Fn(le.id)}else Qn(Q.id,"pm2-logs")},onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),Un.has(Q.id)||xt({position:{x:le.clientX,y:le.clientY},buildingId:Q.id,type:"pm2-logs"})},children:"📜"},Q.id)})}),R.length>0&&o.jsx("span",{className:"guake-status-terminals",children:R.map(Q=>{const ue=Un.has(Q.id);return o.jsx("button",{className:`guake-status-terminal-btn ${ue?"active":""}`,title:`${ue?"Hide":"Show"} database: ${Q.name}`,onClick:()=>{if(ue){const le=at.find(Ee=>Ee.buildingId===Q.id);le&&Fn(le.id)}else Qn(Q.id,"database")},onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),Un.has(Q.id)||xt({position:{x:le.clientX,y:le.clientY},buildingId:Q.id,type:"database"})},children:"🗄️"},Q.id)})}),o.jsx(H5,{})]})]}),(()=>{const Q=[];return rt&&(Q.push({id:"open",label:"Open",icon:"⬇",onClick:()=>Qn(rt.buildingId,rt.type)}),nn.length>0&&(Q.push({id:"split-right",label:"Split Right",icon:"↔",onClick:()=>Ss(rt.buildingId,rt.type,"horizontal")}),Q.push({id:"split-below",label:"Split Below",icon:"↕",onClick:()=>Ss(rt.buildingId,rt.type,"vertical")}))),o.jsx(pr,{children:o.jsx(Do,{isOpen:rt!==null,position:(rt==null?void 0:rt.position)||{x:0,y:0},worldPosition:{x:0,z:0},actions:Q,onClose:()=>xt(null)})})})(),nn.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Po}),o.jsx("div",{ref:bt,className:`guake-bottom-panels-container ${Oe}`,style:{height:Ze},onWheel:Q=>Q.stopPropagation(),children:nn.map((Q,ue)=>{const le=I.get(Q.buildingId);if(!le)return null;const Ee=Lt[ue]??1,nt=(()=>{var ut;if(Q.type==="terminal")return(ut=le.terminalStatus)!=null&&ut.url?o.jsxs("div",{className:"guake-bottom-panel",style:{flex:Ee},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["💻 ",le.name]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Fn(Q.id),children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx(Ax,{terminalUrl:le.terminalStatus.url,visible:!0})]},Q.id):o.jsxs("div",{className:"guake-bottom-panel",style:{flex:Ee},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["💻 ",le.name," (starting...)"]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Fn(Q.id),children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx("div",{className:"guake-bottom-terminal-starting",children:o.jsx("span",{children:"Starting terminal..."})})]},Q.id);if(Q.type==="pm2-logs"){const Nt=ht[Q.id]||"";return o.jsxs("div",{className:"guake-bottom-panel",style:{flex:Ee},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["📜 ",le.name]}),o.jsxs("div",{className:"guake-bottom-terminal-controls",children:[o.jsx("input",{type:"text",className:"guake-bottom-terminal-filter",value:Nt,onChange:_t=>{const sn=_t.target.value;Gt(gn=>{if(!sn.trim()){if(!(Q.id in gn))return gn;const qn={...gn};return delete qn[Q.id],qn}return{...gn,[Q.id]:sn}})},placeholder:"Filter logs","aria-label":`Filter logs for ${le.name}`,spellCheck:!1}),o.jsx("select",{className:"guake-bottom-terminal-retention",value:tn===null?"unlimited":String(tn),onChange:_t=>{const sn=_t.target.value==="unlimited"?null:Number(_t.target.value);je(sn),_O(sn)},"aria-label":`Max log retention for ${le.name}`,children:TO.map(_t=>o.jsx("option",{value:_t===null?"unlimited":String(_t),children:_t===null?"Unlimited":`${_t.toLocaleString()} lines`},_t===null?"unlimited":_t))}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>U.clearStreamingLogs(Q.buildingId),title:"Clear logs",children:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"})})}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>U.sendBuildingCommand(Q.buildingId,"restart"),title:"Restart",children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M1 4v6h6"}),o.jsx("path",{d:"M3.51 15a9 9 0 105.64-11.36L3 10"})]})}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Fn(Q.id),children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),o.jsx(tW,{buildingId:Q.buildingId,filterText:Nt,maxRetention:tn})]},Q.id)}return o.jsxs("div",{className:"guake-bottom-panel",style:{flex:Ee},children:[o.jsxs("div",{className:"guake-bottom-terminal-header",children:[o.jsxs("span",{className:"guake-bottom-terminal-title",children:["🗄️ ",le.name]}),o.jsx("button",{className:"guake-bottom-terminal-close",onClick:()=>Fn(Q.id),children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx(_H,{building:le})]},Q.id)})();return ue>0?o.jsxs(Ce.Fragment,{children:[o.jsx("div",{className:`guake-split-divider ${Oe}`,onMouseDown:ut=>Ls(ut,ue-1)}),nt]},Q.id):nt})})]}),at.filter(Q=>Q.areaId!==$t&&Q.type==="terminal").map(Q=>{var le;const ue=I.get(Q.buildingId);return(le=ue==null?void 0:ue.terminalStatus)!=null&&le.url?o.jsx(Ax,{terminalUrl:ue.terminalStatus.url,visible:!1},Q.id):null})]}),ot&&!ge&&o.jsx("div",{className:"guake-resize-handle",onMouseDown:H,title:n("common:rightPanel.dragToResize")}),!(ot&&ge)&&o.jsxs("div",{className:"guake-handle",onClick:()=>{ot&&U.toggleTerminal()},onDoubleClick:()=>{ot||U.toggleTerminal()},style:{top:ot?`min(${L}%, calc(100vh - 72px))`:"0"},children:[o.jsx("span",{className:"guake-handle-icon",children:ot?"▲":"▼"}),o.jsx("span",{className:"guake-handle-text",children:S.name})]}),qe&&o.jsx(I6,{url:qe.url,name:qe.name,onClose:()=>it(null)}),he&&o.jsx(P6,{state:he,onClose:()=>Be(null)}),ie&&o.jsx(B6,{action:ie,selectedAgentId:T,subordinateCount:((mc=S==null?void 0:S.subordinateIds)==null?void 0:mc.length)||0,onClose:()=>de(null),onClearHistory:It.clearHistory}),o.jsx(F6,{}),o.jsx(z6,{}),o.jsx(U6,{agent:S,isOpen:ct,onClose:()=>fe(!1)}),!y&&o.jsx($6,{agent:S,content:He,onClose:()=>et(null)})]})});function sW(t){return t.trim().replace(/^v/i,"")}function YA(t){const n=sW(t).match(/^(\d+(?:\.\d+)*)(?:-([0-9A-Za-z.-]+))?/);if(!n)return null;const s=n[1].split(".").map(r=>Number.parseInt(r,10));if(s.some(Number.isNaN))return null;const a=n[2]?n[2].split("."):[];return{core:s,prerelease:a}}function aW(t,e){if(t.length===0&&e.length===0)return 0;if(t.length===0)return 1;if(e.length===0)return-1;const n=Math.max(t.length,e.length);for(let s=0;s<n;s+=1){const a=t[s],r=e[s];if(a===void 0)return-1;if(r===void 0)return 1;const i=/^\d+$/.test(a)?Number.parseInt(a,10):null,c=/^\d+$/.test(r)?Number.parseInt(r,10):null;if(i!==null&&c!==null){if(i>c)return 1;if(i<c)return-1;continue}if(i!==null)return-1;if(c!==null)return 1;const d=a.localeCompare(r);if(d!==0)return d>0?1:-1}return 0}function rW(t,e){const n=YA(t),s=YA(e);if(!n||!s)return null;const a=Math.max(n.core.length,s.core.length);for(let r=0;r<a;r+=1){const i=n.core[r]??0,c=s.core[r]??0;if(i>c)return 1;if(i<c)return-1}return aW(n.prerelease,s.prerelease)}function iW(t,e){const n=rW(t,e);return n===null?"unknown":n<0?"behind":n>0?"ahead":"equal"}async function oW(t,e={}){const{timeoutMs:n=5e3,fetchImpl:s=fetch}=e;try{const a=new AbortController,r=setTimeout(()=>a.abort(),n),i=Date.now(),c=await s(`https://registry.npmjs.org/${encodeURIComponent(t)}/latest?t=${i}`,{signal:a.signal,headers:{Accept:"application/json"}});if(clearTimeout(r),!c.ok)return null;const d=await c.json();return typeof d.version=="string"?d.version:null}catch{return null}}async function lW(t,e,n={}){const s=await oW(t,n);return s?{currentVersion:e,latestVersion:s,relation:iW(e,s)}:{currentVersion:e,latestVersion:null,relation:"unknown"}}const cW="tide-commander",Mb="1.36.0";function uW(){const[t,e]=x.useState({currentVersion:Mb,latestVersion:null,relation:"unknown",isChecking:!1}),n=x.useCallback(async()=>{e(a=>({...a,isChecking:!0}));const s=await lW(cW,Mb);e({currentVersion:Mb,latestVersion:s.latestVersion,relation:s.relation,isChecking:!1})},[]);return x.useEffect(()=>{n()},[n]),{...t,refresh:n}}const dW=x.memo(function({agent:e,currentIndex:n,agentIndex:s,isTouchInput:a,isTouchDragEnabled:r,isSelected:i,hasUnseenOutput:c,isDragging:d,isDragOver:f,customClasses:h,onDragStart:m,onDragEnd:b,onDragOver:y,onDragEnter:w,onDragLeave:C,onDrop:N,onAgentClick:k,onAgentDoubleClick:j,onTouchStart:S,onTouchMove:T,onTouchEnd:D,onTouchCancel:E,onHoverEnter:I,onHoverLeave:O,onItemRef:_}){const M=x.useMemo(()=>fr(e.class,h),[e.class,h]),R=!a||r,z=x.useCallback($=>{_(e.id,$)},[e.id,_]);return o.jsxs("div",{ref:z,className:`agent-bar-item ${i?"selected":""} ${e.status} ${e.isBoss?"is-boss":""} ${d?"dragging":""} ${f?"drag-over":""} ${r?"touch-drag-enabled":""}`,draggable:R,onDragStart:$=>m($,e),onDragEnd:b,onDragOver:$=>y($,s),onDragEnter:$=>w($,s),onDragLeave:C,onDrop:$=>N($,s),onTouchStart:$=>S($,e.id),onTouchMove:T,onTouchEnd:D,onTouchCancel:E,onClick:$=>k(e,$),onDoubleClick:()=>j(e),onMouseEnter:()=>I(e),onMouseLeave:O,title:a?`${e.name} (${n+1}) - Long press to reorder`:`${e.name} (${n+1}) - Drag to reorder within group`,children:[o.jsxs("div",{className:"agent-bar-avatar",children:[o.jsx("span",{className:"agent-bar-icon",children:M.icon}),o.jsx("span",{className:"agent-bar-status",style:{backgroundColor:_x(e.status)}}),c&&o.jsx("span",{className:"agent-bar-notification-badge",title:"New output available - click to view"}),e.status==="idle"&&e.lastActivity>0&&o.jsx("span",{className:"agent-bar-idle-clock",style:{color:Tx(e.lastActivity)},title:Ex(e.lastActivity),children:"⏱"})]}),o.jsxs("span",{className:"agent-bar-hotkey",title:`Ctrl+${n+1}`,children:["^",n+1]})]})}),fW=x.memo(function({onFocusAgent:e,onSpawnClick:n,onSpawnBossClick:s,onNewBuildingClick:a,onNewAreaClick:r}){const{t:i}=dt(["common"]),c=ed(),d=ur(),f=$x(),h=HO(),m=Ux(),b=Vr(),y=dr(),w=l1(),[C]=Bj(),[N,k]=x.useState(!1);Mj("AgentBar");const j=x.useRef(null),S=x.useRef(null),T=x.useRef(null),D=x.useRef(new Map);x.useEffect(()=>{{k(!1);return}},[b.experimental2DView]),x.useEffect(()=>{const we=S.current;if(!we)return;const Fe=Ke=>{we.scrollWidth<=we.clientWidth||(Ke.preventDefault(),Math.abs(Ke.deltaX)>Math.abs(Ke.deltaY)?we.scrollLeft+=Ke.deltaX:we.scrollLeft+=Ke.deltaY)};return we.addEventListener("wheel",Fe,{passive:!1}),()=>we.removeEventListener("wheel",Fe)},[]);const[E,I]=x.useState(null),[O,_]=x.useState(new Map),[M,R]=x.useState(null),[z,$]=x.useState(null),W=x.useRef(0),[L,F]=x.useState(null),H=x.useRef(null),V=x.useRef(null),G=x.useRef(null),B=x.useRef(null),K=350,ne=8,q=x.useMemo(()=>typeof window>"u"?!1:"ontouchstart"in window||window.matchMedia("(pointer: coarse)").matches,[]),xe=x.useMemo(()=>Array.from(c.values()).filter(we=>{if(U.isAgentInArchivedArea(we.id))return!1;if(C){const Fe=U.getAreaForAgent(we.id);if(!Fx((Fe==null?void 0:Fe.id)??null))return!1}return!0}).sort((we,Fe)=>(we.createdAt||0)-(Fe.createdAt||0)),[c,d,C]),{orderedAgents:Ae,moveAgent:Z}=hO(xe),ce=Ae,me=x.useMemo(()=>{const we=new Map;for(const Fe of ce)we.set(Fe.id,U.getAreaForAgent(Fe.id));return we},[ce,d]),ee=x.useMemo(()=>{const we=new Map;for(const Ke of ce){const st=me.get(Ke.id)||null,ft=(st==null?void 0:st.id)||null;we.has(ft)||we.set(ft,{area:st,agents:[]}),we.get(ft).agents.push(Ke)}const Fe=Array.from(we.values());return Fe.sort((Ke,st)=>{var ft,wt;return!Ke.area&&st.area?1:Ke.area&&!st.area?-1:!Ke.area&&!st.area?0:(((ft=Ke.area)==null?void 0:ft.name)||"").localeCompare(((wt=st.area)==null?void 0:wt.name)||"")}),Fe},[ce,me]),re=x.useRef(e);re.current=e;const We=x.useRef(M);We.current=M;const ze=x.useRef(ce);ze.current=ce;const Pe=x.useRef(me);Pe.current=me;const ge=x.useRef(Z);ge.current=Z,x.useEffect(()=>{const we=new Map(O);let Fe=!1;for(const Ke of ce){const st=O.get(Ke.id);Ke.currentTool?(!st||st.tool!==Ke.currentTool)&&(we.set(Ke.id,{tool:Ke.currentTool,key:Date.now()}),Fe=!0):st&&setTimeout(()=>{_(ft=>{const wt=new Map(ft);return wt.delete(Ke.id),wt})},1500)}Fe&&_(we)},[ce.map(we=>we.currentTool).join(",")]),x.useEffect(()=>{const we=h;if(!we)return;const Fe=D.current.get(we),Ke=S.current;Fe&&Ke&&requestAnimationFrame(()=>{const st=Fe.getBoundingClientRect(),ft=Ke.getBoundingClientRect(),at=st.left-ft.left+Ke.scrollLeft+st.width/2,gt=Ke.clientWidth;Ke.scrollTo({left:at-gt/2,behavior:"smooth"})})},[h]);const Te=x.useCallback((we,Fe)=>{if(G.current===we.id){G.current=null,Fe.preventDefault(),Fe.stopPropagation();return}U.setLastSelectionViaDirectClick(!0),Fe.shiftKey?U.addToSelection(we.id):U.selectAgent(we.id),U.setTerminalOpen(!0)},[]),qe=x.useCallback(we=>{var Fe;(Fe=re.current)==null||Fe.call(re,we.id),U.setTerminalOpen(!0)},[]),it=x.useCallback(()=>I(null),[]),he=x.useCallback((we,Fe)=>{Fe?D.current.set(we,Fe):D.current.delete(we)},[]),Be=x.useCallback((we,Fe)=>{R(Fe),F(Fe.id),we.dataTransfer.effectAllowed="move",we.dataTransfer.setData("text/plain",Fe.id),requestAnimationFrame(()=>{we.target.classList.add("dragging")})},[]),ie=x.useCallback(we=>{R(null),$(null),F(null),W.current=0,we.target.classList.remove("dragging")},[]),de=x.useCallback((we,Fe)=>{we.preventDefault();const Ke=We.current;if(Ke){const st=Pe.current.get(Ke.id),ft=ze.current[Fe],wt=ft?Pe.current.get(ft.id):null,at=(st==null?void 0:st.id)??null,gt=(wt==null?void 0:wt.id)??null;we.dataTransfer.dropEffect=at===gt?"move":"none"}else we.dataTransfer.dropEffect="move"},[]),He=x.useCallback((we,Fe)=>{we.preventDefault(),W.current++;const Ke=We.current;if(Ke){const st=Pe.current.get(Ke.id),ft=ze.current[Fe],wt=ft?Pe.current.get(ft.id):null,at=(st==null?void 0:st.id)??null,gt=(wt==null?void 0:wt.id)??null;$(at===gt?Fe:null)}else $(Fe)},[]),et=x.useCallback(we=>{W.current--,W.current===0&&$(null)},[]),ct=x.useCallback((we,Fe)=>{we.preventDefault();const Ke=We.current;if(!Ke)return;const st=ze.current,ft=Pe.current,wt=st.findIndex(at=>at.id===Ke.id);if(wt!==-1&&wt!==Fe){const at=ft.get(Ke.id),gt=st[Fe],ht=gt?ft.get(gt.id):null,Gt=(at==null?void 0:at.id)??null,tn=(ht==null?void 0:ht.id)??null;Gt===tn&&ge.current(wt,Fe)}R(null),$(null),F(null),W.current=0},[]),fe=x.useCallback(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]),X=x.useCallback(()=>{B.current&&(clearTimeout(B.current),B.current=null)},[]),se=x.useCallback((we,Fe)=>{if(!q||we.touches.length!==1)return;fe(),X(),F(null);const Ke=we.touches[0];V.current={agentId:Fe,x:Ke.clientX,y:Ke.clientY},H.current=setTimeout(()=>{F(Fe),G.current=Fe,H.current=null},K)},[fe,X,q]),Se=x.useCallback(we=>{if(!q||we.touches.length!==1)return;const Fe=V.current;if(!Fe||!H.current)return;const Ke=we.touches[0],st=Ke.clientX-Fe.x,ft=Ke.clientY-Fe.y;Math.sqrt(st*st+ft*ft)>ne&&(fe(),V.current=null)},[fe,q]),J=x.useCallback(()=>{fe(),V.current=null,We.current||F(null),X(),B.current=setTimeout(()=>{G.current=null,B.current=null},450)},[fe,X]);x.useEffect(()=>()=>{fe(),X()},[fe,X]);const pe=we=>{const Fe=`common:status.${we}`;return i(Fe,{defaultValue:i("common:status.unknown")})},{currentVersion:Re,latestVersion:$e,relation:ye,isChecking:Ie}=uW(),te=Re;let be=0;return o.jsxs("div",{className:"agent-bar",ref:j,children:[o.jsxs("div",{className:"agent-bar-scroll",ref:S,children:[o.jsxs("div",{className:"agent-bar-version",title:$e?`Tide Commander v${te} (npm: v${$e})`:`Tide Commander v${te}`,children:[o.jsxs("span",{children:["v",te]}),ye==="behind"&&$e?o.jsxs("span",{className:"agent-bar-version-badge agent-bar-version-badge-behind",title:`Behind npm latest v${$e}`,children:["npm v",$e]}):ye==="ahead"&&$e?o.jsxs("span",{className:"agent-bar-version-badge agent-bar-version-badge-ahead",title:`Ahead of npm latest v${$e}`,children:["npm v",$e]}):null,ye==="behind"?o.jsx("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"agent-bar-version-status agent-bar-version-status-behind",title:i("common:agentBar.behindNpmTooltip",{defaultValue:"Current version is behind npm latest"}),children:i("common:agentBar.behindNpm",{defaultValue:"(behind npm)"})}):ye==="ahead"?o.jsx("span",{className:"agent-bar-version-status agent-bar-version-status-ahead",title:i("common:agentBar.aheadNpmTooltip",{defaultValue:"Current version is newer than npm latest"}),children:i("common:agentBar.aheadNpm",{defaultValue:"(ahead of npm)"})}):ye==="equal"?o.jsx("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"agent-bar-version-status",children:i("common:agentBar.updated")}):Ie?o.jsx("span",{className:"agent-bar-version-status",children:i("common:agentBar.checkingNpm",{defaultValue:"(checking npm)"})}):o.jsx("span",{className:"agent-bar-version-status",children:i("common:agentBar.unknownNpm",{defaultValue:"(npm unknown)"})}),N&&o.jsx(os,{content:"Refresh 3D Scene (HMR changes pending)",position:"bottom",children:o.jsx("button",{className:"agent-bar-hmr-refresh",onClick:Uj,children:"↻"})})]}),o.jsxs("div",{className:"agent-bar-list",ref:T,children:[o.jsx(os,{content:i("common:agentBar.spawnNewAgent"),position:"bottom",children:o.jsxs("button",{className:"agent-bar-spawn-btn",onClick:n,children:[o.jsx("span",{className:"agent-bar-spawn-icon",children:"+"}),o.jsx("span",{className:"agent-bar-spawn-label",children:i("common:agentBar.newAgent")})]})}),o.jsx(os,{content:i("common:agentBar.spawnBoss"),position:"bottom",children:o.jsxs("button",{className:"agent-bar-spawn-btn agent-bar-boss-btn",onClick:s,children:[o.jsx("span",{className:"agent-bar-spawn-icon",children:"👑"}),o.jsx("span",{className:"agent-bar-spawn-label",children:i("common:agentBar.newBoss")})]})}),o.jsx(os,{content:i("common:agentBar.addNewBuilding"),position:"bottom",children:o.jsxs("button",{className:"agent-bar-spawn-btn agent-bar-building-btn",onClick:a,children:[o.jsx("span",{className:"agent-bar-spawn-icon",children:"🏢"}),o.jsx("span",{className:"agent-bar-spawn-label",children:i("common:agentBar.newBuilding")})]})}),o.jsx(os,{content:i("common:agentBar.drawNewArea"),position:"bottom",children:o.jsxs("button",{className:"agent-bar-spawn-btn agent-bar-area-btn",onClick:r,children:[o.jsx("span",{className:"agent-bar-spawn-icon",children:"🔲"}),o.jsx("span",{className:"agent-bar-spawn-label",children:i("common:agentBar.newArea")})]})}),ee.map(we=>{var st,ft,wt,at,gt;const Fe=we.agents,Ke=!we.area;return o.jsxs("div",{className:`agent-bar-group ${Ke?"unassigned":""}`,style:{borderColor:((st=we.area)==null?void 0:st.color)||void 0,background:we.area?`${we.area.color}15`:void 0},children:[o.jsx("div",{className:"agent-bar-area-label",children:o.jsx("span",{className:"agent-bar-area-name",style:{color:((ft=we.area)==null?void 0:ft.color)||"#888"},children:((wt=we.area)==null?void 0:wt.name)||i("common:agentBar.unassigned")})}),((at=we.area)==null?void 0:at.directories)&&we.area.directories.length>0&&o.jsx("div",{className:"agent-bar-folders",children:we.area.directories.map((ht,Gt)=>o.jsxs("div",{className:"agent-bar-folder-item",onClick:tn=>{tn.stopPropagation(),U.openFileExplorer(ht)},children:[o.jsx("span",{className:"agent-bar-folder-icon",children:"📁"}),o.jsxs("div",{className:"agent-bar-folder-tooltip",children:[o.jsx("div",{className:"agent-bar-folder-tooltip-path",children:ht}),o.jsx("div",{className:"agent-bar-folder-tooltip-hint",children:i("common:agentBar.clickToOpen")})]})]},Gt))}),Fe.map(ht=>{const Gt=be++,tn=ce.findIndex(je=>je.id===ht.id);return o.jsx(dW,{agent:ht,currentIndex:Gt,agentIndex:tn,isTouchInput:q,isTouchDragEnabled:L===ht.id,isSelected:f.has(ht.id),hasUnseenOutput:w.has(ht.id),isDragging:(M==null?void 0:M.id)===ht.id,isDragOver:z===tn,customClasses:y,onDragStart:Be,onDragEnd:ie,onDragOver:de,onDragEnter:He,onDragLeave:et,onDrop:ct,onAgentClick:Te,onAgentDoubleClick:qe,onTouchStart:se,onTouchMove:Se,onTouchEnd:J,onTouchCancel:J,onHoverEnter:I,onHoverLeave:it,onItemRef:he},ht.id)})]},((gt=we.area)==null?void 0:gt.id)||"unassigned")})]})]}),Array.from(O.entries()).map(([we,Fe])=>{const Ke=D.current.get(we);if(!Ke)return null;const st=Ke.getBoundingClientRect(),ft=fs[Fe.tool]||fs.default;return o.jsxs("div",{className:"agent-bar-tool-bubble",title:Fe.tool,style:{position:"fixed",left:st.left+st.width/2,bottom:window.innerHeight-st.top+8},children:[o.jsx("span",{className:"agent-bar-tool-icon",children:ft}),o.jsx("span",{className:"agent-bar-tool-name",children:Fe.tool})]},`tool-${we}-${Fe.key}`)}),E&&(()=>{const we=U.getAreaForAgent(E.id),Fe=m.get(E.id),Ke=fr(E.class,y),st=U.getAgentSupervisorHistory(E.id),ft=st.length>0?st[st.length-1]:void 0,wt=Date.now()-(E.createdAt||Date.now()),at=Math.floor(wt/6e4),gt=Math.floor(at/60),ht=gt>0?`${gt}h ${at%60}m`:`${at}m`,Gt=Ze=>Ze>=1e6?`${(Ze/1e6).toFixed(1)}M`:Ze>=1e3?`${(Ze/1e3).toFixed(1)}K`:Ze.toString(),tn=E.contextLimit>0?Math.round(E.contextUsed/E.contextLimit*100):0,je=Ze=>{switch(Ze){case"on_track":return"#4aff9e";case"completed":return"#4a9eff";case"stalled":return"#ff9e4a";case"blocked":return"#ff4a4a";case"idle":return"#888888";default:return"#888888"}},Oe=D.current.get(E.id),Ye={};if(Oe){const Ze=Oe.getBoundingClientRect();Ye.position="fixed",Ye.left=Ze.left+Ze.width/2,Ye.bottom=window.innerHeight-Ze.top+12}return o.jsxs("div",{className:"agent-bar-tooltip",style:Ye,children:[o.jsxs("div",{className:"agent-bar-tooltip-header",children:[o.jsx("span",{className:"agent-bar-tooltip-icon",children:Ke.icon}),o.jsxs("span",{className:"agent-bar-tooltip-name",children:[o.jsx("img",{src:E.provider==="codex"?"/assets/codex.png":"/assets/claude.png",alt:E.provider,className:"agent-bar-provider-icon",title:E.provider==="codex"?"Codex Agent":"Claude Agent"}),E.name]}),o.jsx("span",{className:"agent-bar-tooltip-status",style:{color:_x(E.status)},children:pe(E.status)})]}),o.jsxs("div",{className:"agent-bar-tooltip-info",children:[o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.class"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[E.class," — ",Ke.description]})]}),we&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.area"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-area",style:{color:we.color},children:we.name})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.directory"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-path",children:E.cwd})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.uptime"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value",children:ht})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.tokens"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[Gt(E.tokensUsed)," ",i("common:agentPopup.used")]})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.context"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",style:{color:tn>80?"#ff4a4a":tn>60?"#ff9e4a":void 0},children:[Gt(E.contextUsed)," / ",Gt(E.contextLimit)," (",tn,"%)"]})]}),E.currentTool&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.tool"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-tool",children:[fs[E.currentTool]||fs.default," ",E.currentTool]})]}),E.taskLabel&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsx("span",{className:"agent-bar-tooltip-label",children:"📋 Task:"}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-tool",children:E.taskLabel})]}),E.currentTask&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.task"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[E.currentTask.substring(0,150),E.currentTask.length>150?"...":""]})]}),E.lastAssignedTask&&!E.currentTask&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.assignedTask"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-query",children:[E.lastAssignedTask.substring(0,200),E.lastAssignedTask.length>200?"...":""]})]}),Fe&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.lastQuery"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-query",children:[Fe.text.substring(0,300),Fe.text.length>300?"...":""]})]}),ft&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"agent-bar-tooltip-divider"}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:agentPopup.supervisor"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value",style:{color:je(ft.analysis.progress)},children:ft.analysis.progress.replace("_"," ")})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.status"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-supervisor",children:ft.analysis.statusDescription})]}),ft.analysis.recentWorkSummary&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.summary"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-supervisor",children:[ft.analysis.recentWorkSummary.substring(0,300),ft.analysis.recentWorkSummary.length>300?"...":""]})]}),ft.analysis.concerns&&ft.analysis.concerns.length>0&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[i("common:labels.concerns"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-concerns",children:ft.analysis.concerns.join("; ")})]})]})]})]})})()]})});function pW({activeTool:t,onExit:e}){const{t:n}=dt(["notifications","terminal"]);if(!t||t==="select")return null;const s=n(t==="rectangle"?"notifications:drawing.rectangleTool":"notifications:drawing.circleTool"),a=t==="rectangle"?"▭":"○";return o.jsxs("div",{className:"drawing-mode-indicator",children:[o.jsxs("div",{className:"drawing-mode-content",children:[o.jsx("span",{className:"drawing-mode-icon",children:a}),o.jsxs("div",{className:"drawing-mode-text",children:[o.jsxs("span",{className:"drawing-mode-title",children:[n("terminal:drawingMode.drawingArea"),": ",s]}),o.jsxs("span",{className:"drawing-mode-hint",children:[n("terminal:drawingMode.clickAndDrag")," • ",n("terminal:drawingMode.pressEscape")]})]})]}),o.jsx("button",{className:"drawing-mode-exit",onClick:e,title:n("terminal:drawingMode.exitDrawingMode"),children:"✕"})]})}const hW={idle:"common:status.idle",working:"common:status.working",waiting:"common:status.waiting",error:"common:status.error",offline:"common:status.offline"},Db=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),mW=t=>{switch(t){case"on_track":return"#4aff9e";case"completed":return"#4a9eff";case"stalled":return"#ff9e4a";case"blocked":return"#ff4a4a";case"idle":return"#888888";default:return"#888888"}},gW=x.memo(function({agent:e,screenPos:n,onClose:s}){const{t:a}=dt(["common"]),r=dr(),i=U.getAreaForAgent(e.id),c=U.getState().lastPrompts.get(e.id),d=fr(e.class,r),f=U.getAgentSupervisorHistory(e.id),h=f.length>0?f[f.length-1]:void 0,m=Date.now()-(e.createdAt||Date.now()),b=Math.floor(m/6e4),y=Math.floor(b/60),w=y>0?`${y}h ${b%60}m`:`${b}m`,C=e.contextLimit>0?Math.round(e.contextUsed/e.contextLimit*100):0,N=x.useMemo(()=>{let S=n.x-150,T=n.y-320-10;return typeof window<"u"&&(S<10?S=10:S+300>window.innerWidth-10&&(S=window.innerWidth-300-10),T<10&&(T=n.y+10)),{position:"fixed",left:S,top:T,zIndex:1e4,maxWidth:300,maxHeight:320,fontSize:"0.85em"}},[n.x,n.y]);return o.jsxs("div",{className:"agent-hover-popup",style:N,onMouseLeave:s,children:[o.jsxs("div",{className:"agent-bar-tooltip-header",children:[o.jsx("span",{className:"agent-bar-tooltip-icon",children:d.icon}),o.jsx("span",{className:"agent-bar-tooltip-name",children:e.name}),o.jsx("span",{className:"agent-bar-tooltip-status",style:{color:_x(e.status)},children:a(hW[e.status]||"common:status.unknown")})]}),o.jsxs("div",{className:"agent-bar-tooltip-info",children:[o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.class"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[e.class," — ",d.description]})]}),i&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.area"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-area",style:{color:i.color},children:i.name})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.directory"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-path",children:e.cwd})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.uptime"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value",children:w})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.tokens"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[Db(e.tokensUsed)," ",a("common:agentPopup.used")]})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.context"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",style:{color:C>80?"#ff4a4a":C>60?"#ff9e4a":void 0},children:[Db(e.contextUsed)," / ",Db(e.contextLimit)," (",C,"%)"]})]}),e.currentTool&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.tool"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-tool",children:[fs[e.currentTool]||fs.default," ",e.currentTool]})]}),e.currentTask&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.task"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value",children:[e.currentTask.substring(0,150),e.currentTask.length>150?"...":""]})]}),e.lastAssignedTask&&!e.currentTask&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.assignedTask"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-query",children:[e.lastAssignedTask.substring(0,200),e.lastAssignedTask.length>200?"...":""]})]}),c&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.lastQuery"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-query",children:[c.text.substring(0,300),c.text.length>300?"...":""]})]}),h&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"agent-bar-tooltip-divider"}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:agentPopup.supervisor"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value",style:{color:mW(h.analysis.progress)},children:h.analysis.progress.replace("_"," ")})]}),o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.status"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-supervisor",children:h.analysis.statusDescription})]}),h.analysis.recentWorkSummary&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.summary"),":"]}),o.jsxs("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-supervisor",children:[h.analysis.recentWorkSummary.substring(0,300),h.analysis.recentWorkSummary.length>300?"...":""]})]}),h.analysis.concerns&&h.analysis.concerns.length>0&&o.jsxs("div",{className:"agent-bar-tooltip-row",children:[o.jsxs("span",{className:"agent-bar-tooltip-label",children:[a("common:labels.concerns"),":"]}),o.jsx("span",{className:"agent-bar-tooltip-value agent-bar-tooltip-concerns",children:h.analysis.concerns.join("; ")})]})]})]})]})});function GA(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,s)).toFixed(1))+" "+n[s]}function KA(t){const n=Date.now()-t,s=Math.floor(n/(1e3*60*60)),a=Math.floor(n%(1e3*60*60)/(1e3*60));return s>0?`${s}h ${a}m`:`${a}m`}const QA={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function bW(t){const e=[],n=/\x1B\[([0-9;]*)m/g;let s=0,a=null,r;for(;(r=n.exec(t))!==null;){if(r.index>s){const c=t.slice(s,r.index);a?e.push(o.jsx("span",{style:{color:a},children:c},e.length)):e.push(c)}const i=r[1].split(";").map(Number);for(const c of i)c===0||c===39?a=null:QA[c]&&(a=QA[c]);s=n.lastIndex}if(s<t.length){const i=t.slice(s);a?e.push(o.jsx("span",{style:{color:a},children:i},e.length)):e.push(i)}return e.length>0?e:[t]}const xW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenLogsModal:r,onOpenUrlInModal:i}){var F,H,V,G,B,K,ne,q,xe,Ae,Z,ce,me,ee,re,We,ze,Pe,ge,Te;const{t:c}=dt(["terminal","common"]),[d,f]=x.useState(!1),[h,m]=x.useState(null),[b,y]=x.useState(!1),w=x.useRef(null),C=x.useRef(h);C.current=h;const{buildingLogs:N}=Rs(),k=U.getBuildingLogs(e.id),j=(F=e.pm2)==null?void 0:F.enabled,S=(H=e.docker)==null?void 0:H.enabled,T=x.useRef(null),D=x.useRef(null),E=x.useCallback(qe=>{qe.preventDefault();const it=C.current?C.current.x:0,he=C.current?C.current.y:0;w.current={mouseX:qe.clientX,mouseY:qe.clientY,popupX:it,popupY:he},y(!0),T.current=Be=>{if(!w.current)return;const ie=Be.clientX-w.current.mouseX,de=Be.clientY-w.current.mouseY;m({x:w.current.popupX+ie,y:w.current.popupY+de})},D.current=()=>{y(!1),w.current=null,T.current&&document.removeEventListener("mousemove",T.current),D.current&&document.removeEventListener("mouseup",D.current)},document.addEventListener("mousemove",T.current),document.addEventListener("mouseup",D.current)},[]);x.useEffect(()=>()=>{T.current&&document.removeEventListener("mousemove",T.current),D.current&&document.removeEventListener("mouseup",D.current)},[]);const I=qe=>{if(qe==="logs"){if((j||S)&&r){r();return}U.sendBuildingCommand(e.id,qe),f(!0)}else U.sendBuildingCommand(e.id,qe)},O=(qe,it)=>{if(qe){const he=`http://localhost:${qe}`;it&&i?i(he):window.open(he,"_blank")}},_=((V=e.pm2Status)==null?void 0:V.ports)||[],M=((B=(G=e.dockerStatus)==null?void 0:G.ports)==null?void 0:B.map(qe=>qe.host))||[],R=j?_:S?M:[],z=j?!!((K=e.pm2)!=null&&K.script):S?!!((ne=e.docker)!=null&&ne.image)||((q=e.docker)==null?void 0:q.mode)==="compose"||((xe=e.docker)==null?void 0:xe.mode)==="existing":!!((Ae=e.commands)!=null&&Ae.start),$=j?!!((Z=e.pm2)!=null&&Z.script):S?!0:!!((ce=e.commands)!=null&&ce.stop),W=j?!!((me=e.pm2)!=null&&me.script):S?!0:!!((ee=e.commands)!=null&&ee.restart),L=x.useMemo(()=>{const it=d?400:250;let he=n.x+20,Be=n.y-80;return typeof window<"u"&&!h&&(n.x+20+280>window.innerWidth&&(he=n.x-280-20),n.y-80<0?Be=10:n.y-80+it>window.innerHeight&&(Be=window.innerHeight-it-10)),{position:"fixed",left:he+((h==null?void 0:h.x)||0),top:Be+((h==null?void 0:h.y)||0),zIndex:1e3,cursor:b?"grabbing":void 0}},[n.x,n.y,d,h,b]);return o.jsxs("div",{className:"building-action-popup",style:L,onClick:qe=>qe.stopPropagation(),children:[o.jsxs("div",{className:`building-popup-header ${b?"dragging":""}`,onMouseDown:E,children:[o.jsx("span",{className:"building-popup-name",children:e.name}),R.length>0&&o.jsx("span",{className:"building-popup-ports",children:R.map(qe=>o.jsxs("a",{href:`http://localhost:${qe}`,className:"building-popup-port-link",onClick:it=>{it.preventDefault(),it.stopPropagation(),O(qe,it.altKey)},onMouseDown:it=>it.stopPropagation(),title:`Open http://localhost:${qe} (Alt+Click for modal)`,children:[":",qe]},qe))}),o.jsx("span",{className:"building-popup-status",style:{backgroundColor:qb[e.status]},children:e.status}),o.jsx("button",{className:"building-popup-close",onClick:s,children:"x"})]}),j&&e.pm2Status&&o.jsxs("div",{className:"building-popup-metrics",children:[o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"PID"}),o.jsx("span",{className:"value",children:e.pm2Status.pid||"-"})]}),o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"CPU"}),o.jsxs("span",{className:"value",children:[((re=e.pm2Status.cpu)==null?void 0:re.toFixed(1))||"0","%"]})]}),o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"MEM"}),o.jsx("span",{className:"value",children:GA(e.pm2Status.memory||0)})]}),e.pm2Status.restarts!==void 0&&e.pm2Status.restarts>0&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"RST"}),o.jsx("span",{className:"value",children:e.pm2Status.restarts})]}),e.pm2Status.uptime&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"UP"}),o.jsx("span",{className:"value",children:KA(e.pm2Status.uptime)})]})]}),S&&e.dockerStatus&&o.jsxs("div",{className:"building-popup-metrics",children:[o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"ID"}),o.jsx("span",{className:"value",children:e.dockerStatus.containerId||"-"})]}),e.dockerStatus.cpu!==void 0&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"CPU"}),o.jsxs("span",{className:"value",children:[e.dockerStatus.cpu.toFixed(1),"%"]})]}),e.dockerStatus.memory!==void 0&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"MEM"}),o.jsx("span",{className:"value",children:GA(e.dockerStatus.memory)})]}),e.dockerStatus.health&&e.dockerStatus.health!=="none"&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"HEALTH"}),o.jsx("span",{className:"value",style:{color:e.dockerStatus.health==="healthy"?"#4ade80":e.dockerStatus.health==="unhealthy"?"#f87171":"#fbbf24"},children:e.dockerStatus.health==="healthy"?"✓":e.dockerStatus.health==="unhealthy"?"✗":"..."})]}),e.dockerStatus.startedAt&&o.jsxs("span",{className:"metric",children:[o.jsx("span",{className:"label",children:"UP"}),o.jsx("span",{className:"value",children:KA(e.dockerStatus.startedAt)})]})]}),S&&((We=e.dockerStatus)==null?void 0:We.services)&&e.dockerStatus.services.length>0&&o.jsx("div",{className:"building-popup-services",children:e.dockerStatus.services.map((qe,it)=>o.jsxs("span",{className:"service-item",title:`${qe.name}: ${qe.status}`,children:[o.jsx("span",{className:"service-indicator",style:{backgroundColor:qe.status==="running"?"#4ade80":"#f87171"}}),o.jsx("span",{className:"service-name",children:qe.name})]},it))}),(e.lastError||j&&((ze=e.pm2Status)==null?void 0:ze.status)==="errored"||S&&((Pe=e.dockerStatus)==null?void 0:Pe.status)==="dead")&&o.jsxs("div",{className:"building-popup-error",children:[e.lastError||c("terminal:building.processFailedToStart"),j&&((ge=e.pm2Status)==null?void 0:ge.restarts)&&e.pm2Status.restarts>5&&o.jsxs("span",{className:"error-hint",children:[" - ",c("terminal:building.checkLogsOrConfig")]}),S&&((Te=e.dockerStatus)==null?void 0:Te.health)==="unhealthy"&&o.jsxs("span",{className:"error-hint",children:[" - ",c("terminal:building.healthCheckFailing")]})]}),o.jsxs("div",{className:"building-popup-actions",children:[o.jsxs("button",{className:"action-btn start",onClick:()=>I("start"),disabled:!z||e.status==="running"||e.status==="starting",title:c(z?"terminal:buildingAction.start":"terminal:buildingAction.noStartCommand"),children:[o.jsx("span",{className:"icon",children:"▶"}),c("terminal:buildingAction.start")]}),o.jsxs("button",{className:"action-btn stop",onClick:()=>I("stop"),disabled:!$||e.status==="stopped"||e.status==="stopping",title:c($?"terminal:buildingAction.stop":"terminal:buildingAction.noStopCommand"),children:[o.jsx("span",{className:"icon",children:"■"}),c("terminal:buildingAction.stop")]}),o.jsxs("button",{className:"action-btn restart",onClick:()=>I("restart"),disabled:!W,title:c(W?"terminal:buildingAction.restart":"terminal:buildingAction.noRestartCommand"),children:[o.jsx("span",{className:"icon",children:"↺"}),c("terminal:buildingAction.restart")]}),o.jsxs("button",{className:"action-btn logs",onClick:()=>I("logs"),title:c("terminal:buildingAction.viewLogs"),children:[o.jsx("span",{className:"icon",children:"📄"}),c("terminal:logs.title")]}),R.length===1&&o.jsxs("button",{className:"action-btn open-url",onClick:qe=>O(R[0],qe.altKey),title:`Open http://localhost:${R[0]} (Alt+Click for modal)`,children:[o.jsx("span",{className:"icon",children:"🔗"}),c("terminal:buildingAction.openInBrowser")]}),R.length>1&&o.jsxs("div",{className:"action-btn-group",children:[o.jsxs("span",{className:"action-btn-label",children:[c("terminal:buildingAction.openInBrowser"),":"]}),R.map(qe=>o.jsxs("button",{className:"action-btn open-url port-btn",onClick:it=>O(qe,it.altKey),title:`Open http://localhost:${qe} (Alt+Click for modal)`,children:[":",qe]},qe))]})]}),d&&k.length>0&&o.jsxs("div",{className:"building-popup-logs",children:[o.jsxs("div",{className:"logs-header",children:[o.jsx("span",{children:c("terminal:logs.title")}),o.jsx("button",{onClick:()=>U.clearBuildingLogs(e.id),children:c("terminal:logs.clear")})]}),o.jsx("div",{className:"logs-content",children:k.slice(-50).map((qe,it)=>o.jsx("pre",{children:bW(qe)},it))})]}),o.jsx("button",{className:"building-popup-settings",onClick:a,children:c("terminal:buildingAction.fullSettings")})]})});function yW(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,s)).toFixed(1))+" "+n[s]}function vW(t){const n=Date.now()-t,s=Math.floor(n/(1e3*60*60)),a=Math.floor(n%(1e3*60*60)/(1e3*60));return s>0?`${s}h ${a}m`:`${a}m`}const wW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenLogsModal:r,onOpenUrlInModal:i}){const{t:c}=dt(["terminal","common"]),[d,f]=x.useState(null),[h,m]=x.useState(!1),b=x.useRef(null),y=x.useRef(d);y.current=d;const{buildings:w}=Rs(),N=(e.subordinateBuildingIds||[]).map(_=>w.get(_)).filter(_=>_!==void 0),k=x.useRef(null),j=x.useRef(null),S=x.useCallback(_=>{_.preventDefault();const M=y.current?y.current.x:0,R=y.current?y.current.y:0;b.current={mouseX:_.clientX,mouseY:_.clientY,popupX:M,popupY:R},m(!0),k.current=z=>{if(!b.current)return;const $=z.clientX-b.current.mouseX,W=z.clientY-b.current.mouseY;f({x:b.current.popupX+$,y:b.current.popupY+W})},j.current=()=>{m(!1),b.current=null,k.current&&document.removeEventListener("mousemove",k.current),j.current&&document.removeEventListener("mouseup",j.current)},document.addEventListener("mousemove",k.current),document.addEventListener("mouseup",j.current)},[]);x.useEffect(()=>()=>{k.current&&document.removeEventListener("mousemove",k.current),j.current&&document.removeEventListener("mouseup",j.current)},[]);const T=_=>{U.sendBossBuildingCommand(e.id,_)},D=N.reduce((_,M)=>(_[M.status]=(_[M.status]||0)+1,_),{}),E=N.some(_=>{var M;return(M=_.pm2)==null?void 0:M.enabled}),I=(_,M)=>{const R=`http://localhost:${_}`;M&&i?i(R):window.open(R,"_blank")},O=x.useMemo(()=>{let R=n.x+20,z=n.y-80;return typeof window<"u"&&!d&&(n.x+20+340>window.innerWidth&&(R=n.x-340-20),n.y-80<0?z=10:n.y-80+350>window.innerHeight&&(z=window.innerHeight-350-10)),{position:"fixed",left:R+((d==null?void 0:d.x)||0),top:z+((d==null?void 0:d.y)||0),zIndex:1e3,cursor:h?"grabbing":void 0}},[n.x,n.y,d,h]);return o.jsxs("div",{className:"building-action-popup boss-building-popup",style:O,onClick:_=>_.stopPropagation(),children:[o.jsxs("div",{className:`building-popup-header boss-header ${h?"dragging":""}`,onMouseDown:S,children:[o.jsx("span",{className:"boss-icon",children:"👑"}),o.jsx("span",{className:"building-popup-name",children:e.name}),o.jsx("span",{className:"subordinate-count",children:c("terminal:building.unitsCount",{count:N.length})}),o.jsx("button",{className:"building-popup-close",onClick:s,children:"x"})]}),o.jsxs("div",{className:"boss-status-overview",children:[Object.entries(D).map(([_,M])=>o.jsxs("span",{className:"status-badge",style:{backgroundColor:qb[_]||"#666"},children:[M," ",_]},_)),N.length===0&&o.jsx("span",{className:"no-subordinates",children:c("terminal:building.noSubordinates")})]}),N.length>0&&o.jsx("div",{className:"subordinate-list",children:N.map(_=>{var M,R,z;return o.jsxs("div",{className:"subordinate-item",children:[o.jsx("span",{className:"sub-status-dot",style:{backgroundColor:qb[_.status]}}),o.jsx("span",{className:"sub-name",children:_.name}),((M=_.pm2Status)==null?void 0:M.ports)&&_.pm2Status.ports.length>0&&o.jsx("span",{className:"sub-port",children:_.pm2Status.ports.map($=>o.jsxs("a",{href:`http://localhost:${$}`,className:"building-popup-port-link",onClick:W=>{W.preventDefault(),W.stopPropagation(),I($,W.altKey)},title:`Open http://localhost:${$} (Alt+Click for modal)`,children:[":",$]},$))}),_.pm2Status&&o.jsxs("span",{className:"sub-metrics",children:[(R=_.pm2Status.cpu)==null?void 0:R.toFixed(0),"% | ",yW(_.pm2Status.memory||0)]}),((z=_.pm2Status)==null?void 0:z.uptime)&&o.jsx("span",{className:"sub-uptime",children:vW(_.pm2Status.uptime)})]},_.id)})}),o.jsxs("div",{className:"building-popup-actions boss-actions",children:[o.jsxs("button",{className:"action-btn start",onClick:()=>T("start_all"),disabled:N.length===0,title:c("terminal:building.startAllSubs"),children:[o.jsx("span",{className:"icon",children:"▶"}),c("terminal:building.startAll")]}),o.jsxs("button",{className:"action-btn stop",onClick:()=>T("stop_all"),disabled:N.length===0,title:c("terminal:building.stopAllSubs"),children:[o.jsx("span",{className:"icon",children:"■"}),c("terminal:building.stopAll")]}),o.jsxs("button",{className:"action-btn restart",onClick:()=>T("restart_all"),disabled:N.length===0,title:c("terminal:building.restartAllSubs"),children:[o.jsx("span",{className:"icon",children:"↺"}),c("terminal:building.restartAll")]}),E&&o.jsxs("button",{className:"action-btn logs",onClick:r,title:c("terminal:building.viewUnifiedLogs"),children:[o.jsx("span",{className:"icon",children:"📄"}),c("terminal:building.logs")]})]}),o.jsx("button",{className:"building-popup-settings",onClick:a,children:c("terminal:building.fullSettings")})]})}),kW=x.memo(function({building:e,screenPos:n,onClose:s,onOpenSettings:a,onOpenDatabasePanel:r}){var D;const{t:i}=dt(["terminal","common"]),[c,d]=x.useState(null),[f,h]=x.useState(!1),m=x.useRef(null),b=x.useRef(c);b.current=c;const y=Yx(e.id),w=((D=e.database)==null?void 0:D.connections)??[],C=x.useRef(null),N=x.useRef(null),k=x.useCallback(E=>{E.preventDefault();const I=b.current?b.current.x:0,O=b.current?b.current.y:0;m.current={mouseX:E.clientX,mouseY:E.clientY,popupX:I,popupY:O},h(!0),C.current=_=>{if(!m.current)return;const M=_.clientX-m.current.mouseX,R=_.clientY-m.current.mouseY;d({x:m.current.popupX+M,y:m.current.popupY+R})},N.current=()=>{h(!1),m.current=null,C.current&&document.removeEventListener("mousemove",C.current),N.current&&document.removeEventListener("mouseup",N.current)},document.addEventListener("mousemove",C.current),document.addEventListener("mouseup",N.current)},[]);x.useEffect(()=>()=>{C.current&&document.removeEventListener("mousemove",C.current),N.current&&document.removeEventListener("mouseup",N.current)},[]);const j=E=>{U.testDatabaseConnection(e.id,E)},S=E=>y.connectionStatus.get(E),T=x.useMemo(()=>{let O=n.x+20,_=n.y-80;return typeof window<"u"&&!c&&(n.x+20+320>window.innerWidth&&(O=n.x-320-20),n.y-80<0?_=10:n.y-80+300>window.innerHeight&&(_=window.innerHeight-300-10)),{position:"fixed",left:O+((c==null?void 0:c.x)||0),top:_+((c==null?void 0:c.y)||0),zIndex:1e3,cursor:f?"grabbing":void 0}},[n.x,n.y,c,f]);return o.jsxs("div",{className:"building-action-popup database-building-popup",style:T,onClick:E=>E.stopPropagation(),children:[o.jsxs("div",{className:`building-popup-header database-header ${f?"dragging":""}`,onMouseDown:k,children:[o.jsx("span",{className:"database-icon",children:"🗄️"}),o.jsx("span",{className:"building-popup-name",children:e.name}),o.jsx("span",{className:"connection-count",children:i("terminal:building.connCount",{count:w.length})}),o.jsx("button",{className:"building-popup-close",onClick:s,children:"x"})]}),w.length>0?o.jsx("div",{className:"database-connection-list",children:w.map(E=>{var O;const I=S(E.id);return o.jsxs("div",{className:"database-connection-item",children:[o.jsx("span",{className:"conn-engine",children:((O=vL[E.engine])==null?void 0:O.icon)??"🗄️"}),o.jsx("span",{className:"conn-name",children:E.name}),o.jsx("span",{className:"conn-host",children:E.engine==="sqlite"?E.filepath||E.database||":memory:":`${E.host}:${E.port}`}),I&&o.jsx("span",{className:`conn-status ${I.connected?"connected":"disconnected"}`,children:I.connected?"●":"○"}),o.jsx("button",{className:"conn-test-btn",onClick:()=>j(E.id),title:i("terminal:building.testConnection"),children:"↻"})]},E.id)})}):o.jsxs("div",{className:"database-no-connections",children:[o.jsx("p",{children:i("terminal:building.noConnections")}),o.jsx("p",{className:"hint",children:i("terminal:building.clickSettingsToAdd")})]}),o.jsxs("div",{className:"building-popup-actions database-actions",children:[o.jsxs("button",{className:"action-btn query",onClick:r,disabled:w.length===0,title:i("terminal:building.openDbExplorer"),children:[o.jsx("span",{className:"icon",children:"⌨"}),i("terminal:building.query")]}),o.jsxs("button",{className:"action-btn test-all",onClick:()=>w.forEach(E=>j(E.id)),disabled:w.length===0,title:i("terminal:building.testAllConnections"),children:[o.jsx("span",{className:"icon",children:"↻"}),i("terminal:building.testAll")]})]}),o.jsx("button",{className:"building-popup-settings",onClick:a,children:i("common:buttons.settings")})]})});function SW({visible:t=!0,position:e="top-right"}){const[n,s]=x.useState(0),[a,r]=x.useState([]),[i,c]=x.useState(null),[d,f]=x.useState([]),[h,m]=x.useState(null),[b,y]=x.useState(null),[w,C]=x.useState(!1),[N,k]=x.useState("fps"),[j,S]=x.useState(null),[T,D]=x.useState(null),[E,I]=x.useState(null),[O,_]=x.useState(typeof window<"u"?window.innerWidth:1024),[M,R]=x.useState(null);x.useEffect(()=>{const Z=()=>_(window.innerWidth);return window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)},[]);const z=Kp(),$=x.useMemo(()=>{const Z=z.filter(me=>me.memoryUsageMB!==void 0&&me.memoryUsageMB>0);return{totalMB:Z.reduce((me,ee)=>me+(ee.memoryUsageMB||0),0),agentCount:Z.length,agents:Z.map(me=>({name:me.name,memoryMB:me.memoryUsageMB||0,status:me.status})).sort((me,ee)=>ee.memoryMB-me.memoryMB)}},[z]),W=x.useRef([]),L=x.useRef(null);if(x.useEffect(()=>{W.current=d},[d]),x.useEffect(()=>{L.current=h},[h]),x.useEffect(()=>{if(!t)return;const Z=async()=>{try{const me=await Bt(Rt("/api/perf"));if(me.ok){const ee=await me.json();D(ee)}}catch{}};Z();const ce=setInterval(Z,w?3e3:1e4);return()=>clearInterval(ce)},[t,w]),x.useEffect(()=>{if(!t)return;const Z=su.getUsage();Z&&M===null&&R(Z.usedMB);const ce=setInterval(()=>{var it,he;Nf.update();const me=Nf.getStats();s(me.current),r(Be=>[...Be,me.current].slice(-60));const ee=su.getUsage();ee&&c(ee);const re=window.__tideScene;if(re){const Be=(it=re.getMemoryDiagnostics)==null?void 0:it.call(re);Be!=null&&Be.threeJs&&m(Be.threeJs);const ie=re.renderer;if((he=ie==null?void 0:ie.info)!=null&&he.memory){const de=ie.info.memory.textures||0,He=Math.round(de*1);I({count:de,estimatedMB:He})}}const We=document.getElementsByTagName("*"),ze=document.getElementsByTagName("canvas"),Pe=document.getElementsByTagName("img"),ge=document.getElementsByTagName("video");let Te=0;for(let Be=0;Be<Math.min(We.length,500);Be++){const ie=We[Be];ie.onclick&&Te++,ie.onmousedown&&Te++,ie.onkeydown&&Te++}Te+=10,S({nodeCount:We.length,listenerCount:Te,canvasCount:ze.length,imageCount:Pe.length,videoCount:ge.length}),ee&&f(Be=>{const ie=L.current,de={timestamp:Date.now(),heapMB:ee.usedMB,geometries:(ie==null?void 0:ie.geometries)??0,textures:(ie==null?void 0:ie.textures)??0};return[...Be,de].slice(-120)});const qe=W.current;if(qe.length>=10){const Be=qe[0],ie=qe[qe.length-1],de=(ie.timestamp-Be.timestamp)/1e3/60;de>.1&&y((ie.heapMB-Be.heapMB)/de)}},1e3);return()=>{clearInterval(ce)}},[t,M]),!t)return null;const F=Z=>{const ce=Math.floor(Z/3600),me=Math.floor(Z%3600/60),ee=Z%60;return ce>0?`${ce}h ${me}m`:me>0?`${me}m ${ee}s`:`${ee}s`},H=Z=>Z>=55?"#4aff9e":Z>=30?"#ffcc00":"#ff4a4a",V=(Z,ce)=>{const me=Z/ce;return me<.5?"#4aff9e":me<.8?"#ffcc00":"#ff4a4a"},G=Z=>Z===null?"#888":Z<1?"#4aff9e":Z<5?"#ffcc00":"#ff4a4a",B=Nf.getStats(),ne=O<=768?80:10,q={"top-left":{top:10,left:10},"top-right":{top:10,right:10},"bottom-left":{bottom:ne,left:10},"bottom-right":{bottom:ne,right:10}},xe=M&&i?i.usedMB-M:0,Ae=Z=>({padding:"2px 8px",fontSize:"9px",border:"none",background:N===Z?"rgba(74, 158, 255, 0.4)":"rgba(255, 255, 255, 0.1)",color:N===Z?"#4a9eff":"#888",borderRadius:"3px",cursor:"pointer"});return o.jsxs("div",{style:{position:"fixed",...q[e],zIndex:99999,fontFamily:"monospace",fontSize:"11px",background:"rgba(0, 0, 0, 0.9)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"4px",padding:"6px 10px",color:"#fff",userSelect:"none",minWidth:w?"260px":"120px",maxWidth:"calc(100vw - 20px)",maxHeight:w?"calc(100vh - 100px)":"auto",overflowY:w?"auto":"visible",transition:"all 0.2s ease"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},onClick:()=>C(!w),children:[o.jsx("span",{style:{color:H(n),fontWeight:"bold",fontSize:"14px"},children:n}),o.jsx("span",{style:{color:"#666",fontSize:"10px"},children:"FPS"}),i&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#444"},children:"|"}),o.jsx("span",{style:{color:V(i.usedMB,i.totalMB),fontWeight:"bold"},children:i.usedMB}),o.jsx("span",{style:{color:"#666",fontSize:"10px"},children:"MB"})]}),b!==null&&Math.abs(b)>.5&&o.jsxs("span",{style:{color:G(b),fontSize:"10px",marginLeft:"4px"},children:[b>0?"+":"",b.toFixed(1),"/m"]}),T&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#444"},children:"|"}),o.jsx("span",{style:{color:"#ff9e4a",fontWeight:"bold"},children:T.process.rssMB}),o.jsx("span",{style:{color:"#666",fontSize:"10px"},children:"SRV"})]}),o.jsx("span",{style:{color:"#444",marginLeft:"auto",fontSize:"10px"},children:w?"▼":"▶"})]}),w&&o.jsxs("div",{style:{marginTop:"8px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"},children:[o.jsxs("div",{style:{display:"flex",gap:"4px",marginBottom:"8px",flexWrap:"wrap"},children:[o.jsx("button",{style:Ae("fps"),onClick:()=>k("fps"),children:"FPS"}),o.jsx("button",{style:Ae("memory"),onClick:()=>k("memory"),children:"Memory"}),o.jsx("button",{style:Ae("threejs"),onClick:()=>k("threejs"),children:"3D"}),o.jsx("button",{style:Ae("dom"),onClick:()=>k("dom"),children:"DOM"}),o.jsx("button",{style:Ae("server"),onClick:()=>k("server"),children:"Server"}),o.jsx("button",{style:Ae("http"),onClick:()=>k("http"),children:"HTTP"})]}),N==="fps"&&o.jsxs("div",{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Current:"}),o.jsx("span",{style:{color:H(B.current)},children:B.current}),o.jsx("span",{style:{color:"#888"},children:"Min:"}),o.jsx("span",{style:{color:H(B.min)},children:B.min}),o.jsx("span",{style:{color:"#888"},children:"Max:"}),o.jsx("span",{style:{color:H(B.max)},children:B.max}),o.jsx("span",{style:{color:"#888"},children:"Avg:"}),o.jsx("span",{style:{color:H(B.avg)},children:B.avg})]}),o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"2px"},children:"60s History:"}),o.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:"30px",gap:"1px",background:"rgba(0,0,0,0.3)",padding:"2px",borderRadius:"2px"},children:a.slice(-60).map((Z,ce)=>o.jsx("div",{style:{width:"3px",height:`${Math.min(100,Z/60*100)}%`,background:H(Z),opacity:.8}},ce))})]})]}),N==="memory"&&i&&o.jsxs("div",{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Used:"}),o.jsxs("span",{style:{color:V(i.usedMB,i.totalMB)},children:[i.usedMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Total:"}),o.jsxs("span",{children:[i.totalMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Limit:"}),o.jsxs("span",{children:[i.limitMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Baseline:"}),o.jsxs("span",{children:[M??"—"," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Growth:"}),o.jsxs("span",{style:{color:xe>50?"#ff4a4a":xe>20?"#ffcc00":"#4aff9e"},children:[xe>0?"+":"",xe," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Rate:"}),o.jsx("span",{style:{color:G(b)},children:b!==null?`${b.toFixed(2)} MB/min`:"—"})]}),o.jsx("div",{style:{marginBottom:"8px"},children:o.jsx("div",{style:{height:"8px",background:"rgba(255,255,255,0.1)",borderRadius:"4px",overflow:"hidden"},children:o.jsx("div",{style:{height:"100%",width:`${i.usedMB/i.limitMB*100}%`,background:V(i.usedMB,i.totalMB),transition:"width 0.3s ease"}})})}),d.length>1&&o.jsxs("div",{children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"2px"},children:"Memory History:"}),o.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:"40px",gap:"1px",background:"rgba(0,0,0,0.3)",padding:"2px",borderRadius:"2px"},children:d.slice(-60).map((Z,ce)=>{const me=Math.min(...d.map(ze=>ze.heapMB)),re=Math.max(...d.map(ze=>ze.heapMB))-me||1,We=(Z.heapMB-me)/re*100;return o.jsx("div",{style:{width:"3px",height:`${Math.max(5,We)}%`,background:Z.heapMB>(M??0)+50?"#ff4a4a":"#4a9eff",opacity:.8},title:`${Z.heapMB}MB`},ce)})})]}),$.agentCount>0&&o.jsxs("div",{style:{marginTop:"8px"},children:[o.jsxs("div",{style:{color:"#666",fontSize:"9px",marginBottom:"2px"},children:["Agent Memory (",$.agentCount,"):"]}),o.jsxs("div",{style:{fontSize:"10px"},children:[o.jsxs("div",{style:{color:"#4aff9e",fontWeight:"bold",marginBottom:"2px"},children:["Total: ",$.totalMB,"MB"]}),o.jsx("div",{style:{maxHeight:"50px",overflowY:"auto"},children:$.agents.slice(0,4).map((Z,ce)=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"1px"},children:[o.jsx("span",{style:{color:Z.status==="working"?"#4aff9e":"#666",maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis"},children:Z.name}),o.jsxs("span",{style:{color:"#4a9eff"},children:[Z.memoryMB,"MB"]})]},ce))})]})]}),o.jsxs("div",{style:{marginTop:"8px",padding:"6px",background:"rgba(0,0,0,0.3)",borderRadius:"4px"},children:[o.jsx("div",{style:{color:"#888",fontSize:"9px",marginBottom:"4px"},children:"Memory Breakdown (estimated):"}),o.jsxs("div",{style:{fontSize:"9px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#4a9eff"},children:"JS Heap"}),o.jsxs("span",{style:{color:"#4a9eff"},children:[i.usedMB," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#ff9e4a"},children:"GPU/Textures"}),o.jsxs("span",{style:{color:"#ff9e4a"},children:["~",(E==null?void 0:E.estimatedMB)??0," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsxs("span",{style:{color:"#9e4aff"},children:["DOM (",(j==null?void 0:j.nodeCount.toLocaleString())??0," nodes)"]}),o.jsxs("span",{style:{color:"#9e4aff"},children:["~",Math.round(((j==null?void 0:j.nodeCount)??0)*.5/1024)," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"4px",marginTop:"4px"},children:[o.jsx("span",{style:{color:"#fff",fontWeight:"bold"},children:"Est. Total"}),o.jsxs("span",{style:{color:"#fff",fontWeight:"bold"},children:["~",i.usedMB+((E==null?void 0:E.estimatedMB)??0)+Math.round(((j==null?void 0:j.nodeCount)??0)*.5/1024)," MB"]})]})]})]})]}),N==="threejs"&&o.jsx("div",{children:h?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Geometries:"}),o.jsx("span",{style:{color:"#4aff9e"},children:h.geometries}),o.jsx("span",{style:{color:"#888"},children:"Textures:"}),o.jsx("span",{style:{color:"#ff9e4a"},children:h.textures}),o.jsx("span",{style:{color:"#888"},children:"Programs:"}),o.jsx("span",{style:{color:"#9e4aff"},children:h.programs})]}),d.length>1&&o.jsxs("div",{children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"2px"},children:"Resource History:"}),o.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:"40px",gap:"1px",background:"rgba(0,0,0,0.3)",padding:"2px",borderRadius:"2px"},children:d.slice(-60).map((Z,ce)=>{const me=Math.max(...d.map(ee=>ee.textures))||1;return o.jsx("div",{style:{width:"3px",height:`${Z.textures/me*100}%`,background:"#ff9e4a",opacity:.8},title:`${Z.textures} textures`},ce)})})]}),o.jsx("div",{style:{color:"#666",fontSize:"9px",marginTop:"8px"},children:"Tip: Watch textures count. If it keeps increasing, there's a leak."})]}):o.jsxs("div",{style:{color:"#666",fontSize:"10px"},children:["Three.js stats unavailable.",o.jsx("br",{}),"SceneManager not exposed."]})}),N==="dom"&&o.jsx("div",{children:j?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"DOM Nodes:"}),o.jsx("span",{style:{color:j.nodeCount>5e3?"#ff4a4a":j.nodeCount>2e3?"#ffcc00":"#4aff9e"},children:j.nodeCount.toLocaleString()}),o.jsx("span",{style:{color:"#888"},children:"Canvases:"}),o.jsx("span",{style:{color:"#4a9eff"},children:j.canvasCount}),o.jsx("span",{style:{color:"#888"},children:"Images:"}),o.jsx("span",{style:{color:"#ff9e4a"},children:j.imageCount}),o.jsx("span",{style:{color:"#888"},children:"Videos:"}),o.jsx("span",{style:{color:"#9e4aff"},children:j.videoCount})]}),E&&o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px"},children:[o.jsx("span",{style:{color:"#888"},children:"GPU Textures:"}),o.jsx("span",{style:{color:"#ff9e4a"},children:E.count}),o.jsx("span",{style:{color:"#888"},children:"Est. VRAM:"}),o.jsxs("span",{style:{color:E.estimatedMB>100?"#ff4a4a":"#4aff9e"},children:["~",E.estimatedMB," MB"]})]}),o.jsxs("div",{style:{marginTop:"8px",padding:"6px",background:"rgba(0,0,0,0.3)",borderRadius:"4px"},children:[o.jsx("div",{style:{color:"#888",fontSize:"9px",marginBottom:"4px"},children:"Memory Breakdown (estimated):"}),o.jsxs("div",{style:{fontSize:"9px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#4a9eff"},children:"JS Heap"}),o.jsxs("span",{style:{color:"#4a9eff"},children:[(i==null?void 0:i.usedMB)??0," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#ff9e4a"},children:"GPU/Textures"}),o.jsxs("span",{style:{color:"#ff9e4a"},children:["~",(E==null?void 0:E.estimatedMB)??0," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"2px"},children:[o.jsx("span",{style:{color:"#9e4aff"},children:"DOM (~0.5KB/node)"}),o.jsxs("span",{style:{color:"#9e4aff"},children:["~",Math.round(j.nodeCount*.5/1024)," MB"]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"4px",marginTop:"4px"},children:[o.jsx("span",{style:{color:"#fff",fontWeight:"bold"},children:"Est. Total"}),o.jsxs("span",{style:{color:"#fff",fontWeight:"bold"},children:["~",((i==null?void 0:i.usedMB)??0)+((E==null?void 0:E.estimatedMB)??0)+Math.round(j.nodeCount*.5/1024)," MB"]})]})]})]}),o.jsx("div",{style:{color:"#666",fontSize:"9px",marginTop:"8px"},children:"Note: Task Manager shows more due to browser overhead, decoded images, and WebGL buffers."})]}):o.jsx("div",{style:{color:"#666",fontSize:"10px"},children:"Loading DOM stats..."})}),N==="server"&&o.jsx("div",{children:T?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Uptime:"}),o.jsx("span",{style:{color:"#4aff9e"},children:F(T.uptime)}),o.jsx("span",{style:{color:"#888"},children:"Heap Used:"}),o.jsxs("span",{style:{color:T.process.heapUsedMB>500?"#ff4a4a":"#4aff9e"},children:[T.process.heapUsedMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"Heap Total:"}),o.jsxs("span",{children:[T.process.heapTotalMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"RSS:"}),o.jsxs("span",{style:{color:"#4a9eff"},children:[T.process.rssMB," MB"]}),o.jsx("span",{style:{color:"#888"},children:"External:"}),o.jsxs("span",{children:[T.process.externalMB," MB"]})]}),o.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px",marginBottom:"8px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:"System:"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px"},children:[o.jsx("span",{style:{color:"#888"},children:"Load Avg:"}),o.jsx("span",{style:{color:T.system.loadAvg[0]>T.system.cpuCount?"#ff4a4a":"#4aff9e"},children:T.system.loadAvg.join(" ")}),o.jsx("span",{style:{color:"#888"},children:"CPUs:"}),o.jsx("span",{children:T.system.cpuCount}),o.jsx("span",{style:{color:"#888"},children:"Sys Memory:"}),o.jsxs("span",{children:[T.system.totalMemMB-T.system.freeMemMB," / ",T.system.totalMemMB," MB"]})]})]}),o.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px",marginBottom:"8px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:"WebSocket:"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px"},children:[o.jsx("span",{style:{color:"#888"},children:"Clients:"}),o.jsx("span",{style:{color:"#4a9eff"},children:T.websocket.clients}),o.jsx("span",{style:{color:"#888"},children:"Sent:"}),o.jsx("span",{children:T.websocket.messagesSent.toLocaleString()}),o.jsx("span",{style:{color:"#888"},children:"Received:"}),o.jsx("span",{children:T.websocket.messagesReceived.toLocaleString()})]})]}),T.agents.total>0&&o.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px"},children:[o.jsxs("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:["Agents (",T.agents.working,"w / ",T.agents.idle,"i / ",T.agents.total,"t):"]}),o.jsx("div",{style:{maxHeight:"80px",overflowY:"auto",fontSize:"10px"},children:T.agents.processes.map(Z=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"1px"},children:[o.jsx("span",{style:{color:Z.status==="working"?"#4aff9e":Z.status==="idle"?"#888":"#ff4a4a",maxWidth:"100px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Z.name}),o.jsxs("span",{style:{color:"#4a9eff"},children:[Z.memoryMB!=null?`${Z.memoryMB}MB`:"—",Z.pid?` (${Z.pid})`:""]})]},Z.id))})]})]}):o.jsx("div",{style:{color:"#666",fontSize:"10px"},children:"Loading server metrics..."})}),N==="http"&&o.jsx("div",{children:T?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888"},children:"Req/sec (30s):"}),o.jsx("span",{style:{color:"#4aff9e"},children:T.http.reqPerSec}),o.jsx("span",{style:{color:"#888"},children:"Avg Latency:"}),o.jsxs("span",{style:{color:T.http.avgLatencyMs>100?"#ff4a4a":T.http.avgLatencyMs>50?"#ffcc00":"#4aff9e"},children:[T.http.avgLatencyMs," ms"]}),o.jsx("span",{style:{color:"#888"},children:"Max Latency:"}),o.jsxs("span",{style:{color:T.http.maxLatencyMs>500?"#ff4a4a":T.http.maxLatencyMs>200?"#ffcc00":"#4aff9e"},children:[T.http.maxLatencyMs," ms"]}),o.jsx("span",{style:{color:"#888"},children:"Recent Reqs:"}),o.jsx("span",{children:T.http.recentRequests})]}),o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:"Avg Latency:"}),o.jsx("div",{style:{height:"8px",background:"rgba(255,255,255,0.1)",borderRadius:"4px",overflow:"hidden"},children:o.jsx("div",{style:{height:"100%",width:`${Math.min(100,T.http.avgLatencyMs/500*100)}%`,background:T.http.avgLatencyMs>100?"#ff4a4a":T.http.avgLatencyMs>50?"#ffcc00":"#4aff9e",transition:"width 0.3s ease"}})}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"8px",color:"#444",marginTop:"2px"},children:[o.jsx("span",{children:"0ms"}),o.jsx("span",{children:"500ms"})]})]}),o.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"6px"},children:[o.jsx("div",{style:{color:"#666",fontSize:"9px",marginBottom:"4px"},children:"Server Process:"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"2px 10px",fontSize:"10px"},children:[o.jsx("span",{style:{color:"#888"},children:"CPU (user):"}),o.jsxs("span",{style:{color:"#4a9eff"},children:[T.process.cpuUser," ms"]}),o.jsx("span",{style:{color:"#888"},children:"CPU (system):"}),o.jsxs("span",{style:{color:"#ff9e4a"},children:[T.process.cpuSystem," ms"]}),o.jsx("span",{style:{color:"#888"},children:"WS Clients:"}),o.jsx("span",{style:{color:"#4aff9e"},children:T.websocket.clients})]})]})]}):o.jsx("div",{style:{color:"#666",fontSize:"10px"},children:"Loading HTTP metrics..."})}),o.jsxs("div",{style:{display:"flex",gap:"4px",marginTop:"8px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px",flexWrap:"wrap"},children:[o.jsx("button",{onClick:Z=>{Z.stopPropagation();const ce=["=== Tide Commander Performance Stats ===",`Timestamp: ${new Date().toISOString()}`,"","--- FPS ---",`Current: ${B.current}`,`Min: ${B.min}`,`Max: ${B.max}`,`Avg: ${B.avg}`];i&&ce.push("","--- Memory ---",`Heap Used: ${i.usedMB} MB`,`Heap Total: ${i.totalMB} MB`,`Heap Limit: ${i.limitMB} MB`,`Baseline: ${M??"N/A"} MB`,`Growth: ${xe>0?"+":""}${xe} MB`,`Growth Rate: ${b!==null?`${b.toFixed(2)} MB/min`:"N/A"}`),h&&ce.push("","--- Three.js ---",`Geometries: ${h.geometries}`,`Textures: ${h.textures}`,`Programs: ${h.programs}`),$.agentCount>0&&(ce.push("","--- Agent Memory ---",`Total: ${$.totalMB} MB`,`Agents: ${$.agentCount}`),$.agents.slice(0,5).forEach(ee=>{ce.push(` ${ee.name}: ${ee.memoryMB} MB (${ee.status})`)})),j&&ce.push("","--- DOM ---",`DOM Nodes: ${j.nodeCount.toLocaleString()}`,`Canvases: ${j.canvasCount}`,`Images: ${j.imageCount}`,`Videos: ${j.videoCount}`),E&&ce.push("","--- Estimated Memory ---",`GPU Textures: ${E.count}`,`Est. VRAM: ~${E.estimatedMB} MB`,`Est. DOM: ~${Math.round(((j==null?void 0:j.nodeCount)??0)*.5/1024)} MB`,`Est. Total: ~${((i==null?void 0:i.usedMB)??0)+E.estimatedMB+Math.round(((j==null?void 0:j.nodeCount)??0)*.5/1024)} MB`),T&&(ce.push("","--- Server ---",`Uptime: ${F(T.uptime)}`,`Heap: ${T.process.heapUsedMB}/${T.process.heapTotalMB} MB`,`RSS: ${T.process.rssMB} MB`,`Load Avg: ${T.system.loadAvg.join(" ")}`,`System Memory: ${T.system.totalMemMB-T.system.freeMemMB}/${T.system.totalMemMB} MB`,"","--- WebSocket ---",`Clients: ${T.websocket.clients}`,`Sent: ${T.websocket.messagesSent}`,`Received: ${T.websocket.messagesReceived}`,"","--- HTTP ---",`Req/sec: ${T.http.reqPerSec}`,`Avg Latency: ${T.http.avgLatencyMs} ms`,`Max Latency: ${T.http.maxLatencyMs} ms`),T.agents.processes.length>0&&(ce.push("","--- Agent Processes ---",`Total: ${T.agents.total} (${T.agents.working} working, ${T.agents.idle} idle)`),T.agents.processes.forEach(ee=>{ce.push(` ${ee.name}: ${ee.memoryMB!=null?`${ee.memoryMB}MB`:"N/A"} (${ee.status})${ee.pid?` PID:${ee.pid}`:""}`)})));const me=ce.join(`
|
|
152
|
+
`);navigator.clipboard.writeText(me).then(()=>{const ee=Z.currentTarget,re=ee.textContent;ee.textContent="Copied!",setTimeout(()=>{ee.textContent=re},1e3)})},style:{flex:1,background:"rgba(74, 255, 158, 0.3)",border:"1px solid rgba(74, 255, 158, 0.5)",color:"#4aff9e",padding:"4px 6px",borderRadius:"3px",fontSize:"9px",cursor:"pointer"},children:"Copy Stats"}),o.jsx("button",{onClick:Z=>{Z.stopPropagation(),su.report();const ce=window.__tideScene;ce!=null&&ce.logMemoryDiagnostics&&ce.logMemoryDiagnostics()},style:{flex:1,background:"rgba(74, 158, 255, 0.3)",border:"1px solid rgba(74, 158, 255, 0.5)",color:"#4a9eff",padding:"4px 6px",borderRadius:"3px",fontSize:"9px",cursor:"pointer"},children:"Console"}),o.jsx("button",{onClick:Z=>{Z.stopPropagation(),Xb.clear(),Nf.reset(),su.reset(),r([]),f([]);const ce=su.getUsage();ce&&R(ce.usedMB)},style:{flex:1,background:"rgba(255, 74, 74, 0.3)",border:"1px solid rgba(255, 74, 74, 0.5)",color:"#ff4a4a",padding:"4px 6px",borderRadius:"3px",fontSize:"9px",cursor:"pointer"},children:"Reset"})]})]})]})}function CW(){const t=o1(),e=x.useCallback(n=>{U.setViewMode(n)},[]);return[t,e]}const AW=["3d","2d","dashboard"],jW=x.memo(function({className:e=""}){const{t:n}=dt(["common"]),[s,a]=CW(),r=x.useRef(null),[i,c]=x.useState(null);x.useLayoutEffect(()=>{const f=r.current;if(!f)return;const h=f.querySelector(".view-mode-toggle__btn--active");h&&c({left:h.offsetLeft,width:h.offsetWidth})},[s]);const d=x.useCallback(f=>{if(f!==s){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:f}})),f==="3d"){requestAnimationFrame(()=>a(f));return}a(f)}},[s,a]);return o.jsxs("div",{className:`view-mode-toggle ${e}`,ref:r,children:[i&&o.jsx("div",{className:"view-mode-toggle__indicator",style:{left:i.left,width:i.width}}),AW.map(f=>o.jsxs("button",{className:`view-mode-toggle__btn ${s===f?"view-mode-toggle__btn--active":""}`,onClick:()=>d(f),title:n(`common:viewMode.descriptions.${f}`),children:[o.jsxs("span",{className:"view-mode-toggle__icon",children:[f==="2d"&&o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),o.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),o.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]}),f==="3d"&&o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),o.jsx("path",{d:"M2 17l10 5 10-5"}),o.jsx("path",{d:"M2 12l10 5 10-5"})]}),f==="dashboard"&&o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),o.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),o.jsx("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),o.jsx("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]})]}),o.jsx("span",{className:"view-mode-toggle__label",children:n(`common:viewMode.labels.${f}`)})]},f))]})});function JT({className:t}){const{t:e}=dt(["terminal"]),[n,s]=x.useState(!1),[a,r]=x.useState(null),i=My(),c=x.useCallback(async y=>{if(y.trim()){console.log("[VoiceAssistant] Transcribed:",y),s(!0),r(null);try{const C=await(await Bt(Rt("/api/voice-assistant/process"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:y})})).json();if(C.success&&C.response)console.log("[VoiceAssistant] Response:",C.response),i.speak(C.response);else{const N=C.error||e("terminal:voiceAssistant.failedToProcess");console.error("[VoiceAssistant] Error:",N),r(N),i.speak(N)}}catch(w){console.error("[VoiceAssistant] Request failed:",w);const C=e("terminal:voiceAssistant.unavailable");r(C),i.speak(C)}finally{s(!1)}}},[i]),d=UT({language:"Spanish",model:"medium",onTranscription:c}),f=d.recording||d.transcribing||n||i.speaking,h=()=>d.error?`${e("terminal:voiceAssistant.error")}: ${d.error}`:a?`${e("terminal:voiceAssistant.error")}: ${a}`:d.recording?e("terminal:voiceAssistant.recording"):d.transcribing?e("terminal:voiceAssistant.transcribing"):n?e("terminal:voiceAssistant.processing"):i.speaking?e("terminal:voiceAssistant.speaking"):e("terminal:voiceAssistant.title"),m=()=>{const y=["voice-assistant-btn",t].filter(Boolean);return d.recording&&y.push("recording"),(d.transcribing||n)&&y.push("processing"),i.speaking&&y.push("speaking"),(a||d.error)&&y.push("error"),y.join(" ")},b=()=>{if(r(null),i.speaking){i.stop();return}d.transcribing||n||d.toggleRecording()};return o.jsxs("button",{className:m(),onClick:b,title:d.supported?h():e("terminal:voiceAssistant.notSupported"),disabled:!d.supported||d.transcribing||n,children:[d.recording?o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),o.jsx("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"})]}):i.speaking?o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",fill:"currentColor"}),o.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),o.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),o.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),o.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),o.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}),f&&o.jsx("span",{className:"voice-assistant-indicator"})]})}const NW=x.memo(function({isOpen:e,onToggle:n,onShowTerminal:s,onOpenSidebar:a,onOpenToolbox:r,onOpenCommander:i,onOpenSupervisor:c,onOpenControls:d,onOpenSkills:f,onOpenSnapshots:h,onTakeSnapshot:m,canTakeSnapshot:b,mobileView:y}){const{t:w}=dt(["terminal","common"]),C=Vr(),N=k=>{k(),n()};return o.jsxs(o.Fragment,{children:[C.experimentalVoiceAssistant&&o.jsx(JT,{className:"mobile-voice-assistant"}),y!=="terminal"&&o.jsx("button",{className:`mobile-fab-toggle ${e?"open":""}`,onClick:n,onTouchStart:k=>k.stopPropagation(),title:w(e?"terminal:mobileFab.closeMenu":"terminal:mobileFab.openMenu"),children:e?"✕":"☰"}),y==="3d"&&o.jsxs("div",{className:`mobile-fab-menu ${e?"open":""}`,children:[o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(s),onTouchEnd:k=>{k.preventDefault(),N(s)},title:w("terminal:mobileFab.showTerminal"),children:"💬"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(a),onTouchEnd:k=>{k.preventDefault(),N(a)},title:w("terminal:header.openSidebar"),children:"📋"}),b&&o.jsx("button",{className:"mobile-fab-option mobile-fab-option--highlight",onClick:()=>N(m),onTouchEnd:k=>{k.preventDefault(),N(m)},title:w("terminal:mobileFab.takeSnapshot"),children:"⭐"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(r),onTouchEnd:k=>{k.preventDefault(),N(r)},title:w("common:floatingButtons.settingsAndTools"),children:"⚙️"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(i),onTouchEnd:k=>{k.preventDefault(),N(i)},title:w("common:floatingButtons.commanderView"),children:"📊"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(c),onTouchEnd:k=>{k.preventDefault(),N(c)},title:w("common:floatingButtons.supervisorOverview"),children:"🎖️"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(d),onTouchEnd:k=>{k.preventDefault(),N(d)},title:w("common:floatingButtons.controls"),children:"⌨️"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(f),onTouchEnd:k=>{k.preventDefault(),N(f)},title:w("common:floatingButtons.manageSkills"),children:"⭐"}),o.jsx("button",{className:"mobile-fab-option",onClick:()=>N(h),onTouchEnd:k=>{k.preventDefault(),N(h)},title:w("common:floatingButtons.viewSnapshots"),children:"📸"})]})]})}),TW=x.memo(function({onOpenToolbox:e,onOpenCommander:n,onOpenSupervisor:s,onOpenControls:a,onOpenSkills:r,onOpenSnapshots:i,isGeneratingReport:c,pip:d}){const{t:f}=dt(["common","terminal"]),h=Vr();return o.jsxs(o.Fragment,{children:[h.experimentalVoiceAssistant&&o.jsx(JT,{}),o.jsx(os,{content:f("common:floatingButtons.settingsAndTools"),position:"left",children:o.jsx("button",{className:"floating-settings-btn",onClick:e,children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})}),o.jsx(os,{content:f("common:floatingButtons.commanderView"),position:"left",children:o.jsx("button",{className:"commander-toggle-btn",onClick:n,children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),o.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),o.jsx("rect",{x:"3",y:"14",width:"7",height:"7"}),o.jsx("rect",{x:"14",y:"14",width:"7",height:"7"})]})})}),o.jsx(os,{content:f("common:floatingButtons.viewSnapshots"),position:"left",children:o.jsx("button",{className:"snapshots-toggle-btn",onClick:i,children:"📸"})}),o.jsx(os,{content:f(c?"terminal:supervisor.generating":"common:floatingButtons.supervisorOverview"),position:"left",children:o.jsxs("button",{className:`supervisor-toggle-btn ${c?"generating":""}`,onClick:s,children:["🎖️",c&&o.jsx("span",{className:"supervisor-generating-indicator"})]})}),o.jsx(os,{content:f("common:floatingButtons.controls"),position:"left",children:o.jsx("button",{className:"shortcuts-toggle-btn",onClick:a,children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),o.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),o.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),o.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),o.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),o.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),o.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),o.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),o.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]})})}),o.jsx(os,{content:f("common:floatingButtons.manageSkills"),position:"left",children:o.jsx("button",{className:"skills-toggle-btn",onClick:r,children:o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})}),o.jsx(os,{content:d.isSupported?d.isOpen?f("common:floatingButtons.closePip"):f("common:floatingButtons.openPip"):f("common:floatingButtons.pipNotSupported"),position:"left",disabled:!d.isSupported,children:o.jsx("button",{className:`pip-toggle-btn ${d.isOpen?"active":""}`,onClick:()=>d.isSupported&&d.toggle({width:320,height:400}),disabled:!d.isSupported,children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),o.jsx("rect",{x:"12",y:"9",width:"8",height:"6",rx:"1"})]})})})]})}),_W=Ce.lazy(()=>vt(()=>import("./SpawnModal-CGFj_b9I.js"),__vite__mapDeps([17,3,1,4])).then(t=>({default:t.SpawnModal}))),EW=Ce.lazy(()=>vt(()=>import("./BossSpawnModal-DzWs1NNZ.js"),__vite__mapDeps([18,3,1,4])).then(t=>({default:t.BossSpawnModal}))),MW=Ce.lazy(()=>vt(()=>import("./SubordinateAssignmentModal-DGFoupVt.js"),__vite__mapDeps([19,3,1,4])).then(t=>({default:t.SubordinateAssignmentModal}))),DW=Ce.lazy(()=>vt(()=>import("./index-CbzHGOPP.js"),__vite__mapDeps([20,3,1,4,21])).then(t=>({default:t.Toolbox}))),RW=Ce.lazy(()=>vt(()=>import("./index-CxtzptPF.js"),__vite__mapDeps([22,3,1,4])).then(t=>({default:t.BuildingConfigModal}))),OW=Ce.lazy(()=>vt(()=>import("./index-D2_-BBP8.js"),__vite__mapDeps([23,24,3,1,4])).then(t=>({default:t.CommanderView}))),LW=Ce.lazy(()=>vt(()=>import("./SupervisorPanel-B1PVopnm.js"),__vite__mapDeps([25,3,1,4])).then(t=>({default:t.SupervisorPanel}))),IW=Ce.lazy(()=>vt(()=>import("./index-Bmu_CPsU.js").then(t=>t.y),[]).then(t=>({default:t.FileExplorerPanel}))),PW=Ce.lazy(()=>vt(()=>import("./index-CpZt7iSV.js"),__vite__mapDeps([26,3,1,4])).then(t=>({default:t.Spotlight}))),BW=Ce.lazy(()=>vt(()=>import("./ControlsModal-D2QDZ20h.js"),__vite__mapDeps([27,3,1,4])).then(t=>({default:t.ControlsModal}))),FW=Ce.lazy(()=>vt(()=>import("./SkillsPanel-BqZSNfNW.js"),__vite__mapDeps([28,3,1,4])).then(t=>({default:t.SkillsPanel}))),zW=Ce.lazy(()=>vt(()=>Promise.resolve().then(()=>k2),void 0).then(t=>({default:t.AgentEditModal}))),$W=Ce.lazy(()=>vt(()=>import("./SnapshotManager-DyqyIhWz.js"),__vite__mapDeps([29,3,1,4])).then(t=>({default:t.SnapshotManager}))),UW=Ce.lazy(()=>vt(()=>import("./RestoreArchivedAreaModal-DjpKSz7P.js"),__vite__mapDeps([30,3,1,4])).then(t=>({default:t.RestoreArchivedAreaModal}))),HW=Ce.lazy(()=>vt(()=>import("./IntegrationsPanel-DZmbjiXV.js"),__vite__mapDeps([31,3,1,4])).then(t=>({default:t.IntegrationsPanel}))),WW=Ce.lazy(()=>vt(()=>import("./MonitoringModal-CWqjvTra.js"),__vite__mapDeps([32,3,1,4])).then(t=>({default:t.MonitoringModal}))),qW=Ce.lazy(()=>vt(()=>import("./WorkflowEditorPanel-ClMl5U8g.js"),__vite__mapDeps([33,3,1,4])).then(t=>({default:t.WorkflowEditorPanel}))),VW=Ce.lazy(()=>vt(()=>import("./TriggerManagerPanel-CFez7_vm.js"),__vite__mapDeps([34,3,1,4])).then(t=>({default:t.TriggerManagerPanel})));function YW({spawnModal:t,bossSpawnModal:e,subordinateModal:n,toolboxModal:s,commanderModal:a,deleteConfirmModal:r,supervisorModal:i,spotlightModal:c,controlsModal:d,skillsModal:f,integrationsModal:h,monitoringModal:m,workflowEditorModal:b,triggerManagerModal:y,buildingModal:w,agentEditModal:C,snapshotsModal:N,restoreArchivedModal:k,explorerModal:j,contextMenu:S,spawnPosition:T,spawnAreaId:D,explorerFolderPath:E,contextMenuActions:I,buildingInitialPosition:O,sceneConfig:_,onConfigChange:M,onToolChange:R,onOpenAreaExplorer:z,onDeleteSelectedAgents:$,pendingBuildingDelete:W,onCancelBuildingDelete:L,onConfirmBuildingDelete:F,showBackNavModal:H,onCloseBackNavModal:V,onLeave:G,onOpenPM2LogsModal:B,onOpenBossLogsModal:K,onOpenDatabasePanel:ne,onSyncScene:q}){const xe=Rs(),Ae=Array.from(xe.snapshots.values()),Z=xe.snapshotsLoading;xe.currentSnapshot,x.useEffect(()=>{N.isOpen&&U.fetchSnapshots()},[N.isOpen]);const ce=W==="selected",me=W&&W!=="selected"?xe.buildings.get(W):null,ee=xe.selectedBuildingIds.size;return o.jsxs(x.Suspense,{fallback:null,children:[o.jsx(DW,{config:_,onConfigChange:M,onToolChange:R,isOpen:s.isOpen,onClose:s.close,onOpenBuildingModal:re=>w.open(re||null),onOpenAreaExplorer:z,onOpenIntegrationsModal:re=>h.open(re),onOpenMonitoringModal:()=>m.open(),onOpenWorkflowEditor:()=>b.open(),onOpenTriggerManager:()=>y.open()}),o.jsx(RW,{isOpen:w.isOpen,onClose:w.close,buildingId:w.data,initialPosition:O||void 0}),o.jsx(_W,{isOpen:t.isOpen,onClose:t.close,onSpawnStart:()=>{},onSpawnEnd:()=>{},spawnPosition:T,spawnAreaId:D}),o.jsx(EW,{isOpen:e.isOpen,onClose:e.close,onSpawnStart:()=>{},onSpawnEnd:()=>{},spawnPosition:T}),o.jsx(MW,{isOpen:n.isOpen,bossId:n.data||"",onClose:n.close}),C.isOpen&&C.data&&(()=>{const re=xe.agents.get(C.data);return re?o.jsx(zW,{agent:re,isOpen:C.isOpen,onClose:C.close}):null})(),r.isOpen&&o.jsx("div",{className:"modal-overlay visible",onClick:r.close,onKeyDown:re=>{re.key==="Escape"&&r.close(),re.key==="Enter"&&$()},children:o.jsxs("div",{className:"modal confirm-modal",onClick:re=>re.stopPropagation(),children:[o.jsx("div",{className:"modal-header",children:"Remove Agents"}),o.jsxs("div",{className:"modal-body confirm-modal-body",children:[o.jsxs("p",{children:["Remove ",xe.selectedAgentIds.size," selected agent",xe.selectedAgentIds.size>1?"s":""," from the battlefield?"]}),o.jsx("p",{className:"confirm-modal-note",children:"Claude Code sessions will continue running in the background."})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:r.close,children:"Cancel"}),o.jsx("button",{className:"btn btn-danger",onClick:$,autoFocus:!0,children:"Remove"})]})]})}),(me||ce)&&o.jsx("div",{className:"modal-overlay visible",onClick:L,onKeyDown:re=>{re.key==="Escape"&&L(),re.key==="Enter"&&F()},children:o.jsxs("div",{className:"modal confirm-modal",onClick:re=>re.stopPropagation(),children:[o.jsxs("div",{className:"modal-header",children:["Delete Building",ce&&ee>1?"s":""]}),o.jsxs("div",{className:"modal-body confirm-modal-body",children:[ce?o.jsxs("p",{children:["Delete ",ee," selected building",ee>1?"s":"","?"]}):o.jsxs("p",{children:["Delete ",o.jsx("strong",{children:me==null?void 0:me.name}),"?"]}),o.jsxs("p",{className:"confirm-modal-note",children:["This will permanently remove the building",ce&&ee>1?"s":""," and ",ce&&ee>1?"their":"its"," configuration."]})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:L,children:"Cancel"}),o.jsx("button",{className:"btn btn-danger",onClick:F,autoFocus:!0,children:"Delete"})]})]})}),H&&o.jsx("div",{className:"modal-overlay navigation-confirm-overlay visible",onClick:V,onKeyDown:re=>{re.key==="Escape"&&V()},children:o.jsxs("div",{className:"modal confirm-modal navigation-confirm-modal",onClick:re=>re.stopPropagation(),children:[o.jsx("div",{className:"modal-header",children:"Leave Tide Commander?"}),o.jsxs("div",{className:"modal-body confirm-modal-body",children:[o.jsx("p",{children:"Are you sure you want to leave this page?"}),o.jsx("p",{className:"confirm-modal-note",children:"Active Claude Code sessions will continue running in the background."})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:V,autoFocus:!0,children:"Stay"}),o.jsx("button",{className:"btn btn-danger",onClick:G,children:"Leave"})]})]})}),o.jsx(x.Profiler,{id:"CommanderView",onRender:yu,children:o.jsx(OW,{isOpen:a.isOpen,onClose:a.close})}),o.jsx(LW,{isOpen:i.isOpen,onClose:i.close}),o.jsx(IW,{isOpen:j.isOpen||E!==null||xe.explorerAreaId!==null,areaId:j.id||xe.explorerAreaId||null,folderPath:E,onChangeArea:re=>j.open(re),onClose:()=>{j.close(),U.closeFileExplorer()}}),o.jsx(PW,{isOpen:c.isOpen,onClose:c.close,onOpenSpawnModal:()=>t.open(),onOpenCommanderView:()=>a.open(),onOpenToolbox:()=>s.open(),onOpenSupervisor:()=>i.open(),onOpenFileExplorer:re=>j.open(re),onOpenPM2LogsModal:B,onOpenBossLogsModal:K,onOpenDatabasePanel:ne,onOpenMonitoringModal:()=>m.open()}),o.jsx(BW,{isOpen:d.isOpen,onClose:d.close}),o.jsx(FW,{isOpen:f.isOpen,onClose:f.close}),o.jsx(HW,{isOpen:h.isOpen,onClose:h.close,initialTab:h.data}),o.jsx(WW,{isOpen:m.isOpen,onClose:m.close}),o.jsx(qW,{isOpen:b.isOpen,onClose:b.close}),o.jsx(VW,{isOpen:y.isOpen,onClose:y.close}),o.jsx(UW,{isOpen:k.isOpen,restorePosition:k.data??null,onClose:k.close,onRestored:q}),N.isOpen&&o.jsx("div",{className:"modal-overlay visible",onClick:N.close,children:o.jsx("div",{className:"modal snapshot-manager-modal",onClick:re=>re.stopPropagation(),children:o.jsx($W,{snapshots:Ae,isLoading:Z,onViewSnapshot:async re=>{await U.loadSnapshot(re),xe.selectedAgentIds.clear(),U.setTerminalOpen(!0),N.close()},onDeleteSnapshot:async re=>{await U.deleteSnapshot(re),await U.fetchSnapshots()},onRestoreSnapshot:async re=>{await U.restoreFiles(re)},onExportSnapshot:async re=>{await U.loadSnapshot(re),N.close()},onClose:N.close})})}),o.jsx(Do,{isOpen:S.isOpen,position:S.screenPosition,worldPosition:S.worldPosition,actions:I,onClose:S.close})]})}function GW({pip:t,title:e="Tide Commander",children:n}){return x.useEffect(()=>{t.pipWindow&&e&&(t.pipWindow.document.title=e)},[t.pipWindow,e]),!t.isOpen||!t.pipContainer?null:ac.createPortal(n,t.pipContainer)}function Oy(t){switch(t){case"working":return"⚡";case"waiting":return"⏳";case"waiting_permission":return"🔐";case"error":return"❌";case"offline":return"💤";case"orphaned":return"👻";case"idle":default:return"●"}}function Ly(t){switch(t){case"working":return"#4aff9e";case"waiting":return"#ff9e4a";case"waiting_permission":return"#ff4a9e";case"error":return"#ff4a4a";case"offline":return"#666";case"orphaned":return"#9e4aff";case"idle":default:return"#888"}}function Iy(t){const e=_o[t.class];return(e==null?void 0:e.icon)||"🤖"}function Rb({agent:t,onClick:e}){const n=Ly(t.status),s=Oy(t.status),a=Iy(t);return o.jsxs("div",{className:`pip-agent-card pip-status-${t.status}`,onClick:()=>e(t.id),title:"Click to view conversation",children:[o.jsxs("div",{className:"pip-agent-header",children:[o.jsx("span",{className:"pip-agent-icon",children:a}),o.jsx("span",{className:"pip-agent-name",children:t.name}),o.jsx("span",{className:"pip-agent-status",style:{color:n},children:s})]}),t.taskLabel&&o.jsxs("div",{className:"pip-agent-task",children:["📋 ",t.taskLabel]}),!t.taskLabel&&t.status==="working"&&t.currentTask&&o.jsx("div",{className:"pip-agent-task",children:t.currentTask.length>60?t.currentTask.slice(0,60)+"...":t.currentTask}),t.currentTool&&o.jsxs("div",{className:"pip-agent-tool",children:[o.jsx("span",{className:"pip-tool-label",children:"Tool:"})," ",t.currentTool]}),o.jsxs("div",{className:"pip-agent-context",children:[o.jsx("div",{className:"pip-context-bar",children:o.jsx("div",{className:"pip-context-fill",style:{width:`${Math.min(Math.round(t.contextUsed/t.contextLimit*100),100)}%`,backgroundColor:t.contextUsed/t.contextLimit*100>80?"#ff4a4a":t.contextUsed/t.contextLimit*100>50?"#ff9e4a":"#4aff9e"}})}),o.jsxs("span",{className:"pip-context-percent",children:[Math.round(t.contextUsed/t.contextLimit*100),"%"]})]})]})}function xu(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}const XA={systemPrompt:"#4a9eff",systemTools:"#9e4aff",messages:"#4aff9e",freeSpace:"rgba(255,255,255,0.1)",autocompactBuffer:"#ff9e4a"},JA={systemPrompt:"System Prompt",systemTools:"System Tools",messages:"Messages",freeSpace:"Free Space",autocompactBuffer:"Autocompact Buffer"};function KW({agent:t,onBack:e}){const n=Iy(t),s=Ly(t.status),a=t.contextStats,r=Math.round(t.contextUsed/t.contextLimit*100),i=t.contextUsed/t.contextLimit*100>80?"#ff4a4a":t.contextUsed/t.contextLimit*100>50?"#ff9e4a":"#4aff9e",c=["systemPrompt","systemTools","messages","autocompactBuffer","freeSpace"];return o.jsxs("div",{className:"pip-container pip-stats-container",children:[o.jsxs("div",{className:"pip-header pip-header-conversation",children:[o.jsx("button",{className:"pip-back-btn",onClick:e,title:"Back to conversation",children:"←"}),o.jsx("span",{className:"pip-agent-icon",children:n}),o.jsx("span",{className:"pip-title",children:t.name}),o.jsx("span",{className:"pip-agent-status-small",style:{color:s},children:Oy(t.status)})]}),o.jsx("div",{className:"pip-stats-content",children:a?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"pip-model-info",children:[o.jsxs("div",{className:"pip-model-info-item",children:[o.jsx("div",{className:"pip-model-info-label",children:"Model"}),o.jsx("div",{className:"pip-model-info-value",children:a.model})]}),o.jsxs("div",{className:"pip-model-info-item",children:[o.jsx("div",{className:"pip-model-info-label",children:"Window"}),o.jsx("div",{className:"pip-model-info-value",children:xu(a.contextWindow)})]})]}),o.jsxs("div",{className:"pip-stats-section",children:[o.jsxs("div",{className:"pip-usage-header",children:[o.jsx("span",{className:"pip-usage-label",children:"Context Usage"}),o.jsxs("span",{className:"pip-usage-value",style:{color:i},children:[xu(a.totalTokens)," / ",xu(a.contextWindow)," (",a.usedPercent,"%)"]})]}),o.jsx("div",{className:"pip-stacked-bar",children:c.map(d=>{const f=a.categories[d];return!f||f.percent<=0?null:o.jsx("div",{className:"pip-stacked-bar-segment",style:{width:`${f.percent}%`,backgroundColor:XA[d]},title:`${JA[d]}: ${xu(f.tokens)}`},d)})})]}),o.jsxs("div",{className:"pip-stats-section",children:[o.jsx("h3",{className:"pip-stats-title",children:"Token Breakdown"}),o.jsx("div",{className:"pip-category-list",children:c.map(d=>{const f=a.categories[d];if(!f)return null;const h=d==="freeSpace";return o.jsxs("div",{className:`pip-category-item ${h?"free-space":""}`,children:[o.jsx("div",{className:"pip-category-color",style:{backgroundColor:XA[d]}}),o.jsxs("div",{className:"pip-category-info",children:[o.jsx("div",{className:"pip-category-name",children:JA[d]}),o.jsxs("div",{className:"pip-category-tokens",children:[xu(f.tokens)," (",f.percent.toFixed(1),"%)"]})]})]},d)})})]}),o.jsxs("div",{className:"pip-stats-updated",children:["Updated: ",new Date(a.lastUpdated).toLocaleTimeString()]})]}):o.jsxs("div",{className:"pip-stats-section",children:[o.jsx("h3",{className:"pip-stats-title",children:"Context Usage"}),o.jsxs("div",{className:"pip-stats-bar-container",children:[o.jsx("div",{className:"pip-stats-bar",children:o.jsx("div",{className:"pip-stats-bar-fill",style:{width:`${Math.min(r,100)}%`,backgroundColor:i}})}),o.jsxs("span",{className:"pip-stats-percent",style:{color:i},children:[r,"%"]})]}),o.jsx("div",{className:"pip-stats-info",children:o.jsx("p",{className:"pip-stats-info-text",children:"Context usage represents how much of the conversation window is filled. Detailed breakdown not available yet."})})]})})]})}function QW({agentId:t,onBack:e}){const n=Kj(t),s=Qj(t),a=r1(),r=i1(),i=Ux(),c=x.useRef(null),d=x.useRef(null),[f,h]=x.useState(""),[m,b]=x.useState(!1),[y]=x.useState("simple"),w=!!(n!=null&&n.sessionId),C=Wj({selectedAgentId:t,hasSessionId:w,reconnectCount:a,historyRefreshTrigger:r,lastPrompts:i,outputScrollRef:c}),N=_T({outputs:s,viewMode:y}),k=x.useMemo(()=>{const{history:$}=C,W=new Map;for(const F of $)F.type==="tool_result"&&F.toolUseId&&W.set(F.toolUseId,F.content);return(F=>F.map(H=>{if(H.type==="tool_use"&&H.toolName==="Bash"&&H.toolUseId){const V=W.get(H.toolUseId);let G;try{G=(H.toolInput||(H.content?JSON.parse(H.content):{})).command}catch{}return{...H,_bashOutput:V,_bashCommand:G}}return H}))($.filter(F=>F.type==="user"||F.type==="assistant"||F.type==="tool_use"))},[C.history]),[j,S]=x.useState({top:!1,bottom:!0}),T=x.useCallback(()=>{if(!c.current)return;const{scrollTop:$,scrollHeight:W,clientHeight:L}=c.current;S({top:$>20,bottom:$<W-L-20})},[]);x.useEffect(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight,T())},[s.length,k.length,T]);const D=x.useCallback(()=>{c.current&&c.current.scrollBy({top:-200,behavior:"smooth"})},[]),E=x.useCallback(()=>{c.current&&c.current.scrollBy({top:200,behavior:"smooth"})},[]),I=x.useCallback(()=>{const $=f.trim();!$||!n||(U.sendCommand(t,$),h(""),setTimeout(()=>{var W;return(W=d.current)==null?void 0:W.focus()},50))},[f,t,n]),O=x.useCallback($=>{h($.target.value)},[]),_=x.useCallback($=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),I())},[I]);x.useEffect(()=>{const $=setTimeout(()=>{var W;return(W=d.current)==null?void 0:W.focus()},100);return()=>clearTimeout($)},[t]);const M=x.useCallback(($,W)=>{const L=sh($,n==null?void 0:n.cwd),F=L.line?{...W||{},targetLine:L.line}:W;U.setFileViewerPath(L.path,F,n==null?void 0:n.cwd)},[n==null?void 0:n.cwd]);if(!n)return o.jsx("div",{className:"pip-container",children:o.jsxs("div",{className:"pip-header pip-header-conversation",children:[o.jsx("button",{className:"pip-back-btn",onClick:e,title:"Back to agents list",children:"←"}),o.jsx("span",{className:"pip-title",children:"Agent not found"})]})});const R=Iy(n),z=Ly(n.status);return m?o.jsx(KW,{agent:n,onBack:()=>b(!1)}):o.jsxs("div",{className:"pip-container pip-conversation-container",children:[o.jsxs("div",{className:"pip-header pip-header-conversation",children:[o.jsx("button",{className:"pip-back-btn",onClick:e,title:"Back to agents list",children:"←"}),o.jsx("span",{className:"pip-agent-icon",children:R}),o.jsx("span",{className:"pip-title",children:n.name}),o.jsx("span",{className:"pip-agent-status-small",style:{color:z},children:Oy(n.status)})]}),o.jsx("div",{className:"pip-context-section",children:o.jsx(y1,{contextInfo:Xp(n),onClick:()=>b(!0)})}),o.jsxs("div",{className:"pip-conversation-wrapper",children:[o.jsxs("div",{className:"pip-conversation guake-output",ref:c,onScroll:T,children:[!C.loadingHistory&&C.hasMore&&o.jsx("div",{className:"guake-load-more pip-load-more",children:C.loadingMore?o.jsx("span",{children:"Loading older messages..."}):o.jsxs("button",{onClick:C.loadMoreHistory,children:["Load more (",C.totalCount-C.history.length," older)"]})}),C.loadingHistory&&o.jsx("div",{className:"pip-loading-indicator",children:o.jsxs("span",{className:"loading-dots",children:[o.jsx("span",{children:"."}),o.jsx("span",{children:"."}),o.jsx("span",{children:"."})]})}),k.map(($,W)=>o.jsx(QT,{message:$,agentId:t,simpleView:!0,onFileClick:M},`h-${W}`)),N.map(($,W)=>o.jsx(Dy,{output:$,agentId:t,onFileClick:M},`o-${W}`)),!C.loadingHistory&&k.length===0&&N.length===0&&n.status!=="working"&&o.jsx("div",{className:"pip-empty",children:o.jsx("p",{children:"No conversation yet"})})]}),o.jsxs("div",{className:"pip-scroll-controls",children:[j.top&&o.jsx("button",{className:"pip-scroll-btn pip-scroll-up",onClick:D,title:"Scroll up",children:"↑"}),j.bottom&&o.jsx("button",{className:"pip-scroll-btn pip-scroll-down",onClick:E,title:"Scroll down",children:"↓"})]})]}),n.currentTool&&o.jsx("div",{className:"pip-current-tool",children:o.jsxs("span",{className:"pip-tool-indicator",children:["Using: ",n.currentTool]})}),o.jsxs("div",{className:"pip-input-area",children:[o.jsx("input",{ref:d,type:"text",className:"pip-input",placeholder:`Message ${n.name}...`,value:f,onChange:O,onKeyDown:_,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),o.jsx("button",{className:"pip-send-btn",onClick:I,disabled:!f.trim(),title:"Send message",children:"➤"})]})]})}function XW({onSelectAgent:t}){const e=Kp(),n=e.filter(c=>c.status==="working"),s=e.filter(c=>c.status==="waiting"||c.status==="waiting_permission"),a=e.filter(c=>c.status!=="working"&&c.status!=="waiting"&&c.status!=="waiting_permission"),r=e.length,i=n.length+s.length;return o.jsxs("div",{className:"pip-container",children:[o.jsxs("div",{className:"pip-header",children:[o.jsx("span",{className:"pip-title",children:"Tide Commander"}),o.jsxs("span",{className:"pip-stats",children:[i,"/",r," active"]})]}),o.jsxs("div",{className:"pip-agents-list",children:[n.length>0&&o.jsxs("div",{className:"pip-section",children:[o.jsxs("div",{className:"pip-section-title",children:["Working (",n.length,")"]}),n.map(c=>o.jsx(Rb,{agent:c,onClick:t},c.id))]}),s.length>0&&o.jsxs("div",{className:"pip-section",children:[o.jsxs("div",{className:"pip-section-title",children:["Waiting (",s.length,")"]}),s.map(c=>o.jsx(Rb,{agent:c,onClick:t},c.id))]}),a.length>0&&o.jsxs("div",{className:"pip-section",children:[o.jsxs("div",{className:"pip-section-title",children:["Idle (",a.length,")"]}),a.map(c=>o.jsx(Rb,{agent:c,onClick:t},c.id))]}),e.length===0&&o.jsx("div",{className:"pip-empty",children:o.jsx("p",{children:"No agents spawned yet"})})]})]})}function JW(){const[t,e]=x.useState(null),n=a=>{e(a)},s=()=>{e(null)};return t?o.jsx(QW,{agentId:t,onBack:s}):o.jsx(XW,{onSelectAgent:n})}function ZW(t){const e=t.trim();if(!e)return{ok:!0,normalizedUrl:""};let n;try{n=new URL(e)}catch{return{ok:!1,normalizedUrl:"",error:"Invalid URL format. Use http://host:port"}}return n.protocol!=="http:"&&n.protocol!=="https:"?{ok:!1,normalizedUrl:"",error:"Unsupported protocol. Use http or https"}:{ok:!0,normalizedUrl:e}}async function eq(t,e=5e3,n=fetch){if(!t)return{ok:!0};const a=`${t.replace(/\/$/,"")}/api/health`,r=new AbortController,i=setTimeout(()=>r.abort(),e);try{const c=await n(a,{method:"GET",cache:"no-store",signal:r.signal});return c.ok?{ok:!0}:{ok:!1,error:`Host reachable but unhealthy (${c.status})`}}catch(c){return c instanceof Error&&c.name==="AbortError"?{ok:!1,error:"Connection timed out while checking host"}:{ok:!1,error:"Host unreachable. Check URL, host, and port"}}finally{clearTimeout(i)}}const tq=4e3;function nq(){const t=Jj(),[e,n]=x.useState(!1),[s,a]=x.useState(!1),[r,i]=x.useState(!0),[c,d]=x.useState(()=>Rx()),[f,h]=x.useState(!1),[m,b]=x.useState(null),[y,w]=x.useState(null),C=x.useRef(!0),N=x.useCallback((D=7e3)=>U.getState().isConnected?Promise.resolve(!0):new Promise(E=>{let I=!1;const O=R=>{I||(I=!0,clearTimeout(M),_(),E(R))},_=U.subscribe(()=>{U.getState().isConnected&&O(!0)}),M=setTimeout(()=>O(!1),D)}),[]);x.useEffect(()=>{const D=setTimeout(()=>i(!1),3e3);return()=>clearTimeout(D)},[]),x.useEffect(()=>()=>{C.current=!1},[]),x.useEffect(()=>VD(D=>{d(D)}),[]);const k=x.useCallback(()=>{navigator.clipboard.writeText("bunx tide-commander").then(()=>{a(!0),setTimeout(()=>a(!1),2e3)}).catch(()=>{})},[]),j=x.useCallback(async()=>{if(f)return;const D=Date.now(),E=()=>tq-(Date.now()-D);b(null),w("Validating URL");const I=c.trim()||"http://localhost:6200",O=ZW(I);if(!O.ok){w(null),b(O.error||"Invalid backend URL");return}h(!0),w("Checking host reachability");const _=E();if(_<=0){h(!1),w(null),b("Connection timeout after 4 seconds");return}const M=await eq(O.normalizedUrl,_);if(!M.ok){if(!C.current)return;h(!1),w(null),E()<=0?b("Connection timeout after 4 seconds"):b(M.error||"Failed to reach host");return}qD(O.normalizedUrl),w("Connecting to server"),zR();const R=E();if(R<=0){h(!1),w(null),b("Connection timeout after 4 seconds");return}const z=await N(R);if(C.current){if(!z){h(!1),w(null),E()<=0?b("Connection timeout after 4 seconds"):b("Could not establish WebSocket connection. Verify host and auth token, then retry");return}h(!1),w("Connected"),b(null)}},[c,f,N]),S=x.useCallback(D=>{D.key==="Enter"&&!f&&j()},[j,f]),T=x.useCallback(()=>{n(!0)},[]);return t||e||r?null:o.jsx("div",{className:"not-connected-overlay",children:o.jsxs("div",{className:"not-connected-panel",children:[o.jsx("h2",{className:"not-connected-title",children:"Tide Commander"}),o.jsx("p",{className:"not-connected-description",children:"A visual multi-agent orchestrator for Claude Code and Codex. Deploy, control, and monitor your AI team from an RTS-inspired interface."}),o.jsx("p",{className:"not-connected-privacy",children:"Tide Commander syncs with Claude Code instances running on your local machine. No files or code are sent to this server."}),o.jsxs("div",{className:"not-connected-setup",children:[o.jsx("p",{className:"not-connected-setup-label",children:"Get started:"}),o.jsxs("div",{className:"not-connected-code",onClick:k,title:"Click to copy",children:[o.jsx("span",{children:"bunx tide-commander"}),o.jsx("span",{className:"not-connected-copy-icon",children:s?"✓":"⧉"})]})]}),o.jsxs("div",{className:"not-connected-url-section",children:[o.jsx("label",{className:"not-connected-url-label",htmlFor:"backend-url",children:"Backend URL"}),o.jsx("div",{className:"not-connected-url-row",children:o.jsx("input",{id:"backend-url",type:"text",className:"not-connected-url-input",placeholder:"http://localhost:6200",value:c,disabled:f,onChange:D=>{const E=D.target.value;d(E),m&&b(null)},onKeyDown:S})}),o.jsx("span",{className:"config-hint",children:"Leave empty for auto-detect"}),y&&!m&&o.jsx("div",{className:"not-connected-status","aria-live":"polite",children:y}),m&&o.jsx("div",{className:"not-connected-error","aria-live":"assertive",children:m})]}),o.jsxs("div",{className:"not-connected-actions",children:[o.jsx("button",{className:"not-connected-btn not-connected-btn-retry",onClick:()=>{j()},disabled:f,children:f?"Connecting...":"↻ Connect"}),o.jsx("button",{className:"not-connected-btn not-connected-btn-explore",onClick:T,children:"Explore"})]})]})})}const ZA="tide-onboarding-dismissed";function sq({onCreateAgent:t}){const{t:e}=dt("common"),n=Jj(),s=Gj(),[a,r]=x.useState(()=>sessionStorage.getItem(ZA)==="1"),i=n&&!a&&s===0,c=x.useCallback(()=>{r(!0),sessionStorage.setItem(ZA,"1")},[]),d=x.useCallback(()=>{c(),t()},[c,t]),f=x.useCallback(h=>{h.key==="Escape"&&c()},[c]);return i?o.jsx(pr,{children:o.jsx("div",{className:"modal-overlay visible",onClick:c,onKeyDown:f,children:o.jsxs("div",{className:"modal onboarding-modal",onClick:h=>h.stopPropagation(),children:[o.jsxs("div",{className:"onboarding-header",children:[o.jsx("h2",{children:e("onboarding.title")}),o.jsx("p",{className:"onboarding-subtitle",children:e("onboarding.subtitle")})]}),o.jsxs("div",{className:"onboarding-steps",children:[o.jsxs("div",{className:"onboarding-step",children:[o.jsx("span",{className:"onboarding-step-number",children:"1"}),o.jsxs("div",{children:[o.jsx("strong",{children:e("onboarding.step1Title")}),o.jsx("p",{children:e("onboarding.step1Desc")})]})]}),o.jsxs("div",{className:"onboarding-step",children:[o.jsx("span",{className:"onboarding-step-number",children:"2"}),o.jsxs("div",{children:[o.jsx("strong",{children:e("onboarding.step2Title")}),o.jsx("p",{children:e("onboarding.step2Desc")})]})]}),o.jsxs("div",{className:"onboarding-step",children:[o.jsx("span",{className:"onboarding-step-number",children:"3"}),o.jsxs("div",{children:[o.jsx("strong",{children:e("onboarding.step3Title")}),o.jsx("p",{children:e("onboarding.step3Desc")})]})]})]}),o.jsxs("div",{className:"onboarding-actions",children:[o.jsx("button",{className:"btn onboarding-cta",onClick:d,autoFocus:!0,children:e("onboarding.createFirst")}),o.jsx("button",{className:"btn btn-secondary",onClick:c,children:e("onboarding.explore")})]})]})})}):null}function ZT(){return{"Content-Type":"application/json","X-Auth-Token":Ii()}}async function aq(t){const e=await fetch(`${Ea()}/api/areas/${t}/organize`,{method:"POST",headers:ZT()});if(!e.ok)throw new Error(`Failed to organize area: ${e.statusText}`);const n=await e.json();return{organized:Array.isArray(n.organized)?n.organized:[],buildings:Array.isArray(n.buildings)?n.buildings:[]}}async function rq(){const t=await fetch(`${Ea()}/api/areas/organize-all`,{method:"POST",headers:ZT()});if(!t.ok)throw new Error(`Failed to organize all areas: ${t.statusText}`);const e=await t.json();return Array.isArray(e.organized)?{organized:e.organized,buildings:Array.isArray(e.buildings)?e.buildings:[]}:(Array.isArray(e.results)?e.results:[]).reduce((n,s)=>(n.organized.push(...s.organized),n.buildings.push(...s.buildings),n),{organized:[],buildings:[]})}function e_(t,e){var s,a;const n=U.getState();for(const r of t.organized){const i=n.agents.get(r.agentId);if(i){const c={...i,position:r.position};U.updateAgent(c),(s=e.current)==null||s.updateAgent(c,!0)}}for(const r of t.buildings){const i=n.buildings.get(r.buildingId);i&&(U.updateBuilding(r.buildingId,{position:r.position}),(a=e.current)==null||a.updateBuilding({...i,position:r.position}))}}function iq(t,e,n,s,a,r){const i=[];if(e.type==="agent"&&e.id){const d=n.get(e.id);if(d)return i.push({id:"select-agent",label:`Select ${d.name}`,icon:"👆",onClick:()=>{var f;U.selectAgent(e.id),(f=r.sceneRef.current)==null||f.refreshSelectionVisuals()}}),i.push({id:"focus-agent",label:"Focus Camera",icon:"🎯",onClick:()=>{var f;(f=r.sceneRef.current)==null||f.focusAgent(e.id)}}),i.push({id:"open-terminal",label:"Open Terminal",icon:"💬",onClick:()=>{U.selectAgent(e.id),U.setTerminalOpen(!0)}}),i.push({id:"edit-agent",label:"Edit Agent",icon:"✏️",onClick:()=>{r.openAgentEditModal(e.id)}}),i.push({id:"divider-agent",label:"",divider:!0,onClick:()=>{}}),i.push({id:"delete-agent",label:`Remove ${d.name}`,icon:"❌",danger:!0,onClick:()=>{var f;U.removeAgentFromServer(e.id),(f=r.sceneRef.current)==null||f.removeAgent(e.id),r.showToast("info","Agent Removed",`${d.name} removed from view`)}}),i}if(e.type==="area"&&e.id){const d=s.get(e.id);if(d)return i.push({id:"select-area",label:`Select "${d.name}"`,icon:"📐",onClick:()=>{U.selectArea(e.id),r.openToolboxModal()}}),d.directories&&d.directories.length>0&&i.push({id:"open-explorer",label:"Open File Explorer",icon:"📁",onClick:()=>{r.openExplorerModal(e.id)}}),i.push({id:"divider-area-layer",label:"",divider:!0,onClick:()=>{}}),i.push({id:"bring-to-front",label:"Bring to Front",icon:"⬆️",onClick:()=>{var f;U.bringAreaToFront(e.id),(f=r.sceneRef.current)==null||f.syncAreas()}}),i.push({id:"send-to-back",label:"Send to Back",icon:"⬇️",onClick:()=>{var f;U.sendAreaToBack(e.id),(f=r.sceneRef.current)==null||f.syncAreas()}}),d.assignedAgentIds.length>0&&i.push({id:"organize-area",label:"Organize Area",icon:"✨",onClick:()=>{aq(e.id).then(f=>{e_(f,r.sceneRef),r.showToast("success","Area Organized",`Arranged ${f.organized.length} agent${f.organized.length!==1?"s":""} in "${d.name}"`)}).catch(f=>{console.error("organize area error:",f),r.showToast("error","Organize Failed",f.message||"Failed to organize area")})}}),i.push({id:"divider-area",label:"",divider:!0,onClick:()=>{}}),i.push({id:"archive-area",label:`Archive "${d.name}"`,icon:"📦",onClick:()=>{var m,b;const f=d.assignedAgentIds.length;U.archiveArea(e.id,y=>U.stopAgent(y)),(m=r.sceneRef.current)==null||m.syncAreas(),(b=r.sceneRef.current)==null||b.syncAgents(Array.from(U.getState().agents.values()));const h=f>0?` (${f} agent${f>1?"s":""} stopped)`:"";r.showToast("info","Zone Archived",`"${d.name}" has been archived${h}`)}}),i.push({id:"delete-area",label:`Delete "${d.name}"`,icon:"🗑️",danger:!0,onClick:()=>{var f;U.deleteArea(e.id),(f=r.sceneRef.current)==null||f.syncAreas(),r.showToast("info","Area Deleted",`"${d.name}" has been deleted`)}}),i}if(e.type==="building"&&e.id){const d=a.get(e.id);if(d)return i.push({id:"select-building",label:`Select "${d.name}"`,icon:"🏢",onClick:()=>{U.selectBuilding(e.id),r.openToolboxModal()}}),i.push({id:"edit-building",label:"Edit Building",icon:"✏️",onClick:()=>{r.openBuildingModal(e.id)}}),i.push({id:"clone-building",label:"Clone Building",icon:"📋",onClick:()=>{const f={name:`${d.name} (Copy)`,type:d.type,style:d.style,color:d.color,scale:d.scale,position:{x:d.position.x+2,z:d.position.z+2},cwd:d.cwd,folderPath:d.folderPath,commands:d.commands,pm2:d.pm2,docker:d.docker,database:d.database,urls:d.urls,subordinateBuildingIds:d.subordinateBuildingIds};U.createBuilding(f),r.showToast("success","Building Cloned",`Created "${f.name}"`)}}),d.type==="folder"&&d.folderPath&&i.push({id:"open-folder",label:"Open Folder",icon:"📁",onClick:()=>{U.openFileExplorer(d.folderPath)}}),i.push({id:"divider-building",label:"",divider:!0,onClick:()=>{}}),i.push({id:"delete-building",label:`Delete "${d.name}"`,icon:"🗑️",danger:!0,onClick:()=>{r.requestBuildingDelete(e.id)}}),i}i.push({id:"spawn-agent",label:"Spawn Agent Here",icon:"🤖",shortcut:"N",onClick:()=>{r.setSpawnPosition(t),r.openSpawnModal()}}),i.push({id:"spawn-boss",label:"Spawn Boss Here",icon:"👑",onClick:()=>{r.setSpawnPosition(t),r.openBossSpawnModal()}}),i.push({id:"divider-1",label:"",divider:!0,onClick:()=>{}}),i.push({id:"draw-area",label:"Draw Area",icon:"📐",onClick:()=>{var d;(d=r.sceneRef.current)==null||d.setDrawingTool("rectangle"),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool("rectangle"),r.showToast("info","Rectangle Tool","Click and drag on the battlefield to draw an area")}}),i.push({id:"new-building",label:"Place Building",icon:"🏢",onClick:()=>{r.openBuildingModal(null)}});const c=Array.from(s.values()).filter(d=>d.archived).length;return c>0&&i.push({id:"restore-archived",label:`Restore Archived Zone (${c})`,icon:"📦",onClick:()=>{r.openRestoreArchivedModal(t)}}),i.push({id:"divider-2",label:"",divider:!0,onClick:()=>{}}),i.push({id:"open-settings",label:"Settings",icon:"⚙️",onClick:()=>{r.openToolboxModal()}}),i.push({id:"open-commander",label:"Commander View",icon:"📊",shortcut:"⌘K",onClick:()=>{r.openCommanderModal()}}),i}const oq=Ce.lazy(()=>vt(()=>import("./index-B4SUGrVB.js"),__vite__mapDeps([35,3,1,4,36])).then(t=>({default:t.DatabasePanel}))),lq=Ce.lazy(()=>vt(()=>import("./PM2LogsModal-DRHybuUO.js"),__vite__mapDeps([37,38,3,1,4])).then(t=>({default:t.PM2LogsModal}))),cq=Ce.lazy(()=>vt(()=>import("./DockerLogsModal-Bh1ghgFV.js"),__vite__mapDeps([39,38,3,1,4])).then(t=>({default:t.DockerLogsModal}))),uq=Ce.lazy(()=>vt(()=>import("./BossLogsModal-B6meUM1T.js"),__vite__mapDeps([40,38,3,1,4])).then(t=>({default:t.BossLogsModal}))),dq=Ce.lazy(()=>vt(()=>import("./Scene2DCanvas-CSfRDtXw.js"),__vite__mapDeps([41,3,1,4,42])).then(t=>({default:t.Scene2DCanvas}))),fq=Ce.lazy(()=>vt(()=>import("./index-BK3kI8Cb.js"),__vite__mapDeps([43,3,1,4,44])).then(t=>({default:t.DashboardView}))),pq=Ce.lazy(()=>vt(()=>import("./IframeModal-CGbINL-o.js"),__vite__mapDeps([45,3,1,4,46])).then(t=>({default:t.IframeModal}))),hq=Ce.lazy(()=>vt(()=>import("./SaveSnapshotModal-CWtf3rgg.js"),__vite__mapDeps([47,3,1,4])).then(t=>({default:t.SaveSnapshotModal})));function mq(){const{t}=dt(["common","notifications"]),e=x.useRef(null),n=x.useRef(null),s=cs(),a=cs(),r=cs(),i=cs(),c=cs(),d=cs(),f=cs(),h=cs(),m=cs(),b=cs(),y=cs(),w=cs(),C=cs(),N=cs(),k=cs(),j=cs(),S=cs(),T=cs(),D=cs(),E=YD(),I=JO(),O=GD(),_=rR(),[M,R]=x.useState(null),z=KR(),[$,W]=x.useState(!1),[L,F]=x.useState(null),[H,V]=x.useState(null),[G,B]=x.useState(null),[K,ne]=x.useState(null),[q,xe]=x.useState(null),[Ae,Z]=x.useState(null),[ce,me]=x.useState(null),[ee,re]=x.useState(null),[We,ze]=x.useState(null),[Pe,ge]=x.useState(null),Te=x.useCallback(Ne=>{ge(Ne),Ne&&localStorage.setItem("tide-commander-last-database-building",Ne)},[]),qe=x.useCallback(()=>Te(null),[Te]),{handleMouseDown:it,handleClick:he}=Ta(qe),Be=x.useCallback(()=>ze(null),[]),{handleMouseDown:ie,handleClick:de}=Ta(Be),He=x.useRef(Ae);He.current=Ae;const et=x.useCallback(Ne=>{Z(Ne)},[]),ct=x.useCallback(()=>He.current,[]),fe=x.useRef(null),[X,se]=x.useState($j),[Se,J]=x.useState(0),[pe,Re]=x.useState(!1),[$e,ye]=x.useState(()=>localStorage.getItem("tide-commander-sidebar-collapsed")==="true"),[Ie,te]=x.useState(!1),[be,we]=x.useState(!1),Fe=t1(),Ke=o1(),st=Wx(),ft=qx(),wt=e1(),{showToast:at}=u1(),{showAgentNotification:gt}=AL(),{showBackNavModal:ht,setShowBackNavModal:Gt,handleLeave:tn}=pO();iO({showToast:at,showAgentNotification:gt});const[je,Oe]=x.useState(!1);x.useEffect(()=>{const Ne=Je=>{var ot;((ot=Je.detail)==null?void 0:ot.mode)==="3d"&&Oe(!0)};return window.addEventListener("tide:viewmode-switch-pressed",Ne),()=>{window.removeEventListener("tide:viewmode-switch-pressed",Ne)}},[]),x.useEffect(()=>{Ke==="3d"&&Oe(!0)},[Ke]);const Ye=rO({canvasRef:e,selectionBoxRef:n,viewMode:Ke,sceneMountKey:Se,showToast:at,showAgentNotification:gt,toolboxModal:i,contextMenu:O,setHoveredAgentPopup:xe,setBuildingPopup:et,getBuildingPopup:ct,openBuildingModal:Ne=>k.open(Ne),openPM2LogsModal:Ne=>me(Ne),openBossLogsModal:Ne=>re(Ne),openDatabasePanel:Ne=>Te(Ne),onSceneLoadingChange:Oe}),Ze=Gj(),Ot=ur(),Ft=Hx(),Lt=$x(),Vt=VO(),ln=qO(),bt=WO(),rt=Vr(),xt=GO(),$t=cL(),En=uL(),nn=x.useMemo(()=>Array.from(Lt),[Lt]),Un=x.useRef(!1);Mj("AppContent"),oO(Ye),lO(Ye),cO(Ye),gO(),uO(Ye,ln),dO(Ye,rt.powerSaving),x.useEffect(()=>{var Dn,Fs;if(Un.current||typeof window>"u")return;const Ne=new URLSearchParams(window.location.search),Je=(Dn=Ne.get("agentId"))==null?void 0:Dn.trim(),Ct=(Fs=Ne.get("agentName"))==null?void 0:Fs.trim();if(!Je&&!Ct||Ze===0)return;const ot=U.getState().agents,jn=Ne.get("openTerminal"),Mt=jn?["1","true","yes"].includes(jn.toLowerCase()):!0;let At=Je?ot.get(Je):void 0;if(!At&&Ct){const Qr=Ct.toLowerCase();At=Array.from(ot.values()).find(pa=>pa.name.toLowerCase()===Qr)}if(!At){console.warn("[DeepLink] No matching agent found for query params",{rawAgentId:Je,rawAgentName:Ct}),Un.current=!0;return}U.selectAgent(At.id),Mt&&U.setTerminalOpen(!0),Ne.delete("agentId"),Ne.delete("agentName"),Ne.delete("openTerminal");const kn=Ne.toString(),ms=`${window.location.pathname}${kn?`?${kn}`:""}${window.location.hash}`;window.history.replaceState({},document.title,ms),Un.current=!0},[Ze]),fO({sceneRef:Ye,spawnModal:s,commanderModal:c,explorerModal:E,spotlightModal:h,deleteConfirmModal:d,onRequestBuildingDelete:()=>ne("selected"),onOpenDatabasePanel:Te,onCloseDatabasePanel:qe,databasePanelOpen:Pe!==null}),Xt("spawn-modal",s.isOpen,s.close),Xt("boss-spawn-modal",a.isOpen,a.close),Xt("subordinate-modal",r.isOpen,r.close),Xt("toolbox-modal",i.isOpen,i.close),Xt("commander-modal",c.isOpen,c.close),Xt("delete-confirm-modal",d.isOpen,d.close),Xt("supervisor-modal",f.isOpen,f.close),Xt("spotlight-modal",h.isOpen,h.close),Xt("controls-modal",m.isOpen,m.close),Xt("skills-modal",b.isOpen,b.close),Xt("integrations-modal",y.isOpen,y.close),Xt("monitoring-modal",w.isOpen,w.close),Xt("workflow-editor-modal",C.isOpen,C.close),Xt("trigger-manager-modal",N.isOpen,N.close),Xt("building-modal",k.isOpen,k.close),Xt("agent-edit-modal",j.isOpen,j.close),Xt("snapshots-modal",S.isOpen,S.close),Xt("save-snapshot-modal",T.isOpen,T.close),Xt("explorer-modal",E.isOpen||I!==null,()=>{E.close(),U.closeFileExplorer()}),Xt("context-menu",O.isOpen,O.close),Xt("mobile-sidebar",pe,()=>Re(!1)),Xt("mobile-fab-menu",be,()=>we(!1)),Xt("file-viewer",st!==null,()=>U.clearFileViewerPath()),Xt("context-modal",ft!==null,()=>U.closeContextModal()),Xt("terminal",wt,()=>U.setTerminalOpen(!1)),Xt("pm2-logs-modal",ce!==null,()=>me(null)),Xt("boss-logs-modal",ee!==null,()=>re(null)),Xt("database-panel",Pe!==null,qe),Xt("terminal-modal",We!==null,Be);const Os=x.useRef(wt),ps=x.useRef(b),ks=x.useRef(m);ps.current=b,ks.current=m,x.useEffect(()=>{Os.current&&!wt&&(ps.current.close(),ks.current.close()),Os.current=wt},[wt]),x.useEffect(()=>{},[]),x.useEffect(()=>{if(Fe!=="3d"||Ke!=="3d")return;const Ne=setTimeout(()=>window.dispatchEvent(new Event("resize")),80);return()=>clearTimeout(Ne)},[Fe,Ke]);const Qn=x.useCallback(Ne=>{var Je,Ct,ot,jn,Mt,At,kn,ms,Dn,Fs;se(Ne),sO(Ne),(Je=Ye.current)==null||Je.setCharacterScale(Ne.characterScale),(Ct=Ye.current)==null||Ct.setScale3D(Ne.scale3d),(ot=Ye.current)==null||ot.setGridVisible(Ne.gridVisible),(jn=Ye.current)==null||jn.setTimeMode(Ne.timeMode),(Mt=Ye.current)==null||Mt.setTerrainConfig(Ne.terrain),(At=Ye.current)==null||At.setFloorStyle(Ne.terrain.floorStyle),(kn=Ye.current)==null||kn.setAgentModelStyle(Ne.modelStyle),(ms=Ye.current)==null||ms.setIdleAnimation(Ne.animations.idleAnimation),(Dn=Ye.current)==null||Dn.setWorkingAnimation(Ne.animations.workingAnimation),(Fs=Ye.current)==null||Fs.setFpsLimit(Ne.fpsLimit)},[Ye]),Ss=x.useCallback(Ne=>{var Je;if((Je=Ye.current)==null||Je.setDrawingTool(Ne),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(Ne),Ne==="rectangle"||Ne==="circle"){const Ct=t(Ne==="rectangle"?"notifications:drawing.rectangleTool":"notifications:drawing.circleTool");at("info",Ct,t("notifications:drawing.clickAndDrag"),3e3)}},[Ye,at]),Fn=x.useCallback(Ne=>{var Je;(Je=Ye.current)==null||Je.focusAgent(Ne)},[Ye]),Ls=x.useCallback(Ne=>{U.killAgent(Ne)},[]),Is=x.useCallback(Ne=>{var Je;(Je=Ye.current)==null||Je.callSubordinates(Ne)},[Ye]),wn=x.useCallback(Ne=>{E.open(Ne)},[E]),Po=x.useCallback(()=>{k.open(null)},[k]),Bo=x.useCallback(()=>{var Ne;(Ne=Ye.current)==null||Ne.setDrawingTool("rectangle"),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool("rectangle"),at("info",t("notifications:drawing.rectangleTool"),t("notifications:drawing.clickAndDrag"),3e3)},[Ye,at]),Ps=x.useCallback(Ne=>{R(Ne)},[]),Ua=x.useCallback(()=>{R(null)},[]),Bi=x.useCallback(()=>{const Ne=Array.from(U.getState().selectedAgentIds);Ne.forEach(Je=>{var Ct;U.removeAgentFromServer(Je),(Ct=Ye.current)==null||Ct.removeAgent(Je)}),d.close(),at("info",t("notifications:toast.agentsRemoved"),t("notifications:toast.agentsRemovedMsg",{count:Ne.length}))},[at,d,Ye,t]),Fi=x.useCallback(()=>{var Ne,Je;if(K==="selected"){const Ct=Vt.size;U.deleteSelectedBuildings(),(Ne=Ye.current)==null||Ne.syncBuildings(),at("info",t("notifications:toast.buildingsDeleted"),t("notifications:toast.buildingsDeletedMsg",{count:Ct}))}else if(K){const Ct=Ft.get(K);U.deleteBuilding(K),(Je=Ye.current)==null||Je.syncBuildings(),at("info",t("notifications:toast.buildingDeleted"),t("notifications:toast.buildingDeletedMsg",{name:(Ct==null?void 0:Ct.name)||"Building"}))}ne(null)},[K,Ft,Vt.size,at,Ye,t]),Bs=x.useMemo(()=>iq(O.worldPosition,O.target,U.getState().agents,Ot,Ft,{showToast:at,openSpawnModal:()=>s.open(),openBossSpawnModal:()=>a.open(),openToolboxModal:()=>i.open(),openCommanderModal:()=>c.open(),openExplorerModal:Ne=>E.open(Ne),openBuildingModal:Ne=>k.open(Ne),openAgentEditModal:Ne=>j.open(Ne),requestBuildingDelete:Ne=>ne(Ne),setSpawnPosition:F,openRestoreArchivedModal:Ne=>D.open(Ne),sceneRef:Ye}),[O.worldPosition,O.target,Ot,Ft,s,a,k,i,c,E,j,D,at,Ye]);x.useEffect(()=>{!s.isOpen&&!a.isOpen&&(F(null),B(null))},[s.isOpen,a.isOpen]),x.useEffect(()=>{const Ne=Mt=>{const At=Mt.detail;B((At==null?void 0:At.areaId)||null),F((At==null?void 0:At.position)||null),s.open()},Je=Mt=>{var ms,Dn;const At=Mt.detail;if(!(At!=null&&At.buildingId))return;const kn=U.getState().buildings.get(At.buildingId);kn&&(kn.type==="server"&&((ms=kn.pm2)!=null&&ms.enabled)?me(At.buildingId):kn.type==="boss"?re(At.buildingId):kn.type==="database"?Te(At.buildingId):kn.type==="folder"&&kn.folderPath?U.openFileExplorer(kn.folderPath):kn.type==="terminal"&&((Dn=kn.terminalStatus)!=null&&Dn.url)?ze(At.buildingId):k.open(At.buildingId))},Ct=Mt=>{const At=Mt.detail;At!=null&&At.buildingId&&k.open(At.buildingId)},ot=Mt=>{const At=Mt.detail;V((At==null?void 0:At.position)||null),k.open(null)},jn=Mt=>{const At=Mt.detail;At!=null&&At.buildingId?ze(At.buildingId):At!=null&&At.url&&R(At.url)};return window.addEventListener("tide:open-spawn-modal",Ne),window.addEventListener("tide:building-action",Je),window.addEventListener("tide:building-edit",Ct),window.addEventListener("tide:building-create",ot),window.addEventListener("tide:open-iframe-modal",jn),()=>{window.removeEventListener("tide:open-spawn-modal",Ne),window.removeEventListener("tide:building-action",Je),window.removeEventListener("tide:building-edit",Ct),window.removeEventListener("tide:building-create",ot),window.removeEventListener("tide:open-iframe-modal",jn)}},[s,k]);const lc=bt==="rectangle"||bt==="circle",Ma=x.useCallback(()=>{var Ne;(Ne=Ye.current)==null||Ne.setDrawingTool(null),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(null)},[Ye]),Ts=x.useCallback(()=>we(Ne=>!Ne),[]),hs=x.useCallback(()=>U.setMobileView("terminal"),[]),Mn=x.useCallback(()=>Re(!0),[]),zi=nn.length===1&&U.getOutputs(nn[0]).length>0;return o.jsxs("div",{className:`app ${wt?"terminal-open":""} ${lc?"drawing-mode":""} ${$e?"sidebar-collapsed":""} mobile-view-${Fe} view-mode-${Ke}`,children:[o.jsx(nq,{}),o.jsx(sq,{onCreateAgent:s.open}),o.jsx(SW,{visible:rt.showFPS,position:"bottom-right"}),o.jsxs("div",{className:"app-top-bar",children:[o.jsx(jW,{className:"app-view-mode-toggle"}),o.jsx(QR,{}),o.jsxs("button",{className:"app-organize-all-btn",disabled:$,title:"Auto-organize all agents in their areas",onClick:()=>{W(!0),rq().then(Ne=>{e_(Ne,Ye),at("success","Organized",`Arranged ${Ne.organized.length} agent${Ne.organized.length!==1?"s":""}`)}).catch(Ne=>{console.error("organize all error:",Ne),at("error","Organize Failed",Ne.message||"Failed to organize")}).finally(()=>W(!1))},children:[$?"⏳":"✨"," Organize"]})]}),o.jsxs("main",{className:"main-content",children:[o.jsxs("div",{className:"battlefield-container",children:[z&&o.jsxs("div",{className:"workspace-switch-overlay",children:[o.jsx("div",{className:"workspace-switch-spinner"}),o.jsx("span",{className:"workspace-switch-text",children:"Switching workspace..."})]}),o.jsx(Ce.Suspense,{fallback:null,children:Ke==="dashboard"?o.jsx(fq,{onSelectAgent:Ne=>U.selectAgent(Ne),onFocusAgent:Ne=>{U.setViewMode("3d"),Fn(Ne)},onKillAgent:Ls,onSelectBuilding:Ne=>U.selectBuilding(Ne),onOpenTerminal:Ne=>{U.selectAgent(Ne),U.setTerminalOpen(!0)},onFocusZone:Ne=>{U.setViewMode("3d");const Je=U.getState().areas.get(Ne);Je&&Je.assignedAgentIds.length>0&&Fn(Je.assignedAgentIds[0])}}):Ke==="2d"?o.jsx(dq,{onAgentClick:(Ne,Je)=>{Je?U.addToSelection(Ne):U.selectAgent(Ne)},onAgentDoubleClick:Ne=>{if(window.innerWidth<=768){U.openTerminalOnMobile(Ne);return}U.selectAgent(Ne),U.setTerminalOpen(!0)},onBuildingClick:(Ne,Je)=>{U.selectBuilding(Ne);const Ct=U.getState().buildings.get(Ne);(Ct==null?void 0:Ct.type)==="folder"&&Ct.folderPath?U.openFileExplorer(Ct.folderPath):((Ct==null?void 0:Ct.type)==="server"||(Ct==null?void 0:Ct.type)==="boss"||(Ct==null?void 0:Ct.type)==="database")&&(fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{et({buildingId:Ne,screenPos:Je,fromClick:!0}),fe.current=null},150))},onBuildingDoubleClick:Ne=>{var Ct;fe.current&&(clearTimeout(fe.current),fe.current=null),et(null);const Je=U.getState().buildings.get(Ne);(Je==null?void 0:Je.type)==="server"&&((Ct=Je.pm2)!=null&&Ct.enabled)?me(Ne):(Je==null?void 0:Je.type)==="boss"?re(Ne):(Je==null?void 0:Je.type)==="database"?Te(Ne):(Je==null?void 0:Je.type)==="folder"&&Je.folderPath?U.openFileExplorer(Je.folderPath):k.open(Ne)},onGroundClick:()=>{U.selectAgent(null),U.selectBuilding(null)},onAreaDoubleClick:Ne=>{U.selectArea(Ne),i.open()},onContextMenu:(Ne,Je,Ct)=>{const ot=Ct?{type:Ct.type,id:Ct.id}:{type:"ground"};O.open(Ne,Je,ot)},onMoveCommand:(Ne,Je)=>{const ot=Ne.length,jn=[];if(ot===1)jn.push({x:Je.x,y:0,z:Je.z});else if(ot<=6){const Mt=1.2*Math.max(1,ot/3);for(let At=0;At<ot;At++){const kn=At/ot*Math.PI*2-Math.PI/2;jn.push({x:Je.x+Math.cos(kn)*Mt,y:0,z:Je.z+Math.sin(kn)*Mt})}}else{const Mt=Math.ceil(Math.sqrt(ot)),At=Math.ceil(ot/Mt),kn=(Mt-1)*1.2/2,ms=(At-1)*1.2/2;for(let Dn=0;Dn<ot;Dn++){const Fs=Dn%Mt,Qr=Math.floor(Dn/Mt);jn.push({x:Je.x+Fs*1.2-kn,y:0,z:Je.z+Qr*1.2-ms})}}Ne.forEach((Mt,At)=>{U.moveAgent(Mt,jn[At])})},onBuildingDragMove:(Ne,Je)=>{var ot;const Ct=U.getState().buildings.get(Ne);Ct&&(U.getState().buildings.set(Ne,{...Ct,position:{x:Je.x,z:Je.z}}),(ot=window.__tideScene2D)==null||ot.syncBuildings())},onBuildingDragEnd:(Ne,Je)=>{U.updateBuildingPosition(Ne,Je)},scale2d:X.scale2d,showTaskLabels:X.show2DTaskLabels,showGrid:X.gridVisible,fpsLimit:X.fpsLimit}):o.jsxs(Ce.Fragment,{children:[o.jsx("canvas",{ref:e,id:"battlefield",tabIndex:0}),o.jsx("div",{ref:n,id:"selection-box"})]},Se)}),je&&o.jsxs("div",{className:"scene-loading-overlay",children:[o.jsx("div",{className:"scene-loading-overlay__spinner"}),o.jsx("span",{className:"scene-loading-overlay__label",children:"Loading 3D scene…"})]})]}),o.jsx(NW,{isOpen:be,onToggle:Ts,onShowTerminal:hs,onOpenSidebar:Mn,onOpenToolbox:i.open,onOpenCommander:c.open,onOpenSupervisor:f.open,onOpenControls:m.open,onOpenSkills:b.open,onOpenSnapshots:S.open,onTakeSnapshot:T.open,canTakeSnapshot:zi,mobileView:Fe}),pe&&o.jsx("div",{className:"sidebar-overlay",onClick:()=>Re(!1)}),!1,o.jsx("button",{className:`sidebar-collapse-edge-btn ${$e?"is-collapsed":""} ${Ie?"can-pin":""}`,onClick:()=>{if(window.innerWidth<=768)Re(!pe);else{const Je=!$e;ye(Je),localStorage.setItem("tide-commander-sidebar-collapsed",String(Je))}},title:$e?"Open sidebar":"Close sidebar",children:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:Ie?o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"10",r:"3"}),o.jsx("line",{x1:"12",y1:"13",x2:"12",y2:"21"}),o.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]}):o.jsx("polyline",{points:$e?"15 18 9 12 15 6":"9 18 15 12 9 6"})})}),o.jsxs("aside",{className:`sidebar ${pe?"sidebar-open":""} ${$e?"sidebar-collapsed":""}`,children:[o.jsx("button",{className:"sidebar-close-btn show-on-mobile",onClick:()=>Re(!1),title:"Close sidebar",children:"✕"}),nn.length>0?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"sidebar-section unit-section",children:o.jsx(x.Profiler,{id:"UnitPanel",onRender:yu,children:o.jsx(_S,{onFocusAgent:Fn,onKillAgent:Ls,onCallSubordinates:Is,onOpenAreaExplorer:wn})})}),o.jsx("div",{className:"sidebar-section tool-history-section",children:o.jsx(x.Profiler,{id:"ToolHistory",onRender:yu,children:o.jsx(T4,{agentIds:nn})})})]}):o.jsx("div",{className:"sidebar-section unit-section",children:o.jsx(x.Profiler,{id:"UnitPanel",onRender:yu,children:o.jsx(_S,{onFocusAgent:Fn,onKillAgent:Ls,onCallSubordinates:Is,onOpenAreaExplorer:wn})})})]}),o.jsx(x.Profiler,{id:"GuakeOutputPanel",onRender:yu,children:o.jsx(nW,{onSaveSnapshot:T.open})})]}),o.jsx(TW,{onOpenToolbox:i.open,onOpenCommander:c.open,onOpenSupervisor:f.open,onOpenControls:m.open,onOpenSkills:b.open,onOpenSnapshots:S.open,isGeneratingReport:xt,pip:_}),o.jsx(pW,{activeTool:bt,onExit:Ma}),q&&(()=>{const Ne=U.getState().agents.get(q.agentId);return Ne?o.jsx(gW,{agent:Ne,screenPos:q.screenPos,onClose:()=>xe(null)}):null})(),Ae&&(()=>{const Ne=Ft.get(Ae.buildingId);if(!Ne)return null;const Je=()=>et(null);return Ne.type==="boss"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(wW,{building:Ne,screenPos:Ae.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(Ae.buildingId)},onOpenLogsModal:()=>{Je(),re(Ae.buildingId)},onOpenUrlInModal:Ps})]}):Ne.type==="database"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(kW,{building:Ne,screenPos:Ae.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(Ae.buildingId)},onOpenDatabasePanel:()=>{Je(),Te(Ae.buildingId)}})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"building-popup-backdrop",onClick:Je}),o.jsx(xW,{building:Ne,screenPos:Ae.screenPos,onClose:Je,onOpenSettings:()=>{Je(),k.open(Ae.buildingId)},onOpenLogsModal:()=>{me(Ae.buildingId)},onOpenUrlInModal:Ps})]})})(),ce&&(()=>{var Je;const Ne=Ft.get(ce);return Ne?(Je=Ne.docker)!=null&&Je.enabled?o.jsx(cq,{building:Ne,isOpen:!0,onClose:()=>me(null)}):o.jsx(lq,{building:Ne,isOpen:!0,onClose:()=>me(null)}):null})(),ee&&(()=>{const Ne=Ft.get(ee);return Ne?o.jsx(uq,{building:Ne,isOpen:!0,onClose:()=>re(null)}):null})(),Pe&&(()=>{const Ne=Ft.get(Pe);return Ne?o.jsx("div",{className:"modal-overlay visible",onMouseDown:it,onClick:he,children:o.jsx("div",{className:"database-panel-modal",children:o.jsx(oq,{building:Ne,onClose:qe})})}):null})(),We&&(()=>{var Je;const Ne=Ft.get(We);return!Ne||!((Je=Ne.terminalStatus)!=null&&Je.url)?null:o.jsx("div",{className:"modal-overlay visible",onMouseDown:ie,onClick:de,children:o.jsxs("div",{className:"terminal-modal-container",children:[o.jsxs("div",{className:"terminal-modal-header",children:[o.jsxs("span",{className:"terminal-modal-title",children:["Terminal - ",Ne.name]}),o.jsx("button",{className:"terminal-modal-close",onClick:Be,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),o.jsx(Ax,{terminalUrl:Ne.terminalStatus.url,visible:!0})]})})})(),o.jsx(GW,{pip:_,title:"Tide Commander - Agents",children:o.jsx(JW,{})}),o.jsx(pq,{url:M||"",title:M?`Preview - ${M}`:"",isOpen:!!M,onClose:Ua}),T.isOpen&&nn.length===1&&(()=>{const Ne=nn[0],Je=U.getState().agents.get(Ne);if(!Je)return null;const Ct=U.getOutputs(Ne);return o.jsx(hq,{isOpen:T.isOpen,onClose:T.close,agent:Je,outputCount:Ct.length,onSave:async ot=>{try{const jn=Ct.map(Mt=>({type:"message",content:Mt.text,timestamp:new Date(Mt.timestamp).toISOString()}));await U.createSnapshot(ot.agentId,Je.name,ot.title,ot.description,jn,[]),T.close(),at("success",t("notifications:toast.snapshotSaved"),t("notifications:toast.snapshotSavedMsg"))}catch(jn){const Mt=jn instanceof Error?jn.message:t("notifications:toast.snapshotFailedMsg");at("error",t("notifications:toast.snapshotFailed"),Mt)}},isSaving:$t,error:En||void 0})})(),o.jsx(fW,{onFocusAgent:Fn,onSpawnClick:s.open,onSpawnBossClick:a.open,onNewBuildingClick:Po,onNewAreaClick:Bo}),o.jsx(YW,{spawnModal:s,bossSpawnModal:a,subordinateModal:r,toolboxModal:i,commanderModal:c,deleteConfirmModal:d,supervisorModal:f,spotlightModal:h,controlsModal:m,skillsModal:b,integrationsModal:y,monitoringModal:w,workflowEditorModal:C,triggerManagerModal:N,buildingModal:k,buildingInitialPosition:H,agentEditModal:j,snapshotsModal:S,restoreArchivedModal:D,explorerModal:E,contextMenu:O,spawnPosition:L,spawnAreaId:G,explorerFolderPath:I,contextMenuActions:Bs,sceneConfig:X,onConfigChange:Qn,onToolChange:Ss,onOpenAreaExplorer:wn,onDeleteSelectedAgents:Bi,pendingBuildingDelete:K,onCancelBuildingDelete:()=>ne(null),onConfirmBuildingDelete:Fi,showBackNavModal:ht,onCloseBackNavModal:()=>Gt(!1),onLeave:tn,onOpenPM2LogsModal:Ne=>me(Ne),onOpenBossLogsModal:Ne=>re(Ne),onOpenDatabasePanel:Ne=>Te(Ne),onSyncScene:()=>{var Ne,Je;(Ne=Ye.current)==null||Ne.syncAreas(),(Je=Ye.current)==null||Je.syncAgents(Array.from(U.getState().agents.values()))}})]})}function gq(){return o.jsx(xL,{children:o.jsx(CL,{children:o.jsx(mq,{})})})}class bq extends x.Component{constructor(n){super(n);Xe(this,"handleReload",()=>{window.location.reload()});Xe(this,"handleDismiss",()=>{this.setState({hasError:!1,error:null,errorInfo:null})});this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,s){console.error("[Tide] React Error:",n,s),this.setState({errorInfo:s})}render(){if(this.state.hasError){const{error:n,errorInfo:s}=this.state;return o.jsx("div",{style:{position:"fixed",inset:0,background:"#1a1a2e",color:"#fff",fontFamily:"monospace",padding:"32px",overflow:"auto",zIndex:99999},children:o.jsxs("div",{style:{maxWidth:"900px",margin:"0 auto"},children:[o.jsxs("h1",{style:{color:"#ff4a4a",fontSize:"24px",marginBottom:"16px",display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx("span",{style:{fontSize:"32px"},children:"💥"}),On.t("errors:crash.title")]}),o.jsx("div",{style:{background:"#2a2a3e",borderRadius:"8px",padding:"16px",marginBottom:"16px"},children:o.jsxs("div",{style:{color:"#ff6b6b",fontSize:"18px",marginBottom:"8px"},children:[n==null?void 0:n.name,": ",n==null?void 0:n.message]})}),o.jsxs("div",{style:{background:"#2a2a3e",borderRadius:"8px",padding:"16px",marginBottom:"16px"},children:[o.jsx("div",{style:{color:"#888",marginBottom:"8px",fontSize:"12px"},children:On.t("errors:crash.stackTrace")}),o.jsx("pre",{style:{color:"#ccc",fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:n==null?void 0:n.stack})]}),(s==null?void 0:s.componentStack)&&o.jsxs("div",{style:{background:"#2a2a3e",borderRadius:"8px",padding:"16px",marginBottom:"16px"},children:[o.jsx("div",{style:{color:"#888",marginBottom:"8px",fontSize:"12px"},children:On.t("errors:crash.componentStack")}),o.jsx("pre",{style:{color:"#ccc",fontSize:"12px",lineHeight:"1.5",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:s.componentStack})]}),o.jsxs("div",{style:{display:"flex",gap:"12px"},children:[o.jsx("button",{onClick:this.handleReload,style:{background:"#4a9eff",color:"#fff",border:"none",borderRadius:"6px",padding:"12px 24px",fontSize:"14px",cursor:"pointer"},children:On.t("common:buttons.reloadPage")}),o.jsx("button",{onClick:this.handleDismiss,style:{background:"#444",color:"#fff",border:"none",borderRadius:"6px",padding:"12px 24px",fontSize:"14px",cursor:"pointer"},children:On.t("common:buttons.tryToContinue")})]}),o.jsx("div",{style:{marginTop:"24px",color:"#666",fontSize:"12px"},children:On.t("errors:crash.checkConsole")})]})})}return this.props.children}}C6();document.addEventListener("wheel",t=>{if(Math.abs(t.deltaX)>Math.abs(t.deltaY)&&Math.abs(t.deltaX)>0){const e=t.target;if(e.tagName==="CANVAS"){t.preventDefault();return}let n=e;for(;n&&n!==document.documentElement;){if(n.scrollWidth>n.clientWidth)return;n=n.parentElement}t.preventDefault()}},{passive:!1});const t_=document.getElementById("app");if(!t_)throw new Error("Could not find #app container");const xq=SM.createRoot(t_);xq.render(o.jsx(Ce.StrictMode,{children:o.jsx(x.Suspense,{fallback:o.jsx("div",{style:{background:"#0a0a0a",height:"100vh"}}),children:o.jsx(bq,{children:o.jsx(gq,{})})})}));console.log("[Tide] Tide Commander initialized");export{Df as $,jL as A,l1 as B,WD as C,vL as D,Ex as E,sV as F,Tx as G,ed as H,Hx as I,ur as J,$x as K,ZO as L,dr as M,Lq as N,NL as O,Fa as P,iV as Q,NH as R,pt as S,fs as T,Xq as U,Bt as V,g1 as W,rV as X,w2 as Y,Mu as Z,Rf as _,Yx as a,AN as a$,Wr as a0,Qp as a1,Qq as a2,Kj as a3,yp as a4,Cq as a5,yL as a6,qb as a7,Vq as a8,Ii as a9,i5 as aA,I6 as aB,P6 as aC,$6 as aD,Fq as aE,Qj as aF,$q as aG,Uq as aH,Mx as aI,Dx as aJ,np as aK,oV as aL,vt as aM,jN as aN,aV as aO,NN as aP,TN as aQ,Lu as aR,Fr as aS,zr as aT,H6 as aU,W6 as aV,u1 as aW,Ab as aX,q6 as aY,Do as aZ,ph as a_,Sq as aa,Hq as ab,_y as ac,ia as ad,Pu as ae,Up as af,Ea as ag,pr as ah,Rx as ai,VD as aj,On as ak,zR as al,qD as am,Yq as an,Gq as ao,Kq as ap,qq as aq,r1 as ar,rS as as,Oq as at,Xj as au,Xt as av,$H as aw,TT as ax,sh as ay,HD as az,iL as b,da as b0,DN as b1,u5 as b2,Ry as b3,mx as b4,y4 as b5,n1 as b6,Tq as b7,Iq as b8,_q as b9,Pq as ba,Bq as bb,Rq as bc,Mq as bd,zq as be,Kp as bf,IL as bg,b2 as bh,y2 as bi,Jq as bj,_o as bk,Ju as bl,TL as bm,Zq as bn,nV as bo,eV as bp,Dq as bq,Eq as br,tV as bs,$R as bt,UR as bu,su as bv,Ox as bw,Wq as c,oL as d,Ay as e,Rs as f,TH as g,Ta as h,Kl as i,o as j,yS as k,Na as l,Tn as m,jq as n,Aq as o,Nf as p,Fx as q,x as r,U as s,Nq as t,dt as u,Yb as v,Rt as w,YR as x,GR as y,Ce as z};
|