openfox 1.6.91 → 1.6.92
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/{auto-compaction-I4YS2BN4.js → auto-compaction-7AGIGW6F.js} +6 -6
- package/dist/{chat-handler-O4FNSVPI.js → chat-handler-UPAEF6HR.js} +9 -9
- package/dist/{chunk-UQSL65WB.js → chunk-2BS6LMIU.js} +398 -470
- package/dist/{chunk-HKCUSLQ5.js → chunk-2TKN2X2A.js} +3 -3
- package/dist/{chunk-SSGVISQU.js → chunk-7KO2BQFQ.js} +8 -7
- package/dist/{chunk-II4UCFTE.js → chunk-7QG6LY5Q.js} +3 -3
- package/dist/{chunk-CL2ZPJAG.js → chunk-ARJIHQ3S.js} +225 -138
- package/dist/{chunk-H5T34J3H.js → chunk-BHZL3N2F.js} +3 -3
- package/dist/{chunk-MOQLMPTA.js → chunk-CHICEUV6.js} +3 -3
- package/dist/{chunk-STUSQVXQ.js → chunk-RJIPM7CO.js} +2 -2
- package/dist/{chunk-B5AP3RSV.js → chunk-RW25DL5R.js} +3 -3
- package/dist/{chunk-A3YOBYWJ.js → chunk-WBQNIWAQ.js} +5 -5
- package/dist/{chunk-DF5BZBP6.js → chunk-XGJ7HDQ7.js} +2 -2
- package/dist/{chunk-6P5WQP6Y.js → chunk-YTPPQK55.js} +2 -2
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{config-GEDIDCBM.js → config-7XJQNOKX.js} +5 -5
- package/dist/{events-AQKDXJFK.js → events-K6AYMXFT.js} +3 -3
- package/dist/{orchestrator-LLOIG2CR.js → orchestrator-M4WINFF3.js} +7 -7
- package/dist/package.json +1 -1
- package/dist/{processor-XL5NULQN.js → processor-D4XQ5QMB.js} +5 -5
- package/dist/{protocol--8PKNwb_.d.ts → protocol-XRiJzlOK.d.ts} +1 -1
- package/dist/{provider-EV3KBC7Y.js → provider-UO5PAZQQ.js} +7 -7
- package/dist/{runtime-config-CBJJJGBD.js → runtime-config-CYHDAC7W.js} +2 -2
- package/dist/{serve-UWKYNKAO.js → serve-Z5FNJUDT.js} +11 -11
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +9 -9
- package/dist/shared/index.d.ts +2 -2
- package/dist/{tools-ZBAAAOUH.js → tools-NFFQWH6M.js} +6 -6
- package/dist/{vision-fallback-4TAGWGVS.js → vision-fallback-GZZWU7CR.js} +2 -2
- package/dist/web/assets/{index-CGEQK8Pf.css → index-CM0cLwa6.css} +1 -1
- package/dist/web/assets/index-SkaCnTiV.js +176 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/web/assets/index-Cb7XVDFv.js +0 -158
- /package/dist/web/{workbox-8c29f6e4.js → workbox-7fc22fbe.js} +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
var sN=Object.defineProperty;var iN=(e,t,n)=>t in e?sN(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qr=(e,t,n)=>iN(e,typeof t!="symbol"?t+"":t,n);function aN(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const u of o.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function Gu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Df={exports:{}},Go={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Lv;function oN(){if(Lv)return Go;Lv=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var u=null;if(o!==void 0&&(u=""+o),a.key!==void 0&&(u=""+a.key),"key"in a){o={};for(var d in a)d!=="key"&&(o[d]=a[d])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:u,ref:a!==void 0?a:null,props:o}}return Go.Fragment=t,Go.jsx=n,Go.jsxs=n,Go}var Ov;function lN(){return Ov||(Ov=1,Df.exports=oN()),Df.exports}var l=lN(),Mf={exports:{}},We={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react.production.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Iv;function cN(){if(Iv)return We;Iv=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function b(P){return P===null||typeof P!="object"?null:(P=v&&P[v]||P["@@iterator"],typeof P=="function"?P:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,j={};function C(P,V,L){this.props=P,this.context=V,this.refs=j,this.updater=L||_}C.prototype.isReactComponent={},C.prototype.setState=function(P,V){if(typeof P!="object"&&typeof P!="function"&&P!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,P,V,"setState")},C.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function E(){}E.prototype=C.prototype;function A(P,V,L){this.props=P,this.context=V,this.refs=j,this.updater=L||_}var O=A.prototype=new E;O.constructor=A,S(O,C.prototype),O.isPureReactComponent=!0;var z=Array.isArray;function B(){}var Y={H:null,A:null,T:null,S:null},ee=Object.prototype.hasOwnProperty;function ie(P,V,L){var G=L.ref;return{$$typeof:e,type:P,key:V,ref:G!==void 0?G:null,props:L}}function D(P,V){return ie(P.type,V,P.props)}function $(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function H(P){var V={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(L){return V[L]})}var U=/\/+/g;function q(P,V){return typeof P=="object"&&P!==null&&P.key!=null?H(""+P.key):V.toString(36)}function T(P){switch(P.status){case"fulfilled":return P.value;case"rejected":throw P.reason;default:switch(typeof P.status=="string"?P.then(B,B):(P.status="pending",P.then(function(V){P.status==="pending"&&(P.status="fulfilled",P.value=V)},function(V){P.status==="pending"&&(P.status="rejected",P.reason=V)})),P.status){case"fulfilled":return P.value;case"rejected":throw P.reason}}throw P}function N(P,V,L,G,W){var Z=typeof P;(Z==="undefined"||Z==="boolean")&&(P=null);var se=!1;if(P===null)se=!0;else switch(Z){case"bigint":case"string":case"number":se=!0;break;case"object":switch(P.$$typeof){case e:case t:se=!0;break;case m:return se=P._init,N(se(P._payload),V,L,G,W)}}if(se)return W=W(P),se=G===""?"."+q(P,0):G,z(W)?(L="",se!=null&&(L=se.replace(U,"$&/")+"/"),N(W,V,L,"",function(Te){return Te})):W!=null&&($(W)&&(W=D(W,L+(W.key==null||P&&P.key===W.key?"":(""+W.key).replace(U,"$&/")+"/")+se)),V.push(W)),1;se=0;var ve=G===""?".":G+":";if(z(P))for(var Ce=0;Ce<P.length;Ce++)G=P[Ce],Z=ve+q(G,Ce),se+=N(G,V,L,Z,W);else if(Ce=b(P),typeof Ce=="function")for(P=Ce.call(P),Ce=0;!(G=P.next()).done;)G=G.value,Z=ve+q(G,Ce++),se+=N(G,V,L,Z,W);else if(Z==="object"){if(typeof P.then=="function")return N(T(P),V,L,G,W);throw V=String(P),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return se}function F(P,V,L){if(P==null)return P;var G=[],W=0;return N(P,G,"","",function(Z){return V.call(L,Z,W++)}),G}function I(P){if(P._status===-1){var V=P._result;V=V(),V.then(function(L){(P._status===0||P._status===-1)&&(P._status=1,P._result=L)},function(L){(P._status===0||P._status===-1)&&(P._status=2,P._result=L)}),P._status===-1&&(P._status=0,P._result=V)}if(P._status===1)return P._result.default;throw P._result}var J=typeof reportError=="function"?reportError:function(P){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof P=="object"&&P!==null&&typeof P.message=="string"?String(P.message):String(P),error:P});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",P);return}console.error(P)},R={map:F,forEach:function(P,V,L){F(P,function(){V.apply(this,arguments)},L)},count:function(P){var V=0;return F(P,function(){V++}),V},toArray:function(P){return F(P,function(V){return V})||[]},only:function(P){if(!$(P))throw Error("React.Children.only expected to receive a single React element child.");return P}};return We.Activity=g,We.Children=R,We.Component=C,We.Fragment=n,We.Profiler=a,We.PureComponent=A,We.StrictMode=r,We.Suspense=p,We.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Y,We.__COMPILER_RUNTIME={__proto__:null,c:function(P){return Y.H.useMemoCache(P)}},We.cache=function(P){return function(){return P.apply(null,arguments)}},We.cacheSignal=function(){return null},We.cloneElement=function(P,V,L){if(P==null)throw Error("The argument must be a React element, but you passed "+P+".");var G=S({},P.props),W=P.key;if(V!=null)for(Z in V.key!==void 0&&(W=""+V.key),V)!ee.call(V,Z)||Z==="key"||Z==="__self"||Z==="__source"||Z==="ref"&&V.ref===void 0||(G[Z]=V[Z]);var Z=arguments.length-2;if(Z===1)G.children=L;else if(1<Z){for(var se=Array(Z),ve=0;ve<Z;ve++)se[ve]=arguments[ve+2];G.children=se}return ie(P.type,W,G)},We.createContext=function(P){return P={$$typeof:u,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null},P.Provider=P,P.Consumer={$$typeof:o,_context:P},P},We.createElement=function(P,V,L){var G,W={},Z=null;if(V!=null)for(G in V.key!==void 0&&(Z=""+V.key),V)ee.call(V,G)&&G!=="key"&&G!=="__self"&&G!=="__source"&&(W[G]=V[G]);var se=arguments.length-2;if(se===1)W.children=L;else if(1<se){for(var ve=Array(se),Ce=0;Ce<se;Ce++)ve[Ce]=arguments[Ce+2];W.children=ve}if(P&&P.defaultProps)for(G in se=P.defaultProps,se)W[G]===void 0&&(W[G]=se[G]);return ie(P,Z,W)},We.createRef=function(){return{current:null}},We.forwardRef=function(P){return{$$typeof:d,render:P}},We.isValidElement=$,We.lazy=function(P){return{$$typeof:m,_payload:{_status:-1,_result:P},_init:I}},We.memo=function(P,V){return{$$typeof:f,type:P,compare:V===void 0?null:V}},We.startTransition=function(P){var V=Y.T,L={};Y.T=L;try{var G=P(),W=Y.S;W!==null&&W(L,G),typeof G=="object"&&G!==null&&typeof G.then=="function"&&G.then(B,J)}catch(Z){J(Z)}finally{V!==null&&L.types!==null&&(V.types=L.types),Y.T=V}},We.unstable_useCacheRefresh=function(){return Y.H.useCacheRefresh()},We.use=function(P){return Y.H.use(P)},We.useActionState=function(P,V,L){return Y.H.useActionState(P,V,L)},We.useCallback=function(P,V){return Y.H.useCallback(P,V)},We.useContext=function(P){return Y.H.useContext(P)},We.useDebugValue=function(){},We.useDeferredValue=function(P,V){return Y.H.useDeferredValue(P,V)},We.useEffect=function(P,V){return Y.H.useEffect(P,V)},We.useEffectEvent=function(P){return Y.H.useEffectEvent(P)},We.useId=function(){return Y.H.useId()},We.useImperativeHandle=function(P,V,L){return Y.H.useImperativeHandle(P,V,L)},We.useInsertionEffect=function(P,V){return Y.H.useInsertionEffect(P,V)},We.useLayoutEffect=function(P,V){return Y.H.useLayoutEffect(P,V)},We.useMemo=function(P,V){return Y.H.useMemo(P,V)},We.useOptimistic=function(P,V){return Y.H.useOptimistic(P,V)},We.useReducer=function(P,V,L){return Y.H.useReducer(P,V,L)},We.useRef=function(P){return Y.H.useRef(P)},We.useState=function(P){return Y.H.useState(P)},We.useSyncExternalStore=function(P,V,L){return Y.H.useSyncExternalStore(P,V,L)},We.useTransition=function(){return Y.H.useTransition()},We.version="19.2.4",We}var Bv;function Yu(){return Bv||(Bv=1,Mf.exports=cN()),Mf.exports}var k=Yu();const zn=Gu(k),uN=aN({__proto__:null,default:zn},[k]);var Rf={exports:{}},Yo={},Lf={exports:{}},Of={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var zv;function dN(){return zv||(zv=1,(function(e){function t(N,F){var I=N.length;N.push(F);e:for(;0<I;){var J=I-1>>>1,R=N[J];if(0<a(R,F))N[J]=F,N[I]=R,I=J;else break e}}function n(N){return N.length===0?null:N[0]}function r(N){if(N.length===0)return null;var F=N[0],I=N.pop();if(I!==F){N[0]=I;e:for(var J=0,R=N.length,P=R>>>1;J<P;){var V=2*(J+1)-1,L=N[V],G=V+1,W=N[G];if(0>a(L,I))G<R&&0>a(W,L)?(N[J]=W,N[G]=I,J=G):(N[J]=L,N[V]=I,J=V);else if(G<R&&0>a(W,I))N[J]=W,N[G]=I,J=G;else break e}}return F}function a(N,F){var I=N.sortIndex-F.sortIndex;return I!==0?I:N.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var p=[],f=[],m=1,g=null,v=3,b=!1,_=!1,S=!1,j=!1,C=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function O(N){for(var F=n(f);F!==null;){if(F.callback===null)r(f);else if(F.startTime<=N)r(f),F.sortIndex=F.expirationTime,t(p,F);else break;F=n(f)}}function z(N){if(S=!1,O(N),!_)if(n(p)!==null)_=!0,B||(B=!0,H());else{var F=n(f);F!==null&&T(z,F.startTime-N)}}var B=!1,Y=-1,ee=5,ie=-1;function D(){return j?!0:!(e.unstable_now()-ie<ee)}function $(){if(j=!1,B){var N=e.unstable_now();ie=N;var F=!0;try{e:{_=!1,S&&(S=!1,E(Y),Y=-1),b=!0;var I=v;try{t:{for(O(N),g=n(p);g!==null&&!(g.expirationTime>N&&D());){var J=g.callback;if(typeof J=="function"){g.callback=null,v=g.priorityLevel;var R=J(g.expirationTime<=N);if(N=e.unstable_now(),typeof R=="function"){g.callback=R,O(N),F=!0;break t}g===n(p)&&r(p),O(N)}else r(p);g=n(p)}if(g!==null)F=!0;else{var P=n(f);P!==null&&T(z,P.startTime-N),F=!1}}break e}finally{g=null,v=I,b=!1}F=void 0}}finally{F?H():B=!1}}}var H;if(typeof A=="function")H=function(){A($)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,q=U.port2;U.port1.onmessage=$,H=function(){q.postMessage(null)}}else H=function(){C($,0)};function T(N,F){Y=C(function(){N(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(N){N.callback=null},e.unstable_forceFrameRate=function(N){0>N||125<N?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ee=0<N?Math.floor(1e3/N):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(N){switch(v){case 1:case 2:case 3:var F=3;break;default:F=v}var I=v;v=F;try{return N()}finally{v=I}},e.unstable_requestPaint=function(){j=!0},e.unstable_runWithPriority=function(N,F){switch(N){case 1:case 2:case 3:case 4:case 5:break;default:N=3}var I=v;v=N;try{return F()}finally{v=I}},e.unstable_scheduleCallback=function(N,F,I){var J=e.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?J+I:J):I=J,N){case 1:var R=-1;break;case 2:R=250;break;case 5:R=1073741823;break;case 4:R=1e4;break;default:R=5e3}return R=I+R,N={id:m++,callback:F,priorityLevel:N,startTime:I,expirationTime:R,sortIndex:-1},I>J?(N.sortIndex=I,t(f,N),n(p)===null&&N===n(f)&&(S?(E(Y),Y=-1):S=!0,T(z,I-J))):(N.sortIndex=R,t(p,N),_||b||(_=!0,B||(B=!0,H()))),N},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(N){var F=v;return function(){var I=v;v=F;try{return N.apply(this,arguments)}finally{v=I}}}})(Of)),Of}var Pv;function hN(){return Pv||(Pv=1,Lf.exports=dN()),Lf.exports}var If={exports:{}},On={};/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var Hv;function fN(){if(Hv)return On;Hv=1;var e=Yu();function t(p){var f="https://react.dev/errors/"+p;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)f+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+p+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function o(p,f,m){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:g==null?null:""+g,children:p,containerInfo:f,implementation:m}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(p,f){if(p==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return On.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,On.createPortal=function(p,f){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return o(p,f,null,m)},On.flushSync=function(p){var f=u.T,m=r.p;try{if(u.T=null,r.p=2,p)return p()}finally{u.T=f,r.p=m,r.d.f()}},On.preconnect=function(p,f){typeof p=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,r.d.C(p,f))},On.prefetchDNS=function(p){typeof p=="string"&&r.d.D(p)},On.preinit=function(p,f){if(typeof p=="string"&&f&&typeof f.as=="string"){var m=f.as,g=d(m,f.crossOrigin),v=typeof f.integrity=="string"?f.integrity:void 0,b=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;m==="style"?r.d.S(p,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:g,integrity:v,fetchPriority:b}):m==="script"&&r.d.X(p,{crossOrigin:g,integrity:v,fetchPriority:b,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},On.preinitModule=function(p,f){if(typeof p=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var m=d(f.as,f.crossOrigin);r.d.M(p,{crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&r.d.M(p)},On.preload=function(p,f){if(typeof p=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var m=f.as,g=d(m,f.crossOrigin);r.d.L(p,m,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},On.preloadModule=function(p,f){if(typeof p=="string")if(f){var m=d(f.as,f.crossOrigin);r.d.m(p,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else r.d.m(p)},On.requestFormReset=function(p){r.d.r(p)},On.unstable_batchedUpdates=function(p,f){return p(f)},On.useFormState=function(p,f,m){return u.H.useFormState(p,f,m)},On.useFormStatus=function(){return u.H.useHostTransitionStatus()},On.version="19.2.4",On}var Fv;function BS(){if(Fv)return If.exports;Fv=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),If.exports=fN(),If.exports}/**
|
|
34
|
+
* @license React
|
|
35
|
+
* react-dom-client.production.js
|
|
36
|
+
*
|
|
37
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the MIT license found in the
|
|
40
|
+
* LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/var $v;function pN(){if($v)return Yo;$v=1;var e=hN(),t=Yu(),n=BS();function r(s){var i="https://react.dev/errors/"+s;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var c=2;c<arguments.length;c++)i+="&args[]="+encodeURIComponent(arguments[c])}return"Minified React error #"+s+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function o(s){var i=s,c=s;if(s.alternate)for(;i.return;)i=i.return;else{s=i;do i=s,(i.flags&4098)!==0&&(c=i.return),s=i.return;while(s)}return i.tag===3?c:null}function u(s){if(s.tag===13){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null}function d(s){if(s.tag===31){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null}function p(s){if(o(s)!==s)throw Error(r(188))}function f(s){var i=s.alternate;if(!i){if(i=o(s),i===null)throw Error(r(188));return i!==s?null:s}for(var c=s,h=i;;){var x=c.return;if(x===null)break;var y=x.alternate;if(y===null){if(h=x.return,h!==null){c=h;continue}break}if(x.child===y.child){for(y=x.child;y;){if(y===c)return p(x),s;if(y===h)return p(x),i;y=y.sibling}throw Error(r(188))}if(c.return!==h.return)c=x,h=y;else{for(var w=!1,M=x.child;M;){if(M===c){w=!0,c=x,h=y;break}if(M===h){w=!0,h=x,c=y;break}M=M.sibling}if(!w){for(M=y.child;M;){if(M===c){w=!0,c=y,h=x;break}if(M===h){w=!0,h=y,c=x;break}M=M.sibling}if(!w)throw Error(r(189))}}if(c.alternate!==h)throw Error(r(190))}if(c.tag!==3)throw Error(r(188));return c.stateNode.current===c?s:i}function m(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(i=m(s),i!==null)return i;s=s.sibling}return null}var g=Object.assign,v=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),A=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function H(s){return s===null||typeof s!="object"?null:(s=$&&s[$]||s["@@iterator"],typeof s=="function"?s:null)}var U=Symbol.for("react.client.reference");function q(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===U?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case S:return"Fragment";case C:return"Profiler";case j:return"StrictMode";case z:return"Suspense";case B:return"SuspenseList";case ie:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case _:return"Portal";case A:return s.displayName||"Context";case E:return(s._context.displayName||"Context")+".Consumer";case O:var i=s.render;return s=s.displayName,s||(s=i.displayName||i.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case Y:return i=s.displayName||null,i!==null?i:q(s.type)||"Memo";case ee:i=s._payload,s=s._init;try{return q(s(i))}catch{}}return null}var T=Array.isArray,N=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},J=[],R=-1;function P(s){return{current:s}}function V(s){0>R||(s.current=J[R],J[R]=null,R--)}function L(s,i){R++,J[R]=s.current,s.current=i}var G=P(null),W=P(null),Z=P(null),se=P(null);function ve(s,i){switch(L(Z,i),L(W,s),L(G,null),i.nodeType){case 9:case 11:s=(s=i.documentElement)&&(s=s.namespaceURI)?rv(s):0;break;default:if(s=i.tagName,i=i.namespaceURI)i=rv(i),s=sv(i,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}V(G),L(G,s)}function Ce(){V(G),V(W),V(Z)}function Te(s){s.memoizedState!==null&&L(se,s);var i=G.current,c=sv(i,s.type);i!==c&&(L(W,s),L(G,c))}function Pe(s){W.current===s&&(V(G),V(W)),se.current===s&&(V(se),Wo._currentValue=I)}var $e,Re;function Xe(s){if($e===void 0)try{throw Error()}catch(c){var i=c.stack.trim().match(/\n( *(at )?)/);$e=i&&i[1]||"",Re=-1<c.stack.indexOf(`
|
|
42
|
+
at`)?" (<anonymous>)":-1<c.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
43
|
+
`+$e+s+Re}var pt=!1;function gt(s,i){if(!s||pt)return"";pt=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var h={DetermineComponentFrameRoot:function(){try{if(i){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(oe){var re=oe}Reflect.construct(s,[],fe)}else{try{fe.call()}catch(oe){re=oe}s.call(fe.prototype)}}else{try{throw Error()}catch(oe){re=oe}(fe=s())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(oe){if(oe&&re&&typeof oe.stack=="string")return[oe.stack,re.stack]}return[null,null]}};h.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var x=Object.getOwnPropertyDescriptor(h.DetermineComponentFrameRoot,"name");x&&x.configurable&&Object.defineProperty(h.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=h.DetermineComponentFrameRoot(),w=y[0],M=y[1];if(w&&M){var K=w.split(`
|
|
44
|
+
`),ne=M.split(`
|
|
45
|
+
`);for(x=h=0;h<K.length&&!K[h].includes("DetermineComponentFrameRoot");)h++;for(;x<ne.length&&!ne[x].includes("DetermineComponentFrameRoot");)x++;if(h===K.length||x===ne.length)for(h=K.length-1,x=ne.length-1;1<=h&&0<=x&&K[h]!==ne[x];)x--;for(;1<=h&&0<=x;h--,x--)if(K[h]!==ne[x]){if(h!==1||x!==1)do if(h--,x--,0>x||K[h]!==ne[x]){var ue=`
|
|
46
|
+
`+K[h].replace(" at new "," at ");return s.displayName&&ue.includes("<anonymous>")&&(ue=ue.replace("<anonymous>",s.displayName)),ue}while(1<=h&&0<=x);break}}}finally{pt=!1,Error.prepareStackTrace=c}return(c=s?s.displayName||s.name:"")?Xe(c):""}function kt(s,i){switch(s.tag){case 26:case 27:case 5:return Xe(s.type);case 16:return Xe("Lazy");case 13:return s.child!==i&&i!==null?Xe("Suspense Fallback"):Xe("Suspense");case 19:return Xe("SuspenseList");case 0:case 15:return gt(s.type,!1);case 11:return gt(s.type.render,!1);case 1:return gt(s.type,!0);case 31:return Xe("Activity");default:return""}}function ct(s){try{var i="",c=null;do i+=kt(s,c),c=s,s=s.return;while(s);return i}catch(h){return`
|
|
47
|
+
Error generating stack: `+h.message+`
|
|
48
|
+
`+h.stack}}var ut=Object.prototype.hasOwnProperty,me=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,ce=e.unstable_shouldYield,Ae=e.unstable_requestPaint,Ie=e.unstable_now,an=e.unstable_getCurrentPriorityLevel,le=e.unstable_ImmediatePriority,xe=e.unstable_UserBlockingPriority,Me=e.unstable_NormalPriority,Be=e.unstable_LowPriority,ot=e.unstable_IdlePriority,Cn=e.log,Vn=e.unstable_setDisableYieldValue,on=null,Bt=null;function ae(s){if(typeof Cn=="function"&&Vn(s),Bt&&typeof Bt.setStrictMode=="function")try{Bt.setStrictMode(on,s)}catch{}}var we=Math.clz32?Math.clz32:xr,qe=Math.log,dt=Math.LN2;function xr(s){return s>>>=0,s===0?32:31-(qe(s)/dt|0)|0}var de=256,ge=262144,Se=4194304;function Ue(s){var i=s&42;if(i!==0)return i;switch(s&-s){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 s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function it(s,i,c){var h=s.pendingLanes;if(h===0)return 0;var x=0,y=s.suspendedLanes,w=s.pingedLanes;s=s.warmLanes;var M=h&134217727;return M!==0?(h=M&~y,h!==0?x=Ue(h):(w&=M,w!==0?x=Ue(w):c||(c=M&~s,c!==0&&(x=Ue(c))))):(M=h&~y,M!==0?x=Ue(M):w!==0?x=Ue(w):c||(c=h&~s,c!==0&&(x=Ue(c)))),x===0?0:i!==0&&i!==x&&(i&y)===0&&(y=x&-x,c=i&-i,y>=c||y===32&&(c&4194048)!==0)?i:x}function He(s,i){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&i)===0}function Nn(s,i){switch(s){case 1:case 2:case 4:case 8:case 64:return i+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 i+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 Yt(){var s=Se;return Se<<=1,(Se&62914560)===0&&(Se=4194304),s}function ln(s){for(var i=[],c=0;31>c;c++)i.push(s);return i}function Zi(s,i){s.pendingLanes|=i,i!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function yd(s,i,c,h,x,y){var w=s.pendingLanes;s.pendingLanes=c,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=c,s.entangledLanes&=c,s.errorRecoveryDisabledLanes&=c,s.shellSuspendCounter=0;var M=s.entanglements,K=s.expirationTimes,ne=s.hiddenUpdates;for(c=w&~c;0<c;){var ue=31-we(c),fe=1<<ue;M[ue]=0,K[ue]=-1;var re=ne[ue];if(re!==null)for(ne[ue]=null,ue=0;ue<re.length;ue++){var oe=re[ue];oe!==null&&(oe.lane&=-536870913)}c&=~fe}h!==0&&Pg(s,h,0),y!==0&&x===0&&s.tag!==0&&(s.suspendedLanes|=y&~(w&~i))}function Pg(s,i,c){s.pendingLanes|=i,s.suspendedLanes&=~i;var h=31-we(i);s.entangledLanes|=i,s.entanglements[h]=s.entanglements[h]|1073741824|c&261930}function Hg(s,i){var c=s.entangledLanes|=i;for(s=s.entanglements;c;){var h=31-we(c),x=1<<h;x&i|s[h]&i&&(s[h]|=i),c&=~x}}function Fg(s,i){var c=i&-i;return c=(c&42)!==0?1:bd(c),(c&(s.suspendedLanes|i))!==0?0:c}function bd(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=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:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function vd(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function $g(){var s=F.p;return s!==0?s:(s=window.event,s===void 0?32:jv(s.type))}function Ug(s,i){var c=F.p;try{return F.p=s,i()}finally{F.p=c}}var Ms=Math.random().toString(36).slice(2),jn="__reactFiber$"+Ms,Kn="__reactProps$"+Ms,Qi="__reactContainer$"+Ms,_d="__reactEvents$"+Ms,Kk="__reactListeners$"+Ms,Gk="__reactHandles$"+Ms,Wg="__reactResources$"+Ms,so="__reactMarker$"+Ms;function Sd(s){delete s[jn],delete s[Kn],delete s[_d],delete s[Kk],delete s[Gk]}function Ji(s){var i=s[jn];if(i)return i;for(var c=s.parentNode;c;){if(i=c[Qi]||c[jn]){if(c=i.alternate,i.child!==null||c!==null&&c.child!==null)for(s=dv(s);s!==null;){if(c=s[jn])return c;s=dv(s)}return i}s=c,c=s.parentNode}return null}function ea(s){if(s=s[jn]||s[Qi]){var i=s.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return s}return null}function io(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s.stateNode;throw Error(r(33))}function ta(s){var i=s[Wg];return i||(i=s[Wg]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function mn(s){s[so]=!0}var qg=new Set,Vg={};function fi(s,i){na(s,i),na(s+"Capture",i)}function na(s,i){for(Vg[s]=i,s=0;s<i.length;s++)qg.add(i[s])}var Yk=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]*$"),Kg={},Gg={};function Xk(s){return ut.call(Gg,s)?!0:ut.call(Kg,s)?!1:Yk.test(s)?Gg[s]=!0:(Kg[s]=!0,!1)}function Gl(s,i,c){if(Xk(i))if(c===null)s.removeAttribute(i);else{switch(typeof c){case"undefined":case"function":case"symbol":s.removeAttribute(i);return;case"boolean":var h=i.toLowerCase().slice(0,5);if(h!=="data-"&&h!=="aria-"){s.removeAttribute(i);return}}s.setAttribute(i,""+c)}}function Yl(s,i,c){if(c===null)s.removeAttribute(i);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(i);return}s.setAttribute(i,""+c)}}function as(s,i,c,h){if(h===null)s.removeAttribute(c);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(c);return}s.setAttributeNS(i,c,""+h)}}function yr(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function Yg(s){var i=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function Zk(s,i,c){var h=Object.getOwnPropertyDescriptor(s.constructor.prototype,i);if(!s.hasOwnProperty(i)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var x=h.get,y=h.set;return Object.defineProperty(s,i,{configurable:!0,get:function(){return x.call(this)},set:function(w){c=""+w,y.call(this,w)}}),Object.defineProperty(s,i,{enumerable:h.enumerable}),{getValue:function(){return c},setValue:function(w){c=""+w},stopTracking:function(){s._valueTracker=null,delete s[i]}}}}function wd(s){if(!s._valueTracker){var i=Yg(s)?"checked":"value";s._valueTracker=Zk(s,i,""+s[i])}}function Xg(s){if(!s)return!1;var i=s._valueTracker;if(!i)return!0;var c=i.getValue(),h="";return s&&(h=Yg(s)?s.checked?"true":"false":s.value),s=h,s!==c?(i.setValue(s),!0):!1}function Xl(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var Qk=/[\n"\\]/g;function br(s){return s.replace(Qk,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function kd(s,i,c,h,x,y,w,M){s.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?s.type=w:s.removeAttribute("type"),i!=null?w==="number"?(i===0&&s.value===""||s.value!=i)&&(s.value=""+yr(i)):s.value!==""+yr(i)&&(s.value=""+yr(i)):w!=="submit"&&w!=="reset"||s.removeAttribute("value"),i!=null?Cd(s,w,yr(i)):c!=null?Cd(s,w,yr(c)):h!=null&&s.removeAttribute("value"),x==null&&y!=null&&(s.defaultChecked=!!y),x!=null&&(s.checked=x&&typeof x!="function"&&typeof x!="symbol"),M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?s.name=""+yr(M):s.removeAttribute("name")}function Zg(s,i,c,h,x,y,w,M){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(s.type=y),i!=null||c!=null){if(!(y!=="submit"&&y!=="reset"||i!=null)){wd(s);return}c=c!=null?""+yr(c):"",i=i!=null?""+yr(i):c,M||i===s.value||(s.value=i),s.defaultValue=i}h=h??x,h=typeof h!="function"&&typeof h!="symbol"&&!!h,s.checked=M?s.checked:!!h,s.defaultChecked=!!h,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(s.name=w),wd(s)}function Cd(s,i,c){i==="number"&&Xl(s.ownerDocument)===s||s.defaultValue===""+c||(s.defaultValue=""+c)}function ra(s,i,c,h){if(s=s.options,i){i={};for(var x=0;x<c.length;x++)i["$"+c[x]]=!0;for(c=0;c<s.length;c++)x=i.hasOwnProperty("$"+s[c].value),s[c].selected!==x&&(s[c].selected=x),x&&h&&(s[c].defaultSelected=!0)}else{for(c=""+yr(c),i=null,x=0;x<s.length;x++){if(s[x].value===c){s[x].selected=!0,h&&(s[x].defaultSelected=!0);return}i!==null||s[x].disabled||(i=s[x])}i!==null&&(i.selected=!0)}}function Qg(s,i,c){if(i!=null&&(i=""+yr(i),i!==s.value&&(s.value=i),c==null)){s.defaultValue!==i&&(s.defaultValue=i);return}s.defaultValue=c!=null?""+yr(c):""}function Jg(s,i,c,h){if(i==null){if(h!=null){if(c!=null)throw Error(r(92));if(T(h)){if(1<h.length)throw Error(r(93));h=h[0]}c=h}c==null&&(c=""),i=c}c=yr(i),s.defaultValue=c,h=s.textContent,h===c&&h!==""&&h!==null&&(s.value=h),wd(s)}function sa(s,i){if(i){var c=s.firstChild;if(c&&c===s.lastChild&&c.nodeType===3){c.nodeValue=i;return}}s.textContent=i}var Jk=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 ex(s,i,c){var h=i.indexOf("--")===0;c==null||typeof c=="boolean"||c===""?h?s.setProperty(i,""):i==="float"?s.cssFloat="":s[i]="":h?s.setProperty(i,c):typeof c!="number"||c===0||Jk.has(i)?i==="float"?s.cssFloat=c:s[i]=(""+c).trim():s[i]=c+"px"}function tx(s,i,c){if(i!=null&&typeof i!="object")throw Error(r(62));if(s=s.style,c!=null){for(var h in c)!c.hasOwnProperty(h)||i!=null&&i.hasOwnProperty(h)||(h.indexOf("--")===0?s.setProperty(h,""):h==="float"?s.cssFloat="":s[h]="");for(var x in i)h=i[x],i.hasOwnProperty(x)&&c[x]!==h&&ex(s,x,h)}else for(var y in i)i.hasOwnProperty(y)&&ex(s,y,i[y])}function Nd(s){if(s.indexOf("-")===-1)return!1;switch(s){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 eC=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"]]),tC=/^[\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 Zl(s){return tC.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function os(){}var jd=null;function Ed(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var ia=null,aa=null;function nx(s){var i=ea(s);if(i&&(s=i.stateNode)){var c=s[Kn]||null;e:switch(s=i.stateNode,i.type){case"input":if(kd(s,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name),i=c.name,c.type==="radio"&&i!=null){for(c=s;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll('input[name="'+br(""+i)+'"][type="radio"]'),i=0;i<c.length;i++){var h=c[i];if(h!==s&&h.form===s.form){var x=h[Kn]||null;if(!x)throw Error(r(90));kd(h,x.value,x.defaultValue,x.defaultValue,x.checked,x.defaultChecked,x.type,x.name)}}for(i=0;i<c.length;i++)h=c[i],h.form===s.form&&Xg(h)}break e;case"textarea":Qg(s,c.value,c.defaultValue);break e;case"select":i=c.value,i!=null&&ra(s,!!c.multiple,i,!1)}}}var Td=!1;function rx(s,i,c){if(Td)return s(i,c);Td=!0;try{var h=s(i);return h}finally{if(Td=!1,(ia!==null||aa!==null)&&(zc(),ia&&(i=ia,s=aa,aa=ia=null,nx(i),s)))for(i=0;i<s.length;i++)nx(s[i])}}function ao(s,i){var c=s.stateNode;if(c===null)return null;var h=c[Kn]||null;if(h===null)return null;c=h[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(h=!h.disabled)||(s=s.type,h=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!h;break e;default:s=!1}if(s)return null;if(c&&typeof c!="function")throw Error(r(231,i,typeof c));return c}var ls=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ad=!1;if(ls)try{var oo={};Object.defineProperty(oo,"passive",{get:function(){Ad=!0}}),window.addEventListener("test",oo,oo),window.removeEventListener("test",oo,oo)}catch{Ad=!1}var Rs=null,Dd=null,Ql=null;function sx(){if(Ql)return Ql;var s,i=Dd,c=i.length,h,x="value"in Rs?Rs.value:Rs.textContent,y=x.length;for(s=0;s<c&&i[s]===x[s];s++);var w=c-s;for(h=1;h<=w&&i[c-h]===x[y-h];h++);return Ql=x.slice(s,1<h?1-h:void 0)}function Jl(s){var i=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&i===13&&(s=13)):s=i,s===10&&(s=13),32<=s||s===13?s:0}function ec(){return!0}function ix(){return!1}function Gn(s){function i(c,h,x,y,w){this._reactName=c,this._targetInst=x,this.type=h,this.nativeEvent=y,this.target=w,this.currentTarget=null;for(var M in s)s.hasOwnProperty(M)&&(c=s[M],this[M]=c?c(y):y[M]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?ec:ix,this.isPropagationStopped=ix,this}return g(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=ec)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=ec)},persist:function(){},isPersistent:ec}),i}var pi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tc=Gn(pi),lo=g({},pi,{view:0,detail:0}),nC=Gn(lo),Md,Rd,co,nc=g({},lo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Od,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==co&&(co&&s.type==="mousemove"?(Md=s.screenX-co.screenX,Rd=s.screenY-co.screenY):Rd=Md=0,co=s),Md)},movementY:function(s){return"movementY"in s?s.movementY:Rd}}),ax=Gn(nc),rC=g({},nc,{dataTransfer:0}),sC=Gn(rC),iC=g({},lo,{relatedTarget:0}),Ld=Gn(iC),aC=g({},pi,{animationName:0,elapsedTime:0,pseudoElement:0}),oC=Gn(aC),lC=g({},pi,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),cC=Gn(lC),uC=g({},pi,{data:0}),ox=Gn(uC),dC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hC={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"},fC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function pC(s){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(s):(s=fC[s])?!!i[s]:!1}function Od(){return pC}var mC=g({},lo,{key:function(s){if(s.key){var i=dC[s.key]||s.key;if(i!=="Unidentified")return i}return s.type==="keypress"?(s=Jl(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?hC[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Od,charCode:function(s){return s.type==="keypress"?Jl(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Jl(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),gC=Gn(mC),xC=g({},nc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),lx=Gn(xC),yC=g({},lo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Od}),bC=Gn(yC),vC=g({},pi,{propertyName:0,elapsedTime:0,pseudoElement:0}),_C=Gn(vC),SC=g({},nc,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),wC=Gn(SC),kC=g({},pi,{newState:0,oldState:0}),CC=Gn(kC),NC=[9,13,27,32],Id=ls&&"CompositionEvent"in window,uo=null;ls&&"documentMode"in document&&(uo=document.documentMode);var jC=ls&&"TextEvent"in window&&!uo,cx=ls&&(!Id||uo&&8<uo&&11>=uo),ux=" ",dx=!1;function hx(s,i){switch(s){case"keyup":return NC.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fx(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var oa=!1;function EC(s,i){switch(s){case"compositionend":return fx(i);case"keypress":return i.which!==32?null:(dx=!0,ux);case"textInput":return s=i.data,s===ux&&dx?null:s;default:return null}}function TC(s,i){if(oa)return s==="compositionend"||!Id&&hx(s,i)?(s=sx(),Ql=Dd=Rs=null,oa=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return cx&&i.locale!=="ko"?null:i.data;default:return null}}var AC={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 px(s){var i=s&&s.nodeName&&s.nodeName.toLowerCase();return i==="input"?!!AC[s.type]:i==="textarea"}function mx(s,i,c,h){ia?aa?aa.push(h):aa=[h]:ia=h,i=qc(i,"onChange"),0<i.length&&(c=new tc("onChange","change",null,c,h),s.push({event:c,listeners:i}))}var ho=null,fo=null;function DC(s){Zb(s,0)}function rc(s){var i=io(s);if(Xg(i))return s}function gx(s,i){if(s==="change")return i}var xx=!1;if(ls){var Bd;if(ls){var zd="oninput"in document;if(!zd){var yx=document.createElement("div");yx.setAttribute("oninput","return;"),zd=typeof yx.oninput=="function"}Bd=zd}else Bd=!1;xx=Bd&&(!document.documentMode||9<document.documentMode)}function bx(){ho&&(ho.detachEvent("onpropertychange",vx),fo=ho=null)}function vx(s){if(s.propertyName==="value"&&rc(fo)){var i=[];mx(i,fo,s,Ed(s)),rx(DC,i)}}function MC(s,i,c){s==="focusin"?(bx(),ho=i,fo=c,ho.attachEvent("onpropertychange",vx)):s==="focusout"&&bx()}function RC(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return rc(fo)}function LC(s,i){if(s==="click")return rc(i)}function OC(s,i){if(s==="input"||s==="change")return rc(i)}function IC(s,i){return s===i&&(s!==0||1/s===1/i)||s!==s&&i!==i}var rr=typeof Object.is=="function"?Object.is:IC;function po(s,i){if(rr(s,i))return!0;if(typeof s!="object"||s===null||typeof i!="object"||i===null)return!1;var c=Object.keys(s),h=Object.keys(i);if(c.length!==h.length)return!1;for(h=0;h<c.length;h++){var x=c[h];if(!ut.call(i,x)||!rr(s[x],i[x]))return!1}return!0}function _x(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Sx(s,i){var c=_x(s);s=0;for(var h;c;){if(c.nodeType===3){if(h=s+c.textContent.length,s<=i&&h>=i)return{node:c,offset:i-s};s=h}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=_x(c)}}function wx(s,i){return s&&i?s===i?!0:s&&s.nodeType===3?!1:i&&i.nodeType===3?wx(s,i.parentNode):"contains"in s?s.contains(i):s.compareDocumentPosition?!!(s.compareDocumentPosition(i)&16):!1:!1}function kx(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var i=Xl(s.document);i instanceof s.HTMLIFrameElement;){try{var c=typeof i.contentWindow.location.href=="string"}catch{c=!1}if(c)s=i.contentWindow;else break;i=Xl(s.document)}return i}function Pd(s){var i=s&&s.nodeName&&s.nodeName.toLowerCase();return i&&(i==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||i==="textarea"||s.contentEditable==="true")}var BC=ls&&"documentMode"in document&&11>=document.documentMode,la=null,Hd=null,mo=null,Fd=!1;function Cx(s,i,c){var h=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Fd||la==null||la!==Xl(h)||(h=la,"selectionStart"in h&&Pd(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),mo&&po(mo,h)||(mo=h,h=qc(Hd,"onSelect"),0<h.length&&(i=new tc("onSelect","select",null,i,c),s.push({event:i,listeners:h}),i.target=la)))}function mi(s,i){var c={};return c[s.toLowerCase()]=i.toLowerCase(),c["Webkit"+s]="webkit"+i,c["Moz"+s]="moz"+i,c}var ca={animationend:mi("Animation","AnimationEnd"),animationiteration:mi("Animation","AnimationIteration"),animationstart:mi("Animation","AnimationStart"),transitionrun:mi("Transition","TransitionRun"),transitionstart:mi("Transition","TransitionStart"),transitioncancel:mi("Transition","TransitionCancel"),transitionend:mi("Transition","TransitionEnd")},$d={},Nx={};ls&&(Nx=document.createElement("div").style,"AnimationEvent"in window||(delete ca.animationend.animation,delete ca.animationiteration.animation,delete ca.animationstart.animation),"TransitionEvent"in window||delete ca.transitionend.transition);function gi(s){if($d[s])return $d[s];if(!ca[s])return s;var i=ca[s],c;for(c in i)if(i.hasOwnProperty(c)&&c in Nx)return $d[s]=i[c];return s}var jx=gi("animationend"),Ex=gi("animationiteration"),Tx=gi("animationstart"),zC=gi("transitionrun"),PC=gi("transitionstart"),HC=gi("transitioncancel"),Ax=gi("transitionend"),Dx=new Map,Ud="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Ud.push("scrollEnd");function Rr(s,i){Dx.set(s,i),fi(i,[s])}var sc=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},vr=[],ua=0,Wd=0;function ic(){for(var s=ua,i=Wd=ua=0;i<s;){var c=vr[i];vr[i++]=null;var h=vr[i];vr[i++]=null;var x=vr[i];vr[i++]=null;var y=vr[i];if(vr[i++]=null,h!==null&&x!==null){var w=h.pending;w===null?x.next=x:(x.next=w.next,w.next=x),h.pending=x}y!==0&&Mx(c,x,y)}}function ac(s,i,c,h){vr[ua++]=s,vr[ua++]=i,vr[ua++]=c,vr[ua++]=h,Wd|=h,s.lanes|=h,s=s.alternate,s!==null&&(s.lanes|=h)}function qd(s,i,c,h){return ac(s,i,c,h),oc(s)}function xi(s,i){return ac(s,null,null,i),oc(s)}function Mx(s,i,c){s.lanes|=c;var h=s.alternate;h!==null&&(h.lanes|=c);for(var x=!1,y=s.return;y!==null;)y.childLanes|=c,h=y.alternate,h!==null&&(h.childLanes|=c),y.tag===22&&(s=y.stateNode,s===null||s._visibility&1||(x=!0)),s=y,y=y.return;return s.tag===3?(y=s.stateNode,x&&i!==null&&(x=31-we(c),s=y.hiddenUpdates,h=s[x],h===null?s[x]=[i]:h.push(i),i.lane=c|536870912),y):null}function oc(s){if(50<Bo)throw Bo=0,ef=null,Error(r(185));for(var i=s.return;i!==null;)s=i,i=s.return;return s.tag===3?s.stateNode:null}var da={};function FC(s,i,c,h){this.tag=s,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=h,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function sr(s,i,c,h){return new FC(s,i,c,h)}function Vd(s){return s=s.prototype,!(!s||!s.isReactComponent)}function cs(s,i){var c=s.alternate;return c===null?(c=sr(s.tag,i,s.key,s.mode),c.elementType=s.elementType,c.type=s.type,c.stateNode=s.stateNode,c.alternate=s,s.alternate=c):(c.pendingProps=i,c.type=s.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=s.flags&65011712,c.childLanes=s.childLanes,c.lanes=s.lanes,c.child=s.child,c.memoizedProps=s.memoizedProps,c.memoizedState=s.memoizedState,c.updateQueue=s.updateQueue,i=s.dependencies,c.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},c.sibling=s.sibling,c.index=s.index,c.ref=s.ref,c.refCleanup=s.refCleanup,c}function Rx(s,i){s.flags&=65011714;var c=s.alternate;return c===null?(s.childLanes=0,s.lanes=i,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,i=c.dependencies,s.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),s}function lc(s,i,c,h,x,y){var w=0;if(h=s,typeof s=="function")Vd(s)&&(w=1);else if(typeof s=="string")w=V2(s,c,G.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case ie:return s=sr(31,c,i,x),s.elementType=ie,s.lanes=y,s;case S:return yi(c.children,x,y,i);case j:w=8,x|=24;break;case C:return s=sr(12,c,i,x|2),s.elementType=C,s.lanes=y,s;case z:return s=sr(13,c,i,x),s.elementType=z,s.lanes=y,s;case B:return s=sr(19,c,i,x),s.elementType=B,s.lanes=y,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case A:w=10;break e;case E:w=9;break e;case O:w=11;break e;case Y:w=14;break e;case ee:w=16,h=null;break e}w=29,c=Error(r(130,s===null?"null":typeof s,"")),h=null}return i=sr(w,c,i,x),i.elementType=s,i.type=h,i.lanes=y,i}function yi(s,i,c,h){return s=sr(7,s,h,i),s.lanes=c,s}function Kd(s,i,c){return s=sr(6,s,null,i),s.lanes=c,s}function Lx(s){var i=sr(18,null,null,0);return i.stateNode=s,i}function Gd(s,i,c){return i=sr(4,s.children!==null?s.children:[],s.key,i),i.lanes=c,i.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},i}var Ox=new WeakMap;function _r(s,i){if(typeof s=="object"&&s!==null){var c=Ox.get(s);return c!==void 0?c:(i={value:s,source:i,stack:ct(i)},Ox.set(s,i),i)}return{value:s,source:i,stack:ct(i)}}var ha=[],fa=0,cc=null,go=0,Sr=[],wr=0,Ls=null,Fr=1,$r="";function us(s,i){ha[fa++]=go,ha[fa++]=cc,cc=s,go=i}function Ix(s,i,c){Sr[wr++]=Fr,Sr[wr++]=$r,Sr[wr++]=Ls,Ls=s;var h=Fr;s=$r;var x=32-we(h)-1;h&=~(1<<x),c+=1;var y=32-we(i)+x;if(30<y){var w=x-x%5;y=(h&(1<<w)-1).toString(32),h>>=w,x-=w,Fr=1<<32-we(i)+x|c<<x|h,$r=y+s}else Fr=1<<y|c<<x|h,$r=s}function Yd(s){s.return!==null&&(us(s,1),Ix(s,1,0))}function Xd(s){for(;s===cc;)cc=ha[--fa],ha[fa]=null,go=ha[--fa],ha[fa]=null;for(;s===Ls;)Ls=Sr[--wr],Sr[wr]=null,$r=Sr[--wr],Sr[wr]=null,Fr=Sr[--wr],Sr[wr]=null}function Bx(s,i){Sr[wr++]=Fr,Sr[wr++]=$r,Sr[wr++]=Ls,Fr=i.id,$r=i.overflow,Ls=s}var En=null,Tt=null,at=!1,Os=null,kr=!1,Zd=Error(r(519));function Is(s){var i=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw xo(_r(i,s)),Zd}function zx(s){var i=s.stateNode,c=s.type,h=s.memoizedProps;switch(i[jn]=s,i[Kn]=h,c){case"dialog":tt("cancel",i),tt("close",i);break;case"iframe":case"object":case"embed":tt("load",i);break;case"video":case"audio":for(c=0;c<Po.length;c++)tt(Po[c],i);break;case"source":tt("error",i);break;case"img":case"image":case"link":tt("error",i),tt("load",i);break;case"details":tt("toggle",i);break;case"input":tt("invalid",i),Zg(i,h.value,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name,!0);break;case"select":tt("invalid",i);break;case"textarea":tt("invalid",i),Jg(i,h.value,h.defaultValue,h.children)}c=h.children,typeof c!="string"&&typeof c!="number"&&typeof c!="bigint"||i.textContent===""+c||h.suppressHydrationWarning===!0||tv(i.textContent,c)?(h.popover!=null&&(tt("beforetoggle",i),tt("toggle",i)),h.onScroll!=null&&tt("scroll",i),h.onScrollEnd!=null&&tt("scrollend",i),h.onClick!=null&&(i.onclick=os),i=!0):i=!1,i||Is(s,!0)}function Px(s){for(En=s.return;En;)switch(En.tag){case 5:case 31:case 13:kr=!1;return;case 27:case 3:kr=!0;return;default:En=En.return}}function pa(s){if(s!==En)return!1;if(!at)return Px(s),at=!0,!1;var i=s.tag,c;if((c=i!==3&&i!==27)&&((c=i===5)&&(c=s.type,c=!(c!=="form"&&c!=="button")||gf(s.type,s.memoizedProps)),c=!c),c&&Tt&&Is(s),Px(s),i===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Tt=uv(s)}else if(i===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Tt=uv(s)}else i===27?(i=Tt,Xs(s.type)?(s=_f,_f=null,Tt=s):Tt=i):Tt=En?Nr(s.stateNode.nextSibling):null;return!0}function bi(){Tt=En=null,at=!1}function Qd(){var s=Os;return s!==null&&(Qn===null?Qn=s:Qn.push.apply(Qn,s),Os=null),s}function xo(s){Os===null?Os=[s]:Os.push(s)}var Jd=P(null),vi=null,ds=null;function Bs(s,i,c){L(Jd,i._currentValue),i._currentValue=c}function hs(s){s._currentValue=Jd.current,V(Jd)}function eh(s,i,c){for(;s!==null;){var h=s.alternate;if((s.childLanes&i)!==i?(s.childLanes|=i,h!==null&&(h.childLanes|=i)):h!==null&&(h.childLanes&i)!==i&&(h.childLanes|=i),s===c)break;s=s.return}}function th(s,i,c,h){var x=s.child;for(x!==null&&(x.return=s);x!==null;){var y=x.dependencies;if(y!==null){var w=x.child;y=y.firstContext;e:for(;y!==null;){var M=y;y=x;for(var K=0;K<i.length;K++)if(M.context===i[K]){y.lanes|=c,M=y.alternate,M!==null&&(M.lanes|=c),eh(y.return,c,s),h||(w=null);break e}y=M.next}}else if(x.tag===18){if(w=x.return,w===null)throw Error(r(341));w.lanes|=c,y=w.alternate,y!==null&&(y.lanes|=c),eh(w,c,s),w=null}else w=x.child;if(w!==null)w.return=x;else for(w=x;w!==null;){if(w===s){w=null;break}if(x=w.sibling,x!==null){x.return=w.return,w=x;break}w=w.return}x=w}}function ma(s,i,c,h){s=null;for(var x=i,y=!1;x!==null;){if(!y){if((x.flags&524288)!==0)y=!0;else if((x.flags&262144)!==0)break}if(x.tag===10){var w=x.alternate;if(w===null)throw Error(r(387));if(w=w.memoizedProps,w!==null){var M=x.type;rr(x.pendingProps.value,w.value)||(s!==null?s.push(M):s=[M])}}else if(x===se.current){if(w=x.alternate,w===null)throw Error(r(387));w.memoizedState.memoizedState!==x.memoizedState.memoizedState&&(s!==null?s.push(Wo):s=[Wo])}x=x.return}s!==null&&th(i,s,c,h),i.flags|=262144}function uc(s){for(s=s.firstContext;s!==null;){if(!rr(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function _i(s){vi=s,ds=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Tn(s){return Hx(vi,s)}function dc(s,i){return vi===null&&_i(s),Hx(s,i)}function Hx(s,i){var c=i._currentValue;if(i={context:i,memoizedValue:c,next:null},ds===null){if(s===null)throw Error(r(308));ds=i,s.dependencies={lanes:0,firstContext:i},s.flags|=524288}else ds=ds.next=i;return c}var $C=typeof AbortController<"u"?AbortController:function(){var s=[],i=this.signal={aborted:!1,addEventListener:function(c,h){s.push(h)}};this.abort=function(){i.aborted=!0,s.forEach(function(c){return c()})}},UC=e.unstable_scheduleCallback,WC=e.unstable_NormalPriority,Xt={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function nh(){return{controller:new $C,data:new Map,refCount:0}}function yo(s){s.refCount--,s.refCount===0&&UC(WC,function(){s.controller.abort()})}var bo=null,rh=0,ga=0,xa=null;function qC(s,i){if(bo===null){var c=bo=[];rh=0,ga=of(),xa={status:"pending",value:void 0,then:function(h){c.push(h)}}}return rh++,i.then(Fx,Fx),i}function Fx(){if(--rh===0&&bo!==null){xa!==null&&(xa.status="fulfilled");var s=bo;bo=null,ga=0,xa=null;for(var i=0;i<s.length;i++)(0,s[i])()}}function VC(s,i){var c=[],h={status:"pending",value:null,reason:null,then:function(x){c.push(x)}};return s.then(function(){h.status="fulfilled",h.value=i;for(var x=0;x<c.length;x++)(0,c[x])(i)},function(x){for(h.status="rejected",h.reason=x,x=0;x<c.length;x++)(0,c[x])(void 0)}),h}var $x=N.S;N.S=function(s,i){Cb=Ie(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&qC(s,i),$x!==null&&$x(s,i)};var Si=P(null);function sh(){var s=Si.current;return s!==null?s:Ct.pooledCache}function hc(s,i){i===null?L(Si,Si.current):L(Si,i.pool)}function Ux(){var s=sh();return s===null?null:{parent:Xt._currentValue,pool:s}}var ya=Error(r(460)),ih=Error(r(474)),fc=Error(r(542)),pc={then:function(){}};function Wx(s){return s=s.status,s==="fulfilled"||s==="rejected"}function qx(s,i,c){switch(c=s[c],c===void 0?s.push(i):c!==i&&(i.then(os,os),i=c),i.status){case"fulfilled":return i.value;case"rejected":throw s=i.reason,Kx(s),s;default:if(typeof i.status=="string")i.then(os,os);else{if(s=Ct,s!==null&&100<s.shellSuspendCounter)throw Error(r(482));s=i,s.status="pending",s.then(function(h){if(i.status==="pending"){var x=i;x.status="fulfilled",x.value=h}},function(h){if(i.status==="pending"){var x=i;x.status="rejected",x.reason=h}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw s=i.reason,Kx(s),s}throw ki=i,ya}}function wi(s){try{var i=s._init;return i(s._payload)}catch(c){throw c!==null&&typeof c=="object"&&typeof c.then=="function"?(ki=c,ya):c}}var ki=null;function Vx(){if(ki===null)throw Error(r(459));var s=ki;return ki=null,s}function Kx(s){if(s===ya||s===fc)throw Error(r(483))}var ba=null,vo=0;function mc(s){var i=vo;return vo+=1,ba===null&&(ba=[]),qx(ba,s,i)}function _o(s,i){i=i.props.ref,s.ref=i!==void 0?i:null}function gc(s,i){throw i.$$typeof===v?Error(r(525)):(s=Object.prototype.toString.call(i),Error(r(31,s==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":s)))}function Gx(s){function i(Q,X){if(s){var te=Q.deletions;te===null?(Q.deletions=[X],Q.flags|=16):te.push(X)}}function c(Q,X){if(!s)return null;for(;X!==null;)i(Q,X),X=X.sibling;return null}function h(Q){for(var X=new Map;Q!==null;)Q.key!==null?X.set(Q.key,Q):X.set(Q.index,Q),Q=Q.sibling;return X}function x(Q,X){return Q=cs(Q,X),Q.index=0,Q.sibling=null,Q}function y(Q,X,te){return Q.index=te,s?(te=Q.alternate,te!==null?(te=te.index,te<X?(Q.flags|=67108866,X):te):(Q.flags|=67108866,X)):(Q.flags|=1048576,X)}function w(Q){return s&&Q.alternate===null&&(Q.flags|=67108866),Q}function M(Q,X,te,he){return X===null||X.tag!==6?(X=Kd(te,Q.mode,he),X.return=Q,X):(X=x(X,te),X.return=Q,X)}function K(Q,X,te,he){var Le=te.type;return Le===S?ue(Q,X,te.props.children,he,te.key):X!==null&&(X.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===ee&&wi(Le)===X.type)?(X=x(X,te.props),_o(X,te),X.return=Q,X):(X=lc(te.type,te.key,te.props,null,Q.mode,he),_o(X,te),X.return=Q,X)}function ne(Q,X,te,he){return X===null||X.tag!==4||X.stateNode.containerInfo!==te.containerInfo||X.stateNode.implementation!==te.implementation?(X=Gd(te,Q.mode,he),X.return=Q,X):(X=x(X,te.children||[]),X.return=Q,X)}function ue(Q,X,te,he,Le){return X===null||X.tag!==7?(X=yi(te,Q.mode,he,Le),X.return=Q,X):(X=x(X,te),X.return=Q,X)}function fe(Q,X,te){if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return X=Kd(""+X,Q.mode,te),X.return=Q,X;if(typeof X=="object"&&X!==null){switch(X.$$typeof){case b:return te=lc(X.type,X.key,X.props,null,Q.mode,te),_o(te,X),te.return=Q,te;case _:return X=Gd(X,Q.mode,te),X.return=Q,X;case ee:return X=wi(X),fe(Q,X,te)}if(T(X)||H(X))return X=yi(X,Q.mode,te,null),X.return=Q,X;if(typeof X.then=="function")return fe(Q,mc(X),te);if(X.$$typeof===A)return fe(Q,dc(Q,X),te);gc(Q,X)}return null}function re(Q,X,te,he){var Le=X!==null?X.key:null;if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return Le!==null?null:M(Q,X,""+te,he);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case b:return te.key===Le?K(Q,X,te,he):null;case _:return te.key===Le?ne(Q,X,te,he):null;case ee:return te=wi(te),re(Q,X,te,he)}if(T(te)||H(te))return Le!==null?null:ue(Q,X,te,he,null);if(typeof te.then=="function")return re(Q,X,mc(te),he);if(te.$$typeof===A)return re(Q,X,dc(Q,te),he);gc(Q,te)}return null}function oe(Q,X,te,he,Le){if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return Q=Q.get(te)||null,M(X,Q,""+he,Le);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case b:return Q=Q.get(he.key===null?te:he.key)||null,K(X,Q,he,Le);case _:return Q=Q.get(he.key===null?te:he.key)||null,ne(X,Q,he,Le);case ee:return he=wi(he),oe(Q,X,te,he,Le)}if(T(he)||H(he))return Q=Q.get(te)||null,ue(X,Q,he,Le,null);if(typeof he.then=="function")return oe(Q,X,te,mc(he),Le);if(he.$$typeof===A)return oe(Q,X,te,dc(X,he),Le);gc(X,he)}return null}function Ee(Q,X,te,he){for(var Le=null,ht=null,De=X,Ke=X=0,st=null;De!==null&&Ke<te.length;Ke++){De.index>Ke?(st=De,De=null):st=De.sibling;var ft=re(Q,De,te[Ke],he);if(ft===null){De===null&&(De=st);break}s&&De&&ft.alternate===null&&i(Q,De),X=y(ft,X,Ke),ht===null?Le=ft:ht.sibling=ft,ht=ft,De=st}if(Ke===te.length)return c(Q,De),at&&us(Q,Ke),Le;if(De===null){for(;Ke<te.length;Ke++)De=fe(Q,te[Ke],he),De!==null&&(X=y(De,X,Ke),ht===null?Le=De:ht.sibling=De,ht=De);return at&&us(Q,Ke),Le}for(De=h(De);Ke<te.length;Ke++)st=oe(De,Q,Ke,te[Ke],he),st!==null&&(s&&st.alternate!==null&&De.delete(st.key===null?Ke:st.key),X=y(st,X,Ke),ht===null?Le=st:ht.sibling=st,ht=st);return s&&De.forEach(function(ti){return i(Q,ti)}),at&&us(Q,Ke),Le}function ze(Q,X,te,he){if(te==null)throw Error(r(151));for(var Le=null,ht=null,De=X,Ke=X=0,st=null,ft=te.next();De!==null&&!ft.done;Ke++,ft=te.next()){De.index>Ke?(st=De,De=null):st=De.sibling;var ti=re(Q,De,ft.value,he);if(ti===null){De===null&&(De=st);break}s&&De&&ti.alternate===null&&i(Q,De),X=y(ti,X,Ke),ht===null?Le=ti:ht.sibling=ti,ht=ti,De=st}if(ft.done)return c(Q,De),at&&us(Q,Ke),Le;if(De===null){for(;!ft.done;Ke++,ft=te.next())ft=fe(Q,ft.value,he),ft!==null&&(X=y(ft,X,Ke),ht===null?Le=ft:ht.sibling=ft,ht=ft);return at&&us(Q,Ke),Le}for(De=h(De);!ft.done;Ke++,ft=te.next())ft=oe(De,Q,Ke,ft.value,he),ft!==null&&(s&&ft.alternate!==null&&De.delete(ft.key===null?Ke:ft.key),X=y(ft,X,Ke),ht===null?Le=ft:ht.sibling=ft,ht=ft);return s&&De.forEach(function(rN){return i(Q,rN)}),at&&us(Q,Ke),Le}function St(Q,X,te,he){if(typeof te=="object"&&te!==null&&te.type===S&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case b:e:{for(var Le=te.key;X!==null;){if(X.key===Le){if(Le=te.type,Le===S){if(X.tag===7){c(Q,X.sibling),he=x(X,te.props.children),he.return=Q,Q=he;break e}}else if(X.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===ee&&wi(Le)===X.type){c(Q,X.sibling),he=x(X,te.props),_o(he,te),he.return=Q,Q=he;break e}c(Q,X);break}else i(Q,X);X=X.sibling}te.type===S?(he=yi(te.props.children,Q.mode,he,te.key),he.return=Q,Q=he):(he=lc(te.type,te.key,te.props,null,Q.mode,he),_o(he,te),he.return=Q,Q=he)}return w(Q);case _:e:{for(Le=te.key;X!==null;){if(X.key===Le)if(X.tag===4&&X.stateNode.containerInfo===te.containerInfo&&X.stateNode.implementation===te.implementation){c(Q,X.sibling),he=x(X,te.children||[]),he.return=Q,Q=he;break e}else{c(Q,X);break}else i(Q,X);X=X.sibling}he=Gd(te,Q.mode,he),he.return=Q,Q=he}return w(Q);case ee:return te=wi(te),St(Q,X,te,he)}if(T(te))return Ee(Q,X,te,he);if(H(te)){if(Le=H(te),typeof Le!="function")throw Error(r(150));return te=Le.call(te),ze(Q,X,te,he)}if(typeof te.then=="function")return St(Q,X,mc(te),he);if(te.$$typeof===A)return St(Q,X,dc(Q,te),he);gc(Q,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,X!==null&&X.tag===6?(c(Q,X.sibling),he=x(X,te),he.return=Q,Q=he):(c(Q,X),he=Kd(te,Q.mode,he),he.return=Q,Q=he),w(Q)):c(Q,X)}return function(Q,X,te,he){try{vo=0;var Le=St(Q,X,te,he);return ba=null,Le}catch(De){if(De===ya||De===fc)throw De;var ht=sr(29,De,null,Q.mode);return ht.lanes=he,ht.return=Q,ht}finally{}}}var Ci=Gx(!0),Yx=Gx(!1),zs=!1;function ah(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function oh(s,i){s=s.updateQueue,i.updateQueue===s&&(i.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function Ps(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Hs(s,i,c){var h=s.updateQueue;if(h===null)return null;if(h=h.shared,(mt&2)!==0){var x=h.pending;return x===null?i.next=i:(i.next=x.next,x.next=i),h.pending=i,i=oc(s),Mx(s,null,c),i}return ac(s,h,i,c),oc(s)}function So(s,i,c){if(i=i.updateQueue,i!==null&&(i=i.shared,(c&4194048)!==0)){var h=i.lanes;h&=s.pendingLanes,c|=h,i.lanes=c,Hg(s,c)}}function lh(s,i){var c=s.updateQueue,h=s.alternate;if(h!==null&&(h=h.updateQueue,c===h)){var x=null,y=null;if(c=c.firstBaseUpdate,c!==null){do{var w={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};y===null?x=y=w:y=y.next=w,c=c.next}while(c!==null);y===null?x=y=i:y=y.next=i}else x=y=i;c={baseState:h.baseState,firstBaseUpdate:x,lastBaseUpdate:y,shared:h.shared,callbacks:h.callbacks},s.updateQueue=c;return}s=c.lastBaseUpdate,s===null?c.firstBaseUpdate=i:s.next=i,c.lastBaseUpdate=i}var ch=!1;function wo(){if(ch){var s=xa;if(s!==null)throw s}}function ko(s,i,c,h){ch=!1;var x=s.updateQueue;zs=!1;var y=x.firstBaseUpdate,w=x.lastBaseUpdate,M=x.shared.pending;if(M!==null){x.shared.pending=null;var K=M,ne=K.next;K.next=null,w===null?y=ne:w.next=ne,w=K;var ue=s.alternate;ue!==null&&(ue=ue.updateQueue,M=ue.lastBaseUpdate,M!==w&&(M===null?ue.firstBaseUpdate=ne:M.next=ne,ue.lastBaseUpdate=K))}if(y!==null){var fe=x.baseState;w=0,ue=ne=K=null,M=y;do{var re=M.lane&-536870913,oe=re!==M.lane;if(oe?(rt&re)===re:(h&re)===re){re!==0&&re===ga&&(ch=!0),ue!==null&&(ue=ue.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var Ee=s,ze=M;re=i;var St=c;switch(ze.tag){case 1:if(Ee=ze.payload,typeof Ee=="function"){fe=Ee.call(St,fe,re);break e}fe=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=ze.payload,re=typeof Ee=="function"?Ee.call(St,fe,re):Ee,re==null)break e;fe=g({},fe,re);break e;case 2:zs=!0}}re=M.callback,re!==null&&(s.flags|=64,oe&&(s.flags|=8192),oe=x.callbacks,oe===null?x.callbacks=[re]:oe.push(re))}else oe={lane:re,tag:M.tag,payload:M.payload,callback:M.callback,next:null},ue===null?(ne=ue=oe,K=fe):ue=ue.next=oe,w|=re;if(M=M.next,M===null){if(M=x.shared.pending,M===null)break;oe=M,M=oe.next,oe.next=null,x.lastBaseUpdate=oe,x.shared.pending=null}}while(!0);ue===null&&(K=fe),x.baseState=K,x.firstBaseUpdate=ne,x.lastBaseUpdate=ue,y===null&&(x.shared.lanes=0),qs|=w,s.lanes=w,s.memoizedState=fe}}function Xx(s,i){if(typeof s!="function")throw Error(r(191,s));s.call(i)}function Zx(s,i){var c=s.callbacks;if(c!==null)for(s.callbacks=null,s=0;s<c.length;s++)Xx(c[s],i)}var va=P(null),xc=P(0);function Qx(s,i){s=_s,L(xc,s),L(va,i),_s=s|i.baseLanes}function uh(){L(xc,_s),L(va,va.current)}function dh(){_s=xc.current,V(va),V(xc)}var ir=P(null),Cr=null;function Fs(s){var i=s.alternate;L(qt,qt.current&1),L(ir,s),Cr===null&&(i===null||va.current!==null||i.memoizedState!==null)&&(Cr=s)}function hh(s){L(qt,qt.current),L(ir,s),Cr===null&&(Cr=s)}function Jx(s){s.tag===22?(L(qt,qt.current),L(ir,s),Cr===null&&(Cr=s)):$s()}function $s(){L(qt,qt.current),L(ir,ir.current)}function ar(s){V(ir),Cr===s&&(Cr=null),V(qt)}var qt=P(0);function yc(s){for(var i=s;i!==null;){if(i.tag===13){var c=i.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||bf(c)||vf(c)))return i}else if(i.tag===19&&(i.memoizedProps.revealOrder==="forwards"||i.memoizedProps.revealOrder==="backwards"||i.memoizedProps.revealOrder==="unstable_legacy-backwards"||i.memoizedProps.revealOrder==="together")){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break;for(;i.sibling===null;){if(i.return===null||i.return===s)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var fs=0,Ve=null,vt=null,Zt=null,bc=!1,_a=!1,Ni=!1,vc=0,Co=0,Sa=null,KC=0;function Ht(){throw Error(r(321))}function fh(s,i){if(i===null)return!1;for(var c=0;c<i.length&&c<s.length;c++)if(!rr(s[c],i[c]))return!1;return!0}function ph(s,i,c,h,x,y){return fs=y,Ve=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,N.H=s===null||s.memoizedState===null?Iy:Th,Ni=!1,y=c(h,x),Ni=!1,_a&&(y=ty(i,c,h,x)),ey(s),y}function ey(s){N.H=Eo;var i=vt!==null&&vt.next!==null;if(fs=0,Zt=vt=Ve=null,bc=!1,Co=0,Sa=null,i)throw Error(r(300));s===null||Qt||(s=s.dependencies,s!==null&&uc(s)&&(Qt=!0))}function ty(s,i,c,h){Ve=s;var x=0;do{if(_a&&(Sa=null),Co=0,_a=!1,25<=x)throw Error(r(301));if(x+=1,Zt=vt=null,s.updateQueue!=null){var y=s.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}N.H=By,y=i(c,h)}while(_a);return y}function GC(){var s=N.H,i=s.useState()[0];return i=typeof i.then=="function"?No(i):i,s=s.useState()[0],(vt!==null?vt.memoizedState:null)!==s&&(Ve.flags|=1024),i}function mh(){var s=vc!==0;return vc=0,s}function gh(s,i,c){i.updateQueue=s.updateQueue,i.flags&=-2053,s.lanes&=~c}function xh(s){if(bc){for(s=s.memoizedState;s!==null;){var i=s.queue;i!==null&&(i.pending=null),s=s.next}bc=!1}fs=0,Zt=vt=Ve=null,_a=!1,Co=vc=0,Sa=null}function Fn(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Zt===null?Ve.memoizedState=Zt=s:Zt=Zt.next=s,Zt}function Vt(){if(vt===null){var s=Ve.alternate;s=s!==null?s.memoizedState:null}else s=vt.next;var i=Zt===null?Ve.memoizedState:Zt.next;if(i!==null)Zt=i,vt=s;else{if(s===null)throw Ve.alternate===null?Error(r(467)):Error(r(310));vt=s,s={memoizedState:vt.memoizedState,baseState:vt.baseState,baseQueue:vt.baseQueue,queue:vt.queue,next:null},Zt===null?Ve.memoizedState=Zt=s:Zt=Zt.next=s}return Zt}function _c(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function No(s){var i=Co;return Co+=1,Sa===null&&(Sa=[]),s=qx(Sa,s,i),i=Ve,(Zt===null?i.memoizedState:Zt.next)===null&&(i=i.alternate,N.H=i===null||i.memoizedState===null?Iy:Th),s}function Sc(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return No(s);if(s.$$typeof===A)return Tn(s)}throw Error(r(438,String(s)))}function yh(s){var i=null,c=Ve.updateQueue;if(c!==null&&(i=c.memoCache),i==null){var h=Ve.alternate;h!==null&&(h=h.updateQueue,h!==null&&(h=h.memoCache,h!=null&&(i={data:h.data.map(function(x){return x.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),c===null&&(c=_c(),Ve.updateQueue=c),c.memoCache=i,c=i.data[i.index],c===void 0)for(c=i.data[i.index]=Array(s),h=0;h<s;h++)c[h]=D;return i.index++,c}function ps(s,i){return typeof i=="function"?i(s):i}function wc(s){var i=Vt();return bh(i,vt,s)}function bh(s,i,c){var h=s.queue;if(h===null)throw Error(r(311));h.lastRenderedReducer=c;var x=s.baseQueue,y=h.pending;if(y!==null){if(x!==null){var w=x.next;x.next=y.next,y.next=w}i.baseQueue=x=y,h.pending=null}if(y=s.baseState,x===null)s.memoizedState=y;else{i=x.next;var M=w=null,K=null,ne=i,ue=!1;do{var fe=ne.lane&-536870913;if(fe!==ne.lane?(rt&fe)===fe:(fs&fe)===fe){var re=ne.revertLane;if(re===0)K!==null&&(K=K.next={lane:0,revertLane:0,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),fe===ga&&(ue=!0);else if((fs&re)===re){ne=ne.next,re===ga&&(ue=!0);continue}else fe={lane:0,revertLane:ne.revertLane,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},K===null?(M=K=fe,w=y):K=K.next=fe,Ve.lanes|=re,qs|=re;fe=ne.action,Ni&&c(y,fe),y=ne.hasEagerState?ne.eagerState:c(y,fe)}else re={lane:fe,revertLane:ne.revertLane,gesture:ne.gesture,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},K===null?(M=K=re,w=y):K=K.next=re,Ve.lanes|=fe,qs|=fe;ne=ne.next}while(ne!==null&&ne!==i);if(K===null?w=y:K.next=M,!rr(y,s.memoizedState)&&(Qt=!0,ue&&(c=xa,c!==null)))throw c;s.memoizedState=y,s.baseState=w,s.baseQueue=K,h.lastRenderedState=y}return x===null&&(h.lanes=0),[s.memoizedState,h.dispatch]}function vh(s){var i=Vt(),c=i.queue;if(c===null)throw Error(r(311));c.lastRenderedReducer=s;var h=c.dispatch,x=c.pending,y=i.memoizedState;if(x!==null){c.pending=null;var w=x=x.next;do y=s(y,w.action),w=w.next;while(w!==x);rr(y,i.memoizedState)||(Qt=!0),i.memoizedState=y,i.baseQueue===null&&(i.baseState=y),c.lastRenderedState=y}return[y,h]}function ny(s,i,c){var h=Ve,x=Vt(),y=at;if(y){if(c===void 0)throw Error(r(407));c=c()}else c=i();var w=!rr((vt||x).memoizedState,c);if(w&&(x.memoizedState=c,Qt=!0),x=x.queue,wh(iy.bind(null,h,x,s),[s]),x.getSnapshot!==i||w||Zt!==null&&Zt.memoizedState.tag&1){if(h.flags|=2048,wa(9,{destroy:void 0},sy.bind(null,h,x,c,i),null),Ct===null)throw Error(r(349));y||(fs&127)!==0||ry(h,i,c)}return c}function ry(s,i,c){s.flags|=16384,s={getSnapshot:i,value:c},i=Ve.updateQueue,i===null?(i=_c(),Ve.updateQueue=i,i.stores=[s]):(c=i.stores,c===null?i.stores=[s]:c.push(s))}function sy(s,i,c,h){i.value=c,i.getSnapshot=h,ay(i)&&oy(s)}function iy(s,i,c){return c(function(){ay(i)&&oy(s)})}function ay(s){var i=s.getSnapshot;s=s.value;try{var c=i();return!rr(s,c)}catch{return!0}}function oy(s){var i=xi(s,2);i!==null&&Jn(i,s,2)}function _h(s){var i=Fn();if(typeof s=="function"){var c=s;if(s=c(),Ni){ae(!0);try{c()}finally{ae(!1)}}}return i.memoizedState=i.baseState=s,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:s},i}function ly(s,i,c,h){return s.baseState=c,bh(s,vt,typeof h=="function"?h:ps)}function YC(s,i,c,h,x){if(Nc(s))throw Error(r(485));if(s=i.action,s!==null){var y={payload:x,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(w){y.listeners.push(w)}};N.T!==null?c(!0):y.isTransition=!1,h(y),c=i.pending,c===null?(y.next=i.pending=y,cy(i,y)):(y.next=c.next,i.pending=c.next=y)}}function cy(s,i){var c=i.action,h=i.payload,x=s.state;if(i.isTransition){var y=N.T,w={};N.T=w;try{var M=c(x,h),K=N.S;K!==null&&K(w,M),uy(s,i,M)}catch(ne){Sh(s,i,ne)}finally{y!==null&&w.types!==null&&(y.types=w.types),N.T=y}}else try{y=c(x,h),uy(s,i,y)}catch(ne){Sh(s,i,ne)}}function uy(s,i,c){c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(function(h){dy(s,i,h)},function(h){return Sh(s,i,h)}):dy(s,i,c)}function dy(s,i,c){i.status="fulfilled",i.value=c,hy(i),s.state=c,i=s.pending,i!==null&&(c=i.next,c===i?s.pending=null:(c=c.next,i.next=c,cy(s,c)))}function Sh(s,i,c){var h=s.pending;if(s.pending=null,h!==null){h=h.next;do i.status="rejected",i.reason=c,hy(i),i=i.next;while(i!==h)}s.action=null}function hy(s){s=s.listeners;for(var i=0;i<s.length;i++)(0,s[i])()}function fy(s,i){return i}function py(s,i){if(at){var c=Ct.formState;if(c!==null){e:{var h=Ve;if(at){if(Tt){t:{for(var x=Tt,y=kr;x.nodeType!==8;){if(!y){x=null;break t}if(x=Nr(x.nextSibling),x===null){x=null;break t}}y=x.data,x=y==="F!"||y==="F"?x:null}if(x){Tt=Nr(x.nextSibling),h=x.data==="F!";break e}}Is(h)}h=!1}h&&(i=c[0])}}return c=Fn(),c.memoizedState=c.baseState=i,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fy,lastRenderedState:i},c.queue=h,c=Ry.bind(null,Ve,h),h.dispatch=c,h=_h(!1),y=Eh.bind(null,Ve,!1,h.queue),h=Fn(),x={state:i,dispatch:null,action:s,pending:null},h.queue=x,c=YC.bind(null,Ve,x,y,c),x.dispatch=c,h.memoizedState=s,[i,c,!1]}function my(s){var i=Vt();return gy(i,vt,s)}function gy(s,i,c){if(i=bh(s,i,fy)[0],s=wc(ps)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var h=No(i)}catch(w){throw w===ya?fc:w}else h=i;i=Vt();var x=i.queue,y=x.dispatch;return c!==i.memoizedState&&(Ve.flags|=2048,wa(9,{destroy:void 0},XC.bind(null,x,c),null)),[h,y,s]}function XC(s,i){s.action=i}function xy(s){var i=Vt(),c=vt;if(c!==null)return gy(i,c,s);Vt(),i=i.memoizedState,c=Vt();var h=c.queue.dispatch;return c.memoizedState=s,[i,h,!1]}function wa(s,i,c,h){return s={tag:s,create:c,deps:h,inst:i,next:null},i=Ve.updateQueue,i===null&&(i=_c(),Ve.updateQueue=i),c=i.lastEffect,c===null?i.lastEffect=s.next=s:(h=c.next,c.next=s,s.next=h,i.lastEffect=s),s}function yy(){return Vt().memoizedState}function kc(s,i,c,h){var x=Fn();Ve.flags|=s,x.memoizedState=wa(1|i,{destroy:void 0},c,h===void 0?null:h)}function Cc(s,i,c,h){var x=Vt();h=h===void 0?null:h;var y=x.memoizedState.inst;vt!==null&&h!==null&&fh(h,vt.memoizedState.deps)?x.memoizedState=wa(i,y,c,h):(Ve.flags|=s,x.memoizedState=wa(1|i,y,c,h))}function by(s,i){kc(8390656,8,s,i)}function wh(s,i){Cc(2048,8,s,i)}function ZC(s){Ve.flags|=4;var i=Ve.updateQueue;if(i===null)i=_c(),Ve.updateQueue=i,i.events=[s];else{var c=i.events;c===null?i.events=[s]:c.push(s)}}function vy(s){var i=Vt().memoizedState;return ZC({ref:i,nextImpl:s}),function(){if((mt&2)!==0)throw Error(r(440));return i.impl.apply(void 0,arguments)}}function _y(s,i){return Cc(4,2,s,i)}function Sy(s,i){return Cc(4,4,s,i)}function wy(s,i){if(typeof i=="function"){s=s();var c=i(s);return function(){typeof c=="function"?c():i(null)}}if(i!=null)return s=s(),i.current=s,function(){i.current=null}}function ky(s,i,c){c=c!=null?c.concat([s]):null,Cc(4,4,wy.bind(null,i,s),c)}function kh(){}function Cy(s,i){var c=Vt();i=i===void 0?null:i;var h=c.memoizedState;return i!==null&&fh(i,h[1])?h[0]:(c.memoizedState=[s,i],s)}function Ny(s,i){var c=Vt();i=i===void 0?null:i;var h=c.memoizedState;if(i!==null&&fh(i,h[1]))return h[0];if(h=s(),Ni){ae(!0);try{s()}finally{ae(!1)}}return c.memoizedState=[h,i],h}function Ch(s,i,c){return c===void 0||(fs&1073741824)!==0&&(rt&261930)===0?s.memoizedState=i:(s.memoizedState=c,s=jb(),Ve.lanes|=s,qs|=s,c)}function jy(s,i,c,h){return rr(c,i)?c:va.current!==null?(s=Ch(s,c,h),rr(s,i)||(Qt=!0),s):(fs&42)===0||(fs&1073741824)!==0&&(rt&261930)===0?(Qt=!0,s.memoizedState=c):(s=jb(),Ve.lanes|=s,qs|=s,i)}function Ey(s,i,c,h,x){var y=F.p;F.p=y!==0&&8>y?y:8;var w=N.T,M={};N.T=M,Eh(s,!1,i,c);try{var K=x(),ne=N.S;if(ne!==null&&ne(M,K),K!==null&&typeof K=="object"&&typeof K.then=="function"){var ue=VC(K,h);jo(s,i,ue,cr(s))}else jo(s,i,h,cr(s))}catch(fe){jo(s,i,{then:function(){},status:"rejected",reason:fe},cr())}finally{F.p=y,w!==null&&M.types!==null&&(w.types=M.types),N.T=w}}function QC(){}function Nh(s,i,c,h){if(s.tag!==5)throw Error(r(476));var x=Ty(s).queue;Ey(s,x,i,I,c===null?QC:function(){return Ay(s),c(h)})}function Ty(s){var i=s.memoizedState;if(i!==null)return i;i={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:I},next:null};var c={};return i.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:c},next:null},s.memoizedState=i,s=s.alternate,s!==null&&(s.memoizedState=i),i}function Ay(s){var i=Ty(s);i.next===null&&(i=s.alternate.memoizedState),jo(s,i.next.queue,{},cr())}function jh(){return Tn(Wo)}function Dy(){return Vt().memoizedState}function My(){return Vt().memoizedState}function JC(s){for(var i=s.return;i!==null;){switch(i.tag){case 24:case 3:var c=cr();s=Ps(c);var h=Hs(i,s,c);h!==null&&(Jn(h,i,c),So(h,i,c)),i={cache:nh()},s.payload=i;return}i=i.return}}function e2(s,i,c){var h=cr();c={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Nc(s)?Ly(i,c):(c=qd(s,i,c,h),c!==null&&(Jn(c,s,h),Oy(c,i,h)))}function Ry(s,i,c){var h=cr();jo(s,i,c,h)}function jo(s,i,c,h){var x={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(Nc(s))Ly(i,x);else{var y=s.alternate;if(s.lanes===0&&(y===null||y.lanes===0)&&(y=i.lastRenderedReducer,y!==null))try{var w=i.lastRenderedState,M=y(w,c);if(x.hasEagerState=!0,x.eagerState=M,rr(M,w))return ac(s,i,x,0),Ct===null&&ic(),!1}catch{}finally{}if(c=qd(s,i,x,h),c!==null)return Jn(c,s,h),Oy(c,i,h),!0}return!1}function Eh(s,i,c,h){if(h={lane:2,revertLane:of(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Nc(s)){if(i)throw Error(r(479))}else i=qd(s,c,h,2),i!==null&&Jn(i,s,2)}function Nc(s){var i=s.alternate;return s===Ve||i!==null&&i===Ve}function Ly(s,i){_a=bc=!0;var c=s.pending;c===null?i.next=i:(i.next=c.next,c.next=i),s.pending=i}function Oy(s,i,c){if((c&4194048)!==0){var h=i.lanes;h&=s.pendingLanes,c|=h,i.lanes=c,Hg(s,c)}}var Eo={readContext:Tn,use:Sc,useCallback:Ht,useContext:Ht,useEffect:Ht,useImperativeHandle:Ht,useLayoutEffect:Ht,useInsertionEffect:Ht,useMemo:Ht,useReducer:Ht,useRef:Ht,useState:Ht,useDebugValue:Ht,useDeferredValue:Ht,useTransition:Ht,useSyncExternalStore:Ht,useId:Ht,useHostTransitionStatus:Ht,useFormState:Ht,useActionState:Ht,useOptimistic:Ht,useMemoCache:Ht,useCacheRefresh:Ht};Eo.useEffectEvent=Ht;var Iy={readContext:Tn,use:Sc,useCallback:function(s,i){return Fn().memoizedState=[s,i===void 0?null:i],s},useContext:Tn,useEffect:by,useImperativeHandle:function(s,i,c){c=c!=null?c.concat([s]):null,kc(4194308,4,wy.bind(null,i,s),c)},useLayoutEffect:function(s,i){return kc(4194308,4,s,i)},useInsertionEffect:function(s,i){kc(4,2,s,i)},useMemo:function(s,i){var c=Fn();i=i===void 0?null:i;var h=s();if(Ni){ae(!0);try{s()}finally{ae(!1)}}return c.memoizedState=[h,i],h},useReducer:function(s,i,c){var h=Fn();if(c!==void 0){var x=c(i);if(Ni){ae(!0);try{c(i)}finally{ae(!1)}}}else x=i;return h.memoizedState=h.baseState=x,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:x},h.queue=s,s=s.dispatch=e2.bind(null,Ve,s),[h.memoizedState,s]},useRef:function(s){var i=Fn();return s={current:s},i.memoizedState=s},useState:function(s){s=_h(s);var i=s.queue,c=Ry.bind(null,Ve,i);return i.dispatch=c,[s.memoizedState,c]},useDebugValue:kh,useDeferredValue:function(s,i){var c=Fn();return Ch(c,s,i)},useTransition:function(){var s=_h(!1);return s=Ey.bind(null,Ve,s.queue,!0,!1),Fn().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,i,c){var h=Ve,x=Fn();if(at){if(c===void 0)throw Error(r(407));c=c()}else{if(c=i(),Ct===null)throw Error(r(349));(rt&127)!==0||ry(h,i,c)}x.memoizedState=c;var y={value:c,getSnapshot:i};return x.queue=y,by(iy.bind(null,h,y,s),[s]),h.flags|=2048,wa(9,{destroy:void 0},sy.bind(null,h,y,c,i),null),c},useId:function(){var s=Fn(),i=Ct.identifierPrefix;if(at){var c=$r,h=Fr;c=(h&~(1<<32-we(h)-1)).toString(32)+c,i="_"+i+"R_"+c,c=vc++,0<c&&(i+="H"+c.toString(32)),i+="_"}else c=KC++,i="_"+i+"r_"+c.toString(32)+"_";return s.memoizedState=i},useHostTransitionStatus:jh,useFormState:py,useActionState:py,useOptimistic:function(s){var i=Fn();i.memoizedState=i.baseState=s;var c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=c,i=Eh.bind(null,Ve,!0,c),c.dispatch=i,[s,i]},useMemoCache:yh,useCacheRefresh:function(){return Fn().memoizedState=JC.bind(null,Ve)},useEffectEvent:function(s){var i=Fn(),c={impl:s};return i.memoizedState=c,function(){if((mt&2)!==0)throw Error(r(440));return c.impl.apply(void 0,arguments)}}},Th={readContext:Tn,use:Sc,useCallback:Cy,useContext:Tn,useEffect:wh,useImperativeHandle:ky,useInsertionEffect:_y,useLayoutEffect:Sy,useMemo:Ny,useReducer:wc,useRef:yy,useState:function(){return wc(ps)},useDebugValue:kh,useDeferredValue:function(s,i){var c=Vt();return jy(c,vt.memoizedState,s,i)},useTransition:function(){var s=wc(ps)[0],i=Vt().memoizedState;return[typeof s=="boolean"?s:No(s),i]},useSyncExternalStore:ny,useId:Dy,useHostTransitionStatus:jh,useFormState:my,useActionState:my,useOptimistic:function(s,i){var c=Vt();return ly(c,vt,s,i)},useMemoCache:yh,useCacheRefresh:My};Th.useEffectEvent=vy;var By={readContext:Tn,use:Sc,useCallback:Cy,useContext:Tn,useEffect:wh,useImperativeHandle:ky,useInsertionEffect:_y,useLayoutEffect:Sy,useMemo:Ny,useReducer:vh,useRef:yy,useState:function(){return vh(ps)},useDebugValue:kh,useDeferredValue:function(s,i){var c=Vt();return vt===null?Ch(c,s,i):jy(c,vt.memoizedState,s,i)},useTransition:function(){var s=vh(ps)[0],i=Vt().memoizedState;return[typeof s=="boolean"?s:No(s),i]},useSyncExternalStore:ny,useId:Dy,useHostTransitionStatus:jh,useFormState:xy,useActionState:xy,useOptimistic:function(s,i){var c=Vt();return vt!==null?ly(c,vt,s,i):(c.baseState=s,[s,c.queue.dispatch])},useMemoCache:yh,useCacheRefresh:My};By.useEffectEvent=vy;function Ah(s,i,c,h){i=s.memoizedState,c=c(h,i),c=c==null?i:g({},i,c),s.memoizedState=c,s.lanes===0&&(s.updateQueue.baseState=c)}var Dh={enqueueSetState:function(s,i,c){s=s._reactInternals;var h=cr(),x=Ps(h);x.payload=i,c!=null&&(x.callback=c),i=Hs(s,x,h),i!==null&&(Jn(i,s,h),So(i,s,h))},enqueueReplaceState:function(s,i,c){s=s._reactInternals;var h=cr(),x=Ps(h);x.tag=1,x.payload=i,c!=null&&(x.callback=c),i=Hs(s,x,h),i!==null&&(Jn(i,s,h),So(i,s,h))},enqueueForceUpdate:function(s,i){s=s._reactInternals;var c=cr(),h=Ps(c);h.tag=2,i!=null&&(h.callback=i),i=Hs(s,h,c),i!==null&&(Jn(i,s,c),So(i,s,c))}};function zy(s,i,c,h,x,y,w){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(h,y,w):i.prototype&&i.prototype.isPureReactComponent?!po(c,h)||!po(x,y):!0}function Py(s,i,c,h){s=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(c,h),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(c,h),i.state!==s&&Dh.enqueueReplaceState(i,i.state,null)}function ji(s,i){var c=i;if("ref"in i){c={};for(var h in i)h!=="ref"&&(c[h]=i[h])}if(s=s.defaultProps){c===i&&(c=g({},c));for(var x in s)c[x]===void 0&&(c[x]=s[x])}return c}function Hy(s){sc(s)}function Fy(s){console.error(s)}function $y(s){sc(s)}function jc(s,i){try{var c=s.onUncaughtError;c(i.value,{componentStack:i.stack})}catch(h){setTimeout(function(){throw h})}}function Uy(s,i,c){try{var h=s.onCaughtError;h(c.value,{componentStack:c.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(x){setTimeout(function(){throw x})}}function Mh(s,i,c){return c=Ps(c),c.tag=3,c.payload={element:null},c.callback=function(){jc(s,i)},c}function Wy(s){return s=Ps(s),s.tag=3,s}function qy(s,i,c,h){var x=c.type.getDerivedStateFromError;if(typeof x=="function"){var y=h.value;s.payload=function(){return x(y)},s.callback=function(){Uy(i,c,h)}}var w=c.stateNode;w!==null&&typeof w.componentDidCatch=="function"&&(s.callback=function(){Uy(i,c,h),typeof x!="function"&&(Vs===null?Vs=new Set([this]):Vs.add(this));var M=h.stack;this.componentDidCatch(h.value,{componentStack:M!==null?M:""})})}function t2(s,i,c,h,x){if(c.flags|=32768,h!==null&&typeof h=="object"&&typeof h.then=="function"){if(i=c.alternate,i!==null&&ma(i,c,x,!0),c=ir.current,c!==null){switch(c.tag){case 31:case 13:return Cr===null?Pc():c.alternate===null&&Ft===0&&(Ft=3),c.flags&=-257,c.flags|=65536,c.lanes=x,h===pc?c.flags|=16384:(i=c.updateQueue,i===null?c.updateQueue=new Set([h]):i.add(h),rf(s,h,x)),!1;case 22:return c.flags|=65536,h===pc?c.flags|=16384:(i=c.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([h])},c.updateQueue=i):(c=i.retryQueue,c===null?i.retryQueue=new Set([h]):c.add(h)),rf(s,h,x)),!1}throw Error(r(435,c.tag))}return rf(s,h,x),Pc(),!1}if(at)return i=ir.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=x,h!==Zd&&(s=Error(r(422),{cause:h}),xo(_r(s,c)))):(h!==Zd&&(i=Error(r(423),{cause:h}),xo(_r(i,c))),s=s.current.alternate,s.flags|=65536,x&=-x,s.lanes|=x,h=_r(h,c),x=Mh(s.stateNode,h,x),lh(s,x),Ft!==4&&(Ft=2)),!1;var y=Error(r(520),{cause:h});if(y=_r(y,c),Io===null?Io=[y]:Io.push(y),Ft!==4&&(Ft=2),i===null)return!0;h=_r(h,c),c=i;do{switch(c.tag){case 3:return c.flags|=65536,s=x&-x,c.lanes|=s,s=Mh(c.stateNode,h,s),lh(c,s),!1;case 1:if(i=c.type,y=c.stateNode,(c.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Vs===null||!Vs.has(y))))return c.flags|=65536,x&=-x,c.lanes|=x,x=Wy(x),qy(x,s,c,h),lh(c,x),!1}c=c.return}while(c!==null);return!1}var Rh=Error(r(461)),Qt=!1;function An(s,i,c,h){i.child=s===null?Yx(i,null,c,h):Ci(i,s.child,c,h)}function Vy(s,i,c,h,x){c=c.render;var y=i.ref;if("ref"in h){var w={};for(var M in h)M!=="ref"&&(w[M]=h[M])}else w=h;return _i(i),h=ph(s,i,c,w,y,x),M=mh(),s!==null&&!Qt?(gh(s,i,x),ms(s,i,x)):(at&&M&&Yd(i),i.flags|=1,An(s,i,h,x),i.child)}function Ky(s,i,c,h,x){if(s===null){var y=c.type;return typeof y=="function"&&!Vd(y)&&y.defaultProps===void 0&&c.compare===null?(i.tag=15,i.type=y,Gy(s,i,y,h,x)):(s=lc(c.type,null,h,i,i.mode,x),s.ref=i.ref,s.return=i,i.child=s)}if(y=s.child,!Fh(s,x)){var w=y.memoizedProps;if(c=c.compare,c=c!==null?c:po,c(w,h)&&s.ref===i.ref)return ms(s,i,x)}return i.flags|=1,s=cs(y,h),s.ref=i.ref,s.return=i,i.child=s}function Gy(s,i,c,h,x){if(s!==null){var y=s.memoizedProps;if(po(y,h)&&s.ref===i.ref)if(Qt=!1,i.pendingProps=h=y,Fh(s,x))(s.flags&131072)!==0&&(Qt=!0);else return i.lanes=s.lanes,ms(s,i,x)}return Lh(s,i,c,h,x)}function Yy(s,i,c,h){var x=h.children,y=s!==null?s.memoizedState:null;if(s===null&&i.stateNode===null&&(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),h.mode==="hidden"){if((i.flags&128)!==0){if(y=y!==null?y.baseLanes|c:c,s!==null){for(h=i.child=s.child,x=0;h!==null;)x=x|h.lanes|h.childLanes,h=h.sibling;h=x&~y}else h=0,i.child=null;return Xy(s,i,y,c,h)}if((c&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},s!==null&&hc(i,y!==null?y.cachePool:null),y!==null?Qx(i,y):uh(),Jx(i);else return h=i.lanes=536870912,Xy(s,i,y!==null?y.baseLanes|c:c,c,h)}else y!==null?(hc(i,y.cachePool),Qx(i,y),$s(),i.memoizedState=null):(s!==null&&hc(i,null),uh(),$s());return An(s,i,x,c),i.child}function To(s,i){return s!==null&&s.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function Xy(s,i,c,h,x){var y=sh();return y=y===null?null:{parent:Xt._currentValue,pool:y},i.memoizedState={baseLanes:c,cachePool:y},s!==null&&hc(i,null),uh(),Jx(i),s!==null&&ma(s,i,h,!0),i.childLanes=x,null}function Ec(s,i){return i=Ac({mode:i.mode,children:i.children},s.mode),i.ref=s.ref,s.child=i,i.return=s,i}function Zy(s,i,c){return Ci(i,s.child,null,c),s=Ec(i,i.pendingProps),s.flags|=2,ar(i),i.memoizedState=null,s}function n2(s,i,c){var h=i.pendingProps,x=(i.flags&128)!==0;if(i.flags&=-129,s===null){if(at){if(h.mode==="hidden")return s=Ec(i,h),i.lanes=536870912,To(null,s);if(hh(i),(s=Tt)?(s=cv(s,kr),s=s!==null&&s.data==="&"?s:null,s!==null&&(i.memoizedState={dehydrated:s,treeContext:Ls!==null?{id:Fr,overflow:$r}:null,retryLane:536870912,hydrationErrors:null},c=Lx(s),c.return=i,i.child=c,En=i,Tt=null)):s=null,s===null)throw Is(i);return i.lanes=536870912,null}return Ec(i,h)}var y=s.memoizedState;if(y!==null){var w=y.dehydrated;if(hh(i),x)if(i.flags&256)i.flags&=-257,i=Zy(s,i,c);else if(i.memoizedState!==null)i.child=s.child,i.flags|=128,i=null;else throw Error(r(558));else if(Qt||ma(s,i,c,!1),x=(c&s.childLanes)!==0,Qt||x){if(h=Ct,h!==null&&(w=Fg(h,c),w!==0&&w!==y.retryLane))throw y.retryLane=w,xi(s,w),Jn(h,s,w),Rh;Pc(),i=Zy(s,i,c)}else s=y.treeContext,Tt=Nr(w.nextSibling),En=i,at=!0,Os=null,kr=!1,s!==null&&Bx(i,s),i=Ec(i,h),i.flags|=4096;return i}return s=cs(s.child,{mode:h.mode,children:h.children}),s.ref=i.ref,i.child=s,s.return=i,s}function Tc(s,i){var c=i.ref;if(c===null)s!==null&&s.ref!==null&&(i.flags|=4194816);else{if(typeof c!="function"&&typeof c!="object")throw Error(r(284));(s===null||s.ref!==c)&&(i.flags|=4194816)}}function Lh(s,i,c,h,x){return _i(i),c=ph(s,i,c,h,void 0,x),h=mh(),s!==null&&!Qt?(gh(s,i,x),ms(s,i,x)):(at&&h&&Yd(i),i.flags|=1,An(s,i,c,x),i.child)}function Qy(s,i,c,h,x,y){return _i(i),i.updateQueue=null,c=ty(i,h,c,x),ey(s),h=mh(),s!==null&&!Qt?(gh(s,i,y),ms(s,i,y)):(at&&h&&Yd(i),i.flags|=1,An(s,i,c,y),i.child)}function Jy(s,i,c,h,x){if(_i(i),i.stateNode===null){var y=da,w=c.contextType;typeof w=="object"&&w!==null&&(y=Tn(w)),y=new c(h,y),i.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=Dh,i.stateNode=y,y._reactInternals=i,y=i.stateNode,y.props=h,y.state=i.memoizedState,y.refs={},ah(i),w=c.contextType,y.context=typeof w=="object"&&w!==null?Tn(w):da,y.state=i.memoizedState,w=c.getDerivedStateFromProps,typeof w=="function"&&(Ah(i,c,w,h),y.state=i.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(w=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),w!==y.state&&Dh.enqueueReplaceState(y,y.state,null),ko(i,h,y,x),wo(),y.state=i.memoizedState),typeof y.componentDidMount=="function"&&(i.flags|=4194308),h=!0}else if(s===null){y=i.stateNode;var M=i.memoizedProps,K=ji(c,M);y.props=K;var ne=y.context,ue=c.contextType;w=da,typeof ue=="object"&&ue!==null&&(w=Tn(ue));var fe=c.getDerivedStateFromProps;ue=typeof fe=="function"||typeof y.getSnapshotBeforeUpdate=="function",M=i.pendingProps!==M,ue||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(M||ne!==w)&&Py(i,y,h,w),zs=!1;var re=i.memoizedState;y.state=re,ko(i,h,y,x),wo(),ne=i.memoizedState,M||re!==ne||zs?(typeof fe=="function"&&(Ah(i,c,fe,h),ne=i.memoizedState),(K=zs||zy(i,c,K,h,re,ne,w))?(ue||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(i.flags|=4194308)):(typeof y.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=h,i.memoizedState=ne),y.props=h,y.state=ne,y.context=w,h=K):(typeof y.componentDidMount=="function"&&(i.flags|=4194308),h=!1)}else{y=i.stateNode,oh(s,i),w=i.memoizedProps,ue=ji(c,w),y.props=ue,fe=i.pendingProps,re=y.context,ne=c.contextType,K=da,typeof ne=="object"&&ne!==null&&(K=Tn(ne)),M=c.getDerivedStateFromProps,(ne=typeof M=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(w!==fe||re!==K)&&Py(i,y,h,K),zs=!1,re=i.memoizedState,y.state=re,ko(i,h,y,x),wo();var oe=i.memoizedState;w!==fe||re!==oe||zs||s!==null&&s.dependencies!==null&&uc(s.dependencies)?(typeof M=="function"&&(Ah(i,c,M,h),oe=i.memoizedState),(ue=zs||zy(i,c,ue,h,re,oe,K)||s!==null&&s.dependencies!==null&&uc(s.dependencies))?(ne||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(h,oe,K),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(h,oe,K)),typeof y.componentDidUpdate=="function"&&(i.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof y.componentDidUpdate!="function"||w===s.memoizedProps&&re===s.memoizedState||(i.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||w===s.memoizedProps&&re===s.memoizedState||(i.flags|=1024),i.memoizedProps=h,i.memoizedState=oe),y.props=h,y.state=oe,y.context=K,h=ue):(typeof y.componentDidUpdate!="function"||w===s.memoizedProps&&re===s.memoizedState||(i.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||w===s.memoizedProps&&re===s.memoizedState||(i.flags|=1024),h=!1)}return y=h,Tc(s,i),h=(i.flags&128)!==0,y||h?(y=i.stateNode,c=h&&typeof c.getDerivedStateFromError!="function"?null:y.render(),i.flags|=1,s!==null&&h?(i.child=Ci(i,s.child,null,x),i.child=Ci(i,null,c,x)):An(s,i,c,x),i.memoizedState=y.state,s=i.child):s=ms(s,i,x),s}function eb(s,i,c,h){return bi(),i.flags|=256,An(s,i,c,h),i.child}var Oh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ih(s){return{baseLanes:s,cachePool:Ux()}}function Bh(s,i,c){return s=s!==null?s.childLanes&~c:0,i&&(s|=lr),s}function tb(s,i,c){var h=i.pendingProps,x=!1,y=(i.flags&128)!==0,w;if((w=y)||(w=s!==null&&s.memoizedState===null?!1:(qt.current&2)!==0),w&&(x=!0,i.flags&=-129),w=(i.flags&32)!==0,i.flags&=-33,s===null){if(at){if(x?Fs(i):$s(),(s=Tt)?(s=cv(s,kr),s=s!==null&&s.data!=="&"?s:null,s!==null&&(i.memoizedState={dehydrated:s,treeContext:Ls!==null?{id:Fr,overflow:$r}:null,retryLane:536870912,hydrationErrors:null},c=Lx(s),c.return=i,i.child=c,En=i,Tt=null)):s=null,s===null)throw Is(i);return vf(s)?i.lanes=32:i.lanes=536870912,null}var M=h.children;return h=h.fallback,x?($s(),x=i.mode,M=Ac({mode:"hidden",children:M},x),h=yi(h,x,c,null),M.return=i,h.return=i,M.sibling=h,i.child=M,h=i.child,h.memoizedState=Ih(c),h.childLanes=Bh(s,w,c),i.memoizedState=Oh,To(null,h)):(Fs(i),zh(i,M))}var K=s.memoizedState;if(K!==null&&(M=K.dehydrated,M!==null)){if(y)i.flags&256?(Fs(i),i.flags&=-257,i=Ph(s,i,c)):i.memoizedState!==null?($s(),i.child=s.child,i.flags|=128,i=null):($s(),M=h.fallback,x=i.mode,h=Ac({mode:"visible",children:h.children},x),M=yi(M,x,c,null),M.flags|=2,h.return=i,M.return=i,h.sibling=M,i.child=h,Ci(i,s.child,null,c),h=i.child,h.memoizedState=Ih(c),h.childLanes=Bh(s,w,c),i.memoizedState=Oh,i=To(null,h));else if(Fs(i),vf(M)){if(w=M.nextSibling&&M.nextSibling.dataset,w)var ne=w.dgst;w=ne,h=Error(r(419)),h.stack="",h.digest=w,xo({value:h,source:null,stack:null}),i=Ph(s,i,c)}else if(Qt||ma(s,i,c,!1),w=(c&s.childLanes)!==0,Qt||w){if(w=Ct,w!==null&&(h=Fg(w,c),h!==0&&h!==K.retryLane))throw K.retryLane=h,xi(s,h),Jn(w,s,h),Rh;bf(M)||Pc(),i=Ph(s,i,c)}else bf(M)?(i.flags|=192,i.child=s.child,i=null):(s=K.treeContext,Tt=Nr(M.nextSibling),En=i,at=!0,Os=null,kr=!1,s!==null&&Bx(i,s),i=zh(i,h.children),i.flags|=4096);return i}return x?($s(),M=h.fallback,x=i.mode,K=s.child,ne=K.sibling,h=cs(K,{mode:"hidden",children:h.children}),h.subtreeFlags=K.subtreeFlags&65011712,ne!==null?M=cs(ne,M):(M=yi(M,x,c,null),M.flags|=2),M.return=i,h.return=i,h.sibling=M,i.child=h,To(null,h),h=i.child,M=s.child.memoizedState,M===null?M=Ih(c):(x=M.cachePool,x!==null?(K=Xt._currentValue,x=x.parent!==K?{parent:K,pool:K}:x):x=Ux(),M={baseLanes:M.baseLanes|c,cachePool:x}),h.memoizedState=M,h.childLanes=Bh(s,w,c),i.memoizedState=Oh,To(s.child,h)):(Fs(i),c=s.child,s=c.sibling,c=cs(c,{mode:"visible",children:h.children}),c.return=i,c.sibling=null,s!==null&&(w=i.deletions,w===null?(i.deletions=[s],i.flags|=16):w.push(s)),i.child=c,i.memoizedState=null,c)}function zh(s,i){return i=Ac({mode:"visible",children:i},s.mode),i.return=s,s.child=i}function Ac(s,i){return s=sr(22,s,null,i),s.lanes=0,s}function Ph(s,i,c){return Ci(i,s.child,null,c),s=zh(i,i.pendingProps.children),s.flags|=2,i.memoizedState=null,s}function nb(s,i,c){s.lanes|=i;var h=s.alternate;h!==null&&(h.lanes|=i),eh(s.return,i,c)}function Hh(s,i,c,h,x,y){var w=s.memoizedState;w===null?s.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:h,tail:c,tailMode:x,treeForkCount:y}:(w.isBackwards=i,w.rendering=null,w.renderingStartTime=0,w.last=h,w.tail=c,w.tailMode=x,w.treeForkCount=y)}function rb(s,i,c){var h=i.pendingProps,x=h.revealOrder,y=h.tail;h=h.children;var w=qt.current,M=(w&2)!==0;if(M?(w=w&1|2,i.flags|=128):w&=1,L(qt,w),An(s,i,h,c),h=at?go:0,!M&&s!==null&&(s.flags&128)!==0)e:for(s=i.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&nb(s,c,i);else if(s.tag===19)nb(s,c,i);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(x){case"forwards":for(c=i.child,x=null;c!==null;)s=c.alternate,s!==null&&yc(s)===null&&(x=c),c=c.sibling;c=x,c===null?(x=i.child,i.child=null):(x=c.sibling,c.sibling=null),Hh(i,!1,x,c,y,h);break;case"backwards":case"unstable_legacy-backwards":for(c=null,x=i.child,i.child=null;x!==null;){if(s=x.alternate,s!==null&&yc(s)===null){i.child=x;break}s=x.sibling,x.sibling=c,c=x,x=s}Hh(i,!0,c,null,y,h);break;case"together":Hh(i,!1,null,null,void 0,h);break;default:i.memoizedState=null}return i.child}function ms(s,i,c){if(s!==null&&(i.dependencies=s.dependencies),qs|=i.lanes,(c&i.childLanes)===0)if(s!==null){if(ma(s,i,c,!1),(c&i.childLanes)===0)return null}else return null;if(s!==null&&i.child!==s.child)throw Error(r(153));if(i.child!==null){for(s=i.child,c=cs(s,s.pendingProps),i.child=c,c.return=i;s.sibling!==null;)s=s.sibling,c=c.sibling=cs(s,s.pendingProps),c.return=i;c.sibling=null}return i.child}function Fh(s,i){return(s.lanes&i)!==0?!0:(s=s.dependencies,!!(s!==null&&uc(s)))}function r2(s,i,c){switch(i.tag){case 3:ve(i,i.stateNode.containerInfo),Bs(i,Xt,s.memoizedState.cache),bi();break;case 27:case 5:Te(i);break;case 4:ve(i,i.stateNode.containerInfo);break;case 10:Bs(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,hh(i),null;break;case 13:var h=i.memoizedState;if(h!==null)return h.dehydrated!==null?(Fs(i),i.flags|=128,null):(c&i.child.childLanes)!==0?tb(s,i,c):(Fs(i),s=ms(s,i,c),s!==null?s.sibling:null);Fs(i);break;case 19:var x=(s.flags&128)!==0;if(h=(c&i.childLanes)!==0,h||(ma(s,i,c,!1),h=(c&i.childLanes)!==0),x){if(h)return rb(s,i,c);i.flags|=128}if(x=i.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),L(qt,qt.current),h)break;return null;case 22:return i.lanes=0,Yy(s,i,c,i.pendingProps);case 24:Bs(i,Xt,s.memoizedState.cache)}return ms(s,i,c)}function sb(s,i,c){if(s!==null)if(s.memoizedProps!==i.pendingProps)Qt=!0;else{if(!Fh(s,c)&&(i.flags&128)===0)return Qt=!1,r2(s,i,c);Qt=(s.flags&131072)!==0}else Qt=!1,at&&(i.flags&1048576)!==0&&Ix(i,go,i.index);switch(i.lanes=0,i.tag){case 16:e:{var h=i.pendingProps;if(s=wi(i.elementType),i.type=s,typeof s=="function")Vd(s)?(h=ji(s,h),i.tag=1,i=Jy(null,i,s,h,c)):(i.tag=0,i=Lh(null,i,s,h,c));else{if(s!=null){var x=s.$$typeof;if(x===O){i.tag=11,i=Vy(null,i,s,h,c);break e}else if(x===Y){i.tag=14,i=Ky(null,i,s,h,c);break e}}throw i=q(s)||s,Error(r(306,i,""))}}return i;case 0:return Lh(s,i,i.type,i.pendingProps,c);case 1:return h=i.type,x=ji(h,i.pendingProps),Jy(s,i,h,x,c);case 3:e:{if(ve(i,i.stateNode.containerInfo),s===null)throw Error(r(387));h=i.pendingProps;var y=i.memoizedState;x=y.element,oh(s,i),ko(i,h,null,c);var w=i.memoizedState;if(h=w.cache,Bs(i,Xt,h),h!==y.cache&&th(i,[Xt],c,!0),wo(),h=w.element,y.isDehydrated)if(y={element:h,isDehydrated:!1,cache:w.cache},i.updateQueue.baseState=y,i.memoizedState=y,i.flags&256){i=eb(s,i,h,c);break e}else if(h!==x){x=_r(Error(r(424)),i),xo(x),i=eb(s,i,h,c);break e}else{switch(s=i.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(Tt=Nr(s.firstChild),En=i,at=!0,Os=null,kr=!0,c=Yx(i,null,h,c),i.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling}else{if(bi(),h===x){i=ms(s,i,c);break e}An(s,i,h,c)}i=i.child}return i;case 26:return Tc(s,i),s===null?(c=mv(i.type,null,i.pendingProps,null))?i.memoizedState=c:at||(c=i.type,s=i.pendingProps,h=Vc(Z.current).createElement(c),h[jn]=i,h[Kn]=s,Dn(h,c,s),mn(h),i.stateNode=h):i.memoizedState=mv(i.type,s.memoizedProps,i.pendingProps,s.memoizedState),null;case 27:return Te(i),s===null&&at&&(h=i.stateNode=hv(i.type,i.pendingProps,Z.current),En=i,kr=!0,x=Tt,Xs(i.type)?(_f=x,Tt=Nr(h.firstChild)):Tt=x),An(s,i,i.pendingProps.children,c),Tc(s,i),s===null&&(i.flags|=4194304),i.child;case 5:return s===null&&at&&((x=h=Tt)&&(h=R2(h,i.type,i.pendingProps,kr),h!==null?(i.stateNode=h,En=i,Tt=Nr(h.firstChild),kr=!1,x=!0):x=!1),x||Is(i)),Te(i),x=i.type,y=i.pendingProps,w=s!==null?s.memoizedProps:null,h=y.children,gf(x,y)?h=null:w!==null&&gf(x,w)&&(i.flags|=32),i.memoizedState!==null&&(x=ph(s,i,GC,null,null,c),Wo._currentValue=x),Tc(s,i),An(s,i,h,c),i.child;case 6:return s===null&&at&&((s=c=Tt)&&(c=L2(c,i.pendingProps,kr),c!==null?(i.stateNode=c,En=i,Tt=null,s=!0):s=!1),s||Is(i)),null;case 13:return tb(s,i,c);case 4:return ve(i,i.stateNode.containerInfo),h=i.pendingProps,s===null?i.child=Ci(i,null,h,c):An(s,i,h,c),i.child;case 11:return Vy(s,i,i.type,i.pendingProps,c);case 7:return An(s,i,i.pendingProps,c),i.child;case 8:return An(s,i,i.pendingProps.children,c),i.child;case 12:return An(s,i,i.pendingProps.children,c),i.child;case 10:return h=i.pendingProps,Bs(i,i.type,h.value),An(s,i,h.children,c),i.child;case 9:return x=i.type._context,h=i.pendingProps.children,_i(i),x=Tn(x),h=h(x),i.flags|=1,An(s,i,h,c),i.child;case 14:return Ky(s,i,i.type,i.pendingProps,c);case 15:return Gy(s,i,i.type,i.pendingProps,c);case 19:return rb(s,i,c);case 31:return n2(s,i,c);case 22:return Yy(s,i,c,i.pendingProps);case 24:return _i(i),h=Tn(Xt),s===null?(x=sh(),x===null&&(x=Ct,y=nh(),x.pooledCache=y,y.refCount++,y!==null&&(x.pooledCacheLanes|=c),x=y),i.memoizedState={parent:h,cache:x},ah(i),Bs(i,Xt,x)):((s.lanes&c)!==0&&(oh(s,i),ko(i,null,null,c),wo()),x=s.memoizedState,y=i.memoizedState,x.parent!==h?(x={parent:h,cache:h},i.memoizedState=x,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=x),Bs(i,Xt,h)):(h=y.cache,Bs(i,Xt,h),h!==x.cache&&th(i,[Xt],c,!0))),An(s,i,i.pendingProps.children,c),i.child;case 29:throw i.pendingProps}throw Error(r(156,i.tag))}function gs(s){s.flags|=4}function $h(s,i,c,h,x){if((i=(s.mode&32)!==0)&&(i=!1),i){if(s.flags|=16777216,(x&335544128)===x)if(s.stateNode.complete)s.flags|=8192;else if(Db())s.flags|=8192;else throw ki=pc,ih}else s.flags&=-16777217}function ib(s,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!vv(i))if(Db())s.flags|=8192;else throw ki=pc,ih}function Dc(s,i){i!==null&&(s.flags|=4),s.flags&16384&&(i=s.tag!==22?Yt():536870912,s.lanes|=i,ja|=i)}function Ao(s,i){if(!at)switch(s.tailMode){case"hidden":i=s.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?s.tail=null:c.sibling=null;break;case"collapsed":c=s.tail;for(var h=null;c!==null;)c.alternate!==null&&(h=c),c=c.sibling;h===null?i||s.tail===null?s.tail=null:s.tail.sibling=null:h.sibling=null}}function At(s){var i=s.alternate!==null&&s.alternate.child===s.child,c=0,h=0;if(i)for(var x=s.child;x!==null;)c|=x.lanes|x.childLanes,h|=x.subtreeFlags&65011712,h|=x.flags&65011712,x.return=s,x=x.sibling;else for(x=s.child;x!==null;)c|=x.lanes|x.childLanes,h|=x.subtreeFlags,h|=x.flags,x.return=s,x=x.sibling;return s.subtreeFlags|=h,s.childLanes=c,i}function s2(s,i,c){var h=i.pendingProps;switch(Xd(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return At(i),null;case 1:return At(i),null;case 3:return c=i.stateNode,h=null,s!==null&&(h=s.memoizedState.cache),i.memoizedState.cache!==h&&(i.flags|=2048),hs(Xt),Ce(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(s===null||s.child===null)&&(pa(i)?gs(i):s===null||s.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Qd())),At(i),null;case 26:var x=i.type,y=i.memoizedState;return s===null?(gs(i),y!==null?(At(i),ib(i,y)):(At(i),$h(i,x,null,h,c))):y?y!==s.memoizedState?(gs(i),At(i),ib(i,y)):(At(i),i.flags&=-16777217):(s=s.memoizedProps,s!==h&&gs(i),At(i),$h(i,x,s,h,c)),null;case 27:if(Pe(i),c=Z.current,x=i.type,s!==null&&i.stateNode!=null)s.memoizedProps!==h&&gs(i);else{if(!h){if(i.stateNode===null)throw Error(r(166));return At(i),null}s=G.current,pa(i)?zx(i):(s=hv(x,h,c),i.stateNode=s,gs(i))}return At(i),null;case 5:if(Pe(i),x=i.type,s!==null&&i.stateNode!=null)s.memoizedProps!==h&&gs(i);else{if(!h){if(i.stateNode===null)throw Error(r(166));return At(i),null}if(y=G.current,pa(i))zx(i);else{var w=Vc(Z.current);switch(y){case 1:y=w.createElementNS("http://www.w3.org/2000/svg",x);break;case 2:y=w.createElementNS("http://www.w3.org/1998/Math/MathML",x);break;default:switch(x){case"svg":y=w.createElementNS("http://www.w3.org/2000/svg",x);break;case"math":y=w.createElementNS("http://www.w3.org/1998/Math/MathML",x);break;case"script":y=w.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof h.is=="string"?w.createElement("select",{is:h.is}):w.createElement("select"),h.multiple?y.multiple=!0:h.size&&(y.size=h.size);break;default:y=typeof h.is=="string"?w.createElement(x,{is:h.is}):w.createElement(x)}}y[jn]=i,y[Kn]=h;e:for(w=i.child;w!==null;){if(w.tag===5||w.tag===6)y.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===i)break e;for(;w.sibling===null;){if(w.return===null||w.return===i)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}i.stateNode=y;e:switch(Dn(y,x,h),x){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}h&&gs(i)}}return At(i),$h(i,i.type,s===null?null:s.memoizedProps,i.pendingProps,c),null;case 6:if(s&&i.stateNode!=null)s.memoizedProps!==h&&gs(i);else{if(typeof h!="string"&&i.stateNode===null)throw Error(r(166));if(s=Z.current,pa(i)){if(s=i.stateNode,c=i.memoizedProps,h=null,x=En,x!==null)switch(x.tag){case 27:case 5:h=x.memoizedProps}s[jn]=i,s=!!(s.nodeValue===c||h!==null&&h.suppressHydrationWarning===!0||tv(s.nodeValue,c)),s||Is(i,!0)}else s=Vc(s).createTextNode(h),s[jn]=i,i.stateNode=s}return At(i),null;case 31:if(c=i.memoizedState,s===null||s.memoizedState!==null){if(h=pa(i),c!==null){if(s===null){if(!h)throw Error(r(318));if(s=i.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[jn]=i}else bi(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;At(i),s=!1}else c=Qd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=c),s=!0;if(!s)return i.flags&256?(ar(i),i):(ar(i),null);if((i.flags&128)!==0)throw Error(r(558))}return At(i),null;case 13:if(h=i.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(x=pa(i),h!==null&&h.dehydrated!==null){if(s===null){if(!x)throw Error(r(318));if(x=i.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(r(317));x[jn]=i}else bi(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;At(i),x=!1}else x=Qd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=x),x=!0;if(!x)return i.flags&256?(ar(i),i):(ar(i),null)}return ar(i),(i.flags&128)!==0?(i.lanes=c,i):(c=h!==null,s=s!==null&&s.memoizedState!==null,c&&(h=i.child,x=null,h.alternate!==null&&h.alternate.memoizedState!==null&&h.alternate.memoizedState.cachePool!==null&&(x=h.alternate.memoizedState.cachePool.pool),y=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(y=h.memoizedState.cachePool.pool),y!==x&&(h.flags|=2048)),c!==s&&c&&(i.child.flags|=8192),Dc(i,i.updateQueue),At(i),null);case 4:return Ce(),s===null&&df(i.stateNode.containerInfo),At(i),null;case 10:return hs(i.type),At(i),null;case 19:if(V(qt),h=i.memoizedState,h===null)return At(i),null;if(x=(i.flags&128)!==0,y=h.rendering,y===null)if(x)Ao(h,!1);else{if(Ft!==0||s!==null&&(s.flags&128)!==0)for(s=i.child;s!==null;){if(y=yc(s),y!==null){for(i.flags|=128,Ao(h,!1),s=y.updateQueue,i.updateQueue=s,Dc(i,s),i.subtreeFlags=0,s=c,c=i.child;c!==null;)Rx(c,s),c=c.sibling;return L(qt,qt.current&1|2),at&&us(i,h.treeForkCount),i.child}s=s.sibling}h.tail!==null&&Ie()>Ic&&(i.flags|=128,x=!0,Ao(h,!1),i.lanes=4194304)}else{if(!x)if(s=yc(y),s!==null){if(i.flags|=128,x=!0,s=s.updateQueue,i.updateQueue=s,Dc(i,s),Ao(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!at)return At(i),null}else 2*Ie()-h.renderingStartTime>Ic&&c!==536870912&&(i.flags|=128,x=!0,Ao(h,!1),i.lanes=4194304);h.isBackwards?(y.sibling=i.child,i.child=y):(s=h.last,s!==null?s.sibling=y:i.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=Ie(),s.sibling=null,c=qt.current,L(qt,x?c&1|2:c&1),at&&us(i,h.treeForkCount),s):(At(i),null);case 22:case 23:return ar(i),dh(),h=i.memoizedState!==null,s!==null?s.memoizedState!==null!==h&&(i.flags|=8192):h&&(i.flags|=8192),h?(c&536870912)!==0&&(i.flags&128)===0&&(At(i),i.subtreeFlags&6&&(i.flags|=8192)):At(i),c=i.updateQueue,c!==null&&Dc(i,c.retryQueue),c=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(c=s.memoizedState.cachePool.pool),h=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(h=i.memoizedState.cachePool.pool),h!==c&&(i.flags|=2048),s!==null&&V(Si),null;case 24:return c=null,s!==null&&(c=s.memoizedState.cache),i.memoizedState.cache!==c&&(i.flags|=2048),hs(Xt),At(i),null;case 25:return null;case 30:return null}throw Error(r(156,i.tag))}function i2(s,i){switch(Xd(i),i.tag){case 1:return s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 3:return hs(Xt),Ce(),s=i.flags,(s&65536)!==0&&(s&128)===0?(i.flags=s&-65537|128,i):null;case 26:case 27:case 5:return Pe(i),null;case 31:if(i.memoizedState!==null){if(ar(i),i.alternate===null)throw Error(r(340));bi()}return s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 13:if(ar(i),s=i.memoizedState,s!==null&&s.dehydrated!==null){if(i.alternate===null)throw Error(r(340));bi()}return s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 19:return V(qt),null;case 4:return Ce(),null;case 10:return hs(i.type),null;case 22:case 23:return ar(i),dh(),s!==null&&V(Si),s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 24:return hs(Xt),null;case 25:return null;default:return null}}function ab(s,i){switch(Xd(i),i.tag){case 3:hs(Xt),Ce();break;case 26:case 27:case 5:Pe(i);break;case 4:Ce();break;case 31:i.memoizedState!==null&&ar(i);break;case 13:ar(i);break;case 19:V(qt);break;case 10:hs(i.type);break;case 22:case 23:ar(i),dh(),s!==null&&V(Si);break;case 24:hs(Xt)}}function Do(s,i){try{var c=i.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var x=h.next;c=x;do{if((c.tag&s)===s){h=void 0;var y=c.create,w=c.inst;h=y(),w.destroy=h}c=c.next}while(c!==x)}}catch(M){yt(i,i.return,M)}}function Us(s,i,c){try{var h=i.updateQueue,x=h!==null?h.lastEffect:null;if(x!==null){var y=x.next;h=y;do{if((h.tag&s)===s){var w=h.inst,M=w.destroy;if(M!==void 0){w.destroy=void 0,x=i;var K=c,ne=M;try{ne()}catch(ue){yt(x,K,ue)}}}h=h.next}while(h!==y)}}catch(ue){yt(i,i.return,ue)}}function ob(s){var i=s.updateQueue;if(i!==null){var c=s.stateNode;try{Zx(i,c)}catch(h){yt(s,s.return,h)}}}function lb(s,i,c){c.props=ji(s.type,s.memoizedProps),c.state=s.memoizedState;try{c.componentWillUnmount()}catch(h){yt(s,i,h)}}function Mo(s,i){try{var c=s.ref;if(c!==null){switch(s.tag){case 26:case 27:case 5:var h=s.stateNode;break;case 30:h=s.stateNode;break;default:h=s.stateNode}typeof c=="function"?s.refCleanup=c(h):c.current=h}}catch(x){yt(s,i,x)}}function Ur(s,i){var c=s.ref,h=s.refCleanup;if(c!==null)if(typeof h=="function")try{h()}catch(x){yt(s,i,x)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(x){yt(s,i,x)}else c.current=null}function cb(s){var i=s.type,c=s.memoizedProps,h=s.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":c.autoFocus&&h.focus();break e;case"img":c.src?h.src=c.src:c.srcSet&&(h.srcset=c.srcSet)}}catch(x){yt(s,s.return,x)}}function Uh(s,i,c){try{var h=s.stateNode;j2(h,s.type,c,i),h[Kn]=i}catch(x){yt(s,s.return,x)}}function ub(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Xs(s.type)||s.tag===4}function Wh(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||ub(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Xs(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function qh(s,i,c){var h=s.tag;if(h===5||h===6)s=s.stateNode,i?(c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c).insertBefore(s,i):(i=c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c,i.appendChild(s),c=c._reactRootContainer,c!=null||i.onclick!==null||(i.onclick=os));else if(h!==4&&(h===27&&Xs(s.type)&&(c=s.stateNode,i=null),s=s.child,s!==null))for(qh(s,i,c),s=s.sibling;s!==null;)qh(s,i,c),s=s.sibling}function Mc(s,i,c){var h=s.tag;if(h===5||h===6)s=s.stateNode,i?c.insertBefore(s,i):c.appendChild(s);else if(h!==4&&(h===27&&Xs(s.type)&&(c=s.stateNode),s=s.child,s!==null))for(Mc(s,i,c),s=s.sibling;s!==null;)Mc(s,i,c),s=s.sibling}function db(s){var i=s.stateNode,c=s.memoizedProps;try{for(var h=s.type,x=i.attributes;x.length;)i.removeAttributeNode(x[0]);Dn(i,h,c),i[jn]=s,i[Kn]=c}catch(y){yt(s,s.return,y)}}var xs=!1,Jt=!1,Vh=!1,hb=typeof WeakSet=="function"?WeakSet:Set,gn=null;function a2(s,i){if(s=s.containerInfo,pf=Jc,s=kx(s),Pd(s)){if("selectionStart"in s)var c={start:s.selectionStart,end:s.selectionEnd};else e:{c=(c=s.ownerDocument)&&c.defaultView||window;var h=c.getSelection&&c.getSelection();if(h&&h.rangeCount!==0){c=h.anchorNode;var x=h.anchorOffset,y=h.focusNode;h=h.focusOffset;try{c.nodeType,y.nodeType}catch{c=null;break e}var w=0,M=-1,K=-1,ne=0,ue=0,fe=s,re=null;t:for(;;){for(var oe;fe!==c||x!==0&&fe.nodeType!==3||(M=w+x),fe!==y||h!==0&&fe.nodeType!==3||(K=w+h),fe.nodeType===3&&(w+=fe.nodeValue.length),(oe=fe.firstChild)!==null;)re=fe,fe=oe;for(;;){if(fe===s)break t;if(re===c&&++ne===x&&(M=w),re===y&&++ue===h&&(K=w),(oe=fe.nextSibling)!==null)break;fe=re,re=fe.parentNode}fe=oe}c=M===-1||K===-1?null:{start:M,end:K}}else c=null}c=c||{start:0,end:0}}else c=null;for(mf={focusedElem:s,selectionRange:c},Jc=!1,gn=i;gn!==null;)if(i=gn,s=i.child,(i.subtreeFlags&1028)!==0&&s!==null)s.return=i,gn=s;else for(;gn!==null;){switch(i=gn,y=i.alternate,s=i.flags,i.tag){case 0:if((s&4)!==0&&(s=i.updateQueue,s=s!==null?s.events:null,s!==null))for(c=0;c<s.length;c++)x=s[c],x.ref.impl=x.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&y!==null){s=void 0,c=i,x=y.memoizedProps,y=y.memoizedState,h=c.stateNode;try{var Ee=ji(c.type,x);s=h.getSnapshotBeforeUpdate(Ee,y),h.__reactInternalSnapshotBeforeUpdate=s}catch(ze){yt(c,c.return,ze)}}break;case 3:if((s&1024)!==0){if(s=i.stateNode.containerInfo,c=s.nodeType,c===9)yf(s);else if(c===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":yf(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(r(163))}if(s=i.sibling,s!==null){s.return=i.return,gn=s;break}gn=i.return}}function fb(s,i,c){var h=c.flags;switch(c.tag){case 0:case 11:case 15:bs(s,c),h&4&&Do(5,c);break;case 1:if(bs(s,c),h&4)if(s=c.stateNode,i===null)try{s.componentDidMount()}catch(w){yt(c,c.return,w)}else{var x=ji(c.type,i.memoizedProps);i=i.memoizedState;try{s.componentDidUpdate(x,i,s.__reactInternalSnapshotBeforeUpdate)}catch(w){yt(c,c.return,w)}}h&64&&ob(c),h&512&&Mo(c,c.return);break;case 3:if(bs(s,c),h&64&&(s=c.updateQueue,s!==null)){if(i=null,c.child!==null)switch(c.child.tag){case 27:case 5:i=c.child.stateNode;break;case 1:i=c.child.stateNode}try{Zx(s,i)}catch(w){yt(c,c.return,w)}}break;case 27:i===null&&h&4&&db(c);case 26:case 5:bs(s,c),i===null&&h&4&&cb(c),h&512&&Mo(c,c.return);break;case 12:bs(s,c);break;case 31:bs(s,c),h&4&&gb(s,c);break;case 13:bs(s,c),h&4&&xb(s,c),h&64&&(s=c.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(c=m2.bind(null,c),O2(s,c))));break;case 22:if(h=c.memoizedState!==null||xs,!h){i=i!==null&&i.memoizedState!==null||Jt,x=xs;var y=Jt;xs=h,(Jt=i)&&!y?vs(s,c,(c.subtreeFlags&8772)!==0):bs(s,c),xs=x,Jt=y}break;case 30:break;default:bs(s,c)}}function pb(s){var i=s.alternate;i!==null&&(s.alternate=null,pb(i)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(i=s.stateNode,i!==null&&Sd(i)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var Ot=null,Yn=!1;function ys(s,i,c){for(c=c.child;c!==null;)mb(s,i,c),c=c.sibling}function mb(s,i,c){if(Bt&&typeof Bt.onCommitFiberUnmount=="function")try{Bt.onCommitFiberUnmount(on,c)}catch{}switch(c.tag){case 26:Jt||Ur(c,i),ys(s,i,c),c.memoizedState?c.memoizedState.count--:c.stateNode&&(c=c.stateNode,c.parentNode.removeChild(c));break;case 27:Jt||Ur(c,i);var h=Ot,x=Yn;Xs(c.type)&&(Ot=c.stateNode,Yn=!1),ys(s,i,c),Fo(c.stateNode),Ot=h,Yn=x;break;case 5:Jt||Ur(c,i);case 6:if(h=Ot,x=Yn,Ot=null,ys(s,i,c),Ot=h,Yn=x,Ot!==null)if(Yn)try{(Ot.nodeType===9?Ot.body:Ot.nodeName==="HTML"?Ot.ownerDocument.body:Ot).removeChild(c.stateNode)}catch(y){yt(c,i,y)}else try{Ot.removeChild(c.stateNode)}catch(y){yt(c,i,y)}break;case 18:Ot!==null&&(Yn?(s=Ot,ov(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,c.stateNode),Oa(s)):ov(Ot,c.stateNode));break;case 4:h=Ot,x=Yn,Ot=c.stateNode.containerInfo,Yn=!0,ys(s,i,c),Ot=h,Yn=x;break;case 0:case 11:case 14:case 15:Us(2,c,i),Jt||Us(4,c,i),ys(s,i,c);break;case 1:Jt||(Ur(c,i),h=c.stateNode,typeof h.componentWillUnmount=="function"&&lb(c,i,h)),ys(s,i,c);break;case 21:ys(s,i,c);break;case 22:Jt=(h=Jt)||c.memoizedState!==null,ys(s,i,c),Jt=h;break;default:ys(s,i,c)}}function gb(s,i){if(i.memoizedState===null&&(s=i.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Oa(s)}catch(c){yt(i,i.return,c)}}}function xb(s,i){if(i.memoizedState===null&&(s=i.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Oa(s)}catch(c){yt(i,i.return,c)}}function o2(s){switch(s.tag){case 31:case 13:case 19:var i=s.stateNode;return i===null&&(i=s.stateNode=new hb),i;case 22:return s=s.stateNode,i=s._retryCache,i===null&&(i=s._retryCache=new hb),i;default:throw Error(r(435,s.tag))}}function Rc(s,i){var c=o2(s);i.forEach(function(h){if(!c.has(h)){c.add(h);var x=g2.bind(null,s,h);h.then(x,x)}})}function Xn(s,i){var c=i.deletions;if(c!==null)for(var h=0;h<c.length;h++){var x=c[h],y=s,w=i,M=w;e:for(;M!==null;){switch(M.tag){case 27:if(Xs(M.type)){Ot=M.stateNode,Yn=!1;break e}break;case 5:Ot=M.stateNode,Yn=!1;break e;case 3:case 4:Ot=M.stateNode.containerInfo,Yn=!0;break e}M=M.return}if(Ot===null)throw Error(r(160));mb(y,w,x),Ot=null,Yn=!1,y=x.alternate,y!==null&&(y.return=null),x.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)yb(i,s),i=i.sibling}var Lr=null;function yb(s,i){var c=s.alternate,h=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:Xn(i,s),Zn(s),h&4&&(Us(3,s,s.return),Do(3,s),Us(5,s,s.return));break;case 1:Xn(i,s),Zn(s),h&512&&(Jt||c===null||Ur(c,c.return)),h&64&&xs&&(s=s.updateQueue,s!==null&&(h=s.callbacks,h!==null&&(c=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=c===null?h:c.concat(h))));break;case 26:var x=Lr;if(Xn(i,s),Zn(s),h&512&&(Jt||c===null||Ur(c,c.return)),h&4){var y=c!==null?c.memoizedState:null;if(h=s.memoizedState,c===null)if(h===null)if(s.stateNode===null){e:{h=s.type,c=s.memoizedProps,x=x.ownerDocument||x;t:switch(h){case"title":y=x.getElementsByTagName("title")[0],(!y||y[so]||y[jn]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=x.createElement(h),x.head.insertBefore(y,x.querySelector("head > title"))),Dn(y,h,c),y[jn]=s,mn(y),h=y;break e;case"link":var w=yv("link","href",x).get(h+(c.href||""));if(w){for(var M=0;M<w.length;M++)if(y=w[M],y.getAttribute("href")===(c.href==null||c.href===""?null:c.href)&&y.getAttribute("rel")===(c.rel==null?null:c.rel)&&y.getAttribute("title")===(c.title==null?null:c.title)&&y.getAttribute("crossorigin")===(c.crossOrigin==null?null:c.crossOrigin)){w.splice(M,1);break t}}y=x.createElement(h),Dn(y,h,c),x.head.appendChild(y);break;case"meta":if(w=yv("meta","content",x).get(h+(c.content||""))){for(M=0;M<w.length;M++)if(y=w[M],y.getAttribute("content")===(c.content==null?null:""+c.content)&&y.getAttribute("name")===(c.name==null?null:c.name)&&y.getAttribute("property")===(c.property==null?null:c.property)&&y.getAttribute("http-equiv")===(c.httpEquiv==null?null:c.httpEquiv)&&y.getAttribute("charset")===(c.charSet==null?null:c.charSet)){w.splice(M,1);break t}}y=x.createElement(h),Dn(y,h,c),x.head.appendChild(y);break;default:throw Error(r(468,h))}y[jn]=s,mn(y),h=y}s.stateNode=h}else bv(x,s.type,s.stateNode);else s.stateNode=xv(x,h,s.memoizedProps);else y!==h?(y===null?c.stateNode!==null&&(c=c.stateNode,c.parentNode.removeChild(c)):y.count--,h===null?bv(x,s.type,s.stateNode):xv(x,h,s.memoizedProps)):h===null&&s.stateNode!==null&&Uh(s,s.memoizedProps,c.memoizedProps)}break;case 27:Xn(i,s),Zn(s),h&512&&(Jt||c===null||Ur(c,c.return)),c!==null&&h&4&&Uh(s,s.memoizedProps,c.memoizedProps);break;case 5:if(Xn(i,s),Zn(s),h&512&&(Jt||c===null||Ur(c,c.return)),s.flags&32){x=s.stateNode;try{sa(x,"")}catch(Ee){yt(s,s.return,Ee)}}h&4&&s.stateNode!=null&&(x=s.memoizedProps,Uh(s,x,c!==null?c.memoizedProps:x)),h&1024&&(Vh=!0);break;case 6:if(Xn(i,s),Zn(s),h&4){if(s.stateNode===null)throw Error(r(162));h=s.memoizedProps,c=s.stateNode;try{c.nodeValue=h}catch(Ee){yt(s,s.return,Ee)}}break;case 3:if(Yc=null,x=Lr,Lr=Kc(i.containerInfo),Xn(i,s),Lr=x,Zn(s),h&4&&c!==null&&c.memoizedState.isDehydrated)try{Oa(i.containerInfo)}catch(Ee){yt(s,s.return,Ee)}Vh&&(Vh=!1,bb(s));break;case 4:h=Lr,Lr=Kc(s.stateNode.containerInfo),Xn(i,s),Zn(s),Lr=h;break;case 12:Xn(i,s),Zn(s);break;case 31:Xn(i,s),Zn(s),h&4&&(h=s.updateQueue,h!==null&&(s.updateQueue=null,Rc(s,h)));break;case 13:Xn(i,s),Zn(s),s.child.flags&8192&&s.memoizedState!==null!=(c!==null&&c.memoizedState!==null)&&(Oc=Ie()),h&4&&(h=s.updateQueue,h!==null&&(s.updateQueue=null,Rc(s,h)));break;case 22:x=s.memoizedState!==null;var K=c!==null&&c.memoizedState!==null,ne=xs,ue=Jt;if(xs=ne||x,Jt=ue||K,Xn(i,s),Jt=ue,xs=ne,Zn(s),h&8192)e:for(i=s.stateNode,i._visibility=x?i._visibility&-2:i._visibility|1,x&&(c===null||K||xs||Jt||Ei(s)),c=null,i=s;;){if(i.tag===5||i.tag===26){if(c===null){K=c=i;try{if(y=K.stateNode,x)w=y.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none";else{M=K.stateNode;var fe=K.memoizedProps.style,re=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;M.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(Ee){yt(K,K.return,Ee)}}}else if(i.tag===6){if(c===null){K=i;try{K.stateNode.nodeValue=x?"":K.memoizedProps}catch(Ee){yt(K,K.return,Ee)}}}else if(i.tag===18){if(c===null){K=i;try{var oe=K.stateNode;x?lv(oe,!0):lv(K.stateNode,!1)}catch(Ee){yt(K,K.return,Ee)}}}else if((i.tag!==22&&i.tag!==23||i.memoizedState===null||i===s)&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;c===i&&(c=null),i=i.return}c===i&&(c=null),i.sibling.return=i.return,i=i.sibling}h&4&&(h=s.updateQueue,h!==null&&(c=h.retryQueue,c!==null&&(h.retryQueue=null,Rc(s,c))));break;case 19:Xn(i,s),Zn(s),h&4&&(h=s.updateQueue,h!==null&&(s.updateQueue=null,Rc(s,h)));break;case 30:break;case 21:break;default:Xn(i,s),Zn(s)}}function Zn(s){var i=s.flags;if(i&2){try{for(var c,h=s.return;h!==null;){if(ub(h)){c=h;break}h=h.return}if(c==null)throw Error(r(160));switch(c.tag){case 27:var x=c.stateNode,y=Wh(s);Mc(s,y,x);break;case 5:var w=c.stateNode;c.flags&32&&(sa(w,""),c.flags&=-33);var M=Wh(s);Mc(s,M,w);break;case 3:case 4:var K=c.stateNode.containerInfo,ne=Wh(s);qh(s,ne,K);break;default:throw Error(r(161))}}catch(ue){yt(s,s.return,ue)}s.flags&=-3}i&4096&&(s.flags&=-4097)}function bb(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var i=s;bb(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),s=s.sibling}}function bs(s,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)fb(s,i.alternate,i),i=i.sibling}function Ei(s){for(s=s.child;s!==null;){var i=s;switch(i.tag){case 0:case 11:case 14:case 15:Us(4,i,i.return),Ei(i);break;case 1:Ur(i,i.return);var c=i.stateNode;typeof c.componentWillUnmount=="function"&&lb(i,i.return,c),Ei(i);break;case 27:Fo(i.stateNode);case 26:case 5:Ur(i,i.return),Ei(i);break;case 22:i.memoizedState===null&&Ei(i);break;case 30:Ei(i);break;default:Ei(i)}s=s.sibling}}function vs(s,i,c){for(c=c&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var h=i.alternate,x=s,y=i,w=y.flags;switch(y.tag){case 0:case 11:case 15:vs(x,y,c),Do(4,y);break;case 1:if(vs(x,y,c),h=y,x=h.stateNode,typeof x.componentDidMount=="function")try{x.componentDidMount()}catch(ne){yt(h,h.return,ne)}if(h=y,x=h.updateQueue,x!==null){var M=h.stateNode;try{var K=x.shared.hiddenCallbacks;if(K!==null)for(x.shared.hiddenCallbacks=null,x=0;x<K.length;x++)Xx(K[x],M)}catch(ne){yt(h,h.return,ne)}}c&&w&64&&ob(y),Mo(y,y.return);break;case 27:db(y);case 26:case 5:vs(x,y,c),c&&h===null&&w&4&&cb(y),Mo(y,y.return);break;case 12:vs(x,y,c);break;case 31:vs(x,y,c),c&&w&4&&gb(x,y);break;case 13:vs(x,y,c),c&&w&4&&xb(x,y);break;case 22:y.memoizedState===null&&vs(x,y,c),Mo(y,y.return);break;case 30:break;default:vs(x,y,c)}i=i.sibling}}function Kh(s,i){var c=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(c=s.memoizedState.cachePool.pool),s=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(s=i.memoizedState.cachePool.pool),s!==c&&(s!=null&&s.refCount++,c!=null&&yo(c))}function Gh(s,i){s=null,i.alternate!==null&&(s=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==s&&(i.refCount++,s!=null&&yo(s))}function Or(s,i,c,h){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)vb(s,i,c,h),i=i.sibling}function vb(s,i,c,h){var x=i.flags;switch(i.tag){case 0:case 11:case 15:Or(s,i,c,h),x&2048&&Do(9,i);break;case 1:Or(s,i,c,h);break;case 3:Or(s,i,c,h),x&2048&&(s=null,i.alternate!==null&&(s=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==s&&(i.refCount++,s!=null&&yo(s)));break;case 12:if(x&2048){Or(s,i,c,h),s=i.stateNode;try{var y=i.memoizedProps,w=y.id,M=y.onPostCommit;typeof M=="function"&&M(w,i.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(K){yt(i,i.return,K)}}else Or(s,i,c,h);break;case 31:Or(s,i,c,h);break;case 13:Or(s,i,c,h);break;case 23:break;case 22:y=i.stateNode,w=i.alternate,i.memoizedState!==null?y._visibility&2?Or(s,i,c,h):Ro(s,i):y._visibility&2?Or(s,i,c,h):(y._visibility|=2,ka(s,i,c,h,(i.subtreeFlags&10256)!==0||!1)),x&2048&&Kh(w,i);break;case 24:Or(s,i,c,h),x&2048&&Gh(i.alternate,i);break;default:Or(s,i,c,h)}}function ka(s,i,c,h,x){for(x=x&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var y=s,w=i,M=c,K=h,ne=w.flags;switch(w.tag){case 0:case 11:case 15:ka(y,w,M,K,x),Do(8,w);break;case 23:break;case 22:var ue=w.stateNode;w.memoizedState!==null?ue._visibility&2?ka(y,w,M,K,x):Ro(y,w):(ue._visibility|=2,ka(y,w,M,K,x)),x&&ne&2048&&Kh(w.alternate,w);break;case 24:ka(y,w,M,K,x),x&&ne&2048&&Gh(w.alternate,w);break;default:ka(y,w,M,K,x)}i=i.sibling}}function Ro(s,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var c=s,h=i,x=h.flags;switch(h.tag){case 22:Ro(c,h),x&2048&&Kh(h.alternate,h);break;case 24:Ro(c,h),x&2048&&Gh(h.alternate,h);break;default:Ro(c,h)}i=i.sibling}}var Lo=8192;function Ca(s,i,c){if(s.subtreeFlags&Lo)for(s=s.child;s!==null;)_b(s,i,c),s=s.sibling}function _b(s,i,c){switch(s.tag){case 26:Ca(s,i,c),s.flags&Lo&&s.memoizedState!==null&&K2(c,Lr,s.memoizedState,s.memoizedProps);break;case 5:Ca(s,i,c);break;case 3:case 4:var h=Lr;Lr=Kc(s.stateNode.containerInfo),Ca(s,i,c),Lr=h;break;case 22:s.memoizedState===null&&(h=s.alternate,h!==null&&h.memoizedState!==null?(h=Lo,Lo=16777216,Ca(s,i,c),Lo=h):Ca(s,i,c));break;default:Ca(s,i,c)}}function Sb(s){var i=s.alternate;if(i!==null&&(s=i.child,s!==null)){i.child=null;do i=s.sibling,s.sibling=null,s=i;while(s!==null)}}function Oo(s){var i=s.deletions;if((s.flags&16)!==0){if(i!==null)for(var c=0;c<i.length;c++){var h=i[c];gn=h,kb(h,s)}Sb(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)wb(s),s=s.sibling}function wb(s){switch(s.tag){case 0:case 11:case 15:Oo(s),s.flags&2048&&Us(9,s,s.return);break;case 3:Oo(s);break;case 12:Oo(s);break;case 22:var i=s.stateNode;s.memoizedState!==null&&i._visibility&2&&(s.return===null||s.return.tag!==13)?(i._visibility&=-3,Lc(s)):Oo(s);break;default:Oo(s)}}function Lc(s){var i=s.deletions;if((s.flags&16)!==0){if(i!==null)for(var c=0;c<i.length;c++){var h=i[c];gn=h,kb(h,s)}Sb(s)}for(s=s.child;s!==null;){switch(i=s,i.tag){case 0:case 11:case 15:Us(8,i,i.return),Lc(i);break;case 22:c=i.stateNode,c._visibility&2&&(c._visibility&=-3,Lc(i));break;default:Lc(i)}s=s.sibling}}function kb(s,i){for(;gn!==null;){var c=gn;switch(c.tag){case 0:case 11:case 15:Us(8,c,i);break;case 23:case 22:if(c.memoizedState!==null&&c.memoizedState.cachePool!==null){var h=c.memoizedState.cachePool.pool;h!=null&&h.refCount++}break;case 24:yo(c.memoizedState.cache)}if(h=c.child,h!==null)h.return=c,gn=h;else e:for(c=s;gn!==null;){h=gn;var x=h.sibling,y=h.return;if(pb(h),h===c){gn=null;break e}if(x!==null){x.return=y,gn=x;break e}gn=y}}}var l2={getCacheForType:function(s){var i=Tn(Xt),c=i.data.get(s);return c===void 0&&(c=s(),i.data.set(s,c)),c},cacheSignal:function(){return Tn(Xt).controller.signal}},c2=typeof WeakMap=="function"?WeakMap:Map,mt=0,Ct=null,et=null,rt=0,xt=0,or=null,Ws=!1,Na=!1,Yh=!1,_s=0,Ft=0,qs=0,Ti=0,Xh=0,lr=0,ja=0,Io=null,Qn=null,Zh=!1,Oc=0,Cb=0,Ic=1/0,Bc=null,Vs=null,cn=0,Ks=null,Ea=null,Ss=0,Qh=0,Jh=null,Nb=null,Bo=0,ef=null;function cr(){return(mt&2)!==0&&rt!==0?rt&-rt:N.T!==null?of():$g()}function jb(){if(lr===0)if((rt&536870912)===0||at){var s=ge;ge<<=1,(ge&3932160)===0&&(ge=262144),lr=s}else lr=536870912;return s=ir.current,s!==null&&(s.flags|=32),lr}function Jn(s,i,c){(s===Ct&&(xt===2||xt===9)||s.cancelPendingCommit!==null)&&(Ta(s,0),Gs(s,rt,lr,!1)),Zi(s,c),((mt&2)===0||s!==Ct)&&(s===Ct&&((mt&2)===0&&(Ti|=c),Ft===4&&Gs(s,rt,lr,!1)),Wr(s))}function Eb(s,i,c){if((mt&6)!==0)throw Error(r(327));var h=!c&&(i&127)===0&&(i&s.expiredLanes)===0||He(s,i),x=h?h2(s,i):nf(s,i,!0),y=h;do{if(x===0){Na&&!h&&Gs(s,i,0,!1);break}else{if(c=s.current.alternate,y&&!u2(c)){x=nf(s,i,!1),y=!1;continue}if(x===2){if(y=i,s.errorRecoveryDisabledLanes&y)var w=0;else w=s.pendingLanes&-536870913,w=w!==0?w:w&536870912?536870912:0;if(w!==0){i=w;e:{var M=s;x=Io;var K=M.current.memoizedState.isDehydrated;if(K&&(Ta(M,w).flags|=256),w=nf(M,w,!1),w!==2){if(Yh&&!K){M.errorRecoveryDisabledLanes|=y,Ti|=y,x=4;break e}y=Qn,Qn=x,y!==null&&(Qn===null?Qn=y:Qn.push.apply(Qn,y))}x=w}if(y=!1,x!==2)continue}}if(x===1){Ta(s,0),Gs(s,i,0,!0);break}e:{switch(h=s,y=x,y){case 0:case 1:throw Error(r(345));case 4:if((i&4194048)!==i)break;case 6:Gs(h,i,lr,!Ws);break e;case 2:Qn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((i&62914560)===i&&(x=Oc+300-Ie(),10<x)){if(Gs(h,i,lr,!Ws),it(h,0,!0)!==0)break e;Ss=i,h.timeoutHandle=iv(Tb.bind(null,h,c,Qn,Bc,Zh,i,lr,Ti,ja,Ws,y,"Throttled",-0,0),x);break e}Tb(h,c,Qn,Bc,Zh,i,lr,Ti,ja,Ws,y,null,-0,0)}}break}while(!0);Wr(s)}function Tb(s,i,c,h,x,y,w,M,K,ne,ue,fe,re,oe){if(s.timeoutHandle=-1,fe=i.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:os},_b(i,y,fe);var Ee=(y&62914560)===y?Oc-Ie():(y&4194048)===y?Cb-Ie():0;if(Ee=G2(fe,Ee),Ee!==null){Ss=y,s.cancelPendingCommit=Ee(Bb.bind(null,s,i,y,c,h,x,w,M,K,ue,fe,null,re,oe)),Gs(s,y,w,!ne);return}}Bb(s,i,y,c,h,x,w,M,K)}function u2(s){for(var i=s;;){var c=i.tag;if((c===0||c===11||c===15)&&i.flags&16384&&(c=i.updateQueue,c!==null&&(c=c.stores,c!==null)))for(var h=0;h<c.length;h++){var x=c[h],y=x.getSnapshot;x=x.value;try{if(!rr(y(),x))return!1}catch{return!1}}if(c=i.child,i.subtreeFlags&16384&&c!==null)c.return=i,i=c;else{if(i===s)break;for(;i.sibling===null;){if(i.return===null||i.return===s)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Gs(s,i,c,h){i&=~Xh,i&=~Ti,s.suspendedLanes|=i,s.pingedLanes&=~i,h&&(s.warmLanes|=i),h=s.expirationTimes;for(var x=i;0<x;){var y=31-we(x),w=1<<y;h[y]=-1,x&=~w}c!==0&&Pg(s,c,i)}function zc(){return(mt&6)===0?(zo(0),!1):!0}function tf(){if(et!==null){if(xt===0)var s=et.return;else s=et,ds=vi=null,xh(s),ba=null,vo=0,s=et;for(;s!==null;)ab(s.alternate,s),s=s.return;et=null}}function Ta(s,i){var c=s.timeoutHandle;c!==-1&&(s.timeoutHandle=-1,A2(c)),c=s.cancelPendingCommit,c!==null&&(s.cancelPendingCommit=null,c()),Ss=0,tf(),Ct=s,et=c=cs(s.current,null),rt=i,xt=0,or=null,Ws=!1,Na=He(s,i),Yh=!1,ja=lr=Xh=Ti=qs=Ft=0,Qn=Io=null,Zh=!1,(i&8)!==0&&(i|=i&32);var h=s.entangledLanes;if(h!==0)for(s=s.entanglements,h&=i;0<h;){var x=31-we(h),y=1<<x;i|=s[x],h&=~y}return _s=i,ic(),c}function Ab(s,i){Ve=null,N.H=Eo,i===ya||i===fc?(i=Vx(),xt=3):i===ih?(i=Vx(),xt=4):xt=i===Rh?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,or=i,et===null&&(Ft=1,jc(s,_r(i,s.current)))}function Db(){var s=ir.current;return s===null?!0:(rt&4194048)===rt?Cr===null:(rt&62914560)===rt||(rt&536870912)!==0?s===Cr:!1}function Mb(){var s=N.H;return N.H=Eo,s===null?Eo:s}function Rb(){var s=N.A;return N.A=l2,s}function Pc(){Ft=4,Ws||(rt&4194048)!==rt&&ir.current!==null||(Na=!0),(qs&134217727)===0&&(Ti&134217727)===0||Ct===null||Gs(Ct,rt,lr,!1)}function nf(s,i,c){var h=mt;mt|=2;var x=Mb(),y=Rb();(Ct!==s||rt!==i)&&(Bc=null,Ta(s,i)),i=!1;var w=Ft;e:do try{if(xt!==0&&et!==null){var M=et,K=or;switch(xt){case 8:tf(),w=6;break e;case 3:case 2:case 9:case 6:ir.current===null&&(i=!0);var ne=xt;if(xt=0,or=null,Aa(s,M,K,ne),c&&Na){w=0;break e}break;default:ne=xt,xt=0,or=null,Aa(s,M,K,ne)}}d2(),w=Ft;break}catch(ue){Ab(s,ue)}while(!0);return i&&s.shellSuspendCounter++,ds=vi=null,mt=h,N.H=x,N.A=y,et===null&&(Ct=null,rt=0,ic()),w}function d2(){for(;et!==null;)Lb(et)}function h2(s,i){var c=mt;mt|=2;var h=Mb(),x=Rb();Ct!==s||rt!==i?(Bc=null,Ic=Ie()+500,Ta(s,i)):Na=He(s,i);e:do try{if(xt!==0&&et!==null){i=et;var y=or;t:switch(xt){case 1:xt=0,or=null,Aa(s,i,y,1);break;case 2:case 9:if(Wx(y)){xt=0,or=null,Ob(i);break}i=function(){xt!==2&&xt!==9||Ct!==s||(xt=7),Wr(s)},y.then(i,i);break e;case 3:xt=7;break e;case 4:xt=5;break e;case 7:Wx(y)?(xt=0,or=null,Ob(i)):(xt=0,or=null,Aa(s,i,y,7));break;case 5:var w=null;switch(et.tag){case 26:w=et.memoizedState;case 5:case 27:var M=et;if(w?vv(w):M.stateNode.complete){xt=0,or=null;var K=M.sibling;if(K!==null)et=K;else{var ne=M.return;ne!==null?(et=ne,Hc(ne)):et=null}break t}}xt=0,or=null,Aa(s,i,y,5);break;case 6:xt=0,or=null,Aa(s,i,y,6);break;case 8:tf(),Ft=6;break e;default:throw Error(r(462))}}f2();break}catch(ue){Ab(s,ue)}while(!0);return ds=vi=null,N.H=h,N.A=x,mt=c,et!==null?0:(Ct=null,rt=0,ic(),Ft)}function f2(){for(;et!==null&&!ce();)Lb(et)}function Lb(s){var i=sb(s.alternate,s,_s);s.memoizedProps=s.pendingProps,i===null?Hc(s):et=i}function Ob(s){var i=s,c=i.alternate;switch(i.tag){case 15:case 0:i=Qy(c,i,i.pendingProps,i.type,void 0,rt);break;case 11:i=Qy(c,i,i.pendingProps,i.type.render,i.ref,rt);break;case 5:xh(i);default:ab(c,i),i=et=Rx(i,_s),i=sb(c,i,_s)}s.memoizedProps=s.pendingProps,i===null?Hc(s):et=i}function Aa(s,i,c,h){ds=vi=null,xh(i),ba=null,vo=0;var x=i.return;try{if(t2(s,x,i,c,rt)){Ft=1,jc(s,_r(c,s.current)),et=null;return}}catch(y){if(x!==null)throw et=x,y;Ft=1,jc(s,_r(c,s.current)),et=null;return}i.flags&32768?(at||h===1?s=!0:Na||(rt&536870912)!==0?s=!1:(Ws=s=!0,(h===2||h===9||h===3||h===6)&&(h=ir.current,h!==null&&h.tag===13&&(h.flags|=16384))),Ib(i,s)):Hc(i)}function Hc(s){var i=s;do{if((i.flags&32768)!==0){Ib(i,Ws);return}s=i.return;var c=s2(i.alternate,i,_s);if(c!==null){et=c;return}if(i=i.sibling,i!==null){et=i;return}et=i=s}while(i!==null);Ft===0&&(Ft=5)}function Ib(s,i){do{var c=i2(s.alternate,s);if(c!==null){c.flags&=32767,et=c;return}if(c=s.return,c!==null&&(c.flags|=32768,c.subtreeFlags=0,c.deletions=null),!i&&(s=s.sibling,s!==null)){et=s;return}et=s=c}while(s!==null);Ft=6,et=null}function Bb(s,i,c,h,x,y,w,M,K){s.cancelPendingCommit=null;do Fc();while(cn!==0);if((mt&6)!==0)throw Error(r(327));if(i!==null){if(i===s.current)throw Error(r(177));if(y=i.lanes|i.childLanes,y|=Wd,yd(s,c,y,w,M,K),s===Ct&&(et=Ct=null,rt=0),Ea=i,Ks=s,Ss=c,Qh=y,Jh=x,Nb=h,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,x2(Me,function(){return $b(),null})):(s.callbackNode=null,s.callbackPriority=0),h=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||h){h=N.T,N.T=null,x=F.p,F.p=2,w=mt,mt|=4;try{a2(s,i,c)}finally{mt=w,F.p=x,N.T=h}}cn=1,zb(),Pb(),Hb()}}function zb(){if(cn===1){cn=0;var s=Ks,i=Ea,c=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||c){c=N.T,N.T=null;var h=F.p;F.p=2;var x=mt;mt|=4;try{yb(i,s);var y=mf,w=kx(s.containerInfo),M=y.focusedElem,K=y.selectionRange;if(w!==M&&M&&M.ownerDocument&&wx(M.ownerDocument.documentElement,M)){if(K!==null&&Pd(M)){var ne=K.start,ue=K.end;if(ue===void 0&&(ue=ne),"selectionStart"in M)M.selectionStart=ne,M.selectionEnd=Math.min(ue,M.value.length);else{var fe=M.ownerDocument||document,re=fe&&fe.defaultView||window;if(re.getSelection){var oe=re.getSelection(),Ee=M.textContent.length,ze=Math.min(K.start,Ee),St=K.end===void 0?ze:Math.min(K.end,Ee);!oe.extend&&ze>St&&(w=St,St=ze,ze=w);var Q=Sx(M,ze),X=Sx(M,St);if(Q&&X&&(oe.rangeCount!==1||oe.anchorNode!==Q.node||oe.anchorOffset!==Q.offset||oe.focusNode!==X.node||oe.focusOffset!==X.offset)){var te=fe.createRange();te.setStart(Q.node,Q.offset),oe.removeAllRanges(),ze>St?(oe.addRange(te),oe.extend(X.node,X.offset)):(te.setEnd(X.node,X.offset),oe.addRange(te))}}}}for(fe=[],oe=M;oe=oe.parentNode;)oe.nodeType===1&&fe.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;M<fe.length;M++){var he=fe[M];he.element.scrollLeft=he.left,he.element.scrollTop=he.top}}Jc=!!pf,mf=pf=null}finally{mt=x,F.p=h,N.T=c}}s.current=i,cn=2}}function Pb(){if(cn===2){cn=0;var s=Ks,i=Ea,c=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||c){c=N.T,N.T=null;var h=F.p;F.p=2;var x=mt;mt|=4;try{fb(s,i.alternate,i)}finally{mt=x,F.p=h,N.T=c}}cn=3}}function Hb(){if(cn===4||cn===3){cn=0,Ae();var s=Ks,i=Ea,c=Ss,h=Nb;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?cn=5:(cn=0,Ea=Ks=null,Fb(s,s.pendingLanes));var x=s.pendingLanes;if(x===0&&(Vs=null),vd(c),i=i.stateNode,Bt&&typeof Bt.onCommitFiberRoot=="function")try{Bt.onCommitFiberRoot(on,i,void 0,(i.current.flags&128)===128)}catch{}if(h!==null){i=N.T,x=F.p,F.p=2,N.T=null;try{for(var y=s.onRecoverableError,w=0;w<h.length;w++){var M=h[w];y(M.value,{componentStack:M.stack})}}finally{N.T=i,F.p=x}}(Ss&3)!==0&&Fc(),Wr(s),x=s.pendingLanes,(c&261930)!==0&&(x&42)!==0?s===ef?Bo++:(Bo=0,ef=s):Bo=0,zo(0)}}function Fb(s,i){(s.pooledCacheLanes&=i)===0&&(i=s.pooledCache,i!=null&&(s.pooledCache=null,yo(i)))}function Fc(){return zb(),Pb(),Hb(),$b()}function $b(){if(cn!==5)return!1;var s=Ks,i=Qh;Qh=0;var c=vd(Ss),h=N.T,x=F.p;try{F.p=32>c?32:c,N.T=null,c=Jh,Jh=null;var y=Ks,w=Ss;if(cn=0,Ea=Ks=null,Ss=0,(mt&6)!==0)throw Error(r(331));var M=mt;if(mt|=4,wb(y.current),vb(y,y.current,w,c),mt=M,zo(0,!1),Bt&&typeof Bt.onPostCommitFiberRoot=="function")try{Bt.onPostCommitFiberRoot(on,y)}catch{}return!0}finally{F.p=x,N.T=h,Fb(s,i)}}function Ub(s,i,c){i=_r(c,i),i=Mh(s.stateNode,i,2),s=Hs(s,i,2),s!==null&&(Zi(s,2),Wr(s))}function yt(s,i,c){if(s.tag===3)Ub(s,s,c);else for(;i!==null;){if(i.tag===3){Ub(i,s,c);break}else if(i.tag===1){var h=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Vs===null||!Vs.has(h))){s=_r(c,s),c=Wy(2),h=Hs(i,c,2),h!==null&&(qy(c,h,i,s),Zi(h,2),Wr(h));break}}i=i.return}}function rf(s,i,c){var h=s.pingCache;if(h===null){h=s.pingCache=new c2;var x=new Set;h.set(i,x)}else x=h.get(i),x===void 0&&(x=new Set,h.set(i,x));x.has(c)||(Yh=!0,x.add(c),s=p2.bind(null,s,i,c),i.then(s,s))}function p2(s,i,c){var h=s.pingCache;h!==null&&h.delete(i),s.pingedLanes|=s.suspendedLanes&c,s.warmLanes&=~c,Ct===s&&(rt&c)===c&&(Ft===4||Ft===3&&(rt&62914560)===rt&&300>Ie()-Oc?(mt&2)===0&&Ta(s,0):Xh|=c,ja===rt&&(ja=0)),Wr(s)}function Wb(s,i){i===0&&(i=Yt()),s=xi(s,i),s!==null&&(Zi(s,i),Wr(s))}function m2(s){var i=s.memoizedState,c=0;i!==null&&(c=i.retryLane),Wb(s,c)}function g2(s,i){var c=0;switch(s.tag){case 31:case 13:var h=s.stateNode,x=s.memoizedState;x!==null&&(c=x.retryLane);break;case 19:h=s.stateNode;break;case 22:h=s.stateNode._retryCache;break;default:throw Error(r(314))}h!==null&&h.delete(i),Wb(s,c)}function x2(s,i){return me(s,i)}var $c=null,Da=null,sf=!1,Uc=!1,af=!1,Ys=0;function Wr(s){s!==Da&&s.next===null&&(Da===null?$c=Da=s:Da=Da.next=s),Uc=!0,sf||(sf=!0,b2())}function zo(s,i){if(!af&&Uc){af=!0;do for(var c=!1,h=$c;h!==null;){if(s!==0){var x=h.pendingLanes;if(x===0)var y=0;else{var w=h.suspendedLanes,M=h.pingedLanes;y=(1<<31-we(42|s)+1)-1,y&=x&~(w&~M),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(c=!0,Gb(h,y))}else y=rt,y=it(h,h===Ct?y:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(y&3)===0||He(h,y)||(c=!0,Gb(h,y));h=h.next}while(c);af=!1}}function y2(){qb()}function qb(){Uc=sf=!1;var s=0;Ys!==0&&T2()&&(s=Ys);for(var i=Ie(),c=null,h=$c;h!==null;){var x=h.next,y=Vb(h,i);y===0?(h.next=null,c===null?$c=x:c.next=x,x===null&&(Da=c)):(c=h,(s!==0||(y&3)!==0)&&(Uc=!0)),h=x}cn!==0&&cn!==5||zo(s),Ys!==0&&(Ys=0)}function Vb(s,i){for(var c=s.suspendedLanes,h=s.pingedLanes,x=s.expirationTimes,y=s.pendingLanes&-62914561;0<y;){var w=31-we(y),M=1<<w,K=x[w];K===-1?((M&c)===0||(M&h)!==0)&&(x[w]=Nn(M,i)):K<=i&&(s.expiredLanes|=M),y&=~M}if(i=Ct,c=rt,c=it(s,s===i?c:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),h=s.callbackNode,c===0||s===i&&(xt===2||xt===9)||s.cancelPendingCommit!==null)return h!==null&&h!==null&&je(h),s.callbackNode=null,s.callbackPriority=0;if((c&3)===0||He(s,c)){if(i=c&-c,i===s.callbackPriority)return i;switch(h!==null&&je(h),vd(c)){case 2:case 8:c=xe;break;case 32:c=Me;break;case 268435456:c=ot;break;default:c=Me}return h=Kb.bind(null,s),c=me(c,h),s.callbackPriority=i,s.callbackNode=c,i}return h!==null&&h!==null&&je(h),s.callbackPriority=2,s.callbackNode=null,2}function Kb(s,i){if(cn!==0&&cn!==5)return s.callbackNode=null,s.callbackPriority=0,null;var c=s.callbackNode;if(Fc()&&s.callbackNode!==c)return null;var h=rt;return h=it(s,s===Ct?h:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),h===0?null:(Eb(s,h,i),Vb(s,Ie()),s.callbackNode!=null&&s.callbackNode===c?Kb.bind(null,s):null)}function Gb(s,i){if(Fc())return null;Eb(s,i,!0)}function b2(){D2(function(){(mt&6)!==0?me(le,y2):qb()})}function of(){if(Ys===0){var s=ga;s===0&&(s=de,de<<=1,(de&261888)===0&&(de=256)),Ys=s}return Ys}function Yb(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:Zl(""+s)}function Xb(s,i){var c=i.ownerDocument.createElement("input");return c.name=i.name,c.value=i.value,s.id&&c.setAttribute("form",s.id),i.parentNode.insertBefore(c,i),s=new FormData(s),c.parentNode.removeChild(c),s}function v2(s,i,c,h,x){if(i==="submit"&&c&&c.stateNode===x){var y=Yb((x[Kn]||null).action),w=h.submitter;w&&(i=(i=w[Kn]||null)?Yb(i.formAction):w.getAttribute("formAction"),i!==null&&(y=i,w=null));var M=new tc("action","action",null,h,x);s.push({event:M,listeners:[{instance:null,listener:function(){if(h.defaultPrevented){if(Ys!==0){var K=w?Xb(x,w):new FormData(x);Nh(c,{pending:!0,data:K,method:x.method,action:y},null,K)}}else typeof y=="function"&&(M.preventDefault(),K=w?Xb(x,w):new FormData(x),Nh(c,{pending:!0,data:K,method:x.method,action:y},y,K))},currentTarget:x}]})}}for(var lf=0;lf<Ud.length;lf++){var cf=Ud[lf],_2=cf.toLowerCase(),S2=cf[0].toUpperCase()+cf.slice(1);Rr(_2,"on"+S2)}Rr(jx,"onAnimationEnd"),Rr(Ex,"onAnimationIteration"),Rr(Tx,"onAnimationStart"),Rr("dblclick","onDoubleClick"),Rr("focusin","onFocus"),Rr("focusout","onBlur"),Rr(zC,"onTransitionRun"),Rr(PC,"onTransitionStart"),Rr(HC,"onTransitionCancel"),Rr(Ax,"onTransitionEnd"),na("onMouseEnter",["mouseout","mouseover"]),na("onMouseLeave",["mouseout","mouseover"]),na("onPointerEnter",["pointerout","pointerover"]),na("onPointerLeave",["pointerout","pointerover"]),fi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),fi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),fi("onBeforeInput",["compositionend","keypress","textInput","paste"]),fi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),fi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),fi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Po="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(" "),w2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Po));function Zb(s,i){i=(i&4)!==0;for(var c=0;c<s.length;c++){var h=s[c],x=h.event;h=h.listeners;e:{var y=void 0;if(i)for(var w=h.length-1;0<=w;w--){var M=h[w],K=M.instance,ne=M.currentTarget;if(M=M.listener,K!==y&&x.isPropagationStopped())break e;y=M,x.currentTarget=ne;try{y(x)}catch(ue){sc(ue)}x.currentTarget=null,y=K}else for(w=0;w<h.length;w++){if(M=h[w],K=M.instance,ne=M.currentTarget,M=M.listener,K!==y&&x.isPropagationStopped())break e;y=M,x.currentTarget=ne;try{y(x)}catch(ue){sc(ue)}x.currentTarget=null,y=K}}}}function tt(s,i){var c=i[_d];c===void 0&&(c=i[_d]=new Set);var h=s+"__bubble";c.has(h)||(Qb(i,s,2,!1),c.add(h))}function uf(s,i,c){var h=0;i&&(h|=4),Qb(c,s,h,i)}var Wc="_reactListening"+Math.random().toString(36).slice(2);function df(s){if(!s[Wc]){s[Wc]=!0,qg.forEach(function(c){c!=="selectionchange"&&(w2.has(c)||uf(c,!1,s),uf(c,!0,s))});var i=s.nodeType===9?s:s.ownerDocument;i===null||i[Wc]||(i[Wc]=!0,uf("selectionchange",!1,i))}}function Qb(s,i,c,h){switch(jv(i)){case 2:var x=Z2;break;case 8:x=Q2;break;default:x=Nf}c=x.bind(null,i,c,s),x=void 0,!Ad||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(x=!0),h?x!==void 0?s.addEventListener(i,c,{capture:!0,passive:x}):s.addEventListener(i,c,!0):x!==void 0?s.addEventListener(i,c,{passive:x}):s.addEventListener(i,c,!1)}function hf(s,i,c,h,x){var y=h;if((i&1)===0&&(i&2)===0&&h!==null)e:for(;;){if(h===null)return;var w=h.tag;if(w===3||w===4){var M=h.stateNode.containerInfo;if(M===x)break;if(w===4)for(w=h.return;w!==null;){var K=w.tag;if((K===3||K===4)&&w.stateNode.containerInfo===x)return;w=w.return}for(;M!==null;){if(w=Ji(M),w===null)return;if(K=w.tag,K===5||K===6||K===26||K===27){h=y=w;continue e}M=M.parentNode}}h=h.return}rx(function(){var ne=y,ue=Ed(c),fe=[];e:{var re=Dx.get(s);if(re!==void 0){var oe=tc,Ee=s;switch(s){case"keypress":if(Jl(c)===0)break e;case"keydown":case"keyup":oe=gC;break;case"focusin":Ee="focus",oe=Ld;break;case"focusout":Ee="blur",oe=Ld;break;case"beforeblur":case"afterblur":oe=Ld;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":oe=ax;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":oe=sC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":oe=bC;break;case jx:case Ex:case Tx:oe=oC;break;case Ax:oe=_C;break;case"scroll":case"scrollend":oe=nC;break;case"wheel":oe=wC;break;case"copy":case"cut":case"paste":oe=cC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":oe=lx;break;case"toggle":case"beforetoggle":oe=CC}var ze=(i&4)!==0,St=!ze&&(s==="scroll"||s==="scrollend"),Q=ze?re!==null?re+"Capture":null:re;ze=[];for(var X=ne,te;X!==null;){var he=X;if(te=he.stateNode,he=he.tag,he!==5&&he!==26&&he!==27||te===null||Q===null||(he=ao(X,Q),he!=null&&ze.push(Ho(X,he,te))),St)break;X=X.return}0<ze.length&&(re=new oe(re,Ee,null,c,ue),fe.push({event:re,listeners:ze}))}}if((i&7)===0){e:{if(re=s==="mouseover"||s==="pointerover",oe=s==="mouseout"||s==="pointerout",re&&c!==jd&&(Ee=c.relatedTarget||c.fromElement)&&(Ji(Ee)||Ee[Qi]))break e;if((oe||re)&&(re=ue.window===ue?ue:(re=ue.ownerDocument)?re.defaultView||re.parentWindow:window,oe?(Ee=c.relatedTarget||c.toElement,oe=ne,Ee=Ee?Ji(Ee):null,Ee!==null&&(St=o(Ee),ze=Ee.tag,Ee!==St||ze!==5&&ze!==27&&ze!==6)&&(Ee=null)):(oe=null,Ee=ne),oe!==Ee)){if(ze=ax,he="onMouseLeave",Q="onMouseEnter",X="mouse",(s==="pointerout"||s==="pointerover")&&(ze=lx,he="onPointerLeave",Q="onPointerEnter",X="pointer"),St=oe==null?re:io(oe),te=Ee==null?re:io(Ee),re=new ze(he,X+"leave",oe,c,ue),re.target=St,re.relatedTarget=te,he=null,Ji(ue)===ne&&(ze=new ze(Q,X+"enter",Ee,c,ue),ze.target=te,ze.relatedTarget=St,he=ze),St=he,oe&&Ee)t:{for(ze=k2,Q=oe,X=Ee,te=0,he=Q;he;he=ze(he))te++;he=0;for(var Le=X;Le;Le=ze(Le))he++;for(;0<te-he;)Q=ze(Q),te--;for(;0<he-te;)X=ze(X),he--;for(;te--;){if(Q===X||X!==null&&Q===X.alternate){ze=Q;break t}Q=ze(Q),X=ze(X)}ze=null}else ze=null;oe!==null&&Jb(fe,re,oe,ze,!1),Ee!==null&&St!==null&&Jb(fe,St,Ee,ze,!0)}}e:{if(re=ne?io(ne):window,oe=re.nodeName&&re.nodeName.toLowerCase(),oe==="select"||oe==="input"&&re.type==="file")var ht=gx;else if(px(re))if(xx)ht=OC;else{ht=RC;var De=MC}else oe=re.nodeName,!oe||oe.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?ne&&Nd(ne.elementType)&&(ht=gx):ht=LC;if(ht&&(ht=ht(s,ne))){mx(fe,ht,c,ue);break e}De&&De(s,re,ne),s==="focusout"&&ne&&re.type==="number"&&ne.memoizedProps.value!=null&&Cd(re,"number",re.value)}switch(De=ne?io(ne):window,s){case"focusin":(px(De)||De.contentEditable==="true")&&(la=De,Hd=ne,mo=null);break;case"focusout":mo=Hd=la=null;break;case"mousedown":Fd=!0;break;case"contextmenu":case"mouseup":case"dragend":Fd=!1,Cx(fe,c,ue);break;case"selectionchange":if(BC)break;case"keydown":case"keyup":Cx(fe,c,ue)}var Ke;if(Id)e:{switch(s){case"compositionstart":var st="onCompositionStart";break e;case"compositionend":st="onCompositionEnd";break e;case"compositionupdate":st="onCompositionUpdate";break e}st=void 0}else oa?hx(s,c)&&(st="onCompositionEnd"):s==="keydown"&&c.keyCode===229&&(st="onCompositionStart");st&&(cx&&c.locale!=="ko"&&(oa||st!=="onCompositionStart"?st==="onCompositionEnd"&&oa&&(Ke=sx()):(Rs=ue,Dd="value"in Rs?Rs.value:Rs.textContent,oa=!0)),De=qc(ne,st),0<De.length&&(st=new ox(st,s,null,c,ue),fe.push({event:st,listeners:De}),Ke?st.data=Ke:(Ke=fx(c),Ke!==null&&(st.data=Ke)))),(Ke=jC?EC(s,c):TC(s,c))&&(st=qc(ne,"onBeforeInput"),0<st.length&&(De=new ox("onBeforeInput","beforeinput",null,c,ue),fe.push({event:De,listeners:st}),De.data=Ke)),v2(fe,s,ne,c,ue)}Zb(fe,i)})}function Ho(s,i,c){return{instance:s,listener:i,currentTarget:c}}function qc(s,i){for(var c=i+"Capture",h=[];s!==null;){var x=s,y=x.stateNode;if(x=x.tag,x!==5&&x!==26&&x!==27||y===null||(x=ao(s,c),x!=null&&h.unshift(Ho(s,x,y)),x=ao(s,i),x!=null&&h.push(Ho(s,x,y))),s.tag===3)return h;s=s.return}return[]}function k2(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function Jb(s,i,c,h,x){for(var y=i._reactName,w=[];c!==null&&c!==h;){var M=c,K=M.alternate,ne=M.stateNode;if(M=M.tag,K!==null&&K===h)break;M!==5&&M!==26&&M!==27||ne===null||(K=ne,x?(ne=ao(c,y),ne!=null&&w.unshift(Ho(c,ne,K))):x||(ne=ao(c,y),ne!=null&&w.push(Ho(c,ne,K)))),c=c.return}w.length!==0&&s.push({event:i,listeners:w})}var C2=/\r\n?/g,N2=/\u0000|\uFFFD/g;function ev(s){return(typeof s=="string"?s:""+s).replace(C2,`
|
|
49
|
+
`).replace(N2,"")}function tv(s,i){return i=ev(i),ev(s)===i}function _t(s,i,c,h,x,y){switch(c){case"children":typeof h=="string"?i==="body"||i==="textarea"&&h===""||sa(s,h):(typeof h=="number"||typeof h=="bigint")&&i!=="body"&&sa(s,""+h);break;case"className":Yl(s,"class",h);break;case"tabIndex":Yl(s,"tabindex",h);break;case"dir":case"role":case"viewBox":case"width":case"height":Yl(s,c,h);break;case"style":tx(s,h,y);break;case"data":if(i!=="object"){Yl(s,"data",h);break}case"src":case"href":if(h===""&&(i!=="a"||c!=="href")){s.removeAttribute(c);break}if(h==null||typeof h=="function"||typeof h=="symbol"||typeof h=="boolean"){s.removeAttribute(c);break}h=Zl(""+h),s.setAttribute(c,h);break;case"action":case"formAction":if(typeof h=="function"){s.setAttribute(c,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(c==="formAction"?(i!=="input"&&_t(s,i,"name",x.name,x,null),_t(s,i,"formEncType",x.formEncType,x,null),_t(s,i,"formMethod",x.formMethod,x,null),_t(s,i,"formTarget",x.formTarget,x,null)):(_t(s,i,"encType",x.encType,x,null),_t(s,i,"method",x.method,x,null),_t(s,i,"target",x.target,x,null)));if(h==null||typeof h=="symbol"||typeof h=="boolean"){s.removeAttribute(c);break}h=Zl(""+h),s.setAttribute(c,h);break;case"onClick":h!=null&&(s.onclick=os);break;case"onScroll":h!=null&&tt("scroll",s);break;case"onScrollEnd":h!=null&&tt("scrollend",s);break;case"dangerouslySetInnerHTML":if(h!=null){if(typeof h!="object"||!("__html"in h))throw Error(r(61));if(c=h.__html,c!=null){if(x.children!=null)throw Error(r(60));s.innerHTML=c}}break;case"multiple":s.multiple=h&&typeof h!="function"&&typeof h!="symbol";break;case"muted":s.muted=h&&typeof h!="function"&&typeof h!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(h==null||typeof h=="function"||typeof h=="boolean"||typeof h=="symbol"){s.removeAttribute("xlink:href");break}c=Zl(""+h),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",c);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":h!=null&&typeof h!="function"&&typeof h!="symbol"?s.setAttribute(c,""+h):s.removeAttribute(c);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":h&&typeof h!="function"&&typeof h!="symbol"?s.setAttribute(c,""):s.removeAttribute(c);break;case"capture":case"download":h===!0?s.setAttribute(c,""):h!==!1&&h!=null&&typeof h!="function"&&typeof h!="symbol"?s.setAttribute(c,h):s.removeAttribute(c);break;case"cols":case"rows":case"size":case"span":h!=null&&typeof h!="function"&&typeof h!="symbol"&&!isNaN(h)&&1<=h?s.setAttribute(c,h):s.removeAttribute(c);break;case"rowSpan":case"start":h==null||typeof h=="function"||typeof h=="symbol"||isNaN(h)?s.removeAttribute(c):s.setAttribute(c,h);break;case"popover":tt("beforetoggle",s),tt("toggle",s),Gl(s,"popover",h);break;case"xlinkActuate":as(s,"http://www.w3.org/1999/xlink","xlink:actuate",h);break;case"xlinkArcrole":as(s,"http://www.w3.org/1999/xlink","xlink:arcrole",h);break;case"xlinkRole":as(s,"http://www.w3.org/1999/xlink","xlink:role",h);break;case"xlinkShow":as(s,"http://www.w3.org/1999/xlink","xlink:show",h);break;case"xlinkTitle":as(s,"http://www.w3.org/1999/xlink","xlink:title",h);break;case"xlinkType":as(s,"http://www.w3.org/1999/xlink","xlink:type",h);break;case"xmlBase":as(s,"http://www.w3.org/XML/1998/namespace","xml:base",h);break;case"xmlLang":as(s,"http://www.w3.org/XML/1998/namespace","xml:lang",h);break;case"xmlSpace":as(s,"http://www.w3.org/XML/1998/namespace","xml:space",h);break;case"is":Gl(s,"is",h);break;case"innerText":case"textContent":break;default:(!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(c=eC.get(c)||c,Gl(s,c,h))}}function ff(s,i,c,h,x,y){switch(c){case"style":tx(s,h,y);break;case"dangerouslySetInnerHTML":if(h!=null){if(typeof h!="object"||!("__html"in h))throw Error(r(61));if(c=h.__html,c!=null){if(x.children!=null)throw Error(r(60));s.innerHTML=c}}break;case"children":typeof h=="string"?sa(s,h):(typeof h=="number"||typeof h=="bigint")&&sa(s,""+h);break;case"onScroll":h!=null&&tt("scroll",s);break;case"onScrollEnd":h!=null&&tt("scrollend",s);break;case"onClick":h!=null&&(s.onclick=os);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Vg.hasOwnProperty(c))e:{if(c[0]==="o"&&c[1]==="n"&&(x=c.endsWith("Capture"),i=c.slice(2,x?c.length-7:void 0),y=s[Kn]||null,y=y!=null?y[c]:null,typeof y=="function"&&s.removeEventListener(i,y,x),typeof h=="function")){typeof y!="function"&&y!==null&&(c in s?s[c]=null:s.hasAttribute(c)&&s.removeAttribute(c)),s.addEventListener(i,h,x);break e}c in s?s[c]=h:h===!0?s.setAttribute(c,""):Gl(s,c,h)}}}function Dn(s,i,c){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":tt("error",s),tt("load",s);var h=!1,x=!1,y;for(y in c)if(c.hasOwnProperty(y)){var w=c[y];if(w!=null)switch(y){case"src":h=!0;break;case"srcSet":x=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,i));default:_t(s,i,y,w,c,null)}}x&&_t(s,i,"srcSet",c.srcSet,c,null),h&&_t(s,i,"src",c.src,c,null);return;case"input":tt("invalid",s);var M=y=w=x=null,K=null,ne=null;for(h in c)if(c.hasOwnProperty(h)){var ue=c[h];if(ue!=null)switch(h){case"name":x=ue;break;case"type":w=ue;break;case"checked":K=ue;break;case"defaultChecked":ne=ue;break;case"value":y=ue;break;case"defaultValue":M=ue;break;case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(r(137,i));break;default:_t(s,i,h,ue,c,null)}}Zg(s,y,M,K,ne,w,x,!1);return;case"select":tt("invalid",s),h=w=y=null;for(x in c)if(c.hasOwnProperty(x)&&(M=c[x],M!=null))switch(x){case"value":y=M;break;case"defaultValue":w=M;break;case"multiple":h=M;default:_t(s,i,x,M,c,null)}i=y,c=w,s.multiple=!!h,i!=null?ra(s,!!h,i,!1):c!=null&&ra(s,!!h,c,!0);return;case"textarea":tt("invalid",s),y=x=h=null;for(w in c)if(c.hasOwnProperty(w)&&(M=c[w],M!=null))switch(w){case"value":h=M;break;case"defaultValue":x=M;break;case"children":y=M;break;case"dangerouslySetInnerHTML":if(M!=null)throw Error(r(91));break;default:_t(s,i,w,M,c,null)}Jg(s,h,x,y);return;case"option":for(K in c)if(c.hasOwnProperty(K)&&(h=c[K],h!=null))switch(K){case"selected":s.selected=h&&typeof h!="function"&&typeof h!="symbol";break;default:_t(s,i,K,h,c,null)}return;case"dialog":tt("beforetoggle",s),tt("toggle",s),tt("cancel",s),tt("close",s);break;case"iframe":case"object":tt("load",s);break;case"video":case"audio":for(h=0;h<Po.length;h++)tt(Po[h],s);break;case"image":tt("error",s),tt("load",s);break;case"details":tt("toggle",s);break;case"embed":case"source":case"link":tt("error",s),tt("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ne in c)if(c.hasOwnProperty(ne)&&(h=c[ne],h!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,i));default:_t(s,i,ne,h,c,null)}return;default:if(Nd(i)){for(ue in c)c.hasOwnProperty(ue)&&(h=c[ue],h!==void 0&&ff(s,i,ue,h,c,void 0));return}}for(M in c)c.hasOwnProperty(M)&&(h=c[M],h!=null&&_t(s,i,M,h,c,null))}function j2(s,i,c,h){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var x=null,y=null,w=null,M=null,K=null,ne=null,ue=null;for(oe in c){var fe=c[oe];if(c.hasOwnProperty(oe)&&fe!=null)switch(oe){case"checked":break;case"value":break;case"defaultValue":K=fe;default:h.hasOwnProperty(oe)||_t(s,i,oe,null,h,fe)}}for(var re in h){var oe=h[re];if(fe=c[re],h.hasOwnProperty(re)&&(oe!=null||fe!=null))switch(re){case"type":y=oe;break;case"name":x=oe;break;case"checked":ne=oe;break;case"defaultChecked":ue=oe;break;case"value":w=oe;break;case"defaultValue":M=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(137,i));break;default:oe!==fe&&_t(s,i,re,oe,h,fe)}}kd(s,w,M,K,ne,ue,y,x);return;case"select":oe=w=M=re=null;for(y in c)if(K=c[y],c.hasOwnProperty(y)&&K!=null)switch(y){case"value":break;case"multiple":oe=K;default:h.hasOwnProperty(y)||_t(s,i,y,null,h,K)}for(x in h)if(y=h[x],K=c[x],h.hasOwnProperty(x)&&(y!=null||K!=null))switch(x){case"value":re=y;break;case"defaultValue":M=y;break;case"multiple":w=y;default:y!==K&&_t(s,i,x,y,h,K)}i=M,c=w,h=oe,re!=null?ra(s,!!c,re,!1):!!h!=!!c&&(i!=null?ra(s,!!c,i,!0):ra(s,!!c,c?[]:"",!1));return;case"textarea":oe=re=null;for(M in c)if(x=c[M],c.hasOwnProperty(M)&&x!=null&&!h.hasOwnProperty(M))switch(M){case"value":break;case"children":break;default:_t(s,i,M,null,h,x)}for(w in h)if(x=h[w],y=c[w],h.hasOwnProperty(w)&&(x!=null||y!=null))switch(w){case"value":re=x;break;case"defaultValue":oe=x;break;case"children":break;case"dangerouslySetInnerHTML":if(x!=null)throw Error(r(91));break;default:x!==y&&_t(s,i,w,x,h,y)}Qg(s,re,oe);return;case"option":for(var Ee in c)if(re=c[Ee],c.hasOwnProperty(Ee)&&re!=null&&!h.hasOwnProperty(Ee))switch(Ee){case"selected":s.selected=!1;break;default:_t(s,i,Ee,null,h,re)}for(K in h)if(re=h[K],oe=c[K],h.hasOwnProperty(K)&&re!==oe&&(re!=null||oe!=null))switch(K){case"selected":s.selected=re&&typeof re!="function"&&typeof re!="symbol";break;default:_t(s,i,K,re,h,oe)}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 ze in c)re=c[ze],c.hasOwnProperty(ze)&&re!=null&&!h.hasOwnProperty(ze)&&_t(s,i,ze,null,h,re);for(ne in h)if(re=h[ne],oe=c[ne],h.hasOwnProperty(ne)&&re!==oe&&(re!=null||oe!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,i));break;default:_t(s,i,ne,re,h,oe)}return;default:if(Nd(i)){for(var St in c)re=c[St],c.hasOwnProperty(St)&&re!==void 0&&!h.hasOwnProperty(St)&&ff(s,i,St,void 0,h,re);for(ue in h)re=h[ue],oe=c[ue],!h.hasOwnProperty(ue)||re===oe||re===void 0&&oe===void 0||ff(s,i,ue,re,h,oe);return}}for(var Q in c)re=c[Q],c.hasOwnProperty(Q)&&re!=null&&!h.hasOwnProperty(Q)&&_t(s,i,Q,null,h,re);for(fe in h)re=h[fe],oe=c[fe],!h.hasOwnProperty(fe)||re===oe||re==null&&oe==null||_t(s,i,fe,re,h,oe)}function nv(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function E2(){if(typeof performance.getEntriesByType=="function"){for(var s=0,i=0,c=performance.getEntriesByType("resource"),h=0;h<c.length;h++){var x=c[h],y=x.transferSize,w=x.initiatorType,M=x.duration;if(y&&M&&nv(w)){for(w=0,M=x.responseEnd,h+=1;h<c.length;h++){var K=c[h],ne=K.startTime;if(ne>M)break;var ue=K.transferSize,fe=K.initiatorType;ue&&nv(fe)&&(K=K.responseEnd,w+=ue*(K<M?1:(M-ne)/(K-ne)))}if(--h,i+=8*(y+w)/(x.duration/1e3),s++,10<s)break}}if(0<s)return i/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var pf=null,mf=null;function Vc(s){return s.nodeType===9?s:s.ownerDocument}function rv(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function sv(s,i){if(s===0)switch(i){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&i==="foreignObject"?0:s}function gf(s,i){return s==="textarea"||s==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.children=="bigint"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var xf=null;function T2(){var s=window.event;return s&&s.type==="popstate"?s===xf?!1:(xf=s,!0):(xf=null,!1)}var iv=typeof setTimeout=="function"?setTimeout:void 0,A2=typeof clearTimeout=="function"?clearTimeout:void 0,av=typeof Promise=="function"?Promise:void 0,D2=typeof queueMicrotask=="function"?queueMicrotask:typeof av<"u"?function(s){return av.resolve(null).then(s).catch(M2)}:iv;function M2(s){setTimeout(function(){throw s})}function Xs(s){return s==="head"}function ov(s,i){var c=i,h=0;do{var x=c.nextSibling;if(s.removeChild(c),x&&x.nodeType===8)if(c=x.data,c==="/$"||c==="/&"){if(h===0){s.removeChild(x),Oa(i);return}h--}else if(c==="$"||c==="$?"||c==="$~"||c==="$!"||c==="&")h++;else if(c==="html")Fo(s.ownerDocument.documentElement);else if(c==="head"){c=s.ownerDocument.head,Fo(c);for(var y=c.firstChild;y;){var w=y.nextSibling,M=y.nodeName;y[so]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&y.rel.toLowerCase()==="stylesheet"||c.removeChild(y),y=w}}else c==="body"&&Fo(s.ownerDocument.body);c=x}while(c);Oa(i)}function lv(s,i){var c=s;s=0;do{var h=c.nextSibling;if(c.nodeType===1?i?(c._stashedDisplay=c.style.display,c.style.display="none"):(c.style.display=c._stashedDisplay||"",c.getAttribute("style")===""&&c.removeAttribute("style")):c.nodeType===3&&(i?(c._stashedText=c.nodeValue,c.nodeValue=""):c.nodeValue=c._stashedText||""),h&&h.nodeType===8)if(c=h.data,c==="/$"){if(s===0)break;s--}else c!=="$"&&c!=="$?"&&c!=="$~"&&c!=="$!"||s++;c=h}while(c)}function yf(s){var i=s.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var c=i;switch(i=i.nextSibling,c.nodeName){case"HTML":case"HEAD":case"BODY":yf(c),Sd(c);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(c.rel.toLowerCase()==="stylesheet")continue}s.removeChild(c)}}function R2(s,i,c,h){for(;s.nodeType===1;){var x=c;if(s.nodeName.toLowerCase()!==i.toLowerCase()){if(!h&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(h){if(!s[so])switch(i){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(y=s.getAttribute("rel"),y==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(y!==x.rel||s.getAttribute("href")!==(x.href==null||x.href===""?null:x.href)||s.getAttribute("crossorigin")!==(x.crossOrigin==null?null:x.crossOrigin)||s.getAttribute("title")!==(x.title==null?null:x.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(y=s.getAttribute("src"),(y!==(x.src==null?null:x.src)||s.getAttribute("type")!==(x.type==null?null:x.type)||s.getAttribute("crossorigin")!==(x.crossOrigin==null?null:x.crossOrigin))&&y&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(i==="input"&&s.type==="hidden"){var y=x.name==null?null:""+x.name;if(x.type==="hidden"&&s.getAttribute("name")===y)return s}else return s;if(s=Nr(s.nextSibling),s===null)break}return null}function L2(s,i,c){if(i==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!c||(s=Nr(s.nextSibling),s===null))return null;return s}function cv(s,i){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!i||(s=Nr(s.nextSibling),s===null))return null;return s}function bf(s){return s.data==="$?"||s.data==="$~"}function vf(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function O2(s,i){var c=s.ownerDocument;if(s.data==="$~")s._reactRetry=i;else if(s.data!=="$?"||c.readyState!=="loading")i();else{var h=function(){i(),c.removeEventListener("DOMContentLoaded",h)};c.addEventListener("DOMContentLoaded",h),s._reactRetry=h}}function Nr(s){for(;s!=null;s=s.nextSibling){var i=s.nodeType;if(i===1||i===3)break;if(i===8){if(i=s.data,i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"||i==="F!"||i==="F")break;if(i==="/$"||i==="/&")return null}}return s}var _f=null;function uv(s){s=s.nextSibling;for(var i=0;s;){if(s.nodeType===8){var c=s.data;if(c==="/$"||c==="/&"){if(i===0)return Nr(s.nextSibling);i--}else c!=="$"&&c!=="$!"&&c!=="$?"&&c!=="$~"&&c!=="&"||i++}s=s.nextSibling}return null}function dv(s){s=s.previousSibling;for(var i=0;s;){if(s.nodeType===8){var c=s.data;if(c==="$"||c==="$!"||c==="$?"||c==="$~"||c==="&"){if(i===0)return s;i--}else c!=="/$"&&c!=="/&"||i++}s=s.previousSibling}return null}function hv(s,i,c){switch(i=Vc(c),s){case"html":if(s=i.documentElement,!s)throw Error(r(452));return s;case"head":if(s=i.head,!s)throw Error(r(453));return s;case"body":if(s=i.body,!s)throw Error(r(454));return s;default:throw Error(r(451))}}function Fo(s){for(var i=s.attributes;i.length;)s.removeAttributeNode(i[0]);Sd(s)}var jr=new Map,fv=new Set;function Kc(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var ws=F.d;F.d={f:I2,r:B2,D:z2,C:P2,L:H2,m:F2,X:U2,S:$2,M:W2};function I2(){var s=ws.f(),i=zc();return s||i}function B2(s){var i=ea(s);i!==null&&i.tag===5&&i.type==="form"?Ay(i):ws.r(s)}var Ma=typeof document>"u"?null:document;function pv(s,i,c){var h=Ma;if(h&&typeof i=="string"&&i){var x=br(i);x='link[rel="'+s+'"][href="'+x+'"]',typeof c=="string"&&(x+='[crossorigin="'+c+'"]'),fv.has(x)||(fv.add(x),s={rel:s,crossOrigin:c,href:i},h.querySelector(x)===null&&(i=h.createElement("link"),Dn(i,"link",s),mn(i),h.head.appendChild(i)))}}function z2(s){ws.D(s),pv("dns-prefetch",s,null)}function P2(s,i){ws.C(s,i),pv("preconnect",s,i)}function H2(s,i,c){ws.L(s,i,c);var h=Ma;if(h&&s&&i){var x='link[rel="preload"][as="'+br(i)+'"]';i==="image"&&c&&c.imageSrcSet?(x+='[imagesrcset="'+br(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(x+='[imagesizes="'+br(c.imageSizes)+'"]')):x+='[href="'+br(s)+'"]';var y=x;switch(i){case"style":y=Ra(s);break;case"script":y=La(s)}jr.has(y)||(s=g({rel:"preload",href:i==="image"&&c&&c.imageSrcSet?void 0:s,as:i},c),jr.set(y,s),h.querySelector(x)!==null||i==="style"&&h.querySelector($o(y))||i==="script"&&h.querySelector(Uo(y))||(i=h.createElement("link"),Dn(i,"link",s),mn(i),h.head.appendChild(i)))}}function F2(s,i){ws.m(s,i);var c=Ma;if(c&&s){var h=i&&typeof i.as=="string"?i.as:"script",x='link[rel="modulepreload"][as="'+br(h)+'"][href="'+br(s)+'"]',y=x;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=La(s)}if(!jr.has(y)&&(s=g({rel:"modulepreload",href:s},i),jr.set(y,s),c.querySelector(x)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(Uo(y)))return}h=c.createElement("link"),Dn(h,"link",s),mn(h),c.head.appendChild(h)}}}function $2(s,i,c){ws.S(s,i,c);var h=Ma;if(h&&s){var x=ta(h).hoistableStyles,y=Ra(s);i=i||"default";var w=x.get(y);if(!w){var M={loading:0,preload:null};if(w=h.querySelector($o(y)))M.loading=5;else{s=g({rel:"stylesheet",href:s,"data-precedence":i},c),(c=jr.get(y))&&Sf(s,c);var K=w=h.createElement("link");mn(K),Dn(K,"link",s),K._p=new Promise(function(ne,ue){K.onload=ne,K.onerror=ue}),K.addEventListener("load",function(){M.loading|=1}),K.addEventListener("error",function(){M.loading|=2}),M.loading|=4,Gc(w,i,h)}w={type:"stylesheet",instance:w,count:1,state:M},x.set(y,w)}}}function U2(s,i){ws.X(s,i);var c=Ma;if(c&&s){var h=ta(c).hoistableScripts,x=La(s),y=h.get(x);y||(y=c.querySelector(Uo(x)),y||(s=g({src:s,async:!0},i),(i=jr.get(x))&&wf(s,i),y=c.createElement("script"),mn(y),Dn(y,"link",s),c.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},h.set(x,y))}}function W2(s,i){ws.M(s,i);var c=Ma;if(c&&s){var h=ta(c).hoistableScripts,x=La(s),y=h.get(x);y||(y=c.querySelector(Uo(x)),y||(s=g({src:s,async:!0,type:"module"},i),(i=jr.get(x))&&wf(s,i),y=c.createElement("script"),mn(y),Dn(y,"link",s),c.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},h.set(x,y))}}function mv(s,i,c,h){var x=(x=Z.current)?Kc(x):null;if(!x)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(i=Ra(c.href),c=ta(x).hoistableStyles,h=c.get(i),h||(h={type:"style",instance:null,count:0,state:null},c.set(i,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){s=Ra(c.href);var y=ta(x).hoistableStyles,w=y.get(s);if(w||(x=x.ownerDocument||x,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(s,w),(y=x.querySelector($o(s)))&&!y._p&&(w.instance=y,w.state.loading=5),jr.has(s)||(c={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},jr.set(s,c),y||q2(x,s,c,w.state))),i&&h===null)throw Error(r(528,""));return w}if(i&&h!==null)throw Error(r(529,""));return null;case"script":return i=c.async,c=c.src,typeof c=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=La(c),c=ta(x).hoistableScripts,h=c.get(i),h||(h={type:"script",instance:null,count:0,state:null},c.set(i,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function Ra(s){return'href="'+br(s)+'"'}function $o(s){return'link[rel="stylesheet"]['+s+"]"}function gv(s){return g({},s,{"data-precedence":s.precedence,precedence:null})}function q2(s,i,c,h){s.querySelector('link[rel="preload"][as="style"]['+i+"]")?h.loading=1:(i=s.createElement("link"),h.preload=i,i.addEventListener("load",function(){return h.loading|=1}),i.addEventListener("error",function(){return h.loading|=2}),Dn(i,"link",c),mn(i),s.head.appendChild(i))}function La(s){return'[src="'+br(s)+'"]'}function Uo(s){return"script[async]"+s}function xv(s,i,c){if(i.count++,i.instance===null)switch(i.type){case"style":var h=s.querySelector('style[data-href~="'+br(c.href)+'"]');if(h)return i.instance=h,mn(h),h;var x=g({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return h=(s.ownerDocument||s).createElement("style"),mn(h),Dn(h,"style",x),Gc(h,c.precedence,s),i.instance=h;case"stylesheet":x=Ra(c.href);var y=s.querySelector($o(x));if(y)return i.state.loading|=4,i.instance=y,mn(y),y;h=gv(c),(x=jr.get(x))&&Sf(h,x),y=(s.ownerDocument||s).createElement("link"),mn(y);var w=y;return w._p=new Promise(function(M,K){w.onload=M,w.onerror=K}),Dn(y,"link",h),i.state.loading|=4,Gc(y,c.precedence,s),i.instance=y;case"script":return y=La(c.src),(x=s.querySelector(Uo(y)))?(i.instance=x,mn(x),x):(h=c,(x=jr.get(y))&&(h=g({},c),wf(h,x)),s=s.ownerDocument||s,x=s.createElement("script"),mn(x),Dn(x,"link",h),s.head.appendChild(x),i.instance=x);case"void":return null;default:throw Error(r(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(h=i.instance,i.state.loading|=4,Gc(h,c.precedence,s));return i.instance}function Gc(s,i,c){for(var h=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),x=h.length?h[h.length-1]:null,y=x,w=0;w<h.length;w++){var M=h[w];if(M.dataset.precedence===i)y=M;else if(y!==x)break}y?y.parentNode.insertBefore(s,y.nextSibling):(i=c.nodeType===9?c.head:c,i.insertBefore(s,i.firstChild))}function Sf(s,i){s.crossOrigin==null&&(s.crossOrigin=i.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=i.referrerPolicy),s.title==null&&(s.title=i.title)}function wf(s,i){s.crossOrigin==null&&(s.crossOrigin=i.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=i.referrerPolicy),s.integrity==null&&(s.integrity=i.integrity)}var Yc=null;function yv(s,i,c){if(Yc===null){var h=new Map,x=Yc=new Map;x.set(c,h)}else x=Yc,h=x.get(c),h||(h=new Map,x.set(c,h));if(h.has(s))return h;for(h.set(s,null),c=c.getElementsByTagName(s),x=0;x<c.length;x++){var y=c[x];if(!(y[so]||y[jn]||s==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var w=y.getAttribute(i)||"";w=s+w;var M=h.get(w);M?M.push(y):h.set(w,[y])}}return h}function bv(s,i,c){s=s.ownerDocument||s,s.head.insertBefore(c,i==="title"?s.querySelector("head > title"):null)}function V2(s,i,c){if(c===1||i.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return s=i.disabled,typeof i.precedence=="string"&&s==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function vv(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function K2(s,i,c,h){if(c.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var x=Ra(h.href),y=i.querySelector($o(x));if(y){i=y._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(s.count++,s=Xc.bind(s),i.then(s,s)),c.state.loading|=4,c.instance=y,mn(y);return}y=i.ownerDocument||i,h=gv(h),(x=jr.get(x))&&Sf(h,x),y=y.createElement("link"),mn(y);var w=y;w._p=new Promise(function(M,K){w.onload=M,w.onerror=K}),Dn(y,"link",h),c.instance=y}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(c,i),(i=c.state.preload)&&(c.state.loading&3)===0&&(s.count++,c=Xc.bind(s),i.addEventListener("load",c),i.addEventListener("error",c))}}var kf=0;function G2(s,i){return s.stylesheets&&s.count===0&&Qc(s,s.stylesheets),0<s.count||0<s.imgCount?function(c){var h=setTimeout(function(){if(s.stylesheets&&Qc(s,s.stylesheets),s.unsuspend){var y=s.unsuspend;s.unsuspend=null,y()}},6e4+i);0<s.imgBytes&&kf===0&&(kf=62500*E2());var x=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&Qc(s,s.stylesheets),s.unsuspend)){var y=s.unsuspend;s.unsuspend=null,y()}},(s.imgBytes>kf?50:800)+i);return s.unsuspend=c,function(){s.unsuspend=null,clearTimeout(h),clearTimeout(x)}}:null}function Xc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Qc(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var Zc=null;function Qc(s,i){s.stylesheets=null,s.unsuspend!==null&&(s.count++,Zc=new Map,i.forEach(Y2,s),Zc=null,Xc.call(s))}function Y2(s,i){if(!(i.state.loading&4)){var c=Zc.get(s);if(c)var h=c.get(null);else{c=new Map,Zc.set(s,c);for(var x=s.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<x.length;y++){var w=x[y];(w.nodeName==="LINK"||w.getAttribute("media")!=="not all")&&(c.set(w.dataset.precedence,w),h=w)}h&&c.set(null,h)}x=i.instance,w=x.getAttribute("data-precedence"),y=c.get(w)||h,y===h&&c.set(null,x),c.set(w,x),this.count++,h=Xc.bind(this),x.addEventListener("load",h),x.addEventListener("error",h),y?y.parentNode.insertBefore(x,y.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(x,s.firstChild)),i.state.loading|=4}}var Wo={$$typeof:A,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function X2(s,i,c,h,x,y,w,M,K){this.tag=1,this.containerInfo=s,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=ln(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ln(0),this.hiddenUpdates=ln(null),this.identifierPrefix=h,this.onUncaughtError=x,this.onCaughtError=y,this.onRecoverableError=w,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=K,this.incompleteTransitions=new Map}function _v(s,i,c,h,x,y,w,M,K,ne,ue,fe){return s=new X2(s,i,c,w,K,ne,ue,fe,M),i=1,y===!0&&(i|=24),y=sr(3,null,null,i),s.current=y,y.stateNode=s,i=nh(),i.refCount++,s.pooledCache=i,i.refCount++,y.memoizedState={element:h,isDehydrated:c,cache:i},ah(y),s}function Sv(s){return s?(s=da,s):da}function wv(s,i,c,h,x,y){x=Sv(x),h.context===null?h.context=x:h.pendingContext=x,h=Ps(i),h.payload={element:c},y=y===void 0?null:y,y!==null&&(h.callback=y),c=Hs(s,h,i),c!==null&&(Jn(c,s,i),So(c,s,i))}function kv(s,i){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var c=s.retryLane;s.retryLane=c!==0&&c<i?c:i}}function Cf(s,i){kv(s,i),(s=s.alternate)&&kv(s,i)}function Cv(s){if(s.tag===13||s.tag===31){var i=xi(s,67108864);i!==null&&Jn(i,s,67108864),Cf(s,67108864)}}function Nv(s){if(s.tag===13||s.tag===31){var i=cr();i=bd(i);var c=xi(s,i);c!==null&&Jn(c,s,i),Cf(s,i)}}var Jc=!0;function Z2(s,i,c,h){var x=N.T;N.T=null;var y=F.p;try{F.p=2,Nf(s,i,c,h)}finally{F.p=y,N.T=x}}function Q2(s,i,c,h){var x=N.T;N.T=null;var y=F.p;try{F.p=8,Nf(s,i,c,h)}finally{F.p=y,N.T=x}}function Nf(s,i,c,h){if(Jc){var x=jf(h);if(x===null)hf(s,i,h,eu,c),Ev(s,h);else if(eN(x,s,i,c,h))h.stopPropagation();else if(Ev(s,h),i&4&&-1<J2.indexOf(s)){for(;x!==null;){var y=ea(x);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var w=Ue(y.pendingLanes);if(w!==0){var M=y;for(M.pendingLanes|=2,M.entangledLanes|=2;w;){var K=1<<31-we(w);M.entanglements[1]|=K,w&=~K}Wr(y),(mt&6)===0&&(Ic=Ie()+500,zo(0))}}break;case 31:case 13:M=xi(y,2),M!==null&&Jn(M,y,2),zc(),Cf(y,2)}if(y=jf(h),y===null&&hf(s,i,h,eu,c),y===x)break;x=y}x!==null&&h.stopPropagation()}else hf(s,i,h,null,c)}}function jf(s){return s=Ed(s),Ef(s)}var eu=null;function Ef(s){if(eu=null,s=Ji(s),s!==null){var i=o(s);if(i===null)s=null;else{var c=i.tag;if(c===13){if(s=u(i),s!==null)return s;s=null}else if(c===31){if(s=d(i),s!==null)return s;s=null}else if(c===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;s=null}else i!==s&&(s=null)}}return eu=s,null}function jv(s){switch(s){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(an()){case le:return 2;case xe:return 8;case Me:case Be:return 32;case ot:return 268435456;default:return 32}default:return 32}}var Tf=!1,Zs=null,Qs=null,Js=null,qo=new Map,Vo=new Map,ei=[],J2="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 Ev(s,i){switch(s){case"focusin":case"focusout":Zs=null;break;case"dragenter":case"dragleave":Qs=null;break;case"mouseover":case"mouseout":Js=null;break;case"pointerover":case"pointerout":qo.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vo.delete(i.pointerId)}}function Ko(s,i,c,h,x,y){return s===null||s.nativeEvent!==y?(s={blockedOn:i,domEventName:c,eventSystemFlags:h,nativeEvent:y,targetContainers:[x]},i!==null&&(i=ea(i),i!==null&&Cv(i)),s):(s.eventSystemFlags|=h,i=s.targetContainers,x!==null&&i.indexOf(x)===-1&&i.push(x),s)}function eN(s,i,c,h,x){switch(i){case"focusin":return Zs=Ko(Zs,s,i,c,h,x),!0;case"dragenter":return Qs=Ko(Qs,s,i,c,h,x),!0;case"mouseover":return Js=Ko(Js,s,i,c,h,x),!0;case"pointerover":var y=x.pointerId;return qo.set(y,Ko(qo.get(y)||null,s,i,c,h,x)),!0;case"gotpointercapture":return y=x.pointerId,Vo.set(y,Ko(Vo.get(y)||null,s,i,c,h,x)),!0}return!1}function Tv(s){var i=Ji(s.target);if(i!==null){var c=o(i);if(c!==null){if(i=c.tag,i===13){if(i=u(c),i!==null){s.blockedOn=i,Ug(s.priority,function(){Nv(c)});return}}else if(i===31){if(i=d(c),i!==null){s.blockedOn=i,Ug(s.priority,function(){Nv(c)});return}}else if(i===3&&c.stateNode.current.memoizedState.isDehydrated){s.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}s.blockedOn=null}function tu(s){if(s.blockedOn!==null)return!1;for(var i=s.targetContainers;0<i.length;){var c=jf(s.nativeEvent);if(c===null){c=s.nativeEvent;var h=new c.constructor(c.type,c);jd=h,c.target.dispatchEvent(h),jd=null}else return i=ea(c),i!==null&&Cv(i),s.blockedOn=c,!1;i.shift()}return!0}function Av(s,i,c){tu(s)&&c.delete(i)}function tN(){Tf=!1,Zs!==null&&tu(Zs)&&(Zs=null),Qs!==null&&tu(Qs)&&(Qs=null),Js!==null&&tu(Js)&&(Js=null),qo.forEach(Av),Vo.forEach(Av)}function nu(s,i){s.blockedOn===i&&(s.blockedOn=null,Tf||(Tf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,tN)))}var ru=null;function Dv(s){ru!==s&&(ru=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ru===s&&(ru=null);for(var i=0;i<s.length;i+=3){var c=s[i],h=s[i+1],x=s[i+2];if(typeof h!="function"){if(Ef(h||c)===null)continue;break}var y=ea(c);y!==null&&(s.splice(i,3),i-=3,Nh(y,{pending:!0,data:x,method:c.method,action:h},h,x))}}))}function Oa(s){function i(K){return nu(K,s)}Zs!==null&&nu(Zs,s),Qs!==null&&nu(Qs,s),Js!==null&&nu(Js,s),qo.forEach(i),Vo.forEach(i);for(var c=0;c<ei.length;c++){var h=ei[c];h.blockedOn===s&&(h.blockedOn=null)}for(;0<ei.length&&(c=ei[0],c.blockedOn===null);)Tv(c),c.blockedOn===null&&ei.shift();if(c=(s.ownerDocument||s).$$reactFormReplay,c!=null)for(h=0;h<c.length;h+=3){var x=c[h],y=c[h+1],w=x[Kn]||null;if(typeof y=="function")w||Dv(c);else if(w){var M=null;if(y&&y.hasAttribute("formAction")){if(x=y,w=y[Kn]||null)M=w.formAction;else if(Ef(x)!==null)continue}else M=w.action;typeof M=="function"?c[h+1]=M:(c.splice(h,3),h-=3),Dv(c)}}}function Mv(){function s(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(w){return x=w})},focusReset:"manual",scroll:"manual"})}function i(){x!==null&&(x(),x=null),h||setTimeout(c,20)}function c(){if(!h&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var h=!1,x=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",i),navigation.addEventListener("navigateerror",i),setTimeout(c,100),function(){h=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",i),navigation.removeEventListener("navigateerror",i),x!==null&&(x(),x=null)}}}function Af(s){this._internalRoot=s}su.prototype.render=Af.prototype.render=function(s){var i=this._internalRoot;if(i===null)throw Error(r(409));var c=i.current,h=cr();wv(c,h,s,i,null,null)},su.prototype.unmount=Af.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var i=s.containerInfo;wv(s.current,2,null,s,null,null),zc(),i[Qi]=null}};function su(s){this._internalRoot=s}su.prototype.unstable_scheduleHydration=function(s){if(s){var i=$g();s={blockedOn:null,target:s,priority:i};for(var c=0;c<ei.length&&i!==0&&i<ei[c].priority;c++);ei.splice(c,0,s),c===0&&Tv(s)}};var Rv=t.version;if(Rv!=="19.2.4")throw Error(r(527,Rv,"19.2.4"));F.findDOMNode=function(s){var i=s._reactInternals;if(i===void 0)throw typeof s.render=="function"?Error(r(188)):(s=Object.keys(s).join(","),Error(r(268,s)));return s=f(i),s=s!==null?m(s):null,s=s===null?null:s.stateNode,s};var nN={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:N,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var iu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!iu.isDisabled&&iu.supportsFiber)try{on=iu.inject(nN),Bt=iu}catch{}}return Yo.createRoot=function(s,i){if(!a(s))throw Error(r(299));var c=!1,h="",x=Hy,y=Fy,w=$y;return i!=null&&(i.unstable_strictMode===!0&&(c=!0),i.identifierPrefix!==void 0&&(h=i.identifierPrefix),i.onUncaughtError!==void 0&&(x=i.onUncaughtError),i.onCaughtError!==void 0&&(y=i.onCaughtError),i.onRecoverableError!==void 0&&(w=i.onRecoverableError)),i=_v(s,1,!1,null,null,c,h,null,x,y,w,Mv),s[Qi]=i.current,df(s),new Af(i)},Yo.hydrateRoot=function(s,i,c){if(!a(s))throw Error(r(299));var h=!1,x="",y=Hy,w=Fy,M=$y,K=null;return c!=null&&(c.unstable_strictMode===!0&&(h=!0),c.identifierPrefix!==void 0&&(x=c.identifierPrefix),c.onUncaughtError!==void 0&&(y=c.onUncaughtError),c.onCaughtError!==void 0&&(w=c.onCaughtError),c.onRecoverableError!==void 0&&(M=c.onRecoverableError),c.formState!==void 0&&(K=c.formState)),i=_v(s,1,!0,i,c??null,h,x,K,y,w,M,Mv),i.context=Sv(null),c=i.current,h=cr(),h=bd(h),x=Ps(h),x.callback=null,Hs(c,x,h),c=h,i.current.lanes=c,Zi(i,c),Wr(i),s[Qi]=i.current,df(s),new su(i)},Yo.version="19.2.4",Yo}var Uv;function mN(){if(Uv)return Rf.exports;Uv=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Rf.exports=pN(),Rf.exports}var gN=mN();const xN=Gu(gN),Wv=e=>{let t;const n=new Set,r=(f,m)=>{const g=typeof f=="function"?f(t):f;if(!Object.is(g,t)){const v=t;t=m??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(b=>b(t,v))}},a=()=>t,d={setState:r,getState:a,getInitialState:()=>p,subscribe:f=>(n.add(f),()=>n.delete(f))},p=t=e(r,a,d);return d},yN=(e=>e?Wv(e):Wv),bN=e=>e;function vN(e,t=bN){const n=zn.useSyncExternalStore(e.subscribe,zn.useCallback(()=>t(e.getState()),[e,t]),zn.useCallback(()=>t(e.getInitialState()),[e,t]));return zn.useDebugValue(n),n}const qv=e=>{const t=yN(e),n=r=>vN(t,r);return Object.assign(n,t),n},gr=(e=>e?qv(e):qv);async function ke(e,t={}){const n=localStorage.getItem("openfox_token"),r={...t.headers instanceof Headers?Object.fromEntries(t.headers.entries()):t.headers,...n?{"x-session-token":n}:{}};return fetch(e,{...t,headers:r})}async function _N(e,t){try{return(await ke(`/api/sessions/${e}/truncate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageIndex:t})})).ok}catch{return!1}}const Qe={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings",DISPLAY_SHOW_THINKING:"display.showThinking",DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT:"display.showVerboseToolOutput",DISPLAY_SHOW_STATS:"display.showStats",DISPLAY_SHOW_AGENT_DEFINITIONS:"display.showAgentDefinitions",DISPLAY_SHOW_WORKFLOW_BARS:"display.showWorkflowBars",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",LLM_DISABLE_XML_PROTECTION:"llm.disableXmlProtection"};function au(e,t){return n=>({loading:{...n.loading,[e]:t}})}function Vv(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const zS=[Qe.DISPLAY_SHOW_THINKING,Qe.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Qe.DISPLAY_SHOW_STATS,Qe.DISPLAY_SHOW_AGENT_DEFINITIONS,Qe.DISPLAY_SHOW_WORKFLOW_BARS];function jm(){return{showThinking:wn(e=>e.settings[Qe.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:wn(e=>e.settings[Qe.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:wn(e=>e.settings[Qe.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:wn(e=>e.settings[Qe.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:wn(e=>e.settings[Qe.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true"}}const wn=gr(e=>({settings:{},loading:{},getSetting:async t=>{e(au(t,!0));try{const r=await(await ke(`/api/settings/${t}`)).json();return e(Vv(t,r.value??"")),r.value}catch{return e(au(t,!1)),null}},setSetting:async(t,n)=>{e(au(t,!0));try{const a=await(await ke(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(Vv(t,a.value??""))}catch{e(au(t,!1))}}})),Kv=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:zS,SETTINGS_KEYS:Qe,useDisplaySettings:jm,useSettingsStore:wn},Symbol.toStringTag,{value:"Module"}));function SN(){const[e,t]=k.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=k.useRef(window.innerHeight);return k.useEffect(()=>{const r=window.visualViewport;if(!r)return;const a=()=>{const o=r.offsetTop,u=r.height,d=n.current-u>100;t({offsetTop:o,height:u,keyboardVisible:d})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}function wN(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,a,o,u=[],d="",p=e.split("/");for(p[0]||p.shift();a=p.shift();)n=a[0],n==="*"?(u.push(n),d+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=a.indexOf("?",1),o=a.indexOf(".",1),u.push(a.substring(1,~r?r:~o?o:a.length)),d+=~r&&!~o?"(?:/([^/]+?))?":"/([^/]+?)",~o&&(d+=(~r?"?":"")+"\\"+a.substring(o))):d+="/"+a;return{keys:u,pattern:new RegExp("^"+d+(t?"(?=$|/)":"/?$"),"i")}}var Bf={exports:{}},zf={};/**
|
|
50
|
+
* @license React
|
|
51
|
+
* use-sync-external-store-shim.production.js
|
|
52
|
+
*
|
|
53
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the MIT license found in the
|
|
56
|
+
* LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/var Gv;function kN(){if(Gv)return zf;Gv=1;var e=Yu();function t(g,v){return g===v&&(g!==0||1/g===1/v)||g!==g&&v!==v}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,o=e.useLayoutEffect,u=e.useDebugValue;function d(g,v){var b=v(),_=r({inst:{value:b,getSnapshot:v}}),S=_[0].inst,j=_[1];return o(function(){S.value=b,S.getSnapshot=v,p(S)&&j({inst:S})},[g,b,v]),a(function(){return p(S)&&j({inst:S}),g(function(){p(S)&&j({inst:S})})},[g]),u(b),b}function p(g){var v=g.getSnapshot;g=g.value;try{var b=v();return!n(g,b)}catch{return!0}}function f(g,v){return v()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:d;return zf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,zf}var Yv;function CN(){return Yv||(Yv=1,Bf.exports=kN()),Bf.exports}var NN=CN();const jN=uN.useInsertionEffect,EN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",TN=EN?k.useLayoutEffect:k.useEffect,AN=jN||TN,PS=e=>{const t=k.useRef([e,(...n)=>t[0](...n)]).current;return AN(()=>{t[0]=e}),t[1]},DN="popstate",Em="pushState",Tm="replaceState",MN="hashchange",Xv=[DN,Em,Tm,MN],RN=e=>{for(const t of Xv)addEventListener(t,e);return()=>{for(const t of Xv)removeEventListener(t,e)}},HS=(e,t)=>NN.useSyncExternalStore(RN,e,t),Zv=()=>location.search,LN=({ssrSearch:e}={})=>HS(Zv,e!=null?()=>e:Zv),Qv=()=>location.pathname,ON=({ssrPath:e}={})=>HS(Qv,e!=null?()=>e:Qv),IN=(e,{replace:t=!1,state:n=null}={})=>history[t?Tm:Em](n,"",e),BN=(e={})=>[ON(e),IN],Jv=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[Jv]>"u"){for(const e of[Em,Tm]){const t=history[e];history[e]=function(){const n=t.apply(this,arguments),r=new Event(e);return r.arguments=arguments,dispatchEvent(r),n}}Object.defineProperty(window,Jv,{value:!0})}const zN=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",FS=(e="")=>e==="/"?"":e,PN=(e,t)=>e[0]==="~"?e.slice(1):FS(t)+e,HN=(e="",t)=>zN(e_(FS(e)),e_(t)),e_=e=>{try{return decodeURI(e)}catch{return e}},$S={hook:BN,searchHook:LN,parser:wN,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},US=k.createContext($S),Qa=()=>k.useContext(US),WS={},qS=k.createContext(WS),FN=()=>k.useContext(qS),Xu=e=>{const[t,n]=e.hook(e);return[HN(e.base,t),PS((r,a)=>e.aroundNav(n,PN(r,e.base),a))]},Hr=()=>Xu(Qa()),Am=(e,t,n,r)=>{const{pattern:a,keys:o}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),u=a.exec(n)||[],[d,...p]=u;return d!==void 0?[!0,(()=>{const f=o!==!1?Object.fromEntries(o.map((g,v)=>[g,p[v]])):u.groups;let m={...p};return f&&Object.assign(m,f),m})(),...r?[d]:[]]:[!1,null]},Dm=e=>Am(Qa().parser,e,Hr()[0]),$N=({children:e,...t})=>{var m,g,v;const n=Qa(),r=t.hook?$S:n;let a=r;const[o,u=t.ssrSearch??""]=((m=t.ssrPath)==null?void 0:m.split("?"))??[];o&&(t.ssrSearch=u,t.ssrPath=o),t.hrefs=t.hrefs??((g=t.hook)==null?void 0:g.hrefs),t.searchHook=t.searchHook??((v=t.hook)==null?void 0:v.searchHook);let d=k.useRef({}),p=d.current,f=p;for(let b in r){const _=b==="base"?r[b]+(t[b]??""):t[b]??r[b];p===f&&_!==f[b]&&(d.current=f={...f}),f[b]=_,(_!==r[b]||_!==a[b])&&(a=f)}return k.createElement(US.Provider,{value:a,children:e})},t_=({children:e,component:t},n)=>t?k.createElement(t,{params:n}):typeof e=="function"?e(n):e,UN=e=>{let t=k.useRef(WS);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,a])=>a!==n[r])?e:n},Xo=({path:e,nest:t,match:n,...r})=>{const a=Qa(),[o]=Xu(a),[u,d,p]=n??Am(a.parser,e,o,t),f=UN({...FN(),...d});if(!u)return null;const m=p?k.createElement($N,{base:p},t_(r,f)):t_(r,f);return k.createElement(qS.Provider,{value:f,children:m})},pr=k.forwardRef((e,t)=>{const n=Qa(),[r,a]=Xu(n),{to:o="",href:u=o,onClick:d,asChild:p,children:f,className:m,replace:g,state:v,transition:b,..._}=e,S=PS(C=>{C.ctrlKey||C.metaKey||C.altKey||C.shiftKey||C.button!==0||(d==null||d(C),C.defaultPrevented||(C.preventDefault(),a(u,e)))}),j=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return p&&k.isValidElement(f)?k.cloneElement(f,{onClick:S,href:j}):k.createElement("a",{..._,onClick:S,href:j,className:m!=null&&m.call?m(r===u):m,children:f,ref:t})}),VS=e=>Array.isArray(e)?e.flatMap(t=>VS(t&&t.type===k.Fragment?t.props.children:t)):[e],WN=({children:e,location:t})=>{const n=Qa(),[r]=Xu(n);for(const a of VS(e)){let o=0;if(k.isValidElement(a)&&(o=Am(n.parser,a.props.path,t||r,a.props.nest))[0])return k.cloneElement(a,{match:o})}return null};function qN(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function KS(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}class VN{constructor(t){qr(this,"ws",null);qr(this,"handlers",new Set);qr(this,"statusHandler",null);qr(this,"baseUrl");qr(this,"isReconnecting",!1);qr(this,"connectingPromise",null);qr(this,"lastCloseCode",0);qr(this,"reconnectAttempts",0);qr(this,"manualReconnectScheduled",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.connectingPromise=new Promise((r,a)=>{try{const o=this.getUrl();this.ws=new WebSocket(o);const u=setTimeout(()=>{var d;((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING&&(this.ws.close(),a(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var d;clearTimeout(u),this.isReconnecting=!1,this.connectingPromise=null,(d=this.statusHandler)==null||d.call(this,"connected"),r()},this.ws.onclose=d=>{var p,f,m;clearTimeout(u),this.lastCloseCode=d.code,((p=this.ws)==null?void 0:p.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"disconnected"),a(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=d=>{clearTimeout(u),console.error("WebSocket error:",d),this.connectingPromise=null,a(d)},this.ws.onmessage=d=>{try{const p=JSON.parse(d.data);qN(p)&&this.handlers.forEach(f=>f(p))}catch(p){console.error("Failed to parse WebSocket message:",p)}}}catch(o){this.connectingPromise=null,a(o)}}),this.connectingPromise))}attemptReconnect(){var a;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(a=this.statusHandler)==null||a.call(this,"reconnecting");const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{})},r)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const r=KS(),a={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(a)),r}subscribe(t){return this.handlers.add(t),()=>this.handlers.delete(t)}get isConnected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}}const KN=window.location.protocol==="https:"?"wss:":"ws:";let wp=window.location.port;wp||(wp=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const GN=`${KN}//${window.location.hostname}:${wp}/ws`,tn=new VN(GN),di=async(e,t,n)=>{try{const r=await ke(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?{success:!0}:{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}},Zu=async(e,t,n)=>{try{const r=await ke(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function GS(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let ou=[];const Qr=gr()((e,t)=>{function n(){if(ou.length===0)return;const a=ou;ou=[],e(o=>({logs:[...o.logs,...a]}))}const r=GS(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:a=>{t().workdir!==a&&(e({workdir:a,status:null,logs:[],config:null,loading:!0}),a&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const a=t().workdir;if(a)try{const u=await(await ke(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:u,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const u=await(await ke(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:u.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const d=(await(await ke(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(p=>({stream:p.stream,content:p.content}));e({logs:d})}catch{}},start:async()=>{const a=t().workdir;if(a)try{const u=await(await ke(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const u=await(await ke(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const u=await(await ke(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},saveConfig:async a=>{const o=t().workdir;if(o)try{const d=await(await ke(`/api/dev-server/config?workdir=${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:d.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const o=t().workdir;if(o)switch(a.type){case"devServer.output":{const u=a.payload;if(u.workdir!==o)return;ou.push({stream:u.stream,content:u.content}),r();break}case"devServer.state":{const u=a.payload;if(u.workdir!==o)return;e(d=>({status:d.status?{...d.status,state:u.state,errorMessage:u.errorMessage}:d.status}));break}}}}});function YN(e){return{...e.temperature!=null&&{temperature:e.temperature},...e.topP!=null&&{topP:e.topP},...e.topK!=null&&{topK:e.topK},...e.maxTokens!=null&&{maxTokens:e.maxTokens}}}async function n_(e,t,n){const r=await ke(`/api/providers/${e}/models/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const a=await r.json();throw new Error(a.error??"Failed to update model")}return r.json()}function r_(e,t,n,r){return e.map(a=>a.id===t?{...a,models:a.models.map(o=>o.id===n?{...o,...r,source:"user"}:o)}:a)}const XN=3e4;function ZN(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return""}}const Mt=gr((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const n=await ke("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json();e({version:r.version,model:r.model,maxContext:r.maxContext,llmUrl:r.llmUrl,llmStatus:r.llmStatus,backend:r.backend,providers:r.providers??[],activeProviderId:r.activeProviderId??null,defaultModelSelection:r.defaultModelSelection??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await ke("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json(),o=ye.getState().currentSession;if(o!=null&&o.providerId&&o.providerModel){e({llmStatus:r.llmStatus,backend:r.backend});return}e({model:r.model,llmStatus:r.llmStatus,backend:r.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:r,providers:a}=t();if(n===r)return!0;e({activating:!0,error:null});try{const o=await ke(`/api/providers/${n}/activate`,{method:"POST"});if(!o.ok){const d=await o.json();throw new Error(d.error??"Failed to activate provider")}const u=await o.json();return e({activeProviderId:u.activeProviderId,model:u.model,backend:u.backend,providers:a.map(d=>({...d,isActive:d.id===u.activeProviderId})),activating:!1}),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(n,r)=>{var d;const{providers:a,defaultModelSelection:o}=t();let u=r;if(!u){const p=o?o.split("/"):[],f=p[0],m=p.slice(1).join("/")??"";if(f===n&&m)u=m;else{const g=a.find(v=>v.id===n);u=((d=g==null?void 0:g.models[0])==null?void 0:d.id)??""}}e({activeProviderId:n,model:u,defaultModelSelection:`${n}/${u}`,providers:a.map(p=>({...p,isActive:p.id===n}))})},updateModelContext:async(n,r,a)=>{e({activating:!0,error:null});try{const o=await n_(n,r,{contextWindow:a}),{providers:u}=t();return e({providers:r_(u,n,r,{contextWindow:a}),activating:!1}),o.contextState&&ye.getState().updateContextState(o.contextState),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to update model context",activating:!1}),!1}},updateModelSettings:async(n,r,a)=>{e({activating:!0,error:null});try{const o=await n_(n,r,a),{providers:u}=t(),d={...a.contextWindow!==void 0&&{contextWindow:a.contextWindow},...YN({temperature:a.temperature??void 0,topP:a.topP??void 0,topK:a.topK??void 0,maxTokens:a.maxTokens??void 0}),...a.supportsVision!==void 0&&{supportsVision:a.supportsVision}};return e({providers:r_(u,n,r,d),activating:!1}),o.contextState&&ye.getState().updateContextState(o.contextState),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to update model settings",activating:!1}),!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await ke(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const u=await r.json();throw new Error(u.error??"Failed to refresh models")}const a=await r.json(),{providers:o}=t();return e({providers:o.map(u=>u.id===n?{...u,models:a.models,status:a.status}:u),activating:!1}),!0}catch(r){return e({error:r instanceof Error?r.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:r}=t();if(n)return;const a=setInterval(()=>{r()},XN);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(a=>a.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:a}=t(),o=r.find(d=>d.id===a);if(!o)return 2e5;const u=o.models.find(d=>d.id===n);return(u==null?void 0:u.contextWindow)??2e5}})),Ut=gr((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await ke("/api/projects")).json();e({projects:r.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,r)=>{try{const a=await ke("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!a.ok){const u=await a.json().catch(()=>({}));return{error:{code:u.code||"UNKNOWN",path:u.path,message:u.error}}}const o=await a.json();return await t().listProjects(),o.project}catch{return null}},loadProject:async n=>{try{const r=await ke(`/api/projects/${n}`);if(!r.ok)return null;const a=await r.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,r)=>{var a;try{const o=await ke(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)return null;const u=await o.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:u.project}),await t().listProjects(),u.project}catch{return null}},deleteProject:async n=>{var r;try{return(await ke(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((r=t().currentProject)==null?void 0:r.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,r)=>{var a;try{const o=await ke(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!o.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const u=await o.json();e({currentProject:u.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}}));let lu=[];const vl=gr()((e,t)=>{function n(){if(lu.length===0)return;const a=lu;lu=[],e(o=>{const u={...o.logs};for(const d of a){const p=u[d.processId]??[];u[d.processId]=[...p,{offset:p.length,content:d.content,timestamp:Date.now(),stream:d.stream}]}return{logs:u}})}const r=GS(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(o=>({processes:[...o.processes,a]})),updateProcess:(a,o)=>e(u=>({processes:u.processes.map(d=>d.id===a?{...d,...o}:d)})),removeProcess:a=>e(o=>({processes:o.processes.filter(u=>u.id!==a),logs:Object.fromEntries(Object.entries(o.logs).filter(([u])=>u!==a))})),stopProcess:async(a,o)=>{try{(await ke(`/api/sessions/${o}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,o,u)=>{lu.push({processId:a,stream:o,content:u}),r()},setLogs:(a,o)=>e(u=>({logs:{...u.logs,[a]:o}})),clearLogs:a=>e(o=>({logs:{...o.logs,[a]:[]}})),handleMessage:(a,o)=>{switch(a){case"backgroundProcess.started":{const{processId:u,name:d,pid:p,status:f}=o;e(m=>({processes:[...m.processes,{id:u,sessionId:"",name:d,command:"",cwd:"",pid:p,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const u=o.processId,d=o.stream,p=o.content;t().appendLog(u,d,p);break}case"backgroundProcess.exited":{const u=o.processId,d=o.exitCode;e(p=>({processes:p.processes.map(f=>f.id===u?{...f,status:"exited",exitCode:d}:f)}));break}case"backgroundProcess.removed":{const u=o.processId;t().removeProcess(u);break}}}}}),QN=[{key:"complete",label:"Task Complete",description:"When an agent finishes its work"},{key:"waiting_for_user",label:"Waiting for Input",description:"When the agent needs your input"},{key:"phase_done",label:"Phase Done",description:"When a build phase completes successfully"},{key:"phase_blocked",label:"Phase Blocked",description:"When a build phase is blocked and needs intervention"},{key:"new_message",label:"New Message",description:"When a new assistant message starts arriving"}],JN=[{url:"/sounds/notification.mp3",label:"Notification"},{url:"/sounds/waiting-for-user.mp3",label:"Waiting for User"},{url:"/sounds/achievement.mp3",label:"Achievement"},{url:"/sounds/intervention.mp3",label:"Intervention"},{url:"/sounds/typing.mp3",label:"Typing"}],YS={complete:"/sounds/notification.mp3",waiting_for_user:"/sounds/waiting-for-user.mp3",phase_done:"/sounds/achievement.mp3",phase_blocked:"/sounds/intervention.mp3",new_message:"/sounds/typing.mp3"},oi={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},XS={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},kp={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...oi},waiting_for_user:{...oi},phase_done:{...oi},phase_blocked:{...oi},new_message:{...XS}},agentOverrides:{}};function ZS(e,t,n){var o;const r=e.events[t];if(!n)return r;const a=(o=e.agentOverrides[n])==null?void 0:o[t];return a?{soundEnabled:a.soundEnabled??r.soundEnabled,browserNotification:a.browserNotification??r.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:r.customSoundUrl}:r}const zi=gr((e,t)=>({settings:kp,loaded:!1,load:()=>{wn.getState().getSetting(Qe.NOTIFICATION_SETTINGS);const r=wn.subscribe(o=>{const u=o.settings[Qe.NOTIFICATION_SETTINGS];if(u!==void 0)try{const d=JSON.parse(u);e({settings:s_(d),loaded:!0})}catch{e({loaded:!0})}}),a=wn.getState().settings[Qe.NOTIFICATION_SETTINGS];if(a)try{const o=JSON.parse(a);e({settings:s_(o),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),Pf(n)},updateEvent:(n,r)=>{const a=t().settings,o={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:o}),Pf(o)},updateAgentOverride:(n,r,a)=>{var p;const o=t().settings,u={...o.agentOverrides};if(a===null){if(u[n]){const f={...u[n]};delete f[r],Object.keys(f).length===0?delete u[n]:u[n]=f}}else u[n]={...u[n],[r]:{...((p=u[n])==null?void 0:p[r])??{},...a}};const d={...o,agentOverrides:u};e({settings:d}),Pf(d)}}));function Pf(e){wn.getState().setSetting(Qe.NOTIFICATION_SETTINGS,JSON.stringify(e))}function s_(e){var t,n,r,a,o;return{soundEnabled:e.soundEnabled??kp.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??kp.browserNotificationEnabled,events:{complete:{...oi,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...oi,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...oi,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...oi,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...XS,...(o=e.events)==null?void 0:o.new_message}},agentOverrides:e.agentOverrides??{}}}const i_=new Map;function ej(e){let t=i_.get(e);return t||(t=new Audio(e),t.volume=.5,i_.set(e,t)),t}let QS=typeof Notification<"u"?Notification.permission:"denied";function tj(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(QS=e,e))}const nj={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},rj={complete:"The agent has finished its work.",waiting_for_user:"The agent needs your input to continue.",phase_done:"The build phase completed successfully.",phase_blocked:"The build phase is blocked and needs intervention.",new_message:"A new assistant message is arriving."};function sj(e){typeof Notification>"u"||QS==="granted"&&(document.hasFocus()||new Notification(nj[e],{body:rj[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function Il(e,t){const{settings:n}=zi.getState(),r=ZS(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??YS[e],o=ej(a);o.currentTime=0,o.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&sj(e)}const ij=e=>Il("complete",e),aj=e=>Il("phase_done",e),oj=e=>Il("phase_blocked",e),a_=e=>Il("waiting_for_user",e),lj=e=>Il("new_message",e);let Zo=!1,Vr=null;const Hf=new Set,en={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Va=null,Bn=null;function Ff(){Va===null&&(Va=requestAnimationFrame(()=>{Va=null,Bn==null||Bn()}))}function Ai(){Va!==null&&(cancelAnimationFrame(Va),Va=null)}function Gt(e,t){return t!==null&&e.sessionId===t}function cj(e,t,n){return e.id!==void 0||Gt(e,t)||n===!0&&e.sessionId!==void 0}function uj(e,t){return e.includes(t)?e:[...e,t]}function Qo(e,t){return e.filter(n=>n!==t)}function dj(e,t){const n=e.find(a=>a.id===t.id),r=n?{...n,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:t.messages.length,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(a=>a.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(a=>a.status.type==="passed").length,messageCount:t.messages.length};return n?e.map(a=>a.id===t.id?r:a):[r,...e]}function o_(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,o=t.find(u=>u.id===r.id);return{...r,title:r.title??(o==null?void 0:o.title),mode:(a==null?void 0:a.mode)??(o==null?void 0:o.mode)??r.mode,phase:(a==null?void 0:a.phase)??(o==null?void 0:o.phase)??r.phase,isRunning:r.isRunning&&(o==null?void 0:o.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}const l_=new Map;function fl(e,t){var o;const n=t===((o=e.currentSession)==null?void 0:o.id)?e.currentSession:null,r=e.sessions.find(u=>u.id===t),a=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function hj(e,t){if(e.type==="chat.done"){const n=e.payload,r=fl(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&ij(a),n.reason==="waiting_for_user"&&a_(a);return}if(e.type==="chat.path_confirmation"){const n=fl(t,e.sessionId);a_(n);return}if(e.type==="task.completed"){const n=fl(t,e.sessionId);aj(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=l_.get(e.sessionId)??null;if(l_.set(e.sessionId,n.phase),r===n.phase)return;const a=fl(t,e.sessionId);n.phase==="blocked"&&oj(a)}}const ye=gr((e,t)=>(Bn=()=>{const n=en;if(!n.messageId)return;const r=n.deltaContent.length>0,a=n.thinkingContent.length>0,o=n.toolOutput.length>0;if(!r&&!a&&!o)return;const u=n.deltaContent,d=n.thinkingContent,p=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(f=>{var g;const m=f.streamingMessage;if(m&&m.id===n.messageId){const v={...m};if(r&&(v.content=v.content+u),a&&(v.thinkingContent=(v.thinkingContent??"")+d),o){const b=new Set;v.toolCalls=(g=v.toolCalls)==null?void 0:g.map(S=>{const j=p.filter(C=>C.callId===S.id);return j.length===0?S:(b.add(S.id),{...S,streamingOutput:[...S.streamingOutput??[],...j.map(C=>({stream:C.stream,content:C.content,timestamp:Date.now()}))]})});const _=p.filter(S=>!b.has(S.callId));_.length>0&&en.toolOutput.push(..._)}return{streamingMessage:v}}if(o){const v=new Set,b=f.messages.map(S=>{var C;if(S.id!==n.messageId)return S;const j=(C=S.toolCalls)==null?void 0:C.map(E=>{const A=p.filter(O=>O.callId===E.id);return A.length===0?E:(v.add(E.id),{...E,streamingOutput:[...E.streamingOutput??[],...A.map(O=>({stream:O.stream,content:O.content,timestamp:Date.now()}))]})});return{...S,toolCalls:j}}),_=p.filter(S=>!v.has(S.callId));return _.length>0&&en.toolOutput.push(..._),{messages:b}}return f})},{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestion:null,visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let r=!1;try{r=(await(await ke("/api/auth")).json()).requiresAuth}catch{}if(r&&!tn.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}tn.onStatusChange(a=>{var o;if(e({connectionStatus:a}),a==="connected"){t().listSessions(void 0),Ut.getState().listProjects();const u=(o=t().currentSession)==null?void 0:o.id;u&&t().loadSession(u)}});try{if(await tn.connect(),!Zo){Zo=!0;const a=t().handleServerMessage;Vr=tn.subscribe(a)}}catch(a){console.error("Failed to connect:",a);const o=tn.getLastCloseCode();if(!tn.hasToken()&&(o===1006||o===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Vr&&(Vr(),Vr=null),Zo=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{tn.disconnect(),Vr&&(Vr(),Vr=null),Zo=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{tn.disconnect(),Vr&&(Vr(),Vr=null),Zo=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async n=>{try{const r=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:n})});if(!r.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:a}=await r.json();tn.setToken(a),e({showPasswordModal:!1}),t().connect();const{listProjects:o}=Ut.getState(),{fetchConfig:u}=Mt.getState();o(),u(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{tn.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,r)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const o=await ke("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,title:r})});if(!o.ok)return e({pendingSessionCreate:!1}),null;const u=await o.json();return tn.send("session.load",{sessionId:u.session.id}),u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{try{const r=t().currentSession;!r||r.id!==n?(Ai(),e({currentSession:null,unreadSessionIds:Qo(t().unreadSessionIds,n),subAgentContextStates:{},messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmations:[],queuedMessages:[],abortInProgress:!1,error:null,pendingSessionCreate:!1})):e({unreadSessionIds:Qo(t().unreadSessionIds,n)});const a=await ke(`/api/sessions/${n}`);if(!a.ok)return;const o=await a.json();e({currentSession:o.session,messages:o.messages??[],contextState:o.contextState,queuedMessages:o.queueState??[]}),tn.send("session.load",{sessionId:n});try{const u=await ke(`/api/sessions/${n}/background-processes`);if(u.ok){const d=await u.json();vl.getState().setProcesses(d.processes??[])}}catch{}}catch{}},listSessions:async(n,r=20)=>{try{const a=new URLSearchParams;a.set("limit",String(r)),n&&a.set("projectId",n);const u=await(await ke(`/api/sessions?${a.toString()}`)).json(),d=u.sessions??[];e(p=>({sessions:o_(d,p.sessions,p.currentSession),sessionsHasMore:n?u.hasMore??!1:!0}))}catch{}},loadMoreSessions:async n=>{const r=t();if(!(r.sessionsPaginationLoading||!r.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const a=new URLSearchParams;a.set("limit","20"),a.set("offset",String(r.sessions.length)),a.set("projectId",n);const u=await(await ke(`/api/sessions?${a.toString()}`)).json(),d=u.sessions??[];e(p=>({sessions:[...p.sessions,...d.map(f=>{const m=p.sessions.find(g=>g.id===f.id);return(m==null?void 0:m.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:u.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var r;try{return(await ke(`/api/sessions/${n}`,{method:"DELETE"})).ok?(await t().listSessions(),((r=t().currentSession)==null?void 0:r.id)===n&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(n,r)=>{var a;try{const o=await ke(`/api/sessions/${n}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r})});if(!o.ok)return!1;if(await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===n){const d=await o.json();d.session&&e({currentSession:d.session})}return!0}catch{return!1}},deleteAllSessions:async n=>{try{return(await ke(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{Ai(),e(n=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingSessionCreate:!1,unreadSessionIds:n.currentSession?Qo(n.unreadSessionIds,n.currentSession.id):n.unreadSessionIds}))},sendMessage:async(n,r,a)=>{var u;const o=(u=t().currentSession)==null?void 0:u.id;if(o){e({streamingMessageId:null});try{const p=await(await ke(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:r,messageKind:a==null?void 0:a.messageKind})})).json();p.queueState&&e({queuedMessages:p.queueState})}catch(d){console.error("Error sending message:",d)}}},stopGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n&&!t().abortInProgress){Ai(),Bn==null||Bn(),e({abortInProgress:!0});try{await ke(`/api/sessions/${n}/stop`,{method:"POST"})}catch(a){console.error("Error stopping generation:",a)}}},continueGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n){e({streamingMessageId:null});try{await ke(`/api/sessions/${n}/continue`,{method:"POST"})}catch(a){console.error("Error continuing generation:",a)}}},launchRunner:(n,r,a)=>{e({streamingMessageId:null});const o={};n!=null&&n.trim()&&(o.content=n),r&&r.length>0&&(o.attachments=r),a&&(o.workflowId=a),tn.send("runner.launch",o)},switchMode:async n=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{const o=await ke(`/api/sessions/${r}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:n})});if(!o.ok){console.error("Failed to switch mode:",await o.json());return}const u=await o.json();u.session&&e({currentSession:u.session})}catch(o){console.error("Error switching mode:",o)}},switchDangerLevel:async n=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{const o=await ke(`/api/sessions/${r}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:n})});if(!o.ok){console.error("Failed to switch danger level:",await o.json());return}const u=await o.json();u.session&&e({currentSession:u.session})}catch(o){console.error("Error switching danger level:",o)}},acceptAndBuild:(n,r,a)=>{var d;e({streamingMessageId:null});const o={};n&&(o.workflowId=n),r!=null&&r.trim()&&(o.content=r),a&&a.length>0&&(o.attachments=a);const u=(d=t().currentSession)==null?void 0:d.id;u&&ke(`/api/sessions/${u}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{tn.send("runner.launch",o)})},editCriteria:async n=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{const o=await ke(`/api/sessions/${r}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:n})});o.ok||console.error("Failed to update criteria:",await o.json())}catch(o){console.error("Error updating criteria:",o)}},compactContext:()=>{tn.send("context.compact",{})},setSessionProvider:async(n,r)=>{var a,o;try{const u=(a=t().currentSession)==null?void 0:a.id;if(!u)return null;const d=await ke(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...r?{model:r}:{}})});if(!d.ok)return null;const p=await d.json();if(e({currentSession:p.session,messages:p.messages??[],contextState:p.contextState}),(o=p.session)!=null&&o.providerId){const f=Mt.getState();f.providers.find(g=>g.id===p.session.providerId)&&f.syncFromSession(p.session.providerId,p.session.providerModel??"")}return p.session}catch{return null}},updateContextState:n=>{e({contextState:n})},updateSubAgentContextState:(n,r)=>{e(a=>({subAgentContextStates:{...a.subAgentContextStates,[n]:r}}))},clearSubAgentContextState:n=>{e(r=>{const a={...r.subAgentContextStates};return delete a[n],{subAgentContextStates:a}})},confirmPath:async(n,r,a=!1)=>{var u;const o=(u=t().currentSession)==null?void 0:u.id;if(o)try{await ke(`/api/sessions/${o}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:r,alwaysAllow:a})})}catch(d){console.error("Error confirming path:",d)}},answerQuestion:async(n,r)=>{var o;const a=(o=t().currentSession)==null?void 0:o.id;if(a){try{await ke(`/api/sessions/${a}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:r})})}catch(u){console.error("Error answering question:",u)}e({pendingQuestion:null})}},queueAsap:async(n,r,a)=>{var u;const o=(u=t().currentSession)==null?void 0:u.id;if(o)try{const p=await(await ke(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:r,messageKind:a})})).json();p.queueState&&e({queuedMessages:p.queueState})}catch(d){console.error("Error queueing ASAP message:",d)}},queueCompletion:async(n,r,a)=>{var u;const o=(u=t().currentSession)==null?void 0:u.id;if(o)try{const p=await(await ke(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:r,messageKind:a})})).json();p.queueState&&e({queuedMessages:p.queueState})}catch(d){console.error("Error queueing completion message:",d)}},cancelQueued:async n=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{const u=await(await ke(`/api/sessions/${r}/queue/${n}`,{method:"DELETE"})).json();u.queueState&&e({queuedMessages:u.queueState})}catch(o){console.error("Error canceling queued message:",o)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{var u,d,p,f,m,g,v,b,_,S,j,C,E,A,O,z,B,Y,ee,ie,D,$,H,U,q;const r=t();hj(n,r);const a=((u=r.currentSession)==null?void 0:u.id)??null,o=()=>{const T=n.sessionId;!T||T===a||e(N=>({unreadSessionIds:uj(N.unreadSessionIds,T)}))};switch(n.type){case"session.state":{const T=n.payload;if(!cj(n,a,r.pendingSessionCreate))break;Ai();const N=T.messages.find(I=>I.isStreaming)??null,F=t().pendingSessionCreate===!0;if(e({currentSession:T.session,sessions:dj(t().sessions,T.session),unreadSessionIds:Qo(t().unreadSessionIds,T.session.id),messages:T.messages,streamingMessageId:(N==null?void 0:N.id)??null,streamingMessage:N,currentTodos:[],pendingPathConfirmations:T.pendingConfirmations??[],error:null,...F?{pendingSessionCreate:T.session.id}:{}}),T.session.providerId){const I=Mt.getState();I.providers.find(R=>R.id===T.session.providerId)&&I.syncFromSession(T.session.providerId,T.session.providerModel??"")}break}case"session.list":{const T=n.payload;e(N=>({sessions:o_(T.sessions,N.sessions,N.currentSession)}));break}case"session.deleted":{const T=n.payload;e(N=>({unreadSessionIds:Qo(N.unreadSessionIds,T.sessionId)})),t().listSessions();break}case"session.deletedAll":{t().listSessions();break}case"session.running":{const T=n.payload,N=n.sessionId,F=(d=t().currentSession)==null?void 0:d.id,I=N&&N!==F;e(J=>({sessions:J.sessions.map(R=>R.id===N?{...R,isRunning:T.isRunning}:R)})),I||e(J=>({currentSession:J.currentSession?{...J.currentSession,isRunning:T.isRunning}:null,...T.isRunning?{}:{abortInProgress:!1,queuedMessages:[]}}));break}case"chat.message":{if(!Gt(n,((p=t().currentSession)==null?void 0:p.id)??null)){o();break}const T=n.payload;e(N=>N.messages.some(F=>F.id===T.message.id)?N:{messages:[...N.messages,T.message],streamingMessageId:T.message.isStreaming?T.message.id:N.streamingMessageId,streamingMessage:T.message.isStreaming?T.message:N.streamingMessage});break}case"chat.message_updated":{if(!Gt(n,((f=t().currentSession)==null?void 0:f.id)??null)){o();break}const T=n.payload,N=T.updates.isStreaming===!1&&t().streamingMessageId===T.messageId;N&&(Ai(),Bn==null||Bn()),e(F=>{const I=F.streamingMessage,J=N;if(I&&I.id===T.messageId){const R={...I,...T.updates};return{messages:F.messages.map(P=>P.id===T.messageId?R:P),streamingMessageId:J?null:F.streamingMessageId,streamingMessage:J?null:{...I,...T.updates}}}return{messages:F.messages.map(R=>R.id===T.messageId?{...R,...T.updates}:R),streamingMessageId:J?null:F.streamingMessageId}});break}case"chat.delta":{if(!Gt(n,((m=t().currentSession)==null?void 0:m.id)??null)){o();break}const T=n.payload;if(!Hf.has(T.messageId)){Hf.add(T.messageId);const N=fl(t(),n.sessionId);lj(N)}en.messageId=T.messageId,en.deltaContent+=T.content,Ff();break}case"chat.thinking":{if(!Gt(n,((g=t().currentSession)==null?void 0:g.id)??null)){o();break}const T=n.payload;en.messageId=T.messageId,en.thinkingContent+=T.content,Ff();break}case"chat.tool_preparing":{if(!Gt(n,((v=t().currentSession)==null?void 0:v.id)??null)){o();break}const T=n.payload,N=t().streamingMessage;if(!N||N.id!==T.messageId||((b=N.toolCalls)==null?void 0:b.find((I,J)=>J===T.index)))return;e(I=>{const J=I.streamingMessage.preparingToolCalls??[],R=J.findIndex(V=>V.index===T.index);let P;return R>=0?P=J.map((V,L)=>L===R?{...V,arguments:T.arguments}:V):P=[...J,{index:T.index,name:T.name,...T.arguments?{arguments:T.arguments}:{}}],{streamingMessage:{...I.streamingMessage,preparingToolCalls:P}}});break}case"chat.tool_call":{if(!Gt(n,((_=t().currentSession)==null?void 0:_.id)??null)){o();break}const T=n.payload,N=F=>{var R;const I=(R=F.preparingToolCalls)==null?void 0:R.filter((P,V)=>{var L;return P.name===T.tool?(L=F.preparingToolCalls)==null?void 0:L.slice(0,V).some(W=>W.name===T.tool):!0}),J=en.toolOutput.filter(P=>P.callId===T.callId);return J.length>0&&(en.toolOutput=en.toolOutput.filter(P=>P.callId!==T.callId)),{...F,toolCalls:[...F.toolCalls??[],{id:T.callId,name:T.tool,arguments:T.args,startedAt:Date.now(),...J.length>0?{streamingOutput:J.map(P=>({stream:P.stream,content:P.content,timestamp:Date.now()}))}:{}}],...I&&I.length>0?{preparingToolCalls:I}:{preparingToolCalls:void 0}}};e(F=>{const I=F.streamingMessage;return I&&I.id===T.messageId?{streamingMessage:N(I)}:{messages:F.messages.map(J=>J.id===T.messageId?N(J):J)}});break}case"chat.tool_output":{if(!Gt(n,((S=t().currentSession)==null?void 0:S.id)??null)){o();break}const T=n.payload;en.messageId=T.messageId,en.toolOutput.push({messageId:T.messageId,callId:T.callId,stream:T.stream,content:T.output}),Ff();break}case"chat.tool_result":{if(!Gt(n,((j=t().currentSession)==null?void 0:j.id)??null)){o();break}const T=n.payload,N=F=>{var J;const I=(J=F.toolCalls)==null?void 0:J.map(R=>R.id===T.callId?{...R,result:T.result}:R);return{...F,toolCalls:I}};e(F=>{const I=F.streamingMessage;return I&&I.id===T.messageId?{streamingMessage:N(I)}:{messages:F.messages.map(J=>J.id===T.messageId?N(J):J)}});break}case"chat.vision_fallback":{if(!Gt(n,((C=t().currentSession)==null?void 0:C.id)??null)){o();break}const T=n.payload;e(N=>{const F=`${T.messageId}-${T.attachmentId}`,I={...N.visionFallbackByMessage};return I[F]={type:T.type,attachmentId:T.attachmentId,filename:T.filename,description:T.description},{visionFallbackByMessage:I}});break}case"chat.todo":{if(!Gt(n,((E=t().currentSession)==null?void 0:E.id)??null)){o();break}const T=n.payload;e({currentTodos:T.todos});break}case"chat.summary":{if(!Gt(n,((A=t().currentSession)==null?void 0:A.id)??null)){o();break}const T=n.payload;e(N=>({currentSession:N.currentSession?{...N.currentSession,summary:T.summary}:null}));break}case"chat.progress":{if(!Gt(n,((O=t().currentSession)==null?void 0:O.id)??null)){o();break}const T=n.payload;console.warn("Progress:",T.message,T.phase);break}case"chat.format_retry":{if(!Gt(n,((z=t().currentSession)==null?void 0:z.id)??null)){o();break}const T=n.payload;console.warn("Format retry:",T.attempt,"/",T.maxAttempts);break}case"chat.done":{if(!Gt(n,((B=t().currentSession)==null?void 0:B.id)??null)){o();break}Ai(),Bn==null||Bn();const T=n.payload,N=T.stats;en.messageId=null,en.deltaContent="",en.thinkingContent="",en.toolOutput=[],Hf.delete(T.messageId),e(F=>{const I=F.streamingMessage,J=I&&I.id===T.messageId?{...I,isStreaming:!1,stats:N??I.stats}:null;return{messages:F.messages.map(R=>R.id===T.messageId?J??{...R,isStreaming:!1,stats:N??R.stats,completeReason:T.reason}:R),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Gt(n,((Y=t().currentSession)==null?void 0:Y.id)??null)){o();break}Ai(),Bn==null||Bn();const T=n.payload;console.error("Chat error:",T.error,"recoverable:",T.recoverable),T.recoverable||(en.messageId=null,en.deltaContent="",en.thinkingContent="",en.toolOutput=[]),e(N=>({error:{code:"CHAT_ERROR",message:T.error},streamingMessageId:T.recoverable?N.streamingMessageId:null,...T.recoverable?{}:{messages:N.streamingMessage?N.messages.map(F=>F.id===N.streamingMessage.id?N.streamingMessage:F):N.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Gt(n,((ee=t().currentSession)==null?void 0:ee.id)??null)){o();break}const T=n.payload,N={callId:T.callId,tool:T.tool,paths:T.paths,workdir:T.workdir,reason:T.reason};e(F=>({pendingPathConfirmations:[...F.pendingPathConfirmations,N]}));break}case"chat.ask_user":{if(!Gt(n,((ie=t().currentSession)==null?void 0:ie.id)??null)){o();return}const T=n.payload;e({pendingQuestion:{callId:T.callId,question:T.question}});break}case"mode.changed":{if(!Gt(n,((D=t().currentSession)==null?void 0:D.id)??null)){o();break}const T=n.payload;e(N=>({currentSession:N.currentSession?{...N.currentSession,mode:T.mode}:null}));break}case"phase.changed":{const T=n.payload,N=n.sessionId,F=($=t().currentSession)==null?void 0:$.id,I=N&&N!==F;e(J=>({sessions:J.sessions.map(R=>R.id===N?{...R,phase:T.phase}:R)})),I||e(J=>({currentSession:J.currentSession?{...J.currentSession,phase:T.phase}:null}));break}case"criteria.updated":{if(!Gt(n,((H=t().currentSession)==null?void 0:H.id)??null)){o();break}const T=n.payload;e(N=>({currentSession:N.currentSession?{...N.currentSession,criteria:T.criteria}:null}));break}case"context.state":{const T=n.payload,N=Gt(n,((U=t().currentSession)==null?void 0:U.id)??null);T.subAgentId?N&&t().updateSubAgentContextState(T.subAgentId,T.context):N?e({contextState:T.context}):o();break}case"session.name_generated":{const T=n.payload,N=n.sessionId,F=(q=t().currentSession)==null?void 0:q.id;e(I=>{const J=I.sessions.map(P=>P.id===N?{...P,title:T.name,updatedAt:new Date().toISOString()}:P),R=F===N?I.currentSession?{...I.currentSession,title:T.name,updatedAt:new Date().toISOString()}:null:I.currentSession;return{sessions:J,currentSession:R}});break}case"queue.state":{const T=n.payload;e({queuedMessages:T.messages??[]});break}case"git.status":{const T=n.payload;e({gitStatus:{branch:T.branch,diff:T.diff}});break}case"devServer.output":case"devServer.state":{Qr.getState().handleMessage(n);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{vl.getState().handleMessage(n.type,n.payload);break}case"error":{const T=n.payload;console.error("Server error:",T),e({error:{code:T.code,message:T.message},streamingMessageId:null});break}}}}));function Mm(){return ye(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function fj(){return ye(e=>e.queuedMessages)}function pj(){return ye(e=>e.abortInProgress)}function mj(){const e=ye(r=>r.connect),t=ye(r=>r.connectionStatus),n=zi(r=>r.load);return k.useEffect(()=>{e()},[e]),k.useEffect(()=>{t==="connected"&&n()},[t,n]),{connectionStatus:t}}const gj="modulepreload",xj=function(e){return"/"+e},c_={},Cp=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(m=>Promise.resolve(m).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=u(n.map(f=>{if(f=xj(f),f in c_)return;c_[f]=!0;const m=f.endsWith(".css"),g=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const v=document.createElement("link");if(v.rel=m?"stylesheet":gj,m||(v.as="script"),v.crossOrigin="",v.href=f,p&&v.setAttribute("nonce",p),document.head.appendChild(v),m)return new Promise((b,_)=>{v.addEventListener("load",b),v.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(u){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=u,window.dispatchEvent(d),!d.defaultPrevented)throw u}return a.then(u=>{for(const d of u||[])d.status==="rejected"&&o(d.reason);return t().catch(o)})},JS=[{key:"color-bg-primary",category:"background",label:"Primary Background",defaultValue:"13 17 23"},{key:"color-bg-secondary",category:"background",label:"Secondary Background",defaultValue:"22 27 34"},{key:"color-bg-tertiary",category:"background",label:"Tertiary Background",defaultValue:"33 38 45"},{key:"color-primary",category:"surface",label:"Primary Surface",defaultValue:"10 10 10"},{key:"color-secondary",category:"surface",label:"Secondary Surface",defaultValue:"20 20 20"},{key:"color-text-primary",category:"text",label:"Primary Text",defaultValue:"139 148 158"},{key:"color-text-secondary",category:"text",label:"Secondary Text",defaultValue:"139 148 158"},{key:"color-text-muted",category:"text",label:"Muted Text",defaultValue:"72 79 88"},{key:"color-accent-primary",category:"accent",label:"Primary Accent",defaultValue:"88 166 255"},{key:"color-accent-success",category:"accent",label:"Success Accent",defaultValue:"63 185 80"},{key:"color-accent-warning",category:"accent",label:"Warning Accent",defaultValue:"210 153 34"},{key:"color-accent-error",category:"accent",label:"Error Accent",defaultValue:"248 81 73"},{key:"color-border",category:"border",label:"Border",defaultValue:"48 53 60"}],Jr=[{id:"dark",name:"Dark",tokens:{"color-bg-primary":"13 17 23","color-bg-secondary":"22 27 34","color-bg-tertiary":"33 38 45","color-primary":"10 10 10","color-secondary":"20 20 20","color-text-primary":"255 255 255","color-text-secondary":"139 148 158","color-text-muted":"72 79 88","color-accent-primary":"88 166 255","color-accent-success":"63 185 80","color-accent-warning":"210 153 34","color-accent-error":"248 81 73","color-border":"48 53 60"}},{id:"light",name:"Light",tokens:{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225"}},{id:"monokai",name:"Monokai",tokens:{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62"}},{id:"dracula",name:"Dracula",tokens:{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90"}},{id:"nord",name:"Nord",tokens:{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"76 86 106","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"76 86 106"}}];function u_(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const yn=gr((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:u_(),applySavedTheme:()=>{const{getSavedTheme:n,applyPreset:r,applyTokens:a}=t(),o=n();if(o)try{const u=JSON.parse(o);u.preset&&u.tokens?(r(u.preset),e({basePreset:u.preset}),a(u.tokens)):u.preset?r(u.preset):u.tokens&&a(u.tokens)}catch{r("dark")}else r("dark")},applyPreset:n=>{Jr.find(a=>a.id===n)&&(e({currentPreset:n,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1}),t().applyTheme())},startCustomizing:()=>{var a;const{currentPreset:n}=t(),r=((a=Jr.find(o=>o.id===n))==null?void 0:a.tokens)??{};e({basePreset:n,customTokens:{...r},isCustom:!0,isCustomizing:!0})},setCustomToken:(n,r)=>{e(a=>({customTokens:{...a.customTokens,[n]:r}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:n}=t();t().saveTheme(JSON.stringify({tokens:n})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:n=>{e({customTokens:n,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var u,d;const{basePreset:n,customTokens:r,isCustom:a}=t();if(a&&n)return{...((u=Jr.find(f=>f.id===n))==null?void 0:u.tokens)??{},...r};if(a)return{...JS.reduce((p,f)=>({...p,[f.key]:f.defaultValue}),{}),...r};const o=Jr.find(p=>p.id===t().currentPreset);return(o==null?void 0:o.tokens)??((d=Jr[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const n=t().getActiveTheme(),r=document.documentElement;Object.entries(n).forEach(([a,o])=>{r.style.setProperty(`--${a}`,o)})},getSavedTheme:()=>{try{const n=localStorage.getItem("openfox:theme");if(!n)return null;if(n[0]!=="{")return JSON.stringify({preset:n});const r=JSON.parse(n);if(r.preset)return JSON.stringify({preset:r.preset});if(r.tokens)return JSON.stringify({tokens:r.tokens})}catch{return null}return null},saveTheme:async n=>{localStorage.setItem("openfox:theme",n);const{useSettingsStore:r}=await Cp(async()=>{const{useSettingsStore:a}=await Promise.resolve().then(()=>Kv);return{useSettingsStore:a}},void 0);await r.getState().setSetting(Qe.DISPLAY_THEME,n)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[]})},addUserPreset:n=>{const{basePreset:r,customTokens:a,currentPreset:o}=t(),u={id:"custom-"+Date.now(),name:n,basePreset:r||o,tokens:{...a}},d=[...t().userPresets,u];e({userPresets:d}),t().saveUserPresets()},applyUserPreset:n=>{const r=t().userPresets[n];r&&(e({currentPreset:r.basePreset,basePreset:r.basePreset,customTokens:{...r.tokens},isCustom:!0,isCustomizing:!1}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:r.basePreset,tokens:r.tokens})).catch(()=>{}))},deleteUserPreset:n=>{const r=t().userPresets.filter((a,o)=>o!==n);e({userPresets:r}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:u_()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),Cp(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>Kv);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting(Qe.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function yj({className:e="w-5 h-5"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function e1({className:e="w-3.5 h-3.5"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function bj({className:e="w-5 h-5"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function vj({className:e="w-3 h-3 text-text-muted"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function _j({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function ns({className:e="w-3.5 h-3.5 text-text-muted"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function rs({className:e="w-3 h-3 text-text-muted",rotate:t}){return l.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:t!==void 0?{transform:`rotate(${t}deg)`}:void 0,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function Sj({className:e="w-4 h-4"}){return l.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function Rm({className:e="w-3.5 h-3.5"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function wj({className:e="w-3 h-3"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function Lm({className:e="w-4 h-4"}){return l.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[l.jsx("circle",{cx:"12",cy:"5",r:"2"}),l.jsx("circle",{cx:"12",cy:"12",r:"2"}),l.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Qu({className:e="w-3.5 h-3.5"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})})}function Om({className:e="w-5 h-5 text-accent-primary"}){return l.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}function kj({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})})}function Cj({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function Nj({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})})}function jj({className:e="w-3 h-3"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Ej({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function d_({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function t1({className:e="w-[18px] h-[18px]"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Tj({className:e="w-4 h-4"}){return l.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),l.jsx("path",{d:"M9.5 2h4.5v4.5"}),l.jsx("path",{d:"M14 2L7.5 8.5"})]})}function Aj({className:e="w-3 h-3",color:t}){return l.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{d:"M8 5v14l11-7z"})})}function Ga({className:e="w-3 h-3 text-accent-primary"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Dj({className:e="w-5 h-5"}){return l.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}function n1({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function Mj({className:e="w-4 h-4"}){return l.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function Rj({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return l.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[l.jsx("title",{children:"Running"}),l.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),l.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Lj({className:e="w-3.5 h-3.5 text-text-muted"}){return l.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"})})}function Oj({className:e="w-3.5 h-3.5 text-text-muted"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}function r1({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function Ij({className:e="w-3.5 h-3.5 shrink-0",color:t}){return l.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Bj({className:e="w-4 h-4"}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("polyline",{points:"4 17 10 11 4 5"}),l.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Ju({className:e="w-3.5 h-3.5"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function Im(){return l.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function zj({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Np({className:e="w-2.5 h-2.5"}){return l.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function Bm({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})}function s1({className:e="w-4 h-4"}){return l.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.55 0 0 1 0-.708z"})})}function jp(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function h_(e,t){const n=tn.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:jp(),type:e,payload:t}))}const Br=gr((e,t)=>({isOpen:!1,sessions:[],workdir:null,setOpen:n=>e({isOpen:n}),toggleOpen:()=>e(n=>({isOpen:!n.isOpen})),setWorkdir:n=>e({workdir:n}),fetchSessions:async n=>{if(!n){e({sessions:[]});return}try{const r=await ke(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const o=tn.ws;if(o&&o.readyState===WebSocket.OPEN)for(const u of a)o.send(JSON.stringify({id:jp(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await ke("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(a.ok){const o=await a.json();e(d=>({sessions:[...d.sessions,o]}));const u=tn.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:jp(),type:"terminal.subscribe",payload:{sessionId:o.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{h_("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{h_("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await ke(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(o=>o.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(a=>{const o=a.sessions.filter(u=>u.id!==r);return o.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:o}});break}}}}));tn.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&Br.getState().handleMessage(e)});var Ja=BS();const ed=k.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},a)=>l.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:l.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));ed.displayName="IconButton";const Pj="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",Ya=k.forwardRef((e,t)=>l.jsx(ed,{ref:t,icon:Pj,title:"Edit",...e}));Ya.displayName="EditButton";const Hj="M6 18L18 6M6 6l12 12",zm=k.forwardRef((e,t)=>l.jsx(ed,{ref:t,icon:Hj,...e}));zm.displayName="CloseButton";const Fj={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[90vh] flex-1"};function Et({label:e,title:t,size:n="md",minHeight:r,children:a,footer:o,className:u,onClose:d,isOpen:p,closeOnBackdropClick:f=!0,closeOnEscape:m=!0,showCloseButton:g=!0}){const[v,b]=k.useState(!1),_=p!==void 0,S=_?p:v,j=k.useCallback(()=>{_||b(!0)},[_]),C=k.useCallback(()=>{_||b(!1),d==null||d()},[_,d]);k.useEffect(()=>{if(!S||!m)return;const A=O=>{O.key==="Escape"&&(O.stopPropagation(),C())};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[S,C,m]);const E=e&&(typeof e=="string"?l.jsx("button",{type:"button",onClick:j,className:u,children:e}):l.jsx("span",{onClick:j,className:u,style:{cursor:"pointer"},children:e}));return l.jsxs(l.Fragment,{children:[E,S&&(typeof document<"u"?Ja.createPortal(l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[l.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:f?C:void 0}),l.jsxs("div",{className:`relative w-full ${Fj[n]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||g)&&l.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&l.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),g&&l.jsx(zm,{onClick:C,className:"ml-auto","aria-label":"Close"})]}),l.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:r?{minHeight:r}:void 0,children:a}),o&&l.jsx("div",{className:"px-4 py-3 border-t border-border",children:o})]})]}),document.body):null)]})}const Ye=k.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...a},o)=>{const u="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},p={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return l.jsx("button",{ref:o,className:`${u} ${d[e]} ${p[t]} ${n}`,...a,children:r})});Ye.displayName="Button";function $j({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return l.jsxs("div",{className:"relative",children:[l.jsx("select",{value:a,disabled:n,onChange:o=>{const u=o.target.value;r(u===t?null:u)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:JN.map(({url:o,label:u})=>l.jsx("option",{value:o,title:u,children:u.split(" ")[0]},o))}),l.jsx(rs,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const f_=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function Uj(){const e=zi(p=>p.settings),t=zi(p=>p.update),n=zi(p=>p.updateEvent),r=zi(p=>p.updateAgentOverride),a=zi(p=>p.load);k.useEffect(()=>{a()},[a]);const o=async()=>{await tj()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(p,f,m,g)=>{p==="general"?n(f,{[m]:g}):r(p,f,{[m]:g})},d=(p,f,m)=>{p==="general"?n(f,{customSoundUrl:m}):r(p,f,{customSoundUrl:m})};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),l.jsx(p_,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:p=>t({...e,soundEnabled:p})}),l.jsx(p_,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:p=>{p&&typeof Notification<"u"&&Notification.permission!=="granted"?o():t({...e,browserNotificationEnabled:p})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&l.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),l.jsx("div",{className:"border border-border rounded overflow-hidden",children:l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:l.jsxs("tr",{className:"border-b border-border",children:[l.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),f_.map(p=>l.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:p.label},p.key))]})}),l.jsx("tbody",{children:QN.map(p=>l.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[l.jsx("td",{className:"px-3 py-2",children:l.jsx("div",{className:"text-text-primary text-xs",children:p.label})}),f_.map(f=>{const m=ZS(e,p.key,f.key==="general"?void 0:f.key),g=YS[p.key];return l.jsx("td",{className:"px-2 py-2 align-top",children:l.jsxs("div",{className:"flex flex-col items-center gap-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:l.jsx("input",{type:"checkbox",checked:m.soundEnabled,onChange:v=>u(f.key,p.key,"soundEnabled",v.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),l.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:l.jsx("input",{type:"checkbox",checked:m.browserNotification,onChange:v=>u(f.key,p.key,"browserNotification",v.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),m.soundEnabled&&e.soundEnabled&&l.jsx($j,{value:m.customSoundUrl,defaultUrl:g,disabled:!e.soundEnabled,onChange:v=>d(f.key,p.key,v)})]})},f.key)})]},p.key))})]})})]})]})}function p_({label:e,description:t,checked:n,onChange:r}){return l.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[l.jsx("div",{className:"pt-0.5",children:l.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),r(!n)},children:l.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})}),l.jsxs("div",{children:[l.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),l.jsx("div",{className:"text-xs text-text-muted",children:t})]})]})}async function Pm(e,t,n){t({loading:!0});try{const a=await(await ke(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const Kr=gr((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchSkills:async()=>{await Pm("/api/skills",e,!0)},toggleSkill:async n=>{try{const a=await(await ke(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(o=>({defaults:o.defaults.map(u=>u.id===n?{...u,enabled:a.enabled}:u),userItems:o.userItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u)}))}catch{}},fetchSkill:async n=>{try{const r=await ke(`/api/skills/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ke(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await di("POST","/api/skills",{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await di("PUT",`/api/skills/${n}`,r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await ke(`/api/skills/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(o=>({userItems:o.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>Zu(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),r)}));function Hm(){const[e,t]=k.useState({id:null,type:null}),n=k.useCallback(o=>t({id:o,type:"delete"}),[]),r=k.useCallback(()=>t({id:null,type:null}),[]),a=k.useCallback((o,u)=>e.id===o&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function Fm({onConfirm:e,onCancel:t}){return l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:e,className:"px-1.5 py-0.5 rounded text-xs hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),l.jsx("button",{onClick:t,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function $m({onClick:e}){return l.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete",children:l.jsx(Ju,{})})}function Nl({onClick:e}){return l.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:l.jsx(Rm,{})})}function Hi({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:o,mono:u}){return l.jsxs("div",{children:[l.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,o&&l.jsx("span",{className:"text-text-muted ml-1",children:o})]}),l.jsx("input",{value:t,onChange:d=>n(d.target.value),readOnly:a,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${u?"font-mono":""} ${a?"opacity-60":""}`})]})}function Wj({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return l.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[l.jsx(Ye,{variant:"secondary",onClick:e,children:"Cancel"}),l.jsx(Ye,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function Um({message:e}){return l.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function i1({label:e="Custom",children:t}){return l.jsxs("div",{children:[l.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),l.jsx("div",{className:"space-y-2",children:t})]})}function a1({description:e,onNew:t,newLabel:n="+ New"}){return l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("p",{className:"text-text-secondary text-sm",children:e}),l.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:l.jsx(Ye,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function o1({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:o,children:u}){return l.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[l.jsx("div",{className:"min-w-0 flex-1 mr-3",children:u}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&l.jsx("button",{onClick:n,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:l.jsx(Qu,{})}),l.jsx(Nl,{onClick:a}),!e&&r&&l.jsx(Ya,{onClick:r}),!e&&(t?l.jsx(Fm,{onConfirm:()=>{o==null||o()},onCancel:()=>{}}):l.jsx($m,{onClick:()=>o==null?void 0:o()}))]})]})}function qj({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:u,onDuplicate:d,onDelete:p}){return l.jsxs(o1,{isBuiltIn:r,isConfirmingDelete:a,onView:o,onEdit:u,onDuplicate:d,onDelete:p,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),l.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&l.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function l1({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:a}){return e&&!t?l.jsx("div",{className:"text-text-muted text-sm",children:n}):t?l.jsx("div",{className:"space-y-4",children:a}):r?l.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function c1({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:o="my-item",nameHint:u,readOnlyId:d=!1,readOnlyHint:p="(read-only)",onNameChange:f,onIdChange:m}){return l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsx(Hi,{label:n,value:e,onChange:f,placeholder:a,hint:u}),l.jsx(Hi,{label:r,value:t,onChange:m,readOnly:d,placeholder:o,hint:d?p:void 0,mono:!0})]})}function u1(e={}){const{initialData:t={}}=e,[n,r]=k.useState("list"),[a,o]=k.useState(null),[u,d]=k.useState(""),[p,f]=k.useState(!1),[m,g]=k.useState(t),v=k.useCallback(()=>{g(t),d(""),o(null)},[t]),b=k.useCallback(C=>{r(C),C==="list"&&v()},[v]),_=k.useCallback(C=>{g(E=>typeof C=="function"?C(E):C)},[]),S=k.useCallback((C,E={})=>{o(C),r("edit"),g({...E}),d("")},[]),j=k.useCallback(()=>{o(null),r("edit"),g(t),d("")},[t]);return{view:n,editingId:a,formError:u,saving:p,formData:m,setView:b,setEditingId:o,setFormError:d,setFormData:_,setSaving:f,resetForm:v,startEditing:S,startNew:j}}function Wm(){return l.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[l.jsx("span",{children:"⚠️"}),l.jsx("p",{className:"text-text-secondary",children:"Editing this value now will have the side-effect of invalidating KV-cache, causing your next message in current sessions to take a long time to process. Consider doing this between sessions."})]})}function m_({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:o,onDelete:u}){return l.jsx(qj,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:o,onDelete:u})}function Vj({isOpen:e}){const t=Kr(N=>N.defaults),n=Kr(N=>N.userItems),r=Kr(N=>N.projectItems),a=Kr(N=>N.loading),o=Kr(N=>N.fetchSkills),u=Kr(N=>N.fetchSkill),d=Kr(N=>N.fetchDefaultContent),p=Kr(N=>N.createSkill),f=Kr(N=>N.updateSkill),m=Kr(N=>N.deleteSkill),{view:g,editingId:v,formError:b,saving:_,formData:S,setView:j,setEditingId:C,setFormError:E,setFormData:A,setSaving:O}=u1(),{clearConfirm:z}=Hm();k.useEffect(()=>{e&&(o(),j("list"),C(null),z())},[e,o,z]);const B=(N,F,I,J)=>{A({name:J??N.metadata.name,id:I??N.metadata.id,description:N.metadata.description??"",version:N.metadata.version??"1.0.0",prompt:N.prompt,isReadOnly:F,destination:"user"})},Y=async N=>{if(t.some(I=>I.id===N)){const I=await d(N);if(!I)return;B(I,!0),C(N),E(""),j("edit")}else{const I=await u(N);if(!I)return;B(I,!0),C(N),E(""),j("edit")}},ee=async N=>{const I=t.some(R=>R.id===N)?await d(N):await u(N);if(!I)return;const J=`${N}-copy-${Date.now()}`;B(I,!1,J,`${I.metadata.name} (copy)`),C(null),E(""),j("edit")},ie=()=>{A({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),j("edit")},D=async N=>{const F=await u(N);F&&(B(F,!1),C(N),E(""),j("edit"))},$=async N=>{await m(N),z()},H=async()=>{const N=v??S.id;if(!N||!S.name||!S.prompt){E("Name, ID, and prompt are required.");return}O(!0),E("");const F={metadata:{id:N,name:S.name,description:S.description,version:S.version},prompt:S.prompt},I=v?await f(v,F):await p(F,S.destination);if(O(!1),!I.success){E(I.error??"Failed to save skill.");return}j("list")},U=N=>{A(F=>({...F,name:N})),v||A(F=>({...F,id:N.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},q=S.isReadOnly;if(g==="edit")return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"flex justify-between items-center mb-3",children:[l.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:q?S.name:v?"Edit Skill":"New Skill"}),l.jsx("button",{onClick:()=>j("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),b&&l.jsx(Um,{message:b}),l.jsxs("div",{className:"space-y-3 mb-3",children:[l.jsx(c1,{name:S.name,id:S.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:U,onIdChange:()=>{}}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsx(Hi,{label:"Description",value:S.description,onChange:N=>A(F=>({...F,description:N})),placeholder:"What this skill does...",readOnly:q}),l.jsx(Hi,{label:"Version",value:S.version,onChange:N=>A(F=>({...F,version:N})),placeholder:"1.0.0",readOnly:q})]})]}),l.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),l.jsx("textarea",{value:S.prompt,onChange:N=>A(F=>({...F,prompt:N.target.value})),readOnly:q,placeholder:"The system prompt for this skill...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!v&&l.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[l.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),l.jsxs("select",{value:S.destination,onChange:N=>A(F=>({...F,destination:N.target.value})),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[l.jsx("option",{value:"user",children:"Global config"}),l.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]}),l.jsx(Wm,{}),l.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[l.jsx(Ye,{variant:"secondary",onClick:()=>j("list"),children:"Cancel"}),q?l.jsx(Ye,{variant:"primary",onClick:()=>{A(N=>({...N,name:N.name+" (copy)",id:`${v}-copy-${Date.now()}`,isReadOnly:!1})),C(null)},children:"Duplicate & Customize"}):l.jsx(Ye,{variant:"primary",onClick:H,disabled:_||!S.name||!S.id||!S.prompt,children:_?"Saving...":"Save"})]})]});function T({items:N}){return N.map(F=>l.jsx(m_,{skill:F,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>Y(F.id),onEdit:()=>D(F.id),onDuplicate:()=>ee(F.id),onDelete:()=>$(F.id)},F.id))}return l.jsxs("div",{children:[l.jsx(a1,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:ie}),l.jsxs(l1,{loading:a,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),l.jsx("div",{className:"space-y-2",children:t.map(N=>l.jsx(m_,{skill:N,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>Y(N.id),onDuplicate:()=>ee(N.id)},N.id))})]}),n.length>0&&l.jsx(i1,{children:l.jsx(T,{items:n})}),r.length>0&&l.jsxs("div",{className:"mt-4",children:[l.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),l.jsx("div",{className:"space-y-2",children:l.jsx(T,{items:r})})]})]})]})}function Kj(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),r=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${r} ${a}`}return e}function Oi(e){const t=e.split(" ").map(n=>parseInt(n,10));return t.length===3&&t.every(n=>!isNaN(n))?`#${t.map(n=>(n??0).toString(16).padStart(2,"0")).join("")}`:e}function Gj({isOpen:e,isNew:t,basePresetId:n,presetName:r,initialTokens:a,onClose:o,onSave:u}){const[d,p]=k.useState(a),[f,m]=k.useState(r);k.useEffect(()=>{p(a),m(r)},[a,r]);const g=(j,C)=>{const E=C.startsWith("#")?Kj(C):C;p(A=>({...A,[j]:E}))},v=()=>{u(f.trim()||"Untitled",{...d})},b=JS.reduce((j,C)=>{const E=C.category;return j[E]||(j[E]=[]),j[E].push(C),j},{}),_={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},S=Jr.find(j=>j.id===n);return l.jsx(Et,{isOpen:e,onClose:o,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:l.jsxs("div",{className:"flex gap-2 justify-end",children:[l.jsx("button",{type:"button",onClick:o,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),l.jsx("button",{type:"button",onClick:v,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),l.jsx("input",{type:"text",value:f,onChange:j=>m(j.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!t&&l.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",l.jsx("span",{className:"text-text-primary",children:S==null?void 0:S.name})]}),Object.entries(b).map(([j,C])=>l.jsxs("div",{className:"space-y-3",children:[l.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:_[j]??j}),l.jsx("div",{className:"grid grid-cols-2 gap-3",children:C.map(E=>l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("label",{htmlFor:E.key,className:"text-xs text-text-muted",children:E.label}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"color",id:E.key,value:Oi(d[E.key]??E.defaultValue),onChange:A=>g(E.key,A.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent"}),l.jsx("input",{type:"text",value:d[E.key]??E.defaultValue,onChange:A=>g(E.key,A.target.value),className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},E.key))})]},j))]})})}function Yj(){const[e,t]=k.useState(null),n=yn(E=>E.currentPreset),r=yn(E=>E.isCustom),a=yn(E=>E.basePreset),o=yn(E=>E.userPresets),u=yn(E=>E.applyPreset),d=yn(E=>E.applyUserPreset),p=yn(E=>E.deleteUserPreset),f=yn(E=>E.saveTheme),m=E=>{u(E),f(JSON.stringify({preset:E})).catch(()=>{})},g=E=>{d(E)},v=E=>{const A=Jr.find(O=>O.id===E);A&&t({type:"new",presetIndex:o.length,basePresetId:E,presetName:A.name+" Copy",tokens:{...A.tokens}})},b=E=>{const A=o[E];if(!A)return;const O=Jr.find(B=>B.id===A.basePreset),z=O?{...O.tokens,...A.tokens}:A.tokens;t({type:"edit",presetIndex:E,basePresetId:A.basePreset,presetName:A.name,tokens:z})},_=(E,A)=>{if(!e)return;const O=[...o];if(e.type==="new"){const z={id:"custom-"+Date.now(),name:E,basePreset:e.basePresetId,tokens:A};O.push(z);const B=O.length-1;yn.setState({userPresets:O}),yn.getState().saveUserPresets(),yn.getState().applyUserPreset(B)}else{const z=O[e.presetIndex];z&&(O[e.presetIndex]={...z,name:E,tokens:A}),yn.setState({userPresets:O}),yn.getState().saveUserPresets(),yn.getState().applyUserPreset(e.presetIndex)}t(null)},S=()=>{t(null)},j=(E,A)=>{E.stopPropagation(),p(A)},C=r?a:n;return l.jsxs("div",{className:"space-y-4",children:[l.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),l.jsx("div",{className:"grid grid-cols-5 gap-2",children:Jr.map(E=>l.jsxs("div",{className:"relative group",children:[l.jsxs("button",{type:"button",onClick:()=>m(E.id),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${C===E.id&&!r?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[l.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:Oi(E.tokens["color-bg-primary"]??"#000"),borderColor:Oi(E.tokens["color-border"]??"#000")},children:l.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Oi(E.tokens["color-text-primary"]??"#fff")}})}),l.jsx("span",{className:"text-xs",children:E.name})]}),l.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),v(E.id)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:l.jsx("span",{className:"text-xs",children:"✎"})})]},E.id))}),o.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),l.jsx("div",{className:"grid grid-cols-5 gap-2",children:o.map((E,A)=>{const O=Jr.find(B=>B.id===E.basePreset),z=O?{...O.tokens,...E.tokens}:E.tokens;return l.jsxs("div",{className:"relative group",children:[l.jsxs("button",{type:"button",onClick:()=>g(A),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${r&&a===E.basePreset&&C===E.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[l.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:Oi(z["color-bg-primary"]??"#000"),borderColor:Oi(z["color-border"]??"#000")},children:l.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Oi(z["color-text-primary"]??"#fff")}})}),l.jsx("span",{className:"text-xs truncate w-full text-center",children:E.name})]}),l.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),b(A)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Edit",children:l.jsx("span",{className:"text-xs",children:"✎"})}),l.jsx("button",{type:"button",onClick:B=>j(B,A),className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-accent-error text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20",children:l.jsx(Bm,{className:"w-3 h-3"})})]},E.id)})})]}),e&&l.jsx(Gj,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:S,onSave:_})]})}function qm(){const e=wn(a=>a.settings),t=wn(a=>a.loading),n=wn(a=>a.getSetting),r=wn(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function Xj({isOpen:e,onClose:t}){const[n,r]=k.useState("instructions");return l.jsx(Et,{isOpen:e,onClose:t,title:"Settings",size:"xl",minHeight:"500px",children:l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[l.jsx(Jo,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),l.jsx(Jo,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),l.jsx(Jo,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),l.jsx(Jo,{label:"Display",active:n==="display",onClick:()=>r("display")}),l.jsx(Jo,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced")})]}),n==="instructions"&&l.jsx(eE,{isOpen:e}),n==="skills"&&l.jsx(Vj,{isOpen:e}),n==="notifications"&&l.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:l.jsx(Uj,{})}),n==="display"&&l.jsx(Jj,{}),n==="advanced"&&l.jsx(Zj,{onClose:t})]})})}function Zj({onClose:e}){const[,t]=Hr(),{settings:n,loading:r,getSetting:a,setSetting:o}=qm(),u=n[Qe.LLM_DISABLE_XML_PROTECTION]==="true",d=r[Qe.LLM_DISABLE_XML_PROTECTION]??!1;k.useEffect(()=>{a(Qe.LLM_DISABLE_XML_PROTECTION)},[a]);const p=async()=>{const m=String(!u);await o(Qe.LLM_DISABLE_XML_PROTECTION,m)};function f(){e(),t("/onboarding")}return d?l.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):l.jsxs("div",{className:"space-y-6",children:[l.jsx("div",{children:l.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Disable XML Tool Call Protection"}),l.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Allow the model to output XML tool call format instead of JSON function calls. Some third-party providers may require this."})]}),l.jsx("button",{type:"button",onClick:p,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${u?"bg-accent-primary":"bg-bg-tertiary"}`,children:l.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${u?"translate-x-6":"translate-x-1"}`})})]})}),l.jsx("hr",{className:"border-border"}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),l.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),l.jsx(Ye,{variant:"secondary",onClick:f,children:"Launch Onboarding"})]})]})}function Qj(){return l.jsx(Yj,{})}function Jj(){const{settings:e,loading:t,getSetting:n,setSetting:r}=qm(),a=t[Qe.DISPLAY_SHOW_THINKING]??!1,o=[{key:Qe.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Qe.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Qe.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Qe.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Qe.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"}],u=Object.fromEntries(o.map(m=>[m.key,e[m.key]??"true"])),[d,p]=k.useState(()=>Object.fromEntries(o.map(m=>[m.key,u[m.key]==="true"])));k.useEffect(()=>{o.forEach(m=>n(m.key))},[n]),k.useEffect(()=>{p(Object.fromEntries(o.map(m=>[m.key,u[m.key]==="true"])))},[JSON.stringify(u)]);const f=async m=>{const g=String(!d[m]);p(v=>({...v,[m]:!v[m]})),await r(m,g)};return a?l.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):l.jsxs("div",{className:"space-y-6",children:[l.jsx(Qj,{}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),l.jsx("div",{className:"space-y-4",children:o.map(({key:m,label:g,description:v})=>l.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-sm text-text-primary",children:g}),l.jsx("div",{className:"text-xs text-text-muted",children:v})]}),l.jsx("button",{type:"button",onClick:()=>f(m),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${d[m]?"bg-accent-primary":"bg-bg-tertiary"}`,children:l.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d[m]?"translate-x-6":"translate-x-1"}`})})]},m))})]})]})}function Jo({label:e,active:t,onClick:n}){return l.jsx("button",{onClick:n,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:e})}function eE({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=qm(),o=t[Qe.GLOBAL_INSTRUCTIONS]??"",u=n[Qe.GLOBAL_INSTRUCTIONS]??!1,[d,p]=k.useState(o),[f,m]=k.useState(!1),[g,v]=k.useState(!1);k.useEffect(()=>{e&&r(Qe.GLOBAL_INSTRUCTIONS)},[e,r]),k.useEffect(()=>{p(o),m(!1)},[o]);const b=async()=>{v(!0),await a(Qe.GLOBAL_INSTRUCTIONS,d),v(!1),m(!1)},_=()=>{p(o),m(!1)},S=u||g;return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),l.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),l.jsx("textarea",{value:d,onChange:j=>{p(j.target.value),m(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:S})]}),f&&l.jsx(Wm,{}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(Ye,{variant:"secondary",onClick:_,disabled:!f,children:"Discard"}),l.jsx(Ye,{variant:"primary",onClick:b,disabled:!f||S,children:g?"Saving...":"Save"})]})]})}/**
|
|
58
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
59
|
+
* @license MIT
|
|
60
|
+
*
|
|
61
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
62
|
+
* @license MIT
|
|
63
|
+
*
|
|
64
|
+
* Originally forked from (with the author's permission):
|
|
65
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
66
|
+
* http://bellard.org/jslinux/
|
|
67
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
68
|
+
*/var d1=Object.defineProperty,tE=Object.getOwnPropertyDescriptor,nE=(e,t)=>{for(var n in t)d1(e,n,{get:t[n],enumerable:!0})},Wt=(e,t,n,r)=>{for(var a=r>1?void 0:r?tE(t,n):t,o=e.length-1,u;o>=0;o--)(u=e[o])&&(a=(r?u(t,n,a):u(a))||a);return r&&a&&d1(t,n,a),a},Ne=(e,t)=>(n,r)=>t(n,r,e),g_="Terminal input",Ep={get:()=>g_,set:e=>g_=e},x_="Too much output to announce, navigate to rows manually to read",Tp={get:()=>x_,set:e=>x_=e};function rE(e){return e.replace(/\r?\n/g,"\r")}function sE(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function iE(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function aE(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");h1(a,t,n,r)}}function h1(e,t,n,r){e=rE(e),e=sE(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function f1(e,t,n){let r=n.getBoundingClientRect(),a=e.clientX-r.left-10,o=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function y_(e,t,n,r,a){f1(e,t,n),a&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ai(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function td(e,t=0,n=e.length){let r="";for(let a=t;a<n;++a){let o=e[a];o>65535?(o-=65536,r+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):r+=String.fromCharCode(o)}return r}var oE=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[r++]=(this._interim-55296)*1024+o-56320+65536:(t[r++]=this._interim,t[r++]=o),this._interim=0}for(let o=a;o<n;++o){let u=e.charCodeAt(o);if(55296<=u&&u<=56319){if(++o>=n)return this._interim=u,r;let d=e.charCodeAt(o);56320<=d&&d<=57343?t[r++]=(u-55296)*1024+d-56320+65536:(t[r++]=u,t[r++]=d);continue}u!==65279&&(t[r++]=u)}return r}},lE=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,a,o,u,d,p=0,f=0;if(this.interim[0]){let v=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let _=0,S;for(;(S=this.interim[++_]&63)&&_<4;)b<<=6,b|=S;let j=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,C=j-_;for(;f<C;){if(f>=n)return 0;if(S=e[f++],(S&192)!==128){f--,v=!0;break}else this.interim[_++]=S,b<<=6,b|=S&63}v||(j===2?b<128?f--:t[r++]=b:j===3?b<2048||b>=55296&&b<=57343||b===65279||(t[r++]=b):b<65536||b>1114111||(t[r++]=b)),this.interim.fill(0)}let m=n-4,g=f;for(;g<n;){for(;g<m&&!((a=e[g])&128)&&!((o=e[g+1])&128)&&!((u=e[g+2])&128)&&!((d=e[g+3])&128);)t[r++]=a,t[r++]=o,t[r++]=u,t[r++]=d,g+=4;if(a=e[g++],a<128)t[r++]=a;else if((a&224)===192){if(g>=n)return this.interim[0]=a,r;if(o=e[g++],(o&192)!==128){g--;continue}if(p=(a&31)<<6|o&63,p<128){g--;continue}t[r++]=p}else if((a&240)===224){if(g>=n)return this.interim[0]=a,r;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,r;if(u=e[g++],(u&192)!==128){g--;continue}if(p=(a&15)<<12|(o&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[r++]=p}else if((a&248)===240){if(g>=n)return this.interim[0]=a,r;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,r;if(u=e[g++],(u&192)!==128){g--;continue}if(g>=n)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=u,r;if(d=e[g++],(d&192)!==128){g--;continue}if(p=(a&7)<<18|(o&63)<<12|(u&63)<<6|d&63,p<65536||p>1114111)continue;t[r++]=p}}return r}},p1="",li=" ",Bl=class m1{constructor(){this.fg=0,this.bg=0,this.extended=new Ru}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new m1;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ru=class g1{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new g1(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Mr=class x1 extends Bl{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ru,this.combinedData=""}static fromCharData(t){let n=new x1;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ai(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(r-55296)*1024+a-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},b_="di$target",Ap="di$dependencies",$f=new Map;function cE(e){return e[Ap]||[]}function kn(e){if($f.has(e))return $f.get(e);let t=function(n,r,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");uE(t,n,a)};return t._id=e,$f.set(e,t),t}function uE(e,t,n){t[b_]===t?t[Ap].push({id:e,index:n}):(t[Ap]=[{id:e,index:n}],t[b_]=t)}var Wn=kn("BufferService"),y1=kn("CoreMouseService"),Ki=kn("CoreService"),dE=kn("CharsetService"),Vm=kn("InstantiationService"),b1=kn("LogService"),qn=kn("OptionsService"),v1=kn("OscLinkService"),hE=kn("UnicodeService"),zl=kn("DecorationService"),Dp=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var m;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],a=this._optionsService.rawOptions.linkHandler,o=new Mr,u=n.getTrimmedLength(),d=-1,p=-1,f=!1;for(let g=0;g<u;g++)if(!(p===-1&&!n.hasContent(g))){if(n.loadCell(g,o),o.hasExtendedAttrs()&&o.extended.urlId)if(p===-1){p=g,d=o.extended.urlId;continue}else f=o.extended.urlId!==d;else p!==-1&&(f=!0);if(f||p!==-1&&g===u-1){let v=(m=this._oscLinkService.getLinkData(d))==null?void 0:m.uri;if(v){let b={start:{x:p+1,y:e},end:{x:g+(!f&&g===u-1?1:0),y:e}},_=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let S=new URL(v);["http:","https:"].includes(S.protocol)||(_=!0)}catch{_=!0}_||r.push({text:v,range:b,activate:(S,j)=>a?a.activate(S,j,b):fE(S,j),hover:(S,j)=>{var C;return(C=a==null?void 0:a.hover)==null?void 0:C.call(a,S,j,b)},leave:(S,j)=>{var C;return(C=a==null?void 0:a.leave)==null?void 0:C.call(a,S,j,b)}})}f=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=g,d=o.extended.urlId):(p=-1,d=-1)}}t(r)}};Dp=Wt([Ne(0,Wn),Ne(1,qn),Ne(2,v1)],Dp);function fE(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
69
|
+
|
|
70
|
+
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var nd=kn("CharSizeService"),Ts=kn("CoreBrowserService"),Km=kn("MouseService"),As=kn("RenderService"),pE=kn("SelectionService"),_1=kn("CharacterJoinerService"),eo=kn("ThemeService"),S1=kn("LinkProviderService"),mE=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?v_.isErrorNoTelemetry(e)?new v_(e.message+`
|
|
71
|
+
|
|
72
|
+
`+e.stack):new Error(e.message+`
|
|
73
|
+
|
|
74
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},gE=new mE;function wu(e){xE(e)||gE.onUnexpectedError(e)}var Mp="Canceled";function xE(e){return e instanceof yE?!0:e instanceof Error&&e.name===Mp&&e.message===Mp}var yE=class extends Error{constructor(){super(Mp),this.name=this.message}};function bE(e){return new Error(`Illegal argument: ${e}`)}var v_=class Rp extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Rp)return t;let n=new Rp;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Lp=class w1 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,w1.prototype)}};function ur(e,t=0){return e[e.length-(1+t)]}var vE;(e=>{function t(o){return o<0}e.isLessThan=t;function n(o){return o<=0}e.isLessThanOrEqual=n;function r(o){return o>0}e.isGreaterThan=r;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(vE||(vE={}));function _E(e,t){let n=this,r=!1,a;return function(){return r||(r=!0,t||(a=e.apply(n,arguments))),a}}var k1;(e=>{function t(O){return O&&typeof O=="object"&&typeof O[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*a(O){yield O}e.single=a;function o(O){return t(O)?O:a(O)}e.wrap=o;function u(O){return O||n}e.from=u;function*d(O){for(let z=O.length-1;z>=0;z--)yield O[z]}e.reverse=d;function p(O){return!O||O[Symbol.iterator]().next().done===!0}e.isEmpty=p;function f(O){return O[Symbol.iterator]().next().value}e.first=f;function m(O,z){let B=0;for(let Y of O)if(z(Y,B++))return!0;return!1}e.some=m;function g(O,z){for(let B of O)if(z(B))return B}e.find=g;function*v(O,z){for(let B of O)z(B)&&(yield B)}e.filter=v;function*b(O,z){let B=0;for(let Y of O)yield z(Y,B++)}e.map=b;function*_(O,z){let B=0;for(let Y of O)yield*z(Y,B++)}e.flatMap=_;function*S(...O){for(let z of O)yield*z}e.concat=S;function j(O,z,B){let Y=B;for(let ee of O)Y=z(Y,ee);return Y}e.reduce=j;function*C(O,z,B=O.length){for(z<0&&(z+=O.length),B<0?B+=O.length:B>O.length&&(B=O.length);z<B;z++)yield O[z]}e.slice=C;function E(O,z=Number.POSITIVE_INFINITY){let B=[];if(z===0)return[B,O];let Y=O[Symbol.iterator]();for(let ee=0;ee<z;ee++){let ie=Y.next();if(ie.done)return[B,e.empty()];B.push(ie.value)}return[B,{[Symbol.iterator](){return Y}}]}e.consume=E;async function A(O){let z=[];for await(let B of O)z.push(B);return Promise.resolve(z)}e.asyncToArray=A})(k1||(k1={}));function Wi(e){if(k1.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function SE(...e){return It(()=>Wi(e))}function It(e){return{dispose:_E(()=>{e()})}}var C1=class N1{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Wi(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?N1.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};C1.DISABLE_DISPOSED_WARNING=!1;var ui=C1,Je=class{constructor(){this._store=new ui,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Je.None=Object.freeze({dispose(){}});var Xa=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},js=typeof window=="object"?window:globalThis,Op=class Ip{constructor(t){this.element=t,this.next=Ip.Undefined,this.prev=Ip.Undefined}};Op.Undefined=new Op(void 0);var zt=Op,__=class{constructor(){this._first=zt.Undefined,this._last=zt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===zt.Undefined}clear(){let e=this._first;for(;e!==zt.Undefined;){let t=e.next;e.prev=zt.Undefined,e.next=zt.Undefined,e=t}this._first=zt.Undefined,this._last=zt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new zt(e);if(this._first===zt.Undefined)this._first=n,this._last=n;else if(t){let a=this._last;this._last=n,n.prev=a,a.next=n}else{let a=this._first;this._first=n,n.next=a,a.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==zt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==zt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==zt.Undefined&&e.next!==zt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===zt.Undefined&&e.next===zt.Undefined?(this._first=zt.Undefined,this._last=zt.Undefined):e.next===zt.Undefined?(this._last=this._last.prev,this._last.next=zt.Undefined):e.prev===zt.Undefined&&(this._first=this._first.next,this._first.prev=zt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==zt.Undefined;)yield e.element,e=e.next}},wE=globalThis.performance&&typeof globalThis.performance.now=="function",kE=class j1{static create(t){return new j1(t)}constructor(t){this._now=wE&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ln;(e=>{e.None=()=>Je.None;function t(H,U){return g(H,()=>{},0,void 0,!0,void 0,U)}e.defer=t;function n(H){return(U,q=null,T)=>{let N=!1,F;return F=H(I=>{if(!N)return F?F.dispose():N=!0,U.call(q,I)},null,T),N&&F.dispose(),F}}e.once=n;function r(H,U,q){return f((T,N=null,F)=>H(I=>T.call(N,U(I)),null,F),q)}e.map=r;function a(H,U,q){return f((T,N=null,F)=>H(I=>{U(I),T.call(N,I)},null,F),q)}e.forEach=a;function o(H,U,q){return f((T,N=null,F)=>H(I=>U(I)&&T.call(N,I),null,F),q)}e.filter=o;function u(H){return H}e.signal=u;function d(...H){return(U,q=null,T)=>{let N=SE(...H.map(F=>F(I=>U.call(q,I))));return m(N,T)}}e.any=d;function p(H,U,q,T){let N=q;return r(H,F=>(N=U(N,F),N),T)}e.reduce=p;function f(H,U){let q,T={onWillAddFirstListener(){q=H(N.fire,N)},onDidRemoveLastListener(){q==null||q.dispose()}},N=new _e(T);return U==null||U.add(N),N.event}function m(H,U){return U instanceof Array?U.push(H):U&&U.add(H),H}function g(H,U,q=100,T=!1,N=!1,F,I){let J,R,P,V=0,L,G={leakWarningThreshold:F,onWillAddFirstListener(){J=H(Z=>{V++,R=U(R,Z),T&&!P&&(W.fire(R),R=void 0),L=()=>{let se=R;R=void 0,P=void 0,(!T||V>1)&&W.fire(se),V=0},typeof q=="number"?(clearTimeout(P),P=setTimeout(L,q)):P===void 0&&(P=0,queueMicrotask(L))})},onWillRemoveListener(){N&&V>0&&(L==null||L())},onDidRemoveLastListener(){L=void 0,J.dispose()}},W=new _e(G);return I==null||I.add(W),W.event}e.debounce=g;function v(H,U=0,q){return e.debounce(H,(T,N)=>T?(T.push(N),T):[N],U,void 0,!0,void 0,q)}e.accumulate=v;function b(H,U=(T,N)=>T===N,q){let T=!0,N;return o(H,F=>{let I=T||!U(F,N);return T=!1,N=F,I},q)}e.latch=b;function _(H,U,q){return[e.filter(H,U,q),e.filter(H,T=>!U(T),q)]}e.split=_;function S(H,U=!1,q=[],T){let N=q.slice(),F=H(R=>{N?N.push(R):J.fire(R)});T&&T.add(F);let I=()=>{N==null||N.forEach(R=>J.fire(R)),N=null},J=new _e({onWillAddFirstListener(){F||(F=H(R=>J.fire(R)),T&&T.add(F))},onDidAddFirstListener(){N&&(U?setTimeout(I):I())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return T&&T.add(J),J.event}e.buffer=S;function j(H,U){return(q,T,N)=>{let F=U(new E);return H(function(I){let J=F.evaluate(I);J!==C&&q.call(T,J)},void 0,N)}}e.chain=j;let C=Symbol("HaltChainable");class E{constructor(){this.steps=[]}map(U){return this.steps.push(U),this}forEach(U){return this.steps.push(q=>(U(q),q)),this}filter(U){return this.steps.push(q=>U(q)?q:C),this}reduce(U,q){let T=q;return this.steps.push(N=>(T=U(T,N),T)),this}latch(U=(q,T)=>q===T){let q=!0,T;return this.steps.push(N=>{let F=q||!U(N,T);return q=!1,T=N,F?N:C}),this}evaluate(U){for(let q of this.steps)if(U=q(U),U===C)break;return U}}function A(H,U,q=T=>T){let T=(...J)=>I.fire(q(...J)),N=()=>H.on(U,T),F=()=>H.removeListener(U,T),I=new _e({onWillAddFirstListener:N,onDidRemoveLastListener:F});return I.event}e.fromNodeEventEmitter=A;function O(H,U,q=T=>T){let T=(...J)=>I.fire(q(...J)),N=()=>H.addEventListener(U,T),F=()=>H.removeEventListener(U,T),I=new _e({onWillAddFirstListener:N,onDidRemoveLastListener:F});return I.event}e.fromDOMEventEmitter=O;function z(H){return new Promise(U=>n(H)(U))}e.toPromise=z;function B(H){let U=new _e;return H.then(q=>{U.fire(q)},()=>{U.fire(void 0)}).finally(()=>{U.dispose()}),U.event}e.fromPromise=B;function Y(H,U){return H(q=>U.fire(q))}e.forward=Y;function ee(H,U,q){return U(q),H(T=>U(T))}e.runAndSubscribe=ee;class ie{constructor(U,q){this._observable=U,this._counter=0,this._hasChanged=!1;let T={onWillAddFirstListener:()=>{U.addObserver(this)},onDidRemoveLastListener:()=>{U.removeObserver(this)}};this.emitter=new _e(T),q&&q.add(this.emitter)}beginUpdate(U){this._counter++}handlePossibleChange(U){}handleChange(U,q){this._hasChanged=!0}endUpdate(U){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function D(H,U){return new ie(H,U).emitter.event}e.fromObservable=D;function $(H){return(U,q,T)=>{let N=0,F=!1,I={beginUpdate(){N++},endUpdate(){N--,N===0&&(H.reportChanges(),F&&(F=!1,U.call(q)))},handlePossibleChange(){},handleChange(){F=!0}};H.addObserver(I),H.reportChanges();let J={dispose(){H.removeObserver(I)}};return T instanceof ui?T.add(J):Array.isArray(T)&&T.push(J),J}}e.fromObservableLight=$})(Ln||(Ln={}));var Bp=class zp{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${zp._idPool++}`,zp.all.add(this)}start(t){this._stopWatch=new kE,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Bp.all=new Set,Bp._idPool=0;var CE=Bp,NE=-1,E1=class T1{constructor(t,n,r=(T1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let a=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,a+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[o,u]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(d),console.warn(o);let p=new TE(d,o);this._errorHandler(p)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,a]of this._stacks)(!t||n<a)&&(t=[r,a],n=a);return t}};E1._idPool=1;var jE=E1,EE=class A1{constructor(t){this.value=t}static create(){let t=new Error;return new A1(t.stack??"")}print(){console.warn(this.value.split(`
|
|
75
|
+
`).slice(2).join(`
|
|
76
|
+
`))}},TE=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},AE=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},DE=0,Uf=class{constructor(e){this.value=e,this.id=DE++}},ME=2,RE,_e=class{constructor(e){var t,n,r,a;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new jE((e==null?void 0:e.onListenerError)??wu,((n=this._options)==null?void 0:n.leakWarningThreshold)??NE):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new CE(this._options._profName):void 0,this._deliveryQueue=(a=this._options)==null?void 0:a.deliveryQueue}dispose(){var e,t,n,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var u,d,p,f,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let g=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(g);let v=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],b=new AE(`${g}. HINT: Stack shows most frequent listener (${v[1]}-times)`,v[0]);return(((u=this._options)==null?void 0:u.onListenerError)||wu)(b),Je.None}if(this._disposed)return Je.None;t&&(e=e.bind(t));let r=new Uf(e),a;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=EE.create(),a=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Uf?(this._deliveryQueue??(this._deliveryQueue=new LE),this._listeners=[this._listeners,r]):this._listeners.push(r):((p=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||p.call(d,this),this._listeners=r,(m=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||m.call(f,this)),this._size++;let o=It(()=>{a==null||a(),this._removeListener(r)});return n instanceof ui?n.add(o):Array.isArray(n)&&n.push(o),o}),this._event}_removeListener(e){var a,o,u,d;if((o=(a=this._options)==null?void 0:a.onWillRemoveListener)==null||o.call(a,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||d.call(u,this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ME<=t.length){let p=0;for(let f=0;f<t.length;f++)t[f]?t[p++]=t[f]:r&&(this._deliveryQueue.end--,p<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=p}}_deliver(e,t){var r;if(!e)return;let n=((r=this._options)==null?void 0:r.onListenerError)||wu;if(!n){e.value(t);return}try{e.value(t)}catch(a){n(a)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,r,a;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof Uf)this._deliver(this._listeners,e);else{let o=this._deliveryQueue;o.enqueue(this,e,this._listeners.length),this._deliverQueue(o)}(a=this._perfMon)==null||a.stop()}hasListeners(){return this._size>0}},LE=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Pp=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new _e,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new _e,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Pp.INSTANCE=new Pp;var Gm=Pp;function OE(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Gm.INSTANCE.onDidChangeZoomLevel;function IE(e){return Gm.INSTANCE.getZoomFactor(e)}Gm.INSTANCE.onDidChangeFullscreen;var to=typeof navigator=="object"?navigator.userAgent:"",Hp=to.indexOf("Firefox")>=0,BE=to.indexOf("AppleWebKit")>=0,Ym=to.indexOf("Chrome")>=0,zE=!Ym&&to.indexOf("Safari")>=0;to.indexOf("Electron/")>=0;to.indexOf("Android")>=0;var Wf=!1;if(typeof js.matchMedia=="function"){let e=js.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=js.matchMedia("(display-mode: fullscreen)");Wf=e.matches,OE(js,e,({matches:n})=>{Wf&&t.matches||(Wf=n)})}var Wa="en",Fp=!1,$p=!1,ku=!1,D1=!1,cu,Cu=Wa,S_=Wa,PE,Ir,Fi=globalThis,Mn,LS;typeof Fi.vscode<"u"&&typeof Fi.vscode.process<"u"?Mn=Fi.vscode.process:typeof process<"u"&&typeof((LS=process==null?void 0:process.versions)==null?void 0:LS.node)=="string"&&(Mn=process);var OS,HE=typeof((OS=Mn==null?void 0:Mn.versions)==null?void 0:OS.electron)=="string",FE=HE&&(Mn==null?void 0:Mn.type)==="renderer",IS;if(typeof Mn=="object"){Fp=Mn.platform==="win32",$p=Mn.platform==="darwin",ku=Mn.platform==="linux",ku&&Mn.env.SNAP&&Mn.env.SNAP_REVISION,Mn.env.CI||Mn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,cu=Wa,Cu=Wa;let e=Mn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);cu=t.userLocale,S_=t.osLocale,Cu=t.resolvedLanguage||Wa,PE=(IS=t.languagePack)==null?void 0:IS.translationsConfigFile}catch{}D1=!0}else typeof navigator=="object"&&!FE?(Ir=navigator.userAgent,Fp=Ir.indexOf("Windows")>=0,$p=Ir.indexOf("Macintosh")>=0,(Ir.indexOf("Macintosh")>=0||Ir.indexOf("iPad")>=0||Ir.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ku=Ir.indexOf("Linux")>=0,(Ir==null?void 0:Ir.indexOf("Mobi"))>=0,Cu=globalThis._VSCODE_NLS_LANGUAGE||Wa,cu=navigator.language.toLowerCase(),S_=cu):console.error("Unable to resolve platform.");var M1=Fp,ts=$p,$E=ku,w_=D1,ss=Ir,ni=Cu,UE;(e=>{function t(){return ni}e.value=t;function n(){return ni.length===2?ni==="en":ni.length>=3?ni[0]==="e"&&ni[1]==="n"&&ni[2]==="-":!1}e.isDefaultVariant=n;function r(){return ni==="en"}e.isDefault=r})(UE||(UE={}));var WE=typeof Fi.postMessage=="function"&&!Fi.importScripts;(()=>{if(WE){let e=[];Fi.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,a=e.length;r<a;r++){let o=e[r];if(o.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),o.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),Fi.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var qE=!!(ss&&ss.indexOf("Chrome")>=0);ss&&ss.indexOf("Firefox")>=0;!qE&&ss&&ss.indexOf("Safari")>=0;ss&&ss.indexOf("Edg/")>=0;ss&&ss.indexOf("Android")>=0;var Ia=typeof navigator=="object"?navigator:{};w_||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ia&&Ia.clipboard&&Ia.clipboard.writeText,w_||Ia&&Ia.clipboard&&Ia.clipboard.readText;var Xm=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},qf=new Xm,k_=new Xm,C_=new Xm,VE=new Array(230),R1;(e=>{function t(d){return qf.keyCodeToStr(d)}e.toString=t;function n(d){return qf.strToKeyCode(d)}e.fromString=n;function r(d){return k_.keyCodeToStr(d)}e.toUserSettingsUS=r;function a(d){return C_.keyCodeToStr(d)}e.toUserSettingsGeneral=a;function o(d){return k_.strToKeyCode(d)||C_.strToKeyCode(d)}e.fromUserSettings=o;function u(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return qf.keyCodeToStr(d)}e.toElectronAccelerator=u})(R1||(R1={}));var KE=class L1{constructor(t,n,r,a,o){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof L1&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${n}${r}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new GE([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},GE=class{constructor(e){if(e.length===0)throw bE("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function YE(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return R1.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Hp)switch(t){case 59:return 85;case 60:if($E)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ts)return 57;break}else if(BE&&(ts&&t===93||!ts&&t===92))return 57;return VE[t]||0}var XE=ts?256:2048,ZE=512,QE=1024,JE=ts?2048:256,N_=class{constructor(e){var n;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=YE(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=XE),this.altKey&&(t|=ZE),this.shiftKey&&(t|=QE),this.metaKey&&(t|=JE),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new KE(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},j_=new WeakMap;function eT(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var tT=class{static getSameOriginWindowChain(e){let t=j_.get(e);if(!t){t=[],j_.set(e,t);let n=e,r;do r=eT(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,a=this.getSameOriginWindowChain(e);for(let o of a){let u=o.window.deref();if(n+=(u==null?void 0:u.scrollY)??0,r+=(u==null?void 0:u.scrollX)??0,u===t||!o.iframeElement)break;let d=o.iframeElement.getBoundingClientRect();n+=d.top,r+=d.left}return{top:n,left:r}}},uu=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=tT.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},E_=class{constructor(e,t=0,n=0){var a;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(Ym){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,u=e,d=((a=e.view)==null?void 0:a.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*d):this.deltaY=o.wheelDeltaY/120;else if(typeof u.VERTICAL_AXIS<"u"&&u.axis===u.VERTICAL_AXIS)this.deltaY=-u.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Hp&&!ts?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")zE&&M1?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*d):this.deltaX=o.wheelDeltaX/120;else if(typeof u.HORIZONTAL_AXIS<"u"&&u.axis===u.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Hp&&!ts?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},O1=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),nT;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof rT?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ln.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:O1})})(nT||(nT={}));var rT=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?O1:(this._emitter||(this._emitter=new _e),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Zm=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Lp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Lp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},sT=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Lp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=It(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},iT;(e=>{async function t(r){let a,o=await Promise.all(r.map(u=>u.then(d=>d,d=>{a||(a=d)})));if(typeof a<"u")throw a;return o}e.settled=t;function n(r){return new Promise(async(a,o)=>{try{await r(a,o)}catch(u){o(u)}})}e.withAsyncBody=n})(iT||(iT={}));var T_=class Tr{static fromArray(t){return new Tr(n=>{n.emitMany(t)})}static fromPromise(t){return new Tr(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Tr(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new Tr(async n=>{await Promise.all(t.map(async r=>{for await(let a of r)n.emitOne(a)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new _e,queueMicrotask(async()=>{let r={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(r)),this.resolve()}catch(a){this.reject(a)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ln.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Tr(async r=>{for await(let a of t)r.emitOne(n(a))})}map(t){return Tr.map(this,t)}static filter(t,n){return new Tr(async r=>{for await(let a of t)n(a)&&r.emitOne(a)})}filter(t){return Tr.filter(this,t)}static coalesce(t){return Tr.filter(t,n=>!!n)}coalesce(){return Tr.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return Tr.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};T_.EMPTY=T_.fromArray([]);var{getWindow:es,getWindowId:aT,onDidRegisterWindow:oT}=(function(){let e=new Map,t={window:js,disposables:new ui};e.set(js.vscodeWindowId,t);let n=new _e,r=new _e,a=new _e;function o(u,d){return(typeof u=="number"?e.get(u):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:r.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Je.None;let d=new ui,p={window:u,disposables:d.add(new ui)};return e.set(u.vscodeWindowId,p),d.add(It(()=>{e.delete(u.vscodeWindowId),r.fire(u)})),d.add(Fe(u,bn.BEFORE_UNLOAD,()=>{a.fire(u)})),n.fire(p),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:o,getWindow(u){var f;let d=u;if((f=d==null?void 0:d.ownerDocument)!=null&&f.defaultView)return d.ownerDocument.defaultView.window;let p=u;return p!=null&&p.view?p.view.window:js},getDocument(u){return es(u).document}}})(),lT=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Fe(e,t,n,r){return new lT(e,t,n,r)}var A_=function(e,t,n,r){return Fe(e,t,n,r)},Qm,cT=class extends sT{constructor(e){super(),this.defaultTarget=e&&es(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},D_=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){wu(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,a=o=>{n.set(o,!1);let u=e.get(o)??[];for(t.set(o,u),e.set(o,[]),r.set(o,!0);u.length>0;)u.sort(D_.sort),u.shift().execute();r.set(o,!1)};Qm=(o,u,d=0)=>{let p=aT(o),f=new D_(u,d),m=e.get(p);return m||(m=[],e.set(p,m)),m.push(f),n.get(p)||(n.set(p,!0),o.requestAnimationFrame(()=>a(p))),f}})();function uT(e){let t=e.getBoundingClientRect(),n=es(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var bn={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},dT=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=er(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=er(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=er(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=er(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=er(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=er(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=er(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=er(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=er(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=er(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=er(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=er(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=er(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=er(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function er(e){return typeof e=="number"?`${e}px`:e}function _l(e){return new dT(e)}var I1=class{constructor(){this._hooks=new ui,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(It(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=es(e)}this._hooks.add(Fe(o,bn.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Fe(o,bn.POINTER_UP,u=>this.stopMonitoring(!0)))}};function hT(e,t,n){let r=null,a=null;if(typeof n.value=="function"?(r="value",a=n.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",a=n.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;n[r]=function(...u){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,u)}),this[o]}}var Xr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Xr||(Xr={}));var pl=class In extends Je{constructor(){super(),this.dispatched=!1,this.targets=new __,this.ignoreTargets=new __,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ln.runAndSubscribe(oT,({window:t,disposables:n})=>{n.add(Fe(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(Fe(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(Fe(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:js,disposables:this._store}))}static addTarget(t){if(!In.isTouchDevice())return Je.None;In.INSTANCE||(In.INSTANCE=new In);let n=In.INSTANCE.targets.push(t);return It(n)}static ignoreTarget(t){if(!In.isTouchDevice())return Je.None;In.INSTANCE||(In.INSTANCE=new In);let n=In.INSTANCE.ignoreTargets.push(t);return It(n)}static isTouchDevice(){return"ontouchstart"in js||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,a=t.targetTouches.length;r<a;r++){let o=t.targetTouches.item(r);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:n,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[n],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let u=this.newGestureEvent(Xr.Start,o.target);u.pageX=o.pageX,u.pageY=o.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),a=Object.keys(this.activeTouches).length;for(let o=0,u=n.changedTouches.length;o<u;o++){let d=n.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let p=this.activeTouches[d.identifier],f=Date.now()-p.initialTimeStamp;if(f<In.HOLD_DELAY&&Math.abs(p.initialPageX-ur(p.rollingPageX))<30&&Math.abs(p.initialPageY-ur(p.rollingPageY))<30){let m=this.newGestureEvent(Xr.Tap,p.initialTarget);m.pageX=ur(p.rollingPageX),m.pageY=ur(p.rollingPageY),this.dispatchEvent(m)}else if(f>=In.HOLD_DELAY&&Math.abs(p.initialPageX-ur(p.rollingPageX))<30&&Math.abs(p.initialPageY-ur(p.rollingPageY))<30){let m=this.newGestureEvent(Xr.Contextmenu,p.initialTarget);m.pageX=ur(p.rollingPageX),m.pageY=ur(p.rollingPageY),this.dispatchEvent(m)}else if(a===1){let m=ur(p.rollingPageX),g=ur(p.rollingPageY),v=ur(p.rollingTimestamps)-p.rollingTimestamps[0],b=m-p.rollingPageX[0],_=g-p.rollingPageY[0],S=[...this.targets].filter(j=>p.initialTarget instanceof Node&&j.contains(p.initialTarget));this.inertia(t,S,r,Math.abs(b)/v,b>0?1:-1,m,Math.abs(_)/v,_>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(Xr.End,p.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===Xr.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>In.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Xr.Change||t.type===Xr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==r;)a++,o=o.parentElement;n.push([a,r])}n.sort((r,a)=>r[0]-a[0]);for(let[r,a]of n)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,a,o,u,d,p,f){this.handle=Qm(t,()=>{let m=Date.now(),g=m-r,v=0,b=0,_=!0;a+=In.SCROLL_FRICTION*g,d+=In.SCROLL_FRICTION*g,a>0&&(_=!1,v=o*a*g),d>0&&(_=!1,b=p*d*g);let S=this.newGestureEvent(Xr.Change);S.translationX=v,S.translationY=b,n.forEach(j=>j.dispatchEvent(S)),_||this.inertia(t,n,m,a,o,u+v,d,p,f+b)})}onTouchMove(t){let n=Date.now();for(let r=0,a=t.changedTouches.length;r<a;r++){let o=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let u=this.activeTouches[o.identifier],d=this.newGestureEvent(Xr.Change,u.initialTarget);d.translationX=o.pageX-ur(u.rollingPageX),d.translationY=o.pageY-ur(u.rollingPageY),d.pageX=o.pageX,d.pageY=o.pageY,this.dispatchEvent(d),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(o.pageX),u.rollingPageY.push(o.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};pl.SCROLL_FRICTION=-.005,pl.HOLD_DELAY=700,pl.CLEAR_TAP_COUNT_TIME=400,Wt([hT],pl,"isTouchDevice",1);var fT=pl,Jm=class extends Je{onclick(e,t){this._register(Fe(e,bn.CLICK,n=>t(new uu(es(e),n))))}onmousedown(e,t){this._register(Fe(e,bn.MOUSE_DOWN,n=>t(new uu(es(e),n))))}onmouseover(e,t){this._register(Fe(e,bn.MOUSE_OVER,n=>t(new uu(es(e),n))))}onmouseleave(e,t){this._register(Fe(e,bn.MOUSE_LEAVE,n=>t(new uu(es(e),n))))}onkeydown(e,t){this._register(Fe(e,bn.KEY_DOWN,n=>t(new N_(n))))}onkeyup(e,t){this._register(Fe(e,bn.KEY_UP,n=>t(new N_(n))))}oninput(e,t){this._register(Fe(e,bn.INPUT,t))}onblur(e,t){this._register(Fe(e,bn.BLUR,t))}onfocus(e,t){this._register(Fe(e,bn.FOCUS,t))}onchange(e,t){this._register(Fe(e,bn.CHANGE,t))}ignoreGesture(e){return fT.ignoreTarget(e)}},M_=11,pT=class extends Jm{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=M_+"px",this.domNode.style.height=M_+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new I1),this._register(A_(this.bgDomNode,bn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(A_(this.domNode,bn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new cT),this._pointerdownScheduleRepeatTimer=this._register(new Zm)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,es(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},mT=class Up{constructor(t,n,r,a,o,u,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,a=a|0,o=o|0,u=u|0,d=d|0),this.rawScrollLeft=a,this.rawScrollTop=d,n<0&&(n=0),a+n>r&&(a=r-n),a<0&&(a=0),o<0&&(o=0),d+o>u&&(d=u-o),d<0&&(d=0),this.width=n,this.scrollWidth=r,this.scrollLeft=a,this.height=o,this.scrollHeight=u,this.scrollTop=d}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Up(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Up(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:u,scrollHeightChanged:d,scrollTopChanged:p}}},gT=class extends Je{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new _e),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new mT(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var r;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(r=this._smoothScrolling)==null||r.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;t?r=new L_(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=L_.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},R_=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Vf(e,t){let n=t-e;return function(r){return e+n*bT(r)}}function xT(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var L_=class Wp{constructor(t,n,r,a){this.from=t,this.to=n,this.duration=a,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,r){if(Math.abs(t-n)>2.5*r){let a,o;return t<n?(a=t+.75*r,o=n-.75*r):(a=t-.75*r,o=n+.75*r),xT(Vf(t,a),Vf(o,n),.33)}return Vf(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),a=this.scrollTop(n);return new R_(r,a,!1)}return new R_(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return Wp.start(t,n,r)}static start(t,n,r){r=r+10;let a=Date.now()-10;return new Wp(t,n,a,r)}};function yT(e){return Math.pow(e,3)}function bT(e){return 1-yT(1-e)}var vT=class extends Je{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Zm)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},_T=140,B1=class extends Jm{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new vT(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new I1),this._shouldRender=!0,this.domNode=_l(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Fe(this.domNode.domNode,bn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new pT(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=_l(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Fe(this.slider.domNode,bn.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);n<=a&&a<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let a=uT(this.domNode.domNode);t=e.pageX-a.left,n=e.pageY-a.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),u=Math.abs(o-n);if(M1&&u>_T){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let d=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(d))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},z1=class qp{constructor(t,n,r,a,o,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new qp(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,a,o){let u=Math.max(0,r-t),d=Math.max(0,u-2*n),p=a>0&&a>r;if(!p)return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(r*d/a))),m=(d-f)/(a-r),g=o*m;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:m,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=qp._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},ST=class extends B1{constructor(e,t,n){let r=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new z1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,a.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},wT=class extends B1{constructor(e,t,n){let r=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new z1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,a.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},kT=500,O_=50,CT=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Vp=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,a=this._rear;do{let o=a===this._front?t:Math.pow(2,-r);if(t-=o,n+=this._memory[a].score*o,a===this._front)break;a=(this._capacity+a-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Ym){let n=es(t.browserEvent),r=IE(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let a=null,o=new CT(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(a=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,a)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),u=Math.abs(n.deltaX),d=Math.abs(n.deltaY),p=Math.max(Math.min(a,u),1),f=Math.max(Math.min(o,d),1),m=Math.max(a,u),g=Math.max(o,d);m%p===0&&g%f===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Vp.INSTANCE=new Vp;var NT=Vp,jT=class extends Jm{constructor(e,t,n){super(),this._onScroll=this._register(new _e),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new _e),this.onWillScroll=this._onWillScroll.event,this._options=TT(t),this._scrollable=n,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let r={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new wT(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new ST(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=_l(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=_l(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=_l(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Zm),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Wi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ts&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new E_(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Wi(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new E_(n))};this._mouseWheelToDispose.push(Fe(this._listenOnDomNode,bn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=NT.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+o===0?u=o=0:Math.abs(o)>=Math.abs(u)?u=0:o=0),this._options.flipAxes&&([o,u]=[u,o]);let d=!ts&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!u&&(u=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),f={};if(o){let m=O_*o,g=p.scrollTop-(m<0?Math.floor(m):Math.ceil(m));this._verticalScrollbar.writeScrollPosition(f,g)}if(u){let m=O_*u,g=p.scrollLeft-(m<0?Math.floor(m):Math.ceil(m));this._horizontalScrollbar.writeScrollPosition(f,g)}f=this._scrollable.validateScrollPosition(f),(p.scrollLeft!==f.scrollLeft||p.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",a=t?" top":"",o=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),kT)}},ET=class extends jT{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function TT(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,ts&&(t.className+=" mac"),t}var Kp=class extends Je{constructor(e,t,n,r,a,o,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new _e),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new gT({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>Qm(r.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ET(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ln.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(It(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(It(()=>this._styleElement.remove())),this._register(Ln.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
77
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(f=>this._handleScroll(f)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Kp=Wt([Ne(2,Wn),Ne(3,Ts),Ne(4,y1),Ne(5,eo),Ne(6,qn),Ne(7,As)],Kp);var Gp=class extends Je{constructor(e,t,n,r,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(It(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Gp=Wt([Ne(1,Wn),Ne(2,Ts),Ne(3,zl),Ne(4,As)],Gp);var AT=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Gr={full:0,left:0,center:0,right:0},ri={full:0,left:0,center:0,right:0},el={full:0,left:0,center:0,right:0},Lu=class extends Je{constructor(e,t,n,r,a,o,u,d){var f;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=a,this._optionsService=o,this._themeService=u,this._coreBrowserService=d,this._colorZoneStore=new AT,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(f=this._viewportElement.parentElement)==null||f.insertBefore(this._canvas,this._viewportElement),this._register(It(()=>{var m;return(m=this._canvas)==null?void 0:m.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ri.full=this._canvas.width,ri.left=e,ri.center=t,ri.right=e,this._refreshDrawHeightConstants(),el.full=1,el.left=1,el.center=1+ri.left,el.right=1+ri.left+ri.center}_refreshDrawHeightConstants(){Gr.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Gr.left=t,Gr.center=t,Gr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Gr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Gr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Gr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Gr.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(el[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Gr[e.position||"full"]/2),ri[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Gr[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Lu=Wt([Ne(2,Wn),Ne(3,zl),Ne(4,As),Ne(5,qn),Ne(6,eo),Ne(7,Ts)],Lu);var pe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
78
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(pe||(pe={}));var Nu;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(Nu||(Nu={}));var P1;(e=>e.ST=`${pe.ESC}\\`)(P1||(P1={}));var Yp=class{constructor(e,t,n,r,a,o){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${pe.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=a+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Yp=Wt([Ne(2,Wn),Ne(3,qn),Ne(4,Ki),Ne(5,As)],Yp);var vn=0,_n=0,Sn=0,$t=0,I_={css:"#00000000",rgba:0},sn;(e=>{function t(a,o,u,d){return d!==void 0?`#${Di(a)}${Di(o)}${Di(u)}${Di(d)}`:`#${Di(a)}${Di(o)}${Di(u)}`}e.toCss=t;function n(a,o,u,d=255){return(a<<24|o<<16|u<<8|d)>>>0}e.toRgba=n;function r(a,o,u,d){return{css:e.toCss(a,o,u,d),rgba:e.toRgba(a,o,u,d)}}e.toColor=r})(sn||(sn={}));var Dt;(e=>{function t(p,f){if($t=(f.rgba&255)/255,$t===1)return{css:f.css,rgba:f.rgba};let m=f.rgba>>24&255,g=f.rgba>>16&255,v=f.rgba>>8&255,b=p.rgba>>24&255,_=p.rgba>>16&255,S=p.rgba>>8&255;vn=b+Math.round((m-b)*$t),_n=_+Math.round((g-_)*$t),Sn=S+Math.round((v-S)*$t);let j=sn.toCss(vn,_n,Sn),C=sn.toRgba(vn,_n,Sn);return{css:j,rgba:C}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function r(p,f,m){let g=ju.ensureContrastRatio(p.rgba,f.rgba,m);if(g)return sn.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=r;function a(p){let f=(p.rgba|255)>>>0;return[vn,_n,Sn]=ju.toChannels(f),{css:sn.toCss(vn,_n,Sn),rgba:f}}e.opaque=a;function o(p,f){return $t=Math.round(f*255),[vn,_n,Sn]=ju.toChannels(p.rgba),{css:sn.toCss(vn,_n,Sn,$t),rgba:sn.toRgba(vn,_n,Sn,$t)}}e.opacity=o;function u(p,f){return $t=p.rgba&255,o(p,$t*f/255)}e.multiplyOpacity=u;function d(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=d})(Dt||(Dt={}));var Pt;(e=>{let t,n;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return vn=parseInt(a.slice(1,2).repeat(2),16),_n=parseInt(a.slice(2,3).repeat(2),16),Sn=parseInt(a.slice(3,4).repeat(2),16),sn.toColor(vn,_n,Sn);case 5:return vn=parseInt(a.slice(1,2).repeat(2),16),_n=parseInt(a.slice(2,3).repeat(2),16),Sn=parseInt(a.slice(3,4).repeat(2),16),$t=parseInt(a.slice(4,5).repeat(2),16),sn.toColor(vn,_n,Sn,$t);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return vn=parseInt(o[1]),_n=parseInt(o[2]),Sn=parseInt(o[3]),$t=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),sn.toColor(vn,_n,Sn,$t);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[vn,_n,Sn,$t]=t.getImageData(0,0,1,1).data,$t!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:sn.toRgba(vn,_n,Sn,$t),css:a}}e.toColor=r})(Pt||(Pt={}));var $n;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,a,o){let u=r/255,d=a/255,p=o/255,f=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),m=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),g=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return f*.2126+m*.7152+g*.0722}e.relativeLuminance2=n})($n||($n={}));var ju;(e=>{function t(u,d){if($t=(d&255)/255,$t===1)return d;let p=d>>24&255,f=d>>16&255,m=d>>8&255,g=u>>24&255,v=u>>16&255,b=u>>8&255;return vn=g+Math.round((p-g)*$t),_n=v+Math.round((f-v)*$t),Sn=b+Math.round((m-b)*$t),sn.toRgba(vn,_n,Sn)}e.blend=t;function n(u,d,p){let f=$n.relativeLuminance(u>>8),m=$n.relativeLuminance(d>>8);if(ks(f,m)<p){if(m<f){let b=r(u,d,p),_=ks(f,$n.relativeLuminance(b>>8));if(_<p){let S=a(u,d,p),j=ks(f,$n.relativeLuminance(S>>8));return _>j?b:S}return b}let g=a(u,d,p),v=ks(f,$n.relativeLuminance(g>>8));if(v<p){let b=r(u,d,p),_=ks(f,$n.relativeLuminance(b>>8));return v>_?g:b}return g}}e.ensureContrastRatio=n;function r(u,d,p){let f=u>>24&255,m=u>>16&255,g=u>>8&255,v=d>>24&255,b=d>>16&255,_=d>>8&255,S=ks($n.relativeLuminance2(v,b,_),$n.relativeLuminance2(f,m,g));for(;S<p&&(v>0||b>0||_>0);)v-=Math.max(0,Math.ceil(v*.1)),b-=Math.max(0,Math.ceil(b*.1)),_-=Math.max(0,Math.ceil(_*.1)),S=ks($n.relativeLuminance2(v,b,_),$n.relativeLuminance2(f,m,g));return(v<<24|b<<16|_<<8|255)>>>0}e.reduceLuminance=r;function a(u,d,p){let f=u>>24&255,m=u>>16&255,g=u>>8&255,v=d>>24&255,b=d>>16&255,_=d>>8&255,S=ks($n.relativeLuminance2(v,b,_),$n.relativeLuminance2(f,m,g));for(;S<p&&(v<255||b<255||_<255);)v=Math.min(255,v+Math.ceil((255-v)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),S=ks($n.relativeLuminance2(v,b,_),$n.relativeLuminance2(f,m,g));return(v<<24|b<<16|_<<8|255)>>>0}e.increaseLuminance=a;function o(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=o})(ju||(ju={}));function Di(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ks(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var DT=class extends Bl{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ou=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Mr}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),a=0,o=0,u=0,d=t.getFg(0),p=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==p){if(f-a>1){let m=this._getJoinedRanges(r,u,o,t,a);for(let g=0;g<m.length;g++)n.push(m[g])}a=f,u=o,d=this._workCell.fg,p=this._workCell.bg}o+=this._workCell.getChars().length||li.length}if(this._bufferService.cols-a>1){let f=this._getJoinedRanges(r,u,o,t,a);for(let m=0;m<f.length;m++)n.push(f[m])}return n}_getJoinedRanges(e,t,n,r,a){let o=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(o)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let p=this._characterJoiners[d].handler(o);for(let f=0;f<p.length;f++)Ou._mergeRanges(u,p[f])}catch(p){console.error(p)}return this._stringRangesToCellRanges(u,r,a),u}_stringRangesToCellRanges(e,t,n){let r=0,a=!1,o=0,u=e[r];if(u){for(let d=n;d<this._bufferService.cols;d++){let p=t.getWidth(d),f=t.getString(d).length||li.length;if(p!==0){if(!a&&u[0]<=o&&(u[0]=d,a=!0),u[1]<=o){if(u[1]=d,u=e[++r],!u)break;u[0]<=o?(u[0]=d,a=!0):a=!1}o+=f}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let a=e[r];if(n){if(t[1]<=a[0])return e[r-1][1]=t[1],e;if(t[1]<=a[1])return e[r-1][1]=Math.max(t[1],a[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=a[0])return e.splice(r,0,t),e;if(t[1]<=a[1])return a[0]=Math.min(t[0],a[0]),e;t[0]<a[1]&&(a[0]=Math.min(t[0],a[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Ou=Wt([Ne(0,Wn)],Ou);function MT(e){return 57508<=e&&e<=57558}function RT(e){return 9472<=e&&e<=9631}function LT(e){return MT(e)||RT(e)}function OT(){return{css:{canvas:du(),cell:du()},device:{canvas:du(),cell:du(),char:{width:0,height:0,left:0,top:0}}}}function du(){return{width:0,height:0}}var Xp=class{constructor(e,t,n,r,a,o,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=a,this._decorationService=o,this._themeService=u,this._workCell=new Mr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,a,o,u,d,p,f,m){let g=[],v=this._characterJoinerService.getJoinedCharacters(t),b=this._themeService.colors,_=e.getNoBgTrimmedLength();n&&_<o+1&&(_=o+1);let S,j=0,C="",E=0,A=0,O=0,z=0,B=!1,Y=0,ee=!1,ie=0,D=0,$=[],H=f!==-1&&m!==-1;for(let U=0;U<_;U++){e.loadCell(U,this._workCell);let q=this._workCell.getWidth();if(q===0)continue;let T=!1,N=U>=D,F=U,I=this._workCell;if(v.length>0&&U===v[0][0]&&N){let Re=v.shift(),Xe=this._isCellInSelection(Re[0],t);for(E=Re[0]+1;E<Re[1];E++)N&&(N=Xe===this._isCellInSelection(E,t));N&&(N=!n||o<Re[0]||o>=Re[1]),N?(T=!0,I=new DT(this._workCell,e.translateToString(!0,Re[0],Re[1]),Re[1]-Re[0]),F=Re[1]-1,q=I.getWidth()):D=Re[1]}let J=this._isCellInSelection(U,t),R=n&&U===o,P=H&&U>=f&&U<=m,V=!1;this._decorationService.forEachDecorationAtCell(U,t,void 0,Re=>{V=!0});let L=I.getChars()||li;if(L===" "&&(I.isUnderline()||I.isOverline())&&(L=" "),ie=q*d-p.get(L,I.isBold(),I.isItalic()),!S)S=this._document.createElement("span");else if(j&&(J&&ee||!J&&!ee&&I.bg===A)&&(J&&ee&&b.selectionForeground||I.fg===O)&&I.extended.ext===z&&P===B&&ie===Y&&!R&&!T&&!V&&N){I.isInvisible()?C+=li:C+=L,j++;continue}else j&&(S.textContent=C),S=this._document.createElement("span"),j=0,C="";if(A=I.bg,O=I.fg,z=I.extended.ext,B=P,Y=ie,ee=J,T&&o>=U&&o<=F&&(o=U),!this._coreService.isCursorHidden&&R&&this._coreService.isCursorInitialized){if($.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&$.push("xterm-cursor-blink"),$.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":$.push("xterm-cursor-outline");break;case"block":$.push("xterm-cursor-block");break;case"bar":$.push("xterm-cursor-bar");break;case"underline":$.push("xterm-cursor-underline");break}}if(I.isBold()&&$.push("xterm-bold"),I.isItalic()&&$.push("xterm-italic"),I.isDim()&&$.push("xterm-dim"),I.isInvisible()?C=li:C=I.getChars()||li,I.isUnderline()&&($.push(`xterm-underline-${I.extended.underlineStyle}`),C===" "&&(C=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())S.style.textDecorationColor=`rgb(${Bl.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let Re=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&Re<8&&(Re+=8),S.style.textDecorationColor=b.ansi[Re].css}I.isOverline()&&($.push("xterm-overline"),C===" "&&(C=" ")),I.isStrikethrough()&&$.push("xterm-strikethrough"),P&&(S.style.textDecoration="underline");let G=I.getFgColor(),W=I.getFgColorMode(),Z=I.getBgColor(),se=I.getBgColorMode(),ve=!!I.isInverse();if(ve){let Re=G;G=Z,Z=Re;let Xe=W;W=se,se=Xe}let Ce,Te,Pe=!1;this._decorationService.forEachDecorationAtCell(U,t,void 0,Re=>{Re.options.layer!=="top"&&Pe||(Re.backgroundColorRGB&&(se=50331648,Z=Re.backgroundColorRGB.rgba>>8&16777215,Ce=Re.backgroundColorRGB),Re.foregroundColorRGB&&(W=50331648,G=Re.foregroundColorRGB.rgba>>8&16777215,Te=Re.foregroundColorRGB),Pe=Re.options.layer==="top")}),!Pe&&J&&(Ce=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,Z=Ce.rgba>>8&16777215,se=50331648,Pe=!0,b.selectionForeground&&(W=50331648,G=b.selectionForeground.rgba>>8&16777215,Te=b.selectionForeground)),Pe&&$.push("xterm-decoration-top");let $e;switch(se){case 16777216:case 33554432:$e=b.ansi[Z],$.push(`xterm-bg-${Z}`);break;case 50331648:$e=sn.toColor(Z>>16,Z>>8&255,Z&255),this._addStyle(S,`background-color:#${B_((Z>>>0).toString(16),"0",6)}`);break;case 0:default:ve?($e=b.foreground,$.push("xterm-bg-257")):$e=b.background}switch(Ce||I.isDim()&&(Ce=Dt.multiplyOpacity($e,.5)),W){case 16777216:case 33554432:I.isBold()&&G<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(G+=8),this._applyMinimumContrast(S,$e,b.ansi[G],I,Ce,void 0)||$.push(`xterm-fg-${G}`);break;case 50331648:let Re=sn.toColor(G>>16&255,G>>8&255,G&255);this._applyMinimumContrast(S,$e,Re,I,Ce,Te)||this._addStyle(S,`color:#${B_(G.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(S,$e,b.foreground,I,Ce,Te)||ve&&$.push("xterm-fg-257")}$.length&&(S.className=$.join(" "),$.length=0),!R&&!T&&!V&&N?j++:S.textContent=C,ie!==this.defaultSpacing&&(S.style.letterSpacing=`${ie}px`),g.push(S),U=F}return S&&j&&(S.textContent=C),g}_applyMinimumContrast(e,t,n,r,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||LT(r.getCode()))return!1;let u=this._getContrastCache(r),d;if(!a&&!o&&(d=u.getColor(t.rgba,n.rgba)),d===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);d=Dt.ensureContrastRatio(a||t,o||n,p),u.setColor((a||t).rgba,(o||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};Xp=Wt([Ne(1,_1),Ne(2,qn),Ne(3,Ts),Ne(4,Ki),Ne(5,zl),Ne(6,eo)],Xp);function B_(e,t,n){for(;e.length<n;)e=t+e;return e}var IT=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[n,r,a,o],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(a),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let u=this._measure(e,0);return u>0&&(this._flat[r]=u),u}let a=e;t&&(a+="B"),n&&(a+="I");let o=this._holey.get(a);if(o===void 0){let u=0;t&&(u|=1),n&&(u|=2),o=this._measure(e,u),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},BT=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,u=n[1]-a,d=Math.max(o,0),p=Math.min(u,e.rows-1);if(d>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=u,this.viewportCappedStartRow=d,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function zT(){return new BT}var Kf="xterm-dom-renderer-owner-",Er="xterm-rows",hu="xterm-fg-",z_="xterm-bg-",tl="xterm-focus",fu="xterm-selection",PT=1,Zp=class extends Je{constructor(e,t,n,r,a,o,u,d,p,f,m,g,v,b){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=a,this._helperContainer=o,this._linkifier2=u,this._charSizeService=p,this._optionsService=f,this._bufferService=m,this._coreService=g,this._coreBrowserService=v,this._themeService=b,this._terminalClass=PT++,this._rowElements=[],this._selectionRenderModel=zT(),this.onRequestRedraw=this._register(new _e).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Er),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(fu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=OT(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(Xp,document),this._element.classList.add(Kf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._register(It(()=>{this._element.classList.remove(Kf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new IT(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Er} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Er} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Er} .xterm-dim { color: ${Dt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Er}.${tl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Er}.${tl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Er}.${tl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Er} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${fu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${fu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${fu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,u]of e.ansi.entries())t+=`${this._terminalSelector} .${hu}${o} { color: ${u.css}; }${this._terminalSelector} .${hu}${o}.xterm-dim { color: ${Dt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${z_}${o} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${hu}257 { color: ${Dt.opaque(e.background).css}; }${this._terminalSelector} .${hu}257.xterm-dim { color: ${Dt.multiplyOpacity(Dt.opaque(e.background),.5).css}; }${this._terminalSelector} .${z_}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(tl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(tl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];d.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],u-o+1))}else{let p=r===o?e[0]:0,f=o===a?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(o,p,f));let m=u-o-1;if(d.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,m)),o!==u){let g=a===u?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(u,0,g))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,r=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return o+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-o),a.style.height=`${r*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${u}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,a=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let f=p+n.ydisp,m=this._rowElements[p],g=n.lines.get(f);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,f,f===r,u,d,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Kf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,a,o){n<0&&(e=0),r<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),r=Math.max(Math.min(r,u),0),a=Math.min(a,this._bufferService.cols);let d=this._bufferService.buffer,p=d.ybase+d.y,f=Math.min(d.x,a-1),m=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,v=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=n;b<=r;++b){let _=b+d.ydisp,S=this._rowElements[b],j=d.lines.get(_);if(!S||!j)break;S.replaceChildren(...this._rowFactory.createRow(j,_,_===p,g,v,f,m,this.dimensions.css.cell.width,this._widthCache,o?b===n?e:0:-1,o?(b===r?t:a)-1:-1))}}};Zp=Wt([Ne(7,Vm),Ne(8,nd),Ne(9,qn),Ne(10,Wn),Ne(11,Ki),Ne(12,Ts),Ne(13,eo)],Zp);var Qp=class extends Je{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new _e),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new FT(this._optionsService))}catch{this._measureStrategy=this._register(new HT(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Qp=Wt([Ne(2,qn)],Qp);var H1=class extends Je{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},HT=class extends H1{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},FT=class extends H1{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},$T=class extends Je{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new UT(this._window)),this._onDprChange=this._register(new _e),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new _e),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Ln.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Fe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Fe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},UT=class extends Je{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Xa),this._onDprChange=this._register(new _e),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(It(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Fe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},WT=class extends Je{constructor(){super(),this.linkProviders=[],this._register(It(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function eg(e,t,n){let r=n.getBoundingClientRect(),a=e.getComputedStyle(n),o=parseInt(a.getPropertyValue("padding-left")),u=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-r.left-o,t.clientY-r.top-u]}function qT(e,t,n,r,a,o,u,d,p){if(!o)return;let f=eg(e,t,n);if(f)return f[0]=Math.ceil((f[0]+(p?u/2:0))/u),f[1]=Math.ceil(f[1]/d),f[0]=Math.min(Math.max(f[0],1),r+(p?1:0)),f[1]=Math.min(Math.max(f[1],1),a),f}var Jp=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,a){return qT(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let n=eg(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Jp=Wt([Ne(0,As),Ne(1,nd)],Jp);var VT=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},F1={};nE(F1,{getSafariVersion:()=>GT,isChromeOS:()=>q1,isFirefox:()=>$1,isIpad:()=>YT,isIphone:()=>XT,isLegacyEdge:()=>KT,isLinux:()=>tg,isMac:()=>Iu,isNode:()=>rd,isSafari:()=>U1,isWindows:()=>W1});var rd=typeof process<"u"&&"title"in process,Pl=rd?"node":navigator.userAgent,Hl=rd?"node":navigator.platform,$1=Pl.includes("Firefox"),KT=Pl.includes("Edge"),U1=/^((?!chrome|android).)*safari/i.test(Pl);function GT(){if(!U1)return 0;let e=Pl.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Iu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Hl),YT=Hl==="iPad",XT=Hl==="iPhone",W1=["Windows","Win16","Win32","WinCE"].includes(Hl),tg=Hl.indexOf("Linux")>=0,q1=/\bCrOS\b/.test(Pl),V1=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),a=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),a=e.timeRemaining(),n*1.5>a){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=a}this.clear()}},ZT=class extends V1{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},QT=class extends V1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Bu=!rd&&"requestIdleCallback"in window?QT:ZT,JT=class{constructor(){this._queue=new Bu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},em=class extends Je{constructor(e,t,n,r,a,o,u,d,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=a,this._coreBrowserService=d,this._renderer=this._register(new Xa),this._pausedResizeTask=new JT,this._observerDisposable=this._register(new Xa),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new _e),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new _e),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new _e),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new _e),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new VT((f,m)=>this._renderRows(f,m),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new e5(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(It(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var f;return(f=this._renderer.value)==null?void 0:f.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=It(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};em=Wt([Ne(2,qn),Ne(3,nd),Ne(4,Ki),Ne(5,zl),Ne(6,Wn),Ne(7,Ts),Ne(8,eo)],em);var e5=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function t5(e,t,n,r){let a=n.buffer.x,o=n.buffer.y;if(!n.buffer.hasScrollback)return s5(a,o,e,t,n,r)+sd(o,t,n,r)+i5(a,o,e,t,n,r);let u;if(o===t)return u=a>e?"D":"C",El(Math.abs(a-e),jl(u,r));u=o>t?"D":"C";let d=Math.abs(o-t),p=r5(o>t?e:a,n)+(d-1)*n.cols+1+n5(o>t?a:e);return El(p,jl(u,r))}function n5(e,t){return e-1}function r5(e,t){return t.cols-e}function s5(e,t,n,r,a,o){return sd(t,r,a,o).length===0?"":El(G1(e,t,e,t-qi(t,a),!1,a).length,jl("D",o))}function sd(e,t,n,r){let a=e-qi(e,n),o=t-qi(t,n),u=Math.abs(a-o)-a5(e,t,n);return El(u,jl(K1(e,t),r))}function i5(e,t,n,r,a,o){let u;sd(t,r,a,o).length>0?u=r-qi(r,a):u=t;let d=r,p=o5(e,t,n,r,a,o);return El(G1(e,u,n,d,p==="C",a).length,jl(p,o))}function a5(e,t,n){var u;let r=0,a=e-qi(e,n),o=t-qi(t,n);for(let d=0;d<Math.abs(a-o);d++){let p=K1(e,t)==="A"?-1:1;(u=n.buffer.lines.get(a+p*d))!=null&&u.isWrapped&&r++}return r}function qi(e,t){let n=0,r=t.buffer.lines.get(e),a=r==null?void 0:r.isWrapped;for(;a&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),a=r==null?void 0:r.isWrapped;return n}function o5(e,t,n,r,a,o){let u;return sd(n,r,a,o).length>0?u=r-qi(r,a):u=t,e<n&&u<=r||e>=n&&u<r?"C":"D"}function K1(e,t){return e>t?"A":"B"}function G1(e,t,n,r,a,o){let u=e,d=t,p="";for(;(u!==n||d!==r)&&d>=0&&d<o.buffer.lines.length;)u+=a?1:-1,a&&u>o.cols-1?(p+=o.buffer.translateBufferLineToString(d,!1,e,u),u=0,e=0,d++):!a&&u<0&&(p+=o.buffer.translateBufferLineToString(d,!1,0,e+1),u=o.cols-1,e=u,d--);return p+o.buffer.translateBufferLineToString(d,!1,e,u)}function jl(e,t){let n=t?"O":"[";return pe.ESC+n+e}function El(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var l5=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function P_(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Gf=50,c5=15,u5=50,d5=500,h5=" ",f5=new RegExp(h5,"g"),tm=class extends Je{constructor(e,t,n,r,a,o,u,d,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=a,this._mouseService=o,this._optionsService=u,this._renderService=d,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Mr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new _e),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new _e),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new _e),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new _e),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new l5(this._bufferService),this._activeSelectionMode=0,this._register(It(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let d=n.translateBufferLineToString(u,!0,a,o);r.push(d)}}else{let a=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],a));for(let o=e[1]+1;o<=t[1]-1;o++){let u=n.lines.get(o),d=n.translateBufferLineToString(o,!0);u!=null&&u.isWrapped?r[r.length-1]+=d:r.push(d)}if(e[1]!==t[1]){let o=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?r[r.length-1]+=u:r.push(u)}}return r.map(a=>a.replace(f5," ")).join(W1?`\r
|
|
79
|
+
`:`
|
|
80
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),tg&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var a,o;let n=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=P_(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=eg(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-Gf),Gf),t/=Gf,t/Math.abs(t)+Math.round(t*(c5-1)))}shouldForceSelection(e){return Iu?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),u5)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Iu&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<d5&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=t5(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let a=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:a>1&&t!==r&&(n+=a-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let u=a.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(o,e[0]),p=d,f=e[0]-d,m=0,g=0,v=0,b=0;if(u.charAt(d)===" "){for(;d>0&&u.charAt(d-1)===" ";)d--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let j=e[0],C=e[0];o.getWidth(j)===0&&(m++,j--),o.getWidth(C)===2&&(g++,C++);let E=o.getString(C).length;for(E>1&&(b+=E-1,p+=E-1);j>0&&d>0&&!this._isCharWordSeparator(o.loadCell(j-1,this._workCell));){o.loadCell(j-1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===0?(m++,j--):A>1&&(v+=A-1,d-=A-1),d--,j--}for(;C<o.length&&p+1<u.length&&!this._isCharWordSeparator(o.loadCell(C+1,this._workCell));){o.loadCell(C+1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===2?(g++,C++):A>1&&(b+=A-1,p+=A-1),p++,C++}}p++;let _=d+f-m+v,S=Math.min(this._bufferService.cols,p-d+m+g-v-b);if(!(!t&&u.slice(d,p).trim()==="")){if(n&&_===0&&o.getCodePoint(0)!==32){let j=a.lines.get(e[1]-1);if(j&&o.isWrapped&&j.getCodePoint(this._bufferService.cols-1)!==32){let C=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(C){let E=this._bufferService.cols-C.start;_-=E,S+=E}}}if(r&&_+S===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let j=a.lines.get(e[1]+1);if(j!=null&&j.isWrapped&&j.getCodePoint(0)!==32){let C=this._getWordAt([0,e[1]+1],!1,!1,!0);C&&(S+=C.length)}}return{start:_,length:S}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=P_(n,this._bufferService.cols)}};tm=Wt([Ne(3,Wn),Ne(4,Ki),Ne(5,Km),Ne(6,qn),Ne(7,As),Ne(8,Ts)],tm);var H_=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},F_=class{constructor(){this._color=new H_,this._css=new H_}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},un=Object.freeze((()=>{let e=[Pt.toColor("#2e3436"),Pt.toColor("#cc0000"),Pt.toColor("#4e9a06"),Pt.toColor("#c4a000"),Pt.toColor("#3465a4"),Pt.toColor("#75507b"),Pt.toColor("#06989a"),Pt.toColor("#d3d7cf"),Pt.toColor("#555753"),Pt.toColor("#ef2929"),Pt.toColor("#8ae234"),Pt.toColor("#fce94f"),Pt.toColor("#729fcf"),Pt.toColor("#ad7fa8"),Pt.toColor("#34e2e2"),Pt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],a=t[n/6%6|0],o=t[n%6];e.push({css:sn.toCss(r,a,o),rgba:sn.toRgba(r,a,o)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:sn.toCss(r,r,r),rgba:sn.toRgba(r,r,r)})}return e})()),Ii=Pt.toColor("#ffffff"),ml=Pt.toColor("#000000"),$_=Pt.toColor("#ffffff"),U_=ml,nl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},p5=Ii,nm=class extends Je{constructor(e){super(),this._optionsService=e,this._contrastCache=new F_,this._halfContrastCache=new F_,this._onChangeColors=this._register(new _e),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ii,background:ml,cursor:$_,cursorAccent:U_,selectionForeground:void 0,selectionBackgroundTransparent:nl,selectionBackgroundOpaque:Dt.blend(ml,nl),selectionInactiveBackgroundTransparent:nl,selectionInactiveBackgroundOpaque:Dt.blend(ml,nl),scrollbarSliderBackground:Dt.opacity(Ii,.2),scrollbarSliderHoverBackground:Dt.opacity(Ii,.4),scrollbarSliderActiveBackground:Dt.opacity(Ii,.5),overviewRulerBorder:Ii,ansi:un.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=wt(e.foreground,Ii),t.background=wt(e.background,ml),t.cursor=Dt.blend(t.background,wt(e.cursor,$_)),t.cursorAccent=Dt.blend(t.background,wt(e.cursorAccent,U_)),t.selectionBackgroundTransparent=wt(e.selectionBackground,nl),t.selectionBackgroundOpaque=Dt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=wt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Dt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?wt(e.selectionForeground,I_):void 0,t.selectionForeground===I_&&(t.selectionForeground=void 0),Dt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Dt.opacity(t.selectionBackgroundTransparent,.3)),Dt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Dt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=wt(e.scrollbarSliderBackground,Dt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=wt(e.scrollbarSliderHoverBackground,Dt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=wt(e.scrollbarSliderActiveBackground,Dt.opacity(t.foreground,.5)),t.overviewRulerBorder=wt(e.overviewRulerBorder,p5),t.ansi=un.slice(),t.ansi[0]=wt(e.black,un[0]),t.ansi[1]=wt(e.red,un[1]),t.ansi[2]=wt(e.green,un[2]),t.ansi[3]=wt(e.yellow,un[3]),t.ansi[4]=wt(e.blue,un[4]),t.ansi[5]=wt(e.magenta,un[5]),t.ansi[6]=wt(e.cyan,un[6]),t.ansi[7]=wt(e.white,un[7]),t.ansi[8]=wt(e.brightBlack,un[8]),t.ansi[9]=wt(e.brightRed,un[9]),t.ansi[10]=wt(e.brightGreen,un[10]),t.ansi[11]=wt(e.brightYellow,un[11]),t.ansi[12]=wt(e.brightBlue,un[12]),t.ansi[13]=wt(e.brightMagenta,un[13]),t.ansi[14]=wt(e.brightCyan,un[14]),t.ansi[15]=wt(e.brightWhite,un[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=wt(e.extendedAnsi[r],un[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};nm=Wt([Ne(0,qn)],nm);function wt(e,t){if(e!==void 0)try{return Pt.toColor(e)}catch{}return t}var m5=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},g5=class{constructor(){this._services=new m5,this._services.set(Vm,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=cE(e).sort((o,u)=>o.index-u.index),r=[];for(let o of n){let u=this._services.get(o.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);r.push(u)}let a=n.length>0?n[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},x5={trace:0,debug:1,info:2,warn:3,error:4,off:5},y5="xterm.js: ",rm=class extends Je{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=x5[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":y5)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};rm=Wt([Ne(0,qn)],rm);var W_=class extends Je{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new _e),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new _e),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new _e),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let a=t-1;a>=0;a--)this.set(e+a+n,this.get(e+a));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Ze=3,rn=Object.freeze(new Bl),pu=0,Yf=2,gl=class Y1{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ze);let a=n||Mr.fromCharData([0,p1,1,0]);for(let o=0;o<t;++o)this.setCell(o,a);this.length=t}get(t){let n=this._data[t*Ze+0],r=n&2097151;return[this._data[t*Ze+1],n&2097152?this._combined[t]:r?ai(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Ze+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Ze+0]=t|2097152|n[2]<<22):this._data[t*Ze+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Ze+0]>>22}hasWidth(t){return this._data[t*Ze+0]&12582912}getFg(t){return this._data[t*Ze+1]}getBg(t){return this._data[t*Ze+2]}hasContent(t){return this._data[t*Ze+0]&4194303}getCodePoint(t){let n=this._data[t*Ze+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Ze+0]&2097152}getString(t){let n=this._data[t*Ze+0];return n&2097152?this._combined[t]:n&2097151?ai(n&2097151):""}isProtected(t){return this._data[t*Ze+2]&536870912}loadCell(t,n){return pu=t*Ze,n.content=this._data[pu+0],n.fg=this._data[pu+1],n.bg=this._data[pu+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Ze+0]=n.content,this._data[t*Ze+1]=n.fg,this._data[t*Ze+2]=n.bg}setCellFromCodepoint(t,n,r,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Ze+0]=n|r<<22,this._data[t*Ze+1]=a.fg,this._data[t*Ze+2]=a.bg}addCodepointToCell(t,n,r){let a=this._data[t*Ze+0];a&2097152?this._combined[t]+=ai(n):a&2097151?(this._combined[t]=ai(a&2097151)+ai(n),a&=-2097152,a|=2097152):a=n|1<<22,r&&(a&=-12582913,a|=r<<22),this._data[t*Ze+0]=a}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let a=new Mr;for(let o=this.length-t-n-1;o>=0;--o)this.setCell(t+n+o,this.loadCell(t+o,a));for(let o=0;o<n;++o)this.setCell(t+o,r)}else for(let a=t;a<this.length;++a)this.setCell(a,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let a=new Mr;for(let o=0;o<this.length-t-n;++o)this.setCell(t+o,this.loadCell(t+n+o,a));for(let o=this.length-n;o<this.length;++o)this.setCell(o,r)}else for(let a=t;a<this.length;++a)this.setCell(a,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,a=!1){if(a){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*Yf<this._data.buffer.byteLength;let r=t*Ze;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let a=new Uint32Array(r);a.set(this._data),this._data=a}for(let a=this.length;a<t;++a)this.setCell(a,n)}else{this._data=this._data.subarray(0,r);let a=Object.keys(this._combined);for(let u=0;u<a.length;u++){let d=parseInt(a[u],10);d>=t&&delete this._combined[d]}let o=Object.keys(this._extendedAttrs);for(let u=0;u<o.length;u++){let d=parseInt(o[u],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,r*4*Yf<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Yf<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new Y1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ze+0]&4194303)return t+(this._data[t*Ze+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ze+0]&4194303||this._data[t*Ze+2]&50331648)return t+(this._data[t*Ze+0]>>22);return 0}copyCellsFrom(t,n,r,a,o){let u=t._data;if(o)for(let p=a-1;p>=0;p--){for(let f=0;f<Ze;f++)this._data[(r+p)*Ze+f]=u[(n+p)*Ze+f];u[(n+p)*Ze+2]&268435456&&(this._extendedAttrs[r+p]=t._extendedAttrs[n+p])}else for(let p=0;p<a;p++){for(let f=0;f<Ze;f++)this._data[(r+p)*Ze+f]=u[(n+p)*Ze+f];u[(n+p)*Ze+2]&268435456&&(this._extendedAttrs[r+p]=t._extendedAttrs[n+p])}let d=Object.keys(t._combined);for(let p=0;p<d.length;p++){let f=parseInt(d[p],10);f>=n&&(this._combined[f-n+r]=t._combined[f])}}translateToString(t,n,r,a){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;n<r;){let u=this._data[n*Ze+0],d=u&2097151,p=u&2097152?this._combined[n]:d?ai(d):li;if(o+=p,a)for(let f=0;f<p.length;++f)a.push(n);n+=u>>22||1}return a&&a.push(n),o}};function b5(e,t,n,r,a,o){let u=[];for(let d=0;d<e.length-1;d++){let p=d,f=e.get(++p);if(!f.isWrapped)continue;let m=[e.get(d)];for(;p<e.length&&f.isWrapped;)m.push(f),f=e.get(++p);if(!o&&r>=d&&r<p){d+=m.length-1;continue}let g=0,v=Tl(m,g,t),b=1,_=0;for(;b<m.length;){let j=Tl(m,b,t),C=j-_,E=n-v,A=Math.min(C,E);m[g].copyCellsFrom(m[b],_,v,A,!1),v+=A,v===n&&(g++,v=0),_+=A,_===j&&(b++,_=0),v===0&&g!==0&&m[g-1].getWidth(n-1)===2&&(m[g].copyCellsFrom(m[g-1],n-1,v++,1,!1),m[g-1].setCell(n-1,a))}m[g].replaceCells(v,n,a);let S=0;for(let j=m.length-1;j>0&&(j>g||m[j].getTrimmedLength()===0);j--)S++;S>0&&(u.push(d+m.length-S),u.push(S)),d+=m.length-1}return u}function v5(e,t){let n=[],r=0,a=t[r],o=0;for(let u=0;u<e.length;u++)if(a===u){let d=t[++r];e.onDeleteEmitter.fire({index:u-o,amount:d}),u+=d-1,o+=d,a=t[++r]}else n.push(u);return{layout:n,countRemoved:o}}function _5(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function S5(e,t,n){let r=[],a=e.map((p,f)=>Tl(e,f,t)).reduce((p,f)=>p+f),o=0,u=0,d=0;for(;d<a;){if(a-d<n){r.push(a-d);break}o+=n;let p=Tl(e,u,t);o>p&&(o-=p,u++);let f=e[u].getWidth(o-1)===2;f&&o--;let m=f?n-1:n;r.push(m),d+=m}return r}function Tl(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,a=e[t+1].getWidth(0)===2;return r&&a?n-1:n}var X1=class Z1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Z1._nextId++,this._onDispose=this.register(new _e),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Wi(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};X1._nextId=1;var w5=X1,pn={},Bi=pn.B;pn[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};pn.A={"#":"£"};pn.B=void 0;pn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};pn.C=pn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};pn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};pn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};pn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};pn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};pn.E=pn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};pn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};pn.H=pn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};pn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var q_=4294967295,V_=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=rn.clone(),this.savedCharset=Bi,this.markers=[],this._nullCell=Mr.fromCharData([0,p1,1,0]),this._whitespaceCell=Mr.fromCharData([0,li,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Bu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new W_(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Ru),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Ru),this._whitespaceCell}getBlankLine(e,t){return new gl(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>q_?q_:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=rn);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new W_(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(rn),r=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)r+=+this.lines.get(u).resize(e,n);let o=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new gl(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new gl(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a<this.lines.maxLength){let u=this.lines.length-a;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)r+=+this.lines.get(o).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=b5(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(rn),n);if(r.length>0){let a=v5(this.lines,r);_5(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(rn),a=n;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new gl(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(rn),a=[],o=0;for(let u=this.lines.length-1;u>=0;u--){let d=this.lines.get(u);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let p=[d];for(;d.isWrapped&&u>0;)d=this.lines.get(--u),p.unshift(d);if(!n){let A=this.ybase+this.y;if(A>=u&&A<u+p.length)continue}let f=p[p.length-1].getTrimmedLength(),m=S5(p,this._cols,e),g=m.length-p.length,v;this.ybase===0&&this.y!==this.lines.length-1?v=Math.max(0,this.y-this.lines.maxLength+g):v=Math.max(0,this.lines.length-this.lines.maxLength+g);let b=[];for(let A=0;A<g;A++){let O=this.getBlankLine(rn,!0);b.push(O)}b.length>0&&(a.push({start:u+p.length+o,newLines:b}),o+=b.length),p.push(...b);let _=m.length-1,S=m[_];S===0&&(_--,S=m[_]);let j=p.length-g-1,C=f;for(;j>=0;){let A=Math.min(C,S);if(p[_]===void 0)break;if(p[_].copyCellsFrom(p[j],C-A,S-A,A,!0),S-=A,S===0&&(_--,S=m[_]),C-=A,C===0){j--;let O=Math.max(j,0);C=Tl(p,O,this._cols)}}for(let A=0;A<p.length;A++)m[A]<e&&p[A].setCell(m[A],r);let E=g-v;for(;E-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+g,this.ybase+t-1)}if(a.length>0){let u=[],d=[];for(let S=0;S<this.lines.length;S++)d.push(this.lines.get(S));let p=this.lines.length,f=p-1,m=0,g=a[m];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let v=0;for(let S=Math.min(this.lines.maxLength-1,p+o-1);S>=0;S--)if(g&&g.start>f+v){for(let j=g.newLines.length-1;j>=0;j--)this.lines.set(S--,g.newLines[j]);S++,u.push({index:f+1,amount:g.newLines.length}),v+=g.newLines.length,g=a[++m]}else this.lines.set(S,d[f--]);let b=0;for(let S=u.length-1;S>=0;S--)u[S].index+=b,this.lines.onInsertEmitter.fire(u[S]),b+=u[S].amount;let _=Math.max(0,p+o-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_)}}translateBufferLineToString(e,t,n=0,r){let a=this.lines.get(e);return a?a.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new w5(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},k5=class extends Je{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new _e),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new V_(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new V_(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Q1=2,J1=1,sm=class extends Je{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new _e),this.onResize=this._onResize.event,this._onScroll=this._register(new _e),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Q1),this.rows=Math.max(e.rawOptions.rows||0,J1),this.buffers=this._register(new k5(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let a=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;o===n.lines.length-1?u?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(o+1,0,r.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=o-a+1;n.lines.shiftElements(a+1,u-1,-1),n.lines.set(o,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};sm=Wt([Ne(0,qn)],sm);var Ba={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Iu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},C5=["normal","bold","100","200","300","400","500","600","700","800","900"],N5=class extends Je{constructor(e){super(),this._onOptionChange=this._register(new _e),this.onOptionChange=this._onOptionChange.event;let t={...Ba};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(It(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Ba))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in Ba))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ba[e]),!j5(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ba[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=C5.includes(t)?t:Ba[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function j5(e){return e==="block"||e==="underline"||e==="bar"}function xl(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&xl(e[r],t-1);return n}var K_=Object.freeze({insertMode:!1}),G_=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),im=class extends Je{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new _e),this.onData=this._onData.event,this._onUserInput=this._register(new _e),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new _e),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new _e),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=xl(K_),this.decPrivateModes=xl(G_)}reset(){this.modes=xl(K_),this.decPrivateModes=xl(G_)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};im=Wt([Ne(0,Wn),Ne(1,b1),Ne(2,qn)],im);var Y_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Xf(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Zf=String.fromCharCode,X_={DEFAULT:e=>{let t=[Xf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Zf(t[0])}${Zf(t[1])}${Zf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Xf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Xf(e,!0)};${e.x};${e.y}${t}`}},am=class extends Je{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new _e),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(Y_))this.addProtocol(r,Y_[r]);for(let r of Object.keys(X_))this.addEncoding(r,X_[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=r+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};am=Wt([Ne(0,Wn),Ne(1,Ki),Ne(2,qn)],am);var Qf=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],E5=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],dn;function T5(e,t){let n=0,r=t.length-1,a;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(a=n+r>>1,e>t[a][1])n=a+1;else if(e<t[a][0])r=a-1;else return!0;return!1}var A5=class{constructor(){if(this.version="6",!dn){dn=new Uint8Array(65536),dn.fill(1),dn[0]=0,dn.fill(0,1,32),dn.fill(0,127,160),dn.fill(2,4352,4448),dn[9001]=2,dn[9002]=2,dn.fill(2,11904,42192),dn[12351]=1,dn.fill(2,44032,55204),dn.fill(2,63744,64256),dn.fill(2,65040,65050),dn.fill(2,65072,65136),dn.fill(2,65280,65377),dn.fill(2,65504,65511);for(let e=0;e<Qf.length;++e)dn.fill(0,Qf[e][0],Qf[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?dn[e]:T5(e,E5)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let a=Pi.extractWidth(t);a===0?r=!1:a>n&&(n=a)}return Pi.createPropertyValue(0,n,r)}},Pi=class Eu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new _e,this.onChange=this._onChange.event;let t=new A5;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,a=t.length;for(let o=0;o<a;++o){let u=t.charCodeAt(o);if(55296<=u&&u<=56319){if(++o>=a)return n+this.wcwidth(u);let f=t.charCodeAt(o);56320<=f&&f<=57343?u=(u-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let d=this.charProperties(u,r),p=Eu.extractWidth(d);Eu.extractShouldJoin(d)&&(p-=Eu.extractWidth(r)),n+=p,r=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},D5=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Z_(e){var r;let t=(r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:r.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var rl=2147483647,M5=256,ew=class om{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>M5)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new om;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let a=t[r];if(Array.isArray(a))for(let o=0;o<a.length;++o)n.addSubParam(a[o]);else n.addParam(a)}return n}clone(){let t=new om(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,a=this._subParamsIdx[n]&255;a-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>rl?rl:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>rl?rl:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,a=this._subParamsIdx[n]&255;a-r>0&&(t[n]=this._subParams.slice(r,a))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,a=r[n-1];r[n-1]=~a?Math.min(a*10+t,rl):t}},sl=[],R5=class{constructor(){this._state=0,this._active=sl,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=sl}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=sl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||sl,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",td(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,a=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=sl,this._id=-1,this._state=0}}},dr=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=td(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},il=[],L5=class{constructor(){this._handlers=Object.create(null),this._active=il,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=il}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=il,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||il,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",td(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,a=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=il,this._ident=0}},yl=new ew;yl.addParam(0);var Q_=class{constructor(e){this._handler=e,this._data="",this._params=yl,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():yl,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=td(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=yl,this._data="",this._hitLimit=!1,n));return this._params=yl,this._data="",this._hitLimit=!1,t}},O5=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let a=0;a<e.length;a++)this.table[t<<8|e[a]]=n<<4|r}},Ar=160,I5=(function(){let e=new O5(4095),t=Array.apply(null,Array(256)).map((d,p)=>p),n=(d,p)=>t.slice(d,p),r=n(32,127),a=n(0,24);a.push(25),a.push.apply(a,n(28,32));let o=n(0,14),u;e.setDefault(1,0),e.addMany(r,0,2,0);for(u in o)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Ar,0,2,0),e.add(Ar,8,5,8),e.add(Ar,6,0,6),e.add(Ar,11,0,11),e.add(Ar,13,13,13),e})(),B5=class extends Je{constructor(e=I5){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new ew,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(It(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new R5),this._dcsParser=this._register(new L5),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;a<e.intermediates.length;++a){let o=e.intermediates.charCodeAt(a);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let a=r.indexOf(t);a!==-1&&r.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let a=r.indexOf(t);a!==-1&&r.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=a}parse(e,t,n){let r=0,a=0,o=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(u=d[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(u=d[p](),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],u=this._oscParser.end(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=o;d<t;++d){switch(r=e[d],a=this._transitions.table[this.currentState<<8|(r<160?r:Ar)],a>>4){case 2:for(let v=d+1;;++v){if(v>=t||(r=e[v])<32||r>126&&r<Ar){this._printHandler(e,d,v),d=v-1;break}if(++v>=t||(r=e[v])<32||r>126&&r<Ar){this._printHandler(e,d,v),d=v-1;break}if(++v>=t||(r=e[v])<32||r>126&&r<Ar){this._printHandler(e,d,v),d=v-1;break}if(++v>=t||(r=e[v])<32||r>126&&r<Ar){this._printHandler(e,d,v),d=v-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:d,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|r],f=p?p.length-1:-1;for(;f>=0&&(u=p[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._preserveStack(3,p,f,a,d),u;f<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++d<t&&(r=e[d])>47&&r<60);d--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let m=this._escHandlers[this._collect<<8|r],g=m?m.length-1:-1;for(;g>=0&&(u=m[g](),u!==!0);g--)if(u instanceof Promise)return this._preserveStack(4,m,g,a,d),u;g<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let v=d+1;;++v)if(v>=t||(r=e[v])===24||r===26||r===27||r>127&&r<Ar){this._dcsParser.put(e,d,v),d=v-1;break}break;case 14:if(u=this._dcsParser.unhook(r!==24&&r!==26),u)return this._preserveStack(6,[],0,a,d),u;r===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let v=d+1;;v++)if(v>=t||(r=e[v])<32||r>127&&r<Ar){this._oscParser.put(e,d,v),d=v-1;break}break;case 6:if(u=this._oscParser.end(r!==24&&r!==26),u)return this._preserveStack(5,[],0,a,d),u;r===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},z5=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,P5=/^[\da-f]+$/;function J_(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=z5.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),P5.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let a=0;a<3;++a){let o=parseInt(t.slice(n*a,n*a+n),16);r[a]=n===1?o<<4:n===2?o:n===3?o>>4:o>>8}return r}}function Jf(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function H5(e,t=16){let[n,r,a]=e;return`rgb:${Jf(n,t)}/${Jf(r,t)}/${Jf(a,t)}`}var F5={"(":0,")":1,"*":2,"+":3,"-":1,".":2},si=131072,e0=10;function t0(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var n0=5e3,r0=0,$5=class extends Je{constructor(e,t,n,r,a,o,u,d,p=new B5){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=u,this._unicodeService=d,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new oE,this._utf8Decoder=new lE,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=rn.clone(),this._eraseAttrDataInternal=rn.clone(),this._onRequestBell=this._register(new _e),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new _e),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new _e),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new _e),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new _e),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new _e),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new _e),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new _e),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new _e),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new _e),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new _e),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new _e),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new _e),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new lm(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,m)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:m.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,m,g)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:m,data:g})}),this._parser.setDcsHandlerFallback((f,m,g)=>{m==="HOOK"&&(g=g.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:m,payload:g})}),this._parser.setPrintHandler((f,m,g)=>this.print(f,m,g)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(pe.BEL,()=>this.bell()),this._parser.setExecuteHandler(pe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(pe.BS,()=>this.backspace()),this._parser.setExecuteHandler(pe.HT,()=>this.tab()),this._parser.setExecuteHandler(pe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(pe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Nu.IND,()=>this.index()),this._parser.setExecuteHandler(Nu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Nu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new dr(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new dr(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new dr(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new dr(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new dr(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new dr(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new dr(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new dr(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new dr(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new dr(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new dr(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new dr(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in pn)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Q_((f,m)=>this.requestStatusString(f,m)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),n0))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${n0} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,a=this._activeBuffer.y,o=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>si&&(o=this._parseStack.position+si)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<si&&(this._parseBuffer=new Uint32Array(Math.min(e.length,si))),u||this._dirtyRowTracker.clearRange(),e.length>si)for(let f=o;f<e.length;f+=si){let m=f+si<e.length?f+si:e.length,g=typeof e=="string"?this._stringDecoder.decode(e.substring(f,m),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,m),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,g))return this._preserveStack(r,a,g,f),this._logSlowResolvingAsync(n),n}else if(!u){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(r,a,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==a)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),p=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);p<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(p,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,n){let r,a,o=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,m=this._curAttrData,g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&g.getWidth(this._activeBuffer.x-1)===2&&g.setCellFromCodepoint(this._activeBuffer.x-1,0,1,m);let v=this._parser.precedingJoinState;for(let b=t;b<n;++b){if(r=e[b],r<127&&o){let C=o[String.fromCharCode(r)];C&&(r=C.charCodeAt(0))}let _=this._unicodeService.charProperties(r,v);a=Pi.extractWidth(_);let S=Pi.extractShouldJoin(_),j=S?Pi.extractWidth(v):0;if(v=_,u&&this._onA11yChar.fire(ai(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-j>d){if(p){let C=g,E=this._activeBuffer.x-j;for(this._activeBuffer.x=j,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),g=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),j>0&&g instanceof gl&&g.copyCellsFrom(C,E,0,j,!1);E<d;)C.setCellFromCodepoint(E++,0,1,m)}else if(this._activeBuffer.x=d-1,a===2)continue}if(S&&this._activeBuffer.x){let C=g.getWidth(this._activeBuffer.x-1)?1:2;g.addCodepointToCell(this._activeBuffer.x-C,r,a);for(let E=a-j;--E>=0;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,m);continue}if(f&&(g.insertCells(this._activeBuffer.x,a-j,this._activeBuffer.getNullCell(m)),g.getWidth(d-1)===2&&g.setCellFromCodepoint(d-1,0,1,m)),g.setCellFromCodepoint(this._activeBuffer.x++,r,a,m),a>0)for(;--a;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,m)}this._parser.precedingJoinState=v,this._activeBuffer.x<d&&n-t>0&&g.getWidth(this._activeBuffer.x)===0&&!g.hasContent(this._activeBuffer.x)&&g.setCellFromCodepoint(this._activeBuffer.x,0,1,m),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>t0(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Q_(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new dr(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),a),r&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var r;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&r.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,a=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(a-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(rn));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=Pi.extractWidth(t),a=this._activeBuffer.x-r,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(a),u=new Uint32Array(o.length*n),d=0;for(let f=0;f<o.length;){let m=o.codePointAt(f)||0;u[d++]=m,f+=m>65535?2:1}let p=d;for(let f=1;f<n;++f)u.copyWithin(p,0,d),p+=d;return this.print(u,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(pe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(pe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(pe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(pe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(pe.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Bi),this._charsetService.setgCharset(1,Bi),this._charsetService.setgCharset(2,Bi),this._charsetService.setgCharset(3,Bi);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(S=>(S[S.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",S[S.SET=1]="SET",S[S.RESET=2]="RESET",S[S.PERMANENTLY_SET=3]="PERMANENTLY_SET",S[S.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let r=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,u=this._coreService,{buffers:d,cols:p}=this._bufferService,{active:f,alt:m}=d,g=this._optionsService.rawOptions,v=(S,j)=>(u.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${S};${j}$y`),!0),b=S=>S?1:2,_=e.params[0];return t?_===2?v(_,4):_===4?v(_,b(u.modes.insertMode)):_===12?v(_,3):_===20?v(_,b(g.convertEol)):v(_,0):_===1?v(_,b(r.applicationCursorKeys)):_===3?v(_,g.windowOptions.setWinLines?p===80?2:p===132?1:0:0):_===6?v(_,b(r.origin)):_===7?v(_,b(r.wraparound)):_===8?v(_,3):_===9?v(_,b(a==="X10")):_===12?v(_,b(g.cursorBlink)):_===25?v(_,b(!u.isCursorHidden)):_===45?v(_,b(r.reverseWraparound)):_===66?v(_,b(r.applicationKeypad)):_===67?v(_,4):_===1e3?v(_,b(a==="VT200")):_===1002?v(_,b(a==="DRAG")):_===1003?v(_,b(a==="ANY")):_===1004?v(_,b(r.sendFocus)):_===1005?v(_,4):_===1006?v(_,b(o==="SGR")):_===1015?v(_,4):_===1016?v(_,b(o==="SGR_PIXELS")):_===1048?v(_,1):_===47||_===1047||_===1049?v(_,b(f===m)):_===2004?v(_,b(r.bracketedPasteMode)):_===2026?v(_,b(r.synchronizedOutput)):v(_,0)}_updateAttrColor(e,t,n,r,a){return t===2?(e|=50331648,e&=-16777216,e|=Bl.fromColorRGB([n,r,a])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],a=0,o=0;do{if(r[o+a]=e.params[t+o],e.hasSubParams(t+o)){let u=e.getSubParams(t+o),d=0;do r[1]===5&&(a=1),r[o+d+1+a]=u[d];while(++d<u.length&&d+o+1+a<r.length);break}if(r[1]===5&&o+a>=2||r[1]===2&&o+a>=5)break;r[1]&&(a=1)}while(++o+t<e.length&&o+a<r.length);for(let u=2;u<r.length;++u)r[u]===-1&&(r[u]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=rn.fg,e.bg=rn.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let a=0;a<t;a++)n=e.params[a],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=rn.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=rn.bg&16777215):n===38||n===48||n===58?a+=this._extractColor(e,a,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=rn.fg&16777215,r.bg&=-67108864,r.bg|=rn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${pe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=rn.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!t0(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${pe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>e0&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>e0&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),a=n.shift();if(/^\d+$/.exec(r)){let o=parseInt(r);if(s0(o))if(a==="?")t.push({type:0,index:o});else{let u=J_(a);u&&t.push({type:1,index:o,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,a=n.findIndex(o=>o.startsWith("id="));return a!==-1&&(r=n[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=J_(n[r]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let a=parseInt(n[r]);s0(a)&&t.push({type:2,index:a})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Bi),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(F5[e[0]],pn[e[1]]||Bi),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=rn.clone(),this._eraseAttrDataInternal=rn.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Mr;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${pe.ESC}${u}${pe.ESC}\\`),!0),r=this._bufferService.buffer,a=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},lm=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(r0=e,e=t,t=r0),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};lm=Wt([Ne(0,Wn)],lm);function s0(e){return 0<=e&&e<256}var U5=5e7,i0=12,W5=50,q5=class extends Je{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new _e),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>U5)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],a=this._action(r,t);if(a){let u=d=>performance.now()-n>=i0?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);a.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(u);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=i0)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>W5&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},cm=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let d=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(p,d)),this._dataByLinkId.set(p.id,p),p.id}let n=e,r=this._getEntryIdKey(n),a=this._entriesWithId.get(r);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(u,o)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cm=Wt([Ne(0,Wn)],cm);var a0=!1,V5=class extends Je{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Xa),this._onBinary=this._register(new _e),this.onBinary=this._onBinary.event,this._onData=this._register(new _e),this.onData=this._onData.event,this._onLineFeed=this._register(new _e),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new _e),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new _e),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new _e),this._instantiationService=new g5,this.optionsService=this._register(new N5(e)),this._instantiationService.setService(qn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sm)),this._instantiationService.setService(Wn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(rm)),this._instantiationService.setService(b1,this._logService),this.coreService=this._register(this._instantiationService.createInstance(im)),this._instantiationService.setService(Ki,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(am)),this._instantiationService.setService(y1,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Pi)),this._instantiationService.setService(hE,this.unicodeService),this._charsetService=this._instantiationService.createInstance(D5),this._instantiationService.setService(dE,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cm),this._instantiationService.setService(v1,this._oscLinkService),this._inputHandler=this._register(new $5(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ln.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ln.forward(this._bufferService.onResize,this._onResize)),this._register(Ln.forward(this.coreService.onData,this._onData)),this._register(Ln.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new q5((t,n)=>this._inputHandler.parse(t,n))),this._register(Ln.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new _e),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!a0&&(this._logService.warn("writeSync is unreliable and will be removed soon."),a0=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Q1),t=Math.max(t,J1),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Z_.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Z_(this._bufferService),!1))),this._windowsWrappingHeuristics.value=It(()=>{for(let t of e)t.dispose()})}}},K5={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function G5(e,t,n,r){var u;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=pe.ESC+"OA":a.key=pe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=pe.ESC+"OD":a.key=pe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=pe.ESC+"OC":a.key=pe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=pe.ESC+"OB":a.key=pe.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":pe.DEL,e.altKey&&(a.key=pe.ESC+a.key);break;case 9:if(e.shiftKey){a.key=pe.ESC+"[Z";break}a.key=pe.HT,a.cancel=!0;break;case 13:a.key=e.altKey?pe.ESC+pe.CR:pe.CR,a.cancel=!0;break;case 27:a.key=pe.ESC,e.altKey&&(a.key=pe.ESC+pe.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"D":t?a.key=pe.ESC+"OD":a.key=pe.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"C":t?a.key=pe.ESC+"OC":a.key=pe.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"A":t?a.key=pe.ESC+"OA":a.key=pe.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"B":t?a.key=pe.ESC+"OB":a.key=pe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=pe.ESC+"[2~");break;case 46:o?a.key=pe.ESC+"[3;"+(o+1)+"~":a.key=pe.ESC+"[3~";break;case 36:o?a.key=pe.ESC+"[1;"+(o+1)+"H":t?a.key=pe.ESC+"OH":a.key=pe.ESC+"[H";break;case 35:o?a.key=pe.ESC+"[1;"+(o+1)+"F":t?a.key=pe.ESC+"OF":a.key=pe.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=pe.ESC+"[5;"+(o+1)+"~":a.key=pe.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=pe.ESC+"[6;"+(o+1)+"~":a.key=pe.ESC+"[6~";break;case 112:o?a.key=pe.ESC+"[1;"+(o+1)+"P":a.key=pe.ESC+"OP";break;case 113:o?a.key=pe.ESC+"[1;"+(o+1)+"Q":a.key=pe.ESC+"OQ";break;case 114:o?a.key=pe.ESC+"[1;"+(o+1)+"R":a.key=pe.ESC+"OR";break;case 115:o?a.key=pe.ESC+"[1;"+(o+1)+"S":a.key=pe.ESC+"OS";break;case 116:o?a.key=pe.ESC+"[15;"+(o+1)+"~":a.key=pe.ESC+"[15~";break;case 117:o?a.key=pe.ESC+"[17;"+(o+1)+"~":a.key=pe.ESC+"[17~";break;case 118:o?a.key=pe.ESC+"[18;"+(o+1)+"~":a.key=pe.ESC+"[18~";break;case 119:o?a.key=pe.ESC+"[19;"+(o+1)+"~":a.key=pe.ESC+"[19~";break;case 120:o?a.key=pe.ESC+"[20;"+(o+1)+"~":a.key=pe.ESC+"[20~";break;case 121:o?a.key=pe.ESC+"[21;"+(o+1)+"~":a.key=pe.ESC+"[21~";break;case 122:o?a.key=pe.ESC+"[23;"+(o+1)+"~":a.key=pe.ESC+"[23~";break;case 123:o?a.key=pe.ESC+"[24;"+(o+1)+"~":a.key=pe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=pe.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=pe.DEL:e.keyCode===219?a.key=pe.ESC:e.keyCode===220?a.key=pe.FS:e.keyCode===221&&(a.key=pe.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let d=(u=K5[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(d)a.key=pe.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,f=String.fromCharCode(p);e.shiftKey&&(f=f.toUpperCase()),a.key=pe.ESC+f}else if(e.keyCode===32)a.key=pe.ESC+(e.ctrlKey?pe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=pe.ESC+p,a.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=pe.US),e.key==="@"&&(a.key=pe.NUL));break}return a}var Kt=0,Y5=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Bu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Bu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<r.length;a++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[a]=e[t],t++):r[a]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Kt=this._search(t),Kt===-1)||this._getKey(this._array[Kt])!==t)return!1;do if(this._array[Kt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Kt),!0;while(++Kt<this._array.length&&this._getKey(this._array[Kt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,o)=>a-o),t=0,n=new Array(this._array.length-e.length),r=0;for(let a=0;a<this._array.length;a++)e[t]===a?t++:n[r++]=this._array[a];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Kt=this._search(e),!(Kt<0||Kt>=this._array.length)&&this._getKey(this._array[Kt])===e))do yield this._array[Kt];while(++Kt<this._array.length&&this._getKey(this._array[Kt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Kt=this._search(e),!(Kt<0||Kt>=this._array.length)&&this._getKey(this._array[Kt])===e))do t(this._array[Kt]);while(++Kt<this._array.length&&this._getKey(this._array[Kt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,a=this._getKey(this._array[r]);if(a>e)n=r-1;else if(a<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},ep=0,o0=0,X5=class extends Je{constructor(){super(),this._decorations=new Y5(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new _e),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new _e),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(It(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Z5(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,a=0;for(let o of this._decorations.getKeyIterator(t))r=o.options.x??0,a=r+(o.options.width??1),e>=r&&e<a&&(!n||(o.options.layer??"bottom")===n)&&(yield o)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,a=>{ep=a.options.x??0,o0=ep+(a.options.width??1),e>=ep&&e<o0&&(!n||(a.options.layer??"bottom")===n)&&r(a)})}},Z5=class extends ui{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new _e),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new _e),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Pt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Pt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Q5=1e3,J5=class{constructor(e,t=Q5){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=r-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},l0=20,zu=class extends Je{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new J5(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
81
|
+
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Fe(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(It(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<l0+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
82
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===l0+1&&(this._liveRegion.textContent+=Tp.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let a=e;a<=t;a++){let o=n.lines.get(n.ydisp+a),u=[],d=(o==null?void 0:o.translateToString(!0,void 0,void 0,u))||"",p=(n.ydisp+a+1).toString(),f=this._rowElements[a];f&&(d.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=d,this._rowColumns.set(f,u)),f.setAttribute("aria-posinset",p),f.setAttribute("aria-setsize",r),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],a=n.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==r)return;let u,d;if(t===0?(u=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(u=this._rowElements.shift(),d=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var d;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:((d=r.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let a=({node:p,offset:f})=>{let m=p instanceof Text?p.parentNode:p,g=parseInt(m==null?void 0:m.getAttribute("aria-posinset"),10)-1;if(isNaN(g))return console.warn("row is invalid. Race condition?"),null;let v=this._rowColumns.get(m);if(!v)return console.warn("columns is null. Race condition?"),null;let b=f<v.length?v[f]:v.slice(-1)[0]+1;return b>=this._terminal.cols&&(++g,b=0),{row:g,column:b}},o=a(t),u=a(n);if(!(!o||!u)){if(o.row>u.row||o.row===u.row&&o.column>=u.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(u.row-o.row)*this._terminal.cols-o.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var a,o;e.style.transform="";let t=e.getBoundingClientRect().width,n=(o=(a=this._rowColumns.get(e))==null?void 0:a.slice(-1))==null?void 0:o[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};zu=Wt([Ne(1,Vm),Ne(2,Ts),Ne(3,As)],zu);var um=class extends Je{constructor(e,t,n,r,a){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=a,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new _e),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new _e),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(It(()=>{var o;Wi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Fe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Fe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Fe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Fe(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let a=n[r];if(a.classList.contains("xterm"))break;if(a.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var r,a;(!this._activeProviderReplies||!t)&&((r=this._activeProviderReplies)==null||r.forEach(o=>{o==null||o.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[o,u]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(n=this._checkLinkProviderResult(o,e,n)):u.provideLinks(e.y,d=>{var f,m;if(this._isMouseOut)return;let p=d==null?void 0:d.map(g=>({link:g}));(f=this._activeProviderReplies)==null||f.set(o,p),n=this._checkLinkProviderResult(o,e,n),((m=this._activeProviderReplies)==null?void 0:m.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let a=t.get(r);if(a)for(let o=0;o<a.length;o++){let u=a[o],d=u.link.range.start.y<e?0:u.link.range.start.x,p=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let f=d;f<=p;f++){if(n.has(f)){a.splice(o--,1);break}n.add(f)}}}}_checkLinkProviderResult(e,t,n){var o;if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),a=!1;for(let u=0;u<e;u++)(!this._activeProviderReplies.has(u)||this._activeProviderReplies.get(u))&&(a=!0);if(!a&&r){let u=r.find(d=>this._linkAtPosition(d.link,t));u&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let u=0;u<this._activeProviderReplies.size;u++){let d=(o=this._activeProviderReplies.get(u))==null?void 0:o.find(p=>this._linkAtPosition(p.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&e3(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Wi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,r;return(r=(n=this._currentLink)==null?void 0:n.state)==null?void 0:r.decorations.pointerCursor},set:n=>{var r;(r=this._currentLink)!=null&&r.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,r;return(r=(n=this._currentLink)==null?void 0:n.state)==null?void 0:r.decorations.underline},set:n=>{var r,a,o;(r=this._currentLink)!=null&&r.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(r,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,n){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,n){var r;(r=this._currentLink)!=null&&r.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return n<=a&&a<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,a){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:a}}};um=Wt([Ne(1,Km),Ne(2,As),Ne(3,Wn),Ne(4,S1)],um);function e3(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var t3=class extends V5{constructor(e={}){super(e),this._linkifier=this._register(new Xa),this.browser=F1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Xa),this._onCursorMove=this._register(new _e),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new _e),this.onKey=this._onKey.event,this._onRender=this._register(new _e),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new _e),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new _e),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new _e),this.onBell=this._onBell.event,this._onFocus=this._register(new _e),this._onBlur=this._register(new _e),this._onA11yCharEmitter=this._register(new _e),this._onA11yTabEmitter=this._register(new _e),this._onWillOpen=this._register(new _e),this._setup(),this._decorationService=this._instantiationService.createInstance(X5),this._instantiationService.setService(zl,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(WT),this._instantiationService.setService(S1,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Dp)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ln.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ln.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ln.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ln.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(It(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let a=Dt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${pe.ESC}]${r};${H5(a)}${P1.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=sn.toColor(...t.color));else{let o=n;this._themeService.modifyColors(u=>u[o]=sn.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(zu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,a=t.getWidth(n),o=this._renderService.dimensions.css.cell.width*a,u=this.buffer.y*this._renderService.dimensions.css.cell.height,d=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=u+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Fe(this.element,"copy",t=>{this.hasSelection()&&iE(t,this._selectionService)}));let e=t=>aE(t,this.textarea,this.coreService,this.optionsService);this._register(Fe(this.textarea,"paste",e)),this._register(Fe(this.element,"paste",e)),$1?this._register(Fe(this.element,"mousedown",t=>{t.button===2&&y_(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Fe(this.element,"contextmenu",t=>{y_(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),tg&&this._register(Fe(this.element,"auxclick",t=>{t.button===1&&f1(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Fe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Fe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Fe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Fe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Fe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Fe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Fe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Fe(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ep.get()),q1||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance($T,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ts,this._coreBrowserService),this._register(Fe(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Fe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Qp,this._document,this._helperContainer),this._instantiationService.setService(nd,this._charSizeService),this._themeService=this._instantiationService.createInstance(nm),this._instantiationService.setService(eo,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ou),this._instantiationService.setService(_1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(em,this.rows,this.screenElement)),this._instantiationService.setService(As,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Yp,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Jp),this._instantiationService.setService(Km,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(um,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Kp,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(tm,this.element,this.screenElement,r)),this._instantiationService.setService(pE,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Ln.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Gp,this.screenElement)),this._register(Fe(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(zu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Lu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Lu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Zp,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(o){var f,m,g,v,b;let u=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!u)return!1;let d,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(d=3,o.button!==void 0&&(d=o.button<3?o.button:3)):d=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,d=o.button<3?o.button:3;break;case"mousedown":p=1,d=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let _=o.deltaY;if(_===0||e.coreMouseService.consumeWheelEvent(o,(v=(g=(m=(f=e._renderService)==null?void 0:f.dimensions)==null?void 0:m.device)==null?void 0:g.cell)==null?void 0:v.height,(b=e._coreBrowserService)==null?void 0:b.dpr)===0)return!1;p=_<0?0:1,d=4;break;default:return!1}return p===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:d,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(n(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(o)),wheel:o=>(n(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&n(o)},mousemove:o=>{o.buttons||n(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?r.mousemove||(t.addEventListener("mousemove",a.mousemove),r.mousemove=a.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),r.wheel=a.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Fe(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return n(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(Fe(t,"wheel",o=>{var u,d,p,f,m;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(f=(p=(d=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:d.device)==null?void 0:p.cell)==null?void 0:f.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return this.cancel(o,!0);let g=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){h1(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=G5(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===pe.ETX||n.key===pe.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(n3(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(rn));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(pe.ESC+"[I"):this.coreService.triggerDataEvent(pe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[6;${a};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function n3(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var r3=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},s3=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Mr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},c0=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new s3(t)}getNullCell(){return new Mr}},i3=class extends Je{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new _e),this.onBufferChange=this._onBufferChange.event,this._normal=new c0(this._core.buffers.normal,"normal"),this._alternate=new c0(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},a3=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},o3=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},l3=["cols","rows"],Yr=0,c3=class extends Je{constructor(e){super(),this._core=this._register(new t3(e)),this._addonManager=this._register(new r3),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,a)=>{this._checkReadonlyOptions(r),this._core.options[r]=a};for(let r in this._core.options){let a={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,a)}}_checkReadonlyOptions(e){if(l3.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new a3(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new o3(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new i3(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
83
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Ep.get()},set promptLabel(e){Ep.set(e)},get tooMuchOutput(){return Tp.get()},set tooMuchOutput(e){Tp.set(e)}}}_verifyIntegers(...e){for(Yr of e)if(Yr===1/0||isNaN(Yr)||Yr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Yr of e)if(Yr&&(Yr===1/0||isNaN(Yr)||Yr%1!==0||Yr<0))throw new Error("This API only accepts positive integers")}};/**
|
|
84
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
85
|
+
* @license MIT
|
|
86
|
+
*
|
|
87
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
88
|
+
* @license MIT
|
|
89
|
+
*
|
|
90
|
+
* Originally forked from (with the author's permission):
|
|
91
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
92
|
+
* http://bellard.org/jslinux/
|
|
93
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
94
|
+
*/var u3=2,d3=1,h3=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var g;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((g=this._terminal.options.overviewRuler)==null?void 0:g.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),u={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},d=u.top+u.bottom,p=u.right+u.left,f=r-d,m=a-p-t;return{cols:Math.max(u3,Math.floor(m/e.css.cell.width)),rows:Math.max(d3,Math.floor(f/e.css.cell.height))}}};function f3({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=k.useRef(null),o=k.useRef(e),u=k.useRef(null),d=k.useRef(null),p=Br(m=>m.writeSession),f=Br(m=>m.resizeSession);return k.useEffect(()=>{o.current=e},[e]),k.useEffect(()=>{if(!n)return;const m=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n]),k.useEffect(()=>{if(!a.current)return;const m=new c3({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new h3;m.loadAddon(g),u.current={term:m,fitAddon:g},a.current.addEventListener("keydown",S=>{S.key==="Escape"&&n&&(S.preventDefault(),S.stopPropagation(),n())}),m.open(a.current);const v=a.current.querySelector(".xterm");v&&(v.style.padding="8px"),g.fit(),r&&setTimeout(()=>{m.focus()},150);const b=new ResizeObserver(()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{requestAnimationFrame(()=>{var j;g.fit&&g.fit();const S=(j=u.current)==null?void 0:j.term;S&&S.cols>0&&S.rows>0&&f(o.current,S.cols,S.rows)})},100)});b.observe(a.current),m.onData(S=>{if(S==="\x1B"&&n){n();return}p(o.current,S)}),m.onKey(S=>{S.key==="\x1B"&&n&&(S.domEvent.stopPropagation(),n())});const _=tn.subscribe(S=>{const j=S.payload;if(S.type==="terminal.output"&&(j==null?void 0:j.sessionId)===o.current){const C=j==null?void 0:j.data;C&&m.write(C)}});return()=>{_(),b.disconnect(),d.current&&clearTimeout(d.current),m.dispose(),u.current=null}},[e,p,f]),l.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[l.jsx("div",{}),l.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:l.jsx(s1,{})})]}),l.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:m=>{m.key==="Escape"&&n&&(m.preventDefault(),m.stopPropagation(),n())}})]})}const tw="openfox-chat-textarea";function nw(){const e=document.getElementById(tw);e&&e.focus()}function p3(e){return e===1?"grid-cols-1":e===2?"grid-cols-1 lg:grid-cols-2":"grid-cols-1 lg:grid-cols-2 xl:grid-cols-3"}function m3({isOpen:e,onClose:t}){const n=Br(_=>_.createSession),r=Br(_=>_.killSession),a=Br(_=>_.sessions),o=Br(_=>_.setWorkdir),u=Br(_=>_.fetchSessions),d=Ut(_=>_.currentProject),[p,f]=k.useState(!0),m=k.useRef(null),g=k.useRef(!1),v=k.useRef(!1),b=k.useCallback(()=>{t()},[t]);return k.useEffect(()=>{d!=null&&d.workdir&&o(d.workdir)},[d==null?void 0:d.workdir,o]),k.useEffect(()=>{e?(f(!0),u(d==null?void 0:d.id).finally(()=>f(!1))):nw()},[e,u,d==null?void 0:d.id]),k.useEffect(()=>{e&&a.length===0&&!p&&!v.current&&(v.current=!0,n(void 0,d==null?void 0:d.id))},[e,a.length,p,n,d==null?void 0:d.id]),k.useEffect(()=>{e?(g.current=!0,setTimeout(()=>{var _;(_=m.current)==null||_.focus(),setTimeout(()=>{g.current=!1},200)},100)):v.current=!1},[e]),k.useEffect(()=>{if(!e)return;const _=S=>{g.current||S.key==="Escape"&&(S.preventDefault(),t())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e,t]),e?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:b}),l.jsxs("div",{ref:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:_=>_.stopPropagation(),onKeyDown:_=>{_.key==="Escape"&&(_.preventDefault(),b())},children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[l.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>n(void 0,d==null?void 0:d.id),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:l.jsx(Dj,{})}),l.jsx("button",{onClick:t,className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close (Esc)",children:l.jsx(Bm,{})})]})]}),l.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:p?l.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?l.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"mb-4",children:"No terminal sessions"}),l.jsx("button",{onClick:()=>n(void 0,d==null?void 0:d.id),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):l.jsx("div",{className:`grid ${p3(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(_=>l.jsx(f3,{sessionId:_.id,onClose:()=>r(_.id),onEscape:b,autoFocus:a.length===1},_.id))})})]})]}):null}function Fl({items:e,trigger:t,minWidth:n="120px",isOpen:r,onOpenChange:a}){const[o,u]=k.useState(!1),d=r!==void 0,p=d?r:o,f=D=>{if(d){const $=typeof D=="function"?D(o):D;a==null||a($)}else u(D)},[m,g]=k.useState(null),v=k.useRef(null),b=k.useRef(null),[_,S]=k.useState(0),j=k.useRef(0),C=k.useRef(e),E=k.useCallback(()=>{if(!v.current)return;const D=v.current.getBoundingClientRect(),$=200,U=window.innerHeight-D.bottom<$;g({top:U?D.top-$-4:D.bottom+4,left:D.left,alignToTop:U})},[]);k.useEffect(()=>{C.current=e},[e]),k.useEffect(()=>{function D($){if(b.current){const H=$.target;b.current.contains(H)||f(!1)}}return p&&document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[p]),k.useEffect(()=>{p&&E()},[p,E]),k.useEffect(()=>{if(!p)return;setTimeout(()=>{var $;($=b.current)==null||$.focus()},0);function D($){const H=C.current,U=H.filter(T=>!A(T)),q=O(j.current,H);switch($.key){case"ArrowDown":if($.preventDefault(),$.stopPropagation(),q<U.length-1){const T=z(j.current+1,H);j.current=T,S(T)}break;case"ArrowUp":if($.preventDefault(),$.stopPropagation(),q>0){const T=B(j.current-1,H);j.current=T,S(T)}break;case"Enter":$.preventDefault(),$.stopPropagation(),Y(j.current,H);break;case"Escape":$.preventDefault(),$.stopPropagation(),f(!1);break}}return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[p,e]);function A(D){var U;const $=D.label;return $?String(((U=$.props)==null?void 0:U.className)??"").includes("cursor-default"):!1}function O(D,$){let H=0;for(let U=0;U<D;U++){const q=$[U];q&&!A(q)&&H++}return H}function z(D,$){for(let H=D;H<$.length;H++){const U=$[H];if(U&&!A(U))return H}return D}function B(D,$){for(let H=D;H>=0;H--){const U=$[H];if(U&&!A(U))return H}return D}function Y(D,$){var U;const H=$[D];!H||A(H)||((U=H.onClick)==null||U.call(H),H.href&&(window.history.pushState(null,"",H.href),window.dispatchEvent(new PopStateEvent("popstate"))),f(!1))}k.useEffect(()=>{p&&(S(e.findIndex(D=>!A(D))),j.current=e.findIndex(D=>!A(D)))},[p,e]);const ee=D=>{D.stopPropagation(),p||E(),f(!p)},ie=m&&l.jsx("div",{ref:b,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${m.alignToTop?"mb-1":"mt-1"}`,style:{top:m.top,left:m.left,minWidth:n},tabIndex:-1,children:e.map((D,$)=>{const U=!A(D)&&$===_,q=l.jsxs(l.Fragment,{children:[D.icon&&l.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:D.icon}),D.label]});return D.href?l.jsx(pr,{href:D.href,onClick:T=>{var N;(N=D.onClick)==null||N.call(D,T),f(!1)},onAuxClick:()=>f(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${D.danger?"text-accent-error hover:bg-accent-error/10":U?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${$!==e.length-1?"border-b border-border":""}`,children:q},$):l.jsx("button",{onClick:T=>{var N;(N=D.onClick)==null||N.call(D,T),D.closeOnClick!==!1&&f(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${D.danger?"text-accent-error hover:bg-accent-error/10":U?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${$!==e.length-1?"border-b border-border":""}`,children:q},$)})});return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"relative",children:l.jsx("div",{ref:v,onClick:ee,children:t})}),p&&Ja.createPortal(ie,document.body)]})}function rw(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],a=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0");return`${r} ${a}/${o}/${u}`}function id(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function g3(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=Math.floor((r.getTime()-a.getTime())/(1e3*60*60*24)),u=id(e);if(o===0)return`today ${u}`;if(o===1)return`yesterday ${u}`;if(o<7)return`${o} days ago ${u}`;{const d=t.getFullYear(),p=String(t.getMonth()+1).padStart(2,"0"),f=String(t.getDate()).padStart(2,"0");return`${d}/${p}/${f} ${u}`}}function sw(e){const t=new Date(e);return{year:t.getFullYear(),month:String(t.getMonth()+1).padStart(2,"0"),day:String(t.getDate()).padStart(2,"0")}}function x3(e){const{year:t,month:n,day:r}=sw(e);return`${t}-${n}-${r}`}function iw(e){const t=new Map;for(const a of e){const o=x3(a.updatedAt);t.has(o)||t.set(o,[]),t.get(o).push(a)}for(const[a,o]of t)o.sort((u,d)=>{const p=new Date(u.updatedAt).getTime();return new Date(d.updatedAt).getTime()-p});const n=Array.from(t.keys()).sort((a,o)=>o.localeCompare(a)),r=new Map;for(const a of n)r.set(a,t.get(a));return r}function y3({items:e,trigger:t,isActive:n=!1}){const[r,a]=k.useState(!1),o=k.useRef(null);return k.useEffect(()=>{function u(d){o.current&&!o.current.contains(d.target)&&a(!1)}if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),l.jsxs("div",{className:"relative",ref:o,children:[l.jsxs("button",{type:"button",onClick:()=>a(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?l.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,l.jsx(rs,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&l.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((u,d)=>{const p=u.label&&typeof u.label=="object"&&u.label.type===pr?u.label:null;if(p){const f=p.props.href||"";return l.jsxs(pr,{href:f,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,p.props.children]},d)}return u.href?l.jsxs("a",{href:u.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},d):l.jsxs("button",{type:"button",onClick:()=>{var f;(f=u.onClick)==null||f.call(u),a(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},d)})})]})}function b3({projects:e,currentProject:t}){const n=Ut(u=>u.loadProject),r=Ut(u=>u.toggleStar),o=k.useMemo(()=>{const u=e.filter(p=>p.isStarred).sort((p,f)=>p.name.localeCompare(f.name)),d=e.filter(p=>!p.isStarred).sort((p,f)=>p.name.localeCompare(f.name));return[...u,...d]},[e]).map(u=>({label:l.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[l.jsx("span",{className:"truncate flex-1",children:u.name}),l.jsx("button",{onClick:d=>{d.stopPropagation(),d.preventDefault(),d.nativeEvent.stopImmediatePropagation(),r(u.id,!u.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:u.isStarred?"Unstar project":"Star project",children:u.isStarred?l.jsx(Lj,{className:"w-3.5 h-3.5 text-yellow-500"}):l.jsx(Oj,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:u.id===t.id?l.jsx(ns,{}):void 0,href:`/p/${u.id}`,closeOnClick:!0,onClick:()=>{n(u.id)}}));return l.jsx(Fl,{items:o,trigger:l.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:t.name,children:[t.name,l.jsx(rs,{})]}),minWidth:"250px"})}function v3({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const a=t.filter(u=>u.projectId===e.id).sort((u,d)=>new Date(d.updatedAt).getTime()-new Date(u.updatedAt).getTime()).slice(0,5),o=[{label:l.jsxs(pr,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[l.jsx(Ga,{className:"w-3 h-3 text-accent-primary"}),l.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(u=>({label:l.jsx(pr,{href:`/p/${e.id}/s/${u.id}`,className:"flex items-center gap-2 truncate text-sm",children:l.jsx("span",{children:u.title??u.id.slice(0,8)})}),icon:u.id===(n==null?void 0:n.id)?l.jsx(ns,{className:"w-3 h-3"}):void 0})),{label:l.jsxs(pr,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[l.jsx(vj,{className:"w-3 h-3"}),l.jsx("span",{className:"text-sm",children:"Projects"})]})}];return l.jsx(y3,{items:o,trigger:l.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function _3({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var m;const o=ye(g=>g.loadSession),u=e.filter(g=>g.projectId===t.id).slice(0,15),d=iw(u),p=k.useMemo(()=>{const g=[];g.push({label:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Ga,{className:"w-4 h-4 text-accent-primary"}),l.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[v,b]of d){const _=b[0];if(_){g.push({label:l.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:rw(_.updatedAt)}),onClick:()=>{}});for(const S of b)g.push({label:l.jsxs("div",{className:"min-w-[160px]",children:[l.jsx("div",{className:"truncate text-sm",children:S.title??S.id.slice(0,8)}),l.jsx("div",{className:"text-text-muted text-xs",children:id(S.updatedAt)})]}),icon:S.id===(n==null?void 0:n.id)?l.jsx(ns,{}):void 0,href:`/p/${t.id}/s/${S.id}`,onClick:()=>{o(S.id)}})}}return g},[t.id,d,n==null?void 0:n.id]),f=n?((m=n.metadata)==null?void 0:m.title)??n.id.slice(0,8):"No session selected";return l.jsx(Fl,{items:p,isOpen:r,onOpenChange:a,trigger:l.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:f,"data-testid":"header-session-dropdown",children:[f,l.jsx(rs,{})]}),minWidth:"280px"})}function S3({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=k.useState(!1),[a,o]=k.useState(!1),[u,d]=k.useState(!!document.fullscreenElement);k.useEffect(()=>{const O=()=>d(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",O),()=>document.removeEventListener("fullscreenchange",O)},[]);const[p]=Hr(),f=p.startsWith("/p/"),m=/^\/p\/[^/]+\/s\/[^/]+$/.test(p),g=ye(O=>O.currentSession),v=ye(O=>O.sessions),b=Ut(O=>O.currentProject),_=Ut(O=>O.projects),S=Mt(O=>O.startAutoRefresh),j=Mt(O=>O.stopAutoRefresh),C=Br(O=>O.setOpen),E=Br(O=>O.isOpen);k.useEffect(()=>{const O=()=>o(!0);return window.addEventListener("open-session-dropdown",O),()=>window.removeEventListener("open-session-dropdown",O)},[]);const A=k.useRef(0);return k.useEffect(()=>{const O=z=>{if(z.key==="Control"&&!z.shiftKey&&!z.metaKey&&!z.altKey){const B=Date.now();B-A.current<300?(z.preventDefault(),z.stopPropagation(),Br.getState().toggleOpen(),A.current=0):A.current=B}};return window.addEventListener("keydown",O,!0),()=>window.removeEventListener("keydown",O,!0)},[]),k.useEffect(()=>(S(),()=>j()),[S,j]),l.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&f&&l.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle session list",children:l.jsx(d_,{})}),l.jsx(pr,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),b&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),l.jsx("span",{className:"hidden md:inline",children:l.jsx(b3,{projects:_,currentProject:b})}),l.jsx("span",{className:"md:hidden",children:l.jsx(v3,{currentProject:b,sessions:v,currentSession:g,projectIdFromUrl:f&&p.split("/")[2]||null},b==null?void 0:b.id)}),l.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),l.jsx("span",{className:"hidden md:inline",children:l.jsx(_3,{sessions:v,currentProject:b,currentSession:g,isOpen:a,onOpenChange:o})})]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&l.jsx("button",{onClick:()=>{var O,z,B;document.fullscreenElement?(O=document.exitFullscreen)==null||O.call(document):(B=(z=document.documentElement).requestFullscreen)==null||B.call(z)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:u?"Exit fullscreen":"Enter fullscreen",children:u?l.jsx(kj,{}):l.jsx(Cj,{})}),f&&l.jsx("button",{onClick:()=>C(!E),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${E?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:l.jsx(Bj,{})}),l.jsx("button",{onClick:()=>r(!0),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Settings",children:l.jsx(Mj,{})}),l.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),window.location.reload()},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:l.jsx(Ej,{})}),t&&m&&l.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle summary sidebar",children:l.jsx(d_,{})})]}),l.jsx(Xj,{isOpen:n,onClose:()=>r(!1)}),l.jsx(m3,{isOpen:E,onClose:()=>C(!1)})]})}function w3({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:o=n?"Saving...":"Save"}){return l.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[l.jsx(Ye,{variant:"secondary",onClick:e,children:a}),l.jsx(Ye,{variant:"primary",onClick:t,disabled:r??n,children:o})]})}function k3({isOpen:e,onClose:t,project:n}){const r=Ut(A=>A.updateProject),[a,o]=k.useState(n.customInstructions??""),[u,d]=k.useState(n.dangerLevel??""),[p,f]=k.useState(!1),[m,g]=k.useState(!1),[v,b]=k.useState(!1),_=p||m;k.useEffect(()=>{o(n.customInstructions??""),d(n.dangerLevel??""),f(!1),g(!1)},[n]);const S=A=>{o(A.target.value),f(!0)},j=A=>{d(A),g(!0)},C=async()=>{b(!0);const A=u===""?null:u;await r(n.id,{customInstructions:a||null,dangerLevel:A}),b(!1),f(!1),g(!1),t()},E=()=>{o(n.customInstructions??""),d(n.dangerLevel??""),f(!1),g(!1),t()};return l.jsx(Et,{isOpen:e,onClose:E,title:`${n.name} Settings`,size:"lg",footer:l.jsx(w3,{onCancel:E,onSave:C,saving:v,saveDisabled:!_||v}),children:l.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),l.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Default danger level for new sessions in this project. Existing sessions are not affected."}),l.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[l.jsx("button",{type:"button",onClick:()=>j(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${u===""?"bg-bg-tertiary text-text-primary border border-border":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Use global default (Normal)",children:"Default"}),l.jsx("button",{type:"button",onClick:()=>j("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${u==="normal"?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),l.jsx("button",{type:"button",onClick:()=>j("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${u==="dangerous"?"bg-red-500/20 text-red-400 border border-red-500/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),l.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),l.jsxs("div",{className:"flex-1 min-h-[150px] pb-4",children:[l.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),l.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files."}),l.jsx("textarea",{value:a,onChange:S,placeholder:"Enter project-specific instructions...",className:"w-full h-full px-3 py-2 mb-3 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:v})]}),p&&l.jsx(Wm,{})]})})}const C3={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},N3="M6 18L18 6M6 6l12 12";function $l({onClick:e,className:t="",size:n="md",variant:r="default"}){const a=r==="overlay"?"bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors":r==="sidebar"?"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors":r==="modal"?"text-text-muted hover:text-text-primary transition-colors":"hover:text-white transition-colors";return l.jsx(ed,{onClick:e,icon:N3,iconSize:C3[n],className:`${a} ${t}`,title:"Close"})}function aw({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Hr(),[a,o]=k.useState(!1),u=ye(z=>z.sessions),d=ye(z=>z.currentSession),p=ye(z=>z.unreadSessionIds),f=ye(z=>z.deleteSession),m=ye(z=>z.deleteAllSessions),g=ye(z=>z.loadMoreSessions),v=ye(z=>z.sessionsHasMore),b=ye(z=>z.sessionsPaginationLoading),_=Ut(z=>z.currentProject),S=k.useRef(null),j=k.useCallback(()=>{v&&!b&&_&&g(_.id)},[v,b,_,g]);k.useEffect(()=>{if(!S.current||!v)return;const z=new IntersectionObserver(B=>{const Y=B[0];Y&&Y.isIntersecting&&j()},{threshold:.1});return z.observe(S.current),()=>z.disconnect()},[v,j]);const C=u.filter(z=>z.projectId===(_==null?void 0:_.id)),E=(z,B)=>{B==null||B.stopPropagation(),confirm("Delete this session?")&&(f(z),(d==null?void 0:d.id)===z&&r(`/p/${e}`))},A=(z,B)=>{B==null||B.stopPropagation();const Y=u.find(D=>D.id===z),ee=(Y==null?void 0:Y.title)??z.slice(0,6),ie=prompt("Rename session:",ee);if(ie!==null&&ie.trim()!==""){const D=ye.getState().renameSession;D(z,ie.trim())}},O=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(m(e),r(`/p/${e}`))};return l.jsxs(l.Fragment,{children:[t&&n&&l.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),l.jsxs("aside",{className:`
|
|
95
|
+
${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden"}
|
|
96
|
+
md:relative md:h-auto md:translate-x-0
|
|
97
|
+
|
|
98
|
+
fixed z-50 h-[calc(100vh-32px)]
|
|
99
|
+
w-[300px] bg-secondary border-r border-border flex flex-col
|
|
100
|
+
transition-all duration-300 ease-in-out
|
|
101
|
+
${t?"translate-x-0":"-translate-x-full"}
|
|
102
|
+
`,children:[l.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[l.jsx(pr,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),l.jsx(Fl,{items:[{label:"Edit project settings",onClick:()=>o(!0)},{label:"Delete all sessions",onClick:O,danger:!0}],trigger:l.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:l.jsx(Lm,{})})}),n&&l.jsx($l,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),_&&l.jsx(k3,{isOpen:a,onClose:()=>o(!1),project:_}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:C.length===0?l.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"No sessions"}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"divide-y divide-border",children:j3(C,d,p,E,A,e)}),b&&l.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),l.jsx("div",{ref:S,className:"h-px"})]})})]})]})}function j3(e,t,n,r,a,o){const u=iw(e);return Array.from(u).map(([d,p])=>{const f=p[0];return f?l.jsxs("div",{children:[l.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:rw(f.updatedAt)}),p.map(m=>{const g=(t==null?void 0:t.id)===m.id,v=n.includes(m.id),b=m.isRunning;return l.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${g?"bg-bg-tertiary":""}`,children:l.jsxs(pr,{href:`/p/${o}/s/${m.id}`,className:`block ${g?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[l.jsxs("div",{className:"flex justify-between items-center mb-1",children:[l.jsx("span",{className:`font-medium truncate text-sm ${g?"text-accent-primary":"text-text-primary"}`,children:m.title??m.id.slice(0,6)}),l.jsx(Fl,{items:[{label:"Rename session",onClick:_=>a(m.id,_)},{label:"Delete session",onClick:_=>r(m.id,_),danger:!0}],trigger:l.jsx("button",{onClick:_=>_.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:l.jsx(Lm,{})})})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[b?l.jsx(Rj,{}):v&&!g?l.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,l.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:id(m.updatedAt)}),l.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[m.messageCount," messages"]})]})]})},m.id)})]},d):null})}const u0=["⠋","⠙","⠹","⠸","⠼","⠴"];function E3(){var d;const e=Ut(p=>p.currentProject),t=ye(p=>p.currentSession),n=Mm(),r=!1,a=k.useRef(0),o=k.useRef(null);k.useEffect(()=>(n?(o.current=window.setInterval(()=>{a.current=(a.current+1)%u0.length,u()},150),u()):(o.current&&(clearInterval(o.current),o.current=null),u()),()=>{o.current&&(clearInterval(o.current),o.current=null)}),[n,e,t,r]);const u=()=>{var g;const f=(g=t==null?void 0:t.metadata)==null?void 0:g.title,m=n?`${u0[a.current]} `:"";e&&f?document.title=`${m}${e.name} - ${f} | OpenFox`:e?document.title=`${m}${e.name} | OpenFox`:document.title=`${m}OpenFox`};return typeof window<"u"&&((d=t==null?void 0:t.metadata)!=null&&d.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function ow(e,t=28){if(e.length<=t)return e;const n=e.split("/").filter(Boolean);if(n.length<=2)return e;const r=n[0],a=n[n.length-1],o=n.slice(1,-1).join("/"),u=t-r.length-a.length-3;if(u<0)return e;const d=o.slice(0,Math.floor(u/2)),p=o.slice(-Math.ceil(u/2));return`/${r}/${d}...${p}/${a}`}function T3({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return l.jsx(Et,{isOpen:e,onClose:t,title:"Delete Project",size:"sm",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("p",{className:"text-text-secondary",children:["This will permanently delete the project"," ",l.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(Ye,{variant:"secondary",onClick:t,children:"Cancel"}),l.jsx(Ye,{variant:"danger",onClick:a,children:"Delete"})]})]})})}const ad=k.forwardRef(({className:e="",...t},n)=>l.jsx("input",{ref:n,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...t}));ad.displayName="Input";function A3(e){return!e||e.trim()===""?{valid:!1,error:"Project name cannot be empty"}:/^[a-zA-Z0-9._-]+$/.test(e)?{valid:!0}:{valid:!1,error:"Project name can only contain letters, numbers, hyphens, underscores, and dots"}}function lw({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,o]=k.useState(!1),[u,d]=k.useState(null),[p,f]=k.useState(null);k.useEffect(()=>{e&&m()},[e]);const m=async()=>{try{const O=await(await ke("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();f({sudoAvailable:O.sudoAvailable,userInGroup:O.userInGroup,groupHasWrite:O.groupHasWrite,groupName:O.groupName||null})}catch{f({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},g=k.useCallback(async A=>{o(!0),d(null);try{const z=await(await ke("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:A})})).json();z.success?(r(),t()):z.sudoAvailable?d("Failed to fix permissions: "+(z.error||"Unknown error")):d(`Passwordless sudo is not available. Please fix permissions manually:
|
|
103
|
+
|
|
104
|
+
`+(A==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(O){d("Failed to fix permissions: "+(O instanceof Error?O.message:"Unknown error"))}finally{o(!1)}},[n,r,t]),v=(p==null?void 0:p.userInGroup)??!1,b=(p==null?void 0:p.groupHasWrite)??!1,_=(p==null?void 0:p.sudoAvailable)??!1,S=(p==null?void 0:p.groupName)??"",j=v&&!b,C=!v&&b,E=!v&&!b;return l.jsx(Et,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"text-sm text-text-secondary",children:[l.jsx("p",{children:j?l.jsxs(l.Fragment,{children:["The group ",l.jsx("strong",{children:S})," doesn't have write access:"]}):C?l.jsxs(l.Fragment,{children:["You're not a member of group ",l.jsx("strong",{children:S}),":"]}):l.jsxs(l.Fragment,{children:["You're not a member of group ",l.jsx("strong",{children:S})," and it doesn't have write access:"]})}),l.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),u?l.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:u}):p?l.jsxs("div",{className:"flex flex-col gap-2",children:[j&&l.jsxs(l.Fragment,{children:[l.jsx(Ye,{type:"button",variant:"primary",onClick:()=>g("group"),disabled:a||!_,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),l.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),l.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),C&&l.jsxs(l.Fragment,{children:[l.jsx(Ye,{type:"button",variant:"primary",onClick:()=>g("join_group"),disabled:a||!_,className:"w-full",children:a?"Joining group...":"Join group"}),l.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),l.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",S," $USER"]})]}),E&&l.jsxs(l.Fragment,{children:[l.jsx(Ye,{type:"button",variant:"primary",onClick:()=>g("join_group_and_group"),disabled:a||!_,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),l.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),l.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",S," $USER",l.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!_&&!u&&l.jsxs("div",{className:"text-xs text-text-secondary",children:[l.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),l.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),l.jsx("div",{className:"flex justify-end",children:l.jsx(Ye,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function D3({isOpen:e,onClose:t}){const[,n]=Hr(),[r,a]=k.useState(""),[o,u]=k.useState(null),[d,p]=k.useState(!1),[f,m]=k.useState(""),[g,v]=k.useState(null),b=k.useRef(null);k.useEffect(()=>{e&&(ke("/api/config").then(O=>O.json()).then(O=>{O.workdir&&m(O.workdir)}),a(""),u(null),p(!1),v(null),setTimeout(()=>{var O;(O=b.current)==null||O.focus()},100))},[e]);const _=k.useCallback(async O=>{O.preventDefault();const z=A3(r);if(!z.valid){u(z.error);return}const B=`${f}/${r}`;await C(B)},[r,n,t,f]),S=k.useCallback(()=>{v(null)},[]),j=k.useCallback(async()=>{const O=`${f}/${r}`;await C(O)},[f,r,n,t,v,u,p]);async function C(O){p(!0),u(null),v(null);try{const z=await ke("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,workdir:O})});if(!z.ok){const ee=await z.json().catch(()=>({}));if(ee.code==="EACCES"){v(O),p(!1);return}throw new Error(ee.error||"Failed to create project")}const Y=(await z.json()).project;t(),n(`/p/${Y.id}`)}catch(z){u(z instanceof Error?z.message:"Failed to create project"),p(!1)}}const E=k.useCallback(()=>{a(""),u(null),t()},[t]),A=r?`${f}/${r}`:"";return l.jsxs(l.Fragment,{children:[l.jsx(Et,{isOpen:e,onClose:E,title:"Create New Project",size:"sm",children:l.jsxs("form",{onSubmit:_,className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),l.jsx(ad,{ref:b,id:"project-name",value:r,onChange:O=>{a(O.target.value),u(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),r&&l.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",l.jsx("span",{className:"font-mono",children:A})]}),o&&l.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:o})]}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(Ye,{type:"button",variant:"secondary",onClick:E,disabled:d,children:"Cancel"}),l.jsx(Ye,{type:"submit",variant:"primary",disabled:d||!r.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(Ga,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&l.jsx(lw,{isOpen:!!g,onClose:S,path:g,onRetry:j})]})}const M3={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function Ul({size:e="md",className:t=""}){return l.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${M3[e]} ${t}`})}function R3({text:e,...t}){return l.jsxs("div",{className:"text-center",children:[l.jsx(Ul,{...t,className:"mx-auto mb-4"}),e&&l.jsx("div",{className:"text-text-secondary",children:e})]})}function cw({onSelect:e,onClose:t,initialPath:n}){const[r,a]=k.useState(null),[o,u]=k.useState(!0),[d,p]=k.useState(""),[f,m]=k.useState(-1),g=k.useRef(null),v=k.useRef([]),b=k.useCallback(async E=>{u(!0),p(""),m(-1);try{const A=E?`/api/directories?path=${encodeURIComponent(E)}`:"/api/directories",z=await(await ke(A)).json();a(z)}catch(A){console.error("Failed to load directories:",A)}finally{u(!1)}},[]);k.useEffect(()=>{b(n)},[n,b]);const _=((r==null?void 0:r.current)??"").split("/").filter(Boolean).map((E,A,O)=>({name:E,path:"/"+O.slice(0,A+1).join("/")})),S=(r==null?void 0:r.directories.filter(E=>d===""||E.name.toLowerCase().includes(d.toLowerCase())))??[],j=[...r!=null&&r.parent?[{type:"parent",path:r.parent,name:".."}]:[],...S.map(E=>({type:"dir",path:E.path,name:E.name}))];k.useEffect(()=>{m(d?0:-1)},[d,S.length]),k.useEffect(()=>{var E;f>=0&&v.current[f]&&((E=v.current[f])==null||E.scrollIntoView({block:"nearest"}))},[f]);const C=E=>{var A;if(E.key==="ArrowDown")E.preventDefault(),m(O=>Math.min(O+1,j.length-1));else if(E.key==="ArrowUp")E.preventDefault(),m(O=>Math.max(O-1,0));else if(E.key==="Enter"){if(E.preventDefault(),f>=0&&j[f]){const O=j[f];O.type,b(O.path)}}else E.key==="Escape"&&(p(""),(A=g.current)==null||A.focus())};return l.jsxs(Et,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",children:[r&&l.jsx("div",{className:"px-3 py-2 bg-bg-tertiary/30 -mx-4 -mt-4 mb-4 border-b border-border",children:l.jsxs("div",{className:"flex items-center text-xs overflow-x-auto",children:[_.map((E,A)=>l.jsxs("span",{className:"flex items-center shrink-0",children:[l.jsx("span",{className:"text-text-muted",children:"/"}),l.jsx("button",{onClick:()=>b(E.path),className:`px-1 ${A===_.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:E.name})]},E.path)),_.length===0&&l.jsx("button",{onClick:()=>b("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]})}),l.jsx("div",{className:"px-4 mb-3",children:l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none flex items-center justify-center",children:l.jsx(Im,{})}),l.jsx(ad,{autoFocus:!0,ref:g,value:d,onChange:E=>p(E.target.value),onKeyDown:C,placeholder:"Filter directories...",className:"w-full pl-9"})]})}),l.jsx("div",{className:"flex-1 overflow-y-auto -mx-4",children:o?l.jsx("div",{className:"p-8 text-center",children:l.jsx(Ul,{size:"sm"})}):j.length===0?l.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:d?"No matching directories":"No subdirectories"}):l.jsx("div",{className:"divide-y divide-border",children:j.map((E,A)=>l.jsxs("button",{ref:O=>{v.current[A]=O},onClick:()=>b(E.path),onDoubleClick:()=>e(E.path),className:`w-full p-3 flex items-center gap-3 text-left transition-colors ${A===f?"bg-accent-primary/20 text-accent-primary":"hover:bg-bg-tertiary/50"}`,children:[E.type==="parent"?l.jsx(yj,{className:"w-5 h-5 text-text-muted"}):l.jsx(Om,{className:"w-5 h-5"}),l.jsx("span",{className:"flex-1",children:E.name}),A===f&&l.jsx("span",{className:"text-xs text-text-muted",children:"⏎ navigate · dbl-click select"})]},E.path))})}),l.jsxs("div",{className:"flex flex-col gap-2 pt-4 border-t border-border mt-4 -mx-4 -mb-4 p-4",children:[(r==null?void 0:r.current)&&l.jsx("button",{onClick:()=>e(r.current),className:"w-full px-4 py-2 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Select this folder"}),l.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]})]})}function L3({isOpen:e,onClose:t}){const[,n]=Hr(),[r,a]=k.useState(!1),[o,u]=k.useState(null),[d,p]=k.useState(!1),f=Ut(D=>D.projects),m=Ut(D=>D.createProject),g=Ut(D=>D.listProjects),v=Ut(D=>D.deleteProject),[b,_]=k.useState(null),[S,j]=k.useState(null),[C,E]=k.useState(null);k.useEffect(()=>{ke("/api/config").then(D=>D.json()).then(D=>{D.workdir&&u(D.workdir)})},[]),k.useEffect(()=>{e&&g()},[e,g]);const A=D=>{n(`/p/${D}`),t()},O=(D,$)=>{$.stopPropagation(),_(D)},z=()=>{b&&(v(b.id),_(null))},B=async D=>{const $=D.split("/").filter(Boolean).pop()??"",H=await m($,D);return g(),j(D),Y(H)?(E(H.error.path||D),!1):!0};function Y(D){return D!=null&&typeof D=="object"&&"error"in D&&D.error!=null&&typeof D.error=="object"&&"code"in D.error&&D.error.code==="EACCES"}const ee=k.useCallback(()=>{E(null)},[]),ie=k.useCallback(async()=>{if(E(null),S){const D=S.split("/").filter(Boolean).pop()??"",$=await m(D,S);g(),j(S),Y($)&&E($.error.path||S)}},[S,m,g,E]);return k.useEffect(()=>{if(S){const D=f.find($=>$.workdir===S);D&&(n(`/p/${D.id}`),t(),j(null))}},[f,S,n,t]),e?l.jsxs(Et,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:l.jsx("div",{className:"flex justify-end gap-2",children:l.jsx(Ye,{variant:"secondary",onClick:t,children:"Close"})}),children:[l.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[l.jsxs("div",{className:"w-full sm:w-1/2 border-b sm:border-b-0 sm:border-r border-border flex flex-col max-h-[40vh] sm:max-h-[50vh]",children:[l.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:l.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:f.length===0?l.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[l.jsx("p",{className:"mb-2",children:"No recent projects"}),l.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):l.jsx("div",{className:"divide-y divide-border",children:f.map(D=>l.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[l.jsxs("button",{onClick:()=>A(D.id),className:"flex-1 flex items-center gap-3 text-left",children:[l.jsx(Om,{className:"w-5 h-5 text-accent-primary"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"font-medium truncate",children:D.name}),l.jsx("div",{className:"text-xs text-text-muted truncate",children:ow(D.workdir,32)})]})]}),l.jsx("button",{onClick:$=>O(D,$),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:l.jsx(Ju,{className:"w-4 h-4"})})]},D.id))})})]}),l.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:l.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[l.jsx(Ye,{variant:"primary",onClick:()=>p(!0),children:"Select existing project"}),l.jsx(Ye,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&l.jsx(D3,{isOpen:r,onClose:()=>a(!1)}),b&&l.jsx(T3,{isOpen:!0,onClose:()=>_(null),projectName:b.name,onConfirm:z}),d&&l.jsx(cw,{initialPath:o??void 0,onSelect:D=>{B(D).then($=>{$&&p(!1)})},onClose:()=>p(!1)}),C&&l.jsx(lw,{isOpen:!0,onClose:ee,path:C,onRetry:ie})]}):null}function O3(){const[e,t]=k.useState(!1),n=ye(g=>g.sessions),r=Ut(g=>g.projects),a=Ut(g=>g.loading),o=Ut(g=>g.listProjects),u=ye(g=>g.listSessions),d=ye(g=>g.connectionStatus);k.useEffect(()=>{d==="connected"&&(o(),u())},[d,o,u]);const p=[...r].sort((g,v)=>{const b=n.filter(C=>C.workdir.startsWith(g.workdir)),_=n.filter(C=>C.workdir.startsWith(v.workdir)),S=b.length>0?new Date(b.reduce((C,E)=>new Date(E.updatedAt)>new Date(C.updatedAt)?E:C).updatedAt).getTime():new Date(g.updatedAt).getTime();return(_.length>0?new Date(_.reduce((C,E)=>new Date(E.updatedAt)>new Date(C.updatedAt)?E:C).updatedAt).getTime():new Date(v.updatedAt).getTime())-S}),f=g=>{const v=r.find(b=>b.id===g);return v?n.filter(b=>b.workdir.startsWith(v.workdir)).sort((b,_)=>new Date(_.updatedAt).getTime()-new Date(b.updatedAt).getTime()).slice(0,5):[]},m=()=>{t(!0)};return l.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto bg-primary",children:[l.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[l.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),l.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),l.jsx(Ye,{variant:"primary",onClick:m,children:"Open Project"})]}),p.map(g=>{const v=f(g.id);return l.jsx("div",{className:"mb-6 md:mb-8",children:l.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[l.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[l.jsxs(pr,{href:`/p/${g.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[l.jsx(Om,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),l.jsx("span",{className:"text-text-primary font-semibold",children:g.name})]}),l.jsx(pr,{href:`/p/${g.id}/new`,className:"rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-1.5 py-1 text-xs",children:"+ New Session"})]}),l.jsx("div",{className:"divide-y divide-border",children:v.length>0?v.map(b=>{const _=r.find(j=>b.workdir.startsWith(j.workdir)),S=_?`/p/${_.id}/s/${b.id}`:"#";return l.jsx(pr,{href:S,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:l.jsx("div",{className:"flex-1 min-w-0",children:l.jsx("div",{className:"text-sm text-text-muted truncate",children:b.title??b.id.slice(0,8)})})}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx("span",{className:"text-text-muted text-xs",children:g3(b.updatedAt)}),l.jsxs("span",{className:"text-text-muted text-xs",children:[b.messageCount," msgs"]})]})]})},b.id)}):l.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},g.id)}),p.length===0&&!a&&l.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),a&&l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(Ul,{})})]}),e&&l.jsx(L3,{isOpen:e,onClose:()=>t(!1)})]})}function I3(){const[,e]=Dm("/p/:projectId/new"),[,t]=Hr(),n=e==null?void 0:e.projectId,r=ye(u=>u.createSession),a=ye(u=>u.resetPendingSessionCreate),o=k.useCallback(async()=>{if(!n)return;const u=await r(n);u?(t(`/p/${n}/s/${u.id}`),a()):(t(`/p/${n}`),a())},[n,r,t,a]);return k.useEffect(()=>{o()},[o]),l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsx(Ul,{})})}function B3(){const e=Ut(t=>t.currentProject);return l.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:l.jsxs("div",{className:"max-w-md",children:[l.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),l.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),l.jsxs("div",{className:"flex flex-col gap-3",children:[e&&l.jsx(pr,{href:`/p/${e.id}/new`,"data-testid":"create-new-session-button",className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),l.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const al=e=>Math.round(e*10)/10;function dm(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function z3(e){return`${e.providerId}::${e.model}`}function P3(e){return`${e.providerName} > ${e.model}`}function d0(e){let t=0,n=0,r=0,a=0,o=0,u=0;const d=[],p=[];let f=0;for(const[v,b]of e.entries()){const _=b.stats,S=dm(_);t+=_.totalTime,n+=_.toolTime,r+=_.prefillTokens,a+=_.generationTokens;const j=_.prefillSpeed>0?_.prefillTokens/_.prefillSpeed:0,C=_.generationSpeed>0?_.generationTokens/_.generationSpeed:0;o+=j,u+=C,d.push({messageId:b.id,timestamp:b.timestamp,...S,mode:_.mode,responseIndex:v+1,prefillTokens:_.prefillTokens,generationTokens:_.generationTokens,prefillSpeed:_.prefillSpeed,generationSpeed:_.generationSpeed,totalTime:_.totalTime,aiTime:_.totalTime-_.toolTime,toolTime:_.toolTime});const E=_.llmCalls??[];for(const A of E)f+=1,p.push({messageId:b.id,timestamp:A.timestamp??b.timestamp,providerId:A.providerId,providerName:A.providerName,backend:A.backend,model:A.model,mode:_.mode,responseIndex:v+1,sessionCallIndex:f,callIndex:A.callIndex,promptTokens:A.promptTokens,completionTokens:A.completionTokens,ttft:A.ttft,completionTime:A.completionTime,prefillSpeed:A.prefillSpeed,generationSpeed:A.generationSpeed,totalTime:A.totalTime,...A.temperature!==void 0&&{temperature:A.temperature},...A.topP!==void 0&&{topP:A.topP},...A.topK!==void 0&&{topK:A.topK},...A.maxTokens!==void 0&&{maxTokens:A.maxTokens}})}const m=o>0?al(r/o):0,g=u>0?al(a/u):0;return{totalTime:al(t),aiTime:al(t-n),toolTime:al(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:m,avgGenerationSpeed:g,responseCount:e.length,llmCallCount:p.length,dataPoints:d,callDataPoints:p}}function H3(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null).sort((a,o)=>new Date(a.timestamp).getTime()-new Date(o.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const o=z3(dm(a.stats)),u=n.get(o)??[];n.set(o,[...u,a])}const r=Array.from(n.entries()).map(([a,o])=>{const u=dm(o[0].stats),d=d0(o);return{...u,key:a,label:P3(u),...d}});return{...d0(t),modelGroups:r}}function F3(e){return k.useMemo(()=>H3(e),[e])}function uw(){var a;const e=ye(o=>o.gitStatus),t=ye(o=>o.currentSession),[n,r]=k.useState(!0);return k.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((a=e==null?void 0:e.diff)==null?void 0:a.files)??[],loading:n,error:null}}}function Pu(e){return e.toLocaleString("en-US").replace(/,/g," ")}function h0(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function $3(e){if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=Math.round(e%60);return`${t}m${n}s`}const f0=["▁","▂","▃","▄","▅","▆","▇","█"];function U3(e,t,n){if(n===t)return 4;const r=(e-t)/(n-t);return Math.min(7,Math.max(0,Math.round(r*7)))}function W3(e,t){if(e===t){const a=Math.max(Math.abs(e)*.05,1);return{minY:e-a,maxY:t+a}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function q3(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((g,v)=>g.x-v.x),r=n[0].x,a=n[n.length-1].x,o=Math.min(...n.map(g=>g.y)),u=Math.max(...n.map(g=>g.y)),{minY:d,maxY:p}=W3(o,u),f=Array.from({length:t},()=>" "),m=new Map;for(const g of n){const v=a===r?0:Math.round((g.x-r)/(a-r)*(t-1)),b=m.get(v)??[];m.set(v,[...b,g.y])}for(const[g,v]of m){const b=Math.max(...v);f[g]=f0[U3(b,d,p)]??f0[0]}return{blocks:f.join(""),minX:r,maxX:a,minY:d,maxY:p}}function p0(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function m0({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:o,showAxes:u=!0,formatY:d=p0,formatX:p=p0}){const f=k.useMemo(()=>{const m=q3(e,t),g=Math.max(t*6,240),v=10,b=8,S=[...e].sort((A,O)=>A.x-O.x).map(A=>{const O=m.maxX===m.minX?g/2:v+(A.x-m.minX)/(m.maxX-m.minX)*(g-v*2),z=m.maxY===m.minY?n/2:b+(m.maxY-A.y)/(m.maxY-m.minY)*(n-b*2);return{...A,cx:O,cy:z,leftPercent:O/g*100,topPercent:z/n*100}}),j=S.map((A,O)=>`${O===0?"M":"L"} ${A.cx.toFixed(1)} ${A.cy.toFixed(1)}`).join(" "),E=[m.maxY,(m.maxY+m.minY)/2,m.minY].map(A=>({value:A,y:m.maxY===m.minY?n/2:b+(m.maxY-A)/(m.maxY-m.minY)*(n-b*2)}));return{...m,chartWidth:g,points:S,path:j,gridLines:E}},[e,n,t]);return e.length===0?l.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&l.jsx("div",{className:"mb-1",children:r}),l.jsx("div",{children:"No data"})]}):l.jsxs("div",{className:"font-mono text-xs",children:[r&&l.jsx("div",{className:"text-text-secondary mb-2",children:r}),l.jsxs("div",{className:"flex gap-3",children:[u&&l.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:f.gridLines.map(m=>l.jsx("span",{children:d(m.value)},`${m.value}-${m.y}`))}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsxs("div",{className:"relative h-[78px]",children:[l.jsxs("svg",{viewBox:`0 0 ${f.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[f.gridLines.map(m=>l.jsx("line",{x1:"0",x2:f.chartWidth,y1:m.y,y2:m.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${m.y}`)),f.points.map(m=>l.jsx("line",{x1:m.cx,x2:m.cx,y1:n-4,y2:m.cy,stroke:"currentColor",className:"text-border/40"},`guide-${m.cx}-${m.cy}`)),f.points.length>1&&l.jsx("path",{d:f.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),f.points.map(m=>l.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${m.leftPercent}%`,top:`${m.topPercent}%`},title:`${p(m.x)} -> ${d(m.y)}`,children:l.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:l.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${m.x}-${m.y}`))]})})]}),u&&l.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[l.jsx("span",{className:"w-12"}),l.jsxs("span",{className:"flex-1 flex justify-between",children:[l.jsx("span",{children:p(f.minX)}),l.jsx("span",{children:a}),l.jsx("span",{children:p(f.maxX)})]})]}),o&&u&&l.jsx("div",{className:"text-text-muted mt-1 text-center",children:o})]})}function V3({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:a=60}){const o=e.map(d=>({x:d.x,y:d.ppSpeed})),u=e.map(d=>({x:d.x,y:d.tgSpeed}));return l.jsxs("div",{className:"space-y-5",children:[l.jsx(m0,{data:o,width:a,label:t,xLabel:r}),l.jsx(m0,{data:u,width:a,label:n,xLabel:r})]})}function K3(e){const t=new Map;for(const n of e.callDataPoints){const r=t.get(n.messageId)??[];t.set(n.messageId,[...r,n])}return e.dataPoints.map(n=>{const r=[...t.get(n.messageId)??[]].sort((a,o)=>a.callIndex-o.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function G3(e){return{mode:"responses",xLabel:"response",prefillLabel:"Prefill Speed (tok/s) by Response",generationLabel:"Generation Speed (tok/s) by Response",points:e.dataPoints.map(t=>({x:t.responseIndex,ppSpeed:t.prefillSpeed,tgSpeed:t.generationSpeed}))}}function Y3(e){return{mode:"calls",xLabel:"context",prefillLabel:"Prefill Speed (tok/s) vs Context",generationLabel:"Generation Speed (tok/s) vs Context",points:e.callDataPoints.map(t=>({x:t.promptTokens,ppSpeed:t.prefillSpeed,tgSpeed:t.generationSpeed}))}}function X3(e){return e.callDataPoints.length>0?Y3(e):G3(e)}function tp(e){if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=e%60;return`${t}m ${n.toFixed(0)}s`}function $i(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function bl(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Z3(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${$i(t)} ctx`:`${$i(t)}-${$i(n)} ctx`}function Hu(e){return`${bl(e)} t/s`}function dw(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function Q3(e){return{exportedAt:new Date().toISOString(),providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model,label:e.label,summary:{totalTime:e.totalTime,aiTime:e.aiTime,toolTime:e.toolTime,prefillTokens:e.prefillTokens,generationTokens:e.generationTokens,avgPrefillSpeed:e.avgPrefillSpeed,avgGenerationSpeed:e.avgGenerationSpeed,responseCount:e.responseCount,llmCallCount:e.llmCallCount},responses:e.dataPoints.map(t=>({responseIndex:t.responseIndex,timestamp:t.timestamp,mode:t.mode,prefillTokens:t.prefillTokens,generationTokens:t.generationTokens,prefillSpeed:t.prefillSpeed,generationSpeed:t.generationSpeed,totalTime:t.totalTime,aiTime:t.aiTime,toolTime:t.toolTime})),llmCalls:e.callDataPoints.map(t=>({sessionCallIndex:t.sessionCallIndex,responseIndex:t.responseIndex,callIndex:t.callIndex,timestamp:t.timestamp,mode:t.mode,promptTokens:t.promptTokens,completionTokens:t.completionTokens,ttft:t.ttft,completionTime:t.completionTime,prefillSpeed:t.prefillSpeed,generationSpeed:t.generationSpeed,totalTime:t.totalTime}))}}function J3({isOpen:e,onClose:t,stats:n}){const r=k.useRef(null),[a,o]=k.useState({}),[u,d]=k.useState(()=>{var _;return((_=n.modelGroups[0])==null?void 0:_.key)??""});k.useEffect(()=>{var _;n.modelGroups.some(S=>S.key===u)||d(((_=n.modelGroups[0])==null?void 0:_.key)??"")},[u,n.modelGroups]);const p=k.useMemo(()=>n.modelGroups.find(_=>_.key===u)??n.modelGroups[0],[u,n.modelGroups]),f=k.useMemo(()=>p?K3(p):[],[p]),m=k.useMemo(()=>p?X3(p):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[p]),g=k.useCallback(_=>{o(S=>({...S,[_]:!S[_]}))},[]),v=k.useCallback(()=>{if(!p)return;const _=Q3(p);navigator.clipboard.writeText(JSON.stringify(_,null,2)).catch(S=>console.error("Failed to copy:",S))},[p]),b=k.useCallback(async()=>{if(r.current)try{const _=(await Cp(async()=>{const{default:C}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:C}},[])).default,S=await _(r.current,{backgroundColor:"#1a1a1a",scale:2}),j=document.createElement("a");j.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,j.href=S.toDataURL("image/png"),j.click()}catch(_){console.error("Failed to export PNG:",_),v()}},[v]);return l.jsx(Et,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:l.jsxs("div",{ref:r,className:"space-y-6",children:[l.jsx("section",{children:l.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(_=>l.jsx("button",{onClick:()=>d(_.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${_.key===(p==null?void 0:p.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:_.label,children:_.label},_.key))})}),p&&l.jsxs("section",{children:[l.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[l.jsx(Cs,{label:"AI Time",value:tp(p.aiTime)}),l.jsx(Cs,{label:"Total Time",value:tp(p.totalTime)}),l.jsx(Cs,{label:"Tool Time",value:tp(p.toolTime)}),l.jsx(Cs,{label:"Responses",value:p.responseCount.toString()}),l.jsx(Cs,{label:"LLM Calls",value:p.llmCallCount.toString()})]}),l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[l.jsx(Cs,{label:"Prefill Tokens",value:$i(p.prefillTokens),subValue:`@ ${bl(p.avgPrefillSpeed)} tok/s`}),l.jsx(Cs,{label:"Gen Tokens",value:$i(p.generationTokens),subValue:`@ ${bl(p.avgGenerationSpeed)} tok/s`}),l.jsx(Cs,{label:"Avg PP Speed",value:`${bl(p.avgPrefillSpeed)}`,subValue:"tok/s"}),l.jsx(Cs,{label:"Avg TG Speed",value:`${bl(p.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),p&&m.points.length>1&&l.jsxs("section",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:v,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),l.jsx("button",{onClick:b,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),l.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:l.jsx(V3,{data:m.points,width:50,prefillLabel:m.prefillLabel,generationLabel:m.generationLabel,xLabel:m.xLabel})})]}),p&&l.jsxs("section",{children:[l.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",p.responseCount," responses)"]}),l.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:l.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[l.jsxs("colgroup",{children:[l.jsx("col",{className:"w-[7%]"}),l.jsx("col",{className:"w-[14%]"}),l.jsx("col",{className:"w-[10%]"}),l.jsx("col",{className:"w-[14%]"}),l.jsx("col",{className:"w-[14%]"}),l.jsx("col",{className:"w-[14%]"}),l.jsx("col",{className:"w-[11%]"}),l.jsx("col",{className:"w-[2%]"})]}),l.jsx("thead",{children:l.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[l.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),l.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),l.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),l.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),l.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),l.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),l.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),l.jsx("th",{className:"px-2 py-2"})]})}),l.jsx("tbody",{children:f.map((_,S)=>l.jsxs(k.Fragment,{children:[l.jsx(eA,{row:_,index:S,isExpanded:a[_.messageId]??!1,onToggle:_.isExpandable?()=>g(_.messageId):void 0}),(a[_.messageId]??!1)&&_.calls.map((j,C)=>l.jsx(tA,{dataPoint:j,index:C},`${j.messageId}-${j.callIndex}`))]},_.messageId))})]})})]})]})})}function Cs({label:e,value:t,subValue:n}){return l.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[l.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),l.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&l.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function eA({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?Z3(e.calls.map(o=>o.promptTokens)):`${$i(e.prefillTokens)} ctx`;return l.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[l.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),l.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:dw(e.timestamp)}),l.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),l.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),l.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Hu(e.prefillSpeed)}),l.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Hu(e.generationSpeed)}),l.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),l.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function tA({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return l.jsxs(l.Fragment,{children:[l.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[l.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),l.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:dw(e.timestamp)}),l.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),l.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:$i(e.promptTokens)}),l.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Hu(e.prefillSpeed)}),l.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Hu(e.generationSpeed)}),l.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),l.jsx("td",{className:"px-2 py-2"})]}),n&&l.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:l.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:l.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&l.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&l.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&l.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&l.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const nA={pending:{icon:"○",color:"text-text-muted",label:"Pending"},in_progress:{icon:"●",color:"text-accent-warning",label:"In Progress",animate:!0},completed:{icon:"◉",color:"text-purple-400",label:"Completed"},passed:{icon:"✓",color:"text-accent-success",label:"Passed"},failed:{icon:"✗",color:"text-accent-error",label:"Failed"}},rA=k.memo(function({criteria:t}){if(t.length===0)return l.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No criteria yet"});const n={pending:0,in_progress:0,completed:0,passed:0,failed:0};for(const a of t){const o=a.status.type;o in n&&n[o]++}const r=Object.keys(n).filter(a=>n[a]>0);return l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("span",{className:"font-semibold text-text-primary",children:"Total:"}),l.jsx("span",{className:"text-text-secondary",children:t.length})]}),l.jsx("div",{className:"space-y-1",children:r.map(a=>{const o=nA[a];return l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("span",{className:`${o.color} ${o.animate?"animate-pulse":""} text-sm leading-tight`,children:o.icon}),l.jsxs("span",{className:"text-text-muted",children:[o.label,":"]}),l.jsx("span",{className:"text-text-primary font-medium",children:n[a]})]},a)})})]})});function sA({isOpen:e,onClose:t}){const n=Qr(S=>S.config),r=Qr(S=>S.saveConfig),[a,o]=k.useState(""),[u,d]=k.useState(""),[p,f]=k.useState(!1),[m,g]=k.useState(!1),[v,b]=k.useState(!1);k.useEffect(()=>{e&&(o((n==null?void 0:n.command)??""),d((n==null?void 0:n.url)??""),f((n==null?void 0:n.hotReload)??!1),g((n==null?void 0:n.disableInspect)??!1))},[e,n]);const _=async()=>{!a.trim()||!u.trim()||(b(!0),await r({command:a.trim(),url:u.trim(),hotReload:p,disableInspect:m}),b(!1),t())};return l.jsx(Et,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),l.jsx("input",{className:"input w-full",type:"text",value:a,onChange:S=>o(S.target.value),placeholder:"npm run dev"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),l.jsx("input",{className:"input w-full",type:"text",value:u,onChange:S=>d(S.target.value),placeholder:"http://localhost:3000"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"hotReload",checked:p,onChange:S=>f(S.target.checked),className:"rounded border-border bg-bg-tertiary"}),l.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"disableInspect",checked:m,onChange:S=>g(S.target.checked),className:"rounded border-border bg-bg-tertiary"}),l.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[l.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),l.jsx("button",{className:"btn btn-primary",onClick:_,disabled:v||!a.trim()||!u.trim(),children:v?"Saving...":"Save"})]})]})})}const g0={30:"text-black",31:"text-red-400",32:"text-accent-success",33:"text-accent-warning",34:"text-blue-400",35:"text-purple-400",36:"text-cyan-400",37:"text-gray-300",90:"text-gray-500",91:"text-red-500",92:"text-green-500",93:"text-yellow-400",94:"text-blue-500",95:"text-pink-400",96:"text-cyan-500",97:"text-white"},iA={40:"bg-black",41:"bg-red-900",42:"bg-green-900",43:"bg-yellow-900",44:"bg-blue-900",45:"bg-purple-900",46:"bg-cyan-900",47:"bg-gray-700"},x0={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},aA="text-text-primary";function oA(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,a="text-text-primary",o;try{for(;(o=n.exec(e))!==null;){if(o.index>r){const f=e.slice(r,o.index);f&&t.push({text:f,className:a})}const u=o[1];if(!u)continue;const d=u.split(";").map(Number);if(d.length===0||d[0]===0){a="text-text-primary";continue}const p=[];for(const f of d)if(f>=30&&f<=37){const m=g0[f];m&&p.push(m)}else if(f>=40&&f<=47){const m=iA[f];m&&p.push(m)}else if(f>=90&&f<=97){const m=g0[f];m&&p.push(m)}else if(f in x0){const m=x0[f];m&&p.push(m)}else f===39?p.push(aA):f===49&&(a=a.split(" ").filter(m=>!m.startsWith("bg-")).join(" "));p.length>0&&(a=p.join(" ")),r=n.lastIndex}if(r<e.length){const u=e.slice(r);u&&t.push({text:u,className:a})}return t}catch(u){return console.warn("ANSI parsing failed, stripping codes:",u),[{text:lA(e),className:"text-text-primary"}]}}function lA(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function Fu(e){const t=oA(e),n=[];return t.forEach((r,a)=>{const o=r.text.split(`
|
|
105
|
+
`);o.forEach((u,d)=>{n.push(zn.createElement("span",{key:`${a}-${d}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),d<o.length-1&&n.push(zn.createElement("br",{key:`${a}-${d}-br`}))})}),n.length===1?n[0]:n}function hw({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return l.jsx("pre",{ref:t,className:n,children:e.length===0?l.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((r,a)=>l.jsx("span",{className:r.stream==="stderr"?"text-accent-warning":"",children:Fu(r.content)},a))})}const fw=k.memo(function({title:t,logs:n,onClose:r,preClassName:a}){const o=k.useRef(null);return k.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[n]),l.jsx(Et,{isOpen:!0,onClose:r,title:t,size:"full",children:l.jsx(hw,{logs:n,preRef:o,preClassName:a})})}),cA=k.memo(function({logs:t,anchorRef:n,isHiding:r,onExpand:a,onClose:o}){const[u,d]=k.useState(null),p=k.useRef(null);return k.useEffect(()=>{var m;const f=(m=n.current)==null?void 0:m.getBoundingClientRect();f&&d({bottom:window.innerHeight-f.bottom,right:window.innerWidth-f.right,width:f.width,height:f.height})},[n]),k.useEffect(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[t]),u?l.jsxs("div",{className:"relative",children:[l.jsx("pre",{ref:p,className:"fixed z-50 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border overflow-auto transition-all duration-150 ease-out select-text",style:{bottom:u.bottom,right:u.right,width:u.width*2,maxHeight:u.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1},children:t.map((f,m)=>l.jsx("span",{className:f.stream==="stderr"?"text-accent-warning":"",children:Fu(f.content)},m))}),l.jsx("button",{onClick:()=>{o(),a()},className:"fixed z-50 px-2 py-1 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors duration-150",style:{bottom:u.bottom+8,right:u.right+8},children:"Expand"})]}):null}),uA=k.memo(function({workdir:t}){const n=Qr(H=>H.setWorkdir),r=Qr(H=>H.status),a=Qr(H=>H.config),o=Qr(H=>H.logs),u=Qr(H=>H.start),d=Qr(H=>H.stop),p=Qr(H=>H.fetchLogs),f=ye(H=>H.currentSession),[m,g]=k.useState(!1),[v,b]=k.useState(!1),[_,S]=k.useState(!1),[j,C]=k.useState(!1),E=k.useRef(null),A=k.useRef(null),O=k.useRef(null),z=k.useRef(null),B=k.useRef(null),Y=()=>{const H=r==null?void 0:r.inspectProxyPort;if(!H){r!=null&&r.url&&window.open(r.url,"_blank");return}const U=`${window.location.protocol}//${window.location.hostname}:${H}`,q=window.open(U,"_blank");if(q){B.current=q;const T=()=>{var F;!B.current||B.current.closed||(B.current.postMessage({type:"setFoxSessionId",sessionId:(f==null?void 0:f.id)??null},"*"),B.current.postMessage({type:"setFoxSessionTitle",sessionTitle:((F=f==null?void 0:f.metadata)==null?void 0:F.title)??null},"*"),B.current.postMessage({type:"setFoxInspectEnabled",enabled:!(a!=null&&a.disableInspect)},"*"))},N=setInterval(()=>{T(),(!B.current||B.current.closed)&&clearInterval(N)},500);setTimeout(()=>clearInterval(N),5e3)}},ee=(r==null?void 0:r.state)??"off",ie=a!==null,D=ee==="running"||ee==="warning";k.useEffect(()=>{n(t??null)},[t,n]),k.useEffect(()=>{D&&p()},[D,p]),k.useEffect(()=>{O.current&&D&&(O.current.scrollTop=O.current.scrollHeight)},[o,D]);const $=()=>{D?d():u()};return l.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${ee==="running"?"bg-accent-success":ee==="warning"?"bg-accent-warning":ee==="error"?"bg-accent-error":"bg-text-muted"}`}),l.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),l.jsx("button",{onClick:()=>g(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:l.jsx(Nj,{})})]}),ie?l.jsxs(l.Fragment,{children:[ee==="running"||ee==="warning"?l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{onClick:$,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[l.jsx(r1,{}),"Stop"]}),(r==null?void 0:r.url)&&l.jsxs("button",{onClick:()=>Y(),className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",title:r.url,children:[l.jsx(Tj,{}),"Open"]})]}):l.jsx("button",{onClick:$,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"}),D&&l.jsxs("div",{ref:z,className:"relative",onMouseEnter:()=>{A.current&&clearTimeout(A.current),E.current=setTimeout(()=>{S(!0),C(!1)},500)},onMouseLeave:()=>{E.current&&clearTimeout(E.current),C(!0),A.current=setTimeout(()=>S(!1),150)},children:[l.jsx(hw,{logs:o,preRef:O,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),(_||j)&&z.current&&Ja.createPortal(l.jsx(cA,{logs:o,anchorRef:z,isHiding:j,onExpand:()=>b(!0),onClose:()=>S(!1)}),document.body)]})]}):l.jsx("button",{onClick:()=>g(!0),className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),l.jsx(sA,{isOpen:m,onClose:()=>g(!1)}),v&&l.jsx(fw,{title:"Dev Server Logs",logs:o,onClose:()=>b(!1)})]})}),dA=k.memo(function({sessionId:t}){var b;const n=vl(_=>_.processes),r=vl(_=>_.stopProcess),[a,o]=k.useState(null),[u,d]=k.useState([]),p=n.filter(_=>_.status!=="exited"),f=p.filter(_=>_.status==="running").length;if(n.length===0)return null;const m=_=>{switch(_){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},g=_=>{const S=vl.getState().logs[_]??[];d(S.map(j=>({content:j.content,stream:j.stream}))),o(_)},v=_=>{t&&r(_,t)};return l.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),l.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),l.jsxs("span",{className:"text-xs text-text-muted",children:["(",f," running)"]})]})}),l.jsx("div",{className:"space-y-2",children:p.map(_=>l.jsx("div",{className:"border border-border rounded p-2",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[l.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${m(_.status)}`}),l.jsx("span",{className:"text-sm text-text-primary truncate",title:_.name,children:_.name}),l.jsxs("span",{className:"text-xs text-text-muted",children:["[",_.status,"]"]})]}),l.jsxs("div",{className:"flex gap-1 ml-2",children:[l.jsx("button",{onClick:()=>g(_.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),l.jsx("button",{onClick:()=>v(_.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},_.id))}),a&&l.jsx(fw,{title:((b=p.find(_=>_.id===a))==null?void 0:b.name)??"",logs:u,onClose:()=>{o(null),d([])}})]})});function hA({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=k.useState("ready"),[o,u]=k.useState(""),[d,p]=k.useState(n);k.useEffect(()=>{if(e){if(n){p(n);return}fetch("/api/auto-update/check").then(m=>m.json()).then(m=>p({current:m.current,latest:m.latest})).catch(()=>{})}},[e]),k.useEffect(()=>{if(!e||r!=="updating")return;const m=setInterval(()=>{u(g=>g.length>=3?"":g+".")},400);return()=>clearInterval(m)},[e,r]);const f=k.useCallback(async()=>{a("updating");const m=(d==null?void 0:d.current)==="1.0.0"&&(d==null?void 0:d.latest)==="1.1.0";if(await ke("/api/auto-update",{method:"POST"}),m){setTimeout(()=>{a("reloading"),localStorage.setItem("openfox_updated_to",(d==null?void 0:d.latest)??"unknown"),localStorage.setItem("update_pending","true"),setTimeout(()=>window.location.reload(),1e3)},5e3);return}let g=!1,v=!1;const b=setInterval(async()=>{try{(await fetch("/api/health")).ok&&g&&(v=!0,clearInterval(b),a("reloading"),localStorage.setItem("openfox_updated_to",(d==null?void 0:d.latest)??"unknown"),localStorage.setItem("update_pending","true"),window.location.reload())}catch{g=!0}},2e3);setTimeout(()=>{v||clearInterval(b)},3e5)},[d==null?void 0:d.current,d==null?void 0:d.latest]);return k.useEffect(()=>{e&&(a("ready"),u(""))},[e]),l.jsxs(Et,{isOpen:e,onClose:r==="updating"?void 0:t,title:"New OpenFox Version Available",size:"sm",closeOnBackdropClick:r!=="updating",showCloseButton:r!=="updating",children:[l.jsxs("div",{className:"flex flex-col gap-4",children:[d&&l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-text-muted",children:"Current version"}),l.jsx("span",{className:"text-text-primary font-mono",children:d.current})]}),d&&l.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[l.jsx("span",{className:"text-text-muted",children:"Latest version"}),l.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:d.latest})]}),r==="updating"&&l.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[l.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),l.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Updating",o]})]}),r==="reloading"&&l.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[l.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),l.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Update complete, reloading",o]})]})]}),r==="ready"&&l.jsx("button",{onClick:f,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),r==="ready"&&l.jsx("div",{className:"flex justify-center mt-2",children:l.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[l.jsx("span",{children:"⚠️"}),l.jsx("p",{className:"text-text-secondary",children:"Server will restart to apply this update. Sessions in progress will be interrupted."})]})})]})}function fA({file:e}){const t=ow(e.path,28),n=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",r=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"";return l.jsxs("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:[l.jsx("span",{className:`truncate ${n}`,title:e.path,children:t}),r&&l.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:r})]})}function pA(){const{diff:e}=uw();return e.loading?l.jsx("div",{className:"mt-3",children:l.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[l.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),l.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?l.jsx("div",{className:"mt-3",children:l.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):l.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:l.jsx("div",{className:"pr-1",children:e.files.map((t,n)=>l.jsx(fA,{file:t},n))})})}function y0({summary:e,messages:t,workdir:n}){const[r,a]=k.useState(!1),[o,u]=k.useState(!1),[d,p]=k.useState(!1),[f,m]=k.useState(!1),g=F3(t),{branch:v}=uw(),b=Mt(j=>j.version),_=ye(j=>j.currentSession),S=k.useCallback(async()=>{u(!0);try{const j=await fetch("/api/auto-update/check");if(j.ok){const C=await j.json();p(C.isUpdateAvailable)}}catch{}finally{u(!1)}},[]);return k.useEffect(()=>{S()},[S]),k.useEffect(()=>{if(new URLSearchParams(window.location.search).get("test-update")==="1"){p(!0),m(!0);const C=new URL(window.location.href);C.searchParams.delete("test-update"),window.history.replaceState({},"",C.toString())}},[]),l.jsxs("div",{className:"flex flex-col h-full",children:[g&&l.jsxs("div",{className:"mb-4",children:[l.jsx("button",{onClick:()=>a(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:l.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[l.jsx("span",{className:"text-text-secondary",children:$3(g.aiTime)}),l.jsx("span",{className:"w-px h-3 bg-border"}),l.jsx("span",{className:"text-text-secondary",children:h0(g.avgPrefillSpeed)}),l.jsx("span",{children:"pp"}),l.jsx("span",{className:"w-px h-3 bg-border"}),l.jsx("span",{className:"text-text-secondary",children:h0(g.avgGenerationSpeed)}),l.jsx("span",{children:"tg"})]})}),l.jsx(J3,{isOpen:r,onClose:()=>a(!1),stats:g})]}),l.jsxs("div",{className:"flex flex-col flex-1 overflow-y-auto",children:[l.jsx("div",{className:"flex items-center justify-between mb-2",children:l.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Summary"})}),e?l.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e}):l.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No summary yet"}),l.jsxs("div",{className:"mt-4",children:[l.jsx("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Progress"}),l.jsx(rA,{criteria:(_==null?void 0:_.criteria)??[]})]})]}),v&&l.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[l.jsx(_j,{}),l.jsx("span",{className:"truncate text-text-secondary",title:v,children:v})]}),l.jsx(pA,{}),l.jsx(uA,{workdir:n}),l.jsx(dA,{sessionId:_==null?void 0:_.id}),b&&l.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[l.jsxs("div",{className:"flex items-center justify-center gap-1",children:[l.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",l.jsxs("span",{className:"font-mono",children:["v",b]}),l.jsx("button",{onClick:()=>S(),disabled:o,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:l.jsx(n1,{className:`w-3 h-3 ${o?"animate-spin":""}`})})]}),d&&l.jsx("button",{onClick:()=>m(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"})]}),l.jsx(hA,{isOpen:f,onClose:()=>m(!1),versionInfo:null})]})}function mA({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const a=ye(o=>o.currentSession);return l.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&l.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),l.jsxs("div",{className:"flex h-full",children:[l.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?l.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary",children:l.jsx(y0,{summary:(a==null?void 0:a.summary)??null,messages:r,workdir:a==null?void 0:a.workdir})}):l.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),l.jsx("aside",{className:`
|
|
106
|
+
md:hidden
|
|
107
|
+
p-4 overflow-y-auto bg-secondary
|
|
108
|
+
transition-all duration-300 ease-in-out
|
|
109
|
+
fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
|
|
110
|
+
${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
|
|
111
|
+
`,children:l.jsx(y0,{summary:(a==null?void 0:a.summary)??null,messages:r,workdir:a==null?void 0:a.workdir})})]})]})}function gA(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function pw({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const a=n==="sm"?"w-12":"w-20",o=n==="sm"?"h-1":"h-1.5";return l.jsx("div",{className:`${o} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:l.jsx("div",{className:`h-full transition-all duration-300 ${gA(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function xA({dangerZone:e,size:t="md"}){return e?l.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function b0(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function yA(){const e=ye(g=>g.contextState),t=ye(g=>g.currentSession),n=ye(g=>g.compactContext),[r,a]=k.useState(!1);if(!e||!t)return null;const{currentTokens:o,maxTokens:u,compactionCount:d,dangerZone:p}=e,f=Math.round(o/u*100),m=t.isRunning;return l.jsx("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:b0(f,p),children:[Pu(o)," / ",Pu(u)]}),l.jsxs("span",{className:b0(f,p),children:["(",f,"%)"]}),l.jsx(pw,{percent:f,dangerZone:p}),l.jsx(xA,{dangerZone:p}),d>0&&l.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[d,"x"]})]}),l.jsx("div",{className:"flex-1 flex justify-end",children:l.jsxs("div",{className:"relative",children:[l.jsx("button",{onClick:()=>a(!r),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:l.jsx(t1,{})}),r&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>a(!1)}),l.jsx("div",{className:"absolute right-0 top-full mt-1.5 z-50 bg-bg-secondary border border-border rounded-lg shadow-xl py-1 min-w-[160px]",children:l.jsx("button",{onClick:()=>{m||n(),a(!1)},disabled:m,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:m?"Cannot compact while running":"Compact context",children:l.jsx("span",{className:p?"text-accent-error":"",children:"Compact"})})})]})]})})]})})}function bA({stats:e,onClose:t}){var n;return l.jsx(Et,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:l.jsxs("div",{className:"space-y-4",children:[l.jsx("div",{className:"flex items-center gap-3",children:l.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",e.mode]})}),l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[l.jsx(mu,{label:"Total Time",value:`${e.totalTime.toFixed(1)}s`}),l.jsx(mu,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),l.jsx(mu,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),l.jsx(mu,{label:"LLM Calls",value:String(((n=e.llmCalls)==null?void 0:n.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&l.jsxs("div",{children:[l.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((r,a)=>l.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",a+1]}),l.jsxs("span",{className:"text-xs text-text-muted",children:[r.ttft.toFixed(2),"s TTFT · ",r.completionTime.toFixed(2),"s gen"]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",l.jsxs("span",{className:"text-text-primary",children:[r.promptTokens," → ",r.completionTokens]})]}),l.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[r.temperature!==void 0&&l.jsx(gu,{label:"temp",value:r.temperature.toFixed(2)}),r.topP!==void 0&&l.jsx(gu,{label:"topP",value:r.topP.toFixed(2)}),r.topK!==void 0&&l.jsx(gu,{label:"topK",value:String(r.topK)}),r.maxTokens!==void 0&&l.jsx(gu,{label:"maxTok",value:String(r.maxTokens)})]})]})]},a))]})]})})}function mu({label:e,value:t}){return l.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[l.jsx("div",{className:"text-xs text-text-muted",children:e}),l.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function gu({label:e,value:t}){return l.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[l.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}const Rt=gr((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const r=await(await ke("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const r=await(await ke("/api/workflows")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],activeWorkflowId:r.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async n=>{try{const r=await ke(`/api/workflows/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ke(`/api/workflows/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createWorkflow:async(n,r)=>{const a=await di("POST","/api/workflows",{...n,destination:r});return a.success&&await t().fetchWorkflows(),a},updateWorkflow:async(n,r)=>{const a=await di("PUT",`/api/workflows/${n}`,r);return a.success&&await t().fetchWorkflows(),a},deleteWorkflow:async n=>{try{const r=await ke(`/api/workflows/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(o=>({userItems:o.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r)=>Zu(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),r)}));function v0(e){const t=[],n=String(e||"");let r=n.indexOf(","),a=0,o=!1;for(;!o;){r===-1&&(r=n.length,o=!0);const u=n.slice(a,r).trim();(u||!o)&&t.push(u),a=r+1,r=n.indexOf(",",a)}return t}function vA(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const _A=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,SA=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,wA={};function _0(e,t){return(wA.jsx?SA:_A).test(e)}const kA=/[ \t\n\f\r]/g;function CA(e){return typeof e=="object"?e.type==="text"?S0(e.value):!1:S0(e)}function S0(e){return e.replace(kA,"")===""}class Wl{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Wl.prototype.normal={};Wl.prototype.property={};Wl.prototype.space=void 0;function mw(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Wl(n,r,t)}function Al(e){return e.toLowerCase()}class nr{constructor(t,n){this.attribute=n,this.property=t}}nr.prototype.attribute="";nr.prototype.booleanish=!1;nr.prototype.boolean=!1;nr.prototype.commaOrSpaceSeparated=!1;nr.prototype.commaSeparated=!1;nr.prototype.defined=!1;nr.prototype.mustUseProperty=!1;nr.prototype.number=!1;nr.prototype.overloadedBoolean=!1;nr.prototype.property="";nr.prototype.spaceSeparated=!1;nr.prototype.space=void 0;let NA=0;const Ge=Gi(),nn=Gi(),hm=Gi(),be=Gi(),jt=Gi(),Ka=Gi(),fr=Gi();function Gi(){return 2**++NA}const fm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ge,booleanish:nn,commaOrSpaceSeparated:fr,commaSeparated:Ka,number:be,overloadedBoolean:hm,spaceSeparated:jt},Symbol.toStringTag,{value:"Module"})),np=Object.keys(fm);class ng extends nr{constructor(t,n,r,a){let o=-1;if(super(t,n),w0(this,"space",a),typeof r=="number")for(;++o<np.length;){const u=np[o];w0(this,np[o],(r&fm[u])===fm[u])}}}ng.prototype.defined=!0;function w0(e,t,n){n&&(e[t]=n)}function no(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new ng(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Al(r)]=r,n[Al(o.attribute)]=r}return new Wl(t,n,e.space)}const gw=no({properties:{ariaActiveDescendant:null,ariaAtomic:nn,ariaAutoComplete:null,ariaBusy:nn,ariaChecked:nn,ariaColCount:be,ariaColIndex:be,ariaColSpan:be,ariaControls:jt,ariaCurrent:null,ariaDescribedBy:jt,ariaDetails:null,ariaDisabled:nn,ariaDropEffect:jt,ariaErrorMessage:null,ariaExpanded:nn,ariaFlowTo:jt,ariaGrabbed:nn,ariaHasPopup:null,ariaHidden:nn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:jt,ariaLevel:be,ariaLive:null,ariaModal:nn,ariaMultiLine:nn,ariaMultiSelectable:nn,ariaOrientation:null,ariaOwns:jt,ariaPlaceholder:null,ariaPosInSet:be,ariaPressed:nn,ariaReadOnly:nn,ariaRelevant:null,ariaRequired:nn,ariaRoleDescription:jt,ariaRowCount:be,ariaRowIndex:be,ariaRowSpan:be,ariaSelected:nn,ariaSetSize:be,ariaSort:null,ariaValueMax:be,ariaValueMin:be,ariaValueNow:be,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function xw(e,t){return t in e?e[t]:t}function yw(e,t){return xw(e,t.toLowerCase())}const jA=no({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ka,acceptCharset:jt,accessKey:jt,action:null,allow:null,allowFullScreen:Ge,allowPaymentRequest:Ge,allowUserMedia:Ge,alt:null,as:null,async:Ge,autoCapitalize:null,autoComplete:jt,autoFocus:Ge,autoPlay:Ge,blocking:jt,capture:null,charSet:null,checked:Ge,cite:null,className:jt,cols:be,colSpan:null,content:null,contentEditable:nn,controls:Ge,controlsList:jt,coords:be|Ka,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ge,defer:Ge,dir:null,dirName:null,disabled:Ge,download:hm,draggable:nn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ge,formTarget:null,headers:jt,height:be,hidden:hm,high:be,href:null,hrefLang:null,htmlFor:jt,httpEquiv:jt,id:null,imageSizes:null,imageSrcSet:null,inert:Ge,inputMode:null,integrity:null,is:null,isMap:Ge,itemId:null,itemProp:jt,itemRef:jt,itemScope:Ge,itemType:jt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ge,low:be,manifest:null,max:null,maxLength:be,media:null,method:null,min:null,minLength:be,multiple:Ge,muted:Ge,name:null,nonce:null,noModule:Ge,noValidate:Ge,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:Ge,optimum:be,pattern:null,ping:jt,placeholder:null,playsInline:Ge,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ge,referrerPolicy:null,rel:jt,required:Ge,reversed:Ge,rows:be,rowSpan:be,sandbox:jt,scope:null,scoped:Ge,seamless:Ge,selected:Ge,shadowRootClonable:Ge,shadowRootDelegatesFocus:Ge,shadowRootMode:null,shape:null,size:be,sizes:null,slot:null,span:be,spellCheck:nn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:be,step:null,style:null,tabIndex:be,target:null,title:null,translate:null,type:null,typeMustMatch:Ge,useMap:null,value:nn,width:be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:jt,axis:null,background:null,bgColor:null,border:be,borderColor:null,bottomMargin:be,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ge,declare:Ge,event:null,face:null,frame:null,frameBorder:null,hSpace:be,leftMargin:be,link:null,longDesc:null,lowSrc:null,marginHeight:be,marginWidth:be,noResize:Ge,noHref:Ge,noShade:Ge,noWrap:Ge,object:null,profile:null,prompt:null,rev:null,rightMargin:be,rules:null,scheme:null,scrolling:nn,standby:null,summary:null,text:null,topMargin:be,valueType:null,version:null,vAlign:null,vLink:null,vSpace:be,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ge,disableRemotePlayback:Ge,prefix:null,property:null,results:be,security:null,unselectable:null},space:"html",transform:yw}),EA=no({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:fr,accentHeight:be,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:be,amplitude:be,arabicForm:null,ascent:be,attributeName:null,attributeType:null,azimuth:be,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:be,by:null,calcMode:null,capHeight:be,className:jt,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:be,diffuseConstant:be,direction:null,display:null,dur:null,divisor:be,dominantBaseline:null,download:Ge,dx:null,dy:null,edgeMode:null,editable:null,elevation:be,enableBackground:null,end:null,event:null,exponent:be,externalResourcesRequired:null,fill:null,fillOpacity:be,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:Ka,g2:Ka,glyphName:Ka,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:be,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:be,horizOriginX:be,horizOriginY:be,id:null,ideographic:be,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:be,k:be,k1:be,k2:be,k3:be,k4:be,kernelMatrix:fr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:be,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:be,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:be,overlineThickness:be,paintOrder:null,panose1:null,path:null,pathLength:be,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:jt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:be,pointsAtY:be,pointsAtZ:be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:fr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:fr,rev:fr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:fr,requiredFeatures:fr,requiredFonts:fr,requiredFormats:fr,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:be,specularExponent:be,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:be,strikethroughThickness:be,string:null,stroke:null,strokeDashArray:fr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:be,strokeOpacity:be,strokeWidth:null,style:null,surfaceScale:be,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:fr,tabIndex:be,tableValues:null,target:null,targetX:be,targetY:be,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:fr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:be,underlineThickness:be,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:be,values:null,vAlphabetic:be,vMathematical:be,vectorEffect:null,vHanging:be,vIdeographic:be,version:null,vertAdvY:be,vertOriginX:be,vertOriginY:be,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:be,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xw}),bw=no({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),vw=no({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yw}),_w=no({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),TA={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"},AA=/[A-Z]/g,k0=/-[a-z]/g,DA=/^data[-\w.:]+$/i;function Sw(e,t){const n=Al(t);let r=t,a=nr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&DA.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(k0,RA);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!k0.test(o)){let u=o.replace(AA,MA);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=ng}return new a(r,t)}function MA(e){return"-"+e.toLowerCase()}function RA(e){return e.charAt(1).toUpperCase()}const ww=mw([gw,jA,bw,vw,_w],"html"),od=mw([gw,EA,bw,vw,_w],"svg");function C0(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function LA(e){return e.join(" ").trim()}var za={},rp,N0;function OA(){if(N0)return rp;N0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,d=/^\s+|\s+$/g,p=`
|
|
112
|
+
`,f="/",m="*",g="",v="comment",b="declaration";function _(j,C){if(typeof j!="string")throw new TypeError("First argument must be a string");if(!j)return[];C=C||{};var E=1,A=1;function O(q){var T=q.match(t);T&&(E+=T.length);var N=q.lastIndexOf(p);A=~N?q.length-N:A+q.length}function z(){var q={line:E,column:A};return function(T){return T.position=new B(q),ie(),T}}function B(q){this.start=q,this.end={line:E,column:A},this.source=C.source}B.prototype.content=j;function Y(q){var T=new Error(C.source+":"+E+":"+A+": "+q);if(T.reason=q,T.filename=C.source,T.line=E,T.column=A,T.source=j,!C.silent)throw T}function ee(q){var T=q.exec(j);if(T){var N=T[0];return O(N),j=j.slice(N.length),T}}function ie(){ee(n)}function D(q){var T;for(q=q||[];T=$();)T!==!1&&q.push(T);return q}function $(){var q=z();if(!(f!=j.charAt(0)||m!=j.charAt(1))){for(var T=2;g!=j.charAt(T)&&(m!=j.charAt(T)||f!=j.charAt(T+1));)++T;if(T+=2,g===j.charAt(T-1))return Y("End of comment missing");var N=j.slice(2,T-2);return A+=2,O(N),j=j.slice(T),A+=2,q({type:v,comment:N})}}function H(){var q=z(),T=ee(r);if(T){if($(),!ee(a))return Y("property missing ':'");var N=ee(o),F=q({type:b,property:S(T[0].replace(e,g)),value:N?S(N[0].replace(e,g)):g});return ee(u),F}}function U(){var q=[];D(q);for(var T;T=H();)T!==!1&&(q.push(T),D(q));return q}return ie(),U()}function S(j){return j?j.replace(d,g):g}return rp=_,rp}var j0;function IA(){if(j0)return za;j0=1;var e=za&&za.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(za,"__esModule",{value:!0}),za.default=n;const t=e(OA());function n(r,a){let o=null;if(!r||typeof r!="string")return o;const u=(0,t.default)(r),d=typeof a=="function";return u.forEach(p=>{if(p.type!=="declaration")return;const{property:f,value:m}=p;d?a(f,m,p):m&&(o=o||{},o[f]=m)}),o}return za}var ol={},E0;function BA(){if(E0)return ol;E0=1,Object.defineProperty(ol,"__esModule",{value:!0}),ol.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(f){return!f||n.test(f)||e.test(f)},u=function(f,m){return m.toUpperCase()},d=function(f,m){return"".concat(m,"-")},p=function(f,m){return m===void 0&&(m={}),o(f)?f:(f=f.toLowerCase(),m.reactCompat?f=f.replace(a,d):f=f.replace(r,d),f.replace(t,u))};return ol.camelCase=p,ol}var ll,T0;function zA(){if(T0)return ll;T0=1;var e=ll&&ll.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(IA()),n=BA();function r(a,o){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(d,p){d&&p&&(u[(0,n.camelCase)(d,o)]=p)}),u}return r.default=r,ll=r,ll}var PA=zA();const HA=Gu(PA),kw=Cw("end"),rg=Cw("start");function Cw(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function FA(e){const t=rg(e),n=kw(e);if(t&&n)return{start:t,end:n}}function Sl(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?A0(e.position):"start"in e||"end"in e?A0(e):"line"in e||"column"in e?pm(e):""}function pm(e){return D0(e&&e.line)+":"+D0(e&&e.column)}function A0(e){return pm(e&&e.start)+"-"+pm(e&&e.end)}function D0(e){return e&&typeof e=="number"?e:1}class Hn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",o={},u=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(u=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const p=r.indexOf(":");p===-1?o.ruleId=r:(o.source=r.slice(0,p),o.ruleId=r.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const d=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=d?d.line:void 0,this.name=Sl(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=u&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Hn.prototype.file="";Hn.prototype.name="";Hn.prototype.reason="";Hn.prototype.message="";Hn.prototype.stack="";Hn.prototype.column=void 0;Hn.prototype.line=void 0;Hn.prototype.ancestors=void 0;Hn.prototype.cause=void 0;Hn.prototype.fatal=void 0;Hn.prototype.place=void 0;Hn.prototype.ruleId=void 0;Hn.prototype.source=void 0;const sg={}.hasOwnProperty,$A=new Map,UA=/[A-Z]/g,WA=new Set(["table","tbody","thead","tfoot","tr"]),qA=new Set(["td","th"]),Nw="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function VA(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=eD(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=JA(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?od:ww,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=jw(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function jw(e,t,n){if(t.type==="element")return KA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return GA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return XA(e,t,n);if(t.type==="mdxjsEsm")return YA(e,t);if(t.type==="root")return ZA(e,t,n);if(t.type==="text")return QA(e,t)}function KA(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=od,e.schema=a),e.ancestors.push(t);const o=Tw(e,t.tagName,!1),u=tD(e,t);let d=ag(e,t);return WA.has(t.tagName)&&(d=d.filter(function(p){return typeof p=="string"?!CA(p):!0})),Ew(e,u,o,t),ig(u,d),e.ancestors.pop(),e.schema=r,e.create(t,o,u,n)}function GA(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Dl(e,t.position)}function YA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Dl(e,t.position)}function XA(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=od,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:Tw(e,t.name,!0),u=nD(e,t),d=ag(e,t);return Ew(e,u,o,t),ig(u,d),e.ancestors.pop(),e.schema=r,e.create(t,o,u,n)}function ZA(e,t,n){const r={};return ig(r,ag(e,t)),e.create(t,e.Fragment,r,n)}function QA(e,t){return t.value}function Ew(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function ig(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function JA(e,t,n){return r;function r(a,o,u,d){const f=Array.isArray(u.children)?n:t;return d?f(o,u,d):f(o,u)}}function eD(e,t){return n;function n(r,a,o,u){const d=Array.isArray(o.children),p=rg(r);return t(a,o,u,d,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function tD(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&sg.call(t.properties,a)){const o=rD(e,a,t.properties[a]);if(o){const[u,d]=o;e.tableCellAlignToStyle&&u==="align"&&typeof d=="string"&&qA.has(t.tagName)?r=d:n[u]=d}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function nD(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const u=o.expression;u.type;const d=u.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else Dl(e,t.position);else{const a=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const d=r.value.data.estree.body[0];d.type,o=e.evaluater.evaluateExpression(d.expression)}else Dl(e,t.position);else o=r.value===null?!0:r.value;n[a]=o}return n}function ag(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:$A;for(;++r<t.children.length;){const o=t.children[r];let u;if(e.passKeys){const p=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(p){const f=a.get(p)||0;u=p+"-"+f,a.set(p,f+1)}}const d=jw(e,o,u);d!==void 0&&n.push(d)}return n}function rD(e,t,n){const r=Sw(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?vA(n):LA(n)),r.property==="style"){let a=typeof n=="object"?n:sD(e,String(n));return e.stylePropertyNameCase==="css"&&(a=iD(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?TA[r.property]||r.property:r.attribute,n]}}function sD(e,t){try{return HA(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new Hn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=Nw+"#cannot-parse-style-attribute",a}}function Tw(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,u;for(;++o<a.length;){const d=_0(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};u=u?{type:"MemberExpression",object:u,property:d,computed:!!(o&&d.type==="Literal"),optional:!1}:d}r=u}else r=_0(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return sg.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);Dl(e)}function Dl(e,t){const n=new Hn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Nw+"#cannot-handle-mdx-estrees-without-createevaluater",n}function iD(e){const t={};let n;for(n in e)sg.call(e,n)&&(t[aD(n)]=e[n]);return t}function aD(e){let t=e.replace(UA,oD);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function oD(e){return"-"+e.toLowerCase()}const sp={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"]},lD={};function og(e,t){const n=lD,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Aw(e,r,a)}function Aw(e,t,n){if(cD(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return M0(e.children,t,n)}return Array.isArray(e)?M0(e,t,n):""}function M0(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=Aw(e[a],t,n);return r.join("")}function cD(e){return!!(e&&typeof e=="object")}const R0=document.createElement("i");function Ml(e){const t="&"+e+";";R0.innerHTML=t;const n=R0.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function mr(e,t,n,r){const a=e.length;let o=0,u;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)u=Array.from(r),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);o<r.length;)u=r.slice(o,o+1e4),u.unshift(t,0),e.splice(...u),o+=1e4,t+=1e4}function Dr(e,t){return e.length>0?(mr(e,e.length,0,t),e):t}const L0={}.hasOwnProperty;function Dw(e){const t={};let n=-1;for(;++n<e.length;)uD(t,e[n]);return t}function uD(e,t){let n;for(n in t){const a=(L0.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let u;if(o)for(u in o){L0.call(a,u)||(a[u]=[]);const d=o[u];dD(a[u],Array.isArray(d)?d:d?[d]:[])}}}function dD(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);mr(e,0,0,r)}function Mw(e,t){const n=Number.parseInt(e,t);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 Pr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Un=hi(/[A-Za-z]/),Pn=hi(/[\dA-Za-z]/),hD=hi(/[#-'*+\--9=?A-Z^-~]/);function $u(e){return e!==null&&(e<32||e===127)}const mm=hi(/\d/),fD=hi(/[\dA-Fa-f]/),pD=hi(/[!-/:-@[-`{-~]/);function Oe(e){return e!==null&&e<-2}function Nt(e){return e!==null&&(e<0||e===32)}function nt(e){return e===-2||e===-1||e===32}const ld=hi(new RegExp("\\p{P}|\\p{S}","u")),Vi=hi(/\s/);function hi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ro(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const o=e.charCodeAt(n);let u="";if(o===37&&Pn(e.charCodeAt(n+1))&&Pn(e.charCodeAt(n+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(u=String.fromCharCode(o));else if(o>55295&&o<57344){const d=e.charCodeAt(n+1);o<56320&&d>56319&&d<57344?(u=String.fromCharCode(o,d),a=1):u="�"}else u=String.fromCharCode(o);u&&(t.push(e.slice(r,n),encodeURIComponent(u)),r=n+a+1,u=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function lt(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let o=0;return u;function u(p){return nt(p)?(e.enter(n),d(p)):t(p)}function d(p){return nt(p)&&o++<a?(e.consume(p),d):(e.exit(n),t(p))}}const mD={tokenize:gD};function gD(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),lt(e,t,"linePrefix")}function a(d){return e.enter("paragraph"),o(d)}function o(d){const p=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=p),n=p,u(d)}function u(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return Oe(d)?(e.consume(d),e.exit("chunkText"),o):(e.consume(d),u)}}const xD={tokenize:yD},O0={tokenize:bD};function yD(e){const t=this,n=[];let r=0,a,o,u;return d;function d(A){if(r<n.length){const O=n[r];return t.containerState=O[1],e.attempt(O[0].continuation,p,f)(A)}return f(A)}function p(A){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&E();const O=t.events.length;let z=O,B;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){B=t.events[z][1].end;break}C(r);let Y=O;for(;Y<t.events.length;)t.events[Y][1].end={...B},Y++;return mr(t.events,z+1,0,t.events.slice(O)),t.events.length=Y,f(A)}return d(A)}function f(A){if(r===n.length){if(!a)return v(A);if(a.currentConstruct&&a.currentConstruct.concrete)return _(A);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(O0,m,g)(A)}function m(A){return a&&E(),C(r),v(A)}function g(A){return t.parser.lazy[t.now().line]=r!==n.length,u=t.now().offset,_(A)}function v(A){return t.containerState={},e.attempt(O0,b,_)(A)}function b(A){return r++,n.push([t.currentConstruct,t.containerState]),v(A)}function _(A){if(A===null){a&&E(),C(0),e.consume(A);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),S(A)}function S(A){if(A===null){j(e.exit("chunkFlow"),!0),C(0),e.consume(A);return}return Oe(A)?(e.consume(A),j(e.exit("chunkFlow")),r=0,t.interrupt=void 0,d):(e.consume(A),S)}function j(A,O){const z=t.sliceStream(A);if(O&&z.push(null),A.previous=o,o&&(o.next=A),o=A,a.defineSkip(A.start),a.write(z),t.parser.lazy[A.start.line]){let B=a.events.length;for(;B--;)if(a.events[B][1].start.offset<u&&(!a.events[B][1].end||a.events[B][1].end.offset>u))return;const Y=t.events.length;let ee=Y,ie,D;for(;ee--;)if(t.events[ee][0]==="exit"&&t.events[ee][1].type==="chunkFlow"){if(ie){D=t.events[ee][1].end;break}ie=!0}for(C(r),B=Y;B<t.events.length;)t.events[B][1].end={...D},B++;mr(t.events,ee+1,0,t.events.slice(Y)),t.events.length=B}}function C(A){let O=n.length;for(;O-- >A;){const z=n[O];t.containerState=z[1],z[0].exit.call(t,e)}n.length=A}function E(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function bD(e,t,n){return lt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Za(e){if(e===null||Nt(e)||Vi(e))return 1;if(ld(e))return 2}function cd(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const gm={name:"attention",resolveAll:vD,tokenize:_D};function vD(e,t){let n=-1,r,a,o,u,d,p,f,m;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;p=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const g={...e[r][1].end},v={...e[n][1].start};I0(g,-p),I0(v,p),u={type:p>1?"strongSequence":"emphasisSequence",start:g,end:{...e[r][1].end}},d={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:v},o={type:p>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...u.start},end:{...d.end}},e[r][1].end={...u.start},e[n][1].start={...d.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=Dr(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=Dr(f,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",o,t]]),f=Dr(f,cd(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=Dr(f,[["exit",o,t],["enter",d,t],["exit",d,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,f=Dr(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,mr(e,r-1,n-r+3,f),n=r+f.length-m-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function _D(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Za(r);let o;return u;function u(p){return o=p,e.enter("attentionSequence"),d(p)}function d(p){if(p===o)return e.consume(p),d;const f=e.exit("attentionSequence"),m=Za(p),g=!m||m===2&&a||n.includes(p),v=!a||a===2&&m||n.includes(r);return f._open=!!(o===42?g:g&&(a||!v)),f._close=!!(o===42?v:v&&(m||!g)),t(p)}}function I0(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const SD={name:"autolink",tokenize:wD};function wD(e,t,n){let r=0;return a;function a(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(b){return Un(b)?(e.consume(b),u):b===64?n(b):f(b)}function u(b){return b===43||b===45||b===46||Pn(b)?(r=1,d(b)):f(b)}function d(b){return b===58?(e.consume(b),r=0,p):(b===43||b===45||b===46||Pn(b))&&r++<32?(e.consume(b),d):(r=0,f(b))}function p(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):b===null||b===32||b===60||$u(b)?n(b):(e.consume(b),p)}function f(b){return b===64?(e.consume(b),m):hD(b)?(e.consume(b),f):n(b)}function m(b){return Pn(b)?g(b):n(b)}function g(b){return b===46?(e.consume(b),r=0,m):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):v(b)}function v(b){if((b===45||Pn(b))&&r++<63){const _=b===45?v:g;return e.consume(b),_}return n(b)}}const ql={partial:!0,tokenize:kD};function kD(e,t,n){return r;function r(o){return nt(o)?lt(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||Oe(o)?t(o):n(o)}}const Rw={continuation:{tokenize:ND},exit:jD,name:"blockQuote",tokenize:CD};function CD(e,t,n){const r=this;return a;function a(u){if(u===62){const d=r.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),o}return n(u)}function o(u){return nt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function ND(e,t,n){const r=this;return a;function a(u){return nt(u)?lt(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):o(u)}function o(u){return e.attempt(Rw,t,n)(u)}}function jD(e){e.exit("blockQuote")}const Lw={name:"characterEscape",tokenize:ED};function ED(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),a}function a(o){return pD(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Ow={name:"characterReference",tokenize:TD};function TD(e,t,n){const r=this;let a=0,o,u;return d;function d(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),p}function p(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),o=31,u=Pn,m(g))}function f(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,u=fD,m):(e.enter("characterReferenceValue"),o=7,u=mm,m(g))}function m(g){if(g===59&&a){const v=e.exit("characterReferenceValue");return u===Pn&&!Ml(r.sliceSerialize(v))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(g)&&a++<o?(e.consume(g),m):n(g)}}const B0={partial:!0,tokenize:DD},z0={concrete:!0,name:"codeFenced",tokenize:AD};function AD(e,t,n){const r=this,a={partial:!0,tokenize:z};let o=0,u=0,d;return p;function p(B){return f(B)}function f(B){const Y=r.events[r.events.length-1];return o=Y&&Y[1].type==="linePrefix"?Y[2].sliceSerialize(Y[1],!0).length:0,d=B,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m(B)}function m(B){return B===d?(u++,e.consume(B),m):u<3?n(B):(e.exit("codeFencedFenceSequence"),nt(B)?lt(e,g,"whitespace")(B):g(B))}function g(B){return B===null||Oe(B)?(e.exit("codeFencedFence"),r.interrupt?t(B):e.check(B0,S,O)(B)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(B))}function v(B){return B===null||Oe(B)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(B)):nt(B)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),lt(e,b,"whitespace")(B)):B===96&&B===d?n(B):(e.consume(B),v)}function b(B){return B===null||Oe(B)?g(B):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),_(B))}function _(B){return B===null||Oe(B)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(B)):B===96&&B===d?n(B):(e.consume(B),_)}function S(B){return e.attempt(a,O,j)(B)}function j(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),C}function C(B){return o>0&&nt(B)?lt(e,E,"linePrefix",o+1)(B):E(B)}function E(B){return B===null||Oe(B)?e.check(B0,S,O)(B):(e.enter("codeFlowValue"),A(B))}function A(B){return B===null||Oe(B)?(e.exit("codeFlowValue"),E(B)):(e.consume(B),A)}function O(B){return e.exit("codeFenced"),t(B)}function z(B,Y,ee){let ie=0;return D;function D(T){return B.enter("lineEnding"),B.consume(T),B.exit("lineEnding"),$}function $(T){return B.enter("codeFencedFence"),nt(T)?lt(B,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):H(T)}function H(T){return T===d?(B.enter("codeFencedFenceSequence"),U(T)):ee(T)}function U(T){return T===d?(ie++,B.consume(T),U):ie>=u?(B.exit("codeFencedFenceSequence"),nt(T)?lt(B,q,"whitespace")(T):q(T)):ee(T)}function q(T){return T===null||Oe(T)?(B.exit("codeFencedFence"),Y(T)):ee(T)}}}function DD(e,t,n){const r=this;return a;function a(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o)}function o(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}const ip={name:"codeIndented",tokenize:RD},MD={partial:!0,tokenize:LD};function RD(e,t,n){const r=this;return a;function a(f){return e.enter("codeIndented"),lt(e,o,"linePrefix",5)(f)}function o(f){const m=r.events[r.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?u(f):n(f)}function u(f){return f===null?p(f):Oe(f)?e.attempt(MD,u,p)(f):(e.enter("codeFlowValue"),d(f))}function d(f){return f===null||Oe(f)?(e.exit("codeFlowValue"),u(f)):(e.consume(f),d)}function p(f){return e.exit("codeIndented"),t(f)}}function LD(e,t,n){const r=this;return a;function a(u){return r.parser.lazy[r.now().line]?n(u):Oe(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):lt(e,o,"linePrefix",5)(u)}function o(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(u):Oe(u)?a(u):n(u)}}const OD={name:"codeText",previous:BD,resolve:ID,tokenize:zD};function ID(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function BD(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function zD(e,t,n){let r=0,a,o;return u;function u(g){return e.enter("codeText"),e.enter("codeTextSequence"),d(g)}function d(g){return g===96?(e.consume(g),r++,d):(e.exit("codeTextSequence"),p(g))}function p(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),p):g===96?(o=e.enter("codeTextSequence"),a=0,m(g)):Oe(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),p):(e.enter("codeTextData"),f(g))}function f(g){return g===null||g===32||g===96||Oe(g)?(e.exit("codeTextData"),p(g)):(e.consume(g),f)}function m(g){return g===96?(e.consume(g),a++,m):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(o.type="codeTextData",f(g))}}class PD{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&cl(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),cl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),cl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);cl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);cl(this.left,n.reverse())}}}function cl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Iw(e){const t={};let n=-1,r,a,o,u,d,p,f;const m=new PD(e);for(;++n<m.length;){for(;n in t;)n=t[n];if(r=m.get(n),n&&r[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(p=r[1]._tokenizer.events,o=0,o<p.length&&p[o][1].type==="lineEndingBlank"&&(o+=2),o<p.length&&p[o][1].type==="content"))for(;++o<p.length&&p[o][1].type!=="content";)p[o][1].type==="chunkText"&&(p[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,HD(m,n)),n=t[n],f=!0);else if(r[1]._container){for(o=n,a=void 0;o--;)if(u=m.get(o),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(a&&(m.get(a)[1].type="lineEndingBlank"),u[1].type="lineEnding",a=o);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;a&&(r[1].end={...m.get(a)[1].start},d=m.slice(a,n),d.unshift(r),m.splice(a,n-a+1,d))}}return mr(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!f}function HD(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const o=[];let u=n._tokenizer;u||(u=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const d=u.events,p=[],f={};let m,g,v=-1,b=n,_=0,S=0;const j=[S];for(;b;){for(;e.get(++a)[1]!==b;);o.push(a),b._tokenizer||(m=r.sliceStream(b),b.next||m.push(null),g&&u.defineSkip(b.start),b._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(m),b._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),g=b,b=b.next}for(b=n;++v<d.length;)d[v][0]==="exit"&&d[v-1][0]==="enter"&&d[v][1].type===d[v-1][1].type&&d[v][1].start.line!==d[v][1].end.line&&(S=v+1,j.push(S),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(u.events=[],b?(b._tokenizer=void 0,b.previous=void 0):j.pop(),v=j.length;v--;){const C=d.slice(j[v],j[v+1]),E=o.pop();p.push([E,E+C.length-1]),e.splice(E,2,C)}for(p.reverse(),v=-1;++v<p.length;)f[_+p[v][0]]=_+p[v][1],_+=p[v][1]-p[v][0]-1;return f}const FD={resolve:UD,tokenize:WD},$D={partial:!0,tokenize:qD};function UD(e){return Iw(e),e}function WD(e,t){let n;return r;function r(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(d)}function a(d){return d===null?o(d):Oe(d)?e.check($D,u,o)(d):(e.consume(d),a)}function o(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function u(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function qD(e,t,n){const r=this;return a;function a(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),lt(e,o,"linePrefix")}function o(u){if(u===null||Oe(u))return n(u);const d=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(u):e.interrupt(r.parser.constructs.flow,n,t)(u)}}function Bw(e,t,n,r,a,o,u,d,p){const f=p||Number.POSITIVE_INFINITY;let m=0;return g;function g(C){return C===60?(e.enter(r),e.enter(a),e.enter(o),e.consume(C),e.exit(o),v):C===null||C===32||C===41||$u(C)?n(C):(e.enter(r),e.enter(u),e.enter(d),e.enter("chunkString",{contentType:"string"}),S(C))}function v(C){return C===62?(e.enter(o),e.consume(C),e.exit(o),e.exit(a),e.exit(r),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),b(C))}function b(C){return C===62?(e.exit("chunkString"),e.exit(d),v(C)):C===null||C===60||Oe(C)?n(C):(e.consume(C),C===92?_:b)}function _(C){return C===60||C===62||C===92?(e.consume(C),b):b(C)}function S(C){return!m&&(C===null||C===41||Nt(C))?(e.exit("chunkString"),e.exit(d),e.exit(u),e.exit(r),t(C)):m<f&&C===40?(e.consume(C),m++,S):C===41?(e.consume(C),m--,S):C===null||C===32||C===40||$u(C)?n(C):(e.consume(C),C===92?j:S)}function j(C){return C===40||C===41||C===92?(e.consume(C),S):S(C)}}function zw(e,t,n,r,a,o){const u=this;let d=0,p;return f;function f(b){return e.enter(r),e.enter(a),e.consume(b),e.exit(a),e.enter(o),m}function m(b){return d>999||b===null||b===91||b===93&&!p||b===94&&!d&&"_hiddenFootnoteSupport"in u.parser.constructs?n(b):b===93?(e.exit(o),e.enter(a),e.consume(b),e.exit(a),e.exit(r),t):Oe(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===null||b===91||b===93||Oe(b)||d++>999?(e.exit("chunkString"),m(b)):(e.consume(b),p||(p=!nt(b)),b===92?v:g)}function v(b){return b===91||b===92||b===93?(e.consume(b),d++,g):g(b)}}function Pw(e,t,n,r,a,o){let u;return d;function d(v){return v===34||v===39||v===40?(e.enter(r),e.enter(a),e.consume(v),e.exit(a),u=v===40?41:v,p):n(v)}function p(v){return v===u?(e.enter(a),e.consume(v),e.exit(a),e.exit(r),t):(e.enter(o),f(v))}function f(v){return v===u?(e.exit(o),p(u)):v===null?n(v):Oe(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),lt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(v))}function m(v){return v===u||v===null||Oe(v)?(e.exit("chunkString"),f(v)):(e.consume(v),v===92?g:m)}function g(v){return v===u||v===92?(e.consume(v),m):m(v)}}function wl(e,t){let n;return r;function r(a){return Oe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):nt(a)?lt(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const VD={name:"definition",tokenize:GD},KD={partial:!0,tokenize:YD};function GD(e,t,n){const r=this;let a;return o;function o(b){return e.enter("definition"),u(b)}function u(b){return zw.call(r,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function d(b){return a=Pr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),p):n(b)}function p(b){return Nt(b)?wl(e,f)(b):f(b)}function f(b){return Bw(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(KD,g,g)(b)}function g(b){return nt(b)?lt(e,v,"whitespace")(b):v(b)}function v(b){return b===null||Oe(b)?(e.exit("definition"),r.parser.defined.push(a),t(b)):n(b)}}function YD(e,t,n){return r;function r(d){return Nt(d)?wl(e,a)(d):n(d)}function a(d){return Pw(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function o(d){return nt(d)?lt(e,u,"whitespace")(d):u(d)}function u(d){return d===null||Oe(d)?t(d):n(d)}}const XD={name:"hardBreakEscape",tokenize:ZD};function ZD(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Oe(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const QD={name:"headingAtx",resolve:JD,tokenize:e4};function JD(e,t){let n=e.length-2,r=3,a,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},mr(e,r,n-r+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function e4(e,t,n){let r=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),u(m)}function u(m){return m===35&&r++<6?(e.consume(m),u):m===null||Nt(m)?(e.exit("atxHeadingSequence"),d(m)):n(m)}function d(m){return m===35?(e.enter("atxHeadingSequence"),p(m)):m===null||Oe(m)?(e.exit("atxHeading"),t(m)):nt(m)?lt(e,d,"whitespace")(m):(e.enter("atxHeadingText"),f(m))}function p(m){return m===35?(e.consume(m),p):(e.exit("atxHeadingSequence"),d(m))}function f(m){return m===null||m===35||Nt(m)?(e.exit("atxHeadingText"),d(m)):(e.consume(m),f)}}const t4=["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"],P0=["pre","script","style","textarea"],n4={concrete:!0,name:"htmlFlow",resolveTo:i4,tokenize:a4},r4={partial:!0,tokenize:l4},s4={partial:!0,tokenize:o4};function i4(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function a4(e,t,n){const r=this;let a,o,u,d,p;return f;function f(L){return m(L)}function m(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),g}function g(L){return L===33?(e.consume(L),v):L===47?(e.consume(L),o=!0,S):L===63?(e.consume(L),a=3,r.interrupt?t:R):Un(L)?(e.consume(L),u=String.fromCharCode(L),j):n(L)}function v(L){return L===45?(e.consume(L),a=2,b):L===91?(e.consume(L),a=5,d=0,_):Un(L)?(e.consume(L),a=4,r.interrupt?t:R):n(L)}function b(L){return L===45?(e.consume(L),r.interrupt?t:R):n(L)}function _(L){const G="CDATA[";return L===G.charCodeAt(d++)?(e.consume(L),d===G.length?r.interrupt?t:H:_):n(L)}function S(L){return Un(L)?(e.consume(L),u=String.fromCharCode(L),j):n(L)}function j(L){if(L===null||L===47||L===62||Nt(L)){const G=L===47,W=u.toLowerCase();return!G&&!o&&P0.includes(W)?(a=1,r.interrupt?t(L):H(L)):t4.includes(u.toLowerCase())?(a=6,G?(e.consume(L),C):r.interrupt?t(L):H(L)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(L):o?E(L):A(L))}return L===45||Pn(L)?(e.consume(L),u+=String.fromCharCode(L),j):n(L)}function C(L){return L===62?(e.consume(L),r.interrupt?t:H):n(L)}function E(L){return nt(L)?(e.consume(L),E):D(L)}function A(L){return L===47?(e.consume(L),D):L===58||L===95||Un(L)?(e.consume(L),O):nt(L)?(e.consume(L),A):D(L)}function O(L){return L===45||L===46||L===58||L===95||Pn(L)?(e.consume(L),O):z(L)}function z(L){return L===61?(e.consume(L),B):nt(L)?(e.consume(L),z):A(L)}function B(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),p=L,Y):nt(L)?(e.consume(L),B):ee(L)}function Y(L){return L===p?(e.consume(L),p=null,ie):L===null||Oe(L)?n(L):(e.consume(L),Y)}function ee(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||Nt(L)?z(L):(e.consume(L),ee)}function ie(L){return L===47||L===62||nt(L)?A(L):n(L)}function D(L){return L===62?(e.consume(L),$):n(L)}function $(L){return L===null||Oe(L)?H(L):nt(L)?(e.consume(L),$):n(L)}function H(L){return L===45&&a===2?(e.consume(L),N):L===60&&a===1?(e.consume(L),F):L===62&&a===4?(e.consume(L),P):L===63&&a===3?(e.consume(L),R):L===93&&a===5?(e.consume(L),J):Oe(L)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(r4,V,U)(L)):L===null||Oe(L)?(e.exit("htmlFlowData"),U(L)):(e.consume(L),H)}function U(L){return e.check(s4,q,V)(L)}function q(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),T}function T(L){return L===null||Oe(L)?U(L):(e.enter("htmlFlowData"),H(L))}function N(L){return L===45?(e.consume(L),R):H(L)}function F(L){return L===47?(e.consume(L),u="",I):H(L)}function I(L){if(L===62){const G=u.toLowerCase();return P0.includes(G)?(e.consume(L),P):H(L)}return Un(L)&&u.length<8?(e.consume(L),u+=String.fromCharCode(L),I):H(L)}function J(L){return L===93?(e.consume(L),R):H(L)}function R(L){return L===62?(e.consume(L),P):L===45&&a===2?(e.consume(L),R):H(L)}function P(L){return L===null||Oe(L)?(e.exit("htmlFlowData"),V(L)):(e.consume(L),P)}function V(L){return e.exit("htmlFlow"),t(L)}}function o4(e,t,n){const r=this;return a;function a(u){return Oe(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):n(u)}function o(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}function l4(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(ql,t,n)}}const c4={name:"htmlText",tokenize:u4};function u4(e,t,n){const r=this;let a,o,u;return d;function d(R){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(R),p}function p(R){return R===33?(e.consume(R),f):R===47?(e.consume(R),z):R===63?(e.consume(R),A):Un(R)?(e.consume(R),ee):n(R)}function f(R){return R===45?(e.consume(R),m):R===91?(e.consume(R),o=0,_):Un(R)?(e.consume(R),E):n(R)}function m(R){return R===45?(e.consume(R),b):n(R)}function g(R){return R===null?n(R):R===45?(e.consume(R),v):Oe(R)?(u=g,F(R)):(e.consume(R),g)}function v(R){return R===45?(e.consume(R),b):g(R)}function b(R){return R===62?N(R):R===45?v(R):g(R)}function _(R){const P="CDATA[";return R===P.charCodeAt(o++)?(e.consume(R),o===P.length?S:_):n(R)}function S(R){return R===null?n(R):R===93?(e.consume(R),j):Oe(R)?(u=S,F(R)):(e.consume(R),S)}function j(R){return R===93?(e.consume(R),C):S(R)}function C(R){return R===62?N(R):R===93?(e.consume(R),C):S(R)}function E(R){return R===null||R===62?N(R):Oe(R)?(u=E,F(R)):(e.consume(R),E)}function A(R){return R===null?n(R):R===63?(e.consume(R),O):Oe(R)?(u=A,F(R)):(e.consume(R),A)}function O(R){return R===62?N(R):A(R)}function z(R){return Un(R)?(e.consume(R),B):n(R)}function B(R){return R===45||Pn(R)?(e.consume(R),B):Y(R)}function Y(R){return Oe(R)?(u=Y,F(R)):nt(R)?(e.consume(R),Y):N(R)}function ee(R){return R===45||Pn(R)?(e.consume(R),ee):R===47||R===62||Nt(R)?ie(R):n(R)}function ie(R){return R===47?(e.consume(R),N):R===58||R===95||Un(R)?(e.consume(R),D):Oe(R)?(u=ie,F(R)):nt(R)?(e.consume(R),ie):N(R)}function D(R){return R===45||R===46||R===58||R===95||Pn(R)?(e.consume(R),D):$(R)}function $(R){return R===61?(e.consume(R),H):Oe(R)?(u=$,F(R)):nt(R)?(e.consume(R),$):ie(R)}function H(R){return R===null||R===60||R===61||R===62||R===96?n(R):R===34||R===39?(e.consume(R),a=R,U):Oe(R)?(u=H,F(R)):nt(R)?(e.consume(R),H):(e.consume(R),q)}function U(R){return R===a?(e.consume(R),a=void 0,T):R===null?n(R):Oe(R)?(u=U,F(R)):(e.consume(R),U)}function q(R){return R===null||R===34||R===39||R===60||R===61||R===96?n(R):R===47||R===62||Nt(R)?ie(R):(e.consume(R),q)}function T(R){return R===47||R===62||Nt(R)?ie(R):n(R)}function N(R){return R===62?(e.consume(R),e.exit("htmlTextData"),e.exit("htmlText"),t):n(R)}function F(R){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),I}function I(R){return nt(R)?lt(e,J,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):J(R)}function J(R){return e.enter("htmlTextData"),u(R)}}const lg={name:"labelEnd",resolveAll:p4,resolveTo:m4,tokenize:g4},d4={tokenize:x4},h4={tokenize:y4},f4={tokenize:b4};function p4(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&mr(e,0,e.length,n),e}function m4(e,t){let n=e.length,r=0,a,o,u,d;for(;n--;)if(a=e[n][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(u=n);const p={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[o][1].start},end:{...e[u][1].end}},m={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[u-2][1].start}};return d=[["enter",p,t],["enter",f,t]],d=Dr(d,e.slice(o+1,o+r+3)),d=Dr(d,[["enter",m,t]]),d=Dr(d,cd(t.parser.constructs.insideSpan.null,e.slice(o+r+4,u-3),t)),d=Dr(d,[["exit",m,t],e[u-2],e[u-1],["exit",f,t]]),d=Dr(d,e.slice(u+1)),d=Dr(d,[["exit",p,t]]),mr(e,o,e.length,d),e}function g4(e,t,n){const r=this;let a=r.events.length,o,u;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){o=r.events[a][1];break}return d;function d(v){return o?o._inactive?g(v):(u=r.parser.defined.includes(Pr(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(v),e.exit("labelMarker"),e.exit("labelEnd"),p):n(v)}function p(v){return v===40?e.attempt(d4,m,u?m:g)(v):v===91?e.attempt(h4,m,u?f:g)(v):u?m(v):g(v)}function f(v){return e.attempt(f4,m,g)(v)}function m(v){return t(v)}function g(v){return o._balanced=!0,n(v)}}function x4(e,t,n){return r;function r(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),a}function a(g){return Nt(g)?wl(e,o)(g):o(g)}function o(g){return g===41?m(g):Bw(e,u,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function u(g){return Nt(g)?wl(e,p)(g):m(g)}function d(g){return n(g)}function p(g){return g===34||g===39||g===40?Pw(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):m(g)}function f(g){return Nt(g)?wl(e,m)(g):m(g)}function m(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):n(g)}}function y4(e,t,n){const r=this;return a;function a(d){return zw.call(r,e,o,u,"reference","referenceMarker","referenceString")(d)}function o(d){return r.parser.defined.includes(Pr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function u(d){return n(d)}}function b4(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),a}function a(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const v4={name:"labelStartImage",resolveAll:lg.resolveAll,tokenize:_4};function _4(e,t,n){const r=this;return a;function a(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),o}function o(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),u):n(d)}function u(d){return d===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(d):t(d)}}const S4={name:"labelStartLink",resolveAll:lg.resolveAll,tokenize:w4};function w4(e,t,n){const r=this;return a;function a(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),o}function o(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const ap={name:"lineEnding",tokenize:k4};function k4(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),lt(e,t,"linePrefix")}}const Tu={name:"thematicBreak",tokenize:C4};function C4(e,t,n){let r=0,a;return o;function o(f){return e.enter("thematicBreak"),u(f)}function u(f){return a=f,d(f)}function d(f){return f===a?(e.enter("thematicBreakSequence"),p(f)):r>=3&&(f===null||Oe(f))?(e.exit("thematicBreak"),t(f)):n(f)}function p(f){return f===a?(e.consume(f),r++,p):(e.exit("thematicBreakSequence"),nt(f)?lt(e,d,"whitespace")(f):d(f))}}const tr={continuation:{tokenize:T4},exit:D4,name:"list",tokenize:E4},N4={partial:!0,tokenize:M4},j4={partial:!0,tokenize:A4};function E4(e,t,n){const r=this,a=r.events[r.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return d;function d(b){const _=r.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(_==="listUnordered"?!r.containerState.marker||b===r.containerState.marker:mm(b)){if(r.containerState.type||(r.containerState.type=_,e.enter(_,{_container:!0})),_==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(Tu,n,f)(b):f(b);if(!r.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(b)}return n(b)}function p(b){return mm(b)&&++u<10?(e.consume(b),p):(!r.interrupt||u<2)&&(r.containerState.marker?b===r.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),f(b)):n(b)}function f(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||b,e.check(ql,r.interrupt?n:m,e.attempt(N4,v,g))}function m(b){return r.containerState.initialBlankLine=!0,o++,v(b)}function g(b){return nt(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),v):n(b)}function v(b){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function T4(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ql,a,o);function a(d){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,lt(e,t,"listItemIndent",r.containerState.size+1)(d)}function o(d){return r.containerState.furtherBlankLines||!nt(d)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,u(d)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(j4,t,u)(d))}function u(d){return r.containerState._closeFlow=!0,r.interrupt=void 0,lt(e,e.attempt(tr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function A4(e,t,n){const r=this;return lt(e,a,"listItemIndent",r.containerState.size+1);function a(o){const u=r.events[r.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===r.containerState.size?t(o):n(o)}}function D4(e){e.exit(this.containerState.type)}function M4(e,t,n){const r=this;return lt(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const u=r.events[r.events.length-1];return!nt(o)&&u&&u[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const H0={name:"setextUnderline",resolveTo:R4,tokenize:L4};function R4(e,t){let n=e.length,r,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const u={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",u,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=u,e.push(["exit",u,t]),e}function L4(e,t,n){const r=this;let a;return o;function o(f){let m=r.events.length,g;for(;m--;)if(r.events[m][1].type!=="lineEnding"&&r.events[m][1].type!=="linePrefix"&&r.events[m][1].type!=="content"){g=r.events[m][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||g)?(e.enter("setextHeadingLine"),a=f,u(f)):n(f)}function u(f){return e.enter("setextHeadingLineSequence"),d(f)}function d(f){return f===a?(e.consume(f),d):(e.exit("setextHeadingLineSequence"),nt(f)?lt(e,p,"lineSuffix")(f):p(f))}function p(f){return f===null||Oe(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const O4={tokenize:I4};function I4(e){const t=this,n=e.attempt(ql,r,e.attempt(this.parser.constructs.flowInitial,a,lt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(FD,a)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const B4={resolveAll:Fw()},z4=Hw("string"),P4=Hw("text");function Hw(e){return{resolveAll:Fw(e==="text"?H4:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],o=n.attempt(a,u,d);return u;function u(m){return f(m)?o(m):d(m)}function d(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),p}function p(m){return f(m)?(n.exit("data"),o(m)):(n.consume(m),p)}function f(m){if(m===null)return!0;const g=a[m];let v=-1;if(g)for(;++v<g.length;){const b=g[v];if(!b.previous||b.previous.call(r,r.previous))return!0}return!1}}}function Fw(e){return t;function t(n,r){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,r):n}}function H4(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let o=a.length,u=-1,d=0,p;for(;o--;){const f=a[o];if(typeof f=="string"){for(u=f.length;f.charCodeAt(u-1)===32;)d++,u--;if(u)break;u=-1}else if(f===-2)p=!0,d++;else if(f!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const f={type:n===e.length||p||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?u:r.start._bufferIndex+u,_index:r.start._index+o,line:r.end.line,column:r.end.column-d,offset:r.end.offset-d},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const F4={42:tr,43:tr,45:tr,48:tr,49:tr,50:tr,51:tr,52:tr,53:tr,54:tr,55:tr,56:tr,57:tr,62:Rw},$4={91:VD},U4={[-2]:ip,[-1]:ip,32:ip},W4={35:QD,42:Tu,45:[H0,Tu],60:n4,61:H0,95:Tu,96:z0,126:z0},q4={38:Ow,92:Lw},V4={[-5]:ap,[-4]:ap,[-3]:ap,33:v4,38:Ow,42:gm,60:[SD,c4],91:S4,92:[XD,Lw],93:lg,95:gm,96:OD},K4={null:[gm,B4]},G4={null:[42,95]},Y4={null:[]},X4=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:G4,contentInitial:$4,disable:Y4,document:F4,flow:W4,flowInitial:U4,insideSpan:K4,string:q4,text:V4},Symbol.toStringTag,{value:"Module"}));function Z4(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let u=[],d=[];const p={attempt:Y(z),check:Y(B),consume:E,enter:A,exit:O,interrupt:Y(B,{interrupt:!0})},f={code:null,containerState:{},defineSkip:S,events:[],now:_,parser:e,previous:null,sliceSerialize:v,sliceStream:b,write:g};let m=t.tokenize.call(f,p);return t.resolveAll&&o.push(t),f;function g($){return u=Dr(u,$),j(),u[u.length-1]!==null?[]:(ee(t,0),f.events=cd(o,f.events,f),f.events)}function v($,H){return J4(b($),H)}function b($){return Q4(u,$)}function _(){const{_bufferIndex:$,_index:H,line:U,column:q,offset:T}=r;return{_bufferIndex:$,_index:H,line:U,column:q,offset:T}}function S($){a[$.line]=$.column,D()}function j(){let $;for(;r._index<u.length;){const H=u[r._index];if(typeof H=="string")for($=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===$&&r._bufferIndex<H.length;)C(H.charCodeAt(r._bufferIndex));else C(H)}}function C($){m=m($)}function E($){Oe($)?(r.line++,r.column=1,r.offset+=$===-3?2:1,D()):$!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===u[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=$}function A($,H){const U=H||{};return U.type=$,U.start=_(),f.events.push(["enter",U,f]),d.push(U),U}function O($){const H=d.pop();return H.end=_(),f.events.push(["exit",H,f]),H}function z($,H){ee($,H.from)}function B($,H){H.restore()}function Y($,H){return U;function U(q,T,N){let F,I,J,R;return Array.isArray(q)?V(q):"tokenize"in q?V([q]):P(q);function P(Z){return se;function se(ve){const Ce=ve!==null&&Z[ve],Te=ve!==null&&Z.null,Pe=[...Array.isArray(Ce)?Ce:Ce?[Ce]:[],...Array.isArray(Te)?Te:Te?[Te]:[]];return V(Pe)(ve)}}function V(Z){return F=Z,I=0,Z.length===0?N:L(Z[I])}function L(Z){return se;function se(ve){return R=ie(),J=Z,Z.partial||(f.currentConstruct=Z),Z.name&&f.parser.constructs.disable.null.includes(Z.name)?W():Z.tokenize.call(H?Object.assign(Object.create(f),H):f,p,G,W)(ve)}}function G(Z){return $(J,R),T}function W(Z){return R.restore(),++I<F.length?L(F[I]):N}}}function ee($,H){$.resolveAll&&!o.includes($)&&o.push($),$.resolve&&mr(f.events,H,f.events.length-H,$.resolve(f.events.slice(H),f)),$.resolveTo&&(f.events=$.resolveTo(f.events,f))}function ie(){const $=_(),H=f.previous,U=f.currentConstruct,q=f.events.length,T=Array.from(d);return{from:q,restore:N};function N(){r=$,f.previous=H,f.currentConstruct=U,f.events.length=q,d=T,D()}}function D(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function Q4(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let u;if(n===a)u=[e[n].slice(r,o)];else{if(u=e.slice(n,a),r>-1){const d=u[0];typeof d=="string"?u[0]=d.slice(r):u.shift()}o>0&&u.push(e[a].slice(0,o))}return u}function J4(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const o=e[n];let u;if(typeof o=="string")u=o;else switch(o){case-5:{u="\r";break}case-4:{u=`
|
|
113
|
+
`;break}case-3:{u=`\r
|
|
114
|
+
`;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&a)continue;u=" ";break}default:u=String.fromCharCode(o)}a=o===-2,r.push(u)}return r.join("")}function eM(e){const r={constructs:Dw([X4,...(e||{}).extensions||[]]),content:a(mD),defined:[],document:a(xD),flow:a(O4),lazy:{},string:a(z4),text:a(P4)};return r;function a(o){return u;function u(d){return Z4(r,o,d)}}}function tM(e){for(;!Iw(e););return e}const F0=/[\0\t\n\r]/g;function nM(){let e=1,t="",n=!0,r;return a;function a(o,u,d){const p=[];let f,m,g,v,b;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(u||void 0).decode(o)),g=0,t="",n&&(o.charCodeAt(0)===65279&&g++,n=void 0);g<o.length;){if(F0.lastIndex=g,f=F0.exec(o),v=f&&f.index!==void 0?f.index:o.length,b=o.charCodeAt(v),!f){t=o.slice(g);break}if(b===10&&g===v&&r)p.push(-3),r=void 0;else switch(r&&(p.push(-5),r=void 0),g<v&&(p.push(o.slice(g,v)),e+=v-g),b){case 0:{p.push(65533),e++;break}case 9:{for(m=Math.ceil(e/4)*4,p.push(-2);e++<m;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:r=!0,e=1}g=v+1}return d&&(r&&p.push(-5),t&&p.push(t),p.push(null)),p}}const rM=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function sM(e){return e.replace(rM,iM)}function iM(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),o=a===120||a===88;return Mw(n.slice(o?2:1),o?16:10)}return Ml(n)||e}const $w={}.hasOwnProperty;function aM(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),oM(n)(tM(eM(n).document().write(nM()(e,t,!0))))}function oM(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(ut),autolinkProtocol:ie,autolinkEmail:ie,atxHeading:o(pt),blockQuote:o(Te),characterEscape:ie,characterReference:ie,codeFenced:o(Pe),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:o(Pe,u),codeText:o($e,u),codeTextData:ie,data:ie,codeFlowValue:ie,definition:o(Re),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:o(Xe),hardBreakEscape:o(gt),hardBreakTrailing:o(gt),htmlFlow:o(kt,u),htmlFlowData:ie,htmlText:o(kt,u),htmlTextData:ie,image:o(ct),label:u,link:o(ut),listItem:o(je),listItemValue:v,listOrdered:o(me,g),listUnordered:o(me),paragraph:o(ce),reference:L,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:o(pt),strong:o(Ae),thematicBreak:o(an)},exit:{atxHeading:p(),atxHeadingSequence:z,autolink:p(),autolinkEmail:Ce,autolinkProtocol:ve,blockQuote:p(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:W,characterReferenceMarkerNumeric:W,characterReferenceValue:Z,characterReference:se,codeFenced:p(j),codeFencedFence:S,codeFencedFenceInfo:b,codeFencedFenceMeta:_,codeFlowValue:D,codeIndented:p(C),codeText:p(T),codeTextData:D,data:D,definition:p(),definitionDestinationString:O,definitionLabelString:E,definitionTitleString:A,emphasis:p(),hardBreakEscape:p(H),hardBreakTrailing:p(H),htmlFlow:p(U),htmlFlowData:D,htmlText:p(q),htmlTextData:D,image:p(F),label:J,labelText:I,lineEnding:$,link:p(N),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:G,resourceDestinationString:R,resourceTitleString:P,resource:V,setextHeading:p(ee),setextHeadingLineSequence:Y,setextHeadingText:B,strong:p(),thematicBreak:p()}};Uw(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(le){let xe={type:"root",children:[]};const Me={stack:[xe],tokenStack:[],config:t,enter:d,exit:f,buffer:u,resume:m,data:n},Be=[];let ot=-1;for(;++ot<le.length;)if(le[ot][1].type==="listOrdered"||le[ot][1].type==="listUnordered")if(le[ot][0]==="enter")Be.push(ot);else{const Cn=Be.pop();ot=a(le,Cn,ot)}for(ot=-1;++ot<le.length;){const Cn=t[le[ot][0]];$w.call(Cn,le[ot][1].type)&&Cn[le[ot][1].type].call(Object.assign({sliceSerialize:le[ot][2].sliceSerialize},Me),le[ot][1])}if(Me.tokenStack.length>0){const Cn=Me.tokenStack[Me.tokenStack.length-1];(Cn[1]||$0).call(Me,void 0,Cn[0])}for(xe.position={start:ii(le.length>0?le[0][1].start:{line:1,column:1,offset:0}),end:ii(le.length>0?le[le.length-2][1].end:{line:1,column:1,offset:0})},ot=-1;++ot<t.transforms.length;)xe=t.transforms[ot](xe)||xe;return xe}function a(le,xe,Me){let Be=xe-1,ot=-1,Cn=!1,Vn,on,Bt,ae;for(;++Be<=Me;){const we=le[Be];switch(we[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{we[0]==="enter"?ot++:ot--,ae=void 0;break}case"lineEndingBlank":{we[0]==="enter"&&(Vn&&!ae&&!ot&&!Bt&&(Bt=Be),ae=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ae=void 0}if(!ot&&we[0]==="enter"&&we[1].type==="listItemPrefix"||ot===-1&&we[0]==="exit"&&(we[1].type==="listUnordered"||we[1].type==="listOrdered")){if(Vn){let qe=Be;for(on=void 0;qe--;){const dt=le[qe];if(dt[1].type==="lineEnding"||dt[1].type==="lineEndingBlank"){if(dt[0]==="exit")continue;on&&(le[on][1].type="lineEndingBlank",Cn=!0),dt[1].type="lineEnding",on=qe}else if(!(dt[1].type==="linePrefix"||dt[1].type==="blockQuotePrefix"||dt[1].type==="blockQuotePrefixWhitespace"||dt[1].type==="blockQuoteMarker"||dt[1].type==="listItemIndent"))break}Bt&&(!on||Bt<on)&&(Vn._spread=!0),Vn.end=Object.assign({},on?le[on][1].start:we[1].end),le.splice(on||Be,0,["exit",Vn,we[2]]),Be++,Me++}if(we[1].type==="listItemPrefix"){const qe={type:"listItem",_spread:!1,start:Object.assign({},we[1].start),end:void 0};Vn=qe,le.splice(Be,0,["enter",qe,we[2]]),Be++,Me++,Bt=void 0,ae=!0}}}return le[xe][1]._spread=Cn,Me}function o(le,xe){return Me;function Me(Be){d.call(this,le(Be),Be),xe&&xe.call(this,Be)}}function u(){this.stack.push({type:"fragment",children:[]})}function d(le,xe,Me){this.stack[this.stack.length-1].children.push(le),this.stack.push(le),this.tokenStack.push([xe,Me||void 0]),le.position={start:ii(xe.start),end:void 0}}function p(le){return xe;function xe(Me){le&&le.call(this,Me),f.call(this,Me)}}function f(le,xe){const Me=this.stack.pop(),Be=this.tokenStack.pop();if(Be)Be[0].type!==le.type&&(xe?xe.call(this,le,Be[0]):(Be[1]||$0).call(this,le,Be[0]));else throw new Error("Cannot close `"+le.type+"` ("+Sl({start:le.start,end:le.end})+"): it’s not open");Me.position.end=ii(le.end)}function m(){return og(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function v(le){if(this.data.expectingFirstListItemValue){const xe=this.stack[this.stack.length-2];xe.start=Number.parseInt(this.sliceSerialize(le),10),this.data.expectingFirstListItemValue=void 0}}function b(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.lang=le}function _(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.meta=le}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function j(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function C(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le.replace(/(\r?\n|\r)$/g,"")}function E(le){const xe=this.resume(),Me=this.stack[this.stack.length-1];Me.label=xe,Me.identifier=Pr(this.sliceSerialize(le)).toLowerCase()}function A(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.title=le}function O(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.url=le}function z(le){const xe=this.stack[this.stack.length-1];if(!xe.depth){const Me=this.sliceSerialize(le).length;xe.depth=Me}}function B(){this.data.setextHeadingSlurpLineEnding=!0}function Y(le){const xe=this.stack[this.stack.length-1];xe.depth=this.sliceSerialize(le).codePointAt(0)===61?1:2}function ee(){this.data.setextHeadingSlurpLineEnding=void 0}function ie(le){const Me=this.stack[this.stack.length-1].children;let Be=Me[Me.length-1];(!Be||Be.type!=="text")&&(Be=Ie(),Be.position={start:ii(le.start),end:void 0},Me.push(Be)),this.stack.push(Be)}function D(le){const xe=this.stack.pop();xe.value+=this.sliceSerialize(le),xe.position.end=ii(le.end)}function $(le){const xe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Me=xe.children[xe.children.length-1];Me.position.end=ii(le.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(xe.type)&&(ie.call(this,le),D.call(this,le))}function H(){this.data.atHardBreak=!0}function U(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le}function q(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le}function T(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.value=le}function N(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=xe,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function F(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=xe,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function I(le){const xe=this.sliceSerialize(le),Me=this.stack[this.stack.length-2];Me.label=sM(xe),Me.identifier=Pr(xe).toLowerCase()}function J(){const le=this.stack[this.stack.length-1],xe=this.resume(),Me=this.stack[this.stack.length-1];if(this.data.inReference=!0,Me.type==="link"){const Be=le.children;Me.children=Be}else Me.alt=xe}function R(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.url=le}function P(){const le=this.resume(),xe=this.stack[this.stack.length-1];xe.title=le}function V(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function G(le){const xe=this.resume(),Me=this.stack[this.stack.length-1];Me.label=xe,Me.identifier=Pr(this.sliceSerialize(le)).toLowerCase(),this.data.referenceType="full"}function W(le){this.data.characterReferenceType=le.type}function Z(le){const xe=this.sliceSerialize(le),Me=this.data.characterReferenceType;let Be;Me?(Be=Mw(xe,Me==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Be=Ml(xe);const ot=this.stack[this.stack.length-1];ot.value+=Be}function se(le){const xe=this.stack.pop();xe.position.end=ii(le.end)}function ve(le){D.call(this,le);const xe=this.stack[this.stack.length-1];xe.url=this.sliceSerialize(le)}function Ce(le){D.call(this,le);const xe=this.stack[this.stack.length-1];xe.url="mailto:"+this.sliceSerialize(le)}function Te(){return{type:"blockquote",children:[]}}function Pe(){return{type:"code",lang:null,meta:null,value:""}}function $e(){return{type:"inlineCode",value:""}}function Re(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Xe(){return{type:"emphasis",children:[]}}function pt(){return{type:"heading",depth:0,children:[]}}function gt(){return{type:"break"}}function kt(){return{type:"html",value:""}}function ct(){return{type:"image",title:null,url:"",alt:null}}function ut(){return{type:"link",title:null,url:"",children:[]}}function me(le){return{type:"list",ordered:le.type==="listOrdered",start:null,spread:le._spread,children:[]}}function je(le){return{type:"listItem",spread:le._spread,checked:null,children:[]}}function ce(){return{type:"paragraph",children:[]}}function Ae(){return{type:"strong",children:[]}}function Ie(){return{type:"text",value:""}}function an(){return{type:"thematicBreak"}}}function ii(e){return{line:e.line,column:e.column,offset:e.offset}}function Uw(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Uw(e,r):lM(e,r)}}function lM(e,t){let n;for(n in t)if($w.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function $0(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Sl({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Sl({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Sl({start:t.start,end:t.end})+") is still open")}function cM(e){const t=this;t.parser=n;function n(r){return aM(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function uM(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function dM(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
115
|
+
`}]}function hM(e,t){const n=t.value?t.value+`
|
|
116
|
+
`:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function fM(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pM(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mM(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=ro(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let u,d=e.footnoteCounts.get(r);d===void 0?(d=0,e.footnoteOrder.push(r),u=e.footnoteOrder.length):u=o+1,d+=1,e.footnoteCounts.set(r,d);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,p);const f={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,f),e.applyData(t,f)}function gM(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xM(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Ww(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=r:a.push({type:"text",value:r}),a}function yM(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Ww(e,t);const a={src:ro(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function bM(e,t){const n={src:ro(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function vM(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function _M(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Ww(e,t);const a={href:ro(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function SM(e,t){const n={href:ro(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function wM(e,t,n){const r=e.all(t),a=n?kM(n):qw(t),o={},u=[];if(typeof t.checked=="boolean"){const m=r[0];let g;m&&m.type==="element"&&m.tagName==="p"?g=m:(g={type:"element",tagName:"p",properties:{},children:[]},r.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let d=-1;for(;++d<r.length;){const m=r[d];(a||d!==0||m.type!=="element"||m.tagName!=="p")&&u.push({type:"text",value:`
|
|
117
|
+
`}),m.type==="element"&&m.tagName==="p"&&!a?u.push(...m.children):u.push(m)}const p=r[r.length-1];p&&(a||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
|
|
118
|
+
`});const f={type:"element",tagName:"li",properties:o,children:u};return e.patch(t,f),e.applyData(t,f)}function kM(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=qw(n[r])}return t}function qw(e){const t=e.spread;return t??e.children.length>1}function CM(e,t){const n={},r=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<r.length;){const u=r[a];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function NM(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jM(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function EM(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function TM(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],u),a.push(u)}if(n.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},d=rg(t.children[1]),p=kw(t.children[t.children.length-1]);d&&p&&(u.position={start:d,end:p}),a.push(u)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function AM(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",u=n&&n.type==="table"?n.align:void 0,d=u?u.length:t.children.length;let p=-1;const f=[];for(;++p<d;){const g=t.children[p],v={},b=u?u[p]:void 0;b&&(v.align=b);let _={type:"element",tagName:o,properties:v,children:[]};g&&(_.children=e.all(g),e.patch(g,_),_=e.applyData(g,_)),f.push(_)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,m),e.applyData(t,m)}function DM(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const U0=9,W0=32;function MM(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const o=[];for(;r;)o.push(q0(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return o.push(q0(t.slice(a),a>0,!1)),o.join("")}function q0(e,t,n){let r=0,a=e.length;if(t){let o=e.codePointAt(r);for(;o===U0||o===W0;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(a-1);for(;o===U0||o===W0;)a--,o=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function RM(e,t){const n={type:"text",value:MM(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function LM(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const OM={blockquote:uM,break:dM,code:hM,delete:fM,emphasis:pM,footnoteReference:mM,heading:gM,html:xM,imageReference:yM,image:bM,inlineCode:vM,linkReference:_M,link:SM,listItem:wM,list:CM,paragraph:NM,root:jM,strong:EM,table:TM,tableCell:DM,tableRow:AM,text:RM,thematicBreak:LM,toml:xu,yaml:xu,definition:xu,footnoteDefinition:xu};function xu(){}const Vw=-1,ud=0,kl=1,Uu=2,cg=3,ug=4,dg=5,hg=6,Kw=7,Gw=8,V0=typeof self=="object"?self:globalThis,IM=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),r=a=>{if(e.has(a))return e.get(a);const[o,u]=t[a];switch(o){case ud:case Vw:return n(u,a);case kl:{const d=n([],a);for(const p of u)d.push(r(p));return d}case Uu:{const d=n({},a);for(const[p,f]of u)d[r(p)]=r(f);return d}case cg:return n(new Date(u),a);case ug:{const{source:d,flags:p}=u;return n(new RegExp(d,p),a)}case dg:{const d=n(new Map,a);for(const[p,f]of u)d.set(r(p),r(f));return d}case hg:{const d=n(new Set,a);for(const p of u)d.add(r(p));return d}case Kw:{const{name:d,message:p}=u;return n(new V0[d](p),a)}case Gw:return n(BigInt(u),a);case"BigInt":return n(Object(BigInt(u)),a);case"ArrayBuffer":return n(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:d}=new Uint8Array(u);return n(new DataView(d),u)}}return n(new V0[o](u),a)};return r},K0=e=>IM(new Map,e)(0),Pa="",{toString:BM}={},{keys:zM}=Object,ul=e=>{const t=typeof e;if(t!=="object"||!e)return[ud,t];const n=BM.call(e).slice(8,-1);switch(n){case"Array":return[kl,Pa];case"Object":return[Uu,Pa];case"Date":return[cg,Pa];case"RegExp":return[ug,Pa];case"Map":return[dg,Pa];case"Set":return[hg,Pa];case"DataView":return[kl,n]}return n.includes("Array")?[kl,n]:n.includes("Error")?[Kw,n]:[Uu,n]},yu=([e,t])=>e===ud&&(t==="function"||t==="symbol"),PM=(e,t,n,r)=>{const a=(u,d)=>{const p=r.push(u)-1;return n.set(d,p),p},o=u=>{if(n.has(u))return n.get(u);let[d,p]=ul(u);switch(d){case ud:{let m=u;switch(p){case"bigint":d=Gw,m=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);m=null;break;case"undefined":return a([Vw],u)}return a([d,m],u)}case kl:{if(p){let v=u;return p==="DataView"?v=new Uint8Array(u.buffer):p==="ArrayBuffer"&&(v=new Uint8Array(u)),a([p,[...v]],u)}const m=[],g=a([d,m],u);for(const v of u)m.push(o(v));return g}case Uu:{if(p)switch(p){case"BigInt":return a([p,u.toString()],u);case"Boolean":case"Number":case"String":return a([p,u.valueOf()],u)}if(t&&"toJSON"in u)return o(u.toJSON());const m=[],g=a([d,m],u);for(const v of zM(u))(e||!yu(ul(u[v])))&&m.push([o(v),o(u[v])]);return g}case cg:return a([d,u.toISOString()],u);case ug:{const{source:m,flags:g}=u;return a([d,{source:m,flags:g}],u)}case dg:{const m=[],g=a([d,m],u);for(const[v,b]of u)(e||!(yu(ul(v))||yu(ul(b))))&&m.push([o(v),o(b)]);return g}case hg:{const m=[],g=a([d,m],u);for(const v of u)(e||!yu(ul(v)))&&m.push(o(v));return g}}const{message:f}=u;return a([d,{name:p,message:f}],u)};return o},G0=(e,{json:t,lossy:n}={})=>{const r=[];return PM(!(t||n),!!t,new Map,r)(e),r},Wu=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?K0(G0(e,t)):structuredClone(e):(e,t)=>K0(G0(e,t));function HM(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function FM(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function $M(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||HM,r=e.options.footnoteBackLabel||FM,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let p=-1;for(;++p<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[p]);if(!f)continue;const m=e.all(f),g=String(f.identifier).toUpperCase(),v=ro(g.toLowerCase());let b=0;const _=[],S=e.footnoteCounts.get(g);for(;S!==void 0&&++b<=S;){_.length>0&&_.push({type:"text",value:" "});let E=typeof n=="string"?n:n(p,b);typeof E=="string"&&(E={type:"text",value:E}),_.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+v+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(p,b),className:["data-footnote-backref"]},children:Array.isArray(E)?E:[E]})}const j=m[m.length-1];if(j&&j.type==="element"&&j.tagName==="p"){const E=j.children[j.children.length-1];E&&E.type==="text"?E.value+=" ":j.children.push({type:"text",value:" "}),j.children.push(..._)}else m.push(..._);const C={type:"element",tagName:"li",properties:{id:t+"fn-"+v},children:e.wrap(m,!0)};e.patch(f,C),d.push(C)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Wu(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
|
|
119
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(d,!0)},{type:"text",value:`
|
|
120
|
+
`}]}}const dd=(function(e){if(e==null)return VM;if(typeof e=="function")return hd(e);if(typeof e=="object")return Array.isArray(e)?UM(e):WM(e);if(typeof e=="string")return qM(e);throw new Error("Expected function, string, or object as test")});function UM(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=dd(e[n]);return hd(r);function r(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function WM(e){const t=e;return hd(n);function n(r){const a=r;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function qM(e){return hd(t);function t(n){return n&&n.type===e}}function hd(e){return t;function t(n,r,a){return!!(KM(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function VM(){return!0}function KM(e){return e!==null&&typeof e=="object"&&"type"in e}const Yw=[],GM=!0,xm=!1,YM="skip";function Xw(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const o=dd(a),u=r?-1:1;d(e,void 0,[])();function d(p,f,m){const g=p&&typeof p=="object"?p:{};if(typeof g.type=="string"){const b=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(p.type+(b?"<"+b+">":""))+")"})}return v;function v(){let b=Yw,_,S,j;if((!t||o(p,f,m[m.length-1]||void 0))&&(b=XM(n(p,m)),b[0]===xm))return b;if("children"in p&&p.children){const C=p;if(C.children&&b[0]!==YM)for(S=(r?C.children.length:-1)+u,j=m.concat(C);S>-1&&S<C.children.length;){const E=C.children[S];if(_=d(E,S,j)(),_[0]===xm)return _;S=typeof _[1]=="number"?_[1]:S+u}}return b}}}function XM(e){return Array.isArray(e)?e:typeof e=="number"?[GM,e]:e==null?Yw:[e]}function fg(e,t,n,r){let a,o,u;typeof t=="function"&&typeof n!="function"?(o=void 0,u=t,a=n):(o=t,u=n,a=r),Xw(e,o,d,a);function d(p,f){const m=f[f.length-1],g=m?m.children.indexOf(p):void 0;return u(p,g,m)}}const ym={}.hasOwnProperty,ZM={};function QM(e,t){const n=t||ZM,r=new Map,a=new Map,o=new Map,u={...OM,...n.handlers},d={all:f,applyData:eR,definitionById:r,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:u,one:p,options:n,patch:JM,wrap:nR};return fg(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const g=m.type==="definition"?r:a,v=String(m.identifier).toUpperCase();g.has(v)||g.set(v,m)}}),d;function p(m,g){const v=m.type,b=d.handlers[v];if(ym.call(d.handlers,v)&&b)return b(d,m,g);if(d.options.passThrough&&d.options.passThrough.includes(v)){if("children"in m){const{children:S,...j}=m,C=Wu(j);return C.children=d.all(m),C}return Wu(m)}return(d.options.unknownHandler||tR)(d,m,g)}function f(m){const g=[];if("children"in m){const v=m.children;let b=-1;for(;++b<v.length;){const _=d.one(v[b],m);if(_){if(b&&v[b-1].type==="break"&&(!Array.isArray(_)&&_.type==="text"&&(_.value=Y0(_.value)),!Array.isArray(_)&&_.type==="element")){const S=_.children[0];S&&S.type==="text"&&(S.value=Y0(S.value))}Array.isArray(_)?g.push(..._):g.push(_)}}}return g}}function JM(e,t){e.position&&(t.position=FA(e))}function eR(e,t){let n=t;if(e&&e.data){const r=e.data.hName,a=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const u="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:u}}n.type==="element"&&o&&Object.assign(n.properties,Wu(o)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function tR(e,t){const n=t.data||{},r="value"in t&&!(ym.call(n,"hProperties")||ym.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function nR(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
121
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
122
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
123
|
+
`}),n}function Y0(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function X0(e,t){const n=QM(e,t),r=n.one(e,void 0),a=$M(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
|
|
124
|
+
`},a),o}function rR(e,t){return e&&"run"in e?async function(n,r){const a=X0(n,{file:r,...t});await e.run(a,r)}:function(n,r){return X0(n,{file:r,...e||t})}}function Z0(e){if(e)throw e}var op,Q0;function sR(){if(Q0)return op;Q0=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},o=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var m=e.call(f,"constructor"),g=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!m&&!g)return!1;var v;for(v in f);return typeof v>"u"||e.call(f,v)},u=function(f,m){n&&m.name==="__proto__"?n(f,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):f[m.name]=m.newValue},d=function(f,m){if(m==="__proto__")if(e.call(f,m)){if(r)return r(f,m).value}else return;return f[m]};return op=function p(){var f,m,g,v,b,_,S=arguments[0],j=1,C=arguments.length,E=!1;for(typeof S=="boolean"&&(E=S,S=arguments[1]||{},j=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});j<C;++j)if(f=arguments[j],f!=null)for(m in f)g=d(S,m),v=d(f,m),S!==v&&(E&&v&&(o(v)||(b=a(v)))?(b?(b=!1,_=g&&a(g)?g:[]):_=g&&o(g)?g:{},u(S,{name:m,newValue:p(E,_,v)})):typeof v<"u"&&u(S,{name:m,newValue:v}));return S},op}var iR=sR();const lp=Gu(iR);function bm(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function aR(){const e=[],t={run:n,use:r};return t;function n(...a){let o=-1;const u=a.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);d(null,...a);function d(p,...f){const m=e[++o];let g=-1;if(p){u(p);return}for(;++g<a.length;)(f[g]===null||f[g]===void 0)&&(f[g]=a[g]);a=f,m?oR(m,d)(...f):u(null,...f)}}function r(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function oR(e,t){let n;return r;function r(...u){const d=e.length>u.length;let p;d&&u.push(a);try{p=e.apply(this,u)}catch(f){const m=f;if(d&&n)throw m;return a(m)}d||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(u,...d){n||(n=!0,t(u,...d))}function o(u){a(null,u)}}const Zr={basename:lR,dirname:cR,extname:uR,join:dR,sep:"/"};function lR(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Vl(e);let n=0,r=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else r<0&&(o=!0,r=a+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let u=-1,d=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else u<0&&(o=!0,u=a+1),d>-1&&(e.codePointAt(a)===t.codePointAt(d--)?d<0&&(r=a):(d=-1,r=u));return n===r?r=u:r<0&&(r=e.length),e.slice(n,r)}function cR(e){if(Vl(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function uR(e){Vl(e);let t=e.length,n=-1,r=0,a=-1,o=0,u;for(;t--;){const d=e.codePointAt(t);if(d===47){if(u){r=t+1;break}continue}n<0&&(u=!0,n=t+1),d===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===r+1?"":e.slice(a,n)}function dR(...e){let t=-1,n;for(;++t<e.length;)Vl(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":hR(n)}function hR(e){Vl(e);const t=e.codePointAt(0)===47;let n=fR(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function fR(e,t){let n="",r=0,a=-1,o=0,u=-1,d,p;for(;++u<=e.length;){if(u<e.length)d=e.codePointAt(u);else{if(d===47)break;d=47}if(d===47){if(!(a===u-1||o===1))if(a!==u-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",r=0):(n=n.slice(0,p),r=n.length-1-n.lastIndexOf("/")),a=u,o=0;continue}}else if(n.length>0){n="",r=0,a=u,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,u):n=e.slice(a+1,u),r=u-a-1;a=u,o=0}else d===46&&o>-1?o++:o=-1}return n}function Vl(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const pR={cwd:mR};function mR(){return"/"}function vm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function gR(e){if(typeof e=="string")e=new URL(e);else if(!vm(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return xR(e)}function xR(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const cp=["history","path","basename","stem","extname","dirname"];class Zw{constructor(t){let n;t?vm(t)?n={path:t}:typeof t=="string"||yR(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":pR.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<cp.length;){const o=cp[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let a;for(a in n)cp.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Zr.basename(this.path):void 0}set basename(t){dp(t,"basename"),up(t,"basename"),this.path=Zr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Zr.dirname(this.path):void 0}set dirname(t){J0(this.basename,"dirname"),this.path=Zr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Zr.extname(this.path):void 0}set extname(t){if(up(t,"extname"),J0(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Zr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){vm(t)&&(t=gR(t)),dp(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Zr.basename(this.path,this.extname):void 0}set stem(t){dp(t,"stem"),up(t,"stem"),this.path=Zr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const a=this.message(t,n,r);throw a.fatal=!0,a}info(t,n,r){const a=this.message(t,n,r);return a.fatal=void 0,a}message(t,n,r){const a=new Hn(t,n,r);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function up(e,t){if(e&&e.includes(Zr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Zr.sep+"`")}function dp(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function J0(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function yR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const bR=(function(e){const r=this.constructor.prototype,a=r[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),vR={}.hasOwnProperty;class pg extends bR{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=aR()}copy(){const t=new pg;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(lp(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(pp("data",this.frozen),this.namespace[t]=n,this):vR.call(this.namespace,t)&&this.namespace[t]||void 0:t?(pp("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const a=n.call(t,...r);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=bu(t),r=this.parser||this.Parser;return hp("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),hp("process",this.parser||this.Parser),fp("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(o,u){const d=bu(t),p=r.parse(d);r.run(p,d,function(m,g,v){if(m||!g||!v)return f(m);const b=g,_=r.stringify(b,v);wR(_)?v.value=_:v.result=_,f(m,v)});function f(m,g){m||!g?u(m):o?o(g):n(void 0,g)}}}processSync(t){let n=!1,r;return this.freeze(),hp("processSync",this.parser||this.Parser),fp("processSync",this.compiler||this.Compiler),this.process(t,a),tS("processSync","process",n),r;function a(o,u){n=!0,Z0(o),r=u}}run(t,n,r){eS(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(u,d){const p=bu(n);a.run(t,p,f);function f(m,g,v){const b=g||t;m?d(m):u?u(b):r(void 0,b,v)}}}runSync(t,n){let r=!1,a;return this.run(t,n,o),tS("runSync","run",r),a;function o(u,d){Z0(u),a=d,r=!0}}stringify(t,n){this.freeze();const r=bu(n),a=this.compiler||this.Compiler;return fp("stringify",a),eS(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(pp("use",this.frozen),t!=null)if(typeof t=="function")p(t,n);else if(typeof t=="object")Array.isArray(t)?d(t):u(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(f){if(typeof f=="function")p(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[m,...g]=f;p(m,g)}else u(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function u(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");d(f.plugins),f.settings&&(a.settings=lp(!0,a.settings,f.settings))}function d(f){let m=-1;if(f!=null)if(Array.isArray(f))for(;++m<f.length;){const g=f[m];o(g)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function p(f,m){let g=-1,v=-1;for(;++g<r.length;)if(r[g][0]===f){v=g;break}if(v===-1)r.push([f,...m]);else if(m.length>0){let[b,..._]=m;const S=r[v][1];bm(S)&&bm(b)&&(b=lp(!0,S,b)),r[v]=[f,b,..._]}}}}const _R=new pg().freeze();function hp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function fp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function pp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function eS(e){if(!bm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function tS(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function bu(e){return SR(e)?e:new Zw(e)}function SR(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function wR(e){return typeof e=="string"||kR(e)}function kR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const CR="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",nS=[],rS={allowDangerousHtml:!0},NR=/^(https?|ircs?|mailto|xmpp)$/i,jR=[{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 ER(e){const t=TR(e),n=AR(e);return DR(t.runSync(t.parse(n),n),e)}function TR(e){const t=e.rehypePlugins||nS,n=e.remarkPlugins||nS,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...rS}:rS;return _R().use(cM).use(n).use(rR,r).use(t)}function AR(e){const t=e.children||"",n=new Zw;return typeof t=="string"&&(n.value=t),n}function DR(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,o=t.disallowedElements,u=t.skipHtml,d=t.unwrapDisallowed,p=t.urlTransform||MR;for(const m of jR)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+CR+m.id,void 0);return fg(e,f),VA(e,{Fragment:l.Fragment,components:a,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function f(m,g,v){if(m.type==="raw"&&v&&typeof g=="number")return u?v.children.splice(g,1):v.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let b;for(b in sp)if(Object.hasOwn(sp,b)&&Object.hasOwn(m.properties,b)){const _=m.properties[b],S=sp[b];(S===null||S.includes(m.tagName))&&(m.properties[b]=p(String(_||""),b,m))}}if(m.type==="element"){let b=n?!n.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&r&&typeof g=="number"&&(b=!r(m,g,v)),b&&v&&typeof g=="number")return d&&m.children?v.children.splice(g,1,...m.children):v.children.splice(g,1),g}}}function MR(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||r!==-1&&t>r||NR.test(e.slice(0,t))?e:""}function sS(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function RR(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function LR(e,t,n){const a=dd((n||{}).ignore||[]),o=OR(t);let u=-1;for(;++u<o.length;)Xw(e,"text",d);function d(f,m){let g=-1,v;for(;++g<m.length;){const b=m[g],_=v?v.children:void 0;if(a(b,_?_.indexOf(b):void 0,v))return;v=b}if(v)return p(f,m)}function p(f,m){const g=m[m.length-1],v=o[u][0],b=o[u][1];let _=0;const j=g.children.indexOf(f);let C=!1,E=[];v.lastIndex=0;let A=v.exec(f.value);for(;A;){const O=A.index,z={index:A.index,input:A.input,stack:[...m,f]};let B=b(...A,z);if(typeof B=="string"&&(B=B.length>0?{type:"text",value:B}:void 0),B===!1?v.lastIndex=O+1:(_!==O&&E.push({type:"text",value:f.value.slice(_,O)}),Array.isArray(B)?E.push(...B):B&&E.push(B),_=O+A[0].length,C=!0),!v.global)break;A=v.exec(f.value)}return C?(_<f.value.length&&E.push({type:"text",value:f.value.slice(_)}),g.children.splice(j,1,...E)):E=[f],j+E.length}}function OR(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const a=n[r];t.push([IR(a[0]),BR(a[1])])}return t}function IR(e){return typeof e=="string"?new RegExp(RR(e),"g"):e}function BR(e){return typeof e=="function"?e:function(){return e}}const mp="phrasing",gp=["autolink","link","image","label"];function zR(){return{transforms:[qR],enter:{literalAutolink:HR,literalAutolinkEmail:xp,literalAutolinkHttp:xp,literalAutolinkWww:xp},exit:{literalAutolink:WR,literalAutolinkEmail:UR,literalAutolinkHttp:FR,literalAutolinkWww:$R}}}function PR(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:mp,notInConstruct:gp},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:mp,notInConstruct:gp},{character:":",before:"[ps]",after:"\\/",inConstruct:mp,notInConstruct:gp}]}}function HR(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function xp(e){this.config.enter.autolinkProtocol.call(this,e)}function FR(e){this.config.exit.autolinkProtocol.call(this,e)}function $R(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function UR(e){this.config.exit.autolinkEmail.call(this,e)}function WR(e){this.exit(e)}function qR(e){LR(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,VR],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),KR]],{ignore:["link","linkReference"]})}function VR(e,t,n,r,a){let o="";if(!Qw(a)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!GR(n)))return!1;const u=YR(n+r);if(!u[0])return!1;const d={type:"link",title:null,url:o+t+u[0],children:[{type:"text",value:t+u[0]}]};return u[1]?[d,{type:"text",value:u[1]}]:d}function KR(e,t,n,r){return!Qw(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function GR(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function YR(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=sS(e,"(");let o=sS(e,")");for(;r!==-1&&a>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function Qw(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Vi(n)||ld(n))&&(!t||n!==47)}Jw.peek=sL;function XR(){this.buffer()}function ZR(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function QR(){this.buffer()}function JR(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function eL(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Pr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function tL(e){this.exit(e)}function nL(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Pr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function rL(e){this.exit(e)}function sL(){return"["}function Jw(e,t,n,r){const a=n.createTracker(r);let o=a.move("[^");const u=n.enter("footnoteReference"),d=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),d(),u(),o+=a.move("]"),o}function iL(){return{enter:{gfmFootnoteCallString:XR,gfmFootnoteCall:ZR,gfmFootnoteDefinitionLabelString:QR,gfmFootnoteDefinition:JR},exit:{gfmFootnoteCallString:eL,gfmFootnoteCall:tL,gfmFootnoteDefinitionLabelString:nL,gfmFootnoteDefinition:rL}}}function aL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Jw},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,o,u){const d=o.createTracker(u);let p=d.move("[^");const f=o.enter("footnoteDefinition"),m=o.enter("label");return p+=d.move(o.safe(o.associationId(r),{before:p,after:"]"})),m(),p+=d.move("]:"),r.children&&r.children.length>0&&(d.shift(4),p+=d.move((t?`
|
|
125
|
+
`:" ")+o.indentLines(o.containerFlow(r,d.current()),t?ek:oL))),f(),p}}function oL(e,t,n){return t===0?e:ek(e,t,n)}function ek(e,t,n){return(n?"":" ")+e}const lL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];tk.peek=fL;function cL(){return{canContainEols:["delete"],enter:{strikethrough:dL},exit:{strikethrough:hL}}}function uL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:lL}],handlers:{delete:tk}}}function dL(e){this.enter({type:"delete",children:[]},e)}function hL(e){this.exit(e)}function tk(e,t,n,r){const a=n.createTracker(r),o=n.enter("strikethrough");let u=a.move("~~");return u+=n.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),o(),u}function fL(){return"~"}function pL(e){return e.length}function mL(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||pL,o=[],u=[],d=[],p=[];let f=0,m=-1;for(;++m<e.length;){const S=[],j=[];let C=-1;for(e[m].length>f&&(f=e[m].length);++C<e[m].length;){const E=gL(e[m][C]);if(n.alignDelimiters!==!1){const A=a(E);j[C]=A,(p[C]===void 0||A>p[C])&&(p[C]=A)}S.push(E)}u[m]=S,d[m]=j}let g=-1;if(typeof r=="object"&&"length"in r)for(;++g<f;)o[g]=iS(r[g]);else{const S=iS(r);for(;++g<f;)o[g]=S}g=-1;const v=[],b=[];for(;++g<f;){const S=o[g];let j="",C="";S===99?(j=":",C=":"):S===108?j=":":S===114&&(C=":");let E=n.alignDelimiters===!1?1:Math.max(1,p[g]-j.length-C.length);const A=j+"-".repeat(E)+C;n.alignDelimiters!==!1&&(E=j.length+E+C.length,E>p[g]&&(p[g]=E),b[g]=E),v[g]=A}u.splice(1,0,v),d.splice(1,0,b),m=-1;const _=[];for(;++m<u.length;){const S=u[m],j=d[m];g=-1;const C=[];for(;++g<f;){const E=S[g]||"";let A="",O="";if(n.alignDelimiters!==!1){const z=p[g]-(j[g]||0),B=o[g];B===114?A=" ".repeat(z):B===99?z%2?(A=" ".repeat(z/2+.5),O=" ".repeat(z/2-.5)):(A=" ".repeat(z/2),O=A):O=" ".repeat(z)}n.delimiterStart!==!1&&!g&&C.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&E==="")&&(n.delimiterStart!==!1||g)&&C.push(" "),n.alignDelimiters!==!1&&C.push(A),C.push(E),n.alignDelimiters!==!1&&C.push(O),n.padding!==!1&&C.push(" "),(n.delimiterEnd!==!1||g!==f-1)&&C.push("|")}_.push(n.delimiterEnd===!1?C.join("").replace(/ +$/,""):C.join(""))}return _.join(`
|
|
126
|
+
`)}function gL(e){return e==null?"":String(e)}function iS(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function xL(e,t,n,r){const a=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const u=n.indentLines(n.containerFlow(e,o.current()),yL);return a(),u}function yL(e,t,n){return">"+(n?"":" ")+e}function bL(e,t){return aS(e,t.inConstruct,!0)&&!aS(e,t.notInConstruct,!1)}function aS(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function oS(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
127
|
+
`&&bL(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
128
|
+
`}function vL(e,t){const n=String(e);let r=n.indexOf(t),a=r,o=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++o>u&&(u=o):o=1,a=r+t.length,r=n.indexOf(t,a);return u}function _L(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function SL(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function wL(e,t,n,r){const a=SL(n),o=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(_L(e,n)){const g=n.enter("codeIndented"),v=n.indentLines(o,kL);return g(),v}const d=n.createTracker(r),p=a.repeat(Math.max(vL(o,a)+1,3)),f=n.enter("codeFenced");let m=d.move(p);if(e.lang){const g=n.enter(`codeFencedLang${u}`);m+=d.move(n.safe(e.lang,{before:m,after:" ",encode:["`"],...d.current()})),g()}if(e.lang&&e.meta){const g=n.enter(`codeFencedMeta${u}`);m+=d.move(" "),m+=d.move(n.safe(e.meta,{before:m,after:`
|
|
129
|
+
`,encode:["`"],...d.current()})),g()}return m+=d.move(`
|
|
130
|
+
`),o&&(m+=d.move(o+`
|
|
131
|
+
`)),m+=d.move(p),f(),m}function kL(e,t,n){return(n?"":" ")+e}function mg(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function CL(e,t,n,r){const a=mg(n),o=a==='"'?"Quote":"Apostrophe",u=n.enter("definition");let d=n.enter("label");const p=n.createTracker(r);let f=p.move("[");return f+=p.move(n.safe(n.associationId(e),{before:f,after:"]",...p.current()})),f+=p.move("]: "),d(),!e.url||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),f+=p.move("<"),f+=p.move(n.safe(e.url,{before:f,after:">",...p.current()})),f+=p.move(">")):(d=n.enter("destinationRaw"),f+=p.move(n.safe(e.url,{before:f,after:e.title?" ":`
|
|
132
|
+
`,...p.current()}))),d(),e.title&&(d=n.enter(`title${o}`),f+=p.move(" "+a),f+=p.move(n.safe(e.title,{before:f,after:a,...p.current()})),f+=p.move(a),d()),u(),f}function NL(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Rl(e){return"&#x"+e.toString(16).toUpperCase()+";"}function qu(e,t,n){const r=Za(e),a=Za(t);return r===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===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}}nk.peek=jL;function nk(e,t,n,r){const a=NL(n),o=n.enter("emphasis"),u=n.createTracker(r),d=u.move(a);let p=u.move(n.containerPhrasing(e,{after:a,before:d,...u.current()}));const f=p.charCodeAt(0),m=qu(r.before.charCodeAt(r.before.length-1),f,a);m.inside&&(p=Rl(f)+p.slice(1));const g=p.charCodeAt(p.length-1),v=qu(r.after.charCodeAt(0),g,a);v.inside&&(p=p.slice(0,-1)+Rl(g));const b=u.move(a);return o(),n.attentionEncodeSurroundingInfo={after:v.outside,before:m.outside},d+p+b}function jL(e,t,n){return n.options.emphasis||"*"}function EL(e,t){let n=!1;return fg(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,xm}),!!((!e.depth||e.depth<3)&&og(e)&&(t.options.setext||n))}function TL(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(EL(e,n)){const m=n.enter("headingSetext"),g=n.enter("phrasing"),v=n.containerPhrasing(e,{...o.current(),before:`
|
|
133
|
+
`,after:`
|
|
134
|
+
`});return g(),m(),v+`
|
|
135
|
+
`+(a===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
|
|
136
|
+
`))+1))}const u="#".repeat(a),d=n.enter("headingAtx"),p=n.enter("phrasing");o.move(u+" ");let f=n.containerPhrasing(e,{before:"# ",after:`
|
|
137
|
+
`,...o.current()});return/^[\t ]/.test(f)&&(f=Rl(f.charCodeAt(0))+f.slice(1)),f=f?u+" "+f:u,n.options.closeAtx&&(f+=" "+u),p(),d(),f}rk.peek=AL;function rk(e){return e.value||""}function AL(){return"<"}sk.peek=DL;function sk(e,t,n,r){const a=mg(n),o=a==='"'?"Quote":"Apostrophe",u=n.enter("image");let d=n.enter("label");const p=n.createTracker(r);let f=p.move("![");return f+=p.move(n.safe(e.alt,{before:f,after:"]",...p.current()})),f+=p.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),f+=p.move("<"),f+=p.move(n.safe(e.url,{before:f,after:">",...p.current()})),f+=p.move(">")):(d=n.enter("destinationRaw"),f+=p.move(n.safe(e.url,{before:f,after:e.title?" ":")",...p.current()}))),d(),e.title&&(d=n.enter(`title${o}`),f+=p.move(" "+a),f+=p.move(n.safe(e.title,{before:f,after:a,...p.current()})),f+=p.move(a),d()),f+=p.move(")"),u(),f}function DL(){return"!"}ik.peek=ML;function ik(e,t,n,r){const a=e.referenceType,o=n.enter("imageReference");let u=n.enter("label");const d=n.createTracker(r);let p=d.move("![");const f=n.safe(e.alt,{before:p,after:"]",...d.current()});p+=d.move(f+"]["),u();const m=n.stack;n.stack=[],u=n.enter("reference");const g=n.safe(n.associationId(e),{before:p,after:"]",...d.current()});return u(),n.stack=m,o(),a==="full"||!f||f!==g?p+=d.move(g+"]"):a==="shortcut"?p=p.slice(0,-1):p+=d.move("]"),p}function ML(){return"!"}ak.peek=RL;function ak(e,t,n){let r=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const u=n.unsafe[o],d=n.compilePattern(u);let p;if(u.atBreak)for(;p=d.exec(r);){let f=p.index;r.charCodeAt(f)===10&&r.charCodeAt(f-1)===13&&f--,r=r.slice(0,f)+" "+r.slice(p.index+1)}}return a+r+a}function RL(){return"`"}function ok(e,t){const n=og(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}lk.peek=LL;function lk(e,t,n,r){const a=mg(n),o=a==='"'?"Quote":"Apostrophe",u=n.createTracker(r);let d,p;if(ok(e,n)){const m=n.stack;n.stack=[],d=n.enter("autolink");let g=u.move("<");return g+=u.move(n.containerPhrasing(e,{before:g,after:">",...u.current()})),g+=u.move(">"),d(),n.stack=m,g}d=n.enter("link"),p=n.enter("label");let f=u.move("[");return f+=u.move(n.containerPhrasing(e,{before:f,after:"](",...u.current()})),f+=u.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),f+=u.move("<"),f+=u.move(n.safe(e.url,{before:f,after:">",...u.current()})),f+=u.move(">")):(p=n.enter("destinationRaw"),f+=u.move(n.safe(e.url,{before:f,after:e.title?" ":")",...u.current()}))),p(),e.title&&(p=n.enter(`title${o}`),f+=u.move(" "+a),f+=u.move(n.safe(e.title,{before:f,after:a,...u.current()})),f+=u.move(a),p()),f+=u.move(")"),d(),f}function LL(e,t,n){return ok(e,n)?"<":"["}ck.peek=OL;function ck(e,t,n,r){const a=e.referenceType,o=n.enter("linkReference");let u=n.enter("label");const d=n.createTracker(r);let p=d.move("[");const f=n.containerPhrasing(e,{before:p,after:"]",...d.current()});p+=d.move(f+"]["),u();const m=n.stack;n.stack=[],u=n.enter("reference");const g=n.safe(n.associationId(e),{before:p,after:"]",...d.current()});return u(),n.stack=m,o(),a==="full"||!f||f!==g?p+=d.move(g+"]"):a==="shortcut"?p=p.slice(0,-1):p+=d.move("]"),p}function OL(){return"["}function gg(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function IL(e){const t=gg(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function BL(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function uk(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function zL(e,t,n,r){const a=n.enter("list"),o=n.bulletCurrent;let u=e.ordered?BL(n):gg(n);const d=e.ordered?u==="."?")":".":IL(n);let p=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&m&&(!m.children||!m.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&&(p=!0),uk(n)===u&&m){let g=-1;for(;++g<e.children.length;){const v=e.children[g];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(u=d),n.bulletCurrent=u;const f=n.containerFlow(e,r);return n.bulletLastUsed=u,n.bulletCurrent=o,a(),f}function PL(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function HL(e,t,n,r){const a=PL(n);let o=n.bulletCurrent||gg(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let u=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const d=n.createTracker(r);d.move(o+" ".repeat(u-o.length)),d.shift(u);const p=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,d.current()),m);return p(),f;function m(g,v,b){return v?(b?"":" ".repeat(u))+g:(b?o:o+" ".repeat(u-o.length))+g}}function FL(e,t,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),u=n.containerPhrasing(e,r);return o(),a(),u}const $L=dd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function UL(e,t,n,r){return(e.children.some(function(u){return $L(u)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function WL(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}dk.peek=qL;function dk(e,t,n,r){const a=WL(n),o=n.enter("strong"),u=n.createTracker(r),d=u.move(a+a);let p=u.move(n.containerPhrasing(e,{after:a,before:d,...u.current()}));const f=p.charCodeAt(0),m=qu(r.before.charCodeAt(r.before.length-1),f,a);m.inside&&(p=Rl(f)+p.slice(1));const g=p.charCodeAt(p.length-1),v=qu(r.after.charCodeAt(0),g,a);v.inside&&(p=p.slice(0,-1)+Rl(g));const b=u.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:v.outside,before:m.outside},d+p+b}function qL(e,t,n){return n.options.strong||"*"}function VL(e,t,n,r){return n.safe(e.value,r)}function KL(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function GL(e,t,n){const r=(uk(n)+(n.options.ruleSpaces?" ":"")).repeat(KL(n));return n.options.ruleSpaces?r.slice(0,-1):r}const hk={blockquote:xL,break:oS,code:wL,definition:CL,emphasis:nk,hardBreak:oS,heading:TL,html:rk,image:sk,imageReference:ik,inlineCode:ak,link:lk,linkReference:ck,list:zL,listItem:HL,paragraph:FL,root:UL,strong:dk,text:VL,thematicBreak:GL};function YL(){return{enter:{table:XL,tableData:lS,tableHeader:lS,tableRow:QL},exit:{codeText:JL,table:ZL,tableData:yp,tableHeader:yp,tableRow:yp}}}function XL(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function ZL(e){this.exit(e),this.data.inTable=void 0}function QL(e){this.enter({type:"tableRow",children:[]},e)}function yp(e){this.exit(e)}function lS(e){this.enter({type:"tableCell",children:[]},e)}function JL(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,eO));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function eO(e,t){return t==="|"?t:e}function tO(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
138
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:u,tableCell:p,tableRow:d}};function u(b,_,S,j){return f(m(b,S,j),b.align)}function d(b,_,S,j){const C=g(b,S,j),E=f([C]);return E.slice(0,E.indexOf(`
|
|
139
|
+
`))}function p(b,_,S,j){const C=S.enter("tableCell"),E=S.enter("phrasing"),A=S.containerPhrasing(b,{...j,before:o,after:o});return E(),C(),A}function f(b,_){return mL(b,{align:_,alignDelimiters:r,padding:n,stringLength:a})}function m(b,_,S){const j=b.children;let C=-1;const E=[],A=_.enter("table");for(;++C<j.length;)E[C]=g(j[C],_,S);return A(),E}function g(b,_,S){const j=b.children;let C=-1;const E=[],A=_.enter("tableRow");for(;++C<j.length;)E[C]=p(j[C],b,_,S);return A(),E}function v(b,_,S){let j=hk.inlineCode(b,_,S);return S.stack.includes("tableCell")&&(j=j.replace(/\|/g,"\\$&")),j}}function nO(){return{exit:{taskListCheckValueChecked:cS,taskListCheckValueUnchecked:cS,paragraph:sO}}}function rO(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:iO}}}function cS(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function sO(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let o=-1,u;for(;++o<a.length;){const d=a[o];if(d.type==="paragraph"){u=d;break}}u===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function iO(e,t,n,r){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",d=n.createTracker(r);o&&d.move(u);let p=hk.listItem(e,t,n,{...r,...d.current()});return o&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),p;function f(m){return m+u}}function aO(){return[zR(),iL(),cL(),YL(),nO()]}function oO(e){return{extensions:[PR(),aL(e),uL(),tO(e),rO()]}}const lO={tokenize:pO,partial:!0},fk={tokenize:mO,partial:!0},pk={tokenize:gO,partial:!0},mk={tokenize:xO,partial:!0},cO={tokenize:yO,partial:!0},gk={name:"wwwAutolink",tokenize:hO,previous:yk},xk={name:"protocolAutolink",tokenize:fO,previous:bk},Ds={name:"emailAutolink",tokenize:dO,previous:vk},is={};function uO(){return{text:is}}let Mi=48;for(;Mi<123;)is[Mi]=Ds,Mi++,Mi===58?Mi=65:Mi===91&&(Mi=97);is[43]=Ds;is[45]=Ds;is[46]=Ds;is[95]=Ds;is[72]=[Ds,xk];is[104]=[Ds,xk];is[87]=[Ds,gk];is[119]=[Ds,gk];function dO(e,t,n){const r=this;let a,o;return u;function u(g){return!_m(g)||!vk.call(r,r.previous)||xg(r.events)?n(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(g))}function d(g){return _m(g)?(e.consume(g),d):g===64?(e.consume(g),p):n(g)}function p(g){return g===46?e.check(cO,m,f)(g):g===45||g===95||Pn(g)?(o=!0,e.consume(g),p):m(g)}function f(g){return e.consume(g),a=!0,p}function m(g){return o&&a&&Un(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):n(g)}}function hO(e,t,n){const r=this;return a;function a(u){return u!==87&&u!==119||!yk.call(r,r.previous)||xg(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(lO,e.attempt(fk,e.attempt(pk,o),n),n)(u))}function o(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function fO(e,t,n){const r=this;let a="",o=!1;return u;function u(g){return(g===72||g===104)&&bk.call(r,r.previous)&&!xg(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(g),e.consume(g),d):n(g)}function d(g){if(Un(g)&&a.length<5)return a+=String.fromCodePoint(g),e.consume(g),d;if(g===58){const v=a.toLowerCase();if(v==="http"||v==="https")return e.consume(g),p}return n(g)}function p(g){return g===47?(e.consume(g),o?f:(o=!0,p)):n(g)}function f(g){return g===null||$u(g)||Nt(g)||Vi(g)||ld(g)?n(g):e.attempt(fk,e.attempt(pk,m),n)(g)}function m(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function pO(e,t,n){let r=0;return a;function a(u){return(u===87||u===119)&&r<3?(r++,e.consume(u),a):u===46&&r===3?(e.consume(u),o):n(u)}function o(u){return u===null?n(u):t(u)}}function mO(e,t,n){let r,a,o;return u;function u(f){return f===46||f===95?e.check(mk,p,d)(f):f===null||Nt(f)||Vi(f)||f!==45&&ld(f)?p(f):(o=!0,e.consume(f),u)}function d(f){return f===95?r=!0:(a=r,r=void 0),e.consume(f),u}function p(f){return a||r||!o?n(f):t(f)}}function gO(e,t){let n=0,r=0;return a;function a(u){return u===40?(n++,e.consume(u),a):u===41&&r<n?o(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(mk,t,o)(u):u===null||Nt(u)||Vi(u)?t(u):(e.consume(u),a)}function o(u){return u===41&&r++,e.consume(u),a}}function xO(e,t,n){return r;function r(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(e.consume(d),r):d===38?(e.consume(d),o):d===93?(e.consume(d),a):d===60||d===null||Nt(d)||Vi(d)?t(d):n(d)}function a(d){return d===null||d===40||d===91||Nt(d)||Vi(d)?t(d):r(d)}function o(d){return Un(d)?u(d):n(d)}function u(d){return d===59?(e.consume(d),r):Un(d)?(e.consume(d),u):n(d)}}function yO(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return Pn(o)?n(o):t(o)}}function yk(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Nt(e)}function bk(e){return!Un(e)}function vk(e){return!(e===47||_m(e))}function _m(e){return e===43||e===45||e===46||e===95||Pn(e)}function xg(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const bO={tokenize:jO,partial:!0};function vO(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:kO,continuation:{tokenize:CO},exit:NO}},text:{91:{name:"gfmFootnoteCall",tokenize:wO},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:_O,resolveTo:SO}}}}function _O(e,t,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u;for(;a--;){const p=r.events[a][1];if(p.type==="labelImage"){u=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return d;function d(p){if(!u||!u._balanced)return n(p);const f=Pr(r.sliceSerialize({start:u.end,end:r.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function SO(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},d=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",u,t],["exit",u,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...d),e}function wO(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,u;return d;function d(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),p}function p(g){return g!==94?n(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(g){if(o>999||g===93&&!u||g===null||g===91||Nt(g))return n(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return a.includes(Pr(r.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(g)}return Nt(g)||(u=!0),o++,e.consume(g),g===92?m:f}function m(g){return g===91||g===92||g===93?(e.consume(g),o++,f):f(g)}}function kO(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,u=0,d;return p;function p(_){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(_){return _===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):n(_)}function m(_){if(u>999||_===93&&!d||_===null||_===91||Nt(_))return n(_);if(_===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return o=Pr(r.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return Nt(_)||(d=!0),u++,e.consume(_),_===92?g:m}function g(_){return _===91||_===92||_===93?(e.consume(_),u++,m):m(_)}function v(_){return _===58?(e.enter("definitionMarker"),e.consume(_),e.exit("definitionMarker"),a.includes(o)||a.push(o),lt(e,b,"gfmFootnoteDefinitionWhitespace")):n(_)}function b(_){return t(_)}}function CO(e,t,n){return e.check(ql,t,e.attempt(bO,t,n))}function NO(e){e.exit("gfmFootnoteDefinition")}function jO(e,t,n){const r=this;return lt(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const u=r.events[r.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(o):n(o)}}function EO(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(u,d){let p=-1;for(;++p<u.length;)if(u[p][0]==="enter"&&u[p][1].type==="strikethroughSequenceTemporary"&&u[p][1]._close){let f=p;for(;f--;)if(u[f][0]==="exit"&&u[f][1].type==="strikethroughSequenceTemporary"&&u[f][1]._open&&u[p][1].end.offset-u[p][1].start.offset===u[f][1].end.offset-u[f][1].start.offset){u[p][1].type="strikethroughSequence",u[f][1].type="strikethroughSequence";const m={type:"strikethrough",start:Object.assign({},u[f][1].start),end:Object.assign({},u[p][1].end)},g={type:"strikethroughText",start:Object.assign({},u[f][1].end),end:Object.assign({},u[p][1].start)},v=[["enter",m,d],["enter",u[f][1],d],["exit",u[f][1],d],["enter",g,d]],b=d.parser.constructs.insideSpan.null;b&&mr(v,v.length,0,cd(b,u.slice(f+1,p),d)),mr(v,v.length,0,[["exit",g,d],["enter",u[p][1],d],["exit",u[p][1],d],["exit",m,d]]),mr(u,f-1,p-f+3,v),p=f+v.length-2;break}}for(p=-1;++p<u.length;)u[p][1].type==="strikethroughSequenceTemporary"&&(u[p][1].type="data");return u}function o(u,d,p){const f=this.previous,m=this.events;let g=0;return v;function v(_){return f===126&&m[m.length-1][1].type!=="characterEscape"?p(_):(u.enter("strikethroughSequenceTemporary"),b(_))}function b(_){const S=Za(f);if(_===126)return g>1?p(_):(u.consume(_),g++,b);if(g<2&&!n)return p(_);const j=u.exit("strikethroughSequenceTemporary"),C=Za(_);return j._open=!C||C===2&&!!S,j._close=!S||S===2&&!!C,d(_)}}}class TO{constructor(){this.map=[]}add(t,n,r){AO(this,t,n,r)}consume(t){if(this.map.sort(function(o,u){return o[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const o of a)t.push(o);a=r.pop()}this.map.length=0}}function AO(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function DO(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function MO(){return{flow:{null:{name:"table",tokenize:RO,resolveAll:LO}}}}function RO(e,t,n){const r=this;let a=0,o=0,u;return d;function d(D){let $=r.events.length-1;for(;$>-1;){const q=r.events[$][1].type;if(q==="lineEnding"||q==="linePrefix")$--;else break}const H=$>-1?r.events[$][1].type:null,U=H==="tableHead"||H==="tableRow"?B:p;return U===B&&r.parser.lazy[r.now().line]?n(D):U(D)}function p(D){return e.enter("tableHead"),e.enter("tableRow"),f(D)}function f(D){return D===124||(u=!0,o+=1),m(D)}function m(D){return D===null?n(D):Oe(D)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),b):n(D):nt(D)?lt(e,m,"whitespace")(D):(o+=1,u&&(u=!1,a+=1),D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),u=!0,m):(e.enter("data"),g(D)))}function g(D){return D===null||D===124||Nt(D)?(e.exit("data"),m(D)):(e.consume(D),D===92?v:g)}function v(D){return D===92||D===124?(e.consume(D),g):g(D)}function b(D){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(D):(e.enter("tableDelimiterRow"),u=!1,nt(D)?lt(e,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):_(D))}function _(D){return D===45||D===58?j(D):D===124?(u=!0,e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),S):z(D)}function S(D){return nt(D)?lt(e,j,"whitespace")(D):j(D)}function j(D){return D===58?(o+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),C):D===45?(o+=1,C(D)):D===null||Oe(D)?O(D):z(D)}function C(D){return D===45?(e.enter("tableDelimiterFiller"),E(D)):z(D)}function E(D){return D===45?(e.consume(D),E):D===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),A):(e.exit("tableDelimiterFiller"),A(D))}function A(D){return nt(D)?lt(e,O,"whitespace")(D):O(D)}function O(D){return D===124?_(D):D===null||Oe(D)?!u||a!==o?z(D):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(D)):z(D)}function z(D){return n(D)}function B(D){return e.enter("tableRow"),Y(D)}function Y(D){return D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),Y):D===null||Oe(D)?(e.exit("tableRow"),t(D)):nt(D)?lt(e,Y,"whitespace")(D):(e.enter("data"),ee(D))}function ee(D){return D===null||D===124||Nt(D)?(e.exit("data"),Y(D)):(e.consume(D),D===92?ie:ee)}function ie(D){return D===92||D===124?(e.consume(D),ee):ee(D)}}function LO(e,t){let n=-1,r=!0,a=0,o=[0,0,0,0],u=[0,0,0,0],d=!1,p=0,f,m,g;const v=new TO;for(;++n<e.length;){const b=e[n],_=b[1];b[0]==="enter"?_.type==="tableHead"?(d=!1,p!==0&&(uS(v,t,p,f,m),m=void 0,p=0),f={type:"table",start:Object.assign({},_.start),end:Object.assign({},_.end)},v.add(n,0,[["enter",f,t]])):_.type==="tableRow"||_.type==="tableDelimiterRow"?(r=!0,g=void 0,o=[0,0,0,0],u=[0,n+1,0,0],d&&(d=!1,m={type:"tableBody",start:Object.assign({},_.start),end:Object.assign({},_.end)},v.add(n,0,[["enter",m,t]])),a=_.type==="tableDelimiterRow"?2:m?3:1):a&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")?(r=!1,u[2]===0&&(o[1]!==0&&(u[0]=u[1],g=vu(v,t,o,a,void 0,g),o=[0,0,0,0]),u[2]=n)):_.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(u[0]=u[1],g=vu(v,t,o,a,void 0,g)),o=u,u=[o[1],n,0,0])):_.type==="tableHead"?(d=!0,p=n):_.type==="tableRow"||_.type==="tableDelimiterRow"?(p=n,o[1]!==0?(u[0]=u[1],g=vu(v,t,o,a,n,g)):u[1]!==0&&(g=vu(v,t,u,a,n,g)),a=0):a&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")&&(u[3]=n)}for(p!==0&&uS(v,t,p,f,m),v.consume(t.events),n=-1;++n<t.events.length;){const b=t.events[n];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=DO(t.events,n))}return e}function vu(e,t,n,r,a,o){const u=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",d="tableContent";n[0]!==0&&(o.end=Object.assign({},Ua(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const p=Ua(t.events,n[1]);if(o={type:u,start:Object.assign({},p),end:Object.assign({},p)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const f=Ua(t.events,n[2]),m=Ua(t.events,n[3]),g={type:d,start:Object.assign({},f),end:Object.assign({},m)};if(e.add(n[2],0,[["enter",g,t]]),r!==2){const v=t.events[n[2]],b=t.events[n[3]];if(v[1].end=Object.assign({},b[1].end),v[1].type="chunkText",v[1].contentType="text",n[3]>n[2]+1){const _=n[2]+1,S=n[3]-n[2]-1;e.add(_,S,[])}}e.add(n[3]+1,0,[["exit",g,t]])}return a!==void 0&&(o.end=Object.assign({},Ua(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function uS(e,t,n,r,a){const o=[],u=Ua(t.events,n);a&&(a.end=Object.assign({},u),o.push(["exit",a,t])),r.end=Object.assign({},u),o.push(["exit",r,t]),e.add(n+1,0,o)}function Ua(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const OO={name:"tasklistCheck",tokenize:BO};function IO(){return{text:{91:OO}}}function BO(e,t,n){const r=this;return a;function a(p){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Nt(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),u):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),u):n(p)}function u(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):n(p)}function d(p){return Oe(p)?t(p):nt(p)?e.check({tokenize:zO},t,n)(p):n(p)}}function zO(e,t,n){return lt(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function PO(e){return Dw([uO(),vO(),EO(e),MO(),IO()])}const HO={};function FO(e){const t=this,n=e||HO,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),u=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(PO(n)),o.push(aO()),u.push(oO(n))}function $O(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function UO(e,t){if(e==null)return{};var n,r,a=$O(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Sm(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function WO(e){if(Array.isArray(e))return Sm(e)}function qO(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function VO(e,t){if(e){if(typeof e=="string")return Sm(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Sm(e,t):void 0}}function KO(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
140
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wm(e){return WO(e)||qO(e)||VO(e)||KO()}function Ll(e){"@babel/helpers - typeof";return Ll=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ll(e)}function GO(e,t){if(Ll(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Ll(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function YO(e){var t=GO(e,"string");return Ll(t)=="symbol"?t:t+""}function _k(e,t,n){return(t=YO(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function km(){return km=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},km.apply(null,arguments)}function dS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function qa(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?dS(Object(n),!0).forEach(function(r){_k(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dS(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function XO(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])];if(t===3)return[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])];if(t>=4)return[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]}var bp={};function ZO(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return bp[t]||(bp[t]=XO(e)),bp[t]}function QO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=e.filter(function(o){return o!=="token"}),a=ZO(r);return a.reduce(function(o,u){return qa(qa({},o),n[u])},t)}function hS(e){return e.join(" ")}function JO(e,t){var n=0;return function(r){return n+=1,r.map(function(a,o){return Sk({node:a,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(o)})})}}function Sk(e){var t=e.node,n=e.stylesheet,r=e.style,a=r===void 0?{}:r,o=e.useInlineStyles,u=e.key,d=t.properties,p=t.type,f=t.tagName,m=t.value;if(p==="text")return m;if(f){var g=JO(n,o),v;if(!o)v=qa(qa({},d),{},{className:hS(d.className)});else{var b=Object.keys(n).reduce(function(C,E){return E.split(".").forEach(function(A){C.includes(A)||C.push(A)}),C},[]),_=d.className&&d.className.includes("token")?["token"]:[],S=d.className&&_.concat(d.className.filter(function(C){return!b.includes(C)}));v=qa(qa({},d),{},{className:hS(S)||void 0,style:QO(d.className,Object.assign({},d.style,a),n)})}var j=g(t.children);return zn.createElement(f,km({key:u},v),j)}}const e6=(function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1});var t6=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function fS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function ci(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?fS(Object(n),!0).forEach(function(r){_k(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fS(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var n6=/\n/g;function r6(e){return e.match(n6)}function s6(e){var t=e.lines,n=e.startingLineNumber,r=e.style;return t.map(function(a,o){var u=o+n;return zn.createElement("span",{key:"line-".concat(o),className:"react-syntax-highlighter-line-number",style:typeof r=="function"?r(u):r},"".concat(u,`
|
|
141
|
+
`))})}function i6(e){var t=e.codeString,n=e.codeStyle,r=e.containerStyle,a=r===void 0?{float:"left",paddingRight:"10px"}:r,o=e.numberStyle,u=o===void 0?{}:o,d=e.startingLineNumber;return zn.createElement("code",{style:Object.assign({},n,a)},s6({lines:t.replace(/\n$/,"").split(`
|
|
142
|
+
`),style:u,startingLineNumber:d}))}function a6(e){return"".concat(e.toString().length,".25em")}function wk(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function kk(e,t,n){var r={display:"inline-block",minWidth:a6(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},a=typeof e=="function"?e(t):e,o=ci(ci({},r),a);return o}function Au(e){var t=e.children,n=e.lineNumber,r=e.lineNumberStyle,a=e.largestLineNumber,o=e.showInlineLineNumbers,u=e.lineProps,d=u===void 0?{}:u,p=e.className,f=p===void 0?[]:p,m=e.showLineNumbers,g=e.wrapLongLines,v=e.wrapLines,b=v===void 0?!1:v,_=b?ci({},typeof d=="function"?d(n):d):{};if(_.className=_.className?[].concat(wm(_.className.trim().split(/\s+/)),wm(f)):f,n&&o){var S=kk(r,n,a);t.unshift(wk(n,S))}return g&m&&(_.style=ci({display:"flex"},_.style)),{type:"element",tagName:"span",properties:_,children:t}}function Ck(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];e.length===void 0&&(e=[e]);for(var r=0;r<e.length;r++){var a=e[r];if(a.type==="text")n.push(Au({children:[a],className:wm(new Set(t))}));else if(a.children){var o,u=t.concat(((o=a.properties)===null||o===void 0?void 0:o.className)||[]);Ck(a.children,u).forEach(function(d){return n.push(d)})}}return n}function o6(e,t,n,r,a,o,u,d,p){var f,m=Ck(e.value),g=[],v=-1,b=0;function _(z,B){var Y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return Au({children:z,lineNumber:B,lineNumberStyle:d,largestLineNumber:u,showInlineLineNumbers:a,lineProps:n,className:Y,showLineNumbers:r,wrapLongLines:p,wrapLines:t})}function S(z,B){if(r&&B&&a){var Y=kk(d,B,u);z.unshift(wk(B,Y))}return z}function j(z,B){var Y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||Y.length>0?_(z,B,Y):S(z,B)}for(var C=function(){var B=m[b],Y=B.children[0].value,ee=r6(Y);if(ee){var ie=Y.split(`
|
|
143
|
+
`);ie.forEach(function(D,$){var H=r&&g.length+o,U={type:"text",value:"".concat(D,`
|
|
144
|
+
`)};if($===0){var q=m.slice(v+1,b).concat(Au({children:[U],className:B.properties.className})),T=j(q,H);g.push(T)}else if($===ie.length-1){var N=m[b+1]&&m[b+1].children&&m[b+1].children[0],F={type:"text",value:"".concat(D)};if(N){var I=Au({children:[F],className:B.properties.className});m.splice(b+1,0,I)}else{var J=[F],R=j(J,H,B.properties.className);g.push(R)}}else{var P=[U],V=j(P,H,B.properties.className);g.push(V)}}),v=b}b++};b<m.length;)C();if(v!==m.length-1){var E=m.slice(v+1,m.length);if(E&&E.length){var A=r&&g.length+o,O=j(E,A);g.push(O)}}return t?g:(f=[]).concat.apply(f,g)}function l6(e){var t=e.rows,n=e.stylesheet,r=e.useInlineStyles;return t.map(function(a,o){return Sk({node:a,stylesheet:n,useInlineStyles:r,key:"code-segment-".concat(o)})})}function Nk(e){return e&&typeof e.highlightAuto<"u"}function c6(e){var t=e.astGenerator,n=e.language,r=e.code,a=e.defaultCodeValue;if(Nk(t)){var o=e6(t,n);return n==="text"?{value:a,language:"text"}:o?t.highlight(n,r):t.highlightAuto(r)}try{return n&&n!=="text"?{value:t.highlight(r,n)}:{value:a}}catch{return{value:a}}}function u6(e,t){return function(r){var a,o,u=r.language,d=r.children,p=r.style,f=p===void 0?t:p,m=r.customStyle,g=m===void 0?{}:m,v=r.codeTagProps,b=v===void 0?{className:u?"language-".concat(u):void 0,style:ci(ci({},f['code[class*="language-"]']),f['code[class*="language-'.concat(u,'"]')])}:v,_=r.useInlineStyles,S=_===void 0?!0:_,j=r.showLineNumbers,C=j===void 0?!1:j,E=r.showInlineLineNumbers,A=E===void 0?!0:E,O=r.startingLineNumber,z=O===void 0?1:O,B=r.lineNumberContainerStyle,Y=r.lineNumberStyle,ee=Y===void 0?{}:Y,ie=r.wrapLines,D=r.wrapLongLines,$=D===void 0?!1:D,H=r.lineProps,U=H===void 0?{}:H,q=r.renderer,T=r.PreTag,N=T===void 0?"pre":T,F=r.CodeTag,I=F===void 0?"code":F,J=r.code,R=J===void 0?(Array.isArray(d)?d[0]:d)||"":J,P=r.astGenerator,V=UO(r,t6);P=P||e;var L=C?zn.createElement(i6,{containerStyle:B,codeStyle:b.style||{},numberStyle:ee,startingLineNumber:z,codeString:R}):null,G=f.hljs||f['pre[class*="language-"]']||{backgroundColor:"#fff"},W=Nk(P)?"hljs":"prismjs",Z=S?Object.assign({},V,{style:Object.assign({},G,g)}):Object.assign({},V,{className:V.className?"".concat(W," ").concat(V.className):W,style:Object.assign({},g)});if($?b.style=ci({whiteSpace:"pre-wrap"},b.style):b.style=ci({whiteSpace:"pre"},b.style),!P)return zn.createElement(N,Z,L,zn.createElement(I,b,R));(ie===void 0&&q||$)&&(ie=!0),q=q||l6;var se=[{type:"text",value:R}],ve=c6({astGenerator:P,language:u,code:R,defaultCodeValue:se});ve.language===null&&(ve.value=se);var Ce=(a=(o=R.match(/\n/g))===null||o===void 0?void 0:o.length)!==null&&a!==void 0?a:0,Te=z+Ce,Pe=o6(ve,ie,U,C,A,z,Te,ee,$);return zn.createElement(N,Z,zn.createElement(I,b,!A&&L,q({rows:Pe,stylesheet:f,useInlineStyles:S})))}}const pS=/[#.]/g;function d6(e,t){const n=e||"",r={};let a=0,o,u;for(;a<n.length;){pS.lastIndex=a;const d=pS.exec(n),p=n.slice(a,d?d.index:n.length);p&&(o?o==="#"?r.id=p:Array.isArray(r.className)?r.className.push(p):r.className=[p]:u=p,a+=p.length),d&&(o=d[0],a++)}return{type:"element",tagName:u||t||"div",properties:r,children:[]}}function jk(e,t,n){const r=n?m6(n):void 0;function a(o,u,...d){let p;if(o==null){p={type:"root",children:[]};const f=u;d.unshift(f)}else{p=d6(o,t);const f=p.tagName.toLowerCase(),m=r?r.get(f):void 0;if(p.tagName=m||f,h6(u))d.unshift(u);else for(const[g,v]of Object.entries(u))f6(e,p.properties,g,v)}for(const f of d)Cm(p.children,f);return p.type==="element"&&p.tagName==="template"&&(p.content={type:"root",children:p.children},p.children=[]),p}return a}function h6(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,n=Object.keys(e);for(const r of n){const a=t[r];if(a&&typeof a=="object"){if(!Array.isArray(a))return!0;const o=a;for(const u of o)if(typeof u!="number"&&typeof u!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function f6(e,t,n,r){const a=Sw(e,n);let o;if(r!=null){if(typeof r=="number"){if(Number.isNaN(r))return;o=r}else typeof r=="boolean"?o=r:typeof r=="string"?a.spaceSeparated?o=C0(r):a.commaSeparated?o=v0(r):a.commaOrSpaceSeparated?o=C0(v0(r).join(" ")):o=mS(a,a.property,r):Array.isArray(r)?o=[...r]:o=a.property==="style"?p6(r):String(r);if(Array.isArray(o)){const u=[];for(const d of o)u.push(mS(a,a.property,d));o=u}a.property==="className"&&Array.isArray(t.className)&&(o=t.className.concat(o)),t[a.property]=o}}function Cm(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const n of t)Cm(e,n);else if(typeof t=="object"&&"type"in t)t.type==="root"?Cm(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function mS(e,t,n){if(typeof n=="string"){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===""||Al(n)===Al(t)))return!0}return n}function p6(e){const t=[];for(const[n,r]of Object.entries(e))t.push([n,r].join(": "));return t.join("; ")}function m6(e){const t=new Map;for(const n of e)t.set(n.toLowerCase(),n);return t}const g6=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],x6=jk(ww,"div");jk(od,"g",g6);const y6=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],gS={0:"�",128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};function Ek(e){const t=typeof e=="string"?e.charCodeAt(0):e;return t>=48&&t<=57}function b6(e){const t=typeof e=="string"?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function v6(e){const t=typeof e=="string"?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function xS(e){return v6(e)||Ek(e)}const _6=["","Named character references must be terminated by a semicolon","Numeric character references must be terminated by a semicolon","Named character references cannot be empty","Numeric character references cannot be empty","Named character references must be known","Numeric character references cannot be disallowed","Numeric character references cannot be outside the permissible Unicode range"];function S6(e,t){const n={},r=typeof n.additional=="string"?n.additional.charCodeAt(0):n.additional,a=[];let o=0,u=-1,d="",p,f;n.position&&("start"in n.position||"indent"in n.position?(f=n.position.indent,p=n.position.start):p=n.position);let m=(p?p.line:0)||1,g=(p?p.column:0)||1,v=_(),b;for(o--;++o<=e.length;)if(b===10&&(g=(f?f[u]:0)||1),b=e.charCodeAt(o),b===38){const C=e.charCodeAt(o+1);if(C===9||C===10||C===12||C===32||C===38||C===60||Number.isNaN(C)||r&&C===r){d+=String.fromCharCode(b),g++;continue}const E=o+1;let A=E,O=E,z;if(C===35){O=++A;const U=e.charCodeAt(O);U===88||U===120?(z="hexadecimal",O=++A):z="decimal"}else z="named";let B="",Y="",ee="";const ie=z==="named"?xS:z==="decimal"?Ek:b6;for(O--;++O<=e.length;){const U=e.charCodeAt(O);if(!ie(U))break;ee+=String.fromCharCode(U),z==="named"&&y6.includes(ee)&&(B=ee,Y=Ml(ee))}let D=e.charCodeAt(O)===59;if(D){O++;const U=z==="named"?Ml(ee):!1;U&&(B=ee,Y=U)}let $=1+O-E,H="";if(!(!D&&n.nonTerminated===!1))if(!ee)z!=="named"&&S(4,$);else if(z==="named"){if(D&&!Y)S(5,1);else if(B!==ee&&(O=A+B.length,$=1+O-A,D=!1),!D){const U=B?1:3;if(n.attribute){const q=e.charCodeAt(O);q===61?(S(U,$),Y=""):xS(q)?Y="":S(U,$)}else S(U,$)}H=Y}else{D||S(2,$);let U=Number.parseInt(ee,z==="hexadecimal"?16:10);if(w6(U))S(7,$),H="�";else if(U in gS)S(6,$),H=gS[U];else{let q="";k6(U)&&S(6,$),U>65535&&(U-=65536,q+=String.fromCharCode(U>>>10|55296),U=56320|U&1023),H=q+String.fromCharCode(U)}}if(H){j(),v=_(),o=O-1,g+=O-E+1,a.push(H);const U=_();U.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,H,{start:v,end:U},e.slice(E-1,O)),v=U}else ee=e.slice(E-1,O),d+=ee,g+=ee.length,o=O-1}else b===10&&(m++,u++,g=0),Number.isNaN(b)?j():(d+=String.fromCharCode(b),g++);return a.join("");function _(){return{line:m,column:g,offset:o+((p?p.offset:0)||0)}}function S(C,E){let A;n.warning&&(A=_(),A.column+=E,A.offset+=E,n.warning.call(n.warningContext||void 0,_6[C],A,C))}function j(){d&&(a.push(d),n.text&&n.text.call(n.textContext||void 0,d,{start:v,end:_()}),d="")}}function w6(e){return e>=55296&&e<=57343||e>1114111}function k6(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534}var C6=0,_u={},xn={util:{type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++C6}),e.__id},clone:function e(t,n){n=n||{};var r,a;switch(xn.util.type(t)){case"Object":if(a=xn.util.objId(t),n[a])return n[a];r={},n[a]=r;for(var o in t)t.hasOwnProperty(o)&&(r[o]=e(t[o],n));return r;case"Array":return a=xn.util.objId(t),n[a]?n[a]:(r=[],n[a]=r,t.forEach(function(u,d){r[d]=e(u,n)}),r);default:return t}}},languages:{plain:_u,plaintext:_u,text:_u,txt:_u,extend:function(e,t){var n=xn.util.clone(xn.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r=r||xn.languages;var a=r[e],o={};for(var u in a)if(a.hasOwnProperty(u)){if(u==t)for(var d in n)n.hasOwnProperty(d)&&(o[d]=n[d]);n.hasOwnProperty(u)||(o[u]=a[u])}var p=r[e];return r[e]=o,xn.languages.DFS(xn.languages,function(f,m){m===p&&f!=e&&(this[f]=o)}),o},DFS:function e(t,n,r,a){a=a||{};var o=xn.util.objId;for(var u in t)if(t.hasOwnProperty(u)){n.call(t,u,t[u],r||u);var d=t[u],p=xn.util.type(d);p==="Object"&&!a[o(d)]?(a[o(d)]=!0,e(d,n,null,a)):p==="Array"&&!a[o(d)]&&(a[o(d)]=!0,e(d,n,u,a))}}},plugins:{},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(xn.hooks.run("before-tokenize",r),!r.grammar)throw new Error('The language "'+r.language+'" has no grammar.');return r.tokens=xn.tokenize(r.code,r.grammar),xn.hooks.run("after-tokenize",r),Cl.stringify(xn.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var a=new N6;return Du(a,a.head,e),Tk(e,a,t,a.head,0),E6(a)},hooks:{all:{},add:function(e,t){var n=xn.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=xn.hooks.all[e];if(!(!n||!n.length))for(var r=0,a;a=n[r++];)a(t)}},Token:Cl};function Cl(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||"").length|0}function yS(e,t,n,r){e.lastIndex=t;var a=e.exec(n);if(a&&r&&a[1]){var o=a[1].length;a.index+=o,a[0]=a[0].slice(o)}return a}function Tk(e,t,n,r,a,o){for(var u in n)if(!(!n.hasOwnProperty(u)||!n[u])){var d=n[u];d=Array.isArray(d)?d:[d];for(var p=0;p<d.length;++p){if(o&&o.cause==u+","+p)return;var f=d[p],m=f.inside,g=!!f.lookbehind,v=!!f.greedy,b=f.alias;if(v&&!f.pattern.global){var _=f.pattern.toString().match(/[imsuy]*$/)[0];f.pattern=RegExp(f.pattern.source,_+"g")}for(var S=f.pattern||f,j=r.next,C=a;j!==t.tail&&!(o&&C>=o.reach);C+=j.value.length,j=j.next){var E=j.value;if(t.length>e.length)return;if(!(E instanceof Cl)){var A=1,O;if(v){if(O=yS(S,C,e,g),!O||O.index>=e.length)break;var ee=O.index,z=O.index+O[0].length,B=C;for(B+=j.value.length;ee>=B;)j=j.next,B+=j.value.length;if(B-=j.value.length,C=B,j.value instanceof Cl)continue;for(var Y=j;Y!==t.tail&&(B<z||typeof Y.value=="string");Y=Y.next)A++,B+=Y.value.length;A--,E=e.slice(C,B),O.index-=C}else if(O=yS(S,0,E,g),!O)continue;var ee=O.index,ie=O[0],D=E.slice(0,ee),$=E.slice(ee+ie.length),H=C+E.length;o&&H>o.reach&&(o.reach=H);var U=j.prev;D&&(U=Du(t,U,D),C+=D.length),j6(t,U,A);var q=new Cl(u,m?xn.tokenize(ie,m):ie,b,ie);if(j=Du(t,U,q),$&&Du(t,j,$),A>1){var T={cause:u+","+p,reach:H};Tk(e,t,n,j.prev,C,T),o&&T.reach>o.reach&&(o.reach=T.reach)}}}}}}function N6(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function Du(e,t,n){var r=t.next,a={value:n,prev:t,next:r};return t.next=a,r.prev=a,e.length++,a}function j6(e,t,n){for(var r=t.next,a=0;a<n&&r!==e.tail;a++)r=r.next;t.next=r,r.prev=t,e.length-=a}function E6(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}const Ak=xn;function Dk(){}Dk.prototype=Ak;const fn=new Dk;fn.highlight=T6;fn.register=A6;fn.alias=D6;fn.registered=M6;fn.listLanguages=R6;fn.util.encode=L6;fn.Token.stringify=Nm;function T6(e,t){if(typeof e!="string")throw new TypeError("Expected `string` for `value`, got `"+e+"`");let n,r;if(t&&typeof t=="object")n=t;else{if(r=t,typeof r!="string")throw new TypeError("Expected `string` for `name`, got `"+r+"`");if(Object.hasOwn(fn.languages,r))n=fn.languages[r];else throw new Error("Unknown language: `"+r+"` is not registered")}return{type:"root",children:Ak.highlight.call(fn,e,n,r)}}function A6(e){if(typeof e!="function"||!e.displayName)throw new Error("Expected `function` for `syntax`, got `"+e+"`");Object.hasOwn(fn.languages,e.displayName)||e(fn)}function D6(e,t){const n=fn.languages;let r={};typeof e=="string"?t&&(r[e]=t):r=e;let a;for(a in r)if(Object.hasOwn(r,a)){const o=r[a],u=typeof o=="string"?[o]:o;let d=-1;for(;++d<u.length;)n[u[d]]=n[a]}}function M6(e){if(typeof e!="string")throw new TypeError("Expected `string` for `aliasOrLanguage`, got `"+e+"`");return Object.hasOwn(fn.languages,e)}function R6(){const e=fn.languages,t=[];let n;for(n in e)Object.hasOwn(e,n)&&typeof e[n]=="object"&&t.push(n);return t}function Nm(e,t){if(typeof e=="string")return{type:"text",value:e};if(Array.isArray(e)){const r=[];let a=-1;for(;++a<e.length;)e[a]!==null&&e[a]!==void 0&&e[a]!==""&&r.push(Nm(e[a],t));return r}const n={attributes:{},classes:["token",e.type],content:Nm(e.content,t),language:t,tag:"span",type:e.type};return e.alias&&n.classes.push(...typeof e.alias=="string"?[e.alias]:e.alias),fn.hooks.run("wrap",n),x6(n.tag+"."+n.classes.join("."),O6(n.attributes),n.content)}function L6(e){return e}function O6(e){let t;for(t in e)Object.hasOwn(e,t)&&(e[t]=S6(e[t]));return e}var bt=u6(fn,{});bt.registerLanguage=function(e,t){return fn.register(t)};bt.alias=function(e,t){return fn.alias(e,t)};Yi.displayName="markup";Yi.aliases=["atom","html","mathml","rss","ssml","svg","xml"];function Yi(e){e.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]},e.languages.markup.tag.inside["attr-value"].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside["internal-subset"].inside=e.languages.markup,e.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.value.replace(/&/,"&"))}),Object.defineProperty(e.languages.markup.tag,"addInlined",{value:function(n,r){var a={};a["language-"+r]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[r]},a.cdata=/^<!\[CDATA\[|\]\]>$/i;var o={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:a}};o["language-"+r]={pattern:/[\s\S]+/,inside:e.languages[r]};var u={};u[n]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return n}),"i"),lookbehind:!0,greedy:!0,inside:o},e.languages.insertBefore("markup","cdata",u)}}),Object.defineProperty(e.languages.markup.tag,"addAttribute",{value:function(t,n){e.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+t+")"+/\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:[n,"language-"+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend("markup",{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}fd.displayName="css";fd.aliases=[];function fd(e){(function(t){var n=/(?:"(?:\\(?:\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+"|"+n.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\\((?:"+n.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+n.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+n.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:n,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 r=t.languages.markup;r&&(r.tag.addInlined("style","css"),r.tag.addAttribute("style","css"))})(e)}Xi.displayName="clike";Xi.aliases=[];function Xi(e){e.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:/[{}[\];(),.:]/}}Kl.displayName="javascript";Kl.aliases=["js"];function Kl(e){e.register(Xi),e.languages.javascript=e.languages.extend("clike",{"class-name":[e.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}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.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:e.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:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.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:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.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:e.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"}}),e.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),e.languages.markup&&(e.languages.markup.tag.addInlined("script","javascript"),e.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")),e.languages.js=e.languages.javascript}yg.displayName="sql";yg.aliases=[];function yg(e){e.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:/[;[\]()`,.]/}}pd.displayName="c";pd.aliases=[];function pd(e){e.register(Xi),e.languages.c=e.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),e.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),e.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},e.languages.c.string],char:e.languages.c.char,comment:e.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:e.languages.c}}}}),e.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete e.languages.c.boolean}bg.displayName="cpp";bg.aliases=[];function bg(e){e.register(pd),(function(t){var n=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,r=/\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g,function(){return n.source});t.languages.cpp=t.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g,function(){return n.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:n,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),t.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g,function(){return r})+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),t.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:t.languages.cpp}}}}),t.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),t.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:t.languages.extend("cpp",{})}}),t.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},t.languages.cpp["base-clause"])})(e)}vg.displayName="bash";vg.aliases=["sh","shell"];function vg(e){(function(t){var n="\\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",r={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},a={bash:r,environment:{pattern:RegExp("\\$"+n),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("(\\{)"+n),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;|&]|[<>]\\()"+n),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:a},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:r}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:a},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:a.entity}}],environment:{pattern:RegExp("\\$?"+n),alias:"constant"},variable:a.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}},r.inside=t.languages.bash;for(var o=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],u=a.variable[1].inside,d=0;d<o.length;d++)u[o[d]]=t.languages.bash[o[d]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(e)}_g.displayName="yaml";_g.aliases=["yml"];function _g(e){(function(t){var n=/[*&][^\s[\]{},]+/,r=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,a="(?:"+r.source+"(?:[ ]+"+n.source+")?|"+n.source+"(?:[ ]+"+r.source+")?)",o=/(?:[^\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}),u=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function d(p,f){f=(f||"").replace(/m/g,"")+"m";var m=/([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g,function(){return a}).replace(/<<value>>/g,function(){return p});return RegExp(m,f)}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 a})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g,function(){return a}).replace(/<<key>>/g,function(){return"(?:"+o+"|"+u+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:d(/\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:d(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:d(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:d(u),lookbehind:!0,greedy:!0},number:{pattern:d(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:r,important:n,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(e)}Sg.displayName="markdown";Sg.aliases=["md"];function Sg(e){e.register(Yi),(function(t){var n=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function r(d){return d=d.replace(/<inner>/g,function(){return n}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+d+")")}var a=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,o=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return a}),u=/\|?[ \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("^"+o+u+"(?:"+o+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+o+u+")(?:"+o+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(a),inside:t.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+o+")"+u+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+o+"$"),inside:{"table-header":{pattern:RegExp(a),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:r(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:r(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:r(/(~~?)(?:(?!~)<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:r(/!?\[(?:(?!\])<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(d){["url","bold","italic","strike","code-snippet"].forEach(function(p){d!==p&&(t.languages.markdown[d].inside.content.inside[p]=t.languages.markdown[p])})}),t.hooks.add("after-tokenize",function(d){if(d.language!=="markdown"&&d.language!=="md")return;function p(f){if(!(!f||typeof f=="string"))for(var m=0,g=f.length;m<g;m++){var v=f[m];if(v.type!=="code"){p(v.content);continue}var b=v.content[1],_=v.content[3];if(b&&_&&b.type==="code-language"&&_.type==="code-block"&&typeof b.content=="string"){var S=b.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");S=(/[a-z][\w-]*/i.exec(S)||[""])[0].toLowerCase();var j="language-"+S;_.alias?typeof _.alias=="string"?_.alias=[_.alias,j]:_.alias.push(j):_.alias=[j]}}}p(d.tokens)}),t.hooks.add("wrap",function(d){if(d.type==="code-block"){for(var p="",f=0,m=d.classes.length;f<m;f++){var g=d.classes[f],v=/language-(.+)/.exec(g);if(v){p=v[1];break}}var b=t.languages[p];if(b)d.content=t.highlight(d.content.value,b,p);else if(p&&p!=="none"&&t.plugins.autoloader){var _="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);d.attributes.id=_,t.plugins.autoloader.loadLanguages(p,function(){var S=document.getElementById(_);S&&(S.innerHTML=t.highlight(S.textContent,t.languages[p],p))})}}}),RegExp(t.languages.markup.tag.pattern.source,"gi"),t.languages.md=t.languages.markdown})(e)}wg.displayName="ruby";wg.aliases=["rb"];function wg(e){e.register(Xi),(function(t){t.languages.ruby=t.languages.extend("clike",{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),t.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var n={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:t.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete t.languages.ruby.function;var r="(?:"+[/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source].join("|")+")",a=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;t.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+r+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:n,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:n,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+a),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+a+/(?=:(?!:))/.source),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),t.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+r),greedy:!0,inside:{interpolation:n,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:n,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:n,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(/%x/.source+r),greedy:!0,inside:{interpolation:n,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:n,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete t.languages.ruby.string,t.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),t.languages.rb=t.languages.ruby})(e)}kg.displayName="diff";kg.aliases=[];function kg(e){(function(t){t.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var n={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(n).forEach(function(r){var a=n[r],o=[];/^\w+$/.test(r)||o.push(/\w+/.exec(r)[0]),r==="diff"&&o.push("bold"),t.languages.diff[r]={pattern:RegExp("^(?:["+a+`].*(?:\r
|
|
145
|
+
?|
|
|
146
|
+
|(?![\\s\\S])))+`,"m"),alias:o,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(r)[0]}}}}),Object.defineProperty(t.languages.diff,"PREFIXES",{value:n})})(e)}Cg.displayName="docker";Cg.aliases=["dockerfile"];function Cg(e){(function(t){var n=/\\[\r\n](?:\s|\\[\r\n]|#.*(?!.))*(?![\s#]|\\[\r\n])/.source,r=/(?:[ \t]+(?![ \t])(?:<SP_BS>)?|<SP_BS>)/.source.replace(/<SP_BS>/g,function(){return n}),a=/"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))*"|'(?:[^'\\\r\n]|\\(?:\r\n|[\s\S]))*'/.source,o=/--[\w-]+=(?:<STR>|(?!["'])(?:[^\s\\]|\\.)+)/.source.replace(/<STR>/g,function(){return a}),u={pattern:RegExp(a),greedy:!0},d={pattern:/(^[ \t]*)#.*/m,lookbehind:!0,greedy:!0};function p(f,m){return f=f.replace(/<OPT>/g,function(){return o}).replace(/<SP>/g,function(){return r}),RegExp(f,m)}t.languages.docker={instruction:{pattern:/(^[ \t]*)(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|ONBUILD|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)(?=\s)(?:\\.|[^\r\n\\])*(?:\\$(?:\s|#.*$)*(?![\s#])(?:\\.|[^\r\n\\])*)*/im,lookbehind:!0,greedy:!0,inside:{options:{pattern:p(/(^(?:ONBUILD<SP>)?\w+<SP>)<OPT>(?:<SP><OPT>)*/.source,"i"),lookbehind:!0,greedy:!0,inside:{property:{pattern:/(^|\s)--[\w-]+/,lookbehind:!0},string:[u,{pattern:/(=)(?!["'])(?:[^\s\\]|\\.)+/,lookbehind:!0}],operator:/\\$/m,punctuation:/=/}},keyword:[{pattern:p(/(^(?:ONBUILD<SP>)?HEALTHCHECK<SP>(?:<OPT><SP>)*)(?:CMD|NONE)\b/.source,"i"),lookbehind:!0,greedy:!0},{pattern:p(/(^(?:ONBUILD<SP>)?FROM<SP>(?:<OPT><SP>)*(?!--)[^ \t\\]+<SP>)AS/.source,"i"),lookbehind:!0,greedy:!0},{pattern:p(/(^ONBUILD<SP>)\w+/.source,"i"),lookbehind:!0,greedy:!0},{pattern:/^\w+/,greedy:!0}],comment:d,string:u,variable:/\$(?:\w+|\{[^{}"'\\]*\})/,operator:/\\$/m}},comment:d},t.languages.dockerfile=t.languages.docker})(e)}Ng.displayName="go";Ng.aliases=[];function Ng(e){e.register(Xi),e.languages.go=e.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/}),e.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete e.languages.go["class-name"]}jg.displayName="graphql";jg.aliases=[];function jg(e){e.languages.graphql={comment:/#.*/,description:{pattern:/(?:"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*")(?=\s*[a-z_])/i,greedy:!0,alias:"string",inside:{"language-markdown":{pattern:/(^"(?:"")?)(?!\1)[\s\S]+(?=\1$)/,lookbehind:!0,inside:e.languages.markdown}}},string:{pattern:/"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*"/,greedy:!0},number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:/\b(?:false|true)\b/,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:"function"},"attr-name":{pattern:/\b[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,greedy:!0},"atom-input":{pattern:/\b[A-Z]\w*Input\b/,alias:"class-name"},scalar:/\b(?:Boolean|Float|ID|Int|String)\b/,constant:/\b[A-Z][A-Z_\d]*\b/,"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*|:\s*|\[)[A-Z_]\w*/,lookbehind:!0},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,lookbehind:!0,alias:"function"},"definition-mutation":{pattern:/(\bmutation\s+)[a-zA-Z_]\w*/,lookbehind:!0,alias:"function"},"definition-query":{pattern:/(\bquery\s+)[a-zA-Z_]\w*/,lookbehind:!0,alias:"function"},keyword:/\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,operator:/[!=|&]|\.{3}/,"property-query":/\w+(?=\s*\()/,object:/\w+(?=\s*\{)/,punctuation:/[!(){}\[\]:=,]/,property:/\w+/},e.hooks.add("after-tokenize",function(n){if(n.language!=="graphql")return;var r=n.tokens.filter(function(j){return typeof j!="string"&&j.type!=="comment"&&j.type!=="scalar"}),a=0;function o(j){return r[a+j]}function u(j,C){C=C||0;for(var E=0;E<j.length;E++){var A=o(E+C);if(!A||A.type!==j[E])return!1}return!0}function d(j,C){for(var E=1,A=a;A<r.length;A++){var O=r[A],z=O.content;if(O.type==="punctuation"&&typeof z=="string"){if(j.test(z))E++;else if(C.test(z)&&(E--,E===0))return A}}return-1}function p(j,C){var E=j.alias;E?Array.isArray(E)||(j.alias=E=[E]):j.alias=E=[],E.push(C)}for(;a<r.length;){var f=r[a++];if(f.type==="keyword"&&f.content==="mutation"){var m=[];if(u(["definition-mutation","punctuation"])&&o(1).content==="("){a+=2;var g=d(/^\($/,/^\)$/);if(g===-1)continue;for(;a<g;a++){var v=o(0);v.type==="variable"&&(p(v,"variable-input"),m.push(v.content))}a=g+1}if(u(["punctuation","property-query"])&&o(0).content==="{"&&(a++,p(o(0),"property-mutation"),m.length>0)){var b=d(/^\{$/,/^\}$/);if(b===-1)continue;for(var _=a;_<b;_++){var S=r[_];S.type==="variable"&&m.indexOf(S.content)>=0&&p(S,"variable-input")}}}}})}Eg.displayName="scss";Eg.aliases=[];function Eg(e){e.register(fd),e.languages.scss=e.languages.extend("css",{comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0},atrule:{pattern:/@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,inside:{rule:/@[\w-]+/}},url:/(?:[-a-z]+-)?url(?=\()/i,selector:{pattern:/(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,inside:{parent:{pattern:/&/,alias:"important"},placeholder:/%[-\w]+/,variable:/\$[-\w]+|#\{\$[-\w]+\}/}},property:{pattern:/(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,inside:{variable:/\$[-\w]+|#\{\$[-\w]+\}/}}}),e.languages.insertBefore("scss","atrule",{keyword:[/@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,{pattern:/( )(?:from|through)(?= )/,lookbehind:!0}]}),e.languages.insertBefore("scss","important",{variable:/\$[-\w]+|#\{\$[-\w]+\}/}),e.languages.insertBefore("scss","function",{"module-modifier":{pattern:/\b(?:as|hide|show|with)\b/i,alias:"keyword"},placeholder:{pattern:/%[-\w]+/,alias:"selector"},statement:{pattern:/\B!(?:default|optional)\b/i,alias:"keyword"},boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"},operator:{pattern:/(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,lookbehind:!0}}),e.languages.scss.atrule.inside.rest=e.languages.scss}Tg.displayName="json";Tg.aliases=["webmanifest"];function Tg(e){e.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"}},e.languages.webmanifest=e.languages.json}Ag.displayName="java";Ag.aliases=[];function Ag(e){e.register(Xi),(function(t){var n=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,r=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,a={pattern:RegExp(/(^|[^\w.])/.source+r+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[a,{pattern:RegExp(/(^|[^\w.])/.source+r+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:a.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+r+/[A-Z]\w*\b/.source),lookbehind:!0,inside:a.inside}],keyword:n,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":a,keyword:n,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+r+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:a.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+r+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:a.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g,function(){return n.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(e)}md.displayName="typescript";md.aliases=["ts"];function md(e){e.register(Kl),(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 n=t.languages.extend("typescript",{});delete n["class-name"],t.languages.typescript["class-name"].inside=n,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:n}}}}),t.languages.ts=t.languages.typescript})(e)}Dg.displayName="python";Dg.aliases=["py"];function Dg(e){e.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:/[{}[\];(),.:]/},e.languages.python["string-interpolation"].inside.interpolation.inside.rest=e.languages.python,e.languages.py=e.languages.python}gd.displayName="jsx";gd.aliases=[];function gd(e){e.register(Kl),e.register(Yi),(function(t){var n=t.util.clone(t.languages.javascript),r=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,a=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,o=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function u(f,m){return f=f.replace(/<S>/g,function(){return r}).replace(/<BRACES>/g,function(){return a}).replace(/<SPREAD>/g,function(){return o}),RegExp(f,m)}o=u(o).source,t.languages.jsx=t.languages.extend("markup",n),t.languages.jsx.tag.pattern=u(/<\/?(?:[\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=n.comment,t.languages.insertBefore("inside","attr-name",{spread:{pattern:u(/<SPREAD>/.source),inside:t.languages.jsx}},t.languages.jsx.tag),t.languages.insertBefore("inside","special-attr",{script:{pattern:u(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:t.languages.jsx}}},t.languages.jsx.tag);var d=function(f){return f?typeof f=="string"?f:typeof f.content=="string"?f.content:f.content.map(d).join(""):""},p=function(f){for(var m=[],g=0;g<f.length;g++){var v=f[g],b=!1;if(typeof v!="string"&&(v.type==="tag"&&v.content[0]&&v.content[0].type==="tag"?v.content[0].content[0].content==="</"?m.length>0&&m[m.length-1].tagName===d(v.content[0].content[1])&&m.pop():v.content[v.content.length-1].content==="/>"||m.push({tagName:d(v.content[0].content[1]),openedBraces:0}):m.length>0&&v.type==="punctuation"&&v.content==="{"?m[m.length-1].openedBraces++:m.length>0&&m[m.length-1].openedBraces>0&&v.type==="punctuation"&&v.content==="}"?m[m.length-1].openedBraces--:b=!0),(b||typeof v=="string")&&m.length>0&&m[m.length-1].openedBraces===0){var _=d(v);g<f.length-1&&(typeof f[g+1]=="string"||f[g+1].type==="plain-text")&&(_+=d(f[g+1]),f.splice(g+1,1)),g>0&&(typeof f[g-1]=="string"||f[g-1].type==="plain-text")&&(_=d(f[g-1])+_,f.splice(g-1,1),g--),f[g]=new t.Token("plain-text",_,null,_)}v.content&&typeof v.content!="string"&&p(v.content)}};t.hooks.add("after-tokenize",function(f){f.language!=="jsx"&&f.language!=="tsx"||p(f.tokens)})})(e)}Mg.displayName="tsx";Mg.aliases=[];function Mg(e){e.register(gd),e.register(md),(function(t){var n=t.util.clone(t.languages.typescript);t.languages.tsx=t.languages.extend("jsx",n),delete t.languages.tsx.parameter,delete t.languages.tsx["literal-property"];var r=t.languages.tsx.tag;r.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+r.pattern.source+")",r.pattern.flags),r.lookbehind=!0})(e)}Rg.displayName="rust";Rg.aliases=[];function Rg(e){(function(t){for(var n=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source,r=0;r<2;r++)n=n.replace(/<self>/g,function(){return n});n=n.replace(/<self>/g,function(){return/[^\s\S]/.source}),t.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+n),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})(e)}Lg.displayName="toml";Lg.aliases=[];function Lg(e){(function(t){var n=/(?:[\w-]+|'[^'\n\r]*'|"(?:\\.|[^\\"\r\n])*")/.source;function r(a){return a.replace(/__/g,function(){return n})}t.languages.toml={comment:{pattern:/#.*/,greedy:!0},table:{pattern:RegExp(r(/(^[\t ]*\[\s*(?:\[\s*)?)__(?:\s*\.\s*__)*(?=\s*\])/.source),"m"),lookbehind:!0,greedy:!0,alias:"class-name"},key:{pattern:RegExp(r(/(^[\t ]*|[{,]\s*)__(?:\s*\.\s*__)*(?=\s*=)/.source),"m"),lookbehind:!0,greedy:!0,alias:"property"},string:{pattern:/"""(?:\\[\s\S]|[^\\])*?"""|'''[\s\S]*?'''|'[^'\n\r]*'|"(?:\\.|[^\\"\r\n])*"/,greedy:!0},date:[{pattern:/\b\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?\b/i,alias:"number"},{pattern:/\b\d{2}:\d{2}:\d{2}(?:\.\d+)?\b/,alias:"number"}],number:/(?:\b0(?:x[\da-zA-Z]+(?:_[\da-zA-Z]+)*|o[0-7]+(?:_[0-7]+)*|b[10]+(?:_[10]+)*))\b|[-+]?\b\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?\b|[-+]?\b(?:inf|nan)\b/,boolean:/\b(?:false|true)\b/,punctuation:/[.,=[\]{}]/}})(e)}const Mu={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}};bt.registerLanguage("typescript",md);bt.registerLanguage("javascript",Kl);bt.registerLanguage("tsx",Mg);bt.registerLanguage("jsx",gd);bt.registerLanguage("python",Dg);bt.registerLanguage("bash",vg);bt.registerLanguage("json",Tg);bt.registerLanguage("css",fd);bt.registerLanguage("html",Yi);bt.registerLanguage("markup",Yi);bt.registerLanguage("xml",Yi);bt.registerLanguage("sql",yg);bt.registerLanguage("yaml",_g);bt.registerLanguage("markdown",Sg);bt.registerLanguage("diff",kg);bt.registerLanguage("rust",Rg);bt.registerLanguage("go",Ng);bt.registerLanguage("java",Ag);bt.registerLanguage("c",pd);bt.registerLanguage("cpp",bg);bt.registerLanguage("ruby",wg);bt.registerLanguage("toml",Lg);bt.registerLanguage("scss",Eg);bt.registerLanguage("graphql",jg);bt.registerLanguage("docker",Cg);function Mk(e=2e3){const[t,n]=k.useState(!1),r=k.useCallback(async a=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{const o=document.createElement("textarea");o.value=a,o.style.position="fixed",o.style.left="-9999px",document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}n(!0),setTimeout(()=>n(!1),e)}catch(o){console.error("Failed to copy:",o)}},[e]);return{copied:t,copy:r}}function I6(e){const t=e?"text-text-muted":"text-sky-400",n=e?"text-text-secondary":"text-amber-400";return{code({className:r,children:a,...o}){const u=/language-(\w+)/.exec(r||"");if(!u&&!String(a).includes(`
|
|
147
|
+
`)){const v=e?"text-text-muted":"text-accent-secondary";return l.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${v} font-mono text-xs`,...o,children:a})}const p=(u==null?void 0:u[1])||"text",f=String(a).replace(/\n$/,""),{copied:m,copy:g}=Mk();return l.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[l.jsxs("div",{className:"absolute bottom-0 right-0 flex items-center gap-2 px-2 py-1 text-xs text-text-muted/70 bg-bg-tertiary/60 rounded-tl rounded-tr z-10",children:[l.jsx("span",{children:p}),l.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.stopPropagation(),g(f)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:m?l.jsx(ns,{}):l.jsx(Rm,{})})]}),l.jsx("div",{className:"overflow-x-auto",children:l.jsx(bt,{style:Mu,language:p,PreTag:"div",customStyle:{margin:0,fontSize:"0.75rem"},codeTagProps:{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"}},children:f})})]})},p({children:r}){const a=e?"text-text-muted":"text-text-primary";return l.jsx("p",{className:`${a} mb-1.5 last:mb-0 leading-tight`,children:r})},ul({children:r}){return l.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:r})},ol({children:r}){return l.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:r})},li({children:r}){const a=e?"text-text-muted":"text-text-primary";return l.jsx("li",{className:`${a} text-sm list-item`,children:r})},h1({children:r}){return l.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${t}`,children:r})},h2({children:r}){return l.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${t}`,children:r})},h3({children:r}){return l.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${t}`,children:r})},h4({children:r}){return l.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${t}`,children:r})},strong({children:r}){return l.jsx("strong",{className:`font-bold ${n}`,children:r})},em({children:r}){return l.jsx("em",{className:e?"italic text-text-secondary":"italic",children:r})},a({href:r,children:a}){return l.jsx("a",{href:r,className:"text-accent-primary hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:a})},blockquote({children:r}){const a=e?"text-text-muted":"text-text-secondary";return l.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${a} italic text-sm`,children:r})},table({children:r}){return l.jsx("div",{className:"overflow-x-auto my-1.5",children:l.jsx("table",{className:"min-w-full border border-border",children:r})})},th({children:r}){return l.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:r})},td({children:r}){return l.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:r})},hr(){return l.jsx("hr",{className:"border-border my-2"})},input({checked:r,...a}){return l.jsx("input",{type:"checkbox",checked:r,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...a})}}}const Es=k.memo(function({content:t,className:n="",muted:r=!1}){const a=k.useMemo(()=>{let u=B6(t);return u=z6(u),u},[t]),o=k.useMemo(()=>I6(r),[r]);return l.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:l.jsx(ER,{remarkPlugins:[FO],components:o,children:a})})});function B6(e){let t=e.replace(/^(\s*)•\s/gm,"$1- ");return t=t.replace(/^(\d+)\.\s*\n(?=\S)/gm,"$1. "),t=t.replace(/^\|\s*$/gm,""),t=t.replace(/^\d+:\s/gm,""),t}function z6(e){const t=/```/g,n=e.match(t);if(((n==null?void 0:n.length)??0)%2===1){const a=e.lastIndexOf("```");return e.slice(a+3).includes(`
|
|
148
|
+
`),e+"\n```"}return e}const P6=k.memo(function({content:t,variant:n="default"}){return n==="labeled"?l.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[l.jsx("span",{className:"text-purple-400",children:"thinking:"}),l.jsx("div",{className:"ml-1.5 mt-0.5",children:l.jsx(Es,{content:t})})]}):l.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:l.jsx(Es,{content:t,muted:!0})})});function Rk({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?l.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}):e==="run_command"||e==="bash"?l.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):l.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}const H6={...Mu,'pre[class*="language-"]':{...Mu['pre[class*="language-"]'],background:"transparent",whiteSpace:"pre-wrap",overflowWrap:"break-word",overflowX:"hidden"},'code[class*="language-"]':{...Mu['code[class*="language-"]'],background:"transparent",whiteSpace:"pre-wrap",overflowWrap:"break-word"}},F6={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",toml:"toml",ini:"ini",conf:"ini",dockerfile:"docker",makefile:"makefile",cmake:"cmake",graphql:"graphql",gql:"graphql",vue:"vue",svelte:"svelte"};function xd(e){var a;if(!e)return"text";const t=e.split("/").pop()??"",n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const r=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return r?F6[r]??"text":"text"}const Lk={margin:0,padding:0,borderRadius:0,fontSize:"0.875rem",lineHeight:"1.5rem",background:"transparent",whiteSpace:"pre-wrap",overflowWrap:"break-word"},$6={...Lk,display:"inline"},U6={margin:0,padding:0,borderRadius:0,fontSize:"0.875rem",lineHeight:"1.5rem",background:"transparent",whiteSpace:"pre-wrap",overflowWrap:"break-word"},Ol=k.memo(function({code:t,language:n,variant:r}){const a=r==="inline"?"span":r==="block-nowrap"?"div":"pre",o=r==="inline"?$6:r==="block-nowrap"?Lk:U6;return l.jsx(bt,{style:H6,language:n,PreTag:a,customStyle:o,children:t})});function Ok({src:e,alt:t,isOpen:n,onClose:r}){return n?l.jsx(Et,{isOpen:n,onClose:r,title:"",size:"full",children:l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const W6=k.memo(function({oldString:t,newString:n,filePath:r}){const a=k.useMemo(()=>xd(r),[r]),o=t.split(`
|
|
149
|
+
`),u=n.split(`
|
|
150
|
+
`),d=t.length>0,p=n.length>0;return!d&&!p?l.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):l.jsxs("div",{className:"rounded overflow-hidden border border-border grid grid-cols-[3px_1.5rem_1fr]",children:[d&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"bg-red-400/60"}),l.jsx("div",{className:"bg-red-950/30 text-red-400/70 text-sm font-mono text-center",children:o.map((f,m)=>l.jsx("div",{className:"leading-[1.5rem]",children:"-"},m))}),l.jsx("div",{className:"bg-red-950/30 pr-2 line-through decoration-red-400/30 overflow-x-auto min-w-0",children:l.jsx(Ol,{code:t,language:a,variant:"block-nowrap"})})]}),p&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"bg-green-400/60"}),l.jsx("div",{className:"bg-green-950/30 text-green-400/70 text-sm font-mono text-center",children:u.map((f,m)=>l.jsx("div",{className:"leading-[1.5rem]",children:"+"},m))}),l.jsx("div",{className:"bg-green-950/30 pr-2 overflow-x-auto min-w-0",children:l.jsx(Ol,{code:n,language:a,variant:"block-nowrap"})})]})]})}),q6=k.memo(function({content:t,filePath:n}){const r=k.useMemo(()=>xd(n),[n]);return l.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:l.jsxs("div",{className:"grid grid-cols-[3px_1.5rem_1fr]",children:[l.jsx("div",{className:"bg-green-400/60"}),l.jsx("div",{className:"bg-green-950/30 text-green-400/70 text-sm font-mono text-center",children:t.split(`
|
|
151
|
+
`).map((a,o)=>l.jsx("div",{className:"leading-[1.5rem]",children:"+"},o))}),l.jsx("div",{className:"bg-green-950/30 pr-2 min-w-0 overflow-x-hidden",children:l.jsx(Ol,{code:t,language:r,variant:"block"})})]})})}),V6=k.memo(function({regions:t,filePath:n}){const r=k.useMemo(()=>xd(n),[n]);return t.length===0?l.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):l.jsx("div",{className:"space-y-2",children:t.map((a,o)=>l.jsx(K6,{region:a,language:r},o))})}),K6=k.memo(function({region:t,language:n}){const r=G6(t),a=Math.max(...t.beforeContext.map(u=>u.lineNumber),...t.afterContext.map(u=>u.lineNumber),...t.edits.flatMap(u=>[u.startLine,u.endLine])),o=String(a).length;return l.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((u,d)=>l.jsx(Y6,{item:u,language:n,lineNumWidth:o},d))})});function G6(e){const t=[];for(const n of e.beforeContext)t.push({type:"context",lineNumber:n.lineNumber,content:n.content});for(const n of e.edits){const r=n.oldContent.split(`
|
|
152
|
+
`);for(let o=0;o<r.length;o++)t.push({type:"removed",lineNumber:n.startLine+o,content:r[o]});const a=n.newContent.split(`
|
|
153
|
+
`);for(let o=0;o<a.length;o++)t.push({type:"added",lineNumber:n.startLine+o,content:a[o]})}for(const n of e.afterContext)t.push({type:"context",lineNumber:n.lineNumber,content:n.content});return t}const Y6=k.memo(function({item:t,language:n,lineNumWidth:r}){const a=String(t.lineNumber).padStart(r," "),o=t.type==="context"?"bg-bg-secondary":t.type==="removed"?"bg-red-950/30":"bg-green-950/30",u=t.type==="context"?"text-text-muted":t.type==="removed"?"text-red-400/70":"text-green-400/70",d=t.type==="context"?" ":t.type==="removed"?"-":"+",p=t.type==="removed"?"line-through decoration-red-400/30":"",f=t.type==="context"?"bg-transparent":t.type==="removed"?"bg-red-400/60":"bg-green-400/60";return l.jsxs("div",{className:`grid grid-cols-[3px_auto_1.25rem_1fr] ${o}`,children:[l.jsx("div",{className:f}),l.jsx("div",{className:"px-2 text-text-muted text-right select-none leading-[1.5rem]",children:a}),l.jsx("div",{className:`text-center select-none leading-[1.5rem] ${u}`,children:d}),l.jsx("div",{className:`pr-2 overflow-x-auto min-w-0 ${p}`,children:l.jsx(Ol,{code:t.content||" ",language:n,variant:"inline"})})]})}),X6=k.memo(function({result:t,metadata:n,filePath:r,heightExpanded:a=!1}){const[o,u]=k.useState(!1),d=k.useMemo(()=>xd(r),[r]),p=n==null?void 0:n.mimeType,f=n==null?void 0:n.base64Data;if(p!=null&&p.startsWith("image/")&&f){const v=`data:${p};base64,${f}`;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors`,onClick:()=>u(!0),children:l.jsx("img",{src:v,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),l.jsx(Ok,{src:v,alt:r,isOpen:o,onClose:()=>u(!1)})]})}if(!t)return l.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});if(d==="markdown"){const v=t.split(`
|
|
154
|
+
`).filter(b=>!b.startsWith(`
|
|
155
|
+
[`)&&!b.startsWith("[")).map(b=>b.replace(/^\d+: /,"")).join(`
|
|
156
|
+
`);return l.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} overflow-y-auto p-2`,children:l.jsx(Es,{content:v})})}const m=t.split(`
|
|
157
|
+
`),g=m.filter(v=>!v.startsWith(`
|
|
158
|
+
[`)&&!v.startsWith("[")).map(v=>v.replace(/^\d+: /,"")).join(`
|
|
159
|
+
`);return l.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} overflow-y-auto`,children:l.jsxs("div",{className:"grid grid-cols-[2.5rem_1fr]",children:[l.jsx("div",{className:"bg-bg-tertiary text-text-muted text-xs font-mono text-right pr-2 select-none py-0.5",children:m.filter(v=>!v.startsWith(`
|
|
160
|
+
[`)&&!v.startsWith("[")).map((v,b)=>{const _=v.match(/^(\d+): /);return l.jsx("div",{className:"leading-[1.5rem]",children:_?_[1]:b+1},b)})}),l.jsx("div",{className:"min-w-0 overflow-x-hidden py-0.5",children:l.jsx(Ol,{code:g,language:d,variant:"block"})})]})})}),Z6={error:{icon:"✗",color:"text-accent-error",bg:"bg-red-500/10",border:"border-red-500/30"},warning:{icon:"⚠",color:"text-accent-warning",bg:"bg-yellow-500/10",border:"border-yellow-500/30"},info:{icon:"ℹ",color:"text-accent-info",bg:"bg-blue-500/10",border:"border-blue-500/30"},hint:{icon:"💡",color:"text-text-muted",bg:"bg-gray-500/10",border:"border-gray-500/30"}},bS=k.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(o=>o.severity==="error"),r=t.filter(o=>o.severity==="warning"),a=t.filter(o=>o.severity==="info"||o.severity==="hint");return l.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[l.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[l.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&l.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&l.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&l.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),l.jsx("div",{className:"max-h-48 overflow-y-auto",children:t.map((o,u)=>{const d=Z6[o.severity];return l.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${d.bg} border-b border-border last:border-b-0`,children:[l.jsx("span",{className:`${d.color} text-xs flex-shrink-0 w-4 text-center`,children:d.icon}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",o.range.start.line+1,":",o.range.start.character+1]}),o.code&&l.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",o.code,"]"]})]}),l.jsx("div",{className:"text-xs text-text-primary break-words",children:o.message})]})]},u)})})]})}),Q6=k.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:o,result:u,error:d,durationMs:p}){const f=k.useRef(null),[m,g]=k.useState(0);k.useEffect(()=>{f.current&&o==="pending"&&(f.current.scrollTop=f.current.scrollHeight)},[a,o]),k.useEffect(()=>{if(o!=="pending"||!r)return;const S=setInterval(()=>{g(Date.now()-r)},100);return()=>clearInterval(S)},[o,r]);const v=n/1e3,b=o==="pending"?m/1e3:(p??0)/1e3,_=o==="pending"?(a==null?void 0:a.map(S=>S.content).join(""))??"":u??"";return l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[l.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),l.jsx("code",{className:"text-text-primary break-all",children:t})]}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[o==="pending"&&l.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),o==="interrupted"&&l.jsx("span",{className:"text-red-400",children:"interrupted"}),l.jsxs("span",{className:o==="pending"?"text-text-secondary":"text-text-muted",children:[b.toFixed(1),"s / ",v,"s"]})]})]}),o==="pending"&&l.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:l.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,m/n*100)}%`}})}),(_||o==="pending")&&l.jsx("pre",{ref:f,className:`text-xs bg-bg-primary p-2 rounded max-h-64 overflow-y-auto ${o==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:o==="pending"&&a?a.map((S,j)=>l.jsx("span",{className:S.stream==="stderr"?"text-accent-warning":"",children:Fu(S.content)},j)):Fu(_)}),o==="error"&&d&&l.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:d}),o!=="pending"&&p!==void 0&&l.jsxs("div",{className:"text-[10px] text-text-muted",children:["Completed in ",(p/1e3).toFixed(2),"s"]})]})});function J6(e){switch(e){case"sensitive_file":return{title:"Sensitive File Access",description:"Accessing files that may contain secrets"};case"both":return{title:"Sensitive File Access",description:"Accessing sensitive files outside project"};case"dangerous_command":return{title:"Dangerous Command",description:"Running potentially dangerous command"};case"git_no_verify":return{title:"Git --no-verify",description:"Bypassing git hooks/pre-commit checks"};case"outside_workdir":default:return{title:"Path Access Request",description:"Accessing paths outside project directory"}}}function eI({confirmation:e}){const t=ye(g=>g.confirmPath),n=ye(g=>g.currentSession),r=ye(g=>g.switchDangerLevel),{title:a,description:o}=J6(e.reason),u=e.reason==="sensitive_file"||e.reason==="both",d=u?"border-red-500/50":"border-amber-500/50",p=u?"bg-red-500/10":"bg-amber-500/10",f=e.reason==="git_no_verify",m=()=>{n!=null&&n.id&&r("dangerous"),t(e.callId,!0,!1)};return l.jsxs("div",{className:`border ${d} ${p} rounded p-3 my-2`,children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx(Np,{}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:`text-sm font-medium ${u?"text-red-400":"text-amber-400"}`,children:a}),l.jsx("div",{className:"text-xs text-text-muted",children:o})]})]}),l.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[l.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),l.jsx("div",{className:"bg-bg-primary rounded p-2 mb-3 max-h-24 overflow-y-auto",children:l.jsx("ul",{className:"space-y-0.5",children:e.paths.map((g,v)=>l.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:g},v))})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>t(e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),l.jsx("button",{onClick:()=>t(e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),l.jsx("button",{onClick:m,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${f?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function tI(e,t){if(e==="read_file"){const r=String(t.path??""),a=t.offset,o=t.limit,u=[];return a!==void 0&&a!==1&&u.push(`offset=${a}`),o!==void 0&&u.push(`limit=${o}`),u.length>0?`${r} [${u.join(", ")}]`:r}if(e==="write_file"||e==="edit_file")return String(t.path??"");if(e==="run_command"||e==="bash")return String(t.command??"");if(e==="return_value"){const r=String(t.content??"");return r.length>60?r.slice(0,60)+"...":r}const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function vS(e,t,n){return tI(e,t)}function nI(e){return JSON.stringify(e,null,2)}const rI={pending:{icon:"●",color:"text-accent-warning",animate:!0},success:{icon:"✓",color:"text-accent-success",animate:!1},error:{icon:"✗",color:"text-accent-error",animate:!1},interrupted:{icon:"✗",color:"text-red-400",animate:!1}},sI=k.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:o,result:u,error:d,durationMs:p,diagnostics:f,editContext:m,startedAt:g,streamingOutput:v,metadata:b,callId:_}){const S=t==="edit_file"||t==="write_file",j=t==="run_command"&&r==="pending",C=t==="read_file",A=o?!1:S||j||t==="return_value",[O,z]=k.useState(A),B=rI[r],Y=ye(ie=>ie.pendingPathConfirmations),ee=r==="pending"&&_?Y.find(ie=>ie.callId===_)??null:null;return a==="compact"?l.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary rounded px-2 py-1.5",children:[l.jsx(Rk,{tool:t}),l.jsx("span",{className:"text-accent-primary font-medium",children:t}),l.jsx("span",{className:"text-text-muted truncate flex-1",children:vS(t,n)}),l.jsx("span",{className:`${B.color} ${B.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):l.jsxs("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0",children:[l.jsxs("button",{className:"w-full flex items-center gap-1.5 p-2 bg-secondary hover:bg-secondary/80 text-left",onClick:()=>z(!O),children:[l.jsx("span",{className:`${B.color} ${B.animate?"animate-pulse":""}`,children:B.icon}),l.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),l.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:vS(t,n)}),l.jsx("span",{className:"text-text-muted text-xs",children:O?"▼":"▶"})]}),ee&&l.jsx(eI,{confirmation:ee}),(O||C)&&l.jsxs("div",{className:"p-2 bg-primary border-t border-border space-y-2 min-w-0",children:[t==="run_command"&&l.jsx(Q6,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:g,streamingOutput:v,status:r,result:u,error:d,durationMs:p}),t==="edit_file"&&r==="success"&&l.jsxs(l.Fragment,{children:[m&&m.regions.length>0?l.jsx(V6,{regions:m.regions,filePath:String(n.path??"")}):l.jsx(W6,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),f&&f.length>0&&l.jsx(bS,{diagnostics:f})]}),t==="write_file"&&r==="success"&&l.jsxs(l.Fragment,{children:[l.jsx(q6,{content:String(n.content??""),filePath:String(n.path??"")}),f&&f.length>0&&l.jsx(bS,{diagnostics:f})]}),t==="read_file"&&r==="success"&&l.jsx(X6,{result:u,metadata:b,filePath:String(n.path??""),heightExpanded:O}),t==="return_value"&&(()=>{const ie=(v==null?void 0:v.map($=>$.content).join(""))??"",D=r==="pending"&&ie?ie:String(n.content??"");return l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),l.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:l.jsx(Es,{content:D})})]})})(),t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),l.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto",children:nI(n)})]}),r==="success"&&u!==void 0&&l.jsxs("div",{children:[l.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",p!==void 0&&` (${p}ms)`,":"]}),l.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-32",children:u||"No output"})]})]}),r==="success"&&(t==="edit_file"||t==="write_file"||t==="read_file")&&p!==void 0&&l.jsxs("div",{className:"text-[10px] text-text-muted",children:["Completed in ",p,"ms"]}),r==="error"&&d&&t!=="run_command"&&l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),l.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error",children:d})]})]})]})}),iI={read_file:"Reading file",write_file:"Writing file",edit_file:"Editing file",run_command:"Running command",glob:"Searching files",grep:"Searching content",ask_user:"Asking user",criterion:"Managing criterion",todo_write:"Updating tasks"};function aI(e){return iI[e]??`Preparing ${e}`}function oI(e){try{const t=e.replace(/\s*\}\s*$/,""),n=JSON.parse(t);if(typeof n.command=="string")return n.command}catch{const t=e.match(/"command"\s*:\s*"([^"]*)/);if(t&&t[1])return t[1]}return null}const lI=k.memo(function({name:t,arguments:n}){let a=aI(t)+"...";if(t==="run_command"&&n){const o=oI(n);o&&(a=o)}return l.jsx("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0 animate-pulse",children:l.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-bg-tertiary",children:[l.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),l.jsx(Rk,{tool:t}),l.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?l.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):l.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),cI={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},uI=k.memo(function({todos:t}){return Array.isArray(t)?t.length===0?l.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):l.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[l.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:l.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),l.jsx("div",{children:t.map((n,r)=>{const a=cI[n.status];return l.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[l.jsx("span",{className:`${(a==null?void 0:a.color)??"text-text-muted"} ${a!=null&&a.animate?"animate-pulse":""} text-sm leading-tight`,children:(a==null?void 0:a.icon)??"○"}),l.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):l.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})}),_S={add:{icon:"○",color:"text-text-muted"},update:{icon:"○",color:"text-text-muted"},remove:{icon:"○",color:"text-text-muted"},complete:{icon:"◉",color:"text-purple-400"},pass:{icon:"✓",color:"text-accent-success"},fail:{icon:"✗",color:"text-accent-error"},get:{icon:"○",color:"text-text-muted"}},Ik=k.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(o=>[o.id,o]))??[]),a=t.find(o=>{var u,d;return o.arguments.action==="get"&&((u=o.result)==null?void 0:u.success)&&((d=o.result)==null?void 0:d.output)});return l.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[l.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:l.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Acceptance Criteria"})}),l.jsx("div",{className:"bg-primary",children:a?(()=>{const o=a.result.output;if(o==="No criteria defined yet.")return l.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[l.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),l.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(o).map((d,p)=>l.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${p>0?"border-t border-border":""}`,children:[l.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsx(Es,{content:`[${d.id}] ${d.description}`})})]},d.id??p))}catch{return t.map((u,d)=>l.jsx(SS,{tc:u,index:d,criteriaMap:r},u.id??d))}})():t.map((o,u)=>l.jsx(SS,{tc:o,index:u,criteriaMap:r},o.id??u))})]})});function SS({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,a=r&&_S[r]?_S[r]:{icon:"○",color:"text-text-muted"},o=e.arguments,u=r==="remove",d=o.id,p=o.description,f=d?n.get(d):void 0,m=p??(f==null?void 0:f.description)??(u&&d?`[${d}]`:"Criterion updated"),g=o.reason,v=r==="fail";return l.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[l.jsx("span",{className:`${a.color} text-sm leading-tight flex-shrink-0`,children:a.icon}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:u?"line-through text-text-muted":"",children:l.jsx(Es,{content:m})}),g&&l.jsxs("div",{className:`mt-1 text-sm ${v?"text-accent-error":"text-text-muted"}`,children:[l.jsx("span",{className:"text-text-muted",children:"└ "}),'"',g,'"']})]})]})}function dI(e){return e==="criterion"}const hI="#6b7280";function Vu(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??hI}const Lt=gr(e=>{const t=async()=>{await Pm("/api/agents",e,!0)};return{defaults:[],userItems:[],projectItems:[],loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await ke(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ke(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const a=await di("POST","/api/agents",{...n,destination:r});return a.success&&await t(),a},updateAgent:async(n,r)=>{const a=await di("PUT",`/api/agents/${n}`,r);return a.success&&await t(),a},deleteAgent:async n=>{try{const r=await ke(`/api/agents/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(o=>({userItems:o.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r)=>Zu(`/api/agents/${n}/duplicate`,t,r)}});function fI(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const a of e)a.type==="tool_call"&&dI(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function pI(e,t){if(e.segments&&e.segments.length>0)return mI(e.segments,e.toolCalls??[],e.preparingToolCalls??[],e.stats,t);const n=[];if(e.thinkingContent&&n.push({type:"thinking",content:e.thinkingContent}),e.content&&n.push({type:"text",content:e.content}),e.toolCalls)for(const r of e.toolCalls)n.push({type:"tool_call",toolCall:r});if(e.preparingToolCalls)for(const r of e.preparingToolCalls)n.push({type:"preparing_tool_call",preparing:r});return t&&e.stats&&n.push({type:"stats",stats:e.stats}),n}function mI(e,t,n,r,a){const o=[],u=new Map(t.map(d=>[d.id,d]));for(const d of e)switch(d.type){case"text":o.push({type:"text",content:d.content});break;case"thinking":d.content&&d.content.trim().length>0&&o.push({type:"thinking",content:d.content});break;case"tool_call":{const p=u.get(d.toolCallId);p&&o.push({type:"tool_call",toolCall:p});break}}for(const d of n)o.push({type:"preparing_tool_call",preparing:d});return a&&r&&o.push({type:"stats",stats:r}),o}const Og=k.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0}){const o=ye(v=>{var b;return(b=v.currentSession)==null?void 0:b.criteria}),u=Lt(v=>v.defaults),d=Lt(v=>v.userItems),p=[...u,...d],f=pI(t,n),m=r?f:f.filter(v=>v.type!=="thinking"),g=fI(m);return g.length===0?null:l.jsx("div",{className:"feed-item",children:l.jsxs("div",{className:"min-w-0",children:[g.map((v,b)=>{var _,S;switch(v.type){case"thinking":return l.jsx(P6,{content:v.content},b);case"text":return l.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:l.jsx(Es,{content:v.content})},b);case"preparing_tool_call":return l.jsx(lI,{name:v.preparing.name,arguments:v.preparing.arguments},`preparing-${v.preparing.index}`);case"tool_call":{const j=v.toolCall,C=j.result;if(j.name==="todo_write"){const O=j.arguments.todos,z=Array.isArray(O)?O:[];return l.jsx(uI,{todos:z},b)}const E=(_=C==null?void 0:C.output)==null?void 0:_.includes("[interrupted by user]"),A=C?E?"interrupted":C.success?"success":"error":"pending";return l.jsx(sI,{tool:j.name,args:j.arguments,status:A,variant:"expandable",forceCompact:!a,result:C==null?void 0:C.output,error:C==null?void 0:C.error,durationMs:C==null?void 0:C.durationMs,diagnostics:C==null?void 0:C.diagnostics,editContext:C==null?void 0:C.editContext,startedAt:j.startedAt,streamingOutput:j.streamingOutput,metadata:C==null?void 0:C.metadata,callId:j.id},b)}case"criteria_group":return l.jsx(Ik,{toolCalls:v.toolCalls,criteria:o},b);case"stats":{const j=v.stats;if(!j||"error"in j)return null;const C=((S=j.model.split("/").pop())==null?void 0:S.split("-").slice(0,2).join("-"))??j.model,E=Vu(p,j.mode),A=z=>z>=1e3?`${(z/1e3).toFixed(1)}k`:z.toString(),O=z=>z>=1e3?`${(z/1e3).toFixed(1)}k`:z.toFixed(1);return l.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted mt-3",children:[l.jsx("span",{className:"flex-1 h-px bg-border"}),l.jsx("span",{className:"text-text-secondary",children:C}),l.jsx("span",{className:"text-text-muted",children:"·"}),l.jsx("span",{style:{color:E},children:j.mode}),l.jsx("span",{className:"text-text-muted",children:"·"}),l.jsxs("span",{children:[j.totalTime.toFixed(1),"s"]}),j.toolTime>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-text-muted",children:"·"}),l.jsxs("span",{children:[j.toolTime.toFixed(1),"s tools"]})]}),l.jsx("span",{className:"text-text-muted",children:"·"}),l.jsxs("span",{children:[A(j.prefillTokens)," @ ",O(j.prefillSpeed)," pp"]}),l.jsx("span",{className:"text-text-muted",children:"·"}),l.jsxs("span",{children:[A(j.generationTokens)," @ ",O(j.generationSpeed)," tg"]}),l.jsx("span",{className:"text-text-muted",children:"·"}),l.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const z=new CustomEvent("open-turn-stats",{detail:{stats:j}});window.dispatchEvent(z)},children:l.jsx(jj,{className:"w-3 h-3"})}),l.jsx("span",{className:"flex-1 h-px bg-border"})]},b)}}}),t.partial&&l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[l.jsx(Np,{}),l.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-amber-400/80 mt-1",children:[l.jsx(Np,{}),l.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]})})});function Ku(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${a},${t})`}function gI(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),n=Math.round(e%60);return n>0?`${t}m ${n}s`:`${t}m`}function xI(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const yI=k.memo(function({data:t}){var u;const n=Rt(d=>d.defaults),r=Rt(d=>d.userItems),o=((u=[...n,...r].find(d=>d.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#8b949e";return l.jsxs("div",{className:"feed-item rounded p-3 border",style:{borderColor:Ku(o,.3),backgroundColor:Ku(o,.08)},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx(Ij,{color:o}),l.jsx("span",{className:"text-sm font-medium",style:{color:o},children:t.workflowName??"Task Completed"})]}),l.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[l.jsx(dl,{label:"Iterations",value:String(t.iterations)}),l.jsx(dl,{label:"Total time",value:gI(t.totalTimeSeconds)}),l.jsx(dl,{label:"Tool calls",value:String(t.totalToolCalls)}),l.jsx(dl,{label:"Tokens",value:xI(t.totalTokensGenerated)}),l.jsx(dl,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function dl({label:e,value:t}){return l.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[l.jsx("div",{className:"text-sm text-text-muted",children:e}),l.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const bI=k.memo(function({data:t}){var u;const n=Rt(d=>d.defaults),r=Rt(d=>d.userItems),o=((u=[...n,...r].find(d=>d.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#6b7280";return l.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:Ku(o,.3),backgroundColor:Ku(o,.08)},children:[l.jsx(Aj,{className:"w-3 h-3 shrink-0",color:o}),l.jsx("span",{className:"text-sm font-medium",style:{color:o},children:t.workflowName}),l.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})});function vI({attachments:e,messageId:t}){const[n,r]=k.useState(null),a=ye(m=>m.visionFallbackByMessage),o=ye(m=>m.messages),u=k.useMemo(()=>{const m=o.findIndex(g=>g.id===t);if(m===-1)return null;for(let g=m+1;g<o.length;g++){const v=o[g];if(v&&v.role==="assistant")return v.id}return null},[o,t]),d=m=>{r(m)},p=()=>{r(null)},f=m=>{const g=`${t}-${m}`;if(a[g])return a[g];if(u){const v=`${u}-${m}`;return a[v]}return null};return e.length===0?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(m=>{const g=f(m.id);return l.jsxs("div",{className:"relative inline-block",children:[l.jsxs("button",{onClick:()=>d(m.data),className:"group relative inline-block",title:m.filename,disabled:(g==null?void 0:g.type)==="start",children:[l.jsx("img",{src:m.data,alt:m.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(g==null?void 0:g.type)==="start"&&l.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:l.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(g==null?void 0:g.type)==="done"&&g.description&&l.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[g.description.slice(0,200),g.description.length>200?"...":""]})]},m.id)})}),n&&l.jsx(Ok,{src:n,alt:"Attached image",isOpen:!0,onClose:p})]})}function _I({isOpen:e,onClose:t,promptContext:n}){const[r,a]=k.useState({systemPrompt:!1,messages:!0,tools:!0,requestOptions:!0,injectedFiles:!0,userMessage:!0}),o=u=>{a(d=>({...d,[u]:!d[u]}))};return l.jsx(Et,{isOpen:e,onClose:t,title:"Prompt Inspector",size:"lg",children:l.jsxs("div",{className:"space-y-4",children:[l.jsx(Ha,{title:"User Message",expanded:r.userMessage??!0,onToggle:()=>o("userMessage"),children:l.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-3 max-h-48 overflow-auto",children:n.userMessage||"(empty)"})}),n.messages.length>0&&l.jsx(Ha,{title:`Prompt Messages (${n.messages.length})`,expanded:r.messages??!0,onToggle:()=>o("messages"),children:l.jsx("div",{className:"space-y-2",children:n.messages.map((u,d)=>l.jsxs("div",{className:"border border-border rounded overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-bg-tertiary/50 text-xs text-text-muted",children:[l.jsx("span",{className:"font-mono text-text-primary",children:u.role}),l.jsx("span",{className:"rounded bg-bg-tertiary px-1.5 py-0.5",children:u.source}),u.toolCallId&&l.jsx("span",{className:"font-mono",children:u.toolCallId}),u.attachments&&u.attachments.length>0&&l.jsxs("span",{className:"rounded bg-bg-tertiary px-1.5 py-0.5",children:[u.attachments.length," attachment",u.attachments.length===1?"":"s"]})]}),u.attachments&&u.attachments.length>0&&l.jsx("div",{className:"border-b border-border px-3 py-2 text-xs text-text-muted",children:u.attachments.map(p=>p.filename).join(", ")}),l.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded-b p-3 max-h-64 overflow-auto font-mono",children:u.content||"(empty)"})]},`${u.role}-${d}`))})}),l.jsx(Ha,{title:`Tools (${n.tools.length})`,expanded:r.tools??!0,onToggle:()=>o("tools"),children:l.jsxs("div",{className:"space-y-2",children:[n.tools.length===0&&l.jsx("div",{className:"text-sm text-text-muted",children:"No tools sent with this request."}),n.tools.map((u,d)=>l.jsxs("div",{className:"bg-bg-tertiary rounded p-3 space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("span",{className:"font-mono text-sm text-text-primary",children:u.name}),l.jsx("span",{className:"text-xs text-text-muted",children:"parameters"})]}),l.jsx("div",{className:"text-sm text-text-secondary",children:u.description}),l.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap max-h-48 overflow-auto font-mono",children:JSON.stringify(u.parameters,null,2)})]},`${u.name}-${d}`))]})}),l.jsx(Ha,{title:"Request Options",expanded:r.requestOptions??!0,onToggle:()=>o("requestOptions"),children:l.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-3 max-h-48 overflow-auto font-mono lowercase",children:JSON.stringify(n.requestOptions,null,2)})}),n.injectedFiles.length>0&&l.jsx(Ha,{title:`Injected Files (${n.injectedFiles.length})`,expanded:r.injectedFiles??!0,onToggle:()=>o("injectedFiles"),children:l.jsx("div",{className:"space-y-2",children:n.injectedFiles.map((u,d)=>l.jsx(SI,{file:u,expanded:r[`file-${d}`]??!1,onToggle:()=>o(`file-${d}`)},d))})}),l.jsx(Ha,{title:"System Prompt",expanded:r.systemPrompt??!1,onToggle:()=>o("systemPrompt"),badge:`${Math.round(n.systemPrompt.length/1e3)}K chars`,children:l.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-3 max-h-96 overflow-auto font-mono",children:n.systemPrompt})})]})})}function SI({file:e,expanded:t,onToggle:n}){return l.jsxs("div",{className:"bg-bg-tertiary rounded overflow-hidden",children:[l.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2 p-2 hover:bg-bg-primary/30 transition-colors",children:[l.jsx(rs,{className:`w-3 h-3 text-text-muted transition-transform ${t?"rotate-90":""}`}),l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${e.source==="global"?"bg-purple-500/20 text-purple-400":e.source==="project"?"bg-blue-500/20 text-blue-400":"bg-green-500/20 text-green-400"}`,children:e.source}),l.jsx("span",{className:"text-sm text-text-primary font-mono truncate flex-1 text-left",children:e.path}),e.content&&l.jsxs("span",{className:"text-xs text-text-muted",children:[Math.round(e.content.length/1e3),"K chars"]})]}),t&&e.content&&l.jsx("div",{className:"border-t border-border/50 p-2",children:l.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap max-h-64 overflow-auto font-mono",children:e.content})})]})}function Ha({title:e,expanded:t,onToggle:n,badge:r,children:a}){return l.jsxs("div",{className:"border border-border rounded overflow-hidden",children:[l.jsx("button",{onClick:n,className:"w-full flex items-center justify-between p-3 bg-bg-tertiary/50 hover:bg-bg-tertiary transition-colors",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(rs,{className:`w-4 h-4 text-text-muted transition-transform ${t?"rotate-90":""}`}),l.jsx("span",{className:"font-medium text-text-primary",children:e}),r&&l.jsx("span",{className:"text-xs text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:r})]})}),t&&l.jsx("div",{className:"p-3 border-t border-border",children:a})]})}function wI({content:e,promptContext:t,align:n="right",messageIndex:r,sessionId:a}){const[o,u]=k.useState(!1),[d,p]=k.useState(!1),[f,m]=k.useState(!1),[g,v]=k.useState(!1),b=k.useRef(null),_=ye(E=>E.loadSession);k.useEffect(()=>{const E=A=>{b.current&&!b.current.contains(A.target)&&u(!1)};return o&&document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[o]);const S=async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(e);else{const E=document.createElement("textarea");E.value=e,E.style.position="fixed",E.style.left="-999999px",document.body.appendChild(E),E.select(),document.execCommand("copy"),document.body.removeChild(E)}m(!0),u(!1),window.setTimeout(()=>m(!1),1500)}catch(E){console.error("Failed to copy:",E)}},j=async()=>{if(!a||r===void 0||!window.confirm("Delete all messages after this point?"))return;v(!0),u(!1),await _N(a,r)&&_(a),v(!1)},C=n==="right";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`flex items-start gap-1.5 ${C?"":"order-first"}`,children:[f&&l.jsx(ns,{className:"w-4 h-4 text-accent-success"}),l.jsxs("div",{ref:b,className:"relative",children:[l.jsx("button",{onClick:()=>u(!o),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary",title:"Message options",children:l.jsx(Lm,{})}),o&&l.jsxs("div",{className:`absolute top-full mt-1 bg-bg-secondary border border-border rounded shadow-xl z-50 py-1 min-w-36 ${C?"right-0":"left-0"}`,children:[l.jsxs("button",{onClick:S,className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[l.jsx(Rm,{className:"w-4 h-4"}),"Copy"]}),a&&r!==void 0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"border-t border-border my-1"}),l.jsxs("button",{onClick:j,disabled:g,className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bg-tertiary flex items-center gap-2 disabled:opacity-50",children:[l.jsx(Ju,{className:"w-4 h-4"}),g?"Deleting...":"Delete after"]})]}),t&&l.jsxs("button",{onClick:()=>{p(!0),u(!1)},className:"w-full px-3 py-1.5 text-left text-sm text-text-primary hover:bg-bg-tertiary flex items-center gap-2",children:[l.jsx(Qu,{className:"w-4 h-4"}),"Inspect"]})]})]})]}),t&&l.jsx(_I,{isOpen:d,onClose:()=>p(!1),promptContext:t})]})}function kI({message:e}){const[t,n]=k.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,a=(r==null?void 0:r.color)??"#6b7280",o=(r==null?void 0:r.name)??"Agent",u=(r==null?void 0:r.type)??"agent",p={agent:"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions"}[u]??"injected",f=u==="workflow"||u==="subagent";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[l.jsx("span",{className:"flex-1 h-px bg-border"}),l.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${f?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!f&&n(!0)}),l.jsx("span",{className:f?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!f&&n(!0),children:o}),l.jsx("span",{children:"·"}),l.jsx("span",{className:f?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!f&&n(!0),children:p}),l.jsx("span",{className:"flex-1 h-px bg-border"})]}),f&&l.jsx("div",{className:"flex justify-center feed-item mb-4",children:l.jsx("div",{className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${a}`},children:l.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:e.content})})}),l.jsx(Et,{isOpen:t,onClose:()=>n(!1),title:`${o} Prompt`,size:"lg",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),l.jsx("span",{className:"text-sm text-text-primary font-medium",children:o}),l.jsxs("span",{className:"text-xs text-text-muted",children:["(",u,")"]})]}),l.jsx("div",{className:"h-full min-h-96",children:l.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap bg-bg-tertiary rounded p-4 h-full min-h-96 overflow-auto font-mono",children:e.content})})]})})]})}function CI({message:e,promptContext:t,messageIndex:n,sessionId:r}){const a=e.messageKind==="auto-prompt",o=e.messageKind==="command",u=e.isSystemGenerated;return l.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",children:[!u&&l.jsx(wI,{content:e.content,promptContext:t,align:"right",messageIndex:n,sessionId:r}),l.jsxs("div",{className:`max-w-[75%] rounded p-2 ${u?o?"bg-teal-500/10 border border-teal-500/30":a?"bg-slate-500/10 border border-slate-500/30":"bg-amber-500/10 border border-amber-500/30":"bg-accent-primary/15 text-text-primary"}`,children:[u&&l.jsx("span",{className:`text-[10px] block mb-0.5 ${o?"text-teal-400":a?"text-slate-400":"text-amber-400"}`,children:o?"Command":a?"Auto":"System"}),l.jsx("div",{className:`whitespace-pre-wrap text-sm ${u?`${o?"text-teal-200":a?"text-slate-200":"text-amber-200 italic"}`:""}`,children:e.content}),e.attachments&&e.attachments.length>0&&l.jsx(vI,{attachments:e.attachments,messageId:e.id})]})]})}function NI({message:e}){const t=wn(r=>r.settings[Qe.LLM_DISABLE_XML_PROTECTION])!=="true",n=async()=>{await wn.getState().setSetting(Qe.LLM_DISABLE_XML_PROTECTION,t?"true":"false")};return l.jsx("div",{className:"flex justify-end feed-item",children:l.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-amber-500/10 border border-amber-500/30",children:[l.jsx("span",{className:"text-[10px] block mb-0.5 text-amber-400",children:"System"}),l.jsx("div",{className:"whitespace-pre-wrap text-sm text-amber-200 italic",children:e.content}),l.jsx("button",{onClick:n,className:"mt-2 text-xs text-amber-400 hover:text-amber-300 underline",children:t?"Disable XML protection":"Enable XML protection"})]})})}const Bk=k.memo(function({message:t,isLastAssistantMessage:n=!1,promptContext:r,messageIndex:a,sessionId:o}){const u=t.role==="user",d=t.role==="assistant",p=t.role==="system",f=t.role==="tool";if(d)return l.jsx(Og,{message:t,showStats:n});if(p&&t.isCompacted)return l.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[l.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),l.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
|
|
161
|
+
`,"")})]});if(f)return l.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[l.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),l.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap overflow-x-auto max-h-32",children:[t.content.slice(0,500),t.content.length>500&&"..."]})]});if(t.messageKind==="workflow-started")try{const m=JSON.parse(t.content);return l.jsx(bI,{data:m})}catch{}if(t.messageKind==="task-completed")try{const m=JSON.parse(t.content);return l.jsx(yI,{data:m})}catch{}return t.messageKind==="context-reset"?l.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[l.jsx("div",{className:"flex-1 border-t border-border"}),l.jsx("span",{children:t.content}),l.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?l.jsx(kI,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?l.jsx(NI,{message:t}):u?l.jsx(CI,{message:t,promptContext:r,messageIndex:a,sessionId:o}):l.jsx("div",{className:"flex justify-start feed-item",children:l.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:l.jsx(Es,{content:t.content})})})}),zk=(e,t)=>{const n=k.useRef(!0),r=k.useRef(null),[a,o]=k.useState(!0),u=()=>{const d=e.current;d&&(d.scrollTop=d.scrollHeight)};return k.useEffect(()=>{const d=e.current;if(!d)return;const p=b=>{if(b.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(()=>{d.scrollHeight-d.scrollTop-d.offsetHeight<100&&(n.current=!0,o(!0))}));return}n.current=!1,o(!1)},f=b=>{b.touches[0]&&(r.current=b.touches[0].clientY)},m=b=>{if(r.current===null)return;const _=b.touches[0];if(!_)return;if(_.clientY-r.current>0){n.current=!1,o(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>{d.scrollHeight-d.scrollTop-d.offsetHeight<100&&(n.current=!0,o(!0))}))},g=new MutationObserver(()=>{n.current&&requestAnimationFrame(u)}),v=setInterval(()=>{n.current&&u()},1e3);return d.addEventListener("wheel",p,{passive:!0}),d.addEventListener("touchstart",f,{passive:!0}),d.addEventListener("touchmove",m,{passive:!0}),g.observe(d,{childList:!0,subtree:!0,characterData:!0}),()=>{d.removeEventListener("wheel",p),d.removeEventListener("touchstart",f),d.removeEventListener("touchmove",m),g.disconnect(),clearInterval(v)}},[t==null?void 0:t.id]),{force_scroll_to_bottom:()=>{n.current=!0,o(!0),u()},isAutoScrollActive:a,setAutoScroll:d=>{n.current=d,o(d),d&&u()}}},jI={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function EI(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function wS(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function TI({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,o=Math.round(t/n*100);return l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[l.jsxs("span",{className:wS(o,a),children:[Pu(t),"/",Pu(n)]}),l.jsxs("span",{className:wS(o,a),children:["(",o,"%)"]}),l.jsx(pw,{percent:o,dangerZone:a,size:"sm"}),a&&l.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&l.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const AI=k.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const o=k.useRef(null),u=k.useRef(null),[d,p]=k.useState(!1),f=Lt(Y=>Y.defaults),m=Lt(Y=>Y.userItems),g=[...f,...m],v=ye(Y=>Y.subAgentContextStates[r]),{showThinking:b,showVerboseToolOutput:_}=jm(),{isAutoScrollActive:S,setAutoScroll:j}=zk(u,null);k.useEffect(()=>{a||j(!0)},[a]);const C=k.useCallback(()=>{const Y=!d;p(Y),Y&&setTimeout(()=>{var ee;(ee=o.current)==null||ee.scrollIntoView({block:"start",behavior:"smooth"})},220)},[d]),E=g.find(Y=>Y.id===n),A=(E==null?void 0:E.name)??jI[n]??n,O=Vu(g,n),z=EI(O),B=t.filter(Y=>Y.role!=="tool");return l.jsxs("div",{ref:o,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[l.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:z,children:[l.jsx("span",{className:"text-xs font-medium",children:A}),l.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:v&&l.jsx(TI,{contextState:v})}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>j(!S),children:[l.jsx("span",{className:`w-1 h-1 rounded-full ${S?"bg-accent-success":"border border-text-muted"}`}),"live"]}),l.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:C,children:[d?"▼":"▶"," Expand"]})]})]}),l.jsx("div",{ref:u,className:`${d?"max-h-[calc(100vh-10rem)]":"max-h-80"} overflow-y-auto p-2 transition-[max-height] duration-200`,children:B.map(Y=>Y.role==="assistant"?l.jsx(Og,{message:Y,showStats:!0,showThinking:b,showVerboseToolOutput:_},Y.id):l.jsx(Bk,{message:Y,isLastAssistantMessage:!1},Y.id))})]})});function DI(e){const t={};let n=null;for(const r of e){if(r.role==="user"&&!r.isSystemGenerated){n=r.id;continue}r.role==="assistant"&&r.promptContext&&n&&t[n]===void 0&&(t[n]=r.promptContext)}return t}const MI=k.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r}){const a=ye($=>{var H;return(H=$.currentSession)==null?void 0:H.criteria}),o=ye($=>{var H;return(H=$.currentSession)==null?void 0:H.id}),u=ye($=>{var H;return(H=$.currentSession)==null?void 0:H.mode}),d=ye($=>{var H;return(H=$.currentSession)==null?void 0:H.phase}),p=ye($=>$.messages),f=ye($=>$.error),m=ye($=>$.clearError),g=ye($=>$.acceptAndBuild),v=Mm(),{showThinking:b,showVerboseToolOutput:_,showStats:S,showAgentDefinitions:j,showWorkflowBars:C}=jm(),E=Rt($=>$.defaults),A=Rt($=>$.userItems),O=[...E,...A],z=k.useMemo(()=>DI(p),[p]),B=u==="planner",Y=((a==null?void 0:a.length)??0)>0,ee=d==="done",ie=t.some($=>$.type==="message"&&$.message.role==="assistant"),D=B&&Y&&!v&&ie&&!ee;return l.jsxs("div",{ref:n,"data-testid":"chat-scroll-container",className:"flex-1 min-w-0 overflow-y-auto relative bg-primary",children:[l.jsx("div",{className:"pt-4",children:t.map(($,H)=>{if($.type==="context-divider")return l.jsxs("div",{className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[l.jsx("div",{className:"flex-1 border-t border-border"}),l.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),l.jsx("div",{className:"flex-1 border-t border-border"})]},H);if($.type==="subagent"){const N=$.messages.some(F=>F.isStreaming);return l.jsx("div",{className:"px-2 md:px-4",children:l.jsx(AI,{messages:$.messages,subAgentType:$.subAgentType,subAgentId:$.subAgentId,isStreaming:N})},H)}if($.type==="criteria-batch")return l.jsx("div",{className:"feed-item px-2 md:px-4",children:l.jsx(Ik,{toolCalls:$.toolCalls,criteria:a})},H);const U=$.message;if(U.role==="assistant")return l.jsx("div",{className:"px-2 md:px-4",children:l.jsx(Og,{message:U,showStats:S,showThinking:b,showVerboseToolOutput:_})},H);const q=!j&&U.messageKind==="auto-prompt",T=!C&&(U.messageKind==="workflow-started"||U.messageKind==="task-completed");return q||T?null:l.jsx("div",{className:"px-2 md:px-4",children:l.jsx("div",{"data-message-id":U.id,className:r===U.id?"rounded animate-highlight-fade":void 0,children:l.jsx(Bk,{message:U,messageIndex:H,sessionId:o,isLastAssistantMessage:!1,promptContext:U.role==="user"?z[U.id]:void 0})})},H)})}),l.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[f&&l.jsx("div",{className:"feed-item bg-red-500/10 border border-red-500/50 rounded p-2",children:l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-red-400 text-sm font-medium",children:f.code}),l.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:f.message})]}),l.jsx($l,{onClick:m,className:"text-red-400 hover:text-red-300 p-0.5",size:"sm"})]})}),D&&l.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:O.map($=>{const H=$.color??"#3b82f6",U=parseInt(H.slice(1,3),16),q=parseInt(H.slice(3,5),16),T=parseInt(H.slice(5,7),16),N=`rgba(${U},${q},${T},0.12)`,F=`rgba(${U},${q},${T},0.22)`,I=`rgba(${U},${q},${T},0.25)`;return l.jsxs("button",{onClick:()=>g($.id),"data-testid":"workflow-run-button",className:"px-4 py-1.5 rounded text-sm font-medium transition-colors",style:{backgroundColor:N,color:H,border:`1px solid ${I}`},onMouseEnter:J=>{J.currentTarget.style.backgroundColor=F},onMouseLeave:J=>{J.currentTarget.style.backgroundColor=N},children:["▶ ",$.name]},$.id)})})]})]})});function RI(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"")}function LI({agent:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:o,onDelete:u}){return l.jsxs(o1,{isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:o,onDelete:u,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),l.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),l.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),e.description&&l.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),l.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[e.allowedTools.slice(0,5).map(d=>l.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:d},d)),e.allowedTools.length>5&&l.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",e.allowedTools.length-5," more"]})]})]})}function kS({title:e,agents:t,subagents:n,isBuiltIn:r,onView:a,onDuplicate:o,onEdit:u,onDelete:d}){if(t.length===0&&n.length===0)return null;const p=f=>l.jsx(LI,{agent:f,isBuiltIn:r,isConfirmingDelete:!1,onView:()=>a(f.id),onEdit:r?void 0:()=>u==null?void 0:u(f.id),onDuplicate:()=>o(f.id),onDelete:r?void 0:()=>d==null?void 0:d(f.id)},f.id);return l.jsxs("div",{children:[l.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),l.jsxs("div",{className:"space-y-2",children:[t.map(p),n.length>0&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:"Sub-agents"}),l.jsx("div",{className:"space-y-2",children:n.map(p)})]})]})]})}function OI({isOpen:e,onClose:t,initialEditId:n}){const r=Lt(ce=>ce.defaults),a=Lt(ce=>ce.userItems),o=Lt(ce=>ce.loading),u=Lt(ce=>ce.fetchAgents),d=Lt(ce=>ce.fetchAgent),p=Lt(ce=>ce.fetchDefaultContent),f=Lt(ce=>ce.createAgent),m=Lt(ce=>ce.updateAgent),g=Lt(ce=>ce.deleteAgent),[v,b]=k.useState("list"),[_,S]=k.useState(null),[j,C]=k.useState(!1),[E,A]=k.useState(""),[O,z]=k.useState(""),[B,Y]=k.useState(""),[ee,ie]=k.useState(!0),[D,$]=k.useState([]),[H,U]=k.useState("#6b7280"),[q,T]=k.useState(""),[N,F]=k.useState(""),[I,J]=k.useState(!1),[R,P]=k.useState([]);function V(ce){const Ae=new Map;for(const Ie of ce){const an=Ie.indexOf(":");if(an===-1)Ae.set(Ie,new Set);else{const le=Ie.slice(0,an),Me=Ie.slice(an+1).split(",").filter(Boolean);Ae.set(le,new Set(Me))}}return Ae}function L(ce){const Ae=[];for(const[Ie,an]of ce)an.size===0?Ae.push(Ie):Ae.push(`${Ie}:${[...an].join(",")}`);return Ae}const G=V(D),W=(ce,Ae)=>{const Ie=new Map(G),an=Ie.get(ce)||new Set,le=new Set(an);le.has(Ae)?le.delete(Ae):le.add(Ae),le.size===0?Ie.set(ce,new Set):Ie.set(ce,le),$(L(Ie))},Z=ce=>{const Ae=new Map(G);Ae.has(ce)?Ae.delete(ce):Ae.set(ce,new Set),$(L(Ae))},se=ce=>{A(ce.metadata.name),z(ce.metadata.id),Y(ce.metadata.description),ie(ce.metadata.subagent),$(ce.metadata.allowedTools),U(ce.metadata.color??"#6b7280"),T(ce.prompt),F("")},ve=(ce,Ae,Ie)=>{A(ce.metadata.name+" (copy)"),z(`${Ae}-copy-${Date.now()}`),Y(ce.metadata.description),ie(ce.metadata.subagent),$(ce.metadata.allowedTools),U(ce.metadata.color??"#6b7280"),T(ce.prompt),F(""),S(null),C(!1),b("edit")},Ce=(ce,Ae)=>{se(ce),S(Ae),C(!0),b("edit")};k.useEffect(()=>{e&&(u(),ke("/api/tools").then(ce=>ce.json()).then(ce=>P(ce.tools||[])).catch(()=>P([])),n?r.some(Ae=>Ae.id===n)?p(n).then(Ae=>{Ae&&ve(Ae,n)}):d(n).then(Ae=>{Ae&&(se(Ae),S(n),C(!1),b("edit"))}):(b("list"),S(null),C(!1)))},[e,u,d,p,n]);const Te=async ce=>{if(r.some(Ie=>Ie.id===ce)){const Ie=await p(ce);if(!Ie)return;Ce(Ie,ce)}else{const Ie=await d(ce);if(!Ie)return;Ce(Ie,ce)}},Pe=async ce=>{const Ae=await p(ce);Ae&&ve(Ae,ce)},$e=()=>{S(null),A(""),z(""),Y(""),ie(!0),$(["read_file"]),U("#6b7280"),T(""),F(""),C(!1),b("edit")},Re=async ce=>{const Ae=await d(ce);Ae&&(se(Ae),S(ce),C(!1),b("edit"))},Xe=async ce=>{await g(ce)},pt=async()=>{const ce=_??O;if(!ce||!E||!q){F("Name and prompt are required.");return}J(!0),F("");const Ae={metadata:{id:ce,name:E,description:B,subagent:ee,allowedTools:D,color:H},prompt:q},Ie=_?await m(_,Ae):await f(Ae);if(J(!1),!Ie.success){F(Ie.error??"Failed to save agent.");return}n?t():b("list")},gt=()=>{n?t():(b("list"),C(!1))},kt=ce=>{A(ce),_||z(RI(ce))},ct=r.filter(ce=>ce.subagent),ut=r.filter(ce=>!ce.subagent),me=a.filter(ce=>ce.subagent),je=a.filter(ce=>!ce.subagent);return v==="edit"?l.jsx(Et,{isOpen:e,onClose:gt,title:j?`${E}`:_?"Edit Agent":"New Agent",size:"xl",children:l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"space-y-3",children:[N&&l.jsx(Um,{message:N}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsx(Hi,{label:"Name",value:E,onChange:kt,placeholder:"My Agent",readOnly:j}),l.jsx(Hi,{label:"ID",value:O,onChange:z,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsx(Hi,{label:"Description",value:B,onChange:Y,placeholder:"What this agent does",readOnly:j}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),l.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[l.jsx("button",{onClick:()=>!j&&ie(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${ee?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${j?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),l.jsx("button",{onClick:()=>!j&&ie(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${ee?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${j?"pointer-events-none opacity-60":""}`,children:"Top-level"}),l.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[l.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),l.jsx("input",{type:"color",value:H,onChange:ce=>!j&&U(ce.target.value),disabled:j,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),l.jsx("div",{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32 overflow-y-auto",children:R.map(ce=>{const Ae=G.has(ce.name),Ie=ce.actions.length>0,an=G.get(ce.name)||new Set,le=l.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${Ae?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[l.jsx("span",{children:ce.name}),Ie&&l.jsx("span",{className:`text-[10px] ${Ae&&an.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]},ce.name);return Ie?j?l.jsxs("button",{className:"px-1.5 py-0.5 rounded text-xs font-mono flex items-center gap-1 bg-bg-primary text-text-muted pointer-events-none opacity-60",children:[l.jsx("span",{children:ce.name}),l.jsx("span",{className:"text-[10px]",children:"*"})]},ce.name):l.jsx(Fl,{trigger:le,minWidth:"160px",items:[...ce.actions.map(xe=>({label:l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${ce.name}-${xe}`,children:[l.jsx("input",{type:"checkbox",id:`${ce.name}-${xe}`,checked:an.has(xe),onChange:()=>W(ce.name,xe),disabled:j,className:"w-3 h-3 rounded accent-accent-primary"}),l.jsx("span",{children:xe})]}),closeOnClick:!1})),{label:Ae?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(Ae)Z(ce.name);else{const xe=new Map(G);xe.set(ce.name,new Set(ce.actions)),$(L(xe))}}}]},ce.name):l.jsx("button",{onClick:()=>!j&&Z(ce.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${Ae?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${j?"pointer-events-none":"cursor-pointer"}`,children:l.jsx("span",{children:ce.name})},ce.name)})})]})]}),l.jsxs("div",{className:"flex-1 min-h-[150px] border-t border-border pt-3 flex flex-col",children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),l.jsx("textarea",{value:q,onChange:ce=>!j&&T(ce.target.value),readOnly:j,placeholder:"Instructions for this agent...",className:`h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary ${j?"opacity-60":""}`})]}),l.jsx(Wj,{onCancel:gt,onSave:pt,saving:I,saveDisabled:!E||!q||j}),j&&l.jsx("div",{className:"flex justify-end mt-2",children:l.jsx(Ye,{variant:"primary",onClick:()=>{A(E+" (copy)"),z(`${_}-copy-${Date.now()}`),S(null),C(!1)},children:"Duplicate & Customize"})})]})}):l.jsxs(Et,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("p",{className:"text-text-secondary text-sm",children:"Agents define behavior, tools, and prompts for top-level modes and sub-agents."}),l.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:l.jsx(Ye,{variant:"primary",size:"sm",onClick:$e,children:"+ New"})})]}),o&&r.length===0&&a.length===0?l.jsx("div",{className:"text-text-muted text-sm",children:"Loading agents..."}):r.length===0&&a.length===0?l.jsx("div",{className:"text-text-muted text-sm",children:"No agents defined."}):l.jsxs("div",{className:"space-y-4",children:[r.length>0&&l.jsx(kS,{title:"Built-in",agents:ut,subagents:ct,isBuiltIn:!0,onView:Te,onDuplicate:Pe}),a.length>0&&l.jsx(kS,{title:"Custom",agents:je,subagents:me,isBuiltIn:!1,onView:Te,onDuplicate:Pe,onEdit:Re,onDelete:Xe})]})]})}function II(){const e=ye(C=>{var E;return(E=C.currentSession)==null?void 0:E.mode}),t=ye(C=>C.switchMode),n=Lt(C=>C.defaults),r=Lt(C=>C.userItems),a=Lt(C=>C.fetchAgents),o=[...n,...r],[u,d]=k.useState(!1),[p,f]=k.useState(!1),[m,g]=k.useState(null),v=k.useRef(null);if(k.useEffect(()=>{a()},[a]),k.useEffect(()=>{function C(E){v.current&&!v.current.contains(E.target)&&d(!1)}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]),!e)return null;const b=o.filter(C=>!C.subagent),_=b.find(C=>C.id===e),S=(_==null?void 0:_.name)??e,j=Vu(o,e);return l.jsxs("div",{className:"relative",ref:v,children:[l.jsxs("button",{type:"button",onClick:()=>d(!u),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[l.jsx("span",{className:"text-sm font-medium",style:{color:j},children:S}),l.jsx(rs,{className:`w-3 h-3 text-text-muted transition-transform ${u?"rotate-180":""}`})]}),u&&b.length>0&&l.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:[b.map((C,E)=>{const A=C.id===e,O=Vu(o,C.id),z=E<4?`Ctrl+${E+1}`:null;return l.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${A?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[l.jsxs("button",{type:"button",onClick:()=>{A||t(C.id),d(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[l.jsx("span",{className:"font-medium truncate",style:{color:O},children:C.name}),A&&l.jsx(ns,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),z&&l.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:["Ctrl+",E+1]})]},C.id)}),l.jsx("div",{className:"border-t border-border p-1",children:l.jsx("button",{type:"button",onClick:()=>{d(!1),f(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),l.jsx(OI,{isOpen:p,onClose:()=>{f(!1),g(null)},initialEditId:m})]})}function BI(){const e=ye(r=>r.currentSession),t=ye(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return l.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[l.jsx("button",{type:"button",onClick:()=>t("normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="normal"?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),l.jsx("button",{type:"button",onClick:()=>t("dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="dangerous"?"bg-red-500/20 text-red-400":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})}function zI({question:e}){const t=ye(u=>u.answerQuestion),[n,r]=k.useState(""),a=()=>{t(e.callId,n)},o=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),a())};return l.jsx(Et,{isOpen:!0,onClose:()=>{},size:"sm",closeOnBackdropClick:!1,closeOnEscape:!1,showCloseButton:!1,children:l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-text-primary",children:e.question}),l.jsx("textarea",{value:n,onChange:u=>r(u.target.value),onKeyDown:o,placeholder:"Type your answer here...",className:"w-full min-h-[120px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:!0}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(Ye,{variant:"secondary",size:"sm",onClick:()=>t(e.callId,""),children:"Skip"}),l.jsx(Ye,{variant:"primary",size:"sm",onClick:a,children:"Send Answer"})]})]})})}function PI(){const e=ye(r=>r.connectionStatus),t=ye(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return l.jsxs("div",{className:`
|
|
162
|
+
flex items-center justify-between px-4 py-2
|
|
163
|
+
text-sm font-medium
|
|
164
|
+
${n?"bg-amber-500/15 border-b border-amber-500/30 text-amber-300":"bg-red-500/15 border-b border-red-500/30 text-red-300"}
|
|
165
|
+
`,children:[l.jsx("div",{className:"flex items-center gap-2",children:n?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"flex gap-1",children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),l.jsx("span",{children:"Reconnecting to server..."})]}):l.jsxs(l.Fragment,{children:[l.jsx(zj,{}),l.jsx("span",{children:"Connection lost"})]})}),l.jsx("button",{onClick:()=>t(),disabled:n,className:`
|
|
166
|
+
px-3 py-1 rounded text-xs font-medium
|
|
167
|
+
transition-colors
|
|
168
|
+
${n?"bg-amber-500/20 text-amber-400 cursor-not-allowed opacity-50":"bg-red-500/20 text-red-300 hover:bg-red-500/30 hover:text-red-200"}
|
|
169
|
+
`,children:n?"Reconnecting...":"Reconnect"})]})}function HI({attachment:e,onRemove:t}){const n=r=>r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`;return l.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[l.jsx($l,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),l.jsx("img",{src:e.data,alt:e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}),l.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),l.jsx("div",{className:"text-[10px] text-text-muted",children:n(e.size)})]})}function FI({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const o=k.useRef(null),u=k.useRef(null);k.useEffect(()=>{u.current&&o.current&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const d=f=>{switch(f.key){case"Enter":f.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":f.preventDefault(),r();break;case"ArrowUp":f.preventDefault(),a("up");break;case"ArrowDown":f.preventDefault(),a("down");break}},p=f=>{n(f)};return l.jsx("div",{ref:o,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg overflow-y-auto max-h-64",onKeyDown:d,children:e.map((f,m)=>l.jsxs("div",{ref:m===t?u:null,role:"listitem",onClick:()=>p(f.content),className:`
|
|
170
|
+
p-2 rounded cursor-pointer transition-colors
|
|
171
|
+
${m===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
|
|
172
|
+
`,children:[l.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[f.formattedTimestamp,f.sessionName&&l.jsxs(l.Fragment,{children:[" | ",l.jsx("span",{className:"text-accent-primary font-medium",children:f.sessionName})]})]}),l.jsx("div",{className:"text-sm text-text-primary mt-1",children:f.trimmedContent})]},f.id))})}function $I(){const e=pj(),t=e?"bg-amber-400":"bg-accent-primary";return l.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs("span",{className:"flex gap-0.5",children:[l.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),l.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),l.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),l.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&l.jsx("span",{className:"text-text-muted",children:"esc to interrupt"})]})}const hn=gr((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await Pm("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await ke(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await ke(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const a=await di("POST","/api/commands",{...n,destination:r});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,r)=>{const a=await di("PUT",`/api/commands/${n}`,r);return a.success&&await t().fetchCommands(),a},deleteCommand:async n=>{try{const r=await ke(`/api/commands/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(o=>({userItems:o.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r)=>Zu(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)})),UI={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function WI(e,t={}){const n={...UI,...t};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=n.maxSizeBytes){const a=await e.arrayBuffer(),o=ZI(a),u=`data:${e.type};base64,${o}`,d=await Pk(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:d.width,height:d.height}}return await qI(e,n)}async function qI(e,t){const n=await KI(e),r=await Pk(n),{width:a,height:o}=VI(r.width,r.height,t.maxWidth,t.maxHeight),u=GI();u.width=a,u.height=o;const d=u.getContext("2d");if(!d)throw new Error("Failed to get canvas context");d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(r,0,0,a,o);let p=t.quality,f="";for(let g=0;g<10&&(f=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,p),!(CS(f)<=t.maxSizeBytes||p<=.3));g++)p-=.1;const m=CS(f);return{dataUrl:f,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:m,width:a,height:o}}function VI(e,t,n,r){const a=e/t;return e>t&&e>n?{width:n,height:Math.round(n/a)}:t>e&&t>r?{width:Math.round(r*a),height:r}:{width:e,height:t}}function KI(e){return new Promise((t,n)=>{const r=XI(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function Pk(e){return new Promise((t,n)=>{const r=YI(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function GI(){var t;const e=Ig();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function YI(){const e=Ig();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function XI(){const e=Ig();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Ig(){return globalThis}function ZI(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const a=t[r];a!==void 0&&(n+=String.fromCharCode(a))}return btoa(n)}function CS(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}function QI(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function JI(e,t=50*1024*1024){return e.size>t?{valid:!1,error:`Image file is too large (${NS(e.size)}). Maximum size is ${NS(t)}.`}:{valid:!0}}function NS(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function vp(e,t,n,r={}){const{maxSizeBytes:a=50*1024*1024,filename:o}=r;if(!QI(e)){n(`Unsupported file type: ${e.type}. Only PNG, JPG, and GIF are supported.`);return}const u=JI(e,a);if(!u.valid){n(u.error??"Image file is too large");return}try{const d=await WI(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),p={id:KS(),filename:o??e.name,mimeType:d.mimeType,size:d.size,data:d.dataUrl};t(p)}catch(d){const p=d instanceof Error?d.message??"Failed to process image":"Failed to process image";n(p)}}function eB({content:e,children:t,position:n="top",delay:r=200}){const[a,o]=k.useState(!1),[u,d]=k.useState({top:0,left:0}),p=k.useRef(void 0),f=k.useRef(null);k.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const m=()=>{p.current=setTimeout(()=>{if(f.current){const b=f.current.getBoundingClientRect();d({top:b.top,left:b.left+b.width/2})}o(!0)},r)},g=()=>{p.current&&clearTimeout(p.current),o(!1)},v=(()=>{switch(n){case"top":return{top:u.top-8,left:u.left,tx:"-50%",ty:"-100%"};case"bottom":return{top:u.top+8,left:u.left,tx:"-50%",ty:"0%"};case"left":return{top:u.top,left:u.left-8,tx:"-100%",ty:"-50%"};case"right":return{top:u.top,left:u.left+8,tx:"0%",ty:"-50%"}}})();return l.jsxs(l.Fragment,{children:[l.jsx("span",{ref:f,className:"inline-flex",onMouseEnter:m,onMouseLeave:g,onFocus:m,onBlur:g,children:t}),a&&Ja.createPortal(l.jsx("div",{className:"fixed z-[9999] px-4 py-3 text-sm text-text-primary bg-bg-secondary border border-border rounded-lg shadow-xl max-w-sm break-words pointer-events-none",style:{top:v.top,left:v.left,transform:`translate(${v.tx}, ${v.ty})`},children:e}),document.body)]})}function _p(e){return{contextWindow:e.contextWindow,temperature:e.temperature??null,topP:e.topP??null,topK:e.topK??null,maxTokens:e.maxTokens??null,supportsVision:e.supportsVision??null}}function tB({label:e,children:t}){return l.jsxs("div",{className:"space-y-3",children:[l.jsx("h4",{className:"text-sm font-medium text-text-secondary border-b border-border/50 pb-1",children:e}),t]})}function hl({label:e,value:t,onChange:n,min:r,max:a,step:o=1,helpText:u,defaultValue:d,profileDefault:p,tooltip:f}){const[m,g]=k.useState((t==null?void 0:t.toString())??""),[v,b]=k.useState(t===null);k.useEffect(()=>{g((t==null?void 0:t.toString())??""),b(t===null)},[t]);const _=C=>{if(g(C),C==="")n(null);else{const E=parseFloat(C);isNaN(E)||n(E)}},S=()=>{v?(b(!1),d!==void 0&&(g(d.toString()),n(d))):(b(!0),n(null))},j=l.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary mb-1",children:[f&&l.jsx(eB,{content:f,children:l.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-xs text-text-muted hover:text-text-secondary cursor-help rounded-full border border-border/50",children:"?"})}),e,l.jsx("button",{type:"button",onClick:S,className:`text-xs px-1.5 py-0.5 rounded border ${v?"border-accent-primary/50 bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-secondary"}`,title:v?"Click to set a custom value":"Click to use default",children:v?"default":"custom"})]});return l.jsxs("div",{children:[j,l.jsx("input",{type:"number",min:r,max:a,step:o,value:m,readOnly:v,onChange:C=>_(C.target.value),onClick:()=>v&&S(),placeholder:v?`${p!==void 0?p:"Using default"} (click to edit)`:"",className:`w-full bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary focus:outline-none focus:border-accent-primary ${v?"opacity-50 cursor-pointer":""}`}),u&&l.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[l.jsx("p",{className:"text-xs text-text-muted",children:u}),p!==void 0&&l.jsxs("span",{className:"text-xs text-text-muted/60",children:["(default: ",p,")"]})]}),!u&&p!==void 0&&l.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Profile default: ",p]})]})}function nB({isOpen:e,onClose:t,providerId:n,model:r}){const[a,o]=k.useState(()=>_p(r)),[u,d]=k.useState(!1),p=Mt(g=>g.updateModelSettings);k.useEffect(()=>{o(_p(r))},[r]);const f=async()=>{if(a.contextWindow<1024||a.contextWindow>1e7)return;d(!0);const g=a.temperature!==(r.temperature??null)||a.topP!==(r.topP??null)||a.topK!==(r.topK??null)||a.maxTokens!==(r.maxTokens??null)||a.supportsVision!==(r.supportsVision??null);await p(n,r.id,{contextWindow:a.contextWindow,...g&&{temperature:a.temperature,topP:a.topP,topK:a.topK,maxTokens:a.maxTokens,supportsVision:a.supportsVision??void 0}}),d(!1),t()},m=()=>{o(_p(r)),t()};return e?l.jsx(Et,{isOpen:e,onClose:t,title:"Model Properties",size:"lg",footer:l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(Ye,{variant:"secondary",onClick:m,disabled:u,children:"Cancel"}),l.jsx(Ye,{variant:"primary",onClick:f,disabled:u||a.contextWindow<1024||a.contextWindow>1e7,children:u?"Saving...":"Save"})]}),children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Model Name"}),l.jsx("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded font-mono text-sm break-all",children:r.id})]}),l.jsx(hl,{label:"Context Window",value:a.contextWindow,onChange:g=>g!==null&&o(v=>({...v,contextWindow:g})),min:1024,max:1e7,helpText:"Range: 1,024 - 10,000,000 tokens"}),l.jsxs(tB,{label:"Sampling Parameters",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsx(hl,{label:"Temperature",value:a.temperature,onChange:g=>o(v=>({...v,temperature:g})),min:0,max:2,step:.1,helpText:"0.0 - 2.0",defaultValue:1,profileDefault:r.defaultTemperature,tooltip:"How random the response is. Low (0.1-0.3) = precise and predictable. High (0.7-1.5) = creative and varied."}),l.jsx(hl,{label:"Top P",value:a.topP,onChange:g=>o(v=>({...v,topP:g})),min:0,max:1,step:.05,helpText:"0.0 - 1.0",defaultValue:1,profileDefault:r.defaultTopP,tooltip:"How to pick the next word. Low (0.5-0.8) = stick to obvious choices. High (0.95-1.0) = allow surprising words."})]}),l.jsx(hl,{label:"Top K",value:a.topK,onChange:g=>o(v=>({...v,topK:g})),min:1,max:200,helpText:"1 - 200 (leave as default if not supported)",profileDefault:r.defaultTopK,tooltip:"Restricts word choices to the top K most likely ones. Low (10-20) = focused. High (50-200) = diverse. Not all backends support this."})]}),l.jsx(hl,{label:"Max Tokens",value:a.maxTokens,onChange:g=>o(v=>({...v,maxTokens:g})),min:256,max:32e3,helpText:"Maximum tokens to generate per response",profileDefault:r.defaultMaxTokens,tooltip:"Longest response length. Higher values let the model write more, but use up your context window faster."}),l.jsxs("div",{children:[l.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary mb-1",children:[l.jsx("input",{type:"checkbox",checked:a.supportsVision??!1,onChange:g=>o(v=>({...v,supportsVision:g.target.checked})),className:"rounded border-border bg-bg-tertiary text-accent-primary focus:ring-accent-primary focus:ring-offset-0"}),"Vision Enabled"]}),l.jsx("p",{className:"text-xs text-text-muted",children:"Allow sending images directly to this model. Disable if the model doesn't support vision."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Source"}),l.jsxs("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded text-sm",children:[r.source==="backend"&&"Auto-detected from backend",r.source==="user"&&"Manually set",r.source==="default"&&"Default value"]})]})]})}):null}function rB(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function sB(){var F;const[,e]=Hr(),t=ye(I=>I.currentSession),n=ye(I=>I.setSessionProvider),[r,a]=k.useState(!1),[o,u]=k.useState([]),[d,p]=k.useState(null),f=k.useRef(null),[m,g]=k.useState(null),v=k.useRef(new Set),b=Mt(I=>I.providers),_=Mt(I=>I.activeProviderId),S=Mt(I=>I.defaultModelSelection);Mt(I=>I.backend);const j=Mt(I=>I.activating),C=Mt(I=>I.activateProvider),E=Mt(I=>I.refreshModel),A=Mt(I=>I.refreshProviderModels);k.useEffect(()=>{function I(J){f.current&&!f.current.contains(J.target)&&(a(!1),u([]),v.current=new Set)}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]),k.useEffect(()=>{if(r){const I=b.map(J=>J.id);u(I),I.forEach(J=>{v.current.has(J)||(v.current.add(J),ie(J))})}},[r,b]);const O=b.find(I=>I.id===_),z=(O==null?void 0:O.status)==="disconnected",B=S?S.split("/").pop()??null:null,Y=B?((F=B.split("/").pop())==null?void 0:F.replace(/-/g," "))??B:"detecting...",ee=(I,J)=>S?S===`${I}/${J}`:!1,ie=async I=>{p(I);try{await A(I)}catch{}finally{p(null)}},D=I=>{o.includes(I.id)?u(o.filter(J=>J!==I.id)):(u([...o,I.id]),ie(I.id))},$=async I=>{if(I.id===_){D(I);return}t?(n(I.id,void 0),Mt.getState().syncFromSession(I.id,""),a(!1),u([])):await C(I.id)&&(a(!1),u([]))},H=I=>{D(I)},U=async(I,J)=>{I.stopPropagation(),v.current.delete(J),await A(J),await ie(J)},q=(I,J)=>{g({providerId:I,model:J})},T=()=>{g(null)},N=async(I,J)=>{if(t){n(I,J),Mt.getState().syncFromSession(I,J),u([]),a(!1);return}p("activating");try{Mt.getState().syncFromSession(I,J),u([]),a(!1);const R=await ke(`/api/providers/${I}/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:J})});if(R.ok){const P=await R.json();Mt.getState().syncFromSession(P.activeProviderId,P.model)}}catch{}finally{p(null)}};return b.length===0?l.jsxs("button",{type:"button",onClick:()=>E(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:z?"LLM server is offline. Click to retry.":B??"Click to refresh model",children:[z?l.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):l.jsx("span",{className:"text-sm text-accent-primary",children:Y}),l.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):l.jsxs("div",{className:"relative",ref:f,children:[l.jsxs("button",{type:"button",onClick:()=>a(!r),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[z?l.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):l.jsx("span",{className:"text-sm text-accent-primary",children:Y}),l.jsx(rs,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&l.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-72 bg-bg-secondary border border-border rounded-lg shadow-lg z-50 overflow-hidden max-h-[80vh] overflow-y-auto",children:[l.jsx("div",{className:"py-1",children:b.map(I=>{var J;return l.jsxs("div",{children:[l.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${I.id===_?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${j?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[l.jsxs("div",{onClick:()=>!j&&$(I),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[l.jsx("span",{className:`text-sm font-medium truncate ${I.id===_?"text-accent-primary":"text-text-primary"}`,children:I.name}),l.jsx("span",{className:"text-xs text-text-muted truncate",children:I.backend!=="auto"&&ZN(I.backend)})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[I.id===_?l.jsx("span",{className:"text-accent-success",title:"Active",children:l.jsx(ns,{className:"w-4 h-4"})}):l.jsx("span",{className:"w-4"}),l.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),U(R,I.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:l.jsx(n1,{className:`w-4 h-4 ${d===I.id?"animate-spin":""} ${I.id===_?"text-accent-primary":"text-text-muted"}`})}),l.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),H(I)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:l.jsx(rs,{className:`w-4 h-4 transition-transform ${o.includes(I.id)?"rotate-180":""} ${I.id===_?"text-accent-primary":"text-text-muted"}`})})]})]}),o.includes(I.id)&&l.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:d===I.id?l.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):(J=I.models)!=null&&J.length?I.models.map(R=>{var P;return l.jsxs("button",{type:"button",onClick:()=>N(I.id,R.id),disabled:d==="activating",className:`w-full px-4 py-1.5 text-left hover:bg-bg-tertiary transition-colors text-sm flex items-center justify-between group ${d==="activating"?"opacity-50 cursor-wait":""} ${ee(I.id,R.id)?"text-accent-primary":"text-text-secondary"}`,children:[l.jsx("span",{className:"truncate flex-1",children:((P=R.id.split("/").pop())==null?void 0:P.replace(/-/g," "))??R.id}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx("span",{className:"text-xs text-text-muted",children:rB(R.contextWindow)}),l.jsx("button",{type:"button",onClick:V=>{V.stopPropagation(),q(I.id,R)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:l.jsx(wj,{className:"w-3 h-3 text-text-muted"})})]}),ee(I.id,R.id)&&l.jsx("span",{className:"text-accent-success flex-shrink-0 ml-1",children:l.jsx(ns,{className:"w-3.5 h-3.5"})})]},R.id)}):l.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},I.id)})}),l.jsx("div",{className:"border-t border-border px-3 py-2",children:l.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),m&&l.jsx(nB,{isOpen:!0,onClose:T,providerId:m.providerId,model:m.model})]})}function iB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function aB({onClick:e}){return l.jsx("button",{type:"button",onClick:e,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:l.jsx(Qu,{})})}function Hk({isOpen:e,onClose:t,initialEditId:n}){const r=hn(me=>me.defaults),a=hn(me=>me.userItems),o=hn(me=>me.projectItems),u=hn(me=>me.loading),d=hn(me=>me.fetchCommands),p=hn(me=>me.fetchCommand),f=hn(me=>me.fetchDefaultContent),m=hn(me=>me.createCommand),g=hn(me=>me.updateCommand),v=hn(me=>me.deleteCommand),[b,_]=k.useState(null),[S,j]=k.useState(null),{view:C,editingId:E,formError:A,saving:O,formData:z,setView:B,setEditingId:Y,setFormError:ee,setFormData:ie,setSaving:D}=u1(),{requestDelete:$,clearConfirm:H,isConfirming:U}=Hm(),q=k.useRef(!1),T=Lt(me=>me.defaults),N=Lt(me=>me.userItems),F=Lt(me=>me.fetchAgents),J=[...T,...N].filter(me=>!me.subagent),R=k.useRef(d),P=k.useRef(F),V=k.useRef(p),L=k.useRef(f),G=k.useRef(n),W=k.useRef(B),Z=k.useRef(Y),se=k.useRef(ee),ve=k.useRef(H);k.useEffect(()=>{R.current=d,P.current=F,V.current=p,L.current=f,G.current=n,W.current=B,Z.current=Y,se.current=ee,ve.current=H}),k.useEffect(()=>{if(e)if(R.current(),P.current(),q.current||(ve.current(),q.current=!0),G.current){const me=r.some(je=>je.id===G.current);W.current("edit"),Z.current(G.current),se.current(""),me?L.current(G.current).then(je=>{je&&ie({name:je.metadata.name+" (copy)",id:`${G.current}-copy-${Date.now()}`,prompt:je.prompt,agentMode:je.metadata.agentMode??"",isDefault:!0,destination:"user"})}):V.current(G.current).then(je=>{je&&ie({name:je.metadata.name,id:je.metadata.id,prompt:je.prompt,agentMode:je.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else W.current("list"),Z.current(null);else q.current=!1},[e]);const Ce=async me=>{_(me);const je=await f(me);j((je==null?void 0:je.prompt)??null)},Te=async me=>{if(r.some(ce=>ce.id===me)){const ce=await f(me);ce&&(Y(null),ie({name:`${ce.metadata.name} (copy)`,id:`${me}-copy-${Date.now()}`,prompt:ce.prompt,agentMode:ce.metadata.agentMode??"",isDefault:!0,destination:"user"}),ee(""),B("edit"))}else{const ce=await p(me);ce&&(Y(null),ie({name:`${ce.metadata.name} (copy)`,id:`${me}-copy-${Date.now()}`,prompt:ce.prompt,agentMode:ce.metadata.agentMode??"",isDefault:!1,destination:"user"}),ee(""),B("edit"))}},Pe=()=>{ie({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),Y(null),B("edit")},$e=async me=>{const je=await p(me);je&&(Y(me),ie({name:je.metadata.name,id:je.metadata.id,prompt:je.prompt,agentMode:je.metadata.agentMode??"",isDefault:!1,destination:"user"}),ee(""),B("edit"))},Re=async me=>{await v(me),H()},Xe=async()=>{const me=E??z.id;if(!me||!z.name||!z.prompt){ee("Name and message are required.");return}D(!0),ee("");const je={metadata:{id:me,name:z.name,...z.agentMode?{agentMode:z.agentMode}:{}},prompt:z.prompt},ce=E?await g(E,je):await m(je,z.destination);if(D(!1),!ce.success){ee(ce.error??"Failed to save command.");return}n?t():B("list")},pt=()=>{n?t():(B("list"),_(null),j(null))},gt=me=>{ie(je=>({...je,name:me})),(!E||z.isDefault)&&ie(je=>({...je,id:iB(me)}))},kt=()=>{_(null),j(null),B("list")},ct=()=>{b&&(_(null),B("edit"),Y(b),f(b).then(me=>{me&&ie({name:`${me.metadata.name} (copy)`,id:`${b}-copy-${Date.now()}`,prompt:me.prompt,agentMode:me.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(b){const me=r.find(je=>je.id===b);return l.jsx(Et,{isOpen:e,onClose:kt,title:`Default: ${(me==null?void 0:me.name)??b}`,size:"xl",children:l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"space-y-3 mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[l.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),l.jsx("span",{className:"font-mono",children:b})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),l.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:me==null?void 0:me.name})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),l.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(me==null?void 0:me.agentMode)||"None"})]})]}),l.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),l.jsx("textarea",{value:S??"",readOnly:!0,placeholder:"...",className:"flex-1 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none opacity-60"})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[l.jsx(Ye,{variant:"secondary",onClick:kt,children:"Close"}),l.jsx(Ye,{variant:"primary",onClick:ct,children:"Duplicate & Customize"})]})]})})}if(C==="edit")return l.jsx(Et,{isOpen:e,onClose:pt,title:E?"Edit Command":"New Command",size:"xl",children:l.jsxs("div",{className:"flex flex-col h-full",children:[A&&l.jsx(Um,{message:A}),l.jsxs("div",{className:"space-y-3 mb-3",children:[l.jsx(c1,{name:z.name,id:z.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!E&&!z.isDefault,onNameChange:gt,onIdChange:me=>ie(je=>({...je,id:me}))}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",l.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),l.jsxs("select",{value:z.agentMode,onChange:me=>ie(je=>({...je,agentMode:me.target.value})),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[l.jsx("option",{value:"",children:"None (keep current mode)"}),J.map(me=>l.jsx("option",{value:me.id,children:me.name},me.id))]})]}),!E&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),l.jsxs("select",{value:z.destination,onChange:me=>ie(je=>({...je,destination:me.target.value})),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[l.jsx("option",{value:"user",children:"Global config"}),l.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})]}),l.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[l.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),l.jsx("textarea",{value:z.prompt,onChange:me=>ie(je=>({...je,prompt:me.target.value})),placeholder:"The message that will be sent when this command is triggered...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[l.jsx(Ye,{variant:"secondary",onClick:pt,children:"Cancel"}),l.jsx(Ye,{variant:"primary",onClick:Xe,disabled:O||!z.name||!z.prompt,children:O?"Saving...":"Save"})]})]})});const ut=me=>me.map(je=>l.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[l.jsx("div",{className:"min-w-0 flex-1 mr-3",children:l.jsx("div",{className:"flex items-center gap-2",children:l.jsx("span",{className:"text-text-primary text-sm font-medium",children:je.name})})}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[l.jsx(Ya,{onClick:()=>$e(je.id)}),l.jsx(Nl,{onClick:()=>Te(je.id)}),U(je.id,"delete")?l.jsx(Fm,{onConfirm:()=>Re(je.id),onCancel:H}):l.jsx($m,{onClick:()=>$(je.id)})]})]},je.id));return l.jsxs(Et,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[l.jsx(a1,{description:"Commands are pre-defined messages you can send with a single click.",onNew:Pe}),l.jsxs(l1,{loading:u,hasItems:r.length>0||a.length>0||o.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),l.jsx("div",{className:"space-y-2",children:r.map(me=>l.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[l.jsx("div",{className:"min-w-0 flex-1 mr-3",children:l.jsx("span",{className:"text-text-primary text-sm font-medium",children:me.name})}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[l.jsx(aB,{onClick:()=>Ce(me.id)}),l.jsx(Nl,{onClick:()=>Te(me.id)})]})]},me.id))})]}),a.length>0&&l.jsx(i1,{children:ut(a)}),o.length>0&&l.jsxs("div",{className:"mt-4",children:[l.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),l.jsx("div",{className:"space-y-2",children:ut(o)})]})]})]})}function oB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function lB(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const cB=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}],Fk={all_criteria_passed:"All passed",all_criteria_completed_or_passed:"All completed",any_criteria_blocked:"Blocked",has_pending_criteria:"Pending/Failed",step_result:"Result",always:"Always"},$k=[{value:"all_criteria_passed",label:"All criteria passed"},{value:"all_criteria_completed_or_passed",label:"All criteria completed or passed"},{value:"any_criteria_blocked",label:"Any criteria blocked (retry limit)"},{value:"has_pending_criteria",label:"Has pending or failed criteria"},{value:"step_result",label:"Step result is..."},{value:"always",label:"Always (fallback)"}],Ri=150,Ns=54,Fa=80,hr=30,$a=70,jS=100,Li=50,Su=50,ES=4;function Bg(e,t){if(e.type==="agent"){const n=t.find(r=>r.id===e.toolMode);return{name:(n==null?void 0:n.name)??(e.toolMode||"Agent"),color:(n==null?void 0:n.color)||"#3b82f6"}}if(e.type==="sub_agent"){const n=t.find(r=>r.id===e.subAgentType);return{name:(n==null?void 0:n.name)??(e.subAgentType||"Sub-Agent"),color:(n==null?void 0:n.color)||"#a855f7"}}return{name:"Shell",color:"#22c55e"}}function uB(e,t,n,r){const a=Su+Li+Ri+jS+Ri+Li+Su,o=a/2,u=Su+Li+Ri/2,d=Su+Li+Ri+jS+Ri/2,p=[],f=[],m=new Map,g=e.filter(q=>q.type==="agent"||q.type==="shell"),v=e.filter(q=>q.type==="sub_agent"),b=v.length>0,_=b?u:o,S=g.length>0?d:o,j=Li+hr/2;if(p.push({id:"$start",type:"terminal",label:"Start",cx:_,cy:j,w:Fa,h:hr}),m.set("$start",{cx:_,cy:j,w:Fa,h:hr}),e.length===0){const q=j+hr/2+$a*2+hr/2;return p.push({id:"$done",type:"terminal",label:"Done",cx:_,cy:q,w:Fa,h:hr}),m.set("$done",{cx:_,cy:q,w:Fa,h:hr}),{nodes:p,edges:f,width:a,height:q+hr/2+Li,posMap:m}}const C=j+hr/2+$a,E=(q,T)=>{q.forEach((N,F)=>{const I=C+F*(Ns+$a)+Ns/2,{name:J,color:R}=Bg(N,r);p.push({id:N.id,type:"step",label:J,color:R,cx:T,cy:I,w:Ri,h:Ns}),m.set(N.id,{cx:T,cy:I,w:Ri,h:Ns})})};E(g,_),E(v,S);const A=g.length>0?C+(g.length-1)*(Ns+$a)+Ns/2:j,O=b?C+(v.length-1)*(Ns+$a)+Ns/2:j,z=Math.max(A,O)+Ns/2+$a+hr/2;p.push({id:"$done",type:"terminal",label:"Done",cx:_,cy:z,w:Fa,h:hr}),m.set("$done",{cx:_,cy:z,w:Fa,h:hr});const B=[];t&&m.has(t)&&B.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let Y=0;for(const q of e)q.transitions.forEach((T,N)=>{if(!T.goto||!m.has(T.goto))return;const F=m.get(q.id),I=m.get(T.goto),J=T.when.type==="step_result"?`${T.when.result}`:Fk[T.when.type]??T.when.type,R=q.id===T.goto;let P;R?P="back":I.cy>F.cy+1?P="down":I.cy<F.cy-1?P="back":P="same",B.push({from:q.id,to:T.goto,label:J,edgeKey:`${q.id}:${N}`,direction:P,backEdgeIndex:P==="back"?Y++:0})});const ee=new Map,ie=new Map,D=new Map,$=new Map;for(const q of B)q.direction==="down"&&(ee.set(q.from,(ee.get(q.from)??0)+1),ie.set(q.to,(ie.get(q.to)??0)+1));const H=new Map,U=new Map;for(const q of B){if(q.direction!=="same")continue;const T=[q.from,q.to].sort().join("|");H.set(T,(H.get(T)??0)+1)}for(const q of B){if(q.direction==="back"||q.direction==="same"){let P=0;if(q.direction==="same"){const V=[q.from,q.to].sort().join("|");P=U.get(V)??0,U.set(V,P+1)}f.push({...q,fromPort:0,toPort:0,sameEdgeIndex:P});continue}const T=ee.get(q.from)??1,N=ie.get(q.to)??1,F=D.get(q.from)??0,I=$.get(q.to)??0;D.set(q.from,F+1),$.set(q.to,I+1);const J=T===1?0:-.6+1.2*F/(T-1),R=N===1?0:-.6+1.2*I/(N-1);f.push({...q,fromPort:J,toPort:R,sameEdgeIndex:0})}return{nodes:p,edges:f,width:a,height:z+hr/2+Li,posMap:m}}function dB({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:o,isReadOnly:u,onSelectNode:d,onSelectEdge:p,onRemoveStep:f,onCreateTransition:m,onReconnectTo:g,onReconnectFrom:v,onDeleteTransition:b}){const _=k.useRef(null),S=k.useRef(!1),[j,C]=k.useState(null),[E,A]=k.useState(null),[O,z]=k.useState(null),{nodes:B,edges:Y,width:ee,height:ie,posMap:D}=k.useMemo(()=>uB(e,t,a,o),[e,t,a,o]),$=k.useCallback(W=>{var Te;const Z=_.current;if(!Z)return{x:0,y:0};const se=Z.createSVGPoint();se.x=W.clientX,se.y=W.clientY;const ve=(Te=Z.getScreenCTM())==null?void 0:Te.inverse();if(!ve)return{x:0,y:0};const Ce=se.matrixTransform(ve);return{x:Ce.x,y:Ce.y}},[]),H=k.useCallback(W=>!W||!E||W==="$start"?!1:E.type==="reconnect-from"?W!=="$done":!0,[E]),U=k.useCallback((W,Z)=>{if(u)return;W.stopPropagation(),W.preventDefault();const se=$(W);A({type:"new",fromNodeId:Z,mouseX:se.x,mouseY:se.y})},[$,u]),q=k.useCallback((W,Z)=>{if(u)return;W.stopPropagation(),W.preventDefault();const se=$(W);A({type:"reconnect-to",fromNodeId:Z.from,edgeKey:Z.edgeKey,mouseX:se.x,mouseY:se.y})},[$,u]),T=k.useCallback((W,Z)=>{if(u)return;W.stopPropagation(),W.preventDefault();const se=$(W);A({type:"reconnect-from",fromNodeId:Z.from,fixedTargetId:Z.to,edgeKey:Z.edgeKey,mouseX:se.x,mouseY:se.y})},[$,u]),N=k.useCallback(W=>{if(!E)return;const Z=$(W);A(se=>se?{...se,mouseX:Z.x,mouseY:Z.y}:null)},[E,$]),F=k.useCallback(()=>{E&&(S.current=!0,O&&H(O)&&(E.type==="new"?m(E.fromNodeId,O):E.type==="reconnect-to"?g(E.edgeKey,O):E.type==="reconnect-from"&&v(E.edgeKey,O)),A(null),z(null))},[E,O,H,m,g,v]),I=k.useCallback(()=>{if(S.current){S.current=!1;return}d(null),p(null)},[d,p]);k.useEffect(()=>{if(u)return;const W=Z=>{Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||Z.target instanceof HTMLSelectElement||(Z.key==="Delete"||Z.key==="Backspace")&&r&&r!=="start"&&(Z.preventDefault(),b(r),p(null))};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[u,r,b,p]);const J=W=>{const Z=D.get(W.from),se=D.get(W.to);if(!Z||!se)return null;let ve,Ce,Te,Pe="middle",$e,Re;if(W.direction==="down"){const Xe=Z.cx+W.fromPort*(Z.w/2-10),pt=Z.cy+Z.h/2,gt=se.cx+W.toPort*(se.w/2-10),kt=se.cy-se.h/2,ct=kt-pt,ut=gt-Xe;ve=`M ${Xe} ${pt} C ${Xe} ${pt+ct*.4}, ${gt-ut*.2} ${kt-ct*.1}, ${gt} ${kt}`,Ce=Xe+(gt-Xe)*.5,Te=pt+ct*.6,$e={x:Xe,y:pt},Re={x:gt,y:kt}}else if(W.direction==="back"){const Xe=W.from===W.to,pt=Z.cx>=ee/2,gt=W.backEdgeIndex*16,kt=pt?ee-20-gt:20+gt;if(Xe){const ct=Z.cx>=ee/2,ut=30+W.backEdgeIndex*14,me=Z.cy-Z.h/2,je=ct?Z.cx+Z.w/2:Z.cx-Z.w/2,ce=ct?je+ut:je-ut,Ae=Z.cx+(ct?Z.w/4:-Z.w/4),Ie=me-20-W.backEdgeIndex*10;ve=`M ${je} ${Z.cy} C ${ce} ${Z.cy}, ${ce} ${Ie}, ${Ae} ${me}`,Ce=ce+10,Te=Ie+4,Pe="middle",$e={x:je,y:Z.cy},Re={x:Ae,y:me}}else{const ct=pt?Z.cx+Z.w/2:Z.cx-Z.w/2,ut=se.cx+(pt?se.w/4:-se.w/4),me=Math.min(Z.cy,se.cy)-se.h/2-18-W.backEdgeIndex*14;ve=`M ${ct} ${Z.cy} L ${kt} ${Z.cy} L ${kt} ${me} L ${ut} ${me} L ${ut} ${se.cy-se.h/2}`,Ce=kt,Te=(Z.cy+me)/2,Pe=pt?"start":"end",$e={x:ct,y:Z.cy},Re={x:ut,y:se.cy-se.h/2}}}else{const Xe=se.cx>Z.cx,pt=W.sameEdgeIndex===0?-12:12,gt=Xe?Z.cx+Z.w/2:Z.cx-Z.w/2,kt=Xe?se.cx-se.w/2:se.cx+se.w/2,ct=Z.cy+pt,ut=se.cy+pt,me=(gt+kt)/2;ve=`M ${gt} ${ct} C ${me} ${ct}, ${me} ${ut}, ${kt} ${ut}`,Ce=me,Te=(ct+ut)/2-6,$e={x:gt,y:ct},Re={x:kt,y:ut}}return{path:ve,labelX:Ce,labelY:Te,labelAnchor:Pe,fromPt:$e,toPt:Re}},R=(W,Z)=>{const se=J(W);if(!se)return null;const{path:ve,labelX:Ce,labelY:Te,labelAnchor:Pe}=se,$e=r===W.edgeKey,Re=W.label&&!(W.from==="$start"&&W.label==="Always");return l.jsxs("g",{children:[l.jsx("path",{d:ve,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Xe=>{Xe.stopPropagation(),p($e?null:W.edgeKey)}}),l.jsx("path",{d:ve,fill:"none",stroke:$e?"#58a6ff":"#484f58",strokeWidth:$e?2.2:1.2,markerEnd:$e?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),Re&&l.jsx("text",{x:Ce+(Pe==="start"?5:Pe==="end"?-5:0),y:Te+3,textAnchor:Pe,className:"text-[8px]",fill:$e?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:W.label})]},Z)},P=()=>{if(!r||E)return null;const W=Y.find(Te=>Te.edgeKey===r);if(!W)return null;const Z=J(W);if(!Z)return null;const{fromPt:se,toPt:ve}=Z,Ce=6;return l.jsxs(l.Fragment,{children:[W.edgeKey!=="start"&&l.jsx("circle",{cx:se.x,cy:se.y,r:Ce,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:Te=>T(Te,W)}),l.jsx("circle",{cx:ve.x,cy:ve.y,r:Ce,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:Te=>q(Te,W)})]})},V=()=>{if(!E)return null;let W,Z,se,ve;if(E.type==="reconnect-from"){const Pe=D.get(E.fixedTargetId);if(!Pe)return null;W=E.mouseX,Z=E.mouseY,se=Pe.cx,ve=Pe.cy-Pe.h/2}else{const Pe=D.get(E.fromNodeId);if(!Pe)return null;W=Pe.cx,Z=Pe.cy+Pe.h/2,se=E.mouseX,ve=E.mouseY}const Ce=ve-Z,Te=Math.abs(Ce)>10?`M ${W} ${Z} C ${W} ${Z+Ce*.4}, ${se} ${ve-Ce*.4}, ${se} ${ve}`:`M ${W} ${Z} L ${se} ${ve}`;return l.jsx("path",{d:Te,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},L=W=>{const Z=W.cy+W.h/2,se=(E==null?void 0:E.fromNodeId)===W.id;return l.jsx("circle",{cx:W.cx,cy:Z,r:ES,fill:se?"#58a6ff":"#1c2128",stroke:se?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:se?1:.5,className:"cursor-crosshair",onMouseDown:ve=>U(ve,W.id)})},G=W=>{const Z=W.cy-W.h/2,se=E&&O===W.id&&H(W.id);return l.jsx("circle",{cx:W.cx,cy:Z,r:ES,fill:se?"#3fb950":"#1c2128",stroke:se?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:se?1:.5})};return l.jsxs("svg",{ref:_,viewBox:`0 0 ${ee} ${ie}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:N,onMouseUp:F,onClick:I,children:[l.jsxs("defs",{children:[l.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:l.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),l.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:l.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),Y.map((W,Z)=>R(W,Z)),B.map(W=>{const Z=n===W.id,se=W.cx-W.w/2,ve=W.cy-W.h/2,Ce=j===W.id,Te=E&&O===W.id&&H(W.id);if(W.type==="terminal"){const $e=W.id==="$start",Re=$e?"#58a6ff":"#3fb950",Xe=$e,pt=!$e;return l.jsxs("g",{onClick:gt=>{gt.stopPropagation(),$e&&!u&&p("start")},className:$e&&!u?"cursor-pointer":void 0,children:[Te&&l.jsx("rect",{x:se-3,y:ve-3,width:W.w+6,height:W.h+6,rx:W.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),$e&&r==="start"&&l.jsx("rect",{x:se-3,y:ve-3,width:W.w+6,height:W.h+6,rx:W.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),l.jsx("rect",{x:se,y:ve,width:W.w,height:W.h,rx:W.h/2,fill:Re,fillOpacity:.08,stroke:Re,strokeOpacity:.4,strokeWidth:1.5}),l.jsx("text",{x:W.cx,y:W.cy+4,textAnchor:"middle",fill:Re,className:"text-[10px] font-medium",pointerEvents:"none",children:W.label}),Xe&&L(W),pt&&G(W)]},W.id)}const Pe=W.color??"#6b7280";return l.jsxs("g",{onClick:$e=>{$e.stopPropagation(),u||d(Z?null:W.id)},onMouseEnter:()=>C(W.id),onMouseLeave:()=>C(null),className:u?void 0:"cursor-pointer",children:[Te&&l.jsx("rect",{x:se-3,y:ve-3,width:W.w+6,height:W.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),Z&&l.jsx("rect",{x:se-3,y:ve-3,width:W.w+6,height:W.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),l.jsx("rect",{x:se,y:ve,width:W.w,height:W.h,rx:10,fill:Pe,fillOpacity:.08,stroke:Pe,strokeOpacity:.6,strokeWidth:Z?2:1.5}),l.jsx("text",{x:W.cx,y:W.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:W.label}),!u&&L(W),!u&&G(W),Ce&&!E&&!u&&l.jsxs("g",{onClick:$e=>{$e.stopPropagation(),f(W.id)},className:"cursor-pointer",children:[l.jsx("circle",{cx:se+W.w-2,cy:ve+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),l.jsx("line",{x1:se+W.w-5,y1:ve-1,x2:se+W.w+1,y2:ve+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx("line",{x1:se+W.w+1,y1:ve-1,x2:se+W.w-5,y2:ve+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},W.id)}),E&&B.map(W=>H(W.id)?l.jsx("rect",{x:W.cx-W.w/2-8,y:W.cy-W.h/2-8,width:W.w+16,height:W.h+16,fill:"transparent",rx:12,onMouseEnter:()=>z(W.id),onMouseLeave:()=>z(null),onMouseUp:Z=>{Z.stopPropagation(),F()}},`drop-${W.id}`):null),V(),P()]})}const zr="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Ui="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Rn="block text-[11px] text-text-secondary mb-0.5";function hB({fromLabel:e,toLabel:t,condition:n,fromStep:r,agentTypes:a,onUpdateCondition:o,onDelete:u}){const d=r&&(r.type==="sub_agent"||r.type==="agent")?a.find(f=>f.id===(r.type==="sub_agent"?r.subAgentType:r.toolMode)):void 0,p=(d==null?void 0:d.results)&&d.results.length>0;return l.jsxs("div",{className:"space-y-3 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:"Transition"}),l.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),l.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[l.jsx("span",{className:"font-medium text-text-primary",children:e}),l.jsx(e1,{}),l.jsx("span",{className:"font-medium text-text-primary",children:t})]}),l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Condition"}),l.jsx("select",{value:n.type,onChange:f=>{o(f.target.value==="step_result"?{type:"step_result",result:"success"}:{type:f.target.value})},className:Ui,children:$k.map(f=>l.jsx("option",{value:f.value,children:f.label},f.value))})]}),n.type==="step_result"&&l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Result"}),p?l.jsx("select",{value:n.result??d.results[0],onChange:f=>{o({type:"step_result",result:f.target.value})},className:Ui,children:d.results.map(f=>l.jsx("option",{value:f,children:f},f))}):l.jsx("input",{type:"text",value:n.result??"success",onChange:f=>o({type:"step_result",result:f.target.value}),placeholder:"e.g. success, passed, failed",className:zr})]}),l.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Press Delete to remove."})]})}function Sp({variables:e,onInsert:t}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>l.jsx("button",{type:"button",onClick:()=>t(n.name),title:n.description,className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-bg-primary border border-border text-text-secondary hover:text-accent-primary hover:border-accent-primary/40 transition-colors",children:`{{${n.name}}}`},n.name))})}function fB({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:o,onRemove:u,onSetEntry:d}){const{color:p,name:f}=Bg(e,n);return l.jsxs("div",{className:"space-y-3 text-sm",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:p+"20",color:p},children:f}),t&&l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[!t&&l.jsx("button",{onClick:d,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),l.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Type"}),l.jsx("select",{value:e.type,onChange:m=>{const g=m.target.value,v=g==="sub_agent"?"verification":"build";if(g==="agent"){const b=n.find(_=>!_.subagent);o({...e,type:g,phase:v,toolMode:(b==null?void 0:b.id)??"builder",name:(b==null?void 0:b.name)??"Agent"})}else if(g==="sub_agent"){const b=n.find(_=>_.subagent);o({...e,type:g,phase:v,subAgentType:(b==null?void 0:b.id)??"",name:(b==null?void 0:b.name)??"Sub-Agent"})}else o({...e,type:g,phase:v,name:"Shell"})},className:Ui,children:cB.map(m=>l.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.type==="agent"&&l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Agent Type"}),l.jsx("select",{value:e.toolMode??"builder",onChange:m=>{const g=n.find(v=>v.id===m.target.value);o({...e,toolMode:m.target.value,name:(g==null?void 0:g.name)??m.target.value})},className:Ui,children:n.filter(m=>!m.subagent).map(m=>l.jsx("option",{value:m.id,children:m.name},m.id))})]}),e.type==="sub_agent"&&l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Sub-Agent Type"}),l.jsxs("select",{value:e.subAgentType??"",onChange:m=>{const g=n.find(v=>v.id===m.target.value);o({...e,subAgentType:m.target.value,name:(g==null?void 0:g.name)??m.target.value})},className:Ui,children:[l.jsx("option",{value:"",children:"— select —"}),n.filter(m=>m.subagent).map(m=>l.jsx("option",{value:m.id,children:m.name},m.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Prompt"}),l.jsx("textarea",{value:e.prompt??"",onChange:m=>o({...e,prompt:m.target.value||void 0}),rows:6,className:`${zr} resize-y text-xs`,placeholder:"Injected on first entry..."}),l.jsx(Sp,{variables:a,onInsert:m=>o({...e,prompt:(e.prompt??"")+`{{${m}}}`})})]}),l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Nudge Prompt"}),l.jsx("textarea",{value:e.nudgePrompt??"",onChange:m=>o({...e,nudgePrompt:m.target.value||void 0}),rows:6,className:`${zr} resize-y text-xs`,placeholder:"Injected on re-entry..."}),l.jsx(Sp,{variables:a,onInsert:m=>o({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${m}}}`})})]})]}),e.type==="shell"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Command"}),l.jsx("textarea",{value:e.command??"",onChange:m=>o({...e,command:m.target.value}),rows:3,className:`${zr} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),l.jsx(Sp,{variables:a,onInsert:m=>o({...e,command:(e.command??"")+`{{${m}}}`})})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Timeout (ms)"}),l.jsx("input",{type:"number",value:e.timeout??6e4,onChange:m=>o({...e,timeout:Number(m.target.value)}),className:`${zr} font-mono text-xs`})]}),l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Success Codes"}),l.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:m=>o({...e,successExitCodes:m.target.value.split(",").map(g=>Number(g.trim())).filter(g=>!isNaN(g))}),className:`${zr} font-mono text-xs`})]})]})]}),l.jsx("div",{className:"pt-1 border-t border-border/50",children:l.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const TS=[];function Uk({isOpen:e,onClose:t,initialEditId:n}){const r=Rt(de=>de.defaults),a=Rt(de=>de.userItems),o=Rt(de=>de.loading),u=Rt(de=>de.templateVariables),d=Rt(de=>de.fetchWorkflows),p=Rt(de=>de.fetchWorkflow),f=Rt(de=>de.fetchDefaultContent),m=Rt(de=>de.fetchTemplateVariables),g=Rt(de=>de.createWorkflow),v=Rt(de=>de.updateWorkflow),b=Rt(de=>de.deleteWorkflow),{requestDelete:_,clearConfirm:S,isConfirming:j}=Hm(),[C,E]=k.useState("list"),[A,O]=k.useState(null),[z,B]=k.useState(!1),[Y,ee]=k.useState(null),[ie,D]=k.useState(null),[$,H]=k.useState(""),[U,q]=k.useState(""),[T,N]=k.useState(""),[F,I]=k.useState("1.0.0"),[J,R]=k.useState("#3b82f6"),[P,V]=k.useState(""),[L,G]=k.useState(50),[W,Z]=k.useState(TS),[se,ve]=k.useState({type:"always"}),[Ce,Te]=k.useState(""),[Pe,$e]=k.useState(!1),[Re,Xe]=k.useState([]),[pt]=k.useState(null);k.useEffect(()=>{e&&(d(),m(),ke("/api/agents").then(de=>de.json()).then(de=>Xe(de.agents??[])).catch(()=>{}),ee(null),D(null),n?r.some(ge=>ge.id===n)?f(n).then(ge=>{ge&&(H(ge.metadata.name+" (copy)"),q(`${n}-copy-${Date.now()}`),N(ge.metadata.description),I(ge.metadata.version),R(ge.metadata.color??"#3b82f6"),V(ge.entryStep),G(ge.settings.maxIterations),Z(ge.steps),ve(ge.startCondition??{type:"always"}),Te(""),O(null),B(!1),E("edit"))}):p(n).then(ge=>{ge&&(H(ge.metadata.name),q(ge.metadata.id),N(ge.metadata.description),I(ge.metadata.version),R(ge.metadata.color??"#3b82f6"),V(ge.entryStep),G(ge.settings.maxIterations),Z(ge.steps),ve(ge.startCondition??{type:"always"}),Te(""),O(n),B(!1),E("edit"))}):(E("list"),O(null),B(!1)))},[e,d,p,f,m,n]);const gt=async de=>{const ge=await p(de);ge&&(O(de),H(ge.metadata.name),q(ge.metadata.id),N(ge.metadata.description),I(ge.metadata.version),R(ge.metadata.color??"#3b82f6"),V(ge.entryStep),G(ge.settings.maxIterations),Z(ge.steps),ve(ge.startCondition??{type:"always"}),Te(""),ee(null),D(null),E("edit"))},kt=async()=>{var it;const de=A??U;if(!de||!$)return Te("Name is required."),!1;if(W.length===0)return Te("Add at least one step."),!1;let ge=P;if(!ge||!W.some(He=>He.id===ge)){if(ge=((it=W.find(He=>He.id))==null?void 0:it.id)??"",!ge)return Te("All steps need an ID."),!1;V(ge)}$e(!0),Te("");const Se={metadata:{id:de,name:$,description:T,version:F||"1.0.0",color:J},entryStep:ge,settings:{maxIterations:L},steps:W,startCondition:se},Ue=A?await v(A,Se):await g(Se);return $e(!1),Ue.success?(A||O(de),!0):(Te(Ue.error??"Failed to save."),!1)},ct=async()=>{await kt()},ut=async()=>{await kt()&&(n?t():E("list"))},me=()=>{n?t():E("list")},je=de=>{H(de),A||q(oB(de))},ce=async de=>{if(r.some(Se=>Se.id===de)){const Se=await f(de);if(!Se)return;H(Se.metadata.name),q(Se.metadata.id),N(Se.metadata.description),I(Se.metadata.version),R(Se.metadata.color??"#3b82f6"),V(Se.entryStep),G(Se.settings.maxIterations),Z(Se.steps),ve(Se.startCondition??{type:"always"}),Te(""),O(de),B(!0)}else{const Se=await p(de);if(!Se)return;H(Se.metadata.name),q(Se.metadata.id),N(Se.metadata.description),I(Se.metadata.version),R(Se.metadata.color??"#3b82f6"),V(Se.entryStep),G(Se.settings.maxIterations),Z(Se.steps),ve(Se.startCondition??{type:"always"}),Te(""),O(de),B(!0)}E("edit")},Ae=async de=>{const Se=r.some(Ue=>Ue.id===de)?await f(de):await p(de);Se&&(H(Se.metadata.name+" (copy)"),q(`${de}-copy-${Date.now()}`),N(Se.metadata.description),I(Se.metadata.version),R(Se.metadata.color??"#3b82f6"),V(Se.entryStep),G(Se.settings.maxIterations),Z(Se.steps),ve(Se.startCondition??{type:"always"}),Te(""),O(null),B(!1),E("edit"))},Ie=()=>{O(null),H(""),q(""),N(""),I("1.0.0"),R("#3b82f6"),V(""),G(50),Z(structuredClone(TS)),ve({type:"always"}),Te(""),ee(null),D(null),B(!1),E("edit")},an=async de=>{await b(de),S()},le=k.useCallback(de=>{ee(de),D(null)},[]),xe=k.useCallback(de=>{D(de),ee(null)},[]),Me=Y!==null?Number(Y):-1,Be=Me>=0?W[Me]??null:null,ot=k.useCallback(de=>{Z(ge=>ge.map((Se,Ue)=>Ue===Me?de:Se))},[Me]),Cn=se.type==="step_result"?`${se.result}`:Fk[se.type]??se.type,Vn=()=>{const de=W.length,ge=lB(W),Se=Re.find(Ue=>!Ue.subagent);Z([...W,{id:ge,name:(Se==null?void 0:Se.name)??"Agent",type:"agent",phase:"build",toolMode:(Se==null?void 0:Se.id)??"builder",transitions:[]}]),P||V(ge),le(String(de))},on=k.useCallback((de,ge)=>{de==="$start"?(V(ge),xe("start")):Z(Se=>{const Ue=Se.find(He=>He.id===de),it=Ue?Ue.transitions.length:0;return xe(`${de}:${it}`),Se.map(He=>He.id===de?{...He,transitions:[...He.transitions,{when:{type:"always"},goto:ge}]}:He)})},[xe]),Bt=k.useCallback((de,ge)=>{if(de==="start")V(ge);else{const Se=de.lastIndexOf(":"),Ue=de.slice(0,Se),it=parseInt(de.slice(Se+1));Z(He=>He.map(Nn=>Nn.id===Ue?{...Nn,transitions:Nn.transitions.map((Yt,ln)=>ln===it?{...Yt,goto:ge}:Yt)}:Nn))}},[]),ae=k.useCallback((de,ge)=>{const Se=de.lastIndexOf(":"),Ue=de.slice(0,Se),it=parseInt(de.slice(Se+1));Z(He=>{const Nn=He.find(ln=>ln.id===Ue);if(!Nn)return He;const Yt=Nn.transitions[it];return Yt?He.map(ln=>ln.id===Ue?{...ln,transitions:ln.transitions.filter((Zi,yd)=>yd!==it)}:ln.id===ge?{...ln,transitions:[...ln.transitions,Yt]}:ln):He}),D(null)},[]),we=k.useCallback(de=>{if(de==="start")V("");else{const ge=de.lastIndexOf(":"),Se=de.slice(0,ge),Ue=parseInt(de.slice(ge+1));Z(it=>it.map(He=>He.id===Se?{...He,transitions:He.transitions.filter((Nn,Yt)=>Yt!==Ue)}:He))}D(null)},[]),qe=k.useCallback((de,ge)=>{if(de==="start")ve(ge);else{const Se=de.lastIndexOf(":"),Ue=de.slice(0,Se),it=parseInt(de.slice(Se+1));Z(He=>He.map(Nn=>Nn.id===Ue?{...Nn,transitions:Nn.transitions.map((Yt,ln)=>ln===it?{...Yt,when:ge}:Yt)}:Nn))}},[]),dt=de=>Bg(de,Re).name,xr=()=>{if(!ie)return null;if(ie==="start"){const Yt=W.find(ln=>ln.id===P);return{type:"start",fromLabel:"Start",toLabel:Yt?dt(Yt):"(none)",condition:se}}const de=ie.lastIndexOf(":"),ge=ie.slice(0,de),Se=parseInt(ie.slice(de+1)),Ue=W.find(Yt=>Yt.id===ge);if(!Ue)return null;const it=Ue.transitions[Se];if(!it)return null;const He=W.find(Yt=>Yt.id===it.goto),Nn=it.goto==="$done"?"Done":He?dt(He):it.goto;return{type:"step",fromLabel:dt(Ue),toLabel:Nn,condition:it.when}};if(C==="edit"){const de=xr();return l.jsxs(Et,{isOpen:e,onClose:me,title:z?$:A?"Edit Workflow":"New Workflow",size:"full",children:[Ce&&l.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:Ce}),l.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[l.jsxs("div",{className:"min-w-[140px]",children:[l.jsx("label",{className:Rn,children:"Name"}),l.jsx("input",{value:$,onChange:ge=>je(ge.target.value),placeholder:"Workflow name",className:`${zr} ${z?"opacity-50":""}`,readOnly:z})]}),l.jsxs("div",{className:"min-w-[100px]",children:[l.jsx("label",{className:Rn,children:"ID"}),l.jsx("input",{value:U,readOnly:!0,className:`${zr} font-mono opacity-50`})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:Rn,children:"Description"}),l.jsx("input",{value:T,onChange:ge=>!z&&N(ge.target.value),readOnly:z,placeholder:"What does this workflow do?",className:`${zr} ${z?"opacity-50":""}`})]}),l.jsxs("div",{className:"w-20",children:[l.jsx("label",{className:Rn,children:"Max Iter."}),l.jsx("input",{type:"number",value:L,onChange:ge=>!z&&G(Number(ge.target.value)),readOnly:z,className:`${zr} font-mono ${z?"opacity-50":""}`})]}),l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Color"}),l.jsx("input",{type:"color",value:J,onChange:ge=>!z&&R(ge.target.value),disabled:z,className:`w-8 h-8 rounded border border-border bg-transparent ${z?"opacity-50":"cursor-pointer"}`})]})]}),l.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[l.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[l.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!z&&l.jsx("button",{onClick:Vn,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),l.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[l.jsx(dB,{steps:W,entryStep:P,selectedNodeId:(Be==null?void 0:Be.id)??null,selectedEdgeKey:ie,startConditionLabel:Cn,agentTypes:Re,isReadOnly:z,onSelectNode:ge=>{if(ge===null){le(null);return}const Se=W.findIndex(Ue=>Ue.id===ge);le(Se>=0?String(Se):null)},onSelectEdge:xe,onRemoveStep:ge=>{var Ue;const Se=W.findIndex(it=>it.id===ge);if(Z(it=>it.filter(He=>He.id!==ge)),Me===Se&&le(null),P===ge){const it=W.filter(He=>He.id!==ge);V(((Ue=it[0])==null?void 0:Ue.id)??"")}},onCreateTransition:on,onReconnectTo:Bt,onReconnectFrom:ae,onDeleteTransition:we}),W.length===0&&l.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[l.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),l.jsx("button",{onClick:Vn,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),l.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[l.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:l.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),l.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:z&&(de||Be)?l.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):de?de.type==="start"?l.jsxs("div",{className:"space-y-3 text-sm",children:[l.jsx("div",{className:"flex items-center gap-2",children:l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),P&&l.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[l.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),l.jsx(e1,{}),l.jsx("span",{className:"text-text-primary font-medium",children:de.toLabel})]}),l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Activation Condition"}),l.jsx("select",{value:se.type,onChange:ge=>ve(ge.target.value==="step_result"?{type:"step_result",result:"success"}:{type:ge.target.value}),className:Ui,children:$k.map(ge=>l.jsx("option",{value:ge.value,children:ge.label},ge.value))})]}),se.type==="step_result"&&l.jsxs("div",{children:[l.jsx("label",{className:Rn,children:"Result"}),P&&(()=>{const ge=W.find(He=>He.id===P),Se=ge&&(ge.type==="sub_agent"||ge.type==="agent")?Re.find(He=>He.id===(ge.type==="sub_agent"?ge.subAgentType:ge.toolMode)):void 0,Ue=(Se==null?void 0:Se.results)&&Se.results.length>0,it=(Se==null?void 0:Se.results)??[];return Ue?l.jsx("select",{value:se.result??it[0],onChange:He=>ve({type:"step_result",result:He.target.value}),className:Ui,children:it.map(He=>l.jsx("option",{value:He,children:He},He))}):l.jsx("input",{type:"text",value:se.result??"success",onChange:He=>ve({type:"step_result",result:He.target.value}),placeholder:"e.g. success, passed, failed",className:zr})})()]}),l.jsx("p",{className:"text-text-muted text-[10px]",children:"Workflow only proceeds when this condition is met. Drag the target handle to change entry step."})]}):l.jsx(hB,{fromLabel:de.fromLabel,toLabel:de.toLabel,condition:de.condition,fromStep:de.type==="step"?W.find(ge=>ge.id===de.fromLabel):void 0,agentTypes:Re,onUpdateCondition:ge=>qe(ie,ge),onDelete:()=>we(ie)}):Be?l.jsx(fB,{step:Be,isEntry:Be.id===P,agentTypes:Re,transitionCount:Be.transitions.length,templateVariables:u,onUpdate:ot,onRemove:()=>{var ge;if(Be&&(Z(W.filter((Se,Ue)=>Ue!==Me)),le(null),P===Be.id)){const Se=W.filter((Ue,it)=>it!==Me);V(((ge=Se[0])==null?void 0:ge.id)??"")}},onSetEntry:()=>V(Be.id)}):l.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",l.jsx("br",{}),"Drag from a port to connect."]})})]})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[l.jsx(Ye,{variant:"secondary",onClick:me,children:"Close"}),z?l.jsx(Ye,{variant:"primary",onClick:()=>{H($+" (copy)"),q(`${A}-copy-${Date.now()}`),O(null),B(!1)},children:"Duplicate & Customize"}):l.jsxs(l.Fragment,{children:[l.jsx(Ye,{variant:"secondary",onClick:ct,disabled:Pe||!$,children:Pe?"Saving...":"Save"}),l.jsx(Ye,{variant:"primary",onClick:ut,disabled:Pe||!$,children:"Save & Close"})]})]})]})}return l.jsxs(Et,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("p",{className:"text-text-secondary text-sm",children:"Workflows define the orchestrator's step sequence when running tasks."}),l.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:l.jsx(Ye,{variant:"primary",size:"sm",onClick:Ie,children:"+ New"})})]}),o&&r.length===0&&a.length===0?l.jsx("div",{className:"text-text-muted text-sm",children:"Loading workflows..."}):r.length===0&&a.length===0?l.jsx("div",{className:"text-text-muted text-sm",children:"No workflows installed."}):l.jsxs("div",{className:"space-y-4",children:[r.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),l.jsx("div",{className:"space-y-2",children:r.map(de=>l.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[l.jsxs("div",{className:"min-w-0 flex-1 mr-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-text-primary text-sm font-medium",children:de.name}),l.jsxs("span",{className:"text-text-muted text-xs",children:["v",de.version]})]}),l.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:de.description})]}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[l.jsx("button",{onClick:()=>ce(de.id),className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:l.jsx(Qu,{})}),l.jsx(Nl,{onClick:()=>Ae(de.id)})]})]},de.id))})]}),a.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Custom"}),l.jsx("div",{className:"space-y-2",children:a.map(de=>l.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[l.jsxs("div",{className:"min-w-0 flex-1 mr-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-text-primary text-sm font-medium",children:de.name}),l.jsxs("span",{className:"text-text-muted text-xs",children:["v",de.version]})]}),l.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:de.description})]}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[l.jsx(Nl,{onClick:()=>Ae(de.id)}),l.jsx(Ya,{onClick:()=>gt(de.id)}),j(de.id,"delete")?l.jsx(Fm,{onConfirm:()=>an(de.id),onCancel:()=>{}}):l.jsx($m,{onClick:()=>_(de.id)})]})]},de.id))})]})]})]})}function pB(e,t){const n=e.startCondition;if(!n||n.type==="always")return!0;switch(n.type){case"has_pending_criteria":return t.some(r=>r.status.type!=="passed");case"all_criteria_passed":return t.length===0||t.every(r=>r.status.type==="passed");case"all_criteria_completed_or_passed":return t.every(r=>r.status.type==="completed"||r.status.type==="passed");case"any_criteria_blocked":return t.some(r=>r.status.type==="failed"&&r.attempts.filter(a=>a.status==="failed").length>=4);case"step_result":return null;default:return null}}function mB({onSendCommand:e,onSelectWorkflow:t,onOpenCommandsManager:n,onOpenWorkflowsManager:r,onAttach:a,textareaContent:o,attachments:u,criteria:d}){const[p,f]=k.useState(!1),[m,g]=k.useState("commands"),[v,b]=k.useState(""),[_,S]=k.useState(0),[j,C]=k.useState(null),[E,A]=k.useState(null),O=k.useRef(null),z=k.useRef(null),B=hn(V=>V.defaults),Y=hn(V=>V.userItems),ee=hn(V=>V.fetchCommands),ie=Rt(V=>V.defaults),D=Rt(V=>V.userItems),$=Rt(V=>V.fetchWorkflows),H=[...B,...Y],U=[...ie,...D];k.useEffect(()=>{p&&(m==="commands"?ee():m==="workflows"&&$())},[p,m,ee,$]),k.useEffect(()=>{p&&(b(""),S(0),requestAnimationFrame(()=>{var V;return(V=O.current)==null?void 0:V.focus()}))},[p,m]),k.useEffect(()=>{if(!p)return;const V=L=>{var G;(G=z.current)!=null&&G.contains(L.target)||f(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[p]);const q=V=>{switch(V.key){case"ArrowDown":V.preventDefault(),S(L=>{const W=(m==="commands"?H:U).filter(Z=>{const se=v.toLowerCase();return!se||Z.name.toLowerCase().includes(se)});return Math.min(L+1,W.length-1)});break;case"ArrowUp":V.preventDefault(),S(L=>Math.max(L-1,0));break;case"Enter":V.preventDefault();break;case"Escape":V.preventDefault(),f(!1);break}},T=V=>{b(V),S(0)},N=H.filter(V=>!v||V.name.toLowerCase().includes(v.toLowerCase())),F=U.filter(V=>!v||V.name.toLowerCase().includes(v.toLowerCase())),I=async V=>{const L=await hn.getState().fetchCommand(V);L&&e(L.prompt,L.metadata.agentMode,o,u),f(!1)},J=V=>{t(V),f(!1)},R=(V,L)=>{L.stopPropagation(),f(!1),C(V)},P=(V,L)=>{L.stopPropagation(),f(!1),A(V)};return l.jsxs("div",{ref:z,className:"relative",children:[l.jsx("button",{type:"button",onClick:()=>f(!p),className:"px-1.5 py-2 rounded-r bg-bg-secondary text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors border-l border-border/50",title:"More options",children:l.jsx(t1,{className:"w-4 h-4"})}),p&&l.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[l.jsxs("div",{className:"flex border-b border-border",children:[l.jsx("button",{type:"button",onClick:()=>{g("commands"),b(""),S(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),l.jsx("button",{type:"button",onClick:()=>{g("workflows"),b(""),S(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),l.jsx("button",{type:"button",onClick:()=>g("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),m!=="attach"&&l.jsx("div",{className:"p-2 border-b border-border",children:l.jsx("input",{ref:O,value:v,onChange:V=>T(V.target.value),onKeyDown:q,placeholder:m==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),l.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:m==="commands"?N.length===0?l.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:H.length===0?"No commands yet":"No matches"}):N.map((V,L)=>l.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${L===_?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[l.jsx("button",{type:"button",onClick:()=>I(V.id),className:"flex-1 text-left",children:l.jsx("div",{className:"text-sm text-text-primary font-medium",children:V.name})}),l.jsx(Ya,{className:"opacity-0 group-hover:opacity-100",onClick:G=>R(V.id,G)})]},V.id)):m==="workflows"?F.length===0?l.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:U.length===0?"No workflows yet":"No matches"}):F.map((V,L)=>{const G=pB(V,d),W=V.color??"#3b82f6";return l.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${L===_?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[l.jsxs("button",{type:"button",onClick:()=>J(V.id),className:"flex-1 text-left flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:W}}),l.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:V.name}),G!==null&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:G?"#22c55e":"#6b7280"},title:G?"Entry condition met":"Entry condition not met"})]}),l.jsx(Ya,{className:"opacity-0 group-hover:opacity-100",onClick:Z=>P(V.id,Z)})]},V.id)}):l.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[l.jsxs("button",{type:"button",onClick:()=>{a(),f(!1)},className:"flex items-center gap-2 px-4 py-2 rounded bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary transition-colors",children:[l.jsx(bj,{className:"w-4 h-4"}),l.jsx("span",{className:"text-sm font-medium",children:"Attach image"})]}),l.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),m!=="attach"&&l.jsx("div",{className:"border-t border-border p-1",children:l.jsx("button",{type:"button",onClick:()=>{f(!1),m==="commands"?n():r()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:m==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),l.jsx(Hk,{isOpen:!!j,onClose:()=>C(null),initialEditId:j}),l.jsx(Uk,{isOpen:!!E,onClose:()=>A(null),initialEditId:E})]})}function Wk(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const o of r){let u=0;for(let d=0;d<o.length&&u<a.length;d++)o[d]===a[u]&&u++;if(u===a.length)return!0}return!1})}function qk(e,t,n,r,a){switch(e.key){case"ArrowDown":e.preventDefault(),n(o=>Math.min(o+1,t));break;case"ArrowUp":e.preventDefault(),n(o=>Math.max(o-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),a();break}}function gB(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function xB({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:o,textareaContent:u,onSearchMessages:d,onToggleAutoScroll:p,isAutoScrollActive:f}){const[,m]=Hr(),g=hn(G=>G.fetchCommands),v=Rt(G=>G.fetchWorkflows),b=Lt(G=>G.fetchAgents),_=hn(G=>G.defaults),S=hn(G=>G.userItems),j=hn(G=>G.projectItems),C=Rt(G=>G.defaults),E=Rt(G=>G.userItems),A=Rt(G=>G.projectItems),O=Lt(G=>G.defaults),z=Lt(G=>G.userItems),B=Lt(G=>G.projectItems),Y=ye(G=>{var W;return(W=G.currentSession)==null?void 0:W.mode}),ee=ye(G=>{var W;return((W=G.currentSession)==null?void 0:W.dangerLevel)??"normal"}),ie=ye(G=>G.switchMode),D=ye(G=>G.switchDangerLevel),$=ye(G=>{var W;return(W=G.currentSession)==null?void 0:W.projectId}),H=k.useRef(void 0),[U,q]=k.useState(""),[T,N]=k.useState(0),F=k.useRef(null),I=k.useRef(!1);k.useEffect(()=>{e&&(I.current=!0)},[e]),k.useEffect(()=>{if(e){g(),v(),b(),q(""),N(0);const G=setTimeout(()=>{var W;return(W=F.current)==null?void 0:W.focus()},50);return()=>clearTimeout(G)}},[e,g,v,b]),k.useEffect(()=>{var G;!e&&I.current&&(n==null||n(),(G=H.current)==null||G.call(H),H.current=void 0)},[e,n]);const J=(G,W)=>{const Z=new Set(W.map(se=>se.id));return[...G.filter(se=>!Z.has(se.id)),...W]},P=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const G=$??gB(window.location.pathname);G&&m(`/p/${G}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{H.current=o,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),d==null||d()}},{id:"toggle-autoscroll",name:f?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),p==null||p(!f)}},...J(J(O,z),B).filter(G=>!G.subagent&&G.id!==Y).map(G=>({id:G.id,name:G.name,prefix:"Agent > Switch to",action:()=>ie(G.id)})),...J(J(_,S),j).map(G=>({id:G.id,name:G.name,prefix:"Command > Launch",action:()=>r(G.id,u)})),...J(J(C,E),A).map(G=>({id:G.id,name:G.name,prefix:"Workflow > Run",action:()=>a(G.id)})),...["normal","dangerous"].filter(G=>G!==ee).map(G=>({id:G,name:G.charAt(0).toUpperCase()+G.slice(1),prefix:"Mode > Switch to",action:()=>D(G)}))].filter(G=>Wk(`${G.prefix} ${G.name}`,U)),V=P.length-1,L=G=>{qk(G,V,N,()=>{var W;(W=P[T])==null||W.action(),t()},t)};return e?Ja.createPortal(l.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[l.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),l.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[l.jsx("input",{ref:F,type:"text",value:U,onChange:G=>{q(G.target.value),N(0)},onKeyDown:L,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),l.jsx(zm,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),l.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:P.length===0?l.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:_.length+S.length+C.length+E.length>0?"No matches":"No agents, commands, or workflows yet"}):P.map((G,W)=>l.jsxs("button",{type:"button",onClick:()=>{G.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${W===T?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[l.jsxs("span",{className:"text-text-muted font-normal",children:[G.prefix," "]}),l.jsx("span",{children:G.name})]},G.id))})]})]}),document.body):null}function yB(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});const a=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0"),d=String(t.getHours()).padStart(2,"0"),p=String(t.getMinutes()).padStart(2,"0");return`${a}/${o}/${u} ${d}:${p}`}function bB({isOpen:e,onClose:t,messages:n,onSelectMessage:r}){const[a,o]=k.useState(""),[u,d]=k.useState(0),p=k.useRef(null),f=k.useRef(!1),m=n.filter(S=>S.role==="user"&&!S.isSystemGenerated&&S.messageKind!=="auto-prompt"&&S.messageKind!=="command");k.useEffect(()=>{e&&(f.current=!0)},[e]),k.useEffect(()=>{if(e){o(""),d(0);const S=setTimeout(()=>{var j;return(j=p.current)==null?void 0:j.focus()},50);return()=>clearTimeout(S)}},[e]);const g=m.filter(S=>Wk(S.content,a)),v=g.length-1,b=S=>{qk(S,v,d,()=>{g[u]&&(r(g[u].id),t())},t)},_=S=>{r(S),t()};return e?Ja.createPortal(l.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[l.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),l.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[l.jsx(Im,{}),l.jsx("input",{ref:p,type:"text",value:a,onChange:S=>{o(S.target.value),d(0)},onKeyDown:b,placeholder:"Search messages...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),l.jsx("button",{type:"button",onClick:t,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Close",children:l.jsx(Bm,{className:"w-4 h-4"})})]}),l.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:g.length===0?l.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:m.length>0?"No matches":"No messages yet"}):g.map((S,j)=>l.jsx("button",{type:"button",onClick:()=>_(S.id),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${j===u?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsx("span",{className:"truncate flex-1",children:S.content}),l.jsx("span",{className:"text-text-muted text-xs shrink-0",children:yB(S.timestamp)})]})},S.id))})]})]}),document.body):null}function vB(e){return e==="criterion"}function _B(e){var t,n;return e.role!=="assistant"||e.subAgentId||(t=e.content)!=null&&t.trim()||(n=e.thinkingContent)!=null&&n.trim()||!e.toolCalls||e.toolCalls.length===0?!1:e.toolCalls.every(r=>vB(r.name))}function SB(e,t=[]){const n=[];let r=null,a=[],o,u=1;const d=new Map,p=new Map,f=[];for(const b of t)b.type==="message"?d.set(b.message.id,b):b.type==="subagent"?p.set(b.subAgentId,b):b.type==="criteria-batch"&&f.push(b);let m=0;const g=()=>{if(a.length>0){const b=f[m];b&&b.type==="criteria-batch"&&b.toolCalls.length===a.length&&b.toolCalls.every((S,j)=>{var C;return S.id===((C=a[j])==null?void 0:C.id)})?n.push(b):n.push({type:"criteria-batch",toolCalls:[...a]}),m++,a=[]}},v=()=>{if(!r)return;const b=r,_=p.get(b.subAgentId);_&&_.type==="subagent"&&_.messages.length===b.messages.length&&_.messages.every((j,C)=>j===b.messages[C])?n.push(_):n.push({type:"subagent",subAgentId:b.subAgentId,subAgentType:b.subAgentType,messages:b.messages}),r=null};for(const b of e)if(b.role!=="tool"){if(b.contextWindowId&&o&&b.contextWindowId!==o&&(g(),v(),u++,n.push({type:"context-divider",windowSequence:u})),o=b.contextWindowId,_B(b)){v();for(const _ of b.toolCalls)a.push(_);continue}if(g(),b.subAgentId&&b.subAgentType)r&&r.subAgentId===b.subAgentId?r.messages.push(b):(v(),r={subAgentId:b.subAgentId,subAgentType:b.subAgentType,messages:[b]});else{v();const _=d.get(b.id);_&&_.type==="message"&&_.message===b?n.push(_):n.push({type:"message",message:b})}}return g(),v(),n}function wB(e){const{year:t,month:n,day:r}=sw(e);return`${t}/${n}/${r} ${id(e)}`}function kB(e,t){return e.length<=t?e:e.substring(0,t)+"..."}const CB=10,NB=150;function jB(e){const t=[];if(e.recentUserPrompts)for(const n of e.recentUserPrompts)t.push({id:n.id,content:n.content,timestamp:n.timestamp,sessionId:e.id,sessionName:e.title||e.id});return t}function EB(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,CB).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:wB(r.timestamp),trimmedContent:kB(r.content,NB),sessionId:r.sessionId,sessionName:r.sessionName}))}function TB(e,t,n){const r=[],a=e.filter(o=>o.role==="user"&&!o.isSystemGenerated&&o.messageKind!=="auto-prompt");for(const o of a)r.push({id:o.id,content:o.content,timestamp:o.timestamp,sessionId:n??"",sessionName:"This session"});for(const o of t)n&&o.id===n||r.push(...jB(o));return EB(r)}function AB(e,t=[],n=null){const[r,a]=k.useState(0),[o,u]=k.useState(!1),d=k.useMemo(()=>TB(e,t,n),[e,t,n]),p=k.useCallback(()=>{d.length>0&&(a(d.length-1),u(!0))},[d.length]),f=k.useCallback(()=>{u(!1),a(0)},[]),m=k.useCallback(()=>{a(b=>d.length===0?b:b===0?d.length-1:b-1)},[d.length]),g=k.useCallback(()=>{a(b=>d.length===0?b:b===d.length-1?0:b+1)},[d.length]),v=k.useCallback(()=>{if(d.length===0||!o)return null;const b=d[r];return(b==null?void 0:b.content)??null},[d,r,o]);return{history:d,selectedIndex:r,showHistory:o,openHistory:p,closeHistory:f,navigateUp:m,navigateDown:g,selectCurrent:v}}function DB({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t}={}){const n=e??!0,[r,a]=k.useState(""),[o,u]=k.useState([]),[d,p]=k.useState(!1),[f,m]=k.useState(null),[g,v]=k.useState(!1),[b,_]=k.useState(!1),[S,j]=k.useState(!1),[C,E]=k.useState(!1),[A,O]=k.useState(null),[z,B]=k.useState(null),Y=k.useRef(null),ee=k.useRef(null),ie=k.useRef(null),D=ye(ae=>ae.currentSession),$=ye(ae=>ae.messages),H=ye(ae=>ae.streamingMessage),U=ye(ae=>ae.sessions),q=ye(ae=>ae.pendingQuestion),T=Mm(),N=ye(ae=>ae.sendMessage),F=ye(ae=>ae.acceptAndBuild),I=ye(ae=>ae.stopGeneration),J=ye(ae=>ae.launchRunner),R=ye(ae=>ae.cancelQueued),P=fj(),V=Lt(ae=>ae.defaults),L=Lt(ae=>ae.userItems),G=[...V,...L].filter(ae=>!ae.subagent),{history:W,selectedIndex:Z,showHistory:se,openHistory:ve,closeHistory:Ce,navigateUp:Te,navigateDown:Pe,selectCurrent:$e}=AB($,U,D==null?void 0:D.id),Re=k.useCallback(ae=>{O(ae),ut(!1);const we=document.querySelector(`[data-message-id="${ae}"]`);we&&we.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>O(null),3e3)},[]);k.useEffect(()=>{const ae=we=>{B(we.detail.stats)};return window.addEventListener("open-turn-stats",ae),()=>window.removeEventListener("open-turn-stats",ae)},[]),k.useEffect(()=>{Rt.getState().fetchWorkflows()},[]);const Xe=k.useMemo(()=>H?$.map(ae=>ae.id===H.id?H:ae):$,[$,H]),pt=k.useRef([]),gt=k.useMemo(()=>{const ae=SB(Xe,pt.current);return pt.current=ae,ae},[Xe]),{force_scroll_to_bottom:kt,isAutoScrollActive:ct,setAutoScroll:ut}=zk(Y,D),me=k.useRef(0),je=k.useCallback(()=>{const ae=ee.current;if(!ae)return;const we=r.length>=me.current;me.current=r.length,we||(ae.style.height="auto"),ae.style.height=`${Math.min(200,ae.scrollHeight)}px`},[r]);k.useEffect(()=>{if(!(D!=null&&D.id))return;const ae=`openfox:draft:${D.id}`,we=localStorage.getItem(ae);we!==null&&a(we)},[D==null?void 0:D.id]),k.useEffect(()=>{var ae;(ae=ee.current)==null||ae.focus(),je()},[D==null?void 0:D.id,je]),k.useEffect(()=>{if(!(D!=null&&D.id))return;const ae=`openfox:draft:${D.id}`,we=setTimeout(()=>{r?localStorage.setItem(ae,r):localStorage.removeItem(ae)},500);return()=>clearTimeout(we)},[D==null?void 0:D.id,r]),k.useEffect(()=>{je()},[r,je]),k.useEffect(()=>{const ae=we=>{const qe=S||g||b||C||z;we.key==="Escape"&&T&&!qe&&I(),we.key==="ScrollLock"&&ut(!ct)};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[T,I,ct,S,g,b,C,z]);const ce=k.useRef(0);k.useEffect(()=>{const ae=we=>{if(we.key==="Shift"&&!we.ctrlKey&&!we.metaKey&&!we.altKey){const qe=Date.now();qe-ce.current<300?(we.preventDefault(),j(!0),ce.current=0):ce.current=qe}};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[]),k.useEffect(()=>{const ae=ee.current;if(!ae)return;const we=async qe=>{var xr;if(document.activeElement!==ae)return;const dt=(xr=qe.clipboardData)==null?void 0:xr.items;if(dt){for(const de of Array.from(dt))if(de.type.startsWith("image/")){qe.preventDefault();const ge=de.getAsFile();if(!ge)continue;await vp(ge,Se=>u(Ue=>[...Ue,Se]),m,{filename:"pasted-image"})}}};return ae.addEventListener("paste",we),()=>ae.removeEventListener("paste",we)},[]);const Ae=()=>{a(""),u([]),D!=null&&D.id&&localStorage.removeItem(`openfox:draft:${D.id}`)},Ie=async ae=>{ae.preventDefault(),!(!r.trim()&&o.length===0)&&(kt(),N(r,o.length>0?o:void 0),Ae())},an=ae=>{if((ae.ctrlKey||ae.metaKey)&&ae.code.startsWith("Digit")){const qe=parseInt(ae.code.slice(-1),10)-1,dt=G[qe];dt&&(ae.preventDefault(),ye.getState().switchMode(dt.id));return}if(se)switch(ae.key){case"Enter":{ae.preventDefault();const we=$e();we&&(a(we),Ce());return}case"Escape":ae.preventDefault(),Ce(),T&&I();return;case"ArrowUp":ae.preventDefault(),Te();return;case"ArrowDown":ae.preventDefault(),Pe();return}if(ae.key==="ArrowUp"&&r.trim()===""&&!se){ae.preventDefault(),ve();return}ae.key==="Enter"&&!ae.shiftKey&&(ae.preventDefault(),Ie(ae))},le=k.useCallback(async ae=>{const we=ae.target.files;if(!(!we||we.length===0)){m(null);for(const qe of Array.from(we))await vp(qe,dt=>u(xr=>[...xr,dt]),m);ie.current&&(ie.current.value="")}},[]),xe=k.useCallback(ae=>{ae.preventDefault(),ae.stopPropagation(),p(!0)},[]),Me=k.useCallback(ae=>{ae.preventDefault(),ae.stopPropagation(),p(!1)},[]),Be=k.useCallback(async ae=>{ae.preventDefault(),ae.stopPropagation(),p(!1),m(null);const we=ae.dataTransfer.files;if(!(!we||we.length===0))for(const qe of Array.from(we))await vp(qe,dt=>u(xr=>[...xr,dt]),m)},[]),ot=k.useCallback(ae=>{u(we=>we.filter(qe=>qe.id!==ae))},[]),Cn=k.useCallback(()=>{var ae;(ae=ie.current)==null||ae.click()},[]),Vn=(D==null?void 0:D.mode)==="planner",on=(D==null?void 0:D.mode)==="builder",Bt=ae=>{const we=r.trim()?r:void 0,qe=o.length>0?o:void 0;Vn?F(ae,we,qe):on&&J(we,qe,ae),Ae()};return l.jsxs(l.Fragment,{children:[l.jsxs(mA,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:t,messages:Xe,children:[q&&l.jsx(zI,{question:q}),l.jsx(yA,{}),z&&l.jsx(bA,{stats:z,onClose:()=>B(null)}),l.jsx(PI,{}),l.jsx(MI,{displayItems:gt,scrollContainerRef:Y,highlightedMessageId:A}),l.jsxs("form",{onSubmit:Ie,className:"relative p-2 md:p-4 bg-secondary",children:[T&&l.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:l.jsx($I,{})}),l.jsxs("button",{type:"button",className:"absolute -top-8 right-12 md:right-16 text-sm text-text-muted hover:text-text-primary z-10 flex items-center gap-1.5",onClick:()=>ut(!ct),children:[ct?l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):l.jsx(rs,{className:"w-3 h-3 text-text-muted"}),ct?"live":"scroll to bottom"]}),l.jsx("button",{type:"button",onClick:()=>E(!0),className:"absolute -top-8 right-2 md:right-4 text-sm text-text-muted hover:text-text-primary z-10 flex items-center p-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Search messages",children:l.jsx(Im,{})}),l.jsx("input",{ref:ie,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:le,className:"hidden",multiple:!0}),f&&l.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:f}),o.length>0&&l.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:o.map(ae=>l.jsx(HI,{attachment:ae,onRemove:ot},ae.id))}),se&&l.jsx(FI,{history:W,selectedIndex:Z,onSelect:ae=>{a(ae),Ce()},onEscape:Ce,onNavigate:ae=>{ae==="up"?Te():Pe()}}),(P==null?void 0:P.length)>0&&l.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:P.map(ae=>l.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${ae.mode==="asap"?"bg-amber-500/15 text-amber-300 border border-amber-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:[l.jsxs("span",{className:"font-medium",children:[ae.mode==="asap"?"ASAP":"Queue",":"]}),l.jsx("span",{className:"truncate max-w-[200px]",children:ae.content}),l.jsx($l,{onClick:()=>R(ae.queueId),size:"sm"})]},ae.queueId))}),l.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${d?"bg-accent-primary/10":"bg-primary"}`,onDragOver:xe,onDragLeave:Me,onDrop:Be,children:[l.jsx("textarea",{id:tw,ref:ee,value:r,onChange:ae=>{a(ae.target.value),se&&Ce()},onKeyDown:an,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"flex-1 bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),l.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[T&&l.jsxs("button",{type:"button",onClick:()=>I(),"data-testid":"chat-stop-button",className:"flex items-center gap-1 px-4 py-1.5 rounded bg-accent-error/20 text-sm text-accent-error font-medium hover:bg-accent-error/30 transition-colors whitespace-nowrap",children:[l.jsx(r1,{}),"Abort"]}),l.jsxs("div",{className:"flex items-center",children:[l.jsx("button",{type:"button",onClick:()=>{var ae;!r.trim()&&o.length===0||((ae=Y.current)==null||ae.scrollTo({top:Y.current.scrollHeight,behavior:"smooth"}),N(r,o),Ae())},disabled:!r.trim()&&o.length===0,"data-testid":"chat-send-button",className:"px-4 py-1.5 rounded-l bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Send"}),l.jsx(mB,{onSendCommand:(ae,we,qe,dt)=>{var de;we&&(D==null?void 0:D.mode)!==we&&ye.getState().switchMode(we);const xr=qe&&qe.trim()?`${qe.trim()}
|
|
173
|
+
|
|
174
|
+
${ae}`:ae;(de=Y.current)==null||de.scrollTo({top:Y.current.scrollHeight,behavior:"smooth"}),N(xr,dt!=null&&dt.length?dt:void 0,{messageKind:"command",isSystemGenerated:!0}),Ae()},onSelectWorkflow:Bt,onOpenCommandsManager:()=>v(!0),onOpenWorkflowsManager:()=>_(!0),onAttach:Cn,textareaContent:r,attachments:o.length>0?o:void 0,criteria:(D==null?void 0:D.criteria)??[]})]})]})]}),l.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(II,{}),l.jsx(BI,{})]}),l.jsx(sB,{})]})]}),l.jsx(Hk,{isOpen:g,onClose:()=>v(!1)}),l.jsx(Uk,{isOpen:b,onClose:()=>_(!1)}),l.jsx(xB,{isOpen:S,onClose:()=>j(!1),onSearchMessages:()=>E(!0),isAutoScrollActive:ct,onToggleAutoScroll:ut,textareaContent:r,onCloseComplete:nw,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(ae,we)=>{const qe=await hn.getState().fetchCommand(ae);if(qe){const dt=we!=null&&we.trim()?`${we.trim()}
|
|
175
|
+
|
|
176
|
+
${qe.prompt}`:qe.prompt;qe.metadata.agentMode&&ye.getState().switchMode(qe.metadata.agentMode),N(dt,o!=null&&o.length?o:void 0,{messageKind:"command",isSystemGenerated:!0}),Ae()}},onSelectWorkflow:ae=>{const we=r.trim()||void 0,qe=o.length>0?o:void 0;(D==null?void 0:D.mode)==="planner"?ye.getState().acceptAndBuild(ae,we,qe):ye.getState().launchRunner(we,qe,ae),Ae()}})]}),C&&l.jsx(bB,{isOpen:C,onClose:()=>E(!1),messages:$,onSelectMessage:Re})]})}k.memo(function({item:t}){const[n,r]=k.useState(!1);return t.type==="start"?l.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[l.jsx("span",{className:"animate-pulse",children:"●"}),l.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&l.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):l.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[l.jsx("span",{className:"text-accent-success",children:"✓"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),l.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:n?"Hide":"Show"})]}),n&&t.description&&l.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:l.jsx(Es,{content:t.description})})]})]})});function AS({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,o]=k.useState(""),u=k.useRef(null);k.useEffect(()=>{e&&(o(""),setTimeout(()=>{var p;return(p=u.current)==null?void 0:p.focus()},100))},[e]);const d=p=>{p.preventDefault(),a.trim()&&n(a)};return l.jsx(Et,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:l.jsxs("form",{onSubmit:d,className:"space-y-4",children:[l.jsx("p",{className:"text-text-secondary text-sm",children:t?"The password you entered was incorrect. Please try again.":"This server requires a password to connect."}),l.jsx(ad,{ref:u,type:"password",value:a,onChange:p=>o(p.target.value),placeholder:"Enter password",autoFocus:!0}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(Ye,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),l.jsx(Ye,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}const MB=[8e3,11434,8080],RB=[{name:"OpenCode Go",url:"https://opencode.ai/zen/go/v1",backend:"opencode-go"}];function DS(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return"Unknown";default:return e}}function LB({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return l.jsx("div",{className:"flex justify-center py-6",children:l.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,o)=>{const u=o+1,d=u<e,p=u===e;return l.jsxs("div",{className:"flex items-center",children:[l.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${d?"bg-accent-primary text-text-primary hover:opacity-80":p?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:d?"✓":u}),l.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${p?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[o]}),o<t-1&&l.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${d?"bg-accent-primary":"bg-border"}`})]},o)})})})}function OB({onNext:e}){const[t,n]=k.useState([]),[r,a]=k.useState([]),[o,u]=k.useState(!1),[d,p]=k.useState(""),[f,m]=k.useState(""),[g,v]=k.useState(""),[b,_]=k.useState("auto"),[S,j]=k.useState(!1),[C,E]=k.useState(null),[A,O]=k.useState(null),[z,B]=k.useState(null),[Y,ee]=k.useState("");k.useEffect(()=>{ie()},[]);async function ie(){try{const T=await ke("/api/providers");if(T.ok){const F=(await T.json()).providers.map(I=>({id:I.id,name:I.name,url:I.url,backend:I.backend,model:null,apiKey:I.apiKey}));n(F),a(F)}}catch{}}async function D(T){j(!0),E(null);const N=b!=="auto";try{const I=await(await ke("/api/providers/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:T,skipBackendDetection:N})})).json();I.success?(N||_(I.backend??"auto"),E({success:!0,model:I.model??void 0})):E({success:!1,error:I.error??"Connection failed"})}catch(F){E({success:!1,error:F instanceof Error?F.message:"Connection failed"})}j(!1)}function $(){if(!f)return;const T=d||`Provider ${r.length+1}`,N={id:`temp-${Date.now()}`,name:T,url:f,backend:C!=null&&C.success?b:"auto",model:C!=null&&C.success?C.model??null:null,apiKey:g||void 0};a([...r,N]),p(""),m(""),v(""),E(null)}function H(T){O(T),t.some(F=>F.id===T)?ke(`/api/providers/${T}`,{method:"DELETE"}).then(()=>{a(r.filter(F=>F.id!==T)),n(t.filter(F=>F.id!==T)),O(null)}).catch(()=>{O(null)}):(a(r.filter(F=>F.id!==T)),O(null))}async function U(){for(const N of r)(N.id.startsWith("temp-")||!t.some(F=>F.id===N.id))&&((await ke("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N.name,url:N.url,backend:N.backend,model:N.model,apiKey:N.apiKey})})).ok||console.error("Failed to add provider",N));const T=r.filter(N=>!N.id.startsWith("temp-"));e({providers:T})}const q=r.length>0;return l.jsxs("div",{className:"max-w-xl mx-auto",children:[l.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),l.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),l.jsxs("div",{className:"space-y-4",children:[r.length>0?l.jsx("div",{className:"space-y-2",children:r.map(T=>l.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:DS(T.backend)}),z===T.id?l.jsx("input",{type:"text",value:Y,onChange:N=>ee(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(a(r.map(F=>F.id===T.id?{...F,name:Y}:F)),B(null)),N.key==="Escape"&&B(null)},onBlur:()=>{a(r.map(N=>N.id===T.id?{...N,name:Y}:N)),B(null)},className:"px-2 py-0.5 bg-bg-primary border border-accent-primary rounded text-text-primary text-sm focus:outline-none",autoFocus:!0}):l.jsx("span",{className:"text-text-primary font-medium cursor-pointer hover:text-accent-primary",onClick:()=>{B(T.id),ee(T.name)},title:"Click to edit",children:T.name})]}),l.jsx("p",{className:"text-text-muted text-sm mt-1",children:T.url}),T.model&&l.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",T.model]})]}),l.jsx("button",{onClick:()=>H(T.id),disabled:A===T.id,className:"p-2 text-text-muted hover:text-red-500 transition-colors disabled:opacity-50",title:"Remove provider",children:l.jsx(Ju,{})})]},T.id))}):l.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:l.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),o?l.jsxs("form",{onSubmit:T=>{T.preventDefault(),f&&$()},className:"space-y-4 p-4 bg-bg-tertiary rounded-lg",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Service Presets"}),l.jsx("div",{className:"grid grid-cols-2 gap-2",children:RB.map(T=>l.jsx("button",{type:"button",onClick:()=>{p(T.name),m(T.url),_(T.backend),E(null)},className:`p-2 rounded border text-center text-sm transition-colors ${f===T.url?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:T.name},T.name))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Local Presets"}),l.jsx("div",{className:"grid grid-cols-3 gap-2",children:MB.map(T=>l.jsxs("button",{type:"button",onClick:()=>{p(""),m(`http://localhost:${T}`),_("auto"),E(null)},className:`p-2 rounded border text-center text-sm transition-colors ${f===`http://localhost:${T}`?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:["localhost:",T]},T))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Or enter address manually"}),l.jsx("input",{type:"text",name:"url",value:f,onChange:T=>{m(T.target.value),E(null)},onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),D(f))},placeholder:"http://localhost:8000","data-testid":"onboarding-provider-url-input",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name (optional)"}),l.jsx("input",{type:"text",name:"name",value:d,onChange:T=>p(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),$())},placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),l.jsx("input",{type:"password",name:"apiKey",value:g,onChange:T=>v(T.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),C&&l.jsx("div",{className:`p-3 rounded-lg ${C.success?"bg-accent-primary/10":"bg-red-500/10"}`,children:C.success?l.jsxs("p",{className:"text-accent-primary font-medium",children:["✓ Connected to ",DS(b),C.model&&` (${C.model})`]}):l.jsx("p",{className:"text-red-500",children:C.error})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{type:"button",onClick:()=>D(f),disabled:!f||S,"data-testid":"onboarding-test-connection-button",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted disabled:opacity-50",children:S?l.jsx(Ga,{className:"w-4 h-4"}):"Test Connection"}),l.jsx("button",{type:"submit",disabled:!f,"data-testid":"onboarding-add-provider-submit-button",className:"flex-1 px-4 py-2 bg-accent-primary text-text-primary rounded-lg hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors font-medium",children:C!=null&&C.success?"Add Provider ✓":"Add Provider"})]}),l.jsx("button",{type:"button",onClick:()=>{u(!1),p(""),m(""),E(null)},className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]}):l.jsxs("button",{onClick:()=>u(!0),"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[l.jsx(Ga,{className:"w-4 h-4"}),"Add Provider"]}),l.jsx("button",{onClick:U,disabled:!q,"data-testid":"onboarding-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function IB({onNext:e}){const[t,n]=k.useState(""),[r,a]=k.useState(!1);return k.useEffect(()=>{ke("/api/config").then(o=>o.json()).then(o=>{o.workdir?n(o.workdir):fetch("/api/directories?path="+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&n(u.current)}).catch(()=>{})}).catch(()=>{fetch("/api/directories?path="+encodeURIComponent("/home")).then(o=>o.json()).then(o=>{o.current&&n(o.current)}).catch(()=>{})})},[]),l.jsxs("div",{className:"max-w-xl mx-auto",children:[l.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),l.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:t,onChange:o=>n(o.target.value),placeholder:"/home/user/projects","data-testid":"onboarding-workdir-input",className:"flex-1 px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),l.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&l.jsx(cw,{initialPath:t||void 0,onSelect:o=>{n(o),a(!1)},onClose:()=>a(!1)}),l.jsx("button",{onClick:()=>e({workdir:t}),disabled:!t,"data-testid":"onboarding-workdir-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function BB({onNext:e}){const[t,n]=k.useState(!1),[r,a]=k.useState("http://localhost:11434"),[o,u]=k.useState("qwen3-vl:2b"),{copied:d,copy:p}=Mk();k.useEffect(()=>{ke("/api/config").then(m=>m.json()).then(m=>{m.visionFallback&&(n(m.visionFallback.enabled),a(m.visionFallback.url),u(m.visionFallback.model))}).catch(()=>{})},[]);function f(m){if(m){e({});return}e({visionFallback:{enabled:t,url:r,model:o,timeout:120}})}return l.jsxs("div",{className:"max-w-xl mx-auto",children:[l.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),l.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[l.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"To enable vision support, you need an Ollama server with a vision model:"}),l.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),l.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[l.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3-vl:2b"}),l.jsx("button",{onClick:()=>p("ollama pull qwen3-vl:2b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:d?l.jsx(ns,{className:"w-4 h-4 text-accent-primary"}):l.jsx(Sj,{className:"w-4 h-4"})})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t,onChange:m=>n(m.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),l.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),t&&l.jsxs("div",{className:"space-y-4 pl-8",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),l.jsx("input",{type:"text",value:r,onChange:m=>a(m.target.value),placeholder:"http://localhost:11434",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),l.jsx("input",{type:"text",value:o,onChange:m=>u(m.target.value),placeholder:"qwen3-vl:2b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-4",children:[l.jsx("button",{onClick:()=>f(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),l.jsx("button",{onClick:()=>f(!1),className:"px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Finish Setup"})]})]})]})}function zB({onComplete:e}){const[t,n]=k.useState(1),[r,a]=k.useState(!1),[o,u]=k.useState({});async function d(g){u(v=>({...v,providers:g.providers})),n(2)}async function p(g){u(v=>({...v,...g})),n(3)}async function f(g){a(!0);try{if(!(await ke("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:o.workdir,visionFallback:g.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(v){console.error("Failed to save onboarding data:",v),a(!1)}}const m=g=>{n(g)};return l.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[l.jsx($l,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),l.jsx(LB,{currentStep:t,totalSteps:3,labels:["LLM Server","Projects Folder","Vision"],onStepClick:m}),l.jsx("div",{className:"max-w-xl mx-auto",children:r?l.jsxs("div",{className:"text-center",children:[l.jsx(Ga,{className:"w-6 h-6"}),l.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):l.jsxs(l.Fragment,{children:[t===1&&l.jsx(OB,{onNext:d}),t===2&&l.jsx(IB,{onNext:p}),t===3&&l.jsx(BB,{onNext:f})]})})]})}const MS="openfox_updated_to",RS="update_pending";function PB(){const[e,t]=k.useState(!1),n=localStorage.getItem(MS),r=localStorage.getItem(RS);k.useEffect(()=>{if(!n||!r)return;const o=setTimeout(()=>t(!0),3e4);return()=>clearTimeout(o)},[n,r]);const a=()=>{localStorage.removeItem(MS),localStorage.removeItem(RS),t(!0)};return e||r!=="true"||!n?null:l.jsxs("div",{className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-2.5 bg-bg-secondary border border-border rounded-lg shadow-xl animate-slide-down",role:"status","aria-live":"polite",children:[l.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:l.jsx(ns,{className:"w-3 h-3 text-accent-primary"})}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),l.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),l.jsx("button",{onClick:a,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:l.jsx(s1,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(yn.getState().loadUserPresets(),yn.getState().applySavedTheme());function zg(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function Vk(){return l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsx(Ul,{})})}function HB({sidebarOpen:e,onSidebarToggle:t}){const[,n]=Dm("/p/:projectId"),r=n==null?void 0:n.projectId,a=ye(f=>f.connectionStatus),o=ye(f=>f.clearSession),u=Ut(f=>f.currentProject),d=zg(),p=a==="connected"||d;return k.useEffect(()=>{p&&r&&(u==null?void 0:u.id)!==r&&Ut.getState().loadProject(r),p&&r&&(ye.getState().listSessions(r),o())},[p,r,u==null?void 0:u.id,o]),!u||u.id!==r?l.jsx(Vk,{}):l.jsxs(l.Fragment,{children:[l.jsx(aw,{projectId:r,isOpen:e,onClose:t}),l.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:l.jsx(B3,{})})]})}function FB({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=Dm("/p/:projectId/s/:sessionId"),o=a==null?void 0:a.projectId,u=a==null?void 0:a.sessionId,[,d]=Hr(),p=ye(A=>A.connectionStatus),f=ye(A=>A.currentSession),m=ye(A=>A.loadSession),g=ye(A=>A.listSessions),v=ye(A=>A.pendingSessionCreate),b=ye(A=>A.error),_=ye(A=>A.clearError),S=Ut(A=>A.currentProject),j=Ut(A=>A.loadProject),C=zg(),E=p==="connected"||C;return k.useEffect(()=>{E&&o&&(S==null?void 0:S.id)!==o&&j(o),E&&u&&(f==null?void 0:f.id)!==u&&m(u),E&&o&&g(o)},[E,o,S==null?void 0:S.id,j,u,f==null?void 0:f.id,m,g,v]),k.useEffect(()=>{(b==null?void 0:b.code)==="NOT_FOUND"&&o&&(_(),d(`/p/${o}`))},[b,o,_,d]),!S||S.id!==o?l.jsx(Vk,{}):l.jsxs(l.Fragment,{children:[l.jsx(aw,{projectId:o,isOpen:e,onClose:t}),l.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:l.jsx(DB,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})})]})}function $B(){const e=Mt(n=>n.fetchConfig);function t(){e(),window.history.back()}return l.jsx("div",{className:"flex-1 overflow-y-auto",children:l.jsx(zB,{onComplete:t})})}function UB(){const{connectionStatus:e}=mj(),t=Mt(N=>N.fetchConfig),n=Mt(N=>N.refreshProviderModels),r=wn(N=>N.getSetting),a=Mt(N=>N.providers),o=Mt(N=>N.activeProviderId),[,u]=Hr(),d=zg(),[p,f]=k.useState(!1);k.useEffect(()=>{(e==="connected"||d)&&t().then(()=>{f(!0);for(const N of zS)r(N);r(Qe.DISPLAY_THEME),r(Qe.DISPLAY_USER_PRESETS)})},[e,d,t,r]),k.useEffect(()=>{p&&o&&n(o).then(()=>{const N=Mt.getState().defaultModelSelection;(N?N.split("/")[0]:null)!==o&&t()})},[p,o,n,t]);const m=wn(N=>N.settings);k.useEffect(()=>{p&&a.length===0&&u("/onboarding")},[p,a.length]),k.useEffect(()=>{const{applyPreset:N,applyTokens:F}=yn.getState(),I=m[Qe.DISPLAY_THEME],J=m[Qe.DISPLAY_USER_PRESETS];if(J&&localStorage.setItem("openfox:userPresets",J),I){localStorage.setItem("openfox:theme",I);try{const R=JSON.parse(I);R.preset&&R.tokens?(N(R.preset),yn.setState({basePreset:R.preset}),F(R.tokens)):R.preset?N(R.preset):R.tokens&&F(R.tokens)}catch{N("dark")}}else N("dark")},[m[Qe.DISPLAY_THEME],m[Qe.DISPLAY_USER_PRESETS]]);const g=()=>{const N=localStorage.getItem("openfox:leftSidebar");return N!==null?N==="true":!0},v=()=>{const N=localStorage.getItem("openfox:rightSidebar");return N!==null?N==="true":!0},[b,_]=k.useState(g),[S,j]=k.useState(v),[C,E]=k.useState(!1),[A,O]=k.useState(!1),[z,B]=k.useState(!1),Y=SN();k.useEffect(()=>{const N=()=>{B(window.innerWidth<768)};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]);const ee=z?C:b,ie=z?A:S,D=()=>{z?E(!C):_(!b)},$=()=>{z?O(!A):j(!S)};k.useEffect(()=>{z||localStorage.setItem("openfox:leftSidebar",String(b))},[b,z]),k.useEffect(()=>{z||localStorage.setItem("openfox:rightSidebar",String(S))},[S,z]),k.useEffect(()=>{(e==="connected"||d)&&t()},[e,t,d]);const H=ye(N=>N.showPasswordModal),U=ye(N=>N.passwordModalRetry),q=ye(N=>N.submitPassword),T=ye(N=>N.cancelPassword);return e!=="connected"&&!H&&!d?l.jsxs(l.Fragment,{children:[l.jsx(AS,{isOpen:!0,isRetry:U,onSubmit:q,onCancel:T}),l.jsx("div",{className:"h-screen flex items-center justify-center",children:l.jsx(R3,{text:"Connecting to server..."})})]}):l.jsxs(l.Fragment,{children:[l.jsx(AS,{isOpen:H,isRetry:U,onSubmit:q,onCancel:T}),l.jsxs("div",{className:"flex flex-col",style:{height:z?`calc(${Y.offsetTop}px + ${Y.height}px)`:"100vh"},children:[l.jsx(E3,{}),l.jsx(S3,{onMenuClick:D,onCriteriaToggle:$}),l.jsx("div",{className:"flex-1 flex overflow-hidden",children:l.jsxs(WN,{children:[l.jsx(Xo,{path:"/onboarding",children:l.jsx($B,{})}),l.jsx(Xo,{path:"/p/:projectId/s/:sessionId",children:l.jsx(FB,{sidebarOpen:ee,onSidebarToggle:D,rightSidebarOpen:ie,onRightSidebarToggle:$})}),l.jsx(Xo,{path:"/p/:projectId/new",children:l.jsx(I3,{})}),l.jsx(Xo,{path:"/p/:projectId",children:l.jsx(HB,{sidebarOpen:ee,onSidebarToggle:D})}),l.jsx(Xo,{path:"/",children:l.jsx(O3,{})})]})})]}),l.jsx(PB,{})]})}xN.createRoot(document.getElementById("root")).render(l.jsx(zn.StrictMode,{children:l.jsx(UB,{})}));
|