openfox 2.0.0-beta.3 → 2.0.0-beta.5

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.
Files changed (33) hide show
  1. package/dist/{auto-compaction-UIWTO3H5.js → auto-compaction-2ZAYDXGF.js} +6 -6
  2. package/dist/{chat-handler-IVIWOR3D.js → chat-handler-BM6EBFKS.js} +9 -9
  3. package/dist/{chunk-YUIMJBSE.js → chunk-CLGRPDZT.js} +26 -28
  4. package/dist/{chunk-ALH4KM2Y.js → chunk-DFWGWULB.js} +23 -135
  5. package/dist/{chunk-UK6XF2OX.js → chunk-I67T2E5K.js} +2 -2
  6. package/dist/{chunk-QFSSKIQ3.js → chunk-OBD6D5ZO.js} +4 -4
  7. package/dist/{chunk-FQLK5GL5.js → chunk-T4HV6GS5.js} +1 -1
  8. package/dist/{chunk-XKR3HCAL.js → chunk-UH27FDT7.js} +6 -24
  9. package/dist/{chunk-CEZNMLOO.js → chunk-V6DYJV5R.js} +2 -5
  10. package/dist/{chunk-UFY4I643.js → chunk-X36JIWSF.js} +4 -4
  11. package/dist/{chunk-NONI4CRP.js → chunk-XL7SW5B4.js} +1 -29
  12. package/dist/cli/dev.js +1 -1
  13. package/dist/cli/index.js +1 -1
  14. package/dist/{events-OHJWCI3S.js → events-T37KTNCX.js} +3 -3
  15. package/dist/{folding-U6UHQAS5.js → folding-IIKWAGG2.js} +2 -2
  16. package/dist/{orchestrator-7ZXM4J22.js → orchestrator-JTUHXF7C.js} +7 -7
  17. package/dist/package.json +1 -1
  18. package/dist/{processor-TKBJLQ2N.js → processor-66YBBQ6B.js} +7 -7
  19. package/dist/{protocol-K62EPEGS.js → protocol-ALBHLBBF.js} +3 -3
  20. package/dist/{protocol-BQ12Aw5J.d.ts → protocol-CiYlonA5.d.ts} +2 -38
  21. package/dist/{serve-7CUQCZC7.js → serve-EUEQ6ERI.js} +8 -8
  22. package/dist/server/index.d.ts +1 -1
  23. package/dist/server/index.js +7 -7
  24. package/dist/shared/index.d.ts +2 -2
  25. package/dist/shared/index.js +1 -1
  26. package/dist/{tools-Z7X4HXZN.js → tools-56LACLKH.js} +6 -6
  27. package/dist/web/assets/{index-BY8EbT5Z.css → index-C5gaXnFj.css} +2 -2
  28. package/dist/web/assets/index-DQ2Vv-Yl.js +317 -0
  29. package/dist/web/index.html +2 -2
  30. package/dist/web/sw.js +1 -1
  31. package/package.json +1 -1
  32. package/dist/web/assets/index-CrYTogyB.js +0 -299
  33. /package/dist/web/{workbox-8c29f6e4.js → workbox-7fc22fbe.js} +0 -0
@@ -0,0 +1,317 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-DA-rfuFy.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/angular-ts-BrjP3tb8.js","assets/scss-D5BDwBP9.js","assets/apl-CORt7UWP.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-HNnZUWAn.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-2xfisSek.js","assets/html-derivative-DlHx6ybY.js","assets/sql-CRqJ_cUM.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nBiQ_Alo.js","assets/coffee-Ch7k5sss.js","assets/cpp-UfJy6YNI.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-DGywbUpC.js","assets/shellscript-Yzrsuije.js","assets/edge-FbVlp4U3.js","assets/elixir-CkH2-t6x.js","assets/elm-DbKCFpqz.js","assets/erb-Dm6A9KJ5.js","assets/ruby-DyJCeAvU.js","assets/haml-D5jkg6IW.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/erlang-DsQrWhSR.js","assets/markdown-Cvjx9yec.js","assets/fortran-fixed-form-CkoXwp7k.js","assets/fortran-free-form-BxgE0vQu.js","assets/fsharp-CXgrBDvD.js","assets/gdresource-BOOCDP_w.js","assets/gdshader-DkwncUOv.js","assets/gdscript-C5YyOfLZ.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-ByusRIyA.js","assets/glimmer-ts-BfAWNZQY.js","assets/hack-DbPARsA_.js","assets/handlebars-BpdQsYii.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-f2NsQr07.js","assets/jison-wvAkD_A8.js","assets/julia-D7OTSIA_.js","assets/r-Dspwwk_N.js","assets/just-CUsbIsdP.js","assets/perl-B9cMNwum.js","assets/latex-CaSxy8MP.js","assets/tex-idrVyKtj.js","assets/liquid-C0sCDyMI.js","assets/marko-DjSrsDqO.js","assets/less-B1dDrJ26.js","assets/mdc-DTYItulj.js","assets/nextflow-C-mBbutL.js","assets/nextflow-groovy-vE_lwT2v.js","assets/nginx-BpAMiNFr.js","assets/nim-BIad80T-.js","assets/php-Csjmro_R.js","assets/pug-DKIMFp6K.js","assets/qml-3beO22l8.js","assets/razor-BjBPvh-w.js","assets/csharp-DSvCPggb.js","assets/rst-CpCqk9r5.js","assets/cmake-D1j8_8rp.js","assets/sas-DEy46yEz.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-8wufbnw4.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-DI20mbqo.js","assets/surrealql-Bq5Q-fJD.js","assets/svelte-Cy7k_4gC.js","assets/templ-DhtptRzy.js","assets/go-C27-OAKa.js","assets/ts-tags-D351s5mN.js","assets/twig-CW1WmMYd.js","assets/vue-D2xRrEX4.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-BoDAl6tE.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js"])))=>i.map(i=>d[i]);
2
+ var xA=Object.defineProperty;var yA=Object.getPrototypeOf;var vA=Reflect.get;var W0=e=>{throw TypeError(e)};var bA=(e,t,n)=>t in e?xA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ce=(e,t,n)=>bA(e,typeof t!="symbol"?t+"":t,n),pp=(e,t,n)=>t.has(e)||W0("Cannot "+n);var Un=(e,t,n)=>(pp(e,t,"read from private field"),n?n.call(e):t.get(e)),aa=(e,t,n)=>t.has(e)?W0("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ur=(e,t,n,r)=>(pp(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),gp=(e,t,n)=>(pp(e,t,"access private method"),n);var G0=(e,t,n)=>vA(yA(e),n,t);function SA(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}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 i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();function Ch(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _p={exports:{}},Wl={};/**
3
+ * @license React
4
+ * react-jsx-runtime.production.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var q0;function wA(){if(q0)return Wl;q0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,a){var l=null;if(a!==void 0&&(l=""+a),i.key!==void 0&&(l=""+i.key),"key"in i){a={};for(var d in i)d!=="key"&&(a[d]=i[d])}else a=i;return i=a.ref,{$$typeof:e,type:r,key:l,ref:i!==void 0?i:null,props:a}}return Wl.Fragment=t,Wl.jsx=n,Wl.jsxs=n,Wl}var K0;function CA(){return K0||(K0=1,_p.exports=wA()),_p.exports}var c=CA(),xp={exports:{}},Ve={};/**
11
+ * @license React
12
+ * react.production.js
13
+ *
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var Y0;function kA(){if(Y0)return Ve;Y0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.iterator;function _(V){return V===null||typeof V!="object"?null:(V=x&&V[x]||V["@@iterator"],typeof V=="function"?V:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,w={};function k(V,K,I){this.props=V,this.context=K,this.refs=w,this.updater=I||v}k.prototype.isReactComponent={},k.prototype.setState=function(V,K){if(typeof V!="object"&&typeof V!="function"&&V!=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,V,K,"setState")},k.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function j(){}j.prototype=k.prototype;function T(V,K,I){this.props=V,this.context=K,this.refs=w,this.updater=I||v}var A=T.prototype=new j;A.constructor=T,S(A,k.prototype),A.isPureReactComponent=!0;var P=Array.isArray;function M(){}var q={H:null,A:null,T:null,S:null},Z=Object.prototype.hasOwnProperty;function J(V,K,I){var Q=I.ref;return{$$typeof:e,type:V,key:K,ref:Q!==void 0?Q:null,props:I}}function L(V,K){return J(V.type,K,V.props)}function G(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function H(V){var K={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(I){return K[I]})}var R=/\/+/g;function U(V,K){return typeof V=="object"&&V!==null&&V.key!=null?H(""+V.key):K.toString(36)}function D(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(M,M):(V.status="pending",V.then(function(K){V.status==="pending"&&(V.status="fulfilled",V.value=K)},function(K){V.status==="pending"&&(V.status="rejected",V.reason=K)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function N(V,K,I,Q,W){var ee=typeof V;(ee==="undefined"||ee==="boolean")&&(V=null);var ne=!1;if(V===null)ne=!0;else switch(ee){case"bigint":case"string":case"number":ne=!0;break;case"object":switch(V.$$typeof){case e:case t:ne=!0;break;case p:return ne=V._init,N(ne(V._payload),K,I,Q,W)}}if(ne)return W=W(V),ne=Q===""?"."+U(V,0):Q,P(W)?(I="",ne!=null&&(I=ne.replace(R,"$&/")+"/"),N(W,K,I,"",function(Ce){return Ce})):W!=null&&(G(W)&&(W=L(W,I+(W.key==null||V&&V.key===W.key?"":(""+W.key).replace(R,"$&/")+"/")+ne)),K.push(W)),1;ne=0;var Se=Q===""?".":Q+":";if(P(V))for(var le=0;le<V.length;le++)Q=V[le],ee=Se+U(Q,le),ne+=N(Q,K,I,ee,W);else if(le=_(V),typeof le=="function")for(V=le.call(V),le=0;!(Q=V.next()).done;)Q=Q.value,ee=Se+U(Q,le++),ne+=N(Q,K,I,ee,W);else if(ee==="object"){if(typeof V.then=="function")return N(D(V),K,I,Q,W);throw K=String(V),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.")}return ne}function F(V,K,I){if(V==null)return V;var Q=[],W=0;return N(V,Q,"","",function(ee){return K.call(I,ee,W++)}),Q}function $(V){if(V._status===-1){var K=V._result;K=K(),K.then(function(I){(V._status===0||V._status===-1)&&(V._status=1,V._result=I)},function(I){(V._status===0||V._status===-1)&&(V._status=2,V._result=I)}),V._status===-1&&(V._status=0,V._result=K)}if(V._status===1)return V._result.default;throw V._result}var se=typeof reportError=="function"?reportError:function(V){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var K=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof V=="object"&&V!==null&&typeof V.message=="string"?String(V.message):String(V),error:V});if(!window.dispatchEvent(K))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",V);return}console.error(V)},B={map:F,forEach:function(V,K,I){F(V,function(){K.apply(this,arguments)},I)},count:function(V){var K=0;return F(V,function(){K++}),K},toArray:function(V){return F(V,function(K){return K})||[]},only:function(V){if(!G(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return Ve.Activity=g,Ve.Children=B,Ve.Component=k,Ve.Fragment=n,Ve.Profiler=i,Ve.PureComponent=T,Ve.StrictMode=r,Ve.Suspense=f,Ve.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=q,Ve.__COMPILER_RUNTIME={__proto__:null,c:function(V){return q.H.useMemoCache(V)}},Ve.cache=function(V){return function(){return V.apply(null,arguments)}},Ve.cacheSignal=function(){return null},Ve.cloneElement=function(V,K,I){if(V==null)throw Error("The argument must be a React element, but you passed "+V+".");var Q=S({},V.props),W=V.key;if(K!=null)for(ee in K.key!==void 0&&(W=""+K.key),K)!Z.call(K,ee)||ee==="key"||ee==="__self"||ee==="__source"||ee==="ref"&&K.ref===void 0||(Q[ee]=K[ee]);var ee=arguments.length-2;if(ee===1)Q.children=I;else if(1<ee){for(var ne=Array(ee),Se=0;Se<ee;Se++)ne[Se]=arguments[Se+2];Q.children=ne}return J(V.type,W,Q)},Ve.createContext=function(V){return V={$$typeof:l,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null},V.Provider=V,V.Consumer={$$typeof:a,_context:V},V},Ve.createElement=function(V,K,I){var Q,W={},ee=null;if(K!=null)for(Q in K.key!==void 0&&(ee=""+K.key),K)Z.call(K,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(W[Q]=K[Q]);var ne=arguments.length-2;if(ne===1)W.children=I;else if(1<ne){for(var Se=Array(ne),le=0;le<ne;le++)Se[le]=arguments[le+2];W.children=Se}if(V&&V.defaultProps)for(Q in ne=V.defaultProps,ne)W[Q]===void 0&&(W[Q]=ne[Q]);return J(V,ee,W)},Ve.createRef=function(){return{current:null}},Ve.forwardRef=function(V){return{$$typeof:d,render:V}},Ve.isValidElement=G,Ve.lazy=function(V){return{$$typeof:p,_payload:{_status:-1,_result:V},_init:$}},Ve.memo=function(V,K){return{$$typeof:h,type:V,compare:K===void 0?null:K}},Ve.startTransition=function(V){var K=q.T,I={};q.T=I;try{var Q=V(),W=q.S;W!==null&&W(I,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(M,se)}catch(ee){se(ee)}finally{K!==null&&I.types!==null&&(K.types=I.types),q.T=K}},Ve.unstable_useCacheRefresh=function(){return q.H.useCacheRefresh()},Ve.use=function(V){return q.H.use(V)},Ve.useActionState=function(V,K,I){return q.H.useActionState(V,K,I)},Ve.useCallback=function(V,K){return q.H.useCallback(V,K)},Ve.useContext=function(V){return q.H.useContext(V)},Ve.useDebugValue=function(){},Ve.useDeferredValue=function(V,K){return q.H.useDeferredValue(V,K)},Ve.useEffect=function(V,K){return q.H.useEffect(V,K)},Ve.useEffectEvent=function(V){return q.H.useEffectEvent(V)},Ve.useId=function(){return q.H.useId()},Ve.useImperativeHandle=function(V,K,I){return q.H.useImperativeHandle(V,K,I)},Ve.useInsertionEffect=function(V,K){return q.H.useInsertionEffect(V,K)},Ve.useLayoutEffect=function(V,K){return q.H.useLayoutEffect(V,K)},Ve.useMemo=function(V,K){return q.H.useMemo(V,K)},Ve.useOptimistic=function(V,K){return q.H.useOptimistic(V,K)},Ve.useReducer=function(V,K,I){return q.H.useReducer(V,K,I)},Ve.useRef=function(V){return q.H.useRef(V)},Ve.useState=function(V){return q.H.useState(V)},Ve.useSyncExternalStore=function(V,K,I){return q.H.useSyncExternalStore(V,K,I)},Ve.useTransition=function(){return q.H.useTransition()},Ve.version="19.2.4",Ve}var X0;function kh(){return X0||(X0=1,xp.exports=kA()),xp.exports}var C=kh();const Ls=Ch(C),EA=SA({__proto__:null,default:Ls},[C]);var yp={exports:{}},Gl={},vp={exports:{}},bp={};/**
19
+ * @license React
20
+ * scheduler.production.js
21
+ *
22
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE file in the root directory of this source tree.
26
+ */var Q0;function NA(){return Q0||(Q0=1,(function(e){function t(N,F){var $=N.length;N.push(F);e:for(;0<$;){var se=$-1>>>1,B=N[se];if(0<i(B,F))N[se]=F,N[$]=B,$=se;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],$=N.pop();if($!==F){N[0]=$;e:for(var se=0,B=N.length,V=B>>>1;se<V;){var K=2*(se+1)-1,I=N[K],Q=K+1,W=N[Q];if(0>i(I,$))Q<B&&0>i(W,I)?(N[se]=W,N[Q]=$,se=Q):(N[se]=I,N[K]=$,se=K);else if(Q<B&&0>i(W,$))N[se]=W,N[Q]=$,se=Q;else break e}}return F}function i(N,F){var $=N.sortIndex-F.sortIndex;return $!==0?$:N.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,d=l.now();e.unstable_now=function(){return l.now()-d}}var f=[],h=[],p=1,g=null,x=3,_=!1,v=!1,S=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function A(N){for(var F=n(h);F!==null;){if(F.callback===null)r(h);else if(F.startTime<=N)r(h),F.sortIndex=F.expirationTime,t(f,F);else break;F=n(h)}}function P(N){if(S=!1,A(N),!v)if(n(f)!==null)v=!0,M||(M=!0,H());else{var F=n(h);F!==null&&D(P,F.startTime-N)}}var M=!1,q=-1,Z=5,J=-1;function L(){return w?!0:!(e.unstable_now()-J<Z)}function G(){if(w=!1,M){var N=e.unstable_now();J=N;var F=!0;try{e:{v=!1,S&&(S=!1,j(q),q=-1),_=!0;var $=x;try{t:{for(A(N),g=n(f);g!==null&&!(g.expirationTime>N&&L());){var se=g.callback;if(typeof se=="function"){g.callback=null,x=g.priorityLevel;var B=se(g.expirationTime<=N);if(N=e.unstable_now(),typeof B=="function"){g.callback=B,A(N),F=!0;break t}g===n(f)&&r(f),A(N)}else r(f);g=n(f)}if(g!==null)F=!0;else{var V=n(h);V!==null&&D(P,V.startTime-N),F=!1}}break e}finally{g=null,x=$,_=!1}F=void 0}}finally{F?H():M=!1}}}var H;if(typeof T=="function")H=function(){T(G)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,U=R.port2;R.port1.onmessage=G,H=function(){U.postMessage(null)}}else H=function(){k(G,0)};function D(N,F){q=k(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"):Z=0<N?Math.floor(1e3/N):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(N){switch(x){case 1:case 2:case 3:var F=3;break;default:F=x}var $=x;x=F;try{return N()}finally{x=$}},e.unstable_requestPaint=function(){w=!0},e.unstable_runWithPriority=function(N,F){switch(N){case 1:case 2:case 3:case 4:case 5:break;default:N=3}var $=x;x=N;try{return F()}finally{x=$}},e.unstable_scheduleCallback=function(N,F,$){var se=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?se+$:se):$=se,N){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=$+B,N={id:p++,callback:F,priorityLevel:N,startTime:$,expirationTime:B,sortIndex:-1},$>se?(N.sortIndex=$,t(h,N),n(f)===null&&N===n(h)&&(S?(j(q),q=-1):S=!0,D(P,$-se))):(N.sortIndex=B,t(f,N),v||_||(v=!0,M||(M=!0,H()))),N},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(N){var F=x;return function(){var $=x;x=F;try{return N.apply(this,arguments)}finally{x=$}}}})(bp)),bp}var J0;function jA(){return J0||(J0=1,vp.exports=NA()),vp.exports}var Sp={exports:{}},In={};/**
27
+ * @license React
28
+ * react-dom.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var Z0;function TA(){if(Z0)return In;Z0=1;var e=kh();function t(f){var h="https://react.dev/errors/"+f;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+f+"; visit "+h+" 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},i=Symbol.for("react.portal");function a(f,h,p){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:g==null?null:""+g,children:f,containerInfo:h,implementation:p}}var l=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(f,h){if(f==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return In.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,In.createPortal=function(f,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return a(f,h,null,p)},In.flushSync=function(f){var h=l.T,p=r.p;try{if(l.T=null,r.p=2,f)return f()}finally{l.T=h,r.p=p,r.d.f()}},In.preconnect=function(f,h){typeof f=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(f,h))},In.prefetchDNS=function(f){typeof f=="string"&&r.d.D(f)},In.preinit=function(f,h){if(typeof f=="string"&&h&&typeof h.as=="string"){var p=h.as,g=d(p,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,_=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(f,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:x,fetchPriority:_}):p==="script"&&r.d.X(f,{crossOrigin:g,integrity:x,fetchPriority:_,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},In.preinitModule=function(f,h){if(typeof f=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=d(h.as,h.crossOrigin);r.d.M(f,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(f)},In.preload=function(f,h){if(typeof f=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,g=d(p,h.crossOrigin);r.d.L(f,p,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},In.preloadModule=function(f,h){if(typeof f=="string")if(h){var p=d(h.as,h.crossOrigin);r.d.m(f,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(f)},In.requestFormReset=function(f){r.d.r(f)},In.unstable_batchedUpdates=function(f,h){return f(h)},In.useFormState=function(f,h,p){return l.H.useFormState(f,h,p)},In.useFormStatus=function(){return l.H.useHostTransitionStatus()},In.version="19.2.4",In}var eS;function OC(){if(eS)return Sp.exports;eS=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(),Sp.exports=TA(),Sp.exports}/**
35
+ * @license React
36
+ * react-dom-client.production.js
37
+ *
38
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */var tS;function AA(){if(tS)return Gl;tS=1;var e=jA(),t=kh(),n=OC();function r(s){var o="https://react.dev/errors/"+s;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+s+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function a(s){var o=s,u=s;if(s.alternate)for(;o.return;)o=o.return;else{s=o;do o=s,(o.flags&4098)!==0&&(u=o.return),s=o.return;while(s)}return o.tag===3?u:null}function l(s){if(s.tag===13){var o=s.memoizedState;if(o===null&&(s=s.alternate,s!==null&&(o=s.memoizedState)),o!==null)return o.dehydrated}return null}function d(s){if(s.tag===31){var o=s.memoizedState;if(o===null&&(s=s.alternate,s!==null&&(o=s.memoizedState)),o!==null)return o.dehydrated}return null}function f(s){if(a(s)!==s)throw Error(r(188))}function h(s){var o=s.alternate;if(!o){if(o=a(s),o===null)throw Error(r(188));return o!==s?null:s}for(var u=s,m=o;;){var y=u.return;if(y===null)break;var b=y.alternate;if(b===null){if(m=y.return,m!==null){u=m;continue}break}if(y.child===b.child){for(b=y.child;b;){if(b===u)return f(y),s;if(b===m)return f(y),o;b=b.sibling}throw Error(r(188))}if(u.return!==m.return)u=y,m=b;else{for(var E=!1,O=y.child;O;){if(O===u){E=!0,u=y,m=b;break}if(O===m){E=!0,m=y,u=b;break}O=O.sibling}if(!E){for(O=b.child;O;){if(O===u){E=!0,u=b,m=y;break}if(O===m){E=!0,m=b,u=y;break}O=O.sibling}if(!E)throw Error(r(189))}}if(u.alternate!==m)throw Error(r(190))}if(u.tag!==3)throw Error(r(188));return u.stateNode.current===u?s:o}function p(s){var o=s.tag;if(o===5||o===26||o===27||o===6)return s;for(s=s.child;s!==null;){if(o=p(s),o!==null)return o;s=s.sibling}return null}var g=Object.assign,x=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),T=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),L=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function H(s){return s===null||typeof s!="object"?null:(s=G&&s[G]||s["@@iterator"],typeof s=="function"?s:null)}var R=Symbol.for("react.client.reference");function U(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===R?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case S:return"Fragment";case k:return"Profiler";case w:return"StrictMode";case P:return"Suspense";case M:return"SuspenseList";case J:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case v:return"Portal";case T:return s.displayName||"Context";case j:return(s._context.displayName||"Context")+".Consumer";case A:var o=s.render;return s=s.displayName,s||(s=o.displayName||o.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case q:return o=s.displayName||null,o!==null?o:U(s.type)||"Memo";case Z:o=s._payload,s=s._init;try{return U(s(o))}catch{}}return null}var D=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,$={pending:!1,data:null,method:null,action:null},se=[],B=-1;function V(s){return{current:s}}function K(s){0>B||(s.current=se[B],se[B]=null,B--)}function I(s,o){B++,se[B]=s.current,s.current=o}var Q=V(null),W=V(null),ee=V(null),ne=V(null);function Se(s,o){switch(I(ee,o),I(W,s),I(Q,null),o.nodeType){case 9:case 11:s=(s=o.documentElement)&&(s=s.namespaceURI)?m0(s):0;break;default:if(s=o.tagName,o=o.namespaceURI)o=m0(o),s=p0(o,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}K(Q),I(Q,s)}function le(){K(Q),K(W),K(ee)}function Ce(s){s.memoizedState!==null&&I(ne,s);var o=Q.current,u=p0(o,s.type);o!==u&&(I(W,s),I(Q,u))}function Re(s){W.current===s&&(K(Q),K(W)),ne.current===s&&(K(ne),Hl._currentValue=$)}var Oe,De;function Ue(s){if(Oe===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);Oe=o&&o[1]||"",De=-1<u.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+Oe+s+De}var it=!1;function st(s,o){if(!s||it)return"";it=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var m={DetermineComponentFrameRoot:function(){try{if(o){var ge=function(){throw Error()};if(Object.defineProperty(ge.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ge,[])}catch(oe){var ae=oe}Reflect.construct(s,[],ge)}else{try{ge.call()}catch(oe){ae=oe}s.call(ge.prototype)}}else{try{throw Error()}catch(oe){ae=oe}(ge=s())&&typeof ge.catch=="function"&&ge.catch(function(){})}}catch(oe){if(oe&&ae&&typeof oe.stack=="string")return[oe.stack,ae.stack]}return[null,null]}};m.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var y=Object.getOwnPropertyDescriptor(m.DetermineComponentFrameRoot,"name");y&&y.configurable&&Object.defineProperty(m.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var b=m.DetermineComponentFrameRoot(),E=b[0],O=b[1];if(E&&O){var Y=E.split(`
45
+ `),ie=O.split(`
46
+ `);for(y=m=0;m<Y.length&&!Y[m].includes("DetermineComponentFrameRoot");)m++;for(;y<ie.length&&!ie[y].includes("DetermineComponentFrameRoot");)y++;if(m===Y.length||y===ie.length)for(m=Y.length-1,y=ie.length-1;1<=m&&0<=y&&Y[m]!==ie[y];)y--;for(;1<=m&&0<=y;m--,y--)if(Y[m]!==ie[y]){if(m!==1||y!==1)do if(m--,y--,0>y||Y[m]!==ie[y]){var de=`
47
+ `+Y[m].replace(" at new "," at ");return s.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",s.displayName)),de}while(1<=m&&0<=y);break}}}finally{it=!1,Error.prepareStackTrace=u}return(u=s?s.displayName||s.name:"")?Ue(u):""}function ye(s,o){switch(s.tag){case 26:case 27:case 5:return Ue(s.type);case 16:return Ue("Lazy");case 13:return s.child!==o&&o!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return st(s.type,!1);case 11:return st(s.type.render,!1);case 1:return st(s.type,!0);case 31:return Ue("Activity");default:return""}}function ze(s){try{var o="",u=null;do o+=ye(s,u),u=s,s=s.return;while(s);return o}catch(m){return`
48
+ Error generating stack: `+m.message+`
49
+ `+m.stack}}var ve=Object.prototype.hasOwnProperty,ue=e.unstable_scheduleCallback,Ee=e.unstable_cancelCallback,_t=e.unstable_shouldYield,Ji=e.unstable_requestPaint,Yt=e.unstable_now,el=e.unstable_getCurrentPriorityLevel,me=e.unstable_ImmediatePriority,ke=e.unstable_UserBlockingPriority,$e=e.unstable_NormalPriority,Xe=e.unstable_LowPriority,ut=e.unstable_IdlePriority,un=e.log,Kn=e.unstable_setDisableYieldValue,zt=null,pt=null;function On(s){if(typeof un=="function"&&Kn(s),pt&&typeof pt.setStrictMode=="function")try{pt.setStrictMode(zt,s)}catch{}}var xt=Math.clz32?Math.clz32:Oa,Br=Math.log,sr=Math.LN2;function Oa(s){return s>>>=0,s===0?32:31-(Br(s)/sr|0)|0}var zr=256,Ia=262144,Pa=4194304;function Jr(s){var o=s&42;if(o!==0)return o;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 Ba(s,o,u){var m=s.pendingLanes;if(m===0)return 0;var y=0,b=s.suspendedLanes,E=s.pingedLanes;s=s.warmLanes;var O=m&134217727;return O!==0?(m=O&~b,m!==0?y=Jr(m):(E&=O,E!==0?y=Jr(E):u||(u=O&~s,u!==0&&(y=Jr(u))))):(O=m&~b,O!==0?y=Jr(O):E!==0?y=Jr(E):u||(u=m&~s,u!==0&&(y=Jr(u)))),y===0?0:o!==0&&o!==y&&(o&b)===0&&(b=y&-y,u=o&-o,b>=u||b===32&&(u&4194048)!==0)?o:y}function Fs(s,o){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&o)===0}function tl(s,o){switch(s){case 1:case 2:case 4:case 8:case 64:return o+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 o+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 Zc(){var s=Pa;return Pa<<=1,(Pa&62914560)===0&&(Pa=4194304),s}function za(s){for(var o=[],u=0;31>u;u++)o.push(s);return o}function Zi(s,o){s.pendingLanes|=o,o!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function fe(s,o,u,m,y,b){var E=s.pendingLanes;s.pendingLanes=u,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=u,s.entangledLanes&=u,s.errorRecoveryDisabledLanes&=u,s.shellSuspendCounter=0;var O=s.entanglements,Y=s.expirationTimes,ie=s.hiddenUpdates;for(u=E&~u;0<u;){var de=31-xt(u),ge=1<<de;O[de]=0,Y[de]=-1;var ae=ie[de];if(ae!==null)for(ie[de]=null,de=0;de<ae.length;de++){var oe=ae[de];oe!==null&&(oe.lane&=-536870913)}u&=~ge}m!==0&&he(s,m,0),b!==0&&y===0&&s.tag!==0&&(s.suspendedLanes|=b&~(E&~o))}function he(s,o,u){s.pendingLanes|=o,s.suspendedLanes&=~o;var m=31-xt(o);s.entangledLanes|=o,s.entanglements[m]=s.entanglements[m]|1073741824|u&261930}function Te(s,o){var u=s.entangledLanes|=o;for(s=s.entanglements;u;){var m=31-xt(u),y=1<<m;y&o|s[m]&o&&(s[m]|=o),u&=~y}}function Pe(s,o){var u=o&-o;return u=(u&42)!==0?1:Qe(u),(u&(s.suspendedLanes|o))!==0?0:u}function Qe(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 We(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function dt(){var s=F.p;return s!==0?s:(s=window.event,s===void 0?32:B0(s.type))}function jn(s,o){var u=F.p;try{return F.p=s,o()}finally{F.p=u}}var It=Math.random().toString(36).slice(2),yt="__reactFiber$"+It,Yn="__reactProps$"+It,$a="__reactContainer$"+It,af="__reactEvents$"+It,oj="__reactListeners$"+It,lj="__reactHandles$"+It,ty="__reactResources$"+It,nl="__reactMarker$"+It;function of(s){delete s[yt],delete s[Yn],delete s[af],delete s[oj],delete s[lj]}function Ha(s){var o=s[yt];if(o)return o;for(var u=s.parentNode;u;){if(o=u[$a]||u[yt]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(s=S0(s);s!==null;){if(u=s[yt])return u;s=S0(s)}return o}s=u,u=s.parentNode}return null}function Fa(s){if(s=s[yt]||s[$a]){var o=s.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return s}return null}function rl(s){var o=s.tag;if(o===5||o===26||o===27||o===6)return s.stateNode;throw Error(r(33))}function Ua(s){var o=s[ty];return o||(o=s[ty]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function yn(s){s[nl]=!0}var ny=new Set,ry={};function Us(s,o){Va(s,o),Va(s+"Capture",o)}function Va(s,o){for(ry[s]=o,s=0;s<o.length;s++)ny.add(o[s])}var cj=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]*$"),iy={},sy={};function uj(s){return ve.call(sy,s)?!0:ve.call(iy,s)?!1:cj.test(s)?sy[s]=!0:(iy[s]=!0,!1)}function eu(s,o,u){if(uj(o))if(u===null)s.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":s.removeAttribute(o);return;case"boolean":var m=o.toLowerCase().slice(0,5);if(m!=="data-"&&m!=="aria-"){s.removeAttribute(o);return}}s.setAttribute(o,""+u)}}function tu(s,o,u){if(u===null)s.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(o);return}s.setAttribute(o,""+u)}}function yi(s,o,u,m){if(m===null)s.removeAttribute(u);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(u);return}s.setAttributeNS(o,u,""+m)}}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 ay(s){var o=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function dj(s,o,u){var m=Object.getOwnPropertyDescriptor(s.constructor.prototype,o);if(!s.hasOwnProperty(o)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var y=m.get,b=m.set;return Object.defineProperty(s,o,{configurable:!0,get:function(){return y.call(this)},set:function(E){u=""+E,b.call(this,E)}}),Object.defineProperty(s,o,{enumerable:m.enumerable}),{getValue:function(){return u},setValue:function(E){u=""+E},stopTracking:function(){s._valueTracker=null,delete s[o]}}}}function lf(s){if(!s._valueTracker){var o=ay(s)?"checked":"value";s._valueTracker=dj(s,o,""+s[o])}}function oy(s){if(!s)return!1;var o=s._valueTracker;if(!o)return!0;var u=o.getValue(),m="";return s&&(m=ay(s)?s.checked?"true":"false":s.value),s=m,s!==u?(o.setValue(s),!0):!1}function nu(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 hj=/[\n"\\]/g;function vr(s){return s.replace(hj,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function cf(s,o,u,m,y,b,E,O){s.name="",E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?s.type=E:s.removeAttribute("type"),o!=null?E==="number"?(o===0&&s.value===""||s.value!=o)&&(s.value=""+yr(o)):s.value!==""+yr(o)&&(s.value=""+yr(o)):E!=="submit"&&E!=="reset"||s.removeAttribute("value"),o!=null?uf(s,E,yr(o)):u!=null?uf(s,E,yr(u)):m!=null&&s.removeAttribute("value"),y==null&&b!=null&&(s.defaultChecked=!!b),y!=null&&(s.checked=y&&typeof y!="function"&&typeof y!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?s.name=""+yr(O):s.removeAttribute("name")}function ly(s,o,u,m,y,b,E,O){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(s.type=b),o!=null||u!=null){if(!(b!=="submit"&&b!=="reset"||o!=null)){lf(s);return}u=u!=null?""+yr(u):"",o=o!=null?""+yr(o):u,O||o===s.value||(s.value=o),s.defaultValue=o}m=m??y,m=typeof m!="function"&&typeof m!="symbol"&&!!m,s.checked=O?s.checked:!!m,s.defaultChecked=!!m,E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(s.name=E),lf(s)}function uf(s,o,u){o==="number"&&nu(s.ownerDocument)===s||s.defaultValue===""+u||(s.defaultValue=""+u)}function Wa(s,o,u,m){if(s=s.options,o){o={};for(var y=0;y<u.length;y++)o["$"+u[y]]=!0;for(u=0;u<s.length;u++)y=o.hasOwnProperty("$"+s[u].value),s[u].selected!==y&&(s[u].selected=y),y&&m&&(s[u].defaultSelected=!0)}else{for(u=""+yr(u),o=null,y=0;y<s.length;y++){if(s[y].value===u){s[y].selected=!0,m&&(s[y].defaultSelected=!0);return}o!==null||s[y].disabled||(o=s[y])}o!==null&&(o.selected=!0)}}function cy(s,o,u){if(o!=null&&(o=""+yr(o),o!==s.value&&(s.value=o),u==null)){s.defaultValue!==o&&(s.defaultValue=o);return}s.defaultValue=u!=null?""+yr(u):""}function uy(s,o,u,m){if(o==null){if(m!=null){if(u!=null)throw Error(r(92));if(D(m)){if(1<m.length)throw Error(r(93));m=m[0]}u=m}u==null&&(u=""),o=u}u=yr(o),s.defaultValue=u,m=s.textContent,m===u&&m!==""&&m!==null&&(s.value=m),lf(s)}function Ga(s,o){if(o){var u=s.firstChild;if(u&&u===s.lastChild&&u.nodeType===3){u.nodeValue=o;return}}s.textContent=o}var fj=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 dy(s,o,u){var m=o.indexOf("--")===0;u==null||typeof u=="boolean"||u===""?m?s.setProperty(o,""):o==="float"?s.cssFloat="":s[o]="":m?s.setProperty(o,u):typeof u!="number"||u===0||fj.has(o)?o==="float"?s.cssFloat=u:s[o]=(""+u).trim():s[o]=u+"px"}function hy(s,o,u){if(o!=null&&typeof o!="object")throw Error(r(62));if(s=s.style,u!=null){for(var m in u)!u.hasOwnProperty(m)||o!=null&&o.hasOwnProperty(m)||(m.indexOf("--")===0?s.setProperty(m,""):m==="float"?s.cssFloat="":s[m]="");for(var y in o)m=o[y],o.hasOwnProperty(y)&&u[y]!==m&&dy(s,y,m)}else for(var b in o)o.hasOwnProperty(b)&&dy(s,b,o[b])}function df(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 mj=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"]]),pj=/^[\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 ru(s){return pj.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function vi(){}var hf=null;function ff(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var qa=null,Ka=null;function fy(s){var o=Fa(s);if(o&&(s=o.stateNode)){var u=s[Yn]||null;e:switch(s=o.stateNode,o.type){case"input":if(cf(s,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name),o=u.name,u.type==="radio"&&o!=null){for(u=s;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll('input[name="'+vr(""+o)+'"][type="radio"]'),o=0;o<u.length;o++){var m=u[o];if(m!==s&&m.form===s.form){var y=m[Yn]||null;if(!y)throw Error(r(90));cf(m,y.value,y.defaultValue,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name)}}for(o=0;o<u.length;o++)m=u[o],m.form===s.form&&oy(m)}break e;case"textarea":cy(s,u.value,u.defaultValue);break e;case"select":o=u.value,o!=null&&Wa(s,!!u.multiple,o,!1)}}}var mf=!1;function my(s,o,u){if(mf)return s(o,u);mf=!0;try{var m=s(o);return m}finally{if(mf=!1,(qa!==null||Ka!==null)&&(Vu(),qa&&(o=qa,s=Ka,Ka=qa=null,fy(o),s)))for(o=0;o<s.length;o++)fy(s[o])}}function il(s,o){var u=s.stateNode;if(u===null)return null;var m=u[Yn]||null;if(m===null)return null;u=m[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(s=s.type,m=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!m;break e;default:s=!1}if(s)return null;if(u&&typeof u!="function")throw Error(r(231,o,typeof u));return u}var bi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pf=!1;if(bi)try{var sl={};Object.defineProperty(sl,"passive",{get:function(){pf=!0}}),window.addEventListener("test",sl,sl),window.removeEventListener("test",sl,sl)}catch{pf=!1}var es=null,gf=null,iu=null;function py(){if(iu)return iu;var s,o=gf,u=o.length,m,y="value"in es?es.value:es.textContent,b=y.length;for(s=0;s<u&&o[s]===y[s];s++);var E=u-s;for(m=1;m<=E&&o[u-m]===y[b-m];m++);return iu=y.slice(s,1<m?1-m:void 0)}function su(s){var o=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&o===13&&(s=13)):s=o,s===10&&(s=13),32<=s||s===13?s:0}function au(){return!0}function gy(){return!1}function Xn(s){function o(u,m,y,b,E){this._reactName=u,this._targetInst=y,this.type=m,this.nativeEvent=b,this.target=E,this.currentTarget=null;for(var O in s)s.hasOwnProperty(O)&&(u=s[O],this[O]=u?u(b):b[O]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?au:gy,this.isPropagationStopped=gy,this}return g(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=au)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=au)},persist:function(){},isPersistent:au}),o}var Vs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ou=Xn(Vs),al=g({},Vs,{view:0,detail:0}),gj=Xn(al),_f,xf,ol,lu=g({},al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vf,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!==ol&&(ol&&s.type==="mousemove"?(_f=s.screenX-ol.screenX,xf=s.screenY-ol.screenY):xf=_f=0,ol=s),_f)},movementY:function(s){return"movementY"in s?s.movementY:xf}}),_y=Xn(lu),_j=g({},lu,{dataTransfer:0}),xj=Xn(_j),yj=g({},al,{relatedTarget:0}),yf=Xn(yj),vj=g({},Vs,{animationName:0,elapsedTime:0,pseudoElement:0}),bj=Xn(vj),Sj=g({},Vs,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),wj=Xn(Sj),Cj=g({},Vs,{data:0}),xy=Xn(Cj),kj={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ej={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"},Nj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function jj(s){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(s):(s=Nj[s])?!!o[s]:!1}function vf(){return jj}var Tj=g({},al,{key:function(s){if(s.key){var o=kj[s.key]||s.key;if(o!=="Unidentified")return o}return s.type==="keypress"?(s=su(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Ej[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vf,charCode:function(s){return s.type==="keypress"?su(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?su(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Aj=Xn(Tj),Dj=g({},lu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),yy=Xn(Dj),Lj=g({},al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vf}),Rj=Xn(Lj),Mj=g({},Vs,{propertyName:0,elapsedTime:0,pseudoElement:0}),Oj=Xn(Mj),Ij=g({},lu,{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}),Pj=Xn(Ij),Bj=g({},Vs,{newState:0,oldState:0}),zj=Xn(Bj),$j=[9,13,27,32],bf=bi&&"CompositionEvent"in window,ll=null;bi&&"documentMode"in document&&(ll=document.documentMode);var Hj=bi&&"TextEvent"in window&&!ll,vy=bi&&(!bf||ll&&8<ll&&11>=ll),by=" ",Sy=!1;function wy(s,o){switch(s){case"keyup":return $j.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cy(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Ya=!1;function Fj(s,o){switch(s){case"compositionend":return Cy(o);case"keypress":return o.which!==32?null:(Sy=!0,by);case"textInput":return s=o.data,s===by&&Sy?null:s;default:return null}}function Uj(s,o){if(Ya)return s==="compositionend"||!bf&&wy(s,o)?(s=py(),iu=gf=es=null,Ya=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return vy&&o.locale!=="ko"?null:o.data;default:return null}}var Vj={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 ky(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o==="input"?!!Vj[s.type]:o==="textarea"}function Ey(s,o,u,m){qa?Ka?Ka.push(m):Ka=[m]:qa=m,o=Qu(o,"onChange"),0<o.length&&(u=new ou("onChange","change",null,u,m),s.push({event:u,listeners:o}))}var cl=null,ul=null;function Wj(s){l0(s,0)}function cu(s){var o=rl(s);if(oy(o))return s}function Ny(s,o){if(s==="change")return o}var jy=!1;if(bi){var Sf;if(bi){var wf="oninput"in document;if(!wf){var Ty=document.createElement("div");Ty.setAttribute("oninput","return;"),wf=typeof Ty.oninput=="function"}Sf=wf}else Sf=!1;jy=Sf&&(!document.documentMode||9<document.documentMode)}function Ay(){cl&&(cl.detachEvent("onpropertychange",Dy),ul=cl=null)}function Dy(s){if(s.propertyName==="value"&&cu(ul)){var o=[];Ey(o,ul,s,ff(s)),my(Wj,o)}}function Gj(s,o,u){s==="focusin"?(Ay(),cl=o,ul=u,cl.attachEvent("onpropertychange",Dy)):s==="focusout"&&Ay()}function qj(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return cu(ul)}function Kj(s,o){if(s==="click")return cu(o)}function Yj(s,o){if(s==="input"||s==="change")return cu(o)}function Xj(s,o){return s===o&&(s!==0||1/s===1/o)||s!==s&&o!==o}var ar=typeof Object.is=="function"?Object.is:Xj;function dl(s,o){if(ar(s,o))return!0;if(typeof s!="object"||s===null||typeof o!="object"||o===null)return!1;var u=Object.keys(s),m=Object.keys(o);if(u.length!==m.length)return!1;for(m=0;m<u.length;m++){var y=u[m];if(!ve.call(o,y)||!ar(s[y],o[y]))return!1}return!0}function Ly(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Ry(s,o){var u=Ly(s);s=0;for(var m;u;){if(u.nodeType===3){if(m=s+u.textContent.length,s<=o&&m>=o)return{node:u,offset:o-s};s=m}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=Ly(u)}}function My(s,o){return s&&o?s===o?!0:s&&s.nodeType===3?!1:o&&o.nodeType===3?My(s,o.parentNode):"contains"in s?s.contains(o):s.compareDocumentPosition?!!(s.compareDocumentPosition(o)&16):!1:!1}function Oy(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var o=nu(s.document);o instanceof s.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)s=o.contentWindow;else break;o=nu(s.document)}return o}function Cf(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o&&(o==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||o==="textarea"||s.contentEditable==="true")}var Qj=bi&&"documentMode"in document&&11>=document.documentMode,Xa=null,kf=null,hl=null,Ef=!1;function Iy(s,o,u){var m=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;Ef||Xa==null||Xa!==nu(m)||(m=Xa,"selectionStart"in m&&Cf(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),hl&&dl(hl,m)||(hl=m,m=Qu(kf,"onSelect"),0<m.length&&(o=new ou("onSelect","select",null,o,u),s.push({event:o,listeners:m}),o.target=Xa)))}function Ws(s,o){var u={};return u[s.toLowerCase()]=o.toLowerCase(),u["Webkit"+s]="webkit"+o,u["Moz"+s]="moz"+o,u}var Qa={animationend:Ws("Animation","AnimationEnd"),animationiteration:Ws("Animation","AnimationIteration"),animationstart:Ws("Animation","AnimationStart"),transitionrun:Ws("Transition","TransitionRun"),transitionstart:Ws("Transition","TransitionStart"),transitioncancel:Ws("Transition","TransitionCancel"),transitionend:Ws("Transition","TransitionEnd")},Nf={},Py={};bi&&(Py=document.createElement("div").style,"AnimationEvent"in window||(delete Qa.animationend.animation,delete Qa.animationiteration.animation,delete Qa.animationstart.animation),"TransitionEvent"in window||delete Qa.transitionend.transition);function Gs(s){if(Nf[s])return Nf[s];if(!Qa[s])return s;var o=Qa[s],u;for(u in o)if(o.hasOwnProperty(u)&&u in Py)return Nf[s]=o[u];return s}var By=Gs("animationend"),zy=Gs("animationiteration"),$y=Gs("animationstart"),Jj=Gs("transitionrun"),Zj=Gs("transitionstart"),eT=Gs("transitioncancel"),Hy=Gs("transitionend"),Fy=new Map,jf="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(" ");jf.push("scrollEnd");function $r(s,o){Fy.set(s,o),Us(o,[s])}var uu=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=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(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},br=[],Ja=0,Tf=0;function du(){for(var s=Ja,o=Tf=Ja=0;o<s;){var u=br[o];br[o++]=null;var m=br[o];br[o++]=null;var y=br[o];br[o++]=null;var b=br[o];if(br[o++]=null,m!==null&&y!==null){var E=m.pending;E===null?y.next=y:(y.next=E.next,E.next=y),m.pending=y}b!==0&&Uy(u,y,b)}}function hu(s,o,u,m){br[Ja++]=s,br[Ja++]=o,br[Ja++]=u,br[Ja++]=m,Tf|=m,s.lanes|=m,s=s.alternate,s!==null&&(s.lanes|=m)}function Af(s,o,u,m){return hu(s,o,u,m),fu(s)}function qs(s,o){return hu(s,null,null,o),fu(s)}function Uy(s,o,u){s.lanes|=u;var m=s.alternate;m!==null&&(m.lanes|=u);for(var y=!1,b=s.return;b!==null;)b.childLanes|=u,m=b.alternate,m!==null&&(m.childLanes|=u),b.tag===22&&(s=b.stateNode,s===null||s._visibility&1||(y=!0)),s=b,b=b.return;return s.tag===3?(b=s.stateNode,y&&o!==null&&(y=31-xt(u),s=b.hiddenUpdates,m=s[y],m===null?s[y]=[o]:m.push(o),o.lane=u|536870912),b):null}function fu(s){if(50<Ml)throw Ml=0,zm=null,Error(r(185));for(var o=s.return;o!==null;)s=o,o=s.return;return s.tag===3?s.stateNode:null}var Za={};function tT(s,o,u,m){this.tag=s,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function or(s,o,u,m){return new tT(s,o,u,m)}function Df(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Si(s,o){var u=s.alternate;return u===null?(u=or(s.tag,o,s.key,s.mode),u.elementType=s.elementType,u.type=s.type,u.stateNode=s.stateNode,u.alternate=s,s.alternate=u):(u.pendingProps=o,u.type=s.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=s.flags&65011712,u.childLanes=s.childLanes,u.lanes=s.lanes,u.child=s.child,u.memoizedProps=s.memoizedProps,u.memoizedState=s.memoizedState,u.updateQueue=s.updateQueue,o=s.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=s.sibling,u.index=s.index,u.ref=s.ref,u.refCleanup=s.refCleanup,u}function Vy(s,o){s.flags&=65011714;var u=s.alternate;return u===null?(s.childLanes=0,s.lanes=o,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=u.childLanes,s.lanes=u.lanes,s.child=u.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=u.memoizedProps,s.memoizedState=u.memoizedState,s.updateQueue=u.updateQueue,s.type=u.type,o=u.dependencies,s.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),s}function mu(s,o,u,m,y,b){var E=0;if(m=s,typeof s=="function")Df(s)&&(E=1);else if(typeof s=="string")E=aA(s,u,Q.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case J:return s=or(31,u,o,y),s.elementType=J,s.lanes=b,s;case S:return Ks(u.children,y,b,o);case w:E=8,y|=24;break;case k:return s=or(12,u,o,y|2),s.elementType=k,s.lanes=b,s;case P:return s=or(13,u,o,y),s.elementType=P,s.lanes=b,s;case M:return s=or(19,u,o,y),s.elementType=M,s.lanes=b,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case T:E=10;break e;case j:E=9;break e;case A:E=11;break e;case q:E=14;break e;case Z:E=16,m=null;break e}E=29,u=Error(r(130,s===null?"null":typeof s,"")),m=null}return o=or(E,u,o,y),o.elementType=s,o.type=m,o.lanes=b,o}function Ks(s,o,u,m){return s=or(7,s,m,o),s.lanes=u,s}function Lf(s,o,u){return s=or(6,s,null,o),s.lanes=u,s}function Wy(s){var o=or(18,null,null,0);return o.stateNode=s,o}function Rf(s,o,u){return o=or(4,s.children!==null?s.children:[],s.key,o),o.lanes=u,o.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},o}var Gy=new WeakMap;function Sr(s,o){if(typeof s=="object"&&s!==null){var u=Gy.get(s);return u!==void 0?u:(o={value:s,source:o,stack:ze(o)},Gy.set(s,o),o)}return{value:s,source:o,stack:ze(o)}}var eo=[],to=0,pu=null,fl=0,wr=[],Cr=0,ts=null,Zr=1,ei="";function wi(s,o){eo[to++]=fl,eo[to++]=pu,pu=s,fl=o}function qy(s,o,u){wr[Cr++]=Zr,wr[Cr++]=ei,wr[Cr++]=ts,ts=s;var m=Zr;s=ei;var y=32-xt(m)-1;m&=~(1<<y),u+=1;var b=32-xt(o)+y;if(30<b){var E=y-y%5;b=(m&(1<<E)-1).toString(32),m>>=E,y-=E,Zr=1<<32-xt(o)+y|u<<y|m,ei=b+s}else Zr=1<<b|u<<y|m,ei=s}function Mf(s){s.return!==null&&(wi(s,1),qy(s,1,0))}function Of(s){for(;s===pu;)pu=eo[--to],eo[to]=null,fl=eo[--to],eo[to]=null;for(;s===ts;)ts=wr[--Cr],wr[Cr]=null,ei=wr[--Cr],wr[Cr]=null,Zr=wr[--Cr],wr[Cr]=null}function Ky(s,o){wr[Cr++]=Zr,wr[Cr++]=ei,wr[Cr++]=ts,Zr=o.id,ei=o.overflow,ts=s}var Tn=null,Lt=null,lt=!1,ns=null,kr=!1,If=Error(r(519));function rs(s){var o=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ml(Sr(o,s)),If}function Yy(s){var o=s.stateNode,u=s.type,m=s.memoizedProps;switch(o[yt]=s,o[Yn]=m,u){case"dialog":nt("cancel",o),nt("close",o);break;case"iframe":case"object":case"embed":nt("load",o);break;case"video":case"audio":for(u=0;u<Il.length;u++)nt(Il[u],o);break;case"source":nt("error",o);break;case"img":case"image":case"link":nt("error",o),nt("load",o);break;case"details":nt("toggle",o);break;case"input":nt("invalid",o),ly(o,m.value,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name,!0);break;case"select":nt("invalid",o);break;case"textarea":nt("invalid",o),uy(o,m.value,m.defaultValue,m.children)}u=m.children,typeof u!="string"&&typeof u!="number"&&typeof u!="bigint"||o.textContent===""+u||m.suppressHydrationWarning===!0||h0(o.textContent,u)?(m.popover!=null&&(nt("beforetoggle",o),nt("toggle",o)),m.onScroll!=null&&nt("scroll",o),m.onScrollEnd!=null&&nt("scrollend",o),m.onClick!=null&&(o.onclick=vi),o=!0):o=!1,o||rs(s,!0)}function Xy(s){for(Tn=s.return;Tn;)switch(Tn.tag){case 5:case 31:case 13:kr=!1;return;case 27:case 3:kr=!0;return;default:Tn=Tn.return}}function no(s){if(s!==Tn)return!1;if(!lt)return Xy(s),lt=!0,!1;var o=s.tag,u;if((u=o!==3&&o!==27)&&((u=o===5)&&(u=s.type,u=!(u!=="form"&&u!=="button")||ep(s.type,s.memoizedProps)),u=!u),u&&Lt&&rs(s),Xy(s),o===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Lt=b0(s)}else if(o===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Lt=b0(s)}else o===27?(o=Lt,_s(s.type)?(s=sp,sp=null,Lt=s):Lt=o):Lt=Tn?Nr(s.stateNode.nextSibling):null;return!0}function Ys(){Lt=Tn=null,lt=!1}function Pf(){var s=ns;return s!==null&&(er===null?er=s:er.push.apply(er,s),ns=null),s}function ml(s){ns===null?ns=[s]:ns.push(s)}var Bf=V(null),Xs=null,Ci=null;function is(s,o,u){I(Bf,o._currentValue),o._currentValue=u}function ki(s){s._currentValue=Bf.current,K(Bf)}function zf(s,o,u){for(;s!==null;){var m=s.alternate;if((s.childLanes&o)!==o?(s.childLanes|=o,m!==null&&(m.childLanes|=o)):m!==null&&(m.childLanes&o)!==o&&(m.childLanes|=o),s===u)break;s=s.return}}function $f(s,o,u,m){var y=s.child;for(y!==null&&(y.return=s);y!==null;){var b=y.dependencies;if(b!==null){var E=y.child;b=b.firstContext;e:for(;b!==null;){var O=b;b=y;for(var Y=0;Y<o.length;Y++)if(O.context===o[Y]){b.lanes|=u,O=b.alternate,O!==null&&(O.lanes|=u),zf(b.return,u,s),m||(E=null);break e}b=O.next}}else if(y.tag===18){if(E=y.return,E===null)throw Error(r(341));E.lanes|=u,b=E.alternate,b!==null&&(b.lanes|=u),zf(E,u,s),E=null}else E=y.child;if(E!==null)E.return=y;else for(E=y;E!==null;){if(E===s){E=null;break}if(y=E.sibling,y!==null){y.return=E.return,E=y;break}E=E.return}y=E}}function ro(s,o,u,m){s=null;for(var y=o,b=!1;y!==null;){if(!b){if((y.flags&524288)!==0)b=!0;else if((y.flags&262144)!==0)break}if(y.tag===10){var E=y.alternate;if(E===null)throw Error(r(387));if(E=E.memoizedProps,E!==null){var O=y.type;ar(y.pendingProps.value,E.value)||(s!==null?s.push(O):s=[O])}}else if(y===ne.current){if(E=y.alternate,E===null)throw Error(r(387));E.memoizedState.memoizedState!==y.memoizedState.memoizedState&&(s!==null?s.push(Hl):s=[Hl])}y=y.return}s!==null&&$f(o,s,u,m),o.flags|=262144}function gu(s){for(s=s.firstContext;s!==null;){if(!ar(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function Qs(s){Xs=s,Ci=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function An(s){return Qy(Xs,s)}function _u(s,o){return Xs===null&&Qs(s),Qy(s,o)}function Qy(s,o){var u=o._currentValue;if(o={context:o,memoizedValue:u,next:null},Ci===null){if(s===null)throw Error(r(308));Ci=o,s.dependencies={lanes:0,firstContext:o},s.flags|=524288}else Ci=Ci.next=o;return u}var nT=typeof AbortController<"u"?AbortController:function(){var s=[],o=this.signal={aborted:!1,addEventListener:function(u,m){s.push(m)}};this.abort=function(){o.aborted=!0,s.forEach(function(u){return u()})}},rT=e.unstable_scheduleCallback,iT=e.unstable_NormalPriority,nn={$$typeof:T,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Hf(){return{controller:new nT,data:new Map,refCount:0}}function pl(s){s.refCount--,s.refCount===0&&rT(iT,function(){s.controller.abort()})}var gl=null,Ff=0,io=0,so=null;function sT(s,o){if(gl===null){var u=gl=[];Ff=0,io=Wm(),so={status:"pending",value:void 0,then:function(m){u.push(m)}}}return Ff++,o.then(Jy,Jy),o}function Jy(){if(--Ff===0&&gl!==null){so!==null&&(so.status="fulfilled");var s=gl;gl=null,io=0,so=null;for(var o=0;o<s.length;o++)(0,s[o])()}}function aT(s,o){var u=[],m={status:"pending",value:null,reason:null,then:function(y){u.push(y)}};return s.then(function(){m.status="fulfilled",m.value=o;for(var y=0;y<u.length;y++)(0,u[y])(o)},function(y){for(m.status="rejected",m.reason=y,y=0;y<u.length;y++)(0,u[y])(void 0)}),m}var Zy=N.S;N.S=function(s,o){Ib=Yt(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&sT(s,o),Zy!==null&&Zy(s,o)};var Js=V(null);function Uf(){var s=Js.current;return s!==null?s:Et.pooledCache}function xu(s,o){o===null?I(Js,Js.current):I(Js,o.pool)}function ev(){var s=Uf();return s===null?null:{parent:nn._currentValue,pool:s}}var ao=Error(r(460)),Vf=Error(r(474)),yu=Error(r(542)),vu={then:function(){}};function tv(s){return s=s.status,s==="fulfilled"||s==="rejected"}function nv(s,o,u){switch(u=s[u],u===void 0?s.push(o):u!==o&&(o.then(vi,vi),o=u),o.status){case"fulfilled":return o.value;case"rejected":throw s=o.reason,iv(s),s;default:if(typeof o.status=="string")o.then(vi,vi);else{if(s=Et,s!==null&&100<s.shellSuspendCounter)throw Error(r(482));s=o,s.status="pending",s.then(function(m){if(o.status==="pending"){var y=o;y.status="fulfilled",y.value=m}},function(m){if(o.status==="pending"){var y=o;y.status="rejected",y.reason=m}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw s=o.reason,iv(s),s}throw ea=o,ao}}function Zs(s){try{var o=s._init;return o(s._payload)}catch(u){throw u!==null&&typeof u=="object"&&typeof u.then=="function"?(ea=u,ao):u}}var ea=null;function rv(){if(ea===null)throw Error(r(459));var s=ea;return ea=null,s}function iv(s){if(s===ao||s===yu)throw Error(r(483))}var oo=null,_l=0;function bu(s){var o=_l;return _l+=1,oo===null&&(oo=[]),nv(oo,s,o)}function xl(s,o){o=o.props.ref,s.ref=o!==void 0?o:null}function Su(s,o){throw o.$$typeof===x?Error(r(525)):(s=Object.prototype.toString.call(o),Error(r(31,s==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":s)))}function sv(s){function o(te,X){if(s){var re=te.deletions;re===null?(te.deletions=[X],te.flags|=16):re.push(X)}}function u(te,X){if(!s)return null;for(;X!==null;)o(te,X),X=X.sibling;return null}function m(te){for(var X=new Map;te!==null;)te.key!==null?X.set(te.key,te):X.set(te.index,te),te=te.sibling;return X}function y(te,X){return te=Si(te,X),te.index=0,te.sibling=null,te}function b(te,X,re){return te.index=re,s?(re=te.alternate,re!==null?(re=re.index,re<X?(te.flags|=67108866,X):re):(te.flags|=67108866,X)):(te.flags|=1048576,X)}function E(te){return s&&te.alternate===null&&(te.flags|=67108866),te}function O(te,X,re,pe){return X===null||X.tag!==6?(X=Lf(re,te.mode,pe),X.return=te,X):(X=y(X,re),X.return=te,X)}function Y(te,X,re,pe){var Ie=re.type;return Ie===S?de(te,X,re.props.children,pe,re.key):X!==null&&(X.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===Z&&Zs(Ie)===X.type)?(X=y(X,re.props),xl(X,re),X.return=te,X):(X=mu(re.type,re.key,re.props,null,te.mode,pe),xl(X,re),X.return=te,X)}function ie(te,X,re,pe){return X===null||X.tag!==4||X.stateNode.containerInfo!==re.containerInfo||X.stateNode.implementation!==re.implementation?(X=Rf(re,te.mode,pe),X.return=te,X):(X=y(X,re.children||[]),X.return=te,X)}function de(te,X,re,pe,Ie){return X===null||X.tag!==7?(X=Ks(re,te.mode,pe,Ie),X.return=te,X):(X=y(X,re),X.return=te,X)}function ge(te,X,re){if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return X=Lf(""+X,te.mode,re),X.return=te,X;if(typeof X=="object"&&X!==null){switch(X.$$typeof){case _:return re=mu(X.type,X.key,X.props,null,te.mode,re),xl(re,X),re.return=te,re;case v:return X=Rf(X,te.mode,re),X.return=te,X;case Z:return X=Zs(X),ge(te,X,re)}if(D(X)||H(X))return X=Ks(X,te.mode,re,null),X.return=te,X;if(typeof X.then=="function")return ge(te,bu(X),re);if(X.$$typeof===T)return ge(te,_u(te,X),re);Su(te,X)}return null}function ae(te,X,re,pe){var Ie=X!==null?X.key:null;if(typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint")return Ie!==null?null:O(te,X,""+re,pe);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case _:return re.key===Ie?Y(te,X,re,pe):null;case v:return re.key===Ie?ie(te,X,re,pe):null;case Z:return re=Zs(re),ae(te,X,re,pe)}if(D(re)||H(re))return Ie!==null?null:de(te,X,re,pe,null);if(typeof re.then=="function")return ae(te,X,bu(re),pe);if(re.$$typeof===T)return ae(te,X,_u(te,re),pe);Su(te,re)}return null}function oe(te,X,re,pe,Ie){if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return te=te.get(re)||null,O(X,te,""+pe,Ie);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case _:return te=te.get(pe.key===null?re:pe.key)||null,Y(X,te,pe,Ie);case v:return te=te.get(pe.key===null?re:pe.key)||null,ie(X,te,pe,Ie);case Z:return pe=Zs(pe),oe(te,X,re,pe,Ie)}if(D(pe)||H(pe))return te=te.get(re)||null,de(X,te,pe,Ie,null);if(typeof pe.then=="function")return oe(te,X,re,bu(pe),Ie);if(pe.$$typeof===T)return oe(te,X,re,_u(X,pe),Ie);Su(X,pe)}return null}function Ae(te,X,re,pe){for(var Ie=null,ht=null,Le=X,Ke=X=0,ot=null;Le!==null&&Ke<re.length;Ke++){Le.index>Ke?(ot=Le,Le=null):ot=Le.sibling;var ft=ae(te,Le,re[Ke],pe);if(ft===null){Le===null&&(Le=ot);break}s&&Le&&ft.alternate===null&&o(te,Le),X=b(ft,X,Ke),ht===null?Ie=ft:ht.sibling=ft,ht=ft,Le=ot}if(Ke===re.length)return u(te,Le),lt&&wi(te,Ke),Ie;if(Le===null){for(;Ke<re.length;Ke++)Le=ge(te,re[Ke],pe),Le!==null&&(X=b(Le,X,Ke),ht===null?Ie=Le:ht.sibling=Le,ht=Le);return lt&&wi(te,Ke),Ie}for(Le=m(Le);Ke<re.length;Ke++)ot=oe(Le,te,Ke,re[Ke],pe),ot!==null&&(s&&ot.alternate!==null&&Le.delete(ot.key===null?Ke:ot.key),X=b(ot,X,Ke),ht===null?Ie=ot:ht.sibling=ot,ht=ot);return s&&Le.forEach(function(Ss){return o(te,Ss)}),lt&&wi(te,Ke),Ie}function He(te,X,re,pe){if(re==null)throw Error(r(151));for(var Ie=null,ht=null,Le=X,Ke=X=0,ot=null,ft=re.next();Le!==null&&!ft.done;Ke++,ft=re.next()){Le.index>Ke?(ot=Le,Le=null):ot=Le.sibling;var Ss=ae(te,Le,ft.value,pe);if(Ss===null){Le===null&&(Le=ot);break}s&&Le&&Ss.alternate===null&&o(te,Le),X=b(Ss,X,Ke),ht===null?Ie=Ss:ht.sibling=Ss,ht=Ss,Le=ot}if(ft.done)return u(te,Le),lt&&wi(te,Ke),Ie;if(Le===null){for(;!ft.done;Ke++,ft=re.next())ft=ge(te,ft.value,pe),ft!==null&&(X=b(ft,X,Ke),ht===null?Ie=ft:ht.sibling=ft,ht=ft);return lt&&wi(te,Ke),Ie}for(Le=m(Le);!ft.done;Ke++,ft=re.next())ft=oe(Le,te,Ke,ft.value,pe),ft!==null&&(s&&ft.alternate!==null&&Le.delete(ft.key===null?Ke:ft.key),X=b(ft,X,Ke),ht===null?Ie=ft:ht.sibling=ft,ht=ft);return s&&Le.forEach(function(_A){return o(te,_A)}),lt&&wi(te,Ke),Ie}function Ct(te,X,re,pe){if(typeof re=="object"&&re!==null&&re.type===S&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case _:e:{for(var Ie=re.key;X!==null;){if(X.key===Ie){if(Ie=re.type,Ie===S){if(X.tag===7){u(te,X.sibling),pe=y(X,re.props.children),pe.return=te,te=pe;break e}}else if(X.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===Z&&Zs(Ie)===X.type){u(te,X.sibling),pe=y(X,re.props),xl(pe,re),pe.return=te,te=pe;break e}u(te,X);break}else o(te,X);X=X.sibling}re.type===S?(pe=Ks(re.props.children,te.mode,pe,re.key),pe.return=te,te=pe):(pe=mu(re.type,re.key,re.props,null,te.mode,pe),xl(pe,re),pe.return=te,te=pe)}return E(te);case v:e:{for(Ie=re.key;X!==null;){if(X.key===Ie)if(X.tag===4&&X.stateNode.containerInfo===re.containerInfo&&X.stateNode.implementation===re.implementation){u(te,X.sibling),pe=y(X,re.children||[]),pe.return=te,te=pe;break e}else{u(te,X);break}else o(te,X);X=X.sibling}pe=Rf(re,te.mode,pe),pe.return=te,te=pe}return E(te);case Z:return re=Zs(re),Ct(te,X,re,pe)}if(D(re))return Ae(te,X,re,pe);if(H(re)){if(Ie=H(re),typeof Ie!="function")throw Error(r(150));return re=Ie.call(re),He(te,X,re,pe)}if(typeof re.then=="function")return Ct(te,X,bu(re),pe);if(re.$$typeof===T)return Ct(te,X,_u(te,re),pe);Su(te,re)}return typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint"?(re=""+re,X!==null&&X.tag===6?(u(te,X.sibling),pe=y(X,re),pe.return=te,te=pe):(u(te,X),pe=Lf(re,te.mode,pe),pe.return=te,te=pe),E(te)):u(te,X)}return function(te,X,re,pe){try{_l=0;var Ie=Ct(te,X,re,pe);return oo=null,Ie}catch(Le){if(Le===ao||Le===yu)throw Le;var ht=or(29,Le,null,te.mode);return ht.lanes=pe,ht.return=te,ht}finally{}}}var ta=sv(!0),av=sv(!1),ss=!1;function Wf(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Gf(s,o){s=s.updateQueue,o.updateQueue===s&&(o.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function as(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function os(s,o,u){var m=s.updateQueue;if(m===null)return null;if(m=m.shared,(gt&2)!==0){var y=m.pending;return y===null?o.next=o:(o.next=y.next,y.next=o),m.pending=o,o=fu(s),Uy(s,null,u),o}return hu(s,m,o,u),fu(s)}function yl(s,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194048)!==0)){var m=o.lanes;m&=s.pendingLanes,u|=m,o.lanes=u,Te(s,u)}}function qf(s,o){var u=s.updateQueue,m=s.alternate;if(m!==null&&(m=m.updateQueue,u===m)){var y=null,b=null;if(u=u.firstBaseUpdate,u!==null){do{var E={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};b===null?y=b=E:b=b.next=E,u=u.next}while(u!==null);b===null?y=b=o:b=b.next=o}else y=b=o;u={baseState:m.baseState,firstBaseUpdate:y,lastBaseUpdate:b,shared:m.shared,callbacks:m.callbacks},s.updateQueue=u;return}s=u.lastBaseUpdate,s===null?u.firstBaseUpdate=o:s.next=o,u.lastBaseUpdate=o}var Kf=!1;function vl(){if(Kf){var s=so;if(s!==null)throw s}}function bl(s,o,u,m){Kf=!1;var y=s.updateQueue;ss=!1;var b=y.firstBaseUpdate,E=y.lastBaseUpdate,O=y.shared.pending;if(O!==null){y.shared.pending=null;var Y=O,ie=Y.next;Y.next=null,E===null?b=ie:E.next=ie,E=Y;var de=s.alternate;de!==null&&(de=de.updateQueue,O=de.lastBaseUpdate,O!==E&&(O===null?de.firstBaseUpdate=ie:O.next=ie,de.lastBaseUpdate=Y))}if(b!==null){var ge=y.baseState;E=0,de=ie=Y=null,O=b;do{var ae=O.lane&-536870913,oe=ae!==O.lane;if(oe?(at&ae)===ae:(m&ae)===ae){ae!==0&&ae===io&&(Kf=!0),de!==null&&(de=de.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var Ae=s,He=O;ae=o;var Ct=u;switch(He.tag){case 1:if(Ae=He.payload,typeof Ae=="function"){ge=Ae.call(Ct,ge,ae);break e}ge=Ae;break e;case 3:Ae.flags=Ae.flags&-65537|128;case 0:if(Ae=He.payload,ae=typeof Ae=="function"?Ae.call(Ct,ge,ae):Ae,ae==null)break e;ge=g({},ge,ae);break e;case 2:ss=!0}}ae=O.callback,ae!==null&&(s.flags|=64,oe&&(s.flags|=8192),oe=y.callbacks,oe===null?y.callbacks=[ae]:oe.push(ae))}else oe={lane:ae,tag:O.tag,payload:O.payload,callback:O.callback,next:null},de===null?(ie=de=oe,Y=ge):de=de.next=oe,E|=ae;if(O=O.next,O===null){if(O=y.shared.pending,O===null)break;oe=O,O=oe.next,oe.next=null,y.lastBaseUpdate=oe,y.shared.pending=null}}while(!0);de===null&&(Y=ge),y.baseState=Y,y.firstBaseUpdate=ie,y.lastBaseUpdate=de,b===null&&(y.shared.lanes=0),hs|=E,s.lanes=E,s.memoizedState=ge}}function ov(s,o){if(typeof s!="function")throw Error(r(191,s));s.call(o)}function lv(s,o){var u=s.callbacks;if(u!==null)for(s.callbacks=null,s=0;s<u.length;s++)ov(u[s],o)}var lo=V(null),wu=V(0);function cv(s,o){s=Mi,I(wu,s),I(lo,o),Mi=s|o.baseLanes}function Yf(){I(wu,Mi),I(lo,lo.current)}function Xf(){Mi=wu.current,K(lo),K(wu)}var lr=V(null),Er=null;function ls(s){var o=s.alternate;I(Xt,Xt.current&1),I(lr,s),Er===null&&(o===null||lo.current!==null||o.memoizedState!==null)&&(Er=s)}function Qf(s){I(Xt,Xt.current),I(lr,s),Er===null&&(Er=s)}function uv(s){s.tag===22?(I(Xt,Xt.current),I(lr,s),Er===null&&(Er=s)):cs()}function cs(){I(Xt,Xt.current),I(lr,lr.current)}function cr(s){K(lr),Er===s&&(Er=null),K(Xt)}var Xt=V(0);function Cu(s){for(var o=s;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||rp(u)||ip(u)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Ei=0,qe=null,St=null,rn=null,ku=!1,co=!1,na=!1,Eu=0,Sl=0,uo=null,oT=0;function Vt(){throw Error(r(321))}function Jf(s,o){if(o===null)return!1;for(var u=0;u<o.length&&u<s.length;u++)if(!ar(s[u],o[u]))return!1;return!0}function Zf(s,o,u,m,y,b){return Ei=b,qe=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,N.H=s===null||s.memoizedState===null?qv:mm,na=!1,b=u(m,y),na=!1,co&&(b=hv(o,u,m,y)),dv(s),b}function dv(s){N.H=kl;var o=St!==null&&St.next!==null;if(Ei=0,rn=St=qe=null,ku=!1,Sl=0,uo=null,o)throw Error(r(300));s===null||sn||(s=s.dependencies,s!==null&&gu(s)&&(sn=!0))}function hv(s,o,u,m){qe=s;var y=0;do{if(co&&(uo=null),Sl=0,co=!1,25<=y)throw Error(r(301));if(y+=1,rn=St=null,s.updateQueue!=null){var b=s.updateQueue;b.lastEffect=null,b.events=null,b.stores=null,b.memoCache!=null&&(b.memoCache.index=0)}N.H=Kv,b=o(u,m)}while(co);return b}function lT(){var s=N.H,o=s.useState()[0];return o=typeof o.then=="function"?wl(o):o,s=s.useState()[0],(St!==null?St.memoizedState:null)!==s&&(qe.flags|=1024),o}function em(){var s=Eu!==0;return Eu=0,s}function tm(s,o,u){o.updateQueue=s.updateQueue,o.flags&=-2053,s.lanes&=~u}function nm(s){if(ku){for(s=s.memoizedState;s!==null;){var o=s.queue;o!==null&&(o.pending=null),s=s.next}ku=!1}Ei=0,rn=St=qe=null,co=!1,Sl=Eu=0,uo=null}function Fn(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rn===null?qe.memoizedState=rn=s:rn=rn.next=s,rn}function Qt(){if(St===null){var s=qe.alternate;s=s!==null?s.memoizedState:null}else s=St.next;var o=rn===null?qe.memoizedState:rn.next;if(o!==null)rn=o,St=s;else{if(s===null)throw qe.alternate===null?Error(r(467)):Error(r(310));St=s,s={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},rn===null?qe.memoizedState=rn=s:rn=rn.next=s}return rn}function Nu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wl(s){var o=Sl;return Sl+=1,uo===null&&(uo=[]),s=nv(uo,s,o),o=qe,(rn===null?o.memoizedState:rn.next)===null&&(o=o.alternate,N.H=o===null||o.memoizedState===null?qv:mm),s}function ju(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return wl(s);if(s.$$typeof===T)return An(s)}throw Error(r(438,String(s)))}function rm(s){var o=null,u=qe.updateQueue;if(u!==null&&(o=u.memoCache),o==null){var m=qe.alternate;m!==null&&(m=m.updateQueue,m!==null&&(m=m.memoCache,m!=null&&(o={data:m.data.map(function(y){return y.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),u===null&&(u=Nu(),qe.updateQueue=u),u.memoCache=o,u=o.data[o.index],u===void 0)for(u=o.data[o.index]=Array(s),m=0;m<s;m++)u[m]=L;return o.index++,u}function Ni(s,o){return typeof o=="function"?o(s):o}function Tu(s){var o=Qt();return im(o,St,s)}function im(s,o,u){var m=s.queue;if(m===null)throw Error(r(311));m.lastRenderedReducer=u;var y=s.baseQueue,b=m.pending;if(b!==null){if(y!==null){var E=y.next;y.next=b.next,b.next=E}o.baseQueue=y=b,m.pending=null}if(b=s.baseState,y===null)s.memoizedState=b;else{o=y.next;var O=E=null,Y=null,ie=o,de=!1;do{var ge=ie.lane&-536870913;if(ge!==ie.lane?(at&ge)===ge:(Ei&ge)===ge){var ae=ie.revertLane;if(ae===0)Y!==null&&(Y=Y.next={lane:0,revertLane:0,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),ge===io&&(de=!0);else if((Ei&ae)===ae){ie=ie.next,ae===io&&(de=!0);continue}else ge={lane:0,revertLane:ie.revertLane,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},Y===null?(O=Y=ge,E=b):Y=Y.next=ge,qe.lanes|=ae,hs|=ae;ge=ie.action,na&&u(b,ge),b=ie.hasEagerState?ie.eagerState:u(b,ge)}else ae={lane:ge,revertLane:ie.revertLane,gesture:ie.gesture,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},Y===null?(O=Y=ae,E=b):Y=Y.next=ae,qe.lanes|=ge,hs|=ge;ie=ie.next}while(ie!==null&&ie!==o);if(Y===null?E=b:Y.next=O,!ar(b,s.memoizedState)&&(sn=!0,de&&(u=so,u!==null)))throw u;s.memoizedState=b,s.baseState=E,s.baseQueue=Y,m.lastRenderedState=b}return y===null&&(m.lanes=0),[s.memoizedState,m.dispatch]}function sm(s){var o=Qt(),u=o.queue;if(u===null)throw Error(r(311));u.lastRenderedReducer=s;var m=u.dispatch,y=u.pending,b=o.memoizedState;if(y!==null){u.pending=null;var E=y=y.next;do b=s(b,E.action),E=E.next;while(E!==y);ar(b,o.memoizedState)||(sn=!0),o.memoizedState=b,o.baseQueue===null&&(o.baseState=b),u.lastRenderedState=b}return[b,m]}function fv(s,o,u){var m=qe,y=Qt(),b=lt;if(b){if(u===void 0)throw Error(r(407));u=u()}else u=o();var E=!ar((St||y).memoizedState,u);if(E&&(y.memoizedState=u,sn=!0),y=y.queue,lm(gv.bind(null,m,y,s),[s]),y.getSnapshot!==o||E||rn!==null&&rn.memoizedState.tag&1){if(m.flags|=2048,ho(9,{destroy:void 0},pv.bind(null,m,y,u,o),null),Et===null)throw Error(r(349));b||(Ei&127)!==0||mv(m,o,u)}return u}function mv(s,o,u){s.flags|=16384,s={getSnapshot:o,value:u},o=qe.updateQueue,o===null?(o=Nu(),qe.updateQueue=o,o.stores=[s]):(u=o.stores,u===null?o.stores=[s]:u.push(s))}function pv(s,o,u,m){o.value=u,o.getSnapshot=m,_v(o)&&xv(s)}function gv(s,o,u){return u(function(){_v(o)&&xv(s)})}function _v(s){var o=s.getSnapshot;s=s.value;try{var u=o();return!ar(s,u)}catch{return!0}}function xv(s){var o=qs(s,2);o!==null&&tr(o,s,2)}function am(s){var o=Fn();if(typeof s=="function"){var u=s;if(s=u(),na){On(!0);try{u()}finally{On(!1)}}}return o.memoizedState=o.baseState=s,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ni,lastRenderedState:s},o}function yv(s,o,u,m){return s.baseState=u,im(s,St,typeof m=="function"?m:Ni)}function cT(s,o,u,m,y){if(Lu(s))throw Error(r(485));if(s=o.action,s!==null){var b={payload:y,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(E){b.listeners.push(E)}};N.T!==null?u(!0):b.isTransition=!1,m(b),u=o.pending,u===null?(b.next=o.pending=b,vv(o,b)):(b.next=u.next,o.pending=u.next=b)}}function vv(s,o){var u=o.action,m=o.payload,y=s.state;if(o.isTransition){var b=N.T,E={};N.T=E;try{var O=u(y,m),Y=N.S;Y!==null&&Y(E,O),bv(s,o,O)}catch(ie){om(s,o,ie)}finally{b!==null&&E.types!==null&&(b.types=E.types),N.T=b}}else try{b=u(y,m),bv(s,o,b)}catch(ie){om(s,o,ie)}}function bv(s,o,u){u!==null&&typeof u=="object"&&typeof u.then=="function"?u.then(function(m){Sv(s,o,m)},function(m){return om(s,o,m)}):Sv(s,o,u)}function Sv(s,o,u){o.status="fulfilled",o.value=u,wv(o),s.state=u,o=s.pending,o!==null&&(u=o.next,u===o?s.pending=null:(u=u.next,o.next=u,vv(s,u)))}function om(s,o,u){var m=s.pending;if(s.pending=null,m!==null){m=m.next;do o.status="rejected",o.reason=u,wv(o),o=o.next;while(o!==m)}s.action=null}function wv(s){s=s.listeners;for(var o=0;o<s.length;o++)(0,s[o])()}function Cv(s,o){return o}function kv(s,o){if(lt){var u=Et.formState;if(u!==null){e:{var m=qe;if(lt){if(Lt){t:{for(var y=Lt,b=kr;y.nodeType!==8;){if(!b){y=null;break t}if(y=Nr(y.nextSibling),y===null){y=null;break t}}b=y.data,y=b==="F!"||b==="F"?y:null}if(y){Lt=Nr(y.nextSibling),m=y.data==="F!";break e}}rs(m)}m=!1}m&&(o=u[0])}}return u=Fn(),u.memoizedState=u.baseState=o,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cv,lastRenderedState:o},u.queue=m,u=Vv.bind(null,qe,m),m.dispatch=u,m=am(!1),b=fm.bind(null,qe,!1,m.queue),m=Fn(),y={state:o,dispatch:null,action:s,pending:null},m.queue=y,u=cT.bind(null,qe,y,b,u),y.dispatch=u,m.memoizedState=s,[o,u,!1]}function Ev(s){var o=Qt();return Nv(o,St,s)}function Nv(s,o,u){if(o=im(s,o,Cv)[0],s=Tu(Ni)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var m=wl(o)}catch(E){throw E===ao?yu:E}else m=o;o=Qt();var y=o.queue,b=y.dispatch;return u!==o.memoizedState&&(qe.flags|=2048,ho(9,{destroy:void 0},uT.bind(null,y,u),null)),[m,b,s]}function uT(s,o){s.action=o}function jv(s){var o=Qt(),u=St;if(u!==null)return Nv(o,u,s);Qt(),o=o.memoizedState,u=Qt();var m=u.queue.dispatch;return u.memoizedState=s,[o,m,!1]}function ho(s,o,u,m){return s={tag:s,create:u,deps:m,inst:o,next:null},o=qe.updateQueue,o===null&&(o=Nu(),qe.updateQueue=o),u=o.lastEffect,u===null?o.lastEffect=s.next=s:(m=u.next,u.next=s,s.next=m,o.lastEffect=s),s}function Tv(){return Qt().memoizedState}function Au(s,o,u,m){var y=Fn();qe.flags|=s,y.memoizedState=ho(1|o,{destroy:void 0},u,m===void 0?null:m)}function Du(s,o,u,m){var y=Qt();m=m===void 0?null:m;var b=y.memoizedState.inst;St!==null&&m!==null&&Jf(m,St.memoizedState.deps)?y.memoizedState=ho(o,b,u,m):(qe.flags|=s,y.memoizedState=ho(1|o,b,u,m))}function Av(s,o){Au(8390656,8,s,o)}function lm(s,o){Du(2048,8,s,o)}function dT(s){qe.flags|=4;var o=qe.updateQueue;if(o===null)o=Nu(),qe.updateQueue=o,o.events=[s];else{var u=o.events;u===null?o.events=[s]:u.push(s)}}function Dv(s){var o=Qt().memoizedState;return dT({ref:o,nextImpl:s}),function(){if((gt&2)!==0)throw Error(r(440));return o.impl.apply(void 0,arguments)}}function Lv(s,o){return Du(4,2,s,o)}function Rv(s,o){return Du(4,4,s,o)}function Mv(s,o){if(typeof o=="function"){s=s();var u=o(s);return function(){typeof u=="function"?u():o(null)}}if(o!=null)return s=s(),o.current=s,function(){o.current=null}}function Ov(s,o,u){u=u!=null?u.concat([s]):null,Du(4,4,Mv.bind(null,o,s),u)}function cm(){}function Iv(s,o){var u=Qt();o=o===void 0?null:o;var m=u.memoizedState;return o!==null&&Jf(o,m[1])?m[0]:(u.memoizedState=[s,o],s)}function Pv(s,o){var u=Qt();o=o===void 0?null:o;var m=u.memoizedState;if(o!==null&&Jf(o,m[1]))return m[0];if(m=s(),na){On(!0);try{s()}finally{On(!1)}}return u.memoizedState=[m,o],m}function um(s,o,u){return u===void 0||(Ei&1073741824)!==0&&(at&261930)===0?s.memoizedState=o:(s.memoizedState=u,s=Bb(),qe.lanes|=s,hs|=s,u)}function Bv(s,o,u,m){return ar(u,o)?u:lo.current!==null?(s=um(s,u,m),ar(s,o)||(sn=!0),s):(Ei&42)===0||(Ei&1073741824)!==0&&(at&261930)===0?(sn=!0,s.memoizedState=u):(s=Bb(),qe.lanes|=s,hs|=s,o)}function zv(s,o,u,m,y){var b=F.p;F.p=b!==0&&8>b?b:8;var E=N.T,O={};N.T=O,fm(s,!1,o,u);try{var Y=y(),ie=N.S;if(ie!==null&&ie(O,Y),Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var de=aT(Y,m);Cl(s,o,de,hr(s))}else Cl(s,o,m,hr(s))}catch(ge){Cl(s,o,{then:function(){},status:"rejected",reason:ge},hr())}finally{F.p=b,E!==null&&O.types!==null&&(E.types=O.types),N.T=E}}function hT(){}function dm(s,o,u,m){if(s.tag!==5)throw Error(r(476));var y=$v(s).queue;zv(s,y,o,$,u===null?hT:function(){return Hv(s),u(m)})}function $v(s){var o=s.memoizedState;if(o!==null)return o;o={memoizedState:$,baseState:$,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ni,lastRenderedState:$},next:null};var u={};return o.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ni,lastRenderedState:u},next:null},s.memoizedState=o,s=s.alternate,s!==null&&(s.memoizedState=o),o}function Hv(s){var o=$v(s);o.next===null&&(o=s.alternate.memoizedState),Cl(s,o.next.queue,{},hr())}function hm(){return An(Hl)}function Fv(){return Qt().memoizedState}function Uv(){return Qt().memoizedState}function fT(s){for(var o=s.return;o!==null;){switch(o.tag){case 24:case 3:var u=hr();s=as(u);var m=os(o,s,u);m!==null&&(tr(m,o,u),yl(m,o,u)),o={cache:Hf()},s.payload=o;return}o=o.return}}function mT(s,o,u){var m=hr();u={lane:m,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Lu(s)?Wv(o,u):(u=Af(s,o,u,m),u!==null&&(tr(u,s,m),Gv(u,o,m)))}function Vv(s,o,u){var m=hr();Cl(s,o,u,m)}function Cl(s,o,u,m){var y={lane:m,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Lu(s))Wv(o,y);else{var b=s.alternate;if(s.lanes===0&&(b===null||b.lanes===0)&&(b=o.lastRenderedReducer,b!==null))try{var E=o.lastRenderedState,O=b(E,u);if(y.hasEagerState=!0,y.eagerState=O,ar(O,E))return hu(s,o,y,0),Et===null&&du(),!1}catch{}finally{}if(u=Af(s,o,y,m),u!==null)return tr(u,s,m),Gv(u,o,m),!0}return!1}function fm(s,o,u,m){if(m={lane:2,revertLane:Wm(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},Lu(s)){if(o)throw Error(r(479))}else o=Af(s,u,m,2),o!==null&&tr(o,s,2)}function Lu(s){var o=s.alternate;return s===qe||o!==null&&o===qe}function Wv(s,o){co=ku=!0;var u=s.pending;u===null?o.next=o:(o.next=u.next,u.next=o),s.pending=o}function Gv(s,o,u){if((u&4194048)!==0){var m=o.lanes;m&=s.pendingLanes,u|=m,o.lanes=u,Te(s,u)}}var kl={readContext:An,use:ju,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useLayoutEffect:Vt,useInsertionEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useSyncExternalStore:Vt,useId:Vt,useHostTransitionStatus:Vt,useFormState:Vt,useActionState:Vt,useOptimistic:Vt,useMemoCache:Vt,useCacheRefresh:Vt};kl.useEffectEvent=Vt;var qv={readContext:An,use:ju,useCallback:function(s,o){return Fn().memoizedState=[s,o===void 0?null:o],s},useContext:An,useEffect:Av,useImperativeHandle:function(s,o,u){u=u!=null?u.concat([s]):null,Au(4194308,4,Mv.bind(null,o,s),u)},useLayoutEffect:function(s,o){return Au(4194308,4,s,o)},useInsertionEffect:function(s,o){Au(4,2,s,o)},useMemo:function(s,o){var u=Fn();o=o===void 0?null:o;var m=s();if(na){On(!0);try{s()}finally{On(!1)}}return u.memoizedState=[m,o],m},useReducer:function(s,o,u){var m=Fn();if(u!==void 0){var y=u(o);if(na){On(!0);try{u(o)}finally{On(!1)}}}else y=o;return m.memoizedState=m.baseState=y,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:y},m.queue=s,s=s.dispatch=mT.bind(null,qe,s),[m.memoizedState,s]},useRef:function(s){var o=Fn();return s={current:s},o.memoizedState=s},useState:function(s){s=am(s);var o=s.queue,u=Vv.bind(null,qe,o);return o.dispatch=u,[s.memoizedState,u]},useDebugValue:cm,useDeferredValue:function(s,o){var u=Fn();return um(u,s,o)},useTransition:function(){var s=am(!1);return s=zv.bind(null,qe,s.queue,!0,!1),Fn().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,o,u){var m=qe,y=Fn();if(lt){if(u===void 0)throw Error(r(407));u=u()}else{if(u=o(),Et===null)throw Error(r(349));(at&127)!==0||mv(m,o,u)}y.memoizedState=u;var b={value:u,getSnapshot:o};return y.queue=b,Av(gv.bind(null,m,b,s),[s]),m.flags|=2048,ho(9,{destroy:void 0},pv.bind(null,m,b,u,o),null),u},useId:function(){var s=Fn(),o=Et.identifierPrefix;if(lt){var u=ei,m=Zr;u=(m&~(1<<32-xt(m)-1)).toString(32)+u,o="_"+o+"R_"+u,u=Eu++,0<u&&(o+="H"+u.toString(32)),o+="_"}else u=oT++,o="_"+o+"r_"+u.toString(32)+"_";return s.memoizedState=o},useHostTransitionStatus:hm,useFormState:kv,useActionState:kv,useOptimistic:function(s){var o=Fn();o.memoizedState=o.baseState=s;var u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=u,o=fm.bind(null,qe,!0,u),u.dispatch=o,[s,o]},useMemoCache:rm,useCacheRefresh:function(){return Fn().memoizedState=fT.bind(null,qe)},useEffectEvent:function(s){var o=Fn(),u={impl:s};return o.memoizedState=u,function(){if((gt&2)!==0)throw Error(r(440));return u.impl.apply(void 0,arguments)}}},mm={readContext:An,use:ju,useCallback:Iv,useContext:An,useEffect:lm,useImperativeHandle:Ov,useInsertionEffect:Lv,useLayoutEffect:Rv,useMemo:Pv,useReducer:Tu,useRef:Tv,useState:function(){return Tu(Ni)},useDebugValue:cm,useDeferredValue:function(s,o){var u=Qt();return Bv(u,St.memoizedState,s,o)},useTransition:function(){var s=Tu(Ni)[0],o=Qt().memoizedState;return[typeof s=="boolean"?s:wl(s),o]},useSyncExternalStore:fv,useId:Fv,useHostTransitionStatus:hm,useFormState:Ev,useActionState:Ev,useOptimistic:function(s,o){var u=Qt();return yv(u,St,s,o)},useMemoCache:rm,useCacheRefresh:Uv};mm.useEffectEvent=Dv;var Kv={readContext:An,use:ju,useCallback:Iv,useContext:An,useEffect:lm,useImperativeHandle:Ov,useInsertionEffect:Lv,useLayoutEffect:Rv,useMemo:Pv,useReducer:sm,useRef:Tv,useState:function(){return sm(Ni)},useDebugValue:cm,useDeferredValue:function(s,o){var u=Qt();return St===null?um(u,s,o):Bv(u,St.memoizedState,s,o)},useTransition:function(){var s=sm(Ni)[0],o=Qt().memoizedState;return[typeof s=="boolean"?s:wl(s),o]},useSyncExternalStore:fv,useId:Fv,useHostTransitionStatus:hm,useFormState:jv,useActionState:jv,useOptimistic:function(s,o){var u=Qt();return St!==null?yv(u,St,s,o):(u.baseState=s,[s,u.queue.dispatch])},useMemoCache:rm,useCacheRefresh:Uv};Kv.useEffectEvent=Dv;function pm(s,o,u,m){o=s.memoizedState,u=u(m,o),u=u==null?o:g({},o,u),s.memoizedState=u,s.lanes===0&&(s.updateQueue.baseState=u)}var gm={enqueueSetState:function(s,o,u){s=s._reactInternals;var m=hr(),y=as(m);y.payload=o,u!=null&&(y.callback=u),o=os(s,y,m),o!==null&&(tr(o,s,m),yl(o,s,m))},enqueueReplaceState:function(s,o,u){s=s._reactInternals;var m=hr(),y=as(m);y.tag=1,y.payload=o,u!=null&&(y.callback=u),o=os(s,y,m),o!==null&&(tr(o,s,m),yl(o,s,m))},enqueueForceUpdate:function(s,o){s=s._reactInternals;var u=hr(),m=as(u);m.tag=2,o!=null&&(m.callback=o),o=os(s,m,u),o!==null&&(tr(o,s,u),yl(o,s,u))}};function Yv(s,o,u,m,y,b,E){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(m,b,E):o.prototype&&o.prototype.isPureReactComponent?!dl(u,m)||!dl(y,b):!0}function Xv(s,o,u,m){s=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,m),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,m),o.state!==s&&gm.enqueueReplaceState(o,o.state,null)}function ra(s,o){var u=o;if("ref"in o){u={};for(var m in o)m!=="ref"&&(u[m]=o[m])}if(s=s.defaultProps){u===o&&(u=g({},u));for(var y in s)u[y]===void 0&&(u[y]=s[y])}return u}function Qv(s){uu(s)}function Jv(s){console.error(s)}function Zv(s){uu(s)}function Ru(s,o){try{var u=s.onUncaughtError;u(o.value,{componentStack:o.stack})}catch(m){setTimeout(function(){throw m})}}function eb(s,o,u){try{var m=s.onCaughtError;m(u.value,{componentStack:u.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(y){setTimeout(function(){throw y})}}function _m(s,o,u){return u=as(u),u.tag=3,u.payload={element:null},u.callback=function(){Ru(s,o)},u}function tb(s){return s=as(s),s.tag=3,s}function nb(s,o,u,m){var y=u.type.getDerivedStateFromError;if(typeof y=="function"){var b=m.value;s.payload=function(){return y(b)},s.callback=function(){eb(o,u,m)}}var E=u.stateNode;E!==null&&typeof E.componentDidCatch=="function"&&(s.callback=function(){eb(o,u,m),typeof y!="function"&&(fs===null?fs=new Set([this]):fs.add(this));var O=m.stack;this.componentDidCatch(m.value,{componentStack:O!==null?O:""})})}function pT(s,o,u,m,y){if(u.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(o=u.alternate,o!==null&&ro(o,u,y,!0),u=lr.current,u!==null){switch(u.tag){case 31:case 13:return Er===null?Wu():u.alternate===null&&Wt===0&&(Wt=3),u.flags&=-257,u.flags|=65536,u.lanes=y,m===vu?u.flags|=16384:(o=u.updateQueue,o===null?u.updateQueue=new Set([m]):o.add(m),Fm(s,m,y)),!1;case 22:return u.flags|=65536,m===vu?u.flags|=16384:(o=u.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([m])},u.updateQueue=o):(u=o.retryQueue,u===null?o.retryQueue=new Set([m]):u.add(m)),Fm(s,m,y)),!1}throw Error(r(435,u.tag))}return Fm(s,m,y),Wu(),!1}if(lt)return o=lr.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=y,m!==If&&(s=Error(r(422),{cause:m}),ml(Sr(s,u)))):(m!==If&&(o=Error(r(423),{cause:m}),ml(Sr(o,u))),s=s.current.alternate,s.flags|=65536,y&=-y,s.lanes|=y,m=Sr(m,u),y=_m(s.stateNode,m,y),qf(s,y),Wt!==4&&(Wt=2)),!1;var b=Error(r(520),{cause:m});if(b=Sr(b,u),Rl===null?Rl=[b]:Rl.push(b),Wt!==4&&(Wt=2),o===null)return!0;m=Sr(m,u),u=o;do{switch(u.tag){case 3:return u.flags|=65536,s=y&-y,u.lanes|=s,s=_m(u.stateNode,m,s),qf(u,s),!1;case 1:if(o=u.type,b=u.stateNode,(u.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(fs===null||!fs.has(b))))return u.flags|=65536,y&=-y,u.lanes|=y,y=tb(y),nb(y,s,u,m),qf(u,y),!1}u=u.return}while(u!==null);return!1}var xm=Error(r(461)),sn=!1;function Dn(s,o,u,m){o.child=s===null?av(o,null,u,m):ta(o,s.child,u,m)}function rb(s,o,u,m,y){u=u.render;var b=o.ref;if("ref"in m){var E={};for(var O in m)O!=="ref"&&(E[O]=m[O])}else E=m;return Qs(o),m=Zf(s,o,u,E,b,y),O=em(),s!==null&&!sn?(tm(s,o,y),ji(s,o,y)):(lt&&O&&Mf(o),o.flags|=1,Dn(s,o,m,y),o.child)}function ib(s,o,u,m,y){if(s===null){var b=u.type;return typeof b=="function"&&!Df(b)&&b.defaultProps===void 0&&u.compare===null?(o.tag=15,o.type=b,sb(s,o,b,m,y)):(s=mu(u.type,null,m,o,o.mode,y),s.ref=o.ref,s.return=o,o.child=s)}if(b=s.child,!Em(s,y)){var E=b.memoizedProps;if(u=u.compare,u=u!==null?u:dl,u(E,m)&&s.ref===o.ref)return ji(s,o,y)}return o.flags|=1,s=Si(b,m),s.ref=o.ref,s.return=o,o.child=s}function sb(s,o,u,m,y){if(s!==null){var b=s.memoizedProps;if(dl(b,m)&&s.ref===o.ref)if(sn=!1,o.pendingProps=m=b,Em(s,y))(s.flags&131072)!==0&&(sn=!0);else return o.lanes=s.lanes,ji(s,o,y)}return ym(s,o,u,m,y)}function ab(s,o,u,m){var y=m.children,b=s!==null?s.memoizedState:null;if(s===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.mode==="hidden"){if((o.flags&128)!==0){if(b=b!==null?b.baseLanes|u:u,s!==null){for(m=o.child=s.child,y=0;m!==null;)y=y|m.lanes|m.childLanes,m=m.sibling;m=y&~b}else m=0,o.child=null;return ob(s,o,b,u,m)}if((u&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},s!==null&&xu(o,b!==null?b.cachePool:null),b!==null?cv(o,b):Yf(),uv(o);else return m=o.lanes=536870912,ob(s,o,b!==null?b.baseLanes|u:u,u,m)}else b!==null?(xu(o,b.cachePool),cv(o,b),cs(),o.memoizedState=null):(s!==null&&xu(o,null),Yf(),cs());return Dn(s,o,y,u),o.child}function El(s,o){return s!==null&&s.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function ob(s,o,u,m,y){var b=Uf();return b=b===null?null:{parent:nn._currentValue,pool:b},o.memoizedState={baseLanes:u,cachePool:b},s!==null&&xu(o,null),Yf(),uv(o),s!==null&&ro(s,o,m,!0),o.childLanes=y,null}function Mu(s,o){return o=Iu({mode:o.mode,children:o.children},s.mode),o.ref=s.ref,s.child=o,o.return=s,o}function lb(s,o,u){return ta(o,s.child,null,u),s=Mu(o,o.pendingProps),s.flags|=2,cr(o),o.memoizedState=null,s}function gT(s,o,u){var m=o.pendingProps,y=(o.flags&128)!==0;if(o.flags&=-129,s===null){if(lt){if(m.mode==="hidden")return s=Mu(o,m),o.lanes=536870912,El(null,s);if(Qf(o),(s=Lt)?(s=v0(s,kr),s=s!==null&&s.data==="&"?s:null,s!==null&&(o.memoizedState={dehydrated:s,treeContext:ts!==null?{id:Zr,overflow:ei}:null,retryLane:536870912,hydrationErrors:null},u=Wy(s),u.return=o,o.child=u,Tn=o,Lt=null)):s=null,s===null)throw rs(o);return o.lanes=536870912,null}return Mu(o,m)}var b=s.memoizedState;if(b!==null){var E=b.dehydrated;if(Qf(o),y)if(o.flags&256)o.flags&=-257,o=lb(s,o,u);else if(o.memoizedState!==null)o.child=s.child,o.flags|=128,o=null;else throw Error(r(558));else if(sn||ro(s,o,u,!1),y=(u&s.childLanes)!==0,sn||y){if(m=Et,m!==null&&(E=Pe(m,u),E!==0&&E!==b.retryLane))throw b.retryLane=E,qs(s,E),tr(m,s,E),xm;Wu(),o=lb(s,o,u)}else s=b.treeContext,Lt=Nr(E.nextSibling),Tn=o,lt=!0,ns=null,kr=!1,s!==null&&Ky(o,s),o=Mu(o,m),o.flags|=4096;return o}return s=Si(s.child,{mode:m.mode,children:m.children}),s.ref=o.ref,o.child=s,s.return=o,s}function Ou(s,o){var u=o.ref;if(u===null)s!==null&&s.ref!==null&&(o.flags|=4194816);else{if(typeof u!="function"&&typeof u!="object")throw Error(r(284));(s===null||s.ref!==u)&&(o.flags|=4194816)}}function ym(s,o,u,m,y){return Qs(o),u=Zf(s,o,u,m,void 0,y),m=em(),s!==null&&!sn?(tm(s,o,y),ji(s,o,y)):(lt&&m&&Mf(o),o.flags|=1,Dn(s,o,u,y),o.child)}function cb(s,o,u,m,y,b){return Qs(o),o.updateQueue=null,u=hv(o,m,u,y),dv(s),m=em(),s!==null&&!sn?(tm(s,o,b),ji(s,o,b)):(lt&&m&&Mf(o),o.flags|=1,Dn(s,o,u,b),o.child)}function ub(s,o,u,m,y){if(Qs(o),o.stateNode===null){var b=Za,E=u.contextType;typeof E=="object"&&E!==null&&(b=An(E)),b=new u(m,b),o.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=gm,o.stateNode=b,b._reactInternals=o,b=o.stateNode,b.props=m,b.state=o.memoizedState,b.refs={},Wf(o),E=u.contextType,b.context=typeof E=="object"&&E!==null?An(E):Za,b.state=o.memoizedState,E=u.getDerivedStateFromProps,typeof E=="function"&&(pm(o,u,E,m),b.state=o.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(E=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),E!==b.state&&gm.enqueueReplaceState(b,b.state,null),bl(o,m,b,y),vl(),b.state=o.memoizedState),typeof b.componentDidMount=="function"&&(o.flags|=4194308),m=!0}else if(s===null){b=o.stateNode;var O=o.memoizedProps,Y=ra(u,O);b.props=Y;var ie=b.context,de=u.contextType;E=Za,typeof de=="object"&&de!==null&&(E=An(de));var ge=u.getDerivedStateFromProps;de=typeof ge=="function"||typeof b.getSnapshotBeforeUpdate=="function",O=o.pendingProps!==O,de||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(O||ie!==E)&&Xv(o,b,m,E),ss=!1;var ae=o.memoizedState;b.state=ae,bl(o,m,b,y),vl(),ie=o.memoizedState,O||ae!==ie||ss?(typeof ge=="function"&&(pm(o,u,ge,m),ie=o.memoizedState),(Y=ss||Yv(o,u,Y,m,ae,ie,E))?(de||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(o.flags|=4194308)):(typeof b.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=m,o.memoizedState=ie),b.props=m,b.state=ie,b.context=E,m=Y):(typeof b.componentDidMount=="function"&&(o.flags|=4194308),m=!1)}else{b=o.stateNode,Gf(s,o),E=o.memoizedProps,de=ra(u,E),b.props=de,ge=o.pendingProps,ae=b.context,ie=u.contextType,Y=Za,typeof ie=="object"&&ie!==null&&(Y=An(ie)),O=u.getDerivedStateFromProps,(ie=typeof O=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(E!==ge||ae!==Y)&&Xv(o,b,m,Y),ss=!1,ae=o.memoizedState,b.state=ae,bl(o,m,b,y),vl();var oe=o.memoizedState;E!==ge||ae!==oe||ss||s!==null&&s.dependencies!==null&&gu(s.dependencies)?(typeof O=="function"&&(pm(o,u,O,m),oe=o.memoizedState),(de=ss||Yv(o,u,de,m,ae,oe,Y)||s!==null&&s.dependencies!==null&&gu(s.dependencies))?(ie||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(m,oe,Y),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(m,oe,Y)),typeof b.componentDidUpdate=="function"&&(o.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof b.componentDidUpdate!="function"||E===s.memoizedProps&&ae===s.memoizedState||(o.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||E===s.memoizedProps&&ae===s.memoizedState||(o.flags|=1024),o.memoizedProps=m,o.memoizedState=oe),b.props=m,b.state=oe,b.context=Y,m=de):(typeof b.componentDidUpdate!="function"||E===s.memoizedProps&&ae===s.memoizedState||(o.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||E===s.memoizedProps&&ae===s.memoizedState||(o.flags|=1024),m=!1)}return b=m,Ou(s,o),m=(o.flags&128)!==0,b||m?(b=o.stateNode,u=m&&typeof u.getDerivedStateFromError!="function"?null:b.render(),o.flags|=1,s!==null&&m?(o.child=ta(o,s.child,null,y),o.child=ta(o,null,u,y)):Dn(s,o,u,y),o.memoizedState=b.state,s=o.child):s=ji(s,o,y),s}function db(s,o,u,m){return Ys(),o.flags|=256,Dn(s,o,u,m),o.child}var vm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bm(s){return{baseLanes:s,cachePool:ev()}}function Sm(s,o,u){return s=s!==null?s.childLanes&~u:0,o&&(s|=dr),s}function hb(s,o,u){var m=o.pendingProps,y=!1,b=(o.flags&128)!==0,E;if((E=b)||(E=s!==null&&s.memoizedState===null?!1:(Xt.current&2)!==0),E&&(y=!0,o.flags&=-129),E=(o.flags&32)!==0,o.flags&=-33,s===null){if(lt){if(y?ls(o):cs(),(s=Lt)?(s=v0(s,kr),s=s!==null&&s.data!=="&"?s:null,s!==null&&(o.memoizedState={dehydrated:s,treeContext:ts!==null?{id:Zr,overflow:ei}:null,retryLane:536870912,hydrationErrors:null},u=Wy(s),u.return=o,o.child=u,Tn=o,Lt=null)):s=null,s===null)throw rs(o);return ip(s)?o.lanes=32:o.lanes=536870912,null}var O=m.children;return m=m.fallback,y?(cs(),y=o.mode,O=Iu({mode:"hidden",children:O},y),m=Ks(m,y,u,null),O.return=o,m.return=o,O.sibling=m,o.child=O,m=o.child,m.memoizedState=bm(u),m.childLanes=Sm(s,E,u),o.memoizedState=vm,El(null,m)):(ls(o),wm(o,O))}var Y=s.memoizedState;if(Y!==null&&(O=Y.dehydrated,O!==null)){if(b)o.flags&256?(ls(o),o.flags&=-257,o=Cm(s,o,u)):o.memoizedState!==null?(cs(),o.child=s.child,o.flags|=128,o=null):(cs(),O=m.fallback,y=o.mode,m=Iu({mode:"visible",children:m.children},y),O=Ks(O,y,u,null),O.flags|=2,m.return=o,O.return=o,m.sibling=O,o.child=m,ta(o,s.child,null,u),m=o.child,m.memoizedState=bm(u),m.childLanes=Sm(s,E,u),o.memoizedState=vm,o=El(null,m));else if(ls(o),ip(O)){if(E=O.nextSibling&&O.nextSibling.dataset,E)var ie=E.dgst;E=ie,m=Error(r(419)),m.stack="",m.digest=E,ml({value:m,source:null,stack:null}),o=Cm(s,o,u)}else if(sn||ro(s,o,u,!1),E=(u&s.childLanes)!==0,sn||E){if(E=Et,E!==null&&(m=Pe(E,u),m!==0&&m!==Y.retryLane))throw Y.retryLane=m,qs(s,m),tr(E,s,m),xm;rp(O)||Wu(),o=Cm(s,o,u)}else rp(O)?(o.flags|=192,o.child=s.child,o=null):(s=Y.treeContext,Lt=Nr(O.nextSibling),Tn=o,lt=!0,ns=null,kr=!1,s!==null&&Ky(o,s),o=wm(o,m.children),o.flags|=4096);return o}return y?(cs(),O=m.fallback,y=o.mode,Y=s.child,ie=Y.sibling,m=Si(Y,{mode:"hidden",children:m.children}),m.subtreeFlags=Y.subtreeFlags&65011712,ie!==null?O=Si(ie,O):(O=Ks(O,y,u,null),O.flags|=2),O.return=o,m.return=o,m.sibling=O,o.child=m,El(null,m),m=o.child,O=s.child.memoizedState,O===null?O=bm(u):(y=O.cachePool,y!==null?(Y=nn._currentValue,y=y.parent!==Y?{parent:Y,pool:Y}:y):y=ev(),O={baseLanes:O.baseLanes|u,cachePool:y}),m.memoizedState=O,m.childLanes=Sm(s,E,u),o.memoizedState=vm,El(s.child,m)):(ls(o),u=s.child,s=u.sibling,u=Si(u,{mode:"visible",children:m.children}),u.return=o,u.sibling=null,s!==null&&(E=o.deletions,E===null?(o.deletions=[s],o.flags|=16):E.push(s)),o.child=u,o.memoizedState=null,u)}function wm(s,o){return o=Iu({mode:"visible",children:o},s.mode),o.return=s,s.child=o}function Iu(s,o){return s=or(22,s,null,o),s.lanes=0,s}function Cm(s,o,u){return ta(o,s.child,null,u),s=wm(o,o.pendingProps.children),s.flags|=2,o.memoizedState=null,s}function fb(s,o,u){s.lanes|=o;var m=s.alternate;m!==null&&(m.lanes|=o),zf(s.return,o,u)}function km(s,o,u,m,y,b){var E=s.memoizedState;E===null?s.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:m,tail:u,tailMode:y,treeForkCount:b}:(E.isBackwards=o,E.rendering=null,E.renderingStartTime=0,E.last=m,E.tail=u,E.tailMode=y,E.treeForkCount=b)}function mb(s,o,u){var m=o.pendingProps,y=m.revealOrder,b=m.tail;m=m.children;var E=Xt.current,O=(E&2)!==0;if(O?(E=E&1|2,o.flags|=128):E&=1,I(Xt,E),Dn(s,o,m,u),m=lt?fl:0,!O&&s!==null&&(s.flags&128)!==0)e:for(s=o.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&fb(s,u,o);else if(s.tag===19)fb(s,u,o);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===o)break e;for(;s.sibling===null;){if(s.return===null||s.return===o)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(y){case"forwards":for(u=o.child,y=null;u!==null;)s=u.alternate,s!==null&&Cu(s)===null&&(y=u),u=u.sibling;u=y,u===null?(y=o.child,o.child=null):(y=u.sibling,u.sibling=null),km(o,!1,y,u,b,m);break;case"backwards":case"unstable_legacy-backwards":for(u=null,y=o.child,o.child=null;y!==null;){if(s=y.alternate,s!==null&&Cu(s)===null){o.child=y;break}s=y.sibling,y.sibling=u,u=y,y=s}km(o,!0,u,null,b,m);break;case"together":km(o,!1,null,null,void 0,m);break;default:o.memoizedState=null}return o.child}function ji(s,o,u){if(s!==null&&(o.dependencies=s.dependencies),hs|=o.lanes,(u&o.childLanes)===0)if(s!==null){if(ro(s,o,u,!1),(u&o.childLanes)===0)return null}else return null;if(s!==null&&o.child!==s.child)throw Error(r(153));if(o.child!==null){for(s=o.child,u=Si(s,s.pendingProps),o.child=u,u.return=o;s.sibling!==null;)s=s.sibling,u=u.sibling=Si(s,s.pendingProps),u.return=o;u.sibling=null}return o.child}function Em(s,o){return(s.lanes&o)!==0?!0:(s=s.dependencies,!!(s!==null&&gu(s)))}function _T(s,o,u){switch(o.tag){case 3:Se(o,o.stateNode.containerInfo),is(o,nn,s.memoizedState.cache),Ys();break;case 27:case 5:Ce(o);break;case 4:Se(o,o.stateNode.containerInfo);break;case 10:is(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Qf(o),null;break;case 13:var m=o.memoizedState;if(m!==null)return m.dehydrated!==null?(ls(o),o.flags|=128,null):(u&o.child.childLanes)!==0?hb(s,o,u):(ls(o),s=ji(s,o,u),s!==null?s.sibling:null);ls(o);break;case 19:var y=(s.flags&128)!==0;if(m=(u&o.childLanes)!==0,m||(ro(s,o,u,!1),m=(u&o.childLanes)!==0),y){if(m)return mb(s,o,u);o.flags|=128}if(y=o.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),I(Xt,Xt.current),m)break;return null;case 22:return o.lanes=0,ab(s,o,u,o.pendingProps);case 24:is(o,nn,s.memoizedState.cache)}return ji(s,o,u)}function pb(s,o,u){if(s!==null)if(s.memoizedProps!==o.pendingProps)sn=!0;else{if(!Em(s,u)&&(o.flags&128)===0)return sn=!1,_T(s,o,u);sn=(s.flags&131072)!==0}else sn=!1,lt&&(o.flags&1048576)!==0&&qy(o,fl,o.index);switch(o.lanes=0,o.tag){case 16:e:{var m=o.pendingProps;if(s=Zs(o.elementType),o.type=s,typeof s=="function")Df(s)?(m=ra(s,m),o.tag=1,o=ub(null,o,s,m,u)):(o.tag=0,o=ym(null,o,s,m,u));else{if(s!=null){var y=s.$$typeof;if(y===A){o.tag=11,o=rb(null,o,s,m,u);break e}else if(y===q){o.tag=14,o=ib(null,o,s,m,u);break e}}throw o=U(s)||s,Error(r(306,o,""))}}return o;case 0:return ym(s,o,o.type,o.pendingProps,u);case 1:return m=o.type,y=ra(m,o.pendingProps),ub(s,o,m,y,u);case 3:e:{if(Se(o,o.stateNode.containerInfo),s===null)throw Error(r(387));m=o.pendingProps;var b=o.memoizedState;y=b.element,Gf(s,o),bl(o,m,null,u);var E=o.memoizedState;if(m=E.cache,is(o,nn,m),m!==b.cache&&$f(o,[nn],u,!0),vl(),m=E.element,b.isDehydrated)if(b={element:m,isDehydrated:!1,cache:E.cache},o.updateQueue.baseState=b,o.memoizedState=b,o.flags&256){o=db(s,o,m,u);break e}else if(m!==y){y=Sr(Error(r(424)),o),ml(y),o=db(s,o,m,u);break e}else{switch(s=o.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(Lt=Nr(s.firstChild),Tn=o,lt=!0,ns=null,kr=!0,u=av(o,null,m,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling}else{if(Ys(),m===y){o=ji(s,o,u);break e}Dn(s,o,m,u)}o=o.child}return o;case 26:return Ou(s,o),s===null?(u=E0(o.type,null,o.pendingProps,null))?o.memoizedState=u:lt||(u=o.type,s=o.pendingProps,m=Ju(ee.current).createElement(u),m[yt]=o,m[Yn]=s,Ln(m,u,s),yn(m),o.stateNode=m):o.memoizedState=E0(o.type,s.memoizedProps,o.pendingProps,s.memoizedState),null;case 27:return Ce(o),s===null&&lt&&(m=o.stateNode=w0(o.type,o.pendingProps,ee.current),Tn=o,kr=!0,y=Lt,_s(o.type)?(sp=y,Lt=Nr(m.firstChild)):Lt=y),Dn(s,o,o.pendingProps.children,u),Ou(s,o),s===null&&(o.flags|=4194304),o.child;case 5:return s===null&&lt&&((y=m=Lt)&&(m=qT(m,o.type,o.pendingProps,kr),m!==null?(o.stateNode=m,Tn=o,Lt=Nr(m.firstChild),kr=!1,y=!0):y=!1),y||rs(o)),Ce(o),y=o.type,b=o.pendingProps,E=s!==null?s.memoizedProps:null,m=b.children,ep(y,b)?m=null:E!==null&&ep(y,E)&&(o.flags|=32),o.memoizedState!==null&&(y=Zf(s,o,lT,null,null,u),Hl._currentValue=y),Ou(s,o),Dn(s,o,m,u),o.child;case 6:return s===null&&lt&&((s=u=Lt)&&(u=KT(u,o.pendingProps,kr),u!==null?(o.stateNode=u,Tn=o,Lt=null,s=!0):s=!1),s||rs(o)),null;case 13:return hb(s,o,u);case 4:return Se(o,o.stateNode.containerInfo),m=o.pendingProps,s===null?o.child=ta(o,null,m,u):Dn(s,o,m,u),o.child;case 11:return rb(s,o,o.type,o.pendingProps,u);case 7:return Dn(s,o,o.pendingProps,u),o.child;case 8:return Dn(s,o,o.pendingProps.children,u),o.child;case 12:return Dn(s,o,o.pendingProps.children,u),o.child;case 10:return m=o.pendingProps,is(o,o.type,m.value),Dn(s,o,m.children,u),o.child;case 9:return y=o.type._context,m=o.pendingProps.children,Qs(o),y=An(y),m=m(y),o.flags|=1,Dn(s,o,m,u),o.child;case 14:return ib(s,o,o.type,o.pendingProps,u);case 15:return sb(s,o,o.type,o.pendingProps,u);case 19:return mb(s,o,u);case 31:return gT(s,o,u);case 22:return ab(s,o,u,o.pendingProps);case 24:return Qs(o),m=An(nn),s===null?(y=Uf(),y===null&&(y=Et,b=Hf(),y.pooledCache=b,b.refCount++,b!==null&&(y.pooledCacheLanes|=u),y=b),o.memoizedState={parent:m,cache:y},Wf(o),is(o,nn,y)):((s.lanes&u)!==0&&(Gf(s,o),bl(o,null,null,u),vl()),y=s.memoizedState,b=o.memoizedState,y.parent!==m?(y={parent:m,cache:m},o.memoizedState=y,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=y),is(o,nn,m)):(m=b.cache,is(o,nn,m),m!==y.cache&&$f(o,[nn],u,!0))),Dn(s,o,o.pendingProps.children,u),o.child;case 29:throw o.pendingProps}throw Error(r(156,o.tag))}function Ti(s){s.flags|=4}function Nm(s,o,u,m,y){if((o=(s.mode&32)!==0)&&(o=!1),o){if(s.flags|=16777216,(y&335544128)===y)if(s.stateNode.complete)s.flags|=8192;else if(Fb())s.flags|=8192;else throw ea=vu,Vf}else s.flags&=-16777217}function gb(s,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!D0(o))if(Fb())s.flags|=8192;else throw ea=vu,Vf}function Pu(s,o){o!==null&&(s.flags|=4),s.flags&16384&&(o=s.tag!==22?Zc():536870912,s.lanes|=o,go|=o)}function Nl(s,o){if(!lt)switch(s.tailMode){case"hidden":o=s.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?s.tail=null:u.sibling=null;break;case"collapsed":u=s.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?o||s.tail===null?s.tail=null:s.tail.sibling=null:m.sibling=null}}function Rt(s){var o=s.alternate!==null&&s.alternate.child===s.child,u=0,m=0;if(o)for(var y=s.child;y!==null;)u|=y.lanes|y.childLanes,m|=y.subtreeFlags&65011712,m|=y.flags&65011712,y.return=s,y=y.sibling;else for(y=s.child;y!==null;)u|=y.lanes|y.childLanes,m|=y.subtreeFlags,m|=y.flags,y.return=s,y=y.sibling;return s.subtreeFlags|=m,s.childLanes=u,o}function xT(s,o,u){var m=o.pendingProps;switch(Of(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rt(o),null;case 1:return Rt(o),null;case 3:return u=o.stateNode,m=null,s!==null&&(m=s.memoizedState.cache),o.memoizedState.cache!==m&&(o.flags|=2048),ki(nn),le(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(s===null||s.child===null)&&(no(o)?Ti(o):s===null||s.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Pf())),Rt(o),null;case 26:var y=o.type,b=o.memoizedState;return s===null?(Ti(o),b!==null?(Rt(o),gb(o,b)):(Rt(o),Nm(o,y,null,m,u))):b?b!==s.memoizedState?(Ti(o),Rt(o),gb(o,b)):(Rt(o),o.flags&=-16777217):(s=s.memoizedProps,s!==m&&Ti(o),Rt(o),Nm(o,y,s,m,u)),null;case 27:if(Re(o),u=ee.current,y=o.type,s!==null&&o.stateNode!=null)s.memoizedProps!==m&&Ti(o);else{if(!m){if(o.stateNode===null)throw Error(r(166));return Rt(o),null}s=Q.current,no(o)?Yy(o):(s=w0(y,m,u),o.stateNode=s,Ti(o))}return Rt(o),null;case 5:if(Re(o),y=o.type,s!==null&&o.stateNode!=null)s.memoizedProps!==m&&Ti(o);else{if(!m){if(o.stateNode===null)throw Error(r(166));return Rt(o),null}if(b=Q.current,no(o))Yy(o);else{var E=Ju(ee.current);switch(b){case 1:b=E.createElementNS("http://www.w3.org/2000/svg",y);break;case 2:b=E.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;default:switch(y){case"svg":b=E.createElementNS("http://www.w3.org/2000/svg",y);break;case"math":b=E.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;case"script":b=E.createElement("div"),b.innerHTML="<script><\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof m.is=="string"?E.createElement("select",{is:m.is}):E.createElement("select"),m.multiple?b.multiple=!0:m.size&&(b.size=m.size);break;default:b=typeof m.is=="string"?E.createElement(y,{is:m.is}):E.createElement(y)}}b[yt]=o,b[Yn]=m;e:for(E=o.child;E!==null;){if(E.tag===5||E.tag===6)b.appendChild(E.stateNode);else if(E.tag!==4&&E.tag!==27&&E.child!==null){E.child.return=E,E=E.child;continue}if(E===o)break e;for(;E.sibling===null;){if(E.return===null||E.return===o)break e;E=E.return}E.sibling.return=E.return,E=E.sibling}o.stateNode=b;e:switch(Ln(b,y,m),y){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&Ti(o)}}return Rt(o),Nm(o,o.type,s===null?null:s.memoizedProps,o.pendingProps,u),null;case 6:if(s&&o.stateNode!=null)s.memoizedProps!==m&&Ti(o);else{if(typeof m!="string"&&o.stateNode===null)throw Error(r(166));if(s=ee.current,no(o)){if(s=o.stateNode,u=o.memoizedProps,m=null,y=Tn,y!==null)switch(y.tag){case 27:case 5:m=y.memoizedProps}s[yt]=o,s=!!(s.nodeValue===u||m!==null&&m.suppressHydrationWarning===!0||h0(s.nodeValue,u)),s||rs(o,!0)}else s=Ju(s).createTextNode(m),s[yt]=o,o.stateNode=s}return Rt(o),null;case 31:if(u=o.memoizedState,s===null||s.memoizedState!==null){if(m=no(o),u!==null){if(s===null){if(!m)throw Error(r(318));if(s=o.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[yt]=o}else Ys(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Rt(o),s=!1}else u=Pf(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=u),s=!0;if(!s)return o.flags&256?(cr(o),o):(cr(o),null);if((o.flags&128)!==0)throw Error(r(558))}return Rt(o),null;case 13:if(m=o.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(y=no(o),m!==null&&m.dehydrated!==null){if(s===null){if(!y)throw Error(r(318));if(y=o.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(r(317));y[yt]=o}else Ys(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Rt(o),y=!1}else y=Pf(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=y),y=!0;if(!y)return o.flags&256?(cr(o),o):(cr(o),null)}return cr(o),(o.flags&128)!==0?(o.lanes=u,o):(u=m!==null,s=s!==null&&s.memoizedState!==null,u&&(m=o.child,y=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(y=m.alternate.memoizedState.cachePool.pool),b=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(b=m.memoizedState.cachePool.pool),b!==y&&(m.flags|=2048)),u!==s&&u&&(o.child.flags|=8192),Pu(o,o.updateQueue),Rt(o),null);case 4:return le(),s===null&&Ym(o.stateNode.containerInfo),Rt(o),null;case 10:return ki(o.type),Rt(o),null;case 19:if(K(Xt),m=o.memoizedState,m===null)return Rt(o),null;if(y=(o.flags&128)!==0,b=m.rendering,b===null)if(y)Nl(m,!1);else{if(Wt!==0||s!==null&&(s.flags&128)!==0)for(s=o.child;s!==null;){if(b=Cu(s),b!==null){for(o.flags|=128,Nl(m,!1),s=b.updateQueue,o.updateQueue=s,Pu(o,s),o.subtreeFlags=0,s=u,u=o.child;u!==null;)Vy(u,s),u=u.sibling;return I(Xt,Xt.current&1|2),lt&&wi(o,m.treeForkCount),o.child}s=s.sibling}m.tail!==null&&Yt()>Fu&&(o.flags|=128,y=!0,Nl(m,!1),o.lanes=4194304)}else{if(!y)if(s=Cu(b),s!==null){if(o.flags|=128,y=!0,s=s.updateQueue,o.updateQueue=s,Pu(o,s),Nl(m,!0),m.tail===null&&m.tailMode==="hidden"&&!b.alternate&&!lt)return Rt(o),null}else 2*Yt()-m.renderingStartTime>Fu&&u!==536870912&&(o.flags|=128,y=!0,Nl(m,!1),o.lanes=4194304);m.isBackwards?(b.sibling=o.child,o.child=b):(s=m.last,s!==null?s.sibling=b:o.child=b,m.last=b)}return m.tail!==null?(s=m.tail,m.rendering=s,m.tail=s.sibling,m.renderingStartTime=Yt(),s.sibling=null,u=Xt.current,I(Xt,y?u&1|2:u&1),lt&&wi(o,m.treeForkCount),s):(Rt(o),null);case 22:case 23:return cr(o),Xf(),m=o.memoizedState!==null,s!==null?s.memoizedState!==null!==m&&(o.flags|=8192):m&&(o.flags|=8192),m?(u&536870912)!==0&&(o.flags&128)===0&&(Rt(o),o.subtreeFlags&6&&(o.flags|=8192)):Rt(o),u=o.updateQueue,u!==null&&Pu(o,u.retryQueue),u=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(u=s.memoizedState.cachePool.pool),m=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(m=o.memoizedState.cachePool.pool),m!==u&&(o.flags|=2048),s!==null&&K(Js),null;case 24:return u=null,s!==null&&(u=s.memoizedState.cache),o.memoizedState.cache!==u&&(o.flags|=2048),ki(nn),Rt(o),null;case 25:return null;case 30:return null}throw Error(r(156,o.tag))}function yT(s,o){switch(Of(o),o.tag){case 1:return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 3:return ki(nn),le(),s=o.flags,(s&65536)!==0&&(s&128)===0?(o.flags=s&-65537|128,o):null;case 26:case 27:case 5:return Re(o),null;case 31:if(o.memoizedState!==null){if(cr(o),o.alternate===null)throw Error(r(340));Ys()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 13:if(cr(o),s=o.memoizedState,s!==null&&s.dehydrated!==null){if(o.alternate===null)throw Error(r(340));Ys()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 19:return K(Xt),null;case 4:return le(),null;case 10:return ki(o.type),null;case 22:case 23:return cr(o),Xf(),s!==null&&K(Js),s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 24:return ki(nn),null;case 25:return null;default:return null}}function _b(s,o){switch(Of(o),o.tag){case 3:ki(nn),le();break;case 26:case 27:case 5:Re(o);break;case 4:le();break;case 31:o.memoizedState!==null&&cr(o);break;case 13:cr(o);break;case 19:K(Xt);break;case 10:ki(o.type);break;case 22:case 23:cr(o),Xf(),s!==null&&K(Js);break;case 24:ki(nn)}}function jl(s,o){try{var u=o.updateQueue,m=u!==null?u.lastEffect:null;if(m!==null){var y=m.next;u=y;do{if((u.tag&s)===s){m=void 0;var b=u.create,E=u.inst;m=b(),E.destroy=m}u=u.next}while(u!==y)}}catch(O){bt(o,o.return,O)}}function us(s,o,u){try{var m=o.updateQueue,y=m!==null?m.lastEffect:null;if(y!==null){var b=y.next;m=b;do{if((m.tag&s)===s){var E=m.inst,O=E.destroy;if(O!==void 0){E.destroy=void 0,y=o;var Y=u,ie=O;try{ie()}catch(de){bt(y,Y,de)}}}m=m.next}while(m!==b)}}catch(de){bt(o,o.return,de)}}function xb(s){var o=s.updateQueue;if(o!==null){var u=s.stateNode;try{lv(o,u)}catch(m){bt(s,s.return,m)}}}function yb(s,o,u){u.props=ra(s.type,s.memoizedProps),u.state=s.memoizedState;try{u.componentWillUnmount()}catch(m){bt(s,o,m)}}function Tl(s,o){try{var u=s.ref;if(u!==null){switch(s.tag){case 26:case 27:case 5:var m=s.stateNode;break;case 30:m=s.stateNode;break;default:m=s.stateNode}typeof u=="function"?s.refCleanup=u(m):u.current=m}}catch(y){bt(s,o,y)}}function ti(s,o){var u=s.ref,m=s.refCleanup;if(u!==null)if(typeof m=="function")try{m()}catch(y){bt(s,o,y)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(y){bt(s,o,y)}else u.current=null}function vb(s){var o=s.type,u=s.memoizedProps,m=s.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":u.autoFocus&&m.focus();break e;case"img":u.src?m.src=u.src:u.srcSet&&(m.srcset=u.srcSet)}}catch(y){bt(s,s.return,y)}}function jm(s,o,u){try{var m=s.stateNode;HT(m,s.type,u,o),m[Yn]=o}catch(y){bt(s,s.return,y)}}function bb(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&_s(s.type)||s.tag===4}function Tm(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||bb(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&&_s(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 Am(s,o,u){var m=s.tag;if(m===5||m===6)s=s.stateNode,o?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(s,o):(o=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,o.appendChild(s),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=vi));else if(m!==4&&(m===27&&_s(s.type)&&(u=s.stateNode,o=null),s=s.child,s!==null))for(Am(s,o,u),s=s.sibling;s!==null;)Am(s,o,u),s=s.sibling}function Bu(s,o,u){var m=s.tag;if(m===5||m===6)s=s.stateNode,o?u.insertBefore(s,o):u.appendChild(s);else if(m!==4&&(m===27&&_s(s.type)&&(u=s.stateNode),s=s.child,s!==null))for(Bu(s,o,u),s=s.sibling;s!==null;)Bu(s,o,u),s=s.sibling}function Sb(s){var o=s.stateNode,u=s.memoizedProps;try{for(var m=s.type,y=o.attributes;y.length;)o.removeAttributeNode(y[0]);Ln(o,m,u),o[yt]=s,o[Yn]=u}catch(b){bt(s,s.return,b)}}var Ai=!1,an=!1,Dm=!1,wb=typeof WeakSet=="function"?WeakSet:Set,vn=null;function vT(s,o){if(s=s.containerInfo,Jm=sd,s=Oy(s),Cf(s)){if("selectionStart"in s)var u={start:s.selectionStart,end:s.selectionEnd};else e:{u=(u=s.ownerDocument)&&u.defaultView||window;var m=u.getSelection&&u.getSelection();if(m&&m.rangeCount!==0){u=m.anchorNode;var y=m.anchorOffset,b=m.focusNode;m=m.focusOffset;try{u.nodeType,b.nodeType}catch{u=null;break e}var E=0,O=-1,Y=-1,ie=0,de=0,ge=s,ae=null;t:for(;;){for(var oe;ge!==u||y!==0&&ge.nodeType!==3||(O=E+y),ge!==b||m!==0&&ge.nodeType!==3||(Y=E+m),ge.nodeType===3&&(E+=ge.nodeValue.length),(oe=ge.firstChild)!==null;)ae=ge,ge=oe;for(;;){if(ge===s)break t;if(ae===u&&++ie===y&&(O=E),ae===b&&++de===m&&(Y=E),(oe=ge.nextSibling)!==null)break;ge=ae,ae=ge.parentNode}ge=oe}u=O===-1||Y===-1?null:{start:O,end:Y}}else u=null}u=u||{start:0,end:0}}else u=null;for(Zm={focusedElem:s,selectionRange:u},sd=!1,vn=o;vn!==null;)if(o=vn,s=o.child,(o.subtreeFlags&1028)!==0&&s!==null)s.return=o,vn=s;else for(;vn!==null;){switch(o=vn,b=o.alternate,s=o.flags,o.tag){case 0:if((s&4)!==0&&(s=o.updateQueue,s=s!==null?s.events:null,s!==null))for(u=0;u<s.length;u++)y=s[u],y.ref.impl=y.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&b!==null){s=void 0,u=o,y=b.memoizedProps,b=b.memoizedState,m=u.stateNode;try{var Ae=ra(u.type,y);s=m.getSnapshotBeforeUpdate(Ae,b),m.__reactInternalSnapshotBeforeUpdate=s}catch(He){bt(u,u.return,He)}}break;case 3:if((s&1024)!==0){if(s=o.stateNode.containerInfo,u=s.nodeType,u===9)np(s);else if(u===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":np(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=o.sibling,s!==null){s.return=o.return,vn=s;break}vn=o.return}}function Cb(s,o,u){var m=u.flags;switch(u.tag){case 0:case 11:case 15:Li(s,u),m&4&&jl(5,u);break;case 1:if(Li(s,u),m&4)if(s=u.stateNode,o===null)try{s.componentDidMount()}catch(E){bt(u,u.return,E)}else{var y=ra(u.type,o.memoizedProps);o=o.memoizedState;try{s.componentDidUpdate(y,o,s.__reactInternalSnapshotBeforeUpdate)}catch(E){bt(u,u.return,E)}}m&64&&xb(u),m&512&&Tl(u,u.return);break;case 3:if(Li(s,u),m&64&&(s=u.updateQueue,s!==null)){if(o=null,u.child!==null)switch(u.child.tag){case 27:case 5:o=u.child.stateNode;break;case 1:o=u.child.stateNode}try{lv(s,o)}catch(E){bt(u,u.return,E)}}break;case 27:o===null&&m&4&&Sb(u);case 26:case 5:Li(s,u),o===null&&m&4&&vb(u),m&512&&Tl(u,u.return);break;case 12:Li(s,u);break;case 31:Li(s,u),m&4&&Nb(s,u);break;case 13:Li(s,u),m&4&&jb(s,u),m&64&&(s=u.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(u=TT.bind(null,u),YT(s,u))));break;case 22:if(m=u.memoizedState!==null||Ai,!m){o=o!==null&&o.memoizedState!==null||an,y=Ai;var b=an;Ai=m,(an=o)&&!b?Ri(s,u,(u.subtreeFlags&8772)!==0):Li(s,u),Ai=y,an=b}break;case 30:break;default:Li(s,u)}}function kb(s){var o=s.alternate;o!==null&&(s.alternate=null,kb(o)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(o=s.stateNode,o!==null&&of(o)),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 Pt=null,Qn=!1;function Di(s,o,u){for(u=u.child;u!==null;)Eb(s,o,u),u=u.sibling}function Eb(s,o,u){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(zt,u)}catch{}switch(u.tag){case 26:an||ti(u,o),Di(s,o,u),u.memoizedState?u.memoizedState.count--:u.stateNode&&(u=u.stateNode,u.parentNode.removeChild(u));break;case 27:an||ti(u,o);var m=Pt,y=Qn;_s(u.type)&&(Pt=u.stateNode,Qn=!1),Di(s,o,u),Bl(u.stateNode),Pt=m,Qn=y;break;case 5:an||ti(u,o);case 6:if(m=Pt,y=Qn,Pt=null,Di(s,o,u),Pt=m,Qn=y,Pt!==null)if(Qn)try{(Pt.nodeType===9?Pt.body:Pt.nodeName==="HTML"?Pt.ownerDocument.body:Pt).removeChild(u.stateNode)}catch(b){bt(u,o,b)}else try{Pt.removeChild(u.stateNode)}catch(b){bt(u,o,b)}break;case 18:Pt!==null&&(Qn?(s=Pt,x0(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,u.stateNode),Co(s)):x0(Pt,u.stateNode));break;case 4:m=Pt,y=Qn,Pt=u.stateNode.containerInfo,Qn=!0,Di(s,o,u),Pt=m,Qn=y;break;case 0:case 11:case 14:case 15:us(2,u,o),an||us(4,u,o),Di(s,o,u);break;case 1:an||(ti(u,o),m=u.stateNode,typeof m.componentWillUnmount=="function"&&yb(u,o,m)),Di(s,o,u);break;case 21:Di(s,o,u);break;case 22:an=(m=an)||u.memoizedState!==null,Di(s,o,u),an=m;break;default:Di(s,o,u)}}function Nb(s,o){if(o.memoizedState===null&&(s=o.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Co(s)}catch(u){bt(o,o.return,u)}}}function jb(s,o){if(o.memoizedState===null&&(s=o.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Co(s)}catch(u){bt(o,o.return,u)}}function bT(s){switch(s.tag){case 31:case 13:case 19:var o=s.stateNode;return o===null&&(o=s.stateNode=new wb),o;case 22:return s=s.stateNode,o=s._retryCache,o===null&&(o=s._retryCache=new wb),o;default:throw Error(r(435,s.tag))}}function zu(s,o){var u=bT(s);o.forEach(function(m){if(!u.has(m)){u.add(m);var y=AT.bind(null,s,m);m.then(y,y)}})}function Jn(s,o){var u=o.deletions;if(u!==null)for(var m=0;m<u.length;m++){var y=u[m],b=s,E=o,O=E;e:for(;O!==null;){switch(O.tag){case 27:if(_s(O.type)){Pt=O.stateNode,Qn=!1;break e}break;case 5:Pt=O.stateNode,Qn=!1;break e;case 3:case 4:Pt=O.stateNode.containerInfo,Qn=!0;break e}O=O.return}if(Pt===null)throw Error(r(160));Eb(b,E,y),Pt=null,Qn=!1,b=y.alternate,b!==null&&(b.return=null),y.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)Tb(o,s),o=o.sibling}var Hr=null;function Tb(s,o){var u=s.alternate,m=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:Jn(o,s),Zn(s),m&4&&(us(3,s,s.return),jl(3,s),us(5,s,s.return));break;case 1:Jn(o,s),Zn(s),m&512&&(an||u===null||ti(u,u.return)),m&64&&Ai&&(s=s.updateQueue,s!==null&&(m=s.callbacks,m!==null&&(u=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=u===null?m:u.concat(m))));break;case 26:var y=Hr;if(Jn(o,s),Zn(s),m&512&&(an||u===null||ti(u,u.return)),m&4){var b=u!==null?u.memoizedState:null;if(m=s.memoizedState,u===null)if(m===null)if(s.stateNode===null){e:{m=s.type,u=s.memoizedProps,y=y.ownerDocument||y;t:switch(m){case"title":b=y.getElementsByTagName("title")[0],(!b||b[nl]||b[yt]||b.namespaceURI==="http://www.w3.org/2000/svg"||b.hasAttribute("itemprop"))&&(b=y.createElement(m),y.head.insertBefore(b,y.querySelector("head > title"))),Ln(b,m,u),b[yt]=s,yn(b),m=b;break e;case"link":var E=T0("link","href",y).get(m+(u.href||""));if(E){for(var O=0;O<E.length;O++)if(b=E[O],b.getAttribute("href")===(u.href==null||u.href===""?null:u.href)&&b.getAttribute("rel")===(u.rel==null?null:u.rel)&&b.getAttribute("title")===(u.title==null?null:u.title)&&b.getAttribute("crossorigin")===(u.crossOrigin==null?null:u.crossOrigin)){E.splice(O,1);break t}}b=y.createElement(m),Ln(b,m,u),y.head.appendChild(b);break;case"meta":if(E=T0("meta","content",y).get(m+(u.content||""))){for(O=0;O<E.length;O++)if(b=E[O],b.getAttribute("content")===(u.content==null?null:""+u.content)&&b.getAttribute("name")===(u.name==null?null:u.name)&&b.getAttribute("property")===(u.property==null?null:u.property)&&b.getAttribute("http-equiv")===(u.httpEquiv==null?null:u.httpEquiv)&&b.getAttribute("charset")===(u.charSet==null?null:u.charSet)){E.splice(O,1);break t}}b=y.createElement(m),Ln(b,m,u),y.head.appendChild(b);break;default:throw Error(r(468,m))}b[yt]=s,yn(b),m=b}s.stateNode=m}else A0(y,s.type,s.stateNode);else s.stateNode=j0(y,m,s.memoizedProps);else b!==m?(b===null?u.stateNode!==null&&(u=u.stateNode,u.parentNode.removeChild(u)):b.count--,m===null?A0(y,s.type,s.stateNode):j0(y,m,s.memoizedProps)):m===null&&s.stateNode!==null&&jm(s,s.memoizedProps,u.memoizedProps)}break;case 27:Jn(o,s),Zn(s),m&512&&(an||u===null||ti(u,u.return)),u!==null&&m&4&&jm(s,s.memoizedProps,u.memoizedProps);break;case 5:if(Jn(o,s),Zn(s),m&512&&(an||u===null||ti(u,u.return)),s.flags&32){y=s.stateNode;try{Ga(y,"")}catch(Ae){bt(s,s.return,Ae)}}m&4&&s.stateNode!=null&&(y=s.memoizedProps,jm(s,y,u!==null?u.memoizedProps:y)),m&1024&&(Dm=!0);break;case 6:if(Jn(o,s),Zn(s),m&4){if(s.stateNode===null)throw Error(r(162));m=s.memoizedProps,u=s.stateNode;try{u.nodeValue=m}catch(Ae){bt(s,s.return,Ae)}}break;case 3:if(td=null,y=Hr,Hr=Zu(o.containerInfo),Jn(o,s),Hr=y,Zn(s),m&4&&u!==null&&u.memoizedState.isDehydrated)try{Co(o.containerInfo)}catch(Ae){bt(s,s.return,Ae)}Dm&&(Dm=!1,Ab(s));break;case 4:m=Hr,Hr=Zu(s.stateNode.containerInfo),Jn(o,s),Zn(s),Hr=m;break;case 12:Jn(o,s),Zn(s);break;case 31:Jn(o,s),Zn(s),m&4&&(m=s.updateQueue,m!==null&&(s.updateQueue=null,zu(s,m)));break;case 13:Jn(o,s),Zn(s),s.child.flags&8192&&s.memoizedState!==null!=(u!==null&&u.memoizedState!==null)&&(Hu=Yt()),m&4&&(m=s.updateQueue,m!==null&&(s.updateQueue=null,zu(s,m)));break;case 22:y=s.memoizedState!==null;var Y=u!==null&&u.memoizedState!==null,ie=Ai,de=an;if(Ai=ie||y,an=de||Y,Jn(o,s),an=de,Ai=ie,Zn(s),m&8192)e:for(o=s.stateNode,o._visibility=y?o._visibility&-2:o._visibility|1,y&&(u===null||Y||Ai||an||ia(s)),u=null,o=s;;){if(o.tag===5||o.tag===26){if(u===null){Y=u=o;try{if(b=Y.stateNode,y)E=b.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none";else{O=Y.stateNode;var ge=Y.memoizedProps.style,ae=ge!=null&&ge.hasOwnProperty("display")?ge.display:null;O.style.display=ae==null||typeof ae=="boolean"?"":(""+ae).trim()}}catch(Ae){bt(Y,Y.return,Ae)}}}else if(o.tag===6){if(u===null){Y=o;try{Y.stateNode.nodeValue=y?"":Y.memoizedProps}catch(Ae){bt(Y,Y.return,Ae)}}}else if(o.tag===18){if(u===null){Y=o;try{var oe=Y.stateNode;y?y0(oe,!0):y0(Y.stateNode,!1)}catch(Ae){bt(Y,Y.return,Ae)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===s)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break e;for(;o.sibling===null;){if(o.return===null||o.return===s)break e;u===o&&(u=null),o=o.return}u===o&&(u=null),o.sibling.return=o.return,o=o.sibling}m&4&&(m=s.updateQueue,m!==null&&(u=m.retryQueue,u!==null&&(m.retryQueue=null,zu(s,u))));break;case 19:Jn(o,s),Zn(s),m&4&&(m=s.updateQueue,m!==null&&(s.updateQueue=null,zu(s,m)));break;case 30:break;case 21:break;default:Jn(o,s),Zn(s)}}function Zn(s){var o=s.flags;if(o&2){try{for(var u,m=s.return;m!==null;){if(bb(m)){u=m;break}m=m.return}if(u==null)throw Error(r(160));switch(u.tag){case 27:var y=u.stateNode,b=Tm(s);Bu(s,b,y);break;case 5:var E=u.stateNode;u.flags&32&&(Ga(E,""),u.flags&=-33);var O=Tm(s);Bu(s,O,E);break;case 3:case 4:var Y=u.stateNode.containerInfo,ie=Tm(s);Am(s,ie,Y);break;default:throw Error(r(161))}}catch(de){bt(s,s.return,de)}s.flags&=-3}o&4096&&(s.flags&=-4097)}function Ab(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var o=s;Ab(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),s=s.sibling}}function Li(s,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)Cb(s,o.alternate,o),o=o.sibling}function ia(s){for(s=s.child;s!==null;){var o=s;switch(o.tag){case 0:case 11:case 14:case 15:us(4,o,o.return),ia(o);break;case 1:ti(o,o.return);var u=o.stateNode;typeof u.componentWillUnmount=="function"&&yb(o,o.return,u),ia(o);break;case 27:Bl(o.stateNode);case 26:case 5:ti(o,o.return),ia(o);break;case 22:o.memoizedState===null&&ia(o);break;case 30:ia(o);break;default:ia(o)}s=s.sibling}}function Ri(s,o,u){for(u=u&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var m=o.alternate,y=s,b=o,E=b.flags;switch(b.tag){case 0:case 11:case 15:Ri(y,b,u),jl(4,b);break;case 1:if(Ri(y,b,u),m=b,y=m.stateNode,typeof y.componentDidMount=="function")try{y.componentDidMount()}catch(ie){bt(m,m.return,ie)}if(m=b,y=m.updateQueue,y!==null){var O=m.stateNode;try{var Y=y.shared.hiddenCallbacks;if(Y!==null)for(y.shared.hiddenCallbacks=null,y=0;y<Y.length;y++)ov(Y[y],O)}catch(ie){bt(m,m.return,ie)}}u&&E&64&&xb(b),Tl(b,b.return);break;case 27:Sb(b);case 26:case 5:Ri(y,b,u),u&&m===null&&E&4&&vb(b),Tl(b,b.return);break;case 12:Ri(y,b,u);break;case 31:Ri(y,b,u),u&&E&4&&Nb(y,b);break;case 13:Ri(y,b,u),u&&E&4&&jb(y,b);break;case 22:b.memoizedState===null&&Ri(y,b,u),Tl(b,b.return);break;case 30:break;default:Ri(y,b,u)}o=o.sibling}}function Lm(s,o){var u=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(u=s.memoizedState.cachePool.pool),s=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(s=o.memoizedState.cachePool.pool),s!==u&&(s!=null&&s.refCount++,u!=null&&pl(u))}function Rm(s,o){s=null,o.alternate!==null&&(s=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==s&&(o.refCount++,s!=null&&pl(s))}function Fr(s,o,u,m){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)Db(s,o,u,m),o=o.sibling}function Db(s,o,u,m){var y=o.flags;switch(o.tag){case 0:case 11:case 15:Fr(s,o,u,m),y&2048&&jl(9,o);break;case 1:Fr(s,o,u,m);break;case 3:Fr(s,o,u,m),y&2048&&(s=null,o.alternate!==null&&(s=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==s&&(o.refCount++,s!=null&&pl(s)));break;case 12:if(y&2048){Fr(s,o,u,m),s=o.stateNode;try{var b=o.memoizedProps,E=b.id,O=b.onPostCommit;typeof O=="function"&&O(E,o.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(Y){bt(o,o.return,Y)}}else Fr(s,o,u,m);break;case 31:Fr(s,o,u,m);break;case 13:Fr(s,o,u,m);break;case 23:break;case 22:b=o.stateNode,E=o.alternate,o.memoizedState!==null?b._visibility&2?Fr(s,o,u,m):Al(s,o):b._visibility&2?Fr(s,o,u,m):(b._visibility|=2,fo(s,o,u,m,(o.subtreeFlags&10256)!==0||!1)),y&2048&&Lm(E,o);break;case 24:Fr(s,o,u,m),y&2048&&Rm(o.alternate,o);break;default:Fr(s,o,u,m)}}function fo(s,o,u,m,y){for(y=y&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var b=s,E=o,O=u,Y=m,ie=E.flags;switch(E.tag){case 0:case 11:case 15:fo(b,E,O,Y,y),jl(8,E);break;case 23:break;case 22:var de=E.stateNode;E.memoizedState!==null?de._visibility&2?fo(b,E,O,Y,y):Al(b,E):(de._visibility|=2,fo(b,E,O,Y,y)),y&&ie&2048&&Lm(E.alternate,E);break;case 24:fo(b,E,O,Y,y),y&&ie&2048&&Rm(E.alternate,E);break;default:fo(b,E,O,Y,y)}o=o.sibling}}function Al(s,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var u=s,m=o,y=m.flags;switch(m.tag){case 22:Al(u,m),y&2048&&Lm(m.alternate,m);break;case 24:Al(u,m),y&2048&&Rm(m.alternate,m);break;default:Al(u,m)}o=o.sibling}}var Dl=8192;function mo(s,o,u){if(s.subtreeFlags&Dl)for(s=s.child;s!==null;)Lb(s,o,u),s=s.sibling}function Lb(s,o,u){switch(s.tag){case 26:mo(s,o,u),s.flags&Dl&&s.memoizedState!==null&&oA(u,Hr,s.memoizedState,s.memoizedProps);break;case 5:mo(s,o,u);break;case 3:case 4:var m=Hr;Hr=Zu(s.stateNode.containerInfo),mo(s,o,u),Hr=m;break;case 22:s.memoizedState===null&&(m=s.alternate,m!==null&&m.memoizedState!==null?(m=Dl,Dl=16777216,mo(s,o,u),Dl=m):mo(s,o,u));break;default:mo(s,o,u)}}function Rb(s){var o=s.alternate;if(o!==null&&(s=o.child,s!==null)){o.child=null;do o=s.sibling,s.sibling=null,s=o;while(s!==null)}}function Ll(s){var o=s.deletions;if((s.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var m=o[u];vn=m,Ob(m,s)}Rb(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Mb(s),s=s.sibling}function Mb(s){switch(s.tag){case 0:case 11:case 15:Ll(s),s.flags&2048&&us(9,s,s.return);break;case 3:Ll(s);break;case 12:Ll(s);break;case 22:var o=s.stateNode;s.memoizedState!==null&&o._visibility&2&&(s.return===null||s.return.tag!==13)?(o._visibility&=-3,$u(s)):Ll(s);break;default:Ll(s)}}function $u(s){var o=s.deletions;if((s.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var m=o[u];vn=m,Ob(m,s)}Rb(s)}for(s=s.child;s!==null;){switch(o=s,o.tag){case 0:case 11:case 15:us(8,o,o.return),$u(o);break;case 22:u=o.stateNode,u._visibility&2&&(u._visibility&=-3,$u(o));break;default:$u(o)}s=s.sibling}}function Ob(s,o){for(;vn!==null;){var u=vn;switch(u.tag){case 0:case 11:case 15:us(8,u,o);break;case 23:case 22:if(u.memoizedState!==null&&u.memoizedState.cachePool!==null){var m=u.memoizedState.cachePool.pool;m!=null&&m.refCount++}break;case 24:pl(u.memoizedState.cache)}if(m=u.child,m!==null)m.return=u,vn=m;else e:for(u=s;vn!==null;){m=vn;var y=m.sibling,b=m.return;if(kb(m),m===u){vn=null;break e}if(y!==null){y.return=b,vn=y;break e}vn=b}}}var ST={getCacheForType:function(s){var o=An(nn),u=o.data.get(s);return u===void 0&&(u=s(),o.data.set(s,u)),u},cacheSignal:function(){return An(nn).controller.signal}},wT=typeof WeakMap=="function"?WeakMap:Map,gt=0,Et=null,tt=null,at=0,vt=0,ur=null,ds=!1,po=!1,Mm=!1,Mi=0,Wt=0,hs=0,sa=0,Om=0,dr=0,go=0,Rl=null,er=null,Im=!1,Hu=0,Ib=0,Fu=1/0,Uu=null,fs=null,dn=0,ms=null,_o=null,Oi=0,Pm=0,Bm=null,Pb=null,Ml=0,zm=null;function hr(){return(gt&2)!==0&&at!==0?at&-at:N.T!==null?Wm():dt()}function Bb(){if(dr===0)if((at&536870912)===0||lt){var s=Ia;Ia<<=1,(Ia&3932160)===0&&(Ia=262144),dr=s}else dr=536870912;return s=lr.current,s!==null&&(s.flags|=32),dr}function tr(s,o,u){(s===Et&&(vt===2||vt===9)||s.cancelPendingCommit!==null)&&(xo(s,0),ps(s,at,dr,!1)),Zi(s,u),((gt&2)===0||s!==Et)&&(s===Et&&((gt&2)===0&&(sa|=u),Wt===4&&ps(s,at,dr,!1)),ni(s))}function zb(s,o,u){if((gt&6)!==0)throw Error(r(327));var m=!u&&(o&127)===0&&(o&s.expiredLanes)===0||Fs(s,o),y=m?ET(s,o):Hm(s,o,!0),b=m;do{if(y===0){po&&!m&&ps(s,o,0,!1);break}else{if(u=s.current.alternate,b&&!CT(u)){y=Hm(s,o,!1),b=!1;continue}if(y===2){if(b=o,s.errorRecoveryDisabledLanes&b)var E=0;else E=s.pendingLanes&-536870913,E=E!==0?E:E&536870912?536870912:0;if(E!==0){o=E;e:{var O=s;y=Rl;var Y=O.current.memoizedState.isDehydrated;if(Y&&(xo(O,E).flags|=256),E=Hm(O,E,!1),E!==2){if(Mm&&!Y){O.errorRecoveryDisabledLanes|=b,sa|=b,y=4;break e}b=er,er=y,b!==null&&(er===null?er=b:er.push.apply(er,b))}y=E}if(b=!1,y!==2)continue}}if(y===1){xo(s,0),ps(s,o,0,!0);break}e:{switch(m=s,b=y,b){case 0:case 1:throw Error(r(345));case 4:if((o&4194048)!==o)break;case 6:ps(m,o,dr,!ds);break e;case 2:er=null;break;case 3:case 5:break;default:throw Error(r(329))}if((o&62914560)===o&&(y=Hu+300-Yt(),10<y)){if(ps(m,o,dr,!ds),Ba(m,0,!0)!==0)break e;Oi=o,m.timeoutHandle=g0($b.bind(null,m,u,er,Uu,Im,o,dr,sa,go,ds,b,"Throttled",-0,0),y);break e}$b(m,u,er,Uu,Im,o,dr,sa,go,ds,b,null,-0,0)}}break}while(!0);ni(s)}function $b(s,o,u,m,y,b,E,O,Y,ie,de,ge,ae,oe){if(s.timeoutHandle=-1,ge=o.subtreeFlags,ge&8192||(ge&16785408)===16785408){ge={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:vi},Lb(o,b,ge);var Ae=(b&62914560)===b?Hu-Yt():(b&4194048)===b?Ib-Yt():0;if(Ae=lA(ge,Ae),Ae!==null){Oi=b,s.cancelPendingCommit=Ae(Kb.bind(null,s,o,b,u,m,y,E,O,Y,de,ge,null,ae,oe)),ps(s,b,E,!ie);return}}Kb(s,o,b,u,m,y,E,O,Y)}function CT(s){for(var o=s;;){var u=o.tag;if((u===0||u===11||u===15)&&o.flags&16384&&(u=o.updateQueue,u!==null&&(u=u.stores,u!==null)))for(var m=0;m<u.length;m++){var y=u[m],b=y.getSnapshot;y=y.value;try{if(!ar(b(),y))return!1}catch{return!1}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;else{if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function ps(s,o,u,m){o&=~Om,o&=~sa,s.suspendedLanes|=o,s.pingedLanes&=~o,m&&(s.warmLanes|=o),m=s.expirationTimes;for(var y=o;0<y;){var b=31-xt(y),E=1<<b;m[b]=-1,y&=~E}u!==0&&he(s,u,o)}function Vu(){return(gt&6)===0?(Ol(0),!1):!0}function $m(){if(tt!==null){if(vt===0)var s=tt.return;else s=tt,Ci=Xs=null,nm(s),oo=null,_l=0,s=tt;for(;s!==null;)_b(s.alternate,s),s=s.return;tt=null}}function xo(s,o){var u=s.timeoutHandle;u!==-1&&(s.timeoutHandle=-1,VT(u)),u=s.cancelPendingCommit,u!==null&&(s.cancelPendingCommit=null,u()),Oi=0,$m(),Et=s,tt=u=Si(s.current,null),at=o,vt=0,ur=null,ds=!1,po=Fs(s,o),Mm=!1,go=dr=Om=sa=hs=Wt=0,er=Rl=null,Im=!1,(o&8)!==0&&(o|=o&32);var m=s.entangledLanes;if(m!==0)for(s=s.entanglements,m&=o;0<m;){var y=31-xt(m),b=1<<y;o|=s[y],m&=~b}return Mi=o,du(),u}function Hb(s,o){qe=null,N.H=kl,o===ao||o===yu?(o=rv(),vt=3):o===Vf?(o=rv(),vt=4):vt=o===xm?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,ur=o,tt===null&&(Wt=1,Ru(s,Sr(o,s.current)))}function Fb(){var s=lr.current;return s===null?!0:(at&4194048)===at?Er===null:(at&62914560)===at||(at&536870912)!==0?s===Er:!1}function Ub(){var s=N.H;return N.H=kl,s===null?kl:s}function Vb(){var s=N.A;return N.A=ST,s}function Wu(){Wt=4,ds||(at&4194048)!==at&&lr.current!==null||(po=!0),(hs&134217727)===0&&(sa&134217727)===0||Et===null||ps(Et,at,dr,!1)}function Hm(s,o,u){var m=gt;gt|=2;var y=Ub(),b=Vb();(Et!==s||at!==o)&&(Uu=null,xo(s,o)),o=!1;var E=Wt;e:do try{if(vt!==0&&tt!==null){var O=tt,Y=ur;switch(vt){case 8:$m(),E=6;break e;case 3:case 2:case 9:case 6:lr.current===null&&(o=!0);var ie=vt;if(vt=0,ur=null,yo(s,O,Y,ie),u&&po){E=0;break e}break;default:ie=vt,vt=0,ur=null,yo(s,O,Y,ie)}}kT(),E=Wt;break}catch(de){Hb(s,de)}while(!0);return o&&s.shellSuspendCounter++,Ci=Xs=null,gt=m,N.H=y,N.A=b,tt===null&&(Et=null,at=0,du()),E}function kT(){for(;tt!==null;)Wb(tt)}function ET(s,o){var u=gt;gt|=2;var m=Ub(),y=Vb();Et!==s||at!==o?(Uu=null,Fu=Yt()+500,xo(s,o)):po=Fs(s,o);e:do try{if(vt!==0&&tt!==null){o=tt;var b=ur;t:switch(vt){case 1:vt=0,ur=null,yo(s,o,b,1);break;case 2:case 9:if(tv(b)){vt=0,ur=null,Gb(o);break}o=function(){vt!==2&&vt!==9||Et!==s||(vt=7),ni(s)},b.then(o,o);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:tv(b)?(vt=0,ur=null,Gb(o)):(vt=0,ur=null,yo(s,o,b,7));break;case 5:var E=null;switch(tt.tag){case 26:E=tt.memoizedState;case 5:case 27:var O=tt;if(E?D0(E):O.stateNode.complete){vt=0,ur=null;var Y=O.sibling;if(Y!==null)tt=Y;else{var ie=O.return;ie!==null?(tt=ie,Gu(ie)):tt=null}break t}}vt=0,ur=null,yo(s,o,b,5);break;case 6:vt=0,ur=null,yo(s,o,b,6);break;case 8:$m(),Wt=6;break e;default:throw Error(r(462))}}NT();break}catch(de){Hb(s,de)}while(!0);return Ci=Xs=null,N.H=m,N.A=y,gt=u,tt!==null?0:(Et=null,at=0,du(),Wt)}function NT(){for(;tt!==null&&!_t();)Wb(tt)}function Wb(s){var o=pb(s.alternate,s,Mi);s.memoizedProps=s.pendingProps,o===null?Gu(s):tt=o}function Gb(s){var o=s,u=o.alternate;switch(o.tag){case 15:case 0:o=cb(u,o,o.pendingProps,o.type,void 0,at);break;case 11:o=cb(u,o,o.pendingProps,o.type.render,o.ref,at);break;case 5:nm(o);default:_b(u,o),o=tt=Vy(o,Mi),o=pb(u,o,Mi)}s.memoizedProps=s.pendingProps,o===null?Gu(s):tt=o}function yo(s,o,u,m){Ci=Xs=null,nm(o),oo=null,_l=0;var y=o.return;try{if(pT(s,y,o,u,at)){Wt=1,Ru(s,Sr(u,s.current)),tt=null;return}}catch(b){if(y!==null)throw tt=y,b;Wt=1,Ru(s,Sr(u,s.current)),tt=null;return}o.flags&32768?(lt||m===1?s=!0:po||(at&536870912)!==0?s=!1:(ds=s=!0,(m===2||m===9||m===3||m===6)&&(m=lr.current,m!==null&&m.tag===13&&(m.flags|=16384))),qb(o,s)):Gu(o)}function Gu(s){var o=s;do{if((o.flags&32768)!==0){qb(o,ds);return}s=o.return;var u=xT(o.alternate,o,Mi);if(u!==null){tt=u;return}if(o=o.sibling,o!==null){tt=o;return}tt=o=s}while(o!==null);Wt===0&&(Wt=5)}function qb(s,o){do{var u=yT(s.alternate,s);if(u!==null){u.flags&=32767,tt=u;return}if(u=s.return,u!==null&&(u.flags|=32768,u.subtreeFlags=0,u.deletions=null),!o&&(s=s.sibling,s!==null)){tt=s;return}tt=s=u}while(s!==null);Wt=6,tt=null}function Kb(s,o,u,m,y,b,E,O,Y){s.cancelPendingCommit=null;do qu();while(dn!==0);if((gt&6)!==0)throw Error(r(327));if(o!==null){if(o===s.current)throw Error(r(177));if(b=o.lanes|o.childLanes,b|=Tf,fe(s,u,b,E,O,Y),s===Et&&(tt=Et=null,at=0),_o=o,ms=s,Oi=u,Pm=b,Bm=y,Pb=m,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,DT($e,function(){return Zb(),null})):(s.callbackNode=null,s.callbackPriority=0),m=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||m){m=N.T,N.T=null,y=F.p,F.p=2,E=gt,gt|=4;try{vT(s,o,u)}finally{gt=E,F.p=y,N.T=m}}dn=1,Yb(),Xb(),Qb()}}function Yb(){if(dn===1){dn=0;var s=ms,o=_o,u=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||u){u=N.T,N.T=null;var m=F.p;F.p=2;var y=gt;gt|=4;try{Tb(o,s);var b=Zm,E=Oy(s.containerInfo),O=b.focusedElem,Y=b.selectionRange;if(E!==O&&O&&O.ownerDocument&&My(O.ownerDocument.documentElement,O)){if(Y!==null&&Cf(O)){var ie=Y.start,de=Y.end;if(de===void 0&&(de=ie),"selectionStart"in O)O.selectionStart=ie,O.selectionEnd=Math.min(de,O.value.length);else{var ge=O.ownerDocument||document,ae=ge&&ge.defaultView||window;if(ae.getSelection){var oe=ae.getSelection(),Ae=O.textContent.length,He=Math.min(Y.start,Ae),Ct=Y.end===void 0?He:Math.min(Y.end,Ae);!oe.extend&&He>Ct&&(E=Ct,Ct=He,He=E);var te=Ry(O,He),X=Ry(O,Ct);if(te&&X&&(oe.rangeCount!==1||oe.anchorNode!==te.node||oe.anchorOffset!==te.offset||oe.focusNode!==X.node||oe.focusOffset!==X.offset)){var re=ge.createRange();re.setStart(te.node,te.offset),oe.removeAllRanges(),He>Ct?(oe.addRange(re),oe.extend(X.node,X.offset)):(re.setEnd(X.node,X.offset),oe.addRange(re))}}}}for(ge=[],oe=O;oe=oe.parentNode;)oe.nodeType===1&&ge.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;O<ge.length;O++){var pe=ge[O];pe.element.scrollLeft=pe.left,pe.element.scrollTop=pe.top}}sd=!!Jm,Zm=Jm=null}finally{gt=y,F.p=m,N.T=u}}s.current=o,dn=2}}function Xb(){if(dn===2){dn=0;var s=ms,o=_o,u=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||u){u=N.T,N.T=null;var m=F.p;F.p=2;var y=gt;gt|=4;try{Cb(s,o.alternate,o)}finally{gt=y,F.p=m,N.T=u}}dn=3}}function Qb(){if(dn===4||dn===3){dn=0,Ji();var s=ms,o=_o,u=Oi,m=Pb;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?dn=5:(dn=0,_o=ms=null,Jb(s,s.pendingLanes));var y=s.pendingLanes;if(y===0&&(fs=null),We(u),o=o.stateNode,pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(zt,o,void 0,(o.current.flags&128)===128)}catch{}if(m!==null){o=N.T,y=F.p,F.p=2,N.T=null;try{for(var b=s.onRecoverableError,E=0;E<m.length;E++){var O=m[E];b(O.value,{componentStack:O.stack})}}finally{N.T=o,F.p=y}}(Oi&3)!==0&&qu(),ni(s),y=s.pendingLanes,(u&261930)!==0&&(y&42)!==0?s===zm?Ml++:(Ml=0,zm=s):Ml=0,Ol(0)}}function Jb(s,o){(s.pooledCacheLanes&=o)===0&&(o=s.pooledCache,o!=null&&(s.pooledCache=null,pl(o)))}function qu(){return Yb(),Xb(),Qb(),Zb()}function Zb(){if(dn!==5)return!1;var s=ms,o=Pm;Pm=0;var u=We(Oi),m=N.T,y=F.p;try{F.p=32>u?32:u,N.T=null,u=Bm,Bm=null;var b=ms,E=Oi;if(dn=0,_o=ms=null,Oi=0,(gt&6)!==0)throw Error(r(331));var O=gt;if(gt|=4,Mb(b.current),Db(b,b.current,E,u),gt=O,Ol(0,!1),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(zt,b)}catch{}return!0}finally{F.p=y,N.T=m,Jb(s,o)}}function e0(s,o,u){o=Sr(u,o),o=_m(s.stateNode,o,2),s=os(s,o,2),s!==null&&(Zi(s,2),ni(s))}function bt(s,o,u){if(s.tag===3)e0(s,s,u);else for(;o!==null;){if(o.tag===3){e0(o,s,u);break}else if(o.tag===1){var m=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(fs===null||!fs.has(m))){s=Sr(u,s),u=tb(2),m=os(o,u,2),m!==null&&(nb(u,m,o,s),Zi(m,2),ni(m));break}}o=o.return}}function Fm(s,o,u){var m=s.pingCache;if(m===null){m=s.pingCache=new wT;var y=new Set;m.set(o,y)}else y=m.get(o),y===void 0&&(y=new Set,m.set(o,y));y.has(u)||(Mm=!0,y.add(u),s=jT.bind(null,s,o,u),o.then(s,s))}function jT(s,o,u){var m=s.pingCache;m!==null&&m.delete(o),s.pingedLanes|=s.suspendedLanes&u,s.warmLanes&=~u,Et===s&&(at&u)===u&&(Wt===4||Wt===3&&(at&62914560)===at&&300>Yt()-Hu?(gt&2)===0&&xo(s,0):Om|=u,go===at&&(go=0)),ni(s)}function t0(s,o){o===0&&(o=Zc()),s=qs(s,o),s!==null&&(Zi(s,o),ni(s))}function TT(s){var o=s.memoizedState,u=0;o!==null&&(u=o.retryLane),t0(s,u)}function AT(s,o){var u=0;switch(s.tag){case 31:case 13:var m=s.stateNode,y=s.memoizedState;y!==null&&(u=y.retryLane);break;case 19:m=s.stateNode;break;case 22:m=s.stateNode._retryCache;break;default:throw Error(r(314))}m!==null&&m.delete(o),t0(s,u)}function DT(s,o){return ue(s,o)}var Ku=null,vo=null,Um=!1,Yu=!1,Vm=!1,gs=0;function ni(s){s!==vo&&s.next===null&&(vo===null?Ku=vo=s:vo=vo.next=s),Yu=!0,Um||(Um=!0,RT())}function Ol(s,o){if(!Vm&&Yu){Vm=!0;do for(var u=!1,m=Ku;m!==null;){if(s!==0){var y=m.pendingLanes;if(y===0)var b=0;else{var E=m.suspendedLanes,O=m.pingedLanes;b=(1<<31-xt(42|s)+1)-1,b&=y&~(E&~O),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(u=!0,s0(m,b))}else b=at,b=Ba(m,m===Et?b:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(b&3)===0||Fs(m,b)||(u=!0,s0(m,b));m=m.next}while(u);Vm=!1}}function LT(){n0()}function n0(){Yu=Um=!1;var s=0;gs!==0&&UT()&&(s=gs);for(var o=Yt(),u=null,m=Ku;m!==null;){var y=m.next,b=r0(m,o);b===0?(m.next=null,u===null?Ku=y:u.next=y,y===null&&(vo=u)):(u=m,(s!==0||(b&3)!==0)&&(Yu=!0)),m=y}dn!==0&&dn!==5||Ol(s),gs!==0&&(gs=0)}function r0(s,o){for(var u=s.suspendedLanes,m=s.pingedLanes,y=s.expirationTimes,b=s.pendingLanes&-62914561;0<b;){var E=31-xt(b),O=1<<E,Y=y[E];Y===-1?((O&u)===0||(O&m)!==0)&&(y[E]=tl(O,o)):Y<=o&&(s.expiredLanes|=O),b&=~O}if(o=Et,u=at,u=Ba(s,s===o?u:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),m=s.callbackNode,u===0||s===o&&(vt===2||vt===9)||s.cancelPendingCommit!==null)return m!==null&&m!==null&&Ee(m),s.callbackNode=null,s.callbackPriority=0;if((u&3)===0||Fs(s,u)){if(o=u&-u,o===s.callbackPriority)return o;switch(m!==null&&Ee(m),We(u)){case 2:case 8:u=ke;break;case 32:u=$e;break;case 268435456:u=ut;break;default:u=$e}return m=i0.bind(null,s),u=ue(u,m),s.callbackPriority=o,s.callbackNode=u,o}return m!==null&&m!==null&&Ee(m),s.callbackPriority=2,s.callbackNode=null,2}function i0(s,o){if(dn!==0&&dn!==5)return s.callbackNode=null,s.callbackPriority=0,null;var u=s.callbackNode;if(qu()&&s.callbackNode!==u)return null;var m=at;return m=Ba(s,s===Et?m:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),m===0?null:(zb(s,m,o),r0(s,Yt()),s.callbackNode!=null&&s.callbackNode===u?i0.bind(null,s):null)}function s0(s,o){if(qu())return null;zb(s,o,!0)}function RT(){WT(function(){(gt&6)!==0?ue(me,LT):n0()})}function Wm(){if(gs===0){var s=io;s===0&&(s=zr,zr<<=1,(zr&261888)===0&&(zr=256)),gs=s}return gs}function a0(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:ru(""+s)}function o0(s,o){var u=o.ownerDocument.createElement("input");return u.name=o.name,u.value=o.value,s.id&&u.setAttribute("form",s.id),o.parentNode.insertBefore(u,o),s=new FormData(s),u.parentNode.removeChild(u),s}function MT(s,o,u,m,y){if(o==="submit"&&u&&u.stateNode===y){var b=a0((y[Yn]||null).action),E=m.submitter;E&&(o=(o=E[Yn]||null)?a0(o.formAction):E.getAttribute("formAction"),o!==null&&(b=o,E=null));var O=new ou("action","action",null,m,y);s.push({event:O,listeners:[{instance:null,listener:function(){if(m.defaultPrevented){if(gs!==0){var Y=E?o0(y,E):new FormData(y);dm(u,{pending:!0,data:Y,method:y.method,action:b},null,Y)}}else typeof b=="function"&&(O.preventDefault(),Y=E?o0(y,E):new FormData(y),dm(u,{pending:!0,data:Y,method:y.method,action:b},b,Y))},currentTarget:y}]})}}for(var Gm=0;Gm<jf.length;Gm++){var qm=jf[Gm],OT=qm.toLowerCase(),IT=qm[0].toUpperCase()+qm.slice(1);$r(OT,"on"+IT)}$r(By,"onAnimationEnd"),$r(zy,"onAnimationIteration"),$r($y,"onAnimationStart"),$r("dblclick","onDoubleClick"),$r("focusin","onFocus"),$r("focusout","onBlur"),$r(Jj,"onTransitionRun"),$r(Zj,"onTransitionStart"),$r(eT,"onTransitionCancel"),$r(Hy,"onTransitionEnd"),Va("onMouseEnter",["mouseout","mouseover"]),Va("onMouseLeave",["mouseout","mouseover"]),Va("onPointerEnter",["pointerout","pointerover"]),Va("onPointerLeave",["pointerout","pointerover"]),Us("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Us("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Us("onBeforeInput",["compositionend","keypress","textInput","paste"]),Us("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Us("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Us("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Il="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(" "),PT=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Il));function l0(s,o){o=(o&4)!==0;for(var u=0;u<s.length;u++){var m=s[u],y=m.event;m=m.listeners;e:{var b=void 0;if(o)for(var E=m.length-1;0<=E;E--){var O=m[E],Y=O.instance,ie=O.currentTarget;if(O=O.listener,Y!==b&&y.isPropagationStopped())break e;b=O,y.currentTarget=ie;try{b(y)}catch(de){uu(de)}y.currentTarget=null,b=Y}else for(E=0;E<m.length;E++){if(O=m[E],Y=O.instance,ie=O.currentTarget,O=O.listener,Y!==b&&y.isPropagationStopped())break e;b=O,y.currentTarget=ie;try{b(y)}catch(de){uu(de)}y.currentTarget=null,b=Y}}}}function nt(s,o){var u=o[af];u===void 0&&(u=o[af]=new Set);var m=s+"__bubble";u.has(m)||(c0(o,s,2,!1),u.add(m))}function Km(s,o,u){var m=0;o&&(m|=4),c0(u,s,m,o)}var Xu="_reactListening"+Math.random().toString(36).slice(2);function Ym(s){if(!s[Xu]){s[Xu]=!0,ny.forEach(function(u){u!=="selectionchange"&&(PT.has(u)||Km(u,!1,s),Km(u,!0,s))});var o=s.nodeType===9?s:s.ownerDocument;o===null||o[Xu]||(o[Xu]=!0,Km("selectionchange",!1,o))}}function c0(s,o,u,m){switch(B0(o)){case 2:var y=dA;break;case 8:y=hA;break;default:y=up}u=y.bind(null,o,u,s),y=void 0,!pf||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(y=!0),m?y!==void 0?s.addEventListener(o,u,{capture:!0,passive:y}):s.addEventListener(o,u,!0):y!==void 0?s.addEventListener(o,u,{passive:y}):s.addEventListener(o,u,!1)}function Xm(s,o,u,m,y){var b=m;if((o&1)===0&&(o&2)===0&&m!==null)e:for(;;){if(m===null)return;var E=m.tag;if(E===3||E===4){var O=m.stateNode.containerInfo;if(O===y)break;if(E===4)for(E=m.return;E!==null;){var Y=E.tag;if((Y===3||Y===4)&&E.stateNode.containerInfo===y)return;E=E.return}for(;O!==null;){if(E=Ha(O),E===null)return;if(Y=E.tag,Y===5||Y===6||Y===26||Y===27){m=b=E;continue e}O=O.parentNode}}m=m.return}my(function(){var ie=b,de=ff(u),ge=[];e:{var ae=Fy.get(s);if(ae!==void 0){var oe=ou,Ae=s;switch(s){case"keypress":if(su(u)===0)break e;case"keydown":case"keyup":oe=Aj;break;case"focusin":Ae="focus",oe=yf;break;case"focusout":Ae="blur",oe=yf;break;case"beforeblur":case"afterblur":oe=yf;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":oe=_y;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":oe=xj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":oe=Rj;break;case By:case zy:case $y:oe=bj;break;case Hy:oe=Oj;break;case"scroll":case"scrollend":oe=gj;break;case"wheel":oe=Pj;break;case"copy":case"cut":case"paste":oe=wj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":oe=yy;break;case"toggle":case"beforetoggle":oe=zj}var He=(o&4)!==0,Ct=!He&&(s==="scroll"||s==="scrollend"),te=He?ae!==null?ae+"Capture":null:ae;He=[];for(var X=ie,re;X!==null;){var pe=X;if(re=pe.stateNode,pe=pe.tag,pe!==5&&pe!==26&&pe!==27||re===null||te===null||(pe=il(X,te),pe!=null&&He.push(Pl(X,pe,re))),Ct)break;X=X.return}0<He.length&&(ae=new oe(ae,Ae,null,u,de),ge.push({event:ae,listeners:He}))}}if((o&7)===0){e:{if(ae=s==="mouseover"||s==="pointerover",oe=s==="mouseout"||s==="pointerout",ae&&u!==hf&&(Ae=u.relatedTarget||u.fromElement)&&(Ha(Ae)||Ae[$a]))break e;if((oe||ae)&&(ae=de.window===de?de:(ae=de.ownerDocument)?ae.defaultView||ae.parentWindow:window,oe?(Ae=u.relatedTarget||u.toElement,oe=ie,Ae=Ae?Ha(Ae):null,Ae!==null&&(Ct=a(Ae),He=Ae.tag,Ae!==Ct||He!==5&&He!==27&&He!==6)&&(Ae=null)):(oe=null,Ae=ie),oe!==Ae)){if(He=_y,pe="onMouseLeave",te="onMouseEnter",X="mouse",(s==="pointerout"||s==="pointerover")&&(He=yy,pe="onPointerLeave",te="onPointerEnter",X="pointer"),Ct=oe==null?ae:rl(oe),re=Ae==null?ae:rl(Ae),ae=new He(pe,X+"leave",oe,u,de),ae.target=Ct,ae.relatedTarget=re,pe=null,Ha(de)===ie&&(He=new He(te,X+"enter",Ae,u,de),He.target=re,He.relatedTarget=Ct,pe=He),Ct=pe,oe&&Ae)t:{for(He=BT,te=oe,X=Ae,re=0,pe=te;pe;pe=He(pe))re++;pe=0;for(var Ie=X;Ie;Ie=He(Ie))pe++;for(;0<re-pe;)te=He(te),re--;for(;0<pe-re;)X=He(X),pe--;for(;re--;){if(te===X||X!==null&&te===X.alternate){He=te;break t}te=He(te),X=He(X)}He=null}else He=null;oe!==null&&u0(ge,ae,oe,He,!1),Ae!==null&&Ct!==null&&u0(ge,Ct,Ae,He,!0)}}e:{if(ae=ie?rl(ie):window,oe=ae.nodeName&&ae.nodeName.toLowerCase(),oe==="select"||oe==="input"&&ae.type==="file")var ht=Ny;else if(ky(ae))if(jy)ht=Yj;else{ht=qj;var Le=Gj}else oe=ae.nodeName,!oe||oe.toLowerCase()!=="input"||ae.type!=="checkbox"&&ae.type!=="radio"?ie&&df(ie.elementType)&&(ht=Ny):ht=Kj;if(ht&&(ht=ht(s,ie))){Ey(ge,ht,u,de);break e}Le&&Le(s,ae,ie),s==="focusout"&&ie&&ae.type==="number"&&ie.memoizedProps.value!=null&&uf(ae,"number",ae.value)}switch(Le=ie?rl(ie):window,s){case"focusin":(ky(Le)||Le.contentEditable==="true")&&(Xa=Le,kf=ie,hl=null);break;case"focusout":hl=kf=Xa=null;break;case"mousedown":Ef=!0;break;case"contextmenu":case"mouseup":case"dragend":Ef=!1,Iy(ge,u,de);break;case"selectionchange":if(Qj)break;case"keydown":case"keyup":Iy(ge,u,de)}var Ke;if(bf)e:{switch(s){case"compositionstart":var ot="onCompositionStart";break e;case"compositionend":ot="onCompositionEnd";break e;case"compositionupdate":ot="onCompositionUpdate";break e}ot=void 0}else Ya?wy(s,u)&&(ot="onCompositionEnd"):s==="keydown"&&u.keyCode===229&&(ot="onCompositionStart");ot&&(vy&&u.locale!=="ko"&&(Ya||ot!=="onCompositionStart"?ot==="onCompositionEnd"&&Ya&&(Ke=py()):(es=de,gf="value"in es?es.value:es.textContent,Ya=!0)),Le=Qu(ie,ot),0<Le.length&&(ot=new xy(ot,s,null,u,de),ge.push({event:ot,listeners:Le}),Ke?ot.data=Ke:(Ke=Cy(u),Ke!==null&&(ot.data=Ke)))),(Ke=Hj?Fj(s,u):Uj(s,u))&&(ot=Qu(ie,"onBeforeInput"),0<ot.length&&(Le=new xy("onBeforeInput","beforeinput",null,u,de),ge.push({event:Le,listeners:ot}),Le.data=Ke)),MT(ge,s,ie,u,de)}l0(ge,o)})}function Pl(s,o,u){return{instance:s,listener:o,currentTarget:u}}function Qu(s,o){for(var u=o+"Capture",m=[];s!==null;){var y=s,b=y.stateNode;if(y=y.tag,y!==5&&y!==26&&y!==27||b===null||(y=il(s,u),y!=null&&m.unshift(Pl(s,y,b)),y=il(s,o),y!=null&&m.push(Pl(s,y,b))),s.tag===3)return m;s=s.return}return[]}function BT(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function u0(s,o,u,m,y){for(var b=o._reactName,E=[];u!==null&&u!==m;){var O=u,Y=O.alternate,ie=O.stateNode;if(O=O.tag,Y!==null&&Y===m)break;O!==5&&O!==26&&O!==27||ie===null||(Y=ie,y?(ie=il(u,b),ie!=null&&E.unshift(Pl(u,ie,Y))):y||(ie=il(u,b),ie!=null&&E.push(Pl(u,ie,Y)))),u=u.return}E.length!==0&&s.push({event:o,listeners:E})}var zT=/\r\n?/g,$T=/\u0000|\uFFFD/g;function d0(s){return(typeof s=="string"?s:""+s).replace(zT,`
50
+ `).replace($T,"")}function h0(s,o){return o=d0(o),d0(s)===o}function wt(s,o,u,m,y,b){switch(u){case"children":typeof m=="string"?o==="body"||o==="textarea"&&m===""||Ga(s,m):(typeof m=="number"||typeof m=="bigint")&&o!=="body"&&Ga(s,""+m);break;case"className":tu(s,"class",m);break;case"tabIndex":tu(s,"tabindex",m);break;case"dir":case"role":case"viewBox":case"width":case"height":tu(s,u,m);break;case"style":hy(s,m,b);break;case"data":if(o!=="object"){tu(s,"data",m);break}case"src":case"href":if(m===""&&(o!=="a"||u!=="href")){s.removeAttribute(u);break}if(m==null||typeof m=="function"||typeof m=="symbol"||typeof m=="boolean"){s.removeAttribute(u);break}m=ru(""+m),s.setAttribute(u,m);break;case"action":case"formAction":if(typeof m=="function"){s.setAttribute(u,"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 b=="function"&&(u==="formAction"?(o!=="input"&&wt(s,o,"name",y.name,y,null),wt(s,o,"formEncType",y.formEncType,y,null),wt(s,o,"formMethod",y.formMethod,y,null),wt(s,o,"formTarget",y.formTarget,y,null)):(wt(s,o,"encType",y.encType,y,null),wt(s,o,"method",y.method,y,null),wt(s,o,"target",y.target,y,null)));if(m==null||typeof m=="symbol"||typeof m=="boolean"){s.removeAttribute(u);break}m=ru(""+m),s.setAttribute(u,m);break;case"onClick":m!=null&&(s.onclick=vi);break;case"onScroll":m!=null&&nt("scroll",s);break;case"onScrollEnd":m!=null&&nt("scrollend",s);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(r(61));if(u=m.__html,u!=null){if(y.children!=null)throw Error(r(60));s.innerHTML=u}}break;case"multiple":s.multiple=m&&typeof m!="function"&&typeof m!="symbol";break;case"muted":s.muted=m&&typeof m!="function"&&typeof m!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(m==null||typeof m=="function"||typeof m=="boolean"||typeof m=="symbol"){s.removeAttribute("xlink:href");break}u=ru(""+m),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":m!=null&&typeof m!="function"&&typeof m!="symbol"?s.setAttribute(u,""+m):s.removeAttribute(u);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":m&&typeof m!="function"&&typeof m!="symbol"?s.setAttribute(u,""):s.removeAttribute(u);break;case"capture":case"download":m===!0?s.setAttribute(u,""):m!==!1&&m!=null&&typeof m!="function"&&typeof m!="symbol"?s.setAttribute(u,m):s.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":m!=null&&typeof m!="function"&&typeof m!="symbol"&&!isNaN(m)&&1<=m?s.setAttribute(u,m):s.removeAttribute(u);break;case"rowSpan":case"start":m==null||typeof m=="function"||typeof m=="symbol"||isNaN(m)?s.removeAttribute(u):s.setAttribute(u,m);break;case"popover":nt("beforetoggle",s),nt("toggle",s),eu(s,"popover",m);break;case"xlinkActuate":yi(s,"http://www.w3.org/1999/xlink","xlink:actuate",m);break;case"xlinkArcrole":yi(s,"http://www.w3.org/1999/xlink","xlink:arcrole",m);break;case"xlinkRole":yi(s,"http://www.w3.org/1999/xlink","xlink:role",m);break;case"xlinkShow":yi(s,"http://www.w3.org/1999/xlink","xlink:show",m);break;case"xlinkTitle":yi(s,"http://www.w3.org/1999/xlink","xlink:title",m);break;case"xlinkType":yi(s,"http://www.w3.org/1999/xlink","xlink:type",m);break;case"xmlBase":yi(s,"http://www.w3.org/XML/1998/namespace","xml:base",m);break;case"xmlLang":yi(s,"http://www.w3.org/XML/1998/namespace","xml:lang",m);break;case"xmlSpace":yi(s,"http://www.w3.org/XML/1998/namespace","xml:space",m);break;case"is":eu(s,"is",m);break;case"innerText":case"textContent":break;default:(!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(u=mj.get(u)||u,eu(s,u,m))}}function Qm(s,o,u,m,y,b){switch(u){case"style":hy(s,m,b);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(r(61));if(u=m.__html,u!=null){if(y.children!=null)throw Error(r(60));s.innerHTML=u}}break;case"children":typeof m=="string"?Ga(s,m):(typeof m=="number"||typeof m=="bigint")&&Ga(s,""+m);break;case"onScroll":m!=null&&nt("scroll",s);break;case"onScrollEnd":m!=null&&nt("scrollend",s);break;case"onClick":m!=null&&(s.onclick=vi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ry.hasOwnProperty(u))e:{if(u[0]==="o"&&u[1]==="n"&&(y=u.endsWith("Capture"),o=u.slice(2,y?u.length-7:void 0),b=s[Yn]||null,b=b!=null?b[u]:null,typeof b=="function"&&s.removeEventListener(o,b,y),typeof m=="function")){typeof b!="function"&&b!==null&&(u in s?s[u]=null:s.hasAttribute(u)&&s.removeAttribute(u)),s.addEventListener(o,m,y);break e}u in s?s[u]=m:m===!0?s.setAttribute(u,""):eu(s,u,m)}}}function Ln(s,o,u){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":nt("error",s),nt("load",s);var m=!1,y=!1,b;for(b in u)if(u.hasOwnProperty(b)){var E=u[b];if(E!=null)switch(b){case"src":m=!0;break;case"srcSet":y=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:wt(s,o,b,E,u,null)}}y&&wt(s,o,"srcSet",u.srcSet,u,null),m&&wt(s,o,"src",u.src,u,null);return;case"input":nt("invalid",s);var O=b=E=y=null,Y=null,ie=null;for(m in u)if(u.hasOwnProperty(m)){var de=u[m];if(de!=null)switch(m){case"name":y=de;break;case"type":E=de;break;case"checked":Y=de;break;case"defaultChecked":ie=de;break;case"value":b=de;break;case"defaultValue":O=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(r(137,o));break;default:wt(s,o,m,de,u,null)}}ly(s,b,O,Y,ie,E,y,!1);return;case"select":nt("invalid",s),m=E=b=null;for(y in u)if(u.hasOwnProperty(y)&&(O=u[y],O!=null))switch(y){case"value":b=O;break;case"defaultValue":E=O;break;case"multiple":m=O;default:wt(s,o,y,O,u,null)}o=b,u=E,s.multiple=!!m,o!=null?Wa(s,!!m,o,!1):u!=null&&Wa(s,!!m,u,!0);return;case"textarea":nt("invalid",s),b=y=m=null;for(E in u)if(u.hasOwnProperty(E)&&(O=u[E],O!=null))switch(E){case"value":m=O;break;case"defaultValue":y=O;break;case"children":b=O;break;case"dangerouslySetInnerHTML":if(O!=null)throw Error(r(91));break;default:wt(s,o,E,O,u,null)}uy(s,m,y,b);return;case"option":for(Y in u)if(u.hasOwnProperty(Y)&&(m=u[Y],m!=null))switch(Y){case"selected":s.selected=m&&typeof m!="function"&&typeof m!="symbol";break;default:wt(s,o,Y,m,u,null)}return;case"dialog":nt("beforetoggle",s),nt("toggle",s),nt("cancel",s),nt("close",s);break;case"iframe":case"object":nt("load",s);break;case"video":case"audio":for(m=0;m<Il.length;m++)nt(Il[m],s);break;case"image":nt("error",s),nt("load",s);break;case"details":nt("toggle",s);break;case"embed":case"source":case"link":nt("error",s),nt("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(ie in u)if(u.hasOwnProperty(ie)&&(m=u[ie],m!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:wt(s,o,ie,m,u,null)}return;default:if(df(o)){for(de in u)u.hasOwnProperty(de)&&(m=u[de],m!==void 0&&Qm(s,o,de,m,u,void 0));return}}for(O in u)u.hasOwnProperty(O)&&(m=u[O],m!=null&&wt(s,o,O,m,u,null))}function HT(s,o,u,m){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var y=null,b=null,E=null,O=null,Y=null,ie=null,de=null;for(oe in u){var ge=u[oe];if(u.hasOwnProperty(oe)&&ge!=null)switch(oe){case"checked":break;case"value":break;case"defaultValue":Y=ge;default:m.hasOwnProperty(oe)||wt(s,o,oe,null,m,ge)}}for(var ae in m){var oe=m[ae];if(ge=u[ae],m.hasOwnProperty(ae)&&(oe!=null||ge!=null))switch(ae){case"type":b=oe;break;case"name":y=oe;break;case"checked":ie=oe;break;case"defaultChecked":de=oe;break;case"value":E=oe;break;case"defaultValue":O=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(137,o));break;default:oe!==ge&&wt(s,o,ae,oe,m,ge)}}cf(s,E,O,Y,ie,de,b,y);return;case"select":oe=E=O=ae=null;for(b in u)if(Y=u[b],u.hasOwnProperty(b)&&Y!=null)switch(b){case"value":break;case"multiple":oe=Y;default:m.hasOwnProperty(b)||wt(s,o,b,null,m,Y)}for(y in m)if(b=m[y],Y=u[y],m.hasOwnProperty(y)&&(b!=null||Y!=null))switch(y){case"value":ae=b;break;case"defaultValue":O=b;break;case"multiple":E=b;default:b!==Y&&wt(s,o,y,b,m,Y)}o=O,u=E,m=oe,ae!=null?Wa(s,!!u,ae,!1):!!m!=!!u&&(o!=null?Wa(s,!!u,o,!0):Wa(s,!!u,u?[]:"",!1));return;case"textarea":oe=ae=null;for(O in u)if(y=u[O],u.hasOwnProperty(O)&&y!=null&&!m.hasOwnProperty(O))switch(O){case"value":break;case"children":break;default:wt(s,o,O,null,m,y)}for(E in m)if(y=m[E],b=u[E],m.hasOwnProperty(E)&&(y!=null||b!=null))switch(E){case"value":ae=y;break;case"defaultValue":oe=y;break;case"children":break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(r(91));break;default:y!==b&&wt(s,o,E,y,m,b)}cy(s,ae,oe);return;case"option":for(var Ae in u)if(ae=u[Ae],u.hasOwnProperty(Ae)&&ae!=null&&!m.hasOwnProperty(Ae))switch(Ae){case"selected":s.selected=!1;break;default:wt(s,o,Ae,null,m,ae)}for(Y in m)if(ae=m[Y],oe=u[Y],m.hasOwnProperty(Y)&&ae!==oe&&(ae!=null||oe!=null))switch(Y){case"selected":s.selected=ae&&typeof ae!="function"&&typeof ae!="symbol";break;default:wt(s,o,Y,ae,m,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 He in u)ae=u[He],u.hasOwnProperty(He)&&ae!=null&&!m.hasOwnProperty(He)&&wt(s,o,He,null,m,ae);for(ie in m)if(ae=m[ie],oe=u[ie],m.hasOwnProperty(ie)&&ae!==oe&&(ae!=null||oe!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(r(137,o));break;default:wt(s,o,ie,ae,m,oe)}return;default:if(df(o)){for(var Ct in u)ae=u[Ct],u.hasOwnProperty(Ct)&&ae!==void 0&&!m.hasOwnProperty(Ct)&&Qm(s,o,Ct,void 0,m,ae);for(de in m)ae=m[de],oe=u[de],!m.hasOwnProperty(de)||ae===oe||ae===void 0&&oe===void 0||Qm(s,o,de,ae,m,oe);return}}for(var te in u)ae=u[te],u.hasOwnProperty(te)&&ae!=null&&!m.hasOwnProperty(te)&&wt(s,o,te,null,m,ae);for(ge in m)ae=m[ge],oe=u[ge],!m.hasOwnProperty(ge)||ae===oe||ae==null&&oe==null||wt(s,o,ge,ae,m,oe)}function f0(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function FT(){if(typeof performance.getEntriesByType=="function"){for(var s=0,o=0,u=performance.getEntriesByType("resource"),m=0;m<u.length;m++){var y=u[m],b=y.transferSize,E=y.initiatorType,O=y.duration;if(b&&O&&f0(E)){for(E=0,O=y.responseEnd,m+=1;m<u.length;m++){var Y=u[m],ie=Y.startTime;if(ie>O)break;var de=Y.transferSize,ge=Y.initiatorType;de&&f0(ge)&&(Y=Y.responseEnd,E+=de*(Y<O?1:(O-ie)/(Y-ie)))}if(--m,o+=8*(b+E)/(y.duration/1e3),s++,10<s)break}}if(0<s)return o/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var Jm=null,Zm=null;function Ju(s){return s.nodeType===9?s:s.ownerDocument}function m0(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 p0(s,o){if(s===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&o==="foreignObject"?0:s}function ep(s,o){return s==="textarea"||s==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var tp=null;function UT(){var s=window.event;return s&&s.type==="popstate"?s===tp?!1:(tp=s,!0):(tp=null,!1)}var g0=typeof setTimeout=="function"?setTimeout:void 0,VT=typeof clearTimeout=="function"?clearTimeout:void 0,_0=typeof Promise=="function"?Promise:void 0,WT=typeof queueMicrotask=="function"?queueMicrotask:typeof _0<"u"?function(s){return _0.resolve(null).then(s).catch(GT)}:g0;function GT(s){setTimeout(function(){throw s})}function _s(s){return s==="head"}function x0(s,o){var u=o,m=0;do{var y=u.nextSibling;if(s.removeChild(u),y&&y.nodeType===8)if(u=y.data,u==="/$"||u==="/&"){if(m===0){s.removeChild(y),Co(o);return}m--}else if(u==="$"||u==="$?"||u==="$~"||u==="$!"||u==="&")m++;else if(u==="html")Bl(s.ownerDocument.documentElement);else if(u==="head"){u=s.ownerDocument.head,Bl(u);for(var b=u.firstChild;b;){var E=b.nextSibling,O=b.nodeName;b[nl]||O==="SCRIPT"||O==="STYLE"||O==="LINK"&&b.rel.toLowerCase()==="stylesheet"||u.removeChild(b),b=E}}else u==="body"&&Bl(s.ownerDocument.body);u=y}while(u);Co(o)}function y0(s,o){var u=s;s=0;do{var m=u.nextSibling;if(u.nodeType===1?o?(u._stashedDisplay=u.style.display,u.style.display="none"):(u.style.display=u._stashedDisplay||"",u.getAttribute("style")===""&&u.removeAttribute("style")):u.nodeType===3&&(o?(u._stashedText=u.nodeValue,u.nodeValue=""):u.nodeValue=u._stashedText||""),m&&m.nodeType===8)if(u=m.data,u==="/$"){if(s===0)break;s--}else u!=="$"&&u!=="$?"&&u!=="$~"&&u!=="$!"||s++;u=m}while(u)}function np(s){var o=s.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var u=o;switch(o=o.nextSibling,u.nodeName){case"HTML":case"HEAD":case"BODY":np(u),of(u);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(u.rel.toLowerCase()==="stylesheet")continue}s.removeChild(u)}}function qT(s,o,u,m){for(;s.nodeType===1;){var y=u;if(s.nodeName.toLowerCase()!==o.toLowerCase()){if(!m&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(m){if(!s[nl])switch(o){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(b=s.getAttribute("rel"),b==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(b!==y.rel||s.getAttribute("href")!==(y.href==null||y.href===""?null:y.href)||s.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin)||s.getAttribute("title")!==(y.title==null?null:y.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(b=s.getAttribute("src"),(b!==(y.src==null?null:y.src)||s.getAttribute("type")!==(y.type==null?null:y.type)||s.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin))&&b&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(o==="input"&&s.type==="hidden"){var b=y.name==null?null:""+y.name;if(y.type==="hidden"&&s.getAttribute("name")===b)return s}else return s;if(s=Nr(s.nextSibling),s===null)break}return null}function KT(s,o,u){if(o==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!u||(s=Nr(s.nextSibling),s===null))return null;return s}function v0(s,o){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!o||(s=Nr(s.nextSibling),s===null))return null;return s}function rp(s){return s.data==="$?"||s.data==="$~"}function ip(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function YT(s,o){var u=s.ownerDocument;if(s.data==="$~")s._reactRetry=o;else if(s.data!=="$?"||u.readyState!=="loading")o();else{var m=function(){o(),u.removeEventListener("DOMContentLoaded",m)};u.addEventListener("DOMContentLoaded",m),s._reactRetry=m}}function Nr(s){for(;s!=null;s=s.nextSibling){var o=s.nodeType;if(o===1||o===3)break;if(o===8){if(o=s.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return s}var sp=null;function b0(s){s=s.nextSibling;for(var o=0;s;){if(s.nodeType===8){var u=s.data;if(u==="/$"||u==="/&"){if(o===0)return Nr(s.nextSibling);o--}else u!=="$"&&u!=="$!"&&u!=="$?"&&u!=="$~"&&u!=="&"||o++}s=s.nextSibling}return null}function S0(s){s=s.previousSibling;for(var o=0;s;){if(s.nodeType===8){var u=s.data;if(u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"){if(o===0)return s;o--}else u!=="/$"&&u!=="/&"||o++}s=s.previousSibling}return null}function w0(s,o,u){switch(o=Ju(u),s){case"html":if(s=o.documentElement,!s)throw Error(r(452));return s;case"head":if(s=o.head,!s)throw Error(r(453));return s;case"body":if(s=o.body,!s)throw Error(r(454));return s;default:throw Error(r(451))}}function Bl(s){for(var o=s.attributes;o.length;)s.removeAttributeNode(o[0]);of(s)}var jr=new Map,C0=new Set;function Zu(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var Ii=F.d;F.d={f:XT,r:QT,D:JT,C:ZT,L:eA,m:tA,X:rA,S:nA,M:iA};function XT(){var s=Ii.f(),o=Vu();return s||o}function QT(s){var o=Fa(s);o!==null&&o.tag===5&&o.type==="form"?Hv(o):Ii.r(s)}var bo=typeof document>"u"?null:document;function k0(s,o,u){var m=bo;if(m&&typeof o=="string"&&o){var y=vr(o);y='link[rel="'+s+'"][href="'+y+'"]',typeof u=="string"&&(y+='[crossorigin="'+u+'"]'),C0.has(y)||(C0.add(y),s={rel:s,crossOrigin:u,href:o},m.querySelector(y)===null&&(o=m.createElement("link"),Ln(o,"link",s),yn(o),m.head.appendChild(o)))}}function JT(s){Ii.D(s),k0("dns-prefetch",s,null)}function ZT(s,o){Ii.C(s,o),k0("preconnect",s,o)}function eA(s,o,u){Ii.L(s,o,u);var m=bo;if(m&&s&&o){var y='link[rel="preload"][as="'+vr(o)+'"]';o==="image"&&u&&u.imageSrcSet?(y+='[imagesrcset="'+vr(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(y+='[imagesizes="'+vr(u.imageSizes)+'"]')):y+='[href="'+vr(s)+'"]';var b=y;switch(o){case"style":b=So(s);break;case"script":b=wo(s)}jr.has(b)||(s=g({rel:"preload",href:o==="image"&&u&&u.imageSrcSet?void 0:s,as:o},u),jr.set(b,s),m.querySelector(y)!==null||o==="style"&&m.querySelector(zl(b))||o==="script"&&m.querySelector($l(b))||(o=m.createElement("link"),Ln(o,"link",s),yn(o),m.head.appendChild(o)))}}function tA(s,o){Ii.m(s,o);var u=bo;if(u&&s){var m=o&&typeof o.as=="string"?o.as:"script",y='link[rel="modulepreload"][as="'+vr(m)+'"][href="'+vr(s)+'"]',b=y;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=wo(s)}if(!jr.has(b)&&(s=g({rel:"modulepreload",href:s},o),jr.set(b,s),u.querySelector(y)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector($l(b)))return}m=u.createElement("link"),Ln(m,"link",s),yn(m),u.head.appendChild(m)}}}function nA(s,o,u){Ii.S(s,o,u);var m=bo;if(m&&s){var y=Ua(m).hoistableStyles,b=So(s);o=o||"default";var E=y.get(b);if(!E){var O={loading:0,preload:null};if(E=m.querySelector(zl(b)))O.loading=5;else{s=g({rel:"stylesheet",href:s,"data-precedence":o},u),(u=jr.get(b))&&ap(s,u);var Y=E=m.createElement("link");yn(Y),Ln(Y,"link",s),Y._p=new Promise(function(ie,de){Y.onload=ie,Y.onerror=de}),Y.addEventListener("load",function(){O.loading|=1}),Y.addEventListener("error",function(){O.loading|=2}),O.loading|=4,ed(E,o,m)}E={type:"stylesheet",instance:E,count:1,state:O},y.set(b,E)}}}function rA(s,o){Ii.X(s,o);var u=bo;if(u&&s){var m=Ua(u).hoistableScripts,y=wo(s),b=m.get(y);b||(b=u.querySelector($l(y)),b||(s=g({src:s,async:!0},o),(o=jr.get(y))&&op(s,o),b=u.createElement("script"),yn(b),Ln(b,"link",s),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},m.set(y,b))}}function iA(s,o){Ii.M(s,o);var u=bo;if(u&&s){var m=Ua(u).hoistableScripts,y=wo(s),b=m.get(y);b||(b=u.querySelector($l(y)),b||(s=g({src:s,async:!0,type:"module"},o),(o=jr.get(y))&&op(s,o),b=u.createElement("script"),yn(b),Ln(b,"link",s),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},m.set(y,b))}}function E0(s,o,u,m){var y=(y=ee.current)?Zu(y):null;if(!y)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(o=So(u.href),u=Ua(y).hoistableStyles,m=u.get(o),m||(m={type:"style",instance:null,count:0,state:null},u.set(o,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){s=So(u.href);var b=Ua(y).hoistableStyles,E=b.get(s);if(E||(y=y.ownerDocument||y,E={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(s,E),(b=y.querySelector(zl(s)))&&!b._p&&(E.instance=b,E.state.loading=5),jr.has(s)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},jr.set(s,u),b||sA(y,s,u,E.state))),o&&m===null)throw Error(r(528,""));return E}if(o&&m!==null)throw Error(r(529,""));return null;case"script":return o=u.async,u=u.src,typeof u=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=wo(u),u=Ua(y).hoistableScripts,m=u.get(o),m||(m={type:"script",instance:null,count:0,state:null},u.set(o,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function So(s){return'href="'+vr(s)+'"'}function zl(s){return'link[rel="stylesheet"]['+s+"]"}function N0(s){return g({},s,{"data-precedence":s.precedence,precedence:null})}function sA(s,o,u,m){s.querySelector('link[rel="preload"][as="style"]['+o+"]")?m.loading=1:(o=s.createElement("link"),m.preload=o,o.addEventListener("load",function(){return m.loading|=1}),o.addEventListener("error",function(){return m.loading|=2}),Ln(o,"link",u),yn(o),s.head.appendChild(o))}function wo(s){return'[src="'+vr(s)+'"]'}function $l(s){return"script[async]"+s}function j0(s,o,u){if(o.count++,o.instance===null)switch(o.type){case"style":var m=s.querySelector('style[data-href~="'+vr(u.href)+'"]');if(m)return o.instance=m,yn(m),m;var y=g({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return m=(s.ownerDocument||s).createElement("style"),yn(m),Ln(m,"style",y),ed(m,u.precedence,s),o.instance=m;case"stylesheet":y=So(u.href);var b=s.querySelector(zl(y));if(b)return o.state.loading|=4,o.instance=b,yn(b),b;m=N0(u),(y=jr.get(y))&&ap(m,y),b=(s.ownerDocument||s).createElement("link"),yn(b);var E=b;return E._p=new Promise(function(O,Y){E.onload=O,E.onerror=Y}),Ln(b,"link",m),o.state.loading|=4,ed(b,u.precedence,s),o.instance=b;case"script":return b=wo(u.src),(y=s.querySelector($l(b)))?(o.instance=y,yn(y),y):(m=u,(y=jr.get(b))&&(m=g({},u),op(m,y)),s=s.ownerDocument||s,y=s.createElement("script"),yn(y),Ln(y,"link",m),s.head.appendChild(y),o.instance=y);case"void":return null;default:throw Error(r(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(m=o.instance,o.state.loading|=4,ed(m,u.precedence,s));return o.instance}function ed(s,o,u){for(var m=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=m.length?m[m.length-1]:null,b=y,E=0;E<m.length;E++){var O=m[E];if(O.dataset.precedence===o)b=O;else if(b!==y)break}b?b.parentNode.insertBefore(s,b.nextSibling):(o=u.nodeType===9?u.head:u,o.insertBefore(s,o.firstChild))}function ap(s,o){s.crossOrigin==null&&(s.crossOrigin=o.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=o.referrerPolicy),s.title==null&&(s.title=o.title)}function op(s,o){s.crossOrigin==null&&(s.crossOrigin=o.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=o.referrerPolicy),s.integrity==null&&(s.integrity=o.integrity)}var td=null;function T0(s,o,u){if(td===null){var m=new Map,y=td=new Map;y.set(u,m)}else y=td,m=y.get(u),m||(m=new Map,y.set(u,m));if(m.has(s))return m;for(m.set(s,null),u=u.getElementsByTagName(s),y=0;y<u.length;y++){var b=u[y];if(!(b[nl]||b[yt]||s==="link"&&b.getAttribute("rel")==="stylesheet")&&b.namespaceURI!=="http://www.w3.org/2000/svg"){var E=b.getAttribute(o)||"";E=s+E;var O=m.get(E);O?O.push(b):m.set(E,[b])}}return m}function A0(s,o,u){s=s.ownerDocument||s,s.head.insertBefore(u,o==="title"?s.querySelector("head > title"):null)}function aA(s,o,u){if(u===1||o.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;switch(o.rel){case"stylesheet":return s=o.disabled,typeof o.precedence=="string"&&s==null;default:return!0}case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function D0(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function oA(s,o,u,m){if(u.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var y=So(m.href),b=o.querySelector(zl(y));if(b){o=b._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(s.count++,s=nd.bind(s),o.then(s,s)),u.state.loading|=4,u.instance=b,yn(b);return}b=o.ownerDocument||o,m=N0(m),(y=jr.get(y))&&ap(m,y),b=b.createElement("link"),yn(b);var E=b;E._p=new Promise(function(O,Y){E.onload=O,E.onerror=Y}),Ln(b,"link",m),u.instance=b}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(u,o),(o=u.state.preload)&&(u.state.loading&3)===0&&(s.count++,u=nd.bind(s),o.addEventListener("load",u),o.addEventListener("error",u))}}var lp=0;function lA(s,o){return s.stylesheets&&s.count===0&&id(s,s.stylesheets),0<s.count||0<s.imgCount?function(u){var m=setTimeout(function(){if(s.stylesheets&&id(s,s.stylesheets),s.unsuspend){var b=s.unsuspend;s.unsuspend=null,b()}},6e4+o);0<s.imgBytes&&lp===0&&(lp=62500*FT());var y=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&id(s,s.stylesheets),s.unsuspend)){var b=s.unsuspend;s.unsuspend=null,b()}},(s.imgBytes>lp?50:800)+o);return s.unsuspend=u,function(){s.unsuspend=null,clearTimeout(m),clearTimeout(y)}}:null}function nd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)id(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var rd=null;function id(s,o){s.stylesheets=null,s.unsuspend!==null&&(s.count++,rd=new Map,o.forEach(cA,s),rd=null,nd.call(s))}function cA(s,o){if(!(o.state.loading&4)){var u=rd.get(s);if(u)var m=u.get(null);else{u=new Map,rd.set(s,u);for(var y=s.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b<y.length;b++){var E=y[b];(E.nodeName==="LINK"||E.getAttribute("media")!=="not all")&&(u.set(E.dataset.precedence,E),m=E)}m&&u.set(null,m)}y=o.instance,E=y.getAttribute("data-precedence"),b=u.get(E)||m,b===m&&u.set(null,y),u.set(E,y),this.count++,m=nd.bind(this),y.addEventListener("load",m),y.addEventListener("error",m),b?b.parentNode.insertBefore(y,b.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(y,s.firstChild)),o.state.loading|=4}}var Hl={$$typeof:T,Provider:null,Consumer:null,_currentValue:$,_currentValue2:$,_threadCount:0};function uA(s,o,u,m,y,b,E,O,Y){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=za(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=za(0),this.hiddenUpdates=za(null),this.identifierPrefix=m,this.onUncaughtError=y,this.onCaughtError=b,this.onRecoverableError=E,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Y,this.incompleteTransitions=new Map}function L0(s,o,u,m,y,b,E,O,Y,ie,de,ge){return s=new uA(s,o,u,E,Y,ie,de,ge,O),o=1,b===!0&&(o|=24),b=or(3,null,null,o),s.current=b,b.stateNode=s,o=Hf(),o.refCount++,s.pooledCache=o,o.refCount++,b.memoizedState={element:m,isDehydrated:u,cache:o},Wf(b),s}function R0(s){return s?(s=Za,s):Za}function M0(s,o,u,m,y,b){y=R0(y),m.context===null?m.context=y:m.pendingContext=y,m=as(o),m.payload={element:u},b=b===void 0?null:b,b!==null&&(m.callback=b),u=os(s,m,o),u!==null&&(tr(u,s,o),yl(u,s,o))}function O0(s,o){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var u=s.retryLane;s.retryLane=u!==0&&u<o?u:o}}function cp(s,o){O0(s,o),(s=s.alternate)&&O0(s,o)}function I0(s){if(s.tag===13||s.tag===31){var o=qs(s,67108864);o!==null&&tr(o,s,67108864),cp(s,67108864)}}function P0(s){if(s.tag===13||s.tag===31){var o=hr();o=Qe(o);var u=qs(s,o);u!==null&&tr(u,s,o),cp(s,o)}}var sd=!0;function dA(s,o,u,m){var y=N.T;N.T=null;var b=F.p;try{F.p=2,up(s,o,u,m)}finally{F.p=b,N.T=y}}function hA(s,o,u,m){var y=N.T;N.T=null;var b=F.p;try{F.p=8,up(s,o,u,m)}finally{F.p=b,N.T=y}}function up(s,o,u,m){if(sd){var y=dp(m);if(y===null)Xm(s,o,m,ad,u),z0(s,m);else if(mA(y,s,o,u,m))m.stopPropagation();else if(z0(s,m),o&4&&-1<fA.indexOf(s)){for(;y!==null;){var b=Fa(y);if(b!==null)switch(b.tag){case 3:if(b=b.stateNode,b.current.memoizedState.isDehydrated){var E=Jr(b.pendingLanes);if(E!==0){var O=b;for(O.pendingLanes|=2,O.entangledLanes|=2;E;){var Y=1<<31-xt(E);O.entanglements[1]|=Y,E&=~Y}ni(b),(gt&6)===0&&(Fu=Yt()+500,Ol(0))}}break;case 31:case 13:O=qs(b,2),O!==null&&tr(O,b,2),Vu(),cp(b,2)}if(b=dp(m),b===null&&Xm(s,o,m,ad,u),b===y)break;y=b}y!==null&&m.stopPropagation()}else Xm(s,o,m,null,u)}}function dp(s){return s=ff(s),hp(s)}var ad=null;function hp(s){if(ad=null,s=Ha(s),s!==null){var o=a(s);if(o===null)s=null;else{var u=o.tag;if(u===13){if(s=l(o),s!==null)return s;s=null}else if(u===31){if(s=d(o),s!==null)return s;s=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;s=null}else o!==s&&(s=null)}}return ad=s,null}function B0(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(el()){case me:return 2;case ke:return 8;case $e:case Xe:return 32;case ut:return 268435456;default:return 32}default:return 32}}var fp=!1,xs=null,ys=null,vs=null,Fl=new Map,Ul=new Map,bs=[],fA="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 z0(s,o){switch(s){case"focusin":case"focusout":xs=null;break;case"dragenter":case"dragleave":ys=null;break;case"mouseover":case"mouseout":vs=null;break;case"pointerover":case"pointerout":Fl.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ul.delete(o.pointerId)}}function Vl(s,o,u,m,y,b){return s===null||s.nativeEvent!==b?(s={blockedOn:o,domEventName:u,eventSystemFlags:m,nativeEvent:b,targetContainers:[y]},o!==null&&(o=Fa(o),o!==null&&I0(o)),s):(s.eventSystemFlags|=m,o=s.targetContainers,y!==null&&o.indexOf(y)===-1&&o.push(y),s)}function mA(s,o,u,m,y){switch(o){case"focusin":return xs=Vl(xs,s,o,u,m,y),!0;case"dragenter":return ys=Vl(ys,s,o,u,m,y),!0;case"mouseover":return vs=Vl(vs,s,o,u,m,y),!0;case"pointerover":var b=y.pointerId;return Fl.set(b,Vl(Fl.get(b)||null,s,o,u,m,y)),!0;case"gotpointercapture":return b=y.pointerId,Ul.set(b,Vl(Ul.get(b)||null,s,o,u,m,y)),!0}return!1}function $0(s){var o=Ha(s.target);if(o!==null){var u=a(o);if(u!==null){if(o=u.tag,o===13){if(o=l(u),o!==null){s.blockedOn=o,jn(s.priority,function(){P0(u)});return}}else if(o===31){if(o=d(u),o!==null){s.blockedOn=o,jn(s.priority,function(){P0(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){s.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}s.blockedOn=null}function od(s){if(s.blockedOn!==null)return!1;for(var o=s.targetContainers;0<o.length;){var u=dp(s.nativeEvent);if(u===null){u=s.nativeEvent;var m=new u.constructor(u.type,u);hf=m,u.target.dispatchEvent(m),hf=null}else return o=Fa(u),o!==null&&I0(o),s.blockedOn=u,!1;o.shift()}return!0}function H0(s,o,u){od(s)&&u.delete(o)}function pA(){fp=!1,xs!==null&&od(xs)&&(xs=null),ys!==null&&od(ys)&&(ys=null),vs!==null&&od(vs)&&(vs=null),Fl.forEach(H0),Ul.forEach(H0)}function ld(s,o){s.blockedOn===o&&(s.blockedOn=null,fp||(fp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,pA)))}var cd=null;function F0(s){cd!==s&&(cd=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){cd===s&&(cd=null);for(var o=0;o<s.length;o+=3){var u=s[o],m=s[o+1],y=s[o+2];if(typeof m!="function"){if(hp(m||u)===null)continue;break}var b=Fa(u);b!==null&&(s.splice(o,3),o-=3,dm(b,{pending:!0,data:y,method:u.method,action:m},m,y))}}))}function Co(s){function o(Y){return ld(Y,s)}xs!==null&&ld(xs,s),ys!==null&&ld(ys,s),vs!==null&&ld(vs,s),Fl.forEach(o),Ul.forEach(o);for(var u=0;u<bs.length;u++){var m=bs[u];m.blockedOn===s&&(m.blockedOn=null)}for(;0<bs.length&&(u=bs[0],u.blockedOn===null);)$0(u),u.blockedOn===null&&bs.shift();if(u=(s.ownerDocument||s).$$reactFormReplay,u!=null)for(m=0;m<u.length;m+=3){var y=u[m],b=u[m+1],E=y[Yn]||null;if(typeof b=="function")E||F0(u);else if(E){var O=null;if(b&&b.hasAttribute("formAction")){if(y=b,E=b[Yn]||null)O=E.formAction;else if(hp(y)!==null)continue}else O=E.action;typeof O=="function"?u[m+1]=O:(u.splice(m,3),m-=3),F0(u)}}}function U0(){function s(b){b.canIntercept&&b.info==="react-transition"&&b.intercept({handler:function(){return new Promise(function(E){return y=E})},focusReset:"manual",scroll:"manual"})}function o(){y!==null&&(y(),y=null),m||setTimeout(u,20)}function u(){if(!m&&!navigation.transition){var b=navigation.currentEntry;b&&b.url!=null&&navigation.navigate(b.url,{state:b.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var m=!1,y=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(u,100),function(){m=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),y!==null&&(y(),y=null)}}}function mp(s){this._internalRoot=s}ud.prototype.render=mp.prototype.render=function(s){var o=this._internalRoot;if(o===null)throw Error(r(409));var u=o.current,m=hr();M0(u,m,s,o,null,null)},ud.prototype.unmount=mp.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var o=s.containerInfo;M0(s.current,2,null,s,null,null),Vu(),o[$a]=null}};function ud(s){this._internalRoot=s}ud.prototype.unstable_scheduleHydration=function(s){if(s){var o=dt();s={blockedOn:null,target:s,priority:o};for(var u=0;u<bs.length&&o!==0&&o<bs[u].priority;u++);bs.splice(u,0,s),u===0&&$0(s)}};var V0=t.version;if(V0!=="19.2.4")throw Error(r(527,V0,"19.2.4"));F.findDOMNode=function(s){var o=s._reactInternals;if(o===void 0)throw typeof s.render=="function"?Error(r(188)):(s=Object.keys(s).join(","),Error(r(268,s)));return s=h(o),s=s!==null?p(s):null,s=s===null?null:s.stateNode,s};var gA={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:N,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var dd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!dd.isDisabled&&dd.supportsFiber)try{zt=dd.inject(gA),pt=dd}catch{}}return Gl.createRoot=function(s,o){if(!i(s))throw Error(r(299));var u=!1,m="",y=Qv,b=Jv,E=Zv;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onUncaughtError!==void 0&&(y=o.onUncaughtError),o.onCaughtError!==void 0&&(b=o.onCaughtError),o.onRecoverableError!==void 0&&(E=o.onRecoverableError)),o=L0(s,1,!1,null,null,u,m,null,y,b,E,U0),s[$a]=o.current,Ym(s),new mp(o)},Gl.hydrateRoot=function(s,o,u){if(!i(s))throw Error(r(299));var m=!1,y="",b=Qv,E=Jv,O=Zv,Y=null;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(y=u.identifierPrefix),u.onUncaughtError!==void 0&&(b=u.onUncaughtError),u.onCaughtError!==void 0&&(E=u.onCaughtError),u.onRecoverableError!==void 0&&(O=u.onRecoverableError),u.formState!==void 0&&(Y=u.formState)),o=L0(s,1,!0,o,u??null,m,y,Y,b,E,O,U0),o.context=R0(null),u=o.current,m=hr(),m=Qe(m),y=as(m),y.callback=null,os(u,y,m),u=m,o.current.lanes=u,Zi(o,u),ni(o),s[$a]=o.current,Ym(s),new ud(o)},Gl.version="19.2.4",Gl}var nS;function DA(){if(nS)return yp.exports;nS=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(),yp.exports=AA(),yp.exports}var LA=DA();const RA=Ch(LA),rS=e=>{let t;const n=new Set,r=(h,p)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const x=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(_=>_(t,x))}},i=()=>t,d={setState:r,getState:i,getInitialState:()=>f,subscribe:h=>(n.add(h),()=>n.delete(h))},f=t=e(r,i,d);return d},MA=(e=>e?rS(e):rS),OA=e=>e;function IA(e,t=OA){const n=Ls.useSyncExternalStore(e.subscribe,Ls.useCallback(()=>t(e.getState()),[e,t]),Ls.useCallback(()=>t(e.getInitialState()),[e,t]));return Ls.useDebugValue(n),n}const iS=e=>{const t=MA(e),n=r=>IA(t,r);return Object.assign(n,t),n},xr=(e=>e?iS(e):iS);async function Ne(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 PA(e,t){try{return(await Ne(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageIndex:t})})).ok}catch{return!1}}const Me={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_SHOW_SYNTAX_HIGHLIGHTING:"display.showSyntaxHighlighting",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",DISPLAY_FOLLOW_SYSTEM_THEME:"display.followSystemTheme",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",LLM_DISABLE_XML_PROTECTION:"llm.disableXmlProtection",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",KEYBINDINGS:"keybindings"};function hd(e,t){return n=>({loading:{...n.loading,[e]:t}})}function sS(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const IC=[Me.DISPLAY_SHOW_THINKING,Me.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Me.DISPLAY_SHOW_STATS,Me.DISPLAY_SHOW_AGENT_DEFINITIONS,Me.DISPLAY_SHOW_WORKFLOW_BARS,Me.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Me.DISPLAY_FOLLOW_SYSTEM_THEME,Me.DISPLAY_SHOW_OPEN_IN_EDITOR];function Eh(){return{showThinking:tn(e=>e.settings[Me.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:tn(e=>e.settings[Me.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:tn(e=>e.settings[Me.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:tn(e=>e.settings[Me.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:tn(e=>e.settings[Me.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:tn(e=>e.settings[Me.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true"}}const tn=xr(e=>({settings:{},loading:{},getSetting:async t=>{e(hd(t,!0));try{const r=await(await Ne(`/api/settings/${t}`)).json();return e(sS(t,r.value??"")),r.value}catch{return e(hd(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await Ne(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:r,loading:Object.fromEntries(t.map(i=>[i,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(hd(t,!0));try{const i=await(await Ne(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(sS(t,i.value??""))}catch{e(hd(t,!1))}}})),wp=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:IC,SETTINGS_KEYS:Me,useDisplaySettings:Eh,useSettingsStore:tn},Symbol.toStringTag,{value:"Module"}));function BA(){const[e,t]=C.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=C.useRef(window.innerHeight);return C.useEffect(()=>{const r=window.visualViewport;if(!r)return;const i=()=>{const a=r.offsetTop,l=r.height,d=n.current-l>100;t({offsetTop:a,height:l,keyboardVisible:d})};return i(),r.addEventListener("resize",i),r.addEventListener("scroll",i),()=>{r.removeEventListener("resize",i),r.removeEventListener("scroll",i)}},[]),e}function zA(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,i,a,l=[],d="",f=e.split("/");for(f[0]||f.shift();i=f.shift();)n=i[0],n==="*"?(l.push(n),d+=i[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=i.indexOf("?",1),a=i.indexOf(".",1),l.push(i.substring(1,~r?r:~a?a:i.length)),d+=~r&&!~a?"(?:/([^/]+?))?":"/([^/]+?)",~a&&(d+=(~r?"?":"")+"\\"+i.substring(a))):d+="/"+i;return{keys:l,pattern:new RegExp("^"+d+(t?"(?=$|/)":"/?$"),"i")}}var Cp={exports:{}},kp={};/**
51
+ * @license React
52
+ * use-sync-external-store-shim.production.js
53
+ *
54
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
55
+ *
56
+ * This source code is licensed under the MIT license found in the
57
+ * LICENSE file in the root directory of this source tree.
58
+ */var aS;function $A(){if(aS)return kp;aS=1;var e=kh();function t(g,x){return g===x&&(g!==0||1/g===1/x)||g!==g&&x!==x}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,i=e.useEffect,a=e.useLayoutEffect,l=e.useDebugValue;function d(g,x){var _=x(),v=r({inst:{value:_,getSnapshot:x}}),S=v[0].inst,w=v[1];return a(function(){S.value=_,S.getSnapshot=x,f(S)&&w({inst:S})},[g,_,x]),i(function(){return f(S)&&w({inst:S}),g(function(){f(S)&&w({inst:S})})},[g]),l(_),_}function f(g){var x=g.getSnapshot;g=g.value;try{var _=x();return!n(g,_)}catch{return!0}}function h(g,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:d;return kp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,kp}var oS;function HA(){return oS||(oS=1,Cp.exports=$A()),Cp.exports}var FA=HA();const UA=EA.useInsertionEffect,VA=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",WA=VA?C.useLayoutEffect:C.useEffect,GA=UA||WA,PC=e=>{const t=C.useRef([e,(...n)=>t[0](...n)]).current;return GA(()=>{t[0]=e}),t[1]},qA="popstate",W_="pushState",G_="replaceState",KA="hashchange",lS=[qA,W_,G_,KA],YA=e=>{for(const t of lS)addEventListener(t,e);return()=>{for(const t of lS)removeEventListener(t,e)}},BC=(e,t)=>FA.useSyncExternalStore(YA,e,t),cS=()=>location.search,XA=({ssrSearch:e}={})=>BC(cS,e!=null?()=>e:cS),uS=()=>location.pathname,QA=({ssrPath:e}={})=>BC(uS,e!=null?()=>e:uS),JA=(e,{replace:t=!1,state:n=null}={})=>history[t?G_:W_](n,"",e),ZA=(e={})=>[QA(e),JA],dS=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[dS]>"u"){for(const e of[W_,G_]){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,dS,{value:!0})}const eD=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",zC=(e="")=>e==="/"?"":e,tD=(e,t)=>e[0]==="~"?e.slice(1):zC(t)+e,nD=(e="",t)=>eD(hS(zC(e)),hS(t)),hS=e=>{try{return decodeURI(e)}catch{return e}},$C={hook:ZA,searchHook:XA,parser:zA,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},HC=C.createContext($C),qo=()=>C.useContext(HC),FC={},UC=C.createContext(FC),rD=()=>C.useContext(UC),Nh=e=>{const[t,n]=e.hook(e);return[nD(e.base,t),PC((r,i)=>e.aroundNav(n,tD(r,e.base),i))]},Qr=()=>Nh(qo()),q_=(e,t,n,r)=>{const{pattern:i,keys:a}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),l=i.exec(n)||[],[d,...f]=l;return d!==void 0?[!0,(()=>{const h=a!==!1?Object.fromEntries(a.map((g,x)=>[g,f[x]])):l.groups;let p={...f};return h&&Object.assign(p,h),p})(),...r?[d]:[]]:[!1,null]},K_=e=>q_(qo().parser,e,Qr()[0]),iD=({children:e,...t})=>{var p,g,x;const n=qo(),r=t.hook?$C:n;let i=r;const[a,l=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];a&&(t.ssrSearch=l,t.ssrPath=a),t.hrefs=t.hrefs??((g=t.hook)==null?void 0:g.hrefs),t.searchHook=t.searchHook??((x=t.hook)==null?void 0:x.searchHook);let d=C.useRef({}),f=d.current,h=f;for(let _ in r){const v=_==="base"?r[_]+(t[_]??""):t[_]??r[_];f===h&&v!==h[_]&&(d.current=h={...h}),h[_]=v,(v!==r[_]||v!==i[_])&&(i=h)}return C.createElement(HC.Provider,{value:i,children:e})},fS=({children:e,component:t},n)=>t?C.createElement(t,{params:n}):typeof e=="function"?e(n):e,sD=e=>{let t=C.useRef(FC);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,i])=>i!==n[r])?e:n},ql=({path:e,nest:t,match:n,...r})=>{const i=qo(),[a]=Nh(i),[l,d,f]=n??q_(i.parser,e,a,t),h=sD({...rD(),...d});if(!l)return null;const p=f?C.createElement(iD,{base:f},fS(r,h)):fS(r,h);return C.createElement(UC.Provider,{value:h,children:p})},gr=C.forwardRef((e,t)=>{const n=qo(),[r,i]=Nh(n),{to:a="",href:l=a,onClick:d,asChild:f,children:h,className:p,replace:g,state:x,transition:_,...v}=e,S=PC(k=>{k.ctrlKey||k.metaKey||k.altKey||k.shiftKey||k.button!==0||(d==null||d(k),k.defaultPrevented||(k.preventDefault(),i(l,e)))}),w=n.hrefs(l[0]==="~"?l.slice(1):n.base+l,n);return f&&C.isValidElement(h)?C.cloneElement(h,{onClick:S,href:w}):C.createElement("a",{...v,onClick:S,href:w,className:p!=null&&p.call?p(r===l):p,children:h,ref:t})}),VC=e=>Array.isArray(e)?e.flatMap(t=>VC(t&&t.type===C.Fragment?t.props.children:t)):[e],aD=({children:e,location:t})=>{const n=qo(),[r]=Nh(n);for(const i of VC(e)){let a=0;if(C.isValidElement(i)&&(a=q_(n.parser,i.props.path,t||r,i.props.nest))[0])return C.cloneElement(i,{match:a})}return null};function oD(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function WC(){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 lD{constructor(t){ce(this,"ws",null);ce(this,"handlers",new Set);ce(this,"statusHandler",null);ce(this,"baseUrl");ce(this,"isReconnecting",!1);ce(this,"connectingPromise",null);ce(this,"lastCloseCode",0);ce(this,"reconnectAttempts",0);ce(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,r;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.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((r=this.ws)==null?void 0:r.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((i,a)=>{try{const l=this.getUrl();this.ws=new WebSocket(l);const d=setTimeout(()=>{var f;((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING&&(this.ws.close(),a(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var f;clearTimeout(d),this.isReconnecting=!1,this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"connected"),i()},this.ws.onclose=f=>{var h,p,g;clearTimeout(d),this.lastCloseCode=f.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),a(new Error(`Connection closed: ${f.code}`))):(this.connectingPromise=null,(g=this.statusHandler)==null||g.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=f=>{clearTimeout(d),console.error("WebSocket error:",f),this.connectingPromise=null,a(f)},this.ws.onmessage=f=>{try{const h=JSON.parse(f.data);oD(h)&&this.handlers.forEach(p=>p(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}catch(l){this.connectingPromise=null,a(l)}}),this.connectingPromise)))}attemptReconnect(){var i;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,(i=this.statusHandler)==null||i.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=WC(),i={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(i)),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 cD=window.location.protocol==="https:"?"wss:":"ws:";let jg=window.location.port;jg||(jg=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const uD=`${cD}//${window.location.hostname}:${jg}/ws`,Ft=new lD(uD);function dD(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}}}function mS(e){e&&xe.getState().updateContextState({...e,dynamicContextChanged:e.dynamicContextChanged??!1})}async function pS(e,t,n){const r=await Ne(`/api/providers/${e}/models/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const i=await r.json();throw new Error(i.error??"Failed to update model")}return r.json()}function gS(e,t,n,r){return e.map(i=>i.id===t?{...i,models:i.models.map(a=>a.id===n?{...a,...r,source:"user"}:a)}:i)}const hD=3e4;function Tg(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 Ot=xr((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 Ne("/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 Ne("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json(),a=xe.getState().currentSession;if(a!=null&&a.providerId&&a.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:i}=t();if(n===r)return!0;e({activating:!0,error:null});try{const a=await Ne(`/api/providers/${n}/activate`,{method:"POST"});if(!a.ok){const d=await a.json();throw new Error(d.error??"Failed to activate provider")}const l=await a.json();return e({activeProviderId:l.activeProviderId,model:l.model,backend:l.backend,providers:i.map(d=>({...d,isActive:d.id===l.activeProviderId})),activating:!1}),!0}catch(a){return e({error:a instanceof Error?a.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(n,r)=>{var d;const{providers:i,defaultModelSelection:a}=t();let l=r;if(!l){const f=a?a.split("/"):[],h=f[0],p=f.slice(1).join("/")??"";if(h===n&&p)l=p;else{const g=i.find(x=>x.id===n);l=((d=g==null?void 0:g.models[0])==null?void 0:d.id)??""}}e({activeProviderId:n,model:l,defaultModelSelection:`${n}/${l}`,providers:i.map(f=>({...f,isActive:f.id===n}))})},updateModelContext:async(n,r,i)=>{e({activating:!0,error:null});try{const a=await pS(n,r,{contextWindow:i}),{providers:l}=t();return e({providers:gS(l,n,r,{contextWindow:i}),activating:!1}),mS(a.contextState),!0}catch(a){return e({error:a instanceof Error?a.message:"Failed to update model context",activating:!1}),!1}},updateModelSettings:async(n,r,i)=>{e({activating:!0,error:null});try{const a=await pS(n,r,i),{providers:l}=t(),d={...i.contextWindow!==void 0&&{contextWindow:i.contextWindow},...dD({temperature:i.temperature??void 0,topP:i.topP??void 0,topK:i.topK??void 0,maxTokens:i.maxTokens??void 0}),...i.supportsVision!==void 0&&{supportsVision:i.supportsVision}};return e({providers:gS(l,n,r,d),activating:!1}),mS(a.contextState),!0}catch(a){return e({error:a instanceof Error?a.message:"Failed to update model settings",activating:!1}),!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await Ne(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const l=await r.json();throw new Error(l.error??"Failed to refresh models")}const i=await r.json(),{providers:a}=t();return e({providers:a.map(l=>l.id===n?{...l,models:i.models,status:i.status}:l),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 i=setInterval(()=>{r()},hD);e({autoRefreshInterval:i})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(i=>i.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:i}=t(),a=r.find(d=>d.id===i);if(!a)return 2e5;const l=a.models.find(d=>d.id===n);return(l==null?void 0:l.contextWindow)??2e5}})),Ut=xr((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await Ne("/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 i=await Ne("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!i.ok){const l=await i.json().catch(()=>({}));return{error:{code:l.code||"UNKNOWN",path:l.path,message:l.error}}}const a=await i.json();return await t().listProjects(),a.project}catch{return null}},loadProject:async n=>{try{const r=await Ne(`/api/projects/${n}`);if(!r.ok)return null;const i=await r.json();return e({currentProject:i.project}),t().projects.length===0&&await t().listProjects(),i.project}catch{return null}},updateProject:async(n,r)=>{var i;try{const a=await Ne(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)return null;const l=await a.json();return((i=t().currentProject)==null?void 0:i.id)===n&&e({currentProject:l.project}),await t().listProjects(),l.project}catch{return null}},deleteProject:async n=>{var r;try{return(await Ne(`/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 i;try{const a=await Ne(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!a.ok)return!1;if(((i=t().currentProject)==null?void 0:i.id)===n){const l=await a.json();e({currentProject:l.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),zs=async(e,t,n)=>{try{const r=await Ne(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"}}},jh=async(e,t,n)=>{try{const r=await Ne(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),i=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:i.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function GC(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let fd=[];const xc=xr()((e,t)=>{function n(){if(fd.length===0)return;const i=fd;fd=[],e(a=>{const l={...a.logs};for(const d of i){const f=l[d.processId]??[];l[d.processId]=[...f,{offset:f.length,content:d.content,timestamp:Date.now(),stream:d.stream}]}return{logs:l}})}const r=GC(n);return{processes:[],logs:{},loading:!1,setProcesses:i=>e({processes:i}),addProcess:i=>e(a=>({processes:[...a.processes,i]})),updateProcess:(i,a)=>e(l=>({processes:l.processes.map(d=>d.id===i?{...d,...a}:d)})),removeProcess:i=>e(a=>({processes:a.processes.filter(l=>l.id!==i),logs:Object.fromEntries(Object.entries(a.logs).filter(([l])=>l!==i))})),stopProcess:async(i,a)=>{try{(await Ne(`/api/sessions/${a}/background-process/${i}/stop`,{method:"POST"})).ok&&t().removeProcess(i)}catch{}},appendLog:(i,a,l)=>{fd.push({processId:i,stream:a,content:l}),r()},setLogs:(i,a)=>e(l=>({logs:{...l.logs,[i]:a}})),clearLogs:i=>e(a=>({logs:{...a.logs,[i]:[]}})),handleMessage:(i,a)=>{switch(i){case"backgroundProcess.started":{const{processId:l,name:d,pid:f,status:h}=a;e(p=>({processes:[...p.processes,{id:l,sessionId:"",name:d,command:"",cwd:"",pid:f,status:h,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const l=a.processId,d=a.stream,f=a.content;t().appendLog(l,d,f);break}case"backgroundProcess.exited":{const l=a.processId,d=a.exitCode;e(f=>({processes:f.processes.map(h=>h.id===l?{...h,status:"exited",exitCode:d}:h)}));break}case"backgroundProcess.removed":{const l=a.processId;t().removeProcess(l);break}}}}}),fD={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let $o=null,Bd=null;function mD(e){Bd=e}function fa(){return fD}function Ep(){$o===null&&($o=requestAnimationFrame(()=>{$o=null,Bd==null||Bd()}))}function ya(){$o!==null&&(cancelAnimationFrame($o),$o=null)}let md=[];const di=xr()((e,t)=>{function n(){if(md.length===0)return;const i=md;md=[],e(a=>({logs:[...a.logs,...i]}))}const r=GC(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:i=>{t().workdir!==i&&(e({workdir:i,status:null,logs:[],config:null,loading:!0}),i&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const i=t().workdir;if(i)try{const l=await(await Ne(`/api/dev-server?workdir=${encodeURIComponent(i)}`)).json();e({status:l,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const i=t().workdir;if(i)try{const l=await(await Ne(`/api/dev-server/config?workdir=${encodeURIComponent(i)}`)).json();e({config:l.config??null})}catch{}},fetchLogs:async()=>{const i=t().workdir;if(i)try{const d=(await(await Ne(`/api/dev-server/logs?workdir=${encodeURIComponent(i)}`)).json()).logs.map(f=>({stream:f.stream,content:f.content}));e({logs:d})}catch{}},start:async()=>{const i=t().workdir;if(i)try{const l=await(await Ne(`/api/dev-server/start?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:l,logs:[]})}catch{}},stop:async()=>{const i=t().workdir;if(i)try{const l=await(await Ne(`/api/dev-server/stop?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:l})}catch{}},restart:async()=>{const i=t().workdir;if(i)try{const l=await(await Ne(`/api/dev-server/restart?workdir=${encodeURIComponent(i)}`,{method:"POST"})).json();e({status:l,logs:[]})}catch{}},saveConfig:async i=>{const a=t().workdir;if(a)try{const d=await(await Ne(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})).json();e({config:d.config??i}),t().fetchStatus()}catch{}},handleMessage:i=>{const a=t().workdir;if(a)switch(i.type){case"devServer.output":{const l=i.payload;if(l.workdir!==a)return;md.push({stream:l.stream,content:l.content}),r();break}case"devServer.state":{const l=i.payload;if(l.workdir!==a)return;e(d=>({status:d.status?{...d.status,state:l.state,errorMessage:l.errorMessage}:d.status}));break}}}}}),pD=[{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"}],gD=[{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"}],qC={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"},Rs={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},KC={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},Ag={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Rs},waiting_for_user:{...Rs},phase_done:{...Rs},phase_blocked:{...Rs},new_message:{...KC}},agentOverrides:{}};function YC(e,t,n){var a;const r=e.events[t];if(!n)return r;const i=(a=e.agentOverrides[n])==null?void 0:a[t];return i?{soundEnabled:i.soundEnabled??r.soundEnabled,browserNotification:i.browserNotification??r.browserNotification,customSoundUrl:i.customSoundUrl!==void 0?i.customSoundUrl:r.customSoundUrl}:r}const _a=xr((e,t)=>({settings:Ag,loaded:!1,load:()=>{tn.getState().getSetting(Me.NOTIFICATION_SETTINGS);const r=tn.subscribe(a=>{const l=a.settings[Me.NOTIFICATION_SETTINGS];if(l!==void 0)try{const d=JSON.parse(l);e({settings:_S(d),loaded:!0})}catch{e({loaded:!0})}}),i=tn.getState().settings[Me.NOTIFICATION_SETTINGS];if(i)try{const a=JSON.parse(i);e({settings:_S(a),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),Np(n)},updateEvent:(n,r)=>{const i=t().settings,a={...i,events:{...i.events,[n]:{...i.events[n],...r}}};e({settings:a}),Np(a)},updateAgentOverride:(n,r,i)=>{var f;const a=t().settings,l={...a.agentOverrides};if(i===null){if(l[n]){const h={...l[n]};delete h[r],Object.keys(h).length===0?delete l[n]:l[n]=h}}else l[n]={...l[n],[r]:{...((f=l[n])==null?void 0:f[r])??{},...i}};const d={...a,agentOverrides:l};e({settings:d}),Np(d)}}));function Np(e){tn.getState().setSetting(Me.NOTIFICATION_SETTINGS,JSON.stringify(e))}function _S(e){var t,n,r,i,a;return{soundEnabled:e.soundEnabled??Ag.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Ag.browserNotificationEnabled,events:{complete:{...Rs,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Rs,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Rs,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...Rs,...(i=e.events)==null?void 0:i.phase_blocked},new_message:{...KC,...(a=e.events)==null?void 0:a.new_message}},agentOverrides:e.agentOverrides??{}}}const xS=new Map;function _D(e){let t=xS.get(e);return t||(t=new Audio(e),t.volume=.5,xS.set(e,t)),t}let XC=typeof Notification<"u"?Notification.permission:"denied";function xD(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(XC=e,e))}const yD={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},vD={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 bD(e){typeof Notification>"u"||XC==="granted"&&(document.hasFocus()||new Notification(yD[e],{body:vD[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function Pc(e,t){const{settings:n}=_a.getState(),r=YC(n,e,t);if(n.soundEnabled&&r.soundEnabled){const i=r.customSoundUrl??qC[e],a=_D(i);a.currentTime=0,a.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&bD(e)}const SD=e=>Pc("complete",e),wD=e=>Pc("phase_done",e),CD=e=>Pc("phase_blocked",e),yS=e=>Pc("waiting_for_user",e),kD=e=>Pc("new_message",e),vS=new Map;function uc(e,t){var a;const n=t===((a=e.currentSession)==null?void 0:a.id)?e.currentSession:null,r=e.sessions.find(l=>l.id===t),i=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return i==="planner"?"planner":i==="builder"?"build":"planner"}function ED(e,t){if(e.type==="chat.done"){const n=e.payload,r=uc(t,e.sessionId),i=n.agentType??r;n.reason==="complete"&&SD(i),n.reason==="waiting_for_user"&&yS(i);return}if(e.type==="chat.path_confirmation"){const n=uc(t,e.sessionId);yS(n);return}if(e.type==="task.completed"){const n=uc(t,e.sessionId);wD(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=vS.get(e.sessionId)??null;if(vS.set(e.sessionId,n.phase),r===n.phase)return;const i=uc(t,e.sessionId);n.phase==="blocked"&&CD(i)}}const jp=new Set;function Zt(e,t){return t!==null&&e.sessionId===t}function ND(e,t,n){return e.id!==void 0||Zt(e,t)||n===!0&&e.sessionId!==void 0}function jD(e,t){return e.includes(t)?e:[...e,t]}function bS(e,t){return e.filter(n=>n!==t)}function TD(e,t){const n=e.find(a=>a.id===t.id),r=t.messageCount??t.messages.length,i=n?{...n,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,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:r};return n?e.map(a=>a.id===t.id?i:a):[i,...e]}function AD(e,t,n){return e.map(r=>{const i=(n==null?void 0:n.id)===r.id?n:null,a=t.find(l=>l.id===r.id);return{...r,title:r.title??(a==null?void 0:a.title),mode:(i==null?void 0:i.mode)??(a==null?void 0:a.mode)??r.mode,phase:(i==null?void 0:i.phase)??(a==null?void 0:a.phase)??r.phase,isRunning:r.isRunning&&(a==null?void 0:a.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function SS(e,t,n,r){var d;const i=e.sessionId,a=(d=n().currentSession)==null?void 0:d.id,l=i&&i!==a;if(t(f=>({sessions:f.sessions.map(h=>h.id===i?r(h):h)})),!l){const f=n().currentSession;if(f){const h=r(f);t(()=>({currentSession:h}))}}}function wS(e,t,n){var l,d,f,h,p,g,x,_,v,S,w,k,j,T,A,P,M,q,Z,J,L,G,H;const r=n();ED(e,r);const i=((l=r.currentSession)==null?void 0:l.id)??null,a=()=>{const R=e.sessionId;!R||R===i||t(U=>({unreadSessionIds:jD(U.unreadSessionIds,R)}))};switch(e.type){case"session.state":{const R=e.payload;if(!ND(e,i,r.pendingSessionCreate))break;ya();const U=R.messages.find(N=>N.isStreaming)??null,D=n().pendingSessionCreate===!0;if(t({currentSession:R.session,sessions:TD(n().sessions,R.session),unreadSessionIds:bS(n().unreadSessionIds,R.session.id),messages:R.messages,streamingMessageId:(U==null?void 0:U.id)??null,streamingMessage:U,currentTodos:[],pendingPathConfirmations:R.pendingConfirmations??[],error:null,...D?{pendingSessionCreate:R.session.id}:{}}),R.session.providerId){const N=Ot.getState();N.providers.find($=>$.id===R.session.providerId)&&N.syncFromSession(R.session.providerId,R.session.providerModel??"")}break}case"session.list":{const R=e.payload;t(U=>({sessions:AD(R.sessions,U.sessions,U.currentSession)}));break}case"session.deleted":{const R=e.payload;t(U=>({unreadSessionIds:bS(U.unreadSessionIds,R.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const R=e.payload;SS(e,t,n,U=>({...U,isRunning:R.isRunning})),R.isRunning||t({abortInProgress:!1,queuedMessages:[]});break}case"chat.message":{if(!Zt(e,((d=n().currentSession)==null?void 0:d.id)??null)){a();break}const R=e.payload;t(U=>{if(U.messages.some(N=>N.id===R.message.id))return U;const D=R.message.role==="user";return{messages:[...U.messages,R.message],sessions:U.sessions.map(N=>N.id===e.sessionId&&D?{...N,messageCount:N.messageCount+1}:N),streamingMessageId:R.message.isStreaming?R.message.id:U.streamingMessageId,streamingMessage:R.message.isStreaming?R.message:U.streamingMessage}});break}case"chat.message_updated":{if(!Zt(e,((f=n().currentSession)==null?void 0:f.id)??null)){a();break}const R=e.payload,U=R.updates.isStreaming===!1&&n().streamingMessageId===R.messageId;U&&ya(),t(D=>{const N=D.streamingMessage;if(N&&N.id===R.messageId){const F={...N,...R.updates};return{messages:D.messages.map($=>$.id===R.messageId?F:$),streamingMessageId:U?null:D.streamingMessageId,streamingMessage:U?null:{...N,...R.updates}}}return{messages:D.messages.map(F=>F.id===R.messageId?{...F,...R.updates}:F),streamingMessageId:U?null:D.streamingMessageId}});break}case"chat.delta":{if(!Zt(e,((h=n().currentSession)==null?void 0:h.id)??null)){a();break}const R=e.payload;if(!jp.has(R.messageId)){jp.add(R.messageId);const D=R.subAgentType?"sub-agent":uc(n(),e.sessionId);kD(D)}const U=fa();U.messageId=R.messageId,U.deltaContent+=R.content,Ep();break}case"chat.thinking":{if(!Zt(e,((p=n().currentSession)==null?void 0:p.id)??null)){a();break}const R=e.payload,U=fa();U.messageId=R.messageId,U.thinkingContent+=R.content,Ep();break}case"chat.tool_preparing":{if(!Zt(e,((g=n().currentSession)==null?void 0:g.id)??null)){a();break}const R=e.payload,U=n().streamingMessage;if(!U||U.id!==R.messageId||((x=U.toolCalls)==null?void 0:x.find((N,F)=>F===R.index)))return;t(N=>{const F=N.streamingMessage.preparingToolCalls??[],$=F.findIndex(B=>B.index===R.index);let se;return $>=0?se=F.map((B,V)=>V===$?{...B,arguments:R.arguments}:B):se=[...F,{index:R.index,name:R.name,...R.arguments?{arguments:R.arguments}:{}}],{streamingMessage:{...N.streamingMessage,preparingToolCalls:se}}});break}case"chat.tool_call":{if(!Zt(e,((_=n().currentSession)==null?void 0:_.id)??null)){a();break}const R=e.payload,U=D=>{var se;const N=(se=D.preparingToolCalls)==null?void 0:se.filter((B,V)=>{var K;return B.name===R.tool?(K=D.preparingToolCalls)==null?void 0:K.slice(0,V).some(Q=>Q.name===R.tool):!0}),F=fa(),$=F.toolOutput.filter(B=>B.callId===R.callId);return $.length>0&&(F.toolOutput=F.toolOutput.filter(B=>B.callId!==R.callId)),{...D,toolCalls:[...D.toolCalls??[],{id:R.callId,name:R.tool,arguments:R.args,startedAt:Date.now(),...$.length>0?{streamingOutput:$.map(B=>({stream:B.stream,content:B.content,timestamp:Date.now()}))}:{}}],...N&&N.length>0?{preparingToolCalls:N}:{preparingToolCalls:void 0}}};t(D=>{const N=D.streamingMessage;return N&&N.id===R.messageId?{streamingMessage:U(N)}:{messages:D.messages.map(F=>F.id===R.messageId?U(F):F)}});break}case"chat.tool_output":{if(!Zt(e,((v=n().currentSession)==null?void 0:v.id)??null)){a();break}const R=e.payload,U=fa();U.messageId=R.messageId,U.toolOutput.push({messageId:R.messageId,callId:R.callId,stream:R.stream,content:R.output}),Ep();break}case"chat.tool_result":{if(!Zt(e,((S=n().currentSession)==null?void 0:S.id)??null)){a();break}const R=e.payload,U=D=>{var F;const N=(F=D.toolCalls)==null?void 0:F.map($=>$.id===R.callId?{...$,result:R.result}:$);return{...D,toolCalls:N}};t(D=>{const N=D.streamingMessage;return N&&N.id===R.messageId?{streamingMessage:U(N)}:{messages:D.messages.map(F=>F.id===R.messageId?U(F):F)}});break}case"chat.vision_fallback":{if(!Zt(e,((w=n().currentSession)==null?void 0:w.id)??null)){a();break}const R=e.payload;t(U=>{const D=`${R.messageId}-${R.attachmentId}`,N={...U.visionFallbackByMessage};return N[D]={type:R.type,attachmentId:R.attachmentId,filename:R.filename,description:R.description},{visionFallbackByMessage:N}});break}case"chat.todo":{if(!Zt(e,((k=n().currentSession)==null?void 0:k.id)??null)){a();break}const R=e.payload;t({currentTodos:R.todos});break}case"chat.progress":{if(!Zt(e,((j=n().currentSession)==null?void 0:j.id)??null)){a();break}const R=e.payload;console.warn("Progress:",R.message,R.phase);break}case"chat.format_retry":{if(!Zt(e,((T=n().currentSession)==null?void 0:T.id)??null)){a();break}const R=e.payload;console.warn("Format retry:",R.attempt,"/",R.maxAttempts);break}case"chat.done":{if(!Zt(e,((A=n().currentSession)==null?void 0:A.id)??null)){a();break}ya();const R=fa();R.messageId=null,R.deltaContent="",R.thinkingContent="",R.toolOutput=[],jp.delete(e.payload.messageId);const U=e.payload,D=U.stats;t(N=>{const F=N.streamingMessage,$=F&&F.id===U.messageId?{...F,isStreaming:!1,stats:D??F.stats}:null;return{messages:N.messages.map(se=>se.id===U.messageId?$??{...se,isStreaming:!1,stats:D??se.stats,completeReason:U.reason}:se),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Zt(e,((P=n().currentSession)==null?void 0:P.id)??null)){a();break}ya();const R=fa(),U=e.payload;console.error("Chat error:",U.error,"recoverable:",U.recoverable),U.recoverable||(R.messageId=null,R.deltaContent="",R.thinkingContent="",R.toolOutput=[]),t(D=>({error:{code:"CHAT_ERROR",message:U.error},streamingMessageId:U.recoverable?D.streamingMessageId:null,...U.recoverable?{}:{messages:D.streamingMessage?D.messages.map(N=>N.id===D.streamingMessage.id?D.streamingMessage:N):D.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Zt(e,((M=n().currentSession)==null?void 0:M.id)??null)){a();break}const R=e.payload,U={callId:R.callId,tool:R.tool,paths:R.paths,workdir:R.workdir,reason:R.reason};t(D=>({pendingPathConfirmations:[...D.pendingPathConfirmations,U]}));break}case"chat.ask_user":{if(!Zt(e,((q=n().currentSession)==null?void 0:q.id)??null)){a();return}const R=e.payload;t({pendingQuestion:{callId:R.callId,question:R.question}});break}case"mode.changed":{if(!Zt(e,((Z=n().currentSession)==null?void 0:Z.id)??null)){a();break}const R=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,mode:R.mode}:null}));break}case"phase.changed":{const R=e.payload;SS(e,t,n,U=>({...U,phase:R.phase}));break}case"criteria.updated":{if(!Zt(e,((J=n().currentSession)==null?void 0:J.id)??null)){a();break}const R=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,criteria:R.criteria}:null}));break}case"metadata.updated":{if(!Zt(e,((L=n().currentSession)==null?void 0:L.id)??null)){a();break}const R=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,metadataEntries:{...U.currentSession.metadataEntries,[R.key]:R.entries}}:null}));break}case"context.state":{const R=e.payload,U=Zt(e,((G=n().currentSession)==null?void 0:G.id)??null);R.subAgentId?U&&n().updateSubAgentContextState(R.subAgentId,R.context):U?t({contextState:R.context}):a();break}case"session.name_generated":{const R=e.payload,U=e.sessionId,D=(H=n().currentSession)==null?void 0:H.id;t(N=>{const F=N.sessions.map(se=>se.id===U?{...se,title:R.name,updatedAt:new Date().toISOString()}:se),$=D===U?N.currentSession?{...N.currentSession,title:R.name,updatedAt:new Date().toISOString()}:null:N.currentSession;return{sessions:F,currentSession:$}});break}case"queue.state":{const R=e.payload;t({queuedMessages:R.messages??[]});break}case"git.status":{const R=e.payload;t({gitStatus:{branch:R.branch,diff:R.diff}});break}case"devServer.output":case"devServer.state":{di.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{xc.getState().handleMessage(e.type,e.payload);break}case"error":{const R=e.payload;console.error("Server error:",R),t({error:{code:R.code,message:R.message},streamingMessageId:null});break}}}let Kl=!1,ri=null;const Tp=new Set,pd=new Map;function CS(e,t,n){return e==null?void 0:e.map(r=>{const i=t.filter(a=>a.callId===r.id);return i.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...i.map(a=>({stream:a.stream,content:a.content,timestamp:Date.now()}))]})})}async function kS(e,t,n,r,i){try{const l=await(await Ne(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();l.queueState&&i({queuedMessages:l.queueState})}catch(a){console.error("Error queueing message:",a)}}const xe=xr((e,t)=>(mD(()=>{const n=fa();if(!n.messageId)return;const r=n.deltaContent.length>0,i=n.thinkingContent.length>0,a=n.toolOutput.length>0;if(!r&&!i&&!a)return;const l=n.deltaContent,d=n.thinkingContent,f=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(h=>{const p=h.streamingMessage;if(p&&p.id===n.messageId){const g={...p};if(r&&(g.content=g.content+l),i&&(g.thinkingContent=(g.thinkingContent??"")+d),a){const x=new Set;g.toolCalls=CS(g.toolCalls,f,x);const _=f.filter(v=>!x.has(v.callId));_.length>0&&n.toolOutput.push(..._)}return{streamingMessage:g}}if(a){const g=new Set,x=h.messages.map(v=>v.id!==n.messageId?v:{...v,toolCalls:CS(v.toolCalls,f,g)}),_=f.filter(v=>!g.has(v.callId));return _.length>0&&n.toolOutput.push(..._),{messages:x}}return h})}),{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 Ne("/api/auth")).json()).requiresAuth}catch{}if(r&&!Ft.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Ft.onStatusChange(i=>{var a;if(e({connectionStatus:i}),i==="connected"){t().listSessions(void 0),Ut.getState().listProjects();const l=(a=t().currentSession)==null?void 0:a.id;l&&t().loadSession(l)}});try{await Ft.connect(),Kl||(Kl=!0,ri=Ft.subscribe(i=>{wS(i,e,t)}))}catch(i){console.error("Failed to connect:",i);const a=Ft.getLastCloseCode();if(!Ft.hasToken()&&(a===1006||a===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}ri&&(ri(),ri=null),Kl=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Ft.disconnect(),ri&&(ri(),ri=null),Kl=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Ft.disconnect(),ri&&(ri(),ri=null),Kl=!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:i}=await r.json();Ft.setToken(i),e({showPasswordModal:!1}),t().connect();const{listProjects:a}=Ut.getState(),{fetchConfig:l}=Ot.getState();a(),l(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Ft.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,r)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const a=await Ne("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,title:r})});if(!a.ok)return e({pendingSessionCreate:!1}),null;const l=await a.json();try{Ft.send("session.load",{sessionId:l.session.id})}catch{}return l.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!Tp.has(n)){Tp.add(n);try{const r=t().currentSession;!r||r.id!==n?(ya(),e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(l=>l!==n),subAgentContextStates:{},messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmations:[],queuedMessages:[],abortInProgress:!1,error:null,pendingSessionCreate:!1})):e({unreadSessionIds:t().unreadSessionIds.filter(l=>l!==n)});const i=await Ne(`/api/sessions/${n}`);if(!i.ok)return;const a=await i.json();e({currentSession:a.session,messages:a.messages??[],contextState:a.contextState,queuedMessages:a.queueState??[]}),Ft.send("session.load",{sessionId:n});try{const l=await Ne(`/api/sessions/${n}/background-processes`);if(l.ok){const d=await l.json();xc.getState().setProcesses(d.processes??[])}}catch{}}catch{}finally{Tp.delete(n)}}},listSessions:async(n,r=20)=>{const i=n??"global";if(pd.has(i))return pd.get(i);const a=(async()=>{try{const l=new URLSearchParams;l.set("limit",String(r)),n&&l.set("projectId",n);const f=await(await Ne(`/api/sessions?${l.toString()}`)).json(),h=f.sessions??[];e(p=>({sessions:h.map(g=>{var _,v;const x=p.sessions.find(S=>S.id===g.id);return{...g,title:g.title??(x==null?void 0:x.title),mode:((_=p.currentSession)==null?void 0:_.id)===g.id?p.currentSession.mode:(x==null?void 0:x.mode)??g.mode,phase:((v=p.currentSession)==null?void 0:v.id)===g.id?p.currentSession.phase:(x==null?void 0:x.phase)??g.phase,isRunning:g.isRunning&&(x==null?void 0:x.isRunning)!==!1,messageCount:g.messageCount,recentUserPrompts:g.recentUserPrompts}}),sessionsHasMore:n?f.hasMore??!1:!0}))}catch{}finally{pd.delete(i)}})();return pd.set(i,a),a},loadMoreSessions:async n=>{const r=t();if(!(r.sessionsPaginationLoading||!r.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const i=new URLSearchParams;i.set("limit","20"),i.set("offset",String(r.sessions.length)),i.set("projectId",n);const l=await(await Ne(`/api/sessions?${i.toString()}`)).json(),d=l.sessions??[];e(f=>({sessions:[...f.sessions,...d.map(h=>{const p=f.sessions.find(g=>g.id===h.id);return(p==null?void 0:p.isRunning)===!1?{...h,isRunning:!1}:h})],sessionsHasMore:l.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var r;try{return(await Ne(`/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 i;try{const a=await Ne(`/api/sessions/${n}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r})});if(!a.ok)return!1;if(await t().listSessions(),((i=t().currentSession)==null?void 0:i.id)===n){const d=await a.json();d.session&&e({currentSession:d.session})}return!0}catch{return!1}},deleteAllSessions:async n=>{try{return(await Ne(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{ya(),e(n=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingSessionCreate:!1,unreadSessionIds:n.currentSession?n.unreadSessionIds.filter(r=>r!==n.currentSession.id):n.unreadSessionIds}))},sendMessage:async(n,r,i)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a){e({streamingMessageId:null});try{const f=await(await Ne(`/api/sessions/${a}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:r,messageKind:i==null?void 0:i.messageKind})})).json();f.queueState&&e({queuedMessages:f.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){ya(),e({abortInProgress:!0});try{await Ne(`/api/sessions/${n}/stop`,{method:"POST"})}catch(i){console.error("Error stopping generation:",i)}}},continueGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n){e({streamingMessageId:null});try{await Ne(`/api/sessions/${n}/continue`,{method:"POST"})}catch(i){console.error("Error continuing generation:",i)}}},launchRunner:(n,r,i,a)=>{e({streamingMessageId:null});const l={};n!=null&&n.trim()&&(l.content=n),r&&r.length>0&&(l.attachments=r),i&&(l.workflowId=i),a&&(l.subGroup=a),Ft.send("runner.launch",l)},switchMode:async n=>{var i;const r=(i=t().currentSession)==null?void 0:i.id;if(r)try{const a=await Ne(`/api/sessions/${r}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:n})});if(!a.ok){console.error("Failed to switch mode:",await a.json());return}const l=await a.json();l.session&&e({currentSession:l.session})}catch(a){console.error("Error switching mode:",a)}},switchDangerLevel:async n=>{var i;const r=(i=t().currentSession)==null?void 0:i.id;if(r)try{const a=await Ne(`/api/sessions/${r}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:n})});if(!a.ok){console.error("Failed to switch danger level:",await a.json());return}const l=await a.json();l.session&&e({currentSession:l.session})}catch(a){console.error("Error switching danger level:",a)}},acceptAndBuild:(n,r,i,a)=>{var f;e({streamingMessageId:null});const l={};n&&(l.workflowId=n),r!=null&&r.trim()&&(l.content=r),i&&i.length>0&&(l.attachments=i),a&&(l.subGroup=a);const d=(f=t().currentSession)==null?void 0:f.id;d&&Ne(`/api/sessions/${d}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{Ft.send("runner.launch",l)})},editCriteria:async n=>{var i;const r=(i=t().currentSession)==null?void 0:i.id;if(r)try{const a=await Ne(`/api/sessions/${r}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:n})});a.ok||console.error("Failed to update criteria:",await a.json())}catch(a){console.error("Error updating criteria:",a)}},compactContext:()=>{Ft.send("context.compact",{})},setSessionProvider:async(n,r)=>{var i,a;try{const l=(i=t().currentSession)==null?void 0:i.id;if(!l)return null;const d=await Ne(`/api/sessions/${l}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...r?{model:r}:{}})});if(!d.ok)return null;const f=await d.json();if(e({currentSession:f.session,messages:f.messages??[],contextState:f.contextState}),(a=f.session)!=null&&a.providerId){const h=Ot.getState();h.providers.find(g=>g.id===f.session.providerId)&&h.syncFromSession(f.session.providerId,f.session.providerModel??"")}return f.session}catch{return null}},updateContextState:n=>{e({contextState:n})},updateSubAgentContextState:(n,r)=>{e(i=>({subAgentContextStates:{...i.subAgentContextStates,[n]:r}}))},clearSubAgentContextState:n=>{e(r=>{const i={...r.subAgentContextStates};return delete i[n],{subAgentContextStates:i}})},confirmPath:async(n,r,i=!1)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{await Ne(`/api/sessions/${a}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:r,alwaysAllow:i})})}catch(d){console.error("Error confirming path:",d)}},answerQuestion:async(n,r)=>{var a;const i=(a=t().currentSession)==null?void 0:a.id;if(i){try{await Ne(`/api/sessions/${i}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:r})})}catch(l){console.error("Error answering question:",l)}e({pendingQuestion:null})}},queueAsap:async(n,r,i)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;a&&await kS(a,n,r,i,e)},queueCompletion:async(n,r,i)=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;a&&await kS(a,n,r,i,e)},cancelQueued:async n=>{var i;const r=(i=t().currentSession)==null?void 0:i.id;if(r)try{const l=await(await Ne(`/api/sessions/${r}/queue/${n}`,{method:"DELETE"})).json();l.queueState&&e({queuedMessages:l.queueState})}catch(a){console.error("Error canceling queued message:",a)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{wS(n,e,t)}}));function Th(){return xe(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function DD(){return xe(e=>e.abortInProgress)}function LD(){const e=xe(r=>r.connect),t=xe(r=>r.connectionStatus),n=_a(r=>r.load);return C.useEffect(()=>{e()},[e]),C.useEffect(()=>{t==="connected"&&n()},[t,n]),{connectionStatus:t}}const RD="modulepreload",MD=function(e){return"/"+e},ES={},z=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),f=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));i=l(n.map(h=>{if(h=MD(h),h in ES)return;ES[h]=!0;const p=h.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":RD,p||(x.as="script"),x.crossOrigin="",x.href=h,f&&x.setAttribute("nonce",f),document.head.appendChild(x),p)return new Promise((_,v)=>{x.addEventListener("load",_),x.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return i.then(l=>{for(const d of l||[])d.status==="rejected"&&a(d.reason);return t().catch(a)})},QC=[{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"}],hi=[{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 NS(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const Gt=xr((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:NS(),followSystemTheme:!0,applySavedTheme:()=>{const{getSavedTheme:n,applyPreset:r,applyTokens:i}=t(),a=n();if(a)try{const l=JSON.parse(a);l.preset&&l.tokens?(r(l.preset),e({basePreset:l.preset}),i(l.tokens)):l.preset?r(l.preset):l.tokens&&i(l.tokens)}catch{r("dark")}else r("dark")},applyPreset:n=>{hi.find(i=>i.id===n)&&(e({currentPreset:n,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1}),t().applyTheme())},startCustomizing:()=>{var i;const{currentPreset:n}=t(),r=((i=hi.find(a=>a.id===n))==null?void 0:i.tokens)??{};e({basePreset:n,customTokens:{...r},isCustom:!0,isCustomizing:!0})},setCustomToken:(n,r)=>{e(i=>({customTokens:{...i.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 l,d;const{basePreset:n,customTokens:r,isCustom:i}=t();if(i&&n)return{...((l=hi.find(h=>h.id===n))==null?void 0:l.tokens)??{},...r};if(i)return{...QC.reduce((f,h)=>({...f,[h.key]:h.defaultValue}),{}),...r};const a=hi.find(f=>f.id===t().currentPreset);return(a==null?void 0:a.tokens)??((d=hi[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const n=t().getActiveTheme(),r=document.documentElement;Object.entries(n).forEach(([i,a])=>{r.style.setProperty(`--${i}`,a)})},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 z(async()=>{const{useSettingsStore:i}=await Promise.resolve().then(()=>wp);return{useSettingsStore:i}},void 0);await r.getState().setSetting(Me.DISPLAY_THEME,n)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:n=>{e({followSystemTheme:n}),z(async()=>{const{useSettingsStore:r,SETTINGS_KEYS:i}=await Promise.resolve().then(()=>wp);return{useSettingsStore:r,SETTINGS_KEYS:i}},void 0).then(({useSettingsStore:r,SETTINGS_KEYS:i})=>{r.getState().setSetting(i.DISPLAY_FOLLOW_SYSTEM_THEME,String(n))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const n=window.matchMedia("(prefers-color-scheme: dark)"),r=a=>{const{followSystemTheme:l}=t();l&&(t().applyPreset(a?"dark":"light"),t().saveTheme(JSON.stringify({preset:a?"dark":"light"})))};r(n.matches);const i=a=>r(a.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0})},addUserPreset:n=>{const{basePreset:r,customTokens:i,currentPreset:a}=t(),l={id:"custom-"+Date.now(),name:n,basePreset:r||a,tokens:{...i}},d=[...t().userPresets,l];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((i,a)=>a!==n);e({userPresets:r}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:NS()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),z(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>wp);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting(Me.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function OD({canLoad:e,projectId:t,currentProjectId:n}){const r=Ut(l=>l.loadProject),i=xe(l=>l.listSessions),a=xe(l=>l.clearSession);C.useEffect(()=>{e&&t&&(n!==t&&r(t),i(t),a())},[e,t,n,r,i,a])}function ID({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:i}){const a=xe(h=>h.loadSession),l=Ut(h=>h.loadProject),d=xe(h=>h.listSessions),f=xe(h=>h.pendingSessionCreate);C.useEffect(()=>{e&&t&&r!==t&&l(t)},[e,t,r,l]),C.useEffect(()=>{e&&n&&i!==n&&a(n),e&&t&&d(t)},[e,n,i,a,d,f,t])}function PD({className:e="w-5 h-5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function JC({className:e="w-3.5 h-3.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function BD({className:e="w-5 h-5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 zD({className:e="w-3 h-3 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 $D({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:c.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 pi({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function gi({className:e="w-3 h-3 text-text-muted",rotate:t}){return c.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:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function HD({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function Y_({className:e="w-3.5 h-3.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 FD({className:e="w-3 h-3"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 X_({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[c.jsx("circle",{cx:"12",cy:"5",r:"2"}),c.jsx("circle",{cx:"12",cy:"12",r:"2"}),c.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Yd({className:e="w-3.5 h-3.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 Q_({className:e="w-5 h-5 text-accent-primary"}){return c.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:c.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 UD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 VD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 WD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:c.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 ZC({className:e="w-3 h-3"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 GD({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 jS({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function ek({className:e="w-[18px] h-[18px]"}){return c.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[c.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function qD({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.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"}),c.jsx("path",{d:"M9.5 2h4.5v4.5"}),c.jsx("path",{d:"M14 2L7.5 8.5"})]})}function KD({className:e="w-3 h-3",color:t}){return c.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{d:"M8 5v14l11-7z"})})}function $s({className:e="w-3 h-3 text-accent-primary"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function YD({className:e="w-5 h-5"}){return c.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:c.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 J_({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 XD({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[c.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"}),c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function QD({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return c.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[c.jsx("title",{children:"Running"}),c.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),c.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function JD({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:c.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 ZD({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 tk({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:c.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function eL({className:e="w-3.5 h-3.5 shrink-0",color:t}){return c.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:c.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 tL({className:e="w-4 h-4"}){return c.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"4 17 10 11 4 5"}),c.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Bc({className:e="w-3.5 h-3.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 Z_(){return c.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 nL({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 Dg({className:e="w-2.5 h-2.5"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 zc({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:c.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 nk({className:e="w-4 h-4"}){return c.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:c.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 rL({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function iL({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function TS({className:e="w-3.5 h-3.5 text-text-muted"}){return c.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function Lg(){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 AS(e,t){const n=Ft.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Lg(),type:e,payload:t}))}const qr=xr((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 Ne(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const i=await r.json();e({sessions:i});const a=Ft.ws;if(a&&a.readyState===WebSocket.OPEN)for(const l of i)a.send(JSON.stringify({id:Lg(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const i=await Ne("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(i.ok){const a=await i.json();e(d=>({sessions:[...d.sessions,a]}));const l=Ft.ws;l&&l.readyState===WebSocket.OPEN&&l.send(JSON.stringify({id:Lg(),type:"terminal.subscribe",payload:{sessionId:a.id}}))}}catch(i){console.error("Failed to create terminal:",i)}},writeSession:(n,r)=>{AS("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,i)=>{AS("terminal.resize",{sessionId:n,cols:r,rows:i})},killSession:async n=>{try{(await Ne(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(i=>({sessions:i.sessions.filter(a=>a.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(i=>{const a=i.sessions.filter(l=>l.id!==r);return a.length===0&&i.isOpen?{sessions:[],isOpen:!1}:{sessions:a}});break}}}}));Ft.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&qr.getState().handleMessage(e)});const Oo={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function Rg(e){if(!e)return structuredClone(Oo);try{const t=JSON.parse(e);return{terminalToggle:t.terminalToggle??structuredClone(Oo.terminalToggle),quickAction:t.quickAction??structuredClone(Oo.quickAction),agentSwitching:t.agentSwitching??structuredClone(Oo.agentSwitching)}}catch{return structuredClone(Oo)}}function DS(e){return e.code.startsWith("Digit")?e.code.slice(-1):e.code.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function rk(e){if(e.type==="double-press")return`Double ${e.key==="Control"?"Ctrl":e.key==="Shift"?"Shift":e.key==="Alt"?"Alt":e.key==="Meta"?"Meta":e.key}`;const t=e.modifiers.map(r=>{switch(r){case"ctrl":return"Ctrl";case"meta":return"⌘";case"alt":return"Alt";case"shift":return"Shift"}}),n=e.key.length===1?e.key.toUpperCase():e.key;return[...t,n].join("+")}function sL(e){return e.type==="double-press"}function ik(e){return e.type==="chord"}function aL(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.code===`Key${t.toUpperCase()}`:t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function sk(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),i=t.modifiers.includes("alt"),a=t.modifiers.includes("shift");return aL(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===i&&e.shiftKey===a}function ex(){const e=tn(t=>t.settings[Me.KEYBINDINGS]);return Rg(e)}function oL(e,t,n){const r=C.useRef(0),i=C.useRef(t);i.current=t,C.useEffect(()=>{if(!e)return;const a=e.threshold??300,l=d=>{if(d.key!==e.key)return;const f=e.key==="Control",h=e.key==="Shift",p=e.key==="Alt",g=e.key==="Meta";if(!f&&d.ctrlKey||!h&&d.shiftKey||!p&&d.altKey||!g&&d.metaKey)return;const x=Date.now();x-r.current<a?(d.preventDefault(),d.stopPropagation(),i.current(),r.current=0):r.current=x};return window.addEventListener("keydown",l,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",l,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function lL(e,t){const n=C.useRef(t);n.current=t,C.useEffect(()=>{if(!e)return;const r=i=>{sk(i,e)&&(i.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function ak(e,t,n){oL(e&&sL(e)?e:void 0,t,n),lL(e&&ik(e)?e:void 0,t)}function cL(e,t,n){const r=C.useRef(n);r.current=n,C.useEffect(()=>{const i=a=>{for(let l=0;l<e.length;l++){const d=e[l];if(!d)continue;const f=t[l];if(f&&ik(d)&&sk(a,d)){a.preventDefault(),r.current(f.id);return}}};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e,t])}var La=OC();const Ah=C.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},i)=>c.jsx("button",{ref:i,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:c.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));Ah.displayName="IconButton";const uL="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",Os=C.forwardRef((e,t)=>c.jsx(Ah,{ref:t,icon:uL,title:"Edit",...e}));Os.displayName="EditButton";const dL="M6 18L18 6M6 6l12 12",tx=C.forwardRef((e,t)=>c.jsx(Ah,{ref:t,icon:dL,...e}));tx.displayName="CloseButton";const hL={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 jt({label:e,title:t,size:n="md",minHeight:r,children:i,footer:a,className:l,onClose:d,isOpen:f,closeOnBackdropClick:h=!0,closeOnEscape:p=!0,showCloseButton:g=!0}){const[x,_]=C.useState(!1),v=f!==void 0,S=v?f:x,w=C.useCallback(()=>{v||_(!0)},[v]),k=C.useCallback(()=>{v||_(!1),d==null||d()},[v,d]);C.useEffect(()=>{if(!S||!p)return;const T=A=>{A.key==="Escape"&&(A.stopPropagation(),k())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[S,k,p]);const j=e&&(typeof e=="string"?c.jsx("button",{type:"button",onClick:w,className:l,children:e}):c.jsx("span",{onClick:w,className:l,style:{cursor:"pointer"},children:e}));return c.jsxs(c.Fragment,{children:[j,S&&(typeof document<"u"?La.createPortal(c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:h?k:void 0}),c.jsxs("div",{className:`relative w-full ${hL[n]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||g)&&c.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&c.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),g&&c.jsx(tx,{onClick:k,className:"ml-auto","aria-label":"Close"})]}),c.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:r?{minHeight:r}:void 0,children:i}),a&&c.jsx("div",{className:"px-4 py-3 border-t border-border",children:a})]})]}),document.body):null)]})}function fL({value:e,defaultUrl:t,disabled:n,onChange:r}){const i=e??t;return c.jsxs("div",{className:"relative",children:[c.jsx("select",{value:i,disabled:n,onChange:a=>{const l=a.target.value;r(l===t?null:l)},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:gD.map(({url:a,label:l})=>c.jsx("option",{value:a,title:l,children:l.split(" ")[0]},a))}),c.jsx(gi,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const LS=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function mL(){const e=_a(f=>f.settings),t=_a(f=>f.update),n=_a(f=>f.updateEvent),r=_a(f=>f.updateAgentOverride),i=_a(f=>f.load);C.useEffect(()=>{i()},[i]);const a=async()=>{await xD()==="granted"&&t({...e,browserNotificationEnabled:!0})},l=(f,h,p,g)=>{f==="general"?n(h,{[p]:g}):r(f,h,{[p]:g})},d=(f,h,p)=>{f==="general"?n(h,{customSoundUrl:p}):r(f,h,{customSoundUrl:p})};return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),c.jsx(RS,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:f=>t({...e,soundEnabled:f})}),c.jsx(RS,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:f=>{f&&typeof Notification<"u"&&Notification.permission!=="granted"?a():t({...e,browserNotificationEnabled:f})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&c.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),c.jsx("div",{className:"border border-border rounded overflow-hidden",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:c.jsxs("tr",{className:"border-b border-border",children:[c.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),LS.map(f=>c.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:f.label},f.key))]})}),c.jsx("tbody",{children:pD.map(f=>c.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[c.jsx("td",{className:"px-3 py-2",children:c.jsx("div",{className:"text-text-primary text-xs",children:f.label})}),LS.map(h=>{const p=YC(e,f.key,h.key==="general"?void 0:h.key),g=qC[f.key];return c.jsx("td",{className:"px-2 py-2 align-top",children:c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:c.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:x=>l(h.key,f.key,"soundEnabled",x.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),c.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:c.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:x=>l(h.key,f.key,"browserNotification",x.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&c.jsx(fL,{value:p.customSoundUrl,defaultUrl:g,disabled:!e.soundEnabled,onChange:x=>d(h.key,f.key,x)})]})},h.key)})]},f.key))})]})})]})]})}function RS({label:e,description:t,checked:n,onChange:r}){return c.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[c.jsx("div",{className:"pt-0.5",children:c.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:i=>{i.preventDefault(),r(!n)},children:c.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"}`})})}),c.jsxs("div",{children:[c.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),c.jsx("div",{className:"text-xs text-text-muted",children:t})]})]})}const Ze=C.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...i},a)=>{const l="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"},f={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return c.jsx("button",{ref:a,className:`${l} ${d[e]} ${f[t]} ${n}`,...i,children:r})});Ze.displayName="Button";async function nx(e,t,n){t({loading:!0});try{const i=await(await Ne(e)).json();t({defaults:i.defaults??[],userItems:i.userItems??[],...n?{projectItems:i.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const ii=xr((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchSkills:async()=>{await nx("/api/skills",e,!0)},toggleSkill:async n=>{try{const i=await(await Ne(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(a=>({defaults:a.defaults.map(l=>l.id===n?{...l,enabled:i.enabled}:l),userItems:a.userItems.map(l=>l.id===n?{...l,enabled:i.enabled}:l)}))}catch{}},fetchSkill:async n=>{try{const r=await Ne(`/api/skills/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ne(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const i=await zs("POST","/api/skills",{...n,destination:r});return i.success&&await t().fetchSkills(),i},updateSkill:async(n,r)=>{const i=await zs("PUT",`/api/skills/${n}`,r);return i.success&&await t().fetchSkills(),i},deleteSkill:async n=>{try{const r=await Ne(`/api/skills/${n}`,{method:"DELETE"}),i=await r.json();return r.ok?(e(a=>({userItems:a.userItems.filter(l=>l.id!==n)})),{success:!0}):{success:!1,error:i.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>jh(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),r)}));function rx(){const[e,t]=C.useState({id:null,type:null}),n=C.useCallback(a=>t({id:a,type:"delete"}),[]),r=C.useCallback(()=>t({id:null,type:null}),[]),i=C.useCallback((a,l)=>e.id===a&&e.type===l,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:i}}function ix({onConfirm:e,onCancel:t}){return c.jsxs("div",{className:"flex items-center gap-1",children:[c.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"}),c.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 sx({onClick:e}){return c.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:c.jsx(Bc,{})})}function Xd({onClick:e}){return c.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:c.jsx(Y_,{})})}function ka({label:e,value:t,onChange:n,placeholder:r,readOnly:i,hint:a,mono:l}){return c.jsxs("div",{children:[c.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,a&&c.jsx("span",{className:"text-text-muted ml-1",children:a})]}),c.jsx("input",{value:t,onChange:d=>n(d.target.value),readOnly:i,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 ${l?"font-mono":""} ${i?"opacity-60":""}`})]})}function pL({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return c.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[c.jsx(Ze,{variant:"secondary",onClick:e,children:"Cancel"}),c.jsx(Ze,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function ax({message:e}){return c.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function ok({description:e,onNew:t,loading:n,hasItems:r,children:i}){return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("p",{className:"text-text-secondary text-sm",children:e}),c.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:c.jsx(Ze,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?c.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?i:c.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function lk({label:e="Custom",children:t}){return c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),c.jsx("div",{className:"space-y-2",children:t})]})}function ck({description:e,onNew:t,newLabel:n="+ New"}){return c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("p",{className:"text-text-secondary text-sm",children:e}),c.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:c.jsx(Ze,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function uk({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:i,onDelete:a,children:l}){return c.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[c.jsx("div",{className:"min-w-0 flex-1 mr-3",children:l}),c.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&c.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:c.jsx(Yd,{})}),c.jsx(Xd,{onClick:i}),!e&&r&&c.jsx(Os,{onClick:r}),!e&&(t?c.jsx(ix,{onConfirm:()=>{a==null||a()},onCancel:()=>{}}):c.jsx(sx,{onClick:()=>a==null?void 0:a()}))]})]})}function gL({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:i,onView:a,onEdit:l,onDuplicate:d,onDelete:f}){return c.jsxs(uk,{isBuiltIn:r,isConfirmingDelete:i,onView:a,onEdit:l,onDuplicate:d,onDelete:f,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),c.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&c.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function dk({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:i}){return e&&!t?c.jsx("div",{className:"text-text-muted text-sm",children:n}):t?c.jsx("div",{className:"space-y-4",children:i}):r?c.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function hk({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:i="My Item",idPlaceholder:a="my-item",nameHint:l,readOnlyId:d=!1,readOnlyHint:f="(read-only)",onNameChange:h,onIdChange:p}){return c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(ka,{label:n,value:e,onChange:h,placeholder:i,hint:l}),c.jsx(ka,{label:r,value:t,onChange:p,readOnly:d,placeholder:a,hint:d?f:void 0,mono:!0})]})}function fk(e={}){const{initialData:t={}}=e,[n,r]=C.useState("list"),[i,a]=C.useState(null),[l,d]=C.useState(""),[f,h]=C.useState(!1),[p,g]=C.useState(t),x=C.useCallback(()=>{g(t),d(""),a(null)},[t]),_=C.useCallback(k=>{r(k),k==="list"&&x()},[x]),v=C.useCallback(k=>{g(j=>typeof k=="function"?k(j):k)},[]),S=C.useCallback((k,j={})=>{a(k),r("edit"),g({...j}),d("")},[]),w=C.useCallback(()=>{a(null),r("edit"),g(t),d("")},[t]);return{view:n,editingId:i,formError:l,saving:f,formData:p,setView:_,setEditingId:a,setFormError:d,setFormData:v,setSaving:h,resetForm:x,startEditing:S,startNew:w}}function MS({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:i,onDuplicate:a,onDelete:l}){return c.jsx(gL,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:i,onDuplicate:a,onDelete:l})}function _L({isOpen:e}){const t=ii(N=>N.defaults),n=ii(N=>N.userItems),r=ii(N=>N.projectItems),i=ii(N=>N.loading),a=ii(N=>N.fetchSkills),l=ii(N=>N.fetchSkill),d=ii(N=>N.fetchDefaultContent),f=ii(N=>N.createSkill),h=ii(N=>N.updateSkill),p=ii(N=>N.deleteSkill),{view:g,editingId:x,formError:_,saving:v,formData:S,setView:w,setEditingId:k,setFormError:j,setFormData:T,setSaving:A}=fk(),{clearConfirm:P}=rx();C.useEffect(()=>{e&&(a(),w("list"),k(null),P())},[e,a,P]);const M=(N,F,$,se)=>{T({name:se??N.metadata.name,id:$??N.metadata.id,description:N.metadata.description??"",version:N.metadata.version??"1.0.0",prompt:N.prompt,isReadOnly:F,destination:"user"})},q=async N=>{if(t.some($=>$.id===N)){const $=await d(N);if(!$)return;M($,!0),k(N),j(""),w("edit")}else{const $=await l(N);if(!$)return;M($,!0),k(N),j(""),w("edit")}},Z=async N=>{const $=t.some(B=>B.id===N)?await d(N):await l(N);if(!$)return;const se=`${N}-copy-${Date.now()}`;M($,!1,se,`${$.metadata.name} (copy)`),k(null),j(""),w("edit")},J=()=>{T({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),w("edit")},L=async N=>{const F=await l(N);F&&(M(F,!1),k(N),j(""),w("edit"))},G=async N=>{await p(N),P()},H=async()=>{const N=x??S.id;if(!N||!S.name||!S.prompt){j("Name, ID, and prompt are required.");return}A(!0),j("");const F={metadata:{id:N,name:S.name,description:S.description,version:S.version},prompt:S.prompt},$=x?await h(x,F):await f(F,S.destination);if(A(!1),!$.success){j($.error??"Failed to save skill.");return}w("list")},R=N=>{T(F=>({...F,name:N})),x||T(F=>({...F,id:N.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},U=S.isReadOnly;if(g==="edit")return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex justify-between items-center mb-3",children:[c.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:U?S.name:x?"Edit Skill":"New Skill"}),c.jsx("button",{onClick:()=>w("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),_&&c.jsx(ax,{message:_}),c.jsxs("div",{className:"space-y-3 mb-3",children:[c.jsx(hk,{name:S.name,id:S.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:R,onIdChange:()=>{}}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(ka,{label:"Description",value:S.description,onChange:N=>T(F=>({...F,description:N})),placeholder:"What this skill does...",readOnly:U}),c.jsx(ka,{label:"Version",value:S.version,onChange:N=>T(F=>({...F,version:N})),placeholder:"1.0.0",readOnly:U})]})]}),c.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),c.jsx("textarea",{value:S.prompt,onChange:N=>T(F=>({...F,prompt:N.target.value})),readOnly:U,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"})]}),!x&&c.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[c.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),c.jsxs("select",{value:S.destination,onChange:N=>T(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:[c.jsx("option",{value:"user",children:"Global config"}),c.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[c.jsx(Ze,{variant:"secondary",onClick:()=>w("list"),children:"Cancel"}),U?c.jsx(Ze,{variant:"primary",onClick:()=>{T(N=>({...N,name:N.name+" (copy)",id:`${x}-copy-${Date.now()}`,isReadOnly:!1})),k(null)},children:"Duplicate & Customize"}):c.jsx(Ze,{variant:"primary",onClick:H,disabled:v||!S.name||!S.id||!S.prompt,children:v?"Saving...":"Save"})]})]});function D({items:N}){return N.map(F=>c.jsx(MS,{skill:F,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>q(F.id),onEdit:()=>L(F.id),onDuplicate:()=>Z(F.id),onDelete:()=>G(F.id)},F.id))}return c.jsxs("div",{children:[c.jsx(ck,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:J}),c.jsxs(dk,{loading:i,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),c.jsx("div",{className:"space-y-2",children:t.map(N=>c.jsx(MS,{skill:N,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>q(N.id),onDuplicate:()=>Z(N.id)},N.id))})]}),n.length>0&&c.jsx(lk,{children:c.jsx(D,{items:n})}),r.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),c.jsx("div",{className:"space-y-2",children:c.jsx(D,{items:r})})]})]})]})}function Dh(){const e=tn(i=>i.settings),t=tn(i=>i.loading),n=tn(i=>i.getSetting),r=tn(i=>i.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function xL({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:i}=Dh(),a=t[Me.GLOBAL_INSTRUCTIONS]??"",l=n[Me.GLOBAL_INSTRUCTIONS]??!1,[d,f]=C.useState(a),[h,p]=C.useState(!1),[g,x]=C.useState(!1);C.useEffect(()=>{e&&r(Me.GLOBAL_INSTRUCTIONS)},[e,r]),C.useEffect(()=>{f(a),p(!1)},[a]);const _=async()=>{x(!0),await i(Me.GLOBAL_INSTRUCTIONS,d),x(!1),p(!1)},v=()=>{f(a),p(!1)},S=l||g;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),c.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),c.jsx("textarea",{value:d,onChange:w=>{f(w.target.value),p(!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})]}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{variant:"secondary",onClick:v,disabled:!h,children:"Discard"}),c.jsx(Ze,{variant:"primary",onClick:_,disabled:!h||S,children:g?"Saving...":"Save"})]})]})}function yL(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),i=parseInt(t[3]??"0",16);return`${n} ${r} ${i}`}return e}function ma(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 vL({isOpen:e,isNew:t,basePresetId:n,presetName:r,initialTokens:i,onClose:a,onSave:l}){const[d,f]=C.useState(i),[h,p]=C.useState(r);C.useEffect(()=>{f(i),p(r)},[i,r]);const g=(w,k)=>{const j=k.startsWith("#")?yL(k):k;f(T=>({...T,[w]:j}))},x=()=>{l(h.trim()||"Untitled",{...d})},_=QC.reduce((w,k)=>{const j=k.category;return w[j]||(w[j]=[]),w[j].push(k),w},{}),v={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},S=hi.find(w=>w.id===n);return c.jsx(jt,{isOpen:e,onClose:a,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:c.jsxs("div",{className:"flex gap-2 justify-end",children:[c.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),c.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),c.jsx("input",{type:"text",value:h,onChange:w=>p(w.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&&c.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",c.jsx("span",{className:"text-text-primary",children:S==null?void 0:S.name})]}),Object.entries(_).map(([w,k])=>c.jsxs("div",{className:"space-y-3",children:[c.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:v[w]??w}),c.jsx("div",{className:"grid grid-cols-2 gap-3",children:k.map(j=>c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{htmlFor:j.key,className:"text-xs text-text-muted",children:j.label}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"color",id:j.key,value:ma(d[j.key]??j.defaultValue),onChange:T=>g(j.key,T.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent"}),c.jsx("input",{type:"text",value:d[j.key]??j.defaultValue,onChange:T=>g(j.key,T.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"})]})]},j.key))})]},w))]})})}function bL(){const[e,t]=C.useState(null),n=Gt(A=>A.currentPreset),r=Gt(A=>A.isCustom),i=Gt(A=>A.basePreset),a=Gt(A=>A.userPresets),l=Gt(A=>A.applyPreset),d=Gt(A=>A.applyUserPreset),f=Gt(A=>A.deleteUserPreset),h=Gt(A=>A.saveTheme),p=Gt(A=>A.followSystemTheme),g=Gt(A=>A.setFollowSystemTheme),x=A=>{l(A),h(JSON.stringify({preset:A})).catch(()=>{})},_=A=>{d(A)},v=A=>{const P=hi.find(M=>M.id===A);P&&t({type:"new",presetIndex:a.length,basePresetId:A,presetName:P.name+" Copy",tokens:{...P.tokens}})},S=A=>{const P=a[A];if(!P)return;const M=hi.find(Z=>Z.id===P.basePreset),q=M?{...M.tokens,...P.tokens}:P.tokens;t({type:"edit",presetIndex:A,basePresetId:P.basePreset,presetName:P.name,tokens:q})},w=(A,P)=>{if(!e)return;const M=[...a];if(e.type==="new"){const q={id:"custom-"+Date.now(),name:A,basePreset:e.basePresetId,tokens:P};M.push(q);const Z=M.length-1;Gt.setState({userPresets:M}),Gt.getState().saveUserPresets(),Gt.getState().applyUserPreset(Z)}else{const q=M[e.presetIndex];q&&(M[e.presetIndex]={...q,name:A,tokens:P}),Gt.setState({userPresets:M}),Gt.getState().saveUserPresets(),Gt.getState().applyUserPreset(e.presetIndex)}t(null)},k=()=>{t(null)},j=(A,P)=>{A.stopPropagation(),f(P)},T=r?i:n;return c.jsxs("div",{className:"space-y-4",children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("button",{type:"button",role:"switch","aria-checked":p,onClick:()=>g(!p),className:`relative w-10 h-5 rounded-full transition-colors ${p?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,children:c.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${p?"translate-x-5":"translate-x-0"}`})}),c.jsx("span",{className:"text-sm text-text-secondary",children:"Follow system theme"})]}),c.jsx("div",{className:"grid grid-cols-5 gap-2",children:hi.map(A=>c.jsxs("div",{className:"relative group",children:[c.jsxs("button",{type:"button",onClick:()=>x(A.id),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${T===A.id&&!r?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[c.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:ma(A.tokens["color-bg-primary"]??"#000"),borderColor:ma(A.tokens["color-border"]??"#000")},children:c.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ma(A.tokens["color-text-primary"]??"#fff")}})}),c.jsx("span",{className:"text-xs",children:A.name})]}),c.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),v(A.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:c.jsx("span",{className:"text-xs",children:"✎"})})]},A.id))}),a.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),c.jsx("div",{className:"grid grid-cols-5 gap-2",children:a.map((A,P)=>{const M=hi.find(Z=>Z.id===A.basePreset),q=M?{...M.tokens,...A.tokens}:A.tokens;return c.jsxs("div",{className:"relative group",children:[c.jsxs("button",{type:"button",onClick:()=>_(P),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${r&&i===A.basePreset&&T===A.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[c.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:ma(q["color-bg-primary"]??"#000"),borderColor:ma(q["color-border"]??"#000")},children:c.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ma(q["color-text-primary"]??"#fff")}})}),c.jsx("span",{className:"text-xs truncate w-full text-center",children:A.name})]}),c.jsx("button",{type:"button",onClick:Z=>{Z.stopPropagation(),S(P)},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:c.jsx("span",{className:"text-xs",children:"✎"})}),c.jsx("button",{type:"button",onClick:Z=>j(Z,P),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:c.jsx(zc,{className:"w-3 h-3"})})]},A.id)})})]}),e&&c.jsx(vL,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:k,onSave:w})]})}function SL(){return c.jsx(bL,{})}function wL(){const{settings:e,loading:t,getSetting:n,setSetting:r}=Dh(),i=t[Me.DISPLAY_SHOW_THINKING]??!1,a=[{key:Me.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Me.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Me.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Me.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Me.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:Me.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but very slow - does not affect red/green diff coloring"}],l=Object.fromEntries(a.map(p=>[p.key,e[p.key]??"true"])),[d,f]=C.useState(()=>Object.fromEntries(a.map(p=>[p.key,l[p.key]==="true"])));C.useEffect(()=>{a.forEach(p=>n(p.key))},[n]),C.useEffect(()=>{f(Object.fromEntries(a.map(p=>[p.key,l[p.key]==="true"])))},[JSON.stringify(l)]);const h=async p=>{const g=String(!d[p]);f(x=>({...x,[p]:!x[p]})),await r(p,g)};return i?c.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):c.jsxs("div",{className:"space-y-6",children:[c.jsx(SL,{}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),c.jsx("div",{className:"space-y-4",children:a.map(({key:p,label:g,description:x})=>c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm text-text-primary",children:g}),c.jsx("div",{className:"text-xs text-text-muted",children:x})]}),c.jsx("button",{type:"button",onClick:()=>h(p),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${d[p]?"bg-accent-primary":"bg-bg-tertiary"}`,children:c.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d[p]?"translate-x-6":"translate-x-1"}`})})]},p))})]})]})}function CL({label:e,binding:t,isRecording:n,onStartRecording:r,onBindingRecorded:i,onCancelRecording:a}){const l=C.useRef(null),d=C.useRef(0),f=C.useRef("");return C.useEffect(()=>{if(!n)return;const h=new Set(["Control","Shift","Alt","Meta"]);let p=[];const g=_=>{if(_.preventDefault(),_.stopPropagation(),_.key==="Escape"){a();return}if(h.has(_.key)){_.ctrlKey&&!p.includes("ctrl")&&p.push("ctrl"),_.metaKey&&!p.includes("meta")&&p.push("meta"),_.altKey&&!p.includes("alt")&&p.push("alt"),_.shiftKey&&!p.includes("shift")&&p.push("shift");return}if(p.length>0||_.ctrlKey||_.metaKey||_.altKey||_.shiftKey){const w=[...p];_.ctrlKey&&!w.includes("ctrl")&&w.push("ctrl"),_.metaKey&&!w.includes("meta")&&w.push("meta"),_.altKey&&!w.includes("alt")&&w.push("alt"),_.shiftKey&&!w.includes("shift")&&w.push("shift"),i({type:"chord",key:DS(_),modifiers:w});return}const v=Date.now(),S=DS(_);if(S===f.current&&v-d.current<400){i({type:"double-press",key:S,threshold:300});return}d.current=v,f.current=S},x=_=>{_.key==="Control"&&(p=p.filter(v=>v!=="ctrl")),_.key==="Shift"&&(p=p.filter(v=>v!=="shift")),_.key==="Alt"&&(p=p.filter(v=>v!=="alt")),_.key==="Meta"&&(p=p.filter(v=>v!=="meta"))};return window.addEventListener("keydown",g,!0),window.addEventListener("keyup",x,!0),()=>{window.removeEventListener("keydown",g,!0),window.removeEventListener("keyup",x,!0)}},[n,i,a]),c.jsxs("div",{ref:l,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${n?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[c.jsx("span",{className:"text-sm text-text-primary",children:e}),c.jsx("div",{className:"flex items-center gap-2",children:n?c.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):c.jsx("button",{type:"button",onClick:r,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:rk(t)})})]})}function kL(){const{settings:e,loading:t,getSetting:n,setSetting:r}=Dh(),i=e[Me.KEYBINDINGS],a=t[Me.KEYBINDINGS]??!1,l=Rg(i),[d,f]=C.useState(null);C.useEffect(()=>{n(Me.KEYBINDINGS)},[n]);const h=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction},...l.agentSwitching.map((_,v)=>({id:`agentSwitching.${v}`,label:`Switch to Agent ${v+1}`,binding:_}))],p=_=>{f(_)},g=C.useCallback(_=>{if(!d)return;const v=Rg(i),S=structuredClone(v);if(d.startsWith("agentSwitching.")){const w=parseInt(d.split(".")[1],10);S.agentSwitching[w]=_}else d==="terminalToggle"?S.terminalToggle=_:d==="quickAction"&&(S.quickAction=_);f(null),r(Me.KEYBINDINGS,JSON.stringify(S))},[d,i,r]),x=()=>{r(Me.KEYBINDINGS,JSON.stringify(Oo))};return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),c.jsx("button",{type:"button",onClick:x,disabled:a,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),a?c.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):c.jsx("div",{className:"space-y-1",children:h.map(_=>c.jsx(CL,{label:_.label,binding:_.binding,isRecording:d===_.id,onStartRecording:()=>p(_.id),onBindingRecorded:g,onCancelRecording:()=>f(null)},_.id))})]})}function Ap({enabled:e,onClick:t}){return c.jsx("button",{type:"button",onClick:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"}`,children:c.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function EL({onClose:e}){const[,t]=Qr(),{settings:n,loading:r,getSetting:i,setSetting:a}=Dh(),l=n[Me.LLM_DISABLE_XML_PROTECTION]==="true",d=n[Me.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",f=n[Me.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",h=r[Me.LLM_DISABLE_XML_PROTECTION]??!1,[p,g]=C.useState({xmlProtection:l,openInEditor:d,dynamicPrompt:f});C.useEffect(()=>{g({xmlProtection:l,openInEditor:d,dynamicPrompt:f})},[l,d,f]),C.useEffect(()=>{i(Me.LLM_DISABLE_XML_PROTECTION),i(Me.DISPLAY_SHOW_OPEN_IN_EDITOR),i(Me.LLM_DYNAMIC_SYSTEM_PROMPT)},[i]);const x=()=>{const w=!p.xmlProtection;g(k=>({...k,xmlProtection:w})),a(Me.LLM_DISABLE_XML_PROTECTION,String(w))},_=()=>{const w=!p.openInEditor;g(k=>({...k,openInEditor:w})),a(Me.DISPLAY_SHOW_OPEN_IN_EDITOR,String(w))},v=()=>{const w=!p.dynamicPrompt;g(k=>({...k,dynamicPrompt:w})),a(Me.LLM_DYNAMIC_SYSTEM_PROMPT,String(w))};function S(){e(),t("/onboarding")}return h?c.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):c.jsxs("div",{className:"space-y-6",children:[c.jsx("div",{children:c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsxs("div",{className:"flex-1 min-w-0 mr-3",children:[c.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Dynamic System Prompt"}),c.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Rebuild the system prompt on every turn. When disabled, changes are applied on demand via the context header for better cache performance."})]}),c.jsx(Ap,{enabled:p.dynamicPrompt,onClick:v})]})}),c.jsx("hr",{className:"border-border"}),c.jsx("div",{children:c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Disable XML Tool Call Protection"}),c.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."})]}),c.jsx(Ap,{enabled:p.xmlProtection,onClick:x})]})}),c.jsx("hr",{className:"border-border"}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Integrations"}),c.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm text-text-primary",children:'Show "Open in VSCode" links'}),c.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Display a link on file reads to open the file directly in VS Code."})]}),c.jsx(Ap,{enabled:p.openInEditor,onClick:_})]})]}),c.jsx("hr",{className:"border-border"}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),c.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),c.jsx(Ze,{variant:"secondary",onClick:S,children:"Launch Onboarding"})]})]})}function ko({label:e,active:t,onClick:n}){return c.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 NL({isOpen:e,onClose:t}){const[n,r]=C.useState("instructions"),i=()=>{try{Ft.send("context.checkDynamic",{})}catch{}t()};return c.jsx(jt,{isOpen:e,onClose:i,title:"Settings",size:"xl",minHeight:"500px",children:c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[c.jsx(ko,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),c.jsx(ko,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),c.jsx(ko,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),c.jsx(ko,{label:"Display",active:n==="display",onClick:()=>r("display")}),c.jsx(ko,{label:"Shortcuts",active:n==="keybindings",onClick:()=>r("keybindings")}),c.jsx(ko,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced")})]}),n==="instructions"&&c.jsx(xL,{isOpen:e}),n==="skills"&&c.jsx(_L,{isOpen:e}),n==="notifications"&&c.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:c.jsx(mL,{})}),n==="display"&&c.jsx(wL,{}),n==="keybindings"&&c.jsx(kL,{}),n==="advanced"&&c.jsx(EL,{onClose:t})]})})}/**
59
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
60
+ * @license MIT
61
+ *
62
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
63
+ * @license MIT
64
+ *
65
+ * Originally forked from (with the author's permission):
66
+ * Fabrice Bellard's javascript vt100 for jslinux:
67
+ * http://bellard.org/jslinux/
68
+ * Copyright (c) 2011 Fabrice Bellard
69
+ */var mk=Object.defineProperty,jL=Object.getOwnPropertyDescriptor,TL=(e,t)=>{for(var n in t)mk(e,n,{get:t[n],enumerable:!0})},Kt=(e,t,n,r)=>{for(var i=r>1?void 0:r?jL(t,n):t,a=e.length-1,l;a>=0;a--)(l=e[a])&&(i=(r?l(t,n,i):l(i))||i);return r&&i&&mk(t,n,i),i},je=(e,t)=>(n,r)=>t(n,r,e),OS="Terminal input",Mg={get:()=>OS,set:e=>OS=e},IS="Too much output to announce, navigate to rows manually to read",Og={get:()=>IS,set:e=>IS=e};function AL(e){return e.replace(/\r?\n/g,"\r")}function DL(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function LL(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function RL(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let i=e.clipboardData.getData("text/plain");pk(i,t,n,r)}}function pk(e,t,n,r){e=AL(e),e=DL(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function gk(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex="1000",t.focus()}function PS(e,t,n,r,i){gk(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ts(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Lh(e,t=0,n=e.length){let r="";for(let i=t;i<n;++i){let a=e[i];a>65535?(a-=65536,r+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):r+=String.fromCharCode(a)}return r}var ML=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let a=e.charCodeAt(i++);56320<=a&&a<=57343?t[r++]=(this._interim-55296)*1024+a-56320+65536:(t[r++]=this._interim,t[r++]=a),this._interim=0}for(let a=i;a<n;++a){let l=e.charCodeAt(a);if(55296<=l&&l<=56319){if(++a>=n)return this._interim=l,r;let d=e.charCodeAt(a);56320<=d&&d<=57343?t[r++]=(l-55296)*1024+d-56320+65536:(t[r++]=l,t[r++]=d);continue}l!==65279&&(t[r++]=l)}return r}},OL=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,n){let r=t.length;if(!r)return 0;let i=0,a,l,d,f,h=0,p=0;if(this.interim[0]){let _=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let S=0,w;for(;(w=this.interim[++S]&63)&&S<4;)v<<=6,v|=w;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,j=k-S;for(;p<j;){if(p>=r)return 0;if(w=t[p++],(w&192)!==128){p--,_=!0;break}else this.interim[S++]=w,v<<=6,v|=w&63}_||(k===2?v<128?p--:n[i++]=v:k===3?v<2048||v>=55296&&v<=57343||v===65279||(n[i++]=v):v<65536||v>1114111||(n[i++]=v)),this.interim.fill(0)}let g=r-4,x=p;for(;x<r;){for(;x<g&&!((a=t[x])&128)&&!((l=t[x+1])&128)&&!((d=t[x+2])&128)&&!((f=t[x+3])&128);)n[i++]=a,n[i++]=l,n[i++]=d,n[i++]=f,x+=4;if(a=t[x++],a<128)n[i++]=a;else if((a&224)===192){if(x>=r)return this.interim[0]=a,i;if(l=t[x++],(l&192)!==128){x--;continue}if(h=(a&31)<<6|l&63,h<128){x--;continue}n[i++]=h}else if((a&240)===224){if(x>=r)return this.interim[0]=a,i;if(l=t[x++],(l&192)!==128){x--;continue}if(x>=r)return this.interim[0]=a,this.interim[1]=l,i;if(d=t[x++],(d&192)!==128){x--;continue}if(h=(a&15)<<12|(l&63)<<6|d&63,h<2048||h>=55296&&h<=57343||h===65279)continue;n[i++]=h}else if((a&248)===240){if(x>=r)return this.interim[0]=a,i;if(l=t[x++],(l&192)!==128){x--;continue}if(x>=r)return this.interim[0]=a,this.interim[1]=l,i;if(d=t[x++],(d&192)!==128){x--;continue}if(x>=r)return this.interim[0]=a,this.interim[1]=l,this.interim[2]=d,i;if(f=t[x++],(f&192)!==128){x--;continue}if(h=(a&7)<<18|(l&63)<<12|(d&63)<<6|f&63,h<65536||h>1114111)continue;n[i++]=h}}return i}},_k="",Ms=" ",$c=class xk{constructor(){this.fg=0,this.bg=0,this.extended=new Qd}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 xk;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}},Qd=class yk{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 yk(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Pr=class vk extends $c{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Qd,this.combinedData=""}static fromCharData(t){let n=new vk;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?Ts(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 i=t[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(r-55296)*1024+i-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()]}},BS="di$target",Ig="di$dependencies",Dp=new Map;function IL(e){return e[Ig]||[]}function Nn(e){if(Dp.has(e))return Dp.get(e);let t=function(n,r,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");PL(t,n,i)};return t._id=e,Dp.set(e,t),t}function PL(e,t,n){t[BS]===t?t[Ig].push({id:e,index:n}):(t[Ig]=[{id:e,index:n}],t[BS]=t)}var Gn=Nn("BufferService"),bk=Nn("CoreMouseService"),Ra=Nn("CoreService"),BL=Nn("CharsetService"),ox=Nn("InstantiationService"),Sk=Nn("LogService"),qn=Nn("OptionsService"),wk=Nn("OscLinkService"),zL=Nn("UnicodeService"),Hc=Nn("DecorationService"),Pg=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var p;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Pr,l=n.getTrimmedLength(),d=-1,f=-1,h=!1;for(let g=0;g<l;g++)if(!(f===-1&&!n.hasContent(g))){if(n.loadCell(g,a),a.hasExtendedAttrs()&&a.extended.urlId)if(f===-1){f=g,d=a.extended.urlId;continue}else h=a.extended.urlId!==d;else f!==-1&&(h=!0);if(h||f!==-1&&g===l-1){let x=(p=this._oscLinkService.getLinkData(d))==null?void 0:p.uri;if(x){let _={start:{x:f+1,y:e},end:{x:g+(!h&&g===l-1?1:0),y:e}},v=!1;if(!(i!=null&&i.allowNonHttpProtocols))try{let S=new URL(x);["http:","https:"].includes(S.protocol)||(v=!0)}catch{v=!0}v||r.push({text:x,range:_,activate:(S,w)=>i?i.activate(S,w,_):$L(S,w),hover:(S,w)=>{var k;return(k=i==null?void 0:i.hover)==null?void 0:k.call(i,S,w,_)},leave:(S,w)=>{var k;return(k=i==null?void 0:i.leave)==null?void 0:k.call(i,S,w,_)}})}h=!1,a.hasExtendedAttrs()&&a.extended.urlId?(f=g,d=a.extended.urlId):(f=-1,d=-1)}}t(r)}};Pg=Kt([je(0,Gn),je(1,qn),je(2,wk)],Pg);function $L(e,t){if(confirm(`Do you want to navigate to ${t}?
70
+
71
+ 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 Rh=Nn("CharSizeService"),Yi=Nn("CoreBrowserService"),lx=Nn("MouseService"),Xi=Nn("RenderService"),HL=Nn("SelectionService"),Ck=Nn("CharacterJoinerService"),Ko=Nn("ThemeService"),kk=Nn("LinkProviderService"),FL=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?zS.isErrorNoTelemetry(e)?new zS(e.message+`
72
+
73
+ `+e.stack):new Error(e.message+`
74
+
75
+ `+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)}},UL=new FL;function zd(e){VL(e)||UL.onUnexpectedError(e)}var Bg="Canceled";function VL(e){return e instanceof WL?!0:e instanceof Error&&e.name===Bg&&e.message===Bg}var WL=class extends Error{constructor(){super(Bg),this.name=this.message}};function GL(e){return new Error(`Illegal argument: ${e}`)}var zS=class zg extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof zg)return t;let n=new zg;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},$g=class Ek extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ek.prototype)}};function fr(e,t=0){return e[e.length-(1+t)]}var qL;(e=>{function t(a){return a<0}e.isLessThan=t;function n(a){return a<=0}e.isLessThanOrEqual=n;function r(a){return a>0}e.isGreaterThan=r;function i(a){return a===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(qL||(qL={}));function KL(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var Nk;(e=>{function t(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(A){yield A}e.single=i;function a(A){return t(A)?A:i(A)}e.wrap=a;function l(A){return A||n}e.from=l;function*d(A){for(let P=A.length-1;P>=0;P--)yield A[P]}e.reverse=d;function f(A){return!A||A[Symbol.iterator]().next().done===!0}e.isEmpty=f;function h(A){return A[Symbol.iterator]().next().value}e.first=h;function p(A,P){let M=0;for(let q of A)if(P(q,M++))return!0;return!1}e.some=p;function g(A,P){for(let M of A)if(P(M))return M}e.find=g;function*x(A,P){for(let M of A)P(M)&&(yield M)}e.filter=x;function*_(A,P){let M=0;for(let q of A)yield P(q,M++)}e.map=_;function*v(A,P){let M=0;for(let q of A)yield*P(q,M++)}e.flatMap=v;function*S(...A){for(let P of A)yield*P}e.concat=S;function w(A,P,M){let q=M;for(let Z of A)q=P(q,Z);return q}e.reduce=w;function*k(A,P,M=A.length){for(P<0&&(P+=A.length),M<0?M+=A.length:M>A.length&&(M=A.length);P<M;P++)yield A[P]}e.slice=k;function j(A,P=Number.POSITIVE_INFINITY){let M=[];if(P===0)return[M,A];let q=A[Symbol.iterator]();for(let Z=0;Z<P;Z++){let J=q.next();if(J.done)return[M,e.empty()];M.push(J.value)}return[M,{[Symbol.iterator](){return q}}]}e.consume=j;async function T(A){let P=[];for await(let M of A)P.push(M);return Promise.resolve(P)}e.asyncToArray=T})(Nk||(Nk={}));function ja(e){if(Nk.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 YL(...e){return Bt(()=>ja(e))}function Bt(e){return{dispose:KL(()=>{e()})}}var jk=class Tk{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{ja(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?Tk.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)}};jk.DISABLE_DISPOSED_WARNING=!1;var Is=jk,et=class{constructor(){this._store=new Is,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};et.None=Object.freeze({dispose(){}});var Uo=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}},Gi=typeof window=="object"?window:globalThis,Hg=class Fg{constructor(t){this.element=t,this.next=Fg.Undefined,this.prev=Fg.Undefined}};Hg.Undefined=new Hg(void 0);var $t=Hg,$S=class{constructor(){this._first=$t.Undefined,this._last=$t.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===$t.Undefined}clear(){let e=this._first;for(;e!==$t.Undefined;){let t=e.next;e.prev=$t.Undefined,e.next=$t.Undefined,e=t}this._first=$t.Undefined,this._last=$t.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new $t(e);if(this._first===$t.Undefined)this._first=n,this._last=n;else if(t){let i=this._last;this._last=n,n.prev=i,i.next=n}else{let i=this._first;this._first=n,n.next=i,i.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==$t.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==$t.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==$t.Undefined&&e.next!==$t.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===$t.Undefined&&e.next===$t.Undefined?(this._first=$t.Undefined,this._last=$t.Undefined):e.next===$t.Undefined?(this._last=this._last.prev,this._last.next=$t.Undefined):e.prev===$t.Undefined&&(this._first=this._first.next,this._first.prev=$t.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==$t.Undefined;)yield e.element,e=e.next}},XL=globalThis.performance&&typeof globalThis.performance.now=="function",QL=class Ak{static create(t){return new Ak(t)}constructor(t){this._now=XL&&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}},Mn;(e=>{e.None=()=>et.None;function t(H,R){return g(H,()=>{},0,void 0,!0,void 0,R)}e.defer=t;function n(H){return(R,U=null,D)=>{let N=!1,F;return F=H($=>{if(!N)return F?F.dispose():N=!0,R.call(U,$)},null,D),N&&F.dispose(),F}}e.once=n;function r(H,R,U){return h((D,N=null,F)=>H($=>D.call(N,R($)),null,F),U)}e.map=r;function i(H,R,U){return h((D,N=null,F)=>H($=>{R($),D.call(N,$)},null,F),U)}e.forEach=i;function a(H,R,U){return h((D,N=null,F)=>H($=>R($)&&D.call(N,$),null,F),U)}e.filter=a;function l(H){return H}e.signal=l;function d(...H){return(R,U=null,D)=>{let N=YL(...H.map(F=>F($=>R.call(U,$))));return p(N,D)}}e.any=d;function f(H,R,U,D){let N=U;return r(H,F=>(N=R(N,F),N),D)}e.reduce=f;function h(H,R){let U,D={onWillAddFirstListener(){U=H(N.fire,N)},onDidRemoveLastListener(){U==null||U.dispose()}},N=new we(D);return R==null||R.add(N),N.event}function p(H,R){return R instanceof Array?R.push(H):R&&R.add(H),H}function g(H,R,U=100,D=!1,N=!1,F,$){let se,B,V,K=0,I,Q={leakWarningThreshold:F,onWillAddFirstListener(){se=H(ee=>{K++,B=R(B,ee),D&&!V&&(W.fire(B),B=void 0),I=()=>{let ne=B;B=void 0,V=void 0,(!D||K>1)&&W.fire(ne),K=0},typeof U=="number"?(clearTimeout(V),V=setTimeout(I,U)):V===void 0&&(V=0,queueMicrotask(I))})},onWillRemoveListener(){N&&K>0&&(I==null||I())},onDidRemoveLastListener(){I=void 0,se.dispose()}},W=new we(Q);return $==null||$.add(W),W.event}e.debounce=g;function x(H,R=0,U){return e.debounce(H,(D,N)=>D?(D.push(N),D):[N],R,void 0,!0,void 0,U)}e.accumulate=x;function _(H,R=(D,N)=>D===N,U){let D=!0,N;return a(H,F=>{let $=D||!R(F,N);return D=!1,N=F,$},U)}e.latch=_;function v(H,R,U){return[e.filter(H,R,U),e.filter(H,D=>!R(D),U)]}e.split=v;function S(H,R=!1,U=[],D){let N=U.slice(),F=H(B=>{N?N.push(B):se.fire(B)});D&&D.add(F);let $=()=>{N==null||N.forEach(B=>se.fire(B)),N=null},se=new we({onWillAddFirstListener(){F||(F=H(B=>se.fire(B)),D&&D.add(F))},onDidAddFirstListener(){N&&(R?setTimeout($):$())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return D&&D.add(se),se.event}e.buffer=S;function w(H,R){return(U,D,N)=>{let F=R(new j);return H(function($){let se=F.evaluate($);se!==k&&U.call(D,se)},void 0,N)}}e.chain=w;let k=Symbol("HaltChainable");class j{constructor(){this.steps=[]}map(R){return this.steps.push(R),this}forEach(R){return this.steps.push(U=>(R(U),U)),this}filter(R){return this.steps.push(U=>R(U)?U:k),this}reduce(R,U){let D=U;return this.steps.push(N=>(D=R(D,N),D)),this}latch(R=(U,D)=>U===D){let U=!0,D;return this.steps.push(N=>{let F=U||!R(N,D);return U=!1,D=N,F?N:k}),this}evaluate(R){for(let U of this.steps)if(R=U(R),R===k)break;return R}}function T(H,R,U=D=>D){let D=(...se)=>$.fire(U(...se)),N=()=>H.on(R,D),F=()=>H.removeListener(R,D),$=new we({onWillAddFirstListener:N,onDidRemoveLastListener:F});return $.event}e.fromNodeEventEmitter=T;function A(H,R,U=D=>D){let D=(...se)=>$.fire(U(...se)),N=()=>H.addEventListener(R,D),F=()=>H.removeEventListener(R,D),$=new we({onWillAddFirstListener:N,onDidRemoveLastListener:F});return $.event}e.fromDOMEventEmitter=A;function P(H){return new Promise(R=>n(H)(R))}e.toPromise=P;function M(H){let R=new we;return H.then(U=>{R.fire(U)},()=>{R.fire(void 0)}).finally(()=>{R.dispose()}),R.event}e.fromPromise=M;function q(H,R){return H(U=>R.fire(U))}e.forward=q;function Z(H,R,U){return R(U),H(D=>R(D))}e.runAndSubscribe=Z;class J{constructor(R,U){this._observable=R,this._counter=0,this._hasChanged=!1;let D={onWillAddFirstListener:()=>{R.addObserver(this)},onDidRemoveLastListener:()=>{R.removeObserver(this)}};this.emitter=new we(D),U&&U.add(this.emitter)}beginUpdate(R){this._counter++}handlePossibleChange(R){}handleChange(R,U){this._hasChanged=!0}endUpdate(R){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function L(H,R){return new J(H,R).emitter.event}e.fromObservable=L;function G(H){return(R,U,D)=>{let N=0,F=!1,$={beginUpdate(){N++},endUpdate(){N--,N===0&&(H.reportChanges(),F&&(F=!1,R.call(U)))},handlePossibleChange(){},handleChange(){F=!0}};H.addObserver($),H.reportChanges();let se={dispose(){H.removeObserver($)}};return D instanceof Is?D.add(se):Array.isArray(D)&&D.push(se),se}}e.fromObservableLight=G})(Mn||(Mn={}));var Ug=class Vg{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Vg._idPool++}`,Vg.all.add(this)}start(t){this._stopWatch=new QL,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}}};Ug.all=new Set,Ug._idPool=0;var JL=Ug,ZL=-1,Dk=class Lk{constructor(t,n,r=(Lk._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 i=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[a,l]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${l}):`;console.warn(d),console.warn(a);let f=new nR(d,a);this._errorHandler(f)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,i]of this._stacks)(!t||n<i)&&(t=[r,i],n=i);return t}};Dk._idPool=1;var eR=Dk,tR=class Rk{constructor(t){this.value=t}static create(){let t=new Error;return new Rk(t.stack??"")}print(){console.warn(this.value.split(`
76
+ `).slice(2).join(`
77
+ `))}},nR=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},rR=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},iR=0,Lp=class{constructor(e){this.value=e,this.id=iR++}},sR=2,aR,we=class{constructor(t){var n,r,i,a;this._size=0,this._options=t,this._leakageMon=(n=this._options)!=null&&n.leakWarningThreshold?new eR((t==null?void 0:t.onListenerError)??zd,((r=this._options)==null?void 0:r.leakWarningThreshold)??ZL):void 0,this._perfMon=(i=this._options)!=null&&i._profName?new JL(this._options._profName):void 0,this._deliveryQueue=(a=this._options)==null?void 0:a.deliveryQueue}dispose(){var t,n,r,i;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(r=(n=this._options)==null?void 0:n.onDidRemoveLastListener)==null||r.call(n),(i=this._leakageMon)==null||i.dispose())}get event(){return this._event??(this._event=(t,n,r)=>{var d,f,h,p,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let x=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(x);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new rR(`${x}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((d=this._options)==null?void 0:d.onListenerError)||zd)(v),et.None}if(this._disposed)return et.None;n&&(t=t.bind(n));let i=new Lp(t),a;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=tR.create(),a=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof Lp?(this._deliveryQueue??(this._deliveryQueue=new oR),this._listeners=[this._listeners,i]):this._listeners.push(i):((h=(f=this._options)==null?void 0:f.onWillAddFirstListener)==null||h.call(f,this),this._listeners=i,(g=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||g.call(p,this)),this._size++;let l=Bt(()=>{a==null||a(),this._removeListener(i)});return r instanceof Is?r.add(l):Array.isArray(r)&&r.push(l),l}),this._event}_removeListener(t){var a,l,d,f;if((l=(a=this._options)==null?void 0:a.onWillRemoveListener)==null||l.call(a,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(f=(d=this._options)==null?void 0:d.onDidRemoveLastListener)==null||f.call(d,this),this._size=0;return}let n=this._listeners,r=n.indexOf(t);if(r===-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--,n[r]=void 0;let i=this._deliveryQueue.current===this;if(this._size*sR<=n.length){let h=0;for(let p=0;p<n.length;p++)n[p]?n[h++]=n[p]:i&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=h}}_deliver(t,n){var i;if(!t)return;let r=((i=this._options)==null?void 0:i.onListenerError)||zd;if(!r){t.value(n);return}try{t.value(n)}catch(a){r(a)}}_deliverQueue(t){let n=t.current._listeners;for(;t.i<t.end;)this._deliver(n[t.i++],t.value);t.reset()}fire(t){var n,r,i,a;if((n=this._deliveryQueue)!=null&&n.current&&(this._deliverQueue(this._deliveryQueue),(r=this._perfMon)==null||r.stop()),(i=this._perfMon)==null||i.start(this._size),this._listeners)if(this._listeners instanceof Lp)this._deliver(this._listeners,t);else{let l=this._deliveryQueue;l.enqueue(this,t,this._listeners.length),this._deliverQueue(l)}(a=this._perfMon)==null||a.stop()}hasListeners(){return this._size>0}},oR=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}},Wg=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new we,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new we,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}};Wg.INSTANCE=new Wg;var cx=Wg;function lR(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}cx.INSTANCE.onDidChangeZoomLevel;function cR(e){return cx.INSTANCE.getZoomFactor(e)}cx.INSTANCE.onDidChangeFullscreen;var Yo=typeof navigator=="object"?navigator.userAgent:"",Gg=Yo.indexOf("Firefox")>=0,uR=Yo.indexOf("AppleWebKit")>=0,ux=Yo.indexOf("Chrome")>=0,dR=!ux&&Yo.indexOf("Safari")>=0;Yo.indexOf("Electron/")>=0;Yo.indexOf("Android")>=0;var Rp=!1;if(typeof Gi.matchMedia=="function"){let e=Gi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Gi.matchMedia("(display-mode: fullscreen)");Rp=e.matches,lR(Gi,e,({matches:n})=>{Rp&&t.matches||(Rp=n)})}var zo="en",qg=!1,Kg=!1,$d=!1,Mk=!1,gd,Hd=zo,HS=zo,hR,Gr,Ea=globalThis,Rn,LC;typeof Ea.vscode<"u"&&typeof Ea.vscode.process<"u"?Rn=Ea.vscode.process:typeof process<"u"&&typeof((LC=process==null?void 0:process.versions)==null?void 0:LC.node)=="string"&&(Rn=process);var RC,fR=typeof((RC=Rn==null?void 0:Rn.versions)==null?void 0:RC.electron)=="string",mR=fR&&(Rn==null?void 0:Rn.type)==="renderer",MC;if(typeof Rn=="object"){qg=Rn.platform==="win32",Kg=Rn.platform==="darwin",$d=Rn.platform==="linux",$d&&Rn.env.SNAP&&Rn.env.SNAP_REVISION,Rn.env.CI||Rn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,gd=zo,Hd=zo;let e=Rn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);gd=t.userLocale,HS=t.osLocale,Hd=t.resolvedLanguage||zo,hR=(MC=t.languagePack)==null?void 0:MC.translationsConfigFile}catch{}Mk=!0}else typeof navigator=="object"&&!mR?(Gr=navigator.userAgent,qg=Gr.indexOf("Windows")>=0,Kg=Gr.indexOf("Macintosh")>=0,(Gr.indexOf("Macintosh")>=0||Gr.indexOf("iPad")>=0||Gr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,$d=Gr.indexOf("Linux")>=0,(Gr==null?void 0:Gr.indexOf("Mobi"))>=0,Hd=globalThis._VSCODE_NLS_LANGUAGE||zo,gd=navigator.language.toLowerCase(),HS=gd):console.error("Unable to resolve platform.");var Ok=qg,mi=Kg,pR=$d,FS=Mk,_i=Gr,ws=Hd,gR;(e=>{function t(){return ws}e.value=t;function n(){return ws.length===2?ws==="en":ws.length>=3?ws[0]==="e"&&ws[1]==="n"&&ws[2]==="-":!1}e.isDefaultVariant=n;function r(){return ws==="en"}e.isDefault=r})(gR||(gR={}));var _R=typeof Ea.postMessage=="function"&&!Ea.importScripts;(()=>{if(_R){let e=[];Ea.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,i=e.length;r<i;r++){let a=e[r];if(a.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),a.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),Ea.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var xR=!!(_i&&_i.indexOf("Chrome")>=0);_i&&_i.indexOf("Firefox")>=0;!xR&&_i&&_i.indexOf("Safari")>=0;_i&&_i.indexOf("Edg/")>=0;_i&&_i.indexOf("Android")>=0;var Eo=typeof navigator=="object"?navigator:{};FS||document.queryCommandSupported&&document.queryCommandSupported("copy")||Eo&&Eo.clipboard&&Eo.clipboard.writeText,FS||Eo&&Eo.clipboard&&Eo.clipboard.readText;var dx=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}},Mp=new dx,US=new dx,VS=new dx,yR=new Array(230),Ik;(e=>{function t(d){return Mp.keyCodeToStr(d)}e.toString=t;function n(d){return Mp.strToKeyCode(d)}e.fromString=n;function r(d){return US.keyCodeToStr(d)}e.toUserSettingsUS=r;function i(d){return VS.keyCodeToStr(d)}e.toUserSettingsGeneral=i;function a(d){return US.strToKeyCode(d)||VS.strToKeyCode(d)}e.fromUserSettings=a;function l(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 Mp.keyCodeToStr(d)}e.toElectronAccelerator=l})(Ik||(Ik={}));var vR=class Pk{constructor(t,n,r,i,a){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=i,this.keyCode=a}equals(t){return t instanceof Pk&&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",i=this.metaKey?"1":"0";return`K${t}${n}${r}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new bR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},bR=class{constructor(e){if(e.length===0)throw GL("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 SR(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Ik.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Gg)switch(t){case 59:return 85;case 60:if(pR)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(mi)return 57;break}else if(uR&&(mi&&t===93||!mi&&t===92))return 57;return yR[t]||0}var wR=mi?256:2048,CR=512,kR=1024,ER=mi?2048:256,WS=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=SR(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|=wR),this.altKey&&(t|=CR),this.shiftKey&&(t|=kR),this.metaKey&&(t|=ER),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new vR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},GS=new WeakMap;function NR(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 jR=class{static getSameOriginWindowChain(e){let t=GS.get(e);if(!t){t=[],GS.set(e,t);let n=e,r;do r=NR(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,i=this.getSameOriginWindowChain(e);for(let a of i){let l=a.window.deref();if(n+=(l==null?void 0:l.scrollY)??0,r+=(l==null?void 0:l.scrollX)??0,l===t||!a.iframeElement)break;let d=a.iframeElement.getBoundingClientRect();n+=d.top,r+=d.left}return{top:n,left:r}}},_d=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=jR.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},qS=class{constructor(e,t=0,n=0){var i;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(ux){let a=navigator.userAgent.match(/Chrome\/(\d+)/);r=(a?parseInt(a[1]):123)<=122}if(e){let a=e,l=e,d=((i=e.view)==null?void 0:i.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")r?this.deltaY=a.wheelDeltaY/(120*d):this.deltaY=a.wheelDeltaY/120;else if(typeof l.VERTICAL_AXIS<"u"&&l.axis===l.VERTICAL_AXIS)this.deltaY=-l.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Gg&&!mi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")dR&&Ok?this.deltaX=-(a.wheelDeltaX/120):r?this.deltaX=a.wheelDeltaX/(120*d):this.deltaX=a.wheelDeltaX/120;else if(typeof l.HORIZONTAL_AXIS<"u"&&l.axis===l.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Gg&&!mi?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()}},Bk=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),TR;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof AR?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Bk})})(TR||(TR={}));var AR=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?Bk:(this._emitter||(this._emitter=new we),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},hx=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 $g("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new $g("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},DR=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 $g("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=Bt(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},LR;(e=>{async function t(r){let i,a=await Promise.all(r.map(l=>l.then(d=>d,d=>{i||(i=d)})));if(typeof i<"u")throw i;return a}e.settled=t;function n(r){return new Promise(async(i,a)=>{try{await r(i,a)}catch(l){a(l)}})}e.withAsyncBody=n})(LR||(LR={}));var KS=class Ar{static fromArray(t){return new Ar(n=>{n.emitMany(t)})}static fromPromise(t){return new Ar(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ar(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new Ar(async n=>{await Promise.all(t.map(async r=>{for await(let i of r)n.emitOne(i)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new we,queueMicrotask(async()=>{let r={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(t(r)),this.resolve()}catch(i){this.reject(i)}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 Mn.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 Ar(async r=>{for await(let i of t)r.emitOne(n(i))})}map(t){return Ar.map(this,t)}static filter(t,n){return new Ar(async r=>{for await(let i of t)n(i)&&r.emitOne(i)})}filter(t){return Ar.filter(this,t)}static coalesce(t){return Ar.filter(t,n=>!!n)}coalesce(){return Ar.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return Ar.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())}};KS.EMPTY=KS.fromArray([]);var{getWindow:fi,getWindowId:RR,onDidRegisterWindow:MR}=(function(){let e=new Map,t={window:Gi,disposables:new Is};e.set(Gi.vscodeWindowId,t);let n=new we,r=new we,i=new we;function a(l,d){return(typeof l=="number"?e.get(l):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(l){if(e.has(l.vscodeWindowId))return et.None;let d=new Is,f={window:l,disposables:d.add(new Is)};return e.set(l.vscodeWindowId,f),d.add(Bt(()=>{e.delete(l.vscodeWindowId),r.fire(l)})),d.add(Fe(l,Sn.BEFORE_UNLOAD,()=>{i.fire(l)})),n.fire(f),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(l){return l.vscodeWindowId},hasWindow(l){return e.has(l)},getWindowById:a,getWindow(l){var h;let d=l;if((h=d==null?void 0:d.ownerDocument)!=null&&h.defaultView)return d.ownerDocument.defaultView.window;let f=l;return f!=null&&f.view?f.view.window:Gi},getDocument(l){return fi(l).document}}})(),OR=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 OR(e,t,n,r)}var YS=function(e,t,n,r){return Fe(e,t,n,r)},fx,IR=class extends DR{constructor(e){super(),this.defaultTarget=e&&fi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},XS=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){zd(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=a=>{n.set(a,!1);let l=e.get(a)??[];for(t.set(a,l),e.set(a,[]),r.set(a,!0);l.length>0;)l.sort(XS.sort),l.shift().execute();r.set(a,!1)};fx=(a,l,d=0)=>{let f=RR(a),h=new XS(l,d),p=e.get(f);return p||(p=[],e.set(f,p)),p.push(h),n.get(f)||(n.set(f,!0),a.requestAnimationFrame(()=>i(f))),h}})();function PR(e){let t=e.getBoundingClientRect(),n=fi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Sn={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"},BR=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=nr(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=nr(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=nr(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=nr(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=nr(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=nr(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=nr(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=nr(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=nr(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=nr(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=nr(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=nr(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=nr(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=nr(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 nr(e){return typeof e=="number"?`${e}px`:e}function yc(e){return new BR(e)}var zk=class{constructor(){this._hooks=new Is,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,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(Bt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=fi(e)}this._hooks.add(Fe(a,Sn.POINTER_MOVE,l=>{if(l.buttons!==n){this.stopMonitoring(!0);return}l.preventDefault(),this._pointerMoveCallback(l)})),this._hooks.add(Fe(a,Sn.POINTER_UP,l=>this.stopMonitoring(!0)))}};function zR(e,t,n){let r=null,i=null;if(typeof n.value=="function"?(r="value",i=n.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",i=n.get),!i)throw new Error("not supported");let a=`$memoize$${t}`;n[r]=function(...l){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,l)}),this[a]}}var oi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(oi||(oi={}));var dc=class Pn extends et{constructor(){super(),this.dispatched=!1,this.targets=new $S,this.ignoreTargets=new $S,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Mn.runAndSubscribe(MR,({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:Gi,disposables:this._store}))}static addTarget(t){if(!Pn.isTouchDevice())return et.None;Pn.INSTANCE||(Pn.INSTANCE=new Pn);let n=Pn.INSTANCE.targets.push(t);return Bt(n)}static ignoreTarget(t){if(!Pn.isTouchDevice())return et.None;Pn.INSTANCE||(Pn.INSTANCE=new Pn);let n=Pn.INSTANCE.ignoreTargets.push(t);return Bt(n)}static isTouchDevice(){return"ontouchstart"in Gi||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,i=t.targetTouches.length;r<i;r++){let a=t.targetTouches.item(r);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:n,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[n],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let l=this.newGestureEvent(oi.Start,a.target);l.pageX=a.pageX,l.pageY=a.pageY,this.dispatchEvent(l)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,l=n.changedTouches.length;a<l;a++){let d=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let f=this.activeTouches[d.identifier],h=Date.now()-f.initialTimeStamp;if(h<Pn.HOLD_DELAY&&Math.abs(f.initialPageX-fr(f.rollingPageX))<30&&Math.abs(f.initialPageY-fr(f.rollingPageY))<30){let p=this.newGestureEvent(oi.Tap,f.initialTarget);p.pageX=fr(f.rollingPageX),p.pageY=fr(f.rollingPageY),this.dispatchEvent(p)}else if(h>=Pn.HOLD_DELAY&&Math.abs(f.initialPageX-fr(f.rollingPageX))<30&&Math.abs(f.initialPageY-fr(f.rollingPageY))<30){let p=this.newGestureEvent(oi.Contextmenu,f.initialTarget);p.pageX=fr(f.rollingPageX),p.pageY=fr(f.rollingPageY),this.dispatchEvent(p)}else if(i===1){let p=fr(f.rollingPageX),g=fr(f.rollingPageY),x=fr(f.rollingTimestamps)-f.rollingTimestamps[0],_=p-f.rollingPageX[0],v=g-f.rollingPageY[0],S=[...this.targets].filter(w=>f.initialTarget instanceof Node&&w.contains(f.initialTarget));this.inertia(t,S,r,Math.abs(_)/x,_>0?1:-1,p,Math.abs(v)/x,v>0?1:-1,g)}this.dispatchEvent(this.newGestureEvent(oi.End,f.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===oi.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>Pn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===oi.Change||t.type===oi.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 i=0,a=t.initialTarget;for(;a&&a!==r;)i++,a=a.parentElement;n.push([i,r])}n.sort((r,i)=>r[0]-i[0]);for(let[r,i]of n)i.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,l,d,f,h){this.handle=fx(t,()=>{let p=Date.now(),g=p-r,x=0,_=0,v=!0;i+=Pn.SCROLL_FRICTION*g,d+=Pn.SCROLL_FRICTION*g,i>0&&(v=!1,x=a*i*g),d>0&&(v=!1,_=f*d*g);let S=this.newGestureEvent(oi.Change);S.translationX=x,S.translationY=_,n.forEach(w=>w.dispatchEvent(S)),v||this.inertia(t,n,p,i,a,l+x,d,f,h+_)})}onTouchMove(t){let n=Date.now();for(let r=0,i=t.changedTouches.length;r<i;r++){let a=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],d=this.newGestureEvent(oi.Change,l.initialTarget);d.translationX=a.pageX-fr(l.rollingPageX),d.translationY=a.pageY-fr(l.rollingPageY),d.pageX=a.pageX,d.pageY=a.pageY,this.dispatchEvent(d),l.rollingPageX.length>3&&(l.rollingPageX.shift(),l.rollingPageY.shift(),l.rollingTimestamps.shift()),l.rollingPageX.push(a.pageX),l.rollingPageY.push(a.pageY),l.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};dc.SCROLL_FRICTION=-.005,dc.HOLD_DELAY=700,dc.CLEAR_TAP_COUNT_TIME=400,Kt([zR],dc,"isTouchDevice",1);var $R=dc,mx=class extends et{onclick(e,t){this._register(Fe(e,Sn.CLICK,n=>t(new _d(fi(e),n))))}onmousedown(e,t){this._register(Fe(e,Sn.MOUSE_DOWN,n=>t(new _d(fi(e),n))))}onmouseover(e,t){this._register(Fe(e,Sn.MOUSE_OVER,n=>t(new _d(fi(e),n))))}onmouseleave(e,t){this._register(Fe(e,Sn.MOUSE_LEAVE,n=>t(new _d(fi(e),n))))}onkeydown(e,t){this._register(Fe(e,Sn.KEY_DOWN,n=>t(new WS(n))))}onkeyup(e,t){this._register(Fe(e,Sn.KEY_UP,n=>t(new WS(n))))}oninput(e,t){this._register(Fe(e,Sn.INPUT,t))}onblur(e,t){this._register(Fe(e,Sn.BLUR,t))}onfocus(e,t){this._register(Fe(e,Sn.FOCUS,t))}onchange(e,t){this._register(Fe(e,Sn.CHANGE,t))}ignoreGesture(e){return $R.ignoreTarget(e)}},QS=11,HR=class extends mx{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=QS+"px",this.domNode.style.height=QS+"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 zk),this._register(YS(this.bgDomNode,Sn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(YS(this.domNode,Sn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new IR),this._pointerdownScheduleRepeatTimer=this._register(new hx)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,fi(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()}},FR=class Yg{constructor(t,n,r,i,a,l,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,i=i|0,a=a|0,l=l|0,d=d|0),this.rawScrollLeft=i,this.rawScrollTop=d,n<0&&(n=0),i+n>r&&(i=r-n),i<0&&(i=0),a<0&&(a=0),d+a>l&&(d=l-a),d<0&&(d=0),this.width=n,this.scrollWidth=r,this.scrollLeft=i,this.height=a,this.scrollHeight=l,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 Yg(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 Yg(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,i=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,l=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,f=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:i,scrollLeftChanged:a,heightChanged:l,scrollHeightChanged:d,scrollTopChanged:f}}},UR=class extends et{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new FR(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 ZS(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=ZS.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)))}},JS=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Op(e,t){let n=t-e;return function(r){return e+n*GR(r)}}function VR(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var ZS=class Xg{constructor(t,n,r,i){this.from=t,this.to=n,this.duration=i,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 i,a;return t<n?(i=t+.75*r,a=n-.75*r):(i=t-.75*r,a=n+.75*r),VR(Op(t,i),Op(a,n),.33)}return Op(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),i=this.scrollTop(n);return new JS(r,i,!1)}return new JS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return Xg.start(t,n,r)}static start(t,n,r){r=r+10;let i=Date.now()-10;return new Xg(t,n,i,r)}};function WR(e){return Math.pow(e,3)}function GR(e){return 1-WR(1-e)}var qR=class extends et{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 hx)}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":"")))}},KR=140,$k=class extends mx{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 qR(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new zk),this._shouldRender=!0,this.domNode=yc(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,Sn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new HR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=yc(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,Sn.POINTER_DOWN,i=>{i.button===0&&(i.preventDefault(),this._sliderPointerDown(i))})),this.onclick(this.slider.domNode,i=>{i.leftButton&&i.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(),i=this._sliderPointerPosition(e);n<=i&&i<=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 i=PR(this.domNode.domNode);t=e.pageX-i.left,n=e.pageY-i.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,i=>{let a=this._sliderOrthogonalPointerPosition(i),l=Math.abs(a-n);if(Ok&&l>KR){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let d=this._sliderPointerPosition(i)-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()}},Hk=class Qg{constructor(t,n,r,i,a,l){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=i,this._scrollSize=a,this._scrollPosition=l,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Qg(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,i,a){let l=Math.max(0,r-t),d=Math.max(0,l-2*n),f=i>0&&i>r;if(!f)return{computedAvailableSize:Math.round(l),computedIsNeeded:f,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(r*d/i))),p=(d-h)/(i-r),g=a*p;return{computedAvailableSize:Math.round(l),computedIsNeeded:f,computedSliderSize:Math.round(h),computedSliderRatio:p,computedSliderPosition:Math.round(g)}}_refreshComputedValues(){let t=Qg._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)}},YR=class extends $k{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Hk(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.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}},XR=class extends $k{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Hk(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.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}},QR=500,e1=50,JR=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Jg=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,i=this._rear;do{let a=i===this._front?t:Math.pow(2,-r);if(t-=a,n+=this._memory[i].score*a,i===this._front)break;i=(this._capacity+i-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(ux){let n=fi(t.browserEvent),r=cR(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 i=null,a=new JR(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(i=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]=a),a.score=this._computeScore(a,i)}_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 i=Math.abs(t.deltaX),a=Math.abs(t.deltaY),l=Math.abs(n.deltaX),d=Math.abs(n.deltaY),f=Math.max(Math.min(i,l),1),h=Math.max(Math.min(a,d),1),p=Math.max(i,l),g=Math.max(a,d);p%f===0&&g%h===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Jg.INSTANCE=new Jg;var ZR=Jg,e5=class extends mx{constructor(e,t,n){super(),this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new we),this.onWillScroll=this._onWillScroll.event,this._options=n5(t),this._scrollable=n,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let r={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new XR(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new YR(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=yc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=yc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=yc(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new hx),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ja(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,mi&&(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 qS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ja(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new qS(n))};this._mouseWheelToDispose.push(Fe(this._listenOnDomNode,Sn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var i;if((i=e.browserEvent)!=null&&i.defaultPrevented)return;let t=ZR.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,l=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&l+a===0?l=a=0:Math.abs(a)>=Math.abs(l)?l=0:a=0),this._options.flipAxes&&([a,l]=[l,a]);let d=!mi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!l&&(l=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(l=l*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),h={};if(a){let p=e1*a,g=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(h,g)}if(l){let p=e1*l,g=f.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(h,g)}h=this._scrollable.validateScrollPosition(h),(f.scrollLeft!==h.scrollLeft||f.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),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":"",i=t?" top":"",a=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${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(),QR)}},t5=class extends e5{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 n5(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,mi&&(t.className+=" mac"),t}var Zg=class extends et{constructor(e,t,n,r,i,a,l,d){super(),this._bufferService=n,this._optionsService=l,this._renderService=d,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new UR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>fx(r.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new t5(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Mn.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Bt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Bt(()=>this._styleElement.remove())),this._register(Mn.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
78
+ `)})),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(h=>this._handleScroll(h)))}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}};Zg=Kt([je(2,Gn),je(3,Yi),je(4,bk),je(5,Ko),je(6,qn),je(7,Xi)],Zg);var e_=class extends et{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,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(a=>this._removeDecoration(a))),this._register(Bt(()=>{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()}};e_=Kt([je(1,Gn),je(2,Yi),je(3,Hc),je(4,Xi)],e_);var r5=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)}},si={full:0,left:0,center:0,right:0},Cs={full:0,left:0,center:0,right:0},Yl={full:0,left:0,center:0,right:0},Jd=class extends et{constructor(e,t,n,r,i,a,l,d){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=l,this._coreBrowserService=d,this._colorZoneStore=new r5,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(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(Bt(()=>{var p;return(p=this._canvas)==null?void 0:p.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;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);Cs.full=this._canvas.width,Cs.left=e,Cs.center=t,Cs.right=e,this._refreshDrawHeightConstants(),Yl.full=1,Yl.left=1,Yl.center=1+Cs.left,Yl.right=1+Cs.left+Cs.center}_refreshDrawHeightConstants(){si.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);si.left=t,si.center=t,si.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*si.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*si.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*si.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*si.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(Yl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-si[e.position||"full"]/2),Cs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+si[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}))}};Jd=Kt([je(2,Gn),je(3,Hc),je(4,Xi),je(5,qn),je(6,Ko),je(7,Yi)],Jd);var _e;(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=`
79
+ `,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=""))(_e||(_e={}));var Fd;(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="Ÿ"))(Fd||(Fd={}));var Fk;(e=>e.ST=`${_e.ESC}\\`)(Fk||(Fk={}));var t_=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,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(`${_e.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,i=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"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 a=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};t_=Kt([je(2,Gn),je(3,qn),je(4,Ra),je(5,Xi)],t_);var wn=0,Cn=0,kn=0,qt=0,t1={css:"#00000000",rgba:0},cn;(e=>{function t(i,a,l,d){return d!==void 0?`#${oa(i)}${oa(a)}${oa(l)}${oa(d)}`:`#${oa(i)}${oa(a)}${oa(l)}`}e.toCss=t;function n(i,a,l,d=255){return(i<<24|a<<16|l<<8|d)>>>0}e.toRgba=n;function r(i,a,l,d){return{css:e.toCss(i,a,l,d),rgba:e.toRgba(i,a,l,d)}}e.toColor=r})(cn||(cn={}));var Mt;(e=>{function t(f,h){if(qt=(h.rgba&255)/255,qt===1)return{css:h.css,rgba:h.rgba};let p=h.rgba>>24&255,g=h.rgba>>16&255,x=h.rgba>>8&255,_=f.rgba>>24&255,v=f.rgba>>16&255,S=f.rgba>>8&255;wn=_+Math.round((p-_)*qt),Cn=v+Math.round((g-v)*qt),kn=S+Math.round((x-S)*qt);let w=cn.toCss(wn,Cn,kn),k=cn.toRgba(wn,Cn,kn);return{css:w,rgba:k}}e.blend=t;function n(f){return(f.rgba&255)===255}e.isOpaque=n;function r(f,h,p){let g=Ud.ensureContrastRatio(f.rgba,h.rgba,p);if(g)return cn.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=r;function i(f){let h=(f.rgba|255)>>>0;return[wn,Cn,kn]=Ud.toChannels(h),{css:cn.toCss(wn,Cn,kn),rgba:h}}e.opaque=i;function a(f,h){return qt=Math.round(h*255),[wn,Cn,kn]=Ud.toChannels(f.rgba),{css:cn.toCss(wn,Cn,kn,qt),rgba:cn.toRgba(wn,Cn,kn,qt)}}e.opacity=a;function l(f,h){return qt=f.rgba&255,a(f,qt*h/255)}e.multiplyOpacity=l;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(Mt||(Mt={}));var Ht;(e=>{let t,n;try{let i=document.createElement("canvas");i.width=1,i.height=1;let a=i.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return wn=parseInt(i.slice(1,2).repeat(2),16),Cn=parseInt(i.slice(2,3).repeat(2),16),kn=parseInt(i.slice(3,4).repeat(2),16),cn.toColor(wn,Cn,kn);case 5:return wn=parseInt(i.slice(1,2).repeat(2),16),Cn=parseInt(i.slice(2,3).repeat(2),16),kn=parseInt(i.slice(3,4).repeat(2),16),qt=parseInt(i.slice(4,5).repeat(2),16),cn.toColor(wn,Cn,kn,qt);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let a=i.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return wn=parseInt(a[1]),Cn=parseInt(a[2]),kn=parseInt(a[3]),qt=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),cn.toColor(wn,Cn,kn,qt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=i,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[wn,Cn,kn,qt]=t.getImageData(0,0,1,1).data,qt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:cn.toRgba(wn,Cn,kn,qt),css:i}}e.toColor=r})(Ht||(Ht={}));var Vn;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,i,a){let l=r/255,d=i/255,f=a/255,h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),p=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),g=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return h*.2126+p*.7152+g*.0722}e.relativeLuminance2=n})(Vn||(Vn={}));var Ud;(e=>{function t(l,d){if(qt=(d&255)/255,qt===1)return d;let f=d>>24&255,h=d>>16&255,p=d>>8&255,g=l>>24&255,x=l>>16&255,_=l>>8&255;return wn=g+Math.round((f-g)*qt),Cn=x+Math.round((h-x)*qt),kn=_+Math.round((p-_)*qt),cn.toRgba(wn,Cn,kn)}e.blend=t;function n(l,d,f){let h=Vn.relativeLuminance(l>>8),p=Vn.relativeLuminance(d>>8);if(Pi(h,p)<f){if(p<h){let _=r(l,d,f),v=Pi(h,Vn.relativeLuminance(_>>8));if(v<f){let S=i(l,d,f),w=Pi(h,Vn.relativeLuminance(S>>8));return v>w?_:S}return _}let g=i(l,d,f),x=Pi(h,Vn.relativeLuminance(g>>8));if(x<f){let _=r(l,d,f),v=Pi(h,Vn.relativeLuminance(_>>8));return x>v?g:_}return g}}e.ensureContrastRatio=n;function r(l,d,f){let h=l>>24&255,p=l>>16&255,g=l>>8&255,x=d>>24&255,_=d>>16&255,v=d>>8&255,S=Pi(Vn.relativeLuminance2(x,_,v),Vn.relativeLuminance2(h,p,g));for(;S<f&&(x>0||_>0||v>0);)x-=Math.max(0,Math.ceil(x*.1)),_-=Math.max(0,Math.ceil(_*.1)),v-=Math.max(0,Math.ceil(v*.1)),S=Pi(Vn.relativeLuminance2(x,_,v),Vn.relativeLuminance2(h,p,g));return(x<<24|_<<16|v<<8|255)>>>0}e.reduceLuminance=r;function i(l,d,f){let h=l>>24&255,p=l>>16&255,g=l>>8&255,x=d>>24&255,_=d>>16&255,v=d>>8&255,S=Pi(Vn.relativeLuminance2(x,_,v),Vn.relativeLuminance2(h,p,g));for(;S<f&&(x<255||_<255||v<255);)x=Math.min(255,x+Math.ceil((255-x)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),S=Pi(Vn.relativeLuminance2(x,_,v),Vn.relativeLuminance2(h,p,g));return(x<<24|_<<16|v<<8|255)>>>0}e.increaseLuminance=i;function a(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}e.toChannels=a})(Ud||(Ud={}));function oa(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Pi(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var i5=class extends $c{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()]}},Zd=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Pr}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),i=0,a=0,l=0,d=t.getFg(0),f=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==f){if(h-i>1){let p=this._getJoinedRanges(r,l,a,t,i);for(let g=0;g<p.length;g++)n.push(p[g])}i=h,l=a,d=this._workCell.fg,f=this._workCell.bg}a+=this._workCell.getChars().length||Ms.length}if(this._bufferService.cols-i>1){let h=this._getJoinedRanges(r,l,a,t,i);for(let p=0;p<h.length;p++)n.push(h[p])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),l=[];try{l=this._characterJoiners[0].handler(a)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let f=this._characterJoiners[d].handler(a);for(let h=0;h<f.length;h++)Zd._mergeRanges(l,f[h])}catch(f){console.error(f)}return this._stringRangesToCellRanges(l,r,i),l}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,l=e[r];if(l){for(let d=n;d<this._bufferService.cols;d++){let f=t.getWidth(d),h=t.getString(d).length||Ms.length;if(f!==0){if(!i&&l[0]<=a&&(l[0]=d,i=!0),l[1]<=a){if(l[1]=d,l=e[++r],!l)break;l[0]<=a?(l[0]=d,i=!0):i=!1}a+=h}}l&&(l[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Zd=Kt([je(0,Gn)],Zd);function s5(e){return 57508<=e&&e<=57558}function a5(e){return 9472<=e&&e<=9631}function o5(e){return s5(e)||a5(e)}function l5(){return{css:{canvas:xd(),cell:xd()},device:{canvas:xd(),cell:xd(),char:{width:0,height:0,left:0,top:0}}}}function xd(){return{width:0,height:0}}var n_=class{constructor(e,t,n,r,i,a,l){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=l,this._workCell=new Pr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,l,d,f,h,p){let g=[],x=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,v=e.getNoBgTrimmedLength();n&&v<a+1&&(v=a+1);let S,w=0,k="",j=0,T=0,A=0,P=0,M=!1,q=0,Z=!1,J=0,L=0,G=[],H=h!==-1&&p!==-1;for(let R=0;R<v;R++){e.loadCell(R,this._workCell);let U=this._workCell.getWidth();if(U===0)continue;let D=!1,N=R>=L,F=R,$=this._workCell;if(x.length>0&&R===x[0][0]&&N){let De=x.shift(),Ue=this._isCellInSelection(De[0],t);for(j=De[0]+1;j<De[1];j++)N&&(N=Ue===this._isCellInSelection(j,t));N&&(N=!n||a<De[0]||a>=De[1]),N?(D=!0,$=new i5(this._workCell,e.translateToString(!0,De[0],De[1]),De[1]-De[0]),F=De[1]-1,U=$.getWidth()):L=De[1]}let se=this._isCellInSelection(R,t),B=n&&R===a,V=H&&R>=h&&R<=p,K=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,De=>{K=!0});let I=$.getChars()||Ms;if(I===" "&&($.isUnderline()||$.isOverline())&&(I=" "),J=U*d-f.get(I,$.isBold(),$.isItalic()),!S)S=this._document.createElement("span");else if(w&&(se&&Z||!se&&!Z&&$.bg===T)&&(se&&Z&&_.selectionForeground||$.fg===A)&&$.extended.ext===P&&V===M&&J===q&&!B&&!D&&!K&&N){$.isInvisible()?k+=Ms:k+=I,w++;continue}else w&&(S.textContent=k),S=this._document.createElement("span"),w=0,k="";if(T=$.bg,A=$.fg,P=$.extended.ext,M=V,q=J,Z=se,D&&a>=R&&a<=F&&(a=R),!this._coreService.isCursorHidden&&B&&this._coreService.isCursorInitialized){if(G.push("xterm-cursor"),this._coreBrowserService.isFocused)l&&G.push("xterm-cursor-blink"),G.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(i)switch(i){case"outline":G.push("xterm-cursor-outline");break;case"block":G.push("xterm-cursor-block");break;case"bar":G.push("xterm-cursor-bar");break;case"underline":G.push("xterm-cursor-underline");break}}if($.isBold()&&G.push("xterm-bold"),$.isItalic()&&G.push("xterm-italic"),$.isDim()&&G.push("xterm-dim"),$.isInvisible()?k=Ms:k=$.getChars()||Ms,$.isUnderline()&&(G.push(`xterm-underline-${$.extended.underlineStyle}`),k===" "&&(k=" "),!$.isUnderlineColorDefault()))if($.isUnderlineColorRGB())S.style.textDecorationColor=`rgb(${$c.toColorRGB($.getUnderlineColor()).join(",")})`;else{let De=$.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&$.isBold()&&De<8&&(De+=8),S.style.textDecorationColor=_.ansi[De].css}$.isOverline()&&(G.push("xterm-overline"),k===" "&&(k=" ")),$.isStrikethrough()&&G.push("xterm-strikethrough"),V&&(S.style.textDecoration="underline");let Q=$.getFgColor(),W=$.getFgColorMode(),ee=$.getBgColor(),ne=$.getBgColorMode(),Se=!!$.isInverse();if(Se){let De=Q;Q=ee,ee=De;let Ue=W;W=ne,ne=Ue}let le,Ce,Re=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,De=>{De.options.layer!=="top"&&Re||(De.backgroundColorRGB&&(ne=50331648,ee=De.backgroundColorRGB.rgba>>8&16777215,le=De.backgroundColorRGB),De.foregroundColorRGB&&(W=50331648,Q=De.foregroundColorRGB.rgba>>8&16777215,Ce=De.foregroundColorRGB),Re=De.options.layer==="top")}),!Re&&se&&(le=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,ee=le.rgba>>8&16777215,ne=50331648,Re=!0,_.selectionForeground&&(W=50331648,Q=_.selectionForeground.rgba>>8&16777215,Ce=_.selectionForeground)),Re&&G.push("xterm-decoration-top");let Oe;switch(ne){case 16777216:case 33554432:Oe=_.ansi[ee],G.push(`xterm-bg-${ee}`);break;case 50331648:Oe=cn.toColor(ee>>16,ee>>8&255,ee&255),this._addStyle(S,`background-color:#${n1((ee>>>0).toString(16),"0",6)}`);break;case 0:default:Se?(Oe=_.foreground,G.push("xterm-bg-257")):Oe=_.background}switch(le||$.isDim()&&(le=Mt.multiplyOpacity(Oe,.5)),W){case 16777216:case 33554432:$.isBold()&&Q<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Q+=8),this._applyMinimumContrast(S,Oe,_.ansi[Q],$,le,void 0)||G.push(`xterm-fg-${Q}`);break;case 50331648:let De=cn.toColor(Q>>16&255,Q>>8&255,Q&255);this._applyMinimumContrast(S,Oe,De,$,le,Ce)||this._addStyle(S,`color:#${n1(Q.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(S,Oe,_.foreground,$,le,Ce)||Se&&G.push("xterm-fg-257")}G.length&&(S.className=G.join(" "),G.length=0),!B&&!D&&!K&&N?w++:S.textContent=k,J!==this.defaultSpacing&&(S.style.letterSpacing=`${J}px`),g.push(S),R=F}return S&&w&&(S.textContent=k),g}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||o5(r.getCode()))return!1;let l=this._getContrastCache(r),d;if(!i&&!a&&(d=l.getColor(t.rgba,n.rgba)),d===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);d=Mt.ensureContrastRatio(i||t,a||n,f),l.setColor((i||t).rgba,(a||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]}};n_=Kt([je(1,Ck),je(2,qn),je(3,Yi),je(4,Ra),je(5,Hc),je(6,Ko)],n_);function n1(e,t,n){for(;e.length<n;)e=t+e;return e}var c5=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),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 l=this._measure(e,0);return l>0&&(this._flat[r]=l),l}let i=e;t&&(i+="B"),n&&(i+="I");let a=this._holey.get(i);if(a===void 0){let l=0;t&&(l|=1),n&&(l|=2),a=this._measure(e,l),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},u5=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 i=e.buffers.active.ydisp,a=t[1]-i,l=n[1]-i,d=Math.max(a,0),f=Math.min(l,e.rows-1);if(d>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=l,this.viewportCappedStartRow=d,this.viewportCappedEndRow=f,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 d5(){return new u5}var Ip="xterm-dom-renderer-owner-",Tr="xterm-rows",yd="xterm-fg-",r1="xterm-bg-",Xl="xterm-focus",vd="xterm-selection",h5=1,r_=class extends et{constructor(e,t,n,r,i,a,l,d,f,h,p,g,x,_){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=l,this._charSizeService=f,this._optionsService=h,this._bufferService=p,this._coreService=g,this._coreBrowserService=x,this._themeService=_,this._terminalClass=h5++,this._rowElements=[],this._selectionRenderModel=d5(),this.onRequestRedraw=this._register(new we).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Tr),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(vd),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=l5(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(v=>this._injectCss(v))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(n_,document),this._element.classList.add(Ip+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(v=>this._handleLinkHover(v))),this._register(this._linkifier2.onHideLinkUnderline(v=>this._handleLinkLeave(v))),this._register(Bt(()=>{this._element.classList.remove(Ip+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new c5(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} .${Tr} 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} .${Tr} { 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} .${Tr} .xterm-dim { color: ${Mt.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}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Tr}.${Xl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Tr}.${Xl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Tr}.${Xl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Tr} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${vd} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${vd} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${vd} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,l]of e.ansi.entries())t+=`${this._terminalSelector} .${yd}${a} { color: ${l.css}; }${this._terminalSelector} .${yd}${a}.xterm-dim { color: ${Mt.multiplyOpacity(l,.5).css}; }${this._terminalSelector} .${r1}${a} { background-color: ${l.css}; }`;t+=`${this._terminalSelector} .${yd}257 { color: ${Mt.opaque(e.background).css}; }${this._terminalSelector} .${yd}257.xterm-dim { color: ${Mt.multiplyOpacity(Mt.opaque(e.background),.5).css}; }${this._terminalSelector} .${r1}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(Xl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Xl),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,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,l=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let f=e[0]>t[0];d.appendChild(this._createSelectionElement(a,f?t[0]:e[0],f?e[0]:t[0],l-a+1))}else{let f=r===a?e[0]:0,h=a===i?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(a,f,h));let p=l-a-1;if(d.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,p)),a!==l){let g=i===l?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(l,0,g))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,l=this.dimensions.css.cell.width*(n-t);return a+l>this.dimensions.css.canvas.width&&(l=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${l}px`,i}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,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,l=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let h=f+n.ydisp,p=this._rowElements[f],g=n.lines.get(h);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,h,h===r,l,d,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ip}${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,i,a){n<0&&(e=0),r<0&&(t=0);let l=this._bufferService.rows-1;n=Math.max(Math.min(n,l),0),r=Math.max(Math.min(r,l),0),i=Math.min(i,this._bufferService.cols);let d=this._bufferService.buffer,f=d.ybase+d.y,h=Math.min(d.x,i-1),p=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,x=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=n;_<=r;++_){let v=_+d.ydisp,S=this._rowElements[_],w=d.lines.get(v);if(!S||!w)break;S.replaceChildren(...this._rowFactory.createRow(w,v,v===f,g,x,h,p,this.dimensions.css.cell.width,this._widthCache,a?_===n?e:0:-1,a?(_===r?t:i)-1:-1))}}};r_=Kt([je(7,ox),je(8,Rh),je(9,qn),je(10,Gn),je(11,Ra),je(12,Yi),je(13,Ko)],r_);var i_=class extends et{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new we),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new m5(this._optionsService))}catch{this._measureStrategy=this._register(new f5(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())}};i_=Kt([je(2,qn)],i_);var Uk=class extends et{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)}},f5=class extends Uk{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}},m5=class extends Uk{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}},p5=class extends et{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 g5(this._window)),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new we),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Mn.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}},g5=class extends et{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Uo),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Bt(()=>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)}},_5=class extends et{constructor(){super(),this.linkProviders=[],this._register(Bt(()=>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 px(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue("padding-left")),l=parseInt(i.getPropertyValue("padding-top"));return[t.clientX-r.left-a,t.clientY-r.top-l]}function x5(e,t,n,r,i,a,l,d,f){if(!a)return;let h=px(e,t,n);if(h)return h[0]=Math.ceil((h[0]+(f?l/2:0))/l),h[1]=Math.ceil(h[1]/d),h[0]=Math.min(Math.max(h[0],1),r+(f?1:0)),h[1]=Math.min(Math.max(h[1],1),i),h}var s_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return x5(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=px(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])}}};s_=Kt([je(0,Xi),je(1,Rh)],s_);var y5=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=[]}},Vk={};TL(Vk,{getSafariVersion:()=>b5,isChromeOS:()=>Kk,isFirefox:()=>Wk,isIpad:()=>S5,isIphone:()=>w5,isLegacyEdge:()=>v5,isLinux:()=>gx,isMac:()=>eh,isNode:()=>Mh,isSafari:()=>Gk,isWindows:()=>qk});var Mh=typeof process<"u"&&"title"in process,Fc=Mh?"node":navigator.userAgent,Uc=Mh?"node":navigator.platform,Wk=Fc.includes("Firefox"),v5=Fc.includes("Edge"),Gk=/^((?!chrome|android).)*safari/i.test(Fc);function b5(){if(!Gk)return 0;let e=Fc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var eh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Uc),S5=Uc==="iPad",w5=Uc==="iPhone",qk=["Windows","Win16","Win32","WinCE"].includes(Uc),gx=Uc.indexOf("Linux")>=0,Kk=/\bCrOS\b/.test(Fc),Yk=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(),i=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),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},C5=class extends Yk{_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())}}},k5=class extends Yk{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},th=!Mh&&"requestIdleCallback"in window?k5:C5,E5=class{constructor(){this._queue=new th}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},a_=class extends et{constructor(e,t,n,r,i,a,l,d,f){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=d,this._renderer=this._register(new Uo),this._pausedResizeTask=new E5,this._observerDisposable=this._register(new Uo),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 we),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new we),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new we),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new y5((h,p)=>this._renderRows(h,p),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new N5(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Bt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(l.onResize(()=>this._fullRefresh())),this._register(l.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(l.cols,l.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(l.buffer.y,l.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,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=Bt(()=>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()}};a_=Kt([je(2,qn),je(3,Rh),je(4,Ra),je(5,Hc),je(6,Gn),je(7,Yi),je(8,Ko)],a_);var N5=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 j5(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return D5(i,a,e,t,n,r)+Oh(a,t,n,r)+L5(i,a,e,t,n,r);let l;if(a===t)return l=i>e?"D":"C",Ec(Math.abs(i-e),kc(l,r));l=a>t?"D":"C";let d=Math.abs(a-t),f=A5(a>t?e:i,n)+(d-1)*n.cols+1+T5(a>t?i:e);return Ec(f,kc(l,r))}function T5(e,t){return e-1}function A5(e,t){return t.cols-e}function D5(e,t,n,r,i,a){return Oh(t,r,i,a).length===0?"":Ec(Qk(e,t,e,t-Ta(t,i),!1,i).length,kc("D",a))}function Oh(e,t,n,r){let i=e-Ta(e,n),a=t-Ta(t,n),l=Math.abs(i-a)-R5(e,t,n);return Ec(l,kc(Xk(e,t),r))}function L5(e,t,n,r,i,a){let l;Oh(t,r,i,a).length>0?l=r-Ta(r,i):l=t;let d=r,f=M5(e,t,n,r,i,a);return Ec(Qk(e,l,n,d,f==="C",i).length,kc(f,a))}function R5(e,t,n){var l;let r=0,i=e-Ta(e,n),a=t-Ta(t,n);for(let d=0;d<Math.abs(i-a);d++){let f=Xk(e,t)==="A"?-1:1;(l=n.buffer.lines.get(i+f*d))!=null&&l.isWrapped&&r++}return r}function Ta(e,t){let n=0,r=t.buffer.lines.get(e),i=r==null?void 0:r.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r==null?void 0:r.isWrapped;return n}function M5(e,t,n,r,i,a){let l;return Oh(n,r,i,a).length>0?l=r-Ta(r,i):l=t,e<n&&l<=r||e>=n&&l<r?"C":"D"}function Xk(e,t){return e>t?"A":"B"}function Qk(e,t,n,r,i,a){let l=e,d=t,f="";for(;(l!==n||d!==r)&&d>=0&&d<a.buffer.lines.length;)l+=i?1:-1,i&&l>a.cols-1?(f+=a.buffer.translateBufferLineToString(d,!1,e,l),l=0,e=0,d++):!i&&l<0&&(f+=a.buffer.translateBufferLineToString(d,!1,0,e+1),l=a.cols-1,e=l,d--);return f+a.buffer.translateBufferLineToString(d,!1,e,l)}function kc(e,t){let n=t?"O":"[";return _e.ESC+n+e}function Ec(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var O5=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 i1(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 Pp=50,I5=15,P5=50,B5=500,z5=" ",$5=new RegExp(z5,"g"),o_=class extends et{constructor(e,t,n,r,i,a,l,d,f){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=l,this._renderService=d,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Pr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new we),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new we),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new O5(this._bufferService),this._activeSelectionMode=0,this._register(Bt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.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 i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let l=e[1];l<=t[1];l++){let d=n.translateBufferLineToString(l,!0,i,a);r.push(d)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let a=e[1]+1;a<=t[1]-1;a++){let l=n.lines.get(a),d=n.translateBufferLineToString(a,!0);l!=null&&l.isWrapped?r[r.length-1]+=d:r.push(d)}if(e[1]!==t[1]){let a=n.lines.get(t[1]),l=n.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?r[r.length-1]+=l:r.push(l)}}return r.map(i=>i.replace($5," ")).join(qk?`\r
80
+ `:`
81
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),gx&&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 i,a;let n=(a=(i=this._linkifier.currentLink)==null?void 0:i.link)==null?void 0:a.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=i1(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=px(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,-Pp),Pp),t/=Pp,t/Math.abs(t)+Math.round(t*(I5-1)))}shouldForceSelection(e){return eh?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(),P5)}_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&&!(eh&&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<B5&&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=j5(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 i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-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 i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let l=i.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(a,e[0]),f=d,h=e[0]-d,p=0,g=0,x=0,_=0;if(l.charAt(d)===" "){for(;d>0&&l.charAt(d-1)===" ";)d--;for(;f<l.length&&l.charAt(f+1)===" ";)f++}else{let w=e[0],k=e[0];a.getWidth(w)===0&&(p++,w--),a.getWidth(k)===2&&(g++,k++);let j=a.getString(k).length;for(j>1&&(_+=j-1,f+=j-1);w>0&&d>0&&!this._isCharWordSeparator(a.loadCell(w-1,this._workCell));){a.loadCell(w-1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===0?(p++,w--):T>1&&(x+=T-1,d-=T-1),d--,w--}for(;k<a.length&&f+1<l.length&&!this._isCharWordSeparator(a.loadCell(k+1,this._workCell));){a.loadCell(k+1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===2?(g++,k++):T>1&&(_+=T-1,f+=T-1),f++,k++}}f++;let v=d+h-p+x,S=Math.min(this._bufferService.cols,f-d+p+g-x-_);if(!(!t&&l.slice(d,f).trim()==="")){if(n&&v===0&&a.getCodePoint(0)!==32){let w=i.lines.get(e[1]-1);if(w&&a.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let j=this._bufferService.cols-k.start;v-=j,S+=j}}}if(r&&v+S===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let w=i.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(S+=k.length)}}return{start:v,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=i1(n,this._bufferService.cols)}};o_=Kt([je(3,Gn),je(4,Ra),je(5,lx),je(6,qn),je(7,Xi),je(8,Yi)],o_);var s1=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={}}},a1=class{constructor(){this._color=new s1,this._css=new s1}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()}},hn=Object.freeze((()=>{let e=[Ht.toColor("#2e3436"),Ht.toColor("#cc0000"),Ht.toColor("#4e9a06"),Ht.toColor("#c4a000"),Ht.toColor("#3465a4"),Ht.toColor("#75507b"),Ht.toColor("#06989a"),Ht.toColor("#d3d7cf"),Ht.toColor("#555753"),Ht.toColor("#ef2929"),Ht.toColor("#8ae234"),Ht.toColor("#fce94f"),Ht.toColor("#729fcf"),Ht.toColor("#ad7fa8"),Ht.toColor("#34e2e2"),Ht.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:cn.toCss(r,i,a),rgba:cn.toRgba(r,i,a)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:cn.toCss(r,r,r),rgba:cn.toRgba(r,r,r)})}return e})()),pa=Ht.toColor("#ffffff"),hc=Ht.toColor("#000000"),o1=Ht.toColor("#ffffff"),l1=hc,Ql={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},H5=pa,l_=class extends et{constructor(e){super(),this._optionsService=e,this._contrastCache=new a1,this._halfContrastCache=new a1,this._onChangeColors=this._register(new we),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:pa,background:hc,cursor:o1,cursorAccent:l1,selectionForeground:void 0,selectionBackgroundTransparent:Ql,selectionBackgroundOpaque:Mt.blend(hc,Ql),selectionInactiveBackgroundTransparent:Ql,selectionInactiveBackgroundOpaque:Mt.blend(hc,Ql),scrollbarSliderBackground:Mt.opacity(pa,.2),scrollbarSliderHoverBackground:Mt.opacity(pa,.4),scrollbarSliderActiveBackground:Mt.opacity(pa,.5),overviewRulerBorder:pa,ansi:hn.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=kt(e.foreground,pa),t.background=kt(e.background,hc),t.cursor=Mt.blend(t.background,kt(e.cursor,o1)),t.cursorAccent=Mt.blend(t.background,kt(e.cursorAccent,l1)),t.selectionBackgroundTransparent=kt(e.selectionBackground,Ql),t.selectionBackgroundOpaque=Mt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=kt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Mt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?kt(e.selectionForeground,t1):void 0,t.selectionForeground===t1&&(t.selectionForeground=void 0),Mt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Mt.opacity(t.selectionBackgroundTransparent,.3)),Mt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Mt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=kt(e.scrollbarSliderBackground,Mt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=kt(e.scrollbarSliderHoverBackground,Mt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=kt(e.scrollbarSliderActiveBackground,Mt.opacity(t.foreground,.5)),t.overviewRulerBorder=kt(e.overviewRulerBorder,H5),t.ansi=hn.slice(),t.ansi[0]=kt(e.black,hn[0]),t.ansi[1]=kt(e.red,hn[1]),t.ansi[2]=kt(e.green,hn[2]),t.ansi[3]=kt(e.yellow,hn[3]),t.ansi[4]=kt(e.blue,hn[4]),t.ansi[5]=kt(e.magenta,hn[5]),t.ansi[6]=kt(e.cyan,hn[6]),t.ansi[7]=kt(e.white,hn[7]),t.ansi[8]=kt(e.brightBlack,hn[8]),t.ansi[9]=kt(e.brightRed,hn[9]),t.ansi[10]=kt(e.brightGreen,hn[10]),t.ansi[11]=kt(e.brightYellow,hn[11]),t.ansi[12]=kt(e.brightBlue,hn[12]),t.ansi[13]=kt(e.brightMagenta,hn[13]),t.ansi[14]=kt(e.brightCyan,hn[14]),t.ansi[15]=kt(e.brightWhite,hn[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]=kt(e.extendedAnsi[r],hn[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()}}};l_=Kt([je(0,qn)],l_);function kt(e,t){if(e!==void 0)try{return Ht.toColor(e)}catch{}return t}var F5=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)}},U5=class{constructor(){this._services=new F5,this._services.set(ox,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=IL(e).sort((a,l)=>a.index-l.index),r=[];for(let a of n){let l=this._services.get(a.id);if(!l)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);r.push(l)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},V5={trace:0,debug:1,info:2,warn:3,error:4,off:5},W5="xterm.js: ",c_=class extends et{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=V5[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?"":W5)+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)}};c_=Kt([je(0,qn)],c_);var c1=class extends et{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new we),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new we),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new we),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 i=t-1;i>=0;i--)this.set(e+i+n,this.get(e+i));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}},Je=3,ln=Object.freeze(new $c),bd=0,Bp=2,fc=class Jk{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Je);let i=n||Pr.fromCharData([0,_k,1,0]);for(let a=0;a<t;++a)this.setCell(a,i);this.length=t}get(t){let n=this._data[t*Je+0],r=n&2097151;return[this._data[t*Je+1],n&2097152?this._combined[t]:r?Ts(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Je+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Je+0]=t|2097152|n[2]<<22):this._data[t*Je+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Je+0]>>22}hasWidth(t){return this._data[t*Je+0]&12582912}getFg(t){return this._data[t*Je+1]}getBg(t){return this._data[t*Je+2]}hasContent(t){return this._data[t*Je+0]&4194303}getCodePoint(t){let n=this._data[t*Je+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Je+0]&2097152}getString(t){let n=this._data[t*Je+0];return n&2097152?this._combined[t]:n&2097151?Ts(n&2097151):""}isProtected(t){return this._data[t*Je+2]&536870912}loadCell(t,n){return bd=t*Je,n.content=this._data[bd+0],n.fg=this._data[bd+1],n.bg=this._data[bd+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*Je+0]=n.content,this._data[t*Je+1]=n.fg,this._data[t*Je+2]=n.bg}setCellFromCodepoint(t,n,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Je+0]=n|r<<22,this._data[t*Je+1]=i.fg,this._data[t*Je+2]=i.bg}addCodepointToCell(t,n,r){let i=this._data[t*Je+0];i&2097152?this._combined[t]+=Ts(n):i&2097151?(this._combined[t]=Ts(i&2097151)+Ts(n),i&=-2097152,i|=2097152):i=n|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*Je+0]=i}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 i=new Pr;for(let a=this.length-t-n-1;a>=0;--a)this.setCell(t+n+a,this.loadCell(t+a,i));for(let a=0;a<n;++a)this.setCell(t+a,r)}else for(let i=t;i<this.length;++i)this.setCell(i,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 i=new Pr;for(let a=0;a<this.length-t-n;++a)this.setCell(t+a,this.loadCell(t+n+a,i));for(let a=this.length-n;a<this.length;++a)this.setCell(a,r)}else for(let i=t;i<this.length;++i)this.setCell(i,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,i=!1){if(i){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*Bp<this._data.buffer.byteLength;let r=t*Je;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,n)}else{this._data=this._data.subarray(0,r);let i=Object.keys(this._combined);for(let l=0;l<i.length;l++){let d=parseInt(i[l],10);d>=t&&delete this._combined[d]}let a=Object.keys(this._extendedAttrs);for(let l=0;l<a.length;l++){let d=parseInt(a[l],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,r*4*Bp<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Bp<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 Jk(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*Je+0]&4194303)return t+(this._data[t*Je+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Je+0]&4194303||this._data[t*Je+2]&50331648)return t+(this._data[t*Je+0]>>22);return 0}copyCellsFrom(t,n,r,i,a){let l=t._data;if(a)for(let f=i-1;f>=0;f--){for(let h=0;h<Je;h++)this._data[(r+f)*Je+h]=l[(n+f)*Je+h];l[(n+f)*Je+2]&268435456&&(this._extendedAttrs[r+f]=t._extendedAttrs[n+f])}else for(let f=0;f<i;f++){for(let h=0;h<Je;h++)this._data[(r+f)*Je+h]=l[(n+f)*Je+h];l[(n+f)*Je+2]&268435456&&(this._extendedAttrs[r+f]=t._extendedAttrs[n+f])}let d=Object.keys(t._combined);for(let f=0;f<d.length;f++){let h=parseInt(d[f],10);h>=n&&(this._combined[h-n+r]=t._combined[h])}}translateToString(t,n,r,i){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let a="";for(;n<r;){let l=this._data[n*Je+0],d=l&2097151,f=l&2097152?this._combined[n]:d?Ts(d):Ms;if(a+=f,i)for(let h=0;h<f.length;++h)i.push(n);n+=l>>22||1}return i&&i.push(n),a}};function G5(e,t,n,r,i,a){let l=[];for(let d=0;d<e.length-1;d++){let f=d,h=e.get(++f);if(!h.isWrapped)continue;let p=[e.get(d)];for(;f<e.length&&h.isWrapped;)p.push(h),h=e.get(++f);if(!a&&r>=d&&r<f){d+=p.length-1;continue}let g=0,x=Nc(p,g,t),_=1,v=0;for(;_<p.length;){let w=Nc(p,_,t),k=w-v,j=n-x,T=Math.min(k,j);p[g].copyCellsFrom(p[_],v,x,T,!1),x+=T,x===n&&(g++,x=0),v+=T,v===w&&(_++,v=0),x===0&&g!==0&&p[g-1].getWidth(n-1)===2&&(p[g].copyCellsFrom(p[g-1],n-1,x++,1,!1),p[g-1].setCell(n-1,i))}p[g].replaceCells(x,n,i);let S=0;for(let w=p.length-1;w>0&&(w>g||p[w].getTrimmedLength()===0);w--)S++;S>0&&(l.push(d+p.length-S),l.push(S)),d+=p.length-1}return l}function q5(e,t){let n=[],r=0,i=t[r],a=0;for(let l=0;l<e.length;l++)if(i===l){let d=t[++r];e.onDeleteEmitter.fire({index:l-a,amount:d}),l+=d-1,a+=d,i=t[++r]}else n.push(l);return{layout:n,countRemoved:a}}function K5(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 Y5(e,t,n){let r=[],i=e.map((f,h)=>Nc(e,h,t)).reduce((f,h)=>f+h),a=0,l=0,d=0;for(;d<i;){if(i-d<n){r.push(i-d);break}a+=n;let f=Nc(e,l,t);a>f&&(a-=f,l++);let h=e[l].getWidth(a-1)===2;h&&a--;let p=h?n-1:n;r.push(p),d+=p}return r}function Nc(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,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var Zk=class e2{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e2._nextId++,this._onDispose=this.register(new we),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ja(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Zk._nextId=1;var X5=Zk,_n={},ga=_n.B;_n[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:"≥","{":"π","|":"≠","}":"£","~":"·"};_n.A={"#":"£"};_n.B=void 0;_n[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};_n.C=_n[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_n.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};_n.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};_n.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};_n.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};_n.E=_n[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};_n.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};_n.H=_n[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_n["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var u1=4294967295,d1=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=ln.clone(),this.savedCharset=ga,this.markers=[],this._nullCell=Pr.fromCharData([0,_k,1,0]),this._whitespaceCell=Pr.fromCharData([0,Ms,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new th,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c1(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 Qd),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 Qd),this._whitespaceCell}getBlankLine(e,t){return new fc(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>u1?u1:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ln);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 c1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(ln),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let l=0;l<this.lines.length;l++)r+=+this.lines.get(l).resize(e,n);let a=0;if(this._rows<t)for(let l=this._rows;l<t;l++)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 fc(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new fc(e,n)));else for(let l=this._rows;l>t;l--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let l=this.lines.length-i;l>0&&(this.lines.trimStart(l),this.ybase=Math.max(this.ybase-l,0),this.ydisp=Math.max(this.ydisp-l,0),this.savedY=Math.max(this.savedY-l,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),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 a=0;a<this.lines.length;a++)r+=+this.lines.get(a).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=G5(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ln),n);if(r.length>0){let i=q5(this.lines,r);K5(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(ln),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new fc(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(ln),i=[],a=0;for(let l=this.lines.length-1;l>=0;l--){let d=this.lines.get(l);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let f=[d];for(;d.isWrapped&&l>0;)d=this.lines.get(--l),f.unshift(d);if(!n){let T=this.ybase+this.y;if(T>=l&&T<l+f.length)continue}let h=f[f.length-1].getTrimmedLength(),p=Y5(f,this._cols,e),g=p.length-f.length,x;this.ybase===0&&this.y!==this.lines.length-1?x=Math.max(0,this.y-this.lines.maxLength+g):x=Math.max(0,this.lines.length-this.lines.maxLength+g);let _=[];for(let T=0;T<g;T++){let A=this.getBlankLine(ln,!0);_.push(A)}_.length>0&&(i.push({start:l+f.length+a,newLines:_}),a+=_.length),f.push(..._);let v=p.length-1,S=p[v];S===0&&(v--,S=p[v]);let w=f.length-g-1,k=h;for(;w>=0;){let T=Math.min(k,S);if(f[v]===void 0)break;if(f[v].copyCellsFrom(f[w],k-T,S-T,T,!0),S-=T,S===0&&(v--,S=p[v]),k-=T,k===0){w--;let A=Math.max(w,0);k=Nc(f,A,this._cols)}}for(let T=0;T<f.length;T++)p[T]<e&&f[T].setCell(p[T],r);let j=g-x;for(;j-- >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+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+g,this.ybase+t-1)}if(i.length>0){let l=[],d=[];for(let S=0;S<this.lines.length;S++)d.push(this.lines.get(S));let f=this.lines.length,h=f-1,p=0,g=i[p];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let x=0;for(let S=Math.min(this.lines.maxLength-1,f+a-1);S>=0;S--)if(g&&g.start>h+x){for(let w=g.newLines.length-1;w>=0;w--)this.lines.set(S--,g.newLines[w]);S++,l.push({index:h+1,amount:g.newLines.length}),x+=g.newLines.length,g=i[++p]}else this.lines.set(S,d[h--]);let _=0;for(let S=l.length-1;S>=0;S--)l[S].index+=_,this.lines.onInsertEmitter.fire(l[S]),_+=l[S].amount;let v=Math.max(0,f+a-this.lines.maxLength);v>0&&this.lines.onTrimEmitter.fire(v)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.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 X5(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)}},Q5=class extends et{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new we),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 d1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new d1(!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)}},t2=2,n2=1,u_=class extends et{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,t2),this.rows=Math.max(e.rawOptions.rows||0,n2),this.buffers=this._register(new Q5(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 i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let l=n.lines.isFull;a===n.lines.length-1?l?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),l?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let l=a-i+1;n.lines.shiftElements(i+1,l-1,-1),n.lines.set(a,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))}};u_=Kt([je(0,qn)],u_);var No={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:eh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},J5=["normal","bold","100","200","300","400","500","600","700","800","900"],Z5=class extends et{constructor(e){super(),this._onOptionChange=this._register(new we),this.onOptionChange=this._onOptionChange.event;let t={...No};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(Bt(()=>{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 No))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in No))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=No[e]),!e3(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=No[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=J5.includes(t)?t:No[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 e3(e){return e==="block"||e==="underline"||e==="bar"}function mc(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]&&mc(e[r],t-1);return n}var h1=Object.freeze({insertMode:!1}),f1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),d_=class extends et{constructor(t,n,r){super(),this._bufferService=t,this._logService=n,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new we),this.onData=this._onData.event,this._onUserInput=this._register(new we),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new we),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=mc(h1),this.decPrivateModes=mc(f1)}reset(){this.modes=mc(h1),this.decPrivateModes=mc(f1)}triggerDataEvent(t,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),n&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(i=>i.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(n=>n.charCodeAt(0))),this._onBinary.fire(t))}};d_=Kt([je(0,Gn),je(1,Sk),je(2,qn)],d_);var m1={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 zp(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 $p=String.fromCharCode,p1={DEFAULT:e=>{let t=[zp(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${$p(t[0])}${$p(t[1])}${$p(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${zp(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${zp(e,!0)};${e.x};${e.y}${t}`}},h_=class extends et{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 we),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(m1))this.addProtocol(r,m1[r]);for(let r of Object.keys(p1))this.addEncoding(r,p1[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,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_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)}};h_=Kt([je(0,Gn),je(1,Ra),je(2,qn)],h_);var Hp=[[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]],t3=[[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]],fn;function n3(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var r3=class{constructor(){if(this.version="6",!fn){fn=new Uint8Array(65536),fn.fill(1),fn[0]=0,fn.fill(0,1,32),fn.fill(0,127,160),fn.fill(2,4352,4448),fn[9001]=2,fn[9002]=2,fn.fill(2,11904,42192),fn[12351]=1,fn.fill(2,44032,55204),fn.fill(2,63744,64256),fn.fill(2,65040,65050),fn.fill(2,65072,65136),fn.fill(2,65280,65377),fn.fill(2,65504,65511);for(let e=0;e<Hp.length;++e)fn.fill(0,Hp[e][0],Hp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?fn[e]:n3(e,t3)?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 i=va.extractWidth(t);i===0?r=!1:i>n&&(n=i)}return va.createPropertyValue(0,n,r)}},va=class Vd{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new we,this.onChange=this._onChange.event;let t=new r3;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,i=t.length;for(let a=0;a<i;++a){let l=t.charCodeAt(a);if(55296<=l&&l<=56319){if(++a>=i)return n+this.wcwidth(l);let h=t.charCodeAt(a);56320<=h&&h<=57343?l=(l-55296)*1024+h-56320+65536:n+=this.wcwidth(h)}let d=this.charProperties(l,r),f=Vd.extractWidth(d);Vd.extractShouldJoin(d)&&(f-=Vd.extractWidth(r)),n+=f,r=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},i3=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 g1(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 Jl=2147483647,s3=256,r2=class f_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>s3)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 f_;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let i=t[r];if(Array.isArray(i))for(let a=0;a<i.length;++a)n.addSubParam(i[a]);else n.addParam(i)}return n}clone(){let t=new f_(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,i=this._subParamsIdx[n]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}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>Jl?Jl: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>Jl?Jl: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,i=this._subParamsIdx[n]&255;i-r>0&&(t[n]=this._subParams.slice(r,i))}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,i=r[n-1];r[n-1]=~i?Math.min(i*10+t,Jl):t}},Zl=[],a3=class{constructor(){this._state=0,this._active=Zl,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=Zl}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=Zl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Zl,!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",Lh(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,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&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=Zl,this._id=-1,this._state=0}}},mr=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+=Lh(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}},ec=[],o3=class{constructor(){this._handlers=Object.create(null),this._active=ec,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ec}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=ec,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ec,!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",Lh(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,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&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=ec,this._ident=0}},pc=new r2;pc.addParam(0);var _1=class{constructor(e){this._handler=e,this._data="",this._params=pc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():pc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Lh(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=pc,this._data="",this._hitLimit=!1,n));return this._params=pc,this._data="",this._hitLimit=!1,t}},l3=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 i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},Lr=160,c3=(function(){let e=new l3(4095),t=Array.apply(null,Array(256)).map((d,f)=>f),n=(d,f)=>t.slice(d,f),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),l;e.setDefault(1,0),e.addMany(r,0,2,0);for(l in a)e.addMany([24,26,153,154],l,3,0),e.addMany(n(128,144),l,3,0),e.addMany(n(144,152),l,3,0),e.add(156,l,0,0),e.add(27,l,11,1),e.add(157,l,4,8),e.addMany([152,158,159],l,0,7),e.add(155,l,11,3),e.add(144,l,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,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(i,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(i,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(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,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(i,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(i,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(Lr,0,2,0),e.add(Lr,8,5,8),e.add(Lr,6,0,6),e.add(Lr,11,0,11),e.add(Lr,13,13,13),e})(),u3=class extends et{constructor(e=c3){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 r2,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(Bt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new a3),this._dcsParser=this._register(new o3),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 i=0;i<e.intermediates.length;++i){let a=e.intermediates.charCodeAt(i);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=a}}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 i=r.indexOf(t);i!==-1&&r.splice(i,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 i=r.indexOf(t);i!==-1&&r.splice(i,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,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,l;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=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,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&f>-1){for(;f>=0&&(l=d[f](this._params),l!==!0);f--)if(l instanceof Promise)return this._parseStack.handlerPos=f,l}this._parseStack.handlers=[];break;case 4:if(n===!1&&f>-1){for(;f>=0&&(l=d[f](),l!==!0);f--)if(l instanceof Promise)return this._parseStack.handlerPos=f,l}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],l=this._dcsParser.unhook(r!==24&&r!==26,n),l)return l;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],l=this._oscParser.end(r!==24&&r!==26,n),l)return l;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=a;d<t;++d){switch(r=e[d],i=this._transitions.table[this.currentState<<8|(r<160?r:Lr)],i>>4){case 2:for(let x=d+1;;++x){if(x>=t||(r=e[x])<32||r>126&&r<Lr){this._printHandler(e,d,x),d=x-1;break}if(++x>=t||(r=e[x])<32||r>126&&r<Lr){this._printHandler(e,d,x),d=x-1;break}if(++x>=t||(r=e[x])<32||r>126&&r<Lr){this._printHandler(e,d,x),d=x-1;break}if(++x>=t||(r=e[x])<32||r>126&&r<Lr){this._printHandler(e,d,x),d=x-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 f=this._csiHandlers[this._collect<<8|r],h=f?f.length-1:-1;for(;h>=0&&(l=f[h](this._params),l!==!0);h--)if(l instanceof Promise)return this._preserveStack(3,f,h,i,d),l;h<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 p=this._escHandlers[this._collect<<8|r],g=p?p.length-1:-1;for(;g>=0&&(l=p[g](),l!==!0);g--)if(l instanceof Promise)return this._preserveStack(4,p,g,i,d),l;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 x=d+1;;++x)if(x>=t||(r=e[x])===24||r===26||r===27||r>127&&r<Lr){this._dcsParser.put(e,d,x),d=x-1;break}break;case 14:if(l=this._dcsParser.unhook(r!==24&&r!==26),l)return this._preserveStack(6,[],0,i,d),l;r===27&&(i|=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 x=d+1;;x++)if(x>=t||(r=e[x])<32||r>127&&r<Lr){this._oscParser.put(e,d,x),d=x-1;break}break;case 6:if(l=this._oscParser.end(r!==24&&r!==26),l)return this._preserveStack(5,[],0,i,d),l;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},d3=/^([\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})$/,h3=/^[\da-f]+$/;function x1(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=d3.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),h3.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let a=parseInt(t.slice(n*i,n*i+n),16);r[i]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return r}}function Fp(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 f3(e,t=16){let[n,r,i]=e;return`rgb:${Fp(n,t)}/${Fp(r,t)}/${Fp(i,t)}`}var m3={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ks=131072,y1=10;function v1(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 b1=5e3,S1=0,p3=class extends et{constructor(e,t,n,r,i,a,l,d,f=new u3){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=l,this._unicodeService=d,this._parser=f,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ML,this._utf8Decoder=new OL,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ln.clone(),this._eraseAttrDataInternal=ln.clone(),this._onRequestBell=this._register(new we),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new we),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new we),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new we),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new we),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new we),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new we),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new we),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new we),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 m_(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,p)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:p.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,p,g)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:p,data:g})}),this._parser.setDcsHandlerFallback((h,p,g)=>{p==="HOOK"&&(g=g.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:p,payload:g})}),this._parser.setPrintHandler((h,p,g)=>this.print(h,p,g)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(_e.BEL,()=>this.bell()),this._parser.setExecuteHandler(_e.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(_e.BS,()=>this.backspace()),this._parser.setExecuteHandler(_e.HT,()=>this.tab()),this._parser.setExecuteHandler(_e.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(_e.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Fd.IND,()=>this.index()),this._parser.setExecuteHandler(Fd.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Fd.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new mr(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new mr(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new mr(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new mr(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new mr(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new mr(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new mr(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new mr(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new mr(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new mr(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new mr(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new mr(h=>this.restoreCursorColor(h))),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 h in _n)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new _1((h,p)=>this.requestStatusString(h,p)))}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"),b1))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${b1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,l=this._parseStack.paused;if(l){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ks&&(a=this._parseStack.position+ks)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ks&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ks))),l||this._dirtyRowTracker.clearRange(),e.length>ks)for(let h=a;h<e.length;h+=ks){let p=h+ks<e.length?h+ks:e.length,g=typeof e=="string"?this._stringDecoder.decode(e.substring(h,p),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,p),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,g))return this._preserveStack(r,i,g,h),this._logSlowResolvingAsync(n),n}else if(!l){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,h))return this._preserveStack(r,i,h,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),f=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);f<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(f,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,l=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,f=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,p=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,p);let x=this._parser.precedingJoinState;for(let _=t;_<n;++_){if(r=e[_],r<127&&a){let k=a[String.fromCharCode(r)];k&&(r=k.charCodeAt(0))}let v=this._unicodeService.charProperties(r,x);i=va.extractWidth(v);let S=va.extractShouldJoin(v),w=S?va.extractWidth(x):0;if(x=v,l&&this._onA11yChar.fire(Ts(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-w>d){if(f){let k=g,j=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),w>0&&g instanceof fc&&g.copyCellsFrom(k,j,0,w,!1);j<d;)k.setCellFromCodepoint(j++,0,1,p)}else if(this._activeBuffer.x=d-1,i===2)continue}if(S&&this._activeBuffer.x){let k=g.getWidth(this._activeBuffer.x-1)?1:2;g.addCodepointToCell(this._activeBuffer.x-k,r,i);for(let j=i-w;--j>=0;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,p);continue}if(h&&(g.insertCells(this._activeBuffer.x,i-w,this._activeBuffer.getNullCell(p)),g.getWidth(d-1)===2&&g.setCellFromCodepoint(d-1,0,1,p)),g.setCellFromCodepoint(this._activeBuffer.x++,r,i,p),i>0)for(;--i;)g.setCellFromCodepoint(this._activeBuffer.x++,0,0,p)}this._parser.precedingJoinState=x,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,p),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>v1(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new _1(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new mr(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,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.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 i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-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(ln));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=va.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),l=new Uint32Array(a.length*n),d=0;for(let h=0;h<a.length;){let p=a.codePointAt(h)||0;l[d++]=p,h+=p>65535?2:1}let f=d;for(let h=1;h<n;++h)l.copyWithin(f,0,d),f+=d;return this.print(l,0,f),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(_e.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(_e.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(_e.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(_e.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(_e.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,ga),this._charsetService.setgCharset(1,ga),this._charsetService.setgCharset(2,ga),this._charsetService.setgCharset(3,ga);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:i,activeEncoding:a}=this._coreMouseService,l=this._coreService,{buffers:d,cols:f}=this._bufferService,{active:h,alt:p}=d,g=this._optionsService.rawOptions,x=(S,w)=>(l.triggerDataEvent(`${_e.ESC}[${t?"":"?"}${S};${w}$y`),!0),_=S=>S?1:2,v=e.params[0];return t?v===2?x(v,4):v===4?x(v,_(l.modes.insertMode)):v===12?x(v,3):v===20?x(v,_(g.convertEol)):x(v,0):v===1?x(v,_(r.applicationCursorKeys)):v===3?x(v,g.windowOptions.setWinLines?f===80?2:f===132?1:0:0):v===6?x(v,_(r.origin)):v===7?x(v,_(r.wraparound)):v===8?x(v,3):v===9?x(v,_(i==="X10")):v===12?x(v,_(g.cursorBlink)):v===25?x(v,_(!l.isCursorHidden)):v===45?x(v,_(r.reverseWraparound)):v===66?x(v,_(r.applicationKeypad)):v===67?x(v,4):v===1e3?x(v,_(i==="VT200")):v===1002?x(v,_(i==="DRAG")):v===1003?x(v,_(i==="ANY")):v===1004?x(v,_(r.sendFocus)):v===1005?x(v,4):v===1006?x(v,_(a==="SGR")):v===1015?x(v,4):v===1016?x(v,_(a==="SGR_PIXELS")):v===1048?x(v,1):v===47||v===1047||v===1049?x(v,_(h===p)):v===2004?x(v,_(r.bracketedPasteMode)):v===2026?x(v,_(r.synchronizedOutput)):x(v,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=$c.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let l=e.getSubParams(t+a),d=0;do r[1]===5&&(i=1),r[a+d+1+i]=l[d];while(++d<l.length&&d+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let l=2;l<r.length;++l)r[l]===-1&&(r[l]=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 a}_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=ln.fg,e.bg=ln.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 i=0;i<t;i++)n=e.params[i],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(i)?e.getSubParams(i)[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|=ln.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=ln.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,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|=ln.fg&16777215,r.bg&=-67108864,r.bg|=ln.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${_e.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.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(`${_e.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=ln.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(!v1(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(`${_e.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>y1&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>y1&&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(),i=n.shift();if(/^\d+$/.exec(r)){let a=parseInt(r);if(w1(a))if(i==="?")t.push({type:0,index:a});else{let l=x1(i);l&&t.push({type:1,index:a,color:l})}}}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,i=n.findIndex(a=>a.startsWith("id="));return i!==-1&&(r=n[i].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 i=x1(n[r]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}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 i=parseInt(n[r]);w1(i)&&t.push({type:2,index:i})}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,ga),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(m3[e[0]],_n[e[1]]||ga),!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=ln.clone(),this._eraseAttrDataInternal=ln.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 Pr;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=l=>(this._coreService.triggerDataEvent(`${_e.ESC}${l}${_e.ESC}\\`),!0),r=this._bufferService.buffer,i=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}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},m_=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&&(S1=e,e=t,t=S1),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};m_=Kt([je(0,Gn)],m_);function w1(e){return 0<=e&&e<256}var g3=5e7,C1=12,_3=50,x3=class extends et{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 we),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>g3)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],i=this._action(r,t);if(i){let l=d=>performance.now()-n>=C1?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);i.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(l);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=C1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>_3&&(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()}},p_=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),f={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(f,d)),this._dataByLinkId.set(f.id,f),f.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),l={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._entriesWithId.set(l.key,l),this._dataByLinkId.set(l.id,l),l.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)))}};p_=Kt([je(0,Gn)],p_);var k1=!1,y3=class extends et{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Uo),this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onData=this._register(new we),this.onData=this._onData.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new we),this._instantiationService=new U5,this.optionsService=this._register(new Z5(e)),this._instantiationService.setService(qn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(u_)),this._instantiationService.setService(Gn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(c_)),this._instantiationService.setService(Sk,this._logService),this.coreService=this._register(this._instantiationService.createInstance(d_)),this._instantiationService.setService(Ra,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(h_)),this._instantiationService.setService(bk,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(va)),this._instantiationService.setService(zL,this.unicodeService),this._charsetService=this._instantiationService.createInstance(i3),this._instantiationService.setService(BL,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(p_),this._instantiationService.setService(wk,this._oscLinkService),this._inputHandler=this._register(new p3(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Mn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Mn.forward(this._bufferService.onResize,this._onResize)),this._register(Mn.forward(this.coreService.onData,this._onData)),this._register(Mn.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 x3((t,n)=>this._inputHandler.parse(t,n))),this._register(Mn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new we),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&&!k1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),k1=!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,t2),t=Math.max(t,n2),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(g1.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(g1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Bt(()=>{for(let t of e)t.dispose()})}}},v3={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 b3(e,t,n,r){var l;let i={type:0,cancel:!1,key:void 0},a=(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?i.key=_e.ESC+"OA":i.key=_e.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=_e.ESC+"OD":i.key=_e.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=_e.ESC+"OC":i.key=_e.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=_e.ESC+"OB":i.key=_e.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":_e.DEL,e.altKey&&(i.key=_e.ESC+i.key);break;case 9:if(e.shiftKey){i.key=_e.ESC+"[Z";break}i.key=_e.HT,i.cancel=!0;break;case 13:i.key=e.altKey?_e.ESC+_e.CR:_e.CR,i.cancel=!0;break;case 27:i.key=_e.ESC,e.altKey&&(i.key=_e.ESC+_e.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=_e.ESC+"[1;"+(a+1)+"D":t?i.key=_e.ESC+"OD":i.key=_e.ESC+"[D";break;case 39:if(e.metaKey)break;a?i.key=_e.ESC+"[1;"+(a+1)+"C":t?i.key=_e.ESC+"OC":i.key=_e.ESC+"[C";break;case 38:if(e.metaKey)break;a?i.key=_e.ESC+"[1;"+(a+1)+"A":t?i.key=_e.ESC+"OA":i.key=_e.ESC+"[A";break;case 40:if(e.metaKey)break;a?i.key=_e.ESC+"[1;"+(a+1)+"B":t?i.key=_e.ESC+"OB":i.key=_e.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=_e.ESC+"[2~");break;case 46:a?i.key=_e.ESC+"[3;"+(a+1)+"~":i.key=_e.ESC+"[3~";break;case 36:a?i.key=_e.ESC+"[1;"+(a+1)+"H":t?i.key=_e.ESC+"OH":i.key=_e.ESC+"[H";break;case 35:a?i.key=_e.ESC+"[1;"+(a+1)+"F":t?i.key=_e.ESC+"OF":i.key=_e.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=_e.ESC+"[5;"+(a+1)+"~":i.key=_e.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=_e.ESC+"[6;"+(a+1)+"~":i.key=_e.ESC+"[6~";break;case 112:a?i.key=_e.ESC+"[1;"+(a+1)+"P":i.key=_e.ESC+"OP";break;case 113:a?i.key=_e.ESC+"[1;"+(a+1)+"Q":i.key=_e.ESC+"OQ";break;case 114:a?i.key=_e.ESC+"[1;"+(a+1)+"R":i.key=_e.ESC+"OR";break;case 115:a?i.key=_e.ESC+"[1;"+(a+1)+"S":i.key=_e.ESC+"OS";break;case 116:a?i.key=_e.ESC+"[15;"+(a+1)+"~":i.key=_e.ESC+"[15~";break;case 117:a?i.key=_e.ESC+"[17;"+(a+1)+"~":i.key=_e.ESC+"[17~";break;case 118:a?i.key=_e.ESC+"[18;"+(a+1)+"~":i.key=_e.ESC+"[18~";break;case 119:a?i.key=_e.ESC+"[19;"+(a+1)+"~":i.key=_e.ESC+"[19~";break;case 120:a?i.key=_e.ESC+"[20;"+(a+1)+"~":i.key=_e.ESC+"[20~";break;case 121:a?i.key=_e.ESC+"[21;"+(a+1)+"~":i.key=_e.ESC+"[21~";break;case 122:a?i.key=_e.ESC+"[23;"+(a+1)+"~":i.key=_e.ESC+"[23~";break;case 123:a?i.key=_e.ESC+"[24;"+(a+1)+"~":i.key=_e.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=_e.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=_e.DEL:e.keyCode===219?i.key=_e.ESC:e.keyCode===220?i.key=_e.FS:e.keyCode===221&&(i.key=_e.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let d=(l=v3[e.keyCode])==null?void 0:l[e.shiftKey?1:0];if(d)i.key=_e.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(f);e.shiftKey&&(h=h.toUpperCase()),i.key=_e.ESC+h}else if(e.keyCode===32)i.key=_e.ESC+(e.ctrlKey?_e.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),i.key=_e.ESC+f,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=_e.US),e.key==="@"&&(i.key=_e.NUL));break}return i}var Jt=0,S3=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new th,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new th,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((i,a)=>this._getKey(i)-this._getKey(a)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=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||(Jt=this._search(t),Jt===-1)||this._getKey(this._array[Jt])!==t)return!1;do if(this._array[Jt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Jt),!0;while(++Jt<this._array.length&&this._getKey(this._array[Jt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,a)=>i-a),t=0,n=new Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];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&&(Jt=this._search(e),!(Jt<0||Jt>=this._array.length)&&this._getKey(this._array[Jt])===e))do yield this._array[Jt];while(++Jt<this._array.length&&this._getKey(this._array[Jt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Jt=this._search(e),!(Jt<0||Jt>=this._array.length)&&this._getKey(this._array[Jt])===e))do t(this._array[Jt]);while(++Jt<this._array.length&&this._getKey(this._array[Jt])===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,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Up=0,E1=0,w3=class extends et{constructor(){super(),this._decorations=new S3(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new we),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new we),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Bt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new C3(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,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,i=>{Up=i.options.x??0,E1=Up+(i.options.width??1),e>=Up&&e<E1&&(!n||(i.options.layer??"bottom")===n)&&r(i)})}},C3=class extends Is{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new we),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new we),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=Ht.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ht.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},k3=1e3,E3=class{constructor(e,t=k3){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 i=r-this._lastRefreshMs,a=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_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)}},N1=20,nh=class extends et{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 i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new E3(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(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
82
+ `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Fe(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Bt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<N1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
83
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===N1+1&&(this._liveRegion.textContent+=Og.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 i=e;i<=t;i++){let a=n.lines.get(n.ydisp+i),l=[],d=(a==null?void 0:a.translateToString(!0,void 0,void 0,l))||"",f=(n.ydisp+i+1).toString(),h=this._rowElements[i];h&&(d.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=d,this._rowColumns.set(h,l)),h.setAttribute("aria-posinset",f),h.setAttribute("aria-setsize",r),this._alignRowWidth(h))}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],i=n.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===a||e.relatedTarget!==r)return;let l,d;if(t===0?(l=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(l=this._rowElements.shift(),d=n,this._rowContainer.removeChild(l)),l.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}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 i=({node:f,offset:h})=>{let p=f instanceof Text?f.parentNode:f,g=parseInt(p==null?void 0:p.getAttribute("aria-posinset"),10)-1;if(isNaN(g))return console.warn("row is invalid. Race condition?"),null;let x=this._rowColumns.get(p);if(!x)return console.warn("columns is null. Race condition?"),null;let _=h<x.length?x[h]:x.slice(-1)[0]+1;return _>=this._terminal.cols&&(++g,_=0),{row:g,column:_}},a=i(t),l=i(n);if(!(!a||!l)){if(a.row>l.row||a.row===l.row&&a.column>=l.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(l.row-a.row)*this._terminal.cols-a.column+l.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 i,a;e.style.transform="";let t=e.getBoundingClientRect().width,n=(a=(i=this._rowColumns.get(e))==null?void 0:i.slice(-1))==null?void 0:a[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};nh=Kt([je(1,ox),je(2,Yi),je(3,Xi)],nh);var g_=class extends et{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new we),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new we),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Bt(()=>{var a;ja(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.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 i=n[r];if(i.classList.contains("xterm"))break;if(i.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,i;(!this._activeProviderReplies||!t)&&((r=this._activeProviderReplies)==null||r.forEach(a=>{a==null||a.forEach(l=>{l.link.dispose&&l.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[a,l]of this._linkProviderService.linkProviders.entries())t?(i=this._activeProviderReplies)!=null&&i.get(a)&&(n=this._checkLinkProviderResult(a,e,n)):l.provideLinks(e.y,d=>{var h,p;if(this._isMouseOut)return;let f=d==null?void 0:d.map(g=>({link:g}));(h=this._activeProviderReplies)==null||h.set(a,f),n=this._checkLinkProviderResult(a,e,n),((p=this._activeProviderReplies)==null?void 0:p.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 i=t.get(r);if(i)for(let a=0;a<i.length;a++){let l=i[a],d=l.link.range.start.y<e?0:l.link.range.start.x,f=l.link.range.end.y>e?this._bufferService.cols:l.link.range.end.x;for(let h=d;h<=f;h++){if(n.has(h)){i.splice(a--,1);break}n.add(h)}}}}_checkLinkProviderResult(e,t,n){var a;if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let l=0;l<e;l++)(!this._activeProviderReplies.has(l)||this._activeProviderReplies.get(l))&&(i=!0);if(!i&&r){let l=r.find(d=>this._linkAtPosition(d.link,t));l&&(n=!0,this._handleNewLink(l))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let l=0;l<this._activeProviderReplies.size;l++){let d=(a=this._activeProviderReplies.get(l))==null?void 0:a.find(f=>this._linkAtPosition(f.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&&N3(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,ja(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,i,a;(r=this._currentLink)!=null&&r.state&&((a=(i=this._currentLink)==null?void 0:i.state)==null?void 0:a.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,i=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(r,i),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!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,i=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(i)}_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,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=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,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};g_=Kt([je(1,lx),je(2,Xi),je(3,Gn),je(4,kk)],g_);function N3(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 j3=class extends y3{constructor(e={}){super(e),this._linkifier=this._register(new Uo),this.browser=Vk,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Uo),this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new we),this.onKey=this._onKey.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new we),this.onBell=this._onBell.event,this._onFocus=this._register(new we),this._onBlur=this._register(new we),this._onA11yCharEmitter=this._register(new we),this._onA11yTabEmitter=this._register(new we),this._onWillOpen=this._register(new we),this._setup(),this._decorationService=this._instantiationService.createInstance(w3),this._instantiationService.setService(Hc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(_5),this._instantiationService.setService(kk,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Pg)),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(Mn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Mn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Mn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Mn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Bt(()=>{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 i=Mt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${_e.ESC}]${r};${f3(i)}${Fk.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=cn.toColor(...t.color));else{let a=n;this._themeService.modifyColors(l=>l[a]=cn.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(nh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(_e.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(_e.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,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,l=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=l+"px",this.textarea.style.width=a+"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()&&LL(t,this._selectionService)}));let e=t=>RL(t,this.textarea,this.coreService,this.optionsService);this._register(Fe(this.textarea,"paste",e)),this._register(Fe(this.element,"paste",e)),Wk?this._register(Fe(this.element,"mousedown",t=>{t.button===2&&PS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Fe(this.element,"contextmenu",t=>{PS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),gx&&this._register(Fe(this.element,"auxclick",t=>{t.button===1&&gk(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 i;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"),((i=this.element)==null?void 0:i.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",a=>this.updateCursorStyle(a))),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",Mg.get()),Kk||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(p5,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Yi,this._coreBrowserService),this._register(Fe(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Fe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(i_,this._document,this._helperContainer),this._instantiationService.setService(Rh,this._charSizeService),this._themeService=this._instantiationService.createInstance(l_),this._instantiationService.setService(Ko,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Zd),this._instantiationService.setService(Ck,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(a_,this.rows,this.screenElement)),this._instantiationService.setService(Xi,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(t_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(s_),this._instantiationService.setService(lx,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(g_,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(Zg,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(o_,this.element,this.screenElement,r)),this._instantiationService.setService(HL,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(Mn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(e_,this.screenElement)),this._register(Fe(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),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(nh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Jd,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Jd,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(r_,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(a){var h,p,g,x,_;let l=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!l)return!1;let d,f;switch(a.overrideType||a.type){case"mousemove":f=32,a.buttons===void 0?(d=3,a.button!==void 0&&(d=a.button<3?a.button:3)):d=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":f=0,d=a.button<3?a.button:3;break;case"mousedown":f=1,d=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let v=a.deltaY;if(v===0||e.coreMouseService.consumeWheelEvent(a,(x=(g=(p=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:p.device)==null?void 0:g.cell)==null?void 0:x.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;f=v<0?0:1,d=4;break;default:return!1}return f===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:l.col,row:l.row,x:l.x,y:l.y,button:d,action:f,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:a=>(n(a),a.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(a)),wheel:a=>(n(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&n(a)},mousemove:a=>{a.buttons||n(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),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()),a&8?r.mousemove||(t.addEventListener("mousemove",i.mousemove),r.mousemove=i.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),a&16?r.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),r.wheel=i.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),a&2?r.mouseup||(r.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),a&4?r.mousedrag||(r.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Fe(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return n(a),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(a)})),this._register(Fe(t,"wheel",a=>{var l,d,f,h,p;if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(h=(f=(d=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:d.device)==null?void 0:f.cell)==null?void 0:h.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return this.cancel(a,!0);let g=_e.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(a,!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){pk(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=b3(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===_e.ETX||n.key===_e.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)&&(T3(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(ln));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(_e.ESC+"[I"):this.coreService.triggerDataEvent(_e.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(`${_e.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[6;${i};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function T3(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var A3=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)}},D3=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 Pr)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},j1=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 D3(t)}getNullCell(){return new Pr}},L3=class extends et{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new we),this.onBufferChange=this._onBufferChange.event,this._normal=new j1(this._core.buffers.normal,"normal"),this._alternate=new j1(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)}},R3=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)}},M3=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}},O3=["cols","rows"],ai=0,I3=class extends et{constructor(e){super(),this._core=this._register(new j3(e)),this._addonManager=this._register(new A3),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,i)=>{this._checkReadonlyOptions(r),this._core.options[r]=i};for(let r in this._core.options){let i={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,i)}}_checkReadonlyOptions(e){if(O3.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 R3(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new M3(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 L3(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
84
+ `,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 Mg.get()},set promptLabel(e){Mg.set(e)},get tooMuchOutput(){return Og.get()},set tooMuchOutput(e){Og.set(e)}}}_verifyIntegers(...e){for(ai of e)if(ai===1/0||isNaN(ai)||ai%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ai of e)if(ai&&(ai===1/0||isNaN(ai)||ai%1!==0||ai<0))throw new Error("This API only accepts positive integers")}};/**
85
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
86
+ * @license MIT
87
+ *
88
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
89
+ * @license MIT
90
+ *
91
+ * Originally forked from (with the author's permission):
92
+ * Fabrice Bellard's javascript vt100 for jslinux:
93
+ * http://bellard.org/jslinux/
94
+ * Copyright (c) 2011 Fabrice Bellard
95
+ */var P3=2,B3=1,z3=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let n=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(n._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){var x;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let n=this._terminal.options.scrollback===0?0:((x=this._terminal.options.overviewRuler)==null?void 0:x.width)||14,r=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(r.getPropertyValue("height")),a=Math.max(0,parseInt(r.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),d={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},f=d.top+d.bottom,h=d.right+d.left,p=i-f,g=a-h-n;return{cols:Math.max(P3,Math.floor(g/t.css.cell.width)),rows:Math.max(B3,Math.floor(p/t.css.cell.height))}}};function $3({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const i=C.useRef(null),a=C.useRef(e),l=C.useRef(null),d=C.useRef(null),f=qr(p=>p.writeSession),h=qr(p=>p.resizeSession);return C.useEffect(()=>{a.current=e},[e]),C.useEffect(()=>{if(!n)return;const p=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]),C.useEffect(()=>{if(!i.current)return;const p=new I3({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new z3;p.loadAddon(g),l.current={term:p,fitAddon:g},i.current.addEventListener("keydown",S=>{S.key==="Escape"&&n&&(S.preventDefault(),S.stopPropagation(),n())}),p.open(i.current);const x=i.current.querySelector(".xterm");x&&(x.style.padding="8px"),g.fit(),r&&setTimeout(()=>{p.focus()},150);const _=new ResizeObserver(()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{requestAnimationFrame(()=>{var w;g.fit&&g.fit();const S=(w=l.current)==null?void 0:w.term;S&&S.cols>0&&S.rows>0&&h(a.current,S.cols,S.rows)})},100)});_.observe(i.current),p.onData(S=>{if(S==="\x1B"&&n){n();return}f(a.current,S)}),p.onKey(S=>{S.key==="\x1B"&&n&&(S.domEvent.stopPropagation(),n())});const v=Ft.subscribe(S=>{const w=S.payload;if(S.type==="terminal.output"&&(w==null?void 0:w.sessionId)===a.current){const k=w==null?void 0:w.data;k&&p.write(k)}});return()=>{v(),_.disconnect(),d.current&&clearTimeout(d.current),p.dispose(),l.current=null}},[e,f,h]),c.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[c.jsx("div",{}),c.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:c.jsx(nk,{})})]}),c.jsx("div",{ref:i,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),n())}})]})}const i2="openfox-chat-textarea";function s2(){const e=document.getElementById(i2);e&&e.focus()}function H3(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 F3({isOpen:e,onClose:t}){const n=qr(v=>v.createSession),r=qr(v=>v.killSession),i=qr(v=>v.sessions),a=qr(v=>v.setWorkdir),l=qr(v=>v.fetchSessions),d=Ut(v=>v.currentProject),[f,h]=C.useState(!0),p=C.useRef(null),g=C.useRef(!1),x=C.useRef(!1),_=C.useCallback(()=>{t()},[t]);return C.useEffect(()=>{d!=null&&d.workdir&&a(d.workdir)},[d==null?void 0:d.workdir,a]),C.useEffect(()=>{e?(h(!0),l(d==null?void 0:d.id).finally(()=>h(!1))):s2()},[e,l,d==null?void 0:d.id]),C.useEffect(()=>{e&&i.length===0&&!f&&!x.current&&(x.current=!0,n(void 0,d==null?void 0:d.id))},[e,i.length,f,n,d==null?void 0:d.id]),C.useEffect(()=>{e?(g.current=!0,setTimeout(()=>{var v;(v=p.current)==null||v.focus(),setTimeout(()=>{g.current=!1},200)},100)):x.current=!1},[e]),C.useEffect(()=>{if(!e)return;const v=S=>{g.current||S.key==="Escape"&&(S.preventDefault(),t())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[e,t]),e?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:_}),c.jsxs("div",{ref:p,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:v=>v.stopPropagation(),onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),_())},children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.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:c.jsx(YD,{})}),c.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:c.jsx(zc,{})})]})]}),c.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:f?c.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):i.length===0?c.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"mb-4",children:"No terminal sessions"}),c.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"})]})}):c.jsx("div",{className:`grid ${H3(i.length)} gap-2 h-full auto-rows-fr`,children:i.map(v=>c.jsx($3,{sessionId:v.id,onClose:()=>r(v.id),onEscape:_,autoFocus:i.length===1},v.id))})})]})]}):null}function Vc({items:e,trigger:t,minWidth:n="120px",isOpen:r,onOpenChange:i}){const[a,l]=C.useState(!1),d=r!==void 0,f=d?r:a,h=L=>{if(d){const G=typeof L=="function"?L(a):L;i==null||i(G)}else l(L)},[p,g]=C.useState(null),x=C.useRef(null),_=C.useRef(null),[v,S]=C.useState(0),w=C.useRef(0),k=C.useRef(e),j=C.useCallback(()=>{if(!x.current)return;const L=x.current.getBoundingClientRect(),G=200,R=window.innerHeight-L.bottom<G;g({top:R?L.top-G-4:L.bottom+4,left:L.left,alignToTop:R})},[]);C.useEffect(()=>{k.current=e},[e]),C.useEffect(()=>{function L(G){if(_.current){const H=G.target;_.current.contains(H)||h(!1)}}return f&&document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}},[f]),C.useEffect(()=>{f&&j()},[f,j]),C.useEffect(()=>{if(!f)return;setTimeout(()=>{var G;(G=_.current)==null||G.focus()},0);function L(G){const H=k.current,R=H.filter(D=>!T(D)),U=A(w.current,H);switch(G.key){case"ArrowDown":if(G.preventDefault(),G.stopPropagation(),U<R.length-1){const D=P(w.current+1,H);w.current=D,S(D)}break;case"ArrowUp":if(G.preventDefault(),G.stopPropagation(),U>0){const D=M(w.current-1,H);w.current=D,S(D)}break;case"Enter":G.preventDefault(),G.stopPropagation(),q(w.current,H);break;case"Escape":G.preventDefault(),G.stopPropagation(),h(!1);break}}return window.addEventListener("keydown",L,!0),()=>window.removeEventListener("keydown",L,!0)},[f,e]);function T(L){var R;const G=L.label;return G?String(((R=G.props)==null?void 0:R.className)??"").includes("cursor-default"):!1}function A(L,G){let H=0;for(let R=0;R<L;R++){const U=G[R];U&&!T(U)&&H++}return H}function P(L,G){for(let H=L;H<G.length;H++){const R=G[H];if(R&&!T(R))return H}return L}function M(L,G){for(let H=L;H>=0;H--){const R=G[H];if(R&&!T(R))return H}return L}function q(L,G){var R;const H=G[L];!H||T(H)||((R=H.onClick)==null||R.call(H),H.href&&(window.history.pushState(null,"",H.href),window.dispatchEvent(new PopStateEvent("popstate"))),h(!1))}C.useEffect(()=>{f&&(S(e.findIndex(L=>!T(L))),w.current=e.findIndex(L=>!T(L)))},[f,e]);const Z=L=>{L.stopPropagation(),f||j(),h(!f)},J=p&&c.jsx("div",{ref:_,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${p.alignToTop?"mb-1":"mt-1"}`,style:{top:p.top,left:p.left,minWidth:n},tabIndex:-1,children:e.map((L,G)=>{const R=!T(L)&&G===v,U=c.jsxs(c.Fragment,{children:[L.icon&&c.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:L.icon}),L.label]});return L.href?c.jsx(gr,{href:L.href,onClick:D=>{var N;(N=L.onClick)==null||N.call(L,D),h(!1)},onAuxClick:()=>h(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${L.danger?"text-accent-error hover:bg-accent-error/10":R?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${G!==e.length-1?"border-b border-border":""}`,children:U},G):c.jsx("button",{onClick:D=>{var N;(N=L.onClick)==null||N.call(L,D),L.closeOnClick!==!1&&h(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${L.danger?"text-accent-error hover:bg-accent-error/10":R?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${G!==e.length-1?"border-b border-border":""}`,children:U},G)})});return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"relative",children:c.jsx("div",{ref:x,onClick:Z,children:t})}),f&&La.createPortal(J,document.body)]})}function U3({projects:e,currentProject:t}){const n=Ut(l=>l.loadProject),r=Ut(l=>l.toggleStar),a=C.useMemo(()=>{const l=e.filter(f=>f.isStarred).sort((f,h)=>f.name.localeCompare(h.name)),d=e.filter(f=>!f.isStarred).sort((f,h)=>f.name.localeCompare(h.name));return[...l,...d]},[e]).map(l=>({label:c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[c.jsx("span",{className:"truncate flex-1",children:l.name}),c.jsx("button",{onClick:d=>{d.stopPropagation(),d.preventDefault(),d.nativeEvent.stopImmediatePropagation(),r(l.id,!l.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:l.isStarred?"Unstar project":"Star project",children:l.isStarred?c.jsx(JD,{className:"w-3.5 h-3.5 text-yellow-500"}):c.jsx(ZD,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:l.id===t.id?c.jsx(pi,{}):void 0,href:`/p/${l.id}`,closeOnClick:!0,onClick:()=>{n(l.id)}}));return c.jsx(Vc,{items:a,trigger:c.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,c.jsx(gi,{})]}),minWidth:"250px"})}function a2(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],i=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${r} ${i}/${a}/${l}`}function Ih(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function V3(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=Math.floor((r.getTime()-i.getTime())/(1e3*60*60*24)),l=Ih(e);if(a===0)return`today ${l}`;if(a===1)return`yesterday ${l}`;if(a<7)return`${a} days ago ${l}`;{const d=t.getFullYear(),f=String(t.getMonth()+1).padStart(2,"0"),h=String(t.getDate()).padStart(2,"0");return`${d}/${f}/${h} ${l}`}}function o2(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 W3(e){const{year:t,month:n,day:r}=o2(e);return`${t}-${n}-${r}`}function l2(e){const t=new Map;for(const i of e){const a=W3(i.updatedAt);t.has(a)||t.set(a,[]),t.get(a).push(i)}for(const[i,a]of t)a.sort((l,d)=>{const f=new Date(l.updatedAt).getTime();return new Date(d.updatedAt).getTime()-f});const n=Array.from(t.keys()).sort((i,a)=>a.localeCompare(i)),r=new Map;for(const i of n)r.set(i,t.get(i));return r}function G3({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:i}){var p;const a=xe(g=>g.loadSession),l=e.filter(g=>g.projectId===t.id).slice(0,15),d=l2(l),f=C.useMemo(()=>{const g=[];g.push({label:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx($s,{className:"w-4 h-4 text-accent-primary"}),c.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[x,_]of d){const v=_[0];if(v){g.push({label:c.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:a2(v.updatedAt)}),onClick:()=>{}});for(const S of _)g.push({label:c.jsxs("div",{className:"min-w-[160px]",children:[c.jsx("div",{className:"truncate text-sm",children:S.title??S.id.slice(0,8)}),c.jsx("div",{className:"text-text-muted text-xs",children:Ih(S.updatedAt)})]}),icon:S.id===(n==null?void 0:n.id)?c.jsx(pi,{}):void 0,href:`/p/${t.id}/s/${S.id}`,onClick:()=>{a(S.id)}})}}return g},[t.id,d,n==null?void 0:n.id]),h=n?((p=n.metadata)==null?void 0:p.title)??n.id.slice(0,8):"No session selected";return c.jsx(Vc,{items:f,isOpen:r,onOpenChange:i,trigger:c.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:h,"data-testid":"header-session-dropdown",children:[h,c.jsx(gi,{})]}),minWidth:"280px"})}function q3({items:e,trigger:t,isActive:n=!1}){const[r,i]=C.useState(!1),a=C.useRef(null);return C.useEffect(()=>{function l(d){a.current&&!a.current.contains(d.target)&&i(!1)}if(r)return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]),c.jsxs("div",{className:"relative",ref:a,children:[c.jsxs("button",{type:"button",onClick:()=>i(!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"?c.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,c.jsx(gi,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&c.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((l,d)=>{const f=l.label&&typeof l.label=="object"&&l.label.type===gr?l.label:null;if(f){const h=f.props.href||"";return c.jsxs(gr,{href:h,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[l.icon,f.props.children]},d)}return l.href?c.jsxs("a",{href:l.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[l.icon,l.label]},d):c.jsxs("button",{type:"button",onClick:()=>{var h;(h=l.onClick)==null||h.call(l),i(!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:[l.icon,l.label]},d)})})]})}function K3({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const i=t.filter(l=>l.projectId===e.id).sort((l,d)=>new Date(d.updatedAt).getTime()-new Date(l.updatedAt).getTime()).slice(0,5),a=[{label:c.jsxs(gr,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[c.jsx($s,{className:"w-3 h-3 text-accent-primary"}),c.jsx("span",{className:"text-sm",children:"New Session"})]})},...i.map(l=>({label:c.jsx(gr,{href:`/p/${e.id}/s/${l.id}`,className:"flex items-center gap-2 truncate text-sm",children:c.jsx("span",{children:l.title??l.id.slice(0,8)})}),icon:l.id===(n==null?void 0:n.id)?c.jsx(pi,{className:"w-3 h-3"}):void 0})),{label:c.jsxs(gr,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[c.jsx(zD,{className:"w-3 h-3"}),c.jsx("span",{className:"text-sm",children:"Projects"})]})}];return c.jsx(q3,{items:a,trigger:c.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function Y3({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=C.useState(!1),[i,a]=C.useState(!1),[l,d]=C.useState(!!document.fullscreenElement);C.useEffect(()=>{const A=()=>d(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",A),()=>document.removeEventListener("fullscreenchange",A)},[]);const[f]=Qr(),h=f.startsWith("/p/"),p=/^\/p\/[^/]+\/s\/[^/]+$/.test(f),g=xe(A=>A.currentSession),x=xe(A=>A.sessions),_=Ut(A=>A.currentProject),v=Ut(A=>A.projects),S=Ot(A=>A.startAutoRefresh),w=Ot(A=>A.stopAutoRefresh),k=qr(A=>A.setOpen),j=qr(A=>A.isOpen);C.useEffect(()=>{const A=()=>a(!0);return window.addEventListener("open-session-dropdown",A),()=>window.removeEventListener("open-session-dropdown",A)},[]);const T=ex();return ak(T.terminalToggle,()=>{qr.getState().toggleOpen()},{capture:!0}),C.useEffect(()=>(S(),()=>w()),[S,w]),c.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&h&&c.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:c.jsx(jS,{})}),c.jsx(gr,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),_&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),c.jsx("span",{className:"hidden md:inline",children:c.jsx(U3,{projects:v,currentProject:_})}),c.jsx("span",{className:"md:hidden",children:c.jsx(K3,{currentProject:_,sessions:x,currentSession:g,projectIdFromUrl:h&&f.split("/")[2]||null},_==null?void 0:_.id)}),c.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),c.jsx("span",{className:"hidden md:inline",children:c.jsx(G3,{sessions:x,currentProject:_,currentSession:g,isOpen:i,onOpenChange:a})})]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p&&c.jsx("button",{onClick:()=>{var A,P,M;document.fullscreenElement?(A=document.exitFullscreen)==null||A.call(document):(M=(P=document.documentElement).requestFullscreen)==null||M.call(P)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:l?"Exit fullscreen":"Enter fullscreen",children:l?c.jsx(UD,{}):c.jsx(VD,{})}),h&&c.jsx("button",{onClick:()=>k(!j),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${j?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:c.jsx(tL,{})}),c.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:c.jsx(XD,{})}),c.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:c.jsx(GD,{})}),t&&p&&c.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Toggle sidebar",children:c.jsx(jS,{})})]}),c.jsx(NL,{isOpen:n,onClose:()=>r(!1)}),c.jsx(F3,{isOpen:j,onClose:()=>k(!1)})]})}function X3({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:i="Cancel",saveLabel:a=n?"Saving...":"Save"}){return c.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[c.jsx(Ze,{variant:"secondary",onClick:e,children:i}),c.jsx(Ze,{variant:"primary",onClick:t,disabled:r??n,children:a})]})}function Q3({isOpen:e,onClose:t,project:n}){const r=Ut(A=>A.updateProject),i=()=>{try{Ft.send("context.checkDynamic",{})}catch{}t()},[a,l]=C.useState(n.customInstructions??""),[d,f]=C.useState(n.dangerLevel??""),[h,p]=C.useState(!1),[g,x]=C.useState(!1),[_,v]=C.useState(!1),S=h||g;C.useEffect(()=>{l(n.customInstructions??""),f(n.dangerLevel??""),p(!1),x(!1)},[n]);const w=A=>{l(A.target.value),p(!0)},k=A=>{f(A),x(!0)},j=async()=>{v(!0);const A=d===""?null:d;await r(n.id,{customInstructions:a||null,dangerLevel:A}),v(!1),p(!1),x(!1),i()},T=()=>{l(n.customInstructions??""),f(n.dangerLevel??""),p(!1),x(!1),i()};return c.jsx(jt,{isOpen:e,onClose:T,title:`${n.name} Settings`,size:"lg",footer:c.jsx(X3,{onCancel:T,onSave:j,saving:_,saveDisabled:!S||_}),children:c.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),c.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."}),c.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[c.jsx("button",{type:"button",onClick:()=>k(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${d===""?"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"}),c.jsx("button",{type:"button",onClick:()=>k("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${d==="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"}),c.jsx("button",{type:"button",onClick:()=>k("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${d==="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"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),c.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),c.jsxs("div",{className:"flex-1 min-h-[150px] pb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),c.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."}),c.jsx("textarea",{value:a,onChange:w,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:_})]})]})})}const J3={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},Z3="M6 18L18 6M6 6l12 12";function Wc({onClick:e,className:t="",size:n="md",variant:r="default"}){const i=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 c.jsx(Ah,{onClick:e,icon:Z3,iconSize:J3[n],className:`${i} ${t}`,title:"Close"})}function c2({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Qr(),[i,a]=C.useState(!1),l=xe(P=>P.sessions),d=xe(P=>P.currentSession),f=xe(P=>P.unreadSessionIds),h=xe(P=>P.deleteSession),p=xe(P=>P.deleteAllSessions),g=xe(P=>P.loadMoreSessions),x=xe(P=>P.sessionsHasMore),_=xe(P=>P.sessionsPaginationLoading),v=Ut(P=>P.currentProject),S=C.useRef(null),w=C.useCallback(()=>{x&&!_&&v&&g(v.id)},[x,_,v,g]);C.useEffect(()=>{if(!S.current||!x)return;const P=new IntersectionObserver(M=>{const q=M[0];q&&q.isIntersecting&&w()},{threshold:.1});return P.observe(S.current),()=>P.disconnect()},[x,w]);const k=l.filter(P=>P.projectId===(v==null?void 0:v.id)),j=(P,M)=>{M==null||M.stopPropagation(),confirm("Delete this session?")&&(h(P),(d==null?void 0:d.id)===P&&r(`/p/${e}`))},T=(P,M)=>{M==null||M.stopPropagation();const q=l.find(L=>L.id===P),Z=(q==null?void 0:q.title)??P.slice(0,6),J=prompt("Rename session:",Z);if(J!==null&&J.trim()!==""){const L=xe.getState().renameSession;L(P,J.trim())}},A=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(p(e),r(`/p/${e}`))};return c.jsxs(c.Fragment,{children:[t&&n&&c.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),c.jsxs("aside",{className:`
96
+ ${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden"}
97
+ md:relative md:h-auto md:translate-x-0
98
+
99
+ fixed z-50 h-[calc(100vh-32px)]
100
+ w-[300px] bg-secondary border-r border-border flex flex-col
101
+ transition-all duration-300 ease-in-out
102
+ ${t?"translate-x-0":"-translate-x-full"}
103
+ `,children:[c.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[c.jsx(gr,{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"}),c.jsx(Vc,{items:[{label:"Edit project settings",onClick:()=>a(!0)},{label:"Delete all sessions",onClick:A,danger:!0}],trigger:c.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:c.jsx(X_,{})})}),n&&c.jsx(Wc,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),v&&c.jsx(Q3,{isOpen:i,onClose:()=>a(!1),project:v}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:k.length===0?c.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"No sessions"}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"divide-y divide-border",children:eM(k,d,f,j,T,e)}),_&&c.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),c.jsx("div",{ref:S,className:"h-px"})]})})]})]})}function eM(e,t,n,r,i,a){const l=l2(e);return Array.from(l).map(([d,f])=>{const h=f[0];return h?c.jsxs("div",{children:[c.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:a2(h.updatedAt)}),f.map(p=>{const g=(t==null?void 0:t.id)===p.id,x=n.includes(p.id),_=p.isRunning;return c.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${g?"bg-bg-tertiary":""}`,children:c.jsxs(gr,{href:`/p/${a}/s/${p.id}`,className:`block ${g?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[c.jsxs("div",{className:"flex justify-between items-center mb-1",children:[c.jsx("span",{className:`font-medium truncate text-sm ${g?"text-accent-primary":"text-text-primary"}`,children:p.title??p.id.slice(0,6)}),c.jsx(Vc,{items:[{label:"Rename session",onClick:v=>i(p.id,v)},{label:"Delete session",onClick:v=>r(p.id,v),danger:!0}],trigger:c.jsx("button",{onClick:v=>v.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:c.jsx(X_,{})})})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[_?c.jsx(QD,{}):x&&!g?c.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,c.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:Ih(p.updatedAt)}),c.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[p.messageCount," messages"]})]})]})},p.id)})]},d):null})}const T1=["⠋","⠙","⠹","⠸","⠼","⠴"];function tM(){var d;const e=Ut(f=>f.currentProject),t=xe(f=>f.currentSession),n=Th(),r=!1,i=C.useRef(0),a=C.useRef(null);C.useEffect(()=>(n?(a.current=window.setInterval(()=>{i.current=(i.current+1)%T1.length,l()},150),l()):(a.current&&(clearInterval(a.current),a.current=null),l()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t,r]);const l=()=>{var g;const h=(g=t==null?void 0:t.metadata)==null?void 0:g.title,p=n?`${T1[i.current]} `:"";e&&h?document.title=`${p}${e.name} - ${h} | OpenFox`:e?document.title=`${p}${e.name} | OpenFox`:document.title=`${p}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 u2(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],i=n[n.length-1],a=n.slice(1,-1).join("/"),l=t-r.length-i.length-3;if(l<0)return e;const d=a.slice(0,Math.floor(l/2)),f=a.slice(-Math.ceil(l/2));return`/${r}/${d}...${f}/${i}`}function d2({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const i=()=>{r(),t()};return c.jsx(jt,{isOpen:e,onClose:t,title:"Delete Project",size:"sm",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("p",{className:"text-text-secondary",children:["This will permanently delete the project"," ",c.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{variant:"secondary",onClick:t,children:"Cancel"}),c.jsx(Ze,{variant:"danger",onClick:i,children:"Delete"})]})]})})}const Ph=C.forwardRef(({className:e="",...t},n)=>c.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}));Ph.displayName="Input";function nM(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 h2({isOpen:e,onClose:t,path:n,onRetry:r}){const[i,a]=C.useState(!1),[l,d]=C.useState(null),[f,h]=C.useState(null);C.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const A=await(await Ne("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();h({sudoAvailable:A.sudoAvailable,userInGroup:A.userInGroup,groupHasWrite:A.groupHasWrite,groupName:A.groupName||null})}catch{h({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},g=C.useCallback(async T=>{a(!0),d(null);try{const P=await(await Ne("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:T})})).json();P.success?(r(),t()):P.sudoAvailable?d("Failed to fix permissions: "+(P.error||"Unknown error")):d(`Passwordless sudo is not available. Please fix permissions manually:
104
+
105
+ `+(T==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(A){d("Failed to fix permissions: "+(A instanceof Error?A.message:"Unknown error"))}finally{a(!1)}},[n,r,t]),x=(f==null?void 0:f.userInGroup)??!1,_=(f==null?void 0:f.groupHasWrite)??!1,v=(f==null?void 0:f.sudoAvailable)??!1,S=(f==null?void 0:f.groupName)??"",w=x&&!_,k=!x&&_,j=!x&&!_;return c.jsx(jt,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"text-sm text-text-secondary",children:[c.jsx("p",{children:w?c.jsxs(c.Fragment,{children:["The group ",c.jsx("strong",{children:S})," doesn't have write access:"]}):k?c.jsxs(c.Fragment,{children:["You're not a member of group ",c.jsx("strong",{children:S}),":"]}):c.jsxs(c.Fragment,{children:["You're not a member of group ",c.jsx("strong",{children:S})," and it doesn't have write access:"]})}),c.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),l?c.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:l}):f?c.jsxs("div",{className:"flex flex-col gap-2",children:[w&&c.jsxs(c.Fragment,{children:[c.jsx(Ze,{type:"button",variant:"primary",onClick:()=>g("group"),disabled:i||!v,className:"w-full",children:i?"Granting access...":"Extend group permissions"}),c.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),c.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),k&&c.jsxs(c.Fragment,{children:[c.jsx(Ze,{type:"button",variant:"primary",onClick:()=>g("join_group"),disabled:i||!v,className:"w-full",children:i?"Joining group...":"Join group"}),c.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),c.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",S," $USER"]})]}),j&&c.jsxs(c.Fragment,{children:[c.jsx(Ze,{type:"button",variant:"primary",onClick:()=>g("join_group_and_group"),disabled:i||!v,className:"w-full",children:i?"Joining group...":"Join group & grant write permissions"}),c.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),c.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",S," $USER",c.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!v&&!l&&c.jsxs("div",{className:"text-xs text-text-secondary",children:[c.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),c.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),c.jsx("div",{className:"flex justify-end",children:c.jsx(Ze,{type:"button",variant:"secondary",onClick:t,disabled:i,children:"Cancel"})})]}):null]})})}function rM({isOpen:e,onClose:t}){const[,n]=Qr(),[r,i]=C.useState(""),[a,l]=C.useState(null),[d,f]=C.useState(!1),[h,p]=C.useState(""),[g,x]=C.useState(null),_=C.useRef(null);C.useEffect(()=>{e&&(Ne("/api/config").then(A=>A.json()).then(A=>{A.workdir&&p(A.workdir)}),i(""),l(null),f(!1),x(null),setTimeout(()=>{var A;(A=_.current)==null||A.focus()},100))},[e]);const v=C.useCallback(async A=>{A.preventDefault();const P=nM(r);if(!P.valid){l(P.error);return}const M=`${h}/${r}`;await k(M)},[r,n,t,h]),S=C.useCallback(()=>{x(null)},[]),w=C.useCallback(async()=>{const A=`${h}/${r}`;await k(A)},[h,r,n,t,x,l,f]);async function k(A){f(!0),l(null),x(null);try{const P=await Ne("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,workdir:A})});if(!P.ok){const Z=await P.json().catch(()=>({}));if(Z.code==="EACCES"){x(A),f(!1);return}throw new Error(Z.error||"Failed to create project")}const q=(await P.json()).project;t(),n(`/p/${q.id}`)}catch(P){l(P instanceof Error?P.message:"Failed to create project"),f(!1)}}const j=C.useCallback(()=>{i(""),l(null),t()},[t]),T=r?`${h}/${r}`:"";return c.jsxs(c.Fragment,{children:[c.jsx(jt,{isOpen:e,onClose:j,title:"Create New Project",size:"sm",children:c.jsxs("form",{onSubmit:v,className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),c.jsx(Ph,{ref:_,id:"project-name",value:r,onChange:A=>{i(A.target.value),l(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),r&&c.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",c.jsx("span",{className:"font-mono",children:T})]}),a&&c.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:a})]}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{type:"button",variant:"secondary",onClick:j,disabled:d,children:"Cancel"}),c.jsx(Ze,{type:"submit",variant:"primary",disabled:d||!r.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx($s,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&c.jsx(h2,{isOpen:!!g,onClose:S,path:g,onRetry:w})]})}const iM={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function Gc({size:e="md",className:t=""}){return c.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${iM[e]} ${t}`})}function sM({text:e,...t}){return c.jsxs("div",{className:"text-center",children:[c.jsx(Gc,{...t,className:"mx-auto mb-4"}),e&&c.jsx("div",{className:"text-text-secondary",children:e})]})}function f2({onSelect:e,onClose:t,initialPath:n}){const[r,i]=C.useState(null),[a,l]=C.useState(!0),[d,f]=C.useState(""),[h,p]=C.useState(-1),g=C.useRef(null),x=C.useRef([]),_=C.useCallback(async j=>{l(!0),f(""),p(-1);try{const T=j?`/api/directories?path=${encodeURIComponent(j)}`:"/api/directories",P=await(await Ne(T)).json();i(P)}catch(T){console.error("Failed to load directories:",T)}finally{l(!1)}},[]);C.useEffect(()=>{_(n)},[n,_]);const v=((r==null?void 0:r.current)??"").split("/").filter(Boolean).map((j,T,A)=>({name:j,path:"/"+A.slice(0,T+1).join("/")})),S=(r==null?void 0:r.directories.filter(j=>d===""||j.name.toLowerCase().includes(d.toLowerCase())))??[],w=[...r!=null&&r.parent?[{type:"parent",path:r.parent,name:".."}]:[],...S.map(j=>({type:"dir",path:j.path,name:j.name}))];C.useEffect(()=>{p(d?0:-1)},[d,S.length]),C.useEffect(()=>{var j;h>=0&&x.current[h]&&((j=x.current[h])==null||j.scrollIntoView({block:"nearest"}))},[h]);const k=j=>{var T;if(j.key==="ArrowDown")j.preventDefault(),p(A=>Math.min(A+1,w.length-1));else if(j.key==="ArrowUp")j.preventDefault(),p(A=>Math.max(A-1,0));else if(j.key==="Enter"){if(j.preventDefault(),h>=0&&w[h]){const A=w[h];A.type,_(A.path)}}else j.key==="Escape"&&(f(""),(T=g.current)==null||T.focus())};return c.jsxs(jt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",children:[r&&c.jsx("div",{className:"px-3 py-2 bg-bg-tertiary/30 -mx-4 -mt-4 mb-4 border-b border-border",children:c.jsxs("div",{className:"flex items-center text-xs overflow-x-auto",children:[v.map((j,T)=>c.jsxs("span",{className:"flex items-center shrink-0",children:[c.jsx("span",{className:"text-text-muted",children:"/"}),c.jsx("button",{onClick:()=>_(j.path),className:`px-1 ${T===v.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:j.name})]},j.path)),v.length===0&&c.jsx("button",{onClick:()=>_("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]})}),c.jsx("div",{className:"px-4 mb-3",children:c.jsxs("div",{className:"relative",children:[c.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:c.jsx(Z_,{})}),c.jsx(Ph,{autoFocus:!0,ref:g,value:d,onChange:j=>f(j.target.value),onKeyDown:k,placeholder:"Filter directories...",className:"w-full pl-9"})]})}),c.jsx("div",{className:"flex-1 overflow-y-auto -mx-4",children:a?c.jsx("div",{className:"p-8 text-center",children:c.jsx(Gc,{size:"sm"})}):w.length===0?c.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:d?"No matching directories":"No subdirectories"}):c.jsx("div",{className:"divide-y divide-border",children:w.map((j,T)=>c.jsxs("button",{ref:A=>{x.current[T]=A},onClick:()=>_(j.path),onDoubleClick:()=>e(j.path),className:`w-full p-3 flex items-center gap-3 text-left transition-colors ${T===h?"bg-accent-primary/20 text-accent-primary":"hover:bg-bg-tertiary/50"}`,children:[j.type==="parent"?c.jsx(PD,{className:"w-5 h-5 text-text-muted"}):c.jsx(Q_,{className:"w-5 h-5"}),c.jsx("span",{className:"flex-1",children:j.name}),T===h&&c.jsx("span",{className:"text-xs text-text-muted",children:"⏎ navigate · dbl-click select"})]},j.path))})}),c.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)&&c.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"}),c.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]})]})}function aM({isOpen:e,onClose:t}){const[,n]=Qr(),[r,i]=C.useState(!1),[a,l]=C.useState(null),[d,f]=C.useState(!1),h=Ut(L=>L.projects),p=Ut(L=>L.createProject),g=Ut(L=>L.listProjects),x=Ut(L=>L.deleteProject),[_,v]=C.useState(null),[S,w]=C.useState(null),[k,j]=C.useState(null);C.useEffect(()=>{Ne("/api/config").then(L=>L.json()).then(L=>{L.workdir&&l(L.workdir)})},[]),C.useEffect(()=>{e&&g()},[e,g]);const T=L=>{n(`/p/${L}`),t()},A=(L,G)=>{G.stopPropagation(),v(L)},P=()=>{_&&(x(_.id),v(null))},M=async L=>{const G=L.split("/").filter(Boolean).pop()??"",H=await p(G,L);return g(),w(L),q(H)?(j(H.error.path||L),!1):!0};function q(L){return L!=null&&typeof L=="object"&&"error"in L&&L.error!=null&&typeof L.error=="object"&&"code"in L.error&&L.error.code==="EACCES"}const Z=C.useCallback(()=>{j(null)},[]),J=C.useCallback(async()=>{if(j(null),S){const L=S.split("/").filter(Boolean).pop()??"",G=await p(L,S);g(),w(S),q(G)&&j(G.error.path||S)}},[S,p,g,j]);return C.useEffect(()=>{if(S){const L=h.find(G=>G.workdir===S);L&&(n(`/p/${L.id}`),t(),w(null))}},[h,S,n,t]),e?c.jsxs(jt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:c.jsx("div",{className:"flex justify-end gap-2",children:c.jsx(Ze,{variant:"secondary",onClick:t,children:"Close"})}),children:[c.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[c.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:[c.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:c.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:h.length===0?c.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[c.jsx("p",{className:"mb-2",children:"No recent projects"}),c.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):c.jsx("div",{className:"divide-y divide-border",children:h.map(L=>c.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[c.jsxs("button",{onClick:()=>T(L.id),className:"flex-1 flex items-center gap-3 text-left",children:[c.jsx(Q_,{className:"w-5 h-5 text-accent-primary"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"font-medium truncate",children:L.name}),c.jsx("div",{className:"text-xs text-text-muted truncate",children:u2(L.workdir,32)})]})]}),c.jsx("button",{onClick:G=>A(L,G),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:c.jsx(Bc,{className:"w-4 h-4"})})]},L.id))})})]}),c.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:c.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[c.jsx(Ze,{variant:"primary",onClick:()=>f(!0),children:"Select existing project"}),c.jsx(Ze,{variant:"secondary",onClick:()=>i(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&c.jsx(rM,{isOpen:r,onClose:()=>i(!1)}),_&&c.jsx(d2,{isOpen:!0,onClose:()=>v(null),projectName:_.name,onConfirm:P}),d&&c.jsx(f2,{initialPath:a??void 0,onSelect:L=>{M(L).then(G=>{G&&f(!1)})},onClose:()=>f(!1)}),k&&c.jsx(h2,{isOpen:!0,onClose:Z,path:k,onRetry:J})]}):null}function oM(){const[e,t]=C.useState(!1),[n,r]=C.useState(null),i=xe(v=>v.sessions),a=Ut(v=>v.projects),l=Ut(v=>v.loading),d=Ut(v=>v.listProjects),f=xe(v=>v.listSessions),h=Ut(v=>v.deleteProject),p=xe(v=>v.connectionStatus);C.useEffect(()=>{p==="connected"&&(d(),f())},[p,d,f]);const g=[...a].sort((v,S)=>{const w=i.filter(A=>A.workdir.startsWith(v.workdir)),k=i.filter(A=>A.workdir.startsWith(S.workdir)),j=w.length>0?new Date(w.reduce((A,P)=>new Date(P.updatedAt)>new Date(A.updatedAt)?P:A).updatedAt).getTime():new Date(v.updatedAt).getTime();return(k.length>0?new Date(k.reduce((A,P)=>new Date(P.updatedAt)>new Date(A.updatedAt)?P:A).updatedAt).getTime():new Date(S.updatedAt).getTime())-j}),x=v=>{const S=a.find(w=>w.id===v);return S?i.filter(w=>w.workdir.startsWith(S.workdir)).sort((w,k)=>new Date(k.updatedAt).getTime()-new Date(w.updatedAt).getTime()).slice(0,5):[]},_=()=>{t(!0)};return c.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto bg-primary",children:[c.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[c.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),c.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),c.jsx(Ze,{variant:"primary",onClick:_,children:"Open Project"})]}),g.map(v=>{const S=x(v.id);return c.jsx("div",{className:"mb-6 md:mb-8",children:c.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[c.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[c.jsxs(gr,{href:`/p/${v.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[c.jsx(Q_,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),c.jsx("span",{className:"text-text-primary font-semibold",children:v.name})]}),c.jsx(gr,{href:`/p/${v.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"}),c.jsx("button",{type:"button",onClick:()=>r({id:v.id,name:v.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:c.jsx(Bc,{className:"w-4 h-4"})})]}),c.jsx("div",{className:"divide-y divide-border",children:S.length>0?S.map(w=>{const k=a.find(T=>w.workdir.startsWith(T.workdir)),j=k?`/p/${k.id}/s/${w.id}`:"#";return c.jsx(gr,{href:j,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:c.jsx("div",{className:"flex-1 min-w-0",children:c.jsx("div",{className:"text-sm text-text-muted truncate",children:w.title??w.id.slice(0,8)})})}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx("span",{className:"text-text-muted text-xs",children:V3(w.updatedAt)}),c.jsxs("span",{className:"text-text-muted text-xs",children:[w.messageCount," msgs"]})]})]})},w.id)}):c.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},v.id)}),g.length===0&&!l&&c.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),l&&c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(Gc,{})})]}),e&&c.jsx(aM,{isOpen:e,onClose:()=>t(!1)}),n&&c.jsx(d2,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>h(n.id)})]})}function lM(){const[,e]=K_("/p/:projectId/new"),[,t]=Qr(),n=e==null?void 0:e.projectId,r=xe(l=>l.createSession),i=xe(l=>l.resetPendingSessionCreate),a=C.useCallback(async()=>{if(!n)return;const l=await r(n);l?(t(`/p/${n}/s/${l.id}`),i()):(t(`/p/${n}`),i())},[n,r,t,i]);return C.useEffect(()=>{a()},[a]),c.jsx("div",{className:"flex-1 flex items-center justify-center",children:c.jsx(Gc,{})})}function cM(){const e=Ut(t=>t.currentProject);return c.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:c.jsxs("div",{className:"max-w-md",children:[c.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),c.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),c.jsxs("div",{className:"flex flex-col gap-3",children:[e&&c.jsx(gr,{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"}),c.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const tc=e=>Math.round(e*10)/10;function uM(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function __(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function dM(e){return`${e.providerId}::${e.model}`}function hM(e){return`${e.providerName} > ${e.model}`}function A1(e){let t=0,n=0,r=0,i=0,a=0,l=0;const d=[],f=[];let h=0;for(const[x,_]of e.entries()){const v=_.stats,S=__(v);t+=v.totalTime,n+=v.toolTime,r+=v.prefillTokens,i+=v.generationTokens;const w=v.prefillSpeed>0?v.prefillTokens/v.prefillSpeed:0,k=v.generationSpeed>0?v.generationTokens/v.generationSpeed:0;a+=w,l+=k,d.push({messageId:_.id,timestamp:_.timestamp,...S,mode:v.mode,responseIndex:x+1,prefillTokens:v.prefillTokens,generationTokens:v.generationTokens,prefillSpeed:v.prefillSpeed,generationSpeed:v.generationSpeed,totalTime:v.totalTime,aiTime:v.totalTime-v.toolTime,toolTime:v.toolTime});const j=v.llmCalls??[];for(const T of j)h+=1,f.push({messageId:_.id,timestamp:T.timestamp??_.timestamp,providerId:T.providerId,providerName:T.providerName,backend:T.backend,model:T.model,mode:v.mode,responseIndex:x+1,sessionCallIndex:h,callIndex:T.callIndex,promptTokens:T.promptTokens,completionTokens:T.completionTokens,ttft:T.ttft,completionTime:T.completionTime,prefillSpeed:T.prefillSpeed,generationSpeed:T.generationSpeed,totalTime:T.totalTime,...T.temperature!==void 0&&{temperature:T.temperature},...T.topP!==void 0&&{topP:T.topP},...T.topK!==void 0&&{topK:T.topK},...T.maxTokens!==void 0&&{maxTokens:T.maxTokens}})}const p=a>0?tc(r/a):0,g=l>0?tc(i/l):0;return{totalTime:tc(t),aiTime:tc(t-n),toolTime:tc(n),prefillTokens:r,generationTokens:i,avgPrefillSpeed:p,avgGenerationSpeed:g,responseCount:e.length,llmCallCount:f.length,dataPoints:d,callDataPoints:f}}function fM(e){const t=e.filter(i=>i.stats!==void 0&&i.stats!==null&&uM(i.stats)).sort((i,a)=>new Date(i.timestamp).getTime()-new Date(a.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const i of t){const a=dM(__(i.stats)),l=n.get(a)??[];n.set(a,[...l,i])}const r=Array.from(n.entries()).map(([i,a])=>{const l=__(a[0].stats),d=A1(a);return{...l,key:i,label:hM(l),...d}});return{...A1(t),modelGroups:r}}function mM(e){return C.useMemo(()=>fM(e),[e])}function m2(){var i;const e=xe(a=>a.gitStatus),t=xe(a=>a.currentSession),[n,r]=C.useState(!0);return C.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((i=e==null?void 0:e.diff)==null?void 0:i.files)??[],loading:n,error:null}}}function rh(e){return e.toLocaleString("en-US").replace(/,/g," ")}function D1(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function pM(e){if(!Number.isFinite(e))return"0s";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 L1=["▁","▂","▃","▄","▅","▆","▇","█"];function gM(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 _M(e,t){if(e===t){const i=Math.max(Math.abs(e)*.05,1);return{minY:e-i,maxY:t+i}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function xM(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((g,x)=>g.x-x.x),r=n[0].x,i=n[n.length-1].x,a=Math.min(...n.map(g=>g.y)),l=Math.max(...n.map(g=>g.y)),{minY:d,maxY:f}=_M(a,l),h=Array.from({length:t},()=>" "),p=new Map;for(const g of n){const x=i===r?0:Math.round((g.x-r)/(i-r)*(t-1)),_=p.get(x)??[];p.set(x,[..._,g.y])}for(const[g,x]of p){const _=Math.max(...x);h[g]=L1[gM(_,d,f)]??L1[0]}return{blocks:h.join(""),minX:r,maxX:i,minY:d,maxY:f}}function R1(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function M1({data:e,width:t=60,height:n=78,label:r,xLabel:i,yLabel:a,showAxes:l=!0,formatY:d=R1,formatX:f=R1}){const h=C.useMemo(()=>{const p=xM(e,t),g=Math.max(t*6,240),x=10,_=8,S=[...e].sort((T,A)=>T.x-A.x).map(T=>{const A=p.maxX===p.minX?g/2:x+(T.x-p.minX)/(p.maxX-p.minX)*(g-x*2),P=p.maxY===p.minY?n/2:_+(p.maxY-T.y)/(p.maxY-p.minY)*(n-_*2);return{...T,cx:A,cy:P,leftPercent:A/g*100,topPercent:P/n*100}}),w=S.map((T,A)=>`${A===0?"M":"L"} ${T.cx.toFixed(1)} ${T.cy.toFixed(1)}`).join(" "),j=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(T=>({value:T,y:p.maxY===p.minY?n/2:_+(p.maxY-T)/(p.maxY-p.minY)*(n-_*2)}));return{...p,chartWidth:g,points:S,path:w,gridLines:j}},[e,n,t]);return e.length===0?c.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&c.jsx("div",{className:"mb-1",children:r}),c.jsx("div",{children:"No data"})]}):c.jsxs("div",{className:"font-mono text-xs",children:[r&&c.jsx("div",{className:"text-text-secondary mb-2",children:r}),c.jsxs("div",{className:"flex gap-3",children:[l&&c.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:h.gridLines.map(p=>c.jsx("span",{children:d(p.value)},`${p.value}-${p.y}`))}),c.jsx("div",{className:"flex-1 min-w-0",children:c.jsxs("div",{className:"relative h-[78px]",children:[c.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(p=>c.jsx("line",{x1:"0",x2:h.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),h.points.map(p=>c.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),h.points.length>1&&c.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(p=>c.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${f(p.x)} -> ${d(p.y)}`,children:c.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:c.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),l&&c.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[c.jsx("span",{className:"w-12"}),c.jsxs("span",{className:"flex-1 flex justify-between",children:[c.jsx("span",{children:f(h.minX)}),c.jsx("span",{children:i}),c.jsx("span",{children:f(h.maxX)})]})]}),a&&l&&c.jsx("div",{className:"text-text-muted mt-1 text-center",children:a})]})}function yM({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:i=60}){const a=e.map(d=>({x:d.x,y:d.ppSpeed})),l=e.map(d=>({x:d.x,y:d.tgSpeed}));return c.jsxs("div",{className:"space-y-5",children:[c.jsx(M1,{data:a,width:i,label:t,xLabel:r}),c.jsx(M1,{data:l,width:i,label:n,xLabel:r})]})}function vM(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((i,a)=>i.callIndex-a.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function bM(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 SM(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 wM(e){return e.callDataPoints.length>0?SM(e):bM(e)}function Vp(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 Na(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function gc(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function CM(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Na(t)} ctx`:`${Na(t)}-${Na(n)} ctx`}function ih(e){return`${gc(e)} t/s`}function p2(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function kM(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 EM({isOpen:e,onClose:t,stats:n}){const r=C.useRef(null),[i,a]=C.useState({}),[l,d]=C.useState(()=>{var v;return((v=n.modelGroups[0])==null?void 0:v.key)??""});C.useEffect(()=>{var v;n.modelGroups.some(S=>S.key===l)||d(((v=n.modelGroups[0])==null?void 0:v.key)??"")},[l,n.modelGroups]);const f=C.useMemo(()=>n.modelGroups.find(v=>v.key===l)??n.modelGroups[0],[l,n.modelGroups]),h=C.useMemo(()=>f?vM(f):[],[f]),p=C.useMemo(()=>f?wM(f):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[f]),g=C.useCallback(v=>{a(S=>({...S,[v]:!S[v]}))},[]),x=C.useCallback(()=>{if(!f)return;const v=kM(f);navigator.clipboard.writeText(JSON.stringify(v,null,2)).catch(S=>console.error("Failed to copy:",S))},[f]),_=C.useCallback(async()=>{if(r.current)try{const v=(await z(async()=>{const{default:k}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:k}},[])).default,S=await v(r.current,{backgroundColor:"#1a1a1a",scale:2}),w=document.createElement("a");w.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,w.href=S.toDataURL("image/png"),w.click()}catch(v){console.error("Failed to export PNG:",v),x()}},[x]);return c.jsx(jt,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:c.jsxs("div",{ref:r,className:"space-y-6",children:[c.jsx("section",{children:c.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(v=>c.jsx("button",{onClick:()=>d(v.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${v.key===(f==null?void 0:f.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:v.label,children:v.label},v.key))})}),f&&c.jsxs("section",{children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[c.jsx(Bi,{label:"AI Time",value:Vp(f.aiTime)}),c.jsx(Bi,{label:"Total Time",value:Vp(f.totalTime)}),c.jsx(Bi,{label:"Tool Time",value:Vp(f.toolTime)}),c.jsx(Bi,{label:"Responses",value:f.responseCount.toString()}),c.jsx(Bi,{label:"LLM Calls",value:f.llmCallCount.toString()})]}),c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[c.jsx(Bi,{label:"Prefill Tokens",value:Na(f.prefillTokens),subValue:`@ ${gc(f.avgPrefillSpeed)} tok/s`}),c.jsx(Bi,{label:"Gen Tokens",value:Na(f.generationTokens),subValue:`@ ${gc(f.avgGenerationSpeed)} tok/s`}),c.jsx(Bi,{label:"Avg PP Speed",value:`${gc(f.avgPrefillSpeed)}`,subValue:"tok/s"}),c.jsx(Bi,{label:"Avg TG Speed",value:`${gc(f.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),f&&p.points.length>1&&c.jsxs("section",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),c.jsx("button",{onClick:_,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),c.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:c.jsx(yM,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),f&&c.jsxs("section",{children:[c.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",f.responseCount," responses)"]}),c.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:c.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[c.jsxs("colgroup",{children:[c.jsx("col",{className:"w-[7%]"}),c.jsx("col",{className:"w-[14%]"}),c.jsx("col",{className:"w-[10%]"}),c.jsx("col",{className:"w-[14%]"}),c.jsx("col",{className:"w-[14%]"}),c.jsx("col",{className:"w-[14%]"}),c.jsx("col",{className:"w-[11%]"}),c.jsx("col",{className:"w-[2%]"})]}),c.jsx("thead",{children:c.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[c.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),c.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),c.jsx("th",{className:"px-2 py-2"})]})}),c.jsx("tbody",{children:h.map((v,S)=>c.jsxs(C.Fragment,{children:[c.jsx(NM,{row:v,index:S,isExpanded:i[v.messageId]??!1,onToggle:v.isExpandable?()=>g(v.messageId):void 0}),(i[v.messageId]??!1)&&v.calls.map((w,k)=>c.jsx(jM,{dataPoint:w,index:k},`${w.messageId}-${w.callIndex}`))]},v.messageId))})]})})]})]})})}function Bi({label:e,value:t,subValue:n}){return c.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[c.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),c.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&c.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function NM({row:e,index:t,isExpanded:n,onToggle:r}){const i=e.calls.length>0?CM(e.calls.map(a=>a.promptTokens)):`${Na(e.prefillTokens)} ctx`;return c.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[c.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:p2(e.timestamp)}),c.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:i.replace(/ ctx$/,"")}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ih(e.prefillSpeed)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ih(e.generationSpeed)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function jM({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return c.jsxs(c.Fragment,{children:[c.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[c.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]}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:p2(e.timestamp)}),c.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Na(e.promptTokens)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ih(e.prefillSpeed)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ih(e.generationSpeed)}),c.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),c.jsx("td",{className:"px-2 py-2"})]}),n&&c.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:c.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:c.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&c.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&c.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&c.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&c.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const TM={passed:{icon:"✓",color:"text-accent-success"},completed:{icon:"◉",color:"text-purple-400"},failed:{icon:"✗",color:"text-accent-error"},resolved:{icon:"✓",color:"text-accent-success"},dismissed:{icon:"–",color:"text-text-muted"},open:{icon:"○",color:"text-accent-warning"},pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"◌",color:"text-accent-warning"}},AM=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function DM(e){return TM[e]??{icon:"○",color:"text-text-muted"}}function g2(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Bh=C.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:i}=DM(t);return c.jsx("span",{className:`${i} ${n}`,children:r})});function O1({entries:e,title:t}){const n=C.useMemo(()=>e.reduce((r,i)=>(r[i.status]=(r[i.status]??0)+1,r),{}),[e]);return c.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[c.jsx("span",{children:t}),Object.keys(n).length>0&&c.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:AM.map(r=>{const i=n[r];return i?c.jsxs("span",{className:"flex items-center gap-0.5",children:[c.jsx(Bh,{status:r}),c.jsx("span",{children:i})]},r):null})})]})}const LM=C.memo(function({entries:t,title:n}){return t.length===0?null:c.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&c.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:c.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),c.jsx("div",{className:"bg-primary",children:t.map((r,i)=>c.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${i>0?"border-t border-border":""}`,children:[c.jsx(Bh,{status:r.status}),c.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[c.jsxs("span",{className:"text-text-muted",children:["[",r.id,"]"]})," ",g2(r.description)]})]},r.id??i))})]})}),RM="#6b7280";function jc(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??RM}const mt=xr(e=>{const t=async()=>{await nx("/api/agents",e,!0)};return{defaults:[],userItems:[],projectItems:[],loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await Ne(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ne(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const i=await zs("POST","/api/agents",{...n,destination:r});return i.success&&await t(),i},updateAgent:async(n,r)=>{const i=await zs("PUT",`/api/agents/${n}`,r);return i.success&&await t(),i},deleteAgent:async n=>{try{const r=await Ne(`/api/agents/${n}`,{method:"DELETE"}),i=await r.json();return r.ok?(e(a=>({userItems:a.userItems.filter(l=>l.id!==n)})),{success:!0}):{success:!1,error:i.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r)=>jh(`/api/agents/${n}/duplicate`,t,r)}}),Nt=xr((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const r=await(await Ne("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const r=await(await Ne("/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 Ne(`/api/workflows/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ne(`/api/workflows/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createWorkflow:async(n,r)=>{const i=await zs("POST","/api/workflows",{...n,destination:r});return i.success&&await t().fetchWorkflows(),i},updateWorkflow:async(n,r)=>{const i=await zs("PUT",`/api/workflows/${n}`,r);return i.success&&await t().fetchWorkflows(),i},deleteWorkflow:async n=>{try{const r=await Ne(`/api/workflows/${n}`,{method:"DELETE"}),i=await r.json();return r.ok?(e(a=>({userItems:a.userItems.filter(l=>l.id!==n)})),{success:!0}):{success:!1,error:i.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r)=>jh(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),r)})),MM={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function OM(e,t){await Ne(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function Sd({id:e,agents:t}){const n=jc(t,e),r=t.find(i=>i.id===e);return c.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function IM({id:e}){const t=Nt(l=>l.defaults),n=Nt(l=>l.userItems),i=C.useMemo(()=>[...t,...n],[t,n]).find(l=>l.id===e),a=(i==null?void 0:i.color)??"#3b82f6";return c.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${a}20`,color:a},children:(i==null?void 0:i.name)??e})}function PM({entries:e,sessionId:t}){const[n,r]=C.useState(e),[i,a]=C.useState(!1),[l,d]=C.useState(null),[f,h]=C.useState(""),[p,g]=C.useState(""),[x,_]=C.useState(!1),[v,S]=C.useState(!1),w=mt(N=>N.defaults),k=mt(N=>N.userItems),j=mt(N=>N.projectItems),T=C.useMemo(()=>[...w,...k,...j],[w,k,j]),A=C.useRef(null),P=C.useRef(null);C.useEffect(()=>{r(e)},[e]),C.useEffect(()=>{var N;i&&((N=A.current)==null||N.focus())},[i]),C.useEffect(()=>{var N;l&&((N=P.current)==null||N.focus())},[l]);const M=C.useCallback(N=>{r(N),OM(t,N)},[t]),q=C.useCallback(()=>{var se;const N=f.trim();if(!N)return;const F=String(n.length),$=[...n,{id:F,description:N,status:"pending"}];M($),h(""),(se=A.current)==null||se.focus()},[n,f,M]),Z=C.useCallback(()=>{a(!1),h("")},[]),J=C.useCallback((N,F)=>{d(N),g(F)},[]),L=C.useCallback(()=>{if(!l)return;const N=p.trim(),F=n.map($=>$.id===l?{...$,description:N||$.description}:$);M(F),d(null)},[l,p,n,M]),G=C.useCallback(N=>{const F=n.map($=>$.id===N?{...$,status:MM[$.status]??"pending"}:$);M(F)},[n,M]),H=C.useCallback(N=>{M(n.filter(F=>F.id!==N))},[n,M]),R=C.useCallback(()=>{M([]),_(!1)},[M]),U=C.useCallback(N=>{N.key==="Enter"&&(N.preventDefault(),q()),N.key==="Escape"&&Z()},[q,Z]),D=C.useCallback(N=>{N.key==="Enter"&&L(),N.key==="Escape"&&d(null)},[L]);return c.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[c.jsxs("div",{className:"bg-primary",children:[n.length===0&&!i&&c.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",c.jsx("button",{onClick:()=>S(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((N,F)=>{const $=N.status,se=l===N.id;return c.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${F>0?"border-t border-border":""}`,children:[c.jsx("button",{onClick:()=>G(N.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${N.status} (click to cycle)`,children:c.jsx(Bh,{status:$})}),c.jsx("div",{className:"flex-1 min-w-0",children:se?c.jsx("input",{ref:P,value:p,onChange:B=>g(B.target.value),onBlur:L,onKeyDown:D,className:"w-full bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary"}):c.jsxs("button",{onClick:()=>J(N.id,N.description),className:"text-xs text-text-primary text-left hover:text-accent-primary transition-colors w-full truncate cursor-pointer",title:"Click to edit",children:["[",N.id,"] ",g2(N.description)]})}),c.jsx("button",{onClick:()=>H(N.id),className:"flex-shrink-0 opacity-0 group-hover:opacity-100 text-text-muted hover:text-accent-error transition-all ml-0.5 cursor-pointer flex items-center self-center",title:"Delete criterion",children:c.jsx(zc,{className:"w-4 h-4"})})]},N.id)})]}),i&&c.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),c.jsx("input",{ref:A,value:f,onChange:N=>h(N.target.value),onKeyDown:U,placeholder:"New criterion...",className:"flex-1 bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"})]})}),c.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[i?c.jsxs(c.Fragment,{children:[c.jsxs("button",{onClick:q,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[c.jsx($s,{className:"w-3 h-3"}),"Add"]}),c.jsx("button",{onClick:Z,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):c.jsxs("button",{onClick:()=>a(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[c.jsx($s,{className:"w-3 h-3"}),"Add"]}),n.length>0&&c.jsxs("button",{onClick:()=>_(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all criteria",children:[c.jsx(Bc,{className:"w-3 h-3"}),"Clear all"]}),c.jsx("button",{onClick:()=>S(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:c.jsx(ZC,{className:"w-3 h-3"})})]}),x&&c.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:c.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[c.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:R,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),c.jsx("button",{onClick:()=>_(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})}),c.jsx(jt,{isOpen:v,onClose:()=>S(!1),title:"About Acceptance Criteria",size:"md",children:c.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[c.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),c.jsxs("p",{children:["To use this feature, start in ",c.jsx(Sd,{id:"planner",agents:T})," mode and",c.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",c.jsx(IM,{id:"default"})," builtin workflow to launch the automation part."]}),c.jsx("p",{children:"This workflow will automatically:"}),c.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[c.jsxs("li",{children:["Launch the ",c.jsx(Sd,{id:"builder",agents:T}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),c.jsxs("li",{children:["Then launch the ",c.jsx(Sd,{id:"verifier",agents:T})," subagent, that will verify each criterion. If every criterion is fulfilled, then it goes to the next step, otherwise, it gives feedback to the main agent until 100% of the criteria are met."]}),c.jsxs("li",{children:["Launch a ",c.jsx(Sd,{id:"code_reviewer",agents:T})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),c.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:c.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function BM({isOpen:e,onClose:t}){const n=di(S=>S.config),r=di(S=>S.saveConfig),[i,a]=C.useState(""),[l,d]=C.useState(""),[f,h]=C.useState(!1),[p,g]=C.useState(!1),[x,_]=C.useState(!1);C.useEffect(()=>{e&&(a((n==null?void 0:n.command)??""),d((n==null?void 0:n.url)??""),h((n==null?void 0:n.hotReload)??!1),g((n==null?void 0:n.disableInspect)??!1))},[e,n]);const v=async()=>{!i.trim()||!l.trim()||(_(!0),await r({command:i.trim(),url:l.trim(),hotReload:f,disableInspect:p}),_(!1),t())};return c.jsx(jt,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),c.jsx("input",{className:"input w-full",type:"text",value:i,onChange:S=>a(S.target.value),placeholder:"npm run dev"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),c.jsx("input",{className:"input w-full",type:"text",value:l,onChange:S=>d(S.target.value),placeholder:"http://localhost:3000"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"hotReload",checked:f,onChange:S=>h(S.target.checked),className:"rounded border-border bg-bg-tertiary"}),c.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:S=>g(S.target.checked),className:"rounded border-border bg-bg-tertiary"}),c.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[c.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),c.jsx("button",{className:"btn btn-primary",onClick:v,disabled:x||!i.trim()||!l.trim(),children:x?"Saving...":"Save"})]})]})})}const I1={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"},zM={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"},P1={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},$M="text-text-primary";function HM(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,i="text-text-primary",a;try{for(;(a=n.exec(e))!==null;){if(a.index>r){const h=e.slice(r,a.index);h&&t.push({text:h,className:i})}const l=a[1];if(!l)continue;const d=l.split(";").map(Number);if(d.length===0||d[0]===0){i="text-text-primary";continue}const f=[];for(const h of d)if(h>=30&&h<=37){const p=I1[h];p&&f.push(p)}else if(h>=40&&h<=47){const p=zM[h];p&&f.push(p)}else if(h>=90&&h<=97){const p=I1[h];p&&f.push(p)}else if(h in P1){const p=P1[h];p&&f.push(p)}else h===39?f.push($M):h===49&&(i=i.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));f.length>0&&(i=f.join(" ")),r=n.lastIndex}if(r<e.length){const l=e.slice(r);l&&t.push({text:l,className:i})}return t}catch(l){return console.warn("ANSI parsing failed, stripping codes:",l),[{text:FM(e),className:"text-text-primary"}]}}function FM(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function sh(e){const t=HM(e),n=[];return t.forEach((r,i)=>{const a=r.text.split(`
106
+ `);a.forEach((l,d)=>{n.push(Ls.createElement("span",{key:`${i}-${d}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},l)),d<a.length-1&&n.push(Ls.createElement("br",{key:`${i}-${d}-br`}))})}),n.length===1?n[0]:n}function _2({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return c.jsx("pre",{ref:t,className:n,children:e.length===0?c.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((r,i)=>c.jsx("span",{className:r.stream==="stderr"?"text-accent-warning":"",children:sh(r.content)},i))})}const x2=C.memo(function({title:t,logs:n,onClose:r,preClassName:i}){const a=C.useRef(null);return C.useEffect(()=>{a.current&&(a.current.scrollTop=a.current.scrollHeight)},[n]),c.jsx(jt,{isOpen:!0,onClose:r,title:t,size:"full",children:c.jsx(_2,{logs:n,preRef:a,preClassName:i})})}),UM=C.memo(function({logs:t,anchorRef:n,isHiding:r,onExpand:i,onClose:a}){const[l,d]=C.useState(null),f=C.useRef(null);return C.useEffect(()=>{var p;const h=(p=n.current)==null?void 0:p.getBoundingClientRect();h&&d({bottom:window.innerHeight-h.bottom,right:window.innerWidth-h.right,width:h.width,height:h.height})},[n]),C.useEffect(()=>{f.current&&(f.current.scrollTop=f.current.scrollHeight)},[t]),l?c.jsxs("div",{className:"relative",children:[c.jsx("pre",{ref:f,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:l.bottom,right:l.right,width:l.width*2,maxHeight:l.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1},children:t.map((h,p)=>c.jsx("span",{className:h.stream==="stderr"?"text-accent-warning":"",children:sh(h.content)},p))}),c.jsx("button",{onClick:()=>{a(),i()},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:l.bottom+8,right:l.right+8},children:"Expand"})]}):null}),VM=C.memo(function({workdir:t}){const n=di(H=>H.setWorkdir),r=di(H=>H.status),i=di(H=>H.config),a=di(H=>H.logs),l=di(H=>H.start),d=di(H=>H.stop),f=di(H=>H.fetchLogs),h=xe(H=>H.currentSession),[p,g]=C.useState(!1),[x,_]=C.useState(!1),[v,S]=C.useState(!1),[w,k]=C.useState(!1),j=C.useRef(null),T=C.useRef(null),A=C.useRef(null),P=C.useRef(null),M=C.useRef(null),q=()=>{const H=r==null?void 0:r.inspectProxyPort;if(!H){r!=null&&r.url&&window.open(r.url,"_blank");return}const R=`${window.location.protocol}//${window.location.hostname}:${H}`,U=window.open(R,"_blank");if(U){M.current=U;const D=()=>{var F;!M.current||M.current.closed||(M.current.postMessage({type:"setFoxSessionId",sessionId:(h==null?void 0:h.id)??null},"*"),M.current.postMessage({type:"setFoxSessionTitle",sessionTitle:((F=h==null?void 0:h.metadata)==null?void 0:F.title)??null},"*"),M.current.postMessage({type:"setFoxInspectEnabled",enabled:!(i!=null&&i.disableInspect)},"*"))},N=setInterval(()=>{D(),(!M.current||M.current.closed)&&clearInterval(N)},500);setTimeout(()=>clearInterval(N),5e3)}},Z=(r==null?void 0:r.state)??"off",J=i!==null,L=Z==="running"||Z==="warning";C.useEffect(()=>{n(t??null)},[t,n]),C.useEffect(()=>{L&&f()},[L,f]),C.useEffect(()=>{A.current&&L&&(A.current.scrollTop=A.current.scrollHeight)},[a,L]);const G=()=>{L?d():l()};return c.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${Z==="running"?"bg-accent-success":Z==="warning"?"bg-accent-warning":Z==="error"?"bg-accent-error":"bg-text-muted"}`}),c.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),c.jsx("button",{onClick:()=>g(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:c.jsx(WD,{})})]}),J?c.jsxs(c.Fragment,{children:[Z==="running"||Z==="warning"?c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{onClick:G,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:[c.jsx(tk,{}),"Stop"]}),(r==null?void 0:r.url)&&c.jsxs("button",{onClick:()=>q(),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:[c.jsx(qD,{}),"Open"]})]}):c.jsx("button",{onClick:G,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"}),L&&c.jsxs("div",{ref:P,className:"relative",onMouseEnter:()=>{T.current&&clearTimeout(T.current),j.current=setTimeout(()=>{S(!0),k(!1)},500)},onMouseLeave:()=>{j.current&&clearTimeout(j.current),k(!0),T.current=setTimeout(()=>S(!1),150)},children:[c.jsx(_2,{logs:a,preRef:A,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),(v||w)&&P.current&&La.createPortal(c.jsx(UM,{logs:a,anchorRef:P,isHiding:w,onExpand:()=>_(!0),onClose:()=>S(!1)}),document.body)]})]}):c.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"}),c.jsx(BM,{isOpen:p,onClose:()=>g(!1)}),x&&c.jsx(x2,{title:"Dev Server Logs",logs:a,onClose:()=>_(!1)})]})}),WM=C.memo(function({sessionId:t}){var _;const n=xc(v=>v.processes),r=xc(v=>v.stopProcess),[i,a]=C.useState(null),[l,d]=C.useState([]),f=n.filter(v=>v.status!=="exited"),h=f.filter(v=>v.status==="running").length;if(n.length===0)return null;const p=v=>{switch(v){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=v=>{const S=xc.getState().logs[v]??[];d(S.map(w=>({content:w.content,stream:w.stream}))),a(v)},x=v=>{t&&r(v,t)};return c.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[c.jsx("div",{className:"flex items-center justify-between",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),c.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),c.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),c.jsx("div",{className:"space-y-2",children:f.map(v=>c.jsx("div",{className:"border border-border rounded p-2",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[c.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(v.status)}`}),c.jsx("span",{className:"text-sm text-text-primary truncate",title:v.name,children:v.name}),c.jsxs("span",{className:"text-xs text-text-muted",children:["[",v.status,"]"]})]}),c.jsxs("div",{className:"flex gap-1 ml-2",children:[c.jsx("button",{onClick:()=>g(v.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"}),c.jsx("button",{onClick:()=>x(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"})]})]})},v.id))}),i&&c.jsx(x2,{title:((_=f.find(v=>v.id===i))==null?void 0:_.name)??"",logs:l,onClose:()=>{a(null),d([])}})]})});function GM({isOpen:e,onClose:t,versionInfo:n}){const[r,i]=C.useState("ready"),[a,l]=C.useState("waiting"),[d,f]=C.useState(""),[h,p]=C.useState(n),[g,x]=C.useState(!1),_=C.useRef(!1);C.useEffect(()=>{if(e){if(n){p(n);return}fetch("/api/auto-update/check").then(w=>w.json()).then(w=>{p({current:w.current,latest:w.latest}),x(w.isService??!1)}).catch(()=>{})}},[e]),C.useEffect(()=>{if(!e||r!=="updating")return;const w=setInterval(()=>{f(k=>k.length>=3?"":k+".")},400);return()=>clearInterval(w)},[e,r]);const v=C.useCallback(async()=>{i("updating"),l("waiting"),_.current=!1;const w=(h==null?void 0:h.current)==="1.0.0"&&(h==null?void 0:h.latest)==="1.1.0",k=await Ne("/api/auto-update",{method:"POST"}),{isService:j}=await k.json();if(w){setTimeout(()=>{i("reloading"),localStorage.setItem("openfox_updated_to",(h==null?void 0:h.latest)??"unknown"),localStorage.setItem("update_pending","true"),setTimeout(()=>window.location.reload(),1e3)},5e3);return}if(!j){setTimeout(()=>{i("complete")},8e3);return}let T=!1;const A=setInterval(async()=>{try{(await fetch("/api/health")).ok&&_.current&&(T=!0,clearInterval(A),i("reloading"),localStorage.setItem("openfox_updated_to",(h==null?void 0:h.latest)??"unknown"),localStorage.setItem("update_pending","true"),window.location.reload())}catch{_.current=!0}},2e3);setTimeout(()=>{T||l("takingLonger")},6e4),setTimeout(()=>{T||(clearInterval(A),i("failed"))},12e4)},[h==null?void 0:h.current,h==null?void 0:h.latest]);C.useEffect(()=>{e&&(i("ready"),l("waiting"),f(""),_.current=!1)},[e]);const S=r!=="updating";return c.jsxs(jt,{isOpen:e,onClose:S?t:void 0,title:r==="failed"?"Update Failed":r==="complete"?"Update Complete":"New OpenFox Version Available",size:"sm",closeOnBackdropClick:S,showCloseButton:S,children:[c.jsxs("div",{className:"flex flex-col gap-4",children:[h&&c.jsxs("div",{className:"flex justify-between text-sm",children:[c.jsx("span",{className:"text-text-muted",children:"Current version"}),c.jsx("span",{className:"text-text-primary font-mono",children:h.current})]}),h&&c.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[c.jsx("span",{className:"text-text-muted",children:"Latest version"}),c.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:h.latest})]}),r==="updating"&&c.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[c.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),c.jsx("p",{className:"text-xs text-text-muted text-center",children:a==="takingLonger"?"Taking longer than expected…":`Updating${d}`})]}),r==="reloading"&&c.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[c.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),c.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Update complete, reloading",d]})]}),r==="complete"&&c.jsx("div",{className:"flex flex-col gap-3 mt-2",children:c.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h==null?void 0:h.latest,". Please relaunch OpenFox to use the new version."]})}),r==="failed"&&c.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-danger/10 border border-accent-danger/30 rounded text-xs",children:[c.jsx("span",{children:"⚠️"}),c.jsx("p",{className:"text-text-secondary",children:"The update timed out. The server may need to be updated manually."})]}),c.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),c.jsxs("p",{className:"text-xs text-text-muted",children:["Run this command in your terminal to complete the update, then start the service with"," ",c.jsx("span",{className:"font-mono text-text-secondary",children:"openfox service start"}),"."]})]})]}),r==="ready"&&c.jsx("button",{onClick:v,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==="complete"||r==="failed")&&c.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"}),r==="ready"&&g&&c.jsx("div",{className:"flex justify-center mt-2",children:c.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:[c.jsx("span",{children:"⚠️"}),c.jsx("p",{className:"text-text-secondary",children:"Server will restart to apply this update. Sessions in progress will be interrupted."})]})})]})}function qM({file:e}){const t=u2(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 c.jsxs("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:[c.jsx("span",{className:`truncate ${n}`,title:e.path,children:t}),r&&c.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 KM(){const{diff:e}=m2();return e.loading?c.jsx("div",{className:"mt-3",children:c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[c.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),c.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?c.jsx("div",{className:"mt-3",children:c.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):c.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:c.jsx("div",{className:"pr-1",children:e.files.map((t,n)=>c.jsx(qM,{file:t},n))})})}function B1({messages:e,workdir:t}){var S,w,k,j;const[n,r]=C.useState(!1),[i,a]=C.useState(!1),[l,d]=C.useState(!1),[f,h]=C.useState(!1),p=mM(e),{branch:g}=m2(),x=Ot(T=>T.version),_=xe(T=>T.currentSession),v=C.useCallback(async()=>{a(!0);try{const T=await fetch("/api/auto-update/check");if(T.ok){const A=await T.json();d(A.isUpdateAvailable)}}catch{}finally{a(!1)}},[]);return C.useEffect(()=>{v()},[v]),C.useEffect(()=>{if(new URLSearchParams(window.location.search).get("test-update")==="1"){d(!0),h(!0);const A=new URL(window.location.href);A.searchParams.delete("test-update"),window.history.replaceState({},"",A.toString())}},[]),c.jsxs("div",{className:"flex flex-col h-full",children:[p&&c.jsxs("div",{className:"mb-4",children:[c.jsx("button",{onClick:()=>r(!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:c.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[c.jsx("span",{className:"text-text-secondary",children:pM(p.aiTime)}),c.jsx("span",{className:"w-px h-3 bg-border"}),c.jsx("span",{className:"text-text-secondary",children:D1(p.avgPrefillSpeed)}),c.jsx("span",{children:"pp"}),c.jsx("span",{className:"w-px h-3 bg-border"}),c.jsx("span",{className:"text-text-secondary",children:D1(p.avgGenerationSpeed)}),c.jsx("span",{children:"tg"})]})}),c.jsx(EM,{isOpen:n,onClose:()=>r(!1),stats:p})]}),c.jsx("div",{className:"flex flex-col flex-1 overflow-y-auto",children:c.jsxs("div",{className:"mt-4",children:[c.jsx(O1,{entries:((S=_==null?void 0:_.metadataEntries)==null?void 0:S.criteria)??[],title:"Acceptance Criteria"}),_&&c.jsx(PM,{entries:((w=_==null?void 0:_.metadataEntries)==null?void 0:w.criteria)??[],sessionId:_.id}),_&&(((j=(k=_.metadataEntries)==null?void 0:k.review_findings)==null?void 0:j.length)??0)>0&&c.jsxs("div",{className:"mt-6",children:[c.jsx(O1,{entries:_.metadataEntries.review_findings,title:"Review Findings"}),c.jsx(LM,{entries:_.metadataEntries.review_findings})]})]})}),g&&c.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[c.jsx($D,{}),c.jsx("span",{className:"truncate text-text-secondary",title:g,children:g})]}),c.jsx(KM,{}),c.jsx(VM,{workdir:t}),c.jsx(WM,{sessionId:_==null?void 0:_.id}),x&&c.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[c.jsxs("div",{className:"flex items-center justify-center gap-1",children:[c.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",c.jsxs("span",{className:"font-mono",children:["v",x]}),c.jsx("button",{onClick:()=>v(),disabled:i,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:c.jsx(J_,{className:`w-3 h-3 ${i?"animate-spin":""}`})})]}),l&&c.jsx("button",{onClick:()=>h(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"})]}),c.jsx(GM,{isOpen:f,onClose:()=>h(!1),versionInfo:null})]})}function YM({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const i=xe(a=>a.currentSession);return c.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&c.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),c.jsxs("div",{className:"flex h-full",children:[c.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?c.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary",children:c.jsx(B1,{messages:r,workdir:i==null?void 0:i.workdir})}):c.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),c.jsx("aside",{className:`
107
+ md:hidden
108
+ p-4 overflow-y-auto bg-secondary
109
+ transition-all duration-300 ease-in-out
110
+ fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
111
+ ${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
112
+ `,children:c.jsx(B1,{messages:r,workdir:i==null?void 0:i.workdir})})]})]})}function XM(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function y2({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const i=n==="sm"?"w-12":"w-20",a=n==="sm"?"h-1":"h-1.5";return c.jsx("div",{className:`${a} bg-bg-tertiary rounded-full overflow-hidden ${i} ${r}`,children:c.jsx("div",{className:`h-full transition-all duration-300 ${XM(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function QM({dangerZone:e,size:t="md"}){return e?c.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function z1(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function JM(){const e=xe(j=>j.contextState),t=xe(j=>j.currentSession),n=xe(j=>j.compactContext),[r,i]=C.useState(!1),[a,l]=C.useState(!1),[d,f]=C.useState(!1),h=C.useRef(!1);if(C.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!h.current&&l(!1),h.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),!e||!t)return null;const{currentTokens:p,maxTokens:g,compactionCount:x,dangerZone:_,dynamicContextChanged:v}=e,S=Math.round(p/g*100),w=t.isRunning,k=()=>{Ft.send("context.applyDynamic",{}),l(!0)};return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:z1(S,_),children:[rh(p)," / ",rh(g)]}),c.jsxs("span",{className:z1(S,_),children:["(",S,"%)"]}),c.jsx(y2,{percent:S,dangerZone:_}),c.jsx(QM,{dangerZone:_}),x>0&&c.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"x"]})]}),c.jsx("div",{className:"flex-1 flex justify-end",children:c.jsxs("div",{className:"relative",children:[c.jsx("button",{onClick:()=>i(!r),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:c.jsx(ek,{})}),r&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>i(!1)}),c.jsxs("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:[c.jsx("button",{onClick:()=>{w||n(),i(!1)},disabled:w,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:w?"Cannot compact while running":"Compact context",children:c.jsx("span",{className:_?"text-accent-error":"",children:"Compact"})}),v&&c.jsx("button",{onClick:()=>{i(!1),f(!0)},disabled:w,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:w?"Cannot apply while running":"Apply dynamic context",children:c.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]})})]})}),v&&!a&&c.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[c.jsx("span",{children:"System prompt has changed —"}),c.jsx("button",{onClick:()=>f(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),c.jsx("button",{onClick:()=>l(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:c.jsx(zc,{})})]})}),c.jsxs(jt,{isOpen:d,onClose:()=>f(!1),title:"Update system prompt",size:"sm",children:[c.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Applying the new system prompt will rebuild the cached prompt, which may cause the next response to take longer while the LLM reprocesses the prefix."}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:()=>f(!1),className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),c.jsx("button",{onClick:()=>{k(),f(!1)},disabled:w,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Update"})]})]})]})}function ZM({stats:e,onClose:t}){var n;return c.jsx(jt,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:c.jsxs("div",{className:"space-y-4",children:[c.jsx("div",{className:"flex items-center gap-3",children:c.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",e.mode]})}),c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[c.jsx(wd,{label:"Total Time",value:`${e.totalTime.toFixed(1)}s`}),c.jsx(wd,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),c.jsx(wd,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),c.jsx(wd,{label:"LLM Calls",value:String(((n=e.llmCalls)==null?void 0:n.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&c.jsxs("div",{children:[c.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((r,i)=>c.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",i+1]}),c.jsxs("span",{className:"text-xs text-text-muted",children:[r.ttft.toFixed(2),"s TTFT · ",r.completionTime.toFixed(2),"s gen"]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[c.jsxs("div",{children:[c.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",c.jsxs("span",{className:"text-text-primary",children:[r.promptTokens," → ",r.completionTokens]})]}),c.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[r.temperature!==void 0&&c.jsx(Cd,{label:"temp",value:r.temperature.toFixed(2)}),r.topP!==void 0&&c.jsx(Cd,{label:"topP",value:r.topP.toFixed(2)}),r.topK!==void 0&&c.jsx(Cd,{label:"topK",value:String(r.topK)}),r.maxTokens!==void 0&&c.jsx(Cd,{label:"maxTok",value:String(r.maxTokens)})]})]})]},i))]})]})})}function wd({label:e,value:t}){return c.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[c.jsx("div",{className:"text-xs text-text-muted",children:e}),c.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function Cd({label:e,value:t}){return c.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[c.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}function v2(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const eO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nO={};function $1(e,t){return(nO.jsx?tO:eO).test(e)}const rO=/[ \t\n\f\r]/g;function zh(e){return typeof e=="object"?e.type==="text"?H1(e.value):!1:H1(e)}function H1(e){return e.replace(rO,"")===""}class qc{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}qc.prototype.normal={};qc.prototype.property={};qc.prototype.space=void 0;function b2(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new qc(n,r,t)}function x_(e){return e.toLowerCase()}class ir{constructor(t,n){this.attribute=n,this.property=t}}ir.prototype.attribute="";ir.prototype.booleanish=!1;ir.prototype.boolean=!1;ir.prototype.commaOrSpaceSeparated=!1;ir.prototype.commaSeparated=!1;ir.prototype.defined=!1;ir.prototype.mustUseProperty=!1;ir.prototype.number=!1;ir.prototype.overloadedBoolean=!1;ir.prototype.property="";ir.prototype.spaceSeparated=!1;ir.prototype.space=void 0;let iO=0;const Ye=Ma(),on=Ma(),y_=Ma(),be=Ma(),At=Ma(),Ho=Ma(),pr=Ma();function Ma(){return 2**++iO}const v_=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ye,booleanish:on,commaOrSpaceSeparated:pr,commaSeparated:Ho,number:be,overloadedBoolean:y_,spaceSeparated:At},Symbol.toStringTag,{value:"Module"})),Wp=Object.keys(v_);class _x extends ir{constructor(t,n,r,i){let a=-1;if(super(t,n),F1(this,"space",i),typeof r=="number")for(;++a<Wp.length;){const l=Wp[a];F1(this,Wp[a],(r&v_[l])===v_[l])}}}_x.prototype.defined=!0;function F1(e,t,n){n&&(e[t]=n)}function Xo(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const a=new _x(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[x_(r)]=r,n[x_(a.attribute)]=r}return new qc(t,n,e.space)}const S2=Xo({properties:{ariaActiveDescendant:null,ariaAtomic:on,ariaAutoComplete:null,ariaBusy:on,ariaChecked:on,ariaColCount:be,ariaColIndex:be,ariaColSpan:be,ariaControls:At,ariaCurrent:null,ariaDescribedBy:At,ariaDetails:null,ariaDisabled:on,ariaDropEffect:At,ariaErrorMessage:null,ariaExpanded:on,ariaFlowTo:At,ariaGrabbed:on,ariaHasPopup:null,ariaHidden:on,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:At,ariaLevel:be,ariaLive:null,ariaModal:on,ariaMultiLine:on,ariaMultiSelectable:on,ariaOrientation:null,ariaOwns:At,ariaPlaceholder:null,ariaPosInSet:be,ariaPressed:on,ariaReadOnly:on,ariaRelevant:null,ariaRequired:on,ariaRoleDescription:At,ariaRowCount:be,ariaRowIndex:be,ariaRowSpan:be,ariaSelected:on,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 w2(e,t){return t in e?e[t]:t}function C2(e,t){return w2(e,t.toLowerCase())}const sO=Xo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ho,acceptCharset:At,accessKey:At,action:null,allow:null,allowFullScreen:Ye,allowPaymentRequest:Ye,allowUserMedia:Ye,alt:null,as:null,async:Ye,autoCapitalize:null,autoComplete:At,autoFocus:Ye,autoPlay:Ye,blocking:At,capture:null,charSet:null,checked:Ye,cite:null,className:At,cols:be,colSpan:null,content:null,contentEditable:on,controls:Ye,controlsList:At,coords:be|Ho,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ye,defer:Ye,dir:null,dirName:null,disabled:Ye,download:y_,draggable:on,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ye,formTarget:null,headers:At,height:be,hidden:y_,high:be,href:null,hrefLang:null,htmlFor:At,httpEquiv:At,id:null,imageSizes:null,imageSrcSet:null,inert:Ye,inputMode:null,integrity:null,is:null,isMap:Ye,itemId:null,itemProp:At,itemRef:At,itemScope:Ye,itemType:At,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ye,low:be,manifest:null,max:null,maxLength:be,media:null,method:null,min:null,minLength:be,multiple:Ye,muted:Ye,name:null,nonce:null,noModule:Ye,noValidate:Ye,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:Ye,optimum:be,pattern:null,ping:At,placeholder:null,playsInline:Ye,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ye,referrerPolicy:null,rel:At,required:Ye,reversed:Ye,rows:be,rowSpan:be,sandbox:At,scope:null,scoped:Ye,seamless:Ye,selected:Ye,shadowRootClonable:Ye,shadowRootDelegatesFocus:Ye,shadowRootMode:null,shape:null,size:be,sizes:null,slot:null,span:be,spellCheck:on,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:Ye,useMap:null,value:on,width:be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:At,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:Ye,declare:Ye,event:null,face:null,frame:null,frameBorder:null,hSpace:be,leftMargin:be,link:null,longDesc:null,lowSrc:null,marginHeight:be,marginWidth:be,noResize:Ye,noHref:Ye,noShade:Ye,noWrap:Ye,object:null,profile:null,prompt:null,rev:null,rightMargin:be,rules:null,scheme:null,scrolling:on,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:Ye,disableRemotePlayback:Ye,prefix:null,property:null,results:be,security:null,unselectable:null},space:"html",transform:C2}),aO=Xo({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:pr,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:At,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:Ye,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:Ho,g2:Ho,glyphName:Ho,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:pr,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:At,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:be,pointsAtY:be,pointsAtZ:be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pr,rev:pr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pr,requiredFeatures:pr,requiredFonts:pr,requiredFormats:pr,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:pr,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:pr,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:pr,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:w2}),k2=Xo({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()}}),E2=Xo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:C2}),N2=Xo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),oO={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"},lO=/[A-Z]/g,U1=/-[a-z]/g,cO=/^data[-\w.:]+$/i;function j2(e,t){const n=x_(t);let r=t,i=ir;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&cO.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(U1,dO);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!U1.test(a)){let l=a.replace(lO,uO);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}i=_x}return new i(r,t)}function uO(e){return"-"+e.toLowerCase()}function dO(e){return e.charAt(1).toUpperCase()}const T2=b2([S2,sO,k2,E2,N2],"html"),Kc=b2([S2,aO,k2,E2,N2],"svg");function A2(e){return e.join(" ").trim()}var jo={},Gp,V1;function hO(){if(V1)return Gp;V1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,d=/^\s+|\s+$/g,f=`
113
+ `,h="/",p="*",g="",x="comment",_="declaration";function v(w,k){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];k=k||{};var j=1,T=1;function A(U){var D=U.match(t);D&&(j+=D.length);var N=U.lastIndexOf(f);T=~N?U.length-N:T+U.length}function P(){var U={line:j,column:T};return function(D){return D.position=new M(U),J(),D}}function M(U){this.start=U,this.end={line:j,column:T},this.source=k.source}M.prototype.content=w;function q(U){var D=new Error(k.source+":"+j+":"+T+": "+U);if(D.reason=U,D.filename=k.source,D.line=j,D.column=T,D.source=w,!k.silent)throw D}function Z(U){var D=U.exec(w);if(D){var N=D[0];return A(N),w=w.slice(N.length),D}}function J(){Z(n)}function L(U){var D;for(U=U||[];D=G();)D!==!1&&U.push(D);return U}function G(){var U=P();if(!(h!=w.charAt(0)||p!=w.charAt(1))){for(var D=2;g!=w.charAt(D)&&(p!=w.charAt(D)||h!=w.charAt(D+1));)++D;if(D+=2,g===w.charAt(D-1))return q("End of comment missing");var N=w.slice(2,D-2);return T+=2,A(N),w=w.slice(D),T+=2,U({type:x,comment:N})}}function H(){var U=P(),D=Z(r);if(D){if(G(),!Z(i))return q("property missing ':'");var N=Z(a),F=U({type:_,property:S(D[0].replace(e,g)),value:N?S(N[0].replace(e,g)):g});return Z(l),F}}function R(){var U=[];L(U);for(var D;D=H();)D!==!1&&(U.push(D),L(U));return U}return J(),R()}function S(w){return w?w.replace(d,g):g}return Gp=v,Gp}var W1;function fO(){if(W1)return jo;W1=1;var e=jo&&jo.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(jo,"__esModule",{value:!0}),jo.default=n;const t=e(hO());function n(r,i){let a=null;if(!r||typeof r!="string")return a;const l=(0,t.default)(r),d=typeof i=="function";return l.forEach(f=>{if(f.type!=="declaration")return;const{property:h,value:p}=f;d?i(h,p,f):p&&(a=a||{},a[h]=p)}),a}return jo}var nc={},G1;function mO(){if(G1)return nc;G1=1,Object.defineProperty(nc,"__esModule",{value:!0}),nc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(h){return!h||n.test(h)||e.test(h)},l=function(h,p){return p.toUpperCase()},d=function(h,p){return"".concat(p,"-")},f=function(h,p){return p===void 0&&(p={}),a(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(i,d):h=h.replace(r,d),h.replace(t,l))};return nc.camelCase=f,nc}var rc,q1;function pO(){if(q1)return rc;q1=1;var e=rc&&rc.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(fO()),n=mO();function r(i,a){var l={};return!i||typeof i!="string"||(0,t.default)(i,function(d,f){d&&f&&(l[(0,n.camelCase)(d,a)]=f)}),l}return r.default=r,rc=r,rc}var gO=pO();const _O=Ch(gO),D2=L2("end"),xx=L2("start");function L2(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 xO(e){const t=xx(e),n=D2(e);if(t&&n)return{start:t,end:n}}function vc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?K1(e.position):"start"in e||"end"in e?K1(e):"line"in e||"column"in e?b_(e):""}function b_(e){return Y1(e&&e.line)+":"+Y1(e&&e.column)}function K1(e){return b_(e&&e.start)+"-"+b_(e&&e.end)}function Y1(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 i="",a={},l=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(l=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const f=r.indexOf(":");f===-1?a.ruleId=r:(a.source=r.slice(0,f),a.ruleId=r.slice(f+1))}if(!a.place&&a.ancestors&&a.ancestors){const f=a.ancestors[a.ancestors.length-1];f&&(a.place=f.position)}const d=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=d?d.line:void 0,this.name=vc(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=l&&a.cause&&typeof a.cause.stack=="string"?a.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 yx={}.hasOwnProperty,yO=new Map,vO=/[A-Z]/g,bO=new Set(["table","tbody","thead","tfoot","tr"]),SO=new Set(["td","th"]),R2="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wO(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=DO(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=AO(n,t.jsx,t.jsxs)}const i={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"?Kc:T2,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=M2(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function M2(e,t,n){if(t.type==="element")return CO(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return kO(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return NO(e,t,n);if(t.type==="mdxjsEsm")return EO(e,t);if(t.type==="root")return jO(e,t,n);if(t.type==="text")return TO(e,t)}function CO(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Kc,e.schema=i),e.ancestors.push(t);const a=I2(e,t.tagName,!1),l=LO(e,t);let d=bx(e,t);return bO.has(t.tagName)&&(d=d.filter(function(f){return typeof f=="string"?!zh(f):!0})),O2(e,l,a,t),vx(l,d),e.ancestors.pop(),e.schema=r,e.create(t,a,l,n)}function kO(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)}Tc(e,t.position)}function EO(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Tc(e,t.position)}function NO(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Kc,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:I2(e,t.name,!0),l=RO(e,t),d=bx(e,t);return O2(e,l,a,t),vx(l,d),e.ancestors.pop(),e.schema=r,e.create(t,a,l,n)}function jO(e,t,n){const r={};return vx(r,bx(e,t)),e.create(t,e.Fragment,r,n)}function TO(e,t){return t.value}function O2(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function vx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function AO(e,t,n){return r;function r(i,a,l,d){const h=Array.isArray(l.children)?n:t;return d?h(a,l,d):h(a,l)}}function DO(e,t){return n;function n(r,i,a,l){const d=Array.isArray(a.children),f=xx(r);return t(i,a,l,d,{columnNumber:f?f.column-1:void 0,fileName:e,lineNumber:f?f.line:void 0},void 0)}}function LO(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&yx.call(t.properties,i)){const a=MO(e,i,t.properties[i]);if(a){const[l,d]=a;e.tableCellAlignToStyle&&l==="align"&&typeof d=="string"&&SO.has(t.tagName)?r=d:n[l]=d}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function RO(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const l=a.expression;l.type;const d=l.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else Tc(e,t.position);else{const i=r.name;let a;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,a=e.evaluater.evaluateExpression(d.expression)}else Tc(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function bx(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:yO;for(;++r<t.children.length;){const a=t.children[r];let l;if(e.passKeys){const f=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(f){const h=i.get(f)||0;l=f+"-"+h,i.set(f,h+1)}}const d=M2(e,a,l);d!==void 0&&n.push(d)}return n}function MO(e,t,n){const r=j2(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?v2(n):A2(n)),r.property==="style"){let i=typeof n=="object"?n:OO(e,String(n));return e.stylePropertyNameCase==="css"&&(i=IO(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?oO[r.property]||r.property:r.attribute,n]}}function OO(e,t){try{return _O(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Hn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=R2+"#cannot-parse-style-attribute",i}}function I2(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let a=-1,l;for(;++a<i.length;){const d=$1(i[a])?{type:"Identifier",name:i[a]}:{type:"Literal",value:i[a]};l=l?{type:"MemberExpression",object:l,property:d,computed:!!(a&&d.type==="Literal"),optional:!1}:d}r=l}else r=$1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return yx.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Tc(e)}function Tc(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=R2+"#cannot-handle-mdx-estrees-without-createevaluater",n}function IO(e){const t={};let n;for(n in e)yx.call(e,n)&&(t[PO(n)]=e[n]);return t}function PO(e){let t=e.replace(vO,BO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function BO(e){return"-"+e.toLowerCase()}const qp={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"]},zO={};function Sx(e,t){const n=zO,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return P2(e,r,i)}function P2(e,t,n){if($O(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 X1(e.children,t,n)}return Array.isArray(e)?X1(e,t,n):""}function X1(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=P2(e[i],t,n);return r.join("")}function $O(e){return!!(e&&typeof e=="object")}const Q1=document.createElement("i");function wx(e){const t="&"+e+";";Q1.innerHTML=t;const n=Q1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function _r(e,t,n,r){const i=e.length;let a=0,l;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)l=Array.from(r),l.unshift(t,n),e.splice(...l);else for(n&&e.splice(t,n);a<r.length;)l=r.slice(a,a+1e4),l.unshift(t,0),e.splice(...l),a+=1e4,t+=1e4}function Rr(e,t){return e.length>0?(_r(e,e.length,0,t),e):t}const J1={}.hasOwnProperty;function B2(e){const t={};let n=-1;for(;++n<e.length;)HO(t,e[n]);return t}function HO(e,t){let n;for(n in t){const i=(J1.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let l;if(a)for(l in a){J1.call(i,l)||(i[l]=[]);const d=a[l];FO(i[l],Array.isArray(d)?d:d?[d]:[])}}}function FO(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);_r(e,0,0,r)}function z2(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 Yr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Wn=Hs(/[A-Za-z]/),$n=Hs(/[\dA-Za-z]/),UO=Hs(/[#-'*+\--9=?A-Z^-~]/);function ah(e){return e!==null&&(e<32||e===127)}const S_=Hs(/\d/),VO=Hs(/[\dA-Fa-f]/),WO=Hs(/[!-/:-@[-`{-~]/);function Be(e){return e!==null&&e<-2}function Tt(e){return e!==null&&(e<0||e===32)}function rt(e){return e===-2||e===-1||e===32}const $h=Hs(new RegExp("\\p{P}|\\p{S}","u")),Aa=Hs(/\s/);function Hs(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Qo(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let l="";if(a===37&&$n(e.charCodeAt(n+1))&&$n(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(l=String.fromCharCode(a));else if(a>55295&&a<57344){const d=e.charCodeAt(n+1);a<56320&&d>56319&&d<57344?(l=String.fromCharCode(a,d),i=1):l="�"}else l=String.fromCharCode(a);l&&(t.push(e.slice(r,n),encodeURIComponent(l)),r=n+i+1,l=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ct(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return l;function l(f){return rt(f)?(e.enter(n),d(f)):t(f)}function d(f){return rt(f)&&a++<i?(e.consume(f),d):(e.exit(n),t(f))}}const GO={tokenize:qO};function qO(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),ct(e,t,"linePrefix")}function i(d){return e.enter("paragraph"),a(d)}function a(d){const f=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=f),n=f,l(d)}function l(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return Be(d)?(e.consume(d),e.exit("chunkText"),a):(e.consume(d),l)}}const KO={tokenize:YO},Z1={tokenize:XO};function YO(e){const t=this,n=[];let r=0,i,a,l;return d;function d(T){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,f,h)(T)}return h(T)}function f(T){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&j();const A=t.events.length;let P=A,M;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){M=t.events[P][1].end;break}k(r);let q=A;for(;q<t.events.length;)t.events[q][1].end={...M},q++;return _r(t.events,P+1,0,t.events.slice(A)),t.events.length=q,h(T)}return d(T)}function h(T){if(r===n.length){if(!i)return x(T);if(i.currentConstruct&&i.currentConstruct.concrete)return v(T);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Z1,p,g)(T)}function p(T){return i&&j(),k(r),x(T)}function g(T){return t.parser.lazy[t.now().line]=r!==n.length,l=t.now().offset,v(T)}function x(T){return t.containerState={},e.attempt(Z1,_,v)(T)}function _(T){return r++,n.push([t.currentConstruct,t.containerState]),x(T)}function v(T){if(T===null){i&&j(),k(0),e.consume(T);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),S(T)}function S(T){if(T===null){w(e.exit("chunkFlow"),!0),k(0),e.consume(T);return}return Be(T)?(e.consume(T),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,d):(e.consume(T),S)}function w(T,A){const P=t.sliceStream(T);if(A&&P.push(null),T.previous=a,a&&(a.next=T),a=T,i.defineSkip(T.start),i.write(P),t.parser.lazy[T.start.line]){let M=i.events.length;for(;M--;)if(i.events[M][1].start.offset<l&&(!i.events[M][1].end||i.events[M][1].end.offset>l))return;const q=t.events.length;let Z=q,J,L;for(;Z--;)if(t.events[Z][0]==="exit"&&t.events[Z][1].type==="chunkFlow"){if(J){L=t.events[Z][1].end;break}J=!0}for(k(r),M=q;M<t.events.length;)t.events[M][1].end={...L},M++;_r(t.events,Z+1,0,t.events.slice(q)),t.events.length=M}}function k(T){let A=n.length;for(;A-- >T;){const P=n[A];t.containerState=P[1],P[0].exit.call(t,e)}n.length=T}function j(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function XO(e,t,n){return ct(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vo(e){if(e===null||Tt(e)||Aa(e))return 1;if($h(e))return 2}function Hh(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const w_={name:"attention",resolveAll:QO,tokenize:JO};function QO(e,t){let n=-1,r,i,a,l,d,f,h,p;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;f=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},x={...e[n][1].start};ew(g,-f),ew(x,f),l={type:f>1?"strongSequence":"emphasisSequence",start:g,end:{...e[r][1].end}},d={type:f>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},a={type:f>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:f>1?"strong":"emphasis",start:{...l.start},end:{...d.end}},e[r][1].end={...l.start},e[n][1].start={...d.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=Rr(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=Rr(h,[["enter",i,t],["enter",l,t],["exit",l,t],["enter",a,t]]),h=Rr(h,Hh(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=Rr(h,[["exit",a,t],["enter",d,t],["exit",d,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,h=Rr(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,_r(e,r-1,n-r+3,h),n=r+h.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function JO(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Vo(r);let a;return l;function l(f){return a=f,e.enter("attentionSequence"),d(f)}function d(f){if(f===a)return e.consume(f),d;const h=e.exit("attentionSequence"),p=Vo(f),g=!p||p===2&&i||n.includes(f),x=!i||i===2&&p||n.includes(r);return h._open=!!(a===42?g:g&&(i||!x)),h._close=!!(a===42?x:x&&(p||!g)),t(f)}}function ew(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ZO={name:"autolink",tokenize:e4};function e4(e,t,n){let r=0;return i;function i(_){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(_),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a}function a(_){return Wn(_)?(e.consume(_),l):_===64?n(_):h(_)}function l(_){return _===43||_===45||_===46||$n(_)?(r=1,d(_)):h(_)}function d(_){return _===58?(e.consume(_),r=0,f):(_===43||_===45||_===46||$n(_))&&r++<32?(e.consume(_),d):(r=0,h(_))}function f(_){return _===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(_),e.exit("autolinkMarker"),e.exit("autolink"),t):_===null||_===32||_===60||ah(_)?n(_):(e.consume(_),f)}function h(_){return _===64?(e.consume(_),p):UO(_)?(e.consume(_),h):n(_)}function p(_){return $n(_)?g(_):n(_)}function g(_){return _===46?(e.consume(_),r=0,p):_===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(_),e.exit("autolinkMarker"),e.exit("autolink"),t):x(_)}function x(_){if((_===45||$n(_))&&r++<63){const v=_===45?x:g;return e.consume(_),v}return n(_)}}const Yc={partial:!0,tokenize:t4};function t4(e,t,n){return r;function r(a){return rt(a)?ct(e,i,"linePrefix")(a):i(a)}function i(a){return a===null||Be(a)?t(a):n(a)}}const $2={continuation:{tokenize:r4},exit:i4,name:"blockQuote",tokenize:n4};function n4(e,t,n){const r=this;return i;function i(l){if(l===62){const d=r.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),a}return n(l)}function a(l){return rt(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(l))}}function r4(e,t,n){const r=this;return i;function i(l){return rt(l)?ct(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):a(l)}function a(l){return e.attempt($2,t,n)(l)}}function i4(e){e.exit("blockQuote")}const H2={name:"characterEscape",tokenize:s4};function s4(e,t,n){return r;function r(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),i}function i(a){return WO(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const F2={name:"characterReference",tokenize:a4};function a4(e,t,n){const r=this;let i=0,a,l;return d;function d(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),f}function f(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),a=31,l=$n,p(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,l=VO,p):(e.enter("characterReferenceValue"),a=7,l=S_,p(g))}function p(g){if(g===59&&i){const x=e.exit("characterReferenceValue");return l===$n&&!wx(r.sliceSerialize(x))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return l(g)&&i++<a?(e.consume(g),p):n(g)}}const tw={partial:!0,tokenize:l4},nw={concrete:!0,name:"codeFenced",tokenize:o4};function o4(e,t,n){const r=this,i={partial:!0,tokenize:P};let a=0,l=0,d;return f;function f(M){return h(M)}function h(M){const q=r.events[r.events.length-1];return a=q&&q[1].type==="linePrefix"?q[2].sliceSerialize(q[1],!0).length:0,d=M,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(M)}function p(M){return M===d?(l++,e.consume(M),p):l<3?n(M):(e.exit("codeFencedFenceSequence"),rt(M)?ct(e,g,"whitespace")(M):g(M))}function g(M){return M===null||Be(M)?(e.exit("codeFencedFence"),r.interrupt?t(M):e.check(tw,S,A)(M)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(M))}function x(M){return M===null||Be(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(M)):rt(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ct(e,_,"whitespace")(M)):M===96&&M===d?n(M):(e.consume(M),x)}function _(M){return M===null||Be(M)?g(M):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),v(M))}function v(M){return M===null||Be(M)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(M)):M===96&&M===d?n(M):(e.consume(M),v)}function S(M){return e.attempt(i,A,w)(M)}function w(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),k}function k(M){return a>0&&rt(M)?ct(e,j,"linePrefix",a+1)(M):j(M)}function j(M){return M===null||Be(M)?e.check(tw,S,A)(M):(e.enter("codeFlowValue"),T(M))}function T(M){return M===null||Be(M)?(e.exit("codeFlowValue"),j(M)):(e.consume(M),T)}function A(M){return e.exit("codeFenced"),t(M)}function P(M,q,Z){let J=0;return L;function L(D){return M.enter("lineEnding"),M.consume(D),M.exit("lineEnding"),G}function G(D){return M.enter("codeFencedFence"),rt(D)?ct(M,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):H(D)}function H(D){return D===d?(M.enter("codeFencedFenceSequence"),R(D)):Z(D)}function R(D){return D===d?(J++,M.consume(D),R):J>=l?(M.exit("codeFencedFenceSequence"),rt(D)?ct(M,U,"whitespace")(D):U(D)):Z(D)}function U(D){return D===null||Be(D)?(M.exit("codeFencedFence"),q(D)):Z(D)}}}function l4(e,t,n){const r=this;return i;function i(l){return l===null?n(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),a)}function a(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}const Kp={name:"codeIndented",tokenize:u4},c4={partial:!0,tokenize:d4};function u4(e,t,n){const r=this;return i;function i(h){return e.enter("codeIndented"),ct(e,a,"linePrefix",5)(h)}function a(h){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?l(h):n(h)}function l(h){return h===null?f(h):Be(h)?e.attempt(c4,l,f)(h):(e.enter("codeFlowValue"),d(h))}function d(h){return h===null||Be(h)?(e.exit("codeFlowValue"),l(h)):(e.consume(h),d)}function f(h){return e.exit("codeIndented"),t(h)}}function d4(e,t,n){const r=this;return i;function i(l){return r.parser.lazy[r.now().line]?n(l):Be(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),i):ct(e,a,"linePrefix",5)(l)}function a(l){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(l):Be(l)?i(l):n(l)}}const h4={name:"codeText",previous:m4,resolve:f4,tokenize:p4};function f4(e){let t=e.length-4,n=3,r,i;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;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function m4(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function p4(e,t,n){let r=0,i,a;return l;function l(g){return e.enter("codeText"),e.enter("codeTextSequence"),d(g)}function d(g){return g===96?(e.consume(g),r++,d):(e.exit("codeTextSequence"),f(g))}function f(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),f):g===96?(a=e.enter("codeTextSequence"),i=0,p(g)):Be(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),f):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||Be(g)?(e.exit("codeTextData"),f(g)):(e.consume(g),h)}function p(g){return g===96?(e.consume(g),i++,p):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(a.type="codeTextData",h(g))}}class g4{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 i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&ic(this.left,r),a.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),ic(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ic(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);ic(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ic(this.left,n.reverse())}}}function ic(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 U2(e){const t={};let n=-1,r,i,a,l,d,f,h;const p=new g4(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(f=r[1]._tokenizer.events,a=0,a<f.length&&f[a][1].type==="lineEndingBlank"&&(a+=2),a<f.length&&f[a][1].type==="content"))for(;++a<f.length&&f[a][1].type!=="content";)f[a][1].type==="chunkText"&&(f[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,_4(p,n)),n=t[n],h=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(l=p.get(a),l[1].type==="lineEnding"||l[1].type==="lineEndingBlank")l[0]==="enter"&&(i&&(p.get(i)[1].type="lineEndingBlank"),l[1].type="lineEnding",i=a);else if(!(l[1].type==="linePrefix"||l[1].type==="listItemIndent"))break;i&&(r[1].end={...p.get(i)[1].start},d=p.slice(i,n),d.unshift(r),p.splice(i,n-i+1,d))}}return _r(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function _4(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let l=n._tokenizer;l||(l=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));const d=l.events,f=[],h={};let p,g,x=-1,_=n,v=0,S=0;const w=[S];for(;_;){for(;e.get(++i)[1]!==_;);a.push(i),_._tokenizer||(p=r.sliceStream(_),_.next||p.push(null),g&&l.defineSkip(_.start),_._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(p),_._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),g=_,_=_.next}for(_=n;++x<d.length;)d[x][0]==="exit"&&d[x-1][0]==="enter"&&d[x][1].type===d[x-1][1].type&&d[x][1].start.line!==d[x][1].end.line&&(S=x+1,w.push(S),_._tokenizer=void 0,_.previous=void 0,_=_.next);for(l.events=[],_?(_._tokenizer=void 0,_.previous=void 0):w.pop(),x=w.length;x--;){const k=d.slice(w[x],w[x+1]),j=a.pop();f.push([j,j+k.length-1]),e.splice(j,2,k)}for(f.reverse(),x=-1;++x<f.length;)h[v+f[x][0]]=v+f[x][1],v+=f[x][1]-f[x][0]-1;return h}const x4={resolve:v4,tokenize:b4},y4={partial:!0,tokenize:S4};function v4(e){return U2(e),e}function b4(e,t){let n;return r;function r(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(d)}function i(d){return d===null?a(d):Be(d)?e.check(y4,l,a)(d):(e.consume(d),i)}function a(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function l(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function S4(e,t,n){const r=this;return i;function i(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),ct(e,a,"linePrefix")}function a(l){if(l===null||Be(l))return n(l);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(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}function V2(e,t,n,r,i,a,l,d,f){const h=f||Number.POSITIVE_INFINITY;let p=0;return g;function g(k){return k===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(k),e.exit(a),x):k===null||k===32||k===41||ah(k)?n(k):(e.enter(r),e.enter(l),e.enter(d),e.enter("chunkString",{contentType:"string"}),S(k))}function x(k){return k===62?(e.enter(a),e.consume(k),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),_(k))}function _(k){return k===62?(e.exit("chunkString"),e.exit(d),x(k)):k===null||k===60||Be(k)?n(k):(e.consume(k),k===92?v:_)}function v(k){return k===60||k===62||k===92?(e.consume(k),_):_(k)}function S(k){return!p&&(k===null||k===41||Tt(k))?(e.exit("chunkString"),e.exit(d),e.exit(l),e.exit(r),t(k)):p<h&&k===40?(e.consume(k),p++,S):k===41?(e.consume(k),p--,S):k===null||k===32||k===40||ah(k)?n(k):(e.consume(k),k===92?w:S)}function w(k){return k===40||k===41||k===92?(e.consume(k),S):S(k)}}function W2(e,t,n,r,i,a){const l=this;let d=0,f;return h;function h(_){return e.enter(r),e.enter(i),e.consume(_),e.exit(i),e.enter(a),p}function p(_){return d>999||_===null||_===91||_===93&&!f||_===94&&!d&&"_hiddenFootnoteSupport"in l.parser.constructs?n(_):_===93?(e.exit(a),e.enter(i),e.consume(_),e.exit(i),e.exit(r),t):Be(_)?(e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),g(_))}function g(_){return _===null||_===91||_===93||Be(_)||d++>999?(e.exit("chunkString"),p(_)):(e.consume(_),f||(f=!rt(_)),_===92?x:g)}function x(_){return _===91||_===92||_===93?(e.consume(_),d++,g):g(_)}}function G2(e,t,n,r,i,a){let l;return d;function d(x){return x===34||x===39||x===40?(e.enter(r),e.enter(i),e.consume(x),e.exit(i),l=x===40?41:x,f):n(x)}function f(x){return x===l?(e.enter(i),e.consume(x),e.exit(i),e.exit(r),t):(e.enter(a),h(x))}function h(x){return x===l?(e.exit(a),f(l)):x===null?n(x):Be(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),ct(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===l||x===null||Be(x)?(e.exit("chunkString"),h(x)):(e.consume(x),x===92?g:p)}function g(x){return x===l||x===92?(e.consume(x),p):p(x)}}function bc(e,t){let n;return r;function r(i){return Be(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):rt(i)?ct(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const w4={name:"definition",tokenize:k4},C4={partial:!0,tokenize:E4};function k4(e,t,n){const r=this;let i;return a;function a(_){return e.enter("definition"),l(_)}function l(_){return W2.call(r,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(_)}function d(_){return i=Yr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),_===58?(e.enter("definitionMarker"),e.consume(_),e.exit("definitionMarker"),f):n(_)}function f(_){return Tt(_)?bc(e,h)(_):h(_)}function h(_){return V2(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(_)}function p(_){return e.attempt(C4,g,g)(_)}function g(_){return rt(_)?ct(e,x,"whitespace")(_):x(_)}function x(_){return _===null||Be(_)?(e.exit("definition"),r.parser.defined.push(i),t(_)):n(_)}}function E4(e,t,n){return r;function r(d){return Tt(d)?bc(e,i)(d):n(d)}function i(d){return G2(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function a(d){return rt(d)?ct(e,l,"whitespace")(d):l(d)}function l(d){return d===null||Be(d)?t(d):n(d)}}const N4={name:"hardBreakEscape",tokenize:j4};function j4(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return Be(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const T4={name:"headingAtx",resolve:A4,tokenize:D4};function A4(e,t){let n=e.length-2,r=3,i,a;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&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},_r(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function D4(e,t,n){let r=0;return i;function i(p){return e.enter("atxHeading"),a(p)}function a(p){return e.enter("atxHeadingSequence"),l(p)}function l(p){return p===35&&r++<6?(e.consume(p),l):p===null||Tt(p)?(e.exit("atxHeadingSequence"),d(p)):n(p)}function d(p){return p===35?(e.enter("atxHeadingSequence"),f(p)):p===null||Be(p)?(e.exit("atxHeading"),t(p)):rt(p)?ct(e,d,"whitespace")(p):(e.enter("atxHeadingText"),h(p))}function f(p){return p===35?(e.consume(p),f):(e.exit("atxHeadingSequence"),d(p))}function h(p){return p===null||p===35||Tt(p)?(e.exit("atxHeadingText"),d(p)):(e.consume(p),h)}}const L4=["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"],rw=["pre","script","style","textarea"],R4={concrete:!0,name:"htmlFlow",resolveTo:I4,tokenize:P4},M4={partial:!0,tokenize:z4},O4={partial:!0,tokenize:B4};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 P4(e,t,n){const r=this;let i,a,l,d,f;return h;function h(I){return p(I)}function p(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),g}function g(I){return I===33?(e.consume(I),x):I===47?(e.consume(I),a=!0,S):I===63?(e.consume(I),i=3,r.interrupt?t:B):Wn(I)?(e.consume(I),l=String.fromCharCode(I),w):n(I)}function x(I){return I===45?(e.consume(I),i=2,_):I===91?(e.consume(I),i=5,d=0,v):Wn(I)?(e.consume(I),i=4,r.interrupt?t:B):n(I)}function _(I){return I===45?(e.consume(I),r.interrupt?t:B):n(I)}function v(I){const Q="CDATA[";return I===Q.charCodeAt(d++)?(e.consume(I),d===Q.length?r.interrupt?t:H:v):n(I)}function S(I){return Wn(I)?(e.consume(I),l=String.fromCharCode(I),w):n(I)}function w(I){if(I===null||I===47||I===62||Tt(I)){const Q=I===47,W=l.toLowerCase();return!Q&&!a&&rw.includes(W)?(i=1,r.interrupt?t(I):H(I)):L4.includes(l.toLowerCase())?(i=6,Q?(e.consume(I),k):r.interrupt?t(I):H(I)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(I):a?j(I):T(I))}return I===45||$n(I)?(e.consume(I),l+=String.fromCharCode(I),w):n(I)}function k(I){return I===62?(e.consume(I),r.interrupt?t:H):n(I)}function j(I){return rt(I)?(e.consume(I),j):L(I)}function T(I){return I===47?(e.consume(I),L):I===58||I===95||Wn(I)?(e.consume(I),A):rt(I)?(e.consume(I),T):L(I)}function A(I){return I===45||I===46||I===58||I===95||$n(I)?(e.consume(I),A):P(I)}function P(I){return I===61?(e.consume(I),M):rt(I)?(e.consume(I),P):T(I)}function M(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),f=I,q):rt(I)?(e.consume(I),M):Z(I)}function q(I){return I===f?(e.consume(I),f=null,J):I===null||Be(I)?n(I):(e.consume(I),q)}function Z(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||Tt(I)?P(I):(e.consume(I),Z)}function J(I){return I===47||I===62||rt(I)?T(I):n(I)}function L(I){return I===62?(e.consume(I),G):n(I)}function G(I){return I===null||Be(I)?H(I):rt(I)?(e.consume(I),G):n(I)}function H(I){return I===45&&i===2?(e.consume(I),N):I===60&&i===1?(e.consume(I),F):I===62&&i===4?(e.consume(I),V):I===63&&i===3?(e.consume(I),B):I===93&&i===5?(e.consume(I),se):Be(I)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(M4,K,R)(I)):I===null||Be(I)?(e.exit("htmlFlowData"),R(I)):(e.consume(I),H)}function R(I){return e.check(O4,U,K)(I)}function U(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),D}function D(I){return I===null||Be(I)?R(I):(e.enter("htmlFlowData"),H(I))}function N(I){return I===45?(e.consume(I),B):H(I)}function F(I){return I===47?(e.consume(I),l="",$):H(I)}function $(I){if(I===62){const Q=l.toLowerCase();return rw.includes(Q)?(e.consume(I),V):H(I)}return Wn(I)&&l.length<8?(e.consume(I),l+=String.fromCharCode(I),$):H(I)}function se(I){return I===93?(e.consume(I),B):H(I)}function B(I){return I===62?(e.consume(I),V):I===45&&i===2?(e.consume(I),B):H(I)}function V(I){return I===null||Be(I)?(e.exit("htmlFlowData"),K(I)):(e.consume(I),V)}function K(I){return e.exit("htmlFlow"),t(I)}}function B4(e,t,n){const r=this;return i;function i(l){return Be(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),a):n(l)}function a(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}function z4(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Yc,t,n)}}const $4={name:"htmlText",tokenize:H4};function H4(e,t,n){const r=this;let i,a,l;return d;function d(B){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(B),f}function f(B){return B===33?(e.consume(B),h):B===47?(e.consume(B),P):B===63?(e.consume(B),T):Wn(B)?(e.consume(B),Z):n(B)}function h(B){return B===45?(e.consume(B),p):B===91?(e.consume(B),a=0,v):Wn(B)?(e.consume(B),j):n(B)}function p(B){return B===45?(e.consume(B),_):n(B)}function g(B){return B===null?n(B):B===45?(e.consume(B),x):Be(B)?(l=g,F(B)):(e.consume(B),g)}function x(B){return B===45?(e.consume(B),_):g(B)}function _(B){return B===62?N(B):B===45?x(B):g(B)}function v(B){const V="CDATA[";return B===V.charCodeAt(a++)?(e.consume(B),a===V.length?S:v):n(B)}function S(B){return B===null?n(B):B===93?(e.consume(B),w):Be(B)?(l=S,F(B)):(e.consume(B),S)}function w(B){return B===93?(e.consume(B),k):S(B)}function k(B){return B===62?N(B):B===93?(e.consume(B),k):S(B)}function j(B){return B===null||B===62?N(B):Be(B)?(l=j,F(B)):(e.consume(B),j)}function T(B){return B===null?n(B):B===63?(e.consume(B),A):Be(B)?(l=T,F(B)):(e.consume(B),T)}function A(B){return B===62?N(B):T(B)}function P(B){return Wn(B)?(e.consume(B),M):n(B)}function M(B){return B===45||$n(B)?(e.consume(B),M):q(B)}function q(B){return Be(B)?(l=q,F(B)):rt(B)?(e.consume(B),q):N(B)}function Z(B){return B===45||$n(B)?(e.consume(B),Z):B===47||B===62||Tt(B)?J(B):n(B)}function J(B){return B===47?(e.consume(B),N):B===58||B===95||Wn(B)?(e.consume(B),L):Be(B)?(l=J,F(B)):rt(B)?(e.consume(B),J):N(B)}function L(B){return B===45||B===46||B===58||B===95||$n(B)?(e.consume(B),L):G(B)}function G(B){return B===61?(e.consume(B),H):Be(B)?(l=G,F(B)):rt(B)?(e.consume(B),G):J(B)}function H(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),i=B,R):Be(B)?(l=H,F(B)):rt(B)?(e.consume(B),H):(e.consume(B),U)}function R(B){return B===i?(e.consume(B),i=void 0,D):B===null?n(B):Be(B)?(l=R,F(B)):(e.consume(B),R)}function U(B){return B===null||B===34||B===39||B===60||B===61||B===96?n(B):B===47||B===62||Tt(B)?J(B):(e.consume(B),U)}function D(B){return B===47||B===62||Tt(B)?J(B):n(B)}function N(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),t):n(B)}function F(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),$}function $(B){return rt(B)?ct(e,se,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):se(B)}function se(B){return e.enter("htmlTextData"),l(B)}}const Cx={name:"labelEnd",resolveAll:W4,resolveTo:G4,tokenize:q4},F4={tokenize:K4},U4={tokenize:Y4},V4={tokenize:X4};function W4(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 i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&_r(e,0,e.length,n),e}function G4(e,t){let n=e.length,r=0,i,a,l,d;for(;n--;)if(i=e[n][1],a){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(l){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(a=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(l=n);const f={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[a][1].start},end:{...e[l][1].end}},p={type:"labelText",start:{...e[a+r+2][1].end},end:{...e[l-2][1].start}};return d=[["enter",f,t],["enter",h,t]],d=Rr(d,e.slice(a+1,a+r+3)),d=Rr(d,[["enter",p,t]]),d=Rr(d,Hh(t.parser.constructs.insideSpan.null,e.slice(a+r+4,l-3),t)),d=Rr(d,[["exit",p,t],e[l-2],e[l-1],["exit",h,t]]),d=Rr(d,e.slice(l+1)),d=Rr(d,[["exit",f,t]]),_r(e,a,e.length,d),e}function q4(e,t,n){const r=this;let i=r.events.length,a,l;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return d;function d(x){return a?a._inactive?g(x):(l=r.parser.defined.includes(Yr(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),f):n(x)}function f(x){return x===40?e.attempt(F4,p,l?p:g)(x):x===91?e.attempt(U4,p,l?h:g)(x):l?p(x):g(x)}function h(x){return e.attempt(V4,p,g)(x)}function p(x){return t(x)}function g(x){return a._balanced=!0,n(x)}}function K4(e,t,n){return r;function r(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),i}function i(g){return Tt(g)?bc(e,a)(g):a(g)}function a(g){return g===41?p(g):V2(e,l,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function l(g){return Tt(g)?bc(e,f)(g):p(g)}function d(g){return n(g)}function f(g){return g===34||g===39||g===40?G2(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):p(g)}function h(g){return Tt(g)?bc(e,p)(g):p(g)}function p(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 i;function i(d){return W2.call(r,e,a,l,"reference","referenceMarker","referenceString")(d)}function a(d){return r.parser.defined.includes(Yr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function l(d){return n(d)}}function X4(e,t,n){return r;function r(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),i}function i(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const Q4={name:"labelStartImage",resolveAll:Cx.resolveAll,tokenize:J4};function J4(e,t,n){const r=this;return i;function i(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),a}function a(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),l):n(d)}function l(d){return d===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(d):t(d)}}const Z4={name:"labelStartLink",resolveAll:Cx.resolveAll,tokenize:eI};function eI(e,t,n){const r=this;return i;function i(l){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelLink"),a}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const Yp={name:"lineEnding",tokenize:tI};function tI(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ct(e,t,"linePrefix")}}const Wd={name:"thematicBreak",tokenize:nI};function nI(e,t,n){let r=0,i;return a;function a(h){return e.enter("thematicBreak"),l(h)}function l(h){return i=h,d(h)}function d(h){return h===i?(e.enter("thematicBreakSequence"),f(h)):r>=3&&(h===null||Be(h))?(e.exit("thematicBreak"),t(h)):n(h)}function f(h){return h===i?(e.consume(h),r++,f):(e.exit("thematicBreakSequence"),rt(h)?ct(e,d,"whitespace")(h):d(h))}}const rr={continuation:{tokenize:aI},exit:lI,name:"list",tokenize:sI},rI={partial:!0,tokenize:cI},iI={partial:!0,tokenize:oI};function sI(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,l=0;return d;function d(_){const v=r.containerState.type||(_===42||_===43||_===45?"listUnordered":"listOrdered");if(v==="listUnordered"?!r.containerState.marker||_===r.containerState.marker:S_(_)){if(r.containerState.type||(r.containerState.type=v,e.enter(v,{_container:!0})),v==="listUnordered")return e.enter("listItemPrefix"),_===42||_===45?e.check(Wd,n,h)(_):h(_);if(!r.interrupt||_===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),f(_)}return n(_)}function f(_){return S_(_)&&++l<10?(e.consume(_),f):(!r.interrupt||l<2)&&(r.containerState.marker?_===r.containerState.marker:_===41||_===46)?(e.exit("listItemValue"),h(_)):n(_)}function h(_){return e.enter("listItemMarker"),e.consume(_),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||_,e.check(Yc,r.interrupt?n:p,e.attempt(rI,x,g))}function p(_){return r.containerState.initialBlankLine=!0,a++,x(_)}function g(_){return rt(_)?(e.enter("listItemPrefixWhitespace"),e.consume(_),e.exit("listItemPrefixWhitespace"),x):n(_)}function x(_){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(_)}}function aI(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Yc,i,a);function i(d){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ct(e,t,"listItemIndent",r.containerState.size+1)(d)}function a(d){return r.containerState.furtherBlankLines||!rt(d)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(d)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(iI,t,l)(d))}function l(d){return r.containerState._closeFlow=!0,r.interrupt=void 0,ct(e,e.attempt(rr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function oI(e,t,n){const r=this;return ct(e,i,"listItemIndent",r.containerState.size+1);function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(a):n(a)}}function lI(e){e.exit(this.containerState.type)}function cI(e,t,n){const r=this;return ct(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const l=r.events[r.events.length-1];return!rt(a)&&l&&l[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const iw={name:"setextUnderline",resolveTo:uI,tokenize:dI};function uI(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const l={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",l,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=l,e.push(["exit",l,t]),e}function dI(e,t,n){const r=this;let i;return a;function a(h){let p=r.events.length,g;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){g=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||g)?(e.enter("setextHeadingLine"),i=h,l(h)):n(h)}function l(h){return e.enter("setextHeadingLineSequence"),d(h)}function d(h){return h===i?(e.consume(h),d):(e.exit("setextHeadingLineSequence"),rt(h)?ct(e,f,"lineSuffix")(h):f(h))}function f(h){return h===null||Be(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const hI={tokenize:fI};function fI(e){const t=this,n=e.attempt(Yc,r,e.attempt(this.parser.constructs.flowInitial,i,ct(e,e.attempt(this.parser.constructs.flow,i,e.attempt(x4,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const mI={resolveAll:K2()},pI=q2("string"),gI=q2("text");function q2(e){return{resolveAll:K2(e==="text"?_I:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,l,d);return l;function l(p){return h(p)?a(p):d(p)}function d(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),f}function f(p){return h(p)?(n.exit("data"),a(p)):(n.consume(p),f)}function h(p){if(p===null)return!0;const g=i[p];let x=-1;if(g)for(;++x<g.length;){const _=g[x];if(!_.previous||_.previous.call(r,r.previous))return!0}return!1}}}function K2(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type==="data"&&(a=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function _I(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],i=t.sliceStream(r);let a=i.length,l=-1,d=0,f;for(;a--;){const h=i[a];if(typeof h=="string"){for(l=h.length;h.charCodeAt(l-1)===32;)d++,l--;if(l)break;l=-1}else if(h===-2)f=!0,d++;else if(h!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const h={type:n===e.length||f||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:r.start._bufferIndex+l,_index:r.start._index+a,line:r.end.line,column:r.end.column-d,offset:r.end.offset-d},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const xI={42:rr,43:rr,45:rr,48:rr,49:rr,50:rr,51:rr,52:rr,53:rr,54:rr,55:rr,56:rr,57:rr,62:$2},yI={91:w4},vI={[-2]:Kp,[-1]:Kp,32:Kp},bI={35:T4,42:Wd,45:[iw,Wd],60:R4,61:iw,95:Wd,96:nw,126:nw},SI={38:F2,92:H2},wI={[-5]:Yp,[-4]:Yp,[-3]:Yp,33:Q4,38:F2,42:w_,60:[ZO,$4],91:Z4,92:[N4,H2],93:Cx,95:w_,96:h4},CI={null:[w_,mI]},kI={null:[42,95]},EI={null:[]},NI=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kI,contentInitial:yI,disable:EI,document:xI,flow:bI,flowInitial:vI,insideSpan:CI,string:SI,text:wI},Symbol.toStringTag,{value:"Module"}));function jI(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 i={},a=[];let l=[],d=[];const f={attempt:q(P),check:q(M),consume:j,enter:T,exit:A,interrupt:q(M,{interrupt:!0})},h={code:null,containerState:{},defineSkip:S,events:[],now:v,parser:e,previous:null,sliceSerialize:x,sliceStream:_,write:g};let p=t.tokenize.call(h,f);return t.resolveAll&&a.push(t),h;function g(G){return l=Rr(l,G),w(),l[l.length-1]!==null?[]:(Z(t,0),h.events=Hh(a,h.events,h),h.events)}function x(G,H){return AI(_(G),H)}function _(G){return TI(l,G)}function v(){const{_bufferIndex:G,_index:H,line:R,column:U,offset:D}=r;return{_bufferIndex:G,_index:H,line:R,column:U,offset:D}}function S(G){i[G.line]=G.column,L()}function w(){let G;for(;r._index<l.length;){const H=l[r._index];if(typeof H=="string")for(G=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===G&&r._bufferIndex<H.length;)k(H.charCodeAt(r._bufferIndex));else k(H)}}function k(G){p=p(G)}function j(G){Be(G)?(r.line++,r.column=1,r.offset+=G===-3?2:1,L()):G!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===l[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=G}function T(G,H){const R=H||{};return R.type=G,R.start=v(),h.events.push(["enter",R,h]),d.push(R),R}function A(G){const H=d.pop();return H.end=v(),h.events.push(["exit",H,h]),H}function P(G,H){Z(G,H.from)}function M(G,H){H.restore()}function q(G,H){return R;function R(U,D,N){let F,$,se,B;return Array.isArray(U)?K(U):"tokenize"in U?K([U]):V(U);function V(ee){return ne;function ne(Se){const le=Se!==null&&ee[Se],Ce=Se!==null&&ee.null,Re=[...Array.isArray(le)?le:le?[le]:[],...Array.isArray(Ce)?Ce:Ce?[Ce]:[]];return K(Re)(Se)}}function K(ee){return F=ee,$=0,ee.length===0?N:I(ee[$])}function I(ee){return ne;function ne(Se){return B=J(),se=ee,ee.partial||(h.currentConstruct=ee),ee.name&&h.parser.constructs.disable.null.includes(ee.name)?W():ee.tokenize.call(H?Object.assign(Object.create(h),H):h,f,Q,W)(Se)}}function Q(ee){return G(se,B),D}function W(ee){return B.restore(),++$<F.length?I(F[$]):N}}}function Z(G,H){G.resolveAll&&!a.includes(G)&&a.push(G),G.resolve&&_r(h.events,H,h.events.length-H,G.resolve(h.events.slice(H),h)),G.resolveTo&&(h.events=G.resolveTo(h.events,h))}function J(){const G=v(),H=h.previous,R=h.currentConstruct,U=h.events.length,D=Array.from(d);return{from:U,restore:N};function N(){r=G,h.previous=H,h.currentConstruct=R,h.events.length=U,d=D,L()}}function L(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function TI(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let l;if(n===i)l=[e[n].slice(r,a)];else{if(l=e.slice(n,i),r>-1){const d=l[0];typeof d=="string"?l[0]=d.slice(r):l.shift()}a>0&&l.push(e[i].slice(0,a))}return l}function AI(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let l;if(typeof a=="string")l=a;else switch(a){case-5:{l="\r";break}case-4:{l=`
114
+ `;break}case-3:{l=`\r
115
+ `;break}case-2:{l=t?" ":" ";break}case-1:{if(!t&&i)continue;l=" ";break}default:l=String.fromCharCode(a)}i=a===-2,r.push(l)}return r.join("")}function DI(e){const r={constructs:B2([NI,...(e||{}).extensions||[]]),content:i(GO),defined:[],document:i(KO),flow:i(hI),lazy:{},string:i(pI),text:i(gI)};return r;function i(a){return l;function l(d){return jI(r,a,d)}}}function LI(e){for(;!U2(e););return e}const sw=/[\0\t\n\r]/g;function RI(){let e=1,t="",n=!0,r;return i;function i(a,l,d){const f=[];let h,p,g,x,_;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(l||void 0).decode(a)),g=0,t="",n&&(a.charCodeAt(0)===65279&&g++,n=void 0);g<a.length;){if(sw.lastIndex=g,h=sw.exec(a),x=h&&h.index!==void 0?h.index:a.length,_=a.charCodeAt(x),!h){t=a.slice(g);break}if(_===10&&g===x&&r)f.push(-3),r=void 0;else switch(r&&(f.push(-5),r=void 0),g<x&&(f.push(a.slice(g,x)),e+=x-g),_){case 0:{f.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,f.push(-2);e++<p;)f.push(-1);break}case 10:{f.push(-4),e=1;break}default:r=!0,e=1}g=x+1}return d&&(r&&f.push(-5),t&&f.push(t),f.push(null)),f}}const MI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function OI(e){return e.replace(MI,II)}function II(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),a=i===120||i===88;return z2(n.slice(a?2:1),a?16:10)}return wx(n)||e}const Y2={}.hasOwnProperty;function PI(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),BI(n)(LI(DI(n).document().write(RI()(e,t,!0))))}function BI(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(ve),autolinkProtocol:J,autolinkEmail:J,atxHeading:a(it),blockQuote:a(Ce),characterEscape:J,characterReference:J,codeFenced:a(Re),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:a(Re,l),codeText:a(Oe,l),codeTextData:J,data:J,codeFlowValue:J,definition:a(De),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:a(Ue),hardBreakEscape:a(st),hardBreakTrailing:a(st),htmlFlow:a(ye,l),htmlFlowData:J,htmlText:a(ye,l),htmlTextData:J,image:a(ze),label:l,link:a(ve),listItem:a(Ee),listItemValue:x,listOrdered:a(ue,g),listUnordered:a(ue),paragraph:a(_t),reference:I,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:a(it),strong:a(Ji),thematicBreak:a(el)},exit:{atxHeading:f(),atxHeadingSequence:P,autolink:f(),autolinkEmail:le,autolinkProtocol:Se,blockQuote:f(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:W,characterReferenceMarkerNumeric:W,characterReferenceValue:ee,characterReference:ne,codeFenced:f(w),codeFencedFence:S,codeFencedFenceInfo:_,codeFencedFenceMeta:v,codeFlowValue:L,codeIndented:f(k),codeText:f(D),codeTextData:L,data:L,definition:f(),definitionDestinationString:A,definitionLabelString:j,definitionTitleString:T,emphasis:f(),hardBreakEscape:f(H),hardBreakTrailing:f(H),htmlFlow:f(R),htmlFlowData:L,htmlText:f(U),htmlTextData:L,image:f(F),label:se,labelText:$,lineEnding:G,link:f(N),listItem:f(),listOrdered:f(),listUnordered:f(),paragraph:f(),referenceString:Q,resourceDestinationString:B,resourceTitleString:V,resource:K,setextHeading:f(Z),setextHeadingLineSequence:q,setextHeadingText:M,strong:f(),thematicBreak:f()}};X2(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(me){let ke={type:"root",children:[]};const $e={stack:[ke],tokenStack:[],config:t,enter:d,exit:h,buffer:l,resume:p,data:n},Xe=[];let ut=-1;for(;++ut<me.length;)if(me[ut][1].type==="listOrdered"||me[ut][1].type==="listUnordered")if(me[ut][0]==="enter")Xe.push(ut);else{const un=Xe.pop();ut=i(me,un,ut)}for(ut=-1;++ut<me.length;){const un=t[me[ut][0]];Y2.call(un,me[ut][1].type)&&un[me[ut][1].type].call(Object.assign({sliceSerialize:me[ut][2].sliceSerialize},$e),me[ut][1])}if($e.tokenStack.length>0){const un=$e.tokenStack[$e.tokenStack.length-1];(un[1]||aw).call($e,void 0,un[0])}for(ke.position={start:Es(me.length>0?me[0][1].start:{line:1,column:1,offset:0}),end:Es(me.length>0?me[me.length-2][1].end:{line:1,column:1,offset:0})},ut=-1;++ut<t.transforms.length;)ke=t.transforms[ut](ke)||ke;return ke}function i(me,ke,$e){let Xe=ke-1,ut=-1,un=!1,Kn,zt,pt,On;for(;++Xe<=$e;){const xt=me[Xe];switch(xt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{xt[0]==="enter"?ut++:ut--,On=void 0;break}case"lineEndingBlank":{xt[0]==="enter"&&(Kn&&!On&&!ut&&!pt&&(pt=Xe),On=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:On=void 0}if(!ut&&xt[0]==="enter"&&xt[1].type==="listItemPrefix"||ut===-1&&xt[0]==="exit"&&(xt[1].type==="listUnordered"||xt[1].type==="listOrdered")){if(Kn){let Br=Xe;for(zt=void 0;Br--;){const sr=me[Br];if(sr[1].type==="lineEnding"||sr[1].type==="lineEndingBlank"){if(sr[0]==="exit")continue;zt&&(me[zt][1].type="lineEndingBlank",un=!0),sr[1].type="lineEnding",zt=Br}else if(!(sr[1].type==="linePrefix"||sr[1].type==="blockQuotePrefix"||sr[1].type==="blockQuotePrefixWhitespace"||sr[1].type==="blockQuoteMarker"||sr[1].type==="listItemIndent"))break}pt&&(!zt||pt<zt)&&(Kn._spread=!0),Kn.end=Object.assign({},zt?me[zt][1].start:xt[1].end),me.splice(zt||Xe,0,["exit",Kn,xt[2]]),Xe++,$e++}if(xt[1].type==="listItemPrefix"){const Br={type:"listItem",_spread:!1,start:Object.assign({},xt[1].start),end:void 0};Kn=Br,me.splice(Xe,0,["enter",Br,xt[2]]),Xe++,$e++,pt=void 0,On=!0}}}return me[ke][1]._spread=un,$e}function a(me,ke){return $e;function $e(Xe){d.call(this,me(Xe),Xe),ke&&ke.call(this,Xe)}}function l(){this.stack.push({type:"fragment",children:[]})}function d(me,ke,$e){this.stack[this.stack.length-1].children.push(me),this.stack.push(me),this.tokenStack.push([ke,$e||void 0]),me.position={start:Es(ke.start),end:void 0}}function f(me){return ke;function ke($e){me&&me.call(this,$e),h.call(this,$e)}}function h(me,ke){const $e=this.stack.pop(),Xe=this.tokenStack.pop();if(Xe)Xe[0].type!==me.type&&(ke?ke.call(this,me,Xe[0]):(Xe[1]||aw).call(this,me,Xe[0]));else throw new Error("Cannot close `"+me.type+"` ("+vc({start:me.start,end:me.end})+"): it’s not open");$e.position.end=Es(me.end)}function p(){return Sx(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function x(me){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(me),10),this.data.expectingFirstListItemValue=void 0}}function _(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=me}function v(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=me}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me.replace(/(\r?\n|\r)$/g,"")}function j(me){const ke=this.resume(),$e=this.stack[this.stack.length-1];$e.label=ke,$e.identifier=Yr(this.sliceSerialize(me)).toLowerCase()}function T(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.title=me}function A(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.url=me}function P(me){const ke=this.stack[this.stack.length-1];if(!ke.depth){const $e=this.sliceSerialize(me).length;ke.depth=$e}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function q(me){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(me).codePointAt(0)===61?1:2}function Z(){this.data.setextHeadingSlurpLineEnding=void 0}function J(me){const $e=this.stack[this.stack.length-1].children;let Xe=$e[$e.length-1];(!Xe||Xe.type!=="text")&&(Xe=Yt(),Xe.position={start:Es(me.start),end:void 0},$e.push(Xe)),this.stack.push(Xe)}function L(me){const ke=this.stack.pop();ke.value+=this.sliceSerialize(me),ke.position.end=Es(me.end)}function G(me){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const $e=ke.children[ke.children.length-1];$e.position.end=Es(me.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(J.call(this,me),L.call(this,me))}function H(){this.data.atHardBreak=!0}function R(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me}function U(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me}function D(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.value=me}function N(){const me=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";me.type+="Reference",me.referenceType=ke,delete me.url,delete me.title}else delete me.identifier,delete me.label;this.data.referenceType=void 0}function F(){const me=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";me.type+="Reference",me.referenceType=ke,delete me.url,delete me.title}else delete me.identifier,delete me.label;this.data.referenceType=void 0}function $(me){const ke=this.sliceSerialize(me),$e=this.stack[this.stack.length-2];$e.label=OI(ke),$e.identifier=Yr(ke).toLowerCase()}function se(){const me=this.stack[this.stack.length-1],ke=this.resume(),$e=this.stack[this.stack.length-1];if(this.data.inReference=!0,$e.type==="link"){const Xe=me.children;$e.children=Xe}else $e.alt=ke}function B(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.url=me}function V(){const me=this.resume(),ke=this.stack[this.stack.length-1];ke.title=me}function K(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function Q(me){const ke=this.resume(),$e=this.stack[this.stack.length-1];$e.label=ke,$e.identifier=Yr(this.sliceSerialize(me)).toLowerCase(),this.data.referenceType="full"}function W(me){this.data.characterReferenceType=me.type}function ee(me){const ke=this.sliceSerialize(me),$e=this.data.characterReferenceType;let Xe;$e?(Xe=z2(ke,$e==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Xe=wx(ke);const ut=this.stack[this.stack.length-1];ut.value+=Xe}function ne(me){const ke=this.stack.pop();ke.position.end=Es(me.end)}function Se(me){L.call(this,me);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(me)}function le(me){L.call(this,me);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(me)}function Ce(){return{type:"blockquote",children:[]}}function Re(){return{type:"code",lang:null,meta:null,value:""}}function Oe(){return{type:"inlineCode",value:""}}function De(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ue(){return{type:"emphasis",children:[]}}function it(){return{type:"heading",depth:0,children:[]}}function st(){return{type:"break"}}function ye(){return{type:"html",value:""}}function ze(){return{type:"image",title:null,url:"",alt:null}}function ve(){return{type:"link",title:null,url:"",children:[]}}function ue(me){return{type:"list",ordered:me.type==="listOrdered",start:null,spread:me._spread,children:[]}}function Ee(me){return{type:"listItem",spread:me._spread,checked:null,children:[]}}function _t(){return{type:"paragraph",children:[]}}function Ji(){return{type:"strong",children:[]}}function Yt(){return{type:"text",value:""}}function el(){return{type:"thematicBreak"}}}function Es(e){return{line:e.line,column:e.column,offset:e.offset}}function X2(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?X2(e,r):zI(e,r)}}function zI(e,t){let n;for(n in t)if(Y2.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 aw(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+vc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+vc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+vc({start:t.start,end:t.end})+") is still open")}function $I(e){const t=this;t.parser=n;function n(r){return PI(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function HI(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 FI(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
116
+ `}]}function UI(e,t){const n=t.value?t.value+`
117
+ `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a}function VI(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function WI(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GI(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Qo(r.toLowerCase()),a=e.footnoteOrder.indexOf(r);let l,d=e.footnoteCounts.get(r);d===void 0?(d=0,e.footnoteOrder.push(r),l=e.footnoteOrder.length):l=a+1,d+=1,e.footnoteCounts.set(r,d);const f={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(l)}]};e.patch(t,f);const h={type:"element",tagName:"sup",properties:{},children:[f]};return e.patch(t,h),e.applyData(t,h)}function qI(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 KI(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Q2(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 i=e.all(t),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const l=i[i.length-1];return l&&l.type==="text"?l.value+=r:i.push({type:"text",value:r}),i}function YI(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Q2(e,t);const i={src:Qo(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function XI(e,t){const n={src:Qo(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 QI(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 JI(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Q2(e,t);const i={href:Qo(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function ZI(e,t){const n={href:Qo(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 eP(e,t,n){const r=e.all(t),i=n?tP(n):J2(t),a={},l=[];if(typeof t.checked=="boolean"){const p=r[0];let g;p&&p.type==="element"&&p.tagName==="p"?g=p:(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:[]}),a.className=["task-list-item"]}let d=-1;for(;++d<r.length;){const p=r[d];(i||d!==0||p.type!=="element"||p.tagName!=="p")&&l.push({type:"text",value:`
118
+ `}),p.type==="element"&&p.tagName==="p"&&!i?l.push(...p.children):l.push(p)}const f=r[r.length-1];f&&(i||f.type!=="element"||f.tagName!=="p")&&l.push({type:"text",value:`
119
+ `});const h={type:"element",tagName:"li",properties:a,children:l};return e.patch(t,h),e.applyData(t,h)}function tP(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=J2(n[r])}return t}function J2(e){const t=e.spread;return t??e.children.length>1}function nP(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const l=r[i];if(l.type==="element"&&l.tagName==="li"&&l.properties&&Array.isArray(l.properties.className)&&l.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function rP(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iP(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function sP(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function aP(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const l={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],l),i.push(l)}if(n.length>0){const l={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},d=xx(t.children[1]),f=D2(t.children[t.children.length-1]);d&&f&&(l.position={start:d,end:f}),i.push(l)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function oP(e,t,n){const r=n?n.children:void 0,a=(r?r.indexOf(t):1)===0?"th":"td",l=n&&n.type==="table"?n.align:void 0,d=l?l.length:t.children.length;let f=-1;const h=[];for(;++f<d;){const g=t.children[f],x={},_=l?l[f]:void 0;_&&(x.align=_);let v={type:"element",tagName:a,properties:x,children:[]};g&&(v.children=e.all(g),e.patch(g,v),v=e.applyData(g,v)),h.push(v)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,p),e.applyData(t,p)}function lP(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const ow=9,lw=32;function cP(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const a=[];for(;r;)a.push(cw(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(cw(t.slice(i),i>0,!1)),a.join("")}function cw(e,t,n){let r=0,i=e.length;if(t){let a=e.codePointAt(r);for(;a===ow||a===lw;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(i-1);for(;a===ow||a===lw;)i--,a=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function uP(e,t){const n={type:"text",value:cP(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function dP(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const hP={blockquote:HI,break:FI,code:UI,delete:VI,emphasis:WI,footnoteReference:GI,heading:qI,html:KI,imageReference:YI,image:XI,inlineCode:QI,linkReference:JI,link:ZI,listItem:eP,list:nP,paragraph:rP,root:iP,strong:sP,table:aP,tableCell:lP,tableRow:oP,text:uP,thematicBreak:dP,toml:kd,yaml:kd,definition:kd,footnoteDefinition:kd};function kd(){}const Z2=-1,Fh=0,Sc=1,oh=2,kx=3,Ex=4,Nx=5,jx=6,eE=7,tE=8,uw=typeof self=="object"?self:globalThis,fP=(e,t)=>{const n=(i,a)=>(e.set(a,i),i),r=i=>{if(e.has(i))return e.get(i);const[a,l]=t[i];switch(a){case Fh:case Z2:return n(l,i);case Sc:{const d=n([],i);for(const f of l)d.push(r(f));return d}case oh:{const d=n({},i);for(const[f,h]of l)d[r(f)]=r(h);return d}case kx:return n(new Date(l),i);case Ex:{const{source:d,flags:f}=l;return n(new RegExp(d,f),i)}case Nx:{const d=n(new Map,i);for(const[f,h]of l)d.set(r(f),r(h));return d}case jx:{const d=n(new Set,i);for(const f of l)d.add(r(f));return d}case eE:{const{name:d,message:f}=l;return n(new uw[d](f),i)}case tE:return n(BigInt(l),i);case"BigInt":return n(Object(BigInt(l)),i);case"ArrayBuffer":return n(new Uint8Array(l).buffer,l);case"DataView":{const{buffer:d}=new Uint8Array(l);return n(new DataView(d),l)}}return n(new uw[a](l),i)};return r},dw=e=>fP(new Map,e)(0),To="",{toString:mP}={},{keys:pP}=Object,sc=e=>{const t=typeof e;if(t!=="object"||!e)return[Fh,t];const n=mP.call(e).slice(8,-1);switch(n){case"Array":return[Sc,To];case"Object":return[oh,To];case"Date":return[kx,To];case"RegExp":return[Ex,To];case"Map":return[Nx,To];case"Set":return[jx,To];case"DataView":return[Sc,n]}return n.includes("Array")?[Sc,n]:n.includes("Error")?[eE,n]:[oh,n]},Ed=([e,t])=>e===Fh&&(t==="function"||t==="symbol"),gP=(e,t,n,r)=>{const i=(l,d)=>{const f=r.push(l)-1;return n.set(d,f),f},a=l=>{if(n.has(l))return n.get(l);let[d,f]=sc(l);switch(d){case Fh:{let p=l;switch(f){case"bigint":d=tE,p=l.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+f);p=null;break;case"undefined":return i([Z2],l)}return i([d,p],l)}case Sc:{if(f){let x=l;return f==="DataView"?x=new Uint8Array(l.buffer):f==="ArrayBuffer"&&(x=new Uint8Array(l)),i([f,[...x]],l)}const p=[],g=i([d,p],l);for(const x of l)p.push(a(x));return g}case oh:{if(f)switch(f){case"BigInt":return i([f,l.toString()],l);case"Boolean":case"Number":case"String":return i([f,l.valueOf()],l)}if(t&&"toJSON"in l)return a(l.toJSON());const p=[],g=i([d,p],l);for(const x of pP(l))(e||!Ed(sc(l[x])))&&p.push([a(x),a(l[x])]);return g}case kx:return i([d,l.toISOString()],l);case Ex:{const{source:p,flags:g}=l;return i([d,{source:p,flags:g}],l)}case Nx:{const p=[],g=i([d,p],l);for(const[x,_]of l)(e||!(Ed(sc(x))||Ed(sc(_))))&&p.push([a(x),a(_)]);return g}case jx:{const p=[],g=i([d,p],l);for(const x of l)(e||!Ed(sc(x)))&&p.push(a(x));return g}}const{message:h}=l;return i([d,{name:f,message:h}],l)};return a},hw=(e,{json:t,lossy:n}={})=>{const r=[];return gP(!(t||n),!!t,new Map,r)(e),r},lh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?dw(hw(e,t)):structuredClone(e):(e,t)=>dw(hw(e,t));function _P(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 xP(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function yP(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||_P,r=e.options.footnoteBackLabel||xP,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",l=e.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let f=-1;for(;++f<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[f]);if(!h)continue;const p=e.all(h),g=String(h.identifier).toUpperCase(),x=Qo(g.toLowerCase());let _=0;const v=[],S=e.footnoteCounts.get(g);for(;S!==void 0&&++_<=S;){v.length>0&&v.push({type:"text",value:" "});let j=typeof n=="string"?n:n(f,_);typeof j=="string"&&(j={type:"text",value:j}),v.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(_>1?"-"+_:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(f,_),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const w=p[p.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const j=w.children[w.children.length-1];j&&j.type==="text"?j.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...v)}else p.push(...v);const k={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(p,!0)};e.patch(h,k),d.push(k)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...lh(l),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
120
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(d,!0)},{type:"text",value:`
121
+ `}]}}const Uh=(function(e){if(e==null)return wP;if(typeof e=="function")return Vh(e);if(typeof e=="object")return Array.isArray(e)?vP(e):bP(e);if(typeof e=="string")return SP(e);throw new Error("Expected function, string, or object as test")});function vP(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Uh(e[n]);return Vh(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function bP(e){const t=e;return Vh(n);function n(r){const i=r;let a;for(a in e)if(i[a]!==t[a])return!1;return!0}}function SP(e){return Vh(t);function t(n){return n&&n.type===e}}function Vh(e){return t;function t(n,r,i){return!!(CP(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function wP(){return!0}function CP(e){return e!==null&&typeof e=="object"&&"type"in e}const nE=[],kP=!0,C_=!1,EP="skip";function rE(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const a=Uh(i),l=r?-1:1;d(e,void 0,[])();function d(f,h,p){const g=f&&typeof f=="object"?f:{};if(typeof g.type=="string"){const _=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(f.type+(_?"<"+_+">":""))+")"})}return x;function x(){let _=nE,v,S,w;if((!t||a(f,h,p[p.length-1]||void 0))&&(_=NP(n(f,p)),_[0]===C_))return _;if("children"in f&&f.children){const k=f;if(k.children&&_[0]!==EP)for(S=(r?k.children.length:-1)+l,w=p.concat(k);S>-1&&S<k.children.length;){const j=k.children[S];if(v=d(j,S,w)(),v[0]===C_)return v;S=typeof v[1]=="number"?v[1]:S+l}}return _}}}function NP(e){return Array.isArray(e)?e:typeof e=="number"?[kP,e]:e==null?nE:[e]}function Tx(e,t,n,r){let i,a,l;typeof t=="function"&&typeof n!="function"?(a=void 0,l=t,i=n):(a=t,l=n,i=r),rE(e,a,d,i);function d(f,h){const p=h[h.length-1],g=p?p.children.indexOf(f):void 0;return l(f,g,p)}}const k_={}.hasOwnProperty,jP={};function TP(e,t){const n=t||jP,r=new Map,i=new Map,a=new Map,l={...hP,...n.handlers},d={all:h,applyData:DP,definitionById:r,footnoteById:i,footnoteCounts:a,footnoteOrder:[],handlers:l,one:f,options:n,patch:AP,wrap:RP};return Tx(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const g=p.type==="definition"?r:i,x=String(p.identifier).toUpperCase();g.has(x)||g.set(x,p)}}),d;function f(p,g){const x=p.type,_=d.handlers[x];if(k_.call(d.handlers,x)&&_)return _(d,p,g);if(d.options.passThrough&&d.options.passThrough.includes(x)){if("children"in p){const{children:S,...w}=p,k=lh(w);return k.children=d.all(p),k}return lh(p)}return(d.options.unknownHandler||LP)(d,p,g)}function h(p){const g=[];if("children"in p){const x=p.children;let _=-1;for(;++_<x.length;){const v=d.one(x[_],p);if(v){if(_&&x[_-1].type==="break"&&(!Array.isArray(v)&&v.type==="text"&&(v.value=fw(v.value)),!Array.isArray(v)&&v.type==="element")){const S=v.children[0];S&&S.type==="text"&&(S.value=fw(S.value))}Array.isArray(v)?g.push(...v):g.push(v)}}}return g}}function AP(e,t){e.position&&(t.position=xO(e))}function DP(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,a=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const l="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:l}}n.type==="element"&&a&&Object.assign(n.properties,lh(a)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function LP(e,t){const n=t.data||{},r="value"in t&&!(k_.call(n,"hProperties")||k_.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 RP(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
122
+ `});++r<e.length;)r&&n.push({type:"text",value:`
123
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
124
+ `}),n}function fw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function mw(e,t){const n=TP(e,t),r=n.one(e,void 0),i=yP(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&a.children.push({type:"text",value:`
125
+ `},i),a}function MP(e,t){return e&&"run"in e?async function(n,r){const i=mw(n,{file:r,...t});await e.run(i,r)}:function(n,r){return mw(n,{file:r,...e||t})}}function pw(e){if(e)throw e}var Xp,gw;function OP(){if(gw)return Xp;gw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},a=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var p=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!p&&!g)return!1;var x;for(x in h);return typeof x>"u"||e.call(h,x)},l=function(h,p){n&&p.name==="__proto__"?n(h,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):h[p.name]=p.newValue},d=function(h,p){if(p==="__proto__")if(e.call(h,p)){if(r)return r(h,p).value}else return;return h[p]};return Xp=function f(){var h,p,g,x,_,v,S=arguments[0],w=1,k=arguments.length,j=!1;for(typeof S=="boolean"&&(j=S,S=arguments[1]||{},w=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});w<k;++w)if(h=arguments[w],h!=null)for(p in h)g=d(S,p),x=d(h,p),S!==x&&(j&&x&&(a(x)||(_=i(x)))?(_?(_=!1,v=g&&i(g)?g:[]):v=g&&a(g)?g:{},l(S,{name:p,newValue:f(j,v,x)})):typeof x<"u"&&l(S,{name:p,newValue:x}));return S},Xp}var IP=OP();const Qp=Ch(IP);function E_(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 PP(){const e=[],t={run:n,use:r};return t;function n(...i){let a=-1;const l=i.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);d(null,...i);function d(f,...h){const p=e[++a];let g=-1;if(f){l(f);return}for(;++g<i.length;)(h[g]===null||h[g]===void 0)&&(h[g]=i[g]);i=h,p?BP(p,d)(...h):l(null,...h)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function BP(e,t){let n;return r;function r(...l){const d=e.length>l.length;let f;d&&l.push(i);try{f=e.apply(this,l)}catch(h){const p=h;if(d&&n)throw p;return i(p)}d||(f&&f.then&&typeof f.then=="function"?f.then(a,i):f instanceof Error?i(f):a(f))}function i(l,...d){n||(n=!0,t(l,...d))}function a(l){i(null,l)}}const ui={basename:zP,dirname:$P,extname:HP,join:FP,sep:"/"};function zP(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Xc(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let l=-1,d=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else l<0&&(a=!0,l=i+1),d>-1&&(e.codePointAt(i)===t.codePointAt(d--)?d<0&&(r=i):(d=-1,r=l));return n===r?r=l:r<0&&(r=e.length),e.slice(n,r)}function $P(e){if(Xc(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 HP(e){Xc(e);let t=e.length,n=-1,r=0,i=-1,a=0,l;for(;t--;){const d=e.codePointAt(t);if(d===47){if(l){r=t+1;break}continue}n<0&&(l=!0,n=t+1),d===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function FP(...e){let t=-1,n;for(;++t<e.length;)Xc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":UP(n)}function UP(e){Xc(e);const t=e.codePointAt(0)===47;let n=VP(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function VP(e,t){let n="",r=0,i=-1,a=0,l=-1,d,f;for(;++l<=e.length;){if(l<e.length)d=e.codePointAt(l);else{if(d===47)break;d=47}if(d===47){if(!(i===l-1||a===1))if(i!==l-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(f=n.lastIndexOf("/"),f!==n.length-1){f<0?(n="",r=0):(n=n.slice(0,f),r=n.length-1-n.lastIndexOf("/")),i=l,a=0;continue}}else if(n.length>0){n="",r=0,i=l,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,l):n=e.slice(i+1,l),r=l-i-1;i=l,a=0}else d===46&&a>-1?a++:a=-1}return n}function Xc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const WP={cwd:GP};function GP(){return"/"}function N_(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function qP(e){if(typeof e=="string")e=new URL(e);else if(!N_(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 KP(e)}function KP(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 i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Jp=["history","path","basename","stem","extname","dirname"];class iE{constructor(t){let n;t?N_(t)?n={path:t}:typeof t=="string"||YP(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":WP.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Jp.length;){const a=Jp[r];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let i;for(i in n)Jp.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?ui.basename(this.path):void 0}set basename(t){eg(t,"basename"),Zp(t,"basename"),this.path=ui.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ui.dirname(this.path):void 0}set dirname(t){_w(this.basename,"dirname"),this.path=ui.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ui.extname(this.path):void 0}set extname(t){if(Zp(t,"extname"),_w(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=ui.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){N_(t)&&(t=qP(t)),eg(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ui.basename(this.path,this.extname):void 0}set stem(t){eg(t,"stem"),Zp(t,"stem"),this.path=ui.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Hn(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Zp(e,t){if(e&&e.includes(ui.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ui.sep+"`")}function eg(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function _w(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function YP(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const XP=(function(e){const r=this.constructor.prototype,i=r[e],a=function(){return i.apply(a,arguments)};return Object.setPrototypeOf(a,r),a}),QP={}.hasOwnProperty;class Ax extends XP{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=PP()}copy(){const t=new Ax;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Qp(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(rg("data",this.frozen),this.namespace[t]=n,this):QP.call(this.namespace,t)&&this.namespace[t]||void 0:t?(rg("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 i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Nd(t),r=this.parser||this.Parser;return tg("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),tg("process",this.parser||this.Parser),ng("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(a,l){const d=Nd(t),f=r.parse(d);r.run(f,d,function(p,g,x){if(p||!g||!x)return h(p);const _=g,v=r.stringify(_,x);e6(v)?x.value=v:x.result=v,h(p,x)});function h(p,g){p||!g?l(p):a?a(g):n(void 0,g)}}}processSync(t){let n=!1,r;return this.freeze(),tg("processSync",this.parser||this.Parser),ng("processSync",this.compiler||this.Compiler),this.process(t,i),yw("processSync","process",n),r;function i(a,l){n=!0,pw(a),r=l}}run(t,n,r){xw(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?a(void 0,r):new Promise(a);function a(l,d){const f=Nd(n);i.run(t,f,h);function h(p,g,x){const _=g||t;p?d(p):l?l(_):r(void 0,_,x)}}}runSync(t,n){let r=!1,i;return this.run(t,n,a),yw("runSync","run",r),i;function a(l,d){pw(l),i=d,r=!0}}stringify(t,n){this.freeze();const r=Nd(n),i=this.compiler||this.Compiler;return ng("stringify",i),xw(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(rg("use",this.frozen),t!=null)if(typeof t=="function")f(t,n);else if(typeof t=="object")Array.isArray(t)?d(t):l(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(h){if(typeof h=="function")f(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[p,...g]=h;f(p,g)}else l(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function l(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");d(h.plugins),h.settings&&(i.settings=Qp(!0,i.settings,h.settings))}function d(h){let p=-1;if(h!=null)if(Array.isArray(h))for(;++p<h.length;){const g=h[p];a(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function f(h,p){let g=-1,x=-1;for(;++g<r.length;)if(r[g][0]===h){x=g;break}if(x===-1)r.push([h,...p]);else if(p.length>0){let[_,...v]=p;const S=r[x][1];E_(S)&&E_(_)&&(_=Qp(!0,S,_)),r[x]=[h,_,...v]}}}}const JP=new Ax().freeze();function tg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ng(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function rg(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 xw(e){if(!E_(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function yw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Nd(e){return ZP(e)?e:new iE(e)}function ZP(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function e6(e){return typeof e=="string"||t6(e)}function t6(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const n6="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",vw=[],bw={allowDangerousHtml:!0},r6=/^(https?|ircs?|mailto|xmpp)$/i,i6=[{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 s6(e){const t=a6(e),n=o6(e);return l6(t.runSync(t.parse(n),n),e)}function a6(e){const t=e.rehypePlugins||vw,n=e.remarkPlugins||vw,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...bw}:bw;return JP().use($I).use(n).use(MP,r).use(t)}function o6(e){const t=e.children||"",n=new iE;return typeof t=="string"&&(n.value=t),n}function l6(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,l=t.skipHtml,d=t.unwrapDisallowed,f=t.urlTransform||c6;for(const p of i6)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+n6+p.id,void 0);return Tx(e,h),wO(e,{Fragment:c.Fragment,components:i,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function h(p,g,x){if(p.type==="raw"&&x&&typeof g=="number")return l?x.children.splice(g,1):x.children[g]={type:"text",value:p.value},g;if(p.type==="element"){let _;for(_ in qp)if(Object.hasOwn(qp,_)&&Object.hasOwn(p.properties,_)){const v=p.properties[_],S=qp[_];(S===null||S.includes(p.tagName))&&(p.properties[_]=f(String(v||""),_,p))}}if(p.type==="element"){let _=n?!n.includes(p.tagName):a?a.includes(p.tagName):!1;if(!_&&r&&typeof g=="number"&&(_=!r(p,g,x)),_&&x&&typeof g=="number")return d&&p.children?x.children.splice(g,1,...p.children):x.children.splice(g,1),g}}}function c6(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||r6.test(e.slice(0,t))?e:""}function ch(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function u6(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function d6(e,t,n){const i=Uh((n||{}).ignore||[]),a=h6(t);let l=-1;for(;++l<a.length;)rE(e,"text",d);function d(h,p){let g=-1,x;for(;++g<p.length;){const _=p[g],v=x?x.children:void 0;if(i(_,v?v.indexOf(_):void 0,x))return;x=_}if(x)return f(h,p)}function f(h,p){const g=p[p.length-1],x=a[l][0],_=a[l][1];let v=0;const w=g.children.indexOf(h);let k=!1,j=[];x.lastIndex=0;let T=x.exec(h.value);for(;T;){const A=T.index,P={index:T.index,input:T.input,stack:[...p,h]};let M=_(...T,P);if(typeof M=="string"&&(M=M.length>0?{type:"text",value:M}:void 0),M===!1?x.lastIndex=A+1:(v!==A&&j.push({type:"text",value:h.value.slice(v,A)}),Array.isArray(M)?j.push(...M):M&&j.push(M),v=A+T[0].length,k=!0),!x.global)break;T=x.exec(h.value)}return k?(v<h.value.length&&j.push({type:"text",value:h.value.slice(v)}),g.children.splice(w,1,...j)):j=[h],w+j.length}}function h6(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 i=n[r];t.push([f6(i[0]),m6(i[1])])}return t}function f6(e){return typeof e=="string"?new RegExp(u6(e),"g"):e}function m6(e){return typeof e=="function"?e:function(){return e}}const ig="phrasing",sg=["autolink","link","image","label"];function p6(){return{transforms:[S6],enter:{literalAutolink:_6,literalAutolinkEmail:ag,literalAutolinkHttp:ag,literalAutolinkWww:ag},exit:{literalAutolink:b6,literalAutolinkEmail:v6,literalAutolinkHttp:x6,literalAutolinkWww:y6}}}function g6(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ig,notInConstruct:sg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ig,notInConstruct:sg},{character:":",before:"[ps]",after:"\\/",inConstruct:ig,notInConstruct:sg}]}}function _6(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ag(e){this.config.enter.autolinkProtocol.call(this,e)}function x6(e){this.config.exit.autolinkProtocol.call(this,e)}function y6(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 v6(e){this.config.exit.autolinkEmail.call(this,e)}function b6(e){this.exit(e)}function S6(e){d6(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,w6],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),C6]],{ignore:["link","linkReference"]})}function w6(e,t,n,r,i){let a="";if(!sE(i)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!k6(n)))return!1;const l=E6(n+r);if(!l[0])return!1;const d={type:"link",title:null,url:a+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[d,{type:"text",value:l[1]}]:d}function C6(e,t,n,r){return!sE(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function k6(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 E6(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 i=ch(e,"(");let a=ch(e,")");for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function sE(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Aa(n)||$h(n))&&(!t||n!==47)}aE.peek=O6;function N6(){this.buffer()}function j6(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function T6(){this.buffer()}function A6(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function D6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Yr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function L6(e){this.exit(e)}function R6(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Yr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function M6(e){this.exit(e)}function O6(){return"["}function aE(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const l=n.enter("footnoteReference"),d=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{after:"]",before:a})),d(),l(),a+=i.move("]"),a}function I6(){return{enter:{gfmFootnoteCallString:N6,gfmFootnoteCall:j6,gfmFootnoteDefinitionLabelString:T6,gfmFootnoteDefinition:A6},exit:{gfmFootnoteCallString:D6,gfmFootnoteCall:L6,gfmFootnoteDefinitionLabelString:R6,gfmFootnoteDefinition:M6}}}function P6(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:aE},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,a,l){const d=a.createTracker(l);let f=d.move("[^");const h=a.enter("footnoteDefinition"),p=a.enter("label");return f+=d.move(a.safe(a.associationId(r),{before:f,after:"]"})),p(),f+=d.move("]:"),r.children&&r.children.length>0&&(d.shift(4),f+=d.move((t?`
126
+ `:" ")+a.indentLines(a.containerFlow(r,d.current()),t?oE:B6))),h(),f}}function B6(e,t,n){return t===0?e:oE(e,t,n)}function oE(e,t,n){return(n?"":" ")+e}const z6=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];lE.peek=V6;function $6(){return{canContainEols:["delete"],enter:{strikethrough:F6},exit:{strikethrough:U6}}}function H6(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:z6}],handlers:{delete:lE}}}function F6(e){this.enter({type:"delete",children:[]},e)}function U6(e){this.exit(e)}function lE(e,t,n,r){const i=n.createTracker(r),a=n.enter("strikethrough");let l=i.move("~~");return l+=n.containerPhrasing(e,{...i.current(),before:l,after:"~"}),l+=i.move("~~"),a(),l}function V6(){return"~"}function W6(e){return e.length}function G6(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||W6,a=[],l=[],d=[],f=[];let h=0,p=-1;for(;++p<e.length;){const S=[],w=[];let k=-1;for(e[p].length>h&&(h=e[p].length);++k<e[p].length;){const j=q6(e[p][k]);if(n.alignDelimiters!==!1){const T=i(j);w[k]=T,(f[k]===void 0||T>f[k])&&(f[k]=T)}S.push(j)}l[p]=S,d[p]=w}let g=-1;if(typeof r=="object"&&"length"in r)for(;++g<h;)a[g]=Sw(r[g]);else{const S=Sw(r);for(;++g<h;)a[g]=S}g=-1;const x=[],_=[];for(;++g<h;){const S=a[g];let w="",k="";S===99?(w=":",k=":"):S===108?w=":":S===114&&(k=":");let j=n.alignDelimiters===!1?1:Math.max(1,f[g]-w.length-k.length);const T=w+"-".repeat(j)+k;n.alignDelimiters!==!1&&(j=w.length+j+k.length,j>f[g]&&(f[g]=j),_[g]=j),x[g]=T}l.splice(1,0,x),d.splice(1,0,_),p=-1;const v=[];for(;++p<l.length;){const S=l[p],w=d[p];g=-1;const k=[];for(;++g<h;){const j=S[g]||"";let T="",A="";if(n.alignDelimiters!==!1){const P=f[g]-(w[g]||0),M=a[g];M===114?T=" ".repeat(P):M===99?P%2?(T=" ".repeat(P/2+.5),A=" ".repeat(P/2-.5)):(T=" ".repeat(P/2),A=T):A=" ".repeat(P)}n.delimiterStart!==!1&&!g&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&j==="")&&(n.delimiterStart!==!1||g)&&k.push(" "),n.alignDelimiters!==!1&&k.push(T),k.push(j),n.alignDelimiters!==!1&&k.push(A),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||g!==h-1)&&k.push("|")}v.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return v.join(`
127
+ `)}function q6(e){return e==null?"":String(e)}function Sw(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}const ww={}.hasOwnProperty;function K6(e,t){const n=t||{};function r(i,...a){let l=r.invalid;const d=r.handlers;if(i&&ww.call(i,e)){const f=String(i[e]);l=ww.call(d,f)?d[f]:r.unknown}if(l)return l.call(this,i,...a)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}function Y6(e,t,n,r){const i=n.enter("blockquote"),a=n.createTracker(r);a.move("> "),a.shift(2);const l=n.indentLines(n.containerFlow(e,a.current()),X6);return i(),l}function X6(e,t,n){return">"+(n?"":" ")+e}function Q6(e,t){return Cw(e,t.inConstruct,!0)&&!Cw(e,t.notInConstruct,!1)}function Cw(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 kw(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
128
+ `&&Q6(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
129
+ `}function J6(e,t){const n=String(e);let r=n.indexOf(t),i=r,a=0,l=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++a>l&&(l=a):a=1,i=r+t.length,r=n.indexOf(t,i);return l}function Z6(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 eB(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 tB(e,t,n,r){const i=eB(n),a=e.value||"",l=i==="`"?"GraveAccent":"Tilde";if(Z6(e,n)){const g=n.enter("codeIndented"),x=n.indentLines(a,nB);return g(),x}const d=n.createTracker(r),f=i.repeat(Math.max(J6(a,i)+1,3)),h=n.enter("codeFenced");let p=d.move(f);if(e.lang){const g=n.enter(`codeFencedLang${l}`);p+=d.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...d.current()})),g()}if(e.lang&&e.meta){const g=n.enter(`codeFencedMeta${l}`);p+=d.move(" "),p+=d.move(n.safe(e.meta,{before:p,after:`
130
+ `,encode:["`"],...d.current()})),g()}return p+=d.move(`
131
+ `),a&&(p+=d.move(a+`
132
+ `)),p+=d.move(f),h(),p}function nB(e,t,n){return(n?"":" ")+e}function Dx(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 rB(e,t,n,r){const i=Dx(n),a=i==='"'?"Quote":"Apostrophe",l=n.enter("definition");let d=n.enter("label");const f=n.createTracker(r);let h=f.move("[");return h+=f.move(n.safe(n.associationId(e),{before:h,after:"]",...f.current()})),h+=f.move("]: "),d(),!e.url||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=f.move("<"),h+=f.move(n.safe(e.url,{before:h,after:">",...f.current()})),h+=f.move(">")):(d=n.enter("destinationRaw"),h+=f.move(n.safe(e.url,{before:h,after:e.title?" ":`
133
+ `,...f.current()}))),d(),e.title&&(d=n.enter(`title${a}`),h+=f.move(" "+i),h+=f.move(n.safe(e.title,{before:h,after:i,...f.current()})),h+=f.move(i),d()),l(),h}function iB(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 Ac(e){return"&#x"+e.toString(16).toUpperCase()+";"}function uh(e,t,n){const r=Vo(e),i=Vo(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}cE.peek=sB;function cE(e,t,n,r){const i=iB(n),a=n.enter("emphasis"),l=n.createTracker(r),d=l.move(i);let f=l.move(n.containerPhrasing(e,{after:i,before:d,...l.current()}));const h=f.charCodeAt(0),p=uh(r.before.charCodeAt(r.before.length-1),h,i);p.inside&&(f=Ac(h)+f.slice(1));const g=f.charCodeAt(f.length-1),x=uh(r.after.charCodeAt(0),g,i);x.inside&&(f=f.slice(0,-1)+Ac(g));const _=l.move(i);return a(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},d+f+_}function sB(e,t,n){return n.options.emphasis||"*"}function aB(e,t){let n=!1;return Tx(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,C_}),!!((!e.depth||e.depth<3)&&Sx(e)&&(t.options.setext||n))}function oB(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(aB(e,n)){const p=n.enter("headingSetext"),g=n.enter("phrasing"),x=n.containerPhrasing(e,{...a.current(),before:`
134
+ `,after:`
135
+ `});return g(),p(),x+`
136
+ `+(i===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
137
+ `))+1))}const l="#".repeat(i),d=n.enter("headingAtx"),f=n.enter("phrasing");a.move(l+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
138
+ `,...a.current()});return/^[\t ]/.test(h)&&(h=Ac(h.charCodeAt(0))+h.slice(1)),h=h?l+" "+h:l,n.options.closeAtx&&(h+=" "+l),f(),d(),h}uE.peek=lB;function uE(e){return e.value||""}function lB(){return"<"}dE.peek=cB;function dE(e,t,n,r){const i=Dx(n),a=i==='"'?"Quote":"Apostrophe",l=n.enter("image");let d=n.enter("label");const f=n.createTracker(r);let h=f.move("![");return h+=f.move(n.safe(e.alt,{before:h,after:"]",...f.current()})),h+=f.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=f.move("<"),h+=f.move(n.safe(e.url,{before:h,after:">",...f.current()})),h+=f.move(">")):(d=n.enter("destinationRaw"),h+=f.move(n.safe(e.url,{before:h,after:e.title?" ":")",...f.current()}))),d(),e.title&&(d=n.enter(`title${a}`),h+=f.move(" "+i),h+=f.move(n.safe(e.title,{before:h,after:i,...f.current()})),h+=f.move(i),d()),h+=f.move(")"),l(),h}function cB(){return"!"}hE.peek=uB;function hE(e,t,n,r){const i=e.referenceType,a=n.enter("imageReference");let l=n.enter("label");const d=n.createTracker(r);let f=d.move("![");const h=n.safe(e.alt,{before:f,after:"]",...d.current()});f+=d.move(h+"]["),l();const p=n.stack;n.stack=[],l=n.enter("reference");const g=n.safe(n.associationId(e),{before:f,after:"]",...d.current()});return l(),n.stack=p,a(),i==="full"||!h||h!==g?f+=d.move(g+"]"):i==="shortcut"?f=f.slice(0,-1):f+=d.move("]"),f}function uB(){return"!"}fE.peek=dB;function fE(e,t,n){let r=e.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const l=n.unsafe[a],d=n.compilePattern(l);let f;if(l.atBreak)for(;f=d.exec(r);){let h=f.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(f.index+1)}}return i+r+i}function dB(){return"`"}function mE(e,t){const n=Sx(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))}pE.peek=hB;function pE(e,t,n,r){const i=Dx(n),a=i==='"'?"Quote":"Apostrophe",l=n.createTracker(r);let d,f;if(mE(e,n)){const p=n.stack;n.stack=[],d=n.enter("autolink");let g=l.move("<");return g+=l.move(n.containerPhrasing(e,{before:g,after:">",...l.current()})),g+=l.move(">"),d(),n.stack=p,g}d=n.enter("link"),f=n.enter("label");let h=l.move("[");return h+=l.move(n.containerPhrasing(e,{before:h,after:"](",...l.current()})),h+=l.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=l.move("<"),h+=l.move(n.safe(e.url,{before:h,after:">",...l.current()})),h+=l.move(">")):(f=n.enter("destinationRaw"),h+=l.move(n.safe(e.url,{before:h,after:e.title?" ":")",...l.current()}))),f(),e.title&&(f=n.enter(`title${a}`),h+=l.move(" "+i),h+=l.move(n.safe(e.title,{before:h,after:i,...l.current()})),h+=l.move(i),f()),h+=l.move(")"),d(),h}function hB(e,t,n){return mE(e,n)?"<":"["}gE.peek=fB;function gE(e,t,n,r){const i=e.referenceType,a=n.enter("linkReference");let l=n.enter("label");const d=n.createTracker(r);let f=d.move("[");const h=n.containerPhrasing(e,{before:f,after:"]",...d.current()});f+=d.move(h+"]["),l();const p=n.stack;n.stack=[],l=n.enter("reference");const g=n.safe(n.associationId(e),{before:f,after:"]",...d.current()});return l(),n.stack=p,a(),i==="full"||!h||h!==g?f+=d.move(g+"]"):i==="shortcut"?f=f.slice(0,-1):f+=d.move("]"),f}function fB(){return"["}function Lx(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 mB(e){const t=Lx(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 pB(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 _E(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 gB(e,t,n,r){const i=n.enter("list"),a=n.bulletCurrent;let l=e.ordered?pB(n):Lx(n);const d=e.ordered?l==="."?")":".":mB(n);let f=t&&n.bulletLastUsed?l===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((l==="*"||l==="-")&&p&&(!p.children||!p.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&&(f=!0),_E(n)===l&&p){let g=-1;for(;++g<e.children.length;){const x=e.children[g];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){f=!0;break}}}}f&&(l=d),n.bulletCurrent=l;const h=n.containerFlow(e,r);return n.bulletLastUsed=l,n.bulletCurrent=a,i(),h}function _B(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 xB(e,t,n,r){const i=_B(n);let a=n.bulletCurrent||Lx(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let l=a.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(l=Math.ceil(l/4)*4);const d=n.createTracker(r);d.move(a+" ".repeat(l-a.length)),d.shift(l);const f=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,d.current()),p);return f(),h;function p(g,x,_){return x?(_?"":" ".repeat(l))+g:(_?a:a+" ".repeat(l-a.length))+g}}function yB(e,t,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),l=n.containerPhrasing(e,r);return a(),i(),l}const vB=Uh(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function bB(e,t,n,r){return(e.children.some(function(l){return vB(l)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function SB(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}xE.peek=wB;function xE(e,t,n,r){const i=SB(n),a=n.enter("strong"),l=n.createTracker(r),d=l.move(i+i);let f=l.move(n.containerPhrasing(e,{after:i,before:d,...l.current()}));const h=f.charCodeAt(0),p=uh(r.before.charCodeAt(r.before.length-1),h,i);p.inside&&(f=Ac(h)+f.slice(1));const g=f.charCodeAt(f.length-1),x=uh(r.after.charCodeAt(0),g,i);x.inside&&(f=f.slice(0,-1)+Ac(g));const _=l.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},d+f+_}function wB(e,t,n){return n.options.strong||"*"}function CB(e,t,n,r){return n.safe(e.value,r)}function kB(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 EB(e,t,n){const r=(_E(n)+(n.options.ruleSpaces?" ":"")).repeat(kB(n));return n.options.ruleSpaces?r.slice(0,-1):r}const yE={blockquote:Y6,break:kw,code:tB,definition:rB,emphasis:cE,hardBreak:kw,heading:oB,html:uE,image:dE,imageReference:hE,inlineCode:fE,link:pE,linkReference:gE,list:gB,listItem:xB,paragraph:yB,root:bB,strong:xE,text:CB,thematicBreak:EB};function NB(){return{enter:{table:jB,tableData:Ew,tableHeader:Ew,tableRow:AB},exit:{codeText:DB,table:TB,tableData:og,tableHeader:og,tableRow:og}}}function jB(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 TB(e){this.exit(e),this.data.inTable=void 0}function AB(e){this.enter({type:"tableRow",children:[]},e)}function og(e){this.exit(e)}function Ew(e){this.enter({type:"tableCell",children:[]},e)}function DB(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,LB));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function LB(e,t){return t==="|"?t:e}function RB(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
139
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:l,tableCell:f,tableRow:d}};function l(_,v,S,w){return h(p(_,S,w),_.align)}function d(_,v,S,w){const k=g(_,S,w),j=h([k]);return j.slice(0,j.indexOf(`
140
+ `))}function f(_,v,S,w){const k=S.enter("tableCell"),j=S.enter("phrasing"),T=S.containerPhrasing(_,{...w,before:a,after:a});return j(),k(),T}function h(_,v){return G6(_,{align:v,alignDelimiters:r,padding:n,stringLength:i})}function p(_,v,S){const w=_.children;let k=-1;const j=[],T=v.enter("table");for(;++k<w.length;)j[k]=g(w[k],v,S);return T(),j}function g(_,v,S){const w=_.children;let k=-1;const j=[],T=v.enter("tableRow");for(;++k<w.length;)j[k]=f(w[k],_,v,S);return T(),j}function x(_,v,S){let w=yE.inlineCode(_,v,S);return S.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function MB(){return{exit:{taskListCheckValueChecked:Nw,taskListCheckValueUnchecked:Nw,paragraph:IB}}}function OB(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:PB}}}function Nw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function IB(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 i=t.children;let a=-1,l;for(;++a<i.length;){const d=i[a];if(d.type==="paragraph"){l=d;break}}l===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 PB(e,t,n,r){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",d=n.createTracker(r);a&&d.move(l);let f=yE.listItem(e,t,n,{...r,...d.current()});return a&&(f=f.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),f;function h(p){return p+l}}function BB(){return[p6(),I6(),$6(),NB(),MB()]}function zB(e){return{extensions:[g6(),P6(e),H6(),RB(e),OB()]}}const $B={tokenize:GB,partial:!0},vE={tokenize:qB,partial:!0},bE={tokenize:KB,partial:!0},SE={tokenize:YB,partial:!0},HB={tokenize:XB,partial:!0},wE={name:"wwwAutolink",tokenize:VB,previous:kE},CE={name:"protocolAutolink",tokenize:WB,previous:EE},Qi={name:"emailAutolink",tokenize:UB,previous:NE},xi={};function FB(){return{text:xi}}let la=48;for(;la<123;)xi[la]=Qi,la++,la===58?la=65:la===91&&(la=97);xi[43]=Qi;xi[45]=Qi;xi[46]=Qi;xi[95]=Qi;xi[72]=[Qi,CE];xi[104]=[Qi,CE];xi[87]=[Qi,wE];xi[119]=[Qi,wE];function UB(e,t,n){const r=this;let i,a;return l;function l(g){return!j_(g)||!NE.call(r,r.previous)||Rx(r.events)?n(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(g))}function d(g){return j_(g)?(e.consume(g),d):g===64?(e.consume(g),f):n(g)}function f(g){return g===46?e.check(HB,p,h)(g):g===45||g===95||$n(g)?(a=!0,e.consume(g),f):p(g)}function h(g){return e.consume(g),i=!0,f}function p(g){return a&&i&&Wn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):n(g)}}function VB(e,t,n){const r=this;return i;function i(l){return l!==87&&l!==119||!kE.call(r,r.previous)||Rx(r.events)?n(l):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check($B,e.attempt(vE,e.attempt(bE,a),n),n)(l))}function a(l){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(l)}}function WB(e,t,n){const r=this;let i="",a=!1;return l;function l(g){return(g===72||g===104)&&EE.call(r,r.previous)&&!Rx(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(g),e.consume(g),d):n(g)}function d(g){if(Wn(g)&&i.length<5)return i+=String.fromCodePoint(g),e.consume(g),d;if(g===58){const x=i.toLowerCase();if(x==="http"||x==="https")return e.consume(g),f}return n(g)}function f(g){return g===47?(e.consume(g),a?h:(a=!0,f)):n(g)}function h(g){return g===null||ah(g)||Tt(g)||Aa(g)||$h(g)?n(g):e.attempt(vE,e.attempt(bE,p),n)(g)}function p(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function GB(e,t,n){let r=0;return i;function i(l){return(l===87||l===119)&&r<3?(r++,e.consume(l),i):l===46&&r===3?(e.consume(l),a):n(l)}function a(l){return l===null?n(l):t(l)}}function qB(e,t,n){let r,i,a;return l;function l(h){return h===46||h===95?e.check(SE,f,d)(h):h===null||Tt(h)||Aa(h)||h!==45&&$h(h)?f(h):(a=!0,e.consume(h),l)}function d(h){return h===95?r=!0:(i=r,r=void 0),e.consume(h),l}function f(h){return i||r||!a?n(h):t(h)}}function KB(e,t){let n=0,r=0;return i;function i(l){return l===40?(n++,e.consume(l),i):l===41&&r<n?a(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?e.check(SE,t,a)(l):l===null||Tt(l)||Aa(l)?t(l):(e.consume(l),i)}function a(l){return l===41&&r++,e.consume(l),i}}function YB(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),a):d===93?(e.consume(d),i):d===60||d===null||Tt(d)||Aa(d)?t(d):n(d)}function i(d){return d===null||d===40||d===91||Tt(d)||Aa(d)?t(d):r(d)}function a(d){return Wn(d)?l(d):n(d)}function l(d){return d===59?(e.consume(d),r):Wn(d)?(e.consume(d),l):n(d)}}function XB(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return $n(a)?n(a):t(a)}}function kE(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tt(e)}function EE(e){return!Wn(e)}function NE(e){return!(e===47||j_(e))}function j_(e){return e===43||e===45||e===46||e===95||$n(e)}function Rx(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 QB={tokenize:s8,partial:!0};function JB(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:n8,continuation:{tokenize:r8},exit:i8}},text:{91:{name:"gfmFootnoteCall",tokenize:t8},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ZB,resolveTo:e8}}}}function ZB(e,t,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l;for(;i--;){const f=r.events[i][1];if(f.type==="labelImage"){l=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return d;function d(f){if(!l||!l._balanced)return n(f);const h=Yr(r.sliceSerialize({start:l.end,end:r.now()}));return h.codePointAt(0)!==94||!a.includes(h.slice(1))?n(f):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),t(f))}}function e8(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)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},d=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...d),e}function t8(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,l;return d;function d(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),f}function f(g){return g!==94?n(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(a>999||g===93&&!l||g===null||g===91||Tt(g))return n(g);if(g===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return i.includes(Yr(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(g)}return Tt(g)||(l=!0),a++,e.consume(g),g===92?p:h}function p(g){return g===91||g===92||g===93?(e.consume(g),a++,h):h(g)}}function n8(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,l=0,d;return f;function f(v){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(v){return v===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(v)}function p(v){if(l>999||v===93&&!d||v===null||v===91||Tt(v))return n(v);if(v===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return a=Yr(r.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return Tt(v)||(d=!0),l++,e.consume(v),v===92?g:p}function g(v){return v===91||v===92||v===93?(e.consume(v),l++,p):p(v)}function x(v){return v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),i.includes(a)||i.push(a),ct(e,_,"gfmFootnoteDefinitionWhitespace")):n(v)}function _(v){return t(v)}}function r8(e,t,n){return e.check(Yc,t,e.attempt(QB,t,n))}function i8(e){e.exit("gfmFootnoteDefinition")}function s8(e,t,n){const r=this;return ct(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?t(a):n(a)}}function a8(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(l,d){let f=-1;for(;++f<l.length;)if(l[f][0]==="enter"&&l[f][1].type==="strikethroughSequenceTemporary"&&l[f][1]._close){let h=f;for(;h--;)if(l[h][0]==="exit"&&l[h][1].type==="strikethroughSequenceTemporary"&&l[h][1]._open&&l[f][1].end.offset-l[f][1].start.offset===l[h][1].end.offset-l[h][1].start.offset){l[f][1].type="strikethroughSequence",l[h][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},l[h][1].start),end:Object.assign({},l[f][1].end)},g={type:"strikethroughText",start:Object.assign({},l[h][1].end),end:Object.assign({},l[f][1].start)},x=[["enter",p,d],["enter",l[h][1],d],["exit",l[h][1],d],["enter",g,d]],_=d.parser.constructs.insideSpan.null;_&&_r(x,x.length,0,Hh(_,l.slice(h+1,f),d)),_r(x,x.length,0,[["exit",g,d],["enter",l[f][1],d],["exit",l[f][1],d],["exit",p,d]]),_r(l,h-1,f-h+3,x),f=h+x.length-2;break}}for(f=-1;++f<l.length;)l[f][1].type==="strikethroughSequenceTemporary"&&(l[f][1].type="data");return l}function a(l,d,f){const h=this.previous,p=this.events;let g=0;return x;function x(v){return h===126&&p[p.length-1][1].type!=="characterEscape"?f(v):(l.enter("strikethroughSequenceTemporary"),_(v))}function _(v){const S=Vo(h);if(v===126)return g>1?f(v):(l.consume(v),g++,_);if(g<2&&!n)return f(v);const w=l.exit("strikethroughSequenceTemporary"),k=Vo(v);return w._open=!k||k===2&&!!S,w._close=!S||S===2&&!!k,d(v)}}}class o8{constructor(){this.map=[]}add(t,n,r){l8(this,t,n,r)}consume(t){if(this.map.sort(function(a,l){return a[0]-l[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 i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function l8(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function c8(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function u8(){return{flow:{null:{name:"table",tokenize:d8,resolveAll:h8}}}}function d8(e,t,n){const r=this;let i=0,a=0,l;return d;function d(L){let G=r.events.length-1;for(;G>-1;){const U=r.events[G][1].type;if(U==="lineEnding"||U==="linePrefix")G--;else break}const H=G>-1?r.events[G][1].type:null,R=H==="tableHead"||H==="tableRow"?M:f;return R===M&&r.parser.lazy[r.now().line]?n(L):R(L)}function f(L){return e.enter("tableHead"),e.enter("tableRow"),h(L)}function h(L){return L===124||(l=!0,a+=1),p(L)}function p(L){return L===null?n(L):Be(L)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),_):n(L):rt(L)?ct(e,p,"whitespace")(L):(a+=1,l&&(l=!1,i+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),l=!0,p):(e.enter("data"),g(L)))}function g(L){return L===null||L===124||Tt(L)?(e.exit("data"),p(L)):(e.consume(L),L===92?x:g)}function x(L){return L===92||L===124?(e.consume(L),g):g(L)}function _(L){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(L):(e.enter("tableDelimiterRow"),l=!1,rt(L)?ct(e,v,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):v(L))}function v(L){return L===45||L===58?w(L):L===124?(l=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),S):P(L)}function S(L){return rt(L)?ct(e,w,"whitespace")(L):w(L)}function w(L){return L===58?(a+=1,l=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),k):L===45?(a+=1,k(L)):L===null||Be(L)?A(L):P(L)}function k(L){return L===45?(e.enter("tableDelimiterFiller"),j(L)):P(L)}function j(L){return L===45?(e.consume(L),j):L===58?(l=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),T):(e.exit("tableDelimiterFiller"),T(L))}function T(L){return rt(L)?ct(e,A,"whitespace")(L):A(L)}function A(L){return L===124?v(L):L===null||Be(L)?!l||i!==a?P(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):P(L)}function P(L){return n(L)}function M(L){return e.enter("tableRow"),q(L)}function q(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),q):L===null||Be(L)?(e.exit("tableRow"),t(L)):rt(L)?ct(e,q,"whitespace")(L):(e.enter("data"),Z(L))}function Z(L){return L===null||L===124||Tt(L)?(e.exit("data"),q(L)):(e.consume(L),L===92?J:Z)}function J(L){return L===92||L===124?(e.consume(L),Z):Z(L)}}function h8(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],l=[0,0,0,0],d=!1,f=0,h,p,g;const x=new o8;for(;++n<e.length;){const _=e[n],v=_[1];_[0]==="enter"?v.type==="tableHead"?(d=!1,f!==0&&(jw(x,t,f,h,p),p=void 0,f=0),h={type:"table",start:Object.assign({},v.start),end:Object.assign({},v.end)},x.add(n,0,[["enter",h,t]])):v.type==="tableRow"||v.type==="tableDelimiterRow"?(r=!0,g=void 0,a=[0,0,0,0],l=[0,n+1,0,0],d&&(d=!1,p={type:"tableBody",start:Object.assign({},v.start),end:Object.assign({},v.end)},x.add(n,0,[["enter",p,t]])),i=v.type==="tableDelimiterRow"?2:p?3:1):i&&(v.type==="data"||v.type==="tableDelimiterMarker"||v.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(a[1]!==0&&(l[0]=l[1],g=jd(x,t,a,i,void 0,g),a=[0,0,0,0]),l[2]=n)):v.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(l[0]=l[1],g=jd(x,t,a,i,void 0,g)),a=l,l=[a[1],n,0,0])):v.type==="tableHead"?(d=!0,f=n):v.type==="tableRow"||v.type==="tableDelimiterRow"?(f=n,a[1]!==0?(l[0]=l[1],g=jd(x,t,a,i,n,g)):l[1]!==0&&(g=jd(x,t,l,i,n,g)),i=0):i&&(v.type==="data"||v.type==="tableDelimiterMarker"||v.type==="tableDelimiterFiller")&&(l[3]=n)}for(f!==0&&jw(x,t,f,h,p),x.consume(t.events),n=-1;++n<t.events.length;){const _=t.events[n];_[0]==="enter"&&_[1].type==="table"&&(_[1]._align=c8(t.events,n))}return e}function jd(e,t,n,r,i,a){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",d="tableContent";n[0]!==0&&(a.end=Object.assign({},Io(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const f=Io(t.events,n[1]);if(a={type:l,start:Object.assign({},f),end:Object.assign({},f)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const h=Io(t.events,n[2]),p=Io(t.events,n[3]),g={type:d,start:Object.assign({},h),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",g,t]]),r!==2){const x=t.events[n[2]],_=t.events[n[3]];if(x[1].end=Object.assign({},_[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const v=n[2]+1,S=n[3]-n[2]-1;e.add(v,S,[])}}e.add(n[3]+1,0,[["exit",g,t]])}return i!==void 0&&(a.end=Object.assign({},Io(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function jw(e,t,n,r,i){const a=[],l=Io(t.events,n);i&&(i.end=Object.assign({},l),a.push(["exit",i,t])),r.end=Object.assign({},l),a.push(["exit",r,t]),e.add(n+1,0,a)}function Io(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const f8={name:"tasklistCheck",tokenize:p8};function m8(){return{text:{91:f8}}}function p8(e,t,n){const r=this;return i;function i(f){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(f):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),a)}function a(f){return Tt(f)?(e.enter("taskListCheckValueUnchecked"),e.consume(f),e.exit("taskListCheckValueUnchecked"),l):f===88||f===120?(e.enter("taskListCheckValueChecked"),e.consume(f),e.exit("taskListCheckValueChecked"),l):n(f)}function l(f){return f===93?(e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):n(f)}function d(f){return Be(f)?t(f):rt(f)?e.check({tokenize:g8},t,n)(f):n(f)}}function g8(e,t,n){return ct(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function _8(e){return B2([FB(),JB(),a8(e),u8(),m8()])}const x8={};function y8(e){const t=this,n=e||x8,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(_8(n)),a.push(BB()),l.push(zB(n))}var T_=Object.defineProperty,v8=Object.getOwnPropertyDescriptor,b8=Object.getOwnPropertyNames,S8=Object.prototype.hasOwnProperty,Mx=(e,t)=>{let n={};for(var r in e)T_(n,r,{get:e[r],enumerable:!0});return T_(n,Symbol.toStringTag,{value:"Module"}),n},w8=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=b8(t),a=0,l=i.length,d;a<l;a++)d=i[a],!S8.call(e,d)&&d!==n&&T_(e,d,{get:(f=>t[f]).bind(null,d),enumerable:!(r=v8(t,d))||r.enumerable});return e},jE=(e,t,n)=>(w8(e,t,"default"),n);const Wh=[{id:"abap",name:"ABAP",import:(()=>z(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>z(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>z(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>z(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>z(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>z(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>z(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>z(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>z(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>z(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>z(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>z(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>z(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>z(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>z(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>z(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>z(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>z(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>z(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>z(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>z(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>z(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>z(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>z(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>z(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>z(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>z(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>z(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>z(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>z(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>z(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>z(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>z(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>z(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>z(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>z(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>z(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>z(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>z(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>z(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>z(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>z(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>z(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>z(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>z(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>z(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>z(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>z(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>z(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>z(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>z(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>z(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>z(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>z(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>z(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>z(()=>import("./erb-Dm6A9KJ5.js"),__vite__mapDeps([32,1,2,3,33,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>z(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>z(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>z(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>z(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>z(()=>import("./fortran-fixed-form-CkoXwp7k.js"),__vite__mapDeps([41,42])))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>z(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>z(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>z(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>z(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>z(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>z(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>z(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>z(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>z(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>z(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>z(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>z(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>z(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>z(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>z(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>z(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>z(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>z(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>z(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>z(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>z(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>z(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>z(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>z(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>z(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>z(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>z(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>z(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>z(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>z(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>z(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>z(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>z(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>z(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>z(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>z(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>z(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>z(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>z(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>z(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>z(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>z(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>z(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>z(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>z(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>z(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>z(()=>import("./just-CUsbIsdP.js"),__vite__mapDeps([63,28,2,11,64,1,3,7,8,16,20,33,34,35,36,13,23,24,25,26,37,38])))},{id:"kdl",name:"KDL",import:(()=>z(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>z(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>z(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>z(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>z(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>z(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>z(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>z(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>z(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>z(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>z(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>z(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>z(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>z(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>z(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>z(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>z(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>z(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>z(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>z(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>z(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>z(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>z(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>z(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>z(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>z(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>z(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>z(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>z(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>z(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>z(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>z(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>z(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>z(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>z(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>z(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>z(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>z(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>z(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>z(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>z(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>z(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>z(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>z(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>z(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>z(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>z(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>z(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>z(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>z(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>z(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>z(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>z(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>z(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>z(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>z(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>z(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>z(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>z(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>z(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>z(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>z(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>z(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>z(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>z(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>z(()=>import("./rst-CpCqk9r5.js"),__vite__mapDeps([80,15,1,2,3,23,24,25,26,16,20,28,38,81,33,34,7,8,35,11,36,13,37])))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>z(()=>import("./ruby-DyJCeAvU.js"),__vite__mapDeps([33,1,2,3,34,7,8,16,35,11,36,13,23,24,25,26,28,37,38])))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>z(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>z(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>z(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>z(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>z(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>z(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>z(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>z(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>z(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>z(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>z(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>z(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>z(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>z(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>z(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>z(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>z(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>z(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>z(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>z(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>z(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>z(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>z(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>z(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>z(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>z(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>z(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>z(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>z(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>z(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>z(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>z(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>z(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>z(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>z(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>z(()=>import("./twig-CW1WmMYd.js"),__vite__mapDeps([95,3,2,5,75,1,7,8,16,9,20,33,34,35,11,36,13,23,24,25,26,28,37,38])))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>z(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>z(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>z(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>z(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>z(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>z(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>z(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>z(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>z(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>z(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>z(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>z(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>z(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>z(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>z(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>z(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>z(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>z(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>z(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>z(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>z(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>z(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>z(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>z(()=>import("./zig-VOosw3JB.js"),[]))}],Ox=Object.fromEntries(Wh.map(e=>[e.id,e.import])),Ix=Object.fromEntries(Wh.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),Px={...Ox,...Ix},Bx=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>z(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>z(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>z(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>z(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>z(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>z(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>z(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>z(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>z(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>z(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>z(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>z(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>z(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>z(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>z(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>z(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>z(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>z(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>z(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>z(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>z(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>z(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>z(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>z(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>z(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>z(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>z(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>z(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>z(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>z(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>z(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>z(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>z(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>z(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>z(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>z(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>z(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>z(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>z(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>z(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>z(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>z(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>z(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>z(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>z(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>z(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>z(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>z(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>z(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>z(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>z(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>z(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>z(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>z(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>z(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>z(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>z(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>z(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>z(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>z(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>z(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>z(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>z(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>z(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>z(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],zx=Object.fromEntries(Bx.map(e=>[e.id,e.import]));var $x=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function C8(){return 2147483648}function k8(){return typeof performance<"u"?performance.now():Date.now()}const E8=(e,t)=>e+(t-e%t)%t;async function N8(e){let t,n;const r={};function i(_){n=_,r.HEAPU8=new Uint8Array(_),r.HEAPU32=new Uint32Array(_)}function a(_,v,S){r.HEAPU8.copyWithin(_,v,v+S)}function l(_){try{return t.grow(_-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function d(_){const v=r.HEAPU8.length;_=_>>>0;const S=C8();if(_>S)return!1;for(let w=1;w<=4;w*=2){let k=v*(1+.2/w);k=Math.min(k,_+100663296);const j=Math.min(S,E8(Math.max(_,k),65536));if(l(j))return!0}return!1}const f=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(_,v,S=1024){const w=v+S;let k=v;for(;_[k]&&!(k>=w);)++k;if(k-v>16&&_.buffer&&f)return f.decode(_.subarray(v,k));let j="";for(;v<k;){let T=_[v++];if(!(T&128)){j+=String.fromCharCode(T);continue}const A=_[v++]&63;if((T&224)===192){j+=String.fromCharCode((T&31)<<6|A);continue}const P=_[v++]&63;if((T&240)===224?T=(T&15)<<12|A<<6|P:T=(T&7)<<18|A<<12|P<<6|_[v++]&63,T<65536)j+=String.fromCharCode(T);else{const M=T-65536;j+=String.fromCharCode(55296|M>>10,56320|M&1023)}}return j}function p(_,v){return _?h(r.HEAPU8,_,v):""}const g={emscripten_get_now:k8,emscripten_memcpy_big:a,emscripten_resize_heap:d,fd_write:()=>0};async function x(){const v=await e({env:g,wasi_snapshot_preview1:g});t=v.memory,i(t.buffer),Object.assign(r,v),r.UTF8ToString=p}return await x(),r}var j8=Object.defineProperty,T8=(e,t,n)=>t in e?j8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pn=(e,t,n)=>T8(e,typeof t!="symbol"?t+"":t,n);let bn=null;function A8(e){throw new $x(e.UTF8ToString(e.getLastOnigError()))}class Gh{constructor(t){pn(this,"utf16Length"),pn(this,"utf8Length"),pn(this,"utf16Value"),pn(this,"utf8Value"),pn(this,"utf16OffsetToUtf8"),pn(this,"utf8OffsetToUtf16");const n=t.length,r=Gh._utf8ByteLength(t),i=r!==n,a=i?new Uint32Array(n+1):null;i&&(a[n]=r);const l=i?new Uint32Array(r+1):null;i&&(l[r]=n);const d=new Uint8Array(r);let f=0;for(let h=0;h<n;h++){const p=t.charCodeAt(h);let g=p,x=!1;if(p>=55296&&p<=56319&&h+1<n){const _=t.charCodeAt(h+1);_>=56320&&_<=57343&&(g=(p-55296<<10)+65536|_-56320,x=!0)}i&&(a[h]=f,x&&(a[h+1]=f),g<=127?l[f+0]=h:g<=2047?(l[f+0]=h,l[f+1]=h):g<=65535?(l[f+0]=h,l[f+1]=h,l[f+2]=h):(l[f+0]=h,l[f+1]=h,l[f+2]=h,l[f+3]=h)),g<=127?d[f++]=g:g<=2047?(d[f++]=192|(g&1984)>>>6,d[f++]=128|(g&63)>>>0):g<=65535?(d[f++]=224|(g&61440)>>>12,d[f++]=128|(g&4032)>>>6,d[f++]=128|(g&63)>>>0):(d[f++]=240|(g&1835008)>>>18,d[f++]=128|(g&258048)>>>12,d[f++]=128|(g&4032)>>>6,d[f++]=128|(g&63)>>>0),x&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=d,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=l}static _utf8ByteLength(t){let n=0;for(let r=0,i=t.length;r<i;r++){const a=t.charCodeAt(r);let l=a,d=!1;if(a>=55296&&a<=56319&&r+1<i){const f=t.charCodeAt(r+1);f>=56320&&f<=57343&&(l=(a-55296<<10)+65536|f-56320,d=!0)}l<=127?n+=1:l<=2047?n+=2:l<=65535?n+=3:n+=4,d&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const qh=class li{constructor(t){if(pn(this,"id",++li.LAST_ID),pn(this,"_onigBinding"),pn(this,"content"),pn(this,"utf16Length"),pn(this,"utf8Length"),pn(this,"utf16OffsetToUtf8"),pn(this,"utf8OffsetToUtf16"),pn(this,"ptr"),!bn)throw new $x("Must invoke loadWasm first.");this._onigBinding=bn,this.content=t;const n=new Gh(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!li._sharedPtrInUse?(li._sharedPtr||(li._sharedPtr=bn.omalloc(1e4)),li._sharedPtrInUse=!0,bn.HEAPU8.set(n.utf8Value,li._sharedPtr),this.ptr=li._sharedPtr):this.ptr=n.createString(bn)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===li._sharedPtr?li._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};pn(qh,"LAST_ID",0);pn(qh,"_sharedPtr",0);pn(qh,"_sharedPtrInUse",!1);let TE=qh;class D8{constructor(t){if(pn(this,"_onigBinding"),pn(this,"_ptr"),!bn)throw new $x("Must invoke loadWasm first.");const n=[],r=[];for(let d=0,f=t.length;d<f;d++){const h=new Gh(t[d]);n[d]=h.createString(bn),r[d]=h.utf8Length}const i=bn.omalloc(4*t.length);bn.HEAPU32.set(n,i/4);const a=bn.omalloc(4*t.length);bn.HEAPU32.set(r,a/4);const l=bn.createOnigScanner(i,a,t.length);for(let d=0,f=t.length;d<f;d++)bn.ofree(n[d]);bn.ofree(a),bn.ofree(i),l===0&&A8(bn),this._onigBinding=bn,this._ptr=l}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let i=0;if(typeof r=="number"&&(i=r),typeof t=="string"){t=new TE(t);const a=this._findNextMatchSync(t,n,!1,i);return t.dispose(),a}return this._findNextMatchSync(t,n,!1,i)}_findNextMatchSync(t,n,r,i){const a=this._onigBinding,l=a.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),i);if(l===0)return null;const d=a.HEAPU32;let f=l/4;const h=d[f++],p=d[f++],g=[];for(let x=0;x<p;x++){const _=t.convertUtf8OffsetToUtf16(d[f++]),v=t.convertUtf8OffsetToUtf16(d[f++]);g[x]={start:_,end:v,length:v-_}}return{index:h,captureIndices:g}}}function L8(e){return typeof e.instantiator=="function"}function R8(e){return typeof e.default=="function"}function M8(e){return typeof e.data<"u"}function O8(e){return typeof Response<"u"&&e instanceof Response}function I8(e){var t;return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&((t=Buffer.isBuffer)==null?void 0:t.call(Buffer,e))||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}let Td;function Hx(e){if(Td)return Td;async function t(){bn=await N8(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),L8(r)?r=await r.instantiator(n):R8(r)?r=await r.default(n):(M8(r)&&(r=r.data),O8(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await P8(r)(n):r=await B8(r)(n):I8(r)?r=await lg(r)(n):r instanceof WebAssembly.Module?r=await lg(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await lg(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Td=t(),Td}function lg(e){return t=>WebAssembly.instantiate(e,t)}function P8(e){return t=>WebAssembly.instantiateStreaming(e,t)}function B8(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let AE;function z8(e){AE=e}function $8(){return AE}async function DE(e){return e&&await Hx(e),{createScanner(t){return new D8(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new TE(t)}}}const H8=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:DE,getDefaultWasmLoader:$8,loadWasm:Hx,setDefaultWasmLoader:z8},Symbol.toStringTag,{value:"Module"}));var LE=Mx({});jE(LE,H8);var Dt=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function F8(e){return Fx(e)}function Fx(e){return Array.isArray(e)?U8(e):e instanceof RegExp?e:typeof e=="object"?V8(e):e}function U8(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Fx(e[n]);return t}function V8(e){let t={};for(let n in e)t[n]=Fx(e[n]);return t}function RE(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function ME(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?ME(e.substring(0,e.length-1)):e.substr(~t+1)}var cg=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ad=class{static hasCaptures(e){return e===null?!1:(cg.lastIndex=0,cg.test(e))}static replaceCaptures(e,t,n){return e.replace(cg,(r,i,a,l)=>{let d=n[parseInt(i||a,10)];if(d){let f=t.substring(d.start,d.end);for(;f[0]===".";)f=f.substring(1);switch(l){case"downcase":return f.toLowerCase();case"upcase":return f.toUpperCase();default:return f}}else return r})}};function OE(e,t){return e<t?-1:e>t?1:0}function IE(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let i=0;i<n;i++){let a=OE(e[i],t[i]);if(a!==0)return a}return 0}return n-r}function Tw(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function PE(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var BE=class{constructor(e){ce(this,"cache",new Map);this.fn=e}get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},dh=class{constructor(e,t,n){ce(this,"_cachedMatchRoot",new BE(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(q8(e),t)}static createFromParsedTheme(e,t){return Y8(e,t)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(i=>W8(e.parent,i.parentScopes));return r?new zE(r.fontStyle,r.foreground,r.background):null}},ug=class Gd{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new Gd(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Gd(n,t[r]);return n}push(t){return new Gd(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function W8(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!G8(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function G8(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var zE=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function q8(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let i=0,a=t.length;i<a;i++){let l=t[i];if(!l.settings)continue;let d;if(typeof l.scope=="string"){let g=l.scope;g=g.replace(/^[,]+/,""),g=g.replace(/[,]+$/,""),d=g.split(",")}else Array.isArray(l.scope)?d=l.scope:d=[""];let f=-1;if(typeof l.settings.fontStyle=="string"){f=0;let g=l.settings.fontStyle.split(" ");for(let x=0,_=g.length;x<_;x++)switch(g[x]){case"italic":f=f|1;break;case"bold":f=f|2;break;case"underline":f=f|4;break;case"strikethrough":f=f|8;break}}let h=null;typeof l.settings.foreground=="string"&&Tw(l.settings.foreground)&&(h=l.settings.foreground);let p=null;typeof l.settings.background=="string"&&Tw(l.settings.background)&&(p=l.settings.background);for(let g=0,x=d.length;g<x;g++){let v=d[g].trim().split(" "),S=v[v.length-1],w=null;v.length>1&&(w=v.slice(0,v.length-1),w.reverse()),n[r++]=new K8(S,w,i,f,h,p)}}return n}var K8=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},zn=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(zn||{});function Y8(e,t){e.sort((f,h)=>{let p=OE(f.scope,h.scope);return p!==0||(p=IE(f.parentScopes,h.parentScopes),p!==0)?p:f.index-h.index});let n=0,r="#000000",i="#ffffff";for(;e.length>=1&&e[0].scope==="";){let f=e.shift();f.fontStyle!==-1&&(n=f.fontStyle),f.foreground!==null&&(r=f.foreground),f.background!==null&&(i=f.background)}let a=new X8(t),l=new zE(n,a.getId(r),a.getId(i)),d=new J8(new A_(0,null,-1,0,0),[]);for(let f=0,h=e.length;f<h;f++){let p=e[f];d.insert(0,p.scope,p.parentScopes,p.fontStyle,a.getId(p.foreground),a.getId(p.background))}return new dh(a,l,d)}var X8=class{constructor(e){ce(this,"_isFrozen");ce(this,"_lastColorId");ce(this,"_id2color");ce(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Q8=Object.freeze([]),A_=class $E{constructor(t,n,r,i,a){ce(this,"scopeDepth");ce(this,"parentScopes");ce(this,"fontStyle");ce(this,"foreground");ce(this,"background");this.scopeDepth=t,this.parentScopes=n||Q8,this.fontStyle=r,this.foreground=i,this.background=a}clone(){return new $E(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,i=t.length;r<i;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,i){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),i!==0&&(this.background=i)}},J8=class D_{constructor(t,n=[],r={}){ce(this,"_rulesWithParentScopes");this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,i=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[i]===">"&&i++,!(r>=t.parentScopes.length||i>=n.parentScopes.length);){const a=n.parentScopes[i].length-t.parentScopes[r].length;if(a!==0)return a;r++,i++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),i,a;if(r===-1?(i=t,a=""):(i=t.substring(0,r),a=t.substring(r+1)),this._children.hasOwnProperty(i))return this._children[i].match(a)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(D_._cmpBySpecificity),n}insert(t,n,r,i,a,l){if(n===""){this._doInsertHere(t,r,i,a,l);return}let d=n.indexOf("."),f,h;d===-1?(f=n,h=""):(f=n.substring(0,d),h=n.substring(d+1));let p;this._children.hasOwnProperty(f)?p=this._children[f]:(p=new D_(this._mainRule.clone(),A_.cloneArr(this._rulesWithParentScopes)),this._children[f]=p),p.insert(t+1,h,r,i,a,l)}_doInsertHere(t,n,r,i,a){if(n===null){this._mainRule.acceptOverwrite(t,r,i,a);return}for(let l=0,d=this._rulesWithParentScopes.length;l<d;l++){let f=this._rulesWithParentScopes[l];if(IE(f.parentScopes,n)===0){f.acceptOverwrite(t,r,i,a);return}}r===-1&&(r=this._mainRule.fontStyle),i===0&&(i=this._mainRule.foreground),a===0&&(a=this._mainRule.background),this._rulesWithParentScopes.push(new A_(t,n,r,i,a))}},Wo=class Dr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Dr.getLanguageId(t),r=Dr.getTokenType(t),i=Dr.getFontStyle(t),a=Dr.getForeground(t),l=Dr.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:l})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,i,a,l,d){let f=Dr.getLanguageId(t),h=Dr.getTokenType(t),p=Dr.containsBalancedBrackets(t)?1:0,g=Dr.getFontStyle(t),x=Dr.getForeground(t),_=Dr.getBackground(t);return n!==0&&(f=n),r!==8&&(h=r),i!==null&&(p=i?1:0),a!==-1&&(g=a),l!==0&&(x=l),d!==0&&(_=d),(f<<0|h<<8|p<<10|g<<11|x<<15|_<<24)>>>0}};function hh(e,t){const n=[],r=Z8(e);let i=r.next();for(;i!==null;){let f=0;if(i.length===2&&i.charAt(1)===":"){switch(i.charAt(0)){case"R":f=1;break;case"L":f=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let h=l();if(n.push({matcher:h,priority:f}),i!==",")break;i=r.next()}return n;function a(){if(i==="-"){i=r.next();const f=a();return h=>!!f&&!f(h)}if(i==="("){i=r.next();const f=d();return i===")"&&(i=r.next()),f}if(Aw(i)){const f=[];do f.push(i),i=r.next();while(Aw(i));return h=>t(f,h)}return null}function l(){const f=[];let h=a();for(;h;)f.push(h),h=a();return p=>f.every(g=>g(p))}function d(){const f=[];let h=l();for(;h&&(f.push(h),i==="|"||i===",");){do i=r.next();while(i==="|"||i===",");h=l()}return p=>f.some(g=>g(p))}}function Aw(e){return!!e&&!!e.match(/[\w\.:]+/)}function Z8(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function HE(e){typeof e.dispose=="function"&&e.dispose()}var Dc=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},ez=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},tz=class{constructor(){ce(this,"_references",[]);ce(this,"_seenReferenceKeys",new Set);ce(this,"visitedRule",new Set)}get references(){return this._references}add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},nz=class{constructor(e,t){ce(this,"seenFullScopeRequests",new Set);ce(this,"seenPartialScopeRequests",new Set);ce(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Dc(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new tz;for(const n of e)rz(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof Dc){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function rz(e,t,n,r){const i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const a=n.lookup(t);e instanceof Dc?qd({baseGrammar:a,selfGrammar:i},r):L_(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);const l=n.injections(e.scopeName);if(l)for(const d of l)r.add(new Dc(d))}function L_(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];fh([r],t,n)}}function qd(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&fh(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&fh(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function fh(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const i=r.repository?RE({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&fh(r.patterns,{...t,repository:i},n);const a=r.include;if(!a)continue;const l=FE(a);switch(l.kind){case 0:qd({...t,selfGrammar:t.baseGrammar},n);break;case 1:qd(t,n);break;case 2:L_(l.ruleName,{...t,repository:i},n);break;case 3:case 4:const d=l.scopeName===t.selfGrammar.scopeName?t.selfGrammar:l.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(d){const f={baseGrammar:t.baseGrammar,selfGrammar:d,repository:i};l.kind===4?L_(l.ruleName,f,n):qd(f,n)}else l.kind===4?n.add(new ez(l.scopeName,l.ruleName)):n.add(new Dc(l.scopeName));break}}}var iz=class{constructor(){ce(this,"kind",0)}},sz=class{constructor(){ce(this,"kind",1)}},az=class{constructor(e){ce(this,"kind",2);this.ruleName=e}},oz=class{constructor(e){ce(this,"kind",3);this.scopeName=e}},lz=class{constructor(e,t){ce(this,"kind",4);this.scopeName=e,this.ruleName=t}};function FE(e){if(e==="$base")return new iz;if(e==="$self")return new sz;const t=e.indexOf("#");if(t===-1)return new oz(e);if(t===0)return new az(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new lz(n,r)}}var cz=/\\(\d+)/,Dw=/\\(\d+)/g,uz=-1,UE=-2;var Qc=class{constructor(e,t,n,r){ce(this,"$location");ce(this,"id");ce(this,"_nameIsCapturing");ce(this,"_name");ce(this,"_contentNameIsCapturing");ce(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Ad.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Ad.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${ME(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Ad.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ad.replaceCaptures(this._contentName,e,t)}},dz=class extends Qc{constructor(t,n,r,i,a){super(t,n,r,i);ce(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=a}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,r,i){throw new Error("Not supported!")}},hz=class extends Qc{constructor(t,n,r,i,a){super(t,n,r,null);ce(this,"_match");ce(this,"captures");ce(this,"_cachedCompiledPatterns");this._match=new Lc(i,this.id),this.captures=a,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,n){n.push(this._match)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,i){return this._getCachedCompiledPatterns(t).compileAG(t,r,i)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Rc,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Lw=class extends Qc{constructor(t,n,r,i,a){super(t,n,r,i);ce(this,"hasMissingPatterns");ce(this,"patterns");ce(this,"_cachedCompiledPatterns");this.patterns=a.patterns,this.hasMissingPatterns=a.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,n){for(const r of this.patterns)t.getRule(r).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,i){return this._getCachedCompiledPatterns(t).compileAG(t,r,i)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Rc,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},R_=class extends Qc{constructor(t,n,r,i,a,l,d,f,h,p){super(t,n,r,i);ce(this,"_begin");ce(this,"beginCaptures");ce(this,"_end");ce(this,"endHasBackReferences");ce(this,"endCaptures");ce(this,"applyEndPatternLast");ce(this,"hasMissingPatterns");ce(this,"patterns");ce(this,"_cachedCompiledPatterns");this._begin=new Lc(a,this.id),this.beginCaptures=l,this._end=new Lc(d||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=f,this.applyEndPatternLast=h||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,i){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,i)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Rc;for(const r of this.patterns)t.getRule(r).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,n):this._cachedCompiledPatterns.setSource(0,n)),this._cachedCompiledPatterns}},mh=class extends Qc{constructor(t,n,r,i,a,l,d,f,h){super(t,n,r,i);ce(this,"_begin");ce(this,"beginCaptures");ce(this,"whileCaptures");ce(this,"_while");ce(this,"whileHasBackReferences");ce(this,"hasMissingPatterns");ce(this,"patterns");ce(this,"_cachedCompiledPatterns");ce(this,"_cachedCompiledWhilePatterns");this._begin=new Lc(a,this.id),this.beginCaptures=l,this.whileCaptures=f,this._while=new Lc(d,UE),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=h.patterns,this.hasMissingPatterns=h.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,n){return this._while.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,i){return this._getCachedCompiledPatterns(t).compileAG(t,r,i)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Rc;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,n){return this._getCachedCompiledWhilePatterns(t,n).compile(t)}compileWhileAG(t,n,r,i){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,r,i)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Rc,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},VE=class Bn{static createCaptureRule(t,n,r,i,a){return t.registerRule(l=>new dz(n,l,r,i,a))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new hz(t.$vscodeTextmateLocation,t.id,t.name,t.match,Bn._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=RE({},r,t.repository));let a=t.patterns;return typeof a>"u"&&t.include&&(a=[{include:t.include}]),new Lw(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Bn._compilePatterns(a,n,r))}return t.while?new mh(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Bn._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Bn._compileCaptures(t.whileCaptures||t.captures,n,r),Bn._compilePatterns(t.patterns,n,r)):new R_(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Bn._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Bn._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Bn._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(const l in t){if(l==="$vscodeTextmateLocation")continue;const d=parseInt(l,10);d>a&&(a=d)}for(let l=0;l<=a;l++)i[l]=null;for(const l in t){if(l==="$vscodeTextmateLocation")continue;const d=parseInt(l,10);let f=0;t[l].patterns&&(f=Bn.getCompiledRuleId(t[l],n,r)),i[d]=Bn.createCaptureRule(n,t[l].$vscodeTextmateLocation,t[l].name,t[l].contentName,f)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,l=t.length;a<l;a++){const d=t[a];let f=-1;if(d.include){const h=FE(d.include);switch(h.kind){case 0:case 1:f=Bn.getCompiledRuleId(r[d.include],n,r);break;case 2:let p=r[h.ruleName];p&&(f=Bn.getCompiledRuleId(p,n,r));break;case 3:case 4:const g=h.scopeName,x=h.kind===4?h.ruleName:null,_=n.getExternalGrammar(g,r);if(_)if(x){let v=_.repository[x];v&&(f=Bn.getCompiledRuleId(v,n,_.repository))}else f=Bn.getCompiledRuleId(_.repository.$self,n,_.repository);break}}else f=Bn.getCompiledRuleId(d,n,r);if(f!==-1){const h=n.getRule(f);let p=!1;if((h instanceof Lw||h instanceof R_||h instanceof mh)&&h.hasMissingPatterns&&h.patterns.length===0&&(p=!0),p)continue;i.push(f)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Lc=class WE{constructor(t,n){ce(this,"source");ce(this,"ruleId");ce(this,"hasAnchor");ce(this,"hasBackReferences");ce(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let i=0,a=[],l=!1;for(let d=0;d<r;d++)if(t.charAt(d)==="\\"&&d+1<r){const h=t.charAt(d+1);h==="z"?(a.push(t.substring(i,d)),a.push("$(?!\\n)(?<!\\n)"),i=d+2):(h==="A"||h==="G")&&(l=!0),d++}this.hasAnchor=l,i===0?this.source=t:(a.push(t.substring(i,r)),this.source=a.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=cz.test(this.source):this.hasBackReferences=!1}clone(){return new WE(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(i=>t.substring(i.start,i.end));return Dw.lastIndex=0,this.source.replace(Dw,(i,a)=>PE(r[parseInt(a,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],i=[],a,l,d,f;for(a=0,l=this.source.length;a<l;a++)d=this.source.charAt(a),t[a]=d,n[a]=d,r[a]=d,i[a]=d,d==="\\"&&a+1<l&&(f=this.source.charAt(a+1),f==="A"?(t[a+1]="￿",n[a+1]="￿",r[a+1]="A",i[a+1]="A"):f==="G"?(t[a+1]="￿",n[a+1]="G",r[a+1]="￿",i[a+1]="G"):(t[a+1]=f,n[a+1]=f,r[a+1]=f,i[a+1]=f),a++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:i.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Rc=class{constructor(){ce(this,"_items");ce(this,"_hasAnchors");ce(this,"_cached");ce(this,"_anchorCache");this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Rw(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(i=>i.resolveAnchors(t,n));return new Rw(e,r,this._items.map(i=>i.ruleId))}},Rw=class{constructor(e,t,n){ce(this,"scanner");this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
141
+ `)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},dg=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Wi,fz=(Wi=class{constructor(t,n){ce(this,"_defaultAttributes");ce(this,"_embeddedLanguagesMatcher");ce(this,"_getBasicScopeAttributes",new BE(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new dg(n,r)}));this._defaultAttributes=new dg(t,8),this._embeddedLanguagesMatcher=new mz(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Wi._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(Wi.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}},ce(Wi,"_NULL_SCOPE_METADATA",new dg(0,0)),ce(Wi,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),Wi),mz=class{constructor(e){ce(this,"values");ce(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>PE(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},Mw=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function GE(e,t,n,r,i,a,l,d){const f=t.content.length;let h=!1,p=-1;if(l){const _=pz(e,t,n,r,i,a);i=_.stack,r=_.linePos,n=_.isFirstLine,p=_.anchorPosition}const g=Date.now();for(;!h;){if(d!==0&&Date.now()-g>d)return new Mw(i,!0);x()}return new Mw(i,!1);function x(){const _=gz(e,t,n,r,i,p);if(!_){a.produce(i,f),h=!0;return}const v=_.captureIndices,S=_.matchedRuleId,w=v&&v.length>0?v[0].end>r:!1;if(S===uz){const k=i.getRule(e);a.produce(i,v[0].start),i=i.withContentNameScopesList(i.nameScopesList),_c(e,t,n,i,a,k.endCaptures,v),a.produce(i,v[0].end);const j=i;if(i=i.parent,p=j.getAnchorPos(),!w&&j.getEnterPos()===r){i=j,a.produce(i,f),h=!0;return}}else{const k=e.getRule(S);a.produce(i,v[0].start);const j=i,T=k.getName(t.content,v),A=i.contentNameScopesList.pushAttributed(T,e);if(i=i.push(S,r,p,v[0].end===f,null,A,A),k instanceof R_){const P=k;_c(e,t,n,i,a,P.beginCaptures,v),a.produce(i,v[0].end),p=v[0].end;const M=P.getContentName(t.content,v),q=A.pushAttributed(M,e);if(i=i.withContentNameScopesList(q),P.endHasBackReferences&&(i=i.withEndRule(P.getEndWithResolvedBackReferences(t.content,v))),!w&&j.hasSameRuleAs(i)){i=i.pop(),a.produce(i,f),h=!0;return}}else if(k instanceof mh){const P=k;_c(e,t,n,i,a,P.beginCaptures,v),a.produce(i,v[0].end),p=v[0].end;const M=P.getContentName(t.content,v),q=A.pushAttributed(M,e);if(i=i.withContentNameScopesList(q),P.whileHasBackReferences&&(i=i.withEndRule(P.getWhileWithResolvedBackReferences(t.content,v))),!w&&j.hasSameRuleAs(i)){i=i.pop(),a.produce(i,f),h=!0;return}}else if(_c(e,t,n,i,a,k.captures,v),a.produce(i,v[0].end),i=i.pop(),!w){i=i.safePop(),a.produce(i,f),h=!0;return}}v[0].end>r&&(r=v[0].end,n=!1)}}function pz(e,t,n,r,i,a){let l=i.beginRuleCapturedEOL?0:-1;const d=[];for(let f=i;f;f=f.pop()){const h=f.getRule(e);h instanceof mh&&d.push({rule:h,stack:f})}for(let f=d.pop();f;f=d.pop()){const{ruleScanner:h,findOptions:p}=yz(f.rule,e,f.stack.endRule,n,r===l),g=h.findNextMatchSync(t,r,p);if(g){if(g.ruleId!==UE){i=f.stack.pop();break}g.captureIndices&&g.captureIndices.length&&(a.produce(f.stack,g.captureIndices[0].start),_c(e,t,n,f.stack,a,f.rule.whileCaptures,g.captureIndices),a.produce(f.stack,g.captureIndices[0].end),l=g.captureIndices[0].end,g.captureIndices[0].end>r&&(r=g.captureIndices[0].end,n=!1))}else{i=f.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:l,isFirstLine:n}}function gz(e,t,n,r,i,a){const l=_z(e,t,n,r,i,a),d=e.getInjections();if(d.length===0)return l;const f=xz(d,e,t,n,r,i,a);if(!f)return l;if(!l)return f;const h=l.captureIndices[0].start,p=f.captureIndices[0].start;return p<h||f.priorityMatch&&p===h?f:l}function _z(e,t,n,r,i,a){const l=i.getRule(e),{ruleScanner:d,findOptions:f}=qE(l,e,i.endRule,n,r===a),h=d.findNextMatchSync(t,r,f);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function xz(e,t,n,r,i,a,l){let d=Number.MAX_VALUE,f=null,h,p=0;const g=a.contentNameScopesList.getScopeNames();for(let x=0,_=e.length;x<_;x++){const v=e[x];if(!v.matcher(g))continue;const S=t.getRule(v.ruleId),{ruleScanner:w,findOptions:k}=qE(S,t,null,r,i===l),j=w.findNextMatchSync(n,i,k);if(!j)continue;const T=j.captureIndices[0].start;if(!(T>=d)&&(d=T,f=j.captureIndices,h=j.ruleId,p=v.priority,d===i))break}return f?{priorityMatch:p===-1,captureIndices:f,matchedRuleId:h}:null}function qE(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function yz(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function _c(e,t,n,r,i,a,l){if(a.length===0)return;const d=t.content,f=Math.min(a.length,l.length),h=[],p=l[0].end;for(let g=0;g<f;g++){const x=a[g];if(x===null)continue;const _=l[g];if(_.length===0)continue;if(_.start>p)break;for(;h.length>0&&h[h.length-1].endPos<=_.start;)i.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?i.produceFromScopes(h[h.length-1].scopes,_.start):i.produce(r,_.start),x.retokenizeCapturedWithRuleId){const S=x.getName(d,l),w=r.contentNameScopesList.pushAttributed(S,e),k=x.getContentName(d,l),j=w.pushAttributed(k,e),T=r.push(x.retokenizeCapturedWithRuleId,_.start,-1,!1,null,w,j),A=e.createOnigString(d.substring(0,_.end));GE(e,A,n&&_.start===0,_.start,T,i,!1,0),HE(A);continue}const v=x.getName(d,l);if(v!==null){const w=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(v,e);h.push(new vz(w,_.end))}}for(;h.length>0;)i.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var vz=class{constructor(e,t){ce(this,"scopes");ce(this,"endPos");this.scopes=e,this.endPos=t}};function bz(e,t,n,r,i,a,l,d){return new wz(e,t,n,r,i,a,l,d)}function Ow(e,t,n,r,i){const a=hh(t,ph),l=VE.getCompiledRuleId(n,r,i.repository);for(const d of a)e.push({debugSelector:t,matcher:d.matcher,ruleId:l,grammar:i,priority:d.priority})}function ph(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let i=n;i<t.length;i++)if(Sz(t[i],r))return n=i+1,!0;return!1})}function Sz(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var wz=class{constructor(e,t,n,r,i,a,l,d){ce(this,"_rootId");ce(this,"_lastRuleId");ce(this,"_ruleId2desc");ce(this,"_includedGrammars");ce(this,"_grammarRepository");ce(this,"_grammar");ce(this,"_injections");ce(this,"_basicScopeAttributesProvider");ce(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=d,this._basicScopeAttributesProvider=new fz(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=l,this._grammar=Iw(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const f of Object.keys(i)){const h=hh(f,ph);for(const p of h)this._tokenTypeMatchers.push({matcher:p.matcher,type:i[f]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:i=>i===this._rootScopeName?this._grammar:this.getExternalGrammar(i),injections:i=>this._grammarRepository.injections(i)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const i=r.injections;if(i)for(let l in i)Ow(t,l,i[l],this,r);const a=this._grammarRepository.injections(n);a&&a.forEach(l=>{const d=this.getExternalGrammar(l);if(d){const f=d.injectionSelector;f&&Ow(t,f,d,this,d)}})}return t.sort((i,a)=>i.priority-a.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Iw(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=VE.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===M_.NULL){i=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),g=Wo.set(0,h.languageId,h.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),x=this.getRule(this._rootId).getName(null,null);let _;x?_=wc.createRootAndLookUpScopeName(x,g,this):_=wc.createRoot("unknown",g),t=new M_(null,this._rootId,-1,-1,!1,null,_,_)}else i=!1,t.reset();e=e+`
142
+ `;const a=this.createOnigString(e),l=a.content.length,d=new kz(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),f=GE(this,a,i,0,t,d,!0,r);return HE(a),{lineLength:l,lineTokens:d,ruleStack:f.stack,stoppedEarly:f.stoppedEarly}}};function Iw(e,t){return e=F8(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var wc=class ci{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,i=(t==null?void 0:t.scopePath)??null;for(const a of n)i=ug.push(i,a.scopeNames),r=new ci(r,i,a.encodedTokenAttributes);return r}static createRoot(t,n){return new ci(null,new ug(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const i=r.getMetadataForScope(t),a=new ug(null,t),l=r.themeProvider.themeMatch(a),d=ci.mergeAttributes(n,i,l);return new ci(null,a,d)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return ci.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let i=-1,a=0,l=0;return r!==null&&(i=r.fontStyle,a=r.foregroundId,l=r.backgroundId),Wo.set(t,n.languageId,n.tokenType,null,i,a,l)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return ci._pushAttributed(this,t,n);const r=t.split(/ /g);let i=this;for(const a of r)i=ci._pushAttributed(i,a,n);return i}static _pushAttributed(t,n,r){const i=r.getMetadataForScope(n),a=t.scopePath.push(n),l=r.themeProvider.themeMatch(a),d=ci.mergeAttributes(t.tokenAttributes,i,l);return new ci(t,a,d)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var i;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((i=r.parent)==null?void 0:i.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},Mr,M_=(Mr=class{constructor(t,n,r,i,a,l,d,f){ce(this,"_stackElementBrand");ce(this,"_enterPos");ce(this,"_anchorPos");ce(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=a,this.endRule=l,this.nameScopesList=d,this.contentNameScopesList=f,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=i}equals(t){return t===null?!1:Mr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?wc.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){Mr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,l,d){return new Mr(this,t,n,r,i,a,l,d)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){var r,i;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(i=this.contentNameScopesList)==null?void 0:i.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new Mr(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){var t,n,r;return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:((n=this.nameScopesList)==null?void 0:n.getExtensionIfDefined(((t=this.parent)==null?void 0:t.nameScopesList)??null))??[],contentNameScopesList:((r=this.contentNameScopesList)==null?void 0:r.getExtensionIfDefined(this.nameScopesList))??[]}}static pushFrame(t,n){const r=wc.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new Mr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,wc.fromExtension(r,n.contentNameScopesList))}},ce(Mr,"NULL",new Mr(null,0,0,0,!1,null,null,null)),Mr),Cz=class{constructor(e,t){ce(this,"balancedBracketScopes");ce(this,"unbalancedBracketScopes");ce(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):hh(n,ph).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>hh(n,ph).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},kz=class{constructor(e,t,n,r){ce(this,"_emitBinaryTokens");ce(this,"_lineText");ce(this,"_tokens");ce(this,"_binaryTokens");ce(this,"_lastTokenEndIndex");ce(this,"_tokenTypeOverrides");this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){var r;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let i=(e==null?void 0:e.tokenAttributes)??0,a=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(a=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const l=(e==null?void 0:e.getScopeNames())??[];for(const d of this._tokenTypeOverrides)d.matcher(l)&&(i=Wo.set(i,0,d.type,null,-1,0,0));this.balancedBracketSelectors&&(a=this.balancedBracketSelectors.match(l))}if(a&&(i=Wo.set(i,0,8,a,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===i){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(i),this._lastTokenEndIndex=t;return}const n=(e==null?void 0:e.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,i=this._binaryTokens.length;r<i;r++)n[r]=this._binaryTokens[r];return n}},Ez=class{constructor(e,t){ce(this,"_grammars",new Map);ce(this,"_rawGrammars",new Map);ce(this,"_injectionGrammars",new Map);ce(this,"_theme");this._onigLib=t,this._theme=e}dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,bz(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},Nz=class{constructor(t){ce(this,"_options");ce(this,"_syncRegistry");ce(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new Ez(dh.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(dh.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,r){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(t,n,r){return this._loadGrammar(t,n,r.embeddedLanguages,r.tokenTypes,new Cz(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,i,a){const l=new nz(this._syncRegistry,t);for(;l.Q.length>0;)l.Q.map(d=>this._loadSingleGrammar(d.scopeName)),l.processQueue();return this._grammarForScopeName(t,n,r,i,a)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,i=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,i)}_grammarForScopeName(t,n=0,r=null,i=null,a=null){return this._syncRegistry.grammarForScopeName(t,n,r,i,a)}},O_=M_.NULL;function gh(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[i,a]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof a=="string"?n[i]=a:i===r&&Object.assign(n,a);return n}function Ps(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function jz(e){return Array.isArray(e)?e:[e]}async function KE(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Kh(e){return!e||["plaintext","txt","text","plain"].includes(e)}function YE(e){return e==="ansi"||Kh(e)}function Yh(e){return e==="none"}function XE(e){return Yh(e)}const Tz=/(\r?\n)/g;function Xh(e,t=!1){var a;if(e.length===0)return[["",0]];const n=e.split(Tz);let r=0;const i=[];for(let l=0;l<n.length;l+=2){const d=t?n[l]+(n[l+1]||""):n[l];i.push([d,r]),r+=n[l].length,r+=((a=n[l+1])==null?void 0:a.length)||0}return i}const Pw={light:"#333333",dark:"#bbbbbb"},Bw={light:"#fffffe",dark:"#1e1e1e"},zw="__shiki_resolved";function Ux(e){var d,f,h,p,g;if(e!=null&&e[zw])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||(t.type="dark"),t.colorReplacements={...t.colorReplacements},t.settings||(t.settings=[]);let{bg:n,fg:r}=t;if(!n||!r){const x=t.settings?t.settings.find(_=>!_.name&&!_.scope):void 0;(d=x==null?void 0:x.settings)!=null&&d.foreground&&(r=x.settings.foreground),(f=x==null?void 0:x.settings)!=null&&f.background&&(n=x.settings.background),!r&&((h=t==null?void 0:t.colors)!=null&&h["editor.foreground"])&&(r=t.colors["editor.foreground"]),!n&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Pw.light:Pw.dark),n||(n=t.type==="light"?Bw.light:Bw.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0;const a=new Map;function l(x){var v;if(a.has(x))return a.get(x);i+=1;const _=`#${i.toString(16).padStart(8,"0").toLowerCase()}`;return(v=t.colorReplacements)!=null&&v[`#${_}`]?l(x):(a.set(x,_),_)}t.settings=t.settings.map(x=>{var w,k;const _=((w=x.settings)==null?void 0:w.foreground)&&!x.settings.foreground.startsWith("#"),v=((k=x.settings)==null?void 0:k.background)&&!x.settings.background.startsWith("#");if(!_&&!v)return x;const S={...x,settings:{...x.settings}};if(_){const j=l(x.settings.foreground);t.colorReplacements[j]=x.settings.foreground,S.settings.foreground=j}if(v){const j=l(x.settings.background);t.colorReplacements[j]=x.settings.background,S.settings.background=j}return S});for(const x of Object.keys(t.colors||{}))if((x==="editor.foreground"||x==="editor.background"||x.startsWith("terminal.ansi"))&&!((g=t.colors[x])!=null&&g.startsWith("#"))){const _=l(t.colors[x]);t.colorReplacements[_]=t.colors[x],t.colors[x]=_}return Object.defineProperty(t,zw,{enumerable:!1,writable:!1,value:!0}),t}async function QE(e){return[...new Set((await Promise.all(e.filter(t=>!YE(t)).map(async t=>await KE(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function JE(e){return(await Promise.all(e.map(async t=>XE(t)?null:Ux(await KE(t))))).filter(t=>!!t)}function ZE(e,t){if(!t)return e;if(t[e]){const n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new Dt(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Az=class extends Nz{constructor(t,n,r,i={}){super(t);ce(this,"_resolver");ce(this,"_themes");ce(this,"_langs");ce(this,"_alias");ce(this,"_resolvedThemes",new Map);ce(this,"_resolvedGrammars",new Map);ce(this,"_langMap",new Map);ce(this,"_langGraph",new Map);ce(this,"_textmateThemeCache",new WeakMap);ce(this,"_loadedThemesCache",null);ce(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=i,this._themes.map(a=>this.loadTheme(a)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=Ux(t);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let n=this._textmateThemeCache.get(t);n||(n=dh.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=ZE(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var a,l,d,f;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(h=>{var p;return(p=h.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const i=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(i.name=t.name,this._resolvedGrammars.set(t.name,i),t.aliases&&t.aliases.forEach(h=>{this._alias[h]=t.name}),this._loadedLanguagesCache=null,n.size)for(const h of n)this._resolvedGrammars.delete(h.name),this._loadedLanguagesCache=null,(l=(a=this._syncRegistry)==null?void 0:a._injectionGrammars)==null||l.delete(h.scopeName),(f=(d=this._syncRegistry)==null?void 0:d._grammars)==null||f.delete(h.scopeName),this.loadLanguage(this._langMap.get(h.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const i of t)this.resolveEmbeddedLanguages(i);const n=[...this._langGraph.entries()],r=n.filter(([i,a])=>!a);if(r.length){const i=n.filter(([a,l])=>{var d;return l?(d=l.embeddedLanguages||l.embeddedLangs)==null?void 0:d.some(f=>r.map(([h])=>h).includes(f)):!1}).filter(a=>!r.includes(a));throw new Dt(`Missing languages ${r.map(([a])=>`\`${a}\``).join(", ")}, required by ${i.map(([a])=>`\`${a}\``).join(", ")}`)}for(const[i,a]of n)this._resolver.addLanguage(a);for(const[i,a]of n)this.loadLanguage(a)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);const n=t.embeddedLanguages??t.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}},Dz=class{constructor(e,t){ce(this,"_langs",new Map);ce(this,"_scopeToLang",new Map);ce(this,"_injections",new Map);ce(this,"_onigLib");this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const i=t.slice(0,r).join(".");n=[...n,...this._injections.get(i)||[]]}return n}};let ac=0;function Lz(e){ac+=1,e.warnings!==!1&&ac>=10&&ac%10===0&&console.warn(`[Shiki] ${ac} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Dt("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Ux),i=new Az(new Dz(e.engine,n),r,n,e.langAlias);let a;function l(j){return ZE(j,e.langAlias)}function d(j){w();const T=i.getGrammar(typeof j=="string"?j:j.name);if(!T)throw new Dt(`Language \`${j}\` not found, you may need to load it first`);return T}function f(j){if(j==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};w();const T=i.getTheme(j);if(!T)throw new Dt(`Theme \`${j}\` not found, you may need to load it first`);return T}function h(j){w();const T=f(j);return a!==j&&(i.setTheme(T),a=j),{theme:T,colorMap:i.getColorMap()}}function p(){return w(),i.getLoadedThemes()}function g(){return w(),i.getLoadedLanguages()}function x(...j){w(),i.loadLanguages(j.flat(1))}async function _(...j){return x(await QE(j))}function v(...j){w();for(const T of j.flat(1))i.loadTheme(T)}async function S(...j){return w(),v(await JE(j))}function w(){if(t)throw new Dt("Shiki instance has been disposed")}function k(){t||(t=!0,i.dispose(),ac-=1)}return{setTheme:h,getTheme:f,getLanguage:d,getLoadedThemes:p,getLoadedLanguages:g,resolveLangAlias:l,loadLanguage:_,loadLanguageSync:x,loadTheme:S,loadThemeSync:v,dispose:k,[Symbol.dispose]:k}}async function Rz(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([JE(e.themes||[]),QE(e.langs||[]),e.engine]);return Lz({...e,themes:t,langs:n,engine:r})}const eN=new WeakMap;function Qh(e,t){eN.set(e,t)}function Mc(e){return eN.get(e)}var Jh=class tN{constructor(...t){ce(this,"_stacks",{});ce(this,"lang");if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,i]=t;this.lang=r,this._stacks={[i]:n}}}get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new tN(Object.fromEntries(jz(n).map(r=>[r,O_])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Mz(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Mz(e){const t=[],n=new Set;function r(i){var l;if(n.has(i))return;n.add(i);const a=(l=i==null?void 0:i.nameScopesList)==null?void 0:l.scopeName;a&&t.push(a),i.parent&&r(i.parent)}return r(e),t}function Oz(e,t){if(!(e instanceof Jh))throw new Dt("Invalid grammar state");return e.getInternalStack(t)}const Iz=/,/,Pz=/ /;function nN(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(Kh(e.resolveLangAlias(n.lang||"text"))||Yh(r))return Xh(t).map(d=>[{content:d[0],offset:d[1]}]);const{theme:i,colorMap:a}=e.setTheme(r),l=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==l.name)throw new Dt(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${l.name}"`);if(!n.grammarState.themes.includes(i.name))throw new Dt(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return zz(t,l,i,a,n)}function Bz(...e){if(e.length===2)return Mc(e[1]);const[t,n,r={}]=e,{lang:i="text",theme:a=t.getLoadedThemes()[0]}=r;if(Kh(i)||Yh(a))throw new Dt("Plain language does not have grammar state");if(i==="ansi")throw new Dt("ANSI language does not have grammar state");const{theme:l,colorMap:d}=t.setTheme(a),f=t.getLanguage(i);return new Jh(Vx(n,f,l,d,r).stateStack,f.name,l.name)}function zz(e,t,n,r,i){const a=Vx(e,t,n,r,i),l=new Jh(a.stateStack,t.name,n.name);return Qh(a.tokens,l),a.tokens}function Vx(e,t,n,r,i){const a=gh(n,i),{tokenizeMaxLineLength:l=0,tokenizeTimeLimit:d=500}=i,f=Xh(e);let h=i.grammarState?Oz(i.grammarState,n.name)??O_:i.grammarContextCode!=null?Vx(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack:O_,p=[];const g=[];for(let x=0,_=f.length;x<_;x++){const[v,S]=f[x];if(v===""){p=[],g.push([]);continue}if(l>0&&v.length>=l){p=[],g.push([{content:v,offset:S,color:"",fontStyle:0}]);continue}let w,k,j;i.includeExplanation&&(w=t.tokenizeLine(v,h,d),k=w.tokens,j=0);const T=t.tokenizeLine2(v,h,d),A=T.tokens.length/2;for(let P=0;P<A;P++){const M=T.tokens[2*P],q=P+1<A?T.tokens[2*P+2]:v.length;if(M===q)continue;const Z=T.tokens[2*P+1],J=Ps(r[Wo.getForeground(Z)],a),L=Wo.getFontStyle(Z),G={content:v.substring(M,q),offset:S+M,color:J,fontStyle:L};if(i.includeExplanation){const H=[];if(i.includeExplanation!=="scopeName")for(const U of n.settings){let D;switch(typeof U.scope){case"string":D=U.scope.split(Iz).map(N=>N.trim());break;case"object":D=U.scope;break;default:continue}H.push({settings:U,selectors:D.map(N=>N.split(Pz))})}G.explanation=[];let R=0;for(;M+R<q;){const U=k[j],D=v.substring(U.startIndex,U.endIndex);R+=D.length,G.explanation.push({content:D,scopes:i.includeExplanation==="scopeName"?$z(U.scopes):Hz(H,U.scopes)}),j+=1}}p.push(G)}g.push(p),p=[],h=T.ruleStack}return{tokens:g,stateStack:h}}function $z(e){return e.map(t=>({scopeName:t}))}function Hz(e,t){const n=[];for(let r=0,i=t.length;r<i;r++){const a=t[r];n[r]={scopeName:a,themeMatches:Uz(e,a,t.slice(0,r))}}return n}function $w(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Fz(e,t,n){if(!$w(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)$w(e[r],n[i])&&(r-=1),i-=1;return r===-1}function Uz(e,t,n){const r=[];for(const{selectors:i,settings:a}of e)for(const l of i)if(Fz(l,t,n)){r.push(a);break}return r}function rN(e,t,n,r=nN){const i=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),a=i.map(h=>{const p=r(e,t,{...n,theme:h.theme});return{tokens:p,state:Mc(p),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),l=Vz(...a.map(h=>h.tokens)),d=l[0].map((h,p)=>h.map((g,x)=>{const _={content:g.content,variants:{},offset:g.offset};return"includeExplanation"in n&&n.includeExplanation&&(_.explanation=g.explanation),l.forEach((v,S)=>{const{content:w,explanation:k,offset:j,...T}=v[p][x];_.variants[i[S].color]=T}),_})),f=a[0].state?new Jh(Object.fromEntries(a.map(h=>{var p;return[h.theme,(p=h.state)==null?void 0:p.getInternalStack(h.theme)]})),a[0].state.lang):void 0;return f&&Qh(d,f),d}function Vz(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const i=e.map(f=>f[r]),a=t.map(()=>[]);t.forEach((f,h)=>f.push(a[h]));const l=i.map(()=>0),d=i.map(f=>f[0]);for(;d.every(f=>f);){const f=Math.min(...d.map(h=>h.content.length));for(let h=0;h<n;h++){const p=d[h];p.content.length===f?(a[h].push(p),l[h]+=1,d[h]=i[h][l[h]]):(a[h].push({...p,content:p.content.slice(0,f)}),d[h]={...p,content:p.content.slice(f),offset:p.offset+f})}}}return t}const Wz=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],Gz=/["&'<>`]/g,qz=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Kz=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Yz=/[|\\{}()[\]^$+*?.]/g,Hw=new WeakMap;function Xz(e,t){if(e=e.replace(t.subset?Qz(t.subset):Gz,r),t.subset||t.escapeOnly)return e;return e.replace(qz,n).replace(Kz,r);function n(i,a,l){return t.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,l.charCodeAt(a+2),t)}function r(i,a,l){return t.format(i.charCodeAt(0),l.charCodeAt(a+1),t)}}function Qz(e){let t=Hw.get(e);return t||(t=Jz(e),Hw.set(e,t)),t}function Jz(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(Yz,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const Zz=/[\dA-Fa-f]/;function e$(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!Zz.test(String.fromCharCode(t))?r:r+";"}const t$=/\d/;function n$(e,t,n){const r="&#"+String(e);return n&&t&&!t$.test(String.fromCharCode(t))?r:r+";"}const r$=["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"],hg={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},i$=["cent","copy","divide","gt","lt","not","para","times"],iN={}.hasOwnProperty,I_={};let Dd;for(Dd in hg)iN.call(hg,Dd)&&(I_[hg[Dd]]=Dd);const s$=/[^\dA-Za-z]/;function a$(e,t,n,r){const i=String.fromCharCode(e);if(iN.call(I_,i)){const a=I_[i],l="&"+a;return n&&r$.includes(a)&&!i$.includes(a)&&(!r||t&&t!==61&&s$.test(String.fromCharCode(t)))?l:l+";"}return""}function o$(e,t,n){let r=e$(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=a$(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){const a=n$(e,t,n.omitOptionalSemicolons);a.length<r.length&&(r=a)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function Fo(e,t){return Xz(e,Object.assign({format:o$},t))}const l$=/^>|^->|<!--|-->|--!>|<!-$/g,c$=[">"],u$=["<",">"];function d$(e,t,n,r){return r.settings.bogusComments?"<?"+Fo(e.value,Object.assign({},r.settings.characterReferences,{subset:c$}))+">":"<!--"+e.value.replace(l$,i)+"-->";function i(a){return Fo(a,Object.assign({},r.settings.characterReferences,{subset:u$}))}}function h$(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}const xn=aN(1),sN=aN(-1),f$=[];function aN(e){return t;function t(n,r,i){const a=n?n.children:f$;let l=(r||0)+e,d=a[l];if(!i)for(;d&&zh(d);)l+=e,d=a[l];return d}}const m$={}.hasOwnProperty;function oN(e){return t;function t(n,r,i){return m$.call(e,n.tagName)&&e[n.tagName](n,r,i)}}const Wx=oN({body:g$,caption:fg,colgroup:fg,dd:v$,dt:y$,head:fg,html:p$,li:x$,optgroup:b$,option:S$,p:_$,rp:Fw,rt:Fw,tbody:C$,td:Uw,tfoot:k$,th:Uw,thead:w$,tr:E$});function fg(e,t,n){const r=xn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&zh(r.value.charAt(0)))}function p$(e,t,n){const r=xn(n,t);return!r||r.type!=="comment"}function g$(e,t,n){const r=xn(n,t);return!r||r.type!=="comment"}function _$(e,t,n){const r=xn(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function x$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function y$(e,t,n){const r=xn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function v$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Fw(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function b$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function S$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function w$(e,t,n){const r=xn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function C$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function k$(e,t,n){return!xn(n,t)}function E$(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function Uw(e,t,n){const r=xn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const N$=oN({body:A$,colgroup:D$,head:T$,html:j$,tbody:L$});function j$(e){const t=xn(e,-1);return!t||t.type!=="comment"}function T$(e){const t=new Set;for(const r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}const n=e.children[0];return!n||n.type==="element"}function A$(e){const t=xn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&zh(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function D$(e,t,n){const r=sN(n,t),i=xn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Wx(r,n.children.indexOf(r),n)?!1:!!(i&&i.type==="element"&&i.tagName==="col")}function L$(e,t,n){const r=sN(n,t),i=xn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Wx(r,n.children.indexOf(r),n)?!1:!!(i&&i.type==="element"&&i.tagName==="tr")}const Ld={name:[[`
143
+ \f\r &/=>`.split(""),`
144
+ \f\r "&'/=>\``.split("")],[`\0
145
+ \f\r "&'/<=>`.split(""),`\0
146
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
147
+ \f\r &>`.split(""),`\0
148
+ \f\r "&'<=>\``.split("")],[`\0
149
+ \f\r "&'<=>\``.split(""),`\0
150
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function R$(e,t,n,r){const i=r.schema,a=i.space==="svg"?!1:r.settings.omitOptionalTags;let l=i.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const d=[];let f;i.space==="html"&&e.tagName==="svg"&&(r.schema=Kc);const h=M$(r,e.properties),p=r.all(i.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=i,p&&(l=!1),(h||!a||!N$(e,t,n))&&(d.push("<",e.tagName,h?" "+h:""),l&&(i.space==="svg"||r.settings.closeSelfClosing)&&(f=h.charAt(h.length-1),(!r.settings.tightSelfClosing||f==="/"||f&&f!=='"'&&f!=="'")&&d.push(" "),d.push("/")),d.push(">")),d.push(p),!l&&(!a||!Wx(e,t,n))&&d.push("</"+e.tagName+">"),d.join("")}function M$(e,t){const n=[];let r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){const a=O$(e,i,t[i]);a&&n.push(a)}}for(;++r<n.length;){const a=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&a!=='"'&&a!=="'"&&(n[r]+=" ")}return n.join("")}function O$(e,t,n){const r=j2(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,a=e.settings.allowDangerousCharacters?0:1;let l=e.quote,d;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const f=Fo(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Ld.name[i][a]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?v2:A2)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?f:(e.settings.preferUnquoted&&(d=Fo(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Ld.unquoted[i][a]}))),d!==n&&(e.settings.quoteSmart&&ch(n,l)>ch(n,e.alternative)&&(l=e.alternative),d=l+Fo(n,Object.assign({},e.settings.characterReferences,{subset:(l==="'"?Ld.single:Ld.double)[i][a],attribute:!0}))+l),f+(d&&"="+d))}const I$=["<","&"];function lN(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Fo(e.value,Object.assign({},r.settings.characterReferences,{subset:I$}))}function P$(e,t,n,r){return r.settings.allowDangerousHtml?e.value:lN(e,t,n,r)}function B$(e,t,n,r){return r.all(e)}const z$=K6("type",{invalid:$$,unknown:H$,handlers:{comment:d$,doctype:h$,element:R$,raw:P$,root:B$,text:lN}});function $$(e){throw new Error("Expected node, not `"+e+"`")}function H$(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const F$={},U$={},V$=[];function W$(e,t){const n=t||F$,r=n.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:G$,all:q$,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Wz,characterReferences:n.characterReferences||U$,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Kc:T2,quote:r,alternative:i}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function G$(e,t,n){return z$(e,t,n,this)}function q$(e){const t=[],n=e&&e.children||V$;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const Vw=/\s+/g;function cN(e,t){var r;if(!t)return e;e.properties||(e.properties={}),(r=e.properties).class||(r.class=[]),typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Vw)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(Vw);for(const i of n)i&&!e.properties.class.includes(i)&&e.properties.class.push(i);return e}const K$=/:?lang=["']([^"']+)["']/g,Y$=/(?:```|~~~)([\w-]+)/g,X$=/\\begin\{([\w-]+)\}/g,Q$=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function J$(e){const t=Xh(e,!0).map(([i])=>i);function n(i){if(i===e.length)return{line:t.length-1,character:t.at(-1).length};let a=i,l=0;for(const d of t){if(a<d.length)break;a-=d.length,l++}return{line:l,character:a}}function r(i,a){let l=0;for(let d=0;d<i;d++)l+=t[d].length;return l+=a,l}return{lines:t,indexToPos:n,posToIndex:r}}function Z$(e,t,n){const r=new Set;for(const a of e.matchAll(K$)){const l=a[1].toLowerCase().trim();l&&r.add(l)}for(const a of e.matchAll(Y$)){const l=a[1].toLowerCase().trim();l&&r.add(l)}for(const a of e.matchAll(X$)){const l=a[1].toLowerCase().trim();l&&r.add(l)}for(const a of e.matchAll(Q$)){const l=a[1].toLowerCase().trim(),d=l.includes("/")?l.split("/").pop():l;d&&r.add(d)}if(!n)return[...r];const i=n.getBundledLanguages();return[...r].filter(a=>a&&i[a])}const e7=["color","background-color"];function t7(e,t){let n=0;const r=[];for(const i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function n7(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,i)=>r-i);return n.length?e.map(r=>r.flatMap(i=>{const a=n.filter(l=>i.offset<l&&l<i.offset+i.content.length).map(l=>l-i.offset).sort((l,d)=>l-d);return a.length?t7(i,a):i})):e}function r7(e,t,n,r,i="css-vars"){const a={content:e.content,explanation:e.explanation,offset:e.offset},l=t.map(p=>_h(e.variants[p])),d=new Set(l.flatMap(p=>Object.keys(p))),f={},h=(p,g)=>{const x=g==="color"?"":g==="background-color"?"-bg":`-${g}`;return n+t[p]+(g==="color"?"":x)};return l.forEach((p,g)=>{for(const x of d){const _=p[x]||"inherit";if(g===0&&r&&e7.includes(x))if(r==="light-dark()"&&l.length>1){const v=t.findIndex(w=>w==="light"),S=t.findIndex(w=>w==="dark");if(v===-1||S===-1)throw new Dt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');f[x]=`light-dark(${l[v][x]||"inherit"}, ${l[S][x]||"inherit"})`,i==="css-vars"&&(f[h(g,x)]=_)}else f[x]=_;else i==="css-vars"&&(f[h(g,x)]=_)}}),a.htmlStyle=f,a}function _h(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&zn.Italic&&(t["font-style"]="italic"),e.fontStyle&zn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&zn.Underline&&n.push("underline"),e.fontStyle&zn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function P_(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function i7(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let a=function(d){if(typeof d=="number"){if(d<0||d>n.source.length)throw new Dt(`Invalid decoration offset: ${d}. Code length: ${n.source.length}`);return{...i.indexToPos(d),offset:d}}else{const f=i.lines[d.line];if(f===void 0)throw new Dt(`Invalid decoration position ${JSON.stringify(d)}. Lines length: ${i.lines.length}`);let h=d.character;if(h<0&&(h=f.length+h),h<0||h>f.length)throw new Dt(`Invalid decoration position ${JSON.stringify(d)}. Line ${d.line} length: ${f.length}`);return{...d,character:h,offset:i.posToIndex(d.line,h)}}};var r=a;const i=J$(n.source),l=(n.options.decorations||[]).map(d=>({...d,start:a(d.start),end:a(d.end)}));s7(l),e.set(n.meta,{decorations:l,converter:i,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){var r;if((r=this.options.decorations)!=null&&r.length)return n7(n,t(this).decorations.flatMap(i=>[i.start.offset,i.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const r=t(this),i=[...n.children].filter(g=>g.type==="element"&&g.tagName==="span");if(i.length!==r.converter.lines.length)throw new Dt(`Number of lines in code element (${i.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function a(g,x,_,v){const S=i[g];let w="",k=-1,j=-1;if(x===0&&(k=0),_===0&&(j=0),_===Number.POSITIVE_INFINITY&&(j=S.children.length),k===-1||j===-1)for(let A=0;A<S.children.length;A++)w+=uN(S.children[A]),k===-1&&w.length===x&&(k=A+1),j===-1&&w.length===_&&(j=A+1);if(k===-1)throw new Dt(`Failed to find start index for decoration ${JSON.stringify(v.start)}`);if(j===-1)throw new Dt(`Failed to find end index for decoration ${JSON.stringify(v.end)}`);const T=S.children.slice(k,j);if(!v.alwaysWrap&&T.length===S.children.length)d(S,v,"line");else if(!v.alwaysWrap&&T.length===1&&T[0].type==="element")d(T[0],v,"token");else{const A={type:"element",tagName:"span",properties:{},children:T};d(A,v,"wrapper"),S.children.splice(k,T.length,A)}}function l(g,x){i[g]=d(i[g],x,"line")}function d(g,x,_){var w;const v=x.properties||{},S=x.transform||(k=>k);return g.tagName=x.tagName||"span",g.properties={...g.properties,...v,class:g.properties.class},(w=x.properties)!=null&&w.class&&cN(g,x.properties.class),g=S(g,_)||g,g}const f=[],h=r.decorations.sort((g,x)=>x.start.offset-g.start.offset||g.end.offset-x.end.offset);for(const g of h){const{start:x,end:_}=g;if(x.line===_.line)a(x.line,x.character,_.character,g);else if(x.line<_.line){a(x.line,x.character,Number.POSITIVE_INFINITY,g);for(let v=x.line+1;v<_.line;v++)f.unshift(()=>l(v,g));a(_.line,0,_.character,g)}}f.forEach(g=>g())}}}function s7(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new Dt(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const i=e[r],a=n.start.offset<=i.start.offset&&i.start.offset<n.end.offset,l=n.start.offset<i.end.offset&&i.end.offset<=n.end.offset,d=i.start.offset<=n.start.offset&&n.start.offset<i.end.offset,f=i.start.offset<n.end.offset&&n.end.offset<=i.end.offset;if(a||l||d||f){if(a&&l||d&&f||d&&n.start.offset===n.end.offset||l&&i.start.offset===i.end.offset)continue;throw new Dt(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(i.start)} intersect.`)}}}}function uN(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(uN).join(""):""}const a7=[i7()];function xh(e){const t=o7(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...a7]}function o7(e){const t=[],n=[],r=[];for(const i of e)switch(i.enforce){case"pre":t.push(i);break;case"post":n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var ba=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],mg={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function l7(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Ww(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function c7(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)mg[r]&&t.push({type:"setDecoration",value:mg[r]});else if(r<=29){const i=mg[r-20];i&&(t.push({type:"resetDecoration",value:i}),i==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:ba[r-30]}});else if(r===38){const i=Ww(e);i&&t.push({type:"setForegroundColor",value:i})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:ba[r-40]}});else if(r===48){const i=Ww(e);i&&t.push({type:"setBackgroundColor",value:i})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:ba[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:ba[r-100+8]}})}return t}function u7(){let e=null,t=null,n=new Set;return{parse(r){const i=[];let a=0;do{const l=l7(r,a),d=l.sequence?r.substring(a,l.startPosition):r.substring(a);if(d.length>0&&i.push({value:d,foreground:e,background:t,decorations:new Set(n)}),l.sequence){const f=c7(l.sequence);for(const h of f)h.type==="resetAll"?(e=null,t=null,n.clear()):h.type==="resetForegroundColor"?e=null:h.type==="resetBackgroundColor"?t=null:h.type==="resetDecoration"&&n.delete(h.value);for(const h of f)h.type==="setForegroundColor"?e=h.value:h.type==="setBackgroundColor"?t=h.value:h.type==="setDecoration"&&n.add(h.value)}a=l.position}while(a<r.length);return i}}}var d7={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function h7(e=d7){function t(d){return e[d]}function n(d){return`#${d.map(f=>Math.max(0,Math.min(f,255)).toString(16).padStart(2,"0")).join("")}`}let r;function i(){if(r)return r;r=[];for(let h=0;h<ba.length;h++)r.push(t(ba[h]));let d=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let p=0;p<6;p++)for(let g=0;g<6;g++)r.push(n([d[h],d[p],d[g]]));let f=8;for(let h=0;h<24;h++,f+=10)r.push(n([f,f,f]));return r}function a(d){return i()[d]}function l(d){switch(d.type){case"named":return t(d.name);case"rgb":return n(d.rgb);case"table":return a(d.index)}}return{value:l}}const f7=/#([0-9a-f]{3,8})/i,m7=/var\((--[\w-]+-ansi-[\w-]+)\)/,p7={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function g7(e,t,n){const r=gh(e,n),i=Xh(t),a=h7(Object.fromEntries(ba.map(d=>{var h;const f=`terminal.ansi${d[0].toUpperCase()}${d.substring(1)}`;return[d,((h=e.colors)==null?void 0:h[f])||p7[d]]}))),l=u7();return i.map(d=>l.parse(d[0]).map(f=>{let h,p;f.decorations.has("reverse")?(h=f.background?a.value(f.background):e.bg,p=f.foreground?a.value(f.foreground):e.fg):(h=f.foreground?a.value(f.foreground):e.fg,p=f.background?a.value(f.background):void 0),h=Ps(h,r),p=Ps(p,r),f.decorations.has("dim")&&(h=_7(h));let g=zn.None;return f.decorations.has("bold")&&(g|=zn.Bold),f.decorations.has("italic")&&(g|=zn.Italic),f.decorations.has("underline")&&(g|=zn.Underline),f.decorations.has("strikethrough")&&(g|=zn.Strikethrough),{content:f.value,offset:d[1],color:h,bgColor:p,fontStyle:g}}))}function _7(e){const t=e.match(f7);if(t){const r=t[1];if(r.length===8){const i=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${i}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const i=r[0],a=r[1],l=r[2],d=r[3];return`#${i}${i}${a}${a}${l}${l}${Math.round(Number.parseInt(`${d}${d}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const i=r[0],a=r[1],l=r[2];return`#${i}${i}${a}${a}${l}${l}80`}}}const n=e.match(m7);return n?`var(${n[1]}-dim)`:e}function B_(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:i=e.getLoadedThemes()[0]}=n;if(!Kh(r)&&!Yh(i)&&r==="ansi"){const{theme:a}=e.setTheme(i);return g7(a,t,n)}return nN(e,t,n)}function yh(e,t,n){let r,i,a,l,d,f;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:p="--shiki-",colorsRendering:g="css-vars"}=n,x=Object.entries(n.themes).filter(k=>k[1]).map(k=>({color:k[0],theme:k[1]})).sort((k,j)=>k.color===h?-1:j.color===h?1:0);if(x.length===0)throw new Dt("`themes` option must not be empty");const _=rN(e,t,n,B_);if(f=Mc(_),h&&h!=="light-dark()"&&!x.some(k=>k.color===h))throw new Dt(`\`themes\` option must contain the defaultColor key \`${h}\``);const v=x.map(k=>e.getTheme(k.theme)),S=x.map(k=>k.color);a=_.map(k=>k.map(j=>r7(j,S,p,h,g))),f&&Qh(a,f);const w=x.map(k=>gh(k.theme,n));i=Gw(x,v,w,p,h,"fg",g),r=Gw(x,v,w,p,h,"bg",g),l=`shiki-themes ${v.map(k=>k.name).join(" ")}`,d=h?void 0:[i,r].join(";")}else if("theme"in n){const h=gh(n.theme,n);a=B_(e,t,n);const p=e.getTheme(n.theme);r=Ps(p.bg,h),i=Ps(p.fg,h),l=p.name,f=Mc(a)}else throw new Dt("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:l,rootStyle:d,grammarState:f}}function Gw(e,t,n,r,i,a,l){return e.map((d,f)=>{const h=Ps(t[f][a],n[f])||"inherit",p=`${r+d.color}${a==="bg"?"-bg":""}:${h}`;if(f===0&&i){if(i==="light-dark()"&&e.length>1){const g=e.findIndex(_=>_.color==="light"),x=e.findIndex(_=>_.color==="dark");if(g===-1||x===-1)throw new Dt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Ps(t[g][a],n[g])||"inherit"}, ${Ps(t[x][a],n[x])||"inherit"});${p}`}return h}return l==="css-vars"?p:null}).filter(d=>!!d).join(";")}const dN=/^\s+$/,x7=/^(\s*)(.*?)(\s*)$/;function vh(e,t,n,r={meta:{},options:n,codeToHast:(i,a)=>vh(e,i,a),codeToTokens:(i,a)=>yh(e,i,a)}){var v,S;let i=t;for(const w of xh(n))i=((v=w.preprocess)==null?void 0:v.call(r,i,n))||i;let{tokens:a,fg:l,bg:d,themeName:f,rootStyle:h,grammarState:p}=yh(e,i,n);const{mergeWhitespaces:g=!0,mergeSameStyleTokens:x=!1}=n;g===!0?a=v7(a):g==="never"&&(a=b7(a)),x&&(a=S7(a));const _={...r,get source(){return i}};for(const w of xh(n))a=((S=w.tokens)==null?void 0:S.call(_,a))||a;return y7(a,{...n,fg:l,bg:d,themeName:f,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},_,p)}function y7(e,t,n,r=Mc(e)){var S,w,k,j;const i=xh(t),a=[],l={type:"root",children:[]},{structure:d="classic",tabindex:f="0"}=t,h={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?h.style=t.rootStyle:h.style=`background-color:${t.bg};color:${t.fg}`),f!==!1&&f!=null&&(h.tabindex=f.toString());for(const[T,A]of Object.entries(t.meta||{}))T.startsWith("_")||(h[T]=A);let p={type:"element",tagName:"pre",properties:h,children:[],data:t.data},g={type:"element",tagName:"code",properties:{},children:a};const x=[],_={...n,structure:d,addClassToHast:cN,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return l},get pre(){return p},get code(){return g},get lines(){return x}};if(e.forEach((T,A)=>{var q,Z;A&&(d==="inline"?l.children.push({type:"element",tagName:"br",properties:{},children:[]}):d==="classic"&&a.push({type:"text",value:`
151
+ `}));let P={type:"element",tagName:"span",properties:{class:"line"},children:[]},M=0;for(const J of T){let L={type:"element",tagName:"span",properties:{...J.htmlAttrs},children:[{type:"text",value:J.content}]};const G=P_(J.htmlStyle||_h(J));G&&(L.properties.style=G);for(const H of i)L=((q=H==null?void 0:H.span)==null?void 0:q.call(_,L,A+1,M,P,J))||L;d==="inline"?l.children.push(L):d==="classic"&&P.children.push(L),M+=J.content.length}if(d==="classic"){for(const J of i)P=((Z=J==null?void 0:J.line)==null?void 0:Z.call(_,P,A+1))||P;x.push(P),a.push(P)}else d==="inline"&&x.push(P)}),d==="classic"){for(const T of i)g=((S=T==null?void 0:T.code)==null?void 0:S.call(_,g))||g;p.children.push(g);for(const T of i)p=((w=T==null?void 0:T.pre)==null?void 0:w.call(_,p))||p;l.children.push(p)}else if(d==="inline"){const T=[];let A={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const M of l.children)M.type==="element"&&M.tagName==="br"?(T.push(A),A={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(M.type==="element"||M.type==="text")&&A.children.push(M);T.push(A);let P={type:"element",tagName:"code",properties:{},children:T};for(const M of i)P=((k=M==null?void 0:M.code)==null?void 0:k.call(_,P))||P;l.children=[];for(let M=0;M<P.children.length;M++){M>0&&l.children.push({type:"element",tagName:"br",properties:{},children:[]});const q=P.children[M];q.type==="element"&&l.children.push(...q.children)}}let v=l;for(const T of i)v=((j=T==null?void 0:T.root)==null?void 0:j.call(_,v))||v;return r&&Qh(v,r),v}function v7(e){return e.map(t=>{const n=[];let r="",i;return t.forEach((a,l)=>{const d=!(a.fontStyle&&(a.fontStyle&zn.Underline||a.fontStyle&zn.Strikethrough));d&&dN.test(a.content)&&t[l+1]?(i===void 0&&(i=a.offset),r+=a.content):r?(d?n.push({...a,offset:i,content:r+a.content}):n.push({content:r,offset:i},a),i=void 0,r=""):n.push(a)}),n})}function b7(e){return e.map(t=>t.flatMap(n=>{if(dN.test(n.content))return n;const r=n.content.match(x7);if(!r)return n;const[,i,a,l]=r;if(!i&&!l)return n;const d=[{...n,offset:n.offset+i.length,content:a}];return i&&d.unshift({content:i,offset:n.offset}),l&&d.push({content:l,offset:n.offset+i.length+a.length}),d}))}function S7(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const i=n.at(-1),a=P_(i.htmlStyle||_h(i)),l=P_(r.htmlStyle||_h(r)),d=i.fontStyle&&(i.fontStyle&zn.Underline||i.fontStyle&zn.Strikethrough),f=r.fontStyle&&(r.fontStyle&zn.Underline||r.fontStyle&zn.Strikethrough);!d&&!f&&a===l?i.content+=r.content:n.push({...r})}return n})}const w7=W$;function C7(e,t,n){var a;const r={meta:{},options:n,codeToHast:(l,d)=>vh(e,l,d),codeToTokens:(l,d)=>yh(e,l,d)};let i=w7(vh(e,t,n,r));for(const l of xh(n))i=((a=l.postprocess)==null?void 0:a.call(r,i,n))||i;return i}async function k7(e){const t=await Rz(e);return{getLastGrammarState:(...n)=>Bz(t,...n),codeToTokensBase:(n,r)=>B_(t,n,r),codeToTokensWithThemes:(n,r)=>rN(t,n,r),codeToTokens:(n,r)=>yh(t,n,r),codeToHast:(n,r)=>vh(t,n,r),codeToHtml:(n,r)=>C7(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function E7(e){const t=e.langs,n=e.themes,r=e.engine;async function i(a){function l(g){var x;if(typeof g=="string"){if(g=((x=a.langAlias)==null?void 0:x[g])||g,YE(g))return[];const _=t[g];if(!_)throw new Dt(`Language \`${g}\` is not included in this bundle. You may want to load it from external source.`);return _}return g}function d(g){if(XE(g))return"none";if(typeof g=="string"){const x=n[g];if(!x)throw new Dt(`Theme \`${g}\` is not included in this bundle. You may want to load it from external source.`);return x}return g}const f=(a.themes??[]).map(g=>d(g)),h=(a.langs??[]).map(g=>l(g)),p=await k7({engine:a.engine??r(),...a,themes:f,langs:h});return{...p,loadLanguage(...g){return p.loadLanguage(...g.map(l))},loadTheme(...g){return p.loadTheme(...g.map(d))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return i}function N7(e){let t;async function n(r={}){if(t){const i=await t;return await Promise.all([i.loadTheme(...r.themes||[]),i.loadLanguage(...r.langs||[])]),i}else{t=e({...r,themes:[],langs:[]});const i=await t;return await Promise.all([i.loadTheme(...r.themes||[]),i.loadLanguage(...r.langs||[])]),i}}return n}function j7(e,t){const n=N7(e);async function r(i,a){var f;const l=await n({langs:[a.lang],themes:"theme"in a?[a.theme]:Object.values(a.themes)}),d=await((f=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:f.call(t,i,a.lang,l));return d&&await l.loadLanguage(...d),l}return{getSingletonHighlighter(i){return n(i)},async codeToHtml(i,a){return(await r(i,a)).codeToHtml(i,a)},async codeToHast(i,a){return(await r(i,a)).codeToHast(i,a)},async codeToTokens(i,a){return(await r(i,a)).codeToTokens(i,a)},async codeToTokensBase(i,a){return(await r(i,a)).codeToTokensBase(i,a)},async codeToTokensWithThemes(i,a){return(await r(i,a)).codeToTokensWithThemes(i,a)},async getLastGrammarState(i,a){return(await n({langs:[a.lang],themes:[a.theme]})).getLastGrammarState(i,a)}}}var T7=Mx({bundledLanguages:()=>Px,bundledLanguagesAlias:()=>Ix,bundledLanguagesBase:()=>Ox,bundledLanguagesInfo:()=>Wh,bundledThemes:()=>zx,bundledThemesInfo:()=>Bx,codeToHast:()=>fN,codeToHtml:()=>hN,codeToTokens:()=>mN,codeToTokensBase:()=>pN,codeToTokensWithThemes:()=>gN,createHighlighter:()=>Zh,getLastGrammarState:()=>xN,getSingletonHighlighter:()=>_N});const Zh=E7({langs:Px,themes:zx,engine:()=>(0,LE.createOnigurumaEngine)(z(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:hN,codeToHast:fN,codeToTokens:mN,codeToTokensBase:pN,codeToTokensWithThemes:gN,getSingletonHighlighter:_N,getLastGrammarState:xN}=j7(Zh,{guessEmbeddedLanguages:Z$}),qw=4294967295;var A7=class{constructor(e,t={}){ce(this,"patterns");ce(this,"options");ce(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(a=>{if(typeof a!="string")return a;const l=r==null?void 0:r.get(a);if(l){if(l instanceof RegExp)return l;if(n)return null;throw l}try{const d=i(a);return r==null||r.set(a,d),d}catch(d){if(r==null||r.set(a,d),n)return null;throw d}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,i=[];function a(l,d,f=0){return{index:l,captureIndices:d.indices.map(h=>h==null?{start:qw,end:qw,length:0}:{start:h[0]+f,end:h[1]+f,length:h[1]-h[0]})}}for(let l=0;l<this.regexps.length;l++){const d=this.regexps[l];if(d)try{d.lastIndex=t;const f=d.exec(r);if(!f)continue;if(f.index===t)return a(l,f,0);i.push([l,f,0])}catch(f){if(this.options.forgiving)continue;throw f}}if(i.length){const l=Math.min(...i.map(d=>d[1].index));for(const[d,f,h]of i)if(f.index===l)return a(d,f,h)}return null}};function Jo(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function D7(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const Gx=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),En=String.raw;function Zo(e,t){if(e==null)throw new Error(t??"Value expected");return e}const yN=En`\[\^?`,vN=`c.? | C(?:-.?)?|${En`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${En`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${En`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${En`o\{[^\}]*\}?`}|${En`\d{1,3}`}`,qx=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Rd=new RegExp(En`
152
+ \\ (?:
153
+ ${vN}
154
+ | [gk]<[^>]*>?
155
+ | [gk]'[^']*'?
156
+ | .
157
+ )
158
+ | \( (?:
159
+ \? (?:
160
+ [:=!>({]
161
+ | <[=!]
162
+ | <[^>]*>
163
+ | '[^']*'
164
+ | ~\|?
165
+ | #(?:[^)\\]|\\.?)*
166
+ | [^:)]*[:)]
167
+ )?
168
+ | \*[^\)]*\)?
169
+ )?
170
+ | (?:${qx.source})+
171
+ | ${yN}
172
+ | .
173
+ `.replace(/\s+/g,""),"gsu"),pg=new RegExp(En`
174
+ \\ (?:
175
+ ${vN}
176
+ | .
177
+ )
178
+ | \[:(?:\^?\p{Alpha}+|\^):\]
179
+ | ${yN}
180
+ | &&
181
+ | .
182
+ `.replace(/\s+/g,""),"gsu");function L7(e,t={}){const n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const r=Q7(n.flags),i=[r.extended],a={captureGroup:n.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(g){i.push(g)},replaceCurrentModX(g){i[i.length-1]=g},singleline:n.rules.singleline};let l=[],d;for(Rd.lastIndex=0;d=Rd.exec(e);){const g=R7(a,e,d[0],Rd.lastIndex);g.tokens?l.push(...g.tokens):g.token&&l.push(g.token),g.lastIndex!==void 0&&(Rd.lastIndex=g.lastIndex)}const f=[];let h=0;l.filter(g=>g.type==="GroupOpen").forEach(g=>{g.kind==="capturing"?g.number=++h:g.raw==="("&&f.push(g)}),h||f.forEach((g,x)=>{g.kind="capturing",g.number=x+1});const p=h||f.length;return{tokens:l.map(g=>g.type==="EscapedNumber"?Z7(g,p):g).flat(),flags:r}}function R7(e,t,n,r){const[i,a]=n;if(n==="["||n==="[^"){const l=M7(t,n,r);return{tokens:l.tokens,lastIndex:l.lastIndex}}if(i==="\\"){if("AbBGyYzZ".includes(a))return{token:Kw(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:V7(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:SN(n)}}if(a==="K")return{token:wN("keep",n)};if(a==="N"||a==="R")return{token:Sa("newline",n,{negate:a==="N"})};if(a==="O")return{token:Sa("any",n)};if(a==="X")return{token:Sa("text_segment",n)};const l=bN(n,{inCharClass:!1});return Array.isArray(l)?{tokens:l}:{token:l}}if(i==="("){if(a==="*")return{token:K7(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:q7(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Po("group",n)};if(n==="(?>")return{token:Po("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Po(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Po("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Po("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:H7(n)}}if(e.getCurrentModX()){if(n==="#"){const l=t.indexOf(`
183
+ `,r);return{lastIndex:l===-1?t.length:l}}if(/^\s$/.test(n)){const l=/\s+/y;return l.lastIndex=r,{lastIndex:l.exec(t)?l.lastIndex:r}}}if(n===".")return{token:Sa("dot",n)};if(n==="^"||n==="$"){const l=e.singleline?{"^":En`\A`,$:En`\Z`}[n]:n;return{token:Kw(l,n)}}return n==="|"?{token:I7(n)}:qx.test(n)?{tokens:e9(n)}:{token:qi(Jo(n),n)}}function M7(e,t,n){const r=[Yw(t[1]==="^",t)];let i=1,a;for(pg.lastIndex=n;a=pg.exec(e);){const l=a[0];if(l[0]==="["&&l[1]!==":")i++,r.push(Yw(l[1]==="^",l));else if(l==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(qi(93,l));else if(i--,r.push(P7(l)),!i)break}else{const d=O7(l);Array.isArray(d)?r.push(...d):r.push(d)}}return{tokens:r,lastIndex:pg.lastIndex||e.length}}function O7(e){if(e[0]==="\\")return bN(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Gx.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Sa("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?B7(e):e==="&&"?z7(e):qi(Jo(e),e)}function bN(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return G7(e);if("dDhHsSwW".includes(n))return Y7(e);if(e.startsWith(En`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return X7(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(l=>parseInt(l,16)),i=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),a=new TextEncoder;return[...i].map(l=>{const d=[...a.encode(l)].map(f=>`\\x${f.toString(16)}`).join("");return qi(Jo(l),d)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return qi(J7(e),e);if(Xw.has(n))return qi(Xw.get(n),e);if(/\d/.test(n))return $7(t,e);if(e==="\\")throw new Error(En`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return qi(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function I7(e){return{type:"Alternator",raw:e}}function Kw(e,t){return{type:"Assertion",kind:e,raw:t}}function SN(e){return{type:"Backreference",raw:e}}function qi(e,t){return{type:"Character",value:e,raw:t}}function P7(e){return{type:"CharacterClassClose",raw:e}}function B7(e){return{type:"CharacterClassHyphen",raw:e}}function z7(e){return{type:"CharacterClassIntersector",raw:e}}function Yw(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Sa(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function wN(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Zo(n.flags),raw:t}}function $7(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function H7(e){return{type:"GroupClose",raw:e}}function Po(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function F7(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function U7(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function V7(e){return{type:"Subroutine",raw:e}}const W7=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Xw=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function G7(e){const t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return qi(Jo(t.toUpperCase())-64,e)}function q7(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const i=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),a=Jw(n),l=Jw(r),d={};if(a&&(d.enable=a),l&&(d.disable=l),e.endsWith(")"))return t.replaceCurrentModX(i),wN("flags",e,{flags:d});if(e.endsWith(":"))return t.pushModX(i),t.numOpenGroups++,Po("group",e,{...(a||l)&&{flags:d}});throw new Error(`Unexpected flag modifier "${e}"`)}function K7(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:i}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const a=i?i.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[l,d,f]=a,h=W7.has(n)?n.toLowerCase():"custom";switch(h){case"fail":case"mismatch":case"skip":if(a.length>0)throw new Error(`Named callout arguments not allowed "${a}"`);break;case"error":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(typeof l=="string")throw new Error(`Named callout argument must be a number "${l}"`);break;case"max":if(!a.length||a.length>2)throw new Error(`Named callout must have one or two arguments "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument one must be a tag or number "${l}"`);if(a.length===2&&(typeof d=="number"||!/^[<>X]$/.test(d)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${d}"`);break;case"count":case"total_count":if(a.length>1)throw new Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof l=="number"||!/^[<>X]$/.test(l)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${l}"`);break;case"cmp":if(a.length!==3)throw new Error(`Named callout must have three arguments "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument one must be a tag or number "${l}"`);if(typeof d=="number"||!/^(?:[<>!=]=|[<>])$/.test(d))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${d}"`);if(typeof f=="string"&&!/^[A-Za-z_]\w*$/.test(f))throw new Error(`Named callout argument three must be a tag or number "${f}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${h}"`)}return F7(h,r??null,(i==null?void 0:i.split(","))??null,e)}function Qw(e){let t=null,n,r;if(e[0]==="{"){const{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,l=1e5;if(+i>l||a&&+a>l)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+i,r=a===void 0?+i:a===""?1/0:+a,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return U7(t,n,r,e)}function Y7(e){const t=e[1].toLowerCase();return Sa({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function X7(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Sa("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function Jw(e){const t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Q7(e){const t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){const r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function J7(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Z7(e,t){const{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!=="0"&&i.length===1||i[0]!=="0"&&+i<=t))return[SN(n)];const a=[],l=i.match(/^[0-7]+|\d/g);for(let d=0;d<l.length;d++){const f=l[d];let h;if(d===0&&f!=="8"&&f!=="9"){if(h=parseInt(f,8),h>127)throw new Error(En`Octal encoded byte above 177 unsupported "${n}"`)}else h=Jo(f);a.push(qi(h,(d===0?"\\":"")+f))}return a}function e9(e){const t=[],n=new RegExp(qx,"gy");let r;for(;r=n.exec(e);){const i=r[0];if(i[0]==="{"){const a=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(i);if(a){const{min:l,max:d}=a.groups;if(+l>+d&&i.endsWith("?")){n.lastIndex--,t.push(Qw(i.slice(0,-1)));continue}}}t.push(Qw(i))}return t}function CN(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;const n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function t9(e){return n9.has(e.type)}const n9=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function kN(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=L7(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(x,_)=>{const v=r.tokens[a.nextIndex];switch(a.parent=x,a.nextIndex++,v.type){case"Alternator":return Da();case"Assertion":return r9(v);case"Backreference":return i9(v,a);case"Character":return ef(v.value,{useLastValid:!!_.isCheckingRangeEnd});case"CharacterClassHyphen":return s9(v,a,_);case"CharacterClassOpen":return a9(v,a,_);case"CharacterSet":return o9(v,a);case"Directive":return f9(v.kind,{flags:v.flags});case"GroupOpen":return l9(v,a,_);case"NamedCallout":return p9(v.kind,v.tag,v.arguments);case"Quantifier":return c9(v,a);case"Subroutine":return u9(v,a);default:throw new Error(`Unexpected token type "${v.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},l=_9(m9(r.flags));let d=l.body[0];for(;a.nextIndex<r.tokens.length;){const x=i(d,{});x.type==="Alternative"?(l.body.push(x),d=x):d.body.push(x)}const{capturingGroups:f,hasNumberedRef:h,namedGroupsByName:p,subroutines:g}=a;if(h&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:x}of g)if(typeof x=="number"){if(x>f.length)throw new Error("Subroutine uses a group number that's not defined");x&&(f[x-1].isSubroutined=!0)}else if(p.has(x)){if(p.get(x).length>1)throw new Error(En`Subroutine uses a duplicate group name "\g<${x}>"`);p.get(x)[0].isSubroutined=!0}else throw new Error(En`Subroutine uses a group name that's not defined "\g<${x}>"`);return l}function r9({kind:e}){return z_(Zo({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===En`\B`||e===En`\Y`})}function i9({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(a,l=!1)=>{const d=t.capturingGroups.length;let f=!1;if(a>d)if(t.skipBackrefValidation)f=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,$_(l?d+1-a:a,{orphan:f})};if(n){const a=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(a)return i(+a.groups.num,!!a.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return $_(r)}return i(+r)}function s9(e,t,n){const{tokens:r,walk:i}=t,a=t.parent,l=a.body.at(-1),d=r[t.nextIndex];if(!n.isCheckingRangeEnd&&l&&l.type!=="CharacterClass"&&l.type!=="CharacterClassRange"&&d&&d.type!=="CharacterClassOpen"&&d.type!=="CharacterClassClose"&&d.type!=="CharacterClassIntersector"){const f=i(a,{...n,isCheckingRangeEnd:!0});if(l.type==="Character"&&f.type==="Character")return a.body.pop(),h9(l,f);throw new Error("Invalid character class range")}return ef(Jo("-"))}function a9({negate:e},t,n){const{tokens:r,walk:i}=t,a=[Kd()],l=r[t.nextIndex];let d=tC(l);for(;d.type!=="CharacterClassClose";){if(d.type==="CharacterClassIntersector")a.push(Kd()),t.nextIndex++;else{const h=a.at(-1);h.body.push(i(h,n))}d=tC(r[t.nextIndex],l)}const f=Kd({negate:e});return a.length===1?f.body=a[0].body:(f.kind="intersection",f.body=a.map(h=>h.body.length===1?h.body[0]:h)),t.nextIndex++,f}function o9({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:l}=r;if(e==="property"){const d=tf(n);if(Gx.has(d)&&!(l!=null&&l.has(d)))e="posix",n=d;else return Bo(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:l})}return e==="posix"?g9(n,{negate:t}):H_(e,{negate:t})}function l9(e,t,n){const{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:l,walk:d}=t,f=x9(e),h=f.type==="AbsenceFunction",p=eC(f),g=p&&f.negate;if(f.type==="CapturingGroup"&&(i.push(f),f.name&&D7(a,f.name,[]).push(f)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let x=nC(r[t.nextIndex]);for(;x.type!=="GroupClose";){if(x.type==="Alternator")f.body.push(Da()),t.nextIndex++;else{const _=f.body.at(-1),v=d(_,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||g});if(_.body.push(v),(p||n.isInLookbehind)&&!l){const S="Lookbehind includes a pattern not allowed by Oniguruma";if(g||n.isInNegLookbehind){if(Zw(v)||v.type==="CapturingGroup")throw new Error(S)}else if(Zw(v)||eC(v)&&v.negate)throw new Error(S)}}x=nC(r[t.nextIndex])}return t.nextIndex++,f}function c9({kind:e,min:t,max:n},r){const i=r.parent,a=i.body.at(-1);if(!a||!t9(a))throw new Error("Quantifier requires a repeatable token");const l=NN(e,t,n,a);return i.body.pop(),l}function u9({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let i=e.slice(3,-1);const a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){const d=+a.groups.num,f=n.length;if(t.hasNumberedRef=!0,i={"":d,"+":f+d,"-":f+1-d}[a.groups.sign],i<1)throw new Error("Invalid subroutine number")}else i==="0"&&(i=0);const l=jN(i);return r.push(l),l}function d9(e,t){return{type:"AbsenceFunction",kind:e,body:Jc(t==null?void 0:t.body)}}function Da(e){return{type:"Alternative",body:TN(e==null?void 0:e.body)}}function z_(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function $_(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function EN(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!y9(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Jc(t==null?void 0:t.body)}}function ef(e,t){const n={useLastValid:!1,...t};if(e>1114111){const r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function Kd(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:TN(e==null?void 0:e.body)}}function h9(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function H_(e,t){const n=!!(t!=null&&t.negate),r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function f9(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Zo(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function m9(e){return{type:"Flags",...e}}function Kr(e){const t=e==null?void 0:e.atomic,n=e==null?void 0:e.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:Jc(e==null?void 0:e.body)}}function xa(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Jc(e==null?void 0:e.body)}}function p9(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function g9(e,t){const n=!!(t!=null&&t.negate);if(!Gx.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function NN(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function _9(e,t){return{type:"Regex",body:Jc(t==null?void 0:t.body),flags:e}}function jN(e){return{type:"Subroutine",ref:e}}function Bo(e,t){var i;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(i=n.unicodePropertyMap)==null?void 0:i.get(tf(e));if(!r){if(n.normalizeUnknownPropertyNames)r=v9(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(En`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function x9({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case"absence_repeater":return d9("repeater");case"atomic":return Kr({atomic:!0});case"capturing":return EN(i,{name:n});case"group":return Kr({flags:e});case"lookahead":case"lookbehind":return xa({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function Jc(e){if(e===void 0)e=[Da()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function TN(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function Zw(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function eC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function y9(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function v9(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function tf(e){return e.replace(/[- _]+/g,"").toLowerCase()}function tC(e,t){const n=t;return Zo(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function nC(e){return Zo(e,"Unclosed group")}function Cc(e,t,n=null){function r(a,l){for(let d=0;d<a.length;d++){const f=i(a[d],l,d,a);d=Math.max(-1,d+f)}}function i(a,l=null,d=null,f=null){var k,j;let h=0,p=!1;const g={node:a,parent:l,key:d,container:f,root:e,remove(){Md(f).splice(Math.max(0,Ao(d)+h),1),h--,p=!0},removeAllNextSiblings(){return Md(f).splice(Ao(d)+1)},removeAllPrevSiblings(){const T=Ao(d)+h;return h-=T,Md(f).splice(0,Math.max(0,T))},replaceWith(T,A={}){const P=!!A.traverse;f?f[Math.max(0,Ao(d)+h)]=T:Zo(l,"Can't replace root node")[d]=T,P&&i(T,l,d,f),p=!0},replaceWithMultiple(T,A={}){const P=!!A.traverse;if(Md(f).splice(Math.max(0,Ao(d)+h),1,...T),h+=T.length-1,P){let M=0;for(let q=0;q<T.length;q++)M+=i(T[q],l,Ao(d)+q+M,f)}p=!0},skip(){p=!0}},{type:x}=a,_=t["*"],v=t[x],S=typeof _=="function"?_:_==null?void 0:_.enter,w=typeof v=="function"?v:v==null?void 0:v.enter;if(S==null||S(g,n),w==null||w(g,n),!p)switch(x){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(a.body,a);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":i(a.min,a,"min"),i(a.max,a,"max");break;case"Quantifier":i(a.body,a,"body");break;case"Regex":r(a.body,a),i(a.flags,a,"flags");break;default:throw new Error(`Unexpected node type "${x}"`)}return(k=v==null?void 0:v.exit)==null||k.call(v,g,n),(j=_==null?void 0:_.exit)==null||j.call(_,g,n),h}return i(e),e}function Md(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Ao(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const b9=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function S9(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function w9(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const Ir=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Kx(e,t,n,r){const i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1];let l=0,d="";for(const f of e.matchAll(i)){const{0:h,groups:{$skip:p}}=f;if(!p&&(!r||r===Ir.DEFAULT==!l)){n instanceof Function?d+=n(f,{context:l?Ir.CHAR_CLASS:Ir.DEFAULT,negated:a[a.length-1]}):d+=n;continue}h[0]==="["?(l++,a.push(h[1]==="^")):h==="]"&&l&&(l--,a.pop()),d+=h}return d}function AN(e,t,n,r){Kx(e,t,n,r)}function C9(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const i=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");i.lastIndex=n;let a=0,l;for(;l=i.exec(e);){const{0:d,groups:{$skip:f}}=l;if(!f&&(!r||r===Ir.DEFAULT==!a))return l;d==="["?a++:d==="]"&&a&&a--,i.lastIndex==l.index&&i.lastIndex++}return null}function Od(e,t,n){return!!C9(e,t,0,n)}function k9(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,l;for(;l=n.exec(e);){const[d]=l;if(d==="[")i++;else if(i)d==="]"&&i--;else if(d==="(")a++;else if(d===")"&&(a--,!a)){r=l.index;break}}return e.slice(t,r)}const rC=new RegExp(String.raw`(?<noncapturingStart>${b9})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function E9(e,t){const n=(t==null?void 0:t.hiddenCaptures)??[];let r=(t==null?void 0:t.captureTransfers)??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const i="(?>",a="(?:(?=(",l=[0],d=[];let f=0,h=0,p=NaN,g;do{g=!1;let x=0,_=0,v=!1,S;for(rC.lastIndex=Number.isNaN(p)?0:p+a.length;S=rC.exec(e);){const{0:w,index:k,groups:{capturingStart:j,noncapturingStart:T}}=S;if(w==="[")x++;else if(x)w==="]"&&x--;else if(w===i&&!v)p=k,v=!0;else if(v&&T)_++;else if(j)v?_++:(f++,l.push(f+h));else if(w===")"&&v){if(!_){h++;const A=f+h;if(e=`${e.slice(0,p)}${a}${e.slice(p+i.length,k)}))<$$${A}>)${e.slice(k+1)}`,g=!0,d.push(A),S9(n,A),r.size){const P=new Map;r.forEach((M,q)=>{P.set(q>=A?q+1:q,M.map(Z=>Z>=A?Z+1:Z))}),r=P}break}_--}}}while(g);return n.push(...d),e=Kx(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:x,groups:{backrefNum:_,wrappedBackrefNum:v}})=>{if(_){const S=+_;if(S>l.length-1)throw new Error(`Backref "${x}" greater than number of captures`);return`\\${l[S]}`}return`\\${v}`},Ir.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const DN=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,gg=new RegExp(String.raw`
184
+ \\(?: \d+
185
+ | c[A-Za-z]
186
+ | [gk]<[^>]+>
187
+ | [pPu]\{[^\}]+\}
188
+ | u[A-Fa-f\d]{4}
189
+ | x[A-Fa-f\d]{2}
190
+ )
191
+ | \((?: \? (?: [:=!>]
192
+ | <(?:[=!]|[^>]+>)
193
+ | [A-Za-z\-]+:
194
+ | \(DEFINE\)
195
+ ))?
196
+ | (?<qBase>${DN})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
197
+ | \\?.
198
+ `.replace(/\s+/g,""),"gsu");function N9(e){if(!new RegExp(`${DN}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,i="",a=0,l;for(gg.lastIndex=0;l=gg.exec(e);){const{0:d,index:f,groups:{qBase:h,qMod:p,invalidQ:g}}=l;if(d==="[")a||(r=f),a++;else if(d==="]")a?a--:r=null;else if(!a)if(p==="+"&&i&&!i.startsWith("(")){if(g)throw new Error(`Invalid quantifier "${d}"`);let x=-1;if(/^\{\d+\}$/.test(h))e=w9(e,f+h.length,p,"");else{if(i===")"||i==="]"){const _=i===")"?n:r;if(_===null)throw new Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,_)}(?>${e.slice(_,f)}${h})${e.slice(f+d.length)}`}else e=`${e.slice(0,f-i.length)}(?>${i}${h})${e.slice(f+d.length)}`;x+=4}gg.lastIndex+=x}else d[0]==="("?t.push(f):d===")"&&(n=t.length?t.pop():null);i=d}return{pattern:e}}const Or=String.raw,j9=Or`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,F_=Or`\(\?R=(?<rDepth>[^\)]+)\)|${j9}`,nf=Or`\(\?<(?![=!])(?<captureName>[^>]+)>`,LN=Or`${nf}|(?<unnamed>\()(?!\?)`,ca=new RegExp(Or`${nf}|${F_}|\(\?|\\?.`,"gsu"),_g="Cannot use multiple overlapping recursions";function T9(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let i=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(F_,"su").test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};if(r==="plugin"&&Od(e,Or`\(\?\(DEFINE\)`,Ir.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const a=[],l=Od(e,Or`\\[1-9]`,Ir.DEFAULT),d=new Map,f=[];let h=!1,p=0,g=0,x;for(ca.lastIndex=0;x=ca.exec(e);){const{0:_,groups:{captureName:v,rDepth:S,gRNameOrNum:w,gRDepth:k}}=x;if(_==="[")p++;else if(p)_==="]"&&p--;else if(S){if(iC(S),h)throw new Error(_g);if(l)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const j=e.slice(0,x.index),T=e.slice(ca.lastIndex);if(Od(T,F_,Ir.DEFAULT))throw new Error(_g);const A=+S-1;e=sC(j,T,A,!1,n,a,g),i=oC(i,j,A,a.length,0,g);break}else if(w){iC(k);let j=!1;for(const H of f)if(H.name===w||H.num===+w){if(j=!0,H.hasRecursedWithin)throw new Error(_g);break}if(!j)throw new Error(Or`Recursive \g cannot be used outside the referenced group "${r==="external"?w:Or`\g<${w}&R=${k}>`}"`);const T=d.get(w),A=k9(e,T);if(l&&Od(A,Or`${nf}|\((?!\?)`,Ir.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const P=e.slice(T,x.index),M=A.slice(P.length+_.length),q=a.length,Z=+k-1,J=sC(P,M,Z,!0,n,a,g);i=oC(i,P,Z,a.length-q,q,g);const L=e.slice(0,T),G=e.slice(T+A.length);e=`${L}${J}${G}`,ca.lastIndex+=J.length-_.length-P.length-M.length,f.forEach(H=>H.hasRecursedWithin=!0),h=!0}else if(v)g++,d.set(String(g),ca.lastIndex),d.set(v,ca.lastIndex),f.push({num:g,name:v});else if(_[0]==="("){const j=_==="(";j&&(g++,d.set(String(g),ca.lastIndex)),f.push(j?{num:g}:{})}else _===")"&&f.pop()}return n.push(...a),{pattern:e,captureTransfers:i,hiddenCaptures:n}}function iC(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function sC(e,t,n,r,i,a,l){const d=new Set;r&&AN(e+t,nf,({groups:{captureName:h}})=>{d.add(h)},Ir.DEFAULT);const f=[n,r?d:null,i,a,l];return`${e}${aC(`(?:${e}`,"forward",...f)}(?:)${aC(`${t})`,"backward",...f)}${t}`}function aC(e,t,n,r,i,a,l){const f=p=>t==="forward"?p+2:n-p+2-1;let h="";for(let p=0;p<n;p++){const g=f(p);h+=Kx(e,Or`${LN}|\\k<(?<backref>[^>]+)>`,({0:x,groups:{captureName:_,unnamed:v,backref:S}})=>{if(S&&r&&!r.has(S))return x;const w=`_$${g}`;if(v||_){const k=l+a.length+1;return a.push(k),A9(i,k),v?x:`(?<${_}${w}>`}return Or`\k<${S}${w}>`},Ir.DEFAULT)}return h}function A9(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function oC(e,t,n,r,i,a){if(e.size&&r){let l=0;AN(t,LN,()=>l++,Ir.DEFAULT);const d=a-l+i,f=new Map;return e.forEach((h,p)=>{const g=(r-l*n)/n,x=l*n,_=p>d+l?p+r:p,v=[];for(const S of h)if(S<=d)v.push(S);else if(S>d+l+g)v.push(S+r);else if(S<=d+l)for(let w=0;w<=n;w++)v.push(S+l*w);else for(let w=0;w<=n;w++)v.push(S+x+g*w);f.set(_,v)}),f}return e}var gn=String.fromCodePoint,Ge=String.raw,Xr={},rf=globalThis.RegExp;Xr.flagGroups=(()=>{try{new rf("(?i:)")}catch{return!1}return!0})();Xr.unicodeSets=(()=>{try{new rf("[[]]","v")}catch{return!1}return!0})();Xr.bugFlagVLiteralHyphenIsRange=Xr.unicodeSets?(()=>{try{new rf(Ge`[\d\-a]`,"v")}catch{return!0}return!1})():!1;Xr.bugNestedClassIgnoresNegation=Xr.unicodeSets&&new rf("[[^a]]","v").test("a");function bh(e,{enable:t,disable:n}){return{dotAll:!(n!=null&&n.dotAll)&&!!(t!=null&&t.dotAll||e.dotAll),ignoreCase:!(n!=null&&n.ignoreCase)&&!!(t!=null&&t.ignoreCase||e.ignoreCase)}}function Oc(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function U_(e,t){return lC[e]>=lC[t]}function D9(e,t){if(e==null)throw new Error(t??"Value expected");return e}var lC={ES2025:2025,ES2024:2024,ES2018:2018},L9={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function RN(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!L9[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=Xr.flagGroups?"ES2025":Xr.unicodeSets?"ES2024":"ES2018"),t}var R9="[ -\r ]",M9=new Set([gn(304),gn(305)]),zi=Ge`[\p{L}\p{M}\p{N}\p{Pc}]`;function MN(e){if(M9.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),i=P9.get(n),a=O9.get(n),l=I9.get(n);return[...r].length===1&&t.add(r),l&&t.add(l),i&&t.add(i),t.add(n),a&&t.add(a),[...t]}var Yx=new Map(`C Other
199
+ Cc Control cntrl
200
+ Cf Format
201
+ Cn Unassigned
202
+ Co Private_Use
203
+ Cs Surrogate
204
+ L Letter
205
+ LC Cased_Letter
206
+ Ll Lowercase_Letter
207
+ Lm Modifier_Letter
208
+ Lo Other_Letter
209
+ Lt Titlecase_Letter
210
+ Lu Uppercase_Letter
211
+ M Mark Combining_Mark
212
+ Mc Spacing_Mark
213
+ Me Enclosing_Mark
214
+ Mn Nonspacing_Mark
215
+ N Number
216
+ Nd Decimal_Number digit
217
+ Nl Letter_Number
218
+ No Other_Number
219
+ P Punctuation punct
220
+ Pc Connector_Punctuation
221
+ Pd Dash_Punctuation
222
+ Pe Close_Punctuation
223
+ Pf Final_Punctuation
224
+ Pi Initial_Punctuation
225
+ Po Other_Punctuation
226
+ Ps Open_Punctuation
227
+ S Symbol
228
+ Sc Currency_Symbol
229
+ Sk Modifier_Symbol
230
+ Sm Math_Symbol
231
+ So Other_Symbol
232
+ Z Separator
233
+ Zl Line_Separator
234
+ Zp Paragraph_Separator
235
+ Zs Space_Separator
236
+ ASCII
237
+ ASCII_Hex_Digit AHex
238
+ Alphabetic Alpha
239
+ Any
240
+ Assigned
241
+ Bidi_Control Bidi_C
242
+ Bidi_Mirrored Bidi_M
243
+ Case_Ignorable CI
244
+ Cased
245
+ Changes_When_Casefolded CWCF
246
+ Changes_When_Casemapped CWCM
247
+ Changes_When_Lowercased CWL
248
+ Changes_When_NFKC_Casefolded CWKCF
249
+ Changes_When_Titlecased CWT
250
+ Changes_When_Uppercased CWU
251
+ Dash
252
+ Default_Ignorable_Code_Point DI
253
+ Deprecated Dep
254
+ Diacritic Dia
255
+ Emoji
256
+ Emoji_Component EComp
257
+ Emoji_Modifier EMod
258
+ Emoji_Modifier_Base EBase
259
+ Emoji_Presentation EPres
260
+ Extended_Pictographic ExtPict
261
+ Extender Ext
262
+ Grapheme_Base Gr_Base
263
+ Grapheme_Extend Gr_Ext
264
+ Hex_Digit Hex
265
+ IDS_Binary_Operator IDSB
266
+ IDS_Trinary_Operator IDST
267
+ ID_Continue IDC
268
+ ID_Start IDS
269
+ Ideographic Ideo
270
+ Join_Control Join_C
271
+ Logical_Order_Exception LOE
272
+ Lowercase Lower
273
+ Math
274
+ Noncharacter_Code_Point NChar
275
+ Pattern_Syntax Pat_Syn
276
+ Pattern_White_Space Pat_WS
277
+ Quotation_Mark QMark
278
+ Radical
279
+ Regional_Indicator RI
280
+ Sentence_Terminal STerm
281
+ Soft_Dotted SD
282
+ Terminal_Punctuation Term
283
+ Unified_Ideograph UIdeo
284
+ Uppercase Upper
285
+ Variation_Selector VS
286
+ White_Space space
287
+ XID_Continue XIDC
288
+ XID_Start XIDS`.split(/\s/).map(e=>[tf(e),e])),O9=new Map([["s",gn(383)],[gn(383),"s"]]),I9=new Map([[gn(223),gn(7838)],[gn(107),gn(8490)],[gn(229),gn(8491)],[gn(969),gn(8486)]]),P9=new Map([Ns(453),Ns(456),Ns(459),Ns(498),...xg(8072,8079),...xg(8088,8095),...xg(8104,8111),Ns(8124),Ns(8140),Ns(8188)]),B9=new Map([["alnum",Ge`[\p{Alpha}\p{Nd}]`],["alpha",Ge`\p{Alpha}`],["ascii",Ge`\p{ASCII}`],["blank",Ge`[\p{Zs}\t]`],["cntrl",Ge`\p{Cc}`],["digit",Ge`\p{Nd}`],["graph",Ge`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",Ge`\p{Lower}`],["print",Ge`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",Ge`[\p{P}\p{S}]`],["space",Ge`\p{space}`],["upper",Ge`\p{Upper}`],["word",Ge`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",Ge`\p{AHex}`]]);function z9(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Ns(e){const t=gn(e);return[t.toLowerCase(),t]}function xg(e,t){return z9(e,t).map(n=>Ns(n))}var ON=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function $9(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};IN(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:U_(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Cc(e,H9,r);const i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};Cc(e,F9,a);const l={groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer};return Cc(e,U9,l),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var H9={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:i}=e;if(i==="repeater"){const a=Kr();a.body[0].body.push(xa({negate:!0,body:r}),Bo("Any"));const l=Kr();l.body[0].body.push(NN("greedy",0,1/0,a)),n(en(l,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const i=e.body.filter(a=>a.kind==="flags");for(let a=n+1;a<t.body.length;a++){const l=t.body[a];Oc(r,l,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=BN(t.get(e));if(r){const i=Kr({flags:r});i.body[0].body=e.body,e.body=[en(i,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:a,replaceWith:l},d){const{kind:f,negate:h}=e,{asciiWordBoundaries:p,avoidSubclass:g,supportedGNodes:x,wordIsAscii:_}=d;if(f==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${h?"Y":"y"}"`);if(f==="line_end")l(en(xa({body:[Da({body:[z_("string_end")]}),Da({body:[ef(10)]})]}),t));else if(f==="line_start")l(en($i(Ge`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(f==="search_start")if(x.has(e))i.flags.sticky=!0,a();else{const v=r[n-1];if(v&&Y9(v))l(en(xa({negate:!0}),t));else{if(g)throw new Error(Ge`Uses "\G" in a way that requires a subclass`);l(js(z_("string_start"),t)),d.strategy="clip_search"}}else if(!(f==="string_end"||f==="string_start"))if(f==="string_end_newline")l(en($i(Ge`(?=\n?\z)`),t));else if(f==="word_boundary"){if(!_&&!p){const v=`(?:(?<=${zi})(?!${zi})|(?<!${zi})(?=${zi}))`,S=`(?:(?<=${zi})(?=${zi})|(?<!${zi})(?!${zi}))`;l(en($i(h?S:v),t))}}else throw new Error(`Unexpected assertion kind "${f}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!vg(n)&&(n=yg(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!vg(r)&&(r=yg(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){const r=Kd({body:[e]});n(en(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:l,wordIsAscii:d}){const{kind:f,negate:h,value:p}=e;if(a&&(f==="digit"||p==="digit")){n(js(H_("digit",{negate:h}),t));return}if(l&&(f==="space"||p==="space")){n(en(bg($i(R9),h),t));return}if(d&&(f==="word"||p==="word")){n(js(H_("word",{negate:h}),t));return}if(f==="any")n(js(Bo("Any"),t));else if(f==="digit")n(js(Bo("Nd",{negate:h}),t));else if(f!=="dot")if(f==="text_segment"){if(r==="strict")throw new Error(Ge`Use of "\X" requires non-strict accuracy`);const g="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",x=Ge`\p{RI}{2}|${g}(?:\u200D${g})*`;n(en($i(Ge`(?>\r\n|${i?Ge`\p{RGI_Emoji}`:x}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(f==="hex")n(js(Bo("AHex",{negate:h}),t));else if(f==="newline")n(en($i(h?`[^
289
+ ]`:`(?>\r
290
+ ?|[
291
+ \v\f…\u2028\u2029])`),t));else if(f==="posix")if(!i&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let g={graph:"!-~",print:" -~"}[p];h&&(g=`\0-${gn(g.codePointAt(0)-1)}${gn(g.codePointAt(2)+1)}-􏿿`),n(en($i(`[${g}]`),t))}else n(en(bg($i(B9.get(p)),h),t));else if(f==="property")Yx.has(tf(p))||(e.key="sc");else if(f==="space")n(js(Bo("space",{negate:h}),t));else if(f==="word")n(en(bg($i(zi),h),t));else throw new Error(`Unexpected character set kind "${f}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:l}){const{kind:d,flags:f}=e;if(d==="flags")if(!f.enable&&!f.disable)r();else{const h=Kr({flags:f});h.body[0].body=l(),i(en(h,t),{traverse:!0})}else if(d==="keep"){const h=n.body[0],g=n.body.length===1&&CN(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==g||g.body.length>1)throw new Error(Ge`Uses "\K" in a way that's unsupported`);const x=xa({behind:!0});x.body[0].body=a(),i(en(x,t))}else throw new Error(`Unexpected directive kind "${d}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(en(xa({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=Kr();t.body[0].body.push(e.body),e.body=en(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,i=!1;for(const a of e.body)if(a.body.length===1&&a.body[0].kind==="search_start")a.body.pop();else{const l=$N(a.body);l?(r=!0,Array.isArray(l)?n.push(...l):n.push(l)):i=!0}r&&!i&&n.forEach(a=>t.add(a))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(Ge`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!vg(n)&&(n=yg(n,t),e.ref=n)}},F9={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:a})=>a)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:l,openRefs:d,reffedNodesByReferencer:f}){const h=i.get(e);if(h&&d.has(e.number)){const g=js(cC(e.number),t);f.set(g,d.get(e.number)),n(g);return}d.set(e.number,e),l.set(e.number,[]),e.name&&Oc(l,e.name,[]);const p=l.get(e.name??e.number);for(let g=0;g<p.length;g++){const x=p[g];if(h===x.node||h&&h===x.origin||e===x.origin){p.splice(g,1);break}}if(l.get(e.number).push({node:e,origin:h}),e.name&&l.get(e.name).push({node:e,origin:h}),e.name){const g=Oc(a,e.name,new Map);let x=!1;if(h)x=!0;else for(const _ of g.values())if(!_.hasDuplicateNameToRemove){x=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:x})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=bh(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:i,ref:a}=e;if(i){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===a||p.number===a)););r.reffedNodesByReferencer.set(e,p);return}const l=r.subroutineRefMap.get(a),d=a===0,f=d?cC(0):PN(l,r.groupOriginByCopy,null);let h=f;if(!d){const p=BN(G9(l,x=>x.type==="Group"&&!!x.flags)),g=p?bh(r.globalFlags,p):r.globalFlags;V9(g,r.currentFlags)||(h=Kr({flags:q9(g)}),h.body[0].body.push(f))}n(en(h,t),{traverse:!d})}},U9={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const a=r.reffedNodesByReferencer.get(e).filter(l=>W9(l,e));if(!a.length)n(en(xa({negate:!0}),t));else if(a.length>1){const l=Kr({atomic:!0,body:a.reverse().map(d=>Da({body:[$_(d.number)]}))});n(en(l,t))}else e.ref=a[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const i=EN();e.body.at(-1).body.push(i)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function IN(e){Cc(e,{"*"({node:t,parent:n}){t.parent=n}})}function V9(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function W9(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=zN(n.parent);for(const i of r){if(i===n)break;if(i===e||HN(i,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function PN(e,t,n,r){const i=Array.isArray(e)?[]:{};for(const[a,l]of Object.entries(e))a==="parent"?i.parent=Array.isArray(n)?r:n:l&&typeof l=="object"?i[a]=PN(l,t,i,n):(a==="type"&&l==="CapturingGroup"&&t.set(i,t.get(e)??e),i[a]=l);return i}function cC(e){const t=jN(e);return t.isRecursive=!0,t}function G9(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function yg(e,t){if(t.has(e))return t.get(e);const n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function BN(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(i=>{var a,l;(a=r.enable)!=null&&a[i]&&(delete n.disable[i],n.enable[i]=!0),(l=r.disable)!=null&&l[i]&&(n.disable[i]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function q9({dotAll:e,ignoreCase:t}){const n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function zN(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function $N(e){const t=e.find(n=>n.kind==="search_start"||X9(n,{negate:!1})||!K9(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const r of t.body){const i=$N(r.body);if(!i)return null;Array.isArray(i)?n.push(...i):n.push(i)}return n}return null}function HN(e,t){const n=zN(e)??[];for(const r of n)if(r===t||HN(r,t))return!0;return!1}function K9({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function Y9(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function X9(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&CN(e.body[0],{type:"Assertion",kind:"search_start"})}function vg(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function $i(e,t){const r=kN(e,{...t,unicodePropertyMap:Yx}).body;return r.length>1||r[0].body.length>1?Kr({body:r}):r[0].body[0]}function bg(e,t){return e.negate=t,e}function js(e,t){return e.parent=t,e}function en(e,t){return IN(e),e.parent=t,e}function Q9(e,t){const n=RN(t),r=U_(n.target,"ES2024"),i=U_(n.target,"ES2025"),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw new Error("Invalid recursionLimit; use 2-20");let l=null,d=null;if(!i){const _=[e.flags.ignoreCase];Cc(e,J9,{getCurrentModI:()=>_.at(-1),popModI(){_.pop()},pushModI(v){_.push(v)},setHasCasedChar(){_.at(-1)?l=!0:d=!0}})}const f={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||l)&&!d)};let h=e;const p={accuracy:n.accuracy,appliedGlobalFlags:f,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:h,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&l&&d),useFlagMods:i,useFlagV:r,verbose:n.verbose};function g(_){return p.lastNode=h,h=_,D9(Z9[_.type],`Unexpected node type "${_.type}"`)(_,p,g)}const x={pattern:e.body.map(g).join("|"),flags:g(e.flags),options:{...e.options}};return r||(delete x.options.force.v,x.options.disable.v=!0,x.options.unicodeSetsPlugin=null),x._captureTransfers=new Map,x._hiddenCaptures=[],p.captureMap.forEach((_,v)=>{_.hidden&&x._hiddenCaptures.push(v),_.transferTo&&Oc(x._captureTransfers,_.transferTo,[]).push(v)}),x}var J9={"*":{enter({node:e},t){if(dC(e)){const n=t.getCurrentModI();t.pushModI(e.flags?bh({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){dC(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Xx(gn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),FN(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&ON.has(e.value)&&t.setHasCasedChar()}},Z9={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?Ge`\B`:Ge`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:i,number:a}=e,l={ignoreCase:t.currentFlags.ignoreCase},d=t.originMap.get(e);return d&&(l.hidden=!0,a>d.number&&(l.transferTo=d.number)),t.captureMap.set(a,l),`(${i?`?<${i}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=gn(e),r=Do(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Xx(n)){const i=MN(n);return t.inCharClass?i.join(""):i.length>1?`[${i.join("")}]`:i[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:i,parent:a}=e;let{body:l}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");Xr.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&l.some(hC)&&(l=[ef(45),...l.filter(h=>!hC(h))]);const d=()=>`[${i?"^":""}${l.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Xr.bugNestedClassIgnoresNegation)&&!i){const p=l.filter(g=>g.type==="CharacterClass"&&g.kind==="union"&&g.negate);if(p.length){const g=Kr(),x=g.body[0];return g.parent=a,x.parent=g,l=l.filter(_=>!p.includes(_)),e.body=l,l.length?(e.parent=x,x.body.push(e)):g.body.pop(),p.forEach(_=>{const v=Da({body:[_]});_.parent=v,v.parent=g,g.body.push(v)}),n(g)}}t.inCharClass=!0;const h=d();return t.inCharClass=!1,h}const f=l[0];if(r==="union"&&!i&&f&&((!t.useFlagV||!t.verbose)&&a.kind==="union"&&!(Xr.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind==="intersection"&&l.length===1&&f.type!=="CharacterClassRange"))return l.map(n).join("");if(!t.useFlagV&&a.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return d()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=Do(n,i),l=Do(r,i),d=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const f=FN(e);iH(f).forEach(p=>{d.add(Array.isArray(p)?`${Do(p[0],i)}-${Do(p[1],i)}`:Do(p,i))})}return`${a}-${l}${[...d].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e==="dot")return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?".":"[^]":Ge`[^\n]`;if(e==="digit")return t?Ge`\D`:Ge`\d`;if(e==="property"){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&ON.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Ge`\P`:Ge`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?Ge`\W`:Ge`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},i,a){const l=i.currentFlags;n&&(i.currentFlags=bh(l,n));const d=t.map(a).join("|"),f=!i.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!i.useFlagMods||!n)?d:`(?${sH(e,n,i.useFlagMods)}${d})`;return i.currentFlags=l,f},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(i).join("|")})`},Quantifier(e,t,n){return n(e.body)+aH(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return t===0?`(?R=${r})`:Ge`\g<${t}&R=${r}>`}},eH=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),tH=new Set(["-","\\","]","^","["]),nH=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),uC=new Map([[9,Ge`\t`],[10,Ge`\n`],[11,Ge`\v`],[12,Ge`\f`],[13,Ge`\r`],[8232,Ge`\u2028`],[8233,Ge`\u2029`],[65279,Ge`\uFEFF`]]),rH=new RegExp("^\\p{Cased}$","u");function Xx(e){return rH.test(e)}function FN(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let l=r;l<=i;l++){const d=gn(l);if(!Xx(d))continue;const f=MN(d).filter(h=>{const p=h.codePointAt(0);return p<r||p>i});if(f.length&&(a.push(...f),n))break}return a}function Do(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(uC.has(e))return uC.get(e);if(e<32||e>126&&e<160||e>262143||t&&oH(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const i=n?r?nH:tH:eH,a=gn(e);return(i.has(a)?"\\":"")+a}function iH(e){const t=e.map(i=>i.codePointAt(0)).sort((i,a)=>i-a),n=[];let r=null;for(let i=0;i<t.length;i++)t[i+1]===t[i]+1?r??(r=t[i]):r===null?n.push(t[i]):(n.push([r,t[i]]),r=null);return n}function sH(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:i,disable:a}=t;r=(i!=null&&i.ignoreCase?"i":"")+(i!=null&&i.dotAll?"s":"")+(a?"-":"")+(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")}return`${r}:`}function aH({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function dC({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function oH(e){return e>47&&e<58}function hC({type:e,value:t}){return e==="Character"&&t===45}var As,Vi,wa,Ds,Ca,Ic,V_,Bs,lH=(Bs=class extends RegExp{constructor(n,r,i){var t=(...SG)=>(super(...SG),aa(this,Ic),aa(this,As,new Map),aa(this,Vi,null),aa(this,wa),aa(this,Ds,null),aa(this,Ca,null),ce(this,"rawOptions",{}),this);const a=!!(i!=null&&i.lazyCompile);if(n instanceof RegExp){if(i)throw new Error("Cannot provide options when copying a regexp");const l=n;t(l,r),Ur(this,wa,l.source),l instanceof Bs&&(Ur(this,As,Un(l,As)),Ur(this,Ds,Un(l,Ds)),Ur(this,Ca,Un(l,Ca)),this.rawOptions=l.rawOptions)}else{const l={hiddenCaptures:[],strategy:null,transfers:[],...i};t(a?"":n,r),Ur(this,wa,n),Ur(this,As,uH(l.hiddenCaptures,l.transfers)),Ur(this,Ca,l.strategy),this.rawOptions=i??{}}a||Ur(this,Vi,this)}get source(){return Un(this,wa)||"(?:)"}exec(n){if(!Un(this,Vi)){const{lazyCompile:a,...l}=this.rawOptions;Ur(this,Vi,new Bs(Un(this,wa),this.flags,l))}const r=this.global||this.sticky,i=this.lastIndex;if(Un(this,Ca)==="clip_search"&&r&&i){this.lastIndex=0;const a=gp(this,Ic,V_).call(this,n.slice(i));return a&&(cH(a,i,n,this.hasIndices),this.lastIndex+=i),a}return gp(this,Ic,V_).call(this,n)}},As=new WeakMap,Vi=new WeakMap,wa=new WeakMap,Ds=new WeakMap,Ca=new WeakMap,Ic=new WeakSet,V_=function(n){Un(this,Vi).lastIndex=this.lastIndex;const r=G0(Bs.prototype,this,"exec").call(Un(this,Vi),n);if(this.lastIndex=Un(this,Vi).lastIndex,!r||!Un(this,As).size)return r;const i=[...r];r.length=1;let a;this.hasIndices&&(a=[...r.indices],r.indices.length=1);const l=[0];for(let d=1;d<i.length;d++){const{hidden:f,transferTo:h}=Un(this,As).get(d)??{};if(f?l.push(null):(l.push(r.length),r.push(i[d]),this.hasIndices&&r.indices.push(a[d])),h&&i[d]!==void 0){const p=l[h];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=i[d],this.hasIndices&&(r.indices[p]=a[d]),r.groups){Un(this,Ds)||Ur(this,Ds,dH(this.source));const g=Un(this,Ds).get(h);g&&(r.groups[g]=i[d],this.hasIndices&&(r.indices.groups[g]=a[d]))}}}return r},Bs);function cH(e,t,n,r){if(e.index+=t,e.input=n,r){const i=e.indices;for(let l=0;l<i.length;l++){const d=i[l];d&&(i[l]=[d[0]+t,d[1]+t])}const a=i.groups;a&&Object.keys(a).forEach(l=>{const d=a[l];d&&(a[l]=[d[0]+t,d[1]+t])})}}function uH(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,i]of t)for(const a of i)Oc(n,a,{}).transferTo=r;return n}function dH(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,i=0,a;for(;a=t.exec(e);){const{0:l,groups:{capture:d,name:f}}=a;l==="["?r++:r?l==="]"&&r--:d&&(i++,f&&n.set(i,f))}return n}function hH(e,t){const n=fH(e,t);return n.options?new lH(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function fH(e,t){const n=RN(t),r=kN(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Yx}),i=$9(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),a=Q9(i,n),l=T9(a.pattern,{captureTransfers:a._captureTransfers,hiddenCaptures:a._hiddenCaptures,mode:"external"}),d=N9(l.pattern),f=E9(d.pattern,{captureTransfers:l.captureTransfers,hiddenCaptures:l.hiddenCaptures}),h={pattern:f.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${a.flags}${a.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const p=f.hiddenCaptures.sort((v,S)=>v-S),g=Array.from(f.captureTransfers),x=i._strategy,_=h.pattern.length>=n.lazyCompileLength;(p.length||g.length||x||_)&&(h.options={...p.length&&{hiddenCaptures:p},...g.length&&{transfers:g},...x&&{strategy:x},..._&&{lazyCompile:_}})}return h}function UN(e,t){return hH(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function mH(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>UN(n,{target:t.target})),{createScanner(n){return new A7(n,t)},createString(n){return{content:n}}}}jE(Mx({bundledLanguages:()=>Px,bundledLanguagesAlias:()=>Ix,bundledLanguagesBase:()=>Ox,bundledLanguagesInfo:()=>Wh,bundledThemes:()=>zx,bundledThemesInfo:()=>Bx,codeToHast:()=>fN,codeToHtml:()=>hN,codeToTokens:()=>mN,codeToTokensBase:()=>pN,codeToTokensWithThemes:()=>gN,createHighlighter:()=>Zh,createJavaScriptRegexEngine:()=>mH,createOnigurumaEngine:()=>DE,defaultJavaScriptRegexConstructor:()=>UN,getLastGrammarState:()=>xN,getSingletonHighlighter:()=>_N,loadWasm:()=>Hx}),T7);let Sg=null;const pH=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],gH=["github-dark-default","vitesse-light","monokai","dracula","nord"],_H={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord"};function xH(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function yH(){return Sg||(Sg=Zh({themes:gH,langs:pH})),Sg}const oc=new Map,vH=50;function bH(e,t,n){return`${e}|${t}|${n}`}async function VN(e,t,n="github-dark-default"){const r=bH(e,t,n),i=oc.get(r);if(i)return i;const l=(await yH()).codeToHtml(e,{lang:t,theme:n,transformers:[xH()]});if(oc.size>=vH){const d=oc.keys().next().value;d&&oc.delete(d)}return oc.set(r,l),l}const SH={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 sf(e){var i;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=(i=t.split(".").pop())==null?void 0:i.toLowerCase();return r?SH[r]??"text":"text"}function WN(){const e=Gt(n=>n.currentPreset);return Gt(n=>n.isCustom)?"github-dark-default":_H[e]??"github-dark-default"}function GN(e=2e3){const[t,n]=C.useState(!1),r=C.useCallback(async i=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(i);else{const a=document.createElement("textarea");a.value=i,a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}n(!0),setTimeout(()=>n(!1),e)}catch(a){console.error("Failed to copy:",a)}},[e]);return{copied:t,copy:r}}const wH=C.memo(function({language:t,codeString:n,showSyntaxHighlighting:r}){const{copied:i,copy:a}=GN(),[l,d]=C.useState(null),f=WN(),h=C.useRef(n);return C.useEffect(()=>{r&&(h.current=n,VN(n,t,f).then(p=>{h.current===n&&d(p)}))},[n,t,f,r]),c.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[c.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:[c.jsx("span",{children:t}),c.jsx("button",{type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation(),a(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:i?c.jsx(pi,{}):c.jsx(Y_,{})})]}),r&&l?c.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:l}}):c.jsx("div",{className:"overflow-x-auto",children:c.jsx("pre",{className:"my-0 px-4 py-3 overflow-x-auto font-mono text-sm whitespace-pre-wrap break-word",children:c.jsx("code",{className:`language-${t}`,children:n})})})]})});function CH(e,t){const n=e?"text-text-muted":"text-sky-400",r=e?"text-text-secondary":"text-amber-400";return{code({className:i,children:a,...l}){const d=/language-(\w+)/.exec(i||"");if(!d&&!String(a).includes(`
292
+ `)){const g=e?"text-text-muted":"text-accent-secondary";return c.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${g} font-mono text-xs`,...l,children:a})}const h=(d==null?void 0:d[1])||"text",p=String(a).replace(/\n$/,"");return c.jsx(wH,{language:h,codeString:p,showSyntaxHighlighting:t})},p({children:i}){const a=e?"text-text-muted":"text-text-primary";return c.jsx("p",{className:`${a} mb-1.5 last:mb-0 leading-tight`,children:i})},ul({children:i}){return c.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:i})},ol({children:i}){return c.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:i})},li({children:i}){const a=e?"text-text-muted":"text-text-primary";return c.jsx("li",{className:`${a} text-sm list-item`,children:i})},h1({children:i}){return c.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:i})},h2({children:i}){return c.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:i})},h3({children:i}){return c.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:i})},h4({children:i}){return c.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:i})},strong({children:i}){return c.jsx("strong",{className:`font-bold ${r}`,children:i})},em({children:i}){return c.jsx("em",{className:e?"italic text-text-secondary":"italic",children:i})},a({href:i,children:a}){return c.jsx("a",{href:i,className:"text-accent-primary hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:a})},blockquote({children:i}){const a=e?"text-text-muted":"text-text-secondary";return c.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${a} italic text-sm`,children:i})},table({children:i}){return c.jsx("div",{className:"overflow-x-auto my-1.5",children:c.jsx("table",{className:"min-w-full border border-border",children:i})})},th({children:i}){return c.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:i})},td({children:i}){return c.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:i})},hr(){return c.jsx("hr",{className:"border-border my-2"})},input({checked:i,...a}){return c.jsx("input",{type:"checkbox",checked:i,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...a})}}}const Ki=C.memo(function({content:t,className:n="",muted:r=!1}){const{showSyntaxHighlighting:i}=Eh(),a=C.useMemo(()=>{let d=kH(t);return d=EH(d),d},[t]),l=C.useMemo(()=>CH(r,i),[r,i]);return c.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:c.jsx(s6,{remarkPlugins:[y8],components:l,children:a})})});function kH(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 EH(e){const t=/```/g,n=e.match(t);if(((n==null?void 0:n.length)??0)%2===1){const i=e.lastIndexOf("```");return e.slice(i+3).includes(`
293
+ `),e+"\n```"}return e}const NH=C.memo(function({content:t,variant:n="default"}){return n==="labeled"?c.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[c.jsx("span",{className:"text-purple-400",children:"thinking:"}),c.jsx("div",{className:"ml-1.5 mt-0.5",children:c.jsx(Ki,{content:t})})]}):c.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:c.jsx(Ki,{content:t,muted:!0})})});function qN({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?c.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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"?c.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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"})}):c.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 Go=C.memo(function({code:t,language:n,variant:r,showLineNumbers:i=!1,startLine:a=1}){const[l,d]=C.useState(null),f=WN(),h=C.useRef(t);if(C.useEffect(()=>{h.current=t,VN(t,n,f).then(g=>{h.current===t&&d(g)})},[t,n,f]),!l){const g=r==="inline"?"span":r==="block-nowrap"?"div":"pre";return c.jsx(g,{className:"language-",children:c.jsx("code",{className:"language-",children:t})})}if(r==="inline")return c.jsx("span",{dangerouslySetInnerHTML:{__html:l}});const p=i?"":"shiki-plain";return c.jsx("div",{className:p,style:{"--shiki-start":a},dangerouslySetInnerHTML:{__html:l}})});function KN({src:e,alt:t,isOpen:n,onClose:r}){return n?c.jsx(jt,{isOpen:n,onClose:r,title:"",size:"full",children:c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const Sh=C.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",i=t==="removed"?"line-through decoration-red-400/30":"";return c.jsx("div",{className:`border-l-[3px] ${r}`,children:c.jsx("div",{className:`min-w-0 py-3 ${i}`,children:c.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),jH=C.memo(function({oldString:t,newString:n,filePath:r}){const i=C.useMemo(()=>sf(r),[r]),a=t.length>0,l=n.length>0;return!a&&!l?c.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):c.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[a&&c.jsx(Sh,{type:"removed",children:c.jsx(Go,{code:t,language:i,variant:"block",showLineNumbers:!0})}),l&&c.jsx(Sh,{type:"added",children:c.jsx(Go,{code:n,language:i,variant:"block",showLineNumbers:!0})})]})}),TH=C.memo(function({content:t,filePath:n}){const r=C.useMemo(()=>sf(n),[n]);return c.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:c.jsx(Sh,{type:"added",children:c.jsx(Go,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),AH=C.memo(function({regions:t,filePath:n}){const r=C.useMemo(()=>sf(n),[n]);return t.length===0?c.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):c.jsx("div",{className:"space-y-2",children:t.map((i,a)=>c.jsx(LH,{region:i,language:r},a))})});function DH(e){const t=[];function n(r,i,a){const l=t[t.length-1];l&&l.type===r&&l.startLine+l.lines.length===i?l.lines.push(a):t.push({type:r,startLine:i,lines:[a]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const i=r.oldContent.split(`
294
+ `);for(let l=0;l<i.length;l++)n("removed",r.startLine+l,i[l]);const a=r.newContent.split(`
295
+ `);for(let l=0;l<a.length;l++)n("added",r.startLine+l,a[l])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const LH=C.memo(function({region:t,language:n}){const r=DH(t);return c.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((i,a)=>c.jsx(RH,{section:i,language:n},a))})}),RH=C.memo(function({section:t,language:n}){const r=t.lines.join(`
296
+ `);return t.type==="context"?c.jsx("div",{children:c.jsx("div",{className:"min-w-0 py-3",children:c.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:c.jsx(Go,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):c.jsx(Sh,{type:t.type,children:c.jsx(Go,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function fC(e){return e.split(`
297
+ `).filter(t=>!t.startsWith(`
298
+ [`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+: /,"")).join(`
299
+ `)}const MH=C.memo(function({result:t,metadata:n,filePath:r,heightExpanded:i=!1}){const[a,l]=C.useState(!1),d=C.useMemo(()=>sf(r),[r]),f=n==null?void 0:n.mimeType,h=n==null?void 0:n.base64Data;if(f!=null&&f.startsWith("image/")&&h){const S=`data:${f};base64,${h}`;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:`rounded overflow-hidden border border-border ${i?"":"max-h-[45vh]"} flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors`,onClick:()=>l(!0),children:c.jsx("img",{src:S,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),c.jsx(KN,{src:S,alt:r,isOpen:a,onClose:()=>l(!1)})]})}if(!t)return c.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const p=t;if(d==="markdown"){const S=fC(p);return c.jsx("div",{className:`rounded overflow-hidden border border-border ${i?"":"max-h-[45vh]"} overflow-y-auto p-2`,children:c.jsx(Ki,{content:S})})}const g=fC(p),x=p.split(`
300
+ `)[0],_=x==null?void 0:x.match(/^(\d+): /),v=_?parseInt(_[1],10):1;return c.jsx("div",{className:`rounded overflow-hidden border border-border ${i?"":"max-h-[45vh]"} overflow-y-auto`,children:c.jsx(Go,{code:g,language:d,variant:"block",showLineNumbers:!0,startLine:v})})}),OH={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"}},mC=C.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(a=>a.severity==="error"),r=t.filter(a=>a.severity==="warning"),i=t.filter(a=>a.severity==="info"||a.severity==="hint");return c.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[c.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[c.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&c.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&c.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),i.length>0&&c.jsxs("span",{className:"text-xs text-text-muted",children:[i.length," info"]})]}),c.jsx("div",{className:"max-h-48 overflow-y-auto",children:t.map((a,l)=>{const d=OH[a.severity];return c.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${d.bg} border-b border-border last:border-b-0`,children:[c.jsx("span",{className:`${d.color} text-xs flex-shrink-0 w-4 text-center`,children:d.icon}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",a.range.start.line+1,":",a.range.start.character+1]}),a.code&&c.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",a.code,"]"]})]}),c.jsx("div",{className:"text-xs text-text-primary break-words",children:a.message})]})]},l)})})]})}),IH=C.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:i,status:a,result:l,error:d,durationMs:f}){const h=C.useRef(null),[p,g]=C.useState(0);C.useEffect(()=>{h.current&&a==="pending"&&(h.current.scrollTop=h.current.scrollHeight)},[i,a]),C.useEffect(()=>{if(a!=="pending"||!r)return;const S=setInterval(()=>{g(Date.now()-r)},100);return()=>clearInterval(S)},[a,r]);const x=n/1e3,_=a==="pending"?p/1e3:(f??0)/1e3,v=a==="pending"?(i==null?void 0:i.map(S=>S.content).join(""))??"":l??"";return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[c.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),c.jsx("code",{className:"text-text-primary break-all",children:t})]}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[a==="pending"&&c.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),a==="interrupted"&&c.jsx("span",{className:"text-red-400",children:"interrupted"}),c.jsxs("span",{className:a==="pending"?"text-text-secondary":"text-text-muted",children:[_.toFixed(1),"s / ",x,"s"]})]})]}),a==="pending"&&c.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:c.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(v||a==="pending")&&c.jsx("pre",{ref:h,className:`text-xs bg-bg-primary p-2 rounded max-h-64 overflow-y-auto ${a==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:a==="pending"&&i?i.map((S,w)=>c.jsx("span",{className:S.stream==="stderr"?"text-accent-warning":"",children:sh(S.content)},w)):sh(v)}),a==="error"&&d&&c.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:d}),a!=="pending"&&f!==void 0&&c.jsxs("div",{className:"text-[10px] text-text-muted",children:["Completed in ",(f/1e3).toFixed(2),"s"]})]})});function PH(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 BH({confirmation:e}){const t=xe(g=>g.confirmPath),n=xe(g=>g.currentSession),r=xe(g=>g.switchDangerLevel),{title:i,description:a}=PH(e.reason),l=e.reason==="sensitive_file"||e.reason==="both",d=l?"border-red-500/50":"border-amber-500/50",f=l?"bg-red-500/10":"bg-amber-500/10",h=e.reason==="git_no_verify",p=()=>{n!=null&&n.id&&r("dangerous"),t(e.callId,!0,!1)};return c.jsxs("div",{className:`border ${d} ${f} rounded p-3 my-2`,children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx(Dg,{}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:`text-sm font-medium ${l?"text-red-400":"text-amber-400"}`,children:i}),c.jsx("div",{className:"text-xs text-text-muted",children:a})]})]}),c.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[c.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),c.jsx("div",{className:"bg-bg-primary rounded p-2 mb-3 max-h-24 overflow-y-auto",children:c.jsx("ul",{className:"space-y-0.5",children:e.paths.map((g,x)=>c.jsx("li",{className:`text-xs font-mono ${l?"text-red-300":"text-amber-300"} break-all`,children:g},x))})}),c.jsxs("div",{className:"flex gap-2",children:[c.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"}),c.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"}),c.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${h?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function zH(e,t){if(e==="read_file"){const r=String(t.path??""),i=t.offset,a=t.limit,l=[];return i!==void 0&&i!==1&&l.push(`offset=${i}`),a!==void 0&&l.push(`limit=${a}`),l.length>0?`${r} [${l.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 pC(e,t,n){return zH(e,t)}function $H(e){return JSON.stringify(e,null,2)}const HH={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}},FH=C.memo(function({tool:t,args:n,status:r,variant:i="compact",forceCompact:a,result:l,error:d,durationMs:f,diagnostics:h,editContext:p,startedAt:g,streamingOutput:x,metadata:_,callId:v}){var G;const S=t==="edit_file"||t==="write_file",w=t==="run_command"&&r==="pending",k=t==="read_file",T=a?!1:S||w||t==="return_value",[A,P]=C.useState(T),M=HH[r],q=tn(H=>H.settings[Me.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",Z=t==="edit_file"?(G=p==null?void 0:p.regions[0])==null?void 0:G.startLine:t==="read_file"?(()=>{const H=l==null?void 0:l.split(`
301
+ `)[0],R=H==null?void 0:H.match(/^(\d+): /);return R?parseInt(R[1],10):void 0})():void 0,J=xe(H=>H.pendingPathConfirmations),L=r==="pending"&&v?J.find(H=>H.callId===v)??null:null;return i==="compact"?c.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary rounded px-2 py-1.5",children:[c.jsx(qN,{tool:t}),c.jsx("span",{className:"text-accent-primary font-medium",children:t}),c.jsx("span",{className:"text-text-muted truncate flex-1",children:pC(t,n)}),c.jsx("span",{className:`${M.color} ${M.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):c.jsxs("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0",children:[c.jsxs("button",{className:"w-full flex items-center gap-1.5 p-2 bg-secondary hover:bg-secondary/80 text-left",onClick:()=>P(!A),children:[c.jsx("span",{className:`${M.color} ${M.animate?"animate-pulse":""}`,children:M.icon}),c.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),c.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:pC(t,n)}),c.jsx("span",{className:"text-text-muted text-xs",children:A?"▼":"▶"})]}),L&&c.jsx(BH,{confirmation:L}),(A||k)&&c.jsxs("div",{className:"p-2 bg-primary border-t border-border space-y-2 min-w-0",children:[t==="run_command"&&c.jsx(IH,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:g,streamingOutput:x,status:r,result:l,error:d,durationMs:f}),t==="edit_file"&&r==="success"&&c.jsxs(c.Fragment,{children:[p&&p.regions.length>0?c.jsx(AH,{regions:p.regions,filePath:String(n.path??"")}):c.jsx(jH,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&c.jsx(mC,{diagnostics:h})]}),t==="write_file"&&r==="success"&&c.jsxs(c.Fragment,{children:[c.jsx(TH,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&c.jsx(mC,{diagnostics:h})]}),t==="read_file"&&r==="success"&&c.jsx(MH,{result:l,metadata:_,filePath:String(n.path??""),heightExpanded:A}),t==="return_value"&&(()=>{const H=(x==null?void 0:x.map(U=>U.content).join(""))??"",R=r==="pending"&&H?H:String(n.content??"");return c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),c.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:c.jsx(Ki,{content:R})})]})})(),t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),c.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto",children:$H(n)})]}),r==="success"&&l!==void 0&&c.jsxs("div",{children:[c.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",f!==void 0&&` (${f}ms)`,":"]}),c.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-32",children:l||"No output"})]})]}),r==="success"&&(t==="edit_file"||t==="write_file"||t==="read_file")&&f!==void 0&&c.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[c.jsxs("span",{children:["Completed in ",f,"ms"]}),q&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String(n.path??"")&&c.jsx("a",{href:`vscode://file/${String(n.path)}${Z?`:${Z}`:""}`,className:"text-accent-primary hover:underline ml-auto",children:"Open in VSCode"})]}),r==="error"&&d&&t!=="run_command"&&c.jsxs("div",{children:[c.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),c.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error",children:d})]})]})]})}),UH={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",session_metadata:"Managing",todo_write:"Updating tasks"},VH={criteria:"criteria",review_findings:"review findings",todos:"tasks"};function WH(e,t){const n=UH[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const i=JSON.parse(t).key;if(i){const a=VH[i]??i;return`${n} ${a}`}}catch{}return n}function GH(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 qH=C.memo(function({name:t,arguments:n}){let i=WH(t,n)+"...";if(t==="run_command"&&n){const a=GH(n);a&&(i=a)}return c.jsx("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0 animate-pulse",children:c.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-bg-tertiary",children:[c.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),c.jsx(qN,{tool:t}),c.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?c.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:i}):c.jsx("span",{className:"text-text-muted text-xs flex-1",children:i})]})})}),KH={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},YH=C.memo(function({todos:t}){return Array.isArray(t)?t.length===0?c.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):c.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[c.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:c.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),c.jsx("div",{children:t.map((n,r)=>{const i=KH[n.status];return c.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[c.jsx("span",{className:`${(i==null?void 0:i.color)??"text-text-muted"} ${i!=null&&i.animate?"animate-pulse":""} text-sm leading-tight`,children:(i==null?void 0:i.icon)??"○"}),c.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):c.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})}),gC={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"},list:{icon:"○",color:"text-text-muted"},schema:{icon:"○",color:"text-text-muted"}},YN=C.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(f=>[f.id,f]))??[]),i=t.find(f=>{var h,p;return f.arguments.action==="get"&&((h=f.result)==null?void 0:h.success)&&((p=f.result)==null?void 0:p.output)}),a=t.some(f=>f.name==="session_metadata"),l={criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"},d=(()=>{if(!a)return"Acceptance Criteria";const f=new Set(t.map(h=>h.arguments.key).filter(Boolean));if(f.size===1){const h=f.values().next().value;return h?l[h]??h:"Session Data"}return"Session Data"})();return c.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[c.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:c.jsx("span",{className:"text-xs font-medium text-text-muted",children:d})}),c.jsx("div",{className:"bg-primary",children:i?(()=>{const f=i.result.output;if(f==="No criteria defined yet.")return c.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[c.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),c.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(f).map((p,g)=>c.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${g>0?"border-t border-border":""}`,children:[c.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),c.jsx("div",{className:"flex-1 min-w-0",children:c.jsx(Ki,{content:`[${p.id}] ${p.description}`})})]},p.id??g))}catch{return t.map((h,p)=>c.jsx(_C,{tc:h,index:p,criteriaMap:r},h.id??p))}})():t.map((f,h)=>c.jsx(_C,{tc:f,index:h,criteriaMap:r},f.id??h))})]})});function _C({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,i=e.arguments,a=e.name==="session_metadata",l=r==="remove",d=i.id,f=i.description,h=d?n.get(d):void 0,p=f??(h==null?void 0:h.description)??(l&&d?`[${d}]`:"Criterion updated"),g=i.reason,x=r==="fail";return c.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[a?c.jsx(Bh,{status:i.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const _=r&&gC[r]?gC[r]:{icon:"○",color:"text-text-muted"};return c.jsx("span",{className:`${_.color} text-sm leading-tight flex-shrink-0`,children:_.icon})})(),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:l?"line-through text-text-muted":"",children:c.jsx(Ki,{content:p})}),g&&c.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[c.jsx("span",{className:"text-text-muted",children:"└ "}),'"',g,'"']})]})]})}function XH(e){return e==="criterion"||e==="session_metadata"}function QH(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const i of e)i.type==="tool_call"&&XH(i.toolCall.name)?n.push(i.toolCall):(r(),t.push(i));return r(),t}function JH(e,t){if(e.segments&&e.segments.length>0)return ZH(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 ZH(e,t,n,r,i){const a=[],l=new Map(t.map(d=>[d.id,d]));for(const d of e)switch(d.type){case"text":a.push({type:"text",content:d.content});break;case"thinking":d.content&&d.content.trim().length>0&&a.push({type:"thinking",content:d.content});break;case"tool_call":{const f=l.get(d.toolCallId);f&&a.push({type:"tool_call",toolCall:f});break}}for(const d of n)a.push({type:"preparing_tool_call",preparing:d});return i&&r&&a.push({type:"stats",stats:r}),a}const Qx=C.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:i=!0}){const a=xe(x=>{var _,v;return(v=(_=x.currentSession)==null?void 0:_.metadataEntries)==null?void 0:v.criteria}),l=mt(x=>x.defaults),d=mt(x=>x.userItems),f=[...l,...d],h=JH(t,n),p=r?h:h.filter(x=>x.type!=="thinking"),g=QH(p);return g.length===0?null:c.jsx("div",{className:"feed-item",children:c.jsxs("div",{className:"min-w-0",children:[g.map((x,_)=>{var v,S;switch(x.type){case"thinking":return c.jsx(NH,{content:x.content},_);case"text":return c.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:c.jsx(Ki,{content:x.content})},_);case"preparing_tool_call":return c.jsx(qH,{name:x.preparing.name,arguments:x.preparing.arguments},`preparing-${x.preparing.index}`);case"tool_call":{const w=x.toolCall,k=w.result;if(w.name==="todo_write"){const A=w.arguments.todos,P=Array.isArray(A)?A:[];return c.jsx(YH,{todos:P},_)}const j=(v=k==null?void 0:k.output)==null?void 0:v.includes("[interrupted by user]"),T=k?j?"interrupted":k.success?"success":"error":"pending";return c.jsx(FH,{tool:w.name,args:w.arguments,status:T,variant:"expandable",forceCompact:!i,result:k==null?void 0:k.output,error:k==null?void 0:k.error,durationMs:k==null?void 0:k.durationMs,diagnostics:k==null?void 0:k.diagnostics,editContext:k==null?void 0:k.editContext,startedAt:w.startedAt,streamingOutput:w.streamingOutput,metadata:k==null?void 0:k.metadata,callId:w.id},_)}case"criteria_group":return c.jsx(YN,{toolCalls:x.toolCalls,criteria:a},_);case"stats":{const w=x.stats;if(!w||"error"in w)return null;const k=((S=w.model.split("/").pop())==null?void 0:S.split("-").slice(0,2).join("-"))??w.model,j=jc(f,w.mode),T=P=>P>=1e3?`${(P/1e3).toFixed(1)}k`:P.toString(),A=P=>P>=1e3?`${(P/1e3).toFixed(1)}k`:P.toFixed(1);return c.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted mt-3",children:[c.jsx("span",{className:"flex-1 h-px bg-border"}),c.jsx("span",{className:"text-text-secondary",children:k}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsx("span",{style:{color:j},children:w.mode}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsxs("span",{children:[w.totalTime.toFixed(1),"s"]}),w.toolTime>0&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsxs("span",{children:[w.toolTime.toFixed(1),"s tools"]})]}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsxs("span",{children:[T(w.prefillTokens)," @ ",A(w.prefillSpeed)," pp"]}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsxs("span",{children:[T(w.generationTokens)," @ ",A(w.generationSpeed)," tg"]}),c.jsx("span",{className:"text-text-muted",children:"·"}),c.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const P=new CustomEvent("open-turn-stats",{detail:{stats:w}});window.dispatchEvent(P)},children:c.jsx(ZC,{className:"w-3 h-3"})}),c.jsx("span",{className:"flex-1 h-px bg-border"})]},_)}}}),t.partial&&c.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[c.jsx(Dg,{}),c.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&c.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-amber-400/80 mt-1",children:[c.jsx(Dg,{}),c.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]})})});function wh(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${i},${t})`}function eF(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 tF(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const nF=C.memo(function({data:t}){var l;const n=Nt(d=>d.defaults),r=Nt(d=>d.userItems),a=((l=[...n,...r].find(d=>d.id===t.workflowId))==null?void 0:l.color)??t.workflowColor??"#8b949e";return c.jsxs("div",{className:"feed-item rounded p-3 border",style:{borderColor:wh(a,.3),backgroundColor:wh(a,.08)},children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx(eL,{color:a}),c.jsx("span",{className:"text-sm font-medium",style:{color:a},children:t.workflowName??"Task Completed"})]}),c.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[c.jsx(lc,{label:"Iterations",value:String(t.iterations)}),c.jsx(lc,{label:"Total time",value:eF(t.totalTimeSeconds)}),c.jsx(lc,{label:"Tool calls",value:String(t.totalToolCalls)}),c.jsx(lc,{label:"Tokens",value:tF(t.totalTokensGenerated)}),c.jsx(lc,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function lc({label:e,value:t}){return c.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[c.jsx("div",{className:"text-sm text-text-muted",children:e}),c.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const rF=C.memo(function({data:t}){var l;const n=Nt(d=>d.defaults),r=Nt(d=>d.userItems),a=((l=[...n,...r].find(d=>d.id===t.workflowId))==null?void 0:l.color)??t.workflowColor??"#6b7280";return c.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:wh(a,.3),backgroundColor:wh(a,.08)},children:[c.jsx(KD,{className:"w-3 h-3 shrink-0",color:a}),c.jsx("span",{className:"text-sm font-medium",style:{color:a},children:t.workflowName}),c.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})});function iF({attachments:e,messageId:t}){const[n,r]=C.useState(null),i=xe(p=>p.visionFallbackByMessage),a=xe(p=>p.messages),l=C.useMemo(()=>{const p=a.findIndex(g=>g.id===t);if(p===-1)return null;for(let g=p+1;g<a.length;g++){const x=a[g];if(x&&x.role==="assistant")return x.id}return null},[a,t]),d=p=>{r(p)},f=()=>{r(null)},h=p=>{const g=`${t}-${p}`;if(i[g])return i[g];if(l){const x=`${l}-${p}`;return i[x]}return null};return e.length===0?null:c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const g=h(p.id);return c.jsxs("div",{className:"relative inline-block",children:[c.jsxs("button",{onClick:()=>d(p.data),className:"group relative inline-block",title:p.filename,disabled:(g==null?void 0:g.type)==="start",children:[c.jsx("img",{src:p.data,alt:p.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"&&c.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:c.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(g==null?void 0:g.type)==="done"&&g.description&&c.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?"...":""]})]},p.id)})}),n&&c.jsx(KN,{src:n,alt:"Attached image",isOpen:!0,onClose:f})]})}function sF({content:e,align:t="right",messageIndex:n,sessionId:r}){const[i,a]=C.useState(!1),[l,d]=C.useState(!1),f=C.useRef(null),h=xe(_=>_.loadSession);C.useEffect(()=>{const _=v=>{f.current&&!f.current.contains(v.target)&&a(!1)};return i&&document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[i]);const p=async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(e);else{const _=document.createElement("textarea");_.value=e,_.style.position="fixed",_.style.left="-999999px",document.body.appendChild(_),_.select(),document.execCommand("copy"),document.body.removeChild(_)}d(!0),a(!1),window.setTimeout(()=>d(!1),1500)}catch(_){console.error("Failed to copy:",_)}},g=async()=>{!r||n===void 0||(a(!1),await PA(r,n),h(r))},x=t==="right";return c.jsx(c.Fragment,{children:c.jsxs("div",{className:`flex items-start gap-1.5 ${x?"":"order-first"}`,children:[l&&c.jsx(pi,{className:"w-4 h-4 text-accent-success"}),c.jsxs("div",{ref:f,className:"relative",children:[c.jsx("button",{onClick:()=>a(!i),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary",title:"Message options",children:c.jsx(X_,{})}),i&&c.jsxs("div",{className:`absolute top-full mt-1 bg-bg-secondary border border-border rounded shadow-xl z-50 py-1 min-w-36 ${x?"right-0":"left-0"}`,children:[c.jsxs("button",{onClick:p,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:[c.jsx(Y_,{className:"w-4 h-4"}),"Copy"]}),r&&n!==void 0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"border-t border-border my-1"}),c.jsxs("button",{onClick:g,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:[c.jsx(J_,{className:"w-4 h-4"}),"Replay"]})]})]})]})]})})}function aF({message:e}){const[t,n]=C.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,i=(r==null?void 0:r.color)??"#6b7280",a=(r==null?void 0:r.name)??"Agent",l=(r==null?void 0:r.type)??"agent",f={agent:"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions"}[l]??"injected",h=l==="workflow"||l==="subagent";return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[c.jsx("span",{className:"flex-1 h-px bg-border"}),c.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:i},onClick:()=>!h&&n(!0)}),c.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:i},onClick:()=>!h&&n(!0),children:a}),c.jsx("span",{children:"·"}),c.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!h&&n(!0),children:f}),c.jsx("span",{className:"flex-1 h-px bg-border"})]}),h&&c.jsx("div",{className:"flex justify-center feed-item mb-4",children:c.jsx("div",{className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${i}`},children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:e.content})})}),c.jsx(jt,{isOpen:t,onClose:()=>n(!1),title:`${a} Prompt`,size:"lg",children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:i}}),c.jsx("span",{className:"text-sm text-text-primary font-medium",children:a}),c.jsxs("span",{className:"text-xs text-text-muted",children:["(",l,")"]})]}),c.jsx("div",{className:"h-full min-h-96",children:c.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 oF({message:e,messageIndex:t,sessionId:n}){const r=e.messageKind==="auto-prompt",i=e.messageKind==="command",a=e.isSystemGenerated;return c.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",children:[!a&&c.jsx(sF,{content:e.content,align:"right",messageIndex:t,sessionId:n}),c.jsxs("div",{className:`max-w-[75%] rounded p-2 ${a?i?"bg-teal-500/10 border border-teal-500/30":r?"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:[a&&c.jsx("span",{className:`text-[10px] block mb-0.5 ${i?"text-teal-400":r?"text-slate-400":"text-amber-400"}`,children:i?"Command":r?"Auto":"System"}),c.jsx("div",{className:`whitespace-pre-wrap text-sm ${a?`${i?"text-teal-200":r?"text-slate-200":"text-amber-200 italic"}`:""}`,children:e.content}),e.attachments&&e.attachments.length>0&&c.jsx(iF,{attachments:e.attachments,messageId:e.id})]})]})}function lF({message:e}){const t=tn(r=>r.settings[Me.LLM_DISABLE_XML_PROTECTION])!=="true",n=async()=>{await tn.getState().setSetting(Me.LLM_DISABLE_XML_PROTECTION,t?"true":"false")};return c.jsx("div",{className:"flex justify-end feed-item",children:c.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-amber-500/10 border border-amber-500/30",children:[c.jsx("span",{className:"text-[10px] block mb-0.5 text-amber-400",children:"System"}),c.jsx("div",{className:"whitespace-pre-wrap text-sm text-amber-200 italic",children:e.content}),c.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 XN=C.memo(function({message:t,isLastAssistantMessage:n=!1,messageIndex:r,sessionId:i}){const a=t.role==="user",l=t.role==="assistant",d=t.role==="system",f=t.role==="tool";if(l)return c.jsx(Qx,{message:t,showStats:n});if(d&&t.isCompacted)return c.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[c.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),c.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
302
+ `,"")})]});if(f)return c.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[c.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),c.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 h=JSON.parse(t.content);return c.jsx(rF,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return c.jsx(nF,{data:h})}catch{}return t.messageKind==="context-reset"?c.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[c.jsx("div",{className:"flex-1 border-t border-border"}),c.jsx("span",{children:t.content}),c.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?c.jsx(aF,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?c.jsx(lF,{message:t}):a?c.jsx(oF,{message:t,messageIndex:r,sessionId:i}):c.jsx("div",{className:"flex justify-start feed-item",children:c.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:c.jsx(Ki,{content:t.content})})})}),QN=(e,t)=>{const n=C.useRef(!0),r=C.useRef(null),[i,a]=C.useState(!0),l=()=>{const d=e.current;d&&(d.scrollTop=d.scrollHeight)};return C.useEffect(()=>{const d=e.current;if(!d)return;const f=_=>{if(_.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(()=>{d.scrollHeight-d.scrollTop-d.offsetHeight<100&&(n.current=!0,a(!0))}));return}n.current=!1,a(!1)},h=_=>{_.touches[0]&&(r.current=_.touches[0].clientY)},p=_=>{if(r.current===null)return;const v=_.touches[0];if(!v)return;if(v.clientY-r.current>0){n.current=!1,a(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>{d.scrollHeight-d.scrollTop-d.offsetHeight<100&&(n.current=!0,a(!0))}))},g=new MutationObserver(()=>{n.current&&requestAnimationFrame(l)}),x=setInterval(()=>{n.current&&l()},1e3);return d.addEventListener("wheel",f,{passive:!0}),d.addEventListener("touchstart",h,{passive:!0}),d.addEventListener("touchmove",p,{passive:!0}),g.observe(d,{childList:!0,subtree:!0,characterData:!0}),()=>{d.removeEventListener("wheel",f),d.removeEventListener("touchstart",h),d.removeEventListener("touchmove",p),g.disconnect(),clearInterval(x)}},[t==null?void 0:t.id]),{force_scroll_to_bottom:()=>{n.current=!0,a(!0),l()},isAutoScrollActive:i,setAutoScroll:d=>{n.current=d,a(d),d&&l()}}},cF={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function uF(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function xC(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function dF({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:i}=e,a=Math.round(t/n*100);return c.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[c.jsxs("span",{className:xC(a,i),children:[rh(t),"/",rh(n)]}),c.jsxs("span",{className:xC(a,i),children:["(",a,"%)"]}),c.jsx(y2,{percent:a,dangerZone:i,size:"sm"}),i&&c.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&c.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const hF=C.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:i}){const a=C.useRef(null),l=C.useRef(null),[d,f]=C.useState(!1),h=mt(q=>q.defaults),p=mt(q=>q.userItems),g=[...h,...p],x=xe(q=>q.subAgentContextStates[r]),{showThinking:_,showVerboseToolOutput:v}=Eh(),{isAutoScrollActive:S,setAutoScroll:w}=QN(l,null);C.useEffect(()=>{i||w(!0)},[i]);const k=C.useCallback(()=>{const q=!d;f(q),q&&setTimeout(()=>{var Z;(Z=a.current)==null||Z.scrollIntoView({block:"start",behavior:"smooth"})},220)},[d]),j=g.find(q=>q.id===n),T=(j==null?void 0:j.name)??cF[n]??n,A=jc(g,n),P=uF(A),M=t.filter(q=>q.role!=="tool");return c.jsxs("div",{ref:a,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[c.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:P,children:[c.jsx("span",{className:"text-xs font-medium",children:T}),c.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:x&&c.jsx(dF,{contextState:x})}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>w(!S),children:[c.jsx("span",{className:`w-1 h-1 rounded-full ${S?"bg-accent-success":"border border-text-muted"}`}),"live"]}),c.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:k,children:[d?"▼":"▶"," Expand"]})]})]}),c.jsx("div",{ref:l,className:`${d?"max-h-[calc(100vh-10rem)]":"max-h-80"} overflow-y-auto p-2 transition-[max-height] duration-200`,children:M.map(q=>q.role==="assistant"?c.jsx(Qx,{message:q,showStats:!0,showThinking:_,showVerboseToolOutput:v},q.id):c.jsx(XN,{message:q,isLastAssistantMessage:!1},q.id))})]})});function JN(e,t,n=!0){C.useEffect(()=>{if(!n)return;const r=i=>{var a;(a=e.current)!=null&&a.contains(i.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const fF=[],mF=C.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r}){const i=xe(J=>{var L,G;return((G=(L=J.currentSession)==null?void 0:L.metadataEntries)==null?void 0:G.criteria)??fF}),a=xe(J=>{var L;return(L=J.currentSession)==null?void 0:L.id}),l=xe(J=>{var L;return(L=J.currentSession)==null?void 0:L.mode}),d=xe(J=>{var L;return(L=J.currentSession)==null?void 0:L.phase}),f=xe(J=>J.error),h=xe(J=>J.clearError),p=xe(J=>J.acceptAndBuild),g=Th(),{showThinking:x,showVerboseToolOutput:_,showStats:v,showAgentDefinitions:S,showWorkflowBars:w}=Eh(),k=Nt(J=>J.defaults),j=Nt(J=>J.userItems),T=[...k,...j],A=l==="planner",P=i.length>0,M=d==="done",q=t.some(J=>J.type==="message"&&J.message.role==="assistant"),Z=A&&P&&!g&&q&&!M;return c.jsxs("div",{ref:n,"data-testid":"chat-scroll-container",className:"flex-1 min-w-0 overflow-y-auto relative bg-primary",children:[c.jsx("div",{className:"pt-4",children:t.map((J,L)=>{if(J.type==="context-divider")return c.jsxs("div",{"data-item-index":L,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[c.jsx("div",{className:"flex-1 border-t border-border"}),c.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),c.jsx("div",{className:"flex-1 border-t border-border"})]},L);if(J.type==="subagent"){const U=J.messages.some(D=>D.isStreaming);return c.jsx("div",{"data-item-index":L,className:"px-2 md:px-4",children:c.jsx(hF,{messages:J.messages,subAgentType:J.subAgentType,subAgentId:J.subAgentId,isStreaming:U})},L)}if(J.type==="criteria-batch")return c.jsx("div",{"data-item-index":L,className:"feed-item px-2 md:px-4",children:c.jsx(YN,{toolCalls:J.toolCalls,criteria:i})},L);const G=J.message;if(G.role==="assistant")return c.jsx("div",{"data-item-index":L,className:"px-2 md:px-4",children:c.jsx(Qx,{message:G,showStats:v,showThinking:x,showVerboseToolOutput:_})},L);const H=!S&&G.messageKind==="auto-prompt",R=!w&&(G.messageKind==="workflow-started"||G.messageKind==="task-completed");return H||R?null:c.jsx("div",{"data-item-index":L,className:"px-2 md:px-4",children:c.jsx("div",{"data-message-id":G.id,className:r===G.id?"rounded animate-highlight-fade":void 0,children:c.jsx(XN,{message:G,messageIndex:L,sessionId:a,isLastAssistantMessage:!1})})},L)})}),c.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[f&&c.jsx("div",{className:"feed-item bg-red-500/10 border border-red-500/50 rounded p-2",children:c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-red-400 text-sm font-medium",children:f.code}),c.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:f.message})]}),c.jsx(Wc,{onClick:h,className:"text-red-400 hover:text-red-300 p-0.5",size:"sm"})]})}),Z&&c.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:T.map(J=>{const L=J.color??"#3b82f6",G=parseInt(L.slice(1,3),16),H=parseInt(L.slice(3,5),16),R=parseInt(L.slice(5,7),16),U=`rgba(${G},${H},${R},0.12)`,D=`rgba(${G},${H},${R},0.22)`,N=`rgba(${G},${H},${R},0.25)`;return c.jsx(pF,{workflowName:J.name,color:L,bg:U,bgHover:D,border:N,subGroups:J.subGroups,onLaunch:F=>p(J.id,void 0,void 0,F)},J.id)})})]})]})});function pF({workflowName:e,color:t,bg:n,bgHover:r,border:i,subGroups:a,onLaunch:l}){const[d,f]=C.useState(!1),h=C.useRef(null);return JN(h,()=>f(!1),d),c.jsxs("div",{className:"relative flex",children:[c.jsxs("button",{onClick:()=>l(),"data-testid":"workflow-run-button",className:"px-4 py-1.5 rounded-l text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${i}`,borderRight:"none"},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=r},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),a&&a.length>0&&c.jsxs("div",{ref:h,className:"relative",children:[c.jsx("button",{onClick:()=>f(!d),className:"px-1.5 py-1.5 rounded-r text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${i}`},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=r},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:"⋮"}),d&&c.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[c.jsx("button",{onClick:()=>{l(),f(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),c.jsx("div",{className:"border-t border-border/50"}),a.map(p=>c.jsx("button",{onClick:()=>{l(p),f(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:p},p))]})]})]})}function gF({question:e}){const t=xe(l=>l.answerQuestion),[n,r]=C.useState(""),i=()=>{t(e.callId,n)},a=l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),i())};return c.jsx(jt,{isOpen:!0,onClose:()=>{},size:"sm",closeOnBackdropClick:!1,closeOnEscape:!1,showCloseButton:!1,children:c.jsxs("div",{className:"space-y-4",children:[c.jsx("p",{className:"text-sm text-text-primary",children:e.question}),c.jsx("textarea",{value:n,onChange:l=>r(l.target.value),onKeyDown:a,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}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{variant:"secondary",size:"sm",onClick:()=>t(e.callId,""),children:"Skip"}),c.jsx(Ze,{variant:"primary",size:"sm",onClick:i,children:"Send Answer"})]})]})})}function _F(){const e=xe(r=>r.connectionStatus),t=xe(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return c.jsxs("div",{className:`
303
+ flex items-center justify-between px-4 py-2
304
+ text-sm font-medium
305
+ ${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"}
306
+ `,children:[c.jsx("div",{className:"flex items-center gap-2",children:n?c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"flex gap-1",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),c.jsx("span",{children:"Reconnecting to server..."})]}):c.jsxs(c.Fragment,{children:[c.jsx(nL,{}),c.jsx("span",{children:"Connection lost"})]})}),c.jsx("button",{onClick:()=>t(),disabled:n,className:`
307
+ px-3 py-1 rounded text-xs font-medium
308
+ transition-colors
309
+ ${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"}
310
+ `,children:n?"Reconnecting...":"Reconnect"})]})}const mn=xr((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await nx("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await Ne(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await Ne(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const i=await zs("POST","/api/commands",{...n,destination:r});return i.success&&await t().fetchCommands(),i},updateCommand:async(n,r)=>{const i=await zs("PUT",`/api/commands/${n}`,r);return i.success&&await t().fetchCommands(),i},deleteCommand:async n=>{try{const r=await Ne(`/api/commands/${n}`,{method:"DELETE"}),i=await r.json();return r.ok?(e(a=>({userItems:a.userItems.filter(l=>l.id!==n)})),{success:!0}):{success:!1,error:i.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r)=>jh(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)}));function xF(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function yF({onClick:e}){return c.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:c.jsx(Yd,{})})}function ZN({isOpen:e,onClose:t,initialEditId:n}){const r=mn(ue=>ue.defaults),i=mn(ue=>ue.userItems),a=mn(ue=>ue.projectItems),l=mn(ue=>ue.loading),d=mn(ue=>ue.fetchCommands),f=mn(ue=>ue.fetchCommand),h=mn(ue=>ue.fetchDefaultContent),p=mn(ue=>ue.createCommand),g=mn(ue=>ue.updateCommand),x=mn(ue=>ue.deleteCommand),[_,v]=C.useState(null),[S,w]=C.useState(null),{view:k,editingId:j,formError:T,saving:A,formData:P,setView:M,setEditingId:q,setFormError:Z,setFormData:J,setSaving:L}=fk(),{requestDelete:G,clearConfirm:H,isConfirming:R}=rx(),U=C.useRef(!1),D=mt(ue=>ue.defaults),N=mt(ue=>ue.userItems),F=mt(ue=>ue.fetchAgents),se=[...D,...N].filter(ue=>!ue.subagent),B=C.useRef(d),V=C.useRef(F),K=C.useRef(f),I=C.useRef(h),Q=C.useRef(n),W=C.useRef(M),ee=C.useRef(q),ne=C.useRef(Z),Se=C.useRef(H);C.useEffect(()=>{B.current=d,V.current=F,K.current=f,I.current=h,Q.current=n,W.current=M,ee.current=q,ne.current=Z,Se.current=H}),C.useEffect(()=>{if(e)if(B.current(),V.current(),U.current||(Se.current(),U.current=!0),Q.current){const ue=r.some(Ee=>Ee.id===Q.current);W.current("edit"),ee.current(Q.current),ne.current(""),ue?I.current(Q.current).then(Ee=>{Ee&&J({name:Ee.metadata.name+" (copy)",id:`${Q.current}-copy-${Date.now()}`,prompt:Ee.prompt,agentMode:Ee.metadata.agentMode??"",isDefault:!0,destination:"user"})}):K.current(Q.current).then(Ee=>{Ee&&J({name:Ee.metadata.name,id:Ee.metadata.id,prompt:Ee.prompt,agentMode:Ee.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else W.current("list"),ee.current(null);else U.current=!1},[e]);const le=async ue=>{v(ue);const Ee=await h(ue);w((Ee==null?void 0:Ee.prompt)??null)},Ce=async ue=>{if(r.some(_t=>_t.id===ue)){const _t=await h(ue);_t&&(q(null),J({name:`${_t.metadata.name} (copy)`,id:`${ue}-copy-${Date.now()}`,prompt:_t.prompt,agentMode:_t.metadata.agentMode??"",isDefault:!0,destination:"user"}),Z(""),M("edit"))}else{const _t=await f(ue);_t&&(q(null),J({name:`${_t.metadata.name} (copy)`,id:`${ue}-copy-${Date.now()}`,prompt:_t.prompt,agentMode:_t.metadata.agentMode??"",isDefault:!1,destination:"user"}),Z(""),M("edit"))}},Re=()=>{J({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),q(null),M("edit")},Oe=async ue=>{const Ee=await f(ue);Ee&&(q(ue),J({name:Ee.metadata.name,id:Ee.metadata.id,prompt:Ee.prompt,agentMode:Ee.metadata.agentMode??"",isDefault:!1,destination:"user"}),Z(""),M("edit"))},De=async ue=>{await x(ue),H()},Ue=async()=>{const ue=j??P.id;if(!ue||!P.name||!P.prompt){Z("Name and message are required.");return}L(!0),Z("");const Ee={metadata:{id:ue,name:P.name,...P.agentMode?{agentMode:P.agentMode}:{}},prompt:P.prompt},_t=j?await g(j,Ee):await p(Ee,P.destination);if(L(!1),!_t.success){Z(_t.error??"Failed to save command.");return}n?t():M("list")},it=()=>{n?t():(M("list"),v(null),w(null))},st=ue=>{J(Ee=>({...Ee,name:ue})),(!j||P.isDefault)&&J(Ee=>({...Ee,id:xF(ue)}))},ye=()=>{v(null),w(null),M("list")},ze=()=>{_&&(v(null),M("edit"),q(_),h(_).then(ue=>{ue&&J({name:`${ue.metadata.name} (copy)`,id:`${_}-copy-${Date.now()}`,prompt:ue.prompt,agentMode:ue.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(_){const ue=r.find(Ee=>Ee.id===_);return c.jsx(jt,{isOpen:e,onClose:ye,title:`Default: ${(ue==null?void 0:ue.name)??_}`,size:"xl",children:c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"space-y-3 mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[c.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),c.jsx("span",{className:"font-mono",children:_})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),c.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:ue==null?void 0:ue.name})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),c.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(ue==null?void 0:ue.agentMode)||"None"})]})]}),c.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),c.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"})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[c.jsx(Ze,{variant:"secondary",onClick:ye,children:"Close"}),c.jsx(Ze,{variant:"primary",onClick:ze,children:"Duplicate & Customize"})]})]})})}if(k==="edit")return c.jsx(jt,{isOpen:e,onClose:it,title:j?"Edit Command":"New Command",size:"xl",children:c.jsxs("div",{className:"flex flex-col h-full",children:[T&&c.jsx(ax,{message:T}),c.jsxs("div",{className:"space-y-3 mb-3",children:[c.jsx(hk,{name:P.name,id:P.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!j&&!P.isDefault,onNameChange:st,onIdChange:ue=>J(Ee=>({...Ee,id:ue}))}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",c.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),c.jsxs("select",{value:P.agentMode,onChange:ue=>J(Ee=>({...Ee,agentMode:ue.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:[c.jsx("option",{value:"",children:"None (keep current mode)"}),se.map(ue=>c.jsx("option",{value:ue.id,children:ue.name},ue.id))]})]}),!j&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),c.jsxs("select",{value:P.destination,onChange:ue=>J(Ee=>({...Ee,destination:ue.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:[c.jsx("option",{value:"user",children:"Global config"}),c.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})]}),c.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),c.jsx("textarea",{value:P.prompt,onChange:ue=>J(Ee=>({...Ee,prompt:ue.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"})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[c.jsx(Ze,{variant:"secondary",onClick:it,children:"Cancel"}),c.jsx(Ze,{variant:"primary",onClick:Ue,disabled:A||!P.name||!P.prompt,children:A?"Saving...":"Save"})]})]})});const ve=ue=>ue.map(Ee=>c.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[c.jsx("div",{className:"min-w-0 flex-1 mr-3",children:c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("span",{className:"text-text-primary text-sm font-medium",children:Ee.name})})}),c.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c.jsx(Os,{onClick:()=>Oe(Ee.id)}),c.jsx(Xd,{onClick:()=>Ce(Ee.id)}),R(Ee.id,"delete")?c.jsx(ix,{onConfirm:()=>De(Ee.id),onCancel:H}):c.jsx(sx,{onClick:()=>G(Ee.id)})]})]},Ee.id));return c.jsxs(jt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[c.jsx(ck,{description:"Commands are pre-defined messages you can send with a single click.",onNew:Re}),c.jsxs(dk,{loading:l,hasItems:r.length>0||i.length>0||a.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),c.jsx("div",{className:"space-y-2",children:r.map(ue=>c.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[c.jsx("div",{className:"min-w-0 flex-1 mr-3",children:c.jsx("span",{className:"text-text-primary text-sm font-medium",children:ue.name})}),c.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c.jsx(yF,{onClick:()=>le(ue.id)}),c.jsx(Xd,{onClick:()=>Ce(ue.id)})]})]},ue.id))})]}),i.length>0&&c.jsx(lk,{children:ve(i)}),a.length>0&&c.jsxs("div",{className:"mt-4",children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),c.jsx("div",{className:"space-y-2",children:ve(a)})]})]})]})}const ua=150,Hi=54,Id=80,Vr=30,Lo=70,yC=100,da=50,Pd=50,vC=4,ej={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},tj=[{value:"step_result",label:"Step result is..."},{value:"metadata_all_match",label:"Metadata all match (key=value)"},{value:"metadata_all_in",label:"Metadata all in list"},{value:"always",label:"Always (fallback)"}],vF=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}];function Jx(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 bF(e,t,n,r){const i=Pd+da+ua+yC+ua+da+Pd,a=i/2,l=Pd+da+ua/2,d=Pd+da+ua+yC+ua/2,f=[],h=[],p=new Map,g=e.filter(D=>D.type==="agent"||D.type==="shell"),x=e.filter(D=>D.type==="sub_agent"),_=x.length>0,v=_?l:a,S=g.length>0?d:a,w=da+Vr/2;f.push({id:"$start",type:"terminal",label:"Start",cx:v,cy:w,w:Id,h:Vr}),p.set("$start",{cx:v,cy:w,w:Id,h:Vr});const k=D=>{f.push({id:"$done",type:"terminal",label:"Done",cx:v,cy:D,w:Id,h:Vr}),p.set("$done",{cx:v,cy:D,w:Id,h:Vr})};if(e.length===0){const D=w+Vr/2+Lo*2+Vr/2;return k(D),{nodes:f,edges:h,width:i,height:D+Vr/2+da,posMap:p}}const j=w+Vr/2+Lo,T=(D,N)=>{D.forEach((F,$)=>{const se=j+$*(Hi+Lo)+Hi/2,{name:B,color:V}=Jx(F,r);f.push({id:F.id,type:"step",label:B,color:V,cx:N,cy:se,w:ua,h:Hi}),p.set(F.id,{cx:N,cy:se,w:ua,h:Hi})})};T(g,v),T(x,S);const A=g.length>0?j+(g.length-1)*(Hi+Lo)+Hi/2:w,P=_?j+(x.length-1)*(Hi+Lo)+Hi/2:w,M=Math.max(A,P)+Hi/2+Lo+Vr/2;k(M);const q=[];t&&p.has(t)&&q.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let Z=0;for(const D of e)D.transitions.forEach((N,F)=>{var I;if(!N.goto||!p.has(N.goto))return;const $=p.get(D.id),se=p.get(N.goto),B=N.when.type==="step_result"?`${N.when.result}`:N.when.type==="metadata_all_match"?`${N.when.key??"?"}=${N.when.value??"?"}`:N.when.type==="metadata_all_in"?`${N.when.key??"?"} in [${((I=N.when.values)==null?void 0:I.join(","))??"?"}]`:ej[N.when.type]??N.when.type,V=D.id===N.goto;let K;V?K="back":se.cy>$.cy+1?K="down":se.cy<$.cy-1?K="back":K="same",q.push({from:D.id,to:N.goto,label:B,edgeKey:`${D.id}:${F}`,direction:K,backEdgeIndex:K==="back"?Z++:0})});const J=new Map,L=new Map,G=new Map,H=new Map;for(const D of q)D.direction==="down"&&(J.set(D.from,(J.get(D.from)??0)+1),L.set(D.to,(L.get(D.to)??0)+1));const R=new Map,U=new Map;for(const D of q){if(D.direction!=="same")continue;const N=[D.from,D.to].sort().join("|");R.set(N,(R.get(N)??0)+1)}for(const D of q){if(D.direction==="back"||D.direction==="same"){let K=0;if(D.direction==="same"){const I=[D.from,D.to].sort().join("|");K=U.get(I)??0,U.set(I,K+1)}h.push({...D,fromPort:0,toPort:0,sameEdgeIndex:K});continue}const N=J.get(D.from)??1,F=L.get(D.to)??1,$=G.get(D.from)??0,se=H.get(D.to)??0;G.set(D.from,$+1),H.set(D.to,se+1);const B=N===1?0:-.6+1.2*$/(N-1),V=F===1?0:-.6+1.2*se/(F-1);h.push({...D,fromPort:B,toPort:V,sameEdgeIndex:0})}return{nodes:f,edges:h,width:i,height:M+Vr/2+da,posMap:p}}function SF({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:i,agentTypes:a,isReadOnly:l,onSelectNode:d,onSelectEdge:f,onRemoveStep:h,onCreateTransition:p,onReconnectTo:g,onReconnectFrom:x,onDeleteTransition:_}){const v=C.useRef(null),S=C.useRef(!1),[w,k]=C.useState(null),[j,T]=C.useState(null),[A,P]=C.useState(null),{nodes:M,edges:q,width:Z,height:J,posMap:L}=C.useMemo(()=>bF(e,t,i,a),[e,t,i,a]),G=C.useCallback(W=>{var Ce;const ee=v.current;if(!ee)return{x:0,y:0};const ne=ee.createSVGPoint();ne.x=W.clientX,ne.y=W.clientY;const Se=(Ce=ee.getScreenCTM())==null?void 0:Ce.inverse();if(!Se)return{x:0,y:0};const le=ne.matrixTransform(Se);return{x:le.x,y:le.y}},[]),H=C.useCallback(W=>!W||!j||W==="$start"?!1:j.type==="reconnect-from"?W!=="$done":!0,[j]),R=C.useCallback((W,ee)=>{if(l)return;W.stopPropagation(),W.preventDefault();const ne=G(W);T({type:"new",fromNodeId:ee,mouseX:ne.x,mouseY:ne.y})},[G,l]),U=C.useCallback((W,ee)=>{if(l)return;W.stopPropagation(),W.preventDefault();const ne=G(W);T({type:"reconnect-to",fromNodeId:ee.from,edgeKey:ee.edgeKey,mouseX:ne.x,mouseY:ne.y})},[G,l]),D=C.useCallback((W,ee)=>{if(l)return;W.stopPropagation(),W.preventDefault();const ne=G(W);T({type:"reconnect-from",fromNodeId:ee.from,fixedTargetId:ee.to,edgeKey:ee.edgeKey,mouseX:ne.x,mouseY:ne.y})},[G,l]),N=C.useCallback(W=>{if(!j)return;const ee=G(W);T(ne=>ne?{...ne,mouseX:ee.x,mouseY:ee.y}:null)},[j,G]),F=C.useCallback(()=>{j&&(S.current=!0,A&&H(A)&&(j.type==="new"?p(j.fromNodeId,A):j.type==="reconnect-to"?g(j.edgeKey,A):j.type==="reconnect-from"&&x(j.edgeKey,A)),T(null),P(null))},[j,A,H,p,g,x]),$=C.useCallback(()=>{if(S.current){S.current=!1;return}d(null),f(null)},[d,f]);C.useEffect(()=>{if(l)return;const W=ee=>{ee.target instanceof HTMLInputElement||ee.target instanceof HTMLTextAreaElement||ee.target instanceof HTMLSelectElement||(ee.key==="Delete"||ee.key==="Backspace")&&r&&r!=="start"&&(ee.preventDefault(),_(r),f(null))};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[l,r,_,f]);const se=W=>{const ee=L.get(W.from),ne=L.get(W.to);if(!ee||!ne)return null;let Se,le,Ce,Re="middle",Oe,De;if(W.direction==="down"){const Ue=ee.cx+W.fromPort*(ee.w/2-10),it=ee.cy+ee.h/2,st=ne.cx+W.toPort*(ne.w/2-10),ye=ne.cy-ne.h/2,ze=ye-it,ve=st-Ue;Se=`M ${Ue} ${it} C ${Ue} ${it+ze*.4}, ${st-ve*.2} ${ye-ze*.1}, ${st} ${ye}`,le=Ue+(st-Ue)*.5,Ce=it+ze*.6,Oe={x:Ue,y:it},De={x:st,y:ye}}else if(W.direction==="back"){const Ue=W.from===W.to,it=ee.cx>=Z/2,st=W.backEdgeIndex*16,ye=it?Z-20-st:20+st;if(Ue){const ze=ee.cx>=Z/2,ve=30+W.backEdgeIndex*14,ue=ee.cy-ee.h/2,Ee=ze?ee.cx+ee.w/2:ee.cx-ee.w/2,_t=ze?Ee+ve:Ee-ve,Ji=ee.cx+(ze?ee.w/4:-ee.w/4),Yt=ue-20-W.backEdgeIndex*10;Se=`M ${Ee} ${ee.cy} C ${_t} ${ee.cy}, ${_t} ${Yt}, ${Ji} ${ue}`,le=_t+10,Ce=Yt+4,Re="middle",Oe={x:Ee,y:ee.cy},De={x:Ji,y:ue}}else{const ze=it?ee.cx+ee.w/2:ee.cx-ee.w/2,ve=ne.cx+(it?ne.w/4:-ne.w/4),ue=Math.min(ee.cy,ne.cy)-ne.h/2-18-W.backEdgeIndex*14;Se=`M ${ze} ${ee.cy} L ${ye} ${ee.cy} L ${ye} ${ue} L ${ve} ${ue} L ${ve} ${ne.cy-ne.h/2}`,le=ye,Ce=(ee.cy+ue)/2,Re=it?"start":"end",Oe={x:ze,y:ee.cy},De={x:ve,y:ne.cy-ne.h/2}}}else{const Ue=ne.cx>ee.cx,it=W.sameEdgeIndex===0?-12:12,st=Ue?ee.cx+ee.w/2:ee.cx-ee.w/2,ye=Ue?ne.cx-ne.w/2:ne.cx+ne.w/2,ze=ee.cy+it,ve=ne.cy+it,ue=(st+ye)/2;Se=`M ${st} ${ze} C ${ue} ${ze}, ${ue} ${ve}, ${ye} ${ve}`,le=ue,Ce=(ze+ve)/2-6,Oe={x:st,y:ze},De={x:ye,y:ve}}return{path:Se,labelX:le,labelY:Ce,labelAnchor:Re,fromPt:Oe,toPt:De}},B=(W,ee)=>{const ne=se(W);if(!ne)return null;const{path:Se,labelX:le,labelY:Ce,labelAnchor:Re}=ne,Oe=r===W.edgeKey,De=W.label&&W.label!=="otherwise";return c.jsxs("g",{children:[c.jsx("path",{d:Se,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Ue=>{Ue.stopPropagation(),l||f(Oe?null:W.edgeKey)}}),c.jsx("path",{d:Se,fill:"none",stroke:Oe?"#58a6ff":"#484f58",strokeWidth:Oe?2.2:1.2,markerEnd:Oe?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),De&&c.jsx("text",{x:le+(Re==="start"?5:Re==="end"?-5:0),y:Ce+3,textAnchor:Re,className:"text-[8px]",fill:Oe?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:W.label})]},ee)},V=()=>{if(!r||j)return null;const W=q.find(Ce=>Ce.edgeKey===r);if(!W)return null;const ee=se(W);if(!ee)return null;const{fromPt:ne,toPt:Se}=ee,le=6;return c.jsxs(c.Fragment,{children:[W.edgeKey!=="start"&&c.jsx("circle",{cx:ne.x,cy:ne.y,r:le,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:Ce=>D(Ce,W)}),c.jsx("circle",{cx:Se.x,cy:Se.y,r:le,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:Ce=>U(Ce,W)})]})},K=()=>{if(!j)return null;let W,ee,ne,Se;if(j.type==="reconnect-from"){const Re=L.get(j.fixedTargetId);if(!Re)return null;W=j.mouseX,ee=j.mouseY,ne=Re.cx,Se=Re.cy-Re.h/2}else{const Re=L.get(j.fromNodeId);if(!Re)return null;W=Re.cx,ee=Re.cy+Re.h/2,ne=j.mouseX,Se=j.mouseY}const le=Se-ee,Ce=Math.abs(le)>10?`M ${W} ${ee} C ${W} ${ee+le*.4}, ${ne} ${Se-le*.4}, ${ne} ${Se}`:`M ${W} ${ee} L ${ne} ${Se}`;return c.jsx("path",{d:Ce,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},I=W=>{const ee=W.cy+W.h/2,ne=(j==null?void 0:j.fromNodeId)===W.id;return c.jsx("circle",{cx:W.cx,cy:ee,r:vC,fill:ne?"#58a6ff":"#1c2128",stroke:ne?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:ne?1:.5,className:"cursor-crosshair",onMouseDown:Se=>R(Se,W.id)})},Q=W=>{const ee=W.cy-W.h/2,ne=j&&A===W.id&&H(W.id);return c.jsx("circle",{cx:W.cx,cy:ee,r:vC,fill:ne?"#3fb950":"#1c2128",stroke:ne?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:ne?1:.5})};return c.jsxs("svg",{ref:v,viewBox:`0 0 ${Z} ${J}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:N,onMouseUp:F,onClick:$,children:[c.jsxs("defs",{children:[c.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:c.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),c.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:c.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),q.map((W,ee)=>B(W,ee)),M.map(W=>{const ee=n===W.id,ne=W.cx-W.w/2,Se=W.cy-W.h/2,le=w===W.id,Ce=j&&A===W.id&&H(W.id);if(W.type==="terminal"){const Oe=W.id==="$start",De=Oe?"#58a6ff":"#3fb950",Ue=Oe,it=!Oe;return c.jsxs("g",{onClick:st=>{st.stopPropagation(),Oe&&!l&&f("start")},className:Oe&&!l?"cursor-pointer":void 0,children:[Ce&&c.jsx("rect",{x:ne-3,y:Se-3,width:W.w+6,height:W.h+6,rx:W.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),Oe&&r==="start"&&c.jsx("rect",{x:ne-3,y:Se-3,width:W.w+6,height:W.h+6,rx:W.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),c.jsx("rect",{x:ne,y:Se,width:W.w,height:W.h,rx:W.h/2,fill:De,fillOpacity:.08,stroke:De,strokeOpacity:.4,strokeWidth:1.5}),c.jsx("text",{x:W.cx,y:W.cy+4,textAnchor:"middle",fill:De,className:"text-[10px] font-medium",pointerEvents:"none",children:W.label}),Ue&&I(W),it&&Q(W)]},W.id)}const Re=W.color??"#6b7280";return c.jsxs("g",{onClick:Oe=>{Oe.stopPropagation(),l||d(ee?null:W.id)},onMouseEnter:()=>k(W.id),onMouseLeave:()=>k(null),className:l?void 0:"cursor-pointer",children:[Ce&&c.jsx("rect",{x:ne-3,y:Se-3,width:W.w+6,height:W.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ee&&c.jsx("rect",{x:ne-3,y:Se-3,width:W.w+6,height:W.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),c.jsx("rect",{x:ne,y:Se,width:W.w,height:W.h,rx:10,fill:Re,fillOpacity:.08,stroke:Re,strokeOpacity:.6,strokeWidth:ee?2:1.5}),c.jsx("text",{x:W.cx,y:W.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:W.label}),!l&&I(W),!l&&Q(W),le&&!j&&!l&&c.jsxs("g",{onClick:Oe=>{Oe.stopPropagation(),h(W.id)},className:"cursor-pointer",children:[c.jsx("circle",{cx:ne+W.w-2,cy:Se+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),c.jsx("line",{x1:ne+W.w-5,y1:Se-1,x2:ne+W.w+1,y2:Se+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),c.jsx("line",{x1:ne+W.w+1,y1:Se-1,x2:ne+W.w-5,y2:Se+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},W.id)}),j&&M.map(W=>H(W.id)?c.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:()=>P(W.id),onMouseLeave:()=>P(null),onMouseUp:ee=>{ee.stopPropagation(),F()}},`drop-${W.id}`):null),K(),V()]})}function wF({name:e,id:t,color:n,description:r,isBuiltIn:i,actions:a}){return c.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),c.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),c.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),i&&c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&c.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),c.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:a})]})}function bC({title:e,items:t,renderActions:n}){return t.length===0?null:c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),c.jsx("div",{className:"space-y-2",children:t.map(r=>c.jsx(wF,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const Ro="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",wg="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",Fi="block text-[11px] text-text-secondary mb-0.5";function Cg({variables:e,onInsert:t}){return e.length===0?null:c.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>c.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 CF({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:i,onUpdate:a,onRemove:l,onSetEntry:d}){const{color:f,name:h}=Jx(e,n);return c.jsxs("div",{className:"space-y-3 text-sm",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:f+"20",color:f},children:h}),t&&c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[!t&&c.jsx("button",{onClick:d,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),c.jsx("button",{onClick:l,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Type"}),c.jsx("select",{value:e.type,onChange:p=>{const g=p.target.value,x=g==="sub_agent"?"verification":"build";if(g==="agent"){const _=n.find(v=>!v.subagent);a({...e,type:g,phase:x,toolMode:(_==null?void 0:_.id)??"builder",name:(_==null?void 0:_.name)??"Agent"})}else if(g==="sub_agent"){const _=n.find(v=>v.subagent);a({...e,type:g,phase:x,subAgentType:(_==null?void 0:_.id)??"",name:(_==null?void 0:_.name)??"Sub-Agent"})}else a({...e,type:g,phase:x,name:"Shell"})},className:wg,children:vF.map(p=>c.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Agent Type"}),c.jsx("select",{value:e.toolMode??"builder",onChange:p=>{const g=n.find(x=>x.id===p.target.value);a({...e,toolMode:p.target.value,name:(g==null?void 0:g.name)??p.target.value})},className:wg,children:n.filter(p=>!p.subagent).map(p=>c.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Sub-Agent Type"}),c.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const g=n.find(x=>x.id===p.target.value);a({...e,subAgentType:p.target.value,name:(g==null?void 0:g.name)??p.target.value})},className:wg,children:[c.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>c.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Prompt"}),c.jsx("textarea",{value:e.prompt??"",onChange:p=>a({...e,prompt:p.target.value||void 0}),rows:6,className:`${Ro} resize-y text-xs`,placeholder:"Injected on first entry..."}),c.jsx(Cg,{variables:i,onInsert:p=>a({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Nudge Prompt"}),c.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>a({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${Ro} resize-y text-xs`,placeholder:"Injected on re-entry..."}),c.jsx(Cg,{variables:i,onInsert:p=>a({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Command"}),c.jsx("textarea",{value:e.command??"",onChange:p=>a({...e,command:p.target.value}),rows:3,className:`${Ro} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),c.jsx(Cg,{variables:i,onInsert:p=>a({...e,command:(e.command??"")+`{{${p}}}`})})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Timeout (ms)"}),c.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>a({...e,timeout:Number(p.target.value)}),className:`${Ro} font-mono text-xs`})]}),c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Success Codes"}),c.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>a({...e,successExitCodes:p.target.value.split(",").map(g=>Number(g.trim())).filter(g=>!isNaN(g))}),className:`${Ro} font-mono text-xs`})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:Fi,children:"Sub-group"}),c.jsx("input",{value:e.subGroup??"",onChange:p=>a({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Ro})]}),c.jsx("div",{className:"pt-1 border-t border-border/50",children:c.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Mo="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",SC="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",ha="block text-[11px] text-text-secondary mb-0.5";function kF({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:i,agentTypes:a,transitionIndex:l,totalTransitions:d,onUpdateCondition:f,onUpdateSubGroup:h,onDelete:p,onMoveUp:g,onMoveDown:x}){var S;const _=i&&(i.type==="sub_agent"||i.type==="agent")?a.find(w=>w.id===(i.type==="sub_agent"?i.subAgentType:i.toolMode)):void 0,v=(_==null?void 0:_.results)&&_.results.length>0;return c.jsxs("div",{className:"space-y-3 text-sm",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",l+1]}),d>1&&c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx("button",{onClick:g,disabled:l===0,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up (higher priority)",children:c.jsx(gi,{className:"w-3 h-3",rotate:180})}),c.jsx("button",{onClick:x,disabled:l===d-1,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down (lower priority)",children:c.jsx(gi,{className:"w-3 h-3"})})]})]}),c.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[c.jsx("span",{className:"font-medium text-text-primary",children:e}),c.jsx(JC,{}),c.jsx("span",{className:"font-medium text-text-primary",children:t})]}),c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Condition"}),c.jsx("select",{value:n.type,onChange:w=>{f(w.target.value==="step_result"?{type:"step_result",result:"success"}:{type:w.target.value})},className:SC,children:tj.map(w=>c.jsx("option",{value:w.value,children:w.label},w.value))})]}),n.type==="step_result"&&c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Result"}),v?c.jsx("select",{value:n.result??_.results[0],onChange:w=>{f({type:"step_result",result:w.target.value})},className:SC,children:_.results.map(w=>c.jsx("option",{value:w,children:w},w))}):c.jsx("input",{type:"text",value:n.result??"success",onChange:w=>f({type:"step_result",result:w.target.value}),placeholder:"e.g. success, passed, failed",className:Mo})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Metadata Key"}),c.jsx("input",{type:"text",value:n.key??"",onChange:w=>f({...n,key:w.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Mo})]}),c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Field"}),c.jsx("input",{type:"text",value:n.field??"",onChange:w=>f({...n,field:w.target.value}),placeholder:"e.g. status",className:Mo})]}),n.type==="metadata_all_match"?c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Value"}),c.jsx("input",{type:"text",value:n.value??"",onChange:w=>f({...n,value:w.target.value}),placeholder:"e.g. passed, resolved",className:Mo})]}):c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Values (comma-separated)"}),c.jsx("input",{type:"text",value:((S=n.values)==null?void 0:S.join(", "))??"",onChange:w=>f({...n,values:w.target.value.split(",").map(k=>k.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Mo})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:ha,children:"Sub-group"}),c.jsx("input",{type:"text",value:r??"",onChange:w=>h(w.target.value||void 0),placeholder:"e.g. build, verify",className:Mo})]}),c.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function EF(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function NF(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const 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",wC="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",Wr="block text-[11px] text-text-secondary mb-0.5",CC=[];function nj({isOpen:e,onClose:t,initialEditId:n}){var za,Zi;const r=Nt(fe=>fe.defaults),i=Nt(fe=>fe.userItems),a=Nt(fe=>fe.loading),l=Nt(fe=>fe.templateVariables),d=Nt(fe=>fe.fetchWorkflows),f=Nt(fe=>fe.fetchWorkflow),h=Nt(fe=>fe.fetchDefaultContent),p=Nt(fe=>fe.fetchTemplateVariables),g=Nt(fe=>fe.createWorkflow),x=Nt(fe=>fe.updateWorkflow),_=Nt(fe=>fe.deleteWorkflow),{requestDelete:v,clearConfirm:S,isConfirming:w}=rx(),[k,j]=C.useState("list"),[T,A]=C.useState(null),[P,M]=C.useState(!1),[q,Z]=C.useState(null),[J,L]=C.useState(null),[G,H]=C.useState(""),[R,U]=C.useState(""),[D,N]=C.useState(""),[F,$]=C.useState("1.0.0"),[se,B]=C.useState("#3b82f6"),[V,K]=C.useState(""),[I,Q]=C.useState(50),[W,ee]=C.useState(CC),[ne,Se]=C.useState({type:"always"}),[le,Ce]=C.useState(""),[Re,Oe]=C.useState(!1),De=mt(fe=>fe.defaults),Ue=mt(fe=>fe.userItems),it=mt(fe=>fe.projectItems),st=C.useMemo(()=>[...De,...Ue,...it],[De,Ue,it]),ye=mt(fe=>fe.fetchAgents),[ze]=C.useState(null);C.useEffect(()=>{e&&(d(),p(),ye(),Z(null),L(null),n?r.some(he=>he.id===n)?h(n).then(he=>{he&&ve({...he,metadata:{...he.metadata,name:he.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):f(n).then(he=>{he&&ve(he,{editingId:n,isReadOnly:!1})}):(j("list"),A(null),M(!1)))},[e,d,f,h,p,n]);const ve=(fe,he)=>{H(fe.metadata.name),U(fe.metadata.id),N(fe.metadata.description),$(fe.metadata.version),B(fe.metadata.color??"#3b82f6"),K(fe.entryStep),Q(fe.settings.maxIterations),ee(fe.steps),Se(fe.startCondition??{type:"always"}),Ce(""),(he==null?void 0:he.editingId)!==void 0&&A(he.editingId),(he==null?void 0:he.isReadOnly)!==void 0&&M(he.isReadOnly),(he==null?void 0:he.selectedNodeKey)!==void 0&&Z(null),(he==null?void 0:he.selectedEdgeKey)!==void 0&&L(null),j("edit")},ue=async fe=>{const he=await f(fe);he&&ve(he,{editingId:fe,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},Ee=async()=>{var Qe;const fe=T??R;if(!fe||!G)return Ce("Name is required."),!1;if(W.length===0)return Ce("Add at least one step."),!1;let he=V;if(!he||!W.some(We=>We.id===he)){if(he=((Qe=W.find(We=>We.id))==null?void 0:Qe.id)??"",!he)return Ce("All steps need an ID."),!1;K(he)}Oe(!0),Ce("");const Te={metadata:{id:fe,name:G,description:D,version:F||"1.0.0",color:se},entryStep:he,settings:{maxIterations:I},steps:W,startCondition:ne},Pe=T?await x(T,Te):await g(Te);return Oe(!1),Pe.success?(T||A(fe),!0):(Ce(Pe.error??"Failed to save."),!1)},_t=async()=>{await Ee()},Ji=async()=>{await Ee()&&(n?t():j("list"))},Yt=()=>{n?t():j("list")},el=fe=>{H(fe),T||U(EF(fe))},me=async fe=>r.some(Te=>Te.id===fe)?await h(fe):await f(fe),ke=async fe=>{const he=await me(fe);he&&ve(he,{editingId:fe,isReadOnly:!0})},$e=async fe=>{const he=await me(fe);he&&ve({...he,metadata:{...he.metadata,name:he.metadata.name+" (copy)",id:`${fe}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Xe=()=>{A(null),H(""),U(""),N(""),$("1.0.0"),B("#3b82f6"),K(""),Q(50),ee(structuredClone(CC)),Se({type:"always"}),Ce(""),Z(null),L(null),M(!1),j("edit")},ut=async fe=>{await _(fe),S()},un=C.useCallback(fe=>{Z(fe),L(null)},[]),Kn=C.useCallback(fe=>{L(fe),Z(null)},[]),zt=q!==null?Number(q):-1,pt=zt>=0?W[zt]??null:null,On=C.useCallback(fe=>{ee(he=>he.map((Te,Pe)=>Pe===zt?fe:Te))},[zt]),xt=ne.type==="step_result"?`${ne.result}`:ne.type==="metadata_all_match"?`${ne.key??"?"}=${ne.value??"?"}`:ne.type==="metadata_all_in"?`${ne.key??"?"} in [${((za=ne.values)==null?void 0:za.join(","))??"?"}]`:ej[ne.type]??ne.type,Br=()=>{const fe=W.length,he=NF(W),Te=st.find(Pe=>!Pe.subagent);ee([...W,{id:he,name:(Te==null?void 0:Te.name)??"Agent",type:"agent",phase:"build",toolMode:(Te==null?void 0:Te.id)??"builder",transitions:[]}]),V||K(he),un(String(fe))},sr=C.useCallback((fe,he)=>{fe==="$start"?(K(he),Kn("start")):ee(Te=>{const Pe=Te.find(We=>We.id===fe),Qe=Pe?Pe.transitions.length:0;return Kn(`${fe}:${Qe}`),Te.map(We=>We.id===fe?{...We,transitions:[...We.transitions,{when:{type:"always"},goto:he}]}:We)})},[Kn]),Oa=fe=>{if(fe==="start")return null;const he=fe.lastIndexOf(":"),Te=fe.slice(0,he),Pe=parseInt(fe.slice(he+1));return{stepId:Te,transIdx:Pe}},zr=C.useCallback((fe,he)=>{const Te=Oa(fe);Te&&ee(Pe=>Pe.map(Qe=>Qe.id===Te.stepId?{...Qe,transitions:Qe.transitions.map((We,dt)=>dt===Te.transIdx?he(We):We)}:Qe))},[]),Ia=C.useCallback((fe,he)=>{if(fe==="start"){K(he);return}zr(fe,Te=>({...Te,goto:he}))},[zr]),Pa=C.useCallback((fe,he)=>{const Te=Oa(fe);Te&&(ee(Pe=>{const Qe=Pe.find(dt=>dt.id===Te.stepId);if(!Qe)return Pe;const We=Qe.transitions[Te.transIdx];return We?Pe.map(dt=>dt.id===Te.stepId?{...dt,transitions:dt.transitions.filter((jn,It)=>It!==Te.transIdx)}:dt.id===he?{...dt,transitions:[...dt.transitions,We]}:dt):Pe}),L(null))},[]),Jr=C.useCallback(fe=>{if(fe==="start"){K(""),L(null);return}const he=Oa(fe);he&&(ee(Te=>Te.map(Pe=>Pe.id===he.stepId?{...Pe,transitions:Pe.transitions.filter((Qe,We)=>We!==he.transIdx)}:Pe)),L(null))},[]),Ba=C.useCallback((fe,he)=>{if(fe==="start"){Se(he);return}zr(fe,Te=>({...Te,when:he}))},[zr]),Fs=C.useCallback((fe,he)=>{fe!=="start"&&zr(fe,Te=>({...Te,subGroup:he||void 0}))},[zr]),tl=fe=>Jx(fe,st).name,Zc=()=>{if(!J)return null;if(J==="start"){const jn=W.find(It=>It.id===V);return{type:"start",fromLabel:"Start",toLabel:jn?tl(jn):"(none)",condition:ne}}const fe=J.lastIndexOf(":"),he=J.slice(0,fe),Te=parseInt(J.slice(fe+1)),Pe=W.find(jn=>jn.id===he);if(!Pe)return null;const Qe=Pe.transitions[Te];if(!Qe)return null;const We=W.find(jn=>jn.id===Qe.goto),dt=Qe.goto==="$done"?"Done":We?tl(We):Qe.goto;return{type:"step",fromLabel:tl(Pe),toLabel:dt,condition:Qe.when,subGroup:Qe.subGroup}};if(k==="edit"){const fe=Zc();return c.jsxs(jt,{isOpen:e,onClose:Yt,title:P?G:T?"Edit Workflow":"New Workflow",size:"full",children:[le&&c.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:le}),c.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[c.jsxs("div",{className:"min-w-[140px]",children:[c.jsx("label",{className:Wr,children:"Name"}),c.jsx("input",{value:G,onChange:he=>el(he.target.value),placeholder:"Workflow name",className:`${Ui} ${P?"opacity-50":""}`,readOnly:P})]}),c.jsxs("div",{className:"min-w-[100px]",children:[c.jsx("label",{className:Wr,children:"ID"}),c.jsx("input",{value:R,readOnly:!0,className:`${Ui} font-mono opacity-50`})]}),c.jsxs("div",{className:"flex-1 min-w-[140px]",children:[c.jsx("label",{className:Wr,children:"Description"}),c.jsx("input",{value:D,onChange:he=>!P&&N(he.target.value),readOnly:P,placeholder:"What does this workflow do?",className:`${Ui} ${P?"opacity-50":""}`})]}),c.jsxs("div",{className:"w-20",children:[c.jsx("label",{className:Wr,children:"Max Iter."}),c.jsx("input",{type:"number",value:I,onChange:he=>!P&&Q(Number(he.target.value)),readOnly:P,className:`${Ui} font-mono ${P?"opacity-50":""}`})]}),c.jsxs("div",{children:[c.jsx("label",{className:Wr,children:"Color"}),c.jsx("input",{type:"color",value:se,onChange:he=>!P&&B(he.target.value),disabled:P,className:`w-8 h-8 rounded border border-border bg-transparent ${P?"opacity-50":"cursor-pointer"}`})]})]}),c.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[c.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[c.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!P&&c.jsx("button",{onClick:Br,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),c.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[c.jsx(SF,{steps:W,entryStep:V,selectedNodeId:(pt==null?void 0:pt.id)??null,selectedEdgeKey:J,startConditionLabel:xt,agentTypes:st,isReadOnly:P,onSelectNode:he=>{if(he===null){un(null);return}const Te=W.findIndex(Pe=>Pe.id===he);un(Te>=0?String(Te):null)},onSelectEdge:Kn,onRemoveStep:he=>{var Pe;const Te=W.findIndex(Qe=>Qe.id===he);if(ee(Qe=>Qe.filter(We=>We.id!==he)),zt===Te&&un(null),V===he){const Qe=W.filter(We=>We.id!==he);K(((Pe=Qe[0])==null?void 0:Pe.id)??"")}},onCreateTransition:sr,onReconnectTo:Ia,onReconnectFrom:Pa,onDeleteTransition:Jr}),W.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[c.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),c.jsx("button",{onClick:Br,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"})]})]})]}),c.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[c.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:c.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),c.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:P&&(fe||pt)?c.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):fe?fe.type==="start"?c.jsxs("div",{className:"space-y-3 text-sm",children:[c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),V&&c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[c.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),c.jsx(JC,{}),c.jsx("span",{className:"text-text-primary font-medium",children:fe.toLabel})]}),c.jsxs("div",{children:[c.jsx("label",{className:Wr,children:"Activation Condition"}),c.jsx("select",{value:ne.type,onChange:he=>Se(he.target.value==="step_result"?{type:"step_result",result:"success"}:he.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:he.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:he.target.value}),className:wC,children:tj.map(he=>c.jsx("option",{value:he.value,children:he.label},he.value))})]}),ne.type==="step_result"&&c.jsxs("div",{children:[c.jsx("label",{className:Wr,children:"Result"}),V&&(()=>{const he=W.find(We=>We.id===V),Te=he&&(he.type==="sub_agent"||he.type==="agent")?st.find(We=>We.id===(he.type==="sub_agent"?he.subAgentType:he.toolMode)):void 0,Pe=(Te==null?void 0:Te.results)&&Te.results.length>0,Qe=(Te==null?void 0:Te.results)??[];return Pe?c.jsx("select",{value:ne.result??Qe[0],onChange:We=>Se({type:"step_result",result:We.target.value}),className:wC,children:Qe.map(We=>c.jsx("option",{value:We,children:We},We))}):c.jsx("input",{type:"text",value:ne.result??"success",onChange:We=>Se({type:"step_result",result:We.target.value}),placeholder:"e.g. success, passed, failed",className:Ui})})()]}),(ne.type==="metadata_all_match"||ne.type==="metadata_all_in")&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:Wr,children:"Metadata Key"}),c.jsx("input",{type:"text",value:ne.key??"",onChange:he=>Se({...ne,key:he.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Ui})]}),c.jsxs("div",{children:[c.jsx("label",{className:Wr,children:"Field"}),c.jsx("input",{type:"text",value:ne.field??"",onChange:he=>Se({...ne,field:he.target.value}),placeholder:"e.g. status",className:Ui})]}),ne.type==="metadata_all_match"?c.jsxs("div",{children:[c.jsx("label",{className:Wr,children:"Value"}),c.jsx("input",{type:"text",value:ne.value??"",onChange:he=>Se({...ne,value:he.target.value}),placeholder:"e.g. passed, resolved",className:Ui})]}):c.jsxs("div",{children:[c.jsx("label",{className:Wr,children:"Values (comma-separated)"}),c.jsx("input",{type:"text",value:((Zi=ne.values)==null?void 0:Zi.join(", "))??"",onChange:he=>Se({...ne,values:he.target.value.split(",").map(Te=>Te.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Ui})]})]}),c.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."})]}):(()=>{const he=Oa(J),Te=he==null?void 0:he.stepId,Pe=(he==null?void 0:he.transIdx)??0,Qe=Te?W.find(dt=>dt.id===Te):void 0,We=(Qe==null?void 0:Qe.transitions.length)??0;return c.jsx(kF,{fromLabel:fe.fromLabel,toLabel:fe.toLabel,condition:fe.condition,subGroup:"subGroup"in fe?fe.subGroup:void 0,fromStep:fe.type==="step"?W.find(dt=>dt.id===fe.fromLabel):void 0,agentTypes:st,transitionIndex:Pe,totalTransitions:We,onUpdateCondition:dt=>Ba(J,dt),onUpdateSubGroup:dt=>Fs(J,dt),onDelete:()=>Jr(J),onMoveUp:()=>{ee(dt=>{const jn=dt.find(yt=>yt.id===Te);if(!jn||Pe===0)return dt;const It=[...jn.transitions];return[It[Pe-1],It[Pe]]=[It[Pe],It[Pe-1]],dt.map(yt=>yt.id===Te?{...yt,transitions:It}:yt)}),L(`${Te}:${Pe-1}`)},onMoveDown:()=>{ee(dt=>{const jn=dt.find(yt=>yt.id===Te);if(!jn||Pe===jn.transitions.length-1)return dt;const It=[...jn.transitions];return[It[Pe],It[Pe+1]]=[It[Pe+1],It[Pe]],dt.map(yt=>yt.id===Te?{...yt,transitions:It}:yt)}),L(`${Te}:${Pe+1}`)}})})():pt?c.jsx(CF,{step:pt,isEntry:pt.id===V,agentTypes:st,transitionCount:pt.transitions.length,templateVariables:l,onUpdate:On,onRemove:()=>{var he;if(pt&&(ee(W.filter((Te,Pe)=>Pe!==zt)),un(null),V===pt.id)){const Te=W.filter((Pe,Qe)=>Qe!==zt);K(((he=Te[0])==null?void 0:he.id)??"")}},onSetEntry:()=>K(pt.id)}):c.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",c.jsx("br",{}),"Drag from a port to connect."]})})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[c.jsx(Ze,{variant:"secondary",onClick:Yt,children:"Close"}),P?c.jsx(Ze,{variant:"primary",onClick:()=>{H(G+" (copy)"),U(`${T}-copy-${Date.now()}`),A(null),M(!1)},children:"Duplicate & Customize"}):c.jsxs(c.Fragment,{children:[c.jsx(Ze,{variant:"primary",onClick:_t,children:"Save"}),c.jsx(Ze,{variant:"primary",onClick:Ji,children:"Save & Close"})]})]})]})}return c.jsx(jt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:c.jsx(ok,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Xe,loading:a,hasItems:r.length>0||i.length>0,children:c.jsxs("div",{className:"space-y-4",children:[c.jsx(bC,{title:"Built-in",items:r,renderActions:fe=>c.jsx(c.Fragment,{children:c.jsx(Os,{onClick:()=>$e(fe.id),children:c.jsx(Yd,{})})})}),c.jsx(bC,{title:"Custom",items:i,renderActions:fe=>c.jsxs(c.Fragment,{children:[c.jsx(Os,{onClick:()=>ke(fe.id),children:c.jsx(Yd,{})}),c.jsx(Os,{onClick:()=>ue(fe.id),children:c.jsx("span",{className:"text-[10px]",children:"Edit"})}),c.jsx(Xd,{onClick:()=>$e(fe.id)}),w(fe.id,"delete")?c.jsx(ix,{onConfirm:()=>ut(fe.id),onCancel:S}):c.jsx(sx,{onClick:()=>v(fe.id)})]})})]})})})}function rj(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(i=>{for(const a of r){let l=0;for(let d=0;d<a.length&&l<i.length;d++)a[d]===i[l]&&l++;if(l===i.length)return!0}return!1})}function ij(e,t,n,r,i){switch(e.key){case"ArrowDown":e.preventDefault(),n(a=>Math.min(a+1,t));break;case"ArrowUp":e.preventDefault(),n(a=>Math.max(a-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),i();break}}function jF(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function TF({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:i,onCloseCompleteAction:a,textareaContent:l,onSearchMessages:d,onToggleAutoScroll:f,isAutoScrollActive:h}){const[,p]=Qr(),g=mn(Q=>Q.fetchCommands),x=Nt(Q=>Q.fetchWorkflows),_=mt(Q=>Q.fetchAgents),v=mn(Q=>Q.defaults),S=mn(Q=>Q.userItems),w=mn(Q=>Q.projectItems),k=Nt(Q=>Q.defaults),j=Nt(Q=>Q.userItems),T=Nt(Q=>Q.projectItems),A=mt(Q=>Q.defaults),P=mt(Q=>Q.userItems),M=mt(Q=>Q.projectItems),q=xe(Q=>{var W;return(W=Q.currentSession)==null?void 0:W.mode}),Z=xe(Q=>{var W;return((W=Q.currentSession)==null?void 0:W.dangerLevel)??"normal"}),J=xe(Q=>Q.switchMode),L=xe(Q=>Q.switchDangerLevel),G=xe(Q=>{var W;return(W=Q.currentSession)==null?void 0:W.projectId}),H=C.useRef(void 0),[R,U]=C.useState(""),[D,N]=C.useState(0),F=C.useRef(null),$=C.useRef(!1);C.useEffect(()=>{e&&($.current=!0)},[e]),C.useEffect(()=>{if(e){g(),x(),_(),U(""),N(0);const Q=setTimeout(()=>{var W;return(W=F.current)==null?void 0:W.focus()},50);return()=>clearTimeout(Q)}},[e,g,x,_]),C.useEffect(()=>{var Q;!e&&$.current&&(n==null||n(),(Q=H.current)==null||Q.call(H),H.current=void 0)},[e,n]);const se=(Q,W)=>{const ee=new Set(W.map(ne=>ne.id));return[...Q.filter(ne=>!ee.has(ne.id)),...W]},V=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const Q=G??jF(window.location.pathname);Q&&p(`/p/${Q}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{H.current=a,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),d==null||d()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),f==null||f(!h)}},...se(se(A,P),M).filter(Q=>!Q.subagent&&Q.id!==q).map(Q=>({id:Q.id,name:Q.name,prefix:"Agent > Switch to",action:()=>J(Q.id)})),...se(se(v,S),w).map(Q=>({id:Q.id,name:Q.name,prefix:"Command > Launch",action:()=>r(Q.id,l)})),...se(se(k,j),T).map(Q=>({id:Q.id,name:Q.name,prefix:"Workflow > Run",action:()=>i(Q.id)})),...["normal","dangerous"].filter(Q=>Q!==Z).map(Q=>({id:Q,name:Q.charAt(0).toUpperCase()+Q.slice(1),prefix:"Mode > Switch to",action:()=>L(Q)}))].filter(Q=>rj(`${Q.prefix} ${Q.name}`,R)),K=V.length-1,I=Q=>{ij(Q,K,N,()=>{var W;(W=V[D])==null||W.action(),t()},t)};return e?La.createPortal(c.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),c.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[c.jsx("input",{ref:F,type:"text",value:R,onChange:Q=>{U(Q.target.value),N(0)},onKeyDown:I,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),c.jsx(tx,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),c.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:V.length===0?c.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:v.length+S.length+k.length+j.length>0?"No matches":"No agents, commands, or workflows yet"}):V.map((Q,W)=>c.jsxs("button",{type:"button",onClick:()=>{Q.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${W===D?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[c.jsxs("span",{className:"text-text-muted font-normal",children:[Q.prefix," "]}),c.jsx("span",{children:Q.name})]},Q.id))})]})]}),document.body):null}function AF(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 i=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0"),d=String(t.getHours()).padStart(2,"0"),f=String(t.getMinutes()).padStart(2,"0");return`${i}/${a}/${l} ${d}:${f}`}function DF(e){var t;if(e.type==="message")return e.message.timestamp;if(e.type==="subagent")return(t=e.messages[0])==null?void 0:t.timestamp}function LF(e){var t,n;if(e.type==="message"){const r=e.message;if(r.role==="assistant"){const i=(t=r.content)==null?void 0:t.trim();return((n=r.thinkingContent)==null?void 0:n.trim())&&!i?"italic text-text-muted":""}if(r.role==="user")return"font-bold"}return""}function RF(e){var n,r;if(e.type!=="message")return c.jsx(TS,{className:"w-3.5 h-3.5"});const t=e.message;return t.role==="assistant"?(n=t.thinkingContent)!=null&&n.trim()&&!((r=t.content)!=null&&r.trim())?c.jsx(iL,{className:"w-3.5 h-3.5"}):c.jsx(TS,{className:"w-3.5 h-3.5"}):c.jsx(rL,{className:"w-3.5 h-3.5"})}function kC(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",i=r.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(n.messageKind==="workflow-started")try{return`Workflow: ${JSON.parse(r).workflowName}`}catch{return"Workflow started"}if(n.messageKind==="task-completed")return"Task completed";if(n.messageKind==="auto-prompt")return"Auto-prompt";if(n.messageKind==="correction")return"Correction";if(n.messageKind==="context-reset")return"Context reset";if(n.messageKind==="command")return"Command executed";if(n.role==="assistant")return i?i.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const a=i.slice(0,200);return a.length<i.length?`${a}...`:a}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:e.type==="criteria-batch"?"Acceptance Criteria":""}function MF({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[i,a]=C.useState(""),[l,d]=C.useState(0),f=C.useRef(null),h=C.useRef(null),p=C.useMemo(()=>n.filter(w=>{var k,j;return!(w.type==="context-divider"||w.type==="message"&&w.message.role==="assistant"&&!((k=w.message.content)!=null&&k.trim())&&!((j=w.message.thinkingContent)!=null&&j.trim()))}),[n]),g=C.useMemo(()=>i?p.filter(w=>{const k=kC(w);return rj(k,i)}):p,[p,i]),x=g.length-1;C.useEffect(()=>{if(e){a(""),d(0);const w=setTimeout(()=>{var k;return(k=f.current)==null?void 0:k.focus()},50);return()=>clearTimeout(w)}},[e]),C.useEffect(()=>{e&&h.current&&(h.current.scrollTop=h.current.scrollHeight)},[e]);const _=w=>{ij(w,x,d,()=>{const k=g[l];if(k){const j=n.indexOf(k);j>=0&&r(j),t()}},t)},v=w=>{const k=n.indexOf(w);k>=0&&r(k),t()},S=w=>n.indexOf(w);return e?La.createPortal(c.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),c.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[c.jsx(Z_,{}),c.jsx("input",{ref:f,type:"text",value:i,onChange:w=>{a(w.target.value),d(0)},onKeyDown:_,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),c.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:c.jsx(zc,{className:"w-4 h-4"})})]}),c.jsx("div",{ref:h,className:"overflow-y-auto max-h-[60vh] p-2",children:g.length===0?c.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:p.length>0?"No matches":"No messages yet"}):g.map((w,k)=>{const j=S(w),T=RF(w),A=kC(w),P=LF(w),M=DF(w),q=w.type==="message"&&w.message.role==="user";return c.jsx("button",{type:"button",onClick:()=>v(w),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${k===l?"bg-accent-primary/20 text-text-primary":q?"bg-accent-primary/5 text-text-secondary hover:bg-accent-primary/10 hover:text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[c.jsx("span",{className:"flex-shrink-0",children:T}),c.jsx("span",{className:`truncate flex-1 ${P}`,children:A})]}),M&&c.jsx("span",{className:"text-text-muted text-xs shrink-0",children:AF(M)})]})},`${j}-${w.type}`)})})]})]}),document.body):null}function OF({attachment:e,onRemove:t}){const n=r=>r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`;return c.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[c.jsx(Wc,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),c.jsx("img",{src:e.data,alt:e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}),c.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),c.jsx("div",{className:"text-[10px] text-text-muted",children:n(e.size)})]})}function IF({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:i}){const a=C.useRef(null),l=C.useRef(null);C.useEffect(()=>{l.current&&a.current&&l.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const d=h=>{switch(h.key){case"Enter":h.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":h.preventDefault(),r();break;case"ArrowUp":h.preventDefault(),i("up");break;case"ArrowDown":h.preventDefault(),i("down");break}},f=h=>{n(h)};return c.jsx("div",{ref:a,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((h,p)=>c.jsxs("div",{ref:p===t?l:null,role:"listitem",onClick:()=>f(h.content),className:`
311
+ p-2 rounded cursor-pointer transition-colors
312
+ ${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
313
+ `,children:[c.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&c.jsxs(c.Fragment,{children:[" | ",c.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),c.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function PF(){const e=DD(),t=e?"bg-amber-400":"bg-accent-primary";return c.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("span",{className:"flex gap-0.5",children:[c.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),c.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),c.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),c.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&c.jsx("span",{className:"text-text-muted",children:"esc to interrupt"})]})}const BF={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function zF(e,t={}){const n={...BF,...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 i=await e.arrayBuffer(),a=GF(i),l=`data:${e.type};base64,${a}`,d=await sj(l);return{dataUrl:l,mimeType:e.type,size:e.size,width:d.width,height:d.height}}return await $F(e,n)}async function $F(e,t){const n=await FF(e),r=await sj(n),{width:i,height:a}=HF(r.width,r.height,t.maxWidth,t.maxHeight),l=UF();l.width=i,l.height=a;const d=l.getContext("2d");if(!d)throw new Error("Failed to get canvas context");d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(r,0,0,i,a);let f=t.quality,h="";for(let g=0;g<10&&(h=l.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,f),!(EC(h)<=t.maxSizeBytes||f<=.3));g++)f-=.1;const p=EC(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:i,height:a}}function HF(e,t,n,r){const i=e/t;return e>t&&e>n?{width:n,height:Math.round(n/i)}:t>e&&t>r?{width:Math.round(r*i),height:r}:{width:e,height:t}}function FF(e){return new Promise((t,n)=>{const r=WF(),i=new r;i.onload=()=>t(i.result),i.onerror=()=>n(new Error("Failed to read file")),i.readAsDataURL(e)})}function sj(e){return new Promise((t,n)=>{const r=VF(),i=new r;i.onload=()=>t(i),i.onerror=()=>n(new Error("Failed to load image")),i.src=e})}function UF(){var t;const e=Zx();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function VF(){const e=Zx();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function WF(){const e=Zx();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Zx(){return globalThis}function GF(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const i=t[r];i!==void 0&&(n+=String.fromCharCode(i))}return btoa(n)}function EC(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}function qF(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function KF(e,t=50*1024*1024){return e.size>t?{valid:!1,error:`Image file is too large (${NC(e.size)}). Maximum size is ${NC(t)}.`}:{valid:!0}}function NC(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function kg(e,t,n,r={}){const{maxSizeBytes:i=50*1024*1024,filename:a}=r;if(!qF(e)){n(`Unsupported file type: ${e.type}. Only PNG, JPG, and GIF are supported.`);return}const l=KF(e,i);if(!l.valid){n(l.error??"Image file is too large");return}try{const d=await zF(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),f={id:WC(),filename:a??e.name,mimeType:d.mimeType,size:d.size,data:d.dataUrl};t(f)}catch(d){const f=d instanceof Error?d.message??"Failed to process image":"Failed to process image";n(f)}}function YF({children:e}){return La.createPortal(e,document.body)}function XF(e){const t=e.startCondition;if(!t||t.type==="always")return!0;switch(t.type){case"step_result":case"metadata_all_match":case"metadata_all_in":return null;default:return null}}function QF({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:i,onAttach:a,textareaContent:l,attachments:d}){const[f,h]=C.useState(!1),[p,g]=C.useState("commands"),[x,_]=C.useState(""),[v,S]=C.useState(0),[w,k]=C.useState(null),[j,T]=C.useState(null),A=C.useRef(null),P=C.useRef(null),M=mn(K=>K.defaults),q=mn(K=>K.userItems),Z=mn(K=>K.fetchCommands),J=Nt(K=>K.defaults),L=Nt(K=>K.userItems),G=Nt(K=>K.fetchWorkflows),H=[...M,...q],R=[...J,...L];C.useEffect(()=>{f&&(p==="commands"?Z():p==="workflows"&&G())},[f,p,Z,G]),C.useEffect(()=>{f&&(_(""),S(0),requestAnimationFrame(()=>{var K;return(K=A.current)==null?void 0:K.focus()}))},[f,p]),C.useEffect(()=>{if(!f)return;const K=I=>{var Q;(Q=P.current)!=null&&Q.contains(I.target)||h(!1)};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[f]);const U=K=>{switch(K.key){case"ArrowDown":K.preventDefault(),S(I=>{const W=(p==="commands"?H:R).filter(ee=>{const ne=x.toLowerCase();return!ne||ee.name.toLowerCase().includes(ne)});return Math.min(I+1,W.length-1)});break;case"ArrowUp":K.preventDefault(),S(I=>Math.max(I-1,0));break;case"Enter":K.preventDefault();break;case"Escape":K.preventDefault(),h(!1);break}},D=K=>{_(K),S(0)},N=H.filter(K=>!x||K.name.toLowerCase().includes(x.toLowerCase())),F=R.filter(K=>!x||K.name.toLowerCase().includes(x.toLowerCase())),$=async K=>{const I=await mn.getState().fetchCommand(K);I&&e(I.prompt,I.metadata.agentMode,l,d),h(!1)},se=K=>{t(K),h(!1)},B=(K,I)=>{I.stopPropagation(),h(!1),k(K)},V=(K,I)=>{I.stopPropagation(),h(!1),T(K)};return c.jsxs("div",{ref:P,className:"relative",children:[c.jsx("button",{type:"button",onClick:()=>h(!f),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:c.jsx(ek,{className:"w-4 h-4"})}),f&&c.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 bg-bg-secondary border border-border rounded-lg shadow-xl z-50",children:[c.jsxs("div",{className:"flex border-b border-border",children:[c.jsx("button",{type:"button",onClick:()=>{g("commands"),_(""),S(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),c.jsx("button",{type:"button",onClick:()=>{g("workflows"),_(""),S(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),c.jsx("button",{type:"button",onClick:()=>g("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),p!=="attach"&&c.jsx("div",{className:"p-2 border-b border-border",children:c.jsx("input",{ref:A,value:x,onChange:K=>D(K.target.value),onKeyDown:U,placeholder:p==="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"})}),c.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:p==="commands"?N.length===0?c.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:H.length===0?"No commands yet":"No matches"}):N.map((K,I)=>c.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${I===v?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[c.jsx("button",{type:"button",onClick:()=>$(K.id),className:"flex-1 text-left",children:c.jsx("div",{className:"text-sm text-text-primary font-medium",children:K.name})}),c.jsx(Os,{className:"opacity-0 group-hover:opacity-100",onClick:Q=>B(K.id,Q)})]},K.id)):p==="workflows"?F.length===0?c.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:R.length===0?"No workflows yet":"No matches"}):F.map((K,I)=>{const Q=XF(K),W=K.color??"#3b82f6";return c.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${I===v?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[c.jsxs("button",{type:"button",onClick:()=>se(K.id),className:"flex-1 text-left flex items-center gap-2",children:[c.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:W}}),c.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:K.name}),Q!==null&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Q?"#22c55e":"#6b7280"},title:Q?"Entry condition met":"Entry condition not met"})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[K.subGroups&&K.subGroups.length>0&&c.jsx(JF,{subGroups:K.subGroups,onSelect:ee=>{h(!1),n(K.id,ee)}}),c.jsx(Os,{className:"opacity-0 group-hover:opacity-100",onClick:ee=>V(K.id,ee)})]})]},K.id)}):c.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[c.jsxs("button",{type:"button",onClick:()=>{a(),h(!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:[c.jsx(BD,{className:"w-4 h-4"}),c.jsx("span",{className:"text-sm font-medium",children:"Attach image"})]}),c.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&c.jsx("div",{className:"border-t border-border p-1",children:c.jsx("button",{type:"button",onClick:()=>{h(!1),p==="commands"?r():i()},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:p==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),c.jsx(ZN,{isOpen:!!w,onClose:()=>k(null),initialEditId:w}),c.jsx(nj,{isOpen:!!j,onClose:()=>T(null),initialEditId:j})]})}function JF({subGroups:e,onSelect:t}){const[n,r]=C.useState(!1),[i,a]=C.useState({top:0,right:0}),l=C.useRef(null),d=C.useRef(null);JN(d,()=>r(!1),n);const f=h=>{if(h.stopPropagation(),!n&&l.current){const p=l.current.getBoundingClientRect();a({top:p.bottom+4,right:window.innerWidth-p.right})}r(!n)};return c.jsxs(c.Fragment,{children:[c.jsx("button",{ref:l,type:"button",onClick:f,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&c.jsx(YF,{children:c.jsx("div",{ref:d,onMouseDown:h=>h.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:i.top,right:i.right},children:e.map(h=>c.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(h)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:h},h))})})]})}function ZF({messages:e,onCancel:t}){return e.length===0?null:c.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>c.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${n.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:[c.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),c.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),c.jsx(Wc,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function eU({agent:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:i,onDuplicate:a,onDelete:l}){return c.jsxs(uk,{isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:i,onDuplicate:a,onDelete:l,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),c.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),c.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&c.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&&c.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),c.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[e.allowedTools.slice(0,5).map(d=>c.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&&c.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",e.allowedTools.length-5," more"]})]})]})}function jC({title:e,agents:t,subagents:n,isBuiltIn:r,onView:i,onDuplicate:a,onEdit:l,onDelete:d}){if(t.length===0&&n.length===0)return null;const f=h=>c.jsx(eU,{agent:h,isBuiltIn:r,isConfirmingDelete:!1,onView:()=>i(h.id),onEdit:r?void 0:()=>l==null?void 0:l(h.id),onDuplicate:()=>a(h.id),onDelete:r?void 0:()=>d==null?void 0:d(h.id)},h.id);return c.jsxs("div",{children:[c.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),c.jsxs("div",{className:"space-y-2",children:[t.map(f),n.length>0&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:"Sub-agents"}),c.jsx("div",{className:"space-y-2",children:n.map(f)})]})]})]})}function tU(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const i=n.slice(0,r),l=n.slice(r+1).split(",").filter(Boolean);t.set(i,new Set(l))}}return t}function Eg(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function nU({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:i,formColor:a,formPrompt:l,formError:d,saving:f,isReadOnly:h,availableTools:p,onNameChange:g,onIdChange:x,onDescriptionChange:_,onSubagentChange:v,onColorChange:S,onPromptChange:w,onSave:k,onCancel:j,onDuplicate:T}){const A=tU(i),P=(Z,J)=>{const L=new Map(A),G=L.get(Z)||new Set,H=new Set(G);H.has(J)?H.delete(J):H.add(J),H.size===0?L.set(Z,new Set):L.set(Z,H),q(Eg(L))},M=Z=>{const J=new Map(A);J.has(Z)?J.delete(Z):J.set(Z,new Set),q(Eg(J))},q=Z=>{};return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"space-y-3",children:[d&&c.jsx(ax,{message:d}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(ka,{label:"Name",value:e,onChange:g,placeholder:"My Agent",readOnly:h}),c.jsx(ka,{label:"ID",value:t,onChange:x,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(ka,{label:"Description",value:n,onChange:_,placeholder:"What this agent does",readOnly:h}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),c.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[c.jsx("button",{onClick:()=>!h&&v(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),c.jsx("button",{onClick:()=>!h&&v(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${h?"pointer-events-none opacity-60":""}`,children:"Top-level"}),c.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[c.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),c.jsx("input",{type:"color",value:a,onChange:Z=>!h&&S(Z.target.value),disabled:h,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),c.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:p.map(Z=>{const J=A.has(Z.name),L=Z.actions.length>0,G=A.get(Z.name)||new Set;return L?h?c.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:[c.jsx("span",{children:Z.name}),c.jsx("span",{className:"text-[10px]",children:"*"})]},Z.name):c.jsx(Vc,{trigger:c.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${J?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[c.jsx("span",{children:Z.name}),L&&c.jsx("span",{className:`text-[10px] ${J&&G.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]}),minWidth:"160px",items:[...Z.actions.map(H=>({label:c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${Z.name}-${H}`,children:[c.jsx("input",{type:"checkbox",id:`${Z.name}-${H}`,checked:G.has(H),onChange:()=>P(Z.name,H),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),c.jsx("span",{children:H})]}),closeOnClick:!1})),{label:J?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(J)M(Z.name);else{const H=new Map(A);H.set(Z.name,new Set(Z.actions)),q(Eg(H))}}}]},Z.name):c.jsx("button",{onClick:()=>!h&&M(Z.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${J?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:c.jsx("span",{children:Z.name})},Z.name)})})]})]}),c.jsxs("div",{className:"flex-1 min-h-[150px] border-t border-border pt-3 flex flex-col",children:[c.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),c.jsx("textarea",{value:l,onChange:Z=>!h&&w(Z.target.value),readOnly:h,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 ${h?"opacity-60":""}`})]}),c.jsx(pL,{onCancel:j,onSave:k,saving:f,saveDisabled:!e||!l||h}),h&&c.jsx("div",{className:"flex justify-end mt-2",children:c.jsx("button",{onClick:T,className:"px-3 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors",children:"Duplicate & Customize"})})]})}function rU(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"")}function iU({isOpen:e,onClose:t,initialEditId:n}){const r=mt(ye=>ye.defaults),i=mt(ye=>ye.userItems),a=mt(ye=>ye.loading),l=mt(ye=>ye.fetchAgents),d=mt(ye=>ye.fetchAgent),f=mt(ye=>ye.fetchDefaultContent),h=mt(ye=>ye.createAgent),p=mt(ye=>ye.updateAgent),g=mt(ye=>ye.deleteAgent),[x,_]=C.useState("list"),[v,S]=C.useState(null),[w,k]=C.useState(!1),[j,T]=C.useState(""),[A,P]=C.useState(""),[M,q]=C.useState(""),[Z,J]=C.useState(!0),[L,G]=C.useState([]),[H,R]=C.useState("#6b7280"),[U,D]=C.useState(""),[N,F]=C.useState(""),[$,se]=C.useState(!1),[B,V]=C.useState([]),K=ye=>{T(ye.metadata.name),P(ye.metadata.id),q(ye.metadata.description),J(ye.metadata.subagent),G(ye.metadata.allowedTools),R(ye.metadata.color??"#6b7280"),D(ye.prompt),F("")},I=(ye,ze,ve)=>{T(ye.metadata.name+" (copy)"),P(`${ze}-copy-${Date.now()}`),q(ye.metadata.description),J(ye.metadata.subagent),G(ye.metadata.allowedTools),R(ye.metadata.color??"#6b7280"),D(ye.prompt),F(""),S(null),k(!1),_("edit")},Q=(ye,ze)=>{K(ye),S(ze),k(!0),_("edit")};C.useEffect(()=>{e&&(l(),Ne("/api/tools").then(ye=>ye.json()).then(ye=>V(ye.tools||[])).catch(()=>V([])),n?r.some(ze=>ze.id===n)?f(n).then(ze=>{ze&&I(ze,n)}):d(n).then(ze=>{ze&&(K(ze),S(n),k(!1),_("edit"))}):(_("list"),S(null),k(!1)))},[e,l,d,f,n]);const W=async ye=>{if(r.some(ve=>ve.id===ye)){const ve=await f(ye);if(!ve)return;Q(ve,ye)}else{const ve=await d(ye);if(!ve)return;Q(ve,ye)}},ee=async ye=>{const ze=await f(ye);ze&&I(ze,ye)},ne=()=>{S(null),T(""),P(""),q(""),J(!0),G(["read_file"]),R("#6b7280"),D(""),F(""),k(!1),_("edit")},Se=async ye=>{const ze=await d(ye);ze&&(K(ze),S(ye),k(!1),_("edit"))},le=async ye=>{await g(ye)},Ce=async()=>{const ye=v??A;if(!ye||!j||!U){F("Name and prompt are required.");return}se(!0),F("");const ze={metadata:{id:ye,name:j,description:M,subagent:Z,allowedTools:L,color:H},prompt:U},ve=v?await p(v,ze):await h(ze);if(se(!1),!ve.success){F(ve.error??"Failed to save agent.");return}n?t():_("list")},Re=()=>{n?t():(_("list"),k(!1))},Oe=ye=>{T(ye),v||P(rU(ye))},De=r.filter(ye=>ye.subagent),Ue=r.filter(ye=>!ye.subagent),it=i.filter(ye=>ye.subagent),st=i.filter(ye=>!ye.subagent);return x==="edit"?c.jsx(jt,{isOpen:e,onClose:Re,title:w?`${j}`:v?"Edit Agent":"New Agent",size:"xl",children:c.jsx(nU,{formName:j,formId:A,formDescription:M,formSubagent:Z,formTools:L,formColor:H,formPrompt:U,formError:N,saving:$,isReadOnly:w,availableTools:B,onNameChange:Oe,onIdChange:P,onDescriptionChange:q,onSubagentChange:J,onColorChange:R,onPromptChange:D,onSave:Ce,onCancel:Re,onDuplicate:()=>{T(j+" (copy)"),P(`${v}-copy-${Date.now()}`),S(null),k(!1)}})}):c.jsx(jt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:c.jsx(ok,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:ne,loading:a,hasItems:r.length>0||i.length>0,children:c.jsxs("div",{className:"space-y-4",children:[r.length>0&&c.jsx(jC,{title:"Built-in",agents:Ue,subagents:De,isBuiltIn:!0,onView:W,onDuplicate:ee}),i.length>0&&c.jsx(jC,{title:"Custom",agents:st,subagents:it,isBuiltIn:!1,onView:W,onDuplicate:ee,onEdit:Se,onDelete:le})]})})})}function sU(){const e=xe(j=>{var T;return(T=j.currentSession)==null?void 0:T.mode}),t=xe(j=>j.switchMode),n=mt(j=>j.defaults),r=mt(j=>j.userItems),i=mt(j=>j.fetchAgents),a=[...n,...r],[l,d]=C.useState(!1),[f,h]=C.useState(!1),[p,g]=C.useState(null),x=C.useRef(null);C.useEffect(()=>{i()},[i]),C.useEffect(()=>{function j(T){x.current&&!x.current.contains(T.target)&&d(!1)}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const _=ex();if(!e)return null;const v=a.filter(j=>!j.subagent),S=v.find(j=>j.id===e),w=(S==null?void 0:S.name)??e,k=jc(a,e);return c.jsxs("div",{className:"relative",ref:x,children:[c.jsxs("button",{type:"button",onClick:()=>d(!l),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[c.jsx("span",{className:"text-sm font-medium",style:{color:k},children:w}),c.jsx(gi,{className:`w-3 h-3 text-text-muted transition-transform ${l?"rotate-180":""}`})]}),l&&v.length>0&&c.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:[v.map((j,T)=>{const A=j.id===e,P=jc(a,j.id),M=_.agentSwitching[T],q=M?rk(M):null;return c.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:[c.jsxs("button",{type:"button",onClick:()=>{A||t(j.id),d(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[c.jsx("span",{className:"font-medium truncate",style:{color:P},children:j.name}),A&&c.jsx(pi,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),q&&c.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:q})]},j.id)}),c.jsx("div",{className:"border-t border-border p-1",children:c.jsx("button",{type:"button",onClick:()=>{d(!1),h(!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..."})})]}),c.jsx(iU,{isOpen:f,onClose:()=>{h(!1),g(null)},initialEditId:p})]})}function aU(){const e=xe(r=>r.currentSession),t=xe(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return c.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[c.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"}),c.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 oU({content:e,children:t,position:n="top",delay:r=200}){const[i,a]=C.useState(!1),[l,d]=C.useState({top:0,left:0}),f=C.useRef(void 0),h=C.useRef(null);C.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const p=()=>{f.current=setTimeout(()=>{if(h.current){const _=h.current.getBoundingClientRect();d({top:_.top,left:_.left+_.width/2})}a(!0)},r)},g=()=>{f.current&&clearTimeout(f.current),a(!1)},x=(()=>{switch(n){case"top":return{top:l.top-8,left:l.left,tx:"-50%",ty:"-100%"};case"bottom":return{top:l.top+8,left:l.left,tx:"-50%",ty:"0%"};case"left":return{top:l.top,left:l.left-8,tx:"-100%",ty:"-50%"};case"right":return{top:l.top,left:l.left+8,tx:"0%",ty:"-50%"}}})();return c.jsxs(c.Fragment,{children:[c.jsx("span",{ref:h,className:"inline-flex",onMouseEnter:p,onMouseLeave:g,onFocus:p,onBlur:g,children:t}),i&&La.createPortal(c.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:x.top,left:x.left,transform:`translate(${x.tx}, ${x.ty})`},children:e}),document.body)]})}function Ng(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 lU({label:e,children:t}){return c.jsxs("div",{className:"space-y-3",children:[c.jsx("h4",{className:"text-sm font-medium text-text-secondary border-b border-border/50 pb-1",children:e}),t]})}function cc({label:e,value:t,onChange:n,min:r,max:i,step:a=1,helpText:l,defaultValue:d,profileDefault:f,tooltip:h}){const[p,g]=C.useState((t==null?void 0:t.toString())??""),[x,_]=C.useState(t===null);C.useEffect(()=>{g((t==null?void 0:t.toString())??""),_(t===null)},[t]);const v=k=>{if(g(k),k==="")n(null);else{const j=parseFloat(k);isNaN(j)||n(j)}},S=()=>{x?(_(!1),d!==void 0&&(g(d.toString()),n(d))):(_(!0),n(null))},w=c.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary mb-1",children:[h&&c.jsx(oU,{content:h,children:c.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,c.jsx("button",{type:"button",onClick:S,className:`text-xs px-1.5 py-0.5 rounded border ${x?"border-accent-primary/50 bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-secondary"}`,title:x?"Click to set a custom value":"Click to use default",children:x?"default":"custom"})]});return c.jsxs("div",{children:[w,c.jsx("input",{type:"number",min:r,max:i,step:a,value:p,readOnly:x,onChange:k=>v(k.target.value),onClick:()=>x&&S(),placeholder:x?`${f!==void 0?f:"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 ${x?"opacity-50 cursor-pointer":""}`}),l&&c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.jsx("p",{className:"text-xs text-text-muted",children:l}),f!==void 0&&c.jsxs("span",{className:"text-xs text-text-muted/60",children:["(default: ",f,")"]})]}),!l&&f!==void 0&&c.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Profile default: ",f]})]})}function cU({isOpen:e,onClose:t,providerId:n,model:r}){const[i,a]=C.useState(()=>Ng(r)),[l,d]=C.useState(!1),f=Ot(g=>g.updateModelSettings);C.useEffect(()=>{a(Ng(r))},[r]);const h=async()=>{if(i.contextWindow<1024||i.contextWindow>1e7)return;d(!0);const g=i.temperature!==(r.temperature??null)||i.topP!==(r.topP??null)||i.topK!==(r.topK??null)||i.maxTokens!==(r.maxTokens??null)||i.supportsVision!==(r.supportsVision??null);await f(n,r.id,{contextWindow:i.contextWindow,...g&&{temperature:i.temperature,topP:i.topP,topK:i.topK,maxTokens:i.maxTokens,supportsVision:i.supportsVision??void 0}}),d(!1),t()},p=()=>{a(Ng(r)),t()};return e?c.jsx(jt,{isOpen:e,onClose:t,title:"Model Properties",size:"lg",footer:c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{variant:"secondary",onClick:p,disabled:l,children:"Cancel"}),c.jsx(Ze,{variant:"primary",onClick:h,disabled:l||i.contextWindow<1024||i.contextWindow>1e7,children:l?"Saving...":"Save"})]}),children:c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Model Name"}),c.jsx("p",{className:"text-text-primary bg-bg-tertiary px-3 py-2 rounded font-mono text-sm break-all",children:r.id})]}),c.jsx(cc,{label:"Context Window",value:i.contextWindow,onChange:g=>g!==null&&a(x=>({...x,contextWindow:g})),min:1024,max:1e7,helpText:"Range: 1,024 - 10,000,000 tokens"}),c.jsxs(lU,{label:"Sampling Parameters",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsx(cc,{label:"Temperature",value:i.temperature,onChange:g=>a(x=>({...x,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."}),c.jsx(cc,{label:"Top P",value:i.topP,onChange:g=>a(x=>({...x,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."})]}),c.jsx(cc,{label:"Top K",value:i.topK,onChange:g=>a(x=>({...x,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."})]}),c.jsx(cc,{label:"Max Tokens",value:i.maxTokens,onChange:g=>a(x=>({...x,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."}),c.jsxs("div",{children:[c.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary mb-1",children:[c.jsx("input",{type:"checkbox",checked:i.supportsVision??!1,onChange:g=>a(x=>({...x,supportsVision:g.target.checked})),className:"rounded border-border bg-bg-tertiary text-accent-primary focus:ring-accent-primary focus:ring-offset-0"}),"Vision Enabled"]}),c.jsx("p",{className:"text-xs text-text-muted",children:"Allow sending images directly to this model. Disable if the model doesn't support vision."})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-1",children:"Source"}),c.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 uU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function dU(){var F;const[,e]=Qr(),t=xe($=>$.currentSession),n=xe($=>$.setSessionProvider),[r,i]=C.useState(!1),[a,l]=C.useState([]),[d,f]=C.useState(null),h=C.useRef(null),[p,g]=C.useState(null),x=C.useRef(new Set),_=Ot($=>$.providers),v=Ot($=>$.activeProviderId),S=Ot($=>$.defaultModelSelection);Ot($=>$.backend);const w=Ot($=>$.activating),k=Ot($=>$.activateProvider),j=Ot($=>$.refreshModel),T=Ot($=>$.refreshProviderModels);C.useEffect(()=>{function $(se){h.current&&!h.current.contains(se.target)&&(i(!1),l([]),x.current=new Set)}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]),C.useEffect(()=>{if(r){const $=_.map(se=>se.id);l($),$.forEach(se=>{x.current.has(se)||(x.current.add(se),J(se))})}},[r,_]);const A=_.find($=>$.id===v),P=(A==null?void 0:A.status)==="disconnected",M=S?S.split("/").pop()??null:null,q=M?((F=M.split("/").pop())==null?void 0:F.replace(/-/g," "))??M:"detecting...",Z=($,se)=>S?S===`${$}/${se}`:!1,J=async $=>{f($);try{await T($)}catch{}finally{f(null)}},L=$=>{a.includes($.id)?l(a.filter(se=>se!==$.id)):(l([...a,$.id]),J($.id))},G=async $=>{if($.id===v){L($);return}t?(n($.id,void 0),Ot.getState().syncFromSession($.id,""),i(!1),l([])):await k($.id)&&(i(!1),l([]))},H=$=>{L($)},R=async($,se)=>{$.stopPropagation(),x.current.delete(se),await T(se),await J(se)},U=($,se)=>{g({providerId:$,model:se})},D=()=>{g(null)},N=async($,se)=>{if(t){n($,se),Ot.getState().syncFromSession($,se),l([]),i(!1);return}f("activating");try{Ot.getState().syncFromSession($,se),l([]),i(!1);const B=await Ne(`/api/providers/${$}/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:se})});if(B.ok){const V=await B.json();Ot.getState().syncFromSession(V.activeProviderId,V.model)}}catch{}finally{f(null)}};return _.length===0?c.jsxs("button",{type:"button",onClick:()=>j(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:P?"LLM server is offline. Click to retry.":M??"Click to refresh model",children:[P?c.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):c.jsx("span",{className:"text-sm text-accent-primary",children:q}),c.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):c.jsxs("div",{className:"relative",ref:h,children:[c.jsxs("button",{type:"button",onClick:()=>i(!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:[P?c.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):c.jsx("span",{className:"text-sm text-accent-primary",children:q}),c.jsx(gi,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&c.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:[c.jsx("div",{className:"py-1",children:_.map($=>{var se;return c.jsxs("div",{children:[c.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${$.id===v?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${w?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[c.jsxs("div",{onClick:()=>!w&&G($),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[c.jsx("span",{className:`text-sm font-medium truncate ${$.id===v?"text-accent-primary":"text-text-primary"}`,children:$.name}),c.jsx("span",{className:"text-xs text-text-muted truncate",children:$.backend!=="auto"&&Tg($.backend)})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[$.id===v?c.jsx("span",{className:"text-accent-success",title:"Active",children:c.jsx(pi,{className:"w-4 h-4"})}):c.jsx("span",{className:"w-4"}),c.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),R(B,$.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:c.jsx(J_,{className:`w-4 h-4 ${d===$.id?"animate-spin":""} ${$.id===v?"text-accent-primary":"text-text-muted"}`})}),c.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),H($)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:c.jsx(gi,{className:`w-4 h-4 transition-transform ${a.includes($.id)?"rotate-180":""} ${$.id===v?"text-accent-primary":"text-text-muted"}`})})]})]}),a.includes($.id)&&c.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:d===$.id?c.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):(se=$.models)!=null&&se.length?$.models.map(B=>{var V;return c.jsxs("button",{type:"button",onClick:()=>N($.id,B.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":""} ${Z($.id,B.id)?"text-accent-primary":"text-text-secondary"}`,children:[c.jsx("span",{className:"truncate flex-1",children:((V=B.id.split("/").pop())==null?void 0:V.replace(/-/g," "))??B.id}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx("span",{className:"text-xs text-text-muted",children:uU(B.contextWindow)}),c.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),U($.id,B)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:c.jsx(FD,{className:"w-3 h-3 text-text-muted"})})]}),Z($.id,B.id)&&c.jsx("span",{className:"text-accent-success flex-shrink-0 ml-1",children:c.jsx(pi,{className:"w-3.5 h-3.5"})})]},B.id)}):c.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},$.id)})}),c.jsx("div",{className:"border-t border-border px-3 py-2",children:c.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),p&&c.jsx(cU,{isOpen:!0,onClose:D,providerId:p.providerId,model:p.model})]})}function hU({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:i,setDragOver:a,errorMessage:l,setErrorMessage:d,scrollContainerRef:f,sessionId:h,sessionMode:p,showHistory:g,history:x,selectedIndex:_,openHistory:v,closeHistory:S,navigateUp:w,navigateDown:k,selectCurrent:j,isAutoScrollActive:T,setAutoScroll:A,onOpenMessageSearch:P,onOpenCommandsModal:M,onOpenWorkflowsModal:q,onSelectWorkflow:Z,onSelectWorkflowWithSubGroup:J,clearInput:L}){const G=C.useRef(null),H=C.useRef(null),R=C.useRef(0),U=Th(),D=xe(le=>le.sendMessage),N=xe(le=>le.stopGeneration),F=xe(le=>le.cancelQueued),$=xe(le=>le.queuedMessages),se=C.useCallback(()=>{const le=G.current;if(!le)return;const Ce=e.length>=R.current;R.current=e.length,Ce||(le.style.height="auto"),le.style.height=`${Math.min(200,le.scrollHeight)}px`},[e]);C.useEffect(()=>{if(!h)return;const le=`openfox:draft:${h}`,Ce=localStorage.getItem(le);Ce!==null&&t(Ce)},[h,t]),C.useEffect(()=>{var le;(le=G.current)==null||le.focus(),se()},[h,se]),C.useEffect(()=>{if(!h)return;const le=`openfox:draft:${h}`,Ce=setTimeout(()=>{e?localStorage.setItem(le,e):localStorage.removeItem(le)},500);return()=>clearTimeout(Ce)},[h,e]),C.useEffect(()=>{se()},[e,se]),C.useEffect(()=>{const le=G.current;if(!le)return;const Ce=async Re=>{var De;if(document.activeElement!==le)return;const Oe=(De=Re.clipboardData)==null?void 0:De.items;if(Oe){for(const Ue of Array.from(Oe))if(Ue.type.startsWith("image/")){Re.preventDefault();const it=Ue.getAsFile();if(!it)continue;await kg(it,st=>r([...n,st]),d,{filename:"pasted-image"})}}};return le.addEventListener("paste",Ce),()=>le.removeEventListener("paste",Ce)},[n,r,d]);const B=le=>{le.preventDefault(),!(!e.trim()&&n.length===0)&&(D(e,n.length>0?n:void 0),L())},V=le=>{if(g)switch(le.key){case"Enter":{le.preventDefault();const Ce=j();Ce&&(t(Ce),S());return}case"Escape":le.preventDefault(),S(),U&&N();return;case"ArrowUp":le.preventDefault(),w();return;case"ArrowDown":le.preventDefault(),k();return}if(le.key==="ArrowUp"&&e.trim()===""&&!g){le.preventDefault(),v();return}le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),B(le))},K=C.useCallback(async le=>{const Ce=le.target.files;if(!(!Ce||Ce.length===0)){d(null);for(const Re of Array.from(Ce))await kg(Re,Oe=>r([...n,Oe]),d);H.current&&(H.current.value="")}},[n,r,d]),I=C.useCallback(le=>{le.preventDefault(),le.stopPropagation(),a(!0)},[a]),Q=C.useCallback(le=>{le.preventDefault(),le.stopPropagation(),a(!1)},[a]),W=C.useCallback(async le=>{le.preventDefault(),le.stopPropagation(),a(!1),d(null);const Ce=le.dataTransfer.files;if(!(!Ce||Ce.length===0))for(const Re of Array.from(Ce))await kg(Re,Oe=>r([...n,Oe]),d)},[n,r,a,d]),ee=C.useCallback(le=>{r(n.filter(Ce=>Ce.id!==le))},[n,r]),ne=C.useCallback(()=>{var le;(le=H.current)==null||le.click()},[]),Se=()=>{var le;!e.trim()&&n.length===0||((le=f.current)==null||le.scrollTo({top:f.current.scrollHeight,behavior:"smooth"}),D(e,n),L())};return c.jsxs("form",{onSubmit:B,className:"relative p-2 md:p-4 bg-secondary",children:[U&&c.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:c.jsx(PF,{})}),c.jsxs("div",{className:"absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2",children:[c.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors",onClick:()=>A(!T),children:[T?c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):c.jsx(gi,{className:"w-3 h-3 text-text-muted"}),T?"live":"scroll to bottom"]}),c.jsxs("button",{type:"button",onClick:P,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Browse history",children:[c.jsx(Z_,{}),"Browse history"]})]}),c.jsx("input",{ref:H,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:K,className:"hidden",multiple:!0}),l&&c.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:l}),n.length>0&&c.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(le=>c.jsx(OF,{attachment:le,onRemove:ee},le.id))}),g&&c.jsx(IF,{history:x,selectedIndex:_,onSelect:le=>{t(le),S()},onEscape:S,onNavigate:le=>{le==="up"?w():k()}}),c.jsx(ZF,{messages:$,onCancel:F}),c.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${i?"bg-accent-primary/10":"bg-primary"}`,onDragOver:I,onDragLeave:Q,onDrop:W,children:[c.jsx("textarea",{id:i2,ref:G,value:e,onChange:le=>{t(le.target.value),g&&S()},onKeyDown:V,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}),c.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[U&&c.jsxs("button",{type:"button",onClick:()=>N(),"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:[c.jsx(tk,{}),"Abort"]}),c.jsxs("div",{className:"flex items-center",children:[c.jsx("button",{type:"button",onClick:Se,disabled:!e.trim()&&n.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"}),c.jsx(QF,{onSendCommand:(le,Ce,Re,Oe)=>{var Ue;Ce&&p!==Ce&&xe.getState().switchMode(Ce);const De=Re&&Re.trim()?`${Re.trim()}
314
+
315
+ ${le}`:le;(Ue=f.current)==null||Ue.scrollTo({top:f.current.scrollHeight,behavior:"smooth"}),D(De,Oe!=null&&Oe.length?Oe:void 0,{messageKind:"command",isSystemGenerated:!0}),L()},onSelectWorkflow:Z,onSelectWorkflowWithSubGroup:J,onOpenCommandsManager:M,onOpenWorkflowsManager:q,onAttach:ne,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),c.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(sU,{}),c.jsx(aU,{})]}),c.jsx(dU,{})]})]})}function fU(e){return e==="criterion"||e==="session_metadata"}function mU(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=>fU(r.name))}function pU(e,t=[]){const n=[];let r=null,i=[],a,l=1;const d=new Map,f=new Map,h=[];for(const _ of t)_.type==="message"?d.set(_.message.id,_):_.type==="subagent"?f.set(_.subAgentId,_):_.type==="criteria-batch"&&h.push(_);let p=0;const g=()=>{if(i.length>0){const _=h[p];_&&_.type==="criteria-batch"&&_.toolCalls.length===i.length&&_.toolCalls.every((S,w)=>{var k;return S.id===((k=i[w])==null?void 0:k.id)})?n.push(_):n.push({type:"criteria-batch",toolCalls:[...i]}),p++,i=[]}},x=()=>{if(!r)return;const _=r,v=f.get(_.subAgentId);v&&v.type==="subagent"&&v.messages.length===_.messages.length&&v.messages.every((w,k)=>w===_.messages[k])?n.push(v):n.push({type:"subagent",subAgentId:_.subAgentId,subAgentType:_.subAgentType,messages:_.messages}),r=null};for(const _ of e)if(_.role!=="tool"){if(_.contextWindowId&&a&&_.contextWindowId!==a&&(g(),x(),l++,n.push({type:"context-divider",windowSequence:l})),a=_.contextWindowId,mU(_)){x();for(const v of _.toolCalls)i.push(v);continue}if(g(),_.subAgentId&&_.subAgentType)r&&r.subAgentId===_.subAgentId?r.messages.push(_):(x(),r={subAgentId:_.subAgentId,subAgentType:_.subAgentType,messages:[_]});else{x();const v=d.get(_.id);v&&v.type==="message"&&v.message===_?n.push(v):n.push({type:"message",message:_})}}return g(),x(),n}function gU(e){const{year:t,month:n,day:r}=o2(e);return`${t}/${n}/${r} ${Ih(e)}`}function _U(e,t){return e.length<=t?e:e.substring(0,t)+"..."}const xU=10,yU=150;function vU(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 bU(e){return[...e].sort((r,i)=>new Date(i.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,xU).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:gU(r.timestamp),trimmedContent:_U(r.content,yU),sessionId:r.sessionId,sessionName:r.sessionName}))}function SU(e,t,n){const r=[],i=e.filter(a=>a.role==="user"&&!a.isSystemGenerated&&a.messageKind!=="auto-prompt");for(const a of i)r.push({id:a.id,content:a.content,timestamp:a.timestamp,sessionId:n??"",sessionName:"This session"});for(const a of t)n&&a.id===n||r.push(...vU(a));return bU(r)}function wU(e,t=[],n=null){const[r,i]=C.useState(0),[a,l]=C.useState(!1),d=C.useMemo(()=>SU(e,t,n),[e,t,n]),f=C.useCallback(()=>{d.length>0&&(i(d.length-1),l(!0))},[d.length]),h=C.useCallback(()=>{l(!1),i(0)},[]),p=C.useCallback(()=>{i(_=>d.length===0?_:_===0?d.length-1:_-1)},[d.length]),g=C.useCallback(()=>{i(_=>d.length===0?_:_===d.length-1?0:_+1)},[d.length]),x=C.useCallback(()=>{if(d.length===0||!a)return null;const _=d[r];return(_==null?void 0:_.content)??null},[d,r,a]);return{history:d,selectedIndex:r,showHistory:a,openHistory:f,closeHistory:h,navigateUp:p,navigateDown:g,selectCurrent:x}}C.memo(function({item:t}){const[n,r]=C.useState(!1);return t.type==="start"?c.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:[c.jsx("span",{className:"animate-pulse",children:"●"}),c.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&c.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):c.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[c.jsx("span",{className:"text-accent-success",children:"✓"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),c.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&&c.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:c.jsx(Ki,{content:t.description})})]})]})});function CU({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t}={}){const n=e??!0,[r,i]=C.useState(""),[a,l]=C.useState([]),[d,f]=C.useState(!1),[h,p]=C.useState(null),[g,x]=C.useState(!1),[_,v]=C.useState(!1),[S,w]=C.useState(!1),[k,j]=C.useState(!1),[T,A]=C.useState(null),P=C.useRef(null),M=xe(ve=>ve.currentSession),q=xe(ve=>ve.messages),Z=xe(ve=>ve.streamingMessage),J=xe(ve=>ve.sessions),L=xe(ve=>ve.pendingQuestion),G=Th(),H=xe(ve=>ve.sendMessage),R=xe(ve=>ve.acceptAndBuild),U=xe(ve=>ve.stopGeneration),D=xe(ve=>ve.launchRunner),N=mt(ve=>ve.defaults),F=mt(ve=>ve.userItems),$=[...N,...F].filter(ve=>!ve.subagent),{history:se,selectedIndex:B,showHistory:V,openHistory:K,closeHistory:I,navigateUp:Q,navigateDown:W,selectCurrent:ee}=wU(q,J,M==null?void 0:M.id);C.useEffect(()=>{const ve=ue=>{A(ue.detail.stats)};return window.addEventListener("open-turn-stats",ve),()=>window.removeEventListener("open-turn-stats",ve)},[]),C.useEffect(()=>{Nt.getState().fetchWorkflows()},[]);const ne=C.useMemo(()=>Z?q.map(ve=>ve.id===Z.id?Z:ve):q,[q,Z]),Se=C.useRef([]),le=C.useMemo(()=>{const ve=pU(ne,Se.current);return Se.current=ve,ve},[ne]),{isAutoScrollActive:Ce,setAutoScroll:Re}=QN(P,M),Oe=C.useCallback(ve=>{var Ee;Re(!1);const ue=document.querySelector(`[data-item-index="${ve}"]`);ue&&(ue.scrollIntoView({behavior:"smooth",block:"start"}),(Ee=ue.closest('[data-testid="chat-scroll-container"]'))==null||Ee.scrollBy(0,-80))},[Re]);C.useEffect(()=>{const ve=ue=>{const Ee=S||g||_||k||T;ue.key==="Escape"&&G&&!Ee&&U(),ue.key==="ScrollLock"&&Re(!Ce)};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[G,U,Ce,S,g,_,k,T]);const De=ex();ak(De.quickAction,()=>{w(!0)}),cL(De.agentSwitching,$,ve=>{xe.getState().switchMode(ve)});const Ue=(M==null?void 0:M.mode)==="planner",it=(M==null?void 0:M.mode)==="builder",st=ve=>{const ue=r.trim()?r:void 0,Ee=a.length>0?a:void 0;Ue?R(ve,ue,Ee):it&&D(ue,Ee,ve),ze()},ye=(ve,ue)=>{const Ee=r.trim()?r:void 0,_t=a.length>0?a:void 0;Ue?R(ve,Ee,_t,ue):it&&D(Ee,_t,ve,ue),ze()},ze=()=>{i(""),l([]),M!=null&&M.id&&localStorage.removeItem(`openfox:draft:${M.id}`)};return c.jsxs(c.Fragment,{children:[c.jsxs(YM,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:t,messages:ne,children:[L&&c.jsx(gF,{question:L}),c.jsx(JM,{}),T&&c.jsx(ZM,{stats:T,onClose:()=>A(null)}),c.jsx(_F,{}),c.jsx(mF,{displayItems:le,scrollContainerRef:P,highlightedMessageId:null}),c.jsx(hU,{input:r,setInput:i,attachments:a,setAttachments:l,dragOver:d,setDragOver:f,errorMessage:h,setErrorMessage:p,scrollContainerRef:P,sessionId:M==null?void 0:M.id,sessionMode:M==null?void 0:M.mode,showHistory:V,history:se,selectedIndex:B,openHistory:K,closeHistory:I,navigateUp:Q,navigateDown:W,selectCurrent:ee,isAutoScrollActive:Ce,setAutoScroll:Re,onOpenMessageSearch:()=>j(!0),onOpenCommandsModal:()=>x(!0),onOpenWorkflowsModal:()=>v(!0),onSelectWorkflow:st,onSelectWorkflowWithSubGroup:ye,clearInput:ze}),c.jsx(ZN,{isOpen:g,onClose:()=>x(!1)}),c.jsx(nj,{isOpen:_,onClose:()=>v(!1)}),c.jsx(TF,{isOpen:S,onClose:()=>w(!1),onSearchMessages:()=>j(!0),isAutoScrollActive:Ce,onToggleAutoScroll:Re,textareaContent:r,onCloseComplete:s2,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(ve,ue)=>{const Ee=await mn.getState().fetchCommand(ve);if(Ee){const _t=ue!=null&&ue.trim()?`${ue.trim()}
316
+
317
+ ${Ee.prompt}`:Ee.prompt;Ee.metadata.agentMode&&xe.getState().switchMode(Ee.metadata.agentMode),H(_t,a!=null&&a.length?a:void 0,{messageKind:"command",isSystemGenerated:!0}),ze()}},onSelectWorkflow:ve=>{const ue=r.trim()||void 0,Ee=a.length>0?a:void 0;(M==null?void 0:M.mode)==="planner"?xe.getState().acceptAndBuild(ve,ue,Ee):xe.getState().launchRunner(ue,Ee,ve),ze()}})]}),k&&c.jsx(MF,{isOpen:k,onClose:()=>j(!1),displayItems:le,onNavigate:Oe})]})}function TC({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[i,a]=C.useState(""),l=C.useRef(null);C.useEffect(()=>{e&&(a(""),setTimeout(()=>{var f;return(f=l.current)==null?void 0:f.focus()},100))},[e]);const d=f=>{f.preventDefault(),i.trim()&&n(i)};return c.jsx(jt,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:c.jsxs("form",{onSubmit:d,className:"space-y-4",children:[c.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."}),c.jsx(Ph,{ref:l,type:"password",value:i,onChange:f=>a(f.target.value),placeholder:"Enter password",autoFocus:!0}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx(Ze,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),c.jsx(Ze,{type:"submit",disabled:!i.trim(),children:t?"Try Again":"Connect"})]})]})})}function kU({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return c.jsx("div",{className:"flex justify-center py-6",children:c.jsx("div",{className:"flex items-center",children:Array.from({length:t},(i,a)=>{const l=a+1,d=l<e,f=l===e;return c.jsxs("div",{className:"flex items-center",children:[c.jsx("button",{onClick:()=>r==null?void 0:r(l),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":f?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:d?"✓":l}),c.jsx("button",{onClick:()=>r==null?void 0:r(l),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${f?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[a]}),a<t-1&&c.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${d?"bg-accent-primary":"bg-border"}`})]},a)})})})}const EU=[8e3,11434,8080],NU=[{name:"OpenCode Go",url:"https://opencode.ai/zen/go/v1",backend:"opencode-go"}];function jU({onNext:e}){const[t,n]=C.useState([]),[r,i]=C.useState([]),[a,l]=C.useState(!1),[d,f]=C.useState(""),[h,p]=C.useState(""),[g,x]=C.useState(""),[_,v]=C.useState("auto"),[S,w]=C.useState(!1),[k,j]=C.useState(null),[T,A]=C.useState(null),[P,M]=C.useState(null),[q,Z]=C.useState("");C.useEffect(()=>{J()},[]);async function J(){try{const D=await Ne("/api/providers");if(D.ok){const F=(await D.json()).providers.map($=>({id:$.id,name:$.name,url:$.url,backend:$.backend,model:null,apiKey:$.apiKey}));n(F),i(F)}}catch{}}async function L(D){w(!0),j(null);const N=_!=="auto";try{const $=await(await Ne("/api/providers/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:D,skipBackendDetection:N})})).json();$.success?(N||v($.backend??"auto"),j({success:!0,model:$.model??void 0})):j({success:!1,error:$.error??"Connection failed"})}catch(F){j({success:!1,error:F instanceof Error?F.message:"Connection failed"})}w(!1)}function G(){if(!h)return;const D=d||`Provider ${r.length+1}`,N={id:`temp-${Date.now()}`,name:D,url:h,backend:k!=null&&k.success?_:"auto",model:k!=null&&k.success?k.model??null:null,apiKey:g||void 0};i([...r,N]),f(""),p(""),x(""),j(null)}function H(D){A(D),t.some(F=>F.id===D)?Ne(`/api/providers/${D}`,{method:"DELETE"}).then(()=>{i(r.filter(F=>F.id!==D)),n(t.filter(F=>F.id!==D)),A(null)}).catch(()=>{A(null)}):(i(r.filter(F=>F.id!==D)),A(null))}async function R(){for(const N of r)(N.id.startsWith("temp-")||!t.some(F=>F.id===N.id))&&((await Ne("/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 D=r.filter(N=>!N.id.startsWith("temp-"));e({providers:D})}const U=r.length>0;return c.jsxs("div",{className:"max-w-xl mx-auto",children:[c.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),c.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),c.jsxs("div",{className:"space-y-4",children:[r.length>0?c.jsx("div",{className:"space-y-2",children:r.map(D=>c.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:Tg(D.backend)}),P===D.id?c.jsx("input",{type:"text",value:q,onChange:N=>Z(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(i(r.map(F=>F.id===D.id?{...F,name:q}:F)),M(null)),N.key==="Escape"&&M(null)},onBlur:()=>{i(r.map(N=>N.id===D.id?{...N,name:q}:N)),M(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}):c.jsx("span",{className:"text-text-primary font-medium cursor-pointer hover:text-accent-primary",onClick:()=>{M(D.id),Z(D.name)},title:"Click to edit",children:D.name})]}),c.jsx("p",{className:"text-text-muted text-sm mt-1",children:D.url}),D.model&&c.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",D.model]})]}),c.jsx("button",{onClick:()=>H(D.id),disabled:T===D.id,className:"p-2 text-text-muted hover:text-red-500 transition-colors disabled:opacity-50",title:"Remove provider",children:c.jsx(Bc,{})})]},D.id))}):c.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:c.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),a?c.jsxs("form",{onSubmit:D=>{D.preventDefault(),h&&G()},className:"space-y-4 p-4 bg-bg-tertiary rounded-lg",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Service Presets"}),c.jsx("div",{className:"grid grid-cols-2 gap-2",children:NU.map(D=>c.jsx("button",{type:"button",onClick:()=>{f(D.name),p(D.url),v(D.backend),j(null)},className:`p-2 rounded border text-center text-sm transition-colors ${h===D.url?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:D.name},D.name))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Local Presets"}),c.jsx("div",{className:"grid grid-cols-3 gap-2",children:EU.map(D=>c.jsxs("button",{type:"button",onClick:()=>{f(""),p(`http://localhost:${D}`),v("auto"),j(null)},className:`p-2 rounded border text-center text-sm transition-colors ${h===`http://localhost:${D}`?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:["localhost:",D]},D))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Or enter address manually"}),c.jsx("input",{type:"text",name:"url",value:h,onChange:D=>{p(D.target.value),j(null)},onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),L(h))},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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name (optional)"}),c.jsx("input",{type:"text",name:"name",value:d,onChange:D=>f(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),G())},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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),c.jsx("input",{type:"password",name:"apiKey",value:g,onChange:D=>x(D.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"})]}),k&&c.jsx("div",{className:`p-3 rounded-lg ${k.success?"bg-accent-primary/10":"bg-red-500/10"}`,children:k.success?c.jsxs("p",{className:"text-accent-primary font-medium",children:["✓ Connected to ",Tg(_),k.model&&` (${k.model})`]}):c.jsx("p",{className:"text-red-500",children:k.error})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",onClick:()=>L(h),disabled:!h||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?c.jsx($s,{className:"w-4 h-4"}):"Test Connection"}),c.jsx("button",{type:"submit",disabled:!h,"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:k!=null&&k.success?"Add Provider ✓":"Add Provider"})]}),c.jsx("button",{type:"button",onClick:()=>{l(!1),f(""),p(""),j(null)},className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]}):c.jsxs("button",{onClick:()=>l(!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:[c.jsx($s,{className:"w-4 h-4"}),"Add Provider"]}),c.jsx("button",{onClick:R,disabled:!U,"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 TU({onNext:e}){const[t,n]=C.useState(""),[r,i]=C.useState(!1);return C.useEffect(()=>{Ne("/api/config").then(a=>a.json()).then(a=>{a.workdir?n(a.workdir):fetch("/api/directories?path="+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})}).catch(()=>{fetch("/api/directories?path="+encodeURIComponent("/home")).then(a=>a.json()).then(a=>{a.current&&n(a.current)}).catch(()=>{})})},[]),c.jsxs("div",{className:"max-w-xl mx-auto",children:[c.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),c.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",value:t,onChange:a=>n(a.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"}),c.jsx("button",{onClick:()=>i(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&c.jsx(f2,{initialPath:t||void 0,onSelect:a=>{n(a),i(!1)},onClose:()=>i(!1)}),c.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 AU({onNext:e}){const[t,n]=C.useState(!1),[r,i]=C.useState("http://localhost:11434"),[a,l]=C.useState("qwen3.5:0.8b"),{copied:d,copy:f}=GN();C.useEffect(()=>{Ne("/api/config").then(p=>p.json()).then(p=>{p.visionFallback&&(n(p.visionFallback.enabled),i(p.visionFallback.url),l(p.visionFallback.model))}).catch(()=>{})},[]);function h(p){if(p){e({});return}e({visionFallback:{enabled:t,url:r,model:a,timeout:120}})}return c.jsxs("div",{className:"max-w-xl mx-auto",children:[c.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),c.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[c.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"To enable vision support, you need an Ollama server with a vision model:"}),c.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),c.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[c.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),c.jsx("button",{onClick:()=>f("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:d?c.jsx(pi,{className:"w-4 h-4 text-accent-primary"}):c.jsx(HD,{className:"w-4 h-4"})})]})]}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:t,onChange:p=>n(p.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),c.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),t&&c.jsxs("div",{className:"space-y-4 pl-8",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),c.jsx("input",{type:"text",value:r,onChange:p=>i(p.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),c.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),placeholder:"qwen3.5:0.8b",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.jsxs("div",{className:"flex items-center justify-between pt-4",children:[c.jsx("button",{onClick:()=>h(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),c.jsx("button",{onClick:()=>h(!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 DU({onComplete:e}){const[t,n]=C.useState(1),[r,i]=C.useState(!1),[a,l]=C.useState({});async function d(g){l(x=>({...x,providers:g.providers})),n(2)}async function f(g){l(x=>({...x,...g})),n(3)}async function h(g){i(!0);try{if(!(await Ne("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:a.workdir,visionFallback:g.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(x){console.error("Failed to save onboarding data:",x),i(!1)}}const p=g=>{n(g)};return c.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[c.jsx(Wc,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),c.jsx(kU,{currentStep:t,totalSteps:3,labels:["LLM Server","Projects Folder","Vision"],onStepClick:p}),c.jsx("div",{className:"max-w-xl mx-auto",children:r?c.jsxs("div",{className:"text-center",children:[c.jsx($s,{className:"w-6 h-6"}),c.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):c.jsxs(c.Fragment,{children:[t===1&&c.jsx(jU,{onNext:d}),t===2&&c.jsx(TU,{onNext:f}),t===3&&c.jsx(AU,{onNext:h})]})})]})}const AC="openfox_updated_to",DC="update_pending";function LU(){const[e,t]=C.useState(!1),n=localStorage.getItem(AC),r=localStorage.getItem(DC);C.useEffect(()=>{if(!n||!r)return;const a=setTimeout(()=>t(!0),3e4);return()=>clearTimeout(a)},[n,r]);const i=()=>{localStorage.removeItem(AC),localStorage.removeItem(DC),t(!0)};return e||r!=="true"||!n?null:c.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:[c.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:c.jsx(pi,{className:"w-3 h-3 text-accent-primary"})}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),c.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),c.jsx("button",{onClick:i,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:c.jsx(nk,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Gt.getState().loadUserPresets(),Gt.getState().applySavedTheme());function ey(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function aj(){return c.jsx("div",{className:"flex-1 flex items-center justify-center",children:c.jsx(Gc,{})})}function RU({sidebarOpen:e,onSidebarToggle:t}){const[,n]=K_("/p/:projectId"),r=n==null?void 0:n.projectId,i=xe(f=>f.connectionStatus),a=Ut(f=>f.currentProject),l=ey();return OD({canLoad:i==="connected"||l,projectId:r,currentProjectId:a==null?void 0:a.id}),!a||a.id!==r?c.jsx(aj,{}):c.jsxs(c.Fragment,{children:[c.jsx(c2,{projectId:r,isOpen:e,onClose:t}),c.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:c.jsx(cM,{})})]})}function MU({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,i]=K_("/p/:projectId/s/:sessionId"),a=i==null?void 0:i.projectId,l=i==null?void 0:i.sessionId,[,d]=Qr(),f=xe(S=>S.connectionStatus),h=xe(S=>S.currentSession),p=xe(S=>S.error),g=xe(S=>S.clearError),x=Ut(S=>S.currentProject),_=ey();return ID({canLoad:f==="connected"||_,projectId:a,sessionId:l,currentProjectId:x==null?void 0:x.id,currentSessionId:h==null?void 0:h.id}),C.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&a&&(g(),d(`/p/${a}`))},[p,a,g,d]),!x||x.id!==a?c.jsx(aj,{}):c.jsxs(c.Fragment,{children:[c.jsx(c2,{projectId:a,isOpen:e,onClose:t}),c.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:c.jsx(CU,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})})]})}function OU(){const e=Ot(n=>n.fetchConfig);function t(){e(),window.history.back()}return c.jsx("div",{className:"flex-1 overflow-y-auto",children:c.jsx(DU,{onComplete:t})})}function IU(){const{connectionStatus:e}=LD(),t=Ot(D=>D.fetchConfig),n=Ot(D=>D.refreshProviderModels),r=Ot(D=>D.providers),i=Ot(D=>D.activeProviderId),[,a]=Qr(),l=ey(),[d,f]=C.useState(!1);C.useEffect(()=>{(e==="connected"||l)&&t().then(()=>{f(!0),tn.getState().getSettings([...IC,Me.DISPLAY_THEME,Me.DISPLAY_USER_PRESETS])})},[e,l,t]),C.useEffect(()=>{d&&i&&n(i).then(()=>{const D=Ot.getState().defaultModelSelection;(D?D.split("/")[0]:null)!==i&&t()})},[d,i,n,t]);const h=tn(D=>D.settings);C.useEffect(()=>{d&&r.length===0&&a("/onboarding")},[d,r.length]),C.useEffect(()=>{const{applyPreset:D,applyTokens:N,setFollowSystemTheme:F,initSystemThemeListener:$}=Gt.getState(),se=h[Me.DISPLAY_THEME],B=h[Me.DISPLAY_USER_PRESETS],V=h[Me.DISPLAY_FOLLOW_SYSTEM_THEME];if(B&&localStorage.setItem("openfox:userPresets",B),se){localStorage.setItem("openfox:theme",se);try{const I=JSON.parse(se);I.preset&&I.tokens?(D(I.preset),Gt.setState({basePreset:I.preset}),N(I.tokens)):I.preset?D(I.preset):I.tokens&&N(I.tokens)}catch{D("dark")}}else D("dark");V!==void 0&&F(V==="true");const K=$();return()=>K()},[h[Me.DISPLAY_THEME],h[Me.DISPLAY_USER_PRESETS],h[Me.DISPLAY_FOLLOW_SYSTEM_THEME]]);const p=()=>{const D=localStorage.getItem("openfox:leftSidebar");return D!==null?D==="true":!0},g=()=>{const D=localStorage.getItem("openfox:rightSidebar");return D!==null?D==="true":!0},[x,_]=C.useState(p),[v,S]=C.useState(g),[w,k]=C.useState(!1),[j,T]=C.useState(!1),[A,P]=C.useState(!1),M=BA();C.useEffect(()=>{const D=()=>{P(window.innerWidth<768)};return D(),window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]);const q=A?w:x,Z=A?j:v,J=()=>{A?k(!w):_(!x)},L=()=>{A?T(!j):S(!v)};C.useEffect(()=>{A||localStorage.setItem("openfox:leftSidebar",String(x))},[x,A]),C.useEffect(()=>{A||localStorage.setItem("openfox:rightSidebar",String(v))},[v,A]),C.useEffect(()=>{(e==="connected"||l)&&t()},[e,t,l]);const G=xe(D=>D.showPasswordModal),H=xe(D=>D.passwordModalRetry),R=xe(D=>D.submitPassword),U=xe(D=>D.cancelPassword);return e!=="connected"&&!G&&!l?c.jsxs(c.Fragment,{children:[c.jsx(TC,{isOpen:!0,isRetry:H,onSubmit:R,onCancel:U}),c.jsx("div",{className:"h-screen flex items-center justify-center",children:c.jsx(sM,{text:"Connecting to server..."})})]}):c.jsxs(c.Fragment,{children:[c.jsx(TC,{isOpen:G,isRetry:H,onSubmit:R,onCancel:U}),c.jsxs("div",{className:"flex flex-col",style:{height:A?`calc(${M.offsetTop}px + ${M.height}px)`:"100vh"},children:[c.jsx(tM,{}),c.jsx(Y3,{onMenuClick:J,onCriteriaToggle:L}),c.jsx("div",{className:"flex-1 flex overflow-hidden",children:c.jsxs(aD,{children:[c.jsx(ql,{path:"/onboarding",children:c.jsx(OU,{})}),c.jsx(ql,{path:"/p/:projectId/s/:sessionId",children:c.jsx(MU,{sidebarOpen:q,onSidebarToggle:J,rightSidebarOpen:Z,onRightSidebarToggle:L})}),c.jsx(ql,{path:"/p/:projectId/new",children:c.jsx(lM,{})}),c.jsx(ql,{path:"/p/:projectId",children:c.jsx(RU,{sidebarOpen:q,onSidebarToggle:J})}),c.jsx(ql,{path:"/",children:c.jsx(oM,{})})]})})]}),c.jsx(LU,{})]})}RA.createRoot(document.getElementById("root")).render(c.jsx(Ls.StrictMode,{children:c.jsx(IU,{})}));