openfox 2.0.87 → 2.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1048 -0
- package/dist/CHANGELOG.md +1048 -0
- package/dist/{chat-handler-AVGJQSYW.js → chat-handler-HB3XN6YE.js} +13 -13
- package/dist/{chunk-L4S5N3WV.js → chunk-2DWWLQVQ.js} +2 -2
- package/dist/{chunk-FY6FQTNN.js → chunk-5UHHGQ7Q.js} +4 -4
- package/dist/{chunk-VGYV5EH6.js → chunk-6YJ5W4KV.js} +75 -59
- package/dist/{chunk-BKH4SIWV.js → chunk-76ADL7EV.js} +7 -7
- package/dist/{chunk-5W2FIWDH.js → chunk-B53QORTX.js} +2 -2
- package/dist/{chunk-STFIEU5F.js → chunk-BNQTJFHQ.js} +3 -1
- package/dist/{chunk-FYYPQ27K.js → chunk-BOO6VR2T.js} +2 -2
- package/dist/{chunk-V5LOH363.js → chunk-DZGVDT2F.js} +4 -4
- package/dist/{chunk-B6VZS5SC.js → chunk-EWUDWUE3.js} +10 -10
- package/dist/chunk-FGK7QLCZ.js +7 -0
- package/dist/{chunk-3JYPDZT2.js → chunk-GLRBRQGJ.js} +2 -2
- package/dist/{chunk-CK7G2JLY.js → chunk-GO54OTGE.js} +11 -11
- package/dist/{chunk-ACL4YUJH.js → chunk-LD46ASP5.js} +2 -2
- package/dist/{chunk-SBVKT4GT.js → chunk-QMSTCWYK.js} +12 -12
- package/dist/{chunk-M6X72DYZ.js → chunk-SUT4OSXR.js} +3 -3
- package/dist/{chunk-OHKBGMLO.js → chunk-TW3PNLMA.js} +2 -2
- package/dist/{chunk-H765CIHN.js → chunk-TXGW36XL.js} +2 -2
- package/dist/{chunk-WVMOGE7U.js → chunk-V4V6UGZZ.js} +3 -3
- package/dist/{chunk-MTZ3PC6K.js → chunk-WWOZHM6D.js} +2 -2
- package/dist/{chunk-W23S3TU5.js → chunk-XNPVKFOJ.js} +2 -2
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-C2P67MA4.js → client-W3AYWMJM.js} +4 -4
- package/dist/{compactor-2YT66FDZ.js → compactor-7JU5CXSG.js} +9 -9
- package/dist/{events-OEDAFNEI.js → events-Z3AJVFSP.js} +6 -6
- package/dist/{folding-FGTCP73N.js → folding-LWKKC4RQ.js} +4 -4
- package/dist/{http-client-I52X7GQB.js → http-client-LITXNO6R.js} +3 -3
- package/dist/{manager-TD2UT62O.js → manager-657CWC5Z.js} +4 -4
- package/dist/{orchestrator-AGJ7EMFZ.js → orchestrator-KTOC65UU.js} +12 -12
- package/dist/package.json +3 -2
- package/dist/{path-security-DWL3R2SF.js → path-security-XXWK5ZCL.js} +7 -7
- package/dist/{platform-OYKGQ7Z3.js → platform-MVVEGKPE.js} +3 -3
- package/dist/{processor-VCDVG7RV.js → processor-3UTJE7EQ.js} +13 -13
- package/dist/{provider-YNYYAR6C.js → provider-YRNABOCC.js} +5 -5
- package/dist/{provider-manager-3DW3A2VC.js → provider-manager-W4MEPXB5.js} +5 -5
- package/dist/{serve-IGWUSQDZ.js → serve-AZ5QSSHE.js} +19 -19
- package/dist/server/index.js +18 -18
- package/dist/{server-3X46OIYC.js → server-T4YPLZDF.js} +14 -14
- package/dist/{sessions-V3BF2OTU.js → sessions-KDQ5TMHX.js} +4 -4
- package/dist/{settings-AGNYWEIE.js → settings-SM3K6S74.js} +2 -2
- package/dist/{tools-X65P65KF.js → tools-A2XBFPRO.js} +11 -11
- package/dist/{update-6GITMIFG.js → update-4D76LEVO.js} +2 -2
- package/dist/web/assets/index-BRy1cx3_.js +306 -0
- package/dist/web/assets/index-D8gCHkwE.css +32 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +3 -2
- package/dist/chunk-3USWJ6MR.js +0 -7
- package/dist/web/assets/index-CsWZt1m8.css +0 -32
- package/dist/web/assets/index-D-r8G7Tf.js +0 -305
|
@@ -0,0 +1,306 @@
|
|
|
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 lj=Object.defineProperty;var cj=Object.getPrototypeOf;var uj=Reflect.get;var Iv=e=>{throw TypeError(e)};var dj=(e,t,n)=>t in e?lj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Se=(e,t,n)=>dj(e,typeof t!="symbol"?t+"":t,n),Xf=(e,t,n)=>t.has(e)||Iv("Cannot "+n);var Mn=(e,t,n)=>(Xf(e,t,"read from private field"),n?n.call(e):t.get(e)),Ti=(e,t,n)=>t.has(e)?Iv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Tr=(e,t,n,r)=>(Xf(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Qf=(e,t,n)=>(Xf(e,t,"access private method"),n);var Mv=(e,t,n)=>uj(cj(e),n,t);function hj(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const l=Object.getOwnPropertyDescriptor(r,a);l&&Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function ud(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Jf={exports:{}},nl={};/**
|
|
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 Pv;function fj(){if(Pv)return nl;Pv=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,l){var u=null;if(l!==void 0&&(u=""+l),a.key!==void 0&&(u=""+a.key),"key"in a){l={};for(var c in a)c!=="key"&&(l[c]=a[c])}else l=a;return a=l.ref,{$$typeof:e,type:r,key:u,ref:a!==void 0?a:null,props:l}}return nl.Fragment=t,nl.jsx=n,nl.jsxs=n,nl}var Bv;function mj(){return Bv||(Bv=1,Jf.exports=fj()),Jf.exports}var i=mj(),Zf={exports:{}},rt={};/**
|
|
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 $v;function pj(){if($v)return rt;$v=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),x=Symbol.iterator;function y($){return $===null||typeof $!="object"?null:($=x&&$[x]||$["@@iterator"],typeof $=="function"?$:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,_={};function S($,q,B){this.props=$,this.context=q,this.refs=_,this.updater=B||w}S.prototype.isReactComponent={},S.prototype.setState=function($,q){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,q,"setState")},S.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function b(){}b.prototype=S.prototype;function v($,q,B){this.props=$,this.context=q,this.refs=_,this.updater=B||w}var E=v.prototype=new b;E.constructor=v,C(E,S.prototype),E.isPureReactComponent=!0;var j=Array.isArray;function T(){}var D={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function O($,q,B){var ee=B.ref;return{$$typeof:e,type:$,key:q,ref:ee!==void 0?ee:null,props:B}}function M($,q){return O($.type,q,$.props)}function W($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function z($){var q={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(B){return q[B]})}var R=/\/+/g;function P($,q){return typeof $=="object"&&$!==null&&$.key!=null?z(""+$.key):q.toString(36)}function V($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(T,T):($.status="pending",$.then(function(q){$.status==="pending"&&($.status="fulfilled",$.value=q)},function(q){$.status==="pending"&&($.status="rejected",$.reason=q)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function G($,q,B,ee,X){var ne=typeof $;(ne==="undefined"||ne==="boolean")&&($=null);var K=!1;if($===null)K=!0;else switch(ne){case"bigint":case"string":case"number":K=!0;break;case"object":switch($.$$typeof){case e:case t:K=!0;break;case p:return K=$._init,G(K($._payload),q,B,ee,X)}}if(K)return X=X($),K=ee===""?"."+P($,0):ee,j(X)?(B="",K!=null&&(B=K.replace(R,"$&/")+"/"),G(X,q,B,"",function(se){return se})):X!=null&&(W(X)&&(X=M(X,B+(X.key==null||$&&$.key===X.key?"":(""+X.key).replace(R,"$&/")+"/")+K)),q.push(X)),1;K=0;var F=ee===""?".":ee+":";if(j($))for(var te=0;te<$.length;te++)ee=$[te],ne=F+P(ee,te),K+=G(ee,q,B,ne,X);else if(te=y($),typeof te=="function")for($=te.call($),te=0;!(ee=$.next()).done;)ee=ee.value,ne=F+P(ee,te++),K+=G(ee,q,B,ne,X);else if(ne==="object"){if(typeof $.then=="function")return G(V($),q,B,ee,X);throw q=String($),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return K}function Z($,q,B){if($==null)return $;var ee=[],X=0;return G($,ee,"","",function(ne){return q.call(B,ne,X++)}),ee}function Q($){if($._status===-1){var q=$._result;q=q(),q.then(function(B){($._status===0||$._status===-1)&&($._status=1,$._result=B)},function(B){($._status===0||$._status===-1)&&($._status=2,$._result=B)}),$._status===-1&&($._status=0,$._result=q)}if($._status===1)return $._result.default;throw $._result}var U=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},I={map:Z,forEach:function($,q,B){Z($,function(){q.apply(this,arguments)},B)},count:function($){var q=0;return Z($,function(){q++}),q},toArray:function($){return Z($,function(q){return q})||[]},only:function($){if(!W($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return rt.Activity=m,rt.Children=I,rt.Component=S,rt.Fragment=n,rt.Profiler=a,rt.PureComponent=v,rt.StrictMode=r,rt.Suspense=d,rt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,rt.__COMPILER_RUNTIME={__proto__:null,c:function($){return D.H.useMemoCache($)}},rt.cache=function($){return function(){return $.apply(null,arguments)}},rt.cacheSignal=function(){return null},rt.cloneElement=function($,q,B){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var ee=C({},$.props),X=$.key;if(q!=null)for(ne in q.key!==void 0&&(X=""+q.key),q)!L.call(q,ne)||ne==="key"||ne==="__self"||ne==="__source"||ne==="ref"&&q.ref===void 0||(ee[ne]=q[ne]);var ne=arguments.length-2;if(ne===1)ee.children=B;else if(1<ne){for(var K=Array(ne),F=0;F<ne;F++)K[F]=arguments[F+2];ee.children=K}return O($.type,X,ee)},rt.createContext=function($){return $={$$typeof:u,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:l,_context:$},$},rt.createElement=function($,q,B){var ee,X={},ne=null;if(q!=null)for(ee in q.key!==void 0&&(ne=""+q.key),q)L.call(q,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(X[ee]=q[ee]);var K=arguments.length-2;if(K===1)X.children=B;else if(1<K){for(var F=Array(K),te=0;te<K;te++)F[te]=arguments[te+2];X.children=F}if($&&$.defaultProps)for(ee in K=$.defaultProps,K)X[ee]===void 0&&(X[ee]=K[ee]);return O($,ne,X)},rt.createRef=function(){return{current:null}},rt.forwardRef=function($){return{$$typeof:c,render:$}},rt.isValidElement=W,rt.lazy=function($){return{$$typeof:p,_payload:{_status:-1,_result:$},_init:Q}},rt.memo=function($,q){return{$$typeof:f,type:$,compare:q===void 0?null:q}},rt.startTransition=function($){var q=D.T,B={};D.T=B;try{var ee=$(),X=D.S;X!==null&&X(B,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(T,U)}catch(ne){U(ne)}finally{q!==null&&B.types!==null&&(q.types=B.types),D.T=q}},rt.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},rt.use=function($){return D.H.use($)},rt.useActionState=function($,q,B){return D.H.useActionState($,q,B)},rt.useCallback=function($,q){return D.H.useCallback($,q)},rt.useContext=function($){return D.H.useContext($)},rt.useDebugValue=function(){},rt.useDeferredValue=function($,q){return D.H.useDeferredValue($,q)},rt.useEffect=function($,q){return D.H.useEffect($,q)},rt.useEffectEvent=function($){return D.H.useEffectEvent($)},rt.useId=function(){return D.H.useId()},rt.useImperativeHandle=function($,q,B){return D.H.useImperativeHandle($,q,B)},rt.useInsertionEffect=function($,q){return D.H.useInsertionEffect($,q)},rt.useLayoutEffect=function($,q){return D.H.useLayoutEffect($,q)},rt.useMemo=function($,q){return D.H.useMemo($,q)},rt.useOptimistic=function($,q){return D.H.useOptimistic($,q)},rt.useReducer=function($,q,B){return D.H.useReducer($,q,B)},rt.useRef=function($){return D.H.useRef($)},rt.useState=function($){return D.H.useState($)},rt.useSyncExternalStore=function($,q,B){return D.H.useSyncExternalStore($,q,B)},rt.useTransition=function(){return D.H.useTransition()},rt.version="19.2.4",rt}var zv;function dd(){return zv||(zv=1,Zf.exports=pj()),Zf.exports}var A=dd();const ri=ud(A),gj=hj({__proto__:null,default:ri},[A]);var em={exports:{}},rl={},tm={exports:{}},nm={};/**
|
|
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 Hv;function xj(){return Hv||(Hv=1,(function(e){function t(G,Z){var Q=G.length;G.push(Z);e:for(;0<Q;){var U=Q-1>>>1,I=G[U];if(0<a(I,Z))G[U]=Z,G[Q]=I,Q=U;else break e}}function n(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var Z=G[0],Q=G.pop();if(Q!==Z){G[0]=Q;e:for(var U=0,I=G.length,$=I>>>1;U<$;){var q=2*(U+1)-1,B=G[q],ee=q+1,X=G[ee];if(0>a(B,Q))ee<I&&0>a(X,B)?(G[U]=X,G[ee]=Q,U=ee):(G[U]=B,G[q]=Q,U=q);else if(ee<I&&0>a(X,Q))G[U]=X,G[ee]=Q,U=ee;else break e}}return Z}function a(G,Z){var Q=G.sortIndex-Z.sortIndex;return Q!==0?Q:G.id-Z.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,x=3,y=!1,w=!1,C=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;function E(G){for(var Z=n(f);Z!==null;){if(Z.callback===null)r(f);else if(Z.startTime<=G)r(f),Z.sortIndex=Z.expirationTime,t(d,Z);else break;Z=n(f)}}function j(G){if(C=!1,E(G),!w)if(n(d)!==null)w=!0,T||(T=!0,z());else{var Z=n(f);Z!==null&&V(j,Z.startTime-G)}}var T=!1,D=-1,L=5,O=-1;function M(){return _?!0:!(e.unstable_now()-O<L)}function W(){if(_=!1,T){var G=e.unstable_now();O=G;var Z=!0;try{e:{w=!1,C&&(C=!1,b(D),D=-1),y=!0;var Q=x;try{t:{for(E(G),m=n(d);m!==null&&!(m.expirationTime>G&&M());){var U=m.callback;if(typeof U=="function"){m.callback=null,x=m.priorityLevel;var I=U(m.expirationTime<=G);if(G=e.unstable_now(),typeof I=="function"){m.callback=I,E(G),Z=!0;break t}m===n(d)&&r(d),E(G)}else r(d);m=n(d)}if(m!==null)Z=!0;else{var $=n(f);$!==null&&V(j,$.startTime-G),Z=!1}}break e}finally{m=null,x=Q,y=!1}Z=void 0}}finally{Z?z():T=!1}}}var z;if(typeof v=="function")z=function(){v(W)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,P=R.port2;R.port1.onmessage=W,z=function(){P.postMessage(null)}}else z=function(){S(W,0)};function V(G,Z){D=S(function(){G(e.unstable_now())},Z)}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(G){G.callback=null},e.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<G?Math.floor(1e3/G):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(G){switch(x){case 1:case 2:case 3:var Z=3;break;default:Z=x}var Q=x;x=Z;try{return G()}finally{x=Q}},e.unstable_requestPaint=function(){_=!0},e.unstable_runWithPriority=function(G,Z){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var Q=x;x=G;try{return Z()}finally{x=Q}},e.unstable_scheduleCallback=function(G,Z,Q){var U=e.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?U+Q:U):Q=U,G){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=Q+I,G={id:p++,callback:Z,priorityLevel:G,startTime:Q,expirationTime:I,sortIndex:-1},Q>U?(G.sortIndex=Q,t(f,G),n(d)===null&&G===n(f)&&(C?(b(D),D=-1):C=!0,V(j,Q-U))):(G.sortIndex=I,t(d,G),w||y||(w=!0,T||(T=!0,z()))),G},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(G){var Z=x;return function(){var Q=x;x=Z;try{return G.apply(this,arguments)}finally{x=Q}}}})(nm)),nm}var Uv;function yj(){return Uv||(Uv=1,tm.exports=xj()),tm.exports}var rm={exports:{}},An={};/**
|
|
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 Fv;function bj(){if(Fv)return An;Fv=1;var e=dd();function t(d){var f="https://react.dev/errors/"+d;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)f+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+d+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function l(d,f,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:m==null?null:""+m,children:d,containerInfo:f,implementation:p}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(d,f){if(d==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return An.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,An.createPortal=function(d,f){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return l(d,f,null,p)},An.flushSync=function(d){var f=u.T,p=r.p;try{if(u.T=null,r.p=2,d)return d()}finally{u.T=f,r.p=p,r.d.f()}},An.preconnect=function(d,f){typeof d=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,r.d.C(d,f))},An.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},An.preinit=function(d,f){if(typeof d=="string"&&f&&typeof f.as=="string"){var p=f.as,m=c(p,f.crossOrigin),x=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;p==="style"?r.d.S(d,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:m,integrity:x,fetchPriority:y}):p==="script"&&r.d.X(d,{crossOrigin:m,integrity:x,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},An.preinitModule=function(d,f){if(typeof d=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var p=c(f.as,f.crossOrigin);r.d.M(d,{crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&r.d.M(d)},An.preload=function(d,f){if(typeof d=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var p=f.as,m=c(p,f.crossOrigin);r.d.L(d,p,{crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},An.preloadModule=function(d,f){if(typeof d=="string")if(f){var p=c(f.as,f.crossOrigin);r.d.m(d,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else r.d.m(d)},An.requestFormReset=function(d){r.d.r(d)},An.unstable_batchedUpdates=function(d,f){return d(f)},An.useFormState=function(d,f,p){return u.H.useFormState(d,f,p)},An.useFormStatus=function(){return u.H.useHostTransitionStatus()},An.version="19.2.4",An}var Vv;function VS(){if(Vv)return rm.exports;Vv=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(),rm.exports=bj(),rm.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 Gv;function vj(){if(Gv)return rl;Gv=1;var e=yj(),t=dd(),n=VS();function r(s){var o="https://react.dev/errors/"+s;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)o+="&args[]="+encodeURIComponent(arguments[h])}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 a(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function l(s){var o=s,h=s;if(s.alternate)for(;o.return;)o=o.return;else{s=o;do o=s,(o.flags&4098)!==0&&(h=o.return),s=o.return;while(s)}return o.tag===3?h:null}function u(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 c(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 d(s){if(l(s)!==s)throw Error(r(188))}function f(s){var o=s.alternate;if(!o){if(o=l(s),o===null)throw Error(r(188));return o!==s?null:s}for(var h=s,g=o;;){var k=h.return;if(k===null)break;var N=k.alternate;if(N===null){if(g=k.return,g!==null){h=g;continue}break}if(k.child===N.child){for(N=k.child;N;){if(N===h)return d(k),s;if(N===g)return d(k),o;N=N.sibling}throw Error(r(188))}if(h.return!==g.return)h=k,g=N;else{for(var H=!1,Y=k.child;Y;){if(Y===h){H=!0,h=k,g=N;break}if(Y===g){H=!0,g=k,h=N;break}Y=Y.sibling}if(!H){for(Y=N.child;Y;){if(Y===h){H=!0,h=N,g=k;break}if(Y===g){H=!0,g=N,h=k;break}Y=Y.sibling}if(!H)throw Error(r(189))}}if(h.alternate!==g)throw Error(r(190))}if(h.tag!==3)throw Error(r(188));return h.stateNode.current===h?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 m=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),v=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),W=Symbol.iterator;function z(s){return s===null||typeof s!="object"?null:(s=W&&s[W]||s["@@iterator"],typeof s=="function"?s:null)}var R=Symbol.for("react.client.reference");function P(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 C:return"Fragment";case S:return"Profiler";case _:return"StrictMode";case j:return"Suspense";case T:return"SuspenseList";case O:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case w:return"Portal";case v:return s.displayName||"Context";case b:return(s._context.displayName||"Context")+".Consumer";case E:var o=s.render;return s=s.displayName,s||(s=o.displayName||o.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case D:return o=s.displayName||null,o!==null?o:P(s.type)||"Memo";case L:o=s._payload,s=s._init;try{return P(s(o))}catch{}}return null}var V=Array.isArray,G=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},U=[],I=-1;function $(s){return{current:s}}function q(s){0>I||(s.current=U[I],U[I]=null,I--)}function B(s,o){I++,U[I]=s.current,s.current=o}var ee=$(null),X=$(null),ne=$(null),K=$(null);function F(s,o){switch(B(ne,o),B(X,s),B(ee,null),o.nodeType){case 9:case 11:s=(s=o.documentElement)&&(s=s.namespaceURI)?sv(s):0;break;default:if(s=o.tagName,o=o.namespaceURI)o=sv(o),s=iv(o,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}q(ee),B(ee,s)}function te(){q(ee),q(X),q(ne)}function se(s){s.memoizedState!==null&&B(K,s);var o=ee.current,h=iv(o,s.type);o!==h&&(B(X,s),B(ee,h))}function xe(s){X.current===s&&(q(ee),q(X)),K.current===s&&(q(K),Jo._currentValue=Q)}var oe,ye;function Le(s){if(oe===void 0)try{throw Error()}catch(h){var o=h.stack.trim().match(/\n( *(at )?)/);oe=o&&o[1]||"",ye=-1<h.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<h.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+oe+s+ye}var Oe=!1;function Me(s,o){if(!s||Oe)return"";Oe=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(o){var Ae=function(){throw Error()};if(Object.defineProperty(Ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ae,[])}catch(ve){var ge=ve}Reflect.construct(s,[],Ae)}else{try{Ae.call()}catch(ve){ge=ve}s.call(Ae.prototype)}}else{try{throw Error()}catch(ve){ge=ve}(Ae=s())&&typeof Ae.catch=="function"&&Ae.catch(function(){})}}catch(ve){if(ve&&ge&&typeof ve.stack=="string")return[ve.stack,ge.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var k=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");k&&k.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var N=g.DetermineComponentFrameRoot(),H=N[0],Y=N[1];if(H&&Y){var ie=H.split(`
|
|
45
|
+
`),pe=Y.split(`
|
|
46
|
+
`);for(k=g=0;g<ie.length&&!ie[g].includes("DetermineComponentFrameRoot");)g++;for(;k<pe.length&&!pe[k].includes("DetermineComponentFrameRoot");)k++;if(g===ie.length||k===pe.length)for(g=ie.length-1,k=pe.length-1;1<=g&&0<=k&&ie[g]!==pe[k];)k--;for(;1<=g&&0<=k;g--,k--)if(ie[g]!==pe[k]){if(g!==1||k!==1)do if(g--,k--,0>k||ie[g]!==pe[k]){var Ee=`
|
|
47
|
+
`+ie[g].replace(" at new "," at ");return s.displayName&&Ee.includes("<anonymous>")&&(Ee=Ee.replace("<anonymous>",s.displayName)),Ee}while(1<=g&&0<=k);break}}}finally{Oe=!1,Error.prepareStackTrace=h}return(h=s?s.displayName||s.name:"")?Le(h):""}function je(s,o){switch(s.tag){case 26:case 27:case 5:return Le(s.type);case 16:return Le("Lazy");case 13:return s.child!==o&&o!==null?Le("Suspense Fallback"):Le("Suspense");case 19:return Le("SuspenseList");case 0:case 15:return Me(s.type,!1);case 11:return Me(s.type.render,!1);case 1:return Me(s.type,!0);case 31:return Le("Activity");default:return""}}function nt(s){try{var o="",h=null;do o+=je(s,h),h=s,s=s.return;while(s);return o}catch(g){return`
|
|
48
|
+
Error generating stack: `+g.message+`
|
|
49
|
+
`+g.stack}}var Xe=Object.prototype.hasOwnProperty,he=e.unstable_scheduleCallback,ce=e.unstable_cancelCallback,de=e.unstable_shouldYield,$e=e.unstable_requestPaint,He=e.unstable_now,ut=e.unstable_getCurrentPriorityLevel,re=e.unstable_ImmediatePriority,be=e.unstable_UserBlockingPriority,ke=e.unstable_NormalPriority,ze=e.unstable_LowPriority,Ye=e.unstable_IdlePriority,We=e.log,tt=e.unstable_setDisableYieldValue,_t=null,It=null;function qt(s){if(typeof We=="function"&&tt(s),It&&typeof It.setStrictMode=="function")try{It.setStrictMode(_t,s)}catch{}}var dt=Math.clz32?Math.clz32:Jt,Cn=Math.log,jt=Math.LN2;function Jt(s){return s>>>=0,s===0?32:31-(Cn(s)/jt|0)|0}var Mr=256,_e=262144,Fe=4194304;function ae(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 fe(s,o,h){var g=s.pendingLanes;if(g===0)return 0;var k=0,N=s.suspendedLanes,H=s.pingedLanes;s=s.warmLanes;var Y=g&134217727;return Y!==0?(g=Y&~N,g!==0?k=ae(g):(H&=Y,H!==0?k=ae(H):h||(h=Y&~s,h!==0&&(k=ae(h))))):(Y=g&~N,Y!==0?k=ae(Y):H!==0?k=ae(H):h||(h=g&~s,h!==0&&(k=ae(h)))),k===0?0:o!==0&&o!==k&&(o&N)===0&&(N=k&-k,h=o&-o,N>=h||N===32&&(h&4194048)!==0)?o:k}function Ie(s,o){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&o)===0}function gt(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 bn(){var s=Fe;return Fe<<=1,(Fe&62914560)===0&&(Fe=4194304),s}function rn(s){for(var o=[],h=0;31>h;h++)o.push(s);return o}function Ce(s,o){s.pendingLanes|=o,o!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Te(s,o,h,g,k,N){var H=s.pendingLanes;s.pendingLanes=h,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=h,s.entangledLanes&=h,s.errorRecoveryDisabledLanes&=h,s.shellSuspendCounter=0;var Y=s.entanglements,ie=s.expirationTimes,pe=s.hiddenUpdates;for(h=H&~h;0<h;){var Ee=31-dt(h),Ae=1<<Ee;Y[Ee]=0,ie[Ee]=-1;var ge=pe[Ee];if(ge!==null)for(pe[Ee]=null,Ee=0;Ee<ge.length;Ee++){var ve=ge[Ee];ve!==null&&(ve.lane&=-536870913)}h&=~Ae}g!==0&&Ue(s,g,0),N!==0&&k===0&&s.tag!==0&&(s.suspendedLanes|=N&~(H&~o))}function Ue(s,o,h){s.pendingLanes|=o,s.suspendedLanes&=~o;var g=31-dt(o);s.entangledLanes|=o,s.entanglements[g]=s.entanglements[g]|1073741824|h&261930}function qe(s,o){var h=s.entangledLanes|=o;for(s=s.entanglements;h;){var g=31-dt(h),k=1<<g;k&o|s[g]&o&&(s[g]|=o),h&=~k}}function at(s,o){var h=o&-o;return h=(h&42)!==0?1:et(h),(h&(s.suspendedLanes|o))!==0?0:h}function et(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 xt(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function sn(){var s=Z.p;return s!==0?s:(s=window.event,s===void 0?32:Nv(s.type))}function Zt(s,o){var h=Z.p;try{return Z.p=s,o()}finally{Z.p=h}}var Wt=Math.random().toString(36).slice(2),an="__reactFiber$"+Wt,Un="__reactProps$"+Wt,Qi="__reactContainer$"+Wt,zd="__reactEvents$"+Wt,Qk="__reactListeners$"+Wt,Jk="__reactHandles$"+Wt,Gg="__reactResources$"+Wt,fo="__reactMarker$"+Wt;function Hd(s){delete s[an],delete s[Un],delete s[zd],delete s[Qk],delete s[Jk]}function Ji(s){var o=s[an];if(o)return o;for(var h=s.parentNode;h;){if(o=h[Qi]||h[an]){if(h=o.alternate,o.child!==null||h!==null&&h.child!==null)for(s=hv(s);s!==null;){if(h=s[an])return h;s=hv(s)}return o}s=h,h=s.parentNode}return null}function Zi(s){if(s=s[an]||s[Qi]){var o=s.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return s}return null}function mo(s){var o=s.tag;if(o===5||o===26||o===27||o===6)return s.stateNode;throw Error(r(33))}function ea(s){var o=s[Gg];return o||(o=s[Gg]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function vn(s){s[fo]=!0}var Wg=new Set,qg={};function hi(s,o){ta(s,o),ta(s+"Capture",o)}function ta(s,o){for(qg[s]=o,s=0;s<o.length;s++)Wg.add(o[s])}var Zk=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Kg={},Yg={};function e2(s){return Xe.call(Yg,s)?!0:Xe.call(Kg,s)?!1:Zk.test(s)?Yg[s]=!0:(Kg[s]=!0,!1)}function Ql(s,o,h){if(e2(o))if(h===null)s.removeAttribute(o);else{switch(typeof h){case"undefined":case"function":case"symbol":s.removeAttribute(o);return;case"boolean":var g=o.toLowerCase().slice(0,5);if(g!=="data-"&&g!=="aria-"){s.removeAttribute(o);return}}s.setAttribute(o,""+h)}}function Jl(s,o,h){if(h===null)s.removeAttribute(o);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(o);return}s.setAttribute(o,""+h)}}function Qr(s,o,h,g){if(g===null)s.removeAttribute(h);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(h);return}s.setAttributeNS(o,h,""+g)}}function ur(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function Xg(s){var o=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function t2(s,o,h){var g=Object.getOwnPropertyDescriptor(s.constructor.prototype,o);if(!s.hasOwnProperty(o)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var k=g.get,N=g.set;return Object.defineProperty(s,o,{configurable:!0,get:function(){return k.call(this)},set:function(H){h=""+H,N.call(this,H)}}),Object.defineProperty(s,o,{enumerable:g.enumerable}),{getValue:function(){return h},setValue:function(H){h=""+H},stopTracking:function(){s._valueTracker=null,delete s[o]}}}}function Ud(s){if(!s._valueTracker){var o=Xg(s)?"checked":"value";s._valueTracker=t2(s,o,""+s[o])}}function Qg(s){if(!s)return!1;var o=s._valueTracker;if(!o)return!0;var h=o.getValue(),g="";return s&&(g=Xg(s)?s.checked?"true":"false":s.value),s=g,s!==h?(o.setValue(s),!0):!1}function Zl(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 n2=/[\n"\\]/g;function dr(s){return s.replace(n2,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function Fd(s,o,h,g,k,N,H,Y){s.name="",H!=null&&typeof H!="function"&&typeof H!="symbol"&&typeof H!="boolean"?s.type=H:s.removeAttribute("type"),o!=null?H==="number"?(o===0&&s.value===""||s.value!=o)&&(s.value=""+ur(o)):s.value!==""+ur(o)&&(s.value=""+ur(o)):H!=="submit"&&H!=="reset"||s.removeAttribute("value"),o!=null?Vd(s,H,ur(o)):h!=null?Vd(s,H,ur(h)):g!=null&&s.removeAttribute("value"),k==null&&N!=null&&(s.defaultChecked=!!N),k!=null&&(s.checked=k&&typeof k!="function"&&typeof k!="symbol"),Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?s.name=""+ur(Y):s.removeAttribute("name")}function Jg(s,o,h,g,k,N,H,Y){if(N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"&&(s.type=N),o!=null||h!=null){if(!(N!=="submit"&&N!=="reset"||o!=null)){Ud(s);return}h=h!=null?""+ur(h):"",o=o!=null?""+ur(o):h,Y||o===s.value||(s.value=o),s.defaultValue=o}g=g??k,g=typeof g!="function"&&typeof g!="symbol"&&!!g,s.checked=Y?s.checked:!!g,s.defaultChecked=!!g,H!=null&&typeof H!="function"&&typeof H!="symbol"&&typeof H!="boolean"&&(s.name=H),Ud(s)}function Vd(s,o,h){o==="number"&&Zl(s.ownerDocument)===s||s.defaultValue===""+h||(s.defaultValue=""+h)}function na(s,o,h,g){if(s=s.options,o){o={};for(var k=0;k<h.length;k++)o["$"+h[k]]=!0;for(h=0;h<s.length;h++)k=o.hasOwnProperty("$"+s[h].value),s[h].selected!==k&&(s[h].selected=k),k&&g&&(s[h].defaultSelected=!0)}else{for(h=""+ur(h),o=null,k=0;k<s.length;k++){if(s[k].value===h){s[k].selected=!0,g&&(s[k].defaultSelected=!0);return}o!==null||s[k].disabled||(o=s[k])}o!==null&&(o.selected=!0)}}function Zg(s,o,h){if(o!=null&&(o=""+ur(o),o!==s.value&&(s.value=o),h==null)){s.defaultValue!==o&&(s.defaultValue=o);return}s.defaultValue=h!=null?""+ur(h):""}function ex(s,o,h,g){if(o==null){if(g!=null){if(h!=null)throw Error(r(92));if(V(g)){if(1<g.length)throw Error(r(93));g=g[0]}h=g}h==null&&(h=""),o=h}h=ur(o),s.defaultValue=h,g=s.textContent,g===h&&g!==""&&g!==null&&(s.value=g),Ud(s)}function ra(s,o){if(o){var h=s.firstChild;if(h&&h===s.lastChild&&h.nodeType===3){h.nodeValue=o;return}}s.textContent=o}var r2=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 tx(s,o,h){var g=o.indexOf("--")===0;h==null||typeof h=="boolean"||h===""?g?s.setProperty(o,""):o==="float"?s.cssFloat="":s[o]="":g?s.setProperty(o,h):typeof h!="number"||h===0||r2.has(o)?o==="float"?s.cssFloat=h:s[o]=(""+h).trim():s[o]=h+"px"}function nx(s,o,h){if(o!=null&&typeof o!="object")throw Error(r(62));if(s=s.style,h!=null){for(var g in h)!h.hasOwnProperty(g)||o!=null&&o.hasOwnProperty(g)||(g.indexOf("--")===0?s.setProperty(g,""):g==="float"?s.cssFloat="":s[g]="");for(var k in o)g=o[k],o.hasOwnProperty(k)&&h[k]!==g&&tx(s,k,g)}else for(var N in o)o.hasOwnProperty(N)&&tx(s,N,o[N])}function Gd(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 s2=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"]]),i2=/^[\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 ec(s){return i2.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function Jr(){}var Wd=null;function qd(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var sa=null,ia=null;function rx(s){var o=Zi(s);if(o&&(s=o.stateNode)){var h=s[Un]||null;e:switch(s=o.stateNode,o.type){case"input":if(Fd(s,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name),o=h.name,h.type==="radio"&&o!=null){for(h=s;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll('input[name="'+dr(""+o)+'"][type="radio"]'),o=0;o<h.length;o++){var g=h[o];if(g!==s&&g.form===s.form){var k=g[Un]||null;if(!k)throw Error(r(90));Fd(g,k.value,k.defaultValue,k.defaultValue,k.checked,k.defaultChecked,k.type,k.name)}}for(o=0;o<h.length;o++)g=h[o],g.form===s.form&&Qg(g)}break e;case"textarea":Zg(s,h.value,h.defaultValue);break e;case"select":o=h.value,o!=null&&na(s,!!h.multiple,o,!1)}}}var Kd=!1;function sx(s,o,h){if(Kd)return s(o,h);Kd=!0;try{var g=s(o);return g}finally{if(Kd=!1,(sa!==null||ia!==null)&&(Hc(),sa&&(o=sa,s=ia,ia=sa=null,rx(o),s)))for(o=0;o<s.length;o++)rx(s[o])}}function po(s,o){var h=s.stateNode;if(h===null)return null;var g=h[Un]||null;if(g===null)return null;h=g[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":(g=!g.disabled)||(s=s.type,g=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!g;break e;default:s=!1}if(s)return null;if(h&&typeof h!="function")throw Error(r(231,o,typeof h));return h}var Zr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yd=!1;if(Zr)try{var go={};Object.defineProperty(go,"passive",{get:function(){Yd=!0}}),window.addEventListener("test",go,go),window.removeEventListener("test",go,go)}catch{Yd=!1}var Ns=null,Xd=null,tc=null;function ix(){if(tc)return tc;var s,o=Xd,h=o.length,g,k="value"in Ns?Ns.value:Ns.textContent,N=k.length;for(s=0;s<h&&o[s]===k[s];s++);var H=h-s;for(g=1;g<=H&&o[h-g]===k[N-g];g++);return tc=k.slice(s,1<g?1-g:void 0)}function nc(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 rc(){return!0}function ax(){return!1}function Fn(s){function o(h,g,k,N,H){this._reactName=h,this._targetInst=k,this.type=g,this.nativeEvent=N,this.target=H,this.currentTarget=null;for(var Y in s)s.hasOwnProperty(Y)&&(h=s[Y],this[Y]=h?h(N):N[Y]);return this.isDefaultPrevented=(N.defaultPrevented!=null?N.defaultPrevented:N.returnValue===!1)?rc:ax,this.isPropagationStopped=ax,this}return m(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=rc)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=rc)},persist:function(){},isPersistent:rc}),o}var fi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sc=Fn(fi),xo=m({},fi,{view:0,detail:0}),a2=Fn(xo),Qd,Jd,yo,ic=m({},xo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:eh,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!==yo&&(yo&&s.type==="mousemove"?(Qd=s.screenX-yo.screenX,Jd=s.screenY-yo.screenY):Jd=Qd=0,yo=s),Qd)},movementY:function(s){return"movementY"in s?s.movementY:Jd}}),ox=Fn(ic),o2=m({},ic,{dataTransfer:0}),l2=Fn(o2),c2=m({},xo,{relatedTarget:0}),Zd=Fn(c2),u2=m({},fi,{animationName:0,elapsedTime:0,pseudoElement:0}),d2=Fn(u2),h2=m({},fi,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),f2=Fn(h2),m2=m({},fi,{data:0}),lx=Fn(m2),p2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},g2={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"},x2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function y2(s){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(s):(s=x2[s])?!!o[s]:!1}function eh(){return y2}var b2=m({},xo,{key:function(s){if(s.key){var o=p2[s.key]||s.key;if(o!=="Unidentified")return o}return s.type==="keypress"?(s=nc(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?g2[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:eh,charCode:function(s){return s.type==="keypress"?nc(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?nc(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),v2=Fn(b2),_2=m({},ic,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cx=Fn(_2),S2=m({},xo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:eh}),w2=Fn(S2),C2=m({},fi,{propertyName:0,elapsedTime:0,pseudoElement:0}),k2=Fn(C2),E2=m({},ic,{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}),j2=Fn(E2),N2=m({},fi,{newState:0,oldState:0}),T2=Fn(N2),A2=[9,13,27,32],th=Zr&&"CompositionEvent"in window,bo=null;Zr&&"documentMode"in document&&(bo=document.documentMode);var L2=Zr&&"TextEvent"in window&&!bo,ux=Zr&&(!th||bo&&8<bo&&11>=bo),dx=" ",hx=!1;function fx(s,o){switch(s){case"keyup":return A2.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function mx(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var aa=!1;function D2(s,o){switch(s){case"compositionend":return mx(o);case"keypress":return o.which!==32?null:(hx=!0,dx);case"textInput":return s=o.data,s===dx&&hx?null:s;default:return null}}function R2(s,o){if(aa)return s==="compositionend"||!th&&fx(s,o)?(s=ix(),tc=Xd=Ns=null,aa=!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 ux&&o.locale!=="ko"?null:o.data;default:return null}}var O2={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function px(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o==="input"?!!O2[s.type]:o==="textarea"}function gx(s,o,h,g){sa?ia?ia.push(g):ia=[g]:sa=g,o=Kc(o,"onChange"),0<o.length&&(h=new sc("onChange","change",null,h,g),s.push({event:h,listeners:o}))}var vo=null,_o=null;function I2(s){Jb(s,0)}function ac(s){var o=mo(s);if(Qg(o))return s}function xx(s,o){if(s==="change")return o}var yx=!1;if(Zr){var nh;if(Zr){var rh="oninput"in document;if(!rh){var bx=document.createElement("div");bx.setAttribute("oninput","return;"),rh=typeof bx.oninput=="function"}nh=rh}else nh=!1;yx=nh&&(!document.documentMode||9<document.documentMode)}function vx(){vo&&(vo.detachEvent("onpropertychange",_x),_o=vo=null)}function _x(s){if(s.propertyName==="value"&&ac(_o)){var o=[];gx(o,_o,s,qd(s)),sx(I2,o)}}function M2(s,o,h){s==="focusin"?(vx(),vo=o,_o=h,vo.attachEvent("onpropertychange",_x)):s==="focusout"&&vx()}function P2(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return ac(_o)}function B2(s,o){if(s==="click")return ac(o)}function $2(s,o){if(s==="input"||s==="change")return ac(o)}function z2(s,o){return s===o&&(s!==0||1/s===1/o)||s!==s&&o!==o}var er=typeof Object.is=="function"?Object.is:z2;function So(s,o){if(er(s,o))return!0;if(typeof s!="object"||s===null||typeof o!="object"||o===null)return!1;var h=Object.keys(s),g=Object.keys(o);if(h.length!==g.length)return!1;for(g=0;g<h.length;g++){var k=h[g];if(!Xe.call(o,k)||!er(s[k],o[k]))return!1}return!0}function Sx(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function wx(s,o){var h=Sx(s);s=0;for(var g;h;){if(h.nodeType===3){if(g=s+h.textContent.length,s<=o&&g>=o)return{node:h,offset:o-s};s=g}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=Sx(h)}}function Cx(s,o){return s&&o?s===o?!0:s&&s.nodeType===3?!1:o&&o.nodeType===3?Cx(s,o.parentNode):"contains"in s?s.contains(o):s.compareDocumentPosition?!!(s.compareDocumentPosition(o)&16):!1:!1}function kx(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var o=Zl(s.document);o instanceof s.HTMLIFrameElement;){try{var h=typeof o.contentWindow.location.href=="string"}catch{h=!1}if(h)s=o.contentWindow;else break;o=Zl(s.document)}return o}function sh(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 H2=Zr&&"documentMode"in document&&11>=document.documentMode,oa=null,ih=null,wo=null,ah=!1;function Ex(s,o,h){var g=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;ah||oa==null||oa!==Zl(g)||(g=oa,"selectionStart"in g&&sh(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),wo&&So(wo,g)||(wo=g,g=Kc(ih,"onSelect"),0<g.length&&(o=new sc("onSelect","select",null,o,h),s.push({event:o,listeners:g}),o.target=oa)))}function mi(s,o){var h={};return h[s.toLowerCase()]=o.toLowerCase(),h["Webkit"+s]="webkit"+o,h["Moz"+s]="moz"+o,h}var la={animationend:mi("Animation","AnimationEnd"),animationiteration:mi("Animation","AnimationIteration"),animationstart:mi("Animation","AnimationStart"),transitionrun:mi("Transition","TransitionRun"),transitionstart:mi("Transition","TransitionStart"),transitioncancel:mi("Transition","TransitionCancel"),transitionend:mi("Transition","TransitionEnd")},oh={},jx={};Zr&&(jx=document.createElement("div").style,"AnimationEvent"in window||(delete la.animationend.animation,delete la.animationiteration.animation,delete la.animationstart.animation),"TransitionEvent"in window||delete la.transitionend.transition);function pi(s){if(oh[s])return oh[s];if(!la[s])return s;var o=la[s],h;for(h in o)if(o.hasOwnProperty(h)&&h in jx)return oh[s]=o[h];return s}var Nx=pi("animationend"),Tx=pi("animationiteration"),Ax=pi("animationstart"),U2=pi("transitionrun"),F2=pi("transitionstart"),V2=pi("transitioncancel"),Lx=pi("transitionend"),Dx=new Map,lh="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(" ");lh.push("scrollEnd");function Er(s,o){Dx.set(s,o),hi(o,[s])}var oc=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)},hr=[],ca=0,ch=0;function lc(){for(var s=ca,o=ch=ca=0;o<s;){var h=hr[o];hr[o++]=null;var g=hr[o];hr[o++]=null;var k=hr[o];hr[o++]=null;var N=hr[o];if(hr[o++]=null,g!==null&&k!==null){var H=g.pending;H===null?k.next=k:(k.next=H.next,H.next=k),g.pending=k}N!==0&&Rx(h,k,N)}}function cc(s,o,h,g){hr[ca++]=s,hr[ca++]=o,hr[ca++]=h,hr[ca++]=g,ch|=g,s.lanes|=g,s=s.alternate,s!==null&&(s.lanes|=g)}function uh(s,o,h,g){return cc(s,o,h,g),uc(s)}function gi(s,o){return cc(s,null,null,o),uc(s)}function Rx(s,o,h){s.lanes|=h;var g=s.alternate;g!==null&&(g.lanes|=h);for(var k=!1,N=s.return;N!==null;)N.childLanes|=h,g=N.alternate,g!==null&&(g.childLanes|=h),N.tag===22&&(s=N.stateNode,s===null||s._visibility&1||(k=!0)),s=N,N=N.return;return s.tag===3?(N=s.stateNode,k&&o!==null&&(k=31-dt(h),s=N.hiddenUpdates,g=s[k],g===null?s[k]=[o]:g.push(o),o.lane=h|536870912),N):null}function uc(s){if(50<Go)throw Go=0,vf=null,Error(r(185));for(var o=s.return;o!==null;)s=o,o=s.return;return s.tag===3?s.stateNode:null}var ua={};function G2(s,o,h,g){this.tag=s,this.key=h,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=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tr(s,o,h,g){return new G2(s,o,h,g)}function dh(s){return s=s.prototype,!(!s||!s.isReactComponent)}function es(s,o){var h=s.alternate;return h===null?(h=tr(s.tag,o,s.key,s.mode),h.elementType=s.elementType,h.type=s.type,h.stateNode=s.stateNode,h.alternate=s,s.alternate=h):(h.pendingProps=o,h.type=s.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=s.flags&65011712,h.childLanes=s.childLanes,h.lanes=s.lanes,h.child=s.child,h.memoizedProps=s.memoizedProps,h.memoizedState=s.memoizedState,h.updateQueue=s.updateQueue,o=s.dependencies,h.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},h.sibling=s.sibling,h.index=s.index,h.ref=s.ref,h.refCleanup=s.refCleanup,h}function Ox(s,o){s.flags&=65011714;var h=s.alternate;return h===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=h.childLanes,s.lanes=h.lanes,s.child=h.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=h.memoizedProps,s.memoizedState=h.memoizedState,s.updateQueue=h.updateQueue,s.type=h.type,o=h.dependencies,s.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),s}function dc(s,o,h,g,k,N){var H=0;if(g=s,typeof s=="function")dh(s)&&(H=1);else if(typeof s=="string")H=XE(s,h,ee.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case O:return s=tr(31,h,o,k),s.elementType=O,s.lanes=N,s;case C:return xi(h.children,k,N,o);case _:H=8,k|=24;break;case S:return s=tr(12,h,o,k|2),s.elementType=S,s.lanes=N,s;case j:return s=tr(13,h,o,k),s.elementType=j,s.lanes=N,s;case T:return s=tr(19,h,o,k),s.elementType=T,s.lanes=N,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case v:H=10;break e;case b:H=9;break e;case E:H=11;break e;case D:H=14;break e;case L:H=16,g=null;break e}H=29,h=Error(r(130,s===null?"null":typeof s,"")),g=null}return o=tr(H,h,o,k),o.elementType=s,o.type=g,o.lanes=N,o}function xi(s,o,h,g){return s=tr(7,s,g,o),s.lanes=h,s}function hh(s,o,h){return s=tr(6,s,null,o),s.lanes=h,s}function Ix(s){var o=tr(18,null,null,0);return o.stateNode=s,o}function fh(s,o,h){return o=tr(4,s.children!==null?s.children:[],s.key,o),o.lanes=h,o.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},o}var Mx=new WeakMap;function fr(s,o){if(typeof s=="object"&&s!==null){var h=Mx.get(s);return h!==void 0?h:(o={value:s,source:o,stack:nt(o)},Mx.set(s,o),o)}return{value:s,source:o,stack:nt(o)}}var da=[],ha=0,hc=null,Co=0,mr=[],pr=0,Ts=null,Pr=1,Br="";function ts(s,o){da[ha++]=Co,da[ha++]=hc,hc=s,Co=o}function Px(s,o,h){mr[pr++]=Pr,mr[pr++]=Br,mr[pr++]=Ts,Ts=s;var g=Pr;s=Br;var k=32-dt(g)-1;g&=~(1<<k),h+=1;var N=32-dt(o)+k;if(30<N){var H=k-k%5;N=(g&(1<<H)-1).toString(32),g>>=H,k-=H,Pr=1<<32-dt(o)+k|h<<k|g,Br=N+s}else Pr=1<<N|h<<k|g,Br=s}function mh(s){s.return!==null&&(ts(s,1),Px(s,1,0))}function ph(s){for(;s===hc;)hc=da[--ha],da[ha]=null,Co=da[--ha],da[ha]=null;for(;s===Ts;)Ts=mr[--pr],mr[pr]=null,Br=mr[--pr],mr[pr]=null,Pr=mr[--pr],mr[pr]=null}function Bx(s,o){mr[pr++]=Pr,mr[pr++]=Br,mr[pr++]=Ts,Pr=o.id,Br=o.overflow,Ts=s}var kn=null,Ut=null,vt=!1,As=null,gr=!1,gh=Error(r(519));function Ls(s){var o=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ko(fr(o,s)),gh}function $x(s){var o=s.stateNode,h=s.type,g=s.memoizedProps;switch(o[an]=s,o[Un]=g,h){case"dialog":ft("cancel",o),ft("close",o);break;case"iframe":case"object":case"embed":ft("load",o);break;case"video":case"audio":for(h=0;h<qo.length;h++)ft(qo[h],o);break;case"source":ft("error",o);break;case"img":case"image":case"link":ft("error",o),ft("load",o);break;case"details":ft("toggle",o);break;case"input":ft("invalid",o),Jg(o,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":ft("invalid",o);break;case"textarea":ft("invalid",o),ex(o,g.value,g.defaultValue,g.children)}h=g.children,typeof h!="string"&&typeof h!="number"&&typeof h!="bigint"||o.textContent===""+h||g.suppressHydrationWarning===!0||nv(o.textContent,h)?(g.popover!=null&&(ft("beforetoggle",o),ft("toggle",o)),g.onScroll!=null&&ft("scroll",o),g.onScrollEnd!=null&&ft("scrollend",o),g.onClick!=null&&(o.onclick=Jr),o=!0):o=!1,o||Ls(s,!0)}function zx(s){for(kn=s.return;kn;)switch(kn.tag){case 5:case 31:case 13:gr=!1;return;case 27:case 3:gr=!0;return;default:kn=kn.return}}function fa(s){if(s!==kn)return!1;if(!vt)return zx(s),vt=!0,!1;var o=s.tag,h;if((h=o!==3&&o!==27)&&((h=o===5)&&(h=s.type,h=!(h!=="form"&&h!=="button")||If(s.type,s.memoizedProps)),h=!h),h&&Ut&&Ls(s),zx(s),o===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Ut=dv(s)}else if(o===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(317));Ut=dv(s)}else o===27?(o=Ut,Gs(s.type)?(s=zf,zf=null,Ut=s):Ut=o):Ut=kn?yr(s.stateNode.nextSibling):null;return!0}function yi(){Ut=kn=null,vt=!1}function xh(){var s=As;return s!==null&&(qn===null?qn=s:qn.push.apply(qn,s),As=null),s}function ko(s){As===null?As=[s]:As.push(s)}var yh=$(null),bi=null,ns=null;function Ds(s,o,h){B(yh,o._currentValue),o._currentValue=h}function rs(s){s._currentValue=yh.current,q(yh)}function bh(s,o,h){for(;s!==null;){var g=s.alternate;if((s.childLanes&o)!==o?(s.childLanes|=o,g!==null&&(g.childLanes|=o)):g!==null&&(g.childLanes&o)!==o&&(g.childLanes|=o),s===h)break;s=s.return}}function vh(s,o,h,g){var k=s.child;for(k!==null&&(k.return=s);k!==null;){var N=k.dependencies;if(N!==null){var H=k.child;N=N.firstContext;e:for(;N!==null;){var Y=N;N=k;for(var ie=0;ie<o.length;ie++)if(Y.context===o[ie]){N.lanes|=h,Y=N.alternate,Y!==null&&(Y.lanes|=h),bh(N.return,h,s),g||(H=null);break e}N=Y.next}}else if(k.tag===18){if(H=k.return,H===null)throw Error(r(341));H.lanes|=h,N=H.alternate,N!==null&&(N.lanes|=h),bh(H,h,s),H=null}else H=k.child;if(H!==null)H.return=k;else for(H=k;H!==null;){if(H===s){H=null;break}if(k=H.sibling,k!==null){k.return=H.return,H=k;break}H=H.return}k=H}}function ma(s,o,h,g){s=null;for(var k=o,N=!1;k!==null;){if(!N){if((k.flags&524288)!==0)N=!0;else if((k.flags&262144)!==0)break}if(k.tag===10){var H=k.alternate;if(H===null)throw Error(r(387));if(H=H.memoizedProps,H!==null){var Y=k.type;er(k.pendingProps.value,H.value)||(s!==null?s.push(Y):s=[Y])}}else if(k===K.current){if(H=k.alternate,H===null)throw Error(r(387));H.memoizedState.memoizedState!==k.memoizedState.memoizedState&&(s!==null?s.push(Jo):s=[Jo])}k=k.return}s!==null&&vh(o,s,h,g),o.flags|=262144}function fc(s){for(s=s.firstContext;s!==null;){if(!er(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function vi(s){bi=s,ns=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function En(s){return Hx(bi,s)}function mc(s,o){return bi===null&&vi(s),Hx(s,o)}function Hx(s,o){var h=o._currentValue;if(o={context:o,memoizedValue:h,next:null},ns===null){if(s===null)throw Error(r(308));ns=o,s.dependencies={lanes:0,firstContext:o},s.flags|=524288}else ns=ns.next=o;return h}var W2=typeof AbortController<"u"?AbortController:function(){var s=[],o=this.signal={aborted:!1,addEventListener:function(h,g){s.push(g)}};this.abort=function(){o.aborted=!0,s.forEach(function(h){return h()})}},q2=e.unstable_scheduleCallback,K2=e.unstable_NormalPriority,on={$$typeof:v,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _h(){return{controller:new W2,data:new Map,refCount:0}}function Eo(s){s.refCount--,s.refCount===0&&q2(K2,function(){s.controller.abort()})}var jo=null,Sh=0,pa=0,ga=null;function Y2(s,o){if(jo===null){var h=jo=[];Sh=0,pa=Ef(),ga={status:"pending",value:void 0,then:function(g){h.push(g)}}}return Sh++,o.then(Ux,Ux),o}function Ux(){if(--Sh===0&&jo!==null){ga!==null&&(ga.status="fulfilled");var s=jo;jo=null,pa=0,ga=null;for(var o=0;o<s.length;o++)(0,s[o])()}}function X2(s,o){var h=[],g={status:"pending",value:null,reason:null,then:function(k){h.push(k)}};return s.then(function(){g.status="fulfilled",g.value=o;for(var k=0;k<h.length;k++)(0,h[k])(o)},function(k){for(g.status="rejected",g.reason=k,k=0;k<h.length;k++)(0,h[k])(void 0)}),g}var Fx=G.S;G.S=function(s,o){Eb=He(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&Y2(s,o),Fx!==null&&Fx(s,o)};var _i=$(null);function wh(){var s=_i.current;return s!==null?s:Mt.pooledCache}function pc(s,o){o===null?B(_i,_i.current):B(_i,o.pool)}function Vx(){var s=wh();return s===null?null:{parent:on._currentValue,pool:s}}var xa=Error(r(460)),Ch=Error(r(474)),gc=Error(r(542)),xc={then:function(){}};function Gx(s){return s=s.status,s==="fulfilled"||s==="rejected"}function Wx(s,o,h){switch(h=s[h],h===void 0?s.push(o):h!==o&&(o.then(Jr,Jr),o=h),o.status){case"fulfilled":return o.value;case"rejected":throw s=o.reason,Kx(s),s;default:if(typeof o.status=="string")o.then(Jr,Jr);else{if(s=Mt,s!==null&&100<s.shellSuspendCounter)throw Error(r(482));s=o,s.status="pending",s.then(function(g){if(o.status==="pending"){var k=o;k.status="fulfilled",k.value=g}},function(g){if(o.status==="pending"){var k=o;k.status="rejected",k.reason=g}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw s=o.reason,Kx(s),s}throw wi=o,xa}}function Si(s){try{var o=s._init;return o(s._payload)}catch(h){throw h!==null&&typeof h=="object"&&typeof h.then=="function"?(wi=h,xa):h}}var wi=null;function qx(){if(wi===null)throw Error(r(459));var s=wi;return wi=null,s}function Kx(s){if(s===xa||s===gc)throw Error(r(483))}var ya=null,No=0;function yc(s){var o=No;return No+=1,ya===null&&(ya=[]),Wx(ya,s,o)}function To(s,o){o=o.props.ref,s.ref=o!==void 0?o:null}function bc(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 Yx(s){function o(ue,le){if(s){var me=ue.deletions;me===null?(ue.deletions=[le],ue.flags|=16):me.push(le)}}function h(ue,le){if(!s)return null;for(;le!==null;)o(ue,le),le=le.sibling;return null}function g(ue){for(var le=new Map;ue!==null;)ue.key!==null?le.set(ue.key,ue):le.set(ue.index,ue),ue=ue.sibling;return le}function k(ue,le){return ue=es(ue,le),ue.index=0,ue.sibling=null,ue}function N(ue,le,me){return ue.index=me,s?(me=ue.alternate,me!==null?(me=me.index,me<le?(ue.flags|=67108866,le):me):(ue.flags|=67108866,le)):(ue.flags|=1048576,le)}function H(ue){return s&&ue.alternate===null&&(ue.flags|=67108866),ue}function Y(ue,le,me,Ne){return le===null||le.tag!==6?(le=hh(me,ue.mode,Ne),le.return=ue,le):(le=k(le,me),le.return=ue,le)}function ie(ue,le,me,Ne){var Ke=me.type;return Ke===C?Ee(ue,le,me.props.children,Ne,me.key):le!==null&&(le.elementType===Ke||typeof Ke=="object"&&Ke!==null&&Ke.$$typeof===L&&Si(Ke)===le.type)?(le=k(le,me.props),To(le,me),le.return=ue,le):(le=dc(me.type,me.key,me.props,null,ue.mode,Ne),To(le,me),le.return=ue,le)}function pe(ue,le,me,Ne){return le===null||le.tag!==4||le.stateNode.containerInfo!==me.containerInfo||le.stateNode.implementation!==me.implementation?(le=fh(me,ue.mode,Ne),le.return=ue,le):(le=k(le,me.children||[]),le.return=ue,le)}function Ee(ue,le,me,Ne,Ke){return le===null||le.tag!==7?(le=xi(me,ue.mode,Ne,Ke),le.return=ue,le):(le=k(le,me),le.return=ue,le)}function Ae(ue,le,me){if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return le=hh(""+le,ue.mode,me),le.return=ue,le;if(typeof le=="object"&&le!==null){switch(le.$$typeof){case y:return me=dc(le.type,le.key,le.props,null,ue.mode,me),To(me,le),me.return=ue,me;case w:return le=fh(le,ue.mode,me),le.return=ue,le;case L:return le=Si(le),Ae(ue,le,me)}if(V(le)||z(le))return le=xi(le,ue.mode,me,null),le.return=ue,le;if(typeof le.then=="function")return Ae(ue,yc(le),me);if(le.$$typeof===v)return Ae(ue,mc(ue,le),me);bc(ue,le)}return null}function ge(ue,le,me,Ne){var Ke=le!==null?le.key:null;if(typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint")return Ke!==null?null:Y(ue,le,""+me,Ne);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case y:return me.key===Ke?ie(ue,le,me,Ne):null;case w:return me.key===Ke?pe(ue,le,me,Ne):null;case L:return me=Si(me),ge(ue,le,me,Ne)}if(V(me)||z(me))return Ke!==null?null:Ee(ue,le,me,Ne,null);if(typeof me.then=="function")return ge(ue,le,yc(me),Ne);if(me.$$typeof===v)return ge(ue,le,mc(ue,me),Ne);bc(ue,me)}return null}function ve(ue,le,me,Ne,Ke){if(typeof Ne=="string"&&Ne!==""||typeof Ne=="number"||typeof Ne=="bigint")return ue=ue.get(me)||null,Y(le,ue,""+Ne,Ke);if(typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case y:return ue=ue.get(Ne.key===null?me:Ne.key)||null,ie(le,ue,Ne,Ke);case w:return ue=ue.get(Ne.key===null?me:Ne.key)||null,pe(le,ue,Ne,Ke);case L:return Ne=Si(Ne),ve(ue,le,me,Ne,Ke)}if(V(Ne)||z(Ne))return ue=ue.get(me)||null,Ee(le,ue,Ne,Ke,null);if(typeof Ne.then=="function")return ve(ue,le,me,yc(Ne),Ke);if(Ne.$$typeof===v)return ve(ue,le,me,mc(le,Ne),Ke);bc(le,Ne)}return null}function Ve(ue,le,me,Ne){for(var Ke=null,Ct=null,Ge=le,ot=le=0,bt=null;Ge!==null&&ot<me.length;ot++){Ge.index>ot?(bt=Ge,Ge=null):bt=Ge.sibling;var kt=ge(ue,Ge,me[ot],Ne);if(kt===null){Ge===null&&(Ge=bt);break}s&&Ge&&kt.alternate===null&&o(ue,Ge),le=N(kt,le,ot),Ct===null?Ke=kt:Ct.sibling=kt,Ct=kt,Ge=bt}if(ot===me.length)return h(ue,Ge),vt&&ts(ue,ot),Ke;if(Ge===null){for(;ot<me.length;ot++)Ge=Ae(ue,me[ot],Ne),Ge!==null&&(le=N(Ge,le,ot),Ct===null?Ke=Ge:Ct.sibling=Ge,Ct=Ge);return vt&&ts(ue,ot),Ke}for(Ge=g(Ge);ot<me.length;ot++)bt=ve(Ge,ue,ot,me[ot],Ne),bt!==null&&(s&&bt.alternate!==null&&Ge.delete(bt.key===null?ot:bt.key),le=N(bt,le,ot),Ct===null?Ke=bt:Ct.sibling=bt,Ct=bt);return s&&Ge.forEach(function(Xs){return o(ue,Xs)}),vt&&ts(ue,ot),Ke}function Ze(ue,le,me,Ne){if(me==null)throw Error(r(151));for(var Ke=null,Ct=null,Ge=le,ot=le=0,bt=null,kt=me.next();Ge!==null&&!kt.done;ot++,kt=me.next()){Ge.index>ot?(bt=Ge,Ge=null):bt=Ge.sibling;var Xs=ge(ue,Ge,kt.value,Ne);if(Xs===null){Ge===null&&(Ge=bt);break}s&&Ge&&Xs.alternate===null&&o(ue,Ge),le=N(Xs,le,ot),Ct===null?Ke=Xs:Ct.sibling=Xs,Ct=Xs,Ge=bt}if(kt.done)return h(ue,Ge),vt&&ts(ue,ot),Ke;if(Ge===null){for(;!kt.done;ot++,kt=me.next())kt=Ae(ue,kt.value,Ne),kt!==null&&(le=N(kt,le,ot),Ct===null?Ke=kt:Ct.sibling=kt,Ct=kt);return vt&&ts(ue,ot),Ke}for(Ge=g(Ge);!kt.done;ot++,kt=me.next())kt=ve(Ge,ue,ot,kt.value,Ne),kt!==null&&(s&&kt.alternate!==null&&Ge.delete(kt.key===null?ot:kt.key),le=N(kt,le,ot),Ct===null?Ke=kt:Ct.sibling=kt,Ct=kt);return s&&Ge.forEach(function(oj){return o(ue,oj)}),vt&&ts(ue,ot),Ke}function Dt(ue,le,me,Ne){if(typeof me=="object"&&me!==null&&me.type===C&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case y:e:{for(var Ke=me.key;le!==null;){if(le.key===Ke){if(Ke=me.type,Ke===C){if(le.tag===7){h(ue,le.sibling),Ne=k(le,me.props.children),Ne.return=ue,ue=Ne;break e}}else if(le.elementType===Ke||typeof Ke=="object"&&Ke!==null&&Ke.$$typeof===L&&Si(Ke)===le.type){h(ue,le.sibling),Ne=k(le,me.props),To(Ne,me),Ne.return=ue,ue=Ne;break e}h(ue,le);break}else o(ue,le);le=le.sibling}me.type===C?(Ne=xi(me.props.children,ue.mode,Ne,me.key),Ne.return=ue,ue=Ne):(Ne=dc(me.type,me.key,me.props,null,ue.mode,Ne),To(Ne,me),Ne.return=ue,ue=Ne)}return H(ue);case w:e:{for(Ke=me.key;le!==null;){if(le.key===Ke)if(le.tag===4&&le.stateNode.containerInfo===me.containerInfo&&le.stateNode.implementation===me.implementation){h(ue,le.sibling),Ne=k(le,me.children||[]),Ne.return=ue,ue=Ne;break e}else{h(ue,le);break}else o(ue,le);le=le.sibling}Ne=fh(me,ue.mode,Ne),Ne.return=ue,ue=Ne}return H(ue);case L:return me=Si(me),Dt(ue,le,me,Ne)}if(V(me))return Ve(ue,le,me,Ne);if(z(me)){if(Ke=z(me),typeof Ke!="function")throw Error(r(150));return me=Ke.call(me),Ze(ue,le,me,Ne)}if(typeof me.then=="function")return Dt(ue,le,yc(me),Ne);if(me.$$typeof===v)return Dt(ue,le,mc(ue,me),Ne);bc(ue,me)}return typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint"?(me=""+me,le!==null&&le.tag===6?(h(ue,le.sibling),Ne=k(le,me),Ne.return=ue,ue=Ne):(h(ue,le),Ne=hh(me,ue.mode,Ne),Ne.return=ue,ue=Ne),H(ue)):h(ue,le)}return function(ue,le,me,Ne){try{No=0;var Ke=Dt(ue,le,me,Ne);return ya=null,Ke}catch(Ge){if(Ge===xa||Ge===gc)throw Ge;var Ct=tr(29,Ge,null,ue.mode);return Ct.lanes=Ne,Ct.return=ue,Ct}finally{}}}var Ci=Yx(!0),Xx=Yx(!1),Rs=!1;function kh(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Eh(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 Os(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Is(s,o,h){var g=s.updateQueue;if(g===null)return null;if(g=g.shared,(Et&2)!==0){var k=g.pending;return k===null?o.next=o:(o.next=k.next,k.next=o),g.pending=o,o=uc(s),Rx(s,null,h),o}return cc(s,g,o,h),uc(s)}function Ao(s,o,h){if(o=o.updateQueue,o!==null&&(o=o.shared,(h&4194048)!==0)){var g=o.lanes;g&=s.pendingLanes,h|=g,o.lanes=h,qe(s,h)}}function jh(s,o){var h=s.updateQueue,g=s.alternate;if(g!==null&&(g=g.updateQueue,h===g)){var k=null,N=null;if(h=h.firstBaseUpdate,h!==null){do{var H={lane:h.lane,tag:h.tag,payload:h.payload,callback:null,next:null};N===null?k=N=H:N=N.next=H,h=h.next}while(h!==null);N===null?k=N=o:N=N.next=o}else k=N=o;h={baseState:g.baseState,firstBaseUpdate:k,lastBaseUpdate:N,shared:g.shared,callbacks:g.callbacks},s.updateQueue=h;return}s=h.lastBaseUpdate,s===null?h.firstBaseUpdate=o:s.next=o,h.lastBaseUpdate=o}var Nh=!1;function Lo(){if(Nh){var s=ga;if(s!==null)throw s}}function Do(s,o,h,g){Nh=!1;var k=s.updateQueue;Rs=!1;var N=k.firstBaseUpdate,H=k.lastBaseUpdate,Y=k.shared.pending;if(Y!==null){k.shared.pending=null;var ie=Y,pe=ie.next;ie.next=null,H===null?N=pe:H.next=pe,H=ie;var Ee=s.alternate;Ee!==null&&(Ee=Ee.updateQueue,Y=Ee.lastBaseUpdate,Y!==H&&(Y===null?Ee.firstBaseUpdate=pe:Y.next=pe,Ee.lastBaseUpdate=ie))}if(N!==null){var Ae=k.baseState;H=0,Ee=pe=ie=null,Y=N;do{var ge=Y.lane&-536870913,ve=ge!==Y.lane;if(ve?(yt&ge)===ge:(g&ge)===ge){ge!==0&&ge===pa&&(Nh=!0),Ee!==null&&(Ee=Ee.next={lane:0,tag:Y.tag,payload:Y.payload,callback:null,next:null});e:{var Ve=s,Ze=Y;ge=o;var Dt=h;switch(Ze.tag){case 1:if(Ve=Ze.payload,typeof Ve=="function"){Ae=Ve.call(Dt,Ae,ge);break e}Ae=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Ze.payload,ge=typeof Ve=="function"?Ve.call(Dt,Ae,ge):Ve,ge==null)break e;Ae=m({},Ae,ge);break e;case 2:Rs=!0}}ge=Y.callback,ge!==null&&(s.flags|=64,ve&&(s.flags|=8192),ve=k.callbacks,ve===null?k.callbacks=[ge]:ve.push(ge))}else ve={lane:ge,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},Ee===null?(pe=Ee=ve,ie=Ae):Ee=Ee.next=ve,H|=ge;if(Y=Y.next,Y===null){if(Y=k.shared.pending,Y===null)break;ve=Y,Y=ve.next,ve.next=null,k.lastBaseUpdate=ve,k.shared.pending=null}}while(!0);Ee===null&&(ie=Ae),k.baseState=ie,k.firstBaseUpdate=pe,k.lastBaseUpdate=Ee,N===null&&(k.shared.lanes=0),zs|=H,s.lanes=H,s.memoizedState=Ae}}function Qx(s,o){if(typeof s!="function")throw Error(r(191,s));s.call(o)}function Jx(s,o){var h=s.callbacks;if(h!==null)for(s.callbacks=null,s=0;s<h.length;s++)Qx(h[s],o)}var ba=$(null),vc=$(0);function Zx(s,o){s=hs,B(vc,s),B(ba,o),hs=s|o.baseLanes}function Th(){B(vc,hs),B(ba,ba.current)}function Ah(){hs=vc.current,q(ba),q(vc)}var nr=$(null),xr=null;function Ms(s){var o=s.alternate;B(en,en.current&1),B(nr,s),xr===null&&(o===null||ba.current!==null||o.memoizedState!==null)&&(xr=s)}function Lh(s){B(en,en.current),B(nr,s),xr===null&&(xr=s)}function ey(s){s.tag===22?(B(en,en.current),B(nr,s),xr===null&&(xr=s)):Ps()}function Ps(){B(en,en.current),B(nr,nr.current)}function rr(s){q(nr),xr===s&&(xr=null),q(en)}var en=$(0);function _c(s){for(var o=s;o!==null;){if(o.tag===13){var h=o.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||Bf(h)||$f(h)))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 ss=0,it=null,At=null,ln=null,Sc=!1,va=!1,ki=!1,wc=0,Ro=0,_a=null,Q2=0;function Kt(){throw Error(r(321))}function Dh(s,o){if(o===null)return!1;for(var h=0;h<o.length&&h<s.length;h++)if(!er(s[h],o[h]))return!1;return!0}function Rh(s,o,h,g,k,N){return ss=N,it=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,G.H=s===null||s.memoizedState===null?Py:Kh,ki=!1,N=h(g,k),ki=!1,va&&(N=ny(o,h,g,k)),ty(s),N}function ty(s){G.H=Mo;var o=At!==null&&At.next!==null;if(ss=0,ln=At=it=null,Sc=!1,Ro=0,_a=null,o)throw Error(r(300));s===null||cn||(s=s.dependencies,s!==null&&fc(s)&&(cn=!0))}function ny(s,o,h,g){it=s;var k=0;do{if(va&&(_a=null),Ro=0,va=!1,25<=k)throw Error(r(301));if(k+=1,ln=At=null,s.updateQueue!=null){var N=s.updateQueue;N.lastEffect=null,N.events=null,N.stores=null,N.memoCache!=null&&(N.memoCache.index=0)}G.H=By,N=o(h,g)}while(va);return N}function J2(){var s=G.H,o=s.useState()[0];return o=typeof o.then=="function"?Oo(o):o,s=s.useState()[0],(At!==null?At.memoizedState:null)!==s&&(it.flags|=1024),o}function Oh(){var s=wc!==0;return wc=0,s}function Ih(s,o,h){o.updateQueue=s.updateQueue,o.flags&=-2053,s.lanes&=~h}function Mh(s){if(Sc){for(s=s.memoizedState;s!==null;){var o=s.queue;o!==null&&(o.pending=null),s=s.next}Sc=!1}ss=0,ln=At=it=null,va=!1,Ro=wc=0,_a=null}function In(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ln===null?it.memoizedState=ln=s:ln=ln.next=s,ln}function tn(){if(At===null){var s=it.alternate;s=s!==null?s.memoizedState:null}else s=At.next;var o=ln===null?it.memoizedState:ln.next;if(o!==null)ln=o,At=s;else{if(s===null)throw it.alternate===null?Error(r(467)):Error(r(310));At=s,s={memoizedState:At.memoizedState,baseState:At.baseState,baseQueue:At.baseQueue,queue:At.queue,next:null},ln===null?it.memoizedState=ln=s:ln=ln.next=s}return ln}function Cc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Oo(s){var o=Ro;return Ro+=1,_a===null&&(_a=[]),s=Wx(_a,s,o),o=it,(ln===null?o.memoizedState:ln.next)===null&&(o=o.alternate,G.H=o===null||o.memoizedState===null?Py:Kh),s}function kc(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return Oo(s);if(s.$$typeof===v)return En(s)}throw Error(r(438,String(s)))}function Ph(s){var o=null,h=it.updateQueue;if(h!==null&&(o=h.memoCache),o==null){var g=it.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(o={data:g.data.map(function(k){return k.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),h===null&&(h=Cc(),it.updateQueue=h),h.memoCache=o,h=o.data[o.index],h===void 0)for(h=o.data[o.index]=Array(s),g=0;g<s;g++)h[g]=M;return o.index++,h}function is(s,o){return typeof o=="function"?o(s):o}function Ec(s){var o=tn();return Bh(o,At,s)}function Bh(s,o,h){var g=s.queue;if(g===null)throw Error(r(311));g.lastRenderedReducer=h;var k=s.baseQueue,N=g.pending;if(N!==null){if(k!==null){var H=k.next;k.next=N.next,N.next=H}o.baseQueue=k=N,g.pending=null}if(N=s.baseState,k===null)s.memoizedState=N;else{o=k.next;var Y=H=null,ie=null,pe=o,Ee=!1;do{var Ae=pe.lane&-536870913;if(Ae!==pe.lane?(yt&Ae)===Ae:(ss&Ae)===Ae){var ge=pe.revertLane;if(ge===0)ie!==null&&(ie=ie.next={lane:0,revertLane:0,gesture:null,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null}),Ae===pa&&(Ee=!0);else if((ss&ge)===ge){pe=pe.next,ge===pa&&(Ee=!0);continue}else Ae={lane:0,revertLane:pe.revertLane,gesture:null,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null},ie===null?(Y=ie=Ae,H=N):ie=ie.next=Ae,it.lanes|=ge,zs|=ge;Ae=pe.action,ki&&h(N,Ae),N=pe.hasEagerState?pe.eagerState:h(N,Ae)}else ge={lane:Ae,revertLane:pe.revertLane,gesture:pe.gesture,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null},ie===null?(Y=ie=ge,H=N):ie=ie.next=ge,it.lanes|=Ae,zs|=Ae;pe=pe.next}while(pe!==null&&pe!==o);if(ie===null?H=N:ie.next=Y,!er(N,s.memoizedState)&&(cn=!0,Ee&&(h=ga,h!==null)))throw h;s.memoizedState=N,s.baseState=H,s.baseQueue=ie,g.lastRenderedState=N}return k===null&&(g.lanes=0),[s.memoizedState,g.dispatch]}function $h(s){var o=tn(),h=o.queue;if(h===null)throw Error(r(311));h.lastRenderedReducer=s;var g=h.dispatch,k=h.pending,N=o.memoizedState;if(k!==null){h.pending=null;var H=k=k.next;do N=s(N,H.action),H=H.next;while(H!==k);er(N,o.memoizedState)||(cn=!0),o.memoizedState=N,o.baseQueue===null&&(o.baseState=N),h.lastRenderedState=N}return[N,g]}function ry(s,o,h){var g=it,k=tn(),N=vt;if(N){if(h===void 0)throw Error(r(407));h=h()}else h=o();var H=!er((At||k).memoizedState,h);if(H&&(k.memoizedState=h,cn=!0),k=k.queue,Uh(ay.bind(null,g,k,s),[s]),k.getSnapshot!==o||H||ln!==null&&ln.memoizedState.tag&1){if(g.flags|=2048,Sa(9,{destroy:void 0},iy.bind(null,g,k,h,o),null),Mt===null)throw Error(r(349));N||(ss&127)!==0||sy(g,o,h)}return h}function sy(s,o,h){s.flags|=16384,s={getSnapshot:o,value:h},o=it.updateQueue,o===null?(o=Cc(),it.updateQueue=o,o.stores=[s]):(h=o.stores,h===null?o.stores=[s]:h.push(s))}function iy(s,o,h,g){o.value=h,o.getSnapshot=g,oy(o)&&ly(s)}function ay(s,o,h){return h(function(){oy(o)&&ly(s)})}function oy(s){var o=s.getSnapshot;s=s.value;try{var h=o();return!er(s,h)}catch{return!0}}function ly(s){var o=gi(s,2);o!==null&&Kn(o,s,2)}function zh(s){var o=In();if(typeof s=="function"){var h=s;if(s=h(),ki){qt(!0);try{h()}finally{qt(!1)}}}return o.memoizedState=o.baseState=s,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:s},o}function cy(s,o,h,g){return s.baseState=h,Bh(s,At,typeof g=="function"?g:is)}function Z2(s,o,h,g,k){if(Tc(s))throw Error(r(485));if(s=o.action,s!==null){var N={payload:k,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(H){N.listeners.push(H)}};G.T!==null?h(!0):N.isTransition=!1,g(N),h=o.pending,h===null?(N.next=o.pending=N,uy(o,N)):(N.next=h.next,o.pending=h.next=N)}}function uy(s,o){var h=o.action,g=o.payload,k=s.state;if(o.isTransition){var N=G.T,H={};G.T=H;try{var Y=h(k,g),ie=G.S;ie!==null&&ie(H,Y),dy(s,o,Y)}catch(pe){Hh(s,o,pe)}finally{N!==null&&H.types!==null&&(N.types=H.types),G.T=N}}else try{N=h(k,g),dy(s,o,N)}catch(pe){Hh(s,o,pe)}}function dy(s,o,h){h!==null&&typeof h=="object"&&typeof h.then=="function"?h.then(function(g){hy(s,o,g)},function(g){return Hh(s,o,g)}):hy(s,o,h)}function hy(s,o,h){o.status="fulfilled",o.value=h,fy(o),s.state=h,o=s.pending,o!==null&&(h=o.next,h===o?s.pending=null:(h=h.next,o.next=h,uy(s,h)))}function Hh(s,o,h){var g=s.pending;if(s.pending=null,g!==null){g=g.next;do o.status="rejected",o.reason=h,fy(o),o=o.next;while(o!==g)}s.action=null}function fy(s){s=s.listeners;for(var o=0;o<s.length;o++)(0,s[o])()}function my(s,o){return o}function py(s,o){if(vt){var h=Mt.formState;if(h!==null){e:{var g=it;if(vt){if(Ut){t:{for(var k=Ut,N=gr;k.nodeType!==8;){if(!N){k=null;break t}if(k=yr(k.nextSibling),k===null){k=null;break t}}N=k.data,k=N==="F!"||N==="F"?k:null}if(k){Ut=yr(k.nextSibling),g=k.data==="F!";break e}}Ls(g)}g=!1}g&&(o=h[0])}}return h=In(),h.memoizedState=h.baseState=o,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:my,lastRenderedState:o},h.queue=g,h=Oy.bind(null,it,g),g.dispatch=h,g=zh(!1),N=qh.bind(null,it,!1,g.queue),g=In(),k={state:o,dispatch:null,action:s,pending:null},g.queue=k,h=Z2.bind(null,it,k,N,h),k.dispatch=h,g.memoizedState=s,[o,h,!1]}function gy(s){var o=tn();return xy(o,At,s)}function xy(s,o,h){if(o=Bh(s,o,my)[0],s=Ec(is)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var g=Oo(o)}catch(H){throw H===xa?gc:H}else g=o;o=tn();var k=o.queue,N=k.dispatch;return h!==o.memoizedState&&(it.flags|=2048,Sa(9,{destroy:void 0},eE.bind(null,k,h),null)),[g,N,s]}function eE(s,o){s.action=o}function yy(s){var o=tn(),h=At;if(h!==null)return xy(o,h,s);tn(),o=o.memoizedState,h=tn();var g=h.queue.dispatch;return h.memoizedState=s,[o,g,!1]}function Sa(s,o,h,g){return s={tag:s,create:h,deps:g,inst:o,next:null},o=it.updateQueue,o===null&&(o=Cc(),it.updateQueue=o),h=o.lastEffect,h===null?o.lastEffect=s.next=s:(g=h.next,h.next=s,s.next=g,o.lastEffect=s),s}function by(){return tn().memoizedState}function jc(s,o,h,g){var k=In();it.flags|=s,k.memoizedState=Sa(1|o,{destroy:void 0},h,g===void 0?null:g)}function Nc(s,o,h,g){var k=tn();g=g===void 0?null:g;var N=k.memoizedState.inst;At!==null&&g!==null&&Dh(g,At.memoizedState.deps)?k.memoizedState=Sa(o,N,h,g):(it.flags|=s,k.memoizedState=Sa(1|o,N,h,g))}function vy(s,o){jc(8390656,8,s,o)}function Uh(s,o){Nc(2048,8,s,o)}function tE(s){it.flags|=4;var o=it.updateQueue;if(o===null)o=Cc(),it.updateQueue=o,o.events=[s];else{var h=o.events;h===null?o.events=[s]:h.push(s)}}function _y(s){var o=tn().memoizedState;return tE({ref:o,nextImpl:s}),function(){if((Et&2)!==0)throw Error(r(440));return o.impl.apply(void 0,arguments)}}function Sy(s,o){return Nc(4,2,s,o)}function wy(s,o){return Nc(4,4,s,o)}function Cy(s,o){if(typeof o=="function"){s=s();var h=o(s);return function(){typeof h=="function"?h():o(null)}}if(o!=null)return s=s(),o.current=s,function(){o.current=null}}function ky(s,o,h){h=h!=null?h.concat([s]):null,Nc(4,4,Cy.bind(null,o,s),h)}function Fh(){}function Ey(s,o){var h=tn();o=o===void 0?null:o;var g=h.memoizedState;return o!==null&&Dh(o,g[1])?g[0]:(h.memoizedState=[s,o],s)}function jy(s,o){var h=tn();o=o===void 0?null:o;var g=h.memoizedState;if(o!==null&&Dh(o,g[1]))return g[0];if(g=s(),ki){qt(!0);try{s()}finally{qt(!1)}}return h.memoizedState=[g,o],g}function Vh(s,o,h){return h===void 0||(ss&1073741824)!==0&&(yt&261930)===0?s.memoizedState=o:(s.memoizedState=h,s=Nb(),it.lanes|=s,zs|=s,h)}function Ny(s,o,h,g){return er(h,o)?h:ba.current!==null?(s=Vh(s,h,g),er(s,o)||(cn=!0),s):(ss&42)===0||(ss&1073741824)!==0&&(yt&261930)===0?(cn=!0,s.memoizedState=h):(s=Nb(),it.lanes|=s,zs|=s,o)}function Ty(s,o,h,g,k){var N=Z.p;Z.p=N!==0&&8>N?N:8;var H=G.T,Y={};G.T=Y,qh(s,!1,o,h);try{var ie=k(),pe=G.S;if(pe!==null&&pe(Y,ie),ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var Ee=X2(ie,g);Io(s,o,Ee,ar(s))}else Io(s,o,g,ar(s))}catch(Ae){Io(s,o,{then:function(){},status:"rejected",reason:Ae},ar())}finally{Z.p=N,H!==null&&Y.types!==null&&(H.types=Y.types),G.T=H}}function nE(){}function Gh(s,o,h,g){if(s.tag!==5)throw Error(r(476));var k=Ay(s).queue;Ty(s,k,o,Q,h===null?nE:function(){return Ly(s),h(g)})}function Ay(s){var o=s.memoizedState;if(o!==null)return o;o={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:Q},next:null};var h={};return o.next={memoizedState:h,baseState:h,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:h},next:null},s.memoizedState=o,s=s.alternate,s!==null&&(s.memoizedState=o),o}function Ly(s){var o=Ay(s);o.next===null&&(o=s.alternate.memoizedState),Io(s,o.next.queue,{},ar())}function Wh(){return En(Jo)}function Dy(){return tn().memoizedState}function Ry(){return tn().memoizedState}function rE(s){for(var o=s.return;o!==null;){switch(o.tag){case 24:case 3:var h=ar();s=Os(h);var g=Is(o,s,h);g!==null&&(Kn(g,o,h),Ao(g,o,h)),o={cache:_h()},s.payload=o;return}o=o.return}}function sE(s,o,h){var g=ar();h={lane:g,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Tc(s)?Iy(o,h):(h=uh(s,o,h,g),h!==null&&(Kn(h,s,g),My(h,o,g)))}function Oy(s,o,h){var g=ar();Io(s,o,h,g)}function Io(s,o,h,g){var k={lane:g,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null};if(Tc(s))Iy(o,k);else{var N=s.alternate;if(s.lanes===0&&(N===null||N.lanes===0)&&(N=o.lastRenderedReducer,N!==null))try{var H=o.lastRenderedState,Y=N(H,h);if(k.hasEagerState=!0,k.eagerState=Y,er(Y,H))return cc(s,o,k,0),Mt===null&&lc(),!1}catch{}finally{}if(h=uh(s,o,k,g),h!==null)return Kn(h,s,g),My(h,o,g),!0}return!1}function qh(s,o,h,g){if(g={lane:2,revertLane:Ef(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},Tc(s)){if(o)throw Error(r(479))}else o=uh(s,h,g,2),o!==null&&Kn(o,s,2)}function Tc(s){var o=s.alternate;return s===it||o!==null&&o===it}function Iy(s,o){va=Sc=!0;var h=s.pending;h===null?o.next=o:(o.next=h.next,h.next=o),s.pending=o}function My(s,o,h){if((h&4194048)!==0){var g=o.lanes;g&=s.pendingLanes,h|=g,o.lanes=h,qe(s,h)}}var Mo={readContext:En,use:kc,useCallback:Kt,useContext:Kt,useEffect:Kt,useImperativeHandle:Kt,useLayoutEffect:Kt,useInsertionEffect:Kt,useMemo:Kt,useReducer:Kt,useRef:Kt,useState:Kt,useDebugValue:Kt,useDeferredValue:Kt,useTransition:Kt,useSyncExternalStore:Kt,useId:Kt,useHostTransitionStatus:Kt,useFormState:Kt,useActionState:Kt,useOptimistic:Kt,useMemoCache:Kt,useCacheRefresh:Kt};Mo.useEffectEvent=Kt;var Py={readContext:En,use:kc,useCallback:function(s,o){return In().memoizedState=[s,o===void 0?null:o],s},useContext:En,useEffect:vy,useImperativeHandle:function(s,o,h){h=h!=null?h.concat([s]):null,jc(4194308,4,Cy.bind(null,o,s),h)},useLayoutEffect:function(s,o){return jc(4194308,4,s,o)},useInsertionEffect:function(s,o){jc(4,2,s,o)},useMemo:function(s,o){var h=In();o=o===void 0?null:o;var g=s();if(ki){qt(!0);try{s()}finally{qt(!1)}}return h.memoizedState=[g,o],g},useReducer:function(s,o,h){var g=In();if(h!==void 0){var k=h(o);if(ki){qt(!0);try{h(o)}finally{qt(!1)}}}else k=o;return g.memoizedState=g.baseState=k,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:k},g.queue=s,s=s.dispatch=sE.bind(null,it,s),[g.memoizedState,s]},useRef:function(s){var o=In();return s={current:s},o.memoizedState=s},useState:function(s){s=zh(s);var o=s.queue,h=Oy.bind(null,it,o);return o.dispatch=h,[s.memoizedState,h]},useDebugValue:Fh,useDeferredValue:function(s,o){var h=In();return Vh(h,s,o)},useTransition:function(){var s=zh(!1);return s=Ty.bind(null,it,s.queue,!0,!1),In().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,o,h){var g=it,k=In();if(vt){if(h===void 0)throw Error(r(407));h=h()}else{if(h=o(),Mt===null)throw Error(r(349));(yt&127)!==0||sy(g,o,h)}k.memoizedState=h;var N={value:h,getSnapshot:o};return k.queue=N,vy(ay.bind(null,g,N,s),[s]),g.flags|=2048,Sa(9,{destroy:void 0},iy.bind(null,g,N,h,o),null),h},useId:function(){var s=In(),o=Mt.identifierPrefix;if(vt){var h=Br,g=Pr;h=(g&~(1<<32-dt(g)-1)).toString(32)+h,o="_"+o+"R_"+h,h=wc++,0<h&&(o+="H"+h.toString(32)),o+="_"}else h=Q2++,o="_"+o+"r_"+h.toString(32)+"_";return s.memoizedState=o},useHostTransitionStatus:Wh,useFormState:py,useActionState:py,useOptimistic:function(s){var o=In();o.memoizedState=o.baseState=s;var h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=h,o=qh.bind(null,it,!0,h),h.dispatch=o,[s,o]},useMemoCache:Ph,useCacheRefresh:function(){return In().memoizedState=rE.bind(null,it)},useEffectEvent:function(s){var o=In(),h={impl:s};return o.memoizedState=h,function(){if((Et&2)!==0)throw Error(r(440));return h.impl.apply(void 0,arguments)}}},Kh={readContext:En,use:kc,useCallback:Ey,useContext:En,useEffect:Uh,useImperativeHandle:ky,useInsertionEffect:Sy,useLayoutEffect:wy,useMemo:jy,useReducer:Ec,useRef:by,useState:function(){return Ec(is)},useDebugValue:Fh,useDeferredValue:function(s,o){var h=tn();return Ny(h,At.memoizedState,s,o)},useTransition:function(){var s=Ec(is)[0],o=tn().memoizedState;return[typeof s=="boolean"?s:Oo(s),o]},useSyncExternalStore:ry,useId:Dy,useHostTransitionStatus:Wh,useFormState:gy,useActionState:gy,useOptimistic:function(s,o){var h=tn();return cy(h,At,s,o)},useMemoCache:Ph,useCacheRefresh:Ry};Kh.useEffectEvent=_y;var By={readContext:En,use:kc,useCallback:Ey,useContext:En,useEffect:Uh,useImperativeHandle:ky,useInsertionEffect:Sy,useLayoutEffect:wy,useMemo:jy,useReducer:$h,useRef:by,useState:function(){return $h(is)},useDebugValue:Fh,useDeferredValue:function(s,o){var h=tn();return At===null?Vh(h,s,o):Ny(h,At.memoizedState,s,o)},useTransition:function(){var s=$h(is)[0],o=tn().memoizedState;return[typeof s=="boolean"?s:Oo(s),o]},useSyncExternalStore:ry,useId:Dy,useHostTransitionStatus:Wh,useFormState:yy,useActionState:yy,useOptimistic:function(s,o){var h=tn();return At!==null?cy(h,At,s,o):(h.baseState=s,[s,h.queue.dispatch])},useMemoCache:Ph,useCacheRefresh:Ry};By.useEffectEvent=_y;function Yh(s,o,h,g){o=s.memoizedState,h=h(g,o),h=h==null?o:m({},o,h),s.memoizedState=h,s.lanes===0&&(s.updateQueue.baseState=h)}var Xh={enqueueSetState:function(s,o,h){s=s._reactInternals;var g=ar(),k=Os(g);k.payload=o,h!=null&&(k.callback=h),o=Is(s,k,g),o!==null&&(Kn(o,s,g),Ao(o,s,g))},enqueueReplaceState:function(s,o,h){s=s._reactInternals;var g=ar(),k=Os(g);k.tag=1,k.payload=o,h!=null&&(k.callback=h),o=Is(s,k,g),o!==null&&(Kn(o,s,g),Ao(o,s,g))},enqueueForceUpdate:function(s,o){s=s._reactInternals;var h=ar(),g=Os(h);g.tag=2,o!=null&&(g.callback=o),o=Is(s,g,h),o!==null&&(Kn(o,s,h),Ao(o,s,h))}};function $y(s,o,h,g,k,N,H){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(g,N,H):o.prototype&&o.prototype.isPureReactComponent?!So(h,g)||!So(k,N):!0}function zy(s,o,h,g){s=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(h,g),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(h,g),o.state!==s&&Xh.enqueueReplaceState(o,o.state,null)}function Ei(s,o){var h=o;if("ref"in o){h={};for(var g in o)g!=="ref"&&(h[g]=o[g])}if(s=s.defaultProps){h===o&&(h=m({},h));for(var k in s)h[k]===void 0&&(h[k]=s[k])}return h}function Hy(s){oc(s)}function Uy(s){console.error(s)}function Fy(s){oc(s)}function Ac(s,o){try{var h=s.onUncaughtError;h(o.value,{componentStack:o.stack})}catch(g){setTimeout(function(){throw g})}}function Vy(s,o,h){try{var g=s.onCaughtError;g(h.value,{componentStack:h.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(k){setTimeout(function(){throw k})}}function Qh(s,o,h){return h=Os(h),h.tag=3,h.payload={element:null},h.callback=function(){Ac(s,o)},h}function Gy(s){return s=Os(s),s.tag=3,s}function Wy(s,o,h,g){var k=h.type.getDerivedStateFromError;if(typeof k=="function"){var N=g.value;s.payload=function(){return k(N)},s.callback=function(){Vy(o,h,g)}}var H=h.stateNode;H!==null&&typeof H.componentDidCatch=="function"&&(s.callback=function(){Vy(o,h,g),typeof k!="function"&&(Hs===null?Hs=new Set([this]):Hs.add(this));var Y=g.stack;this.componentDidCatch(g.value,{componentStack:Y!==null?Y:""})})}function iE(s,o,h,g,k){if(h.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(o=h.alternate,o!==null&&ma(o,h,k,!0),h=nr.current,h!==null){switch(h.tag){case 31:case 13:return xr===null?Uc():h.alternate===null&&Yt===0&&(Yt=3),h.flags&=-257,h.flags|=65536,h.lanes=k,g===xc?h.flags|=16384:(o=h.updateQueue,o===null?h.updateQueue=new Set([g]):o.add(g),wf(s,g,k)),!1;case 22:return h.flags|=65536,g===xc?h.flags|=16384:(o=h.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([g])},h.updateQueue=o):(h=o.retryQueue,h===null?o.retryQueue=new Set([g]):h.add(g)),wf(s,g,k)),!1}throw Error(r(435,h.tag))}return wf(s,g,k),Uc(),!1}if(vt)return o=nr.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=k,g!==gh&&(s=Error(r(422),{cause:g}),ko(fr(s,h)))):(g!==gh&&(o=Error(r(423),{cause:g}),ko(fr(o,h))),s=s.current.alternate,s.flags|=65536,k&=-k,s.lanes|=k,g=fr(g,h),k=Qh(s.stateNode,g,k),jh(s,k),Yt!==4&&(Yt=2)),!1;var N=Error(r(520),{cause:g});if(N=fr(N,h),Vo===null?Vo=[N]:Vo.push(N),Yt!==4&&(Yt=2),o===null)return!0;g=fr(g,h),h=o;do{switch(h.tag){case 3:return h.flags|=65536,s=k&-k,h.lanes|=s,s=Qh(h.stateNode,g,s),jh(h,s),!1;case 1:if(o=h.type,N=h.stateNode,(h.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||N!==null&&typeof N.componentDidCatch=="function"&&(Hs===null||!Hs.has(N))))return h.flags|=65536,k&=-k,h.lanes|=k,k=Gy(k),Wy(k,s,h,g),jh(h,k),!1}h=h.return}while(h!==null);return!1}var Jh=Error(r(461)),cn=!1;function jn(s,o,h,g){o.child=s===null?Xx(o,null,h,g):Ci(o,s.child,h,g)}function qy(s,o,h,g,k){h=h.render;var N=o.ref;if("ref"in g){var H={};for(var Y in g)Y!=="ref"&&(H[Y]=g[Y])}else H=g;return vi(o),g=Rh(s,o,h,H,N,k),Y=Oh(),s!==null&&!cn?(Ih(s,o,k),as(s,o,k)):(vt&&Y&&mh(o),o.flags|=1,jn(s,o,g,k),o.child)}function Ky(s,o,h,g,k){if(s===null){var N=h.type;return typeof N=="function"&&!dh(N)&&N.defaultProps===void 0&&h.compare===null?(o.tag=15,o.type=N,Yy(s,o,N,g,k)):(s=dc(h.type,null,g,o,o.mode,k),s.ref=o.ref,s.return=o,o.child=s)}if(N=s.child,!of(s,k)){var H=N.memoizedProps;if(h=h.compare,h=h!==null?h:So,h(H,g)&&s.ref===o.ref)return as(s,o,k)}return o.flags|=1,s=es(N,g),s.ref=o.ref,s.return=o,o.child=s}function Yy(s,o,h,g,k){if(s!==null){var N=s.memoizedProps;if(So(N,g)&&s.ref===o.ref)if(cn=!1,o.pendingProps=g=N,of(s,k))(s.flags&131072)!==0&&(cn=!0);else return o.lanes=s.lanes,as(s,o,k)}return Zh(s,o,h,g,k)}function Xy(s,o,h,g){var k=g.children,N=s!==null?s.memoizedState:null;if(s===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.mode==="hidden"){if((o.flags&128)!==0){if(N=N!==null?N.baseLanes|h:h,s!==null){for(g=o.child=s.child,k=0;g!==null;)k=k|g.lanes|g.childLanes,g=g.sibling;g=k&~N}else g=0,o.child=null;return Qy(s,o,N,h,g)}if((h&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},s!==null&&pc(o,N!==null?N.cachePool:null),N!==null?Zx(o,N):Th(),ey(o);else return g=o.lanes=536870912,Qy(s,o,N!==null?N.baseLanes|h:h,h,g)}else N!==null?(pc(o,N.cachePool),Zx(o,N),Ps(),o.memoizedState=null):(s!==null&&pc(o,null),Th(),Ps());return jn(s,o,k,h),o.child}function Po(s,o){return s!==null&&s.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function Qy(s,o,h,g,k){var N=wh();return N=N===null?null:{parent:on._currentValue,pool:N},o.memoizedState={baseLanes:h,cachePool:N},s!==null&&pc(o,null),Th(),ey(o),s!==null&&ma(s,o,g,!0),o.childLanes=k,null}function Lc(s,o){return o=Rc({mode:o.mode,children:o.children},s.mode),o.ref=s.ref,s.child=o,o.return=s,o}function Jy(s,o,h){return Ci(o,s.child,null,h),s=Lc(o,o.pendingProps),s.flags|=2,rr(o),o.memoizedState=null,s}function aE(s,o,h){var g=o.pendingProps,k=(o.flags&128)!==0;if(o.flags&=-129,s===null){if(vt){if(g.mode==="hidden")return s=Lc(o,g),o.lanes=536870912,Po(null,s);if(Lh(o),(s=Ut)?(s=uv(s,gr),s=s!==null&&s.data==="&"?s:null,s!==null&&(o.memoizedState={dehydrated:s,treeContext:Ts!==null?{id:Pr,overflow:Br}:null,retryLane:536870912,hydrationErrors:null},h=Ix(s),h.return=o,o.child=h,kn=o,Ut=null)):s=null,s===null)throw Ls(o);return o.lanes=536870912,null}return Lc(o,g)}var N=s.memoizedState;if(N!==null){var H=N.dehydrated;if(Lh(o),k)if(o.flags&256)o.flags&=-257,o=Jy(s,o,h);else if(o.memoizedState!==null)o.child=s.child,o.flags|=128,o=null;else throw Error(r(558));else if(cn||ma(s,o,h,!1),k=(h&s.childLanes)!==0,cn||k){if(g=Mt,g!==null&&(H=at(g,h),H!==0&&H!==N.retryLane))throw N.retryLane=H,gi(s,H),Kn(g,s,H),Jh;Uc(),o=Jy(s,o,h)}else s=N.treeContext,Ut=yr(H.nextSibling),kn=o,vt=!0,As=null,gr=!1,s!==null&&Bx(o,s),o=Lc(o,g),o.flags|=4096;return o}return s=es(s.child,{mode:g.mode,children:g.children}),s.ref=o.ref,o.child=s,s.return=o,s}function Dc(s,o){var h=o.ref;if(h===null)s!==null&&s.ref!==null&&(o.flags|=4194816);else{if(typeof h!="function"&&typeof h!="object")throw Error(r(284));(s===null||s.ref!==h)&&(o.flags|=4194816)}}function Zh(s,o,h,g,k){return vi(o),h=Rh(s,o,h,g,void 0,k),g=Oh(),s!==null&&!cn?(Ih(s,o,k),as(s,o,k)):(vt&&g&&mh(o),o.flags|=1,jn(s,o,h,k),o.child)}function Zy(s,o,h,g,k,N){return vi(o),o.updateQueue=null,h=ny(o,g,h,k),ty(s),g=Oh(),s!==null&&!cn?(Ih(s,o,N),as(s,o,N)):(vt&&g&&mh(o),o.flags|=1,jn(s,o,h,N),o.child)}function eb(s,o,h,g,k){if(vi(o),o.stateNode===null){var N=ua,H=h.contextType;typeof H=="object"&&H!==null&&(N=En(H)),N=new h(g,N),o.memoizedState=N.state!==null&&N.state!==void 0?N.state:null,N.updater=Xh,o.stateNode=N,N._reactInternals=o,N=o.stateNode,N.props=g,N.state=o.memoizedState,N.refs={},kh(o),H=h.contextType,N.context=typeof H=="object"&&H!==null?En(H):ua,N.state=o.memoizedState,H=h.getDerivedStateFromProps,typeof H=="function"&&(Yh(o,h,H,g),N.state=o.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof N.getSnapshotBeforeUpdate=="function"||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||(H=N.state,typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount(),H!==N.state&&Xh.enqueueReplaceState(N,N.state,null),Do(o,g,N,k),Lo(),N.state=o.memoizedState),typeof N.componentDidMount=="function"&&(o.flags|=4194308),g=!0}else if(s===null){N=o.stateNode;var Y=o.memoizedProps,ie=Ei(h,Y);N.props=ie;var pe=N.context,Ee=h.contextType;H=ua,typeof Ee=="object"&&Ee!==null&&(H=En(Ee));var Ae=h.getDerivedStateFromProps;Ee=typeof Ae=="function"||typeof N.getSnapshotBeforeUpdate=="function",Y=o.pendingProps!==Y,Ee||typeof N.UNSAFE_componentWillReceiveProps!="function"&&typeof N.componentWillReceiveProps!="function"||(Y||pe!==H)&&zy(o,N,g,H),Rs=!1;var ge=o.memoizedState;N.state=ge,Do(o,g,N,k),Lo(),pe=o.memoizedState,Y||ge!==pe||Rs?(typeof Ae=="function"&&(Yh(o,h,Ae,g),pe=o.memoizedState),(ie=Rs||$y(o,h,ie,g,ge,pe,H))?(Ee||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||(typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount()),typeof N.componentDidMount=="function"&&(o.flags|=4194308)):(typeof N.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=g,o.memoizedState=pe),N.props=g,N.state=pe,N.context=H,g=ie):(typeof N.componentDidMount=="function"&&(o.flags|=4194308),g=!1)}else{N=o.stateNode,Eh(s,o),H=o.memoizedProps,Ee=Ei(h,H),N.props=Ee,Ae=o.pendingProps,ge=N.context,pe=h.contextType,ie=ua,typeof pe=="object"&&pe!==null&&(ie=En(pe)),Y=h.getDerivedStateFromProps,(pe=typeof Y=="function"||typeof N.getSnapshotBeforeUpdate=="function")||typeof N.UNSAFE_componentWillReceiveProps!="function"&&typeof N.componentWillReceiveProps!="function"||(H!==Ae||ge!==ie)&&zy(o,N,g,ie),Rs=!1,ge=o.memoizedState,N.state=ge,Do(o,g,N,k),Lo();var ve=o.memoizedState;H!==Ae||ge!==ve||Rs||s!==null&&s.dependencies!==null&&fc(s.dependencies)?(typeof Y=="function"&&(Yh(o,h,Y,g),ve=o.memoizedState),(Ee=Rs||$y(o,h,Ee,g,ge,ve,ie)||s!==null&&s.dependencies!==null&&fc(s.dependencies))?(pe||typeof N.UNSAFE_componentWillUpdate!="function"&&typeof N.componentWillUpdate!="function"||(typeof N.componentWillUpdate=="function"&&N.componentWillUpdate(g,ve,ie),typeof N.UNSAFE_componentWillUpdate=="function"&&N.UNSAFE_componentWillUpdate(g,ve,ie)),typeof N.componentDidUpdate=="function"&&(o.flags|=4),typeof N.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof N.componentDidUpdate!="function"||H===s.memoizedProps&&ge===s.memoizedState||(o.flags|=4),typeof N.getSnapshotBeforeUpdate!="function"||H===s.memoizedProps&&ge===s.memoizedState||(o.flags|=1024),o.memoizedProps=g,o.memoizedState=ve),N.props=g,N.state=ve,N.context=ie,g=Ee):(typeof N.componentDidUpdate!="function"||H===s.memoizedProps&&ge===s.memoizedState||(o.flags|=4),typeof N.getSnapshotBeforeUpdate!="function"||H===s.memoizedProps&&ge===s.memoizedState||(o.flags|=1024),g=!1)}return N=g,Dc(s,o),g=(o.flags&128)!==0,N||g?(N=o.stateNode,h=g&&typeof h.getDerivedStateFromError!="function"?null:N.render(),o.flags|=1,s!==null&&g?(o.child=Ci(o,s.child,null,k),o.child=Ci(o,null,h,k)):jn(s,o,h,k),o.memoizedState=N.state,s=o.child):s=as(s,o,k),s}function tb(s,o,h,g){return yi(),o.flags|=256,jn(s,o,h,g),o.child}var ef={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function tf(s){return{baseLanes:s,cachePool:Vx()}}function nf(s,o,h){return s=s!==null?s.childLanes&~h:0,o&&(s|=ir),s}function nb(s,o,h){var g=o.pendingProps,k=!1,N=(o.flags&128)!==0,H;if((H=N)||(H=s!==null&&s.memoizedState===null?!1:(en.current&2)!==0),H&&(k=!0,o.flags&=-129),H=(o.flags&32)!==0,o.flags&=-33,s===null){if(vt){if(k?Ms(o):Ps(),(s=Ut)?(s=uv(s,gr),s=s!==null&&s.data!=="&"?s:null,s!==null&&(o.memoizedState={dehydrated:s,treeContext:Ts!==null?{id:Pr,overflow:Br}:null,retryLane:536870912,hydrationErrors:null},h=Ix(s),h.return=o,o.child=h,kn=o,Ut=null)):s=null,s===null)throw Ls(o);return $f(s)?o.lanes=32:o.lanes=536870912,null}var Y=g.children;return g=g.fallback,k?(Ps(),k=o.mode,Y=Rc({mode:"hidden",children:Y},k),g=xi(g,k,h,null),Y.return=o,g.return=o,Y.sibling=g,o.child=Y,g=o.child,g.memoizedState=tf(h),g.childLanes=nf(s,H,h),o.memoizedState=ef,Po(null,g)):(Ms(o),rf(o,Y))}var ie=s.memoizedState;if(ie!==null&&(Y=ie.dehydrated,Y!==null)){if(N)o.flags&256?(Ms(o),o.flags&=-257,o=sf(s,o,h)):o.memoizedState!==null?(Ps(),o.child=s.child,o.flags|=128,o=null):(Ps(),Y=g.fallback,k=o.mode,g=Rc({mode:"visible",children:g.children},k),Y=xi(Y,k,h,null),Y.flags|=2,g.return=o,Y.return=o,g.sibling=Y,o.child=g,Ci(o,s.child,null,h),g=o.child,g.memoizedState=tf(h),g.childLanes=nf(s,H,h),o.memoizedState=ef,o=Po(null,g));else if(Ms(o),$f(Y)){if(H=Y.nextSibling&&Y.nextSibling.dataset,H)var pe=H.dgst;H=pe,g=Error(r(419)),g.stack="",g.digest=H,ko({value:g,source:null,stack:null}),o=sf(s,o,h)}else if(cn||ma(s,o,h,!1),H=(h&s.childLanes)!==0,cn||H){if(H=Mt,H!==null&&(g=at(H,h),g!==0&&g!==ie.retryLane))throw ie.retryLane=g,gi(s,g),Kn(H,s,g),Jh;Bf(Y)||Uc(),o=sf(s,o,h)}else Bf(Y)?(o.flags|=192,o.child=s.child,o=null):(s=ie.treeContext,Ut=yr(Y.nextSibling),kn=o,vt=!0,As=null,gr=!1,s!==null&&Bx(o,s),o=rf(o,g.children),o.flags|=4096);return o}return k?(Ps(),Y=g.fallback,k=o.mode,ie=s.child,pe=ie.sibling,g=es(ie,{mode:"hidden",children:g.children}),g.subtreeFlags=ie.subtreeFlags&65011712,pe!==null?Y=es(pe,Y):(Y=xi(Y,k,h,null),Y.flags|=2),Y.return=o,g.return=o,g.sibling=Y,o.child=g,Po(null,g),g=o.child,Y=s.child.memoizedState,Y===null?Y=tf(h):(k=Y.cachePool,k!==null?(ie=on._currentValue,k=k.parent!==ie?{parent:ie,pool:ie}:k):k=Vx(),Y={baseLanes:Y.baseLanes|h,cachePool:k}),g.memoizedState=Y,g.childLanes=nf(s,H,h),o.memoizedState=ef,Po(s.child,g)):(Ms(o),h=s.child,s=h.sibling,h=es(h,{mode:"visible",children:g.children}),h.return=o,h.sibling=null,s!==null&&(H=o.deletions,H===null?(o.deletions=[s],o.flags|=16):H.push(s)),o.child=h,o.memoizedState=null,h)}function rf(s,o){return o=Rc({mode:"visible",children:o},s.mode),o.return=s,s.child=o}function Rc(s,o){return s=tr(22,s,null,o),s.lanes=0,s}function sf(s,o,h){return Ci(o,s.child,null,h),s=rf(o,o.pendingProps.children),s.flags|=2,o.memoizedState=null,s}function rb(s,o,h){s.lanes|=o;var g=s.alternate;g!==null&&(g.lanes|=o),bh(s.return,o,h)}function af(s,o,h,g,k,N){var H=s.memoizedState;H===null?s.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:g,tail:h,tailMode:k,treeForkCount:N}:(H.isBackwards=o,H.rendering=null,H.renderingStartTime=0,H.last=g,H.tail=h,H.tailMode=k,H.treeForkCount=N)}function sb(s,o,h){var g=o.pendingProps,k=g.revealOrder,N=g.tail;g=g.children;var H=en.current,Y=(H&2)!==0;if(Y?(H=H&1|2,o.flags|=128):H&=1,B(en,H),jn(s,o,g,h),g=vt?Co:0,!Y&&s!==null&&(s.flags&128)!==0)e:for(s=o.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&rb(s,h,o);else if(s.tag===19)rb(s,h,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(k){case"forwards":for(h=o.child,k=null;h!==null;)s=h.alternate,s!==null&&_c(s)===null&&(k=h),h=h.sibling;h=k,h===null?(k=o.child,o.child=null):(k=h.sibling,h.sibling=null),af(o,!1,k,h,N,g);break;case"backwards":case"unstable_legacy-backwards":for(h=null,k=o.child,o.child=null;k!==null;){if(s=k.alternate,s!==null&&_c(s)===null){o.child=k;break}s=k.sibling,k.sibling=h,h=k,k=s}af(o,!0,h,null,N,g);break;case"together":af(o,!1,null,null,void 0,g);break;default:o.memoizedState=null}return o.child}function as(s,o,h){if(s!==null&&(o.dependencies=s.dependencies),zs|=o.lanes,(h&o.childLanes)===0)if(s!==null){if(ma(s,o,h,!1),(h&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,h=es(s,s.pendingProps),o.child=h,h.return=o;s.sibling!==null;)s=s.sibling,h=h.sibling=es(s,s.pendingProps),h.return=o;h.sibling=null}return o.child}function of(s,o){return(s.lanes&o)!==0?!0:(s=s.dependencies,!!(s!==null&&fc(s)))}function oE(s,o,h){switch(o.tag){case 3:F(o,o.stateNode.containerInfo),Ds(o,on,s.memoizedState.cache),yi();break;case 27:case 5:se(o);break;case 4:F(o,o.stateNode.containerInfo);break;case 10:Ds(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Lh(o),null;break;case 13:var g=o.memoizedState;if(g!==null)return g.dehydrated!==null?(Ms(o),o.flags|=128,null):(h&o.child.childLanes)!==0?nb(s,o,h):(Ms(o),s=as(s,o,h),s!==null?s.sibling:null);Ms(o);break;case 19:var k=(s.flags&128)!==0;if(g=(h&o.childLanes)!==0,g||(ma(s,o,h,!1),g=(h&o.childLanes)!==0),k){if(g)return sb(s,o,h);o.flags|=128}if(k=o.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),B(en,en.current),g)break;return null;case 22:return o.lanes=0,Xy(s,o,h,o.pendingProps);case 24:Ds(o,on,s.memoizedState.cache)}return as(s,o,h)}function ib(s,o,h){if(s!==null)if(s.memoizedProps!==o.pendingProps)cn=!0;else{if(!of(s,h)&&(o.flags&128)===0)return cn=!1,oE(s,o,h);cn=(s.flags&131072)!==0}else cn=!1,vt&&(o.flags&1048576)!==0&&Px(o,Co,o.index);switch(o.lanes=0,o.tag){case 16:e:{var g=o.pendingProps;if(s=Si(o.elementType),o.type=s,typeof s=="function")dh(s)?(g=Ei(s,g),o.tag=1,o=eb(null,o,s,g,h)):(o.tag=0,o=Zh(null,o,s,g,h));else{if(s!=null){var k=s.$$typeof;if(k===E){o.tag=11,o=qy(null,o,s,g,h);break e}else if(k===D){o.tag=14,o=Ky(null,o,s,g,h);break e}}throw o=P(s)||s,Error(r(306,o,""))}}return o;case 0:return Zh(s,o,o.type,o.pendingProps,h);case 1:return g=o.type,k=Ei(g,o.pendingProps),eb(s,o,g,k,h);case 3:e:{if(F(o,o.stateNode.containerInfo),s===null)throw Error(r(387));g=o.pendingProps;var N=o.memoizedState;k=N.element,Eh(s,o),Do(o,g,null,h);var H=o.memoizedState;if(g=H.cache,Ds(o,on,g),g!==N.cache&&vh(o,[on],h,!0),Lo(),g=H.element,N.isDehydrated)if(N={element:g,isDehydrated:!1,cache:H.cache},o.updateQueue.baseState=N,o.memoizedState=N,o.flags&256){o=tb(s,o,g,h);break e}else if(g!==k){k=fr(Error(r(424)),o),ko(k),o=tb(s,o,g,h);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(Ut=yr(s.firstChild),kn=o,vt=!0,As=null,gr=!0,h=Xx(o,null,g,h),o.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling}else{if(yi(),g===k){o=as(s,o,h);break e}jn(s,o,g,h)}o=o.child}return o;case 26:return Dc(s,o),s===null?(h=gv(o.type,null,o.pendingProps,null))?o.memoizedState=h:vt||(h=o.type,s=o.pendingProps,g=Yc(ne.current).createElement(h),g[an]=o,g[Un]=s,Nn(g,h,s),vn(g),o.stateNode=g):o.memoizedState=gv(o.type,s.memoizedProps,o.pendingProps,s.memoizedState),null;case 27:return se(o),s===null&&vt&&(g=o.stateNode=fv(o.type,o.pendingProps,ne.current),kn=o,gr=!0,k=Ut,Gs(o.type)?(zf=k,Ut=yr(g.firstChild)):Ut=k),jn(s,o,o.pendingProps.children,h),Dc(s,o),s===null&&(o.flags|=4194304),o.child;case 5:return s===null&&vt&&((k=g=Ut)&&(g=PE(g,o.type,o.pendingProps,gr),g!==null?(o.stateNode=g,kn=o,Ut=yr(g.firstChild),gr=!1,k=!0):k=!1),k||Ls(o)),se(o),k=o.type,N=o.pendingProps,H=s!==null?s.memoizedProps:null,g=N.children,If(k,N)?g=null:H!==null&&If(k,H)&&(o.flags|=32),o.memoizedState!==null&&(k=Rh(s,o,J2,null,null,h),Jo._currentValue=k),Dc(s,o),jn(s,o,g,h),o.child;case 6:return s===null&&vt&&((s=h=Ut)&&(h=BE(h,o.pendingProps,gr),h!==null?(o.stateNode=h,kn=o,Ut=null,s=!0):s=!1),s||Ls(o)),null;case 13:return nb(s,o,h);case 4:return F(o,o.stateNode.containerInfo),g=o.pendingProps,s===null?o.child=Ci(o,null,g,h):jn(s,o,g,h),o.child;case 11:return qy(s,o,o.type,o.pendingProps,h);case 7:return jn(s,o,o.pendingProps,h),o.child;case 8:return jn(s,o,o.pendingProps.children,h),o.child;case 12:return jn(s,o,o.pendingProps.children,h),o.child;case 10:return g=o.pendingProps,Ds(o,o.type,g.value),jn(s,o,g.children,h),o.child;case 9:return k=o.type._context,g=o.pendingProps.children,vi(o),k=En(k),g=g(k),o.flags|=1,jn(s,o,g,h),o.child;case 14:return Ky(s,o,o.type,o.pendingProps,h);case 15:return Yy(s,o,o.type,o.pendingProps,h);case 19:return sb(s,o,h);case 31:return aE(s,o,h);case 22:return Xy(s,o,h,o.pendingProps);case 24:return vi(o),g=En(on),s===null?(k=wh(),k===null&&(k=Mt,N=_h(),k.pooledCache=N,N.refCount++,N!==null&&(k.pooledCacheLanes|=h),k=N),o.memoizedState={parent:g,cache:k},kh(o),Ds(o,on,k)):((s.lanes&h)!==0&&(Eh(s,o),Do(o,null,null,h),Lo()),k=s.memoizedState,N=o.memoizedState,k.parent!==g?(k={parent:g,cache:g},o.memoizedState=k,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=k),Ds(o,on,g)):(g=N.cache,Ds(o,on,g),g!==k.cache&&vh(o,[on],h,!0))),jn(s,o,o.pendingProps.children,h),o.child;case 29:throw o.pendingProps}throw Error(r(156,o.tag))}function os(s){s.flags|=4}function lf(s,o,h,g,k){if((o=(s.mode&32)!==0)&&(o=!1),o){if(s.flags|=16777216,(k&335544128)===k)if(s.stateNode.complete)s.flags|=8192;else if(Db())s.flags|=8192;else throw wi=xc,Ch}else s.flags&=-16777217}function ab(s,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!_v(o))if(Db())s.flags|=8192;else throw wi=xc,Ch}function Oc(s,o){o!==null&&(s.flags|=4),s.flags&16384&&(o=s.tag!==22?bn():536870912,s.lanes|=o,Ea|=o)}function Bo(s,o){if(!vt)switch(s.tailMode){case"hidden":o=s.tail;for(var h=null;o!==null;)o.alternate!==null&&(h=o),o=o.sibling;h===null?s.tail=null:h.sibling=null;break;case"collapsed":h=s.tail;for(var g=null;h!==null;)h.alternate!==null&&(g=h),h=h.sibling;g===null?o||s.tail===null?s.tail=null:s.tail.sibling=null:g.sibling=null}}function Ft(s){var o=s.alternate!==null&&s.alternate.child===s.child,h=0,g=0;if(o)for(var k=s.child;k!==null;)h|=k.lanes|k.childLanes,g|=k.subtreeFlags&65011712,g|=k.flags&65011712,k.return=s,k=k.sibling;else for(k=s.child;k!==null;)h|=k.lanes|k.childLanes,g|=k.subtreeFlags,g|=k.flags,k.return=s,k=k.sibling;return s.subtreeFlags|=g,s.childLanes=h,o}function lE(s,o,h){var g=o.pendingProps;switch(ph(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ft(o),null;case 1:return Ft(o),null;case 3:return h=o.stateNode,g=null,s!==null&&(g=s.memoizedState.cache),o.memoizedState.cache!==g&&(o.flags|=2048),rs(on),te(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(s===null||s.child===null)&&(fa(o)?os(o):s===null||s.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,xh())),Ft(o),null;case 26:var k=o.type,N=o.memoizedState;return s===null?(os(o),N!==null?(Ft(o),ab(o,N)):(Ft(o),lf(o,k,null,g,h))):N?N!==s.memoizedState?(os(o),Ft(o),ab(o,N)):(Ft(o),o.flags&=-16777217):(s=s.memoizedProps,s!==g&&os(o),Ft(o),lf(o,k,s,g,h)),null;case 27:if(xe(o),h=ne.current,k=o.type,s!==null&&o.stateNode!=null)s.memoizedProps!==g&&os(o);else{if(!g){if(o.stateNode===null)throw Error(r(166));return Ft(o),null}s=ee.current,fa(o)?$x(o):(s=fv(k,g,h),o.stateNode=s,os(o))}return Ft(o),null;case 5:if(xe(o),k=o.type,s!==null&&o.stateNode!=null)s.memoizedProps!==g&&os(o);else{if(!g){if(o.stateNode===null)throw Error(r(166));return Ft(o),null}if(N=ee.current,fa(o))$x(o);else{var H=Yc(ne.current);switch(N){case 1:N=H.createElementNS("http://www.w3.org/2000/svg",k);break;case 2:N=H.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;default:switch(k){case"svg":N=H.createElementNS("http://www.w3.org/2000/svg",k);break;case"math":N=H.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;case"script":N=H.createElement("div"),N.innerHTML="<script><\/script>",N=N.removeChild(N.firstChild);break;case"select":N=typeof g.is=="string"?H.createElement("select",{is:g.is}):H.createElement("select"),g.multiple?N.multiple=!0:g.size&&(N.size=g.size);break;default:N=typeof g.is=="string"?H.createElement(k,{is:g.is}):H.createElement(k)}}N[an]=o,N[Un]=g;e:for(H=o.child;H!==null;){if(H.tag===5||H.tag===6)N.appendChild(H.stateNode);else if(H.tag!==4&&H.tag!==27&&H.child!==null){H.child.return=H,H=H.child;continue}if(H===o)break e;for(;H.sibling===null;){if(H.return===null||H.return===o)break e;H=H.return}H.sibling.return=H.return,H=H.sibling}o.stateNode=N;e:switch(Nn(N,k,g),k){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&os(o)}}return Ft(o),lf(o,o.type,s===null?null:s.memoizedProps,o.pendingProps,h),null;case 6:if(s&&o.stateNode!=null)s.memoizedProps!==g&&os(o);else{if(typeof g!="string"&&o.stateNode===null)throw Error(r(166));if(s=ne.current,fa(o)){if(s=o.stateNode,h=o.memoizedProps,g=null,k=kn,k!==null)switch(k.tag){case 27:case 5:g=k.memoizedProps}s[an]=o,s=!!(s.nodeValue===h||g!==null&&g.suppressHydrationWarning===!0||nv(s.nodeValue,h)),s||Ls(o,!0)}else s=Yc(s).createTextNode(g),s[an]=o,o.stateNode=s}return Ft(o),null;case 31:if(h=o.memoizedState,s===null||s.memoizedState!==null){if(g=fa(o),h!==null){if(s===null){if(!g)throw Error(r(318));if(s=o.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[an]=o}else yi(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Ft(o),s=!1}else h=xh(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=h),s=!0;if(!s)return o.flags&256?(rr(o),o):(rr(o),null);if((o.flags&128)!==0)throw Error(r(558))}return Ft(o),null;case 13:if(g=o.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(k=fa(o),g!==null&&g.dehydrated!==null){if(s===null){if(!k)throw Error(r(318));if(k=o.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(r(317));k[an]=o}else yi(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Ft(o),k=!1}else k=xh(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=k),k=!0;if(!k)return o.flags&256?(rr(o),o):(rr(o),null)}return rr(o),(o.flags&128)!==0?(o.lanes=h,o):(h=g!==null,s=s!==null&&s.memoizedState!==null,h&&(g=o.child,k=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(k=g.alternate.memoizedState.cachePool.pool),N=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(N=g.memoizedState.cachePool.pool),N!==k&&(g.flags|=2048)),h!==s&&h&&(o.child.flags|=8192),Oc(o,o.updateQueue),Ft(o),null);case 4:return te(),s===null&&Af(o.stateNode.containerInfo),Ft(o),null;case 10:return rs(o.type),Ft(o),null;case 19:if(q(en),g=o.memoizedState,g===null)return Ft(o),null;if(k=(o.flags&128)!==0,N=g.rendering,N===null)if(k)Bo(g,!1);else{if(Yt!==0||s!==null&&(s.flags&128)!==0)for(s=o.child;s!==null;){if(N=_c(s),N!==null){for(o.flags|=128,Bo(g,!1),s=N.updateQueue,o.updateQueue=s,Oc(o,s),o.subtreeFlags=0,s=h,h=o.child;h!==null;)Ox(h,s),h=h.sibling;return B(en,en.current&1|2),vt&&ts(o,g.treeForkCount),o.child}s=s.sibling}g.tail!==null&&He()>$c&&(o.flags|=128,k=!0,Bo(g,!1),o.lanes=4194304)}else{if(!k)if(s=_c(N),s!==null){if(o.flags|=128,k=!0,s=s.updateQueue,o.updateQueue=s,Oc(o,s),Bo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!N.alternate&&!vt)return Ft(o),null}else 2*He()-g.renderingStartTime>$c&&h!==536870912&&(o.flags|=128,k=!0,Bo(g,!1),o.lanes=4194304);g.isBackwards?(N.sibling=o.child,o.child=N):(s=g.last,s!==null?s.sibling=N:o.child=N,g.last=N)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=He(),s.sibling=null,h=en.current,B(en,k?h&1|2:h&1),vt&&ts(o,g.treeForkCount),s):(Ft(o),null);case 22:case 23:return rr(o),Ah(),g=o.memoizedState!==null,s!==null?s.memoizedState!==null!==g&&(o.flags|=8192):g&&(o.flags|=8192),g?(h&536870912)!==0&&(o.flags&128)===0&&(Ft(o),o.subtreeFlags&6&&(o.flags|=8192)):Ft(o),h=o.updateQueue,h!==null&&Oc(o,h.retryQueue),h=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),g=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),g!==h&&(o.flags|=2048),s!==null&&q(_i),null;case 24:return h=null,s!==null&&(h=s.memoizedState.cache),o.memoizedState.cache!==h&&(o.flags|=2048),rs(on),Ft(o),null;case 25:return null;case 30:return null}throw Error(r(156,o.tag))}function cE(s,o){switch(ph(o),o.tag){case 1:return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 3:return rs(on),te(),s=o.flags,(s&65536)!==0&&(s&128)===0?(o.flags=s&-65537|128,o):null;case 26:case 27:case 5:return xe(o),null;case 31:if(o.memoizedState!==null){if(rr(o),o.alternate===null)throw Error(r(340));yi()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 13:if(rr(o),s=o.memoizedState,s!==null&&s.dehydrated!==null){if(o.alternate===null)throw Error(r(340));yi()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 19:return q(en),null;case 4:return te(),null;case 10:return rs(o.type),null;case 22:case 23:return rr(o),Ah(),s!==null&&q(_i),s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 24:return rs(on),null;case 25:return null;default:return null}}function ob(s,o){switch(ph(o),o.tag){case 3:rs(on),te();break;case 26:case 27:case 5:xe(o);break;case 4:te();break;case 31:o.memoizedState!==null&&rr(o);break;case 13:rr(o);break;case 19:q(en);break;case 10:rs(o.type);break;case 22:case 23:rr(o),Ah(),s!==null&&q(_i);break;case 24:rs(on)}}function $o(s,o){try{var h=o.updateQueue,g=h!==null?h.lastEffect:null;if(g!==null){var k=g.next;h=k;do{if((h.tag&s)===s){g=void 0;var N=h.create,H=h.inst;g=N(),H.destroy=g}h=h.next}while(h!==k)}}catch(Y){Tt(o,o.return,Y)}}function Bs(s,o,h){try{var g=o.updateQueue,k=g!==null?g.lastEffect:null;if(k!==null){var N=k.next;g=N;do{if((g.tag&s)===s){var H=g.inst,Y=H.destroy;if(Y!==void 0){H.destroy=void 0,k=o;var ie=h,pe=Y;try{pe()}catch(Ee){Tt(k,ie,Ee)}}}g=g.next}while(g!==N)}}catch(Ee){Tt(o,o.return,Ee)}}function lb(s){var o=s.updateQueue;if(o!==null){var h=s.stateNode;try{Jx(o,h)}catch(g){Tt(s,s.return,g)}}}function cb(s,o,h){h.props=Ei(s.type,s.memoizedProps),h.state=s.memoizedState;try{h.componentWillUnmount()}catch(g){Tt(s,o,g)}}function zo(s,o){try{var h=s.ref;if(h!==null){switch(s.tag){case 26:case 27:case 5:var g=s.stateNode;break;case 30:g=s.stateNode;break;default:g=s.stateNode}typeof h=="function"?s.refCleanup=h(g):h.current=g}}catch(k){Tt(s,o,k)}}function $r(s,o){var h=s.ref,g=s.refCleanup;if(h!==null)if(typeof g=="function")try{g()}catch(k){Tt(s,o,k)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof h=="function")try{h(null)}catch(k){Tt(s,o,k)}else h.current=null}function ub(s){var o=s.type,h=s.memoizedProps,g=s.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":h.autoFocus&&g.focus();break e;case"img":h.src?g.src=h.src:h.srcSet&&(g.srcset=h.srcSet)}}catch(k){Tt(s,s.return,k)}}function cf(s,o,h){try{var g=s.stateNode;LE(g,s.type,h,o),g[Un]=o}catch(k){Tt(s,s.return,k)}}function db(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Gs(s.type)||s.tag===4}function uf(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||db(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&&Gs(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 df(s,o,h){var g=s.tag;if(g===5||g===6)s=s.stateNode,o?(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h).insertBefore(s,o):(o=h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,o.appendChild(s),h=h._reactRootContainer,h!=null||o.onclick!==null||(o.onclick=Jr));else if(g!==4&&(g===27&&Gs(s.type)&&(h=s.stateNode,o=null),s=s.child,s!==null))for(df(s,o,h),s=s.sibling;s!==null;)df(s,o,h),s=s.sibling}function Ic(s,o,h){var g=s.tag;if(g===5||g===6)s=s.stateNode,o?h.insertBefore(s,o):h.appendChild(s);else if(g!==4&&(g===27&&Gs(s.type)&&(h=s.stateNode),s=s.child,s!==null))for(Ic(s,o,h),s=s.sibling;s!==null;)Ic(s,o,h),s=s.sibling}function hb(s){var o=s.stateNode,h=s.memoizedProps;try{for(var g=s.type,k=o.attributes;k.length;)o.removeAttributeNode(k[0]);Nn(o,g,h),o[an]=s,o[Un]=h}catch(N){Tt(s,s.return,N)}}var ls=!1,un=!1,hf=!1,fb=typeof WeakSet=="function"?WeakSet:Set,_n=null;function uE(s,o){if(s=s.containerInfo,Rf=nu,s=kx(s),sh(s)){if("selectionStart"in s)var h={start:s.selectionStart,end:s.selectionEnd};else e:{h=(h=s.ownerDocument)&&h.defaultView||window;var g=h.getSelection&&h.getSelection();if(g&&g.rangeCount!==0){h=g.anchorNode;var k=g.anchorOffset,N=g.focusNode;g=g.focusOffset;try{h.nodeType,N.nodeType}catch{h=null;break e}var H=0,Y=-1,ie=-1,pe=0,Ee=0,Ae=s,ge=null;t:for(;;){for(var ve;Ae!==h||k!==0&&Ae.nodeType!==3||(Y=H+k),Ae!==N||g!==0&&Ae.nodeType!==3||(ie=H+g),Ae.nodeType===3&&(H+=Ae.nodeValue.length),(ve=Ae.firstChild)!==null;)ge=Ae,Ae=ve;for(;;){if(Ae===s)break t;if(ge===h&&++pe===k&&(Y=H),ge===N&&++Ee===g&&(ie=H),(ve=Ae.nextSibling)!==null)break;Ae=ge,ge=Ae.parentNode}Ae=ve}h=Y===-1||ie===-1?null:{start:Y,end:ie}}else h=null}h=h||{start:0,end:0}}else h=null;for(Of={focusedElem:s,selectionRange:h},nu=!1,_n=o;_n!==null;)if(o=_n,s=o.child,(o.subtreeFlags&1028)!==0&&s!==null)s.return=o,_n=s;else for(;_n!==null;){switch(o=_n,N=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(h=0;h<s.length;h++)k=s[h],k.ref.impl=k.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&N!==null){s=void 0,h=o,k=N.memoizedProps,N=N.memoizedState,g=h.stateNode;try{var Ve=Ei(h.type,k);s=g.getSnapshotBeforeUpdate(Ve,N),g.__reactInternalSnapshotBeforeUpdate=s}catch(Ze){Tt(h,h.return,Ze)}}break;case 3:if((s&1024)!==0){if(s=o.stateNode.containerInfo,h=s.nodeType,h===9)Pf(s);else if(h===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":Pf(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,_n=s;break}_n=o.return}}function mb(s,o,h){var g=h.flags;switch(h.tag){case 0:case 11:case 15:us(s,h),g&4&&$o(5,h);break;case 1:if(us(s,h),g&4)if(s=h.stateNode,o===null)try{s.componentDidMount()}catch(H){Tt(h,h.return,H)}else{var k=Ei(h.type,o.memoizedProps);o=o.memoizedState;try{s.componentDidUpdate(k,o,s.__reactInternalSnapshotBeforeUpdate)}catch(H){Tt(h,h.return,H)}}g&64&&lb(h),g&512&&zo(h,h.return);break;case 3:if(us(s,h),g&64&&(s=h.updateQueue,s!==null)){if(o=null,h.child!==null)switch(h.child.tag){case 27:case 5:o=h.child.stateNode;break;case 1:o=h.child.stateNode}try{Jx(s,o)}catch(H){Tt(h,h.return,H)}}break;case 27:o===null&&g&4&&hb(h);case 26:case 5:us(s,h),o===null&&g&4&&ub(h),g&512&&zo(h,h.return);break;case 12:us(s,h);break;case 31:us(s,h),g&4&&xb(s,h);break;case 13:us(s,h),g&4&&yb(s,h),g&64&&(s=h.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(h=bE.bind(null,h),$E(s,h))));break;case 22:if(g=h.memoizedState!==null||ls,!g){o=o!==null&&o.memoizedState!==null||un,k=ls;var N=un;ls=g,(un=o)&&!N?ds(s,h,(h.subtreeFlags&8772)!==0):us(s,h),ls=k,un=N}break;case 30:break;default:us(s,h)}}function pb(s){var o=s.alternate;o!==null&&(s.alternate=null,pb(o)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(o=s.stateNode,o!==null&&Hd(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 Vt=null,Vn=!1;function cs(s,o,h){for(h=h.child;h!==null;)gb(s,o,h),h=h.sibling}function gb(s,o,h){if(It&&typeof It.onCommitFiberUnmount=="function")try{It.onCommitFiberUnmount(_t,h)}catch{}switch(h.tag){case 26:un||$r(h,o),cs(s,o,h),h.memoizedState?h.memoizedState.count--:h.stateNode&&(h=h.stateNode,h.parentNode.removeChild(h));break;case 27:un||$r(h,o);var g=Vt,k=Vn;Gs(h.type)&&(Vt=h.stateNode,Vn=!1),cs(s,o,h),Yo(h.stateNode),Vt=g,Vn=k;break;case 5:un||$r(h,o);case 6:if(g=Vt,k=Vn,Vt=null,cs(s,o,h),Vt=g,Vn=k,Vt!==null)if(Vn)try{(Vt.nodeType===9?Vt.body:Vt.nodeName==="HTML"?Vt.ownerDocument.body:Vt).removeChild(h.stateNode)}catch(N){Tt(h,o,N)}else try{Vt.removeChild(h.stateNode)}catch(N){Tt(h,o,N)}break;case 18:Vt!==null&&(Vn?(s=Vt,lv(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,h.stateNode),Oa(s)):lv(Vt,h.stateNode));break;case 4:g=Vt,k=Vn,Vt=h.stateNode.containerInfo,Vn=!0,cs(s,o,h),Vt=g,Vn=k;break;case 0:case 11:case 14:case 15:Bs(2,h,o),un||Bs(4,h,o),cs(s,o,h);break;case 1:un||($r(h,o),g=h.stateNode,typeof g.componentWillUnmount=="function"&&cb(h,o,g)),cs(s,o,h);break;case 21:cs(s,o,h);break;case 22:un=(g=un)||h.memoizedState!==null,cs(s,o,h),un=g;break;default:cs(s,o,h)}}function xb(s,o){if(o.memoizedState===null&&(s=o.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Oa(s)}catch(h){Tt(o,o.return,h)}}}function yb(s,o){if(o.memoizedState===null&&(s=o.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Oa(s)}catch(h){Tt(o,o.return,h)}}function dE(s){switch(s.tag){case 31:case 13:case 19:var o=s.stateNode;return o===null&&(o=s.stateNode=new fb),o;case 22:return s=s.stateNode,o=s._retryCache,o===null&&(o=s._retryCache=new fb),o;default:throw Error(r(435,s.tag))}}function Mc(s,o){var h=dE(s);o.forEach(function(g){if(!h.has(g)){h.add(g);var k=vE.bind(null,s,g);g.then(k,k)}})}function Gn(s,o){var h=o.deletions;if(h!==null)for(var g=0;g<h.length;g++){var k=h[g],N=s,H=o,Y=H;e:for(;Y!==null;){switch(Y.tag){case 27:if(Gs(Y.type)){Vt=Y.stateNode,Vn=!1;break e}break;case 5:Vt=Y.stateNode,Vn=!1;break e;case 3:case 4:Vt=Y.stateNode.containerInfo,Vn=!0;break e}Y=Y.return}if(Vt===null)throw Error(r(160));gb(N,H,k),Vt=null,Vn=!1,N=k.alternate,N!==null&&(N.return=null),k.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)bb(o,s),o=o.sibling}var jr=null;function bb(s,o){var h=s.alternate,g=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:Gn(o,s),Wn(s),g&4&&(Bs(3,s,s.return),$o(3,s),Bs(5,s,s.return));break;case 1:Gn(o,s),Wn(s),g&512&&(un||h===null||$r(h,h.return)),g&64&&ls&&(s=s.updateQueue,s!==null&&(g=s.callbacks,g!==null&&(h=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=h===null?g:h.concat(g))));break;case 26:var k=jr;if(Gn(o,s),Wn(s),g&512&&(un||h===null||$r(h,h.return)),g&4){var N=h!==null?h.memoizedState:null;if(g=s.memoizedState,h===null)if(g===null)if(s.stateNode===null){e:{g=s.type,h=s.memoizedProps,k=k.ownerDocument||k;t:switch(g){case"title":N=k.getElementsByTagName("title")[0],(!N||N[fo]||N[an]||N.namespaceURI==="http://www.w3.org/2000/svg"||N.hasAttribute("itemprop"))&&(N=k.createElement(g),k.head.insertBefore(N,k.querySelector("head > title"))),Nn(N,g,h),N[an]=s,vn(N),g=N;break e;case"link":var H=bv("link","href",k).get(g+(h.href||""));if(H){for(var Y=0;Y<H.length;Y++)if(N=H[Y],N.getAttribute("href")===(h.href==null||h.href===""?null:h.href)&&N.getAttribute("rel")===(h.rel==null?null:h.rel)&&N.getAttribute("title")===(h.title==null?null:h.title)&&N.getAttribute("crossorigin")===(h.crossOrigin==null?null:h.crossOrigin)){H.splice(Y,1);break t}}N=k.createElement(g),Nn(N,g,h),k.head.appendChild(N);break;case"meta":if(H=bv("meta","content",k).get(g+(h.content||""))){for(Y=0;Y<H.length;Y++)if(N=H[Y],N.getAttribute("content")===(h.content==null?null:""+h.content)&&N.getAttribute("name")===(h.name==null?null:h.name)&&N.getAttribute("property")===(h.property==null?null:h.property)&&N.getAttribute("http-equiv")===(h.httpEquiv==null?null:h.httpEquiv)&&N.getAttribute("charset")===(h.charSet==null?null:h.charSet)){H.splice(Y,1);break t}}N=k.createElement(g),Nn(N,g,h),k.head.appendChild(N);break;default:throw Error(r(468,g))}N[an]=s,vn(N),g=N}s.stateNode=g}else vv(k,s.type,s.stateNode);else s.stateNode=yv(k,g,s.memoizedProps);else N!==g?(N===null?h.stateNode!==null&&(h=h.stateNode,h.parentNode.removeChild(h)):N.count--,g===null?vv(k,s.type,s.stateNode):yv(k,g,s.memoizedProps)):g===null&&s.stateNode!==null&&cf(s,s.memoizedProps,h.memoizedProps)}break;case 27:Gn(o,s),Wn(s),g&512&&(un||h===null||$r(h,h.return)),h!==null&&g&4&&cf(s,s.memoizedProps,h.memoizedProps);break;case 5:if(Gn(o,s),Wn(s),g&512&&(un||h===null||$r(h,h.return)),s.flags&32){k=s.stateNode;try{ra(k,"")}catch(Ve){Tt(s,s.return,Ve)}}g&4&&s.stateNode!=null&&(k=s.memoizedProps,cf(s,k,h!==null?h.memoizedProps:k)),g&1024&&(hf=!0);break;case 6:if(Gn(o,s),Wn(s),g&4){if(s.stateNode===null)throw Error(r(162));g=s.memoizedProps,h=s.stateNode;try{h.nodeValue=g}catch(Ve){Tt(s,s.return,Ve)}}break;case 3:if(Jc=null,k=jr,jr=Xc(o.containerInfo),Gn(o,s),jr=k,Wn(s),g&4&&h!==null&&h.memoizedState.isDehydrated)try{Oa(o.containerInfo)}catch(Ve){Tt(s,s.return,Ve)}hf&&(hf=!1,vb(s));break;case 4:g=jr,jr=Xc(s.stateNode.containerInfo),Gn(o,s),Wn(s),jr=g;break;case 12:Gn(o,s),Wn(s);break;case 31:Gn(o,s),Wn(s),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Mc(s,g)));break;case 13:Gn(o,s),Wn(s),s.child.flags&8192&&s.memoizedState!==null!=(h!==null&&h.memoizedState!==null)&&(Bc=He()),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Mc(s,g)));break;case 22:k=s.memoizedState!==null;var ie=h!==null&&h.memoizedState!==null,pe=ls,Ee=un;if(ls=pe||k,un=Ee||ie,Gn(o,s),un=Ee,ls=pe,Wn(s),g&8192)e:for(o=s.stateNode,o._visibility=k?o._visibility&-2:o._visibility|1,k&&(h===null||ie||ls||un||ji(s)),h=null,o=s;;){if(o.tag===5||o.tag===26){if(h===null){ie=h=o;try{if(N=ie.stateNode,k)H=N.style,typeof H.setProperty=="function"?H.setProperty("display","none","important"):H.display="none";else{Y=ie.stateNode;var Ae=ie.memoizedProps.style,ge=Ae!=null&&Ae.hasOwnProperty("display")?Ae.display:null;Y.style.display=ge==null||typeof ge=="boolean"?"":(""+ge).trim()}}catch(Ve){Tt(ie,ie.return,Ve)}}}else if(o.tag===6){if(h===null){ie=o;try{ie.stateNode.nodeValue=k?"":ie.memoizedProps}catch(Ve){Tt(ie,ie.return,Ve)}}}else if(o.tag===18){if(h===null){ie=o;try{var ve=ie.stateNode;k?cv(ve,!0):cv(ie.stateNode,!1)}catch(Ve){Tt(ie,ie.return,Ve)}}}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;h===o&&(h=null),o=o.return}h===o&&(h=null),o.sibling.return=o.return,o=o.sibling}g&4&&(g=s.updateQueue,g!==null&&(h=g.retryQueue,h!==null&&(g.retryQueue=null,Mc(s,h))));break;case 19:Gn(o,s),Wn(s),g&4&&(g=s.updateQueue,g!==null&&(s.updateQueue=null,Mc(s,g)));break;case 30:break;case 21:break;default:Gn(o,s),Wn(s)}}function Wn(s){var o=s.flags;if(o&2){try{for(var h,g=s.return;g!==null;){if(db(g)){h=g;break}g=g.return}if(h==null)throw Error(r(160));switch(h.tag){case 27:var k=h.stateNode,N=uf(s);Ic(s,N,k);break;case 5:var H=h.stateNode;h.flags&32&&(ra(H,""),h.flags&=-33);var Y=uf(s);Ic(s,Y,H);break;case 3:case 4:var ie=h.stateNode.containerInfo,pe=uf(s);df(s,pe,ie);break;default:throw Error(r(161))}}catch(Ee){Tt(s,s.return,Ee)}s.flags&=-3}o&4096&&(s.flags&=-4097)}function vb(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var o=s;vb(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),s=s.sibling}}function us(s,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)mb(s,o.alternate,o),o=o.sibling}function ji(s){for(s=s.child;s!==null;){var o=s;switch(o.tag){case 0:case 11:case 14:case 15:Bs(4,o,o.return),ji(o);break;case 1:$r(o,o.return);var h=o.stateNode;typeof h.componentWillUnmount=="function"&&cb(o,o.return,h),ji(o);break;case 27:Yo(o.stateNode);case 26:case 5:$r(o,o.return),ji(o);break;case 22:o.memoizedState===null&&ji(o);break;case 30:ji(o);break;default:ji(o)}s=s.sibling}}function ds(s,o,h){for(h=h&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var g=o.alternate,k=s,N=o,H=N.flags;switch(N.tag){case 0:case 11:case 15:ds(k,N,h),$o(4,N);break;case 1:if(ds(k,N,h),g=N,k=g.stateNode,typeof k.componentDidMount=="function")try{k.componentDidMount()}catch(pe){Tt(g,g.return,pe)}if(g=N,k=g.updateQueue,k!==null){var Y=g.stateNode;try{var ie=k.shared.hiddenCallbacks;if(ie!==null)for(k.shared.hiddenCallbacks=null,k=0;k<ie.length;k++)Qx(ie[k],Y)}catch(pe){Tt(g,g.return,pe)}}h&&H&64&&lb(N),zo(N,N.return);break;case 27:hb(N);case 26:case 5:ds(k,N,h),h&&g===null&&H&4&&ub(N),zo(N,N.return);break;case 12:ds(k,N,h);break;case 31:ds(k,N,h),h&&H&4&&xb(k,N);break;case 13:ds(k,N,h),h&&H&4&&yb(k,N);break;case 22:N.memoizedState===null&&ds(k,N,h),zo(N,N.return);break;case 30:break;default:ds(k,N,h)}o=o.sibling}}function ff(s,o){var h=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),s=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(s=o.memoizedState.cachePool.pool),s!==h&&(s!=null&&s.refCount++,h!=null&&Eo(h))}function mf(s,o){s=null,o.alternate!==null&&(s=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==s&&(o.refCount++,s!=null&&Eo(s))}function Nr(s,o,h,g){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)_b(s,o,h,g),o=o.sibling}function _b(s,o,h,g){var k=o.flags;switch(o.tag){case 0:case 11:case 15:Nr(s,o,h,g),k&2048&&$o(9,o);break;case 1:Nr(s,o,h,g);break;case 3:Nr(s,o,h,g),k&2048&&(s=null,o.alternate!==null&&(s=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==s&&(o.refCount++,s!=null&&Eo(s)));break;case 12:if(k&2048){Nr(s,o,h,g),s=o.stateNode;try{var N=o.memoizedProps,H=N.id,Y=N.onPostCommit;typeof Y=="function"&&Y(H,o.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(ie){Tt(o,o.return,ie)}}else Nr(s,o,h,g);break;case 31:Nr(s,o,h,g);break;case 13:Nr(s,o,h,g);break;case 23:break;case 22:N=o.stateNode,H=o.alternate,o.memoizedState!==null?N._visibility&2?Nr(s,o,h,g):Ho(s,o):N._visibility&2?Nr(s,o,h,g):(N._visibility|=2,wa(s,o,h,g,(o.subtreeFlags&10256)!==0||!1)),k&2048&&ff(H,o);break;case 24:Nr(s,o,h,g),k&2048&&mf(o.alternate,o);break;default:Nr(s,o,h,g)}}function wa(s,o,h,g,k){for(k=k&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var N=s,H=o,Y=h,ie=g,pe=H.flags;switch(H.tag){case 0:case 11:case 15:wa(N,H,Y,ie,k),$o(8,H);break;case 23:break;case 22:var Ee=H.stateNode;H.memoizedState!==null?Ee._visibility&2?wa(N,H,Y,ie,k):Ho(N,H):(Ee._visibility|=2,wa(N,H,Y,ie,k)),k&&pe&2048&&ff(H.alternate,H);break;case 24:wa(N,H,Y,ie,k),k&&pe&2048&&mf(H.alternate,H);break;default:wa(N,H,Y,ie,k)}o=o.sibling}}function Ho(s,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var h=s,g=o,k=g.flags;switch(g.tag){case 22:Ho(h,g),k&2048&&ff(g.alternate,g);break;case 24:Ho(h,g),k&2048&&mf(g.alternate,g);break;default:Ho(h,g)}o=o.sibling}}var Uo=8192;function Ca(s,o,h){if(s.subtreeFlags&Uo)for(s=s.child;s!==null;)Sb(s,o,h),s=s.sibling}function Sb(s,o,h){switch(s.tag){case 26:Ca(s,o,h),s.flags&Uo&&s.memoizedState!==null&&QE(h,jr,s.memoizedState,s.memoizedProps);break;case 5:Ca(s,o,h);break;case 3:case 4:var g=jr;jr=Xc(s.stateNode.containerInfo),Ca(s,o,h),jr=g;break;case 22:s.memoizedState===null&&(g=s.alternate,g!==null&&g.memoizedState!==null?(g=Uo,Uo=16777216,Ca(s,o,h),Uo=g):Ca(s,o,h));break;default:Ca(s,o,h)}}function wb(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 Fo(s){var o=s.deletions;if((s.flags&16)!==0){if(o!==null)for(var h=0;h<o.length;h++){var g=o[h];_n=g,kb(g,s)}wb(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Cb(s),s=s.sibling}function Cb(s){switch(s.tag){case 0:case 11:case 15:Fo(s),s.flags&2048&&Bs(9,s,s.return);break;case 3:Fo(s);break;case 12:Fo(s);break;case 22:var o=s.stateNode;s.memoizedState!==null&&o._visibility&2&&(s.return===null||s.return.tag!==13)?(o._visibility&=-3,Pc(s)):Fo(s);break;default:Fo(s)}}function Pc(s){var o=s.deletions;if((s.flags&16)!==0){if(o!==null)for(var h=0;h<o.length;h++){var g=o[h];_n=g,kb(g,s)}wb(s)}for(s=s.child;s!==null;){switch(o=s,o.tag){case 0:case 11:case 15:Bs(8,o,o.return),Pc(o);break;case 22:h=o.stateNode,h._visibility&2&&(h._visibility&=-3,Pc(o));break;default:Pc(o)}s=s.sibling}}function kb(s,o){for(;_n!==null;){var h=_n;switch(h.tag){case 0:case 11:case 15:Bs(8,h,o);break;case 23:case 22:if(h.memoizedState!==null&&h.memoizedState.cachePool!==null){var g=h.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:Eo(h.memoizedState.cache)}if(g=h.child,g!==null)g.return=h,_n=g;else e:for(h=s;_n!==null;){g=_n;var k=g.sibling,N=g.return;if(pb(g),g===h){_n=null;break e}if(k!==null){k.return=N,_n=k;break e}_n=N}}}var hE={getCacheForType:function(s){var o=En(on),h=o.data.get(s);return h===void 0&&(h=s(),o.data.set(s,h)),h},cacheSignal:function(){return En(on).controller.signal}},fE=typeof WeakMap=="function"?WeakMap:Map,Et=0,Mt=null,ht=null,yt=0,Nt=0,sr=null,$s=!1,ka=!1,pf=!1,hs=0,Yt=0,zs=0,Ni=0,gf=0,ir=0,Ea=0,Vo=null,qn=null,xf=!1,Bc=0,Eb=0,$c=1/0,zc=null,Hs=null,pn=0,Us=null,ja=null,fs=0,yf=0,bf=null,jb=null,Go=0,vf=null;function ar(){return(Et&2)!==0&&yt!==0?yt&-yt:G.T!==null?Ef():sn()}function Nb(){if(ir===0)if((yt&536870912)===0||vt){var s=_e;_e<<=1,(_e&3932160)===0&&(_e=262144),ir=s}else ir=536870912;return s=nr.current,s!==null&&(s.flags|=32),ir}function Kn(s,o,h){(s===Mt&&(Nt===2||Nt===9)||s.cancelPendingCommit!==null)&&(Na(s,0),Fs(s,yt,ir,!1)),Ce(s,h),((Et&2)===0||s!==Mt)&&(s===Mt&&((Et&2)===0&&(Ni|=h),Yt===4&&Fs(s,yt,ir,!1)),zr(s))}function Tb(s,o,h){if((Et&6)!==0)throw Error(r(327));var g=!h&&(o&127)===0&&(o&s.expiredLanes)===0||Ie(s,o),k=g?gE(s,o):Sf(s,o,!0),N=g;do{if(k===0){ka&&!g&&Fs(s,o,0,!1);break}else{if(h=s.current.alternate,N&&!mE(h)){k=Sf(s,o,!1),N=!1;continue}if(k===2){if(N=o,s.errorRecoveryDisabledLanes&N)var H=0;else H=s.pendingLanes&-536870913,H=H!==0?H:H&536870912?536870912:0;if(H!==0){o=H;e:{var Y=s;k=Vo;var ie=Y.current.memoizedState.isDehydrated;if(ie&&(Na(Y,H).flags|=256),H=Sf(Y,H,!1),H!==2){if(pf&&!ie){Y.errorRecoveryDisabledLanes|=N,Ni|=N,k=4;break e}N=qn,qn=k,N!==null&&(qn===null?qn=N:qn.push.apply(qn,N))}k=H}if(N=!1,k!==2)continue}}if(k===1){Na(s,0),Fs(s,o,0,!0);break}e:{switch(g=s,N=k,N){case 0:case 1:throw Error(r(345));case 4:if((o&4194048)!==o)break;case 6:Fs(g,o,ir,!$s);break e;case 2:qn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((o&62914560)===o&&(k=Bc+300-He(),10<k)){if(Fs(g,o,ir,!$s),fe(g,0,!0)!==0)break e;fs=o,g.timeoutHandle=av(Ab.bind(null,g,h,qn,zc,xf,o,ir,Ni,Ea,$s,N,"Throttled",-0,0),k);break e}Ab(g,h,qn,zc,xf,o,ir,Ni,Ea,$s,N,null,-0,0)}}break}while(!0);zr(s)}function Ab(s,o,h,g,k,N,H,Y,ie,pe,Ee,Ae,ge,ve){if(s.timeoutHandle=-1,Ae=o.subtreeFlags,Ae&8192||(Ae&16785408)===16785408){Ae={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Jr},Sb(o,N,Ae);var Ve=(N&62914560)===N?Bc-He():(N&4194048)===N?Eb-He():0;if(Ve=JE(Ae,Ve),Ve!==null){fs=N,s.cancelPendingCommit=Ve(Bb.bind(null,s,o,N,h,g,k,H,Y,ie,Ee,Ae,null,ge,ve)),Fs(s,N,H,!pe);return}}Bb(s,o,N,h,g,k,H,Y,ie)}function mE(s){for(var o=s;;){var h=o.tag;if((h===0||h===11||h===15)&&o.flags&16384&&(h=o.updateQueue,h!==null&&(h=h.stores,h!==null)))for(var g=0;g<h.length;g++){var k=h[g],N=k.getSnapshot;k=k.value;try{if(!er(N(),k))return!1}catch{return!1}}if(h=o.child,o.subtreeFlags&16384&&h!==null)h.return=o,o=h;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 Fs(s,o,h,g){o&=~gf,o&=~Ni,s.suspendedLanes|=o,s.pingedLanes&=~o,g&&(s.warmLanes|=o),g=s.expirationTimes;for(var k=o;0<k;){var N=31-dt(k),H=1<<N;g[N]=-1,k&=~H}h!==0&&Ue(s,h,o)}function Hc(){return(Et&6)===0?(Wo(0),!1):!0}function _f(){if(ht!==null){if(Nt===0)var s=ht.return;else s=ht,ns=bi=null,Mh(s),ya=null,No=0,s=ht;for(;s!==null;)ob(s.alternate,s),s=s.return;ht=null}}function Na(s,o){var h=s.timeoutHandle;h!==-1&&(s.timeoutHandle=-1,OE(h)),h=s.cancelPendingCommit,h!==null&&(s.cancelPendingCommit=null,h()),fs=0,_f(),Mt=s,ht=h=es(s.current,null),yt=o,Nt=0,sr=null,$s=!1,ka=Ie(s,o),pf=!1,Ea=ir=gf=Ni=zs=Yt=0,qn=Vo=null,xf=!1,(o&8)!==0&&(o|=o&32);var g=s.entangledLanes;if(g!==0)for(s=s.entanglements,g&=o;0<g;){var k=31-dt(g),N=1<<k;o|=s[k],g&=~N}return hs=o,lc(),h}function Lb(s,o){it=null,G.H=Mo,o===xa||o===gc?(o=qx(),Nt=3):o===Ch?(o=qx(),Nt=4):Nt=o===Jh?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,sr=o,ht===null&&(Yt=1,Ac(s,fr(o,s.current)))}function Db(){var s=nr.current;return s===null?!0:(yt&4194048)===yt?xr===null:(yt&62914560)===yt||(yt&536870912)!==0?s===xr:!1}function Rb(){var s=G.H;return G.H=Mo,s===null?Mo:s}function Ob(){var s=G.A;return G.A=hE,s}function Uc(){Yt=4,$s||(yt&4194048)!==yt&&nr.current!==null||(ka=!0),(zs&134217727)===0&&(Ni&134217727)===0||Mt===null||Fs(Mt,yt,ir,!1)}function Sf(s,o,h){var g=Et;Et|=2;var k=Rb(),N=Ob();(Mt!==s||yt!==o)&&(zc=null,Na(s,o)),o=!1;var H=Yt;e:do try{if(Nt!==0&&ht!==null){var Y=ht,ie=sr;switch(Nt){case 8:_f(),H=6;break e;case 3:case 2:case 9:case 6:nr.current===null&&(o=!0);var pe=Nt;if(Nt=0,sr=null,Ta(s,Y,ie,pe),h&&ka){H=0;break e}break;default:pe=Nt,Nt=0,sr=null,Ta(s,Y,ie,pe)}}pE(),H=Yt;break}catch(Ee){Lb(s,Ee)}while(!0);return o&&s.shellSuspendCounter++,ns=bi=null,Et=g,G.H=k,G.A=N,ht===null&&(Mt=null,yt=0,lc()),H}function pE(){for(;ht!==null;)Ib(ht)}function gE(s,o){var h=Et;Et|=2;var g=Rb(),k=Ob();Mt!==s||yt!==o?(zc=null,$c=He()+500,Na(s,o)):ka=Ie(s,o);e:do try{if(Nt!==0&&ht!==null){o=ht;var N=sr;t:switch(Nt){case 1:Nt=0,sr=null,Ta(s,o,N,1);break;case 2:case 9:if(Gx(N)){Nt=0,sr=null,Mb(o);break}o=function(){Nt!==2&&Nt!==9||Mt!==s||(Nt=7),zr(s)},N.then(o,o);break e;case 3:Nt=7;break e;case 4:Nt=5;break e;case 7:Gx(N)?(Nt=0,sr=null,Mb(o)):(Nt=0,sr=null,Ta(s,o,N,7));break;case 5:var H=null;switch(ht.tag){case 26:H=ht.memoizedState;case 5:case 27:var Y=ht;if(H?_v(H):Y.stateNode.complete){Nt=0,sr=null;var ie=Y.sibling;if(ie!==null)ht=ie;else{var pe=Y.return;pe!==null?(ht=pe,Fc(pe)):ht=null}break t}}Nt=0,sr=null,Ta(s,o,N,5);break;case 6:Nt=0,sr=null,Ta(s,o,N,6);break;case 8:_f(),Yt=6;break e;default:throw Error(r(462))}}xE();break}catch(Ee){Lb(s,Ee)}while(!0);return ns=bi=null,G.H=g,G.A=k,Et=h,ht!==null?0:(Mt=null,yt=0,lc(),Yt)}function xE(){for(;ht!==null&&!de();)Ib(ht)}function Ib(s){var o=ib(s.alternate,s,hs);s.memoizedProps=s.pendingProps,o===null?Fc(s):ht=o}function Mb(s){var o=s,h=o.alternate;switch(o.tag){case 15:case 0:o=Zy(h,o,o.pendingProps,o.type,void 0,yt);break;case 11:o=Zy(h,o,o.pendingProps,o.type.render,o.ref,yt);break;case 5:Mh(o);default:ob(h,o),o=ht=Ox(o,hs),o=ib(h,o,hs)}s.memoizedProps=s.pendingProps,o===null?Fc(s):ht=o}function Ta(s,o,h,g){ns=bi=null,Mh(o),ya=null,No=0;var k=o.return;try{if(iE(s,k,o,h,yt)){Yt=1,Ac(s,fr(h,s.current)),ht=null;return}}catch(N){if(k!==null)throw ht=k,N;Yt=1,Ac(s,fr(h,s.current)),ht=null;return}o.flags&32768?(vt||g===1?s=!0:ka||(yt&536870912)!==0?s=!1:($s=s=!0,(g===2||g===9||g===3||g===6)&&(g=nr.current,g!==null&&g.tag===13&&(g.flags|=16384))),Pb(o,s)):Fc(o)}function Fc(s){var o=s;do{if((o.flags&32768)!==0){Pb(o,$s);return}s=o.return;var h=lE(o.alternate,o,hs);if(h!==null){ht=h;return}if(o=o.sibling,o!==null){ht=o;return}ht=o=s}while(o!==null);Yt===0&&(Yt=5)}function Pb(s,o){do{var h=cE(s.alternate,s);if(h!==null){h.flags&=32767,ht=h;return}if(h=s.return,h!==null&&(h.flags|=32768,h.subtreeFlags=0,h.deletions=null),!o&&(s=s.sibling,s!==null)){ht=s;return}ht=s=h}while(s!==null);Yt=6,ht=null}function Bb(s,o,h,g,k,N,H,Y,ie){s.cancelPendingCommit=null;do Vc();while(pn!==0);if((Et&6)!==0)throw Error(r(327));if(o!==null){if(o===s.current)throw Error(r(177));if(N=o.lanes|o.childLanes,N|=ch,Te(s,h,N,H,Y,ie),s===Mt&&(ht=Mt=null,yt=0),ja=o,Us=s,fs=h,yf=N,bf=k,jb=g,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,_E(ke,function(){return Fb(),null})):(s.callbackNode=null,s.callbackPriority=0),g=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||g){g=G.T,G.T=null,k=Z.p,Z.p=2,H=Et,Et|=4;try{uE(s,o,h)}finally{Et=H,Z.p=k,G.T=g}}pn=1,$b(),zb(),Hb()}}function $b(){if(pn===1){pn=0;var s=Us,o=ja,h=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||h){h=G.T,G.T=null;var g=Z.p;Z.p=2;var k=Et;Et|=4;try{bb(o,s);var N=Of,H=kx(s.containerInfo),Y=N.focusedElem,ie=N.selectionRange;if(H!==Y&&Y&&Y.ownerDocument&&Cx(Y.ownerDocument.documentElement,Y)){if(ie!==null&&sh(Y)){var pe=ie.start,Ee=ie.end;if(Ee===void 0&&(Ee=pe),"selectionStart"in Y)Y.selectionStart=pe,Y.selectionEnd=Math.min(Ee,Y.value.length);else{var Ae=Y.ownerDocument||document,ge=Ae&&Ae.defaultView||window;if(ge.getSelection){var ve=ge.getSelection(),Ve=Y.textContent.length,Ze=Math.min(ie.start,Ve),Dt=ie.end===void 0?Ze:Math.min(ie.end,Ve);!ve.extend&&Ze>Dt&&(H=Dt,Dt=Ze,Ze=H);var ue=wx(Y,Ze),le=wx(Y,Dt);if(ue&&le&&(ve.rangeCount!==1||ve.anchorNode!==ue.node||ve.anchorOffset!==ue.offset||ve.focusNode!==le.node||ve.focusOffset!==le.offset)){var me=Ae.createRange();me.setStart(ue.node,ue.offset),ve.removeAllRanges(),Ze>Dt?(ve.addRange(me),ve.extend(le.node,le.offset)):(me.setEnd(le.node,le.offset),ve.addRange(me))}}}}for(Ae=[],ve=Y;ve=ve.parentNode;)ve.nodeType===1&&Ae.push({element:ve,left:ve.scrollLeft,top:ve.scrollTop});for(typeof Y.focus=="function"&&Y.focus(),Y=0;Y<Ae.length;Y++){var Ne=Ae[Y];Ne.element.scrollLeft=Ne.left,Ne.element.scrollTop=Ne.top}}nu=!!Rf,Of=Rf=null}finally{Et=k,Z.p=g,G.T=h}}s.current=o,pn=2}}function zb(){if(pn===2){pn=0;var s=Us,o=ja,h=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||h){h=G.T,G.T=null;var g=Z.p;Z.p=2;var k=Et;Et|=4;try{mb(s,o.alternate,o)}finally{Et=k,Z.p=g,G.T=h}}pn=3}}function Hb(){if(pn===4||pn===3){pn=0,$e();var s=Us,o=ja,h=fs,g=jb;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?pn=5:(pn=0,ja=Us=null,Ub(s,s.pendingLanes));var k=s.pendingLanes;if(k===0&&(Hs=null),xt(h),o=o.stateNode,It&&typeof It.onCommitFiberRoot=="function")try{It.onCommitFiberRoot(_t,o,void 0,(o.current.flags&128)===128)}catch{}if(g!==null){o=G.T,k=Z.p,Z.p=2,G.T=null;try{for(var N=s.onRecoverableError,H=0;H<g.length;H++){var Y=g[H];N(Y.value,{componentStack:Y.stack})}}finally{G.T=o,Z.p=k}}(fs&3)!==0&&Vc(),zr(s),k=s.pendingLanes,(h&261930)!==0&&(k&42)!==0?s===vf?Go++:(Go=0,vf=s):Go=0,Wo(0)}}function Ub(s,o){(s.pooledCacheLanes&=o)===0&&(o=s.pooledCache,o!=null&&(s.pooledCache=null,Eo(o)))}function Vc(){return $b(),zb(),Hb(),Fb()}function Fb(){if(pn!==5)return!1;var s=Us,o=yf;yf=0;var h=xt(fs),g=G.T,k=Z.p;try{Z.p=32>h?32:h,G.T=null,h=bf,bf=null;var N=Us,H=fs;if(pn=0,ja=Us=null,fs=0,(Et&6)!==0)throw Error(r(331));var Y=Et;if(Et|=4,Cb(N.current),_b(N,N.current,H,h),Et=Y,Wo(0,!1),It&&typeof It.onPostCommitFiberRoot=="function")try{It.onPostCommitFiberRoot(_t,N)}catch{}return!0}finally{Z.p=k,G.T=g,Ub(s,o)}}function Vb(s,o,h){o=fr(h,o),o=Qh(s.stateNode,o,2),s=Is(s,o,2),s!==null&&(Ce(s,2),zr(s))}function Tt(s,o,h){if(s.tag===3)Vb(s,s,h);else for(;o!==null;){if(o.tag===3){Vb(o,s,h);break}else if(o.tag===1){var g=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Hs===null||!Hs.has(g))){s=fr(h,s),h=Gy(2),g=Is(o,h,2),g!==null&&(Wy(h,g,o,s),Ce(g,2),zr(g));break}}o=o.return}}function wf(s,o,h){var g=s.pingCache;if(g===null){g=s.pingCache=new fE;var k=new Set;g.set(o,k)}else k=g.get(o),k===void 0&&(k=new Set,g.set(o,k));k.has(h)||(pf=!0,k.add(h),s=yE.bind(null,s,o,h),o.then(s,s))}function yE(s,o,h){var g=s.pingCache;g!==null&&g.delete(o),s.pingedLanes|=s.suspendedLanes&h,s.warmLanes&=~h,Mt===s&&(yt&h)===h&&(Yt===4||Yt===3&&(yt&62914560)===yt&&300>He()-Bc?(Et&2)===0&&Na(s,0):gf|=h,Ea===yt&&(Ea=0)),zr(s)}function Gb(s,o){o===0&&(o=bn()),s=gi(s,o),s!==null&&(Ce(s,o),zr(s))}function bE(s){var o=s.memoizedState,h=0;o!==null&&(h=o.retryLane),Gb(s,h)}function vE(s,o){var h=0;switch(s.tag){case 31:case 13:var g=s.stateNode,k=s.memoizedState;k!==null&&(h=k.retryLane);break;case 19:g=s.stateNode;break;case 22:g=s.stateNode._retryCache;break;default:throw Error(r(314))}g!==null&&g.delete(o),Gb(s,h)}function _E(s,o){return he(s,o)}var Gc=null,Aa=null,Cf=!1,Wc=!1,kf=!1,Vs=0;function zr(s){s!==Aa&&s.next===null&&(Aa===null?Gc=Aa=s:Aa=Aa.next=s),Wc=!0,Cf||(Cf=!0,wE())}function Wo(s,o){if(!kf&&Wc){kf=!0;do for(var h=!1,g=Gc;g!==null;){if(s!==0){var k=g.pendingLanes;if(k===0)var N=0;else{var H=g.suspendedLanes,Y=g.pingedLanes;N=(1<<31-dt(42|s)+1)-1,N&=k&~(H&~Y),N=N&201326741?N&201326741|1:N?N|2:0}N!==0&&(h=!0,Yb(g,N))}else N=yt,N=fe(g,g===Mt?N:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(N&3)===0||Ie(g,N)||(h=!0,Yb(g,N));g=g.next}while(h);kf=!1}}function SE(){Wb()}function Wb(){Wc=Cf=!1;var s=0;Vs!==0&&RE()&&(s=Vs);for(var o=He(),h=null,g=Gc;g!==null;){var k=g.next,N=qb(g,o);N===0?(g.next=null,h===null?Gc=k:h.next=k,k===null&&(Aa=h)):(h=g,(s!==0||(N&3)!==0)&&(Wc=!0)),g=k}pn!==0&&pn!==5||Wo(s),Vs!==0&&(Vs=0)}function qb(s,o){for(var h=s.suspendedLanes,g=s.pingedLanes,k=s.expirationTimes,N=s.pendingLanes&-62914561;0<N;){var H=31-dt(N),Y=1<<H,ie=k[H];ie===-1?((Y&h)===0||(Y&g)!==0)&&(k[H]=gt(Y,o)):ie<=o&&(s.expiredLanes|=Y),N&=~Y}if(o=Mt,h=yt,h=fe(s,s===o?h:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),g=s.callbackNode,h===0||s===o&&(Nt===2||Nt===9)||s.cancelPendingCommit!==null)return g!==null&&g!==null&&ce(g),s.callbackNode=null,s.callbackPriority=0;if((h&3)===0||Ie(s,h)){if(o=h&-h,o===s.callbackPriority)return o;switch(g!==null&&ce(g),xt(h)){case 2:case 8:h=be;break;case 32:h=ke;break;case 268435456:h=Ye;break;default:h=ke}return g=Kb.bind(null,s),h=he(h,g),s.callbackPriority=o,s.callbackNode=h,o}return g!==null&&g!==null&&ce(g),s.callbackPriority=2,s.callbackNode=null,2}function Kb(s,o){if(pn!==0&&pn!==5)return s.callbackNode=null,s.callbackPriority=0,null;var h=s.callbackNode;if(Vc()&&s.callbackNode!==h)return null;var g=yt;return g=fe(s,s===Mt?g:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),g===0?null:(Tb(s,g,o),qb(s,He()),s.callbackNode!=null&&s.callbackNode===h?Kb.bind(null,s):null)}function Yb(s,o){if(Vc())return null;Tb(s,o,!0)}function wE(){IE(function(){(Et&6)!==0?he(re,SE):Wb()})}function Ef(){if(Vs===0){var s=pa;s===0&&(s=Mr,Mr<<=1,(Mr&261888)===0&&(Mr=256)),Vs=s}return Vs}function Xb(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:ec(""+s)}function Qb(s,o){var h=o.ownerDocument.createElement("input");return h.name=o.name,h.value=o.value,s.id&&h.setAttribute("form",s.id),o.parentNode.insertBefore(h,o),s=new FormData(s),h.parentNode.removeChild(h),s}function CE(s,o,h,g,k){if(o==="submit"&&h&&h.stateNode===k){var N=Xb((k[Un]||null).action),H=g.submitter;H&&(o=(o=H[Un]||null)?Xb(o.formAction):H.getAttribute("formAction"),o!==null&&(N=o,H=null));var Y=new sc("action","action",null,g,k);s.push({event:Y,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(Vs!==0){var ie=H?Qb(k,H):new FormData(k);Gh(h,{pending:!0,data:ie,method:k.method,action:N},null,ie)}}else typeof N=="function"&&(Y.preventDefault(),ie=H?Qb(k,H):new FormData(k),Gh(h,{pending:!0,data:ie,method:k.method,action:N},N,ie))},currentTarget:k}]})}}for(var jf=0;jf<lh.length;jf++){var Nf=lh[jf],kE=Nf.toLowerCase(),EE=Nf[0].toUpperCase()+Nf.slice(1);Er(kE,"on"+EE)}Er(Nx,"onAnimationEnd"),Er(Tx,"onAnimationIteration"),Er(Ax,"onAnimationStart"),Er("dblclick","onDoubleClick"),Er("focusin","onFocus"),Er("focusout","onBlur"),Er(U2,"onTransitionRun"),Er(F2,"onTransitionStart"),Er(V2,"onTransitionCancel"),Er(Lx,"onTransitionEnd"),ta("onMouseEnter",["mouseout","mouseover"]),ta("onMouseLeave",["mouseout","mouseover"]),ta("onPointerEnter",["pointerout","pointerover"]),ta("onPointerLeave",["pointerout","pointerover"]),hi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),hi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),hi("onBeforeInput",["compositionend","keypress","textInput","paste"]),hi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),hi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),hi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var qo="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(" "),jE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(qo));function Jb(s,o){o=(o&4)!==0;for(var h=0;h<s.length;h++){var g=s[h],k=g.event;g=g.listeners;e:{var N=void 0;if(o)for(var H=g.length-1;0<=H;H--){var Y=g[H],ie=Y.instance,pe=Y.currentTarget;if(Y=Y.listener,ie!==N&&k.isPropagationStopped())break e;N=Y,k.currentTarget=pe;try{N(k)}catch(Ee){oc(Ee)}k.currentTarget=null,N=ie}else for(H=0;H<g.length;H++){if(Y=g[H],ie=Y.instance,pe=Y.currentTarget,Y=Y.listener,ie!==N&&k.isPropagationStopped())break e;N=Y,k.currentTarget=pe;try{N(k)}catch(Ee){oc(Ee)}k.currentTarget=null,N=ie}}}}function ft(s,o){var h=o[zd];h===void 0&&(h=o[zd]=new Set);var g=s+"__bubble";h.has(g)||(Zb(o,s,2,!1),h.add(g))}function Tf(s,o,h){var g=0;o&&(g|=4),Zb(h,s,g,o)}var qc="_reactListening"+Math.random().toString(36).slice(2);function Af(s){if(!s[qc]){s[qc]=!0,Wg.forEach(function(h){h!=="selectionchange"&&(jE.has(h)||Tf(h,!1,s),Tf(h,!0,s))});var o=s.nodeType===9?s:s.ownerDocument;o===null||o[qc]||(o[qc]=!0,Tf("selectionchange",!1,o))}}function Zb(s,o,h,g){switch(Nv(o)){case 2:var k=tj;break;case 8:k=nj;break;default:k=Gf}h=k.bind(null,o,h,s),k=void 0,!Yd||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(k=!0),g?k!==void 0?s.addEventListener(o,h,{capture:!0,passive:k}):s.addEventListener(o,h,!0):k!==void 0?s.addEventListener(o,h,{passive:k}):s.addEventListener(o,h,!1)}function Lf(s,o,h,g,k){var N=g;if((o&1)===0&&(o&2)===0&&g!==null)e:for(;;){if(g===null)return;var H=g.tag;if(H===3||H===4){var Y=g.stateNode.containerInfo;if(Y===k)break;if(H===4)for(H=g.return;H!==null;){var ie=H.tag;if((ie===3||ie===4)&&H.stateNode.containerInfo===k)return;H=H.return}for(;Y!==null;){if(H=Ji(Y),H===null)return;if(ie=H.tag,ie===5||ie===6||ie===26||ie===27){g=N=H;continue e}Y=Y.parentNode}}g=g.return}sx(function(){var pe=N,Ee=qd(h),Ae=[];e:{var ge=Dx.get(s);if(ge!==void 0){var ve=sc,Ve=s;switch(s){case"keypress":if(nc(h)===0)break e;case"keydown":case"keyup":ve=v2;break;case"focusin":Ve="focus",ve=Zd;break;case"focusout":Ve="blur",ve=Zd;break;case"beforeblur":case"afterblur":ve=Zd;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ve=ox;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ve=l2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ve=w2;break;case Nx:case Tx:case Ax:ve=d2;break;case Lx:ve=k2;break;case"scroll":case"scrollend":ve=a2;break;case"wheel":ve=j2;break;case"copy":case"cut":case"paste":ve=f2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ve=cx;break;case"toggle":case"beforetoggle":ve=T2}var Ze=(o&4)!==0,Dt=!Ze&&(s==="scroll"||s==="scrollend"),ue=Ze?ge!==null?ge+"Capture":null:ge;Ze=[];for(var le=pe,me;le!==null;){var Ne=le;if(me=Ne.stateNode,Ne=Ne.tag,Ne!==5&&Ne!==26&&Ne!==27||me===null||ue===null||(Ne=po(le,ue),Ne!=null&&Ze.push(Ko(le,Ne,me))),Dt)break;le=le.return}0<Ze.length&&(ge=new ve(ge,Ve,null,h,Ee),Ae.push({event:ge,listeners:Ze}))}}if((o&7)===0){e:{if(ge=s==="mouseover"||s==="pointerover",ve=s==="mouseout"||s==="pointerout",ge&&h!==Wd&&(Ve=h.relatedTarget||h.fromElement)&&(Ji(Ve)||Ve[Qi]))break e;if((ve||ge)&&(ge=Ee.window===Ee?Ee:(ge=Ee.ownerDocument)?ge.defaultView||ge.parentWindow:window,ve?(Ve=h.relatedTarget||h.toElement,ve=pe,Ve=Ve?Ji(Ve):null,Ve!==null&&(Dt=l(Ve),Ze=Ve.tag,Ve!==Dt||Ze!==5&&Ze!==27&&Ze!==6)&&(Ve=null)):(ve=null,Ve=pe),ve!==Ve)){if(Ze=ox,Ne="onMouseLeave",ue="onMouseEnter",le="mouse",(s==="pointerout"||s==="pointerover")&&(Ze=cx,Ne="onPointerLeave",ue="onPointerEnter",le="pointer"),Dt=ve==null?ge:mo(ve),me=Ve==null?ge:mo(Ve),ge=new Ze(Ne,le+"leave",ve,h,Ee),ge.target=Dt,ge.relatedTarget=me,Ne=null,Ji(Ee)===pe&&(Ze=new Ze(ue,le+"enter",Ve,h,Ee),Ze.target=me,Ze.relatedTarget=Dt,Ne=Ze),Dt=Ne,ve&&Ve)t:{for(Ze=NE,ue=ve,le=Ve,me=0,Ne=ue;Ne;Ne=Ze(Ne))me++;Ne=0;for(var Ke=le;Ke;Ke=Ze(Ke))Ne++;for(;0<me-Ne;)ue=Ze(ue),me--;for(;0<Ne-me;)le=Ze(le),Ne--;for(;me--;){if(ue===le||le!==null&&ue===le.alternate){Ze=ue;break t}ue=Ze(ue),le=Ze(le)}Ze=null}else Ze=null;ve!==null&&ev(Ae,ge,ve,Ze,!1),Ve!==null&&Dt!==null&&ev(Ae,Dt,Ve,Ze,!0)}}e:{if(ge=pe?mo(pe):window,ve=ge.nodeName&&ge.nodeName.toLowerCase(),ve==="select"||ve==="input"&&ge.type==="file")var Ct=xx;else if(px(ge))if(yx)Ct=$2;else{Ct=P2;var Ge=M2}else ve=ge.nodeName,!ve||ve.toLowerCase()!=="input"||ge.type!=="checkbox"&&ge.type!=="radio"?pe&&Gd(pe.elementType)&&(Ct=xx):Ct=B2;if(Ct&&(Ct=Ct(s,pe))){gx(Ae,Ct,h,Ee);break e}Ge&&Ge(s,ge,pe),s==="focusout"&&pe&&ge.type==="number"&&pe.memoizedProps.value!=null&&Vd(ge,"number",ge.value)}switch(Ge=pe?mo(pe):window,s){case"focusin":(px(Ge)||Ge.contentEditable==="true")&&(oa=Ge,ih=pe,wo=null);break;case"focusout":wo=ih=oa=null;break;case"mousedown":ah=!0;break;case"contextmenu":case"mouseup":case"dragend":ah=!1,Ex(Ae,h,Ee);break;case"selectionchange":if(H2)break;case"keydown":case"keyup":Ex(Ae,h,Ee)}var ot;if(th)e:{switch(s){case"compositionstart":var bt="onCompositionStart";break e;case"compositionend":bt="onCompositionEnd";break e;case"compositionupdate":bt="onCompositionUpdate";break e}bt=void 0}else aa?fx(s,h)&&(bt="onCompositionEnd"):s==="keydown"&&h.keyCode===229&&(bt="onCompositionStart");bt&&(ux&&h.locale!=="ko"&&(aa||bt!=="onCompositionStart"?bt==="onCompositionEnd"&&aa&&(ot=ix()):(Ns=Ee,Xd="value"in Ns?Ns.value:Ns.textContent,aa=!0)),Ge=Kc(pe,bt),0<Ge.length&&(bt=new lx(bt,s,null,h,Ee),Ae.push({event:bt,listeners:Ge}),ot?bt.data=ot:(ot=mx(h),ot!==null&&(bt.data=ot)))),(ot=L2?D2(s,h):R2(s,h))&&(bt=Kc(pe,"onBeforeInput"),0<bt.length&&(Ge=new lx("onBeforeInput","beforeinput",null,h,Ee),Ae.push({event:Ge,listeners:bt}),Ge.data=ot)),CE(Ae,s,pe,h,Ee)}Jb(Ae,o)})}function Ko(s,o,h){return{instance:s,listener:o,currentTarget:h}}function Kc(s,o){for(var h=o+"Capture",g=[];s!==null;){var k=s,N=k.stateNode;if(k=k.tag,k!==5&&k!==26&&k!==27||N===null||(k=po(s,h),k!=null&&g.unshift(Ko(s,k,N)),k=po(s,o),k!=null&&g.push(Ko(s,k,N))),s.tag===3)return g;s=s.return}return[]}function NE(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function ev(s,o,h,g,k){for(var N=o._reactName,H=[];h!==null&&h!==g;){var Y=h,ie=Y.alternate,pe=Y.stateNode;if(Y=Y.tag,ie!==null&&ie===g)break;Y!==5&&Y!==26&&Y!==27||pe===null||(ie=pe,k?(pe=po(h,N),pe!=null&&H.unshift(Ko(h,pe,ie))):k||(pe=po(h,N),pe!=null&&H.push(Ko(h,pe,ie)))),h=h.return}H.length!==0&&s.push({event:o,listeners:H})}var TE=/\r\n?/g,AE=/\u0000|\uFFFD/g;function tv(s){return(typeof s=="string"?s:""+s).replace(TE,`
|
|
50
|
+
`).replace(AE,"")}function nv(s,o){return o=tv(o),tv(s)===o}function Lt(s,o,h,g,k,N){switch(h){case"children":typeof g=="string"?o==="body"||o==="textarea"&&g===""||ra(s,g):(typeof g=="number"||typeof g=="bigint")&&o!=="body"&&ra(s,""+g);break;case"className":Jl(s,"class",g);break;case"tabIndex":Jl(s,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Jl(s,h,g);break;case"style":nx(s,g,N);break;case"data":if(o!=="object"){Jl(s,"data",g);break}case"src":case"href":if(g===""&&(o!=="a"||h!=="href")){s.removeAttribute(h);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){s.removeAttribute(h);break}g=ec(""+g),s.setAttribute(h,g);break;case"action":case"formAction":if(typeof g=="function"){s.setAttribute(h,"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 N=="function"&&(h==="formAction"?(o!=="input"&&Lt(s,o,"name",k.name,k,null),Lt(s,o,"formEncType",k.formEncType,k,null),Lt(s,o,"formMethod",k.formMethod,k,null),Lt(s,o,"formTarget",k.formTarget,k,null)):(Lt(s,o,"encType",k.encType,k,null),Lt(s,o,"method",k.method,k,null),Lt(s,o,"target",k.target,k,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){s.removeAttribute(h);break}g=ec(""+g),s.setAttribute(h,g);break;case"onClick":g!=null&&(s.onclick=Jr);break;case"onScroll":g!=null&&ft("scroll",s);break;case"onScrollEnd":g!=null&&ft("scrollend",s);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(h=g.__html,h!=null){if(k.children!=null)throw Error(r(60));s.innerHTML=h}}break;case"multiple":s.multiple=g&&typeof g!="function"&&typeof g!="symbol";break;case"muted":s.muted=g&&typeof g!="function"&&typeof g!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(g==null||typeof g=="function"||typeof g=="boolean"||typeof g=="symbol"){s.removeAttribute("xlink:href");break}h=ec(""+g),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",h);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":g!=null&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(h,""+g):s.removeAttribute(h);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":g&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(h,""):s.removeAttribute(h);break;case"capture":case"download":g===!0?s.setAttribute(h,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?s.setAttribute(h,g):s.removeAttribute(h);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?s.setAttribute(h,g):s.removeAttribute(h);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?s.removeAttribute(h):s.setAttribute(h,g);break;case"popover":ft("beforetoggle",s),ft("toggle",s),Ql(s,"popover",g);break;case"xlinkActuate":Qr(s,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":Qr(s,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":Qr(s,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":Qr(s,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":Qr(s,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":Qr(s,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":Qr(s,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":Qr(s,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":Qr(s,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":Ql(s,"is",g);break;case"innerText":case"textContent":break;default:(!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(h=s2.get(h)||h,Ql(s,h,g))}}function Df(s,o,h,g,k,N){switch(h){case"style":nx(s,g,N);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(r(61));if(h=g.__html,h!=null){if(k.children!=null)throw Error(r(60));s.innerHTML=h}}break;case"children":typeof g=="string"?ra(s,g):(typeof g=="number"||typeof g=="bigint")&&ra(s,""+g);break;case"onScroll":g!=null&&ft("scroll",s);break;case"onScrollEnd":g!=null&&ft("scrollend",s);break;case"onClick":g!=null&&(s.onclick=Jr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!qg.hasOwnProperty(h))e:{if(h[0]==="o"&&h[1]==="n"&&(k=h.endsWith("Capture"),o=h.slice(2,k?h.length-7:void 0),N=s[Un]||null,N=N!=null?N[h]:null,typeof N=="function"&&s.removeEventListener(o,N,k),typeof g=="function")){typeof N!="function"&&N!==null&&(h in s?s[h]=null:s.hasAttribute(h)&&s.removeAttribute(h)),s.addEventListener(o,g,k);break e}h in s?s[h]=g:g===!0?s.setAttribute(h,""):Ql(s,h,g)}}}function Nn(s,o,h){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ft("error",s),ft("load",s);var g=!1,k=!1,N;for(N in h)if(h.hasOwnProperty(N)){var H=h[N];if(H!=null)switch(N){case"src":g=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Lt(s,o,N,H,h,null)}}k&&Lt(s,o,"srcSet",h.srcSet,h,null),g&&Lt(s,o,"src",h.src,h,null);return;case"input":ft("invalid",s);var Y=N=H=k=null,ie=null,pe=null;for(g in h)if(h.hasOwnProperty(g)){var Ee=h[g];if(Ee!=null)switch(g){case"name":k=Ee;break;case"type":H=Ee;break;case"checked":ie=Ee;break;case"defaultChecked":pe=Ee;break;case"value":N=Ee;break;case"defaultValue":Y=Ee;break;case"children":case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(r(137,o));break;default:Lt(s,o,g,Ee,h,null)}}Jg(s,N,Y,ie,pe,H,k,!1);return;case"select":ft("invalid",s),g=H=N=null;for(k in h)if(h.hasOwnProperty(k)&&(Y=h[k],Y!=null))switch(k){case"value":N=Y;break;case"defaultValue":H=Y;break;case"multiple":g=Y;default:Lt(s,o,k,Y,h,null)}o=N,h=H,s.multiple=!!g,o!=null?na(s,!!g,o,!1):h!=null&&na(s,!!g,h,!0);return;case"textarea":ft("invalid",s),N=k=g=null;for(H in h)if(h.hasOwnProperty(H)&&(Y=h[H],Y!=null))switch(H){case"value":g=Y;break;case"defaultValue":k=Y;break;case"children":N=Y;break;case"dangerouslySetInnerHTML":if(Y!=null)throw Error(r(91));break;default:Lt(s,o,H,Y,h,null)}ex(s,g,k,N);return;case"option":for(ie in h)if(h.hasOwnProperty(ie)&&(g=h[ie],g!=null))switch(ie){case"selected":s.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:Lt(s,o,ie,g,h,null)}return;case"dialog":ft("beforetoggle",s),ft("toggle",s),ft("cancel",s),ft("close",s);break;case"iframe":case"object":ft("load",s);break;case"video":case"audio":for(g=0;g<qo.length;g++)ft(qo[g],s);break;case"image":ft("error",s),ft("load",s);break;case"details":ft("toggle",s);break;case"embed":case"source":case"link":ft("error",s),ft("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(pe in h)if(h.hasOwnProperty(pe)&&(g=h[pe],g!=null))switch(pe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Lt(s,o,pe,g,h,null)}return;default:if(Gd(o)){for(Ee in h)h.hasOwnProperty(Ee)&&(g=h[Ee],g!==void 0&&Df(s,o,Ee,g,h,void 0));return}}for(Y in h)h.hasOwnProperty(Y)&&(g=h[Y],g!=null&&Lt(s,o,Y,g,h,null))}function LE(s,o,h,g){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var k=null,N=null,H=null,Y=null,ie=null,pe=null,Ee=null;for(ve in h){var Ae=h[ve];if(h.hasOwnProperty(ve)&&Ae!=null)switch(ve){case"checked":break;case"value":break;case"defaultValue":ie=Ae;default:g.hasOwnProperty(ve)||Lt(s,o,ve,null,g,Ae)}}for(var ge in g){var ve=g[ge];if(Ae=h[ge],g.hasOwnProperty(ge)&&(ve!=null||Ae!=null))switch(ge){case"type":N=ve;break;case"name":k=ve;break;case"checked":pe=ve;break;case"defaultChecked":Ee=ve;break;case"value":H=ve;break;case"defaultValue":Y=ve;break;case"children":case"dangerouslySetInnerHTML":if(ve!=null)throw Error(r(137,o));break;default:ve!==Ae&&Lt(s,o,ge,ve,g,Ae)}}Fd(s,H,Y,ie,pe,Ee,N,k);return;case"select":ve=H=Y=ge=null;for(N in h)if(ie=h[N],h.hasOwnProperty(N)&&ie!=null)switch(N){case"value":break;case"multiple":ve=ie;default:g.hasOwnProperty(N)||Lt(s,o,N,null,g,ie)}for(k in g)if(N=g[k],ie=h[k],g.hasOwnProperty(k)&&(N!=null||ie!=null))switch(k){case"value":ge=N;break;case"defaultValue":Y=N;break;case"multiple":H=N;default:N!==ie&&Lt(s,o,k,N,g,ie)}o=Y,h=H,g=ve,ge!=null?na(s,!!h,ge,!1):!!g!=!!h&&(o!=null?na(s,!!h,o,!0):na(s,!!h,h?[]:"",!1));return;case"textarea":ve=ge=null;for(Y in h)if(k=h[Y],h.hasOwnProperty(Y)&&k!=null&&!g.hasOwnProperty(Y))switch(Y){case"value":break;case"children":break;default:Lt(s,o,Y,null,g,k)}for(H in g)if(k=g[H],N=h[H],g.hasOwnProperty(H)&&(k!=null||N!=null))switch(H){case"value":ge=k;break;case"defaultValue":ve=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(r(91));break;default:k!==N&&Lt(s,o,H,k,g,N)}Zg(s,ge,ve);return;case"option":for(var Ve in h)if(ge=h[Ve],h.hasOwnProperty(Ve)&&ge!=null&&!g.hasOwnProperty(Ve))switch(Ve){case"selected":s.selected=!1;break;default:Lt(s,o,Ve,null,g,ge)}for(ie in g)if(ge=g[ie],ve=h[ie],g.hasOwnProperty(ie)&&ge!==ve&&(ge!=null||ve!=null))switch(ie){case"selected":s.selected=ge&&typeof ge!="function"&&typeof ge!="symbol";break;default:Lt(s,o,ie,ge,g,ve)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ze in h)ge=h[Ze],h.hasOwnProperty(Ze)&&ge!=null&&!g.hasOwnProperty(Ze)&&Lt(s,o,Ze,null,g,ge);for(pe in g)if(ge=g[pe],ve=h[pe],g.hasOwnProperty(pe)&&ge!==ve&&(ge!=null||ve!=null))switch(pe){case"children":case"dangerouslySetInnerHTML":if(ge!=null)throw Error(r(137,o));break;default:Lt(s,o,pe,ge,g,ve)}return;default:if(Gd(o)){for(var Dt in h)ge=h[Dt],h.hasOwnProperty(Dt)&&ge!==void 0&&!g.hasOwnProperty(Dt)&&Df(s,o,Dt,void 0,g,ge);for(Ee in g)ge=g[Ee],ve=h[Ee],!g.hasOwnProperty(Ee)||ge===ve||ge===void 0&&ve===void 0||Df(s,o,Ee,ge,g,ve);return}}for(var ue in h)ge=h[ue],h.hasOwnProperty(ue)&&ge!=null&&!g.hasOwnProperty(ue)&&Lt(s,o,ue,null,g,ge);for(Ae in g)ge=g[Ae],ve=h[Ae],!g.hasOwnProperty(Ae)||ge===ve||ge==null&&ve==null||Lt(s,o,Ae,ge,g,ve)}function rv(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function DE(){if(typeof performance.getEntriesByType=="function"){for(var s=0,o=0,h=performance.getEntriesByType("resource"),g=0;g<h.length;g++){var k=h[g],N=k.transferSize,H=k.initiatorType,Y=k.duration;if(N&&Y&&rv(H)){for(H=0,Y=k.responseEnd,g+=1;g<h.length;g++){var ie=h[g],pe=ie.startTime;if(pe>Y)break;var Ee=ie.transferSize,Ae=ie.initiatorType;Ee&&rv(Ae)&&(ie=ie.responseEnd,H+=Ee*(ie<Y?1:(Y-pe)/(ie-pe)))}if(--g,o+=8*(N+H)/(k.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 Rf=null,Of=null;function Yc(s){return s.nodeType===9?s:s.ownerDocument}function sv(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 iv(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 If(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 Mf=null;function RE(){var s=window.event;return s&&s.type==="popstate"?s===Mf?!1:(Mf=s,!0):(Mf=null,!1)}var av=typeof setTimeout=="function"?setTimeout:void 0,OE=typeof clearTimeout=="function"?clearTimeout:void 0,ov=typeof Promise=="function"?Promise:void 0,IE=typeof queueMicrotask=="function"?queueMicrotask:typeof ov<"u"?function(s){return ov.resolve(null).then(s).catch(ME)}:av;function ME(s){setTimeout(function(){throw s})}function Gs(s){return s==="head"}function lv(s,o){var h=o,g=0;do{var k=h.nextSibling;if(s.removeChild(h),k&&k.nodeType===8)if(h=k.data,h==="/$"||h==="/&"){if(g===0){s.removeChild(k),Oa(o);return}g--}else if(h==="$"||h==="$?"||h==="$~"||h==="$!"||h==="&")g++;else if(h==="html")Yo(s.ownerDocument.documentElement);else if(h==="head"){h=s.ownerDocument.head,Yo(h);for(var N=h.firstChild;N;){var H=N.nextSibling,Y=N.nodeName;N[fo]||Y==="SCRIPT"||Y==="STYLE"||Y==="LINK"&&N.rel.toLowerCase()==="stylesheet"||h.removeChild(N),N=H}}else h==="body"&&Yo(s.ownerDocument.body);h=k}while(h);Oa(o)}function cv(s,o){var h=s;s=0;do{var g=h.nextSibling;if(h.nodeType===1?o?(h._stashedDisplay=h.style.display,h.style.display="none"):(h.style.display=h._stashedDisplay||"",h.getAttribute("style")===""&&h.removeAttribute("style")):h.nodeType===3&&(o?(h._stashedText=h.nodeValue,h.nodeValue=""):h.nodeValue=h._stashedText||""),g&&g.nodeType===8)if(h=g.data,h==="/$"){if(s===0)break;s--}else h!=="$"&&h!=="$?"&&h!=="$~"&&h!=="$!"||s++;h=g}while(h)}function Pf(s){var o=s.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var h=o;switch(o=o.nextSibling,h.nodeName){case"HTML":case"HEAD":case"BODY":Pf(h),Hd(h);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(h.rel.toLowerCase()==="stylesheet")continue}s.removeChild(h)}}function PE(s,o,h,g){for(;s.nodeType===1;){var k=h;if(s.nodeName.toLowerCase()!==o.toLowerCase()){if(!g&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(g){if(!s[fo])switch(o){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(N=s.getAttribute("rel"),N==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(N!==k.rel||s.getAttribute("href")!==(k.href==null||k.href===""?null:k.href)||s.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin)||s.getAttribute("title")!==(k.title==null?null:k.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(N=s.getAttribute("src"),(N!==(k.src==null?null:k.src)||s.getAttribute("type")!==(k.type==null?null:k.type)||s.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&N&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(o==="input"&&s.type==="hidden"){var N=k.name==null?null:""+k.name;if(k.type==="hidden"&&s.getAttribute("name")===N)return s}else return s;if(s=yr(s.nextSibling),s===null)break}return null}function BE(s,o,h){if(o==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!h||(s=yr(s.nextSibling),s===null))return null;return s}function uv(s,o){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!o||(s=yr(s.nextSibling),s===null))return null;return s}function Bf(s){return s.data==="$?"||s.data==="$~"}function $f(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function $E(s,o){var h=s.ownerDocument;if(s.data==="$~")s._reactRetry=o;else if(s.data!=="$?"||h.readyState!=="loading")o();else{var g=function(){o(),h.removeEventListener("DOMContentLoaded",g)};h.addEventListener("DOMContentLoaded",g),s._reactRetry=g}}function yr(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 zf=null;function dv(s){s=s.nextSibling;for(var o=0;s;){if(s.nodeType===8){var h=s.data;if(h==="/$"||h==="/&"){if(o===0)return yr(s.nextSibling);o--}else h!=="$"&&h!=="$!"&&h!=="$?"&&h!=="$~"&&h!=="&"||o++}s=s.nextSibling}return null}function hv(s){s=s.previousSibling;for(var o=0;s;){if(s.nodeType===8){var h=s.data;if(h==="$"||h==="$!"||h==="$?"||h==="$~"||h==="&"){if(o===0)return s;o--}else h!=="/$"&&h!=="/&"||o++}s=s.previousSibling}return null}function fv(s,o,h){switch(o=Yc(h),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 Yo(s){for(var o=s.attributes;o.length;)s.removeAttributeNode(o[0]);Hd(s)}var br=new Map,mv=new Set;function Xc(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var ms=Z.d;Z.d={f:zE,r:HE,D:UE,C:FE,L:VE,m:GE,X:qE,S:WE,M:KE};function zE(){var s=ms.f(),o=Hc();return s||o}function HE(s){var o=Zi(s);o!==null&&o.tag===5&&o.type==="form"?Ly(o):ms.r(s)}var La=typeof document>"u"?null:document;function pv(s,o,h){var g=La;if(g&&typeof o=="string"&&o){var k=dr(o);k='link[rel="'+s+'"][href="'+k+'"]',typeof h=="string"&&(k+='[crossorigin="'+h+'"]'),mv.has(k)||(mv.add(k),s={rel:s,crossOrigin:h,href:o},g.querySelector(k)===null&&(o=g.createElement("link"),Nn(o,"link",s),vn(o),g.head.appendChild(o)))}}function UE(s){ms.D(s),pv("dns-prefetch",s,null)}function FE(s,o){ms.C(s,o),pv("preconnect",s,o)}function VE(s,o,h){ms.L(s,o,h);var g=La;if(g&&s&&o){var k='link[rel="preload"][as="'+dr(o)+'"]';o==="image"&&h&&h.imageSrcSet?(k+='[imagesrcset="'+dr(h.imageSrcSet)+'"]',typeof h.imageSizes=="string"&&(k+='[imagesizes="'+dr(h.imageSizes)+'"]')):k+='[href="'+dr(s)+'"]';var N=k;switch(o){case"style":N=Da(s);break;case"script":N=Ra(s)}br.has(N)||(s=m({rel:"preload",href:o==="image"&&h&&h.imageSrcSet?void 0:s,as:o},h),br.set(N,s),g.querySelector(k)!==null||o==="style"&&g.querySelector(Xo(N))||o==="script"&&g.querySelector(Qo(N))||(o=g.createElement("link"),Nn(o,"link",s),vn(o),g.head.appendChild(o)))}}function GE(s,o){ms.m(s,o);var h=La;if(h&&s){var g=o&&typeof o.as=="string"?o.as:"script",k='link[rel="modulepreload"][as="'+dr(g)+'"][href="'+dr(s)+'"]',N=k;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":N=Ra(s)}if(!br.has(N)&&(s=m({rel:"modulepreload",href:s},o),br.set(N,s),h.querySelector(k)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(h.querySelector(Qo(N)))return}g=h.createElement("link"),Nn(g,"link",s),vn(g),h.head.appendChild(g)}}}function WE(s,o,h){ms.S(s,o,h);var g=La;if(g&&s){var k=ea(g).hoistableStyles,N=Da(s);o=o||"default";var H=k.get(N);if(!H){var Y={loading:0,preload:null};if(H=g.querySelector(Xo(N)))Y.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":o},h),(h=br.get(N))&&Hf(s,h);var ie=H=g.createElement("link");vn(ie),Nn(ie,"link",s),ie._p=new Promise(function(pe,Ee){ie.onload=pe,ie.onerror=Ee}),ie.addEventListener("load",function(){Y.loading|=1}),ie.addEventListener("error",function(){Y.loading|=2}),Y.loading|=4,Qc(H,o,g)}H={type:"stylesheet",instance:H,count:1,state:Y},k.set(N,H)}}}function qE(s,o){ms.X(s,o);var h=La;if(h&&s){var g=ea(h).hoistableScripts,k=Ra(s),N=g.get(k);N||(N=h.querySelector(Qo(k)),N||(s=m({src:s,async:!0},o),(o=br.get(k))&&Uf(s,o),N=h.createElement("script"),vn(N),Nn(N,"link",s),h.head.appendChild(N)),N={type:"script",instance:N,count:1,state:null},g.set(k,N))}}function KE(s,o){ms.M(s,o);var h=La;if(h&&s){var g=ea(h).hoistableScripts,k=Ra(s),N=g.get(k);N||(N=h.querySelector(Qo(k)),N||(s=m({src:s,async:!0,type:"module"},o),(o=br.get(k))&&Uf(s,o),N=h.createElement("script"),vn(N),Nn(N,"link",s),h.head.appendChild(N)),N={type:"script",instance:N,count:1,state:null},g.set(k,N))}}function gv(s,o,h,g){var k=(k=ne.current)?Xc(k):null;if(!k)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof h.precedence=="string"&&typeof h.href=="string"?(o=Da(h.href),h=ea(k).hoistableStyles,g=h.get(o),g||(g={type:"style",instance:null,count:0,state:null},h.set(o,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(h.rel==="stylesheet"&&typeof h.href=="string"&&typeof h.precedence=="string"){s=Da(h.href);var N=ea(k).hoistableStyles,H=N.get(s);if(H||(k=k.ownerDocument||k,H={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},N.set(s,H),(N=k.querySelector(Xo(s)))&&!N._p&&(H.instance=N,H.state.loading=5),br.has(s)||(h={rel:"preload",as:"style",href:h.href,crossOrigin:h.crossOrigin,integrity:h.integrity,media:h.media,hrefLang:h.hrefLang,referrerPolicy:h.referrerPolicy},br.set(s,h),N||YE(k,s,h,H.state))),o&&g===null)throw Error(r(528,""));return H}if(o&&g!==null)throw Error(r(529,""));return null;case"script":return o=h.async,h=h.src,typeof h=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=Ra(h),h=ea(k).hoistableScripts,g=h.get(o),g||(g={type:"script",instance:null,count:0,state:null},h.set(o,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function Da(s){return'href="'+dr(s)+'"'}function Xo(s){return'link[rel="stylesheet"]['+s+"]"}function xv(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function YE(s,o,h,g){s.querySelector('link[rel="preload"][as="style"]['+o+"]")?g.loading=1:(o=s.createElement("link"),g.preload=o,o.addEventListener("load",function(){return g.loading|=1}),o.addEventListener("error",function(){return g.loading|=2}),Nn(o,"link",h),vn(o),s.head.appendChild(o))}function Ra(s){return'[src="'+dr(s)+'"]'}function Qo(s){return"script[async]"+s}function yv(s,o,h){if(o.count++,o.instance===null)switch(o.type){case"style":var g=s.querySelector('style[data-href~="'+dr(h.href)+'"]');if(g)return o.instance=g,vn(g),g;var k=m({},h,{"data-href":h.href,"data-precedence":h.precedence,href:null,precedence:null});return g=(s.ownerDocument||s).createElement("style"),vn(g),Nn(g,"style",k),Qc(g,h.precedence,s),o.instance=g;case"stylesheet":k=Da(h.href);var N=s.querySelector(Xo(k));if(N)return o.state.loading|=4,o.instance=N,vn(N),N;g=xv(h),(k=br.get(k))&&Hf(g,k),N=(s.ownerDocument||s).createElement("link"),vn(N);var H=N;return H._p=new Promise(function(Y,ie){H.onload=Y,H.onerror=ie}),Nn(N,"link",g),o.state.loading|=4,Qc(N,h.precedence,s),o.instance=N;case"script":return N=Ra(h.src),(k=s.querySelector(Qo(N)))?(o.instance=k,vn(k),k):(g=h,(k=br.get(N))&&(g=m({},h),Uf(g,k)),s=s.ownerDocument||s,k=s.createElement("script"),vn(k),Nn(k,"link",g),s.head.appendChild(k),o.instance=k);case"void":return null;default:throw Error(r(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(g=o.instance,o.state.loading|=4,Qc(g,h.precedence,s));return o.instance}function Qc(s,o,h){for(var g=h.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=g.length?g[g.length-1]:null,N=k,H=0;H<g.length;H++){var Y=g[H];if(Y.dataset.precedence===o)N=Y;else if(N!==k)break}N?N.parentNode.insertBefore(s,N.nextSibling):(o=h.nodeType===9?h.head:h,o.insertBefore(s,o.firstChild))}function Hf(s,o){s.crossOrigin==null&&(s.crossOrigin=o.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=o.referrerPolicy),s.title==null&&(s.title=o.title)}function Uf(s,o){s.crossOrigin==null&&(s.crossOrigin=o.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=o.referrerPolicy),s.integrity==null&&(s.integrity=o.integrity)}var Jc=null;function bv(s,o,h){if(Jc===null){var g=new Map,k=Jc=new Map;k.set(h,g)}else k=Jc,g=k.get(h),g||(g=new Map,k.set(h,g));if(g.has(s))return g;for(g.set(s,null),h=h.getElementsByTagName(s),k=0;k<h.length;k++){var N=h[k];if(!(N[fo]||N[an]||s==="link"&&N.getAttribute("rel")==="stylesheet")&&N.namespaceURI!=="http://www.w3.org/2000/svg"){var H=N.getAttribute(o)||"";H=s+H;var Y=g.get(H);Y?Y.push(N):g.set(H,[N])}}return g}function vv(s,o,h){s=s.ownerDocument||s,s.head.insertBefore(h,o==="title"?s.querySelector("head > title"):null)}function XE(s,o,h){if(h===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 _v(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function QE(s,o,h,g){if(h.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(h.state.loading&4)===0){if(h.instance===null){var k=Da(g.href),N=o.querySelector(Xo(k));if(N){o=N._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(s.count++,s=Zc.bind(s),o.then(s,s)),h.state.loading|=4,h.instance=N,vn(N);return}N=o.ownerDocument||o,g=xv(g),(k=br.get(k))&&Hf(g,k),N=N.createElement("link"),vn(N);var H=N;H._p=new Promise(function(Y,ie){H.onload=Y,H.onerror=ie}),Nn(N,"link",g),h.instance=N}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(h,o),(o=h.state.preload)&&(h.state.loading&3)===0&&(s.count++,h=Zc.bind(s),o.addEventListener("load",h),o.addEventListener("error",h))}}var Ff=0;function JE(s,o){return s.stylesheets&&s.count===0&&tu(s,s.stylesheets),0<s.count||0<s.imgCount?function(h){var g=setTimeout(function(){if(s.stylesheets&&tu(s,s.stylesheets),s.unsuspend){var N=s.unsuspend;s.unsuspend=null,N()}},6e4+o);0<s.imgBytes&&Ff===0&&(Ff=62500*DE());var k=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&tu(s,s.stylesheets),s.unsuspend)){var N=s.unsuspend;s.unsuspend=null,N()}},(s.imgBytes>Ff?50:800)+o);return s.unsuspend=h,function(){s.unsuspend=null,clearTimeout(g),clearTimeout(k)}}:null}function Zc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)tu(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var eu=null;function tu(s,o){s.stylesheets=null,s.unsuspend!==null&&(s.count++,eu=new Map,o.forEach(ZE,s),eu=null,Zc.call(s))}function ZE(s,o){if(!(o.state.loading&4)){var h=eu.get(s);if(h)var g=h.get(null);else{h=new Map,eu.set(s,h);for(var k=s.querySelectorAll("link[data-precedence],style[data-precedence]"),N=0;N<k.length;N++){var H=k[N];(H.nodeName==="LINK"||H.getAttribute("media")!=="not all")&&(h.set(H.dataset.precedence,H),g=H)}g&&h.set(null,g)}k=o.instance,H=k.getAttribute("data-precedence"),N=h.get(H)||g,N===g&&h.set(null,k),h.set(H,k),this.count++,g=Zc.bind(this),k.addEventListener("load",g),k.addEventListener("error",g),N?N.parentNode.insertBefore(k,N.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(k,s.firstChild)),o.state.loading|=4}}var Jo={$$typeof:v,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function ej(s,o,h,g,k,N,H,Y,ie){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=rn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rn(0),this.hiddenUpdates=rn(null),this.identifierPrefix=g,this.onUncaughtError=k,this.onCaughtError=N,this.onRecoverableError=H,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ie,this.incompleteTransitions=new Map}function Sv(s,o,h,g,k,N,H,Y,ie,pe,Ee,Ae){return s=new ej(s,o,h,H,ie,pe,Ee,Ae,Y),o=1,N===!0&&(o|=24),N=tr(3,null,null,o),s.current=N,N.stateNode=s,o=_h(),o.refCount++,s.pooledCache=o,o.refCount++,N.memoizedState={element:g,isDehydrated:h,cache:o},kh(N),s}function wv(s){return s?(s=ua,s):ua}function Cv(s,o,h,g,k,N){k=wv(k),g.context===null?g.context=k:g.pendingContext=k,g=Os(o),g.payload={element:h},N=N===void 0?null:N,N!==null&&(g.callback=N),h=Is(s,g,o),h!==null&&(Kn(h,s,o),Ao(h,s,o))}function kv(s,o){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var h=s.retryLane;s.retryLane=h!==0&&h<o?h:o}}function Vf(s,o){kv(s,o),(s=s.alternate)&&kv(s,o)}function Ev(s){if(s.tag===13||s.tag===31){var o=gi(s,67108864);o!==null&&Kn(o,s,67108864),Vf(s,67108864)}}function jv(s){if(s.tag===13||s.tag===31){var o=ar();o=et(o);var h=gi(s,o);h!==null&&Kn(h,s,o),Vf(s,o)}}var nu=!0;function tj(s,o,h,g){var k=G.T;G.T=null;var N=Z.p;try{Z.p=2,Gf(s,o,h,g)}finally{Z.p=N,G.T=k}}function nj(s,o,h,g){var k=G.T;G.T=null;var N=Z.p;try{Z.p=8,Gf(s,o,h,g)}finally{Z.p=N,G.T=k}}function Gf(s,o,h,g){if(nu){var k=Wf(g);if(k===null)Lf(s,o,g,ru,h),Tv(s,g);else if(sj(k,s,o,h,g))g.stopPropagation();else if(Tv(s,g),o&4&&-1<rj.indexOf(s)){for(;k!==null;){var N=Zi(k);if(N!==null)switch(N.tag){case 3:if(N=N.stateNode,N.current.memoizedState.isDehydrated){var H=ae(N.pendingLanes);if(H!==0){var Y=N;for(Y.pendingLanes|=2,Y.entangledLanes|=2;H;){var ie=1<<31-dt(H);Y.entanglements[1]|=ie,H&=~ie}zr(N),(Et&6)===0&&($c=He()+500,Wo(0))}}break;case 31:case 13:Y=gi(N,2),Y!==null&&Kn(Y,N,2),Hc(),Vf(N,2)}if(N=Wf(g),N===null&&Lf(s,o,g,ru,h),N===k)break;k=N}k!==null&&g.stopPropagation()}else Lf(s,o,g,null,h)}}function Wf(s){return s=qd(s),qf(s)}var ru=null;function qf(s){if(ru=null,s=Ji(s),s!==null){var o=l(s);if(o===null)s=null;else{var h=o.tag;if(h===13){if(s=u(o),s!==null)return s;s=null}else if(h===31){if(s=c(o),s!==null)return s;s=null}else if(h===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;s=null}else o!==s&&(s=null)}}return ru=s,null}function Nv(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(ut()){case re:return 2;case be:return 8;case ke:case ze:return 32;case Ye:return 268435456;default:return 32}default:return 32}}var Kf=!1,Ws=null,qs=null,Ks=null,Zo=new Map,el=new Map,Ys=[],rj="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 Tv(s,o){switch(s){case"focusin":case"focusout":Ws=null;break;case"dragenter":case"dragleave":qs=null;break;case"mouseover":case"mouseout":Ks=null;break;case"pointerover":case"pointerout":Zo.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":el.delete(o.pointerId)}}function tl(s,o,h,g,k,N){return s===null||s.nativeEvent!==N?(s={blockedOn:o,domEventName:h,eventSystemFlags:g,nativeEvent:N,targetContainers:[k]},o!==null&&(o=Zi(o),o!==null&&Ev(o)),s):(s.eventSystemFlags|=g,o=s.targetContainers,k!==null&&o.indexOf(k)===-1&&o.push(k),s)}function sj(s,o,h,g,k){switch(o){case"focusin":return Ws=tl(Ws,s,o,h,g,k),!0;case"dragenter":return qs=tl(qs,s,o,h,g,k),!0;case"mouseover":return Ks=tl(Ks,s,o,h,g,k),!0;case"pointerover":var N=k.pointerId;return Zo.set(N,tl(Zo.get(N)||null,s,o,h,g,k)),!0;case"gotpointercapture":return N=k.pointerId,el.set(N,tl(el.get(N)||null,s,o,h,g,k)),!0}return!1}function Av(s){var o=Ji(s.target);if(o!==null){var h=l(o);if(h!==null){if(o=h.tag,o===13){if(o=u(h),o!==null){s.blockedOn=o,Zt(s.priority,function(){jv(h)});return}}else if(o===31){if(o=c(h),o!==null){s.blockedOn=o,Zt(s.priority,function(){jv(h)});return}}else if(o===3&&h.stateNode.current.memoizedState.isDehydrated){s.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}s.blockedOn=null}function su(s){if(s.blockedOn!==null)return!1;for(var o=s.targetContainers;0<o.length;){var h=Wf(s.nativeEvent);if(h===null){h=s.nativeEvent;var g=new h.constructor(h.type,h);Wd=g,h.target.dispatchEvent(g),Wd=null}else return o=Zi(h),o!==null&&Ev(o),s.blockedOn=h,!1;o.shift()}return!0}function Lv(s,o,h){su(s)&&h.delete(o)}function ij(){Kf=!1,Ws!==null&&su(Ws)&&(Ws=null),qs!==null&&su(qs)&&(qs=null),Ks!==null&&su(Ks)&&(Ks=null),Zo.forEach(Lv),el.forEach(Lv)}function iu(s,o){s.blockedOn===o&&(s.blockedOn=null,Kf||(Kf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,ij)))}var au=null;function Dv(s){au!==s&&(au=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){au===s&&(au=null);for(var o=0;o<s.length;o+=3){var h=s[o],g=s[o+1],k=s[o+2];if(typeof g!="function"){if(qf(g||h)===null)continue;break}var N=Zi(h);N!==null&&(s.splice(o,3),o-=3,Gh(N,{pending:!0,data:k,method:h.method,action:g},g,k))}}))}function Oa(s){function o(ie){return iu(ie,s)}Ws!==null&&iu(Ws,s),qs!==null&&iu(qs,s),Ks!==null&&iu(Ks,s),Zo.forEach(o),el.forEach(o);for(var h=0;h<Ys.length;h++){var g=Ys[h];g.blockedOn===s&&(g.blockedOn=null)}for(;0<Ys.length&&(h=Ys[0],h.blockedOn===null);)Av(h),h.blockedOn===null&&Ys.shift();if(h=(s.ownerDocument||s).$$reactFormReplay,h!=null)for(g=0;g<h.length;g+=3){var k=h[g],N=h[g+1],H=k[Un]||null;if(typeof N=="function")H||Dv(h);else if(H){var Y=null;if(N&&N.hasAttribute("formAction")){if(k=N,H=N[Un]||null)Y=H.formAction;else if(qf(k)!==null)continue}else Y=H.action;typeof Y=="function"?h[g+1]=Y:(h.splice(g,3),g-=3),Dv(h)}}}function Rv(){function s(N){N.canIntercept&&N.info==="react-transition"&&N.intercept({handler:function(){return new Promise(function(H){return k=H})},focusReset:"manual",scroll:"manual"})}function o(){k!==null&&(k(),k=null),g||setTimeout(h,20)}function h(){if(!g&&!navigation.transition){var N=navigation.currentEntry;N&&N.url!=null&&navigation.navigate(N.url,{state:N.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var g=!1,k=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(h,100),function(){g=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),k!==null&&(k(),k=null)}}}function Yf(s){this._internalRoot=s}ou.prototype.render=Yf.prototype.render=function(s){var o=this._internalRoot;if(o===null)throw Error(r(409));var h=o.current,g=ar();Cv(h,g,s,o,null,null)},ou.prototype.unmount=Yf.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var o=s.containerInfo;Cv(s.current,2,null,s,null,null),Hc(),o[Qi]=null}};function ou(s){this._internalRoot=s}ou.prototype.unstable_scheduleHydration=function(s){if(s){var o=sn();s={blockedOn:null,target:s,priority:o};for(var h=0;h<Ys.length&&o!==0&&o<Ys[h].priority;h++);Ys.splice(h,0,s),h===0&&Av(s)}};var Ov=t.version;if(Ov!=="19.2.4")throw Error(r(527,Ov,"19.2.4"));Z.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=f(o),s=s!==null?p(s):null,s=s===null?null:s.stateNode,s};var aj={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:G,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var lu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lu.isDisabled&&lu.supportsFiber)try{_t=lu.inject(aj),It=lu}catch{}}return rl.createRoot=function(s,o){if(!a(s))throw Error(r(299));var h=!1,g="",k=Hy,N=Uy,H=Fy;return o!=null&&(o.unstable_strictMode===!0&&(h=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onUncaughtError!==void 0&&(k=o.onUncaughtError),o.onCaughtError!==void 0&&(N=o.onCaughtError),o.onRecoverableError!==void 0&&(H=o.onRecoverableError)),o=Sv(s,1,!1,null,null,h,g,null,k,N,H,Rv),s[Qi]=o.current,Af(s),new Yf(o)},rl.hydrateRoot=function(s,o,h){if(!a(s))throw Error(r(299));var g=!1,k="",N=Hy,H=Uy,Y=Fy,ie=null;return h!=null&&(h.unstable_strictMode===!0&&(g=!0),h.identifierPrefix!==void 0&&(k=h.identifierPrefix),h.onUncaughtError!==void 0&&(N=h.onUncaughtError),h.onCaughtError!==void 0&&(H=h.onCaughtError),h.onRecoverableError!==void 0&&(Y=h.onRecoverableError),h.formState!==void 0&&(ie=h.formState)),o=Sv(s,1,!0,o,h??null,g,k,ie,N,H,Y,Rv),o.context=wv(null),h=o.current,g=ar(),g=et(g),k=Os(g),k.callback=null,Is(h,k,g),h=g,o.current.lanes=h,Ce(o,h),zr(o),s[Qi]=o.current,Af(s),new ou(o)},rl.version="19.2.4",rl}var Wv;function _j(){if(Wv)return em.exports;Wv=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(),em.exports=vj(),em.exports}var Sj=_j();const wj=ud(Sj);function Cj(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,a,l,u=[],c="",d=e.split("/");for(d[0]||d.shift();a=d.shift();)n=a[0],n==="*"?(u.push(n),c+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(r=a.indexOf("?",1),l=a.indexOf(".",1),u.push(a.substring(1,~r?r:~l?l:a.length)),c+=~r&&!~l?"(?:/([^/]+?))?":"/([^/]+?)",~l&&(c+=(~r?"?":"")+"\\"+a.substring(l))):c+="/"+a;return{keys:u,pattern:new RegExp("^"+c+(t?"(?=$|/)":"/?$"),"i")}}var sm={exports:{}},im={};/**
|
|
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 qv;function kj(){if(qv)return im;qv=1;var e=dd();function t(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function c(m,x){var y=x(),w=r({inst:{value:y,getSnapshot:x}}),C=w[0].inst,_=w[1];return l(function(){C.value=y,C.getSnapshot=x,d(C)&&_({inst:C})},[m,y,x]),a(function(){return d(C)&&_({inst:C}),m(function(){d(C)&&_({inst:C})})},[m]),u(y),y}function d(m){var x=m.getSnapshot;m=m.value;try{var y=x();return!n(m,y)}catch{return!0}}function f(m,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return im.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,im}var Kv;function Ej(){return Kv||(Kv=1,sm.exports=kj()),sm.exports}var jj=Ej();const Nj=gj.useInsertionEffect,Tj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Aj=Tj?A.useLayoutEffect:A.useEffect,Lj=Nj||Aj,GS=e=>{const t=A.useRef([e,(...n)=>t[0](...n)]).current;return Lj(()=>{t[0]=e}),t[1]},Dj="popstate",Fp="pushState",Vp="replaceState",Rj="hashchange",Yv=[Dj,Fp,Vp,Rj],Oj=e=>{for(const t of Yv)addEventListener(t,e);return()=>{for(const t of Yv)removeEventListener(t,e)}},WS=(e,t)=>jj.useSyncExternalStore(Oj,e,t),Xv=()=>location.search,Ij=({ssrSearch:e}={})=>WS(Xv,e!=null?()=>e:Xv),Qv=()=>location.pathname,Mj=({ssrPath:e}={})=>WS(Qv,e!=null?()=>e:Qv),Pj=(e,{replace:t=!1,state:n=null}={})=>history[t?Vp:Fp](n,"",e),Bj=(e={})=>[Mj(e),Pj],Jv=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[Jv]>"u"){for(const e of[Fp,Vp]){const t=history[e];history[e]=function(){const n=t.apply(this,arguments),r=new Event(e);return r.arguments=arguments,dispatchEvent(r),n}}Object.defineProperty(window,Jv,{value:!0})}const $j=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",qS=(e="")=>e==="/"?"":e,zj=(e,t)=>e[0]==="~"?e.slice(1):qS(t)+e,Hj=(e="",t)=>$j(Zv(qS(e)),Zv(t)),Zv=e=>{try{return decodeURI(e)}catch{return e}},KS={hook:Bj,searchHook:Ij,parser:Cj,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},YS=A.createContext(KS),no=()=>A.useContext(YS),XS={},QS=A.createContext(XS),Uj=()=>A.useContext(QS),hd=e=>{const[t,n]=e.hook(e);return[Hj(e.base,t),GS((r,a)=>e.aroundNav(n,zj(r,e.base),a))]},zn=()=>hd(no()),Gp=(e,t,n,r)=>{const{pattern:a,keys:l}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),u=a.exec(n)||[],[c,...d]=u;return c!==void 0?[!0,(()=>{const f=l!==!1?Object.fromEntries(l.map((m,x)=>[m,d[x]])):u.groups;let p={...d};return f&&Object.assign(p,f),p})(),...r?[c]:[]]:[!1,null]},ro=e=>Gp(no().parser,e,zn()[0]),JS=({children:e,...t})=>{var p,m,x;const n=no(),r=t.hook?KS:n;let a=r;const[l,u=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];l&&(t.ssrSearch=u,t.ssrPath=l),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((x=t.hook)==null?void 0:x.searchHook);let c=A.useRef({}),d=c.current,f=d;for(let y in r){const w=y==="base"?r[y]+(t[y]??""):t[y]??r[y];d===f&&w!==f[y]&&(c.current=f={...f}),f[y]=w,(w!==r[y]||w!==a[y])&&(a=f)}return A.createElement(YS.Provider,{value:a,children:e})},e_=({children:e,component:t},n)=>t?A.createElement(t,{params:n}):typeof e=="function"?e(n):e,Fj=e=>{let t=A.useRef(XS);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,a])=>a!==n[r])?e:n},sl=({path:e,nest:t,match:n,...r})=>{const a=no(),[l]=hd(a),[u,c,d]=n??Gp(a.parser,e,l,t),f=Fj({...Uj(),...c});if(!u)return null;const p=d?A.createElement(JS,{base:d},e_(r,f)):e_(r,f);return A.createElement(QS.Provider,{value:f,children:p})},Xn=A.forwardRef((e,t)=>{const n=no(),[r,a]=hd(n),{to:l="",href:u=l,onClick:c,asChild:d,children:f,className:p,replace:m,state:x,transition:y,...w}=e,C=GS(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(c==null||c(S),S.defaultPrevented||(S.preventDefault(),a(u,e)))}),_=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return d&&A.isValidElement(f)?A.cloneElement(f,{onClick:C,href:_}):A.createElement("a",{...w,onClick:C,href:_,className:p!=null&&p.call?p(r===u):p,children:f,ref:t})}),ZS=e=>Array.isArray(e)?e.flatMap(t=>ZS(t&&t.type===A.Fragment?t.props.children:t)):[e],Vj=({children:e,location:t})=>{const n=no(),[r]=hd(n);for(const a of ZS(e)){let l=0;if(A.isValidElement(a)&&(l=Gp(n.parser,a.props.path,t||r,a.props.nest))[0])return A.cloneElement(a,{match:l})}return null},t_=e=>{let t;const n=new Set,r=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const x=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,x))}},a=()=>t,c={setState:r,getState:a,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f))},d=t=e(r,a,c);return c},Gj=(e=>e?t_(e):t_),Wj=e=>e;function qj(e,t=Wj){const n=ri.useSyncExternalStore(e.subscribe,ri.useCallback(()=>t(e.getState()),[e,t]),ri.useCallback(()=>t(e.getInitialState()),[e,t]));return ri.useDebugValue(n),n}const n_=e=>{const t=Gj(e),n=r=>qj(t,r);return Object.assign(n,t),n},Hn=(e=>e?n_(e):n_);function Kj(){if(typeof document>"u")return"";const e=Array.from(document.scripts).find(a=>{const l=new URL(a.src,window.location.href).pathname;return l.includes("/assets/")||l.endsWith("/src/main.tsx")});if(!e)return"";const t=new URL(e.src,window.location.href).pathname,n=t.includes("/assets/")?"/assets/":"/src/",r=t.indexOf(n);return r>0?t.slice(0,r):""}const e1=Kj();function Cs(e){return e.startsWith("/")?`${e1}${e}`||"/":e}async function we(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(Cs(e),{...t,headers:r})}async function r_(e,t,n){try{return(await we(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{content:n}:{}})})).ok}catch{return!1}}const De={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_SYSTEM_THEME_PREFS:"display.systemThemePrefs",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",DISPLAY_SHOW_CHANGELOG_ON_UPDATE:"display.showChangelogOnUpdate",DISPLAY_MAX_VISIBLE_ITEMS:"display.maxVisibleItems",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",CACHE_WARMING:"cache.warming",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns",SKILLS_DIRECTORIES:"skills.directories",SEARCH_ENGINE:"search.engine",SEARCH_TAVILY_API_KEY:"search.tavilyApiKey",SEARCH_SEARXNG_URL:"search.searxngUrl",SEARCH_SEARXNG_API_KEY:"search.searxngApiKey",TOOLS_USE_RTK:"tools.useRtk",TOOLS_SHELL:"tools.shell",CONFIRM_ON_WORKSPACE_ACTIONS:"tools.confirmOnWorkspaceActions",PROXY_URL:"network.proxyUrl",DEFAULT_AGENT:"agent.defaultAgent"};function cu(e,t){return n=>({loading:{...n.loading,[e]:t}})}function s_(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const Wp=[De.DISPLAY_SHOW_THINKING,De.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,De.DISPLAY_SHOW_STATS,De.DISPLAY_SHOW_AGENT_DEFINITIONS,De.DISPLAY_SHOW_WORKFLOW_BARS,De.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,De.DISPLAY_FOLLOW_SYSTEM_THEME,De.DISPLAY_SHOW_OPEN_IN_EDITOR,De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,De.DISPLAY_MAX_VISIBLE_ITEMS];function Ki(){return{showThinking:Gt(e=>e.settings[De.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:Gt(e=>e.settings[De.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:Gt(e=>e.settings[De.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:Gt(e=>e.settings[De.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:Gt(e=>e.settings[De.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:Gt(e=>e.settings[De.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(Gt(e=>e.settings[De.DISPLAY_MAX_VISIBLE_ITEMS]??"300"))}}const Gt=Hn(e=>({settings:{},loading:{},getSetting:async t=>{e(cu(t,!0));try{const r=await(await we(`/api/settings/${t}`)).json();return e(s_(t,r.value??"")),r.value}catch{return e(cu(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await we(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:r,loading:Object.fromEntries(t.map(a=>[a,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(cu(t,!0));try{const a=await(await we(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(s_(t,a.value??""))}catch{e(cu(t,!1))}}})),il=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:Wp,SETTINGS_KEYS:De,useDisplaySettings:Ki,useSettingsStore:Gt},Symbol.toStringTag,{value:"Module"}));function Yj(){const[e,t]=A.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=A.useRef(window.innerHeight);return A.useEffect(()=>{const r=window.visualViewport;if(!r)return;const a=()=>{const l=r.offsetTop,u=r.height,c=n.current-u>100;t({offsetTop:l,height:u,keyboardVisible:c})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}function Xj(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Ou(){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 Qj{constructor(t){Se(this,"ws",null);Se(this,"handlers",new Set);Se(this,"statusHandler",null);Se(this,"baseUrl");Se(this,"isReconnecting",!1);Se(this,"connectingPromise",null);Se(this,"lastCloseCode",0);Se(this,"reconnectAttempts",0);Se(this,"manualReconnectScheduled",!1);Se(this,"pwaRecoveryAttempted",!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((a,l)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const c=setTimeout(()=>{var d;((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING&&(this.ws.close(),l(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var d;clearTimeout(c),this.isReconnecting=!1,this.reconnectAttempts=0,this.connectingPromise=null,(d=this.statusHandler)==null||d.call(this,"connected"),a()},this.ws.onclose=d=>{var f,p,m;clearTimeout(c),this.lastCloseCode=d.code,((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),l(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=d=>{clearTimeout(c),console.error("WebSocket error:",d),this.connectingPromise=null,l(d)},this.ws.onmessage=d=>{try{const f=JSON.parse(d.data);Xj(f)&&this.handlers.forEach(p=>p(f))}catch(f){console.error("Failed to parse WebSocket message:",f)}}}catch(u){this.connectingPromise=null,l(u)}}),this.connectingPromise)))}async recoverPwaStuckConnection(){if(this.pwaRecoveryAttempted||!window.matchMedia("(display-mode: standalone)").matches||!("serviceWorker"in navigator))return;this.pwaRecoveryAttempted=!0;const n=await navigator.serviceWorker.getRegistrations();n.length!==0&&(console.warn("[WS] PWA mode detected with stale service worker — unregistering and reloading"),await Promise.all(n.map(r=>r.unregister())),window.location.reload())}attemptReconnect(){var r;if(this.lastCloseCode===4e3&&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,(r=this.statusHandler)==null||r.call(this,"reconnecting");const n=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(()=>{this.reconnectAttempts>=3&&this.recoverPwaStuckConnection()})},n)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{this.recoverPwaStuckConnection()})}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=Ou(),a={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(a)),r}subscribe(t){return this.handlers.add(t),()=>this.handlers.delete(t)}get isConnected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}}const Jj=window.location.protocol==="https:"?"wss:":"ws:";let rp=window.location.port;rp||(rp=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const Zj=`${Jj}//${window.location.hostname}:${rp}${Cs("/ws")}`,Xt=new Qj(Zj),eN=3e4;function t1(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"lmstudio":return"LM Studio";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"unknown":return"Other"}}const Qt=Hn((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,platform:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const n=await we("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json(),a=r.platform&&typeof r.platform=="object"?{isWSL:!!r.platform.isWSL,wslDistro:String(r.platform.wslDistro??"")}:null;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,platform:a,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await we("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json();e({model:r.model,llmStatus:r.llmStatus,backend:r.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:r,providers:a}=t();if(n===r)return!0;e({activating:!0,error:null});try{const l=await we(`/api/providers/${n}/activate`,{method:"POST"});if(!l.ok){const c=await l.json();throw new Error(c.error??"Failed to activate provider")}const u=await l.json();return e({activeProviderId:u.activeProviderId,model:u.model,backend:u.backend,providers:a.map(c=>({...c,isActive:c.id===u.activeProviderId})),activating:!1}),!0}catch(l){return e({error:l instanceof Error?l.message:"Failed to switch provider",activating:!1}),!1}},setDefaultModel:async(n,r)=>{const{providers:a}=t();try{const l=await we("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!l.ok)return!1;const u=await l.json();return e({activeProviderId:n,model:r,defaultModelSelection:u.defaultModelSelection,providers:a.map(c=>({...c,isActive:c.id===n}))}),!0}catch{return!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const r=await we(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const u=await r.json();throw new Error(u.error??"Failed to refresh models")}const a=await r.json(),{providers:l}=t();return e({providers:l.map(u=>u.id===n?{...u,models:a.models,status:a.status}:u),activating:!1}),!0}catch(r){return e({error:r instanceof Error?r.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:r}=t();if(n)return;const a=setInterval(()=>{r()},eN);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(a=>a.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:a}=t(),l=r.find(c=>c.id===a);if(!l)return 2e5;const u=l.models.find(c=>c.id===n);return(u==null?void 0:u.contextWindow)??2e5}})),Ht=Hn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await we("/api/projects")).json();e({projects:r.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,r)=>{try{const a=await we("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});if(!a.ok){const u=await a.json().catch(()=>({}));return{error:{code:u.code||"UNKNOWN",path:u.path,message:u.error}}}const l=await a.json();return await t().listProjects(),l.project}catch{return null}},loadProject:async n=>{try{const r=await we(`/api/projects/${n}`);if(!r.ok)return null;const a=await r.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,r)=>{var a;try{const l=await we(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!l.ok)return null;const u=await l.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:u.project}),await t().listProjects(),u.project}catch{return null}},deleteProject:async n=>{var r;try{return(await we(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((r=t().currentProject)==null?void 0:r.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,r)=>{var a;try{const l=await we(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});if(!l.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const u=await l.json();e({currentProject:u.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),ci=async(e,t,n)=>{try{const r=await we(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"}}},fd=async(e,t,n)=>{try{const r=await we(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function n1(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let uu=[];const vl=Hn()((e,t)=>{function n(){if(uu.length===0)return;const a=uu;uu=[],e(l=>{const u={...l.logs};for(const c of a){const d=u[c.processId]??[];u[c.processId]=[...d,{offset:d.length,content:c.content,timestamp:Date.now(),stream:c.stream}]}return{logs:u}})}const r=n1(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(l=>({processes:[...l.processes,a]})),updateProcess:(a,l)=>e(u=>({processes:u.processes.map(c=>c.id===a?{...c,...l}:c)})),removeProcess:a=>e(l=>({processes:l.processes.filter(u=>u.id!==a),logs:Object.fromEntries(Object.entries(l.logs).filter(([u])=>u!==a))})),stopProcess:async(a,l)=>{try{(await we(`/api/sessions/${l}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,l,u)=>{uu.push({processId:a,stream:l,content:u}),r()},setLogs:(a,l)=>e(u=>({logs:{...u.logs,[a]:l}})),clearLogs:a=>e(l=>({logs:{...l.logs,[a]:[]}})),handleMessage:(a,l)=>{switch(a){case"backgroundProcess.started":{const{processId:u,name:c,pid:d,status:f}=l;e(p=>({processes:[...p.processes,{id:u,sessionId:"",name:c,command:"",cwd:"",pid:d,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const u=l.processId,c=l.stream,d=l.content;t().appendLog(u,c,d);break}case"backgroundProcess.exited":{const u=l.processId,c=l.exitCode;e(d=>({processes:d.processes.map(f=>f.id===u?{...f,status:"exited",exitCode:c}:f)}));break}case"backgroundProcess.removed":{const u=l.processId;t().removeProcess(u);break}}}}}),tN={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Iu=null;function nN(e){Iu=e}function Ii(){return tN}function am(){Iu==null||Iu()}let du=[];const Gr=Hn()((e,t)=>{function n(){if(du.length===0)return;const a=du;du=[],e(l=>({logs:[...l.logs,...a]}))}const r=n1(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:a=>{t().workdir!==a&&(e({workdir:a,status:null,logs:[],config:null,loading:!0}),a&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const a=t().workdir;if(a)try{const u=await(await we(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:u,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const u=await(await we(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:u.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const c=(await(await we(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content}));e({logs:c})}catch{}},start:async()=>{const a=t().workdir;if(a)try{const u=await(await we(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const u=await(await we(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const u=await(await we(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:u,logs:[]})}catch{}},saveConfig:async a=>{const l=t().workdir;if(l)try{const c=await(await we(`/api/dev-server/config?workdir=${encodeURIComponent(l)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:c.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const l=t().workdir;if(l)switch(a.type){case"devServer.output":{const u=a.payload;if(u.workdir!==l)return;du.push({stream:u.stream,content:u.content}),r();break}case"devServer.state":{const u=a.payload;if(u.workdir!==l)return;e(c=>({status:c.status?{...c.status,state:u.state,errorMessage:u.errorMessage,...u.url!==void 0?{url:u.url}:{},...u.inspectProxyPort!==void 0?{inspectProxyPort:u.inspectProxyPort}:{}}:{state:u.state,url:u.url??null,hotReload:!1,config:null,errorMessage:u.errorMessage,inspectProxyPort:u.inspectProxyPort??null}}));break}}}}}),rN=[{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"}],sN=[{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"}],r1={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"},si={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},s1={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},sp={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...si},waiting_for_user:{...si},phase_done:{...si},phase_blocked:{...si},new_message:{...s1}},agentOverrides:{}};function i1(e,t,n){var l;const r=e.events[t];if(!n)return r;const a=(l=e.agentOverrides[n])==null?void 0:l[t];return a?{soundEnabled:a.soundEnabled??r.soundEnabled,browserNotification:a.browserNotification??r.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:r.customSoundUrl}:r}const Mi=Hn((e,t)=>({settings:sp,loaded:!1,load:()=>{Gt.getState().getSetting(De.NOTIFICATION_SETTINGS);const r=Gt.subscribe(l=>{const u=l.settings[De.NOTIFICATION_SETTINGS];if(u!==void 0)try{const c=JSON.parse(u);e({settings:i_(c),loaded:!0})}catch{e({loaded:!0})}}),a=Gt.getState().settings[De.NOTIFICATION_SETTINGS];if(a)try{const l=JSON.parse(a);e({settings:i_(l),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),om(n)},updateEvent:(n,r)=>{const a=t().settings,l={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:l}),om(l)},updateAgentOverride:(n,r,a)=>{var d;const l=t().settings,u={...l.agentOverrides};if(a===null){if(u[n]){const f={...u[n]};delete f[r],Object.keys(f).length===0?delete u[n]:u[n]=f}}else u[n]={...u[n],[r]:{...((d=u[n])==null?void 0:d[r])??{},...a}};const c={...l,agentOverrides:u};e({settings:c}),om(c)}}));function om(e){Gt.getState().setSetting(De.NOTIFICATION_SETTINGS,JSON.stringify(e))}function i_(e){var t,n,r,a,l;return{soundEnabled:e.soundEnabled??sp.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??sp.browserNotificationEnabled,events:{complete:{...si,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...si,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...si,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...si,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...s1,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const a_=new Map;function iN(e){let t=a_.get(e);return t||(t=new Audio(Cs(e)),t.volume=.5,a_.set(e,t)),t}let a1=typeof Notification<"u"?Notification.permission:"denied";function aN(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(a1=e,e))}const oN={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},lN={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 cN(e){typeof Notification>"u"||a1==="granted"&&(document.hasFocus()||new Notification(oN[e],{body:lN[e],icon:Cs("/fox.svg"),tag:`openfox-${e}`}))}function $l(e,t){const{settings:n}=Mi.getState(),r=i1(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??r1[e],l=iN(a);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&cN(e)}const uN=e=>$l("complete",e),dN=e=>$l("phase_done",e),hN=e=>$l("phase_blocked",e),lm=e=>$l("waiting_for_user",e),fN=e=>$l("new_message",e),o_=new Map;function Fa(e,t){var l;const n=t===((l=e.currentSession)==null?void 0:l.id)?e.currentSession:null,r=e.sessions.find(u=>u.id===t),a=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function mN(e,t){if(e.type==="chat.done"){const n=e.payload,r=Fa(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&uN(a),n.reason==="waiting_for_user"&&lm(a);return}if(e.type==="chat.path_confirmation"){const n=Fa(t,e.sessionId);lm(n);return}if(e.type==="session.confirmation_pending"){const n=Fa(t,e.sessionId);lm(n);return}if(e.type==="task.completed"){const n=Fa(t,e.sessionId);dN(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=o_.get(e.sessionId)??null;if(o_.set(e.sessionId,n.phase),r===n.phase)return;const a=Fa(t,e.sessionId);n.phase==="blocked"&&hN(a)}}const cm=new Set;function dn(e,t){return t!==null&&e.sessionId===t}function pN(e,t,n){return e.id!==void 0||dn(e,t)||n===!0&&e.sessionId!==void 0}function gN(e,t){return e.includes(t)?e:[...e,t]}function l_(e,t){return e.filter(n=>n!==t)}function xN(e,t){const n=e.find(l=>l.id===t.id),r=t.messageCount??t.messages.length,a=n?{...n,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length,messageCount:r};return n?e.map(l=>l.id===t.id?a:l):[a,...e]}function um(e,t){const n=e.findIndex(r=>r.callId===t.callId);if(n>=0){const r=[...e];return r[n]=t,r}return[...e,t]}function yN(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,l=t.find(u=>u.id===r.id);return{...r,title:r.title??(l==null?void 0:l.title),mode:(a==null?void 0:a.mode)??(l==null?void 0:l.mode)??r.mode,phase:(a==null?void 0:a.phase)??(l==null?void 0:l.phase)??r.phase,isRunning:r.isRunning&&(l==null?void 0:l.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function c_(e,t,n,r){var c;const a=e.sessionId,l=(c=n().currentSession)==null?void 0:c.id,u=a&&a!==l;if(t(d=>({sessions:d.sessions.map(f=>f.id===a?r(f):f)})),!u){const d=n().currentSession;if(d){const f=r(d);t(()=>({currentSession:f}))}}}function u_(e,t,n){var c,d,f,p,m,x,y,w,C,_,S,b,v,E,j,T,D,L,O,M,W,z;const r=n();mN(e,r);const a=((c=r.currentSession)==null?void 0:c.id)??null,l=()=>{const R=e.sessionId;!R||R===a||t(P=>({unreadSessionIds:gN(P.unreadSessionIds,R)}))},u=(R,P,V)=>({messages:R.messages.map(G=>G.id===P?V(G):G)});switch(e.type){case"session.state":{const R=e.payload;if(!pN(e,a,r.pendingSessionCreate))break;const P=n().pendingSessionCreate===!0,V=R.pendingConfirmations??[],G=R.session.id,Z={...n().crossSessionConfirmations};delete Z[G],t({currentSession:R.session,sessions:xN(n().sessions,R.session),unreadSessionIds:l_(n().unreadSessionIds,G),messages:R.messages,hiddenCount:R.hiddenCount??0,currentTodos:[],pendingPathConfirmations:V,crossSessionConfirmations:Z,sessionsWithPendingConfirmations:Object.keys(Z),pendingQuestions:R.pendingQuestions??[],...P?{pendingSessionCreate:R.session.id}:{}});break}case"session.list":{const R=e.payload;t(P=>({sessions:yN(R.sessions,P.sessions,P.currentSession)}));break}case"session.created":{const R=e.payload;t(P=>({sessions:P.sessions.some(V=>V.id===R.session.id)?P.sessions.map(V=>V.id===R.session.id?{...V,...R.session}:V):[R.session,...P.sessions]}));break}case"session.deleted":{const R=e.payload;t(P=>({unreadSessionIds:l_(P.unreadSessionIds,R.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const R=e.payload;c_(e,t,n,P=>({...P,isRunning:R.isRunning})),R.isRunning||t({abortInProgress:!1,queuedMessages:[]}),R.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!dn(e,((d=n().currentSession)==null?void 0:d.id)??null)){l();break}const R=e.payload;t(P=>{if(P.messages.some(G=>G.id===R.message.id))return P;const V=R.message.role==="user";return{messages:[...P.messages,R.message],sessions:P.sessions.map(G=>G.id===e.sessionId&&V?{...G,messageCount:G.messageCount+1}:G)}});break}case"chat.message_updated":{if(!dn(e,((f=n().currentSession)==null?void 0:f.id)??null)){l();break}const R=e.payload,P=n().messages.find(V=>V.id===R.messageId);R.updates.isStreaming===!1&&(P==null||P.isStreaming),t(V=>({messages:V.messages.map(G=>G.id===R.messageId?{...G,...R.updates}:G)}));break}case"chat.delta":{if(!dn(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const R=e.payload;if(!cm.has(R.messageId)){cm.add(R.messageId);const V=R.subAgentType?"sub-agent":Fa(n(),e.sessionId);fN(V)}const P=Ii();P.messageId=R.messageId,P.deltaContent+=R.content,am();break}case"chat.thinking":{if(!dn(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const R=e.payload,P=Ii();P.messageId=R.messageId,P.thinkingContent+=R.content,am();break}case"chat.tool_preparing":{if(!dn(e,((x=n().currentSession)==null?void 0:x.id)??null)){l();break}const R=e.payload;t(P=>{var I;const V=P.messages.find($=>$.id===R.messageId);if(!V)return{};if((I=V.toolCalls)==null?void 0:I.find(($,q)=>q===R.index))return{};const Z=V.preparingToolCalls??[],Q=Z.findIndex($=>$.index===R.index);let U;return Q>=0?U=Z.map(($,q)=>q===Q?{...$,arguments:R.arguments}:$):U=[...Z,{index:R.index,name:R.name,...R.arguments?{arguments:R.arguments}:{}}],{messages:P.messages.map($=>$.id===R.messageId?{...$,preparingToolCalls:U}:$)}});break}case"chat.tool_call":{if(!dn(e,((y=n().currentSession)==null?void 0:y.id)??null)){l();break}const R=e.payload,P=V=>{var I;const G=(V.toolCalls??[]).length,Z=(I=V.preparingToolCalls)==null?void 0:I.filter($=>$.index!==G),Q=Ii(),U=Q.toolOutput.filter($=>$.callId===R.callId);return U.length>0&&(Q.toolOutput=Q.toolOutput.filter($=>$.callId!==R.callId)),{...V,toolCalls:[...V.toolCalls??[],{id:R.callId,name:R.tool,arguments:R.args,startedAt:Date.now(),...U.length>0?{streamingOutput:U.map($=>({stream:$.stream,content:$.content,timestamp:Date.now()}))}:{}}],...Z&&Z.length>0?{preparingToolCalls:Z}:{preparingToolCalls:void 0}}};t(V=>u(V,R.messageId,P));break}case"chat.tool_output":{if(!dn(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const R=e.payload,P=Ii();P.messageId=R.messageId,P.toolOutput.push({messageId:R.messageId,callId:R.callId,stream:R.stream,content:R.output}),am();break}case"chat.tool_result":{if(!dn(e,((C=n().currentSession)==null?void 0:C.id)??null)){l();break}const R=e.payload,P=V=>{var Z;const G=(Z=V.toolCalls)==null?void 0:Z.map(Q=>Q.id===R.callId?{...Q,result:R.result}:Q);return{...V,toolCalls:G}};t(V=>u(V,R.messageId,P));break}case"chat.vision_fallback":{if(!dn(e,((_=n().currentSession)==null?void 0:_.id)??null)){l();break}const R=e.payload;t(P=>{const V=`${R.messageId}-${R.attachmentId}`,G={...P.visionFallbackByMessage};return G[V]={type:R.type,attachmentId:R.attachmentId,filename:R.filename,description:R.description},{visionFallbackByMessage:G}});break}case"chat.todo":{if(!dn(e,((S=n().currentSession)==null?void 0:S.id)??null)){l();break}const R=e.payload;t({currentTodos:R.todos});break}case"chat.progress":{if(!dn(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const R=e.payload;console.warn("Progress:",R.message,R.phase);break}case"chat.format_retry":{if(!dn(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const R=e.payload;console.warn("Format retry:",R.attempt,"/",R.maxAttempts);break}case"chat.done":{if(!dn(e,((E=n().currentSession)==null?void 0:E.id)??null)){l();break}const R=Ii();R.messageId=null,R.deltaContent="",R.thinkingContent="",R.toolOutput=[],cm.delete(e.payload.messageId);const P=e.payload,V=P.stats;t(G=>({messages:G.messages.map(Z=>Z.id===P.messageId?{...Z,isStreaming:!1,stats:V??Z.stats,completeReason:P.reason,preparingToolCalls:void 0}:Z),visionFallbackByMessage:{}}));break}case"chat.error":{if(!dn(e,((j=n().currentSession)==null?void 0:j.id)??null)){l();break}const R=Ii(),P=e.payload;console.error("Chat error:",P.error,"recoverable:",P.recoverable),P.recoverable||(R.messageId=null,R.deltaContent="",R.thinkingContent="",R.toolOutput=[]),t(V=>({error:{code:"CHAT_ERROR",message:P.error},...P.recoverable?{}:{messages:V.messages}}));break}case"chat.path_confirmation":{const R=e.sessionId,P=R===(((T=n().currentSession)==null?void 0:T.id)??null),V=e.payload,G={callId:V.callId,tool:V.tool,paths:V.paths,workdir:V.workdir,reason:V.reason};if(!P){l(),R&&t(Z=>({crossSessionConfirmations:{...Z.crossSessionConfirmations,[R]:um(Z.crossSessionConfirmations[R]??[],G)},sessionsWithPendingConfirmations:Z.sessionsWithPendingConfirmations.includes(R)?Z.sessionsWithPendingConfirmations:[...Z.sessionsWithPendingConfirmations,R]}));break}t(Z=>({pendingPathConfirmations:um(Z.pendingPathConfirmations,G)}));break}case"session.confirmation_pending":{const R=e.sessionId,P=e.payload,V={callId:P.callId,tool:P.tool,paths:P.paths,workdir:P.workdir,reason:P.reason};R&&t(G=>({crossSessionConfirmations:{...G.crossSessionConfirmations,[R]:um(G.crossSessionConfirmations[R]??[],V)},sessionsWithPendingConfirmations:G.sessionsWithPendingConfirmations.includes(R)?G.sessionsWithPendingConfirmations:[...G.sessionsWithPendingConfirmations,R]}));break}case"session.confirmation_resolved":{const R=e.sessionId,P=e.payload;R&&t(V=>{const Z=(V.crossSessionConfirmations[R]??[]).filter(U=>U.callId!==P.callId),Q={...V.crossSessionConfirmations};return Z.length===0?delete Q[R]:Q[R]=Z,{crossSessionConfirmations:Q,sessionsWithPendingConfirmations:Object.keys(Q)}});break}case"chat.ask_user":{if(!dn(e,((D=n().currentSession)==null?void 0:D.id)??null)){l();return}const R=e.payload,P={callId:R.callId,question:R.question,type:R.type??"text",options:R.options??void 0};t(V=>({pendingQuestions:[...V.pendingQuestions.filter(G=>G.callId!==R.callId),P]}));break}case"mode.changed":{if(!dn(e,((L=n().currentSession)==null?void 0:L.id)??null)){l();break}const R=e.payload;t(P=>({currentSession:P.currentSession?{...P.currentSession,mode:R.mode}:null}));break}case"phase.changed":{const R=e.payload;c_(e,t,n,P=>({...P,phase:R.phase}));break}case"criteria.updated":{if(!dn(e,((O=n().currentSession)==null?void 0:O.id)??null)){l();break}const R=e.payload;t(P=>({currentSession:P.currentSession?{...P.currentSession,criteria:R.criteria}:null}));break}case"metadata.updated":{if(!dn(e,((M=n().currentSession)==null?void 0:M.id)??null)){l();break}const R=e.payload;t(P=>({currentSession:P.currentSession?{...P.currentSession,metadataEntries:{...P.currentSession.metadataEntries,[R.key]:R.entries}}:null}));break}case"context.state":{const R=e.payload,P=dn(e,((W=n().currentSession)==null?void 0:W.id)??null);R.subAgentId?P&&n().updateSubAgentContextState(R.subAgentId,R.context):P?t({contextState:R.context}):l();break}case"session.name_generated":{const R=e.payload,P=e.sessionId,V=(z=n().currentSession)==null?void 0:z.id;t(G=>{const Z=G.sessions.map(U=>U.id===P?{...U,title:R.name,updatedAt:new Date().toISOString()}:U),Q=V===P?G.currentSession?{...G.currentSession,title:R.name,updatedAt:new Date().toISOString()}:null:G.currentSession;return{sessions:Z,currentSession:Q}});break}case"queue.state":{const R=e.payload;t({queuedMessages:R.messages??[]});break}case"mcp.servers.changed":{window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const R=e.payload;t({gitStatus:{branch:R.branch,diff:R.diff}});break}case"devServer.output":case"devServer.state":{Gr.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{vl.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}});break}}}let al=!1,Hr=null;const dm=new Set,hu=new Map;function d_(e,t,n){return e==null?void 0:e.map(r=>{const a=t.filter(l=>l.callId===r.id);return a.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...a.map(l=>({stream:l.stream,content:l.content,timestamp:Date.now()}))]})})}async function h_(e,t,n,r,a){try{const u=await(await we(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();u.queueState&&a({queuedMessages:u.queueState})}catch(l){console.error("Error queueing message:",l)}}const Re=Hn((e,t)=>(nN(()=>{const n=Ii();if(!n.messageId)return;const r=n.deltaContent.length>0,a=n.thinkingContent.length>0,l=n.toolOutput.length>0;if(!r&&!a&&!l)return;const u=n.deltaContent,c=n.thinkingContent,d=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(f=>{const p=f.messages.find(m=>m.id===n.messageId);if(p){const m={...p};if(r&&(m.content=m.content+u),a&&(m.thinkingContent=(m.thinkingContent??"")+c),l){const x=new Set;m.toolCalls=d_(m.toolCalls,d,x);const y=d.filter(w=>!x.has(w.callId));y.length>0&&n.toolOutput.push(...y)}return{messages:f.messages.map(x=>x.id===n.messageId?m:x)}}if(l){const m=new Set,x=f.messages.map(w=>w.id!==n.messageId?w:{...w,toolCalls:d_(w.toolCalls,d,m)}),y=d.filter(w=>!m.has(w.callId));return y.length>0&&n.toolOutput.push(...y),{messages:x}}return f})}),{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],crossSessionConfirmations:{},sessionsWithPendingConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,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 we("/api/auth")).json()).requiresAuth}catch{}if(r&&!Xt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Xt.onStatusChange(a=>{var l;if(e({connectionStatus:a}),a==="connected"){t().listSessions(void 0),Ht.getState().listProjects();const u=(l=t().currentSession)==null?void 0:l.id;u&&t().loadSession(u)}});try{await Xt.connect(),al||(al=!0,Hr=Xt.subscribe(a=>{u_(a,e,t)}))}catch(a){console.error("Failed to connect:",a);const l=Xt.getLastCloseCode();if(!Xt.hasToken()&&(l===1006||l===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Hr&&(Hr(),Hr=null),al=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Xt.disconnect(),Hr&&(Hr(),Hr=null),al=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Xt.disconnect(),Hr&&(Hr(),Hr=null),al=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async n=>{try{const r=await fetch(Cs("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:n})});if(!r.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:a}=await r.json();Xt.setToken(a),e({showPasswordModal:!1}),t().connect();const{listProjects:l}=Ht.getState(),{fetchConfig:u}=Qt.getState();l(),u(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Xt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,r)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const l=await we("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,title:r})});if(!l.ok)return e({pendingSessionCreate:!1}),null;const u=await l.json();try{Xt.send("session.load",{sessionId:u.session.id})}catch{}return u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!dm.has(n)){dm.add(n);try{const r=t().currentSession;if(!r||r.id!==n){const d=r==null?void 0:r.id,f=t().pendingPathConfirmations,m={...t().crossSessionConfirmations};d&&f.length>0&&(m[d]=[...m[d]??[],...f]),e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(x=>x!==n),subAgentContextStates:{},messages:[],currentTodos:[],contextState:null,pendingPathConfirmations:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,gitStatus:null,pendingSessionCreate:!1,crossSessionConfirmations:m,sessionsWithPendingConfirmations:Object.keys(m)})}else e({unreadSessionIds:t().unreadSessionIds.filter(d=>d!==n)});const a=await we(`/api/sessions/${n}`);if(!a.ok)return;const l=await a.json(),u=l.messages??[],c={...t().crossSessionConfirmations};delete c[n],e({currentSession:l.session,messages:u,hiddenCount:l.hiddenCount??0,contextState:l.contextState,queuedMessages:l.queueState??[],pendingPathConfirmations:l.pendingConfirmations??[],pendingQuestions:l.pendingQuestions??[],crossSessionConfirmations:c,sessionsWithPendingConfirmations:Object.keys(c)}),Xt.send("session.load",{sessionId:n});try{const d=await we(`/api/sessions/${n}/background-processes`);if(d.ok){const f=await d.json();vl.getState().setProcesses(f.processes??[])}}catch{}}catch{}finally{dm.delete(n)}}},listSessions:async(n,r=20)=>{const a=n??"global";if(hu.has(a))return hu.get(a);const l=(async()=>{var u;try{const c=new URLSearchParams;c.set("limit",String(r)),n&&c.set("projectId",n);const f=await(await we(`/api/sessions?${c.toString()}`)).json(),p=f.sessions??[];e(x=>({sessions:p.map(y=>{var C,_;const w=x.sessions.find(S=>S.id===y.id);return{...y,title:y.title??(w==null?void 0:w.title),mode:((C=x.currentSession)==null?void 0:C.id)===y.id?x.currentSession.mode:(w==null?void 0:w.mode)??y.mode,phase:((_=x.currentSession)==null?void 0:_.id)===y.id?x.currentSession.phase:(w==null?void 0:w.phase)??y.phase,isRunning:y.isRunning&&(w==null?void 0:w.isRunning)!==!1,messageCount:y.messageCount,recentUserPrompts:y.recentUserPrompts}}),sessionsHasMore:n?f.hasMore??!1:!0}));const m=f.pendingConfirmationsBySession;if(m){const x=(u=t().currentSession)==null?void 0:u.id,y={};for(const[w,C]of Object.entries(m))w!==x&&(y[w]=C);e({crossSessionConfirmations:y,sessionsWithPendingConfirmations:Object.keys(y)})}}catch{}finally{hu.delete(a)}})();return hu.set(a,l),l},loadMoreSessions:async n=>{const r=t();if(!(r.sessionsPaginationLoading||!r.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const a=new URLSearchParams;a.set("limit","20"),a.set("offset",String(r.sessions.length)),a.set("projectId",n);const u=await(await we(`/api/sessions?${a.toString()}`)).json(),c=u.sessions??[];e(d=>({sessions:[...d.sessions,...c.map(f=>{const p=d.sessions.find(m=>m.id===f.id);return(p==null?void 0:p.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:u.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var r;try{return(await we(`/api/sessions/${n}`,{method:"DELETE"})).ok?(await t().listSessions(),((r=t().currentSession)==null?void 0:r.id)===n&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(n,r)=>{var a;try{const l=await we(`/api/sessions/${n}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r})});if(!l.ok)return!1;if(await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===n){const c=await l.json();c.session&&e({currentSession:c.session})}return!0}catch{return!1}},deleteAllSessions:async n=>{try{return(await we(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{e(n=>({currentSession:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,unreadSessionIds:n.currentSession?n.unreadSessionIds.filter(r=>r!==n.currentSession.id):n.unreadSessionIds}))},sendMessage:async(n,r,a)=>{var u;e({error:null});const l=(u=t().currentSession)==null?void 0:u.id;if(l)try{const c=n==null?void 0:n.trim(),d=r&&r.length>0,f={};c&&(f.content=n),d&&(f.attachments=r),a!=null&&a.messageKind&&(f.messageKind=a.messageKind);const m=await(await we(`/api/sessions/${l}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).json();m.queueState&&e({queuedMessages:m.queueState})}catch(c){console.error("Error sending message:",c)}},stopGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n&&!t().abortInProgress){e({abortInProgress:!0});try{const l=await(await we(`/api/sessions/${n}/stop`,{method:"POST"})).json();if(l.queuedMessages&&l.queuedMessages.length>0){const u=l.queuedMessages.map(c=>c.content).join(`
|
|
59
|
+
`);e({restoredInput:u})}}catch(a){console.error("Error stopping generation:",a)}}},continueGeneration:async()=>{var r;const n=(r=t().currentSession)==null?void 0:r.id;if(n)try{await we(`/api/sessions/${n}/continue`,{method:"POST"})}catch(a){console.error("Error continuing generation:",a)}},launchWorkflow:(n,r,a,l)=>{const u={};n!=null&&n.trim()&&(u.content=n),r&&r.length>0&&(u.attachments=r),a&&(u.workflowId=a),l&&(u.subGroup=l),Xt.send("runner.launch",u)},switchMode:async n=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{const l=await we(`/api/sessions/${r}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:n})});if(!l.ok){console.error("Failed to switch mode:",await l.json());return}const u=await l.json();u.session&&e({currentSession:u.session}),u.messages&&e({messages:u.messages,hiddenCount:u.hiddenCount??0})}catch(l){console.error("Error switching mode:",l)}},switchDangerLevel:async n=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{const l=await we(`/api/sessions/${r}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:n})});if(!l.ok){console.error("Failed to switch danger level:",await l.json());return}const u=await l.json();u.session&&e({currentSession:u.session})}catch(l){console.error("Error switching danger level:",l)}},editCriteria:async n=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{const l=await we(`/api/sessions/${r}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:n})});l.ok||console.error("Failed to update criteria:",await l.json())}catch(l){console.error("Error updating criteria:",l)}},compactContext:()=>{Xt.send("context.compact",{})},setSessionProvider:async(n,r)=>{var a;try{const l=(a=t().currentSession)==null?void 0:a.id;if(!l)return null;const u=await we(`/api/sessions/${l}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...r?{model:r}:{}})});if(!u.ok)return null;const c=await u.json();return e({currentSession:c.session,messages:c.messages??[],hiddenCount:c.hiddenCount??0,contextState:c.contextState}),c.session}catch{return null}},updateContextState:n=>{e({contextState:n})},updateSubAgentContextState:(n,r)=>{e(a=>({subAgentContextStates:{...a.subAgentContextStates,[n]:r}}))},clearSubAgentContextState:n=>{e(r=>{const a={...r.subAgentContextStates};return delete a[n],{subAgentContextStates:a}})},confirmPath:async(n,r,a=!1)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;if(l)try{const c=await we(`/api/sessions/${l}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:r,alwaysAllow:a})});if(!c.ok){const d=await c.json().catch(()=>({}));console.error("Error confirming path:",d.error??`HTTP ${c.status}`)}}catch(c){console.error("Error confirming path:",c)}},answerQuestion:async(n,r,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;if(l){try{await we(`/api/sessions/${l}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:r,skip:a})})}catch(c){console.error("Error answering question:",c)}e(c=>({pendingQuestions:c.pendingQuestions.filter(d=>d.callId!==n)}))}},queueAsap:async(n,r,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await h_(l,n,r,a,e)},queueCompletion:async(n,r,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await h_(l,n,r,a,e)},cancelQueued:async n=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{const u=await(await we(`/api/sessions/${r}/queue/${n}`,{method:"DELETE"})).json();u.queueState&&e({queuedMessages:u.queueState})}catch(l){console.error("Error canceling queued message:",l)}},clearError:()=>{e({error:null})},clearRestoredInput:()=>{e({restoredInput:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{u_(n,e,t)}}));function md(){return Re(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function bN(){return Re(e=>e.abortInProgress)}function vN(){const e=Re(a=>a.connect),t=Re(a=>a.connectionStatus),n=Mi(a=>a.load),r=ro("/p/:projectId/s/:sessionId/readonly")[0];return A.useEffect(()=>{r||e()},[e,r]),A.useEffect(()=>{r||t==="connected"&&n()},[t,n,r]),{connectionStatus:t}}const _N="modulepreload",SN=function(e){return"/"+e},f_={},J=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=u(n.map(f=>{if(f=SN(f),f in f_)return;f_[f]=!0;const p=f.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":_N,p||(x.as="script"),x.crossOrigin="",x.href=f,d&&x.setAttribute("nonce",d),document.head.appendChild(x),p)return new Promise((y,w)=>{x.addEventListener("load",y),x.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function l(u){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=u,window.dispatchEvent(c),!c.defaultPrevented)throw u}return a.then(u=>{for(const c of u||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})},wN=[{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"},{key:"color-text-heading",category:"text",label:"Heading Text",defaultValue:"56 189 248"},{key:"color-text-bold",category:"text",label:"Bold Text",defaultValue:"251 191 36"},{key:"color-text-code",category:"text",label:"Inline Code Text",defaultValue:"88 166 255"},{key:"color-text-link",category:"text",label:"Link Text",defaultValue:"88 166 255"},{key:"color-bg-system",category:"background",label:"System Message Background",defaultValue:"40 35 28"},{key:"color-border-system",category:"border",label:"System Message Border",defaultValue:"65 55 25"},{key:"color-text-system",category:"text",label:"System Message Text",defaultValue:"253 230 138"},{key:"color-text-thinking",category:"text",label:"Thinking Label",defaultValue:"192 132 252"},{key:"color-text-truncated",category:"text",label:"Truncation Warning",defaultValue:"251 191 36"},{key:"color-text-tool-error",category:"text",label:"Tool Error Text",defaultValue:"248 81 73"}],CN=JSON.parse('[{"id":"system","name":"System","tokens":{}},{"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","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"255 255 255","color-text-link":"88 166 255","color-bg-system":"40 35 28","color-border-system":"65 55 25","color-text-system":"253 230 138","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"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","color-text-heading":"2 132 199","color-text-bold":"217 119 6","color-text-code":"37 99 235","color-text-link":"37 99 235","color-bg-system":"254 243 199","color-border-system":"252 211 77","color-text-system":"146 100 30","color-text-thinking":"147 51 234","color-text-truncated":"217 119 6","color-text-tool-error":"220 38 38"},"mode":"light"},{"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","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"248 248 242","color-text-link":"102 217 239","color-bg-system":"62 57 40","color-border-system":"85 75 40","color-text-system":"230 219 116","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"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","color-text-heading":"189 147 249","color-text-bold":"255 184 108","color-text-code":"189 147 249","color-text-link":"189 147 249","color-bg-system":"68 64 50","color-border-system":"90 80 60","color-text-system":"255 184 108","color-text-thinking":"255 121 198","color-text-truncated":"255 184 108","color-text-tool-error":"255 85 85"},"mode":"dark"},{"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":"121 133 160","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":"121 133 160","color-text-heading":"129 161 193","color-text-bold":"235 203 139","color-text-code":"129 161 193","color-text-link":"129 161 193","color-bg-system":"67 62 50","color-border-system":"85 80 60","color-text-system":"235 203 139","color-text-thinking":"184 142 173","color-text-truncated":"235 203 139","color-text-tool-error":"191 97 106"},"mode":"dark"},{"id":"rose-pine-dawn","name":"Rose Pine Dawn","tokens":{"color-bg-primary":"250 244 237","color-bg-secondary":"244 237 228","color-bg-tertiary":"235 226 216","color-primary":"250 244 237","color-secondary":"244 237 228","color-text-primary":"87 82 95","color-text-secondary":"111 105 120","color-text-muted":"175 170 180","color-accent-primary":"215 130 126","color-accent-success":"104 157 153","color-accent-warning":"234 157 84","color-accent-error":"215 85 112","color-border":"230 218 206","color-text-heading":"215 130 126","color-text-bold":"234 157 84","color-text-code":"145 117 186","color-text-link":"215 130 126","color-bg-system":"244 237 228","color-border-system":"230 218 206","color-text-system":"162 137 123","color-text-thinking":"145 117 186","color-text-truncated":"234 157 84","color-text-tool-error":"215 85 112"},"mode":"light"},{"id":"everforest-light","name":"Everforest Light","tokens":{"color-bg-primary":"255 248 235","color-bg-secondary":"245 238 220","color-bg-tertiary":"237 228 208","color-primary":"255 248 235","color-secondary":"245 238 220","color-text-primary":"91 105 86","color-text-secondary":"127 139 116","color-text-muted":"179 181 158","color-accent-primary":"100 153 117","color-accent-success":"141 169 73","color-accent-warning":"224 146 66","color-accent-error":"203 97 80","color-border":"230 216 194","color-text-heading":"100 153 117","color-text-bold":"224 146 66","color-text-code":"146 131 176","color-text-link":"100 153 117","color-bg-system":"245 238 220","color-border-system":"230 216 194","color-text-system":"163 147 121","color-text-thinking":"146 131 176","color-text-truncated":"224 146 66","color-text-tool-error":"203 97 80"},"mode":"light"},{"id":"synthwave-84","name":"Synthwave-84","tokens":{"color-bg-primary":"13 15 26","color-bg-secondary":"20 24 41","color-bg-tertiary":"26 31 51","color-primary":"10 12 20","color-secondary":"20 24 41","color-text-primary":"212 230 255","color-text-secondary":"136 153 187","color-text-muted":"68 85 119","color-accent-primary":"0 229 255","color-accent-success":"0 255 65","color-accent-warning":"255 106 0","color-accent-error":"255 0 60","color-border":"26 51 102","color-text-heading":"0 229 255","color-text-bold":"255 140 0","color-text-code":"0 255 170","color-text-link":"0 229 255","color-bg-system":"26 20 10","color-border-system":"51 40 20","color-text-system":"255 170 80","color-text-thinking":"191 0 255","color-text-truncated":"255 140 0","color-text-tool-error":"255 0 60"},"mode":"dark"},{"id":"one-dark-pro","name":"One Dark Pro","tokens":{"color-bg-primary":"40 44 52","color-bg-secondary":"33 37 43","color-bg-tertiary":"47 52 62","color-primary":"28 31 37","color-secondary":"33 37 43","color-text-primary":"171 178 191","color-text-secondary":"150 155 168","color-text-muted":"92 99 112","color-accent-primary":"97 175 239","color-accent-success":"152 195 121","color-accent-warning":"209 154 102","color-accent-error":"224 108 117","color-border":"57 62 72","color-text-heading":"97 175 239","color-text-bold":"209 154 102","color-text-code":"198 120 221","color-text-link":"97 175 239","color-bg-system":"47 42 32","color-border-system":"68 60 46","color-text-system":"224 190 79","color-text-thinking":"198 120 221","color-text-truncated":"209 154 102","color-text-tool-error":"224 108 117"},"mode":"dark"},{"id":"night-owl","name":"Night Owl","tokens":{"color-bg-primary":"1 22 39","color-bg-secondary":"0 30 55","color-bg-tertiary":"11 41 66","color-primary":"1 20 33","color-secondary":"0 30 55","color-text-primary":"214 222 235","color-text-secondary":"162 176 196","color-text-muted":"82 98 126","color-accent-primary":"130 170 255","color-accent-success":"34 218 110","color-accent-warning":"247 140 108","color-accent-error":"239 83 80","color-border":"30 56 85","color-text-heading":"130 170 255","color-text-bold":"247 140 108","color-text-code":"199 146 234","color-text-link":"130 170 255","color-bg-system":"30 25 20","color-border-system":"60 50 40","color-text-system":"247 199 120","color-text-thinking":"199 146 234","color-text-truncated":"247 140 108","color-text-tool-error":"239 83 80"},"mode":"dark"},{"id":"catppuccin-mocha","name":"Catppuccin Mocha","tokens":{"color-bg-primary":"30 30 46","color-bg-secondary":"24 24 37","color-bg-tertiary":"49 50 68","color-primary":"17 17 27","color-secondary":"24 24 37","color-text-primary":"205 214 244","color-text-secondary":"186 194 222","color-text-muted":"108 112 134","color-accent-primary":"137 180 250","color-accent-success":"166 227 161","color-accent-warning":"249 226 175","color-accent-error":"243 139 168","color-border":"69 71 90","color-text-heading":"137 180 250","color-text-bold":"249 226 175","color-text-code":"203 166 247","color-text-link":"137 180 250","color-bg-system":"37 37 54","color-border-system":"69 71 90","color-text-system":"250 179 135","color-text-thinking":"203 166 247","color-text-truncated":"249 226 175","color-text-tool-error":"243 139 168"},"mode":"dark"},{"id":"rose-pine","name":"Rose Pine","tokens":{"color-bg-primary":"25 23 36","color-bg-secondary":"31 29 46","color-bg-tertiary":"38 35 58","color-primary":"20 18 30","color-secondary":"31 29 46","color-text-primary":"224 222 244","color-text-secondary":"196 194 220","color-text-muted":"110 106 134","color-accent-primary":"235 188 186","color-accent-success":"156 207 216","color-accent-warning":"246 193 119","color-accent-error":"235 111 146","color-border":"44 40 67","color-text-heading":"235 188 186","color-text-bold":"246 193 119","color-text-code":"196 167 231","color-text-link":"235 188 186","color-bg-system":"44 38 36","color-border-system":"60 52 50","color-text-system":"246 193 119","color-text-thinking":"196 167 231","color-text-truncated":"246 193 119","color-text-tool-error":"235 111 146"},"mode":"dark"},{"id":"kanagawa-wave","name":"Kanagawa Wave","tokens":{"color-bg-primary":"31 34 44","color-bg-secondary":"25 28 36","color-bg-tertiary":"42 47 58","color-primary":"25 28 36","color-secondary":"25 28 36","color-text-primary":"220 224 206","color-text-secondary":"188 193 178","color-text-muted":"108 112 99","color-accent-primary":"133 189 168","color-accent-success":"157 198 113","color-accent-warning":"226 190 107","color-accent-error":"227 116 102","color-border":"51 59 72","color-text-heading":"133 189 168","color-text-bold":"226 190 107","color-text-code":"194 160 191","color-text-link":"133 189 168","color-bg-system":"42 38 30","color-border-system":"60 54 44","color-text-system":"226 190 107","color-text-thinking":"194 160 191","color-text-truncated":"226 190 107","color-text-tool-error":"227 116 102"},"mode":"dark"},{"id":"light-plus","name":"Light Plus","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"243 244 245","color-bg-tertiary":"233 235 238","color-primary":"255 255 255","color-secondary":"243 244 245","color-text-primary":"0 0 0","color-text-secondary":"80 80 80","color-text-muted":"140 140 140","color-accent-primary":"0 92 197","color-accent-success":"0 128 0","color-accent-warning":"178 110 0","color-accent-error":"204 0 0","color-border":"217 217 217","color-text-heading":"0 0 0","color-text-bold":"0 0 0","color-text-code":"204 0 0","color-text-link":"0 92 197","color-bg-system":"255 243 207","color-border-system":"255 220 150","color-text-system":"130 80 0","color-text-thinking":"130 50 180","color-text-truncated":"178 110 0","color-text-tool-error":"204 0 0"},"mode":"light"}]'),o1={tokens:wN,presets:CN},l1=o1.tokens,Pn=o1.presets;function m_(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function kN(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const Rt=Hn((e,t)=>{const n=kN();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:m_(),followSystemTheme:!0,isSystem:!1,systemDarkPreset:n.darkPreset,systemLightPreset:n.lightPreset,activeUserPresetId:null,applySavedTheme:()=>{const{getSavedTheme:r,applyPreset:a,applyTokens:l}=t(),u=r();if(u)try{const c=JSON.parse(u);c.preset&&c.tokens?(a(c.preset),e({basePreset:c.preset}),l(c.tokens)):c.preset?a(c.preset):c.tokens&&l(c.tokens)}catch{a("dark")}else a("dark")},applyPreset:r=>{if(Pn.find(l=>l.id===r))if(r==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)"),{systemDarkPreset:u,systemLightPreset:c,userPresets:d}=t(),f=l.matches?u:c,p=d.find(m=>m.id===f);e(p?{basePreset:"system",currentPreset:p.basePreset,customTokens:{...p.tokens},isCustom:!0,isCustomizing:!1,isSystem:!0,activeUserPresetId:p.id}:{basePreset:"system",currentPreset:f,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0,activeUserPresetId:null}),t().applyTheme()}else e({currentPreset:r,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1,activeUserPresetId:null}),t().applyTheme()},startCustomizing:()=>{var l;const{currentPreset:r}=t(),a=((l=Pn.find(u=>u.id===r))==null?void 0:l.tokens)??{};e({basePreset:r,customTokens:{...a},isCustom:!0,isCustomizing:!0})},setCustomToken:(r,a)=>{e(l=>({customTokens:{...l.customTokens,[r]:a}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:r}=t();t().saveTheme(JSON.stringify({tokens:r})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:r=>{e({customTokens:r,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var c,d;const{basePreset:r,customTokens:a,isCustom:l}=t();if(l&&r)return{...((c=Pn.find(p=>p.id===r))==null?void 0:c.tokens)??{},...a};if(l)return{...l1.reduce((f,p)=>({...f,[p.key]:p.defaultValue}),{}),...a};const u=Pn.find(f=>f.id===t().currentPreset);return(u==null?void 0:u.tokens)??((d=Pn[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const r=t().getActiveTheme(),a=document.documentElement;Object.entries(r).forEach(([l,u])=>{a.style.setProperty(`--${l}`,u)})},getSavedTheme:()=>{try{const r=localStorage.getItem("openfox:theme");if(!r)return null;if(r[0]!=="{")return JSON.stringify({preset:r});const a=JSON.parse(r);if(a.preset)return JSON.stringify({preset:a.preset});if(a.tokens)return JSON.stringify({tokens:a.tokens})}catch{return null}return null},saveTheme:async r=>{localStorage.setItem("openfox:theme",r);const{useSettingsStore:a}=await J(async()=>{const{useSettingsStore:l}=await Promise.resolve().then(()=>il);return{useSettingsStore:l}},void 0);await a.getState().setSetting(De.DISPLAY_THEME,r)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:r=>{e({followSystemTheme:r}),J(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>il);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_FOLLOW_SYSTEM_THEME,String(r))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const r=window.matchMedia("(prefers-color-scheme: dark)"),a=u=>{const{followSystemTheme:c,systemDarkPreset:d,systemLightPreset:f}=t();if(!c)return;const p=u?d:f;t().applyPreset(p),t().saveTheme(JSON.stringify({preset:p}))},l=u=>a(u.matches);return r.addEventListener("change",l),()=>r.removeEventListener("change",l)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0,systemDarkPreset:"dark",systemLightPreset:"light",activeUserPresetId:null})},addUserPreset:r=>{const{basePreset:a,customTokens:l,currentPreset:u}=t(),c=a||u,d=Pn.find(m=>m.id===c),f={id:"custom-"+Date.now(),name:r,basePreset:c,mode:d==null?void 0:d.mode,tokens:{...l}},p=[...t().userPresets,f];e({userPresets:p}),t().saveUserPresets()},applyUserPreset:r=>{const a=t().userPresets[r];a&&(e({currentPreset:a.basePreset,basePreset:a.basePreset,customTokens:{...a.tokens},isCustom:!0,isCustomizing:!1,activeUserPresetId:a.id}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:a.basePreset,tokens:a.tokens})).catch(()=>{}))},deleteUserPreset:r=>{const a=t().userPresets.filter((l,u)=>u!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:m_()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),J(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>il);return{useSettingsStore:r}},void 0).then(({useSettingsStore:r})=>{r.getState().setSetting(De.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})},setSystemDarkPreset:r=>{e({systemDarkPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset})),J(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>il);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset}))}),t().isSystem&&t().applyPreset("system")},setSystemLightPreset:r=>{e({systemLightPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r})),J(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>il);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r}))}),t().isSystem&&t().applyPreset("system")}}});function EN({canLoad:e,projectId:t,currentProjectId:n}){const r=Ht(u=>u.loadProject),a=Re(u=>u.listSessions),l=Re(u=>u.clearSession);A.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),l())},[e,t,n,r,a,l])}function jN({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const l=Re(f=>f.loadSession),u=Ht(f=>f.loadProject),c=Re(f=>f.listSessions),d=Re(f=>f.pendingSessionCreate);A.useEffect(()=>{e&&t&&r!==t&&u(t)},[e,t,r,u]),A.useEffect(()=>{e&&n&&a!==n&&l(n),e&&t&&c(t)},[e,n,a,l,c,d,t])}function NN({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function c1({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function TN({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 AN({className:e="w-3 h-3 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 Mu({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.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 Ir({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function Qn({className:e="w-3 h-3 text-text-muted",rotate:t}){return i.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:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function LN({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),i.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function qp({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 u1({className:e="w-3 h-3"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 d1({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("circle",{cx:"12",cy:"5",r:"2"}),i.jsx("circle",{cx:"12",cy:"12",r:"2"}),i.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Kp({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 Kr({className:e="w-5 h-5 text-accent-primary"}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:i.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 DN({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 RN({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 ON({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.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 Yp({className:e="w-3 h-3"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 IN({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 p_({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function h1({className:e="w-[18px] h-[18px]"}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function MN({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.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"}),i.jsx("path",{d:"M9.5 2h4.5v4.5"}),i.jsx("path",{d:"M14 2L7.5 8.5"})]})}function PN({className:e="w-3 h-3",color:t}){return i.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{d:"M8 5v14l11-7z"})})}function ks({className:e="w-3 h-3 text-accent-primary"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function BN({className:e="w-5 h-5"}){return i.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:i.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 pd({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 $N({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.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"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function zN({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return i.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[i.jsx("title",{children:"Running"}),i.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),i.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function f1({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:i.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 m1({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 Xp({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function HN({className:e="w-3.5 h-3.5 shrink-0",color:t}){return i.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:i.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 UN({className:e="w-4 h-4"}){return i.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"4 17 10 11 4 5"}),i.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function so({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 Vi({className:e="w-3.5 h-3.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 FN({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 ip({className:e="w-2.5 h-2.5"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 Es({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:i.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 Qp({className:e="w-4 h-4"}){return i.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:i.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 VN({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 GN({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 g_({className:e="w-3.5 h-3.5 text-text-muted"}){return i.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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 ap(){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 x_(e,t){const n=Xt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:ap(),type:e,payload:t}))}const Lr=Hn((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 we(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const l=Xt.ws;if(l&&l.readyState===WebSocket.OPEN)for(const u of a)l.send(JSON.stringify({id:ap(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await we("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(a.ok){const l=await a.json();e(c=>({sessions:[...c.sessions,l]}));const u=Xt.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:ap(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{x_("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{x_("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await we(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(l=>l.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(a=>{const l=a.sessions.filter(u=>u.id!==r);return l.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:l}});break}}}}));Xt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&Lr.getState().handleMessage(e)});const ws=Hn((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(Cs(`/api/auto-update/check${n?"?force=true":""}`));if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();e({status:a.isUpdateAvailable?"available":"upToDate",current:a.current,latest:a.latest})}catch{e({status:"error"})}}}})),Wr={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},modelSelector:{type:"chord",key:"m",modifiers:["ctrl"]},sessionSearch:{type:"chord",key:"s",modifiers:["ctrl"]},criteriaSidebar:{type:"chord",key:"d",modifiers:["ctrl"]},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 op(e){if(!e)return structuredClone(Wr);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(Wr[r]):t[r];return{terminalToggle:n("terminalToggle"),quickAction:n("quickAction"),modelSelector:n("modelSelector"),sessionSearch:n("sessionSearch"),criteriaSidebar:n("criteriaSidebar"),agentSwitching:n("agentSwitching")}}catch{return structuredClone(Wr)}}function y_(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function Fu(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 WN(e){return e.type==="double-press"}function p1(e){return e.type==="chord"}function qN(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.key.toLowerCase()===t.toLowerCase():t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function g1(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return qN(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===l}function zl(){const e=Gt(t=>t.settings[De.KEYBINDINGS]);return op(e)}function KN(e,t,n){const r=A.useRef(0),a=A.useRef(t);a.current=t,A.useEffect(()=>{if(!e)return;const l=e.threshold??300,u=c=>{if(c.key!==e.key)return;const d=e.key==="Control",f=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!d&&c.ctrlKey||!f&&c.shiftKey||!p&&c.altKey||!m&&c.metaKey)return;const x=Date.now();x-r.current<l?(c.preventDefault(),c.stopPropagation(),a.current(),r.current=0):r.current=x};return window.addEventListener("keydown",u,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",u,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function YN(e,t){const n=A.useRef(t);n.current=t,A.useEffect(()=>{if(!e)return;const r=a=>{g1(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function jl(e,t,n){KN(e&&WN(e)?e:void 0,t,n),YN(e&&p1(e)?e:void 0,t)}function XN(e,t,n){const r=A.useRef(n);r.current=n,A.useEffect(()=>{const a=l=>{for(let u=0;u<e.length;u++){const c=e[u];if(!c)continue;const d=t[u];if(d&&p1(c)&&g1(l,c)){l.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var io=VS();const gd=A.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},a)=>i.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));gd.displayName="IconButton";const QN="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",Gi=A.forwardRef((e,t)=>i.jsx(gd,{ref:t,icon:QN,title:"Edit",...e}));Gi.displayName="EditButton";const JN="M6 18L18 6M6 6l12 12",Jp=A.forwardRef((e,t)=>i.jsx(gd,{ref:t,icon:JN,...e}));Jp.displayName="CloseButton";const ZN={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 wt({label:e,title:t,headerRight:n,size:r="md",minHeight:a,children:l,footer:u,className:c,onClose:d,isOpen:f,closeOnBackdropClick:p=!0,closeOnEscape:m=!0,showCloseButton:x=!0,scrollable:y=!0}){const[w,C]=A.useState(!1),_=f!==void 0,S=_?f:w,b=A.useCallback(()=>{_||C(!0)},[_]),v=A.useCallback(()=>{_||C(!1),d==null||d()},[_,d]);A.useEffect(()=>{if(!S||!m)return;const j=T=>{if(T.key==="Escape"){const D=document.activeElement;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"))return;T.stopPropagation(),v()}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[S,v,m]);const E=e&&(typeof e=="string"?i.jsx("button",{type:"button",onClick:b,className:c,children:e}):i.jsx("span",{onClick:b,className:c,style:{cursor:"pointer"},children:e}));return i.jsxs(i.Fragment,{children:[E,S&&(typeof document<"u"?io.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p?v:void 0}),i.jsxs("div",{role:"dialog",className:`relative w-full ${ZN[r]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||x)&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&i.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),i.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[n,x&&i.jsx(Jp,{onClick:v,"aria-label":"Close"})]})]}),i.jsx("div",{className:`p-4 flex-1 min-h-0${y?" overflow-y-auto":" overflow-hidden flex flex-col"}`,style:a?{minHeight:a}:void 0,children:l}),u&&i.jsx("div",{className:"px-4 py-3 border-t border-border",children:u})]})]}),document.body):null)]})}function eT({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return i.jsxs("div",{className:"relative",children:[i.jsx("select",{value:a,disabled:n,onChange:l=>{const u=l.target.value;r(u===t?null:u)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:sN.map(({url:l,label:u})=>i.jsx("option",{value:l,title:u,children:u.split(" ")[0]},l))}),i.jsx(Qn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const b_=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function tT(){const e=Mi(d=>d.settings),t=Mi(d=>d.update),n=Mi(d=>d.updateEvent),r=Mi(d=>d.updateAgentOverride),a=Mi(d=>d.load);A.useEffect(()=>{a()},[a]);const l=async()=>{await aN()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(d,f,p,m)=>{d==="general"?n(f,{[p]:m}):r(d,f,{[p]:m})},c=(d,f,p)=>{d==="general"?n(f,{customSoundUrl:p}):r(d,f,{customSoundUrl:p})};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),i.jsx(v_,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),i.jsx(v_,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:d=>{d&&typeof Notification<"u"&&Notification.permission!=="granted"?l():t({...e,browserNotificationEnabled:d})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&i.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),i.jsx("div",{className:"border border-border rounded overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:i.jsxs("tr",{className:"border-b border-border",children:[i.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),b_.map(d=>i.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),i.jsx("tbody",{children:rN.map(d=>i.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[i.jsx("td",{className:"px-3 py-2",children:i.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),b_.map(f=>{const p=i1(e,d.key,f.key==="general"?void 0:f.key),m=r1[d.key];return i.jsx("td",{className:"px-2 py-2 align-top",children:i.jsxs("div",{className:"flex flex-col items-center gap-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:i.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:x=>u(f.key,d.key,"soundEnabled",x.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),i.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:i.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:x=>u(f.key,d.key,"browserNotification",x.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&i.jsx(eT,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:x=>c(f.key,d.key,x)})]})},f.key)})]},d.key))})]})})]})]})}function v_({label:e,description:t,checked:n,onChange:r}){return i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),i.jsx("div",{className:"flex-shrink-0 pt-0.5",children:i.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),r(!n)},children:i.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"}`})})})]})}const Je=A.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...a},l)=>{const u="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",c={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"},d={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return i.jsx("button",{ref:l,className:`${u} ${c[e]} ${d[t]} ${n}`,...a,children:r})});Je.displayName="Button";async function __(e,t,n){try{const r=await we(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}const Tn=Hn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,fetchSkills:async()=>{e({loading:!0});try{const r=await(await we("/api/skills")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],items:r.items??[],selectedDirectory:r.selectedDirectory??null,diagnostics:r.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await we(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(l=>({defaults:l.defaults.map(u=>u.id===n?{...u,enabled:a.enabled}:u),userItems:l.userItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u),projectItems:l.projectItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u),items:l.items.map(u=>u.id===n?{...u,enabled:a.enabled}:u)}))}catch{}},fetchSkill:async n=>{try{const r=await we(`/api/skills/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await we(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await ci("POST","/api/skills",{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await ci("PUT",`/api/skills/${n}`,r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await we(`/api/skills/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,r)=>fd(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),r),selectDirectory:async n=>__("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await we("/api/skills/library",{method:"DELETE"}),await t().fetchSkills()},installSkill:async n=>{const r=new FormData;r.append("packageName",n.packageName),r.append("paths",JSON.stringify(n.files.map(a=>a.path)));for(const a of n.files)r.append("files",a.file,a.file.name);return __("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function Hl(){const[e,t]=A.useState({id:null,type:null}),n=A.useCallback(l=>t({id:l,type:"delete"}),[]),r=A.useCallback(()=>t({id:null,type:null}),[]),a=A.useCallback((l,u)=>e.id===l&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function Zp({onConfirm:e,onCancel:t}){return i.jsxs("div",{className:"flex items-center gap-1",children:[i.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"}),i.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 eg({onClick:e}){return i.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:i.jsx(so,{})})}function Vu({onClick:e}){return i.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:i.jsx(qp,{})})}function Cr({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:l,mono:u}){return i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,l&&i.jsx("span",{className:"text-text-muted ml-1",children:l})]}),i.jsx("input",{value:t,onChange:c=>n(c.target.value),readOnly:a,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${u?"font-mono":""} ${a?"opacity-60":""}`})]})}function nT({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return i.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[i.jsx(Je,{variant:"secondary",onClick:e,children:"Cancel"}),i.jsx(Je,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function Ka({message:e}){return i.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function x1({description:e,onNew:t,loading:n,hasItems:r,children:a}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("p",{className:"text-text-secondary text-sm",children:e}),i.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:i.jsx(Je,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?i.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?a:i.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function y1({label:e="Custom",children:t}){return i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),i.jsx("div",{className:"space-y-2",children:t})]})}function b1({description:e,onNew:t,newLabel:n="+ New"}){return i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("p",{className:"text-text-secondary text-sm",children:e}),i.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:i.jsx(Je,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function tg({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:a}){return e&&!t?i.jsx("div",{className:"text-text-muted text-sm",children:n}):t?i.jsx("div",{className:"space-y-4",children:a}):r?i.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function v1({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:l="my-item",nameHint:u,readOnlyId:c=!1,readOnlyHint:d="(read-only)",onNameChange:f,onIdChange:p}){return i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(Cr,{label:n,value:e,onChange:f,placeholder:a,hint:u}),i.jsx(Cr,{label:r,value:t,onChange:p,readOnly:c,placeholder:l,hint:c?d:void 0,mono:!0})]})}function _1(e={}){const{initialData:t={}}=e,[n,r]=A.useState("list"),[a,l]=A.useState(null),[u,c]=A.useState(""),[d,f]=A.useState(!1),[p,m]=A.useState(t),x=A.useCallback(()=>{m(t),c(""),l(null)},[t]),y=A.useCallback(S=>{r(S),S==="list"&&x()},[x]),w=A.useCallback(S=>{m(b=>typeof S=="function"?S(b):S)},[]),C=A.useCallback((S,b={})=>{l(S),r("edit"),m({...b}),c("")},[]),_=A.useCallback(()=>{l(null),r("edit"),m(t),c("")},[t]);return{view:n,editingId:a,formError:u,saving:d,formData:p,setView:y,setEditingId:l,setFormError:c,setFormData:w,setSaving:f,resetForm:x,startEditing:C,startNew:_}}function Nl({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:l="Confirm",confirmVariant:u="primary",disabled:c=!1}){return i.jsx(wt,{isOpen:e,onClose:t,title:r,size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"text-text-secondary",children:a}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Je,{variant:"secondary",onClick:t,disabled:c,children:"Cancel"}),i.jsx(Je,{variant:u,onClick:n,disabled:c,autoFocus:!0,children:l})]})]})})}const rT={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function ui({size:e="md",className:t=""}){return i.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${rT[e]} ${t}`})}function sT({text:e,...t}){return i.jsxs("div",{className:"text-center",children:[i.jsx(ui,{...t,className:"mx-auto mb-4"}),e&&i.jsx("div",{className:"text-text-secondary",children:e})]})}function S1(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function iT(e){const t=e.includes("\\")?"\\":"/";return e.split(/[\\/]/).filter(Boolean).map((n,r,a)=>({name:n,path:t==="/"?"/"+a.slice(0,r+1).join("/"):a.slice(0,r+1).join("\\")+(r===0?"\\":"")}))}function w1(e,t=28){if(e.length<=t)return e;const n=e.split("/").filter(Boolean);if(n.length<=2)return e;const r=n[0],a=n[n.length-1],l=n.slice(1,-1).join("/"),u=t-r.length-a.length-3;if(u<0)return e;const c=l.slice(0,Math.floor(u/2)),d=l.slice(-Math.ceil(u/2));return`/${r}/${c}...${d}/${a}`}const ai=A.forwardRef(({className:e="",...t},n)=>i.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}));ai.displayName="Input";function xd({onSelect:e,onClose:t,initialPath:n}){const[r,a]=A.useState(null),[l,u]=A.useState(!0),[c,d]=A.useState(""),[f,p]=A.useState(-1),m=A.useRef(null),x=A.useRef(null),y=A.useCallback(async v=>{u(!0),d(""),p(-1);try{const E=v?`/api/directories?path=${encodeURIComponent(v)}`:"/api/directories",T=await(await we(E)).json();a(T)}catch(E){console.error("Failed to load directories:",E)}finally{u(!1)}},[]);A.useEffect(()=>{y(n)},[n,y]);const w=iT((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(v=>c===""||v.name.toLowerCase().includes(c.toLowerCase())))??[],_=[...!c&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(v=>({type:"dir",path:v.path,name:v.name}))];A.useEffect(()=>{p(c?0:-1)},[c,C.length]),A.useEffect(()=>{if(f>=0&&x.current){const v=x.current.querySelector(`[data-index="${f}"]`);v==null||v.scrollIntoView({block:"nearest"})}},[f]);const S=v=>{var E;if(v.key==="ArrowDown")v.preventDefault(),p(j=>Math.min(j+1,_.length-1));else if(v.key==="ArrowUp")v.preventDefault(),p(j=>Math.max(j-1,0));else if(v.key==="Enter"){if(f<0||!_[f]||v.target instanceof HTMLElement&&v.target.dataset.select==="true")return;v.preventDefault(),v.shiftKey?y(_[f].path):e(_[f].path)}else v.key==="Escape"&&(d(""),(E=m.current)==null||E.focus())},b=i.jsx("div",{className:"flex flex-col gap-2",children:i.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return i.jsx(wt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:b,scrollable:!1,children:i.jsxs("div",{ref:x,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:S,children:[i.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[r&&i.jsx("div",{className:"px-3 pt-3 pb-1",children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[w.map((v,E)=>i.jsxs("span",{className:"flex items-center shrink-0",children:[i.jsx("span",{className:"text-text-muted",children:"/"}),i.jsx("button",{onClick:()=>y(v.path),className:`px-1 ${E===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:v.name})]},v.path)),w.length===0&&i.jsx("button",{onClick:()=>y("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(r==null?void 0:r.current)&&i.jsx("button",{onClick:()=>e(r.current),className:"ml-auto shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90",children:"Select"})]})}),i.jsx("div",{className:"px-4 py-2",children:i.jsxs("div",{className:"relative",children:[i.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:i.jsx(Vi,{})}),i.jsx(ai,{autoFocus:!0,ref:m,value:c,onChange:v=>d(v.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:l?i.jsx("div",{className:"p-8 text-center",children:i.jsx(ui,{size:"sm"})}):_.length===0?i.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:c?"No matching directories":"No subdirectories"}):i.jsx("div",{className:"divide-y divide-border",children:_.map((v,E)=>i.jsxs("div",{"data-index":E,className:`group flex items-center ${E===f?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[i.jsxs("button",{onClick:()=>{y(v.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[v.type==="parent"?i.jsx(NN,{className:"w-5 h-5 text-text-muted shrink-0"}):i.jsx(Kr,{className:"w-5 h-5 shrink-0"}),i.jsx("span",{className:"truncate",children:v.name}),v.type==="dir"&&i.jsx(Qn,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${E===f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),v.type==="dir"&&i.jsx("button",{"data-select":"true",tabIndex:E===f?0:-1,onClick:j=>{j.stopPropagation(),e(v.path)},className:`mr-2 shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90 ${E===f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,"aria-label":`Select ${v.name}`,children:"Select"})]},v.path))})})]})})}function C1(e,t){if(!e||!t.some(n=>n.path==="SKILL.md"))throw new Error("Drop one folder containing SKILL.md.");return{packageName:e,files:t}}function aT(e){const t=[...e];if(!t.length)throw new Error("Choose one skill folder.");const n=new Set(t.map(a=>a.webkitRelativePath.split("/")[0]).filter(Boolean));if(n.size!==1)throw new Error("Choose exactly one skill folder.");const r=[...n][0];return C1(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function oT(e){return new Promise((t,n)=>e.file(t,n))}async function k1(e,t=""){const n=e.createReader(),r=[];for(;;){const l=await new Promise((u,c)=>n.readEntries(u,c));if(!l.length)break;r.push(...l)}return(await Promise.all(r.map(async l=>{const u=t?`${t}/${l.name}`:l.name;return l.isDirectory?k1(l,u):[{path:u,file:await oT(l)}]}))).flat()}async function lT(e){const t=[...e.items].filter(r=>r.kind==="file").map(r=>{var a;return((a=r.webkitGetAsEntry)==null?void 0:a.call(r))??null}).filter(r=>!!r);if(t.length!==1||!t[0].isDirectory)throw new Error("Drop exactly one skill folder.");const n=t[0];return C1(n.name,await k1(n))}function cT({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[l,u]=A.useState(!1),[c,d]=A.useState(!1),[f,p]=A.useState(""),[m,x]=A.useState(null),[y,w]=A.useState(!1),C=A.useRef(null);A.useEffect(()=>{var E;(E=C.current)==null||E.setAttribute("webkitdirectory","")},[]);const _=E=>{x(E)},S=async()=>{if(!m||y)return;w(!0);const E=await t(m);if(E&&!E.success){p(E.error??"Cannot use selected folder."),w(!1);return}x(null),u(!1),w(!1)},b=async E=>{d(!0),p("");const j=await a(E);d(!1),j.success||p(j.error??"Failed to install skill package.")},v=async E=>{if(E.preventDefault(),!(!(e!=null&&e.available)||c))try{await b(await lT(E.dataTransfer))}catch(j){p(j instanceof Error?j.message:"Invalid skill folder.")}};return i.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),i.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),i.jsxs("div",{className:"flex shrink-0 gap-2",children:[i.jsx(Je,{variant:"secondary",onClick:()=>u(!0),children:"Change folder"}),e&&i.jsxs(i.Fragment,{children:[i.jsx(Je,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&i.jsx(Je,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),i.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||c,onClick:()=>{var E;return(E=C.current)==null?void 0:E.click()},onDragOver:E=>E.preventDefault(),onDrop:v,className:"mt-3 w-full rounded border border-dashed border-border px-4 py-5 text-center text-xs text-text-secondary disabled:cursor-not-allowed disabled:opacity-50",children:e!=null&&e.available?c?"Installing skill package...":"Drop one skill folder here":"Choose a skills folder to enable drag and drop."}),i.jsx("input",{ref:C,hidden:!0,type:"file",multiple:!0,onChange:E=>{var j;if((j=E.target.files)!=null&&j.length)try{b(aT(E.target.files))}catch(T){p(T instanceof Error?T.message:"Invalid skill folder.")}finally{E.target.value=""}}}),f&&i.jsx("p",{className:"mt-2 text-xs text-error",children:f}),l&&i.jsx(xd,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:_,onClose:()=>u(!1)}),i.jsx(Nl,{isOpen:m!==null,onClose:()=>x(null),onConfirm:S,title:"Trust this folder?",message:"Skills may contain instructions and scripts. Select this folder for discovery without executing package content?",confirmLabel:"Trust folder",disabled:y})]})}function Ui({enabled:e,onClick:t,label:n}){return i.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,onClick:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function E1({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:l,onCancelDelete:u,actions:c,children:d}){return i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:d}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&i.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:i.jsx(Kp,{})}),i.jsx(Vu,{onClick:a}),!e&&r&&i.jsx(Gi,{onClick:r}),!e&&l&&(t?i.jsx(Zp,{onConfirm:()=>{l==null||l()},onCancel:()=>u==null?void 0:u()}):i.jsx(eg,{onClick:()=>l==null?void 0:l()})),c]})]})}function uT({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:f,actions:p}){return i.jsxs(E1,{isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:f,actions:p,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&i.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function S_({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:l,onDelete:u,onToggle:c,readOnly:d=!1}){return i.jsx(uT,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:d?void 0:a,onDuplicate:l,onDelete:d?void 0:u,actions:i.jsx(Ui,{enabled:e.enabled,onClick:c,label:`Activation for ${e.name}`})})}function dT({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return i.jsxs(wt,{isOpen:e!==null,onClose:r,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Je,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),i.jsx(Je,{variant:"danger",onClick:a,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[i.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),i.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&i.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&i.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function hT({isOpen:e}){const t=Tn(te=>te.defaults),n=Tn(te=>te.userItems),r=Tn(te=>te.projectItems),a=Tn(te=>te.items),l=Tn(te=>te.selectedDirectory),u=Tn(te=>te.diagnostics),c=Tn(te=>te.loading),d=Tn(te=>te.fetchSkills),f=Tn(te=>te.fetchSkill),p=Tn(te=>te.fetchDefaultContent),m=Tn(te=>te.createSkill),x=Tn(te=>te.updateSkill),y=Tn(te=>te.deleteSkill),w=Tn(te=>te.selectDirectory),C=Tn(te=>te.removeDirectory),_=Tn(te=>te.installSkill),S=Tn(te=>te.toggleSkill),[b,v]=A.useState(null),[E,j]=A.useState(!1),[T,D]=A.useState(""),{view:L,editingId:O,formError:M,saving:W,formData:z,setView:R,setEditingId:P,setFormError:V,setFormData:G,setSaving:Z}=_1(),{clearConfirm:Q}=Hl();A.useEffect(()=>{e&&(d(),R("list"),P(null),Q())},[e,d,Q]);const U=(te,se,xe,oe)=>{G({name:oe??te.metadata.name,id:xe??te.metadata.id,description:te.metadata.description??"",version:te.metadata.version??"1.0.0",prompt:te.prompt,isReadOnly:se,destination:"user"})},I=async te=>{if(t.some(xe=>xe.id===te)){const xe=await p(te);if(!xe)return;U(xe,!0),P(te),V(""),R("edit")}else{const xe=await f(te);if(!xe)return;U(xe,!0),P(te),V(""),R("edit")}},$=async te=>{const xe=t.some(ye=>ye.id===te)?await p(te):await f(te);if(!xe)return;const oe=`${te}-copy-${Date.now()}`;U(xe,!1,oe,`${xe.metadata.name} (copy)`),P(null),V(""),R("edit")},q=()=>{G({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),R("edit")},B=async te=>{const se=await f(te);se&&(U(se,!1),P(te),V(""),R("edit"))},ee=async()=>{if(!b)return;j(!0),D("");const te=await y(b.id);if(j(!1),!te.success){D(te.error??"Failed to delete skill.");return}await d(),v(null),Q()},X=async()=>{const te=O??z.id;if(!te||!z.name||!z.prompt){V("Name, ID, and prompt are required.");return}Z(!0),V("");const se={metadata:{id:te,name:z.name,description:z.description,version:z.version},prompt:z.prompt},xe=O?await x(O,se):await m(se,z.destination);if(Z(!1),!xe.success){V(xe.error??"Failed to save skill.");return}R("list")},ne=te=>{G(se=>({...se,name:te})),O||G(se=>({...se,id:te.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},K=z.isReadOnly;if(L==="edit")return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-3",children:[i.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:K?z.name:O?"Edit Skill":"New Skill"}),i.jsx("button",{onClick:()=>R("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),M&&i.jsx(Ka,{message:M}),i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsx(v1,{name:z.name,id:z.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:ne,onIdChange:()=>{}}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(Cr,{label:"Description",value:z.description,onChange:te=>G(se=>({...se,description:te})),placeholder:"What this skill does...",readOnly:K}),i.jsx(Cr,{label:"Version",value:z.version,onChange:te=>G(se=>({...se,version:te})),placeholder:"1.0.0",readOnly:K})]})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),i.jsx("textarea",{value:z.prompt,onChange:te=>G(se=>({...se,prompt:te.target.value})),readOnly:K,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"})]}),!O&&i.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),i.jsxs("select",{value:z.destination,onChange:te=>G(se=>({...se,destination:te.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:[i.jsx("option",{value:"user",children:"Global config"}),i.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[i.jsx(Je,{variant:"secondary",onClick:()=>R("list"),children:"Cancel"}),K?i.jsx(Je,{variant:"primary",onClick:()=>{G(te=>({...te,name:te.name+" (copy)",id:`${O}-copy-${Date.now()}`,isReadOnly:!1})),P(null)},children:"Duplicate & Customize"}):i.jsx(Je,{variant:"primary",onClick:X,disabled:W||!z.name||!z.id||!z.prompt,children:W?"Saving...":"Save"})]})]});function F({items:te}){return te.map(se=>i.jsx(S_,{skill:se,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>I(se.id),onEdit:()=>B(se.id),onDuplicate:()=>$(se.id),onDelete:()=>{D(""),v(se)},onToggle:()=>S(se.id),readOnly:se.readOnly},se.id))}return i.jsxs("div",{children:[i.jsx(dT,{skill:b,deleting:E,error:T,onClose:()=>{E||v(null)},onConfirm:ee}),i.jsx(cT,{selectedDirectory:l,onSelect:w,onRemove:C,onRefresh:d,onInstall:_}),u.length>0&&i.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:u.map((te,se)=>i.jsx("p",{children:te},`${te}-${se}`))}),i.jsx(b1,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:q}),i.jsxs(tg,{loading:c,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),i.jsx("div",{className:"space-y-2",children:t.map(te=>i.jsx(S_,{skill:te,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>I(te.id),onDuplicate:()=>$(te.id),onToggle:()=>S(te.id)},te.id))})]}),n.length>0&&i.jsx(y1,{children:i.jsx(F,{items:n})}),a.some(te=>["global-shared","selected","project-shared"].includes(te.source))&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),i.jsx("div",{className:"space-y-2",children:i.jsx(F,{items:a.filter(te=>["global-shared","selected","project-shared"].includes(te.source))})})]}),r.length>0&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),i.jsx("div",{className:"space-y-2",children:i.jsx(F,{items:r})})]})]})]})}function ao(){const e=Gt(a=>a.settings),t=Gt(a=>a.loading),n=Gt(a=>a.getSetting),r=Gt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function fT({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=ao(),l=t[De.GLOBAL_INSTRUCTIONS]??"",u=n[De.GLOBAL_INSTRUCTIONS]??!1,[c,d]=A.useState(l),[f,p]=A.useState(!1),[m,x]=A.useState(!1);A.useEffect(()=>{e&&r(De.GLOBAL_INSTRUCTIONS)},[e,r]),A.useEffect(()=>{d(l),p(!1)},[l]);const y=async()=>{x(!0),await a(De.GLOBAL_INSTRUCTIONS,c),x(!1),p(!1)},w=()=>{d(l),p(!1)},C=u||m;return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),i.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),i.jsx("textarea",{value:c,onChange:_=>{d(_.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:C})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Je,{variant:"secondary",onClick:w,disabled:!f,children:"Discard"}),i.jsx(Je,{variant:"primary",onClick:y,disabled:!f||C,children:m?"Saving...":"Save"})]})]})}function mT(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),r=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${r} ${a}`}return e}function Pu(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 pT({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:l,onClose:u,onSave:c}){const[d,f]=A.useState(l),[p,m]=A.useState(r),[x,y]=A.useState(a);A.useEffect(()=>{f(l),m(r)},[l,r]);const w=(v,E)=>{const j=E.startsWith("#")?mT(E):E;f(T=>({...T,[v]:j}))},C=()=>{c(p.trim()||"Untitled",{...d},x)},_=l1.reduce((v,E)=>{const j=E.category;return v[j]||(v[j]=[]),v[j].push(E),v},{}),S={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},b=Pn.find(v=>v.id===n);return i.jsx(wt,{isOpen:e,onClose:u,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:i.jsxs("div",{className:"flex gap-2 justify-end",children:[i.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:C,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),i.jsx("input",{type:"text",value:p,onChange:v=>m(v.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"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Mode"}),i.jsxs("div",{className:"flex rounded overflow-hidden border border-border",children:[i.jsx("button",{type:"button",onClick:()=>y("dark"),className:`px-3 py-2 text-xs font-medium transition-colors ${x==="dark"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Dark"}),i.jsx("button",{type:"button",onClick:()=>y("light"),className:`px-3 py-2 text-xs font-medium transition-colors ${x==="light"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Light"})]})]})]}),!t&&i.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",i.jsx("span",{className:"text-text-primary",children:b==null?void 0:b.name})]}),Object.entries(_).map(([v,E])=>i.jsxs("div",{className:"space-y-3",children:[i.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:S[v]??v}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:E.map(j=>i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:j.key,className:"text-xs text-text-muted",children:j.label}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"color",id:j.key,value:Pu(d[j.key]??j.defaultValue),onChange:T=>w(j.key,T.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),i.jsx("input",{type:"text",value:d[j.key]??j.defaultValue,onChange:T=>w(j.key,T.target.value),className:"flex-1 min-w-0 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))})]},v))]})})}function w_({preset:e,isActive:t,isUnderlying:n,onClick:r,onNewFrom:a,onEdit:l,onDelete:u}){return i.jsxs("div",{className:"relative group",children:[i.jsxs("button",{type:"button",onClick:r,className:`flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors min-w-[80px] ${t?"border-accent-primary bg-bg-tertiary text-text-primary":n?"border-dashed border-accent-primary/50 bg-bg-tertiary/50 text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[i.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:e.id==="system"?"transparent":Pu(e.tokens["color-bg-primary"]??"#000"),borderColor:Pu(e.tokens["color-border"]??"#000")},children:e.id==="system"?i.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):i.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Pu(e.tokens["color-text-primary"]??"#fff")}})}),i.jsx("span",{className:"text-xs",children:e.name})]}),a&&i.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),a()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:i.jsx("span",{className:"text-xs",children:"✎"})}),l&&i.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),l()},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:i.jsx("span",{className:"text-xs",children:"✎"})}),u&&i.jsx("button",{type:"button",onClick:c=>u(c),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:i.jsx(Es,{className:"w-3 h-3"})})]})}function gT(){const[e,t]=A.useState(null),n=Rt(z=>z.currentPreset),r=Rt(z=>z.isCustom),a=Rt(z=>z.basePreset),l=Rt(z=>z.isSystem),u=Rt(z=>z.systemDarkPreset),c=Rt(z=>z.systemLightPreset),d=Rt(z=>z.applyPreset),f=Rt(z=>z.applyUserPreset),p=Rt(z=>z.deleteUserPreset),m=Rt(z=>z.saveTheme),x=Rt(z=>z.setSystemDarkPreset),y=Rt(z=>z.setSystemLightPreset),w=Rt(z=>z.activeUserPresetId),C=Rt(z=>z.userPresets),_=Pn.filter(z=>z.mode==="dark"),S=Pn.filter(z=>z.mode==="light"),b=z=>{var R;if(l){const P=C[z];if(!P)return;const V=P.mode??((R=Pn.find(G=>G.id===P.basePreset))==null?void 0:R.mode);V==="dark"?x(P.id):V==="light"&&y(P.id)}else f(z)},v=z=>{const R=Pn.find(P=>P.id===z);R&&t({type:"new",presetIndex:C.length,basePresetId:z,presetName:R.name+" Copy",mode:R.mode??"dark",tokens:{...R.tokens}})},E=z=>{const R=C[z];if(!R)return;const P=Pn.find(G=>G.id===R.basePreset),V=P?{...P.tokens,...R.tokens}:R.tokens;t({type:"edit",presetIndex:z,basePresetId:R.basePreset,presetName:R.name,mode:R.mode??"dark",tokens:V})},j=(z,R,P)=>{if(!e)return;const V=[...C];if(e.type==="new"){const G={id:"custom-"+Date.now(),name:z,basePreset:e.basePresetId,mode:P,tokens:R};V.push(G);const Z=V.length-1;Rt.setState({userPresets:V}),Rt.getState().saveUserPresets(),Rt.getState().applyUserPreset(Z)}else{const G=V[e.presetIndex];G&&(V[e.presetIndex]={...G,name:z,mode:P,tokens:R}),Rt.setState({userPresets:V}),Rt.getState().saveUserPresets(),Rt.getState().applyUserPreset(e.presetIndex)}t(null)},T=()=>{t(null)},D=(z,R)=>{z.stopPropagation(),p(R)},L=l?"system":r?a:n,O=()=>{l?(d(n),m(JSON.stringify({preset:n})).catch(()=>{})):(d("system"),m(JSON.stringify({preset:"system"})).catch(()=>{}))},M=z=>{if(l){const R=Pn.find(P=>P.id===z);(R==null?void 0:R.mode)==="dark"?x(z):(R==null?void 0:R.mode)==="light"&&y(z)}else d(z),m(JSON.stringify({preset:z})).catch(()=>{})},W=z=>{const R=Pn.find(P=>P.id===z.basePreset);return R?{...R.tokens,...z.tokens}:z.tokens};return i.jsxs("div",{className:"space-y-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),i.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[i.jsx("span",{className:"text-sm text-text-primary font-medium",children:"Follow system theme"}),i.jsx("button",{type:"button",onClick:O,className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${l?"bg-accent-primary":"bg-bg-tertiary"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l?"translate-x-6":"translate-x-1"}`})})]}),[{title:"Dark Themes",mode:"dark"},{title:"Light Themes",mode:"light"}].map(({title:z,mode:R})=>{const P=R==="dark"?_:S,V=C.filter(G=>{var Q;return(G.mode??((Q=Pn.find(U=>U.id===G.basePreset))==null?void 0:Q.mode))===R});return i.jsxs("div",{children:[i.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:z}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[P.map(G=>i.jsx(w_,{preset:G,isActive:G.id===L&&!r,isUnderlying:l&&(G.id===u||G.id===c),onClick:()=>M(G.id),onNewFrom:()=>v(G.id)},G.id)),V.map(G=>{const Z=C.indexOf(G),Q=W(G);return i.jsx(w_,{preset:{id:G.id,name:G.name,tokens:Q},isActive:w===G.id,isUnderlying:l&&(G.id===u||G.id===c),onClick:()=>b(Z),onEdit:()=>E(Z),onDelete:U=>D(U,Z)},G.id)})]})]},z)}),e&&i.jsx(pT,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,mode:e.mode,initialTokens:e.tokens,onClose:T,onSave:j})]})}function xT(){return i.jsx(gT,{})}function yT(){const{settings:e,loading:t,getSetting:n,setSetting:r}=ao(),a=t[De.DISPLAY_SHOW_THINKING]??!1,l=e[De.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[u,c]=A.useState(l);A.useEffect(()=>{n(De.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),A.useEffect(()=>{c(l)},[l]);const d=()=>{const w=parseInt(u,10),C=isNaN(w)||w<0?0:Math.min(w,9999);c(String(C)),r(De.DISPLAY_MAX_VISIBLE_ITEMS,String(C))},f=[{key:De.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:De.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:De.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:De.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:De.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:De.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews"}],p=Object.fromEntries(f.map(w=>[w.key,e[w.key]??"true"])),[m,x]=A.useState(()=>Object.fromEntries(f.map(w=>[w.key,p[w.key]==="true"])));A.useEffect(()=>{f.forEach(w=>n(w.key))},[n]),A.useEffect(()=>{x(Object.fromEntries(f.map(w=>[w.key,p[w.key]==="true"])))},[JSON.stringify(p)]);const y=async w=>{const C=String(!m[w]);x(_=>({..._,[w]:!_[w]})),await r(w,C)};return a?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):i.jsxs("div",{className:"space-y-6",children:[i.jsx(xT,{}),i.jsxs("div",{className:"border-t border-border pt-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),i.jsx("div",{className:"space-y-4",children:f.map(({key:w,label:C,description:_})=>i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary font-medium",children:C}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:_})]}),i.jsx("button",{type:"button",onClick:()=>y(w),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${m[w]?"bg-accent-primary":"bg-bg-tertiary"}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${m[w]?"translate-x-6":"translate-x-1"}`})})]},w))})]}),i.jsx("div",{className:"border-t border-border pt-4",children:i.jsxs("label",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),i.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Keep only the last N items in the feed. Set to 0 to show all."})]}),i.jsx("input",{type:"number",min:0,max:9999,value:u,onChange:w=>{const C=w.target.value.replace(/[^0-9]/g,"");c(C)},onBlur:d,onKeyDown:w=>{w.key==="Enter"&&d()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})})]})}function lp(){const[e,t]=A.useState("Test"),[n,r]=A.useState(""),[a,l]=A.useState(!1),u=A.useCallback(async c=>{t("Testing..."),r(""),l(!1);try{const d=await c();d.success?(t("Success"),l(!0),setTimeout(()=>{t("Test"),l(!1)},3e3)):(r(d.error??"Test failed"),t("Test"))}catch{r("Connection error"),t("Test")}},[]);return[e,n,a,u]}function bT(e){try{return new RegExp(e),!0}catch{return!1}}function vT({value:e,onChange:t}){const[n,r]=A.useState({}),a=(d,f)=>{const p=e.patterns.map((m,x)=>x===d?{...m,...f}:m);t({...e,patterns:p})},l=d=>{const f=e.patterns.filter((p,m)=>m!==d);t({...e,patterns:f})},u=()=>{const d={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,d]})},c=(d,f)=>{r(p=>({...p,[d]:f.length>0&&!bT(f)})),a(d,{pattern:f})};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),i.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange:d=>{const f=parseInt(d.target.value,10),p=isNaN(f)?10:Math.max(1,Math.min(100,f));t({...e,maxRetriesPerTurn:p})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?i.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[i.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),i.jsx("th",{className:"pb-2 pr-2",children:"Field"}),i.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),i.jsx("th",{className:"pb-2 pr-2",children:"Action"}),i.jsx("th",{className:"pb-2 w-8"})]})}),i.jsx("tbody",{children:e.patterns.map((d,f)=>i.jsxs("tr",{className:"border-b border-border",children:[i.jsx("td",{className:"py-2 pr-2",children:i.jsx("input",{type:"checkbox",checked:d.active,onChange:()=>a(f,{active:!d.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${f+1}`})}),i.jsx("td",{className:"py-2 pr-2",children:i.jsxs("select",{value:d.field,onChange:p=>a(f,{field:p.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[i.jsx("option",{value:"content",children:"content"}),i.jsx("option",{value:"thinking",children:"thinking"}),i.jsx("option",{value:"both",children:"both"})]})}),i.jsx("td",{className:"py-2 pr-2",children:i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"text",value:d.pattern,onChange:p=>c(f,p.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),d.pattern.length>0&&i.jsx("span",{className:`text-sm ${n[f]?"text-red-500":"text-green-500"}`,children:n[f]?"✗":"✓"})]})}),i.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),i.jsx("td",{className:"py-2",children:i.jsx("button",{onClick:()=>l(f),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},f))})]}),i.jsx(Je,{variant:"secondary",onClick:u,children:"Add Pattern"})]})}function j1({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=A.useState("ready"),[l,u]=A.useState(""),[c,d]=A.useState(n),[f,p]=A.useState(null),[m,x]=A.useState(null);A.useEffect(()=>{!e||n||fetch(Cs("/api/auto-update/check")).then(S=>S.json()).then(S=>{d({current:S.current,latest:S.latest})}).catch(()=>{})},[e]),A.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const S=setInterval(()=>{u(b=>b.length>=3?"":b+".")},400);return()=>clearInterval(S)},[e,r]);const y=A.useCallback(async()=>{a("updating"),x(null);try{const b=await(await we("/api/auto-update",{method:"POST"})).json();if(b.success){const v=b.version??"unknown";p(v),localStorage.setItem("openfox_updated_to",v),localStorage.setItem("update_pending","true"),b.isService?(a("restarting"),await we("/api/auto-update/restart",{method:"POST"}).catch(()=>{}),setTimeout(()=>window.location.reload(),5e3)):a("complete")}else x(b.error??"Update failed"),a("failed")}catch(S){x(S instanceof Error?S.message:"Update request failed"),a("failed")}},[]);A.useEffect(()=>{e&&(a("ready"),u(""),p(null),x(null))},[e]);const w=r!=="updating"&&r!=="restarting",C=S=>S,_=r==="failed"?"Update Failed":r==="complete"||r==="restarting"?"Update Complete":"New OpenFox version available";return i.jsxs(wt,{isOpen:e,onClose:w?t:void 0,title:_,size:"md",closeOnBackdropClick:w,showCloseButton:w,children:[i.jsxs("div",{className:"flex flex-col gap-4",children:[c&&i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-text-muted",children:"Current version"}),i.jsx("span",{className:"text-text-primary font-mono",children:C(c.current)})]}),c&&i.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[i.jsx("span",{className:"text-text-muted",children:"Latest version"}),i.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:c.latest})]}),(r==="updating"||r==="restarting")&&i.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[i.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),i.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",l]})]}),r==="complete"&&i.jsx("div",{className:"flex flex-col gap-3 mt-2",children:i.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",f??(c==null?void 0:c.latest),"."," Please restart OpenFox to use the new version."]})}),r==="failed"&&i.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[i.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:[i.jsx("span",{children:"⚠️"}),i.jsx("p",{className:"text-text-secondary",children:m})]}),i.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),i.jsx("p",{className:"text-xs text-text-muted",children:"Run this command in your terminal to complete the update."})]})]}),r==="ready"&&i.jsx("button",{onClick:y,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")&&i.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"})]})}function _T(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ST=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,wT=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,CT={};function C_(e,t){return(CT.jsx?wT:ST).test(e)}const kT=/[ \t\n\f\r]/g;function ET(e){return typeof e=="object"?e.type==="text"?k_(e.value):!1:k_(e)}function k_(e){return e.replace(kT,"")===""}let Ul=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Ul.prototype.normal={};Ul.prototype.property={};Ul.prototype.space=void 0;function N1(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Ul(n,r,t)}function cp(e){return e.toLowerCase()}let Jn=class{constructor(t,n){this.attribute=n,this.property=t}};Jn.prototype.attribute="";Jn.prototype.booleanish=!1;Jn.prototype.boolean=!1;Jn.prototype.commaOrSpaceSeparated=!1;Jn.prototype.commaSeparated=!1;Jn.prototype.defined=!1;Jn.prototype.mustUseProperty=!1;Jn.prototype.number=!1;Jn.prototype.overloadedBoolean=!1;Jn.prototype.property="";Jn.prototype.spaceSeparated=!1;Jn.prototype.space=void 0;let jT=0;const lt=Yi(),hn=Yi(),up=Yi(),Pe=Yi(),Bt=Yi(),Ya=Yi(),or=Yi();function Yi(){return 2**++jT}const dp=Object.freeze(Object.defineProperty({__proto__:null,boolean:lt,booleanish:hn,commaOrSpaceSeparated:or,commaSeparated:Ya,number:Pe,overloadedBoolean:up,spaceSeparated:Bt},Symbol.toStringTag,{value:"Module"})),hm=Object.keys(dp);let ng=class extends Jn{constructor(t,n,r,a){let l=-1;if(super(t,n),E_(this,"space",a),typeof r=="number")for(;++l<hm.length;){const u=hm[l];E_(this,hm[l],(r&dp[u])===dp[u])}}};ng.prototype.defined=!0;function E_(e,t,n){n&&(e[t]=n)}function oo(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new ng(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[cp(r)]=r,n[cp(l.attribute)]=r}return new Ul(t,n,e.space)}const T1=oo({properties:{ariaActiveDescendant:null,ariaAtomic:hn,ariaAutoComplete:null,ariaBusy:hn,ariaChecked:hn,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:Bt,ariaCurrent:null,ariaDescribedBy:Bt,ariaDetails:null,ariaDisabled:hn,ariaDropEffect:Bt,ariaErrorMessage:null,ariaExpanded:hn,ariaFlowTo:Bt,ariaGrabbed:hn,ariaHasPopup:null,ariaHidden:hn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Bt,ariaLevel:Pe,ariaLive:null,ariaModal:hn,ariaMultiLine:hn,ariaMultiSelectable:hn,ariaOrientation:null,ariaOwns:Bt,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:hn,ariaReadOnly:hn,ariaRelevant:null,ariaRequired:hn,ariaRoleDescription:Bt,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:hn,ariaSetSize:Pe,ariaSort:null,ariaValueMax:Pe,ariaValueMin:Pe,ariaValueNow:Pe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function A1(e,t){return t in e?e[t]:t}function L1(e,t){return A1(e,t.toLowerCase())}const NT=oo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ya,acceptCharset:Bt,accessKey:Bt,action:null,allow:null,allowFullScreen:lt,allowPaymentRequest:lt,allowUserMedia:lt,alt:null,as:null,async:lt,autoCapitalize:null,autoComplete:Bt,autoFocus:lt,autoPlay:lt,blocking:Bt,capture:null,charSet:null,checked:lt,cite:null,className:Bt,cols:Pe,colSpan:null,content:null,contentEditable:hn,controls:lt,controlsList:Bt,coords:Pe|Ya,crossOrigin:null,data:null,dateTime:null,decoding:null,default:lt,defer:lt,dir:null,dirName:null,disabled:lt,download:up,draggable:hn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:lt,formTarget:null,headers:Bt,height:Pe,hidden:up,high:Pe,href:null,hrefLang:null,htmlFor:Bt,httpEquiv:Bt,id:null,imageSizes:null,imageSrcSet:null,inert:lt,inputMode:null,integrity:null,is:null,isMap:lt,itemId:null,itemProp:Bt,itemRef:Bt,itemScope:lt,itemType:Bt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:lt,low:Pe,manifest:null,max:null,maxLength:Pe,media:null,method:null,min:null,minLength:Pe,multiple:lt,muted:lt,name:null,nonce:null,noModule:lt,noValidate:lt,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:lt,optimum:Pe,pattern:null,ping:Bt,placeholder:null,playsInline:lt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:lt,referrerPolicy:null,rel:Bt,required:lt,reversed:lt,rows:Pe,rowSpan:Pe,sandbox:Bt,scope:null,scoped:lt,seamless:lt,selected:lt,shadowRootClonable:lt,shadowRootDelegatesFocus:lt,shadowRootMode:null,shape:null,size:Pe,sizes:null,slot:null,span:Pe,spellCheck:hn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Pe,step:null,style:null,tabIndex:Pe,target:null,title:null,translate:null,type:null,typeMustMatch:lt,useMap:null,value:hn,width:Pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Bt,axis:null,background:null,bgColor:null,border:Pe,borderColor:null,bottomMargin:Pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:lt,declare:lt,event:null,face:null,frame:null,frameBorder:null,hSpace:Pe,leftMargin:Pe,link:null,longDesc:null,lowSrc:null,marginHeight:Pe,marginWidth:Pe,noResize:lt,noHref:lt,noShade:lt,noWrap:lt,object:null,profile:null,prompt:null,rev:null,rightMargin:Pe,rules:null,scheme:null,scrolling:hn,standby:null,summary:null,text:null,topMargin:Pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:lt,disableRemotePlayback:lt,prefix:null,property:null,results:Pe,security:null,unselectable:null},space:"html",transform:L1}),TT=oo({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:or,accentHeight:Pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Pe,amplitude:Pe,arabicForm:null,ascent:Pe,attributeName:null,attributeType:null,azimuth:Pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Pe,by:null,calcMode:null,capHeight:Pe,className:Bt,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:Pe,diffuseConstant:Pe,direction:null,display:null,dur:null,divisor:Pe,dominantBaseline:null,download:lt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Pe,enableBackground:null,end:null,event:null,exponent:Pe,externalResourcesRequired:null,fill:null,fillOpacity:Pe,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:Ya,g2:Ya,glyphName:Ya,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Pe,horizOriginX:Pe,horizOriginY:Pe,id:null,ideographic:Pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Pe,k:Pe,k1:Pe,k2:Pe,k3:Pe,k4:Pe,kernelMatrix:or,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Pe,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:Pe,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:Pe,overlineThickness:Pe,paintOrder:null,panose1:null,path:null,pathLength:Pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Bt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Pe,pointsAtY:Pe,pointsAtZ:Pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:or,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:or,rev:or,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:or,requiredFeatures:or,requiredFonts:or,requiredFormats:or,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:Pe,specularExponent:Pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Pe,strikethroughThickness:Pe,string:null,stroke:null,strokeDashArray:or,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Pe,strokeOpacity:Pe,strokeWidth:null,style:null,surfaceScale:Pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:or,tabIndex:Pe,tableValues:null,target:null,targetX:Pe,targetY:Pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:or,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Pe,underlineThickness:Pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Pe,values:null,vAlphabetic:Pe,vMathematical:Pe,vectorEffect:null,vHanging:Pe,vIdeographic:Pe,version:null,vertAdvY:Pe,vertOriginX:Pe,vertOriginY:Pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:A1}),D1=oo({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()}}),R1=oo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:L1}),O1=oo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),AT={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"},LT=/[A-Z]/g,j_=/-[a-z]/g,DT=/^data[-\w.:]+$/i;function RT(e,t){const n=cp(t);let r=t,a=Jn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&DT.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(j_,IT);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!j_.test(l)){let u=l.replace(LT,OT);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=ng}return new a(r,t)}function OT(e){return"-"+e.toLowerCase()}function IT(e){return e.charAt(1).toUpperCase()}const MT=N1([T1,NT,D1,R1,O1],"html"),rg=N1([T1,TT,D1,R1,O1],"svg");function PT(e){return e.join(" ").trim()}var Ia={},fm,N_;function BT(){if(N_)return fm;N_=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
|
|
60
|
+
`,f="/",p="*",m="",x="comment",y="declaration";function w(_,S){if(typeof _!="string")throw new TypeError("First argument must be a string");if(!_)return[];S=S||{};var b=1,v=1;function E(P){var V=P.match(t);V&&(b+=V.length);var G=P.lastIndexOf(d);v=~G?P.length-G:v+P.length}function j(){var P={line:b,column:v};return function(V){return V.position=new T(P),O(),V}}function T(P){this.start=P,this.end={line:b,column:v},this.source=S.source}T.prototype.content=_;function D(P){var V=new Error(S.source+":"+b+":"+v+": "+P);if(V.reason=P,V.filename=S.source,V.line=b,V.column=v,V.source=_,!S.silent)throw V}function L(P){var V=P.exec(_);if(V){var G=V[0];return E(G),_=_.slice(G.length),V}}function O(){L(n)}function M(P){var V;for(P=P||[];V=W();)V!==!1&&P.push(V);return P}function W(){var P=j();if(!(f!=_.charAt(0)||p!=_.charAt(1))){for(var V=2;m!=_.charAt(V)&&(p!=_.charAt(V)||f!=_.charAt(V+1));)++V;if(V+=2,m===_.charAt(V-1))return D("End of comment missing");var G=_.slice(2,V-2);return v+=2,E(G),_=_.slice(V),v+=2,P({type:x,comment:G})}}function z(){var P=j(),V=L(r);if(V){if(W(),!L(a))return D("property missing ':'");var G=L(l),Z=P({type:y,property:C(V[0].replace(e,m)),value:G?C(G[0].replace(e,m)):m});return L(u),Z}}function R(){var P=[];M(P);for(var V;V=z();)V!==!1&&(P.push(V),M(P));return P}return O(),R()}function C(_){return _?_.replace(c,m):m}return fm=w,fm}var T_;function $T(){if(T_)return Ia;T_=1;var e=Ia&&Ia.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ia,"__esModule",{value:!0}),Ia.default=n;const t=e(BT());function n(r,a){let l=null;if(!r||typeof r!="string")return l;const u=(0,t.default)(r),c=typeof a=="function";return u.forEach(d=>{if(d.type!=="declaration")return;const{property:f,value:p}=d;c?a(f,p,d):p&&(l=l||{},l[f]=p)}),l}return Ia}var ol={},A_;function zT(){if(A_)return ol;A_=1,Object.defineProperty(ol,"__esModule",{value:!0}),ol.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(f){return!f||n.test(f)||e.test(f)},u=function(f,p){return p.toUpperCase()},c=function(f,p){return"".concat(p,"-")},d=function(f,p){return p===void 0&&(p={}),l(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(a,c):f=f.replace(r,c),f.replace(t,u))};return ol.camelCase=d,ol}var ll,L_;function HT(){if(L_)return ll;L_=1;var e=ll&&ll.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e($T()),n=zT();function r(a,l){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(c,d){c&&d&&(u[(0,n.camelCase)(c,l)]=d)}),u}return r.default=r,ll=r,ll}var UT=HT();const FT=ud(UT),I1=M1("end"),sg=M1("start");function M1(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 VT(e){const t=sg(e),n=I1(e);if(t&&n)return{start:t,end:n}}function _l(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?D_(e.position):"start"in e||"end"in e?D_(e):"line"in e||"column"in e?hp(e):""}function hp(e){return R_(e&&e.line)+":"+R_(e&&e.column)}function D_(e){return hp(e&&e.start)+"-"+hp(e&&e.end)}function R_(e){return e&&typeof e=="number"?e:1}class On extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",l={},u=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?a=t:!l.cause&&t&&(u=!0,a=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?l.ruleId=r:(l.source=r.slice(0,d),l.ruleId=r.slice(d+1))}if(!l.place&&l.ancestors&&l.ancestors){const d=l.ancestors[l.ancestors.length-1];d&&(l.place=d.position)}const c=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=_l(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=u&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}On.prototype.file="";On.prototype.name="";On.prototype.reason="";On.prototype.message="";On.prototype.stack="";On.prototype.column=void 0;On.prototype.line=void 0;On.prototype.ancestors=void 0;On.prototype.cause=void 0;On.prototype.fatal=void 0;On.prototype.place=void 0;On.prototype.ruleId=void 0;On.prototype.source=void 0;const ig={}.hasOwnProperty,GT=new Map,WT=/[A-Z]/g,qT=new Set(["table","tbody","thead","tfoot","tr"]),KT=new Set(["td","th"]),P1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function YT(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=rA(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=nA(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?rg:MT,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=B1(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function B1(e,t,n){if(t.type==="element")return XT(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return QT(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return ZT(e,t,n);if(t.type==="mdxjsEsm")return JT(e,t);if(t.type==="root")return eA(e,t,n);if(t.type==="text")return tA(e,t)}function XT(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=rg,e.schema=a),e.ancestors.push(t);const l=z1(e,t.tagName,!1),u=sA(e,t);let c=og(e,t);return qT.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!ET(d):!0})),$1(e,u,l,t),ag(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function QT(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)}Tl(e,t.position)}function JT(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Tl(e,t.position)}function ZT(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=rg,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:z1(e,t.name,!0),u=iA(e,t),c=og(e,t);return $1(e,u,l,t),ag(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function eA(e,t,n){const r={};return ag(r,og(e,t)),e.create(t,e.Fragment,r,n)}function tA(e,t){return t.value}function $1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function ag(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function nA(e,t,n){return r;function r(a,l,u,c){const f=Array.isArray(u.children)?n:t;return c?f(l,u,c):f(l,u)}}function rA(e,t){return n;function n(r,a,l,u){const c=Array.isArray(l.children),d=sg(r);return t(a,l,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function sA(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&ig.call(t.properties,a)){const l=aA(e,a,t.properties[a]);if(l){const[u,c]=l;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&KT.has(t.tagName)?r=c:n[u]=c}}if(r){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function iA(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];l.type;const u=l.expression;u.type;const c=u.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else Tl(e,t.position);else{const a=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,l=e.evaluater.evaluateExpression(c.expression)}else Tl(e,t.position);else l=r.value===null?!0:r.value;n[a]=l}return n}function og(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:GT;for(;++r<t.children.length;){const l=t.children[r];let u;if(e.passKeys){const d=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(d){const f=a.get(d)||0;u=d+"-"+f,a.set(d,f+1)}}const c=B1(e,l,u);c!==void 0&&n.push(c)}return n}function aA(e,t,n){const r=RT(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?_T(n):PT(n)),r.property==="style"){let a=typeof n=="object"?n:oA(e,String(n));return e.stylePropertyNameCase==="css"&&(a=lA(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?AT[r.property]||r.property:r.attribute,n]}}function oA(e,t){try{return FT(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new On("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=P1+"#cannot-parse-style-attribute",a}}function z1(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,u;for(;++l<a.length;){const c=C_(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};u=u?{type:"MemberExpression",object:u,property:c,computed:!!(l&&c.type==="Literal"),optional:!1}:c}r=u}else r=C_(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return ig.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);Tl(e)}function Tl(e,t){const n=new On("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=P1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function lA(e){const t={};let n;for(n in e)ig.call(e,n)&&(t[cA(n)]=e[n]);return t}function cA(e){let t=e.replace(WT,uA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function uA(e){return"-"+e.toLowerCase()}const mm={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"]},dA={};function lg(e,t){const n=dA,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return H1(e,r,a)}function H1(e,t,n){if(hA(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 O_(e.children,t,n)}return Array.isArray(e)?O_(e,t,n):""}function O_(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=H1(e[a],t,n);return r.join("")}function hA(e){return!!(e&&typeof e=="object")}const I_=document.createElement("i");function cg(e){const t="&"+e+";";I_.innerHTML=t;const n=I_.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function cr(e,t,n,r){const a=e.length;let l=0,u;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)u=Array.from(r),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);l<r.length;)u=r.slice(l,l+1e4),u.unshift(t,0),e.splice(...u),l+=1e4,t+=1e4}function _r(e,t){return e.length>0?(cr(e,e.length,0,t),e):t}const M_={}.hasOwnProperty;function U1(e){const t={};let n=-1;for(;++n<e.length;)fA(t,e[n]);return t}function fA(e,t){let n;for(n in t){const a=(M_.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){M_.call(a,u)||(a[u]=[]);const c=l[u];mA(a[u],Array.isArray(c)?c:c?[c]:[])}}}function mA(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);cr(e,0,0,r)}function F1(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 Rr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const $n=di(/[A-Za-z]/),Rn=di(/[\dA-Za-z]/),pA=di(/[#-'*+\--9=?A-Z^-~]/);function Gu(e){return e!==null&&(e<32||e===127)}const fp=di(/\d/),gA=di(/[\dA-Fa-f]/),xA=di(/[!-/:-@[-`{-~]/);function Qe(e){return e!==null&&e<-2}function Pt(e){return e!==null&&(e<0||e===32)}function pt(e){return e===-2||e===-1||e===32}const yd=di(new RegExp("\\p{P}|\\p{S}","u")),Wi=di(/\s/);function di(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function lo(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&Rn(e.charCodeAt(n+1))&&Rn(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(u=String.fromCharCode(l));else if(l>55295&&l<57344){const c=e.charCodeAt(n+1);l<56320&&c>56319&&c<57344?(u=String.fromCharCode(l,c),a=1):u="�"}else u=String.fromCharCode(l);u&&(t.push(e.slice(r,n),encodeURIComponent(u)),r=n+a+1,u=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function St(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(d){return pt(d)?(e.enter(n),c(d)):t(d)}function c(d){return pt(d)&&l++<a?(e.consume(d),c):(e.exit(n),t(d))}}const yA={tokenize:bA};function bA(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),St(e,t,"linePrefix")}function a(c){return e.enter("paragraph"),l(c)}function l(c){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,u(c)}function u(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Qe(c)?(e.consume(c),e.exit("chunkText"),l):(e.consume(c),u)}}const vA={tokenize:_A},P_={tokenize:SA};function _A(e){const t=this,n=[];let r=0,a,l,u;return c;function c(v){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,d,f)(v)}return f(v)}function d(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&b();const E=t.events.length;let j=E,T;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){T=t.events[j][1].end;break}S(r);let D=E;for(;D<t.events.length;)t.events[D][1].end={...T},D++;return cr(t.events,j+1,0,t.events.slice(E)),t.events.length=D,f(v)}return c(v)}function f(v){if(r===n.length){if(!a)return x(v);if(a.currentConstruct&&a.currentConstruct.concrete)return w(v);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(P_,p,m)(v)}function p(v){return a&&b(),S(r),x(v)}function m(v){return t.parser.lazy[t.now().line]=r!==n.length,u=t.now().offset,w(v)}function x(v){return t.containerState={},e.attempt(P_,y,w)(v)}function y(v){return r++,n.push([t.currentConstruct,t.containerState]),x(v)}function w(v){if(v===null){a&&b(),S(0),e.consume(v);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),C(v)}function C(v){if(v===null){_(e.exit("chunkFlow"),!0),S(0),e.consume(v);return}return Qe(v)?(e.consume(v),_(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(v),C)}function _(v,E){const j=t.sliceStream(v);if(E&&j.push(null),v.previous=l,l&&(l.next=v),l=v,a.defineSkip(v.start),a.write(j),t.parser.lazy[v.start.line]){let T=a.events.length;for(;T--;)if(a.events[T][1].start.offset<u&&(!a.events[T][1].end||a.events[T][1].end.offset>u))return;const D=t.events.length;let L=D,O,M;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(O){M=t.events[L][1].end;break}O=!0}for(S(r),T=D;T<t.events.length;)t.events[T][1].end={...M},T++;cr(t.events,L+1,0,t.events.slice(D)),t.events.length=T}}function S(v){let E=n.length;for(;E-- >v;){const j=n[E];t.containerState=j[1],j[0].exit.call(t,e)}n.length=v}function b(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function SA(e,t,n){return St(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ja(e){if(e===null||Pt(e)||Wi(e))return 1;if(yd(e))return 2}function bd(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!r.includes(l)&&(t=l(t,n),r.push(l))}return t}const mp={name:"attention",resolveAll:wA,tokenize:CA};function wA(e,t){let n=-1,r,a,l,u,c,d,f,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;d=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 m={...e[r][1].end},x={...e[n][1].start};B_(m,-d),B_(x,d),u={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...e[r][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},l={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[r][1].end={...u.start},e[n][1].start={...c.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=_r(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=_r(f,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",l,t]]),f=_r(f,bd(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=_r(f,[["exit",l,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,f=_r(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,cr(e,r-1,n-r+3,f),n=r+f.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function CA(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Ja(r);let l;return u;function u(d){return l=d,e.enter("attentionSequence"),c(d)}function c(d){if(d===l)return e.consume(d),c;const f=e.exit("attentionSequence"),p=Ja(d),m=!p||p===2&&a||n.includes(d),x=!a||a===2&&p||n.includes(r);return f._open=!!(l===42?m:m&&(a||!x)),f._close=!!(l===42?x:x&&(p||!m)),t(d)}}function B_(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const kA={name:"autolink",tokenize:EA};function EA(e,t,n){let r=0;return a;function a(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return $n(y)?(e.consume(y),u):y===64?n(y):f(y)}function u(y){return y===43||y===45||y===46||Rn(y)?(r=1,c(y)):f(y)}function c(y){return y===58?(e.consume(y),r=0,d):(y===43||y===45||y===46||Rn(y))&&r++<32?(e.consume(y),c):(r=0,f(y))}function d(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||Gu(y)?n(y):(e.consume(y),d)}function f(y){return y===64?(e.consume(y),p):pA(y)?(e.consume(y),f):n(y)}function p(y){return Rn(y)?m(y):n(y)}function m(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):x(y)}function x(y){if((y===45||Rn(y))&&r++<63){const w=y===45?x:m;return e.consume(y),w}return n(y)}}const Fl={partial:!0,tokenize:jA};function jA(e,t,n){return r;function r(l){return pt(l)?St(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||Qe(l)?t(l):n(l)}}const V1={continuation:{tokenize:TA},exit:AA,name:"blockQuote",tokenize:NA};function NA(e,t,n){const r=this;return a;function a(u){if(u===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),l}return n(u)}function l(u){return pt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function TA(e,t,n){const r=this;return a;function a(u){return pt(u)?St(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(V1,t,n)(u)}}function AA(e){e.exit("blockQuote")}const G1={name:"characterEscape",tokenize:LA};function LA(e,t,n){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return xA(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const W1={name:"characterReference",tokenize:DA};function DA(e,t,n){const r=this;let a=0,l,u;return c;function c(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),d}function d(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),l=31,u=Rn,p(m))}function f(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=gA,p):(e.enter("characterReferenceValue"),l=7,u=fp,p(m))}function p(m){if(m===59&&a){const x=e.exit("characterReferenceValue");return u===Rn&&!cg(r.sliceSerialize(x))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(m)&&a++<l?(e.consume(m),p):n(m)}}const $_={partial:!0,tokenize:OA},z_={concrete:!0,name:"codeFenced",tokenize:RA};function RA(e,t,n){const r=this,a={partial:!0,tokenize:j};let l=0,u=0,c;return d;function d(T){return f(T)}function f(T){const D=r.events[r.events.length-1];return l=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,c=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===c?(u++,e.consume(T),p):u<3?n(T):(e.exit("codeFencedFenceSequence"),pt(T)?St(e,m,"whitespace")(T):m(T))}function m(T){return T===null||Qe(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check($_,C,E)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(T))}function x(T){return T===null||Qe(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(T)):pt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),St(e,y,"whitespace")(T)):T===96&&T===c?n(T):(e.consume(T),x)}function y(T){return T===null||Qe(T)?m(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===null||Qe(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(T)):T===96&&T===c?n(T):(e.consume(T),w)}function C(T){return e.attempt(a,E,_)(T)}function _(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),S}function S(T){return l>0&&pt(T)?St(e,b,"linePrefix",l+1)(T):b(T)}function b(T){return T===null||Qe(T)?e.check($_,C,E)(T):(e.enter("codeFlowValue"),v(T))}function v(T){return T===null||Qe(T)?(e.exit("codeFlowValue"),b(T)):(e.consume(T),v)}function E(T){return e.exit("codeFenced"),t(T)}function j(T,D,L){let O=0;return M;function M(V){return T.enter("lineEnding"),T.consume(V),T.exit("lineEnding"),W}function W(V){return T.enter("codeFencedFence"),pt(V)?St(T,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):z(V)}function z(V){return V===c?(T.enter("codeFencedFenceSequence"),R(V)):L(V)}function R(V){return V===c?(O++,T.consume(V),R):O>=u?(T.exit("codeFencedFenceSequence"),pt(V)?St(T,P,"whitespace")(V):P(V)):L(V)}function P(V){return V===null||Qe(V)?(T.exit("codeFencedFence"),D(V)):L(V)}}}function OA(e,t,n){const r=this;return a;function a(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}const pm={name:"codeIndented",tokenize:MA},IA={partial:!0,tokenize:PA};function MA(e,t,n){const r=this;return a;function a(f){return e.enter("codeIndented"),St(e,l,"linePrefix",5)(f)}function l(f){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?u(f):n(f)}function u(f){return f===null?d(f):Qe(f)?e.attempt(IA,u,d)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||Qe(f)?(e.exit("codeFlowValue"),u(f)):(e.consume(f),c)}function d(f){return e.exit("codeIndented"),t(f)}}function PA(e,t,n){const r=this;return a;function a(u){return r.parser.lazy[r.now().line]?n(u):Qe(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):St(e,l,"linePrefix",5)(u)}function l(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):Qe(u)?a(u):n(u)}}const BA={name:"codeText",previous:zA,resolve:$A,tokenize:HA};function $A(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function zA(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function HA(e,t,n){let r=0,a,l;return u;function u(m){return e.enter("codeText"),e.enter("codeTextSequence"),c(m)}function c(m){return m===96?(e.consume(m),r++,c):(e.exit("codeTextSequence"),d(m))}function d(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),d):m===96?(l=e.enter("codeTextSequence"),a=0,p(m)):Qe(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("codeTextData"),f(m))}function f(m){return m===null||m===32||m===96||Qe(m)?(e.exit("codeTextData"),d(m)):(e.consume(m),f)}function p(m){return m===96?(e.consume(m),a++,p):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",f(m))}}class UA{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&cl(this.left,r),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),cl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),cl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);cl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);cl(this.left,n.reverse())}}}function cl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function q1(e){const t={};let n=-1,r,a,l,u,c,d,f;const p=new UA(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"&&(d=r[1]._tokenizer.events,l=0,l<d.length&&d[l][1].type==="lineEndingBlank"&&(l+=2),l<d.length&&d[l][1].type==="content"))for(;++l<d.length&&d[l][1].type!=="content";)d[l][1].type==="chunkText"&&(d[l][1]._isInFirstContentOfListItem=!0,l++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,FA(p,n)),n=t[n],f=!0);else if(r[1]._container){for(l=n,a=void 0;l--;)if(u=p.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(a&&(p.get(a)[1].type="lineEndingBlank"),u[1].type="lineEnding",a=l);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;a&&(r[1].end={...p.get(a)[1].start},c=p.slice(a,n),c.unshift(r),p.splice(a,n-a+1,c))}}return cr(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function FA(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const l=[];let u=n._tokenizer;u||(u=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const c=u.events,d=[],f={};let p,m,x=-1,y=n,w=0,C=0;const _=[C];for(;y;){for(;e.get(++a)[1]!==y;);l.push(a),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),m&&u.defineSkip(y.start),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(p),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),m=y,y=y.next}for(y=n;++x<c.length;)c[x][0]==="exit"&&c[x-1][0]==="enter"&&c[x][1].type===c[x-1][1].type&&c[x][1].start.line!==c[x][1].end.line&&(C=x+1,_.push(C),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(u.events=[],y?(y._tokenizer=void 0,y.previous=void 0):_.pop(),x=_.length;x--;){const S=c.slice(_[x],_[x+1]),b=l.pop();d.push([b,b+S.length-1]),e.splice(b,2,S)}for(d.reverse(),x=-1;++x<d.length;)f[w+d[x][0]]=w+d[x][1],w+=d[x][1]-d[x][0]-1;return f}const VA={resolve:WA,tokenize:qA},GA={partial:!0,tokenize:KA};function WA(e){return q1(e),e}function qA(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?l(c):Qe(c)?e.check(GA,u,l)(c):(e.consume(c),a)}function l(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function u(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function KA(e,t,n){const r=this;return a;function a(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),St(e,l,"linePrefix")}function l(u){if(u===null||Qe(u))return n(u);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):e.interrupt(r.parser.constructs.flow,n,t)(u)}}function K1(e,t,n,r,a,l,u,c,d){const f=d||Number.POSITIVE_INFINITY;let p=0;return m;function m(S){return S===60?(e.enter(r),e.enter(a),e.enter(l),e.consume(S),e.exit(l),x):S===null||S===32||S===41||Gu(S)?n(S):(e.enter(r),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(S))}function x(S){return S===62?(e.enter(l),e.consume(S),e.exit(l),e.exit(a),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),y(S))}function y(S){return S===62?(e.exit("chunkString"),e.exit(c),x(S)):S===null||S===60||Qe(S)?n(S):(e.consume(S),S===92?w:y)}function w(S){return S===60||S===62||S===92?(e.consume(S),y):y(S)}function C(S){return!p&&(S===null||S===41||Pt(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(r),t(S)):p<f&&S===40?(e.consume(S),p++,C):S===41?(e.consume(S),p--,C):S===null||S===32||S===40||Gu(S)?n(S):(e.consume(S),S===92?_:C)}function _(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function Y1(e,t,n,r,a,l){const u=this;let c=0,d;return f;function f(y){return e.enter(r),e.enter(a),e.consume(y),e.exit(a),e.enter(l),p}function p(y){return c>999||y===null||y===91||y===93&&!d||y===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?n(y):y===93?(e.exit(l),e.enter(a),e.consume(y),e.exit(a),e.exit(r),t):Qe(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===null||y===91||y===93||Qe(y)||c++>999?(e.exit("chunkString"),p(y)):(e.consume(y),d||(d=!pt(y)),y===92?x:m)}function x(y){return y===91||y===92||y===93?(e.consume(y),c++,m):m(y)}}function X1(e,t,n,r,a,l){let u;return c;function c(x){return x===34||x===39||x===40?(e.enter(r),e.enter(a),e.consume(x),e.exit(a),u=x===40?41:x,d):n(x)}function d(x){return x===u?(e.enter(a),e.consume(x),e.exit(a),e.exit(r),t):(e.enter(l),f(x))}function f(x){return x===u?(e.exit(l),d(u)):x===null?n(x):Qe(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),St(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===u||x===null||Qe(x)?(e.exit("chunkString"),f(x)):(e.consume(x),x===92?m:p)}function m(x){return x===u||x===92?(e.consume(x),p):p(x)}}function Sl(e,t){let n;return r;function r(a){return Qe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):pt(a)?St(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const YA={name:"definition",tokenize:QA},XA={partial:!0,tokenize:JA};function QA(e,t,n){const r=this;let a;return l;function l(y){return e.enter("definition"),u(y)}function u(y){return Y1.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return a=Rr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),d):n(y)}function d(y){return Pt(y)?Sl(e,f)(y):f(y)}function f(y){return K1(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(XA,m,m)(y)}function m(y){return pt(y)?St(e,x,"whitespace")(y):x(y)}function x(y){return y===null||Qe(y)?(e.exit("definition"),r.parser.defined.push(a),t(y)):n(y)}}function JA(e,t,n){return r;function r(c){return Pt(c)?Sl(e,a)(c):n(c)}function a(c){return X1(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function l(c){return pt(c)?St(e,u,"whitespace")(c):u(c)}function u(c){return c===null||Qe(c)?t(c):n(c)}}const ZA={name:"hardBreakEscape",tokenize:eL};function eL(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return Qe(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const tL={name:"headingAtx",resolve:nL,tokenize:rL};function nL(e,t){let n=e.length-2,r=3,a,l;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},l={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},cr(e,r,n-r+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function rL(e,t,n){let r=0;return a;function a(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),u(p)}function u(p){return p===35&&r++<6?(e.consume(p),u):p===null||Pt(p)?(e.exit("atxHeadingSequence"),c(p)):n(p)}function c(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||Qe(p)?(e.exit("atxHeading"),t(p)):pt(p)?St(e,c,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),c(p))}function f(p){return p===null||p===35||Pt(p)?(e.exit("atxHeadingText"),c(p)):(e.consume(p),f)}}const sL=["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"],H_=["pre","script","style","textarea"],iL={concrete:!0,name:"htmlFlow",resolveTo:lL,tokenize:cL},aL={partial:!0,tokenize:dL},oL={partial:!0,tokenize:uL};function lL(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 cL(e,t,n){const r=this;let a,l,u,c,d;return f;function f(B){return p(B)}function p(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),x):B===47?(e.consume(B),l=!0,C):B===63?(e.consume(B),a=3,r.interrupt?t:I):$n(B)?(e.consume(B),u=String.fromCharCode(B),_):n(B)}function x(B){return B===45?(e.consume(B),a=2,y):B===91?(e.consume(B),a=5,c=0,w):$n(B)?(e.consume(B),a=4,r.interrupt?t:I):n(B)}function y(B){return B===45?(e.consume(B),r.interrupt?t:I):n(B)}function w(B){const ee="CDATA[";return B===ee.charCodeAt(c++)?(e.consume(B),c===ee.length?r.interrupt?t:z:w):n(B)}function C(B){return $n(B)?(e.consume(B),u=String.fromCharCode(B),_):n(B)}function _(B){if(B===null||B===47||B===62||Pt(B)){const ee=B===47,X=u.toLowerCase();return!ee&&!l&&H_.includes(X)?(a=1,r.interrupt?t(B):z(B)):sL.includes(u.toLowerCase())?(a=6,ee?(e.consume(B),S):r.interrupt?t(B):z(B)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):l?b(B):v(B))}return B===45||Rn(B)?(e.consume(B),u+=String.fromCharCode(B),_):n(B)}function S(B){return B===62?(e.consume(B),r.interrupt?t:z):n(B)}function b(B){return pt(B)?(e.consume(B),b):M(B)}function v(B){return B===47?(e.consume(B),M):B===58||B===95||$n(B)?(e.consume(B),E):pt(B)?(e.consume(B),v):M(B)}function E(B){return B===45||B===46||B===58||B===95||Rn(B)?(e.consume(B),E):j(B)}function j(B){return B===61?(e.consume(B),T):pt(B)?(e.consume(B),j):v(B)}function T(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),d=B,D):pt(B)?(e.consume(B),T):L(B)}function D(B){return B===d?(e.consume(B),d=null,O):B===null||Qe(B)?n(B):(e.consume(B),D)}function L(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Pt(B)?j(B):(e.consume(B),L)}function O(B){return B===47||B===62||pt(B)?v(B):n(B)}function M(B){return B===62?(e.consume(B),W):n(B)}function W(B){return B===null||Qe(B)?z(B):pt(B)?(e.consume(B),W):n(B)}function z(B){return B===45&&a===2?(e.consume(B),G):B===60&&a===1?(e.consume(B),Z):B===62&&a===4?(e.consume(B),$):B===63&&a===3?(e.consume(B),I):B===93&&a===5?(e.consume(B),U):Qe(B)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(aL,q,R)(B)):B===null||Qe(B)?(e.exit("htmlFlowData"),R(B)):(e.consume(B),z)}function R(B){return e.check(oL,P,q)(B)}function P(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),V}function V(B){return B===null||Qe(B)?R(B):(e.enter("htmlFlowData"),z(B))}function G(B){return B===45?(e.consume(B),I):z(B)}function Z(B){return B===47?(e.consume(B),u="",Q):z(B)}function Q(B){if(B===62){const ee=u.toLowerCase();return H_.includes(ee)?(e.consume(B),$):z(B)}return $n(B)&&u.length<8?(e.consume(B),u+=String.fromCharCode(B),Q):z(B)}function U(B){return B===93?(e.consume(B),I):z(B)}function I(B){return B===62?(e.consume(B),$):B===45&&a===2?(e.consume(B),I):z(B)}function $(B){return B===null||Qe(B)?(e.exit("htmlFlowData"),q(B)):(e.consume(B),$)}function q(B){return e.exit("htmlFlow"),t(B)}}function uL(e,t,n){const r=this;return a;function a(u){return Qe(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):n(u)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}function dL(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Fl,t,n)}}const hL={name:"htmlText",tokenize:fL};function fL(e,t,n){const r=this;let a,l,u;return c;function c(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),d}function d(I){return I===33?(e.consume(I),f):I===47?(e.consume(I),j):I===63?(e.consume(I),v):$n(I)?(e.consume(I),L):n(I)}function f(I){return I===45?(e.consume(I),p):I===91?(e.consume(I),l=0,w):$n(I)?(e.consume(I),b):n(I)}function p(I){return I===45?(e.consume(I),y):n(I)}function m(I){return I===null?n(I):I===45?(e.consume(I),x):Qe(I)?(u=m,Z(I)):(e.consume(I),m)}function x(I){return I===45?(e.consume(I),y):m(I)}function y(I){return I===62?G(I):I===45?x(I):m(I)}function w(I){const $="CDATA[";return I===$.charCodeAt(l++)?(e.consume(I),l===$.length?C:w):n(I)}function C(I){return I===null?n(I):I===93?(e.consume(I),_):Qe(I)?(u=C,Z(I)):(e.consume(I),C)}function _(I){return I===93?(e.consume(I),S):C(I)}function S(I){return I===62?G(I):I===93?(e.consume(I),S):C(I)}function b(I){return I===null||I===62?G(I):Qe(I)?(u=b,Z(I)):(e.consume(I),b)}function v(I){return I===null?n(I):I===63?(e.consume(I),E):Qe(I)?(u=v,Z(I)):(e.consume(I),v)}function E(I){return I===62?G(I):v(I)}function j(I){return $n(I)?(e.consume(I),T):n(I)}function T(I){return I===45||Rn(I)?(e.consume(I),T):D(I)}function D(I){return Qe(I)?(u=D,Z(I)):pt(I)?(e.consume(I),D):G(I)}function L(I){return I===45||Rn(I)?(e.consume(I),L):I===47||I===62||Pt(I)?O(I):n(I)}function O(I){return I===47?(e.consume(I),G):I===58||I===95||$n(I)?(e.consume(I),M):Qe(I)?(u=O,Z(I)):pt(I)?(e.consume(I),O):G(I)}function M(I){return I===45||I===46||I===58||I===95||Rn(I)?(e.consume(I),M):W(I)}function W(I){return I===61?(e.consume(I),z):Qe(I)?(u=W,Z(I)):pt(I)?(e.consume(I),W):O(I)}function z(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),a=I,R):Qe(I)?(u=z,Z(I)):pt(I)?(e.consume(I),z):(e.consume(I),P)}function R(I){return I===a?(e.consume(I),a=void 0,V):I===null?n(I):Qe(I)?(u=R,Z(I)):(e.consume(I),R)}function P(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||Pt(I)?O(I):(e.consume(I),P)}function V(I){return I===47||I===62||Pt(I)?O(I):n(I)}function G(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function Z(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),Q}function Q(I){return pt(I)?St(e,U,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):U(I)}function U(I){return e.enter("htmlTextData"),u(I)}}const ug={name:"labelEnd",resolveAll:xL,resolveTo:yL,tokenize:bL},mL={tokenize:vL},pL={tokenize:_L},gL={tokenize:SL};function xL(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&cr(e,0,e.length,n),e}function yL(e,t){let n=e.length,r=0,a,l,u,c;for(;n--;)if(a=e[n][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(u=n);const d={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[l][1].start},end:{...e[u][1].end}},p={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[u-2][1].start}};return c=[["enter",d,t],["enter",f,t]],c=_r(c,e.slice(l+1,l+r+3)),c=_r(c,[["enter",p,t]]),c=_r(c,bd(t.parser.constructs.insideSpan.null,e.slice(l+r+4,u-3),t)),c=_r(c,[["exit",p,t],e[u-2],e[u-1],["exit",f,t]]),c=_r(c,e.slice(u+1)),c=_r(c,[["exit",d,t]]),cr(e,l,e.length,c),e}function bL(e,t,n){const r=this;let a=r.events.length,l,u;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){l=r.events[a][1];break}return c;function c(x){return l?l._inactive?m(x):(u=r.parser.defined.includes(Rr(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),d):n(x)}function d(x){return x===40?e.attempt(mL,p,u?p:m)(x):x===91?e.attempt(pL,p,u?f:m)(x):u?p(x):m(x)}function f(x){return e.attempt(gL,p,m)(x)}function p(x){return t(x)}function m(x){return l._balanced=!0,n(x)}}function vL(e,t,n){return r;function r(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),a}function a(m){return Pt(m)?Sl(e,l)(m):l(m)}function l(m){return m===41?p(m):K1(e,u,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function u(m){return Pt(m)?Sl(e,d)(m):p(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?X1(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function f(m){return Pt(m)?Sl(e,p)(m):p(m)}function p(m){return m===41?(e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),e.exit("resource"),t):n(m)}}function _L(e,t,n){const r=this;return a;function a(c){return Y1.call(r,e,l,u,"reference","referenceMarker","referenceString")(c)}function l(c){return r.parser.defined.includes(Rr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function u(c){return n(c)}}function SL(e,t,n){return r;function r(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),a}function a(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const wL={name:"labelStartImage",resolveAll:ug.resolveAll,tokenize:CL};function CL(e,t,n){const r=this;return a;function a(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),l}function l(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),u):n(c)}function u(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const kL={name:"labelStartLink",resolveAll:ug.resolveAll,tokenize:EL};function EL(e,t,n){const r=this;return a;function a(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),l}function l(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const gm={name:"lineEnding",tokenize:jL};function jL(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),St(e,t,"linePrefix")}}const Bu={name:"thematicBreak",tokenize:NL};function NL(e,t,n){let r=0,a;return l;function l(f){return e.enter("thematicBreak"),u(f)}function u(f){return a=f,c(f)}function c(f){return f===a?(e.enter("thematicBreakSequence"),d(f)):r>=3&&(f===null||Qe(f))?(e.exit("thematicBreak"),t(f)):n(f)}function d(f){return f===a?(e.consume(f),r++,d):(e.exit("thematicBreakSequence"),pt(f)?St(e,c,"whitespace")(f):c(f))}}const Yn={continuation:{tokenize:DL},exit:OL,name:"list",tokenize:LL},TL={partial:!0,tokenize:IL},AL={partial:!0,tokenize:RL};function LL(e,t,n){const r=this,a=r.events[r.events.length-1];let l=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return c;function c(y){const w=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:fp(y)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Bu,n,f)(y):f(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(y)}return n(y)}function d(y){return fp(y)&&++u<10?(e.consume(y),d):(!r.interrupt||u<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Fl,r.interrupt?n:p,e.attempt(TL,x,m))}function p(y){return r.containerState.initialBlankLine=!0,l++,x(y)}function m(y){return pt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),x):n(y)}function x(y){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function DL(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Fl,a,l);function a(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,St(e,t,"listItemIndent",r.containerState.size+1)(c)}function l(c){return r.containerState.furtherBlankLines||!pt(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,u(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(AL,t,u)(c))}function u(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,St(e,e.attempt(Yn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function RL(e,t,n){const r=this;return St(e,a,"listItemIndent",r.containerState.size+1);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===r.containerState.size?t(l):n(l)}}function OL(e){e.exit(this.containerState.type)}function IL(e,t,n){const r=this;return St(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const u=r.events[r.events.length-1];return!pt(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const U_={name:"setextUnderline",resolveTo:ML,tokenize:PL};function ML(e,t){let n=e.length,r,a,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const u={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",l?(e.splice(a,0,["enter",u,t]),e.splice(l+1,0,["exit",e[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=u,e.push(["exit",u,t]),e}function PL(e,t,n){const r=this;let a;return l;function l(f){let p=r.events.length,m;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){m=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||m)?(e.enter("setextHeadingLine"),a=f,u(f)):n(f)}function u(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===a?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),pt(f)?St(e,d,"lineSuffix")(f):d(f))}function d(f){return f===null||Qe(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const BL={tokenize:$L};function $L(e){const t=this,n=e.attempt(Fl,r,e.attempt(this.parser.constructs.flowInitial,a,St(e,e.attempt(this.parser.constructs.flow,a,e.attempt(VA,a)),"linePrefix")));return n;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const zL={resolveAll:J1()},HL=Q1("string"),UL=Q1("text");function Q1(e){return{resolveAll:J1(e==="text"?FL:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],l=n.attempt(a,u,c);return u;function u(p){return f(p)?l(p):c(p)}function c(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),d}function d(p){return f(p)?(n.exit("data"),l(p)):(n.consume(p),d)}function f(p){if(p===null)return!0;const m=a[p];let x=-1;if(m)for(;++x<m.length;){const y=m[x];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function J1(e){return t;function t(n,r){let a=-1,l;for(;++a<=n.length;)l===void 0?n[a]&&n[a][1].type==="data"&&(l=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==l+2&&(n[l][1].end=n[a-1][1].end,n.splice(l+2,a-l-2),a=l+2),l=void 0);return e?e(n,r):n}}function FL(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let l=a.length,u=-1,c=0,d;for(;l--;){const f=a[l];if(typeof f=="string"){for(u=f.length;f.charCodeAt(u-1)===32;)c++,u--;if(u)break;u=-1}else if(f===-2)d=!0,c++;else if(f!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const f={type:n===e.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?u:r.start._bufferIndex+u,_index:r.start._index+l,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const VL={42:Yn,43:Yn,45:Yn,48:Yn,49:Yn,50:Yn,51:Yn,52:Yn,53:Yn,54:Yn,55:Yn,56:Yn,57:Yn,62:V1},GL={91:YA},WL={[-2]:pm,[-1]:pm,32:pm},qL={35:tL,42:Bu,45:[U_,Bu],60:iL,61:U_,95:Bu,96:z_,126:z_},KL={38:W1,92:G1},YL={[-5]:gm,[-4]:gm,[-3]:gm,33:wL,38:W1,42:mp,60:[kA,hL],91:kL,92:[ZA,G1],93:ug,95:mp,96:BA},XL={null:[mp,zL]},QL={null:[42,95]},JL={null:[]},ZL=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:QL,contentInitial:GL,disable:JL,document:VL,flow:qL,flowInitial:WL,insideSpan:XL,string:KL,text:YL},Symbol.toStringTag,{value:"Module"}));function eD(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},l=[];let u=[],c=[];const d={attempt:D(j),check:D(T),consume:b,enter:v,exit:E,interrupt:D(T,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:x,sliceStream:y,write:m};let p=t.tokenize.call(f,d);return t.resolveAll&&l.push(t),f;function m(W){return u=_r(u,W),_(),u[u.length-1]!==null?[]:(L(t,0),f.events=bd(l,f.events,f),f.events)}function x(W,z){return nD(y(W),z)}function y(W){return tD(u,W)}function w(){const{_bufferIndex:W,_index:z,line:R,column:P,offset:V}=r;return{_bufferIndex:W,_index:z,line:R,column:P,offset:V}}function C(W){a[W.line]=W.column,M()}function _(){let W;for(;r._index<u.length;){const z=u[r._index];if(typeof z=="string")for(W=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===W&&r._bufferIndex<z.length;)S(z.charCodeAt(r._bufferIndex));else S(z)}}function S(W){p=p(W)}function b(W){Qe(W)?(r.line++,r.column=1,r.offset+=W===-3?2:1,M()):W!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===u[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=W}function v(W,z){const R=z||{};return R.type=W,R.start=w(),f.events.push(["enter",R,f]),c.push(R),R}function E(W){const z=c.pop();return z.end=w(),f.events.push(["exit",z,f]),z}function j(W,z){L(W,z.from)}function T(W,z){z.restore()}function D(W,z){return R;function R(P,V,G){let Z,Q,U,I;return Array.isArray(P)?q(P):"tokenize"in P?q([P]):$(P);function $(ne){return K;function K(F){const te=F!==null&&ne[F],se=F!==null&&ne.null,xe=[...Array.isArray(te)?te:te?[te]:[],...Array.isArray(se)?se:se?[se]:[]];return q(xe)(F)}}function q(ne){return Z=ne,Q=0,ne.length===0?G:B(ne[Q])}function B(ne){return K;function K(F){return I=O(),U=ne,ne.partial||(f.currentConstruct=ne),ne.name&&f.parser.constructs.disable.null.includes(ne.name)?X():ne.tokenize.call(z?Object.assign(Object.create(f),z):f,d,ee,X)(F)}}function ee(ne){return W(U,I),V}function X(ne){return I.restore(),++Q<Z.length?B(Z[Q]):G}}}function L(W,z){W.resolveAll&&!l.includes(W)&&l.push(W),W.resolve&&cr(f.events,z,f.events.length-z,W.resolve(f.events.slice(z),f)),W.resolveTo&&(f.events=W.resolveTo(f.events,f))}function O(){const W=w(),z=f.previous,R=f.currentConstruct,P=f.events.length,V=Array.from(c);return{from:P,restore:G};function G(){r=W,f.previous=z,f.currentConstruct=R,f.events.length=P,c=V,M()}}function M(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function tD(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let u;if(n===a)u=[e[n].slice(r,l)];else{if(u=e.slice(n,a),r>-1){const c=u[0];typeof c=="string"?u[0]=c.slice(r):u.shift()}l>0&&u.push(e[a].slice(0,l))}return u}function nD(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const l=e[n];let u;if(typeof l=="string")u=l;else switch(l){case-5:{u="\r";break}case-4:{u=`
|
|
61
|
+
`;break}case-3:{u=`\r
|
|
62
|
+
`;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&a)continue;u=" ";break}default:u=String.fromCharCode(l)}a=l===-2,r.push(u)}return r.join("")}function rD(e){const r={constructs:U1([ZL,...(e||{}).extensions||[]]),content:a(yA),defined:[],document:a(vA),flow:a(BL),lazy:{},string:a(HL),text:a(UL)};return r;function a(l){return u;function u(c){return eD(r,l,c)}}}function sD(e){for(;!q1(e););return e}const F_=/[\0\t\n\r]/g;function iD(){let e=1,t="",n=!0,r;return a;function a(l,u,c){const d=[];let f,p,m,x,y;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(u||void 0).decode(l)),m=0,t="",n&&(l.charCodeAt(0)===65279&&m++,n=void 0);m<l.length;){if(F_.lastIndex=m,f=F_.exec(l),x=f&&f.index!==void 0?f.index:l.length,y=l.charCodeAt(x),!f){t=l.slice(m);break}if(y===10&&m===x&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),m<x&&(d.push(l.slice(m,x)),e+=x-m),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}m=x+1}return c&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const aD=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function oD(e){return e.replace(aD,lD)}function lD(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return F1(n.slice(l?2:1),l?16:10)}return cg(n)||e}const Z1={}.hasOwnProperty;function cD(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),uD(n)(sD(rD(n).document().write(iD()(e,t,!0))))}function uD(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Xe),autolinkProtocol:O,autolinkEmail:O,atxHeading:l(Oe),blockQuote:l(se),characterEscape:O,characterReference:O,codeFenced:l(xe),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(xe,u),codeText:l(oe,u),codeTextData:O,data:O,codeFlowValue:O,definition:l(ye),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l(Le),hardBreakEscape:l(Me),hardBreakTrailing:l(Me),htmlFlow:l(je,u),htmlFlowData:O,htmlText:l(je,u),htmlTextData:O,image:l(nt),label:u,link:l(Xe),listItem:l(ce),listItemValue:x,listOrdered:l(he,m),listUnordered:l(he),paragraph:l(de),reference:B,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l(Oe),strong:l($e),thematicBreak:l(ut)},exit:{atxHeading:d(),atxHeadingSequence:j,autolink:d(),autolinkEmail:te,autolinkProtocol:F,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:X,characterReferenceMarkerNumeric:X,characterReferenceValue:ne,characterReference:K,codeFenced:d(_),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:M,codeIndented:d(S),codeText:d(V),codeTextData:M,data:M,definition:d(),definitionDestinationString:E,definitionLabelString:b,definitionTitleString:v,emphasis:d(),hardBreakEscape:d(z),hardBreakTrailing:d(z),htmlFlow:d(R),htmlFlowData:M,htmlText:d(P),htmlTextData:M,image:d(Z),label:U,labelText:Q,lineEnding:W,link:d(G),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:ee,resourceDestinationString:I,resourceTitleString:$,resource:q,setextHeading:d(L),setextHeadingLineSequence:D,setextHeadingText:T,strong:d(),thematicBreak:d()}};ew(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(re){let be={type:"root",children:[]};const ke={stack:[be],tokenStack:[],config:t,enter:c,exit:f,buffer:u,resume:p,data:n},ze=[];let Ye=-1;for(;++Ye<re.length;)if(re[Ye][1].type==="listOrdered"||re[Ye][1].type==="listUnordered")if(re[Ye][0]==="enter")ze.push(Ye);else{const We=ze.pop();Ye=a(re,We,Ye)}for(Ye=-1;++Ye<re.length;){const We=t[re[Ye][0]];Z1.call(We,re[Ye][1].type)&&We[re[Ye][1].type].call(Object.assign({sliceSerialize:re[Ye][2].sliceSerialize},ke),re[Ye][1])}if(ke.tokenStack.length>0){const We=ke.tokenStack[ke.tokenStack.length-1];(We[1]||V_).call(ke,void 0,We[0])}for(be.position={start:Qs(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:Qs(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},Ye=-1;++Ye<t.transforms.length;)be=t.transforms[Ye](be)||be;return be}function a(re,be,ke){let ze=be-1,Ye=-1,We=!1,tt,_t,It,qt;for(;++ze<=ke;){const dt=re[ze];switch(dt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{dt[0]==="enter"?Ye++:Ye--,qt=void 0;break}case"lineEndingBlank":{dt[0]==="enter"&&(tt&&!qt&&!Ye&&!It&&(It=ze),qt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:qt=void 0}if(!Ye&&dt[0]==="enter"&&dt[1].type==="listItemPrefix"||Ye===-1&&dt[0]==="exit"&&(dt[1].type==="listUnordered"||dt[1].type==="listOrdered")){if(tt){let Cn=ze;for(_t=void 0;Cn--;){const jt=re[Cn];if(jt[1].type==="lineEnding"||jt[1].type==="lineEndingBlank"){if(jt[0]==="exit")continue;_t&&(re[_t][1].type="lineEndingBlank",We=!0),jt[1].type="lineEnding",_t=Cn}else if(!(jt[1].type==="linePrefix"||jt[1].type==="blockQuotePrefix"||jt[1].type==="blockQuotePrefixWhitespace"||jt[1].type==="blockQuoteMarker"||jt[1].type==="listItemIndent"))break}It&&(!_t||It<_t)&&(tt._spread=!0),tt.end=Object.assign({},_t?re[_t][1].start:dt[1].end),re.splice(_t||ze,0,["exit",tt,dt[2]]),ze++,ke++}if(dt[1].type==="listItemPrefix"){const Cn={type:"listItem",_spread:!1,start:Object.assign({},dt[1].start),end:void 0};tt=Cn,re.splice(ze,0,["enter",Cn,dt[2]]),ze++,ke++,It=void 0,qt=!0}}}return re[be][1]._spread=We,ke}function l(re,be){return ke;function ke(ze){c.call(this,re(ze),ze),be&&be.call(this,ze)}}function u(){this.stack.push({type:"fragment",children:[]})}function c(re,be,ke){this.stack[this.stack.length-1].children.push(re),this.stack.push(re),this.tokenStack.push([be,ke||void 0]),re.position={start:Qs(be.start),end:void 0}}function d(re){return be;function be(ke){re&&re.call(this,ke),f.call(this,ke)}}function f(re,be){const ke=this.stack.pop(),ze=this.tokenStack.pop();if(ze)ze[0].type!==re.type&&(be?be.call(this,re,ze[0]):(ze[1]||V_).call(this,re,ze[0]));else throw new Error("Cannot close `"+re.type+"` ("+_l({start:re.start,end:re.end})+"): it’s not open");ke.position.end=Qs(re.end)}function p(){return lg(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function x(re){if(this.data.expectingFirstListItemValue){const be=this.stack[this.stack.length-2];be.start=Number.parseInt(this.sliceSerialize(re),10),this.data.expectingFirstListItemValue=void 0}}function y(){const re=this.resume(),be=this.stack[this.stack.length-1];be.lang=re}function w(){const re=this.resume(),be=this.stack[this.stack.length-1];be.meta=re}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){const re=this.resume(),be=this.stack[this.stack.length-1];be.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const re=this.resume(),be=this.stack[this.stack.length-1];be.value=re.replace(/(\r?\n|\r)$/g,"")}function b(re){const be=this.resume(),ke=this.stack[this.stack.length-1];ke.label=be,ke.identifier=Rr(this.sliceSerialize(re)).toLowerCase()}function v(){const re=this.resume(),be=this.stack[this.stack.length-1];be.title=re}function E(){const re=this.resume(),be=this.stack[this.stack.length-1];be.url=re}function j(re){const be=this.stack[this.stack.length-1];if(!be.depth){const ke=this.sliceSerialize(re).length;be.depth=ke}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function D(re){const be=this.stack[this.stack.length-1];be.depth=this.sliceSerialize(re).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function O(re){const ke=this.stack[this.stack.length-1].children;let ze=ke[ke.length-1];(!ze||ze.type!=="text")&&(ze=He(),ze.position={start:Qs(re.start),end:void 0},ke.push(ze)),this.stack.push(ze)}function M(re){const be=this.stack.pop();be.value+=this.sliceSerialize(re),be.position.end=Qs(re.end)}function W(re){const be=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ke=be.children[be.children.length-1];ke.position.end=Qs(re.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(be.type)&&(O.call(this,re),M.call(this,re))}function z(){this.data.atHardBreak=!0}function R(){const re=this.resume(),be=this.stack[this.stack.length-1];be.value=re}function P(){const re=this.resume(),be=this.stack[this.stack.length-1];be.value=re}function V(){const re=this.resume(),be=this.stack[this.stack.length-1];be.value=re}function G(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const be=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=be,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function Z(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const be=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=be,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function Q(re){const be=this.sliceSerialize(re),ke=this.stack[this.stack.length-2];ke.label=oD(be),ke.identifier=Rr(be).toLowerCase()}function U(){const re=this.stack[this.stack.length-1],be=this.resume(),ke=this.stack[this.stack.length-1];if(this.data.inReference=!0,ke.type==="link"){const ze=re.children;ke.children=ze}else ke.alt=be}function I(){const re=this.resume(),be=this.stack[this.stack.length-1];be.url=re}function $(){const re=this.resume(),be=this.stack[this.stack.length-1];be.title=re}function q(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function ee(re){const be=this.resume(),ke=this.stack[this.stack.length-1];ke.label=be,ke.identifier=Rr(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function X(re){this.data.characterReferenceType=re.type}function ne(re){const be=this.sliceSerialize(re),ke=this.data.characterReferenceType;let ze;ke?(ze=F1(be,ke==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ze=cg(be);const Ye=this.stack[this.stack.length-1];Ye.value+=ze}function K(re){const be=this.stack.pop();be.position.end=Qs(re.end)}function F(re){M.call(this,re);const be=this.stack[this.stack.length-1];be.url=this.sliceSerialize(re)}function te(re){M.call(this,re);const be=this.stack[this.stack.length-1];be.url="mailto:"+this.sliceSerialize(re)}function se(){return{type:"blockquote",children:[]}}function xe(){return{type:"code",lang:null,meta:null,value:""}}function oe(){return{type:"inlineCode",value:""}}function ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Le(){return{type:"emphasis",children:[]}}function Oe(){return{type:"heading",depth:0,children:[]}}function Me(){return{type:"break"}}function je(){return{type:"html",value:""}}function nt(){return{type:"image",title:null,url:"",alt:null}}function Xe(){return{type:"link",title:null,url:"",children:[]}}function he(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function ce(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function de(){return{type:"paragraph",children:[]}}function $e(){return{type:"strong",children:[]}}function He(){return{type:"text",value:""}}function ut(){return{type:"thematicBreak"}}}function Qs(e){return{line:e.line,column:e.column,offset:e.offset}}function ew(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ew(e,r):dD(e,r)}}function dD(e,t){let n;for(n in t)if(Z1.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 V_(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+_l({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+_l({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+_l({start:t.start,end:t.end})+") is still open")}function hD(e){const t=this;t.parser=n;function n(r){return cD(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function fD(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 mD(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
63
|
+
`}]}function pD(e,t){const n=t.value?t.value+`
|
|
64
|
+
`:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let l={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function gD(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xD(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yD(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=lo(r.toLowerCase()),l=e.footnoteOrder.indexOf(r);let u,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),u=e.footnoteOrder.length):u=l+1,c+=1,e.footnoteCounts.set(r,c);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);const f={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,f),e.applyData(t,f)}function bD(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 vD(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function tw(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),l=a[0];l&&l.type==="text"?l.value="["+l.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=r:a.push({type:"text",value:r}),a}function _D(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return tw(e,t);const a={src:lo(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,l),e.applyData(t,l)}function SD(e,t){const n={src:lo(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 wD(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 CD(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return tw(e,t);const a={href:lo(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function kD(e,t){const n={href:lo(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 ED(e,t,n){const r=e.all(t),a=n?jD(n):nw(t),l={},u=[];if(typeof t.checked=="boolean"){const p=r[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},r.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const p=r[c];(a||c!==0||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
|
|
65
|
+
`}),p.type==="element"&&p.tagName==="p"&&!a?u.push(...p.children):u.push(p)}const d=r[r.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&u.push({type:"text",value:`
|
|
66
|
+
`});const f={type:"element",tagName:"li",properties:l,children:u};return e.patch(t,f),e.applyData(t,f)}function jD(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=nw(n[r])}return t}function nw(e){const t=e.spread;return t??e.children.length>1}function ND(e,t){const n={},r=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<r.length;){const u=r[a];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,l),e.applyData(t,l)}function TD(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function AD(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function LD(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DD(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],u),a.push(u)}if(n.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=sg(t.children[1]),d=I1(t.children[t.children.length-1]);c&&d&&(u.position={start:c,end:d}),a.push(u)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,l),e.applyData(t,l)}function RD(e,t,n){const r=n?n.children:void 0,l=(r?r.indexOf(t):1)===0?"th":"td",u=n&&n.type==="table"?n.align:void 0,c=u?u.length:t.children.length;let d=-1;const f=[];for(;++d<c;){const m=t.children[d],x={},y=u?u[d]:void 0;y&&(x.align=y);let w={type:"element",tagName:l,properties:x,children:[]};m&&(w.children=e.all(m),e.patch(m,w),w=e.applyData(m,w)),f.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,p),e.applyData(t,p)}function OD(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const G_=9,W_=32;function ID(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const l=[];for(;r;)l.push(q_(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return l.push(q_(t.slice(a),a>0,!1)),l.join("")}function q_(e,t,n){let r=0,a=e.length;if(t){let l=e.codePointAt(r);for(;l===G_||l===W_;)r++,l=e.codePointAt(r)}if(n){let l=e.codePointAt(a-1);for(;l===G_||l===W_;)a--,l=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function MD(e,t){const n={type:"text",value:ID(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function PD(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const BD={blockquote:fD,break:mD,code:pD,delete:gD,emphasis:xD,footnoteReference:yD,heading:bD,html:vD,imageReference:_D,image:SD,inlineCode:wD,linkReference:CD,link:kD,listItem:ED,list:ND,paragraph:TD,root:AD,strong:LD,table:DD,tableCell:OD,tableRow:RD,text:MD,thematicBreak:PD,toml:fu,yaml:fu,definition:fu,footnoteDefinition:fu};function fu(){}const rw=-1,vd=0,wl=1,Wu=2,dg=3,hg=4,fg=5,mg=6,sw=7,iw=8,K_=typeof self=="object"?self:globalThis,$D=(e,t)=>{const n=(a,l)=>(e.set(l,a),a),r=a=>{if(e.has(a))return e.get(a);const[l,u]=t[a];switch(l){case vd:case rw:return n(u,a);case wl:{const c=n([],a);for(const d of u)c.push(r(d));return c}case Wu:{const c=n({},a);for(const[d,f]of u)c[r(d)]=r(f);return c}case dg:return n(new Date(u),a);case hg:{const{source:c,flags:d}=u;return n(new RegExp(c,d),a)}case fg:{const c=n(new Map,a);for(const[d,f]of u)c.set(r(d),r(f));return c}case mg:{const c=n(new Set,a);for(const d of u)c.add(r(d));return c}case sw:{const{name:c,message:d}=u;return n(new K_[c](d),a)}case iw:return n(BigInt(u),a);case"BigInt":return n(Object(BigInt(u)),a);case"ArrayBuffer":return n(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:c}=new Uint8Array(u);return n(new DataView(c),u)}}return n(new K_[l](u),a)};return r},Y_=e=>$D(new Map,e)(0),Ma="",{toString:zD}={},{keys:HD}=Object,ul=e=>{const t=typeof e;if(t!=="object"||!e)return[vd,t];const n=zD.call(e).slice(8,-1);switch(n){case"Array":return[wl,Ma];case"Object":return[Wu,Ma];case"Date":return[dg,Ma];case"RegExp":return[hg,Ma];case"Map":return[fg,Ma];case"Set":return[mg,Ma];case"DataView":return[wl,n]}return n.includes("Array")?[wl,n]:n.includes("Error")?[sw,n]:[Wu,n]},mu=([e,t])=>e===vd&&(t==="function"||t==="symbol"),UD=(e,t,n,r)=>{const a=(u,c)=>{const d=r.push(u)-1;return n.set(c,d),d},l=u=>{if(n.has(u))return n.get(u);let[c,d]=ul(u);switch(c){case vd:{let p=u;switch(d){case"bigint":c=iw,p=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return a([rw],u)}return a([c,p],u)}case wl:{if(d){let x=u;return d==="DataView"?x=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(u)),a([d,[...x]],u)}const p=[],m=a([c,p],u);for(const x of u)p.push(l(x));return m}case Wu:{if(d)switch(d){case"BigInt":return a([d,u.toString()],u);case"Boolean":case"Number":case"String":return a([d,u.valueOf()],u)}if(t&&"toJSON"in u)return l(u.toJSON());const p=[],m=a([c,p],u);for(const x of HD(u))(e||!mu(ul(u[x])))&&p.push([l(x),l(u[x])]);return m}case dg:return a([c,u.toISOString()],u);case hg:{const{source:p,flags:m}=u;return a([c,{source:p,flags:m}],u)}case fg:{const p=[],m=a([c,p],u);for(const[x,y]of u)(e||!(mu(ul(x))||mu(ul(y))))&&p.push([l(x),l(y)]);return m}case mg:{const p=[],m=a([c,p],u);for(const x of u)(e||!mu(ul(x)))&&p.push(l(x));return m}}const{message:f}=u;return a([c,{name:d,message:f}],u)};return l},X_=(e,{json:t,lossy:n}={})=>{const r=[];return UD(!(t||n),!!t,new Map,r)(e),r},qu=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Y_(X_(e,t)):structuredClone(e):(e,t)=>Y_(X_(e,t));function FD(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 VD(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function GD(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||FD,r=e.options.footnoteBackLabel||VD,a=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[d]);if(!f)continue;const p=e.all(f),m=String(f.identifier).toUpperCase(),x=lo(m.toLowerCase());let y=0;const w=[],C=e.footnoteCounts.get(m);for(;C!==void 0&&++y<=C;){w.length>0&&w.push({type:"text",value:" "});let b=typeof n=="string"?n:n(d,y);typeof b=="string"&&(b={type:"text",value:b}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(d,y),className:["data-footnote-backref"]},children:Array.isArray(b)?b:[b]})}const _=p[p.length-1];if(_&&_.type==="element"&&_.tagName==="p"){const b=_.children[_.children.length-1];b&&b.type==="text"?b.value+=" ":_.children.push({type:"text",value:" "}),_.children.push(...w)}else p.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(p,!0)};e.patch(f,S),c.push(S)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...qu(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
|
|
67
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
|
|
68
|
+
`}]}}const _d=(function(e){if(e==null)return YD;if(typeof e=="function")return Sd(e);if(typeof e=="object")return Array.isArray(e)?WD(e):qD(e);if(typeof e=="string")return KD(e);throw new Error("Expected function, string, or object as test")});function WD(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=_d(e[n]);return Sd(r);function r(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function qD(e){const t=e;return Sd(n);function n(r){const a=r;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function KD(e){return Sd(t);function t(n){return n&&n.type===e}}function Sd(e){return t;function t(n,r,a){return!!(XD(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function YD(){return!0}function XD(e){return e!==null&&typeof e=="object"&&"type"in e}const aw=[],QD=!0,pp=!1,JD="skip";function ow(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const l=_d(a),u=r?-1:1;c(e,void 0,[])();function c(d,f,p){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const y=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return x;function x(){let y=aw,w,C,_;if((!t||l(d,f,p[p.length-1]||void 0))&&(y=ZD(n(d,p)),y[0]===pp))return y;if("children"in d&&d.children){const S=d;if(S.children&&y[0]!==JD)for(C=(r?S.children.length:-1)+u,_=p.concat(S);C>-1&&C<S.children.length;){const b=S.children[C];if(w=c(b,C,_)(),w[0]===pp)return w;C=typeof w[1]=="number"?w[1]:C+u}}return y}}}function ZD(e){return Array.isArray(e)?e:typeof e=="number"?[QD,e]:e==null?aw:[e]}function pg(e,t,n,r){let a,l,u;typeof t=="function"&&typeof n!="function"?(l=void 0,u=t,a=n):(l=t,u=n,a=r),ow(e,l,c,a);function c(d,f){const p=f[f.length-1],m=p?p.children.indexOf(d):void 0;return u(d,m,p)}}const gp={}.hasOwnProperty,e3={};function t3(e,t){const n=t||e3,r=new Map,a=new Map,l=new Map,u={...BD,...n.handlers},c={all:f,applyData:r3,definitionById:r,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:u,one:d,options:n,patch:n3,wrap:i3};return pg(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?r:a,x=String(p.identifier).toUpperCase();m.has(x)||m.set(x,p)}}),c;function d(p,m){const x=p.type,y=c.handlers[x];if(gp.call(c.handlers,x)&&y)return y(c,p,m);if(c.options.passThrough&&c.options.passThrough.includes(x)){if("children"in p){const{children:C,..._}=p,S=qu(_);return S.children=c.all(p),S}return qu(p)}return(c.options.unknownHandler||s3)(c,p,m)}function f(p){const m=[];if("children"in p){const x=p.children;let y=-1;for(;++y<x.length;){const w=c.one(x[y],p);if(w){if(y&&x[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Q_(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=Q_(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function n3(e,t){e.position&&(t.position=VT(e))}function r3(e,t){let n=t;if(e&&e.data){const r=e.data.hName,a=e.data.hChildren,l=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const u="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:u}}n.type==="element"&&l&&Object.assign(n.properties,qu(l)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function s3(e,t){const n=t.data||{},r="value"in t&&!(gp.call(n,"hProperties")||gp.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 i3(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
69
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
70
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
71
|
+
`}),n}function Q_(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function J_(e,t){const n=t3(e,t),r=n.one(e,void 0),a=GD(n),l=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
|
|
72
|
+
`},a),l}function a3(e,t){return e&&"run"in e?async function(n,r){const a=J_(n,{file:r,...t});await e.run(a,r)}:function(n,r){return J_(n,{file:r,...e||t})}}function Z_(e){if(e)throw e}var xm,e0;function o3(){if(e0)return xm;e0=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},l=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var p=e.call(f,"constructor"),m=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!p&&!m)return!1;var x;for(x in f);return typeof x>"u"||e.call(f,x)},u=function(f,p){n&&p.name==="__proto__"?n(f,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):f[p.name]=p.newValue},c=function(f,p){if(p==="__proto__")if(e.call(f,p)){if(r)return r(f,p).value}else return;return f[p]};return xm=function d(){var f,p,m,x,y,w,C=arguments[0],_=1,S=arguments.length,b=!1;for(typeof C=="boolean"&&(b=C,C=arguments[1]||{},_=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});_<S;++_)if(f=arguments[_],f!=null)for(p in f)m=c(C,p),x=c(f,p),C!==x&&(b&&x&&(l(x)||(y=a(x)))?(y?(y=!1,w=m&&a(m)?m:[]):w=m&&l(m)?m:{},u(C,{name:p,newValue:d(b,w,x)})):typeof x<"u"&&u(C,{name:p,newValue:x}));return C},xm}var l3=o3();const ym=ud(l3);function xp(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 c3(){const e=[],t={run:n,use:r};return t;function n(...a){let l=-1;const u=a.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);c(null,...a);function c(d,...f){const p=e[++l];let m=-1;if(d){u(d);return}for(;++m<a.length;)(f[m]===null||f[m]===void 0)&&(f[m]=a[m]);a=f,p?u3(p,c)(...f):u(null,...f)}}function r(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function u3(e,t){let n;return r;function r(...u){const c=e.length>u.length;let d;c&&u.push(a);try{d=e.apply(this,u)}catch(f){const p=f;if(c&&n)throw p;return a(p)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,a):d instanceof Error?a(d):l(d))}function a(u,...c){n||(n=!0,t(u,...c))}function l(u){a(null,u)}}const Vr={basename:d3,dirname:h3,extname:f3,join:m3,sep:"/"};function d3(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Vl(e);let n=0,r=-1,a=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else r<0&&(l=!0,r=a+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let u=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else u<0&&(l=!0,u=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(r=a):(c=-1,r=u));return n===r?r=u:r<0&&(r=e.length),e.slice(n,r)}function h3(e){if(Vl(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function f3(e){Vl(e);let t=e.length,n=-1,r=0,a=-1,l=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){r=t+1;break}continue}n<0&&(u=!0,n=t+1),c===46?a<0?a=t:l!==1&&(l=1):a>-1&&(l=-1)}return a<0||n<0||l===0||l===1&&a===n-1&&a===r+1?"":e.slice(a,n)}function m3(...e){let t=-1,n;for(;++t<e.length;)Vl(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":p3(n)}function p3(e){Vl(e);const t=e.codePointAt(0)===47;let n=g3(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function g3(e,t){let n="",r=0,a=-1,l=0,u=-1,c,d;for(;++u<=e.length;){if(u<e.length)c=e.codePointAt(u);else{if(c===47)break;c=47}if(c===47){if(!(a===u-1||l===1))if(a!==u-1&&l===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),a=u,l=0;continue}}else if(n.length>0){n="",r=0,a=u,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,u):n=e.slice(a+1,u),r=u-a-1;a=u,l=0}else c===46&&l>-1?l++:l=-1}return n}function Vl(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const x3={cwd:y3};function y3(){return"/"}function yp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function b3(e){if(typeof e=="string")e=new URL(e);else if(!yp(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 v3(e)}function v3(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const bm=["history","path","basename","stem","extname","dirname"];class lw{constructor(t){let n;t?yp(t)?n={path:t}:typeof t=="string"||_3(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":x3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<bm.length;){const l=bm[r];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let a;for(a in n)bm.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Vr.basename(this.path):void 0}set basename(t){_m(t,"basename"),vm(t,"basename"),this.path=Vr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Vr.dirname(this.path):void 0}set dirname(t){t0(this.basename,"dirname"),this.path=Vr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Vr.extname(this.path):void 0}set extname(t){if(vm(t,"extname"),t0(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=Vr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){yp(t)&&(t=b3(t)),_m(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Vr.basename(this.path,this.extname):void 0}set stem(t){_m(t,"stem"),vm(t,"stem"),this.path=Vr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const a=this.message(t,n,r);throw a.fatal=!0,a}info(t,n,r){const a=this.message(t,n,r);return a.fatal=void 0,a}message(t,n,r){const a=new On(t,n,r);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function vm(e,t){if(e&&e.includes(Vr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Vr.sep+"`")}function _m(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function t0(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function _3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const S3=(function(e){const r=this.constructor.prototype,a=r[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,r),l}),w3={}.hasOwnProperty;class gg extends S3{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=c3()}copy(){const t=new gg;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ym(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Cm("data",this.frozen),this.namespace[t]=n,this):w3.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Cm("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const a=n.call(t,...r);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=pu(t),r=this.parser||this.Parser;return Sm("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Sm("process",this.parser||this.Parser),wm("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,u){const c=pu(t),d=r.parse(c);r.run(d,c,function(p,m,x){if(p||!m||!x)return f(p);const y=m,w=r.stringify(y,x);E3(w)?x.value=w:x.result=w,f(p,x)});function f(p,m){p||!m?u(p):l?l(m):n(void 0,m)}}}processSync(t){let n=!1,r;return this.freeze(),Sm("processSync",this.parser||this.Parser),wm("processSync",this.compiler||this.Compiler),this.process(t,a),r0("processSync","process",n),r;function a(l,u){n=!0,Z_(l),r=u}}run(t,n,r){n0(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?l(void 0,r):new Promise(l);function l(u,c){const d=pu(n);a.run(t,d,f);function f(p,m,x){const y=m||t;p?c(p):u?u(y):r(void 0,y,x)}}}runSync(t,n){let r=!1,a;return this.run(t,n,l),r0("runSync","run",r),a;function l(u,c){Z_(u),a=c,r=!0}}stringify(t,n){this.freeze();const r=pu(n),a=this.compiler||this.Compiler;return wm("stringify",a),n0(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(Cm("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):u(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(f){if(typeof f=="function")d(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[p,...m]=f;d(p,m)}else u(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function u(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(f.plugins),f.settings&&(a.settings=ym(!0,a.settings,f.settings))}function c(f){let p=-1;if(f!=null)if(Array.isArray(f))for(;++p<f.length;){const m=f[p];l(m)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function d(f,p){let m=-1,x=-1;for(;++m<r.length;)if(r[m][0]===f){x=m;break}if(x===-1)r.push([f,...p]);else if(p.length>0){let[y,...w]=p;const C=r[x][1];xp(C)&&xp(y)&&(y=ym(!0,C,y)),r[x]=[f,y,...w]}}}}const C3=new gg().freeze();function Sm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function wm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Cm(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 n0(e){if(!xp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function r0(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function pu(e){return k3(e)?e:new lw(e)}function k3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function E3(e){return typeof e=="string"||j3(e)}function j3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const N3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",s0=[],i0={allowDangerousHtml:!0},T3=/^(https?|ircs?|mailto|xmpp)$/i,A3=[{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 L3(e){const t=D3(e),n=R3(e);return O3(t.runSync(t.parse(n),n),e)}function D3(e){const t=e.rehypePlugins||s0,n=e.remarkPlugins||s0,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...i0}:i0;return C3().use(hD).use(n).use(a3,r).use(t)}function R3(e){const t=e.children||"",n=new lw;return typeof t=="string"&&(n.value=t),n}function O3(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,l=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||I3;for(const p of A3)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+N3+p.id,void 0);return pg(e,f),YT(e,{Fragment:i.Fragment,components:a,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function f(p,m,x){if(p.type==="raw"&&x&&typeof m=="number")return u?x.children.splice(m,1):x.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let y;for(y in mm)if(Object.hasOwn(mm,y)&&Object.hasOwn(p.properties,y)){const w=p.properties[y],C=mm[y];(C===null||C.includes(p.tagName))&&(p.properties[y]=d(String(w||""),y,p))}}if(p.type==="element"){let y=n?!n.includes(p.tagName):l?l.includes(p.tagName):!1;if(!y&&r&&typeof m=="number"&&(y=!r(p,m,x)),y&&x&&typeof m=="number")return c&&p.children?x.children.splice(m,1,...p.children):x.children.splice(m,1),m}}}function I3(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||r!==-1&&t>r||T3.test(e.slice(0,t))?e:""}function a0(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function M3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function P3(e,t,n){const a=_d((n||{}).ignore||[]),l=B3(t);let u=-1;for(;++u<l.length;)ow(e,"text",c);function c(f,p){let m=-1,x;for(;++m<p.length;){const y=p[m],w=x?x.children:void 0;if(a(y,w?w.indexOf(y):void 0,x))return;x=y}if(x)return d(f,p)}function d(f,p){const m=p[p.length-1],x=l[u][0],y=l[u][1];let w=0;const _=m.children.indexOf(f);let S=!1,b=[];x.lastIndex=0;let v=x.exec(f.value);for(;v;){const E=v.index,j={index:v.index,input:v.input,stack:[...p,f]};let T=y(...v,j);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?x.lastIndex=E+1:(w!==E&&b.push({type:"text",value:f.value.slice(w,E)}),Array.isArray(T)?b.push(...T):T&&b.push(T),w=E+v[0].length,S=!0),!x.global)break;v=x.exec(f.value)}return S?(w<f.value.length&&b.push({type:"text",value:f.value.slice(w)}),m.children.splice(_,1,...b)):b=[f],_+b.length}}function B3(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const a=n[r];t.push([$3(a[0]),z3(a[1])])}return t}function $3(e){return typeof e=="string"?new RegExp(M3(e),"g"):e}function z3(e){return typeof e=="function"?e:function(){return e}}const km="phrasing",Em=["autolink","link","image","label"];function H3(){return{transforms:[K3],enter:{literalAutolink:F3,literalAutolinkEmail:jm,literalAutolinkHttp:jm,literalAutolinkWww:jm},exit:{literalAutolink:q3,literalAutolinkEmail:W3,literalAutolinkHttp:V3,literalAutolinkWww:G3}}}function U3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:km,notInConstruct:Em},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:km,notInConstruct:Em},{character:":",before:"[ps]",after:"\\/",inConstruct:km,notInConstruct:Em}]}}function F3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function jm(e){this.config.enter.autolinkProtocol.call(this,e)}function V3(e){this.config.exit.autolinkProtocol.call(this,e)}function G3(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 W3(e){this.config.exit.autolinkEmail.call(this,e)}function q3(e){this.exit(e)}function K3(e){P3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Y3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),X3]],{ignore:["link","linkReference"]})}function Y3(e,t,n,r,a){let l="";if(!cw(a)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!Q3(n)))return!1;const u=J3(n+r);if(!u[0])return!1;const c={type:"link",title:null,url:l+t+u[0],children:[{type:"text",value:t+u[0]}]};return u[1]?[c,{type:"text",value:u[1]}]:c}function X3(e,t,n,r){return!cw(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Q3(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 J3(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=a0(e,"(");let l=a0(e,")");for(;r!==-1&&a>l;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),l++;return[e,n]}function cw(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Wi(n)||yd(n))&&(!t||n!==47)}uw.peek=o5;function Z3(){this.buffer()}function e5(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function t5(){this.buffer()}function n5(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function r5(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Rr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function s5(e){this.exit(e)}function i5(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Rr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function a5(e){this.exit(e)}function o5(){return"["}function uw(e,t,n,r){const a=n.createTracker(r);let l=a.move("[^");const u=n.enter("footnoteReference"),c=n.enter("reference");return l+=a.move(n.safe(n.associationId(e),{after:"]",before:l})),c(),u(),l+=a.move("]"),l}function l5(){return{enter:{gfmFootnoteCallString:Z3,gfmFootnoteCall:e5,gfmFootnoteDefinitionLabelString:t5,gfmFootnoteDefinition:n5},exit:{gfmFootnoteCallString:r5,gfmFootnoteCall:s5,gfmFootnoteDefinitionLabelString:i5,gfmFootnoteDefinition:a5}}}function c5(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:uw},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,l,u){const c=l.createTracker(u);let d=c.move("[^");const f=l.enter("footnoteDefinition"),p=l.enter("label");return d+=c.move(l.safe(l.associationId(r),{before:d,after:"]"})),p(),d+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),d+=c.move((t?`
|
|
73
|
+
`:" ")+l.indentLines(l.containerFlow(r,c.current()),t?dw:u5))),f(),d}}function u5(e,t,n){return t===0?e:dw(e,t,n)}function dw(e,t,n){return(n?"":" ")+e}const d5=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];hw.peek=g5;function h5(){return{canContainEols:["delete"],enter:{strikethrough:m5},exit:{strikethrough:p5}}}function f5(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:d5}],handlers:{delete:hw}}}function m5(e){this.enter({type:"delete",children:[]},e)}function p5(e){this.exit(e)}function hw(e,t,n,r){const a=n.createTracker(r),l=n.enter("strikethrough");let u=a.move("~~");return u+=n.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),l(),u}function g5(){return"~"}function x5(e){return e.length}function y5(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||x5,l=[],u=[],c=[],d=[];let f=0,p=-1;for(;++p<e.length;){const C=[],_=[];let S=-1;for(e[p].length>f&&(f=e[p].length);++S<e[p].length;){const b=b5(e[p][S]);if(n.alignDelimiters!==!1){const v=a(b);_[S]=v,(d[S]===void 0||v>d[S])&&(d[S]=v)}C.push(b)}u[p]=C,c[p]=_}let m=-1;if(typeof r=="object"&&"length"in r)for(;++m<f;)l[m]=o0(r[m]);else{const C=o0(r);for(;++m<f;)l[m]=C}m=-1;const x=[],y=[];for(;++m<f;){const C=l[m];let _="",S="";C===99?(_=":",S=":"):C===108?_=":":C===114&&(S=":");let b=n.alignDelimiters===!1?1:Math.max(1,d[m]-_.length-S.length);const v=_+"-".repeat(b)+S;n.alignDelimiters!==!1&&(b=_.length+b+S.length,b>d[m]&&(d[m]=b),y[m]=b),x[m]=v}u.splice(1,0,x),c.splice(1,0,y),p=-1;const w=[];for(;++p<u.length;){const C=u[p],_=c[p];m=-1;const S=[];for(;++m<f;){const b=C[m]||"";let v="",E="";if(n.alignDelimiters!==!1){const j=d[m]-(_[m]||0),T=l[m];T===114?v=" ".repeat(j):T===99?j%2?(v=" ".repeat(j/2+.5),E=" ".repeat(j/2-.5)):(v=" ".repeat(j/2),E=v):E=" ".repeat(j)}n.delimiterStart!==!1&&!m&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&b==="")&&(n.delimiterStart!==!1||m)&&S.push(" "),n.alignDelimiters!==!1&&S.push(v),S.push(b),n.alignDelimiters!==!1&&S.push(E),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||m!==f-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
|
|
74
|
+
`)}function b5(e){return e==null?"":String(e)}function o0(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function v5(e,t,n,r){const a=n.enter("blockquote"),l=n.createTracker(r);l.move("> "),l.shift(2);const u=n.indentLines(n.containerFlow(e,l.current()),_5);return a(),u}function _5(e,t,n){return">"+(n?"":" ")+e}function S5(e,t){return l0(e,t.inConstruct,!0)&&!l0(e,t.notInConstruct,!1)}function l0(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 c0(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
75
|
+
`&&S5(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
76
|
+
`}function w5(e,t){const n=String(e);let r=n.indexOf(t),a=r,l=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++l>u&&(u=l):l=1,a=r+t.length,r=n.indexOf(t,a);return u}function C5(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 k5(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 E5(e,t,n,r){const a=k5(n),l=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(C5(e,n)){const m=n.enter("codeIndented"),x=n.indentLines(l,j5);return m(),x}const c=n.createTracker(r),d=a.repeat(Math.max(w5(l,a)+1,3)),f=n.enter("codeFenced");let p=c.move(d);if(e.lang){const m=n.enter(`codeFencedLang${u}`);p+=c.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...c.current()})),m()}if(e.lang&&e.meta){const m=n.enter(`codeFencedMeta${u}`);p+=c.move(" "),p+=c.move(n.safe(e.meta,{before:p,after:`
|
|
77
|
+
`,encode:["`"],...c.current()})),m()}return p+=c.move(`
|
|
78
|
+
`),l&&(p+=c.move(l+`
|
|
79
|
+
`)),p+=c.move(d),f(),p}function j5(e,t,n){return(n?"":" ")+e}function xg(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 N5(e,t,n,r){const a=xg(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("definition");let c=n.enter("label");const d=n.createTracker(r);let f=d.move("[");return f+=d.move(n.safe(n.associationId(e),{before:f,after:"]",...d.current()})),f+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(e.url,{before:f,after:e.title?" ":`
|
|
80
|
+
`,...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),f+=d.move(" "+a),f+=d.move(n.safe(e.title,{before:f,after:a,...d.current()})),f+=d.move(a),c()),u(),f}function T5(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 Al(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ku(e,t,n){const r=Ja(e),a=Ja(t);return r===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}fw.peek=A5;function fw(e,t,n,r){const a=T5(n),l=n.enter("emphasis"),u=n.createTracker(r),c=u.move(a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const f=d.charCodeAt(0),p=Ku(r.before.charCodeAt(r.before.length-1),f,a);p.inside&&(d=Al(f)+d.slice(1));const m=d.charCodeAt(d.length-1),x=Ku(r.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+Al(m));const y=u.move(a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function A5(e,t,n){return n.options.emphasis||"*"}function L5(e,t){let n=!1;return pg(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,pp}),!!((!e.depth||e.depth<3)&&lg(e)&&(t.options.setext||n))}function D5(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(r);if(L5(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),x=n.containerPhrasing(e,{...l.current(),before:`
|
|
81
|
+
`,after:`
|
|
82
|
+
`});return m(),p(),x+`
|
|
83
|
+
`+(a===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
|
|
84
|
+
`))+1))}const u="#".repeat(a),c=n.enter("headingAtx"),d=n.enter("phrasing");l.move(u+" ");let f=n.containerPhrasing(e,{before:"# ",after:`
|
|
85
|
+
`,...l.current()});return/^[\t ]/.test(f)&&(f=Al(f.charCodeAt(0))+f.slice(1)),f=f?u+" "+f:u,n.options.closeAtx&&(f+=" "+u),d(),c(),f}mw.peek=R5;function mw(e){return e.value||""}function R5(){return"<"}pw.peek=O5;function pw(e,t,n,r){const a=xg(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("image");let c=n.enter("label");const d=n.createTracker(r);let f=d.move("![");return f+=d.move(n.safe(e.alt,{before:f,after:"]",...d.current()})),f+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(e.url,{before:f,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),f+=d.move(" "+a),f+=d.move(n.safe(e.title,{before:f,after:a,...d.current()})),f+=d.move(a),c()),f+=d.move(")"),u(),f}function O5(){return"!"}gw.peek=I5;function gw(e,t,n,r){const a=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("![");const f=n.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!f||f!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function I5(){return"!"}xw.peek=M5;function xw(e,t,n){let r=e.value||"",a="`",l=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++l<n.unsafe.length;){const u=n.unsafe[l],c=n.compilePattern(u);let d;if(u.atBreak)for(;d=c.exec(r);){let f=d.index;r.charCodeAt(f)===10&&r.charCodeAt(f-1)===13&&f--,r=r.slice(0,f)+" "+r.slice(d.index+1)}}return a+r+a}function M5(){return"`"}function yw(e,t){const n=lg(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))}bw.peek=P5;function bw(e,t,n,r){const a=xg(n),l=a==='"'?"Quote":"Apostrophe",u=n.createTracker(r);let c,d;if(yw(e,n)){const p=n.stack;n.stack=[],c=n.enter("autolink");let m=u.move("<");return m+=u.move(n.containerPhrasing(e,{before:m,after:">",...u.current()})),m+=u.move(">"),c(),n.stack=p,m}c=n.enter("link"),d=n.enter("label");let f=u.move("[");return f+=u.move(n.containerPhrasing(e,{before:f,after:"](",...u.current()})),f+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),f+=u.move("<"),f+=u.move(n.safe(e.url,{before:f,after:">",...u.current()})),f+=u.move(">")):(d=n.enter("destinationRaw"),f+=u.move(n.safe(e.url,{before:f,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=n.enter(`title${l}`),f+=u.move(" "+a),f+=u.move(n.safe(e.title,{before:f,after:a,...u.current()})),f+=u.move(a),d()),f+=u.move(")"),c(),f}function P5(e,t,n){return yw(e,n)?"<":"["}vw.peek=B5;function vw(e,t,n,r){const a=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("[");const f=n.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),u();const p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!f||f!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function B5(){return"["}function yg(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 $5(e){const t=yg(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 z5(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 _w(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 H5(e,t,n,r){const a=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?z5(n):yg(n);const c=e.ordered?u==="."?")":".":$5(n);let d=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&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&&(d=!0),_w(n)===u&&p){let m=-1;for(;++m<e.children.length;){const x=e.children[m];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(u=c),n.bulletCurrent=u;const f=n.containerFlow(e,r);return n.bulletLastUsed=u,n.bulletCurrent=l,a(),f}function U5(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 F5(e,t,n,r){const a=U5(n);let l=n.bulletCurrent||yg(n);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let u=l.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const c=n.createTracker(r);c.move(l+" ".repeat(u-l.length)),c.shift(u);const d=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,c.current()),p);return d(),f;function p(m,x,y){return x?(y?"":" ".repeat(u))+m:(y?l:l+" ".repeat(u-l.length))+m}}function V5(e,t,n,r){const a=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,r);return l(),a(),u}const G5=_d(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function W5(e,t,n,r){return(e.children.some(function(u){return G5(u)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function q5(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Sw.peek=K5;function Sw(e,t,n,r){const a=q5(n),l=n.enter("strong"),u=n.createTracker(r),c=u.move(a+a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const f=d.charCodeAt(0),p=Ku(r.before.charCodeAt(r.before.length-1),f,a);p.inside&&(d=Al(f)+d.slice(1));const m=d.charCodeAt(d.length-1),x=Ku(r.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+Al(m));const y=u.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function K5(e,t,n){return n.options.strong||"*"}function Y5(e,t,n,r){return n.safe(e.value,r)}function X5(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 Q5(e,t,n){const r=(_w(n)+(n.options.ruleSpaces?" ":"")).repeat(X5(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ww={blockquote:v5,break:c0,code:E5,definition:N5,emphasis:fw,hardBreak:c0,heading:D5,html:mw,image:pw,imageReference:gw,inlineCode:xw,link:bw,linkReference:vw,list:H5,listItem:F5,paragraph:V5,root:W5,strong:Sw,text:Y5,thematicBreak:Q5};function J5(){return{enter:{table:Z5,tableData:u0,tableHeader:u0,tableRow:tR},exit:{codeText:nR,table:eR,tableData:Nm,tableHeader:Nm,tableRow:Nm}}}function Z5(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 eR(e){this.exit(e),this.data.inTable=void 0}function tR(e){this.enter({type:"tableRow",children:[]},e)}function Nm(e){this.exit(e)}function u0(e){this.enter({type:"tableCell",children:[]},e)}function nR(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,rR));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function rR(e,t){return t==="|"?t:e}function sR(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
86
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:d,tableRow:c}};function u(y,w,C,_){return f(p(y,C,_),y.align)}function c(y,w,C,_){const S=m(y,C,_),b=f([S]);return b.slice(0,b.indexOf(`
|
|
87
|
+
`))}function d(y,w,C,_){const S=C.enter("tableCell"),b=C.enter("phrasing"),v=C.containerPhrasing(y,{..._,before:l,after:l});return b(),S(),v}function f(y,w){return y5(y,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function p(y,w,C){const _=y.children;let S=-1;const b=[],v=w.enter("table");for(;++S<_.length;)b[S]=m(_[S],w,C);return v(),b}function m(y,w,C){const _=y.children;let S=-1;const b=[],v=w.enter("tableRow");for(;++S<_.length;)b[S]=d(_[S],y,w,C);return v(),b}function x(y,w,C){let _=ww.inlineCode(y,w,C);return C.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function iR(){return{exit:{taskListCheckValueChecked:d0,taskListCheckValueUnchecked:d0,paragraph:oR}}}function aR(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:lR}}}function d0(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function oR(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let l=-1,u;for(;++l<a.length;){const c=a[l];if(c.type==="paragraph"){u=c;break}}u===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function lR(e,t,n,r){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);l&&c.move(u);let d=ww.listItem(e,t,n,{...r,...c.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),d;function f(p){return p+u}}function cR(){return[H3(),l5(),h5(),J5(),iR()]}function uR(e){return{extensions:[U3(),c5(e),f5(),sR(e),aR()]}}const dR={tokenize:xR,partial:!0},Cw={tokenize:yR,partial:!0},kw={tokenize:bR,partial:!0},Ew={tokenize:vR,partial:!0},hR={tokenize:_R,partial:!0},jw={name:"wwwAutolink",tokenize:pR,previous:Tw},Nw={name:"protocolAutolink",tokenize:gR,previous:Aw},js={name:"emailAutolink",tokenize:mR,previous:Lw},Xr={};function fR(){return{text:Xr}}let Ai=48;for(;Ai<123;)Xr[Ai]=js,Ai++,Ai===58?Ai=65:Ai===91&&(Ai=97);Xr[43]=js;Xr[45]=js;Xr[46]=js;Xr[95]=js;Xr[72]=[js,Nw];Xr[104]=[js,Nw];Xr[87]=[js,jw];Xr[119]=[js,jw];function mR(e,t,n){const r=this;let a,l;return u;function u(m){return!bp(m)||!Lw.call(r,r.previous)||bg(r.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(m))}function c(m){return bp(m)?(e.consume(m),c):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(hR,p,f)(m):m===45||m===95||Rn(m)?(l=!0,e.consume(m),d):p(m)}function f(m){return e.consume(m),a=!0,d}function p(m){return l&&a&&$n(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function pR(e,t,n){const r=this;return a;function a(u){return u!==87&&u!==119||!Tw.call(r,r.previous)||bg(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(dR,e.attempt(Cw,e.attempt(kw,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function gR(e,t,n){const r=this;let a="",l=!1;return u;function u(m){return(m===72||m===104)&&Aw.call(r,r.previous)&&!bg(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),c):n(m)}function c(m){if($n(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),c;if(m===58){const x=a.toLowerCase();if(x==="http"||x==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),l?f:(l=!0,d)):n(m)}function f(m){return m===null||Gu(m)||Pt(m)||Wi(m)||yd(m)?n(m):e.attempt(Cw,e.attempt(kw,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function xR(e,t,n){let r=0;return a;function a(u){return(u===87||u===119)&&r<3?(r++,e.consume(u),a):u===46&&r===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function yR(e,t,n){let r,a,l;return u;function u(f){return f===46||f===95?e.check(Ew,d,c)(f):f===null||Pt(f)||Wi(f)||f!==45&&yd(f)?d(f):(l=!0,e.consume(f),u)}function c(f){return f===95?r=!0:(a=r,r=void 0),e.consume(f),u}function d(f){return a||r||!l?n(f):t(f)}}function bR(e,t){let n=0,r=0;return a;function a(u){return u===40?(n++,e.consume(u),a):u===41&&r<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(Ew,t,l)(u):u===null||Pt(u)||Wi(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&r++,e.consume(u),a}}function vR(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),l):c===93?(e.consume(c),a):c===60||c===null||Pt(c)||Wi(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||Pt(c)||Wi(c)?t(c):r(c)}function l(c){return $n(c)?u(c):n(c)}function u(c){return c===59?(e.consume(c),r):$n(c)?(e.consume(c),u):n(c)}}function _R(e,t,n){return r;function r(l){return e.consume(l),a}function a(l){return Rn(l)?n(l):t(l)}}function Tw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Pt(e)}function Aw(e){return!$n(e)}function Lw(e){return!(e===47||bp(e))}function bp(e){return e===43||e===45||e===46||e===95||Rn(e)}function bg(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 SR={tokenize:AR,partial:!0};function wR(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:jR,continuation:{tokenize:NR},exit:TR}},text:{91:{name:"gfmFootnoteCall",tokenize:ER},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:CR,resolveTo:kR}}}}function CR(e,t,n){const r=this;let a=r.events.length;const l=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u;for(;a--;){const d=r.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!u||!u._balanced)return n(d);const f=Rr(r.sliceSerialize({start:u.end,end:r.now()}));return f.codePointAt(0)!==94||!l.includes(f.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function kR(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function ER(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l=0,u;return c;function c(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(m){if(l>999||m===93&&!u||m===null||m===91||Pt(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Rr(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return Pt(m)||(u=!0),l++,e.consume(m),m===92?p:f}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,f):f(m)}}function jR(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l,u=0,c;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(w)}function p(w){if(u>999||w===93&&!c||w===null||w===91||Pt(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return l=Rr(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return Pt(w)||(c=!0),u++,e.consume(w),w===92?m:p}function m(w){return w===91||w===92||w===93?(e.consume(w),u++,p):p(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(l)||a.push(l),St(e,y,"gfmFootnoteDefinitionWhitespace")):n(w)}function y(w){return t(w)}}function NR(e,t,n){return e.check(Fl,t,e.attempt(SR,t,n))}function TR(e){e.exit("gfmFootnoteDefinition")}function AR(e,t,n){const r=this;return St(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function LR(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:l,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(u,c){let d=-1;for(;++d<u.length;)if(u[d][0]==="enter"&&u[d][1].type==="strikethroughSequenceTemporary"&&u[d][1]._close){let f=d;for(;f--;)if(u[f][0]==="exit"&&u[f][1].type==="strikethroughSequenceTemporary"&&u[f][1]._open&&u[d][1].end.offset-u[d][1].start.offset===u[f][1].end.offset-u[f][1].start.offset){u[d][1].type="strikethroughSequence",u[f][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},u[f][1].start),end:Object.assign({},u[d][1].end)},m={type:"strikethroughText",start:Object.assign({},u[f][1].end),end:Object.assign({},u[d][1].start)},x=[["enter",p,c],["enter",u[f][1],c],["exit",u[f][1],c],["enter",m,c]],y=c.parser.constructs.insideSpan.null;y&&cr(x,x.length,0,bd(y,u.slice(f+1,d),c)),cr(x,x.length,0,[["exit",m,c],["enter",u[d][1],c],["exit",u[d][1],c],["exit",p,c]]),cr(u,f-1,d-f+3,x),d=f+x.length-2;break}}for(d=-1;++d<u.length;)u[d][1].type==="strikethroughSequenceTemporary"&&(u[d][1].type="data");return u}function l(u,c,d){const f=this.previous,p=this.events;let m=0;return x;function x(w){return f===126&&p[p.length-1][1].type!=="characterEscape"?d(w):(u.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const C=Ja(f);if(w===126)return m>1?d(w):(u.consume(w),m++,y);if(m<2&&!n)return d(w);const _=u.exit("strikethroughSequenceTemporary"),S=Ja(w);return _._open=!S||S===2&&!!C,_._close=!C||C===2&&!!S,c(w)}}}class DR{constructor(){this.map=[]}add(t,n,r){RR(this,t,n,r)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const l of a)t.push(l);a=r.pop()}this.map.length=0}}function RR(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function OR(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=r.length-1;r[l]=r[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function IR(){return{flow:{null:{name:"table",tokenize:MR,resolveAll:PR}}}}function MR(e,t,n){const r=this;let a=0,l=0,u;return c;function c(M){let W=r.events.length-1;for(;W>-1;){const P=r.events[W][1].type;if(P==="lineEnding"||P==="linePrefix")W--;else break}const z=W>-1?r.events[W][1].type:null,R=z==="tableHead"||z==="tableRow"?T:d;return R===T&&r.parser.lazy[r.now().line]?n(M):R(M)}function d(M){return e.enter("tableHead"),e.enter("tableRow"),f(M)}function f(M){return M===124||(u=!0,l+=1),p(M)}function p(M){return M===null?n(M):Qe(M)?l>1?(l=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),y):n(M):pt(M)?St(e,p,"whitespace")(M):(l+=1,u&&(u=!1,a+=1),M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),u=!0,p):(e.enter("data"),m(M)))}function m(M){return M===null||M===124||Pt(M)?(e.exit("data"),p(M)):(e.consume(M),M===92?x:m)}function x(M){return M===92||M===124?(e.consume(M),m):m(M)}function y(M){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(M):(e.enter("tableDelimiterRow"),u=!1,pt(M)?St(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):w(M))}function w(M){return M===45||M===58?_(M):M===124?(u=!0,e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),C):j(M)}function C(M){return pt(M)?St(e,_,"whitespace")(M):_(M)}function _(M){return M===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),S):M===45?(l+=1,S(M)):M===null||Qe(M)?E(M):j(M)}function S(M){return M===45?(e.enter("tableDelimiterFiller"),b(M)):j(M)}function b(M){return M===45?(e.consume(M),b):M===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(M))}function v(M){return pt(M)?St(e,E,"whitespace")(M):E(M)}function E(M){return M===124?w(M):M===null||Qe(M)?!u||a!==l?j(M):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(M)):j(M)}function j(M){return n(M)}function T(M){return e.enter("tableRow"),D(M)}function D(M){return M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),D):M===null||Qe(M)?(e.exit("tableRow"),t(M)):pt(M)?St(e,D,"whitespace")(M):(e.enter("data"),L(M))}function L(M){return M===null||M===124||Pt(M)?(e.exit("data"),D(M)):(e.consume(M),M===92?O:L)}function O(M){return M===92||M===124?(e.consume(M),L):L(M)}}function PR(e,t){let n=-1,r=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,f,p,m;const x=new DR;for(;++n<e.length;){const y=e[n],w=y[1];y[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(h0(x,t,d,f,p),p=void 0,d=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",f,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",p,t]])),a=w.type==="tableDelimiterRow"?2:p?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=gu(x,t,l,a,void 0,m),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(l[1]!==0&&(u[0]=u[1],m=gu(x,t,l,a,void 0,m)),l=u,u=[l[1],n,0,0])):w.type==="tableHead"?(c=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,l[1]!==0?(u[0]=u[1],m=gu(x,t,l,a,n,m)):u[1]!==0&&(m=gu(x,t,u,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&h0(x,t,d,f,p),x.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=OR(t.events,n))}return e}function gu(e,t,n,r,a,l){const u=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(l.end=Object.assign({},Va(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=Va(t.events,n[1]);if(l={type:u,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const f=Va(t.events,n[2]),p=Va(t.events,n[3]),m={type:c,start:Object.assign({},f),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,t]]),r!==2){const x=t.events[n[2]],y=t.events[n[3]];if(x[1].end=Object.assign({},y[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},Va(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function h0(e,t,n,r,a){const l=[],u=Va(t.events,n);a&&(a.end=Object.assign({},u),l.push(["exit",a,t])),r.end=Object.assign({},u),l.push(["exit",r,t]),e.add(n+1,0,l)}function Va(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const BR={name:"tasklistCheck",tokenize:zR};function $R(){return{text:{91:BR}}}function zR(e,t,n){const r=this;return a;function a(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),l)}function l(d){return Pt(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):n(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(d)}function c(d){return Qe(d)?t(d):pt(d)?e.check({tokenize:HR},t,n)(d):n(d)}}function HR(e,t,n){return St(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function UR(e){return U1([fR(),wR(),LR(e),IR(),$R()])}const FR={};function VR(e){const t=this,n=e||FR,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),l=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),u=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(UR(n)),l.push(cR()),u.push(uR(n))}var vp=Object.defineProperty,GR=Object.getOwnPropertyDescriptor,WR=Object.getOwnPropertyNames,qR=Object.prototype.hasOwnProperty,vg=(e,t)=>{let n={};for(var r in e)vp(n,r,{get:e[r],enumerable:!0});return vp(n,Symbol.toStringTag,{value:"Module"}),n},KR=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=WR(t),l=0,u=a.length,c;l<u;l++)c=a[l],!qR.call(e,c)&&c!==n&&vp(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(r=GR(t,c))||r.enumerable});return e},Dw=(e,t,n)=>(KR(e,t,"default"),n);const wd=[{id:"abap",name:"ABAP",import:(()=>J(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>J(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>J(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>J(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>J(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>J(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>J(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>J(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>J(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>J(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>J(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>J(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>J(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>J(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>J(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>J(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>J(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>J(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>J(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>J(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>J(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>J(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>J(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>J(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>J(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>J(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>J(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>J(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>J(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>J(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>J(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>J(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>J(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>J(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>J(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>J(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>J(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>J(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>J(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>J(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>J(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>J(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>J(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>J(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>J(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>J(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>J(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>J(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>J(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>J(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>J(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>J(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>J(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>J(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>J(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>J(()=>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:(()=>J(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>J(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>J(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>J(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>J(()=>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:(()=>J(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>J(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>J(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>J(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>J(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>J(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>J(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>J(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>J(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>J(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>J(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>J(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>J(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>J(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>J(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>J(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>J(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>J(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>J(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>J(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>J(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>J(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>J(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>J(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>J(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>J(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>J(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>J(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>J(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>J(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>J(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>J(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>J(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>J(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>J(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>J(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>J(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>J(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>J(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>J(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>J(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>J(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>J(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>J(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>J(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>J(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>J(()=>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:(()=>J(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>J(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>J(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>J(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>J(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>J(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>J(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>J(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>J(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>J(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>J(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>J(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>J(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>J(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>J(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>J(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>J(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>J(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>J(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>J(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>J(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>J(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>J(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>J(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>J(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>J(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>J(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>J(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>J(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>J(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>J(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>J(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>J(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>J(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>J(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>J(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>J(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>J(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>J(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>J(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>J(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>J(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>J(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>J(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>J(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>J(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>J(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>J(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>J(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>J(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>J(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>J(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>J(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>J(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>J(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>J(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>J(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>J(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>J(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>J(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>J(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>J(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>J(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>J(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>J(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>J(()=>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:(()=>J(()=>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:(()=>J(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>J(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>J(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>J(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>J(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>J(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>J(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>J(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>J(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>J(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>J(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>J(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>J(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>J(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>J(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>J(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>J(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>J(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>J(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>J(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>J(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>J(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>J(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>J(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>J(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>J(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>J(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>J(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>J(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>J(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>J(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>J(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>J(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>J(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>J(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>J(()=>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:(()=>J(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>J(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>J(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>J(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>J(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>J(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>J(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>J(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>J(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>J(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>J(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>J(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>J(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>J(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>J(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>J(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>J(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>J(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>J(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>J(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>J(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>J(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>J(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>J(()=>import("./zig-VOosw3JB.js"),[]))}],_g=Object.fromEntries(wd.map(e=>[e.id,e.import])),Sg=Object.fromEntries(wd.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),Cd={..._g,...Sg},wg=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>J(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>J(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>J(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>J(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>J(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>J(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>J(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>J(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>J(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>J(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>J(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>J(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>J(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>J(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>J(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>J(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>J(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>J(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>J(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>J(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>J(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>J(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>J(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>J(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>J(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>J(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>J(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>J(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>J(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>J(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>J(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>J(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>J(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>J(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>J(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>J(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>J(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>J(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>J(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>J(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>J(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>J(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>J(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>J(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>J(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>J(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>J(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>J(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>J(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>J(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>J(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>J(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>J(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>J(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>J(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>J(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>J(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>J(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>J(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>J(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>J(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>J(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>J(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>J(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>J(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],Cg=Object.fromEntries(wg.map(e=>[e.id,e.import]));var kg=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function YR(){return 2147483648}function XR(){return typeof performance<"u"?performance.now():Date.now()}const QR=(e,t)=>e+(t-e%t)%t;async function JR(e){let t,n;const r={};function a(y){n=y,r.HEAPU8=new Uint8Array(y),r.HEAPU32=new Uint32Array(y)}function l(y,w,C){r.HEAPU8.copyWithin(y,w,w+C)}function u(y){try{return t.grow(y-n.byteLength+65535>>>16),a(t.buffer),1}catch{}}function c(y){const w=r.HEAPU8.length;y=y>>>0;const C=YR();if(y>C)return!1;for(let _=1;_<=4;_*=2){let S=w*(1+.2/_);S=Math.min(S,y+100663296);const b=Math.min(C,QR(Math.max(y,S),65536));if(u(b))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function f(y,w,C=1024){const _=w+C;let S=w;for(;y[S]&&!(S>=_);)++S;if(S-w>16&&y.buffer&&d)return d.decode(y.subarray(w,S));let b="";for(;w<S;){let v=y[w++];if(!(v&128)){b+=String.fromCharCode(v);continue}const E=y[w++]&63;if((v&224)===192){b+=String.fromCharCode((v&31)<<6|E);continue}const j=y[w++]&63;if((v&240)===224?v=(v&15)<<12|E<<6|j:v=(v&7)<<18|E<<12|j<<6|y[w++]&63,v<65536)b+=String.fromCharCode(v);else{const T=v-65536;b+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return b}function p(y,w){return y?f(r.HEAPU8,y,w):""}const m={emscripten_get_now:XR,emscripten_memcpy_big:l,emscripten_resize_heap:c,fd_write:()=>0};async function x(){const w=await e({env:m,wasi_snapshot_preview1:m});t=w.memory,a(t.buffer),Object.assign(r,w),r.UTF8ToString=p}return await x(),r}var ZR=Object.defineProperty,e4=(e,t,n)=>t in e?ZR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gn=(e,t,n)=>e4(e,typeof t!="symbol"?t+"":t,n);let Sn=null;function t4(e){throw new kg(e.UTF8ToString(e.getLastOnigError()))}class kd{constructor(t){gn(this,"utf16Length"),gn(this,"utf8Length"),gn(this,"utf16Value"),gn(this,"utf8Value"),gn(this,"utf16OffsetToUtf8"),gn(this,"utf8OffsetToUtf16");const n=t.length,r=kd._utf8ByteLength(t),a=r!==n,l=a?new Uint32Array(n+1):null;a&&(l[n]=r);const u=a?new Uint32Array(r+1):null;a&&(u[r]=n);const c=new Uint8Array(r);let d=0;for(let f=0;f<n;f++){const p=t.charCodeAt(f);let m=p,x=!1;if(p>=55296&&p<=56319&&f+1<n){const y=t.charCodeAt(f+1);y>=56320&&y<=57343&&(m=(p-55296<<10)+65536|y-56320,x=!0)}a&&(l[f]=d,x&&(l[f+1]=d),m<=127?u[d+0]=f:m<=2047?(u[d+0]=f,u[d+1]=f):m<=65535?(u[d+0]=f,u[d+1]=f,u[d+2]=f):(u[d+0]=f,u[d+1]=f,u[d+2]=f,u[d+3]=f)),m<=127?c[d++]=m:m<=2047?(c[d++]=192|(m&1984)>>>6,c[d++]=128|(m&63)>>>0):m<=65535?(c[d++]=224|(m&61440)>>>12,c[d++]=128|(m&4032)>>>6,c[d++]=128|(m&63)>>>0):(c[d++]=240|(m&1835008)>>>18,c[d++]=128|(m&258048)>>>12,c[d++]=128|(m&4032)>>>6,c[d++]=128|(m&63)>>>0),x&&f++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=c,this.utf16OffsetToUtf8=l,this.utf8OffsetToUtf16=u}static _utf8ByteLength(t){let n=0;for(let r=0,a=t.length;r<a;r++){const l=t.charCodeAt(r);let u=l,c=!1;if(l>=55296&&l<=56319&&r+1<a){const d=t.charCodeAt(r+1);d>=56320&&d<=57343&&(u=(l-55296<<10)+65536|d-56320,c=!0)}u<=127?n+=1:u<=2047?n+=2:u<=65535?n+=3:n+=4,c&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const Ed=class Ur{constructor(t){if(gn(this,"id",++Ur.LAST_ID),gn(this,"_onigBinding"),gn(this,"content"),gn(this,"utf16Length"),gn(this,"utf8Length"),gn(this,"utf16OffsetToUtf8"),gn(this,"utf8OffsetToUtf16"),gn(this,"ptr"),!Sn)throw new kg("Must invoke loadWasm first.");this._onigBinding=Sn,this.content=t;const n=new kd(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ur._sharedPtrInUse?(Ur._sharedPtr||(Ur._sharedPtr=Sn.omalloc(1e4)),Ur._sharedPtrInUse=!0,Sn.HEAPU8.set(n.utf8Value,Ur._sharedPtr),this.ptr=Ur._sharedPtr):this.ptr=n.createString(Sn)}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===Ur._sharedPtr?Ur._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};gn(Ed,"LAST_ID",0);gn(Ed,"_sharedPtr",0);gn(Ed,"_sharedPtrInUse",!1);let Rw=Ed;class n4{constructor(t){if(gn(this,"_onigBinding"),gn(this,"_ptr"),!Sn)throw new kg("Must invoke loadWasm first.");const n=[],r=[];for(let c=0,d=t.length;c<d;c++){const f=new kd(t[c]);n[c]=f.createString(Sn),r[c]=f.utf8Length}const a=Sn.omalloc(4*t.length);Sn.HEAPU32.set(n,a/4);const l=Sn.omalloc(4*t.length);Sn.HEAPU32.set(r,l/4);const u=Sn.createOnigScanner(a,l,t.length);for(let c=0,d=t.length;c<d;c++)Sn.ofree(n[c]);Sn.ofree(l),Sn.ofree(a),u===0&&t4(Sn),this._onigBinding=Sn,this._ptr=u}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let a=0;if(typeof r=="number"&&(a=r),typeof t=="string"){t=new Rw(t);const l=this._findNextMatchSync(t,n,!1,a);return t.dispose(),l}return this._findNextMatchSync(t,n,!1,a)}_findNextMatchSync(t,n,r,a){const l=this._onigBinding,u=l.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),a);if(u===0)return null;const c=l.HEAPU32;let d=u/4;const f=c[d++],p=c[d++],m=[];for(let x=0;x<p;x++){const y=t.convertUtf8OffsetToUtf16(c[d++]),w=t.convertUtf8OffsetToUtf16(c[d++]);m[x]={start:y,end:w,length:w-y}}return{index:f,captureIndices:m}}}function r4(e){return typeof e.instantiator=="function"}function s4(e){return typeof e.default=="function"}function i4(e){return typeof e.data<"u"}function a4(e){return typeof Response<"u"&&e instanceof Response}function o4(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 xu;function Eg(e){if(xu)return xu;async function t(){Sn=await JR(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),r4(r)?r=await r.instantiator(n):s4(r)?r=await r.default(n):(i4(r)&&(r=r.data),a4(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await l4(r)(n):r=await c4(r)(n):o4(r)?r=await Tm(r)(n):r instanceof WebAssembly.Module?r=await Tm(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Tm(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return xu=t(),xu}function Tm(e){return t=>WebAssembly.instantiate(e,t)}function l4(e){return t=>WebAssembly.instantiateStreaming(e,t)}function c4(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let Ow;function u4(e){Ow=e}function d4(){return Ow}async function Iw(e){return e&&await Eg(e),{createScanner(t){return new n4(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new Rw(t)}}}const h4=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:Iw,getDefaultWasmLoader:d4,loadWasm:Eg,setDefaultWasmLoader:u4},Symbol.toStringTag,{value:"Module"}));var Mw=vg({});Dw(Mw,h4);var zt=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function f4(e){return jg(e)}function jg(e){return Array.isArray(e)?m4(e):e instanceof RegExp?e:typeof e=="object"?p4(e):e}function m4(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=jg(e[n]);return t}function p4(e){let t={};for(let n in e)t[n]=jg(e[n]);return t}function Pw(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function Bw(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Bw(e.substring(0,e.length-1)):e.substr(~t+1)}var Am=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,yu=class{static hasCaptures(e){return e===null?!1:(Am.lastIndex=0,Am.test(e))}static replaceCaptures(e,t,n){return e.replace(Am,(r,a,l,u)=>{let c=n[parseInt(a||l,10)];if(c){let d=t.substring(c.start,c.end);for(;d[0]===".";)d=d.substring(1);switch(u){case"downcase":return d.toLowerCase();case"upcase":return d.toUpperCase();default:return d}}else return r})}};function $w(e,t){return e<t?-1:e>t?1:0}function zw(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 a=0;a<n;a++){let l=$w(e[a],t[a]);if(l!==0)return l}return 0}return n-r}function f0(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 Hw(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Uw=class{constructor(e){Se(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}},Yu=class{constructor(e,t,n){Se(this,"_cachedMatchRoot",new Uw(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(y4(e),t)}static createFromParsedTheme(e,t){return v4(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(a=>g4(e.parent,a.parentScopes));return r?new Fw(r.fontStyle,r.foreground,r.background):null}},Lm=class $u{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new $u(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new $u(n,t[r]);return n}push(t){return new $u(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 g4(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],a=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],a=!0}for(;e&&!x4(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function x4(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Fw=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function y4(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let a=0,l=t.length;a<l;a++){let u=t[a];if(!u.settings)continue;let c;if(typeof u.scope=="string"){let m=u.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),c=m.split(",")}else Array.isArray(u.scope)?c=u.scope:c=[""];let d=-1;if(typeof u.settings.fontStyle=="string"){d=0;let m=u.settings.fontStyle.split(" ");for(let x=0,y=m.length;x<y;x++)switch(m[x]){case"italic":d=d|1;break;case"bold":d=d|2;break;case"underline":d=d|4;break;case"strikethrough":d=d|8;break}}let f=null;typeof u.settings.foreground=="string"&&f0(u.settings.foreground)&&(f=u.settings.foreground);let p=null;typeof u.settings.background=="string"&&f0(u.settings.background)&&(p=u.settings.background);for(let m=0,x=c.length;m<x;m++){let w=c[m].trim().split(" "),C=w[w.length-1],_=null;w.length>1&&(_=w.slice(0,w.length-1),_.reverse()),n[r++]=new b4(C,_,a,d,f,p)}}return n}var b4=class{constructor(e,t,n,r,a,l){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=a,this.background=l}},Dn=(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))(Dn||{});function v4(e,t){e.sort((d,f)=>{let p=$w(d.scope,f.scope);return p!==0||(p=zw(d.parentScopes,f.parentScopes),p!==0)?p:d.index-f.index});let n=0,r="#000000",a="#ffffff";for(;e.length>=1&&e[0].scope==="";){let d=e.shift();d.fontStyle!==-1&&(n=d.fontStyle),d.foreground!==null&&(r=d.foreground),d.background!==null&&(a=d.background)}let l=new _4(t),u=new Fw(n,l.getId(r),l.getId(a)),c=new w4(new _p(0,null,-1,0,0),[]);for(let d=0,f=e.length;d<f;d++){let p=e[d];c.insert(0,p.scope,p.parentScopes,p.fontStyle,l.getId(p.foreground),l.getId(p.background))}return new Yu(l,u,c)}var _4=class{constructor(e){Se(this,"_isFrozen");Se(this,"_lastColorId");Se(this,"_id2color");Se(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)}},S4=Object.freeze([]),_p=class Vw{constructor(t,n,r,a,l){Se(this,"scopeDepth");Se(this,"parentScopes");Se(this,"fontStyle");Se(this,"foreground");Se(this,"background");this.scopeDepth=t,this.parentScopes=n||S4,this.fontStyle=r,this.foreground=a,this.background=l}clone(){return new Vw(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,a=t.length;r<a;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,a){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),a!==0&&(this.background=a)}},w4=class Sp{constructor(t,n=[],r={}){Se(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,a=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[a]===">"&&a++,!(r>=t.parentScopes.length||a>=n.parentScopes.length);){const l=n.parentScopes[a].length-t.parentScopes[r].length;if(l!==0)return l;r++,a++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),a,l;if(r===-1?(a=t,l=""):(a=t.substring(0,r),l=t.substring(r+1)),this._children.hasOwnProperty(a))return this._children[a].match(l)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Sp._cmpBySpecificity),n}insert(t,n,r,a,l,u){if(n===""){this._doInsertHere(t,r,a,l,u);return}let c=n.indexOf("."),d,f;c===-1?(d=n,f=""):(d=n.substring(0,c),f=n.substring(c+1));let p;this._children.hasOwnProperty(d)?p=this._children[d]:(p=new Sp(this._mainRule.clone(),_p.cloneArr(this._rulesWithParentScopes)),this._children[d]=p),p.insert(t+1,f,r,a,l,u)}_doInsertHere(t,n,r,a,l){if(n===null){this._mainRule.acceptOverwrite(t,r,a,l);return}for(let u=0,c=this._rulesWithParentScopes.length;u<c;u++){let d=this._rulesWithParentScopes[u];if(zw(d.parentScopes,n)===0){d.acceptOverwrite(t,r,a,l);return}}r===-1&&(r=this._mainRule.fontStyle),a===0&&(a=this._mainRule.foreground),l===0&&(l=this._mainRule.background),this._rulesWithParentScopes.push(new _p(t,n,r,a,l))}},Za=class vr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=vr.getLanguageId(t),r=vr.getTokenType(t),a=vr.getFontStyle(t),l=vr.getForeground(t),u=vr.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:a,foreground:l,background:u})}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,a,l,u,c){let d=vr.getLanguageId(t),f=vr.getTokenType(t),p=vr.containsBalancedBrackets(t)?1:0,m=vr.getFontStyle(t),x=vr.getForeground(t),y=vr.getBackground(t);return n!==0&&(d=n),r!==8&&(f=r),a!==null&&(p=a?1:0),l!==-1&&(m=l),u!==0&&(x=u),c!==0&&(y=c),(d<<0|f<<8|p<<10|m<<11|x<<15|y<<24)>>>0}};function Xu(e,t){const n=[],r=C4(e);let a=r.next();for(;a!==null;){let d=0;if(a.length===2&&a.charAt(1)===":"){switch(a.charAt(0)){case"R":d=1;break;case"L":d=-1;break;default:console.log(`Unknown priority ${a} in scope selector`)}a=r.next()}let f=u();if(n.push({matcher:f,priority:d}),a!==",")break;a=r.next()}return n;function l(){if(a==="-"){a=r.next();const d=l();return f=>!!d&&!d(f)}if(a==="("){a=r.next();const d=c();return a===")"&&(a=r.next()),d}if(m0(a)){const d=[];do d.push(a),a=r.next();while(m0(a));return f=>t(d,f)}return null}function u(){const d=[];let f=l();for(;f;)d.push(f),f=l();return p=>d.every(m=>m(p))}function c(){const d=[];let f=u();for(;f&&(d.push(f),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");f=u()}return p=>d.some(m=>m(p))}}function m0(e){return!!e&&!!e.match(/[\w\.:]+/)}function C4(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 Gw(e){typeof e.dispose=="function"&&e.dispose()}var Ll=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},k4=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},E4=class{constructor(){Se(this,"_references",[]);Se(this,"_seenReferenceKeys",new Set);Se(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))}},j4=class{constructor(e,t){Se(this,"seenFullScopeRequests",new Set);Se(this,"seenPartialScopeRequests",new Set);Se(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Ll(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new E4;for(const n of e)N4(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof Ll){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 N4(e,t,n,r){const a=n.lookup(e.scopeName);if(!a){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const l=n.lookup(t);e instanceof Ll?zu({baseGrammar:l,selfGrammar:a},r):wp(e.ruleName,{baseGrammar:l,selfGrammar:a,repository:a.repository},r);const u=n.injections(e.scopeName);if(u)for(const c of u)r.add(new Ll(c))}function wp(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];Qu([r],t,n)}}function zu(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Qu(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Qu(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Qu(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?Pw({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Qu(r.patterns,{...t,repository:a},n);const l=r.include;if(!l)continue;const u=Ww(l);switch(u.kind){case 0:zu({...t,selfGrammar:t.baseGrammar},n);break;case 1:zu(t,n);break;case 2:wp(u.ruleName,{...t,repository:a},n);break;case 3:case 4:const c=u.scopeName===t.selfGrammar.scopeName?t.selfGrammar:u.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(c){const d={baseGrammar:t.baseGrammar,selfGrammar:c,repository:a};u.kind===4?wp(u.ruleName,d,n):zu(d,n)}else u.kind===4?n.add(new k4(u.scopeName,u.ruleName)):n.add(new Ll(u.scopeName));break}}}var T4=class{constructor(){Se(this,"kind",0)}},A4=class{constructor(){Se(this,"kind",1)}},L4=class{constructor(e){Se(this,"kind",2);this.ruleName=e}},D4=class{constructor(e){Se(this,"kind",3);this.scopeName=e}},R4=class{constructor(e,t){Se(this,"kind",4);this.scopeName=e,this.ruleName=t}};function Ww(e){if(e==="$base")return new T4;if(e==="$self")return new A4;const t=e.indexOf("#");if(t===-1)return new D4(e);if(t===0)return new L4(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new R4(n,r)}}var O4=/\\(\d+)/,p0=/\\(\d+)/g,I4=-1,qw=-2;var Gl=class{constructor(e,t,n,r){Se(this,"$location");Se(this,"id");Se(this,"_nameIsCapturing");Se(this,"_name");Se(this,"_contentNameIsCapturing");Se(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=yu.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=yu.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${Bw(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:yu.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:yu.replaceCaptures(this._contentName,e,t)}},M4=class extends Gl{constructor(t,n,r,a,l){super(t,n,r,a);Se(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=l}dispose(){}collectPatterns(t,n){throw new Error("Not supported!")}compile(t,n){throw new Error("Not supported!")}compileAG(t,n,r,a){throw new Error("Not supported!")}},P4=class extends Gl{constructor(t,n,r,a,l){super(t,n,r,null);Se(this,"_match");Se(this,"captures");Se(this,"_cachedCompiledPatterns");this._match=new Dl(a,this.id),this.captures=l,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,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Rl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},g0=class extends Gl{constructor(t,n,r,a,l){super(t,n,r,a);Se(this,"hasMissingPatterns");Se(this,"patterns");Se(this,"_cachedCompiledPatterns");this.patterns=l.patterns,this.hasMissingPatterns=l.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,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Rl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Cp=class extends Gl{constructor(t,n,r,a,l,u,c,d,f,p){super(t,n,r,a);Se(this,"_begin");Se(this,"beginCaptures");Se(this,"_end");Se(this,"endHasBackReferences");Se(this,"endCaptures");Se(this,"applyEndPatternLast");Se(this,"hasMissingPatterns");Se(this,"patterns");Se(this,"_cachedCompiledPatterns");this._begin=new Dl(l,this.id),this.beginCaptures=u,this._end=new Dl(c||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=f||!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,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Rl;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}},Ju=class extends Gl{constructor(t,n,r,a,l,u,c,d,f){super(t,n,r,a);Se(this,"_begin");Se(this,"beginCaptures");Se(this,"whileCaptures");Se(this,"_while");Se(this,"whileHasBackReferences");Se(this,"hasMissingPatterns");Se(this,"patterns");Se(this,"_cachedCompiledPatterns");Se(this,"_cachedCompiledWhilePatterns");this._begin=new Dl(l,this.id),this.beginCaptures=u,this.whileCaptures=d,this._while=new Dl(c,qw),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=f.patterns,this.hasMissingPatterns=f.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,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Rl;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,a){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,r,a)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Rl,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||""),this._cachedCompiledWhilePatterns}},Kw=class Ln{static createCaptureRule(t,n,r,a,l){return t.registerRule(u=>new M4(n,u,r,a,l))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new P4(t.$vscodeTextmateLocation,t.id,t.name,t.match,Ln._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Pw({},r,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new g0(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Ln._compilePatterns(l,n,r))}return t.while?new Ju(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Ln._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Ln._compileCaptures(t.whileCaptures||t.captures,n,r),Ln._compilePatterns(t.patterns,n,r)):new Cp(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Ln._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Ln._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Ln._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let a=[];if(t){let l=0;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);c>l&&(l=c)}for(let u=0;u<=l;u++)a[u]=null;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);let d=0;t[u].patterns&&(d=Ln.getCompiledRuleId(t[u],n,r)),a[c]=Ln.createCaptureRule(n,t[u].$vscodeTextmateLocation,t[u].name,t[u].contentName,d)}}return a}static _compilePatterns(t,n,r){let a=[];if(t)for(let l=0,u=t.length;l<u;l++){const c=t[l];let d=-1;if(c.include){const f=Ww(c.include);switch(f.kind){case 0:case 1:d=Ln.getCompiledRuleId(r[c.include],n,r);break;case 2:let p=r[f.ruleName];p&&(d=Ln.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=f.scopeName,x=f.kind===4?f.ruleName:null,y=n.getExternalGrammar(m,r);if(y)if(x){let w=y.repository[x];w&&(d=Ln.getCompiledRuleId(w,n,y.repository))}else d=Ln.getCompiledRuleId(y.repository.$self,n,y.repository);break}}else d=Ln.getCompiledRuleId(c,n,r);if(d!==-1){const f=n.getRule(d);let p=!1;if((f instanceof g0||f instanceof Cp||f instanceof Ju)&&f.hasMissingPatterns&&f.patterns.length===0&&(p=!0),p)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},Dl=class Yw{constructor(t,n){Se(this,"source");Se(this,"ruleId");Se(this,"hasAnchor");Se(this,"hasBackReferences");Se(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let a=0,l=[],u=!1;for(let c=0;c<r;c++)if(t.charAt(c)==="\\"&&c+1<r){const f=t.charAt(c+1);f==="z"?(l.push(t.substring(a,c)),l.push("$(?!\\n)(?<!\\n)"),a=c+2):(f==="A"||f==="G")&&(u=!0),c++}this.hasAnchor=u,a===0?this.source=t:(l.push(t.substring(a,r)),this.source=l.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=O4.test(this.source):this.hasBackReferences=!1}clone(){return new Yw(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(a=>t.substring(a.start,a.end));return p0.lastIndex=0,this.source.replace(p0,(a,l)=>Hw(r[parseInt(l,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=[],a=[],l,u,c,d;for(l=0,u=this.source.length;l<u;l++)c=this.source.charAt(l),t[l]=c,n[l]=c,r[l]=c,a[l]=c,c==="\\"&&l+1<u&&(d=this.source.charAt(l+1),d==="A"?(t[l+1]="",n[l+1]="",r[l+1]="A",a[l+1]="A"):d==="G"?(t[l+1]="",n[l+1]="G",r[l+1]="",a[l+1]="G"):(t[l+1]=d,n[l+1]=d,r[l+1]=d,a[l+1]=d),l++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:a.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}},Rl=class{constructor(){Se(this,"_items");Se(this,"_hasAnchors");Se(this,"_cached");Se(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 x0(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(a=>a.resolveAnchors(t,n));return new x0(e,r,this._items.map(a=>a.ruleId))}},x0=class{constructor(e,t,n){Se(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(`
|
|
88
|
+
`)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Dm=class{constructor(e,t){this.languageId=e,this.tokenType=t}},_s,B4=(_s=class{constructor(t,n){Se(this,"_defaultAttributes");Se(this,"_embeddedLanguagesMatcher");Se(this,"_getBasicScopeAttributes",new Uw(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Dm(n,r)}));this._defaultAttributes=new Dm(t,8),this._embeddedLanguagesMatcher=new $4(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?_s._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(_s.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!")}},Se(_s,"_NULL_SCOPE_METADATA",new Dm(0,0)),Se(_s,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),_s),$4=class{constructor(e){Se(this,"values");Se(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>Hw(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])}},y0=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Xw(e,t,n,r,a,l,u,c){const d=t.content.length;let f=!1,p=-1;if(u){const y=z4(e,t,n,r,a,l);a=y.stack,r=y.linePos,n=y.isFirstLine,p=y.anchorPosition}const m=Date.now();for(;!f;){if(c!==0&&Date.now()-m>c)return new y0(a,!0);x()}return new y0(a,!1);function x(){const y=H4(e,t,n,r,a,p);if(!y){l.produce(a,d),f=!0;return}const w=y.captureIndices,C=y.matchedRuleId,_=w&&w.length>0?w[0].end>r:!1;if(C===I4){const S=a.getRule(e);l.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),yl(e,t,n,a,l,S.endCaptures,w),l.produce(a,w[0].end);const b=a;if(a=a.parent,p=b.getAnchorPos(),!_&&b.getEnterPos()===r){a=b,l.produce(a,d),f=!0;return}}else{const S=e.getRule(C);l.produce(a,w[0].start);const b=a,v=S.getName(t.content,w),E=a.contentNameScopesList.pushAttributed(v,e);if(a=a.push(C,r,p,w[0].end===d,null,E,E),S instanceof Cp){const j=S;yl(e,t,n,a,l,j.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const T=j.getContentName(t.content,w),D=E.pushAttributed(T,e);if(a=a.withContentNameScopesList(D),j.endHasBackReferences&&(a=a.withEndRule(j.getEndWithResolvedBackReferences(t.content,w))),!_&&b.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),f=!0;return}}else if(S instanceof Ju){const j=S;yl(e,t,n,a,l,j.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const T=j.getContentName(t.content,w),D=E.pushAttributed(T,e);if(a=a.withContentNameScopesList(D),j.whileHasBackReferences&&(a=a.withEndRule(j.getWhileWithResolvedBackReferences(t.content,w))),!_&&b.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),f=!0;return}}else if(yl(e,t,n,a,l,S.captures,w),l.produce(a,w[0].end),a=a.pop(),!_){a=a.safePop(),l.produce(a,d),f=!0;return}}w[0].end>r&&(r=w[0].end,n=!1)}}function z4(e,t,n,r,a,l){let u=a.beginRuleCapturedEOL?0:-1;const c=[];for(let d=a;d;d=d.pop()){const f=d.getRule(e);f instanceof Ju&&c.push({rule:f,stack:d})}for(let d=c.pop();d;d=c.pop()){const{ruleScanner:f,findOptions:p}=V4(d.rule,e,d.stack.endRule,n,r===u),m=f.findNextMatchSync(t,r,p);if(m){if(m.ruleId!==qw){a=d.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(l.produce(d.stack,m.captureIndices[0].start),yl(e,t,n,d.stack,l,d.rule.whileCaptures,m.captureIndices),l.produce(d.stack,m.captureIndices[0].end),u=m.captureIndices[0].end,m.captureIndices[0].end>r&&(r=m.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:r,anchorPosition:u,isFirstLine:n}}function H4(e,t,n,r,a,l){const u=U4(e,t,n,r,a,l),c=e.getInjections();if(c.length===0)return u;const d=F4(c,e,t,n,r,a,l);if(!d)return u;if(!u)return d;const f=u.captureIndices[0].start,p=d.captureIndices[0].start;return p<f||d.priorityMatch&&p===f?d:u}function U4(e,t,n,r,a,l){const u=a.getRule(e),{ruleScanner:c,findOptions:d}=Qw(u,e,a.endRule,n,r===l),f=c.findNextMatchSync(t,r,d);return f?{captureIndices:f.captureIndices,matchedRuleId:f.ruleId}:null}function F4(e,t,n,r,a,l,u){let c=Number.MAX_VALUE,d=null,f,p=0;const m=l.contentNameScopesList.getScopeNames();for(let x=0,y=e.length;x<y;x++){const w=e[x];if(!w.matcher(m))continue;const C=t.getRule(w.ruleId),{ruleScanner:_,findOptions:S}=Qw(C,t,null,r,a===u),b=_.findNextMatchSync(n,a,S);if(!b)continue;const v=b.captureIndices[0].start;if(!(v>=c)&&(c=v,d=b.captureIndices,f=b.ruleId,p=w.priority,c===a))break}return d?{priorityMatch:p===-1,captureIndices:d,matchedRuleId:f}:null}function Qw(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function V4(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function yl(e,t,n,r,a,l,u){if(l.length===0)return;const c=t.content,d=Math.min(l.length,u.length),f=[],p=u[0].end;for(let m=0;m<d;m++){const x=l[m];if(x===null)continue;const y=u[m];if(y.length===0)continue;if(y.start>p)break;for(;f.length>0&&f[f.length-1].endPos<=y.start;)a.produceFromScopes(f[f.length-1].scopes,f[f.length-1].endPos),f.pop();if(f.length>0?a.produceFromScopes(f[f.length-1].scopes,y.start):a.produce(r,y.start),x.retokenizeCapturedWithRuleId){const C=x.getName(c,u),_=r.contentNameScopesList.pushAttributed(C,e),S=x.getContentName(c,u),b=_.pushAttributed(S,e),v=r.push(x.retokenizeCapturedWithRuleId,y.start,-1,!1,null,_,b),E=e.createOnigString(c.substring(0,y.end));Xw(e,E,n&&y.start===0,y.start,v,a,!1,0),Gw(E);continue}const w=x.getName(c,u);if(w!==null){const _=(f.length>0?f[f.length-1].scopes:r.contentNameScopesList).pushAttributed(w,e);f.push(new G4(_,y.end))}}for(;f.length>0;)a.produceFromScopes(f[f.length-1].scopes,f[f.length-1].endPos),f.pop()}var G4=class{constructor(e,t){Se(this,"scopes");Se(this,"endPos");this.scopes=e,this.endPos=t}};function W4(e,t,n,r,a,l,u,c){return new K4(e,t,n,r,a,l,u,c)}function b0(e,t,n,r,a){const l=Xu(t,Zu),u=Kw.getCompiledRuleId(n,r,a.repository);for(const c of l)e.push({debugSelector:t,matcher:c.matcher,ruleId:u,grammar:a,priority:c.priority})}function Zu(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let a=n;a<t.length;a++)if(q4(t[a],r))return n=a+1,!0;return!1})}function q4(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 K4=class{constructor(e,t,n,r,a,l,u,c){Se(this,"_rootId");Se(this,"_lastRuleId");Se(this,"_ruleId2desc");Se(this,"_includedGrammars");Se(this,"_grammarRepository");Se(this,"_grammar");Se(this,"_injections");Se(this,"_basicScopeAttributesProvider");Se(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=c,this._basicScopeAttributesProvider=new B4(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=u,this._grammar=v0(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const f=Xu(d,Zu);for(const p of f)this._tokenTypeMatchers.push({matcher:p.matcher,type:a[d]})}}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:a=>a===this._rootScopeName?this._grammar:this.getExternalGrammar(a),injections:a=>this._grammarRepository.injections(a)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const a=r.injections;if(a)for(let u in a)b0(t,u,a[u],this,r);const l=this._grammarRepository.injections(n);l&&l.forEach(u=>{const c=this.getExternalGrammar(u);if(c){const d=c.injectionSelector;d&&b0(t,d,c,this,c)}})}return t.sort((a,l)=>a.priority-l.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]=v0(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=Kw.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===kp.NULL){a=!0;const f=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Za.set(0,f.languageId,f.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),x=this.getRule(this._rootId).getName(null,null);let y;x?y=Cl.createRootAndLookUpScopeName(x,m,this):y=Cl.createRoot("unknown",m),t=new kp(null,this._rootId,-1,-1,!1,null,y,y)}else a=!1,t.reset();e=e+`
|
|
89
|
+
`;const l=this.createOnigString(e),u=l.content.length,c=new X4(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=Xw(this,l,a,0,t,c,!0,r);return Gw(l),{lineLength:u,lineTokens:c,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function v0(e,t){return e=f4(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 Cl=class Fr{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,a=(t==null?void 0:t.scopePath)??null;for(const l of n)a=Lm.push(a,l.scopeNames),r=new Fr(r,a,l.encodedTokenAttributes);return r}static createRoot(t,n){return new Fr(null,new Lm(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),l=new Lm(null,t),u=r.themeProvider.themeMatch(l),c=Fr.mergeAttributes(n,a,u);return new Fr(null,l,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Fr.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 a=-1,l=0,u=0;return r!==null&&(a=r.fontStyle,l=r.foregroundId,u=r.backgroundId),Za.set(t,n.languageId,n.tokenType,null,a,l,u)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Fr._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const l of r)a=Fr._pushAttributed(a,l,n);return a}static _pushAttributed(t,n,r){const a=r.getMetadataForScope(n),l=t.scopePath.push(n),u=r.themeProvider.themeMatch(l),c=Fr.mergeAttributes(t.tokenAttributes,a,u);return new Fr(t,l,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((a=r.parent)==null?void 0:a.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},Sr,kp=(Sr=class{constructor(t,n,r,a,l,u,c,d){Se(this,"_stackElementBrand");Se(this,"_enterPos");Se(this,"_anchorPos");Se(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=l,this.endRule=u,this.nameScopesList=c,this.contentNameScopesList=d,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=a}equals(t){return t===null?!1:Sr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Cl.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(){Sr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,l,u,c){return new Sr(this,t,n,r,a,l,u,c)}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,a;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(a=this.contentNameScopesList)==null?void 0:a.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 Sr(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=Cl.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new Sr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Cl.fromExtension(r,n.contentNameScopesList))}},Se(Sr,"NULL",new Sr(null,0,0,0,!1,null,null,null)),Sr),Y4=class{constructor(e,t){Se(this,"balancedBracketScopes");Se(this,"unbalancedBracketScopes");Se(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Xu(n,Zu).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Xu(n,Zu).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}},X4=class{constructor(e,t,n,r){Se(this,"_emitBinaryTokens");Se(this,"_lineText");Se(this,"_tokens");Se(this,"_binaryTokens");Se(this,"_lastTokenEndIndex");Se(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 a=(e==null?void 0:e.tokenAttributes)??0,l=!1;if((r=this.balancedBracketSelectors)!=null&&r.matchesAlways&&(l=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const u=(e==null?void 0:e.getScopeNames())??[];for(const c of this._tokenTypeOverrides)c.matcher(u)&&(a=Za.set(a,0,c.type,null,-1,0,0));this.balancedBracketSelectors&&(l=this.balancedBracketSelectors.match(u))}if(l&&(a=Za.set(a,0,8,l,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===a){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(a),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,a=this._binaryTokens.length;r<a;r++)n[r]=this._binaryTokens[r];return n}},Q4=class{constructor(e,t){Se(this,"_grammars",new Map);Se(this,"_rawGrammars",new Map);Se(this,"_injectionGrammars",new Map);Se(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,a){if(!this._grammars.has(e)){let l=this._rawGrammars.get(e);if(!l)return null;this._grammars.set(e,W4(e,l,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},J4=class{constructor(t){Se(this,"_options");Se(this,"_syncRegistry");Se(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new Q4(Yu.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(Yu.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 Y4(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,l){const u=new j4(this._syncRegistry,t);for(;u.Q.length>0;)u.Q.map(c=>this._loadSingleGrammar(c.scopeName)),u.processQueue();return this._grammarForScopeName(t,n,r,a,l)}_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,a=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,a)}_grammarForScopeName(t,n=0,r=null,a=null,l=null){return this._syncRegistry.grammarForScopeName(t,n,r,a,l)}},Ep=kp.NULL;function ed(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[a,l]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof l=="string"?n[a]=l:a===r&&Object.assign(n,l);return n}function oi(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function Z4(e){return Array.isArray(e)?e:[e]}async function Jw(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function jd(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Zw(e){return e==="ansi"||jd(e)}function Nd(e){return e==="none"}function eC(e){return Nd(e)}const eO=/(\r?\n)/g;function Td(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split(eO);let r=0;const a=[];for(let u=0;u<n.length;u+=2){const c=t?n[u]+(n[u+1]||""):n[u];a.push([c,r]),r+=n[u].length,r+=((l=n[u+1])==null?void 0:l.length)||0}return a}const _0={light:"#333333",dark:"#bbbbbb"},S0={light:"#fffffe",dark:"#1e1e1e"},w0="__shiki_resolved";function Ng(e){var c,d,f,p,m;if(e!=null&&e[w0])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(y=>!y.name&&!y.scope):void 0;(c=x==null?void 0:x.settings)!=null&&c.foreground&&(r=x.settings.foreground),(d=x==null?void 0:x.settings)!=null&&d.background&&(n=x.settings.background),!r&&((f=t==null?void 0:t.colors)!=null&&f["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"?_0.light:_0.dark),n||(n=t.type==="light"?S0.light:S0.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 a=0;const l=new Map;function u(x){var w;if(l.has(x))return l.get(x);a+=1;const y=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${y}`]?u(x):(l.set(x,y),y)}t.settings=t.settings.map(x=>{var _,S;const y=((_=x.settings)==null?void 0:_.foreground)&&!x.settings.foreground.startsWith("#"),w=((S=x.settings)==null?void 0:S.background)&&!x.settings.background.startsWith("#");if(!y&&!w)return x;const C={...x,settings:{...x.settings}};if(y){const b=u(x.settings.foreground);t.colorReplacements[b]=x.settings.foreground,C.settings.foreground=b}if(w){const b=u(x.settings.background);t.colorReplacements[b]=x.settings.background,C.settings.background=b}return C});for(const x of Object.keys(t.colors||{}))if((x==="editor.foreground"||x==="editor.background"||x.startsWith("terminal.ansi"))&&!((m=t.colors[x])!=null&&m.startsWith("#"))){const y=u(t.colors[x]);t.colorReplacements[y]=t.colors[x],t.colors[x]=y}return Object.defineProperty(t,w0,{enumerable:!1,writable:!1,value:!0}),t}async function tC(e){return[...new Set((await Promise.all(e.filter(t=>!Zw(t)).map(async t=>await Jw(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function nC(e){return(await Promise.all(e.map(async t=>eC(t)?null:Ng(await Jw(t))))).filter(t=>!!t)}function rC(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 zt(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var tO=class extends J4{constructor(t,n,r,a={}){super(t);Se(this,"_resolver");Se(this,"_themes");Se(this,"_langs");Se(this,"_alias");Se(this,"_resolvedThemes",new Map);Se(this,"_resolvedGrammars",new Map);Se(this,"_langMap",new Map);Se(this,"_langGraph",new Map);Se(this,"_textmateThemeCache",new WeakMap);Se(this,"_loadedThemesCache",null);Se(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,this._alias=a,this._themes.map(l=>this.loadTheme(l)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=Ng(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=Yu.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=rC(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var l,u,c,d;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(f=>{var p;return(p=f.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 a=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(f=>{this._alias[f]=t.name}),this._loadedLanguagesCache=null,n.size)for(const f of n)this._resolvedGrammars.delete(f.name),this._loadedLanguagesCache=null,(u=(l=this._syncRegistry)==null?void 0:l._injectionGrammars)==null||u.delete(f.scopeName),(d=(c=this._syncRegistry)==null?void 0:c._grammars)==null||d.delete(f.scopeName),this.loadLanguage(this._langMap.get(f.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const a of t)this.resolveEmbeddedLanguages(a);const n=[...this._langGraph.entries()],r=n.filter(([a,l])=>!l);if(r.length){const a=n.filter(([l,u])=>{var c;return u?(c=u.embeddedLanguages||u.embeddedLangs)==null?void 0:c.some(d=>r.map(([f])=>f).includes(d)):!1}).filter(l=>!r.includes(l));throw new zt(`Missing languages ${r.map(([l])=>`\`${l}\``).join(", ")}, required by ${a.map(([l])=>`\`${l}\``).join(", ")}`)}for(const[a,l]of n)this._resolver.addLanguage(l);for(const[a,l]of n)this.loadLanguage(l)}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))}},nO=class{constructor(e,t){Se(this,"_langs",new Map);Se(this,"_scopeToLang",new Map);Se(this,"_injections",new Map);Se(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 a=t.slice(0,r).join(".");n=[...n,...this._injections.get(a)||[]]}return n}};let dl=0;function rO(e){dl+=1,e.warnings!==!1&&dl>=10&&dl%10===0&&console.warn(`[Shiki] ${dl} 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 zt("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Ng),a=new tO(new nO(e.engine,n),r,n,e.langAlias);let l;function u(b){return rC(b,e.langAlias)}function c(b){_();const v=a.getGrammar(typeof b=="string"?b:b.name);if(!v)throw new zt(`Language \`${b}\` not found, you may need to load it first`);return v}function d(b){if(b==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};_();const v=a.getTheme(b);if(!v)throw new zt(`Theme \`${b}\` not found, you may need to load it first`);return v}function f(b){_();const v=d(b);return l!==b&&(a.setTheme(v),l=b),{theme:v,colorMap:a.getColorMap()}}function p(){return _(),a.getLoadedThemes()}function m(){return _(),a.getLoadedLanguages()}function x(...b){_(),a.loadLanguages(b.flat(1))}async function y(...b){return x(await tC(b))}function w(...b){_();for(const v of b.flat(1))a.loadTheme(v)}async function C(...b){return _(),w(await nC(b))}function _(){if(t)throw new zt("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),dl-=1)}return{setTheme:f,getTheme:d,getLanguage:c,getLoadedThemes:p,getLoadedLanguages:m,resolveLangAlias:u,loadLanguage:y,loadLanguageSync:x,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function sO(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([nC(e.themes||[]),tC(e.langs||[]),e.engine]);return rO({...e,themes:t,langs:n,engine:r})}const sC=new WeakMap;function Ad(e,t){sC.set(e,t)}function Ol(e){return sC.get(e)}var Ld=class iC{constructor(...t){Se(this,"_stacks",{});Se(this,"lang");if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,a]=t;this.lang=r,this._stacks={[a]: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 iC(Object.fromEntries(Z4(n).map(r=>[r,Ep])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return iO(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function iO(e){const t=[],n=new Set;function r(a){var u;if(n.has(a))return;n.add(a);const l=(u=a==null?void 0:a.nameScopesList)==null?void 0:u.scopeName;l&&t.push(l),a.parent&&r(a.parent)}return r(e),t}function aO(e,t){if(!(e instanceof Ld))throw new zt("Invalid grammar state");return e.getInternalStack(t)}const oO=/,/,lO=/ /;function aC(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(jd(e.resolveLangAlias(n.lang||"text"))||Nd(r))return Td(t).map(c=>[{content:c[0],offset:c[1]}]);const{theme:a,colorMap:l}=e.setTheme(r),u=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==u.name)throw new zt(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${u.name}"`);if(!n.grammarState.themes.includes(a.name))throw new zt(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return uO(t,u,a,l,n)}function cO(...e){if(e.length===2)return Ol(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:l=t.getLoadedThemes()[0]}=r;if(jd(a)||Nd(l))throw new zt("Plain language does not have grammar state");if(a==="ansi")throw new zt("ANSI language does not have grammar state");const{theme:u,colorMap:c}=t.setTheme(l),d=t.getLanguage(a);return new Ld(Tg(n,d,u,c,r).stateStack,d.name,u.name)}function uO(e,t,n,r,a){const l=Tg(e,t,n,r,a),u=new Ld(l.stateStack,t.name,n.name);return Ad(l.tokens,u),l.tokens}function Tg(e,t,n,r,a){const l=ed(n,a),{tokenizeMaxLineLength:u=0,tokenizeTimeLimit:c=500}=a,d=Td(e);let f=a.grammarState?aO(a.grammarState,n.name)??Ep:a.grammarContextCode!=null?Tg(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ep,p=[];const m=[];for(let x=0,y=d.length;x<y;x++){const[w,C]=d[x];if(w===""){p=[],m.push([]);continue}if(u>0&&w.length>=u){p=[],m.push([{content:w,offset:C,color:"",fontStyle:0}]);continue}let _,S,b;a.includeExplanation&&(_=t.tokenizeLine(w,f,c),S=_.tokens,b=0);const v=t.tokenizeLine2(w,f,c),E=v.tokens.length/2;for(let j=0;j<E;j++){const T=v.tokens[2*j],D=j+1<E?v.tokens[2*j+2]:w.length;if(T===D)continue;const L=v.tokens[2*j+1],O=oi(r[Za.getForeground(L)],l),M=Za.getFontStyle(L),W={content:w.substring(T,D),offset:C+T,color:O,fontStyle:M};if(a.includeExplanation){const z=[];if(a.includeExplanation!=="scopeName")for(const P of n.settings){let V;switch(typeof P.scope){case"string":V=P.scope.split(oO).map(G=>G.trim());break;case"object":V=P.scope;break;default:continue}z.push({settings:P,selectors:V.map(G=>G.split(lO))})}W.explanation=[];let R=0;for(;T+R<D;){const P=S[b],V=w.substring(P.startIndex,P.endIndex);R+=V.length,W.explanation.push({content:V,scopes:a.includeExplanation==="scopeName"?dO(P.scopes):hO(z,P.scopes)}),b+=1}}p.push(W)}m.push(p),p=[],f=v.ruleStack}return{tokens:m,stateStack:f}}function dO(e){return e.map(t=>({scopeName:t}))}function hO(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const l=t[r];n[r]={scopeName:l,themeMatches:mO(e,l,t.slice(0,r))}}return n}function C0(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function fO(e,t,n){if(!C0(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)C0(e[r],n[a])&&(r-=1),a-=1;return r===-1}function mO(e,t,n){const r=[];for(const{selectors:a,settings:l}of e)for(const u of a)if(fO(u,t,n)){r.push(l);break}return r}function oC(e,t,n,r=aC){const a=Object.entries(n.themes).filter(f=>f[1]).map(f=>({color:f[0],theme:f[1]})),l=a.map(f=>{const p=r(e,t,{...n,theme:f.theme});return{tokens:p,state:Ol(p),theme:typeof f.theme=="string"?f.theme:f.theme.name}}),u=pO(...l.map(f=>f.tokens)),c=u[0].map((f,p)=>f.map((m,x)=>{const y={content:m.content,variants:{},offset:m.offset};return"includeExplanation"in n&&n.includeExplanation&&(y.explanation=m.explanation),u.forEach((w,C)=>{const{content:_,explanation:S,offset:b,...v}=w[p][x];y.variants[a[C].color]=v}),y})),d=l[0].state?new Ld(Object.fromEntries(l.map(f=>{var p;return[f.theme,(p=f.state)==null?void 0:p.getInternalStack(f.theme)]})),l[0].state.lang):void 0;return d&&Ad(c,d),c}function pO(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const a=e.map(d=>d[r]),l=t.map(()=>[]);t.forEach((d,f)=>d.push(l[f]));const u=a.map(()=>0),c=a.map(d=>d[0]);for(;c.every(d=>d);){const d=Math.min(...c.map(f=>f.content.length));for(let f=0;f<n;f++){const p=c[f];p.content.length===d?(l[f].push(p),u[f]+=1,c[f]=a[f][u[f]]):(l[f].push({...p,content:p.content.slice(0,d)}),c[f]={...p,content:p.content.slice(d),offset:p.offset+d})}}}return t}const gO=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Wl{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Wl.prototype.normal={};Wl.prototype.property={};Wl.prototype.space=void 0;function lC(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Wl(n,r,t)}function jp(e){return e.toLowerCase()}class Zn{constructor(t,n){this.attribute=n,this.property=t}}Zn.prototype.attribute="";Zn.prototype.booleanish=!1;Zn.prototype.boolean=!1;Zn.prototype.commaOrSpaceSeparated=!1;Zn.prototype.commaSeparated=!1;Zn.prototype.defined=!1;Zn.prototype.mustUseProperty=!1;Zn.prototype.number=!1;Zn.prototype.overloadedBoolean=!1;Zn.prototype.property="";Zn.prototype.spaceSeparated=!1;Zn.prototype.space=void 0;let xO=0;const ct=Xi(),fn=Xi(),Np=Xi(),Be=Xi(),$t=Xi(),Xa=Xi(),lr=Xi();function Xi(){return 2**++xO}const Tp=Object.freeze(Object.defineProperty({__proto__:null,boolean:ct,booleanish:fn,commaOrSpaceSeparated:lr,commaSeparated:Xa,number:Be,overloadedBoolean:Np,spaceSeparated:$t},Symbol.toStringTag,{value:"Module"})),Rm=Object.keys(Tp);class Ag extends Zn{constructor(t,n,r,a){let l=-1;if(super(t,n),k0(this,"space",a),typeof r=="number")for(;++l<Rm.length;){const u=Rm[l];k0(this,Rm[l],(r&Tp[u])===Tp[u])}}}Ag.prototype.defined=!0;function k0(e,t,n){n&&(e[t]=n)}function co(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new Ag(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[jp(r)]=r,n[jp(l.attribute)]=r}return new Wl(t,n,e.space)}const cC=co({properties:{ariaActiveDescendant:null,ariaAtomic:fn,ariaAutoComplete:null,ariaBusy:fn,ariaChecked:fn,ariaColCount:Be,ariaColIndex:Be,ariaColSpan:Be,ariaControls:$t,ariaCurrent:null,ariaDescribedBy:$t,ariaDetails:null,ariaDisabled:fn,ariaDropEffect:$t,ariaErrorMessage:null,ariaExpanded:fn,ariaFlowTo:$t,ariaGrabbed:fn,ariaHasPopup:null,ariaHidden:fn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:$t,ariaLevel:Be,ariaLive:null,ariaModal:fn,ariaMultiLine:fn,ariaMultiSelectable:fn,ariaOrientation:null,ariaOwns:$t,ariaPlaceholder:null,ariaPosInSet:Be,ariaPressed:fn,ariaReadOnly:fn,ariaRelevant:null,ariaRequired:fn,ariaRoleDescription:$t,ariaRowCount:Be,ariaRowIndex:Be,ariaRowSpan:Be,ariaSelected:fn,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 uC(e,t){return t in e?e[t]:t}function dC(e,t){return uC(e,t.toLowerCase())}const yO=co({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Xa,acceptCharset:$t,accessKey:$t,action:null,allow:null,allowFullScreen:ct,allowPaymentRequest:ct,allowUserMedia:ct,alt:null,as:null,async:ct,autoCapitalize:null,autoComplete:$t,autoFocus:ct,autoPlay:ct,blocking:$t,capture:null,charSet:null,checked:ct,cite:null,className:$t,cols:Be,colSpan:null,content:null,contentEditable:fn,controls:ct,controlsList:$t,coords:Be|Xa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ct,defer:ct,dir:null,dirName:null,disabled:ct,download:Np,draggable:fn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ct,formTarget:null,headers:$t,height:Be,hidden:Np,high:Be,href:null,hrefLang:null,htmlFor:$t,httpEquiv:$t,id:null,imageSizes:null,imageSrcSet:null,inert:ct,inputMode:null,integrity:null,is:null,isMap:ct,itemId:null,itemProp:$t,itemRef:$t,itemScope:ct,itemType:$t,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ct,low:Be,manifest:null,max:null,maxLength:Be,media:null,method:null,min:null,minLength:Be,multiple:ct,muted:ct,name:null,nonce:null,noModule:ct,noValidate:ct,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:ct,optimum:Be,pattern:null,ping:$t,placeholder:null,playsInline:ct,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ct,referrerPolicy:null,rel:$t,required:ct,reversed:ct,rows:Be,rowSpan:Be,sandbox:$t,scope:null,scoped:ct,seamless:ct,selected:ct,shadowRootClonable:ct,shadowRootDelegatesFocus:ct,shadowRootMode:null,shape:null,size:Be,sizes:null,slot:null,span:Be,spellCheck:fn,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:ct,useMap:null,value:fn,width:Be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:$t,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:ct,declare:ct,event:null,face:null,frame:null,frameBorder:null,hSpace:Be,leftMargin:Be,link:null,longDesc:null,lowSrc:null,marginHeight:Be,marginWidth:Be,noResize:ct,noHref:ct,noShade:ct,noWrap:ct,object:null,profile:null,prompt:null,rev:null,rightMargin:Be,rules:null,scheme:null,scrolling:fn,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:ct,disableRemotePlayback:ct,prefix:null,property:null,results:Be,security:null,unselectable:null},space:"html",transform:dC}),bO=co({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:lr,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:$t,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:ct,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:Xa,g2:Xa,glyphName:Xa,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:lr,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:$t,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Be,pointsAtY:Be,pointsAtZ:Be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:lr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:lr,rev:lr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:lr,requiredFeatures:lr,requiredFonts:lr,requiredFormats:lr,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:lr,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:lr,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:lr,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:uC}),hC=co({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()}}),fC=co({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:dC}),mC=co({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),vO=/[A-Z]/g,E0=/-[a-z]/g,_O=/^data[-\w.:]+$/i;function SO(e,t){const n=jp(t);let r=t,a=Zn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&_O.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(E0,CO);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!E0.test(l)){let u=l.replace(vO,wO);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=Ag}return new a(r,t)}function wO(e){return"-"+e.toLowerCase()}function CO(e){return e.charAt(1).toUpperCase()}const kO=lC([cC,yO,hC,fC,mC],"html"),pC=lC([cC,bO,hC,fC,mC],"svg"),j0={}.hasOwnProperty;function EO(e,t){const n=t||{};function r(a,...l){let u=r.invalid;const c=r.handlers;if(a&&j0.call(a,e)){const d=String(a[e]);u=j0.call(c,d)?c[d]:r.unknown}if(u)return u.call(this,a,...l)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const jO=/["&'<>`]/g,NO=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,TO=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,AO=/[|\\{}()[\]^$+*?.]/g,N0=new WeakMap;function LO(e,t){if(e=e.replace(t.subset?DO(t.subset):jO,r),t.subset||t.escapeOnly)return e;return e.replace(NO,n).replace(TO,r);function n(a,l,u){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,u.charCodeAt(l+2),t)}function r(a,l,u){return t.format(a.charCodeAt(0),u.charCodeAt(l+1),t)}}function DO(e){let t=N0.get(e);return t||(t=RO(e),N0.set(e,t)),t}function RO(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(AO,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const OO=/[\dA-Fa-f]/;function IO(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!OO.test(String.fromCharCode(t))?r:r+";"}const MO=/\d/;function PO(e,t,n){const r="&#"+String(e);return n&&t&&!MO.test(String.fromCharCode(t))?r:r+";"}const BO=["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"],Om={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:"€"},$O=["cent","copy","divide","gt","lt","not","para","times"],gC={}.hasOwnProperty,Ap={};let bu;for(bu in Om)gC.call(Om,bu)&&(Ap[Om[bu]]=bu);const zO=/[^\dA-Za-z]/;function HO(e,t,n,r){const a=String.fromCharCode(e);if(gC.call(Ap,a)){const l=Ap[a],u="&"+l;return n&&BO.includes(l)&&!$O.includes(l)&&(!r||t&&t!==61&&zO.test(String.fromCharCode(t)))?u:u+";"}return""}function UO(e,t,n){let r=IO(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=HO(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const l=PO(e,t,n.omitOptionalSemicolons);l.length<r.length&&(r=l)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function Qa(e,t){return LO(e,Object.assign({format:UO},t))}const FO=/^>|^->|<!--|-->|--!>|<!-$/g,VO=[">"],GO=["<",">"];function WO(e,t,n,r){return r.settings.bogusComments?"<?"+Qa(e.value,Object.assign({},r.settings.characterReferences,{subset:VO}))+">":"<!--"+e.value.replace(FO,a)+"-->";function a(l){return Qa(l,Object.assign({},r.settings.characterReferences,{subset:GO}))}}function qO(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function T0(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function KO(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function YO(e){return e.join(" ").trim()}const XO=/[ \t\n\f\r]/g;function Lg(e){return typeof e=="object"?e.type==="text"?A0(e.value):!1:A0(e)}function A0(e){return e.replace(XO,"")===""}const yn=yC(1),xC=yC(-1),QO=[];function yC(e){return t;function t(n,r,a){const l=n?n.children:QO;let u=(r||0)+e,c=l[u];if(!a)for(;c&&Lg(c);)u+=e,c=l[u];return c}}const JO={}.hasOwnProperty;function bC(e){return t;function t(n,r,a){return JO.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const Dg=bC({body:eI,caption:Im,colgroup:Im,dd:sI,dt:rI,head:Im,html:ZO,li:nI,optgroup:iI,option:aI,p:tI,rp:L0,rt:L0,tbody:lI,td:D0,tfoot:cI,th:D0,thead:oI,tr:uI});function Im(e,t,n){const r=yn(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Lg(r.value.charAt(0)))}function ZO(e,t,n){const r=yn(n,t);return!r||r.type!=="comment"}function eI(e,t,n){const r=yn(n,t);return!r||r.type!=="comment"}function tI(e,t,n){const r=yn(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 nI(e,t,n){const r=yn(n,t);return!r||r.type==="element"&&r.tagName==="li"}function rI(e,t,n){const r=yn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function sI(e,t,n){const r=yn(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function L0(e,t,n){const r=yn(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function iI(e,t,n){const r=yn(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function aI(e,t,n){const r=yn(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function oI(e,t,n){const r=yn(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function lI(e,t,n){const r=yn(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function cI(e,t,n){return!yn(n,t)}function uI(e,t,n){const r=yn(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function D0(e,t,n){const r=yn(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const dI=bC({body:mI,colgroup:pI,head:fI,html:hI,tbody:gI});function hI(e){const t=yn(e,-1);return!t||t.type!=="comment"}function fI(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 mI(e){const t=yn(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Lg(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function pI(e,t,n){const r=xC(n,t),a=yn(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Dg(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function gI(e,t,n){const r=xC(n,t),a=yn(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Dg(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const vu={name:[[`
|
|
90
|
+
\f\r &/=>`.split(""),`
|
|
91
|
+
\f\r "&'/=>\``.split("")],[`\0
|
|
92
|
+
\f\r "&'/<=>`.split(""),`\0
|
|
93
|
+
\f\r "&'/<=>\``.split("")]],unquoted:[[`
|
|
94
|
+
\f\r &>`.split(""),`\0
|
|
95
|
+
\f\r "&'<=>\``.split("")],[`\0
|
|
96
|
+
\f\r "&'<=>\``.split(""),`\0
|
|
97
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function xI(e,t,n,r){const a=r.schema,l=a.space==="svg"?!1:r.settings.omitOptionalTags;let u=a.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const c=[];let d;a.space==="html"&&e.tagName==="svg"&&(r.schema=pC);const f=yI(r,e.properties),p=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,p&&(u=!1),(f||!l||!dI(e,t,n))&&(c.push("<",e.tagName,f?" "+f:""),u&&(a.space==="svg"||r.settings.closeSelfClosing)&&(d=f.charAt(f.length-1),(!r.settings.tightSelfClosing||d==="/"||d&&d!=='"'&&d!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(p),!u&&(!l||!Dg(e,t,n))&&c.push("</"+e.tagName+">"),c.join("")}function yI(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const l=bI(e,a,t[a]);l&&n.push(l)}}for(;++r<n.length;){const l=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&l!=='"'&&l!=="'"&&(n[r]+=" ")}return n.join("")}function bI(e,t,n){const r=SO(e.schema,t),a=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,l=e.settings.allowDangerousCharacters?0:1;let u=e.quote,c;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 d=Qa(r.attribute,Object.assign({},e.settings.characterReferences,{subset:vu.name[a][l]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?KO:YO)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(c=Qa(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:vu.unquoted[a][l]}))),c!==n&&(e.settings.quoteSmart&&T0(n,u)>T0(n,e.alternative)&&(u=e.alternative),c=u+Qa(n,Object.assign({},e.settings.characterReferences,{subset:(u==="'"?vu.single:vu.double)[a][l],attribute:!0}))+u),d+(c&&"="+c))}const vI=["<","&"];function vC(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Qa(e.value,Object.assign({},r.settings.characterReferences,{subset:vI}))}function _I(e,t,n,r){return r.settings.allowDangerousHtml?e.value:vC(e,t,n,r)}function SI(e,t,n,r){return r.all(e)}const wI=EO("type",{invalid:CI,unknown:kI,handlers:{comment:WO,doctype:qO,element:xI,raw:_I,root:SI,text:vC}});function CI(e){throw new Error("Expected node, not `"+e+"`")}function kI(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const EI={},jI={},NI=[];function TI(e,t){const n=t||EI,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:AI,all:LI,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||gO,characterReferences:n.characterReferences||jI,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?pC:kO,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function AI(e,t,n){return wI(e,t,n,this)}function LI(e){const t=[],n=e&&e.children||NI;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const R0=/\s+/g;function _C(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(R0)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(R0);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const DI=/:?lang=["']([^"']+)["']/g,RI=/(?:```|~~~)([\w-]+)/g,OI=/\\begin\{([\w-]+)\}/g,II=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function MI(e){const t=Td(e,!0).map(([a])=>a);function n(a){if(a===e.length)return{line:t.length-1,character:t.at(-1).length};let l=a,u=0;for(const c of t){if(l<c.length)break;l-=c.length,u++}return{line:u,character:l}}function r(a,l){let u=0;for(let c=0;c<a;c++)u+=t[c].length;return u+=l,u}return{lines:t,indexToPos:n,posToIndex:r}}function PI(e,t,n){const r=new Set;for(const l of e.matchAll(DI)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(RI)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(OI)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(II)){const u=l[1].toLowerCase().trim(),c=u.includes("/")?u.split("/").pop():u;c&&r.add(c)}if(!n)return[...r];const a=n.getBundledLanguages();return[...r].filter(l=>l&&a[l])}const BI=["color","background-color"];function $I(e,t){let n=0;const r=[];for(const a of t)a>n&&r.push({...e,content:e.content.slice(n,a),offset:e.offset+n}),n=a;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function zI(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,a)=>r-a);return n.length?e.map(r=>r.flatMap(a=>{const l=n.filter(u=>a.offset<u&&u<a.offset+a.content.length).map(u=>u-a.offset).sort((u,c)=>u-c);return l.length?$I(a,l):a})):e}function HI(e,t,n,r,a="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},u=t.map(p=>td(e.variants[p])),c=new Set(u.flatMap(p=>Object.keys(p))),d={},f=(p,m)=>{const x=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[p]+(m==="color"?"":x)};return u.forEach((p,m)=>{for(const x of c){const y=p[x]||"inherit";if(m===0&&r&&BI.includes(x))if(r==="light-dark()"&&u.length>1){const w=t.findIndex(_=>_==="light"),C=t.findIndex(_=>_==="dark");if(w===-1||C===-1)throw new zt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[x]=`light-dark(${u[w][x]||"inherit"}, ${u[C][x]||"inherit"})`,a==="css-vars"&&(d[f(m,x)]=y)}else d[x]=y;else a==="css-vars"&&(d[f(m,x)]=y)}}),l.htmlStyle=d,l}function td(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&Dn.Italic&&(t["font-style"]="italic"),e.fontStyle&Dn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&Dn.Underline&&n.push("underline"),e.fontStyle&Dn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Lp(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function UI(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let l=function(c){if(typeof c=="number"){if(c<0||c>n.source.length)throw new zt(`Invalid decoration offset: ${c}. Code length: ${n.source.length}`);return{...a.indexToPos(c),offset:c}}else{const d=a.lines[c.line];if(d===void 0)throw new zt(`Invalid decoration position ${JSON.stringify(c)}. Lines length: ${a.lines.length}`);let f=c.character;if(f<0&&(f=d.length+f),f<0||f>d.length)throw new zt(`Invalid decoration position ${JSON.stringify(c)}. Line ${c.line} length: ${d.length}`);return{...c,character:f,offset:a.posToIndex(c.line,f)}}};var r=l;const a=MI(n.source),u=(n.options.decorations||[]).map(c=>({...c,start:l(c.start),end:l(c.end)}));FI(u),e.set(n.meta,{decorations:u,converter:a,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 zI(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const r=t(this),a=[...n.children].filter(m=>m.type==="element"&&m.tagName==="span");if(a.length!==r.converter.lines.length)throw new zt(`Number of lines in code element (${a.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function l(m,x,y,w){const C=a[m];let _="",S=-1,b=-1;if(x===0&&(S=0),y===0&&(b=0),y===Number.POSITIVE_INFINITY&&(b=C.children.length),S===-1||b===-1)for(let E=0;E<C.children.length;E++)_+=SC(C.children[E]),S===-1&&_.length===x&&(S=E+1),b===-1&&_.length===y&&(b=E+1);if(S===-1)throw new zt(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(b===-1)throw new zt(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const v=C.children.slice(S,b);if(!w.alwaysWrap&&v.length===C.children.length)c(C,w,"line");else if(!w.alwaysWrap&&v.length===1&&v[0].type==="element")c(v[0],w,"token");else{const E={type:"element",tagName:"span",properties:{},children:v};c(E,w,"wrapper"),C.children.splice(S,v.length,E)}}function u(m,x){a[m]=c(a[m],x,"line")}function c(m,x,y){var _;const w=x.properties||{},C=x.transform||(S=>S);return m.tagName=x.tagName||"span",m.properties={...m.properties,...w,class:m.properties.class},(_=x.properties)!=null&&_.class&&_C(m,x.properties.class),m=C(m,y)||m,m}const d=[],f=r.decorations.sort((m,x)=>x.start.offset-m.start.offset||m.end.offset-x.end.offset);for(const m of f){const{start:x,end:y}=m;if(x.line===y.line)l(x.line,x.character,y.character,m);else if(x.line<y.line){l(x.line,x.character,Number.POSITIVE_INFINITY,m);for(let w=x.line+1;w<y.line;w++)d.unshift(()=>u(w,m));l(y.line,0,y.character,m)}}d.forEach(m=>m())}}}function FI(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new zt(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const a=e[r],l=n.start.offset<=a.start.offset&&a.start.offset<n.end.offset,u=n.start.offset<a.end.offset&&a.end.offset<=n.end.offset,c=a.start.offset<=n.start.offset&&n.start.offset<a.end.offset,d=a.start.offset<n.end.offset&&n.end.offset<=a.end.offset;if(l||u||c||d){if(l&&u||c&&d||c&&n.start.offset===n.end.offset||u&&a.start.offset===a.end.offset)continue;throw new zt(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function SC(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(SC).join(""):""}const VI=[UI()];function nd(e){const t=GI(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...VI]}function GI(e){const t=[],n=[],r=[];for(const a of e)switch(a.enforce){case"pre":t.push(a);break;case"post":n.push(a);break;default:r.push(a)}return{pre:t,post:n,normal:r}}var Bi=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Mm={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function WI(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 O0(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 qI(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)Mm[r]&&t.push({type:"setDecoration",value:Mm[r]});else if(r<=29){const a=Mm[r-20];a&&(t.push({type:"resetDecoration",value:a}),a==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Bi[r-30]}});else if(r===38){const a=O0(e);a&&t.push({type:"setForegroundColor",value:a})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Bi[r-40]}});else if(r===48){const a=O0(e);a&&t.push({type:"setBackgroundColor",value:a})}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:Bi[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Bi[r-100+8]}})}return t}function KI(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let l=0;do{const u=WI(r,l),c=u.sequence?r.substring(l,u.startPosition):r.substring(l);if(c.length>0&&a.push({value:c,foreground:e,background:t,decorations:new Set(n)}),u.sequence){const d=qI(u.sequence);for(const f of d)f.type==="resetAll"?(e=null,t=null,n.clear()):f.type==="resetForegroundColor"?e=null:f.type==="resetBackgroundColor"?t=null:f.type==="resetDecoration"&&n.delete(f.value);for(const f of d)f.type==="setForegroundColor"?e=f.value:f.type==="setBackgroundColor"?t=f.value:f.type==="setDecoration"&&n.add(f.value)}l=u.position}while(l<r.length);return a}}}var YI={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 XI(e=YI){function t(c){return e[c]}function n(c){return`#${c.map(d=>Math.max(0,Math.min(d,255)).toString(16).padStart(2,"0")).join("")}`}let r;function a(){if(r)return r;r=[];for(let f=0;f<Bi.length;f++)r.push(t(Bi[f]));let c=[0,95,135,175,215,255];for(let f=0;f<6;f++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)r.push(n([c[f],c[p],c[m]]));let d=8;for(let f=0;f<24;f++,d+=10)r.push(n([d,d,d]));return r}function l(c){return a()[c]}function u(c){switch(c.type){case"named":return t(c.name);case"rgb":return n(c.rgb);case"table":return l(c.index)}}return{value:u}}const QI=/#([0-9a-f]{3,8})/i,JI=/var\((--[\w-]+-ansi-[\w-]+)\)/,ZI={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 eM(e,t,n){const r=ed(e,n),a=Td(t),l=XI(Object.fromEntries(Bi.map(c=>{var f;const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`;return[c,((f=e.colors)==null?void 0:f[d])||ZI[c]]}))),u=KI();return a.map(c=>u.parse(c[0]).map(d=>{let f,p;d.decorations.has("reverse")?(f=d.background?l.value(d.background):e.bg,p=d.foreground?l.value(d.foreground):e.fg):(f=d.foreground?l.value(d.foreground):e.fg,p=d.background?l.value(d.background):void 0),f=oi(f,r),p=oi(p,r),d.decorations.has("dim")&&(f=tM(f));let m=Dn.None;return d.decorations.has("bold")&&(m|=Dn.Bold),d.decorations.has("italic")&&(m|=Dn.Italic),d.decorations.has("underline")&&(m|=Dn.Underline),d.decorations.has("strikethrough")&&(m|=Dn.Strikethrough),{content:d.value,offset:c[1],color:f,bgColor:p,fontStyle:m}}))}function tM(e){const t=e.match(QI);if(t){const r=t[1];if(r.length===8){const a=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${a}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const a=r[0],l=r[1],u=r[2],c=r[3];return`#${a}${a}${l}${l}${u}${u}${Math.round(Number.parseInt(`${c}${c}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const a=r[0],l=r[1],u=r[2];return`#${a}${a}${l}${l}${u}${u}80`}}}const n=e.match(JI);return n?`var(${n[1]}-dim)`:e}function Dp(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!jd(r)&&!Nd(a)&&r==="ansi"){const{theme:l}=e.setTheme(a);return eM(l,t,n)}return aC(e,t,n)}function rd(e,t,n){let r,a,l,u,c,d;if("themes"in n){const{defaultColor:f="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,x=Object.entries(n.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,b)=>S.color===f?-1:b.color===f?1:0);if(x.length===0)throw new zt("`themes` option must not be empty");const y=oC(e,t,n,Dp);if(d=Ol(y),f&&f!=="light-dark()"&&!x.some(S=>S.color===f))throw new zt(`\`themes\` option must contain the defaultColor key \`${f}\``);const w=x.map(S=>e.getTheme(S.theme)),C=x.map(S=>S.color);l=y.map(S=>S.map(b=>HI(b,C,p,f,m))),d&&Ad(l,d);const _=x.map(S=>ed(S.theme,n));a=I0(x,w,_,p,f,"fg",m),r=I0(x,w,_,p,f,"bg",m),u=`shiki-themes ${w.map(S=>S.name).join(" ")}`,c=f?void 0:[a,r].join(";")}else if("theme"in n){const f=ed(n.theme,n);l=Dp(e,t,n);const p=e.getTheme(n.theme);r=oi(p.bg,f),a=oi(p.fg,f),u=p.name,d=Ol(l)}else throw new zt("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:a,bg:r,themeName:u,rootStyle:c,grammarState:d}}function I0(e,t,n,r,a,l,u){return e.map((c,d)=>{const f=oi(t[d][l],n[d])||"inherit",p=`${r+c.color}${l==="bg"?"-bg":""}:${f}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const m=e.findIndex(y=>y.color==="light"),x=e.findIndex(y=>y.color==="dark");if(m===-1||x===-1)throw new zt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${oi(t[m][l],n[m])||"inherit"}, ${oi(t[x][l],n[x])||"inherit"});${p}`}return f}return u==="css-vars"?p:null}).filter(c=>!!c).join(";")}const wC=/^\s+$/,nM=/^(\s*)(.*?)(\s*)$/;function sd(e,t,n,r={meta:{},options:n,codeToHast:(a,l)=>sd(e,a,l),codeToTokens:(a,l)=>rd(e,a,l)}){var w,C;let a=t;for(const _ of nd(n))a=((w=_.preprocess)==null?void 0:w.call(r,a,n))||a;let{tokens:l,fg:u,bg:c,themeName:d,rootStyle:f,grammarState:p}=rd(e,a,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:x=!1}=n;m===!0?l=sM(l):m==="never"&&(l=iM(l)),x&&(l=aM(l));const y={...r,get source(){return a}};for(const _ of nd(n))l=((C=_.tokens)==null?void 0:C.call(y,l))||l;return rM(l,{...n,fg:u,bg:c,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??f},y,p)}function rM(e,t,n,r=Ol(e)){var C,_,S,b;const a=nd(t),l=[],u={type:"root",children:[]},{structure:c="classic",tabindex:d="0"}=t,f={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?f.style=t.rootStyle:f.style=`background-color:${t.bg};color:${t.fg}`),d!==!1&&d!=null&&(f.tabindex=d.toString());for(const[v,E]of Object.entries(t.meta||{}))v.startsWith("_")||(f[v]=E);let p={type:"element",tagName:"pre",properties:f,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:l};const x=[],y={...n,structure:c,addClassToHast:_C,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return u},get pre(){return p},get code(){return m},get lines(){return x}};if(e.forEach((v,E)=>{var D,L;E&&(c==="inline"?u.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&l.push({type:"text",value:`
|
|
98
|
+
`}));let j={type:"element",tagName:"span",properties:{class:"line"},children:[]},T=0;for(const O of v){let M={type:"element",tagName:"span",properties:{...O.htmlAttrs},children:[{type:"text",value:O.content}]};const W=Lp(O.htmlStyle||td(O));W&&(M.properties.style=W);for(const z of a)M=((D=z==null?void 0:z.span)==null?void 0:D.call(y,M,E+1,T,j,O))||M;c==="inline"?u.children.push(M):c==="classic"&&j.children.push(M),T+=O.content.length}if(c==="classic"){for(const O of a)j=((L=O==null?void 0:O.line)==null?void 0:L.call(y,j,E+1))||j;x.push(j),l.push(j)}else c==="inline"&&x.push(j)}),c==="classic"){for(const v of a)m=((C=v==null?void 0:v.code)==null?void 0:C.call(y,m))||m;p.children.push(m);for(const v of a)p=((_=v==null?void 0:v.pre)==null?void 0:_.call(y,p))||p;u.children.push(p)}else if(c==="inline"){const v=[];let E={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const T of u.children)T.type==="element"&&T.tagName==="br"?(v.push(E),E={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(T.type==="element"||T.type==="text")&&E.children.push(T);v.push(E);let j={type:"element",tagName:"code",properties:{},children:v};for(const T of a)j=((S=T==null?void 0:T.code)==null?void 0:S.call(y,j))||j;u.children=[];for(let T=0;T<j.children.length;T++){T>0&&u.children.push({type:"element",tagName:"br",properties:{},children:[]});const D=j.children[T];D.type==="element"&&u.children.push(...D.children)}}let w=u;for(const v of a)w=((b=v==null?void 0:v.root)==null?void 0:b.call(y,w))||w;return r&&Ad(w,r),w}function sM(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((l,u)=>{const c=!(l.fontStyle&&(l.fontStyle&Dn.Underline||l.fontStyle&Dn.Strikethrough));c&&wC.test(l.content)&&t[u+1]?(a===void 0&&(a=l.offset),r+=l.content):r?(c?n.push({...l,offset:a,content:r+l.content}):n.push({content:r,offset:a},l),a=void 0,r=""):n.push(l)}),n})}function iM(e){return e.map(t=>t.flatMap(n=>{if(wC.test(n.content))return n;const r=n.content.match(nM);if(!r)return n;const[,a,l,u]=r;if(!a&&!u)return n;const c=[{...n,offset:n.offset+a.length,content:l}];return a&&c.unshift({content:a,offset:n.offset}),u&&c.push({content:u,offset:n.offset+a.length+l.length}),c}))}function aM(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const a=n.at(-1),l=Lp(a.htmlStyle||td(a)),u=Lp(r.htmlStyle||td(r)),c=a.fontStyle&&(a.fontStyle&Dn.Underline||a.fontStyle&Dn.Strikethrough),d=r.fontStyle&&(r.fontStyle&Dn.Underline||r.fontStyle&Dn.Strikethrough);!c&&!d&&l===u?a.content+=r.content:n.push({...r})}return n})}const oM=TI;function lM(e,t,n){var l;const r={meta:{},options:n,codeToHast:(u,c)=>sd(e,u,c),codeToTokens:(u,c)=>rd(e,u,c)};let a=oM(sd(e,t,n,r));for(const u of nd(n))a=((l=u.postprocess)==null?void 0:l.call(r,a,n))||a;return a}async function cM(e){const t=await sO(e);return{getLastGrammarState:(...n)=>cO(t,...n),codeToTokensBase:(n,r)=>Dp(t,n,r),codeToTokensWithThemes:(n,r)=>oC(t,n,r),codeToTokens:(n,r)=>rd(t,n,r),codeToHast:(n,r)=>sd(t,n,r),codeToHtml:(n,r)=>lM(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function uM(e){const t=e.langs,n=e.themes,r=e.engine;async function a(l){function u(m){var x;if(typeof m=="string"){if(m=((x=l.langAlias)==null?void 0:x[m])||m,Zw(m))return[];const y=t[m];if(!y)throw new zt(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return y}return m}function c(m){if(eC(m))return"none";if(typeof m=="string"){const x=n[m];if(!x)throw new zt(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return x}return m}const d=(l.themes??[]).map(m=>c(m)),f=(l.langs??[]).map(m=>u(m)),p=await cM({engine:l.engine??r(),...l,themes:d,langs:f});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(u))},loadTheme(...m){return p.loadTheme(...m.map(c))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function dM(e){let t;async function n(r={}){if(t){const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}else{t=e({...r,themes:[],langs:[]});const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}}return n}function hM(e,t){const n=dM(e);async function r(a,l){var d;const u=await n({langs:[l.lang],themes:"theme"in l?[l.theme]:Object.values(l.themes)}),c=await((d=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:d.call(t,a,l.lang,u));return c&&await u.loadLanguage(...c),u}return{getSingletonHighlighter(a){return n(a)},async codeToHtml(a,l){return(await r(a,l)).codeToHtml(a,l)},async codeToHast(a,l){return(await r(a,l)).codeToHast(a,l)},async codeToTokens(a,l){return(await r(a,l)).codeToTokens(a,l)},async codeToTokensBase(a,l){return(await r(a,l)).codeToTokensBase(a,l)},async codeToTokensWithThemes(a,l){return(await r(a,l)).codeToTokensWithThemes(a,l)},async getLastGrammarState(a,l){return(await n({langs:[l.lang],themes:[l.theme]})).getLastGrammarState(a,l)}}}var fM=vg({bundledLanguages:()=>Cd,bundledLanguagesAlias:()=>Sg,bundledLanguagesBase:()=>_g,bundledLanguagesInfo:()=>wd,bundledThemes:()=>Cg,bundledThemesInfo:()=>wg,codeToHast:()=>kC,codeToHtml:()=>CC,codeToTokens:()=>EC,codeToTokensBase:()=>jC,codeToTokensWithThemes:()=>NC,createHighlighter:()=>Dd,getLastGrammarState:()=>AC,getSingletonHighlighter:()=>TC});const Dd=uM({langs:Cd,themes:Cg,engine:()=>(0,Mw.createOnigurumaEngine)(J(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:CC,codeToHast:kC,codeToTokens:EC,codeToTokensBase:jC,codeToTokensWithThemes:NC,getSingletonHighlighter:TC,getLastGrammarState:AC}=hM(Dd,{guessEmbeddedLanguages:PI}),M0=4294967295;var mM=class{constructor(e,t={}){Se(this,"patterns");Se(this,"options");Se(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:a}=t;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(l=>{if(typeof l!="string")return l;const u=r==null?void 0:r.get(l);if(u){if(u instanceof RegExp)return u;if(n)return null;throw u}try{const c=a(l);return r==null||r.set(l,c),c}catch(c){if(r==null||r.set(l,c),n)return null;throw c}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,a=[];function l(u,c,d=0){return{index:u,captureIndices:c.indices.map(f=>f==null?{start:M0,end:M0,length:0}:{start:f[0]+d,end:f[1]+d,length:f[1]-f[0]})}}for(let u=0;u<this.regexps.length;u++){const c=this.regexps[u];if(c)try{c.lastIndex=t;const d=c.exec(r);if(!d)continue;if(d.index===t)return l(u,d,0);a.push([u,d,0])}catch(d){if(this.options.forgiving)continue;throw d}}if(a.length){const u=Math.min(...a.map(c=>c[1].index));for(const[c,d,f]of a)if(d.index===u)return l(c,d,f)}return null}};function uo(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function pM(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const Rg=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),wn=String.raw;function ho(e,t){if(e==null)throw new Error(t??"Value expected");return e}const LC=wn`\[\^?`,DC=`c.? | C(?:-.?)?|${wn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${wn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${wn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${wn`o\{[^\}]*\}?`}|${wn`\d{1,3}`}`,Og=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,_u=new RegExp(wn`
|
|
99
|
+
\\ (?:
|
|
100
|
+
${DC}
|
|
101
|
+
| [gk]<[^>]*>?
|
|
102
|
+
| [gk]'[^']*'?
|
|
103
|
+
| .
|
|
104
|
+
)
|
|
105
|
+
| \( (?:
|
|
106
|
+
\? (?:
|
|
107
|
+
[:=!>({]
|
|
108
|
+
| <[=!]
|
|
109
|
+
| <[^>]*>
|
|
110
|
+
| '[^']*'
|
|
111
|
+
| ~\|?
|
|
112
|
+
| #(?:[^)\\]|\\.?)*
|
|
113
|
+
| [^:)]*[:)]
|
|
114
|
+
)?
|
|
115
|
+
| \*[^\)]*\)?
|
|
116
|
+
)?
|
|
117
|
+
| (?:${Og.source})+
|
|
118
|
+
| ${LC}
|
|
119
|
+
| .
|
|
120
|
+
`.replace(/\s+/g,""),"gsu"),Pm=new RegExp(wn`
|
|
121
|
+
\\ (?:
|
|
122
|
+
${DC}
|
|
123
|
+
| .
|
|
124
|
+
)
|
|
125
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
126
|
+
| ${LC}
|
|
127
|
+
| &&
|
|
128
|
+
| .
|
|
129
|
+
`.replace(/\s+/g,""),"gsu");function gM(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=IM(n.flags),a=[r.extended],l={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(m){a.push(m)},replaceCurrentModX(m){a[a.length-1]=m},singleline:n.rules.singleline};let u=[],c;for(_u.lastIndex=0;c=_u.exec(e);){const m=xM(l,e,c[0],_u.lastIndex);m.tokens?u.push(...m.tokens):m.token&&u.push(m.token),m.lastIndex!==void 0&&(_u.lastIndex=m.lastIndex)}const d=[];let f=0;u.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++f:m.raw==="("&&d.push(m)}),f||d.forEach((m,x)=>{m.kind="capturing",m.number=x+1});const p=f||d.length;return{tokens:u.map(m=>m.type==="EscapedNumber"?PM(m,p):m).flat(),flags:r}}function xM(e,t,n,r){const[a,l]=n;if(n==="["||n==="[^"){const u=yM(t,n,r);return{tokens:u.tokens,lastIndex:u.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(l))return{token:P0(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:NM(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:OC(n)}}if(l==="K")return{token:IC("keep",n)};if(l==="N"||l==="R")return{token:$i("newline",n,{negate:l==="N"})};if(l==="O")return{token:$i("any",n)};if(l==="X")return{token:$i("text_segment",n)};const u=RC(n,{inCharClass:!1});return Array.isArray(u)?{tokens:u}:{token:u}}if(a==="("){if(l==="*")return{token:DM(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:LM(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Ga("group",n)};if(n==="(?>")return{token:Ga("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Ga(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Ga("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Ga("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:kM(n)}}if(e.getCurrentModX()){if(n==="#"){const u=t.indexOf(`
|
|
130
|
+
`,r);return{lastIndex:u===-1?t.length:u}}if(/^\s$/.test(n)){const u=/\s+/y;return u.lastIndex=r,{lastIndex:u.exec(t)?u.lastIndex:r}}}if(n===".")return{token:$i("dot",n)};if(n==="^"||n==="$"){const u=e.singleline?{"^":wn`\A`,$:wn`\Z`}[n]:n;return{token:P0(u,n)}}return n==="|"?{token:vM(n)}:Og.test(n)?{tokens:BM(n)}:{token:Ss(uo(n),n)}}function yM(e,t,n){const r=[B0(t[1]==="^",t)];let a=1,l;for(Pm.lastIndex=n;l=Pm.exec(e);){const u=l[0];if(u[0]==="["&&u[1]!==":")a++,r.push(B0(u[1]==="^",u));else if(u==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Ss(93,u));else if(a--,r.push(_M(u)),!a)break}else{const c=bM(u);Array.isArray(c)?r.push(...c):r.push(c)}}return{tokens:r,lastIndex:Pm.lastIndex||e.length}}function bM(e){if(e[0]==="\\")return RC(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Rg.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return $i("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?SM(e):e==="&&"?wM(e):Ss(uo(e),e)}function RC(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return AM(e);if("dDhHsSwW".includes(n))return RM(e);if(e.startsWith(wn`\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 OM(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(u=>parseInt(u,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),l=new TextEncoder;return[...a].map(u=>{const c=[...l.encode(u)].map(d=>`\\x${d.toString(16)}`).join("");return Ss(uo(u),c)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Ss(MM(e),e);if($0.has(n))return Ss($0.get(n),e);if(/\d/.test(n))return CM(t,e);if(e==="\\")throw new Error(wn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Ss(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function vM(e){return{type:"Alternator",raw:e}}function P0(e,t){return{type:"Assertion",kind:e,raw:t}}function OC(e){return{type:"Backreference",raw:e}}function Ss(e,t){return{type:"Character",value:e,raw:t}}function _M(e){return{type:"CharacterClassClose",raw:e}}function SM(e){return{type:"CharacterClassHyphen",raw:e}}function wM(e){return{type:"CharacterClassIntersector",raw:e}}function B0(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function $i(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function IC(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:ho(n.flags),raw:t}}function CM(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function kM(e){return{type:"GroupClose",raw:e}}function Ga(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function EM(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function jM(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function NM(e){return{type:"Subroutine",raw:e}}const TM=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),$0=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function AM(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 Ss(uo(t.toUpperCase())-64,e)}function LM(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const a=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),l=H0(n),u=H0(r),c={};if(l&&(c.enable=l),u&&(c.disable=u),e.endsWith(")"))return t.replaceCurrentModX(a),IC("flags",e,{flags:c});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,Ga("group",e,{...(l||u)&&{flags:c}});throw new Error(`Unexpected flag modifier "${e}"`)}function DM(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:a}=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 l=a?a.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[u,c,d]=l,f=TM.has(n)?n.toLowerCase():"custom";switch(f){case"fail":case"mismatch":case"skip":if(l.length>0)throw new Error(`Named callout arguments not allowed "${l}"`);break;case"error":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(typeof u=="string")throw new Error(`Named callout argument must be a number "${u}"`);break;case"max":if(!l.length||l.length>2)throw new Error(`Named callout must have one or two arguments "${l}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument one must be a tag or number "${u}"`);if(l.length===2&&(typeof c=="number"||!/^[<>X]$/.test(c)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${c}"`);break;case"count":case"total_count":if(l.length>1)throw new Error(`Named callout allows only one argument "${l}"`);if(l.length===1&&(typeof u=="number"||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${u}"`);break;case"cmp":if(l.length!==3)throw new Error(`Named callout must have three arguments "${l}"`);if(typeof u=="string"&&!/^[A-Za-z_]\w*$/.test(u))throw new Error(`Named callout argument one must be a tag or number "${u}"`);if(typeof c=="number"||!/^(?:[<>!=]=|[<>])$/.test(c))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${c}"`);if(typeof d=="string"&&!/^[A-Za-z_]\w*$/.test(d))throw new Error(`Named callout argument three must be a tag or number "${d}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${f}"`)}return EM(f,r??null,(a==null?void 0:a.split(","))??null,e)}function z0(e){let t=null,n,r;if(e[0]==="{"){const{minStr:a,maxStr:l}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,u=1e5;if(+a>u||l&&+l>u)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+a,r=l===void 0?+a:l===""?1/0:+l,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 jM(t,n,r,e)}function RM(e){const t=e[1].toLowerCase();return $i({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function OM(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return $i("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function H0(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 IM(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 MM(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 PM(e,t){const{raw:n,inCharClass:r}=e,a=n.slice(1);if(!r&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=t))return[OC(n)];const l=[],u=a.match(/^[0-7]+|\d/g);for(let c=0;c<u.length;c++){const d=u[c];let f;if(c===0&&d!=="8"&&d!=="9"){if(f=parseInt(d,8),f>127)throw new Error(wn`Octal encoded byte above 177 unsupported "${n}"`)}else f=uo(d);l.push(Ss(f,(c===0?"\\":"")+d))}return l}function BM(e){const t=[],n=new RegExp(Og,"gy");let r;for(;r=n.exec(e);){const a=r[0];if(a[0]==="{"){const l=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(a);if(l){const{min:u,max:c}=l.groups;if(+u>+c&&a.endsWith("?")){n.lastIndex--,t.push(z0(a.slice(0,-1)));continue}}}t.push(z0(a))}return t}function MC(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 $M(e){return zM.has(e.type)}const zM=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function PC(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=gM(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(x,y)=>{const w=r.tokens[l.nextIndex];switch(l.parent=x,l.nextIndex++,w.type){case"Alternator":return qi();case"Assertion":return HM(w);case"Backreference":return UM(w,l);case"Character":return Rd(w.value,{useLastValid:!!y.isCheckingRangeEnd});case"CharacterClassHyphen":return FM(w,l,y);case"CharacterClassOpen":return VM(w,l,y);case"CharacterSet":return GM(w,l);case"Directive":return QM(w.kind,{flags:w.flags});case"GroupOpen":return WM(w,l,y);case"NamedCallout":return ZM(w.kind,w.tag,w.arguments);case"Quantifier":return qM(w,l);case"Subroutine":return KM(w,l);default:throw new Error(`Unexpected token type "${w.type}"`)}},l={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:a},u=tP(JM(r.flags));let c=u.body[0];for(;l.nextIndex<r.tokens.length;){const x=a(c,{});x.type==="Alternative"?(u.body.push(x),c=x):c.body.push(x)}const{capturingGroups:d,hasNumberedRef:f,namedGroupsByName:p,subroutines:m}=l;if(f&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:x}of m)if(typeof x=="number"){if(x>d.length)throw new Error("Subroutine uses a group number that's not defined");x&&(d[x-1].isSubroutined=!0)}else if(p.has(x)){if(p.get(x).length>1)throw new Error(wn`Subroutine uses a duplicate group name "\g<${x}>"`);p.get(x)[0].isSubroutined=!0}else throw new Error(wn`Subroutine uses a group name that's not defined "\g<${x}>"`);return u}function HM({kind:e}){return Rp(ho({"^":"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===wn`\B`||e===wn`\Y`})}function UM({raw:e},t){const n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),a=(l,u=!1)=>{const c=t.capturingGroups.length;let d=!1;if(l>c)if(t.skipBackrefValidation)d=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Op(u?c+1-l:l,{orphan:d})};if(n){const l=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(l)return a(+l.groups.num,!!l.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 Op(r)}return a(+r)}function FM(e,t,n){const{tokens:r,walk:a}=t,l=t.parent,u=l.body.at(-1),c=r[t.nextIndex];if(!n.isCheckingRangeEnd&&u&&u.type!=="CharacterClass"&&u.type!=="CharacterClassRange"&&c&&c.type!=="CharacterClassOpen"&&c.type!=="CharacterClassClose"&&c.type!=="CharacterClassIntersector"){const d=a(l,{...n,isCheckingRangeEnd:!0});if(u.type==="Character"&&d.type==="Character")return l.body.pop(),XM(u,d);throw new Error("Invalid character class range")}return Rd(uo("-"))}function VM({negate:e},t,n){const{tokens:r,walk:a}=t,l=[Hu()],u=r[t.nextIndex];let c=V0(u);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")l.push(Hu()),t.nextIndex++;else{const f=l.at(-1);f.body.push(a(f,n))}c=V0(r[t.nextIndex],u)}const d=Hu({negate:e});return l.length===1?d.body=l[0].body:(d.kind="intersection",d.body=l.map(f=>f.body.length===1?f.body[0]:f)),t.nextIndex++,d}function GM({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u}=r;if(e==="property"){const c=Od(n);if(Rg.has(c)&&!(u!=null&&u.has(c)))e="posix",n=c;else return Wa(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u})}return e==="posix"?eP(n,{negate:t}):Ip(e,{negate:t})}function WM(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:l,skipLookbehindValidation:u,walk:c}=t,d=nP(e),f=d.type==="AbsenceFunction",p=F0(d),m=p&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&pM(l,d.name,[]).push(d)),f&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let x=G0(r[t.nextIndex]);for(;x.type!=="GroupClose";){if(x.type==="Alternator")d.body.push(qi()),t.nextIndex++;else{const y=d.body.at(-1),w=c(y,{...n,isInAbsenceFunction:n.isInAbsenceFunction||f,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||m});if(y.body.push(w),(p||n.isInLookbehind)&&!u){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(m||n.isInNegLookbehind){if(U0(w)||w.type==="CapturingGroup")throw new Error(C)}else if(U0(w)||F0(w)&&w.negate)throw new Error(C)}}x=G0(r[t.nextIndex])}return t.nextIndex++,d}function qM({kind:e,min:t,max:n},r){const a=r.parent,l=a.body.at(-1);if(!l||!$M(l))throw new Error("Quantifier requires a repeatable token");const u=$C(e,t,n,l);return a.body.pop(),u}function KM({raw:e},t){const{capturingGroups:n,subroutines:r}=t;let a=e.slice(3,-1);const l=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(a);if(l){const c=+l.groups.num,d=n.length;if(t.hasNumberedRef=!0,a={"":c,"+":d+c,"-":d+1-c}[l.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const u=zC(a);return r.push(u),u}function YM(e,t){return{type:"AbsenceFunction",kind:e,body:ql(t==null?void 0:t.body)}}function qi(e){return{type:"Alternative",body:HC(e==null?void 0:e.body)}}function Rp(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function Op(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function BC(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!rP(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:ql(t==null?void 0:t.body)}}function Rd(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 Hu(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:HC(e==null?void 0:e.body)}}function XM(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Ip(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 QM(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:ho(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function JM(e){return{type:"Flags",...e}}function Dr(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:ql(e==null?void 0:e.body)}}function Pi(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:ql(e==null?void 0:e.body)}}function ZM(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function eP(e,t){const n=!!(t!=null&&t.negate);if(!Rg.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function $C(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 tP(e,t){return{type:"Regex",body:ql(t==null?void 0:t.body),flags:e}}function zC(e){return{type:"Subroutine",ref:e}}function Wa(e,t){var a;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(a=n.unicodePropertyMap)==null?void 0:a.get(Od(e));if(!r){if(n.normalizeUnknownPropertyNames)r=sP(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(wn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function nP({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return YM("repeater");case"atomic":return Dr({atomic:!0});case"capturing":return BC(a,{name:n});case"group":return Dr({flags:e});case"lookahead":case"lookbehind":return Pi({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function ql(e){if(e===void 0)e=[qi()];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 HC(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 U0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function F0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function rP(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function sP(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 Od(e){return e.replace(/[- _]+/g,"").toLowerCase()}function V0(e,t){const n=t;return ho(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function G0(e){return ho(e,"Unclosed group")}function kl(e,t,n=null){function r(l,u){for(let c=0;c<l.length;c++){const d=a(l[c],u,c,l);c=Math.max(-1,c+d)}}function a(l,u=null,c=null,d=null){var S,b;let f=0,p=!1;const m={node:l,parent:u,key:c,container:d,root:e,remove(){Su(d).splice(Math.max(0,Pa(c)+f),1),f--,p=!0},removeAllNextSiblings(){return Su(d).splice(Pa(c)+1)},removeAllPrevSiblings(){const v=Pa(c)+f;return f-=v,Su(d).splice(0,Math.max(0,v))},replaceWith(v,E={}){const j=!!E.traverse;d?d[Math.max(0,Pa(c)+f)]=v:ho(u,"Can't replace root node")[c]=v,j&&a(v,u,c,d),p=!0},replaceWithMultiple(v,E={}){const j=!!E.traverse;if(Su(d).splice(Math.max(0,Pa(c)+f),1,...v),f+=v.length-1,j){let T=0;for(let D=0;D<v.length;D++)T+=a(v[D],u,Pa(c)+D+T,d)}p=!0},skip(){p=!0}},{type:x}=l,y=t["*"],w=t[x],C=typeof y=="function"?y:y==null?void 0:y.enter,_=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(m,n),_==null||_(m,n),!p)switch(x){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(l.body,l);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":a(l.min,l,"min"),a(l.max,l,"max");break;case"Quantifier":a(l.body,l,"body");break;case"Regex":r(l.body,l),a(l.flags,l,"flags");break;default:throw new Error(`Unexpected node type "${x}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,m,n),(b=y==null?void 0:y.exit)==null||b.call(y,m,n),f}return a(e),e}function Su(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Pa(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const iP=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function aP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function oP(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const kr=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Ig(e,t,n,r){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),l=[!1];let u=0,c="";for(const d of e.matchAll(a)){const{0:f,groups:{$skip:p}}=d;if(!p&&(!r||r===kr.DEFAULT==!u)){n instanceof Function?c+=n(d,{context:u?kr.CHAR_CLASS:kr.DEFAULT,negated:l[l.length-1]}):c+=n;continue}f[0]==="["?(u++,l.push(f[1]==="^")):f==="]"&&u&&(u--,l.pop()),c+=f}return c}function UC(e,t,n,r){Ig(e,t,n,r)}function lP(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const a=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=n;let l=0,u;for(;u=a.exec(e);){const{0:c,groups:{$skip:d}}=u;if(!d&&(!r||r===kr.DEFAULT==!l))return u;c==="["?l++:c==="]"&&l&&l--,a.lastIndex==u.index&&a.lastIndex++}return null}function wu(e,t,n){return!!lP(e,t,0,n)}function cP(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=e.length,a=0,l=1,u;for(;u=n.exec(e);){const[c]=u;if(c==="[")a++;else if(a)c==="]"&&a--;else if(c==="(")l++;else if(c===")"&&(l--,!l)){r=u.index;break}}return e.slice(t,r)}const W0=new RegExp(String.raw`(?<noncapturingStart>${iP})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function uP(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 a="(?>",l="(?:(?=(",u=[0],c=[];let d=0,f=0,p=NaN,m;do{m=!1;let x=0,y=0,w=!1,C;for(W0.lastIndex=Number.isNaN(p)?0:p+l.length;C=W0.exec(e);){const{0:_,index:S,groups:{capturingStart:b,noncapturingStart:v}}=C;if(_==="[")x++;else if(x)_==="]"&&x--;else if(_===a&&!w)p=S,w=!0;else if(w&&v)y++;else if(b)w?y++:(d++,u.push(d+f));else if(_===")"&&w){if(!y){f++;const E=d+f;if(e=`${e.slice(0,p)}${l}${e.slice(p+a.length,S)}))<$$${E}>)${e.slice(S+1)}`,m=!0,c.push(E),aP(n,E),r.size){const j=new Map;r.forEach((T,D)=>{j.set(D>=E?D+1:D,T.map(L=>L>=E?L+1:L))}),r=j}break}y--}}}while(m);return n.push(...c),e=Ig(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:x,groups:{backrefNum:y,wrappedBackrefNum:w}})=>{if(y){const C=+y;if(C>u.length-1)throw new Error(`Backref "${x}" greater than number of captures`);return`\\${u[C]}`}return`\\${w}`},kr.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const FC=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Bm=new RegExp(String.raw`
|
|
131
|
+
\\(?: \d+
|
|
132
|
+
| c[A-Za-z]
|
|
133
|
+
| [gk]<[^>]+>
|
|
134
|
+
| [pPu]\{[^\}]+\}
|
|
135
|
+
| u[A-Fa-f\d]{4}
|
|
136
|
+
| x[A-Fa-f\d]{2}
|
|
137
|
+
)
|
|
138
|
+
| \((?: \? (?: [:=!>]
|
|
139
|
+
| <(?:[=!]|[^>]+>)
|
|
140
|
+
| [A-Za-z\-]+:
|
|
141
|
+
| \(DEFINE\)
|
|
142
|
+
))?
|
|
143
|
+
| (?<qBase>${FC})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
144
|
+
| \\?.
|
|
145
|
+
`.replace(/\s+/g,""),"gsu");function dP(e){if(!new RegExp(`${FC}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",l=0,u;for(Bm.lastIndex=0;u=Bm.exec(e);){const{0:c,index:d,groups:{qBase:f,qMod:p,invalidQ:m}}=u;if(c==="[")l||(r=d),l++;else if(c==="]")l?l--:r=null;else if(!l)if(p==="+"&&a&&!a.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${c}"`);let x=-1;if(/^\{\d+\}$/.test(f))e=oP(e,d+f.length,p,"");else{if(a===")"||a==="]"){const y=a===")"?n:r;if(y===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,y)}(?>${e.slice(y,d)}${f})${e.slice(d+c.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${f})${e.slice(d+c.length)}`;x+=4}Bm.lastIndex+=x}else c[0]==="("?t.push(d):c===")"&&(n=t.length?t.pop():null);a=c}return{pattern:e}}const wr=String.raw,hP=wr`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Mp=wr`\(\?R=(?<rDepth>[^\)]+)\)|${hP}`,Id=wr`\(\?<(?![=!])(?<captureName>[^>]+)>`,VC=wr`${Id}|(?<unnamed>\()(?!\?)`,Li=new RegExp(wr`${Id}|${Mp}|\(\?|\\?.`,"gsu"),$m="Cannot use multiple overlapping recursions";function fP(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(Mp,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&wu(e,wr`\(\?\(DEFINE\)`,kr.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],u=wu(e,wr`\\[1-9]`,kr.DEFAULT),c=new Map,d=[];let f=!1,p=0,m=0,x;for(Li.lastIndex=0;x=Li.exec(e);){const{0:y,groups:{captureName:w,rDepth:C,gRNameOrNum:_,gRDepth:S}}=x;if(y==="[")p++;else if(p)y==="]"&&p--;else if(C){if(q0(C),f)throw new Error($m);if(u)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const b=e.slice(0,x.index),v=e.slice(Li.lastIndex);if(wu(v,Mp,kr.DEFAULT))throw new Error($m);const E=+C-1;e=K0(b,v,E,!1,n,l,m),a=X0(a,b,E,l.length,0,m);break}else if(_){q0(S);let b=!1;for(const z of d)if(z.name===_||z.num===+_){if(b=!0,z.hasRecursedWithin)throw new Error($m);break}if(!b)throw new Error(wr`Recursive \g cannot be used outside the referenced group "${r==="external"?_:wr`\g<${_}&R=${S}>`}"`);const v=c.get(_),E=cP(e,v);if(u&&wu(E,wr`${Id}|\((?!\?)`,kr.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const j=e.slice(v,x.index),T=E.slice(j.length+y.length),D=l.length,L=+S-1,O=K0(j,T,L,!0,n,l,m);a=X0(a,j,L,l.length-D,D,m);const M=e.slice(0,v),W=e.slice(v+E.length);e=`${M}${O}${W}`,Li.lastIndex+=O.length-y.length-j.length-T.length,d.forEach(z=>z.hasRecursedWithin=!0),f=!0}else if(w)m++,c.set(String(m),Li.lastIndex),c.set(w,Li.lastIndex),d.push({num:m,name:w});else if(y[0]==="("){const b=y==="(";b&&(m++,c.set(String(m),Li.lastIndex)),d.push(b?{num:m}:{})}else y===")"&&d.pop()}return n.push(...l),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function q0(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 K0(e,t,n,r,a,l,u){const c=new Set;r&&UC(e+t,Id,({groups:{captureName:f}})=>{c.add(f)},kr.DEFAULT);const d=[n,r?c:null,a,l,u];return`${e}${Y0(`(?:${e}`,"forward",...d)}(?:)${Y0(`${t})`,"backward",...d)}${t}`}function Y0(e,t,n,r,a,l,u){const d=p=>t==="forward"?p+2:n-p+2-1;let f="";for(let p=0;p<n;p++){const m=d(p);f+=Ig(e,wr`${VC}|\\k<(?<backref>[^>]+)>`,({0:x,groups:{captureName:y,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return x;const _=`_$${m}`;if(w||y){const S=u+l.length+1;return l.push(S),mP(a,S),w?x:`(?<${y}${_}>`}return wr`\k<${C}${_}>`},kr.DEFAULT)}return f}function mP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function X0(e,t,n,r,a,l){if(e.size&&r){let u=0;UC(t,VC,()=>u++,kr.DEFAULT);const c=l-u+a,d=new Map;return e.forEach((f,p)=>{const m=(r-u*n)/n,x=u*n,y=p>c+u?p+r:p,w=[];for(const C of f)if(C<=c)w.push(C);else if(C>c+u+m)w.push(C+r);else if(C<=c+u)for(let _=0;_<=n;_++)w.push(C+u*_);else for(let _=0;_<=n;_++)w.push(C+x+m*_);d.set(y,w)}),d}return e}var xn=String.fromCodePoint,st=String.raw,Or={},Md=globalThis.RegExp;Or.flagGroups=(()=>{try{new Md("(?i:)")}catch{return!1}return!0})();Or.unicodeSets=(()=>{try{new Md("[[]]","v")}catch{return!1}return!0})();Or.bugFlagVLiteralHyphenIsRange=Or.unicodeSets?(()=>{try{new Md(st`[\d\-a]`,"v")}catch{return!0}return!1})():!1;Or.bugNestedClassIgnoresNegation=Or.unicodeSets&&new Md("[[^a]]","v").test("a");function id(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 Il(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Pp(e,t){return Q0[e]>=Q0[t]}function pP(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Q0={ES2025:2025,ES2024:2024,ES2018:2018},gP={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function GC(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!gP[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=Or.flagGroups?"ES2025":Or.unicodeSets?"ES2024":"ES2018"),t}var xP="[ -\r ]",yP=new Set([xn(304),xn(305)]),ps=st`[\p{L}\p{M}\p{N}\p{Pc}]`;function WC(e){if(yP.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=_P.get(n),l=bP.get(n),u=vP.get(n);return[...r].length===1&&t.add(r),u&&t.add(u),a&&t.add(a),t.add(n),l&&t.add(l),[...t]}var Mg=new Map(`C Other
|
|
146
|
+
Cc Control cntrl
|
|
147
|
+
Cf Format
|
|
148
|
+
Cn Unassigned
|
|
149
|
+
Co Private_Use
|
|
150
|
+
Cs Surrogate
|
|
151
|
+
L Letter
|
|
152
|
+
LC Cased_Letter
|
|
153
|
+
Ll Lowercase_Letter
|
|
154
|
+
Lm Modifier_Letter
|
|
155
|
+
Lo Other_Letter
|
|
156
|
+
Lt Titlecase_Letter
|
|
157
|
+
Lu Uppercase_Letter
|
|
158
|
+
M Mark Combining_Mark
|
|
159
|
+
Mc Spacing_Mark
|
|
160
|
+
Me Enclosing_Mark
|
|
161
|
+
Mn Nonspacing_Mark
|
|
162
|
+
N Number
|
|
163
|
+
Nd Decimal_Number digit
|
|
164
|
+
Nl Letter_Number
|
|
165
|
+
No Other_Number
|
|
166
|
+
P Punctuation punct
|
|
167
|
+
Pc Connector_Punctuation
|
|
168
|
+
Pd Dash_Punctuation
|
|
169
|
+
Pe Close_Punctuation
|
|
170
|
+
Pf Final_Punctuation
|
|
171
|
+
Pi Initial_Punctuation
|
|
172
|
+
Po Other_Punctuation
|
|
173
|
+
Ps Open_Punctuation
|
|
174
|
+
S Symbol
|
|
175
|
+
Sc Currency_Symbol
|
|
176
|
+
Sk Modifier_Symbol
|
|
177
|
+
Sm Math_Symbol
|
|
178
|
+
So Other_Symbol
|
|
179
|
+
Z Separator
|
|
180
|
+
Zl Line_Separator
|
|
181
|
+
Zp Paragraph_Separator
|
|
182
|
+
Zs Space_Separator
|
|
183
|
+
ASCII
|
|
184
|
+
ASCII_Hex_Digit AHex
|
|
185
|
+
Alphabetic Alpha
|
|
186
|
+
Any
|
|
187
|
+
Assigned
|
|
188
|
+
Bidi_Control Bidi_C
|
|
189
|
+
Bidi_Mirrored Bidi_M
|
|
190
|
+
Case_Ignorable CI
|
|
191
|
+
Cased
|
|
192
|
+
Changes_When_Casefolded CWCF
|
|
193
|
+
Changes_When_Casemapped CWCM
|
|
194
|
+
Changes_When_Lowercased CWL
|
|
195
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
196
|
+
Changes_When_Titlecased CWT
|
|
197
|
+
Changes_When_Uppercased CWU
|
|
198
|
+
Dash
|
|
199
|
+
Default_Ignorable_Code_Point DI
|
|
200
|
+
Deprecated Dep
|
|
201
|
+
Diacritic Dia
|
|
202
|
+
Emoji
|
|
203
|
+
Emoji_Component EComp
|
|
204
|
+
Emoji_Modifier EMod
|
|
205
|
+
Emoji_Modifier_Base EBase
|
|
206
|
+
Emoji_Presentation EPres
|
|
207
|
+
Extended_Pictographic ExtPict
|
|
208
|
+
Extender Ext
|
|
209
|
+
Grapheme_Base Gr_Base
|
|
210
|
+
Grapheme_Extend Gr_Ext
|
|
211
|
+
Hex_Digit Hex
|
|
212
|
+
IDS_Binary_Operator IDSB
|
|
213
|
+
IDS_Trinary_Operator IDST
|
|
214
|
+
ID_Continue IDC
|
|
215
|
+
ID_Start IDS
|
|
216
|
+
Ideographic Ideo
|
|
217
|
+
Join_Control Join_C
|
|
218
|
+
Logical_Order_Exception LOE
|
|
219
|
+
Lowercase Lower
|
|
220
|
+
Math
|
|
221
|
+
Noncharacter_Code_Point NChar
|
|
222
|
+
Pattern_Syntax Pat_Syn
|
|
223
|
+
Pattern_White_Space Pat_WS
|
|
224
|
+
Quotation_Mark QMark
|
|
225
|
+
Radical
|
|
226
|
+
Regional_Indicator RI
|
|
227
|
+
Sentence_Terminal STerm
|
|
228
|
+
Soft_Dotted SD
|
|
229
|
+
Terminal_Punctuation Term
|
|
230
|
+
Unified_Ideograph UIdeo
|
|
231
|
+
Uppercase Upper
|
|
232
|
+
Variation_Selector VS
|
|
233
|
+
White_Space space
|
|
234
|
+
XID_Continue XIDC
|
|
235
|
+
XID_Start XIDS`.split(/\s/).map(e=>[Od(e),e])),bP=new Map([["s",xn(383)],[xn(383),"s"]]),vP=new Map([[xn(223),xn(7838)],[xn(107),xn(8490)],[xn(229),xn(8491)],[xn(969),xn(8486)]]),_P=new Map([Zs(453),Zs(456),Zs(459),Zs(498),...zm(8072,8079),...zm(8088,8095),...zm(8104,8111),Zs(8124),Zs(8140),Zs(8188)]),SP=new Map([["alnum",st`[\p{Alpha}\p{Nd}]`],["alpha",st`\p{Alpha}`],["ascii",st`\p{ASCII}`],["blank",st`[\p{Zs}\t]`],["cntrl",st`\p{Cc}`],["digit",st`\p{Nd}`],["graph",st`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",st`\p{Lower}`],["print",st`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",st`[\p{P}\p{S}]`],["space",st`\p{space}`],["upper",st`\p{Upper}`],["word",st`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",st`\p{AHex}`]]);function wP(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Zs(e){const t=xn(e);return[t.toLowerCase(),t]}function zm(e,t){return wP(e,t).map(n=>Zs(n))}var qC=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function CP(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};KC(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Pp(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};kl(e,kP,r);const a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},l={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};kl(e,EP,l);const u={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return kl(e,jP,u),e._originMap=l.groupOriginByCopy,e._strategy=r.strategy,e}var kP={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const l=Dr();l.body[0].body.push(Pi({negate:!0,body:r}),Wa("Any"));const u=Dr();u.body[0].body.push($C("greedy",0,1/0,l)),n(nn(u,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const a=e.body.filter(l=>l.kind==="flags");for(let l=n+1;l<t.body.length;l++){const u=t.body[l];Il(r,u,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=XC(t.get(e));if(r){const a=Dr({flags:r});a.body[0].body=e.body,e.body=[nn(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:a,remove:l,replaceWith:u},c){const{kind:d,negate:f}=e,{asciiWordBoundaries:p,avoidSubclass:m,supportedGNodes:x,wordIsAscii:y}=c;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${f?"Y":"y"}"`);if(d==="line_end")u(nn(Pi({body:[qi({body:[Rp("string_end")]}),qi({body:[Rd(10)]})]}),t));else if(d==="line_start")u(nn(gs(st`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(x.has(e))a.flags.sticky=!0,l();else{const w=r[n-1];if(w&&RP(w))u(nn(Pi({negate:!0}),t));else{if(m)throw new Error(st`Uses "\G" in a way that requires a subclass`);u(ei(Rp("string_start"),t)),c.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")u(nn(gs(st`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!y&&!p){const w=`(?:(?<=${ps})(?!${ps})|(?<!${ps})(?=${ps}))`,C=`(?:(?<=${ps})(?=${ps})|(?<!${ps})(?!${ps}))`;u(nn(gs(f?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Um(n)&&(n=Hm(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Um(r)&&(r=Hm(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=Hu({body:[e]});n(nn(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:a,digitIsAscii:l,spaceIsAscii:u,wordIsAscii:c}){const{kind:d,negate:f,value:p}=e;if(l&&(d==="digit"||p==="digit")){n(ei(Ip("digit",{negate:f}),t));return}if(u&&(d==="space"||p==="space")){n(nn(Fm(gs(xP),f),t));return}if(c&&(d==="word"||p==="word")){n(ei(Ip("word",{negate:f}),t));return}if(d==="any")n(ei(Wa("Any"),t));else if(d==="digit")n(ei(Wa("Nd",{negate:f}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(st`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",x=st`\p{RI}{2}|${m}(?:\u200D${m})*`;n(nn(gs(st`(?>\r\n|${a?st`\p{RGI_Emoji}`:x}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(ei(Wa("AHex",{negate:f}),t));else if(d==="newline")n(nn(gs(f?`[^
|
|
236
|
+
]`:`(?>\r
|
|
237
|
+
?|[
|
|
238
|
+
\v\f
\u2028\u2029])`),t));else if(d==="posix")if(!a&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[p];f&&(m=`\0-${xn(m.codePointAt(0)-1)}${xn(m.codePointAt(2)+1)}-`),n(nn(gs(`[${m}]`),t))}else n(nn(Fm(gs(SP.get(p)),f),t));else if(d==="property")Mg.has(Od(p))||(e.key="sc");else if(d==="space")n(ei(Wa("space",{negate:f}),t));else if(d==="word")n(nn(Fm(gs(ps),f),t));else throw new Error(`Unexpected character set kind "${d}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:a,removeAllPrevSiblings:l,removeAllNextSiblings:u}){const{kind:c,flags:d}=e;if(c==="flags")if(!d.enable&&!d.disable)r();else{const f=Dr({flags:d});f.body[0].body=u(),a(nn(f,t),{traverse:!0})}else if(c==="keep"){const f=n.body[0],m=n.body.length===1&&MC(f,{type:"Group"})&&f.body[0].body.length===1?f.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(st`Uses "\K" in a way that's unsupported`);const x=Pi({behind:!0});x.body[0].body=l(),a(nn(x,t))}else throw new Error(`Unexpected directive kind "${c}"`)},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(nn(Pi({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=Dr();t.body[0].body.push(e.body),e.body=nn(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,a=!1;for(const l of e.body)if(l.body.length===1&&l.body[0].kind==="search_start")l.body.pop();else{const u=JC(l.body);u?(r=!0,Array.isArray(u)?n.push(...u):n.push(u)):a=!0}r&&!a&&n.forEach(l=>t.add(l))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(st`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Um(n)&&(n=Hm(n,t),e.ref=n)}},EP={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:a}=e;r||n.set(e,[...t.get(a).map(({node:l})=>l)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:a,groupsByName:l,multiplexCapturesToLeftByRef:u,openRefs:c,reffedNodesByReferencer:d}){const f=a.get(e);if(f&&c.has(e.number)){const m=ei(J0(e.number),t);d.set(m,c.get(e.number)),n(m);return}c.set(e.number,e),u.set(e.number,[]),e.name&&Il(u,e.name,[]);const p=u.get(e.name??e.number);for(let m=0;m<p.length;m++){const x=p[m];if(f===x.node||f&&f===x.origin||e===x.origin){p.splice(m,1);break}}if(u.get(e.number).push({node:e,origin:f}),e.name&&u.get(e.name).push({node:e,origin:f}),e.name){const m=Il(l,e.name,new Map);let x=!1;if(f)x=!0;else for(const y of m.values())if(!y.hasDuplicateNameToRemove){x=!0;break}l.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=id(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:a,ref:l}=e;if(a){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===l||p.number===l)););r.reffedNodesByReferencer.set(e,p);return}const u=r.subroutineRefMap.get(l),c=l===0,d=c?J0(0):YC(u,r.groupOriginByCopy,null);let f=d;if(!c){const p=XC(AP(u,x=>x.type==="Group"&&!!x.flags)),m=p?id(r.globalFlags,p):r.globalFlags;NP(m,r.currentFlags)||(f=Dr({flags:LP(m)}),f.body[0].body.push(d))}n(nn(f,t),{traverse:!c})}},jP={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const l=r.reffedNodesByReferencer.get(e).filter(u=>TP(u,e));if(!l.length)n(nn(Pi({negate:!0}),t));else if(l.length>1){const u=Dr({atomic:!0,body:l.reverse().map(c=>qi({body:[Op(c.number)]}))});n(nn(u,t))}else e.ref=l[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 a=BC();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function KC(e){kl(e,{"*"({node:t,parent:n}){t.parent=n}})}function NP(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function TP(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=QC(n.parent);for(const a of r){if(a===n)break;if(a===e||ZC(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function YC(e,t,n,r){const a=Array.isArray(e)?[]:{};for(const[l,u]of Object.entries(e))l==="parent"?a.parent=Array.isArray(n)?r:n:u&&typeof u=="object"?a[l]=YC(u,t,a,n):(l==="type"&&u==="CapturingGroup"&&t.set(a,t.get(e)??e),a[l]=u);return a}function J0(e){const t=zC(e);return t.isRecursive=!0,t}function AP(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Hm(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 XC(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(a=>{var l,u;(l=r.enable)!=null&&l[a]&&(delete n.disable[a],n.enable[a]=!0),(u=r.disable)!=null&&u[a]&&(n.disable[a]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function LP({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 QC(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function JC(e){const t=e.find(n=>n.kind==="search_start"||OP(n,{negate:!1})||!DP(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 a=JC(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function ZC(e,t){const n=QC(e)??[];for(const r of n)if(r===t||ZC(r,t))return!0;return!1}function DP({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function RP(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function OP(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&MC(e.body[0],{type:"Assertion",kind:"search_start"})}function Um(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function gs(e,t){const r=PC(e,{...t,unicodePropertyMap:Mg}).body;return r.length>1||r[0].body.length>1?Dr({body:r}):r[0].body[0]}function Fm(e,t){return e.negate=t,e}function ei(e,t){return e.parent=t,e}function nn(e,t){return KC(e),e.parent=t,e}function IP(e,t){const n=GC(t),r=Pp(n.target,"ES2024"),a=Pp(n.target,"ES2025"),l=n.rules.recursionLimit;if(!Number.isInteger(l)||l<2||l>20)throw new Error("Invalid recursionLimit; use 2-20");let u=null,c=null;if(!a){const y=[e.flags.ignoreCase];kl(e,MP,{getCurrentModI:()=>y.at(-1),popModI(){y.pop()},pushModI(w){y.push(w)},setHasCasedChar(){y.at(-1)?u=!0:c=!0}})}const d={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||u)&&!c)};let f=e;const p={accuracy:n.accuracy,appliedGlobalFlags:d,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:f,originMap:e._originMap,recursionLimit:l,useAppliedIgnoreCase:!!(!a&&u&&c),useFlagMods:a,useFlagV:r,verbose:n.verbose};function m(y){return p.lastNode=f,f=y,pP(PP[y.type],`Unexpected node type "${y.type}"`)(y,p,m)}const x={pattern:e.body.map(m).join("|"),flags:m(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((y,w)=>{y.hidden&&x._hiddenCaptures.push(w),y.transferTo&&Il(x._captureTransfers,y.transferTo,[]).push(w)}),x}var MP={"*":{enter({node:e},t){if(eS(e)){const n=t.getCurrentModI();t.pushModI(e.flags?id({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){eS(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Pg(xn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),ek(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&qC.has(e.value)&&t.setHasCasedChar()}},PP={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?st`\B`:st`\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:a,number:l}=e,u={ignoreCase:t.currentFlags.ignoreCase},c=t.originMap.get(e);return c&&(u.hidden=!0,l>c.number&&(u.transferTo=c.number)),t.captureMap.set(l,u),`(${a?`?<${a}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=xn(e),r=Ba(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Pg(n)){const a=WC(n);return t.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:a,parent:l}=e;let{body:u}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");Or.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&u.some(tS)&&(u=[Rd(45),...u.filter(f=>!tS(f))]);const c=()=>`[${a?"^":""}${u.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Or.bugNestedClassIgnoresNegation)&&!a){const p=u.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=Dr(),x=m.body[0];return m.parent=l,x.parent=m,u=u.filter(y=>!p.includes(y)),e.body=u,u.length?(e.parent=x,x.body.push(e)):m.body.pop(),p.forEach(y=>{const w=qi({body:[y]});y.parent=w,w.parent=m,m.body.push(w)}),n(m)}}t.inCharClass=!0;const f=c();return t.inCharClass=!1,f}const d=u[0];if(r==="union"&&!a&&d&&((!t.useFlagV||!t.verbose)&&l.kind==="union"&&!(Or.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&l.kind==="intersection"&&u.length===1&&d.type!=="CharacterClassRange"))return u.map(n).join("");if(!t.useFlagV&&l.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return c()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},l=Ba(n,a),u=Ba(r,a),c=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=ek(e);UP(d).forEach(p=>{c.add(Array.isArray(p)?`${Ba(p[0],a)}-${Ba(p[1],a)}`:Ba(p,a))})}return`${l}-${u}${[...c].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":st`[^\n]`;if(e==="digit")return t?st`\D`:st`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&qC.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?st`\P`:st`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?st`\W`:st`\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},a,l){const u=a.currentFlags;n&&(a.currentFlags=id(u,n));const c=t.map(l).join("|"),d=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?c:`(?${FP(e,n,a.useFlagMods)}${c})`;return a.currentFlags=u,d},LookaroundAssertion({body:e,kind:t,negate:n},r,a){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(a).join("|")})`},Quantifier(e,t,n){return n(e.body)+VP(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})`:st`\g<${t}&R=${r}>`}},BP=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),$P=new Set(["-","\\","]","^","["]),zP=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Z0=new Map([[9,st`\t`],[10,st`\n`],[11,st`\v`],[12,st`\f`],[13,st`\r`],[8232,st`\u2028`],[8233,st`\u2029`],[65279,st`\uFEFF`]]),HP=new RegExp("^\\p{Cased}$","u");function Pg(e){return HP.test(e)}function ek(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,a=e.max.value,l=[];if(r<65&&(a===65535||a>=131071)||r===65536&&a>=131071)return l;for(let u=r;u<=a;u++){const c=xn(u);if(!Pg(c))continue;const d=WC(c).filter(f=>{const p=f.codePointAt(0);return p<r||p>a});if(d.length&&(l.push(...d),n))break}return l}function Ba(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Z0.has(e))return Z0.get(e);if(e<32||e>126&&e<160||e>262143||t&&GP(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?zP:$P:BP,l=xn(e);return(a.has(l)?"\\":"")+l}function UP(e){const t=e.map(a=>a.codePointAt(0)).sort((a,l)=>a-l),n=[];let r=null;for(let a=0;a<t.length;a++)t[a+1]===t[a]+1?r??(r=t[a]):r===null?n.push(t[a]):(n.push([r,t[a]]),r=null);return n}function FP(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:a,disable:l}=t;r=(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")+(l?"-":"")+(l!=null&&l.ignoreCase?"i":"")+(l!=null&&l.dotAll?"s":"")}return`${r}:`}function VP({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 eS({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function GP(e){return e>47&&e<58}function tS({type:e,value:t}){return e==="Character"&&t===45}var ti,vs,zi,ni,Hi,Bl,Bp,li,WP=(li=class extends RegExp{constructor(n,r,a){var t=(...h9)=>(super(...h9),Ti(this,Bl),Ti(this,ti,new Map),Ti(this,vs,null),Ti(this,zi),Ti(this,ni,null),Ti(this,Hi,null),Se(this,"rawOptions",{}),this);const l=!!(a!=null&&a.lazyCompile);if(n instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const u=n;t(u,r),Tr(this,zi,u.source),u instanceof li&&(Tr(this,ti,Mn(u,ti)),Tr(this,ni,Mn(u,ni)),Tr(this,Hi,Mn(u,Hi)),this.rawOptions=u.rawOptions)}else{const u={hiddenCaptures:[],strategy:null,transfers:[],...a};t(l?"":n,r),Tr(this,zi,n),Tr(this,ti,KP(u.hiddenCaptures,u.transfers)),Tr(this,Hi,u.strategy),this.rawOptions=a??{}}l||Tr(this,vs,this)}get source(){return Mn(this,zi)||"(?:)"}exec(n){if(!Mn(this,vs)){const{lazyCompile:l,...u}=this.rawOptions;Tr(this,vs,new li(Mn(this,zi),this.flags,u))}const r=this.global||this.sticky,a=this.lastIndex;if(Mn(this,Hi)==="clip_search"&&r&&a){this.lastIndex=0;const l=Qf(this,Bl,Bp).call(this,n.slice(a));return l&&(qP(l,a,n,this.hasIndices),this.lastIndex+=a),l}return Qf(this,Bl,Bp).call(this,n)}},ti=new WeakMap,vs=new WeakMap,zi=new WeakMap,ni=new WeakMap,Hi=new WeakMap,Bl=new WeakSet,Bp=function(n){Mn(this,vs).lastIndex=this.lastIndex;const r=Mv(li.prototype,this,"exec").call(Mn(this,vs),n);if(this.lastIndex=Mn(this,vs).lastIndex,!r||!Mn(this,ti).size)return r;const a=[...r];r.length=1;let l;this.hasIndices&&(l=[...r.indices],r.indices.length=1);const u=[0];for(let c=1;c<a.length;c++){const{hidden:d,transferTo:f}=Mn(this,ti).get(c)??{};if(d?u.push(null):(u.push(r.length),r.push(a[c]),this.hasIndices&&r.indices.push(l[c])),f&&a[c]!==void 0){const p=u[f];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=a[c],this.hasIndices&&(r.indices[p]=l[c]),r.groups){Mn(this,ni)||Tr(this,ni,YP(this.source));const m=Mn(this,ni).get(f);m&&(r.groups[m]=a[c],this.hasIndices&&(r.indices.groups[m]=l[c]))}}}return r},li);function qP(e,t,n,r){if(e.index+=t,e.input=n,r){const a=e.indices;for(let u=0;u<a.length;u++){const c=a[u];c&&(a[u]=[c[0]+t,c[1]+t])}const l=a.groups;l&&Object.keys(l).forEach(u=>{const c=l[u];c&&(l[u]=[c[0]+t,c[1]+t])})}}function KP(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,a]of t)for(const l of a)Il(n,l,{}).transferTo=r;return n}function YP(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,a=0,l;for(;l=t.exec(e);){const{0:u,groups:{capture:c,name:d}}=l;u==="["?r++:r?u==="]"&&r--:c&&(a++,d&&n.set(a,d))}return n}function XP(e,t){const n=QP(e,t);return n.options?new WP(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function QP(e,t){const n=GC(t),r=PC(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Mg}),a=CP(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=IP(a,n),u=fP(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),c=dP(u.pattern),d=uP(c.pattern,{captureTransfers:u.captureTransfers,hiddenCaptures:u.hiddenCaptures}),f={pattern:d.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${l.flags}${l.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const p=d.hiddenCaptures.sort((w,C)=>w-C),m=Array.from(d.captureTransfers),x=a._strategy,y=f.pattern.length>=n.lazyCompileLength;(p.length||m.length||x||y)&&(f.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},...x&&{strategy:x},...y&&{lazyCompile:y}})}return f}function tk(e,t){return XP(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function JP(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>tk(n,{target:t.target})),{createScanner(n){return new mM(n,t)},createString(n){return{content:n}}}}Dw(vg({bundledLanguages:()=>Cd,bundledLanguagesAlias:()=>Sg,bundledLanguagesBase:()=>_g,bundledLanguagesInfo:()=>wd,bundledThemes:()=>Cg,bundledThemesInfo:()=>wg,codeToHast:()=>kC,codeToHtml:()=>CC,codeToTokens:()=>EC,codeToTokensBase:()=>jC,codeToTokensWithThemes:()=>NC,createHighlighter:()=>Dd,createJavaScriptRegexEngine:()=>JP,createOnigurumaEngine:()=>Iw,defaultJavaScriptRegexConstructor:()=>tk,getLastGrammarState:()=>AC,getSingletonHighlighter:()=>TC,loadWasm:()=>Eg}),fM);let Vm=null;const El=new Set,Cu=new Map,nS=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],ZP=["github-dark-default","vitesse-light","monokai","dracula","nord","everforest-light","rose-pine-dawn","synthwave-84","one-dark-pro","night-owl","catppuccin-mocha","rose-pine","kanagawa-wave","light-plus"],Gm={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord","rose-pine-dawn":"rose-pine-dawn","everforest-light":"everforest-light","synthwave-84":"synthwave-84","one-dark-pro":"one-dark-pro","night-owl":"night-owl","catppuccin-mocha":"catppuccin-mocha","rose-pine":"rose-pine","kanagawa-wave":"kanagawa-wave","light-plus":"light-plus"};function e6(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function nk(){return Vm||(Vm=Dd({themes:ZP,langs:nS}).then(e=>(nS.forEach(t=>El.add(t)),e))),Vm}async function t6(e){if(El.has(e))return;if(Cu.has(e))return Cu.get(e);const t=(async()=>{const n=await nk(),r=Cd[e];if(r){await n.loadLanguage(r),El.add(e);return}try{const a=await J(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),El.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();Cu.set(e,t),await t,Cu.delete(e)}const hl=new Map,n6=50;function r6(e,t,n){return`${e}|${t}|${n}`}async function rk(e,t,n="github-dark-default"){t!=="text"&&!El.has(t)&&await t6(t);const r=r6(e,t,n),a=hl.get(r);if(a)return a;const u=(await nk()).codeToHtml(e,{lang:t,theme:n,transformers:[e6()]});if(hl.size>=n6){const c=hl.keys().next().value;c&&hl.delete(c)}return hl.set(r,u),u}const s6={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 Pd(e){var a;if(!e)return"text";const t=e.split("/").pop()??"",n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const r=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return r?s6[r]??"text":"text"}function sk(){const e=Rt(r=>r.currentPreset),t=Rt(r=>r.isCustom),n=Rt(r=>r.basePreset);return i6(e,t,n)}function i6(e,t,n){return t?n&&n!=="system"&&Gm[n]?Gm[n]??"github-dark-default":"github-dark-default":Gm[e]??"github-dark-default"}function ik(e=2e3){const[t,n]=A.useState(!1),r=A.useCallback(async a=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{const l=document.createElement("textarea");l.value=a,l.style.position="fixed",l.style.left="-9999px",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l)}n(!0),setTimeout(()=>n(!1),e)}catch(l){console.error("Failed to copy:",l)}},[e]);return{copied:t,copy:r}}const a6=A.memo(function({language:t,codeString:n,showSyntaxHighlighting:r}){const{copied:a,copy:l}=ik(),[u,c]=A.useState(null),d=sk(),f=A.useRef(n);return A.useEffect(()=>{r&&(f.current=n,rk(n,t,d).then(p=>{f.current===n&&c(p)}))},[n,t,d,r]),i.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[i.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:[i.jsx("span",{children:t}),i.jsx("button",{type:"button",onClick:p=>{p.preventDefault(),p.stopPropagation(),l(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:a?i.jsx(Ir,{}):i.jsx(qp,{})})]}),r&&u?i.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):i.jsx("div",{className:"overflow-x-auto",children:i.jsx("pre",{className:"my-0 px-4 py-3 overflow-x-auto font-mono text-sm whitespace-pre-wrap break-word",children:i.jsx("code",{className:`language-${t}`,children:n})})})]})});function o6(e,t){const n=e?"text-text-muted":"text-text-heading",r=e?"text-text-secondary":"text-text-bold";return{code({className:a,children:l,...u}){const c=/language-(\w+)/.exec(a||"");if(!c&&!String(l).includes(`
|
|
239
|
+
`)){const m=e?"text-text-muted":"text-text-code";return i.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${m} font-mono text-xs`,...u,children:l})}const f=(c==null?void 0:c[1])||"text",p=String(l).replace(/\n$/,"");return i.jsx(a6,{language:f,codeString:p,showSyntaxHighlighting:t})},p({children:a}){const l=e?"text-text-muted":"text-text-primary";return i.jsx("p",{className:`${l} mb-1.5 last:mb-0 leading-tight break-words`,children:a})},ul({children:a}){return i.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a})},ol({children:a}){return i.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a})},li({children:a}){const l=e?"text-text-muted":"text-text-primary";return i.jsx("li",{className:`${l} text-sm list-item`,children:a})},h1({children:a}){return i.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h2({children:a}){return i.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h3({children:a}){return i.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},h4({children:a}){return i.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},strong({children:a}){return i.jsx("strong",{className:`font-bold ${r}`,children:a})},em({children:a}){return i.jsx("em",{className:e?"italic text-text-secondary":"italic",children:a})},a({href:a,children:l}){return i.jsx("a",{href:a,className:"text-text-link hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:l})},blockquote({children:a}){const l=e?"text-text-muted":"text-text-secondary";return i.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${l} italic text-sm`,children:a})},table({children:a}){return i.jsx("div",{className:"overflow-x-auto my-1.5",children:i.jsx("table",{className:"min-w-full border border-border",children:a})})},th({children:a}){return i.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:a})},td({children:a}){return i.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:a})},hr(){return i.jsx("hr",{className:"border-border my-2"})},input({checked:a,...l}){return i.jsx("input",{type:"checkbox",checked:a,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...l})}}}const Bn=A.memo(function({content:t,className:n="",muted:r=!1}){const{showSyntaxHighlighting:a}=Ki(),l=A.useMemo(()=>{let c=l6(t);return c=c6(c),c},[t]),u=A.useMemo(()=>o6(r,a),[r,a]);return i.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:i.jsx(L3,{remarkPlugins:[VR],components:u,children:l})})});function l6(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+\|/gm,""),t}function c6(e){const t=/```/g,n=e.match(t);if(((n==null?void 0:n.length)??0)%2===1){const a=e.lastIndexOf("```");return e.slice(a+3).includes(`
|
|
240
|
+
`),e+"\n```"}return e}function ak({isOpen:e,onClose:t}){const[n,r]=A.useState(null),[a,l]=A.useState(!1),{settings:u,getSetting:c,setSetting:d}=ao(),f=u[De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";A.useEffect(()=>{e&&c(De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,c]),A.useEffect(()=>{e&&(l(!0),we("/api/changelog").then(m=>m.json()).then(m=>{r(m.content)}).catch(()=>{r(`# Changelog
|
|
241
|
+
|
|
242
|
+
Failed to load changelog.`)}).finally(()=>l(!1)))},[e]);const p=A.useCallback(()=>{const m=f?"false":"true";d(De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,m)},[f,d]);return i.jsx(wt,{isOpen:e,onClose:t,title:"What's New in OpenFox",size:"xl",closeOnBackdropClick:!0,showCloseButton:!0,footer:i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx(Ui,{enabled:f,onClick:p}),i.jsx("span",{className:"text-sm text-text-muted",children:"Show changelog on future updates"})]}),children:i.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:a?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):i.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:i.jsx(Bn,{content:n??""})})})})}async function ok(e,t,n){t({loading:!0});try{const a=await(await we(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const u6="#6b7280";function Ml(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??u6}const mt=Hn(e=>{const t=async()=>{await ok("/api/agents",e,!0)};return{defaults:[],userItems:[],projectItems:[],loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await we(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await we(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const a=await ci("POST","/api/agents",{...n,destination:r});return a.success&&await t(),a},updateAgent:async(n,r)=>{const a=await ci("PUT",`/api/agents/${n}`,r);return a.success&&await t(),a},deleteAgent:async n=>{try{const r=await we(`/api/agents/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateAgent:async(n,r)=>fd(`/api/agents/${n}/duplicate`,t,r)}});function d6({onClose:e}){const[,t]=zn(),{settings:n,getSetting:r,setSetting:a}=ao(),l=n[De.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",u=n[De.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",c=n[De.CACHE_WARMING]==="true",[d,f]=A.useState({openInEditor:l,dynamicPrompt:u,cacheWarming:c}),[p,m]=A.useState({patterns:[],maxRetriesPerTurn:10}),[x,y]=A.useState(""),[w,C]=A.useState(""),[_,S]=A.useState(!1),[b,v,E,j]=lp(),[T,D]=A.useState(!1),[L,O]=A.useState(!1),M=Qt(F=>F.version),W=ws(F=>F.status),z=ws(F=>F.latest),R=ws(F=>F.check),P=M&&z?{current:M,latest:z}:null,[V,G]=A.useState(!1),Z=mt(F=>F.defaults),Q=mt(F=>F.userItems),U=mt(F=>F.fetchAgents),I=[...Z,...Q].filter(F=>!F.subagent);A.useEffect(()=>{f({openInEditor:l,dynamicPrompt:u,cacheWarming:c})},[l,u,c]),A.useEffect(()=>{r(De.DISPLAY_SHOW_OPEN_IN_EDITOR),r(De.LLM_DYNAMIC_SYSTEM_PROMPT),r(De.CACHE_WARMING),r(De.RETRY_PATTERNS),r(De.PROXY_URL)},[r]),A.useEffect(()=>{const F=n[De.RETRY_PATTERNS];if(F)try{m(JSON.parse(F))}catch{}},[n]),A.useEffect(()=>{const F=n[De.PROXY_URL];F!==void 0&&y(F)},[n]),A.useEffect(()=>{U().catch(()=>{})},[U]),A.useEffect(()=>{r(De.DEFAULT_AGENT)},[r]),A.useEffect(()=>{const F=n[De.DEFAULT_AGENT];F!==void 0&&(C(F),S(!0))},[n]);const $=A.useCallback(F=>{m(F),a(De.RETRY_PATTERNS,JSON.stringify(F))},[a]),q=F=>{y(F),a(De.PROXY_URL,F)};function B(){j(async()=>(await we("/api/proxy/test",{method:"POST"})).json())}const ee=()=>{const F=!d.openInEditor;f(te=>({...te,openInEditor:F})),a(De.DISPLAY_SHOW_OPEN_IN_EDITOR,String(F))},X=()=>{const F=!d.dynamicPrompt;f(te=>({...te,dynamicPrompt:F})),a(De.LLM_DYNAMIC_SYSTEM_PROMPT,String(F))},ne=()=>{const F=!d.cacheWarming;f(te=>({...te,cacheWarming:F})),a(De.CACHE_WARMING,String(F))};function K(){e(),t("/onboarding")}return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsxs("h3",{className:"text-sm font-medium text-text-primary mb-1",children:[W==="available"&&i.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent-primary mr-1.5 align-middle"}),"Updates"]}),i.jsx("p",{className:"text-sm text-text-muted mb-4",children:M?i.jsxs(i.Fragment,{children:["Current version: ",i.jsxs("span",{className:"font-mono",children:["v",M]})]}):"Check for a new OpenFox version."}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Je,{variant:"secondary",onClick:()=>{G(!0),R()},disabled:W==="checking",children:W==="checking"?"Checking…":"Check for Updates"}),V&&W==="upToDate"&&i.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),W==="error"&&i.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),W==="available"&&i.jsxs("button",{onClick:()=>D(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",z," →"]})]})]}),i.jsx(j1,{isOpen:T,onClose:()=>D(!1),versionInfo:P}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsx("button",{onClick:()=>O(!0),className:"text-sm text-accent-primary hover:underline",children:"View Changelog →"}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("span",{className:"text-xs text-text-muted",children:"Show on update"}),i.jsx(Ui,{enabled:(n[De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const te=(n[De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,te)}})]})]}),i.jsx(ak,{isOpen:L,onClose:()=>O(!1)}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Default Agent"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Choose which agent is used by default for new sessions. The stock Planner is read-only; custom agents can have broader capabilities."}),i.jsxs("select",{value:_?w:"",onChange:F=>{const te=F.target.value;C(te),a(De.DEFAULT_AGENT,te)},className:"w-full px-3 py-2 text-sm bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary",children:[!_&&i.jsx("option",{value:"",children:"Loading…"}),_&&i.jsx("option",{value:"",children:"System default (planner)"}),I.map(F=>i.jsx("option",{value:F.id,children:F.name},F.id))]}),I.length===0&&_&&i.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),i.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Manage providers, workdir and vision fallback."}),i.jsx(Je,{variant:"secondary",onClick:K,children:"Launch Onboarding"})]}),i.jsx("hr",{className:"border-border"}),i.jsx("div",{children:i.jsx(Wm,{title:'Show "Open in VSCode" links',description:"Display a link on file reads to open the file directly in VS Code.",enabled:d.openInEditor,onToggle:ee})}),i.jsx("hr",{className:"border-border"}),i.jsx(Wm,{title:"Speculative Cache Warming",description:"On first keystroke in an empty session, prefill the LLM KV cache to reduce time-to-first-token.",enabled:d.cacheWarming,onToggle:ne,boldTitle:!0}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"HTTP Proxy"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Proxy server for LLM API requests. Leave empty for direct connection."}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(ai,{type:"text",value:x,onChange:F=>q(F.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),i.jsx(Je,{variant:"secondary",onClick:B,style:E?{color:"rgb(63, 185, 80)"}:void 0,children:b})]}),v&&i.jsx("p",{className:"text-xs text-red-500 mt-1",children:v})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Define regex patterns that, when matched against LLM responses mid-stream, trigger an automatic retry with a "continue" prompt. The content that triggered the match is preserved in the chat feed.'}),i.jsx(vT,{value:p,onChange:$})]}),i.jsx("hr",{className:"border-border"}),i.jsx(Wm,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:X,boldTitle:!0})]})}function Wm({title:e,description:t,enabled:n,onToggle:r,boldTitle:a}){return i.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:`text-sm ${a?"font-medium":""} text-text-primary`,children:e}),i.jsx("div",{className:"text-sm text-text-muted mt-0.5",children:t})]}),i.jsx("div",{className:"flex-shrink-0",children:i.jsx(Ui,{enabled:n,onClick:r})})]})}function h6(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function f6({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:l,onClear:u,onReset:c,onCancelRecording:d}){const f=A.useRef(null),p=A.useRef(0),m=A.useRef("");return A.useEffect(()=>{if(!r)return;const x=new Set(["Control","Shift","Alt","Meta"]);let y=[];const w=_=>{if(_.preventDefault(),_.stopPropagation(),_.key==="Escape"){d();return}if(x.has(_.key)){const v=Date.now();if(_.key===m.current&&v-p.current<400){l({type:"double-press",key:_.key,threshold:300});return}p.current=v,m.current=_.key,_.ctrlKey&&!y.includes("ctrl")&&y.push("ctrl"),_.metaKey&&!y.includes("meta")&&y.push("meta"),_.altKey&&!y.includes("alt")&&y.push("alt"),_.shiftKey&&!y.includes("shift")&&y.push("shift");return}if(y.length>0||_.ctrlKey||_.metaKey||_.altKey||_.shiftKey){const v=[...y];_.ctrlKey&&!v.includes("ctrl")&&v.push("ctrl"),_.metaKey&&!v.includes("meta")&&v.push("meta"),_.altKey&&!v.includes("alt")&&v.push("alt"),_.shiftKey&&!v.includes("shift")&&v.push("shift"),l({type:"chord",key:y_(_),modifiers:v});return}const S=Date.now(),b=y_(_);if(b===m.current&&S-p.current<400){l({type:"double-press",key:b,threshold:300});return}p.current=S,m.current=b},C=_=>{_.key==="Control"&&(y=y.filter(S=>S!=="ctrl")),_.key==="Shift"&&(y=y.filter(S=>S!=="shift")),_.key==="Alt"&&(y=y.filter(S=>S!=="alt")),_.key==="Meta"&&(y=y.filter(S=>S!=="meta"))};return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",C,!0),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",C,!0)}},[r,l,d]),i.jsxs("div",{ref:f,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${r?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[i.jsx("span",{className:"text-sm text-text-primary",children:e}),i.jsx("div",{className:"flex items-center gap-2",children:r?i.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:a,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:t?Fu(t):"None"}),t&&i.jsx("button",{type:"button",onClick:u,title:"Remove shortcut","aria-label":`Remove shortcut for ${e}`,className:"p-1 text-text-muted rounded hover:text-accent-error hover:bg-bg-tertiary transition-colors",children:i.jsx(Qp,{className:"w-3.5 h-3.5"})}),!h6(t,n)&&i.jsx("button",{type:"button",onClick:c,title:"Reset to default","aria-label":`Reset ${e} to default`,className:"p-1 text-text-muted rounded hover:text-accent-primary hover:bg-bg-tertiary transition-colors",children:i.jsx(pd,{className:"w-3.5 h-3.5"})})]})})]})}function m6(){const{settings:e,loading:t,setSetting:n}=ao(),r=e[De.KEYBINDINGS],a=t[De.KEYBINDINGS]??!1,l=op(r),[u,c]=A.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle,defaultBinding:Wr.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction,defaultBinding:Wr.quickAction},{id:"modelSelector",label:"Select Model",binding:l.modelSelector,defaultBinding:Wr.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:l.sessionSearch,defaultBinding:Wr.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:l.criteriaSidebar,defaultBinding:Wr.criteriaSidebar},...l.agentSwitching.map((y,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:y,defaultBinding:Wr.agentSwitching[w]??null}))],f=y=>{c(y)},p=A.useCallback((y,w)=>{const C=op(r);if(y.startsWith("agentSwitching.")){const _=parseInt(y.split(".")[1],10);C.agentSwitching[_]=w}else y==="terminalToggle"?C.terminalToggle=w:y==="quickAction"?C.quickAction=w:y==="modelSelector"?C.modelSelector=w:y==="sessionSearch"?C.sessionSearch=w:y==="criteriaSidebar"&&(C.criteriaSidebar=w);n(De.KEYBINDINGS,JSON.stringify(C))},[r,n]),m=A.useCallback(y=>{u&&(c(null),p(u,y))},[u,p]),x=()=>{n(De.KEYBINDINGS,JSON.stringify(Wr))};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),i.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?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):i.jsx("div",{className:"space-y-1",children:d.map(y=>i.jsx(f6,{label:y.label,binding:y.binding,defaultBinding:y.defaultBinding,isRecording:u===y.id,onStartRecording:()=>f(y.id),onBindingRecorded:m,onClear:()=>p(y.id,null),onReset:()=>p(y.id,y.defaultBinding),onCancelRecording:()=>c(null)},y.id))})]})}function rS(e){const t={};return e.split(`
|
|
243
|
+
`).filter(Boolean).forEach(n=>{const r=n.indexOf("=");r>0&&(t[n.slice(0,r).trim()]=n.slice(r+1).trim())}),t}function sS({formData:e,onChange:t}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>t({...e,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),i.jsx("button",{onClick:()=>t({...e,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),e.transport==="stdio"?i.jsxs(i.Fragment,{children:[i.jsx(Cr,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),i.jsx(Cr,{label:"Arguments",value:e.args,onChange:n=>t({...e,args:n}),placeholder:"space-separated args"}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",i.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),i.jsx("textarea",{value:e.env,onChange:n=>t({...e,env:n.target.value}),placeholder:"API_KEY=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}):i.jsxs(i.Fragment,{children:[i.jsx(Cr,{label:"URL",value:e.url,onChange:n=>t({...e,url:n}),placeholder:"e.g. https://mcp.example.com/mcp"}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",i.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),i.jsx("textarea",{value:e.headers,onChange:n=>t({...e,headers:n.target.value}),placeholder:"X-API-Key=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}),i.jsx(Cr,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}function iS(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function qm(e,t,n,r=250){const a=A.useRef(!0);A.useEffect(()=>{if(a.current){a.current=!1;return}const l=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(l)},[e,t,r,n])}function aS({saving:e,saveLabel:t,savingLabel:n,onCancel:r,onSave:a}){return i.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[i.jsx(Je,{variant:"secondary",onClick:r,disabled:e,children:"Cancel"}),i.jsx(Je,{variant:"primary",onClick:a,disabled:e,children:e?n:t})]})}function p6(){const{settings:e,getSetting:t,setSetting:n}=ao(),[r,a]=A.useState(""),[l,u]=A.useState(""),[c,d]=A.useState(""),[f,p]=A.useState("");qm(l,De.SEARCH_TAVILY_API_KEY,n),qm(c,De.SEARCH_SEARXNG_URL,n),qm(f,De.SEARCH_SEARXNG_API_KEY,n);const[m,x,y,w]=lp(),[C,_,S,b]=lp();A.useEffect(()=>{t(De.SEARCH_ENGINE),t(De.SEARCH_TAVILY_API_KEY),t(De.SEARCH_SEARXNG_URL),t(De.SEARCH_SEARXNG_API_KEY),t(De.TOOLS_USE_RTK),t(De.CONFIRM_ON_WORKSPACE_ACTIONS)},[t]),A.useEffect(()=>{e[De.SEARCH_ENGINE]!==void 0&&(a(e[De.SEARCH_ENGINE]??""),u(e[De.SEARCH_TAVILY_API_KEY]??""),d(e[De.SEARCH_SEARXNG_URL]??""),p(e[De.SEARCH_SEARXNG_API_KEY]??""))},[e]);function v(re){a(re),n(De.SEARCH_ENGINE,re)}function E(){w(async()=>(await we("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:l||void 0})})).json())}function j(){b(async()=>(await we("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:c||void 0,searxngApiKey:f||void 0})})).json())}const[T,D]=A.useState("checking");A.useEffect(()=>{we("/api/tools/rtk-check").then(re=>re.json()).then(re=>D(re.available?"available":"unavailable")).catch(()=>D("unavailable"))},[]);const[L,O]=A.useState([]);A.useEffect(()=>{t(De.TOOLS_SHELL),we("/api/tools/shells").then(re=>re.json()).then(re=>O(re.shells??[])).catch(()=>O([]))},[t]);const M=e[De.TOOLS_SHELL]||"cmd",[W,z]=A.useState([]),[R,P]=A.useState(!0),[V,G]=A.useState(!1),[Z,Q]=A.useState(null),[U,I]=A.useState(new Set),[$,q]=A.useState(new Set),[B,ee]=A.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",timeout:""}),[X,ne]=A.useState(""),[K,F]=A.useState(""),[te,se]=A.useState(!1),{requestDelete:xe,clearConfirm:oe,isConfirming:ye}=Hl(),Le=A.useCallback(async()=>{try{const be=await(await we("/api/mcp/servers")).json();z(be.servers??[])}catch{}P(!1)},[]);A.useEffect(()=>{Le()},[Le]),A.useEffect(()=>{const re=()=>Le();return window.addEventListener("mcp-servers-changed",re),()=>window.removeEventListener("mcp-servers-changed",re)},[Le]);const Oe=re=>{I(be=>{const ke=new Set(be);return ke.has(re)?ke.delete(re):ke.add(re),ke})};function Me(){if(B.transport==="stdio"&&!B.command)return"Command is required for stdio transport";if(B.transport==="http"&&!B.url)return"URL is required for HTTP transport";if(B.timeout){const re=parseFloat(B.timeout);if(isNaN(re)||re<=0)return"Timeout must be a positive number"}return null}function je(re){const be=re?{name:B.name,transport:B.transport}:{transport:B.transport};if(B.transport==="stdio"?(be.command=B.command,be.args=B.args?B.args.split(" ").filter(Boolean):[],be.env=rS(B.env)):(be.url=B.url,be.headers=rS(B.headers)),B.timeout){const ke=parseFloat(B.timeout);!isNaN(ke)&&ke>0&&(be.timeout=ke)}return be}const nt={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",timeout:""},Xe=async()=>{if(ne(""),!B.name){ne("Name is required");return}const re=Me();if(re){ne(re);return}se(!0);try{const be=je(!0),ke=await we("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(be)});if(!ke.ok){const ze=await ke.json();throw new Error(ze.error??"Failed to add server")}G(!1),ee(nt),await Le()}catch(be){ne(be instanceof Error?be.message:String(be))}finally{se(!1)}},he=re=>{var be;ee({name:re.name,transport:re.config.transport,command:re.config.command??"",args:((be=re.config.args)==null?void 0:be.join(" "))??"",env:re.config.env?Object.entries(re.config.env).map(([ke,ze])=>`${ke}=${ze}`).join(`
|
|
244
|
+
`):"",url:re.config.url??"",headers:re.config.headers?Object.entries(re.config.headers).map(([ke,ze])=>`${ke}=${ze}`).join(`
|
|
245
|
+
`):"",timeout:re.config.timeout!==void 0?String(re.config.timeout):""}),ne(""),Q(re.name)},ce=async()=>{ne("");const re=Me();if(re){ne(re);return}se(!0);try{const be=je(!1),ke=await we(`/api/mcp/servers/${encodeURIComponent(Z)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(be)});if(!ke.ok){const ze=await ke.json();throw new Error(ze.error??"Failed to update server")}Q(null),ee(nt),await Le()}catch(be){ne(be instanceof Error?be.message:String(be))}finally{se(!1)}},de=async re=>{try{const be=await we(`/api/mcp/servers/${encodeURIComponent(re)}`,{method:"DELETE"});if(!be.ok){const ke=await be.json().catch(()=>({}));throw new Error(ke.error??"Failed to remove server")}oe(),F(""),await Le()}catch(be){F(be instanceof Error?be.message:String(be))}},$e=async(re,be,ke)=>{try{const ze=await we(`/api/mcp/servers/${encodeURIComponent(re)}/tools/${encodeURIComponent(be)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:ke})});if(!ze.ok){const Ye=await ze.json().catch(()=>({}));throw new Error(Ye.error??"Failed to toggle tool")}F(""),await Le()}catch(ze){F(ze instanceof Error?ze.message:String(ze))}},He=re=>{switch(re){case"connected":return"text-accent-success";case"error":return"text-accent-error";default:return"text-text-muted"}},ut=re=>{switch(re){case"connected":return"●";case"error":return"●";default:return"○"}};return i.jsxs("div",{className:"space-y-8",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),i.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(re=>i.jsx("button",{onClick:()=>v(re),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===re?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:re||"Off"},re))})]}),r==="tavily"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(ai,{type:"password",value:l,onChange:re=>u(re.target.value),placeholder:"tvly-...",className:"flex-1"}),i.jsx(Je,{variant:"secondary",onClick:E,style:y?{color:"rgb(63, 185, 80)"}:void 0,children:m})]}),x&&i.jsx("p",{className:"text-xs text-red-500 mt-1",children:x}),i.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",i.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),i.jsx(ai,{type:"url",value:c,onChange:re=>d(re.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsx(ai,{type:"password",value:f,onChange:re=>p(re.target.value),placeholder:"Optional API key",className:"w-full"})]}),i.jsx(Je,{variant:"secondary",onClick:j,style:S?{color:"rgb(63, 185, 80)"}:void 0,children:C}),_&&i.jsx("p",{className:"text-xs text-red-500",children:_})]})]})]}),L.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Shell"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Shell used to run agent commands and integrated terminals. Git Bash gives the agent a Unix-like toolset (grep, sed, ls…) and usually works better than cmd.exe."}),i.jsx("div",{className:"flex gap-2",children:L.map(re=>i.jsxs("button",{onClick:()=>n(De.TOOLS_SHELL,re.id),disabled:!re.available,title:re.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${M===re.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":re.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[re.label,!re.available&&" (not found)"]},re.id))}),i.jsx("p",{className:"text-xs text-text-muted mt-2",children:"Applies to new commands and newly opened terminals. Running terminals keep their current shell."})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",i.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),i.jsxs("div",{className:"flex items-center justify-between py-2",children:[i.jsx("div",{className:"flex-1",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),T==="checking"&&i.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),T==="available"&&i.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),T==="unavailable"&&i.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),i.jsx(Ui,{enabled:e[De.TOOLS_USE_RTK]==="true",onClick:()=>n(De.TOOLS_USE_RTK,e[De.TOOLS_USE_RTK]==="true"?"false":"true")})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Agent Confirmations"}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Require confirmation for workspace changes and git mutations. When disabled, the agent proceeds without interruption."}),i.jsxs("div",{className:"flex items-center justify-between py-2",children:[i.jsx("div",{className:"flex-1",children:i.jsx("span",{className:"text-sm text-text-primary",children:"Confirm on workspace & git actions"})}),i.jsx(Ui,{enabled:e[De.CONFIRM_ON_WORKSPACE_ACTIONS]==="true",onClick:()=>n(De.CONFIRM_ON_WORKSPACE_ACTIONS,e[De.CONFIRM_ON_WORKSPACE_ACTIONS]==="true"?"false":"true")})]})]}),i.jsx("hr",{className:"border-border"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"MCP Servers"}),i.jsx(Je,{variant:"primary",size:"sm",onClick:()=>G(!0),children:"+ Add Server"})]}),i.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),K&&i.jsx(Ka,{message:K}),i.jsx(tg,{loading:R,hasItems:W.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:W.map(re=>{var be;return i.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer hover:bg-bg-primary/50 transition-colors",onClick:()=>Oe(re.name),children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:`text-sm ${He(re.status)}`,children:ut(re.status)}),i.jsx("span",{className:"text-sm font-medium text-text-primary",children:re.name}),i.jsx("span",{className:"text-xs text-text-muted",children:re.config.transport}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",re.tools.length," tools)"]}),i.jsxs("span",{className:"text-xs text-text-muted",children:[iS(re.estimatedTokens)," tokens"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[re.status==="error"&&re.error&&i.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:re.error,children:re.error}),U.has(re.name)&&(ye(re.name,"delete")?i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:ke=>{ke.stopPropagation(),de(re.name)},className:"px-2 py-1 rounded text-xs font-medium hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),i.jsx("button",{onClick:ke=>{ke.stopPropagation(),oe()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:ke=>{ke.stopPropagation(),he(re)},className:"px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",children:"Edit"}),i.jsx("button",{onClick:ke=>{ke.stopPropagation(),xe(re.name)},className:"px-2 py-1 rounded text-xs font-medium text-accent-error/80 hover:text-accent-error hover:bg-accent-error/10 transition-colors",children:"Remove"})]})),i.jsx("span",{className:"text-xs text-text-muted",children:U.has(re.name)?"▲":"▼"})]})]}),U.has(re.name)&&i.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[re.config.command&&i.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[re.config.command," ",((be=re.config.args)==null?void 0:be.join(" "))??""]}),re.config.url&&i.jsx("div",{className:"text-xs text-text-muted font-mono",children:re.config.url}),re.config.timeout!==void 0&&i.jsxs("div",{className:"text-xs text-text-muted",children:["Timeout: ",re.config.timeout,"s"]}),re.tools.length===0?i.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):i.jsx("div",{className:"space-y-1",children:re.tools.map(ke=>i.jsxs("div",{className:"py-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[i.jsx("span",{className:"text-xs text-text-primary font-mono",children:ke.name}),ke.description&&ke.description.length>80?i.jsxs("button",{onClick:()=>{const ze=`${re.name}:${ke.name}`;q(Ye=>{const We=new Set(Ye);return We.has(ze)?We.delete(ze):We.add(ze),We})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[i.jsx("span",{className:"truncate max-w-[300px]",children:ke.description}),i.jsx(Qn,{rotate:$.has(`${re.name}:${ke.name}`)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):ke.description?i.jsx("span",{className:"text-xs text-text-muted ml-2",children:ke.description}):null]}),i.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:iS(ke.estimatedTokens)}),i.jsx(Ui,{enabled:ke.enabled,onClick:()=>$e(re.name,ke.name,!ke.enabled)})]}),ke.description&&ke.description.length>80&&$.has(`${re.name}:${ke.name}`)&&i.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:ke.description})]},ke.name))})]})]},re.name)})}),V&&i.jsx(wt,{isOpen:V,onClose:()=>{G(!1),ne("")},title:"Add MCP Server",size:"sm",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx(Cr,{label:"Name",value:B.name,onChange:re=>ee({...B,name:re}),placeholder:"e.g. filesystem"}),i.jsx(sS,{formData:B,onChange:ee}),X&&i.jsx(Ka,{message:X}),i.jsx(aS,{saving:te,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{G(!1),ne(""),se(!1),ee(nt)},onSave:Xe})]})}),Z!==null&&i.jsx(wt,{isOpen:!0,onClose:()=>{Q(null),ne("")},title:`Edit MCP Server: ${Z}`,size:"sm",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx(sS,{formData:B,onChange:ee}),X&&i.jsx(Ka,{message:X}),i.jsx(aS,{saving:te,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{Q(null),ne(""),se(!1),ee(nt)},onSave:ce})]})})]})]})}const lk="openfox_user_plugins";function g6(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function Km(e){const t=g6(e);if(!t)return null;try{const n=await fetch(`https://api.github.com/repos/${t.owner}/${t.repo}/releases/latest`,{signal:AbortSignal.timeout(5e3)});return n.ok?(await n.json()).tag_name??null:null}catch{return null}}function ku(){try{return JSON.parse(localStorage.getItem(lk)??"[]")}catch{return[]}}function oS(e){localStorage.setItem(lk,JSON.stringify(e))}function x6({onAdd:e}){const[t,n]=A.useState(""),[r,a]=A.useState(""),[l,u]=A.useState(!1),c=d=>{d.preventDefault(),!(!t.trim()||!r.trim())&&(e({name:t.trim(),displayName:t.trim(),description:"User-added plugin",githubUrl:r.trim()}),n(""),a(""),u(!0),setTimeout(()=>u(!1),2e3))};return i.jsxs("form",{onSubmit:c,className:"flex gap-2 items-end",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),i.jsx("input",{type:"text",value:t,onChange:d=>n(d.target.value),placeholder:"my-plugin",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),i.jsxs("div",{className:"flex-[2]",children:[i.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"GitHub URL"}),i.jsx("input",{type:"text",value:r,onChange:d=>a(d.target.value),placeholder:"https://github.com/user/repo",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),i.jsx(Je,{type:"submit",variant:"primary",size:"sm",children:l?"Added":"Add"})]})}function y6({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[l,u]=A.useState(t?"installed":"idle"),[c,d]=A.useState(!1),[f,p]=A.useState(""),[m,x]=A.useState(n),[y,w]=A.useState(!1),[C,_]=A.useState(!1);A.useEffect(()=>{x(n)},[n]);const S=A.useCallback(async()=>{const M=await we("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),W=await M.json();if(M.ok)u("installed"),e.latestVersion&&x(e.latestVersion),W.loaded||p(W.loadError??"Plugin installed but failed to load");else throw new Error(W.error??"Install failed")},[e.githubUrl,e.name]),b=async()=>{u("installing"),p("");try{await S()}catch(M){u("error"),p(M instanceof Error?M.message:"Connection error")}},v=()=>{w(!0)},E=async()=>{_(!0);try{(await we(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(u("idle"),r(e.name))}catch{}_(!1),w(!1)},j=async()=>{d(!0),p("");try{await S()}catch(M){p(M instanceof Error?M.message:"Update failed")}d(!1)},T=m??n,D=e.latestVersion&&T&&T!=="unknown"&&e.latestVersion!==T,L=l==="installing"?"Installing…":c?"Updating…":l==="installed"?"Installed ✓":"Install",O=l==="installing"||l==="installed"||c;return i.jsxs("div",{className:"border border-border rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary",children:e.displayName}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",e.name,")"]})]}),i.jsx("p",{className:"text-xs text-text-muted mt-1",children:e.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs",children:[e.githubUrl&&i.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer",className:"text-accent-primary hover:underline",children:"GitHub"}),e.versionLoading?i.jsx("span",{className:"text-text-muted",children:"Loading version…"}):e.latestVersion?i.jsxs("span",{className:"text-text-muted",children:["v",e.latestVersion]}):null,T&&T!=="unknown"&&i.jsxs("span",{className:"text-text-muted",children:["installed: v",T]})]}),l==="error"&&f&&i.jsx("p",{className:"text-xs text-accent-error mt-1",children:f})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1",children:[i.jsxs("div",{className:"flex gap-1",children:[e.githubUrl&&i.jsx(Je,{variant:l==="installed"?"secondary":"primary",size:"sm",onClick:b,disabled:O,children:L}),D&&i.jsx(Je,{variant:"primary",size:"sm",onClick:j,children:"Update"}),l==="installed"&&i.jsx(Je,{variant:"danger",size:"sm",onClick:v,children:"Remove"})]}),l==="installed"&&i.jsx("button",{onClick:()=>a(e.name),className:"text-xs text-accent-primary hover:underline",children:"Open folder"})]})]}),i.jsx(Nl,{isOpen:y,onClose:()=>w(!1),onConfirm:E,title:`Remove "${e.displayName}"?`,message:`Remove the "${e.displayName}" plugin from your installation.`,confirmLabel:"Remove",confirmVariant:"danger",disabled:C})]})}function b6(){const[e,t]=A.useState([]),[n,r]=A.useState([]),[a,l]=A.useState({}),[u,c]=A.useState(!0),[d,f]=A.useState(""),[p,m]=A.useState("");A.useEffect(()=>{let S=!1;Promise.all([we("/api/plugins/registry").then(v=>{if(!v.ok)throw new Error(`HTTP ${v.status}`);return v.json()}),we("/api/plugins/installed").then(v=>v.ok?v.json():{installed:[]})]).then(([v,E])=>{if(S)return;const j={},T=E.installed;for(const W of T)j[W.name]=W.version;l(j);const D=v.plugins.map(W=>({...W,latestVersion:null,versionLoading:!0}));t(D),D.forEach(W=>{Km(W.githubUrl).then(z=>{S||t(R=>R.map(P=>P.name===W.name?{...P,latestVersion:z,versionLoading:!1}:P))})});const L=new Set(D.map(W=>W.name)),O=ku(),M=[];for(const W of T)!L.has(W.name)&&!O.some(z=>z.name===W.name)&&M.push({name:W.name,displayName:W.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});M.length>0&&r(W=>[...W,...M])}).catch(v=>{S||f(v instanceof Error?v.message:"Failed to load plugins")}).finally(()=>{S||c(!1)});const b=ku();return b.length>0&&(r(b.map(v=>({...v,latestVersion:null,versionLoading:!0}))),b.forEach(v=>{Km(v.githubUrl).then(E=>{S||r(j=>j.map(T=>T.name===v.name?{...T,latestVersion:E,versionLoading:!1}:T))})})),()=>{S=!0}},[]);const x=async S=>{try{S?await we(`/api/plugins/${S}/open-folder`):await we("/api/plugins/open-folder")}catch{}},y=A.useCallback(S=>{l(E=>{const j={...E};return delete j[S],j});const b=ku(),v=b.filter(E=>E.name!==S);v.length!==b.length&&oS(v),r(E=>E.filter(j=>j.name!==S))},[]),w=A.useCallback(S=>{if(new Set(e.map(E=>E.name)).has(S.name)){m(`"${S.displayName}" is already listed in the registry and won't be added again.`);return}const v=ku();oS([...v,S]),r(E=>[...E,{...S,latestVersion:null,versionLoading:!0}]),Km(S.githubUrl).then(E=>{r(j=>j.map(T=>T.name===S.name?{...T,latestVersion:E,versionLoading:!1}:T))})},[e]),C=new Set,_=[...e,...n].filter(S=>C.has(S.name)?!1:(C.add(S.name),!0));return u?i.jsx("div",{className:"text-sm text-text-muted",children:"Loading plugins..."}):i.jsxs("div",{className:"space-y-4",children:[d&&i.jsxs("div",{className:"text-sm text-accent-error bg-accent-error/10 border border-accent-error/30 rounded-lg p-3",children:["Failed to load plugin registry: ",d]}),p&&i.jsxs("div",{className:"text-sm text-accent-warning bg-accent-warning/10 border border-accent-warning/30 rounded-lg p-3 flex justify-between items-center",children:[i.jsx("span",{children:p}),i.jsx("button",{onClick:()=>m(""),className:"text-text-muted hover:text-text-primary ml-2",children:"×"})]}),i.jsxs("div",{className:"border border-border rounded-lg p-4",children:[i.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Add Plugin"}),i.jsx(x6,{onAdd:w})]}),_.length===0&&!d&&i.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),_.map(S=>i.jsx(y6,{plugin:S,initiallyInstalled:S.name in a,installedVersion:a[S.name]??null,onRemove:y,onOpenFolder:x},S.name))]})}function v6({isOpen:e,onClose:t}){const[n,r]=A.useState("instructions"),a=ws(u=>u.status==="available"),l=()=>{try{Xt.send("context.checkDynamic",{})}catch{}t()};return i.jsx(wt,{isOpen:e,onClose:l,title:"Settings",size:"xl",minHeight:"500px",children:i.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1 overflow-x-auto scrollbar-hide",children:[i.jsx(Js,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),i.jsx(Js,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),i.jsx(Js,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),i.jsx(Js,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),i.jsx(Js,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),i.jsx(Js,{label:"Display",active:n==="display",onClick:()=>r("display")}),i.jsx(Js,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),i.jsx(Js,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),n==="instructions"&&i.jsx(fT,{isOpen:e}),n==="skills"&&i.jsx(hT,{isOpen:e}),n==="plugins"&&i.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:i.jsx(b6,{})}),n==="notifications"&&i.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:i.jsx(tT,{})}),n==="display"&&i.jsx(yT,{}),n==="keybindings"&&i.jsx(m6,{}),n==="tools"&&i.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:i.jsx(p6,{})}),n==="advanced"&&i.jsx(d6,{onClose:t})]})})}function Js({label:e,active:t,onClick:n,showDot:r}){return i.jsxs("button",{onClick:n,className:`relative px-4 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:[e,r&&i.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]})}var Ym={exports:{}},lS;function _6(){return lS||(lS=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(u,c,d){var f=this&&this.__decorate||function(b,v,E,j){var T,D=arguments.length,L=D<3?v:j===null?j=Object.getOwnPropertyDescriptor(v,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,v,E,j);else for(var O=b.length-1;O>=0;O--)(T=b[O])&&(L=(D<3?T(L):D>3?T(v,E,L):T(v,E))||L);return D>3&&L&&Object.defineProperty(v,E,L),L},p=this&&this.__param||function(b,v){return function(E,j){v(E,j,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=d(9042),x=d(9924),y=d(844),w=d(4725),C=d(2585),_=d(3656);let S=c.AccessibilityManager=class extends y.Disposable{constructor(b,v,E,j){super(),this._terminal=b,this._coreBrowserService=E,this._renderService=j,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let T=0;T<this._terminal.rows;T++)this._rowElements[T]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[T]);if(this._topBoundaryFocusListener=T=>this._handleBoundaryFocus(T,0),this._bottomBoundaryFocusListener=T=>this._handleBoundaryFocus(T,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(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((T=>this._handleResize(T.rows)))),this.register(this._terminal.onRender((T=>this._refreshRows(T.start,T.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((T=>this._handleChar(T)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
246
|
+
`)))),this.register(this._terminal.onA11yTab((T=>this._handleTab(T)))),this.register(this._terminal.onKey((T=>this._handleKey(T.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,_.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(b){for(let v=0;v<b;v++)this._handleChar(" ")}_handleChar(b){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==b&&(this._charsToAnnounce+=b):this._charsToAnnounce+=b,b===`
|
|
247
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(b){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(b)||this._charsToConsume.push(b)}_refreshRows(b,v){this._liveRegionDebouncer.refresh(b,v,this._terminal.rows)}_renderRows(b,v){const E=this._terminal.buffer,j=E.lines.length.toString();for(let T=b;T<=v;T++){const D=E.lines.get(E.ydisp+T),L=[],O=(D==null?void 0:D.translateToString(!0,void 0,void 0,L))||"",M=(E.ydisp+T+1).toString(),W=this._rowElements[T];W&&(O.length===0?(W.innerText=" ",this._rowColumns.set(W,[0,1])):(W.textContent=O,this._rowColumns.set(W,L)),W.setAttribute("aria-posinset",M),W.setAttribute("aria-setsize",j))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(b,v){const E=b.target,j=this._rowElements[v===0?1:this._rowElements.length-2];if(E.getAttribute("aria-posinset")===(v===0?"1":`${this._terminal.buffer.lines.length}`)||b.relatedTarget!==j)return;let T,D;if(v===0?(T=E,D=this._rowElements.pop(),this._rowContainer.removeChild(D)):(T=this._rowElements.shift(),D=E,this._rowContainer.removeChild(T)),T.removeEventListener("focus",this._topBoundaryFocusListener),D.removeEventListener("focus",this._bottomBoundaryFocusListener),v===0){const L=this._createAccessibilityTreeNode();this._rowElements.unshift(L),this._rowContainer.insertAdjacentElement("afterbegin",L)}else{const L=this._createAccessibilityTreeNode();this._rowElements.push(L),this._rowContainer.appendChild(L)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(v===0?-1:1),this._rowElements[v===0?1:this._rowElements.length-2].focus(),b.preventDefault(),b.stopImmediatePropagation()}_handleSelectionChange(){var O;if(this._rowElements.length===0)return;const b=document.getSelection();if(!b)return;if(b.isCollapsed)return void(this._rowContainer.contains(b.anchorNode)&&this._terminal.clearSelection());if(!b.anchorNode||!b.focusNode)return void console.error("anchorNode and/or focusNode are null");let v={node:b.anchorNode,offset:b.anchorOffset},E={node:b.focusNode,offset:b.focusOffset};if((v.node.compareDocumentPosition(E.node)&Node.DOCUMENT_POSITION_PRECEDING||v.node===E.node&&v.offset>E.offset)&&([v,E]=[E,v]),v.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(v={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(v.node))return;const j=this._rowElements.slice(-1)[0];if(E.node.compareDocumentPosition(j)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(E={node:j,offset:((O=j.textContent)==null?void 0:O.length)??0}),!this._rowContainer.contains(E.node))return;const T=({node:M,offset:W})=>{const z=M instanceof Text?M.parentNode:M;let R=parseInt(z==null?void 0:z.getAttribute("aria-posinset"),10)-1;if(isNaN(R))return console.warn("row is invalid. Race condition?"),null;const P=this._rowColumns.get(z);if(!P)return console.warn("columns is null. Race condition?"),null;let V=W<P.length?P[W]:P.slice(-1)[0]+1;return V>=this._terminal.cols&&(++R,V=0),{row:R,column:V}},D=T(v),L=T(E);if(D&&L){if(D.row>L.row||D.row===L.row&&D.column>=L.column)throw new Error("invalid range");this._terminal.select(D.column,D.row,(L.row-D.row)*this._terminal.cols-D.column+L.column)}}_handleResize(b){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let v=this._rowContainer.children.length;v<this._terminal.rows;v++)this._rowElements[v]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[v]);for(;this._rowElements.length>b;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const b=this._coreBrowserService.mainDocument.createElement("div");return b.setAttribute("role","listitem"),b.tabIndex=-1,this._refreshRowDimensions(b),b}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let b=0;b<this._terminal.rows;b++)this._refreshRowDimensions(this._rowElements[b])}}_refreshRowDimensions(b){b.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=S=f([p(1,C.IInstantiationService),p(2,w.ICoreBrowserService),p(3,w.IRenderService)],S)},3614:(u,c)=>{function d(x){return x.replace(/\r?\n/g,"\r")}function f(x,y){return y?"\x1B[200~"+x+"\x1B[201~":x}function p(x,y,w,C){x=f(x=d(x),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(x,!0),y.value=""}function m(x,y,w){const C=w.getBoundingClientRect(),_=x.clientX-C.left-10,S=x.clientY-C.top-10;y.style.width="20px",y.style.height="20px",y.style.left=`${_}px`,y.style.top=`${S}px`,y.style.zIndex="1000",y.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=d,c.bracketTextForPaste=f,c.copyHandler=function(x,y){x.clipboardData&&x.clipboardData.setData("text/plain",y.selectionText),x.preventDefault()},c.handlePasteEvent=function(x,y,w,C){x.stopPropagation(),x.clipboardData&&p(x.clipboardData.getData("text/plain"),y,w,C)},c.paste=p,c.moveTextAreaUnderMouseCursor=m,c.rightClickHandler=function(x,y,w,C,_){m(x,y,w),_&&C.rightClickSelect(x),y.value=C.selectionText,y.select()}},7239:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const f=d(1505);c.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(p,m,x){this._css.set(p,m,x)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,x){this._color.set(p,m,x)}getColor(p,m){return this._color.get(p,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(d,f,p,m){d.addEventListener(f,p,m);let x=!1;return{dispose:()=>{x||(x=!0,d.removeEventListener(f,p,m))}}}},3551:function(u,c,d){var f=this&&this.__decorate||function(S,b,v,E){var j,T=arguments.length,D=T<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,v):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,b,v,E);else for(var L=S.length-1;L>=0;L--)(j=S[L])&&(D=(T<3?j(D):T>3?j(b,v,D):j(b,v))||D);return T>3&&D&&Object.defineProperty(b,v,D),D},p=this&&this.__param||function(S,b){return function(v,E){b(v,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const m=d(3656),x=d(8460),y=d(844),w=d(2585),C=d(4725);let _=c.Linkifier=class extends y.Disposable{get currentLink(){return this._currentLink}constructor(S,b,v,E,j){super(),this._element=S,this._mouseService=b,this._renderService=v,this._bufferService=E,this._linkProviderService=j,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new x.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new x.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,y.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,y.toDisposable)((()=>{var T;this._lastMouseEvent=void 0,(T=this._activeProviderReplies)==null||T.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,m.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,m.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(S){this._lastMouseEvent=S;const b=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!b)return;this._isMouseOut=!1;const v=S.composedPath();for(let E=0;E<v.length;E++){const j=v[E];if(j.classList.contains("xterm"))break;if(j.classList.contains("xterm-hover"))return}this._lastBufferCell&&b.x===this._lastBufferCell.x&&b.y===this._lastBufferCell.y||(this._handleHover(b),this._lastBufferCell=b)}_handleHover(S){if(this._activeLine!==S.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(S,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,S)||(this._clearCurrentLink(),this._askForLink(S,!0))}_askForLink(S,b){var E,j;this._activeProviderReplies&&b||((E=this._activeProviderReplies)==null||E.forEach((T=>{T==null||T.forEach((D=>{D.link.dispose&&D.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let v=!1;for(const[T,D]of this._linkProviderService.linkProviders.entries())b?(j=this._activeProviderReplies)!=null&&j.get(T)&&(v=this._checkLinkProviderResult(T,S,v)):D.provideLinks(S.y,(L=>{var M,W;if(this._isMouseOut)return;const O=L==null?void 0:L.map((z=>({link:z})));(M=this._activeProviderReplies)==null||M.set(T,O),v=this._checkLinkProviderResult(T,S,v),((W=this._activeProviderReplies)==null?void 0:W.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,b){const v=new Set;for(let E=0;E<b.size;E++){const j=b.get(E);if(j)for(let T=0;T<j.length;T++){const D=j[T],L=D.link.range.start.y<S?0:D.link.range.start.x,O=D.link.range.end.y>S?this._bufferService.cols:D.link.range.end.x;for(let M=L;M<=O;M++){if(v.has(M)){j.splice(T--,1);break}v.add(M)}}}}_checkLinkProviderResult(S,b,v){var T;if(!this._activeProviderReplies)return v;const E=this._activeProviderReplies.get(S);let j=!1;for(let D=0;D<S;D++)this._activeProviderReplies.has(D)&&!this._activeProviderReplies.get(D)||(j=!0);if(!j&&E){const D=E.find((L=>this._linkAtPosition(L.link,b)));D&&(v=!0,this._handleNewLink(D))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!v)for(let D=0;D<this._activeProviderReplies.size;D++){const L=(T=this._activeProviderReplies.get(D))==null?void 0:T.find((O=>this._linkAtPosition(O.link,b)));if(L){v=!0,this._handleNewLink(L);break}}return v}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const b=this._positionFromMouseEvent(S,this._element,this._mouseService);b&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,b)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,b){this._currentLink&&this._lastMouseEvent&&(!S||!b||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=b)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,y.disposeArray)(this._linkCacheDisposables))}_handleNewLink(S){if(!this._lastMouseEvent)return;const b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._linkAtPosition(S.link,b)&&(this._currentLink=S,this._currentLink.state={decorations:{underline:S.link.decorations===void 0||S.link.decorations.underline,pointerCursor:S.link.decorations===void 0||S.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,S.link,this._lastMouseEvent),S.link.decorations={},Object.defineProperties(S.link.decorations,{pointerCursor:{get:()=>{var v,E;return(E=(v=this._currentLink)==null?void 0:v.state)==null?void 0:E.decorations.pointerCursor},set:v=>{var E;(E=this._currentLink)!=null&&E.state&&this._currentLink.state.decorations.pointerCursor!==v&&(this._currentLink.state.decorations.pointerCursor=v,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",v))}},underline:{get:()=>{var v,E;return(E=(v=this._currentLink)==null?void 0:v.state)==null?void 0:E.decorations.underline},set:v=>{var E,j,T;(E=this._currentLink)!=null&&E.state&&((T=(j=this._currentLink)==null?void 0:j.state)==null?void 0:T.decorations.underline)!==v&&(this._currentLink.state.decorations.underline=v,this._currentLink.state.isHovered&&this._fireUnderlineEvent(S.link,v))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((v=>{if(!this._currentLink)return;const E=v.start===0?0:v.start+1+this._bufferService.buffer.ydisp,j=this._bufferService.buffer.ydisp+1+v.end;if(this._currentLink.link.range.start.y>=E&&this._currentLink.link.range.end.y<=j&&(this._clearCurrentLink(E,j),this._lastMouseEvent)){const T=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);T&&this._askForLink(T,!1)}}))))}_linkHover(S,b,v){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!0),this._currentLink.state.decorations.pointerCursor&&S.classList.add("xterm-cursor-pointer")),b.hover&&b.hover(v,b.text)}_fireUnderlineEvent(S,b){const v=S.range,E=this._bufferService.buffer.ydisp,j=this._createLinkUnderlineEvent(v.start.x-1,v.start.y-E-1,v.end.x,v.end.y-E-1,void 0);(b?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(j)}_linkLeave(S,b,v){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!1),this._currentLink.state.decorations.pointerCursor&&S.classList.remove("xterm-cursor-pointer")),b.leave&&b.leave(v,b.text)}_linkAtPosition(S,b){const v=S.range.start.y*this._bufferService.cols+S.range.start.x,E=S.range.end.y*this._bufferService.cols+S.range.end.x,j=b.y*this._bufferService.cols+b.x;return v<=j&&j<=E}_positionFromMouseEvent(S,b,v){const E=v.getCoords(S,b,this._bufferService.cols,this._bufferService.rows);if(E)return{x:E[0],y:E[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,b,v,E,j){return{x1:S,y1:b,x2:v,y2:E,cols:this._bufferService.cols,fg:j}}};c.Linkifier=_=f([p(1,C.IMouseService),p(2,C.IRenderService),p(3,w.IBufferService),p(4,C.ILinkProviderService)],_)},9042:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.tooMuchOutput=c.promptLabel=void 0,c.promptLabel="Terminal input",c.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(u,c,d){var f=this&&this.__decorate||function(C,_,S,b){var v,E=arguments.length,j=E<3?_:b===null?b=Object.getOwnPropertyDescriptor(_,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(C,_,S,b);else for(var T=C.length-1;T>=0;T--)(v=C[T])&&(j=(E<3?v(j):E>3?v(_,S,j):v(_,S))||j);return E>3&&j&&Object.defineProperty(_,S,j),j},p=this&&this.__param||function(C,_){return function(S,b){_(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const m=d(511),x=d(2585);let y=c.OscLinkProvider=class{constructor(C,_,S){this._bufferService=C,this._optionsService=_,this._oscLinkService=S}provideLinks(C,_){var O;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void _(void 0);const b=[],v=this._optionsService.rawOptions.linkHandler,E=new m.CellData,j=S.getTrimmedLength();let T=-1,D=-1,L=!1;for(let M=0;M<j;M++)if(D!==-1||S.hasContent(M)){if(S.loadCell(M,E),E.hasExtendedAttrs()&&E.extended.urlId){if(D===-1){D=M,T=E.extended.urlId;continue}L=E.extended.urlId!==T}else D!==-1&&(L=!0);if(L||D!==-1&&M===j-1){const W=(O=this._oscLinkService.getLinkData(T))==null?void 0:O.uri;if(W){const z={start:{x:D+1,y:C},end:{x:M+(L||M!==j-1?0:1),y:C}};let R=!1;if(!(v!=null&&v.allowNonHttpProtocols))try{const P=new URL(W);["http:","https:"].includes(P.protocol)||(R=!0)}catch{R=!0}R||b.push({text:W,range:z,activate:(P,V)=>v?v.activate(P,V,z):w(0,V),hover:(P,V)=>{var G;return(G=v==null?void 0:v.hover)==null?void 0:G.call(v,P,V,z)},leave:(P,V)=>{var G;return(G=v==null?void 0:v.leave)==null?void 0:G.call(v,P,V,z)}})}L=!1,E.hasExtendedAttrs()&&E.extended.urlId?(D=M,T=E.extended.urlId):(D=-1,T=-1)}}_(b)}};function w(C,_){if(confirm(`Do you want to navigate to ${_}?
|
|
248
|
+
|
|
249
|
+
WARNING: This link could potentially be dangerous`)){const S=window.open();if(S){try{S.opener=null}catch{}S.location.href=_}else console.warn("Opening link blocked as opener could not be cleared")}}c.OscLinkProvider=y=f([p(0,x.IBufferService),p(1,x.IOptionsService),p(2,x.IOscLinkService)],y)},6193:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.RenderDebouncer=void 0,c.RenderDebouncer=class{constructor(d,f){this._renderCallback=d,this._coreBrowserService=f,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(d){return this._refreshCallbacks.push(d),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(d,f,p){this._rowCount=p,d=d!==void 0?d:0,f=f!==void 0?f:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,f):f,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)return void this._runRefreshCallbacks();const d=Math.max(this._rowStart,0),f=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,f),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const d of this._refreshCallbacks)d(0);this._refreshCallbacks=[]}}},3236:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const f=d(3614),p=d(3656),m=d(3551),x=d(9042),y=d(3730),w=d(1680),C=d(3107),_=d(5744),S=d(2950),b=d(1296),v=d(428),E=d(4269),j=d(5114),T=d(8934),D=d(3230),L=d(9312),O=d(4725),M=d(6731),W=d(8055),z=d(8969),R=d(8460),P=d(844),V=d(6114),G=d(8437),Z=d(2584),Q=d(7399),U=d(5941),I=d(9074),$=d(2585),q=d(5435),B=d(4567),ee=d(779);class X extends z.CoreTerminal{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}constructor(K={}){super(K),this.browser=V,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new P.MutableDisposable),this._onCursorMove=this.register(new R.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new R.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new R.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new R.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new R.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new R.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new R.EventEmitter),this._onBlur=this.register(new R.EventEmitter),this._onA11yCharEmitter=this.register(new R.EventEmitter),this._onA11yTabEmitter=this.register(new R.EventEmitter),this._onWillOpen=this.register(new R.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(I.DecorationService),this._instantiationService.setService($.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ee.LinkProviderService),this._instantiationService.setService(O.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(y.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,te)=>this.refresh(F,te)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),this.register((0,R.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,R.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((F=>this._afterResize(F.cols,F.rows)))),this.register((0,P.toDisposable)((()=>{var F,te;this._customKeyEventHandler=void 0,(te=(F=this.element)==null?void 0:F.parentNode)==null||te.removeChild(this.element)})))}_handleColorEvent(K){if(this._themeService)for(const F of K){let te,se="";switch(F.index){case 256:te="foreground",se="10";break;case 257:te="background",se="11";break;case 258:te="cursor",se="12";break;default:te="ansi",se="4;"+F.index}switch(F.type){case 0:const xe=W.color.toColorRGB(te==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[te]);this.coreService.triggerDataEvent(`${Z.C0.ESC}]${se};${(0,U.toRgbString)(xe)}${Z.C1_ESCAPED.ST}`);break;case 1:if(te==="ansi")this._themeService.modifyColors((oe=>oe.ansi[F.index]=W.channels.toColor(...F.color)));else{const oe=te;this._themeService.modifyColors((ye=>ye[oe]=W.channels.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(K){K?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(B.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(K){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var K;return(K=this.textarea)==null?void 0:K.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const K=this.buffer.ybase+this.buffer.y,F=this.buffer.lines.get(K);if(!F)return;const te=Math.min(this.buffer.x,this.cols-1),se=this._renderService.dimensions.css.cell.height,xe=F.getWidth(te),oe=this._renderService.dimensions.css.cell.width*xe,ye=this.buffer.y*this._renderService.dimensions.css.cell.height,Le=te*this._renderService.dimensions.css.cell.width;this.textarea.style.left=Le+"px",this.textarea.style.top=ye+"px",this.textarea.style.width=oe+"px",this.textarea.style.height=se+"px",this.textarea.style.lineHeight=se+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,p.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,f.copyHandler)(F,this._selectionService)})));const K=F=>(0,f.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",K)),this.register((0,p.addDisposableDomListener)(this.element,"paste",K)),V.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,f.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,f.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),V.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,f.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,p.addDisposableDomListener)(this.textarea,"keyup",(K=>this._keyUp(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keydown",(K=>this._keyDown(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keypress",(K=>this._keyPress(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionupdate",(K=>this._compositionHelper.compositionupdate(K)))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,p.addDisposableDomListener)(this.textarea,"input",(K=>this._inputEvent(K)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(K){var te;if(!K)throw new Error("Terminal requires a parent element.");if(K.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((te=this.element)==null?void 0:te.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=K.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"),K.appendChild(this.element);const F=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),F.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,p.addDisposableDomListener)(this.screenElement,"mousemove",(se=>this.updateCursorStyle(se)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),F.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",x.promptLabel),V.isChromeOS||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._coreBrowserService=this.register(this._instantiationService.createInstance(j.CoreBrowserService,this.textarea,K.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(O.ICoreBrowserService,this._coreBrowserService),this.register((0,p.addDisposableDomListener)(this.textarea,"focus",(se=>this._handleTextAreaFocus(se)))),this.register((0,p.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(v.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(O.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(M.ThemeService),this._instantiationService.setService(O.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(E.CharacterJoinerService),this._instantiationService.setService(O.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(D.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(O.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((se=>this._onRender.fire(se)))),this.onResize((se=>this._renderService.resize(se.cols,se.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(S.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(T.MouseService),this._instantiationService.setService(O.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(F);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),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.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(L.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(O.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((se=>this._renderService.handleSelectionChanged(se.start,se.end,se.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((se=>{this.textarea.value=se,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((se=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,p.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(se=>this._selectionService.handleMouseDown(se)))),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(B.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(se=>this._handleScreenReaderModeOptionChange(se)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(_.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(se=>{!this._overviewRulerRenderer&&se&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(_.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(b.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const K=this,F=this.element;function te(oe){const ye=K._mouseService.getMouseReportCoords(oe,K.screenElement);if(!ye)return!1;let Le,Oe;switch(oe.overrideType||oe.type){case"mousemove":Oe=32,oe.buttons===void 0?(Le=3,oe.button!==void 0&&(Le=oe.button<3?oe.button:3)):Le=1&oe.buttons?0:4&oe.buttons?1:2&oe.buttons?2:3;break;case"mouseup":Oe=0,Le=oe.button<3?oe.button:3;break;case"mousedown":Oe=1,Le=oe.button<3?oe.button:3;break;case"wheel":if(K._customWheelEventHandler&&K._customWheelEventHandler(oe)===!1||K.viewport.getLinesScrolled(oe)===0)return!1;Oe=oe.deltaY<0?0:1,Le=4;break;default:return!1}return!(Oe===void 0||Le===void 0||Le>4)&&K.coreMouseService.triggerMouseEvent({col:ye.col,row:ye.row,x:ye.x,y:ye.y,button:Le,action:Oe,ctrl:oe.ctrlKey,alt:oe.altKey,shift:oe.shiftKey})}const se={mouseup:null,wheel:null,mousedrag:null,mousemove:null},xe={mouseup:oe=>(te(oe),oe.buttons||(this._document.removeEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.removeEventListener("mousemove",se.mousedrag)),this.cancel(oe)),wheel:oe=>(te(oe),this.cancel(oe,!0)),mousedrag:oe=>{oe.buttons&&te(oe)},mousemove:oe=>{oe.buttons||te(oe)}};this.register(this.coreMouseService.onProtocolChange((oe=>{oe?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(oe)),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()),8&oe?se.mousemove||(F.addEventListener("mousemove",xe.mousemove),se.mousemove=xe.mousemove):(F.removeEventListener("mousemove",se.mousemove),se.mousemove=null),16&oe?se.wheel||(F.addEventListener("wheel",xe.wheel,{passive:!1}),se.wheel=xe.wheel):(F.removeEventListener("wheel",se.wheel),se.wheel=null),2&oe?se.mouseup||(se.mouseup=xe.mouseup):(this._document.removeEventListener("mouseup",se.mouseup),se.mouseup=null),4&oe?se.mousedrag||(se.mousedrag=xe.mousedrag):(this._document.removeEventListener("mousemove",se.mousedrag),se.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(F,"mousedown",(oe=>{if(oe.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(oe))return te(oe),se.mouseup&&this._document.addEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.addEventListener("mousemove",se.mousedrag),this.cancel(oe)}))),this.register((0,p.addDisposableDomListener)(F,"wheel",(oe=>{if(!se.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(oe)===!1)return!1;if(!this.buffer.hasScrollback){const ye=this.viewport.getLinesScrolled(oe);if(ye===0)return;const Le=Z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(oe.deltaY<0?"A":"B");let Oe="";for(let Me=0;Me<Math.abs(ye);Me++)Oe+=Le;return this.coreService.triggerDataEvent(Oe,!0),this.cancel(oe,!0)}return this.viewport.handleWheel(oe)?this.cancel(oe):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(F,"touchstart",(oe=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(oe),this.cancel(oe)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(F,"touchmove",(oe=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(oe)?void 0:this.cancel(oe)}),{passive:!1}))}refresh(K,F){var te;(te=this._renderService)==null||te.refreshRows(K,F)}updateCursorStyle(K){var F;(F=this._selectionService)!=null&&F.shouldColumnSelect(K)?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(K,F,te=0){var se;te===1?(super.scrollLines(K,F,te),this.refresh(0,this.rows-1)):(se=this.viewport)==null||se.scrollLines(K)}paste(K){(0,f.paste)(K,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(K){this._customKeyEventHandler=K}attachCustomWheelEventHandler(K){this._customWheelEventHandler=K}registerLinkProvider(K){return this._linkProviderService.registerLinkProvider(K)}registerCharacterJoiner(K){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const F=this._characterJoinerService.register(K);return this.refresh(0,this.rows-1),F}deregisterCharacterJoiner(K){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(K)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(K){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+K)}registerDecoration(K){return this._decorationService.registerDecoration(K)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(K,F,te){this._selectionService.setSelection(K,F,te)}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 K;(K=this._selectionService)==null||K.clearSelection()}selectAll(){var K;(K=this._selectionService)==null||K.selectAll()}selectLines(K,F){var te;(te=this._selectionService)==null||te.selectLines(K,F)}_keyDown(K){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&K.altKey;if(!F&&!this._compositionHelper.keydown(K))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||K.key!=="Dead"&&K.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const te=(0,Q.evaluateKeyboardEvent)(K,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(K),te.type===3||te.type===2){const se=this.rows-1;return this.scrollLines(te.type===2?-se:se),this.cancel(K,!0)}return te.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,K)||(te.cancel&&this.cancel(K,!0),!te.key||!!(K.key&&!K.ctrlKey&&!K.altKey&&!K.metaKey&&K.key.length===1&&K.key.charCodeAt(0)>=65&&K.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(te.key!==Z.C0.ETX&&te.key!==Z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:te.key,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(te.key,!0),!this.optionsService.rawOptions.screenReaderMode||K.altKey||K.ctrlKey?this.cancel(K,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(K,F){const te=K.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||K.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||K.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?te:te&&(!F.keyCode||F.keyCode>47)}_keyUp(K){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(K)||this.focus(),this.updateCursorStyle(K),this._keyPressHandled=!1)}_keyPress(K){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;if(this.cancel(K),K.charCode)F=K.charCode;else if(K.which===null||K.which===void 0)F=K.keyCode;else{if(K.which===0||K.charCode===0)return!1;F=K.which}return!(!F||(K.altKey||K.ctrlKey||K.metaKey)&&!this._isThirdLevelShift(this.browser,K)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(F,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(K){if(K.data&&K.inputType==="insertText"&&(!K.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const F=K.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(K),!0}return!1}resize(K,F){K!==this.cols||F!==this.rows?super.resize(K,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(K,F){var te,se;(te=this._charSizeService)==null||te.measure(),(se=this.viewport)==null||se.syncScrollArea(!0)}clear(){var K;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 F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(G.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(K=this.viewport)==null||K.reset(),this.refresh(0,this.rows-1)}}reset(){var F,te;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(F=this._selectionService)==null||F.reset(),this._decorationService.reset(),(te=this.viewport)==null||te.reset(),this._customKeyEventHandler=K,this.refresh(0,this.rows-1)}clearTextureAtlas(){var K;(K=this._renderService)==null||K.clearTextureAtlas()}_reportFocus(){var K;(K=this.element)!=null&&K.classList.contains("focus")?this.coreService.triggerDataEvent(Z.C0.ESC+"[I"):this.coreService.triggerDataEvent(Z.C0.ESC+"[O")}_reportWindowsOptions(K){if(this._renderService)switch(K){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),te=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[4;${te};${F}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const se=this._renderService.dimensions.css.cell.width.toFixed(0),xe=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[6;${xe};${se}t`)}}cancel(K,F){if(this.options.cancelEvents||F)return K.preventDefault(),K.stopPropagation(),!1}}c.Terminal=X},9924:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TimeBasedDebouncer=void 0,c.TimeBasedDebouncer=class{constructor(d,f=1e3){this._renderCallback=d,this._debounceThresholdMS=f,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(d,f,p){this._rowCount=p,d=d!==void 0?d:0,f=f!==void 0?f:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,f):f;const m=Date.now();if(m-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=m,this._innerRefresh();else if(!this._additionalRefreshRequested){const x=m-this._lastRefreshMs,y=this._debounceThresholdMS-x;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),y)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const d=Math.max(this._rowStart,0),f=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,f)}}},1680:function(u,c,d){var f=this&&this.__decorate||function(S,b,v,E){var j,T=arguments.length,D=T<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,v):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,b,v,E);else for(var L=S.length-1;L>=0;L--)(j=S[L])&&(D=(T<3?j(D):T>3?j(b,v,D):j(b,v))||D);return T>3&&D&&Object.defineProperty(b,v,D),D},p=this&&this.__param||function(S,b){return function(v,E){b(v,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Viewport=void 0;const m=d(3656),x=d(4725),y=d(8460),w=d(844),C=d(2585);let _=c.Viewport=class extends w.Disposable{constructor(S,b,v,E,j,T,D,L){super(),this._viewportElement=S,this._scrollArea=b,this._bufferService=v,this._optionsService=E,this._charSizeService=j,this._renderService=T,this._coreBrowserService=D,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new y.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((O=>this._activeBuffer=O.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((O=>this._renderDimensions=O))),this._handleThemeChange(L.colors),this.register(L.onChangeColors((O=>this._handleThemeChange(O)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(S){this._viewportElement.style.backgroundColor=S.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(S){if(S)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const b=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==b&&(this._lastRecordedBufferHeight=b,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const S=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==S&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=S),this._refreshAnimationFrame=null}syncScrollArea(S=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(S);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(S)}_handleScroll(S){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const b=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:b,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const S=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(S*(this._smoothScrollState.target-this._smoothScrollState.origin)),S<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(S,b){const v=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(b<0&&this._viewportElement.scrollTop!==0||b>0&&v<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const b=this._getPixelsScrolled(S);return b!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+b:this._smoothScrollState.target+=b,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=b,this._bubbleScroll(S,b))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const b=S*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+b,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:S,suppressScrollEvent:!1})}_getPixelsScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let b=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?b*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(b*=this._currentRowHeight*this._bufferService.rows),b}getBufferElements(S,b){var L;let v,E="";const j=[],T=b??this._bufferService.buffer.lines.length,D=this._bufferService.buffer.lines;for(let O=S;O<T;O++){const M=D.get(O);if(!M)continue;const W=(L=D.get(O+1))==null?void 0:L.isWrapped;if(E+=M.translateToString(!W),!W||O===D.length-1){const z=document.createElement("div");z.textContent=E,j.push(z),E.length>0&&(v=z),E=""}}return{bufferElements:j,cursorElement:v}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let b=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(b/=this._currentRowHeight+0,this._wheelPartialScroll+=b,b=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(b*=this._bufferService.rows),b}_applyScrollModifier(S,b){const v=this._optionsService.rawOptions.fastScrollModifier;return v==="alt"&&b.altKey||v==="ctrl"&&b.ctrlKey||v==="shift"&&b.shiftKey?S*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:S*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(S){this._lastTouchY=S.touches[0].pageY}handleTouchMove(S){const b=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,b!==0&&(this._viewportElement.scrollTop+=b,this._bubbleScroll(S,b))}};c.Viewport=_=f([p(2,C.IBufferService),p(3,C.IOptionsService),p(4,x.ICharSizeService),p(5,x.IRenderService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],_)},3107:function(u,c,d){var f=this&&this.__decorate||function(C,_,S,b){var v,E=arguments.length,j=E<3?_:b===null?b=Object.getOwnPropertyDescriptor(_,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(C,_,S,b);else for(var T=C.length-1;T>=0;T--)(v=C[T])&&(j=(E<3?v(j):E>3?v(_,S,j):v(_,S))||j);return E>3&&j&&Object.defineProperty(_,S,j),j},p=this&&this.__param||function(C,_){return function(S,b){_(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferDecorationRenderer=void 0;const m=d(4725),x=d(844),y=d(2585);let w=c.BufferDecorationRenderer=class extends x.Disposable{constructor(C,_,S,b,v){super(),this._screenElement=C,this._bufferService=_,this._coreBrowserService=S,this._decorationService=b,this._renderService=v,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((E=>this._removeDecoration(E)))),this.register((0,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const C of this._decorationService.decorations)this._renderDecoration(C);this._dimensionsChanged=!1}_renderDecoration(C){this._refreshStyle(C),this._dimensionsChanged&&this._refreshXPosition(C)}_createElement(C){var b;const _=this._coreBrowserService.mainDocument.createElement("div");_.classList.add("xterm-decoration"),_.classList.toggle("xterm-decoration-top-layer",((b=C==null?void 0:C.options)==null?void 0:b.layer)==="top"),_.style.width=`${Math.round((C.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,_.style.height=(C.options.height||1)*this._renderService.dimensions.css.cell.height+"px",_.style.top=(C.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",_.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=C.options.x??0;return S&&S>this._bufferService.cols&&(_.style.display="none"),this._refreshXPosition(C,_),_}_refreshStyle(C){const _=C.marker.line-this._bufferService.buffers.active.ydisp;if(_<0||_>=this._bufferService.rows)C.element&&(C.element.style.display="none",C.onRenderEmitter.fire(C.element));else{let S=this._decorationElements.get(C);S||(S=this._createElement(C),C.element=S,this._decorationElements.set(C,S),this._container.appendChild(S),C.onDispose((()=>{this._decorationElements.delete(C),S.remove()}))),S.style.top=_*this._renderService.dimensions.css.cell.height+"px",S.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(S)}}_refreshXPosition(C,_=C.element){if(!_)return;const S=C.options.x??0;(C.options.anchor||"left")==="right"?_.style.right=S?S*this._renderService.dimensions.css.cell.width+"px":"":_.style.left=S?S*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(C){var _;(_=this._decorationElements.get(C))==null||_.remove(),this._decorationElements.delete(C),C.dispose()}};c.BufferDecorationRenderer=w=f([p(1,y.IBufferService),p(2,m.ICoreBrowserService),p(3,y.IDecorationService),p(4,m.IRenderService)],w)},5871:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorZoneStore=void 0,c.ColorZoneStore=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(d){if(d.options.overviewRulerOptions){for(const f of this._zones)if(f.color===d.options.overviewRulerOptions.color&&f.position===d.options.overviewRulerOptions.position){if(this._lineIntersectsZone(f,d.marker.line))return;if(this._lineAdjacentToZone(f,d.marker.line,d.options.overviewRulerOptions.position))return void this._addLineToZone(f,d.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=d.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=d.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=d.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=d.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:d.options.overviewRulerOptions.color,position:d.options.overviewRulerOptions.position,startBufferLine:d.marker.line,endBufferLine:d.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(d){this._linePadding=d}_lineIntersectsZone(d,f){return f>=d.startBufferLine&&f<=d.endBufferLine}_lineAdjacentToZone(d,f,p){return f>=d.startBufferLine-this._linePadding[p||"full"]&&f<=d.endBufferLine+this._linePadding[p||"full"]}_addLineToZone(d,f){d.startBufferLine=Math.min(d.startBufferLine,f),d.endBufferLine=Math.max(d.endBufferLine,f)}}},5744:function(u,c,d){var f=this&&this.__decorate||function(v,E,j,T){var D,L=arguments.length,O=L<3?E:T===null?T=Object.getOwnPropertyDescriptor(E,j):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,E,j,T);else for(var M=v.length-1;M>=0;M--)(D=v[M])&&(O=(L<3?D(O):L>3?D(E,j,O):D(E,j))||O);return L>3&&O&&Object.defineProperty(E,j,O),O},p=this&&this.__param||function(v,E){return function(j,T){E(j,T,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OverviewRulerRenderer=void 0;const m=d(5871),x=d(4725),y=d(844),w=d(2585),C={full:0,left:0,center:0,right:0},_={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let b=c.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(v,E,j,T,D,L,O){var W;super(),this._viewportElement=v,this._screenElement=E,this._bufferService=j,this._decorationService=T,this._renderService=D,this._optionsService=L,this._coreBrowserService=O,this._colorZoneStore=new m.ColorZoneStore,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(),(W=this._viewportElement.parentElement)==null||W.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var z;(z=this._canvas)==null||z.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){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())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const v=Math.floor(this._canvas.width/3),E=Math.ceil(this._canvas.width/3);_.full=this._canvas.width,_.left=v,_.center=E,_.right=v,this._refreshDrawHeightConstants(),S.full=0,S.left=0,S.center=_.left,S.right=_.left+_.center}_refreshDrawHeightConstants(){C.full=Math.round(2*this._coreBrowserService.dpr);const v=this._canvas.height/this._bufferService.buffer.lines.length,E=Math.round(Math.max(Math.min(v,12),6)*this._coreBrowserService.dpr);C.left=E,C.center=E,C.right=E}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.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(const E of this._decorationService.decorations)this._colorZoneStore.addDecoration(E);this._ctx.lineWidth=1;const v=this._colorZoneStore.zones;for(const E of v)E.position!=="full"&&this._renderColorZone(E);for(const E of v)E.position==="full"&&this._renderColorZone(E);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(v){this._ctx.fillStyle=v.color,this._ctx.fillRect(S[v.position||"full"],Math.round((this._canvas.height-1)*(v.startBufferLine/this._bufferService.buffers.active.lines.length)-C[v.position||"full"]/2),_[v.position||"full"],Math.round((this._canvas.height-1)*((v.endBufferLine-v.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[v.position||"full"]))}_queueRefresh(v,E){this._shouldUpdateDimensions=v||this._shouldUpdateDimensions,this._shouldUpdateAnchor=E||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};c.OverviewRulerRenderer=b=f([p(2,w.IBufferService),p(3,w.IDecorationService),p(4,x.IRenderService),p(5,w.IOptionsService),p(6,x.ICoreBrowserService)],b)},2950:function(u,c,d){var f=this&&this.__decorate||function(C,_,S,b){var v,E=arguments.length,j=E<3?_:b===null?b=Object.getOwnPropertyDescriptor(_,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(C,_,S,b);else for(var T=C.length-1;T>=0;T--)(v=C[T])&&(j=(E<3?v(j):E>3?v(_,S,j):v(_,S))||j);return E>3&&j&&Object.defineProperty(_,S,j),j},p=this&&this.__param||function(C,_){return function(S,b){_(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CompositionHelper=void 0;const m=d(4725),x=d(2585),y=d(2584);let w=c.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,_,S,b,v,E){this._textarea=C,this._compositionView=_,this._bufferService=S,this._optionsService=b,this._coreService=v,this._renderService=E,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(C){this._compositionView.textContent=C.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(C){if(this._isComposing||this._isSendingComposition){if(C.keyCode===229||C.keyCode===16||C.keyCode===17||C.keyCode===18)return!1;this._finalizeComposition(!1)}return C.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(C){if(this._compositionView.classList.remove("active"),this._isComposing=!1,C){const _={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let S;this._isSendingComposition=!1,_.start+=this._dataAlreadySent.length,S=this._isComposing?this._textarea.value.substring(_.start,_.end):this._textarea.value.substring(_.start),S.length>0&&this._coreService.triggerDataEvent(S,!0)}}),0)}else{this._isSendingComposition=!1;const _=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(_,!0)}}_handleAnyTextareaChanges(){const C=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const _=this._textarea.value,S=_.replace(C,"");this._dataAlreadySent=S,_.length>C.length?this._coreService.triggerDataEvent(S,!0):_.length<C.length?this._coreService.triggerDataEvent(`${y.C0.DEL}`,!0):_.length===C.length&&_!==C&&this._coreService.triggerDataEvent(_,!0)}}),0)}updateCompositionElements(C){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const _=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),S=this._renderService.dimensions.css.cell.height,b=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,v=_*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=v+"px",this._compositionView.style.top=b+"px",this._compositionView.style.height=S+"px",this._compositionView.style.lineHeight=S+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const E=this._compositionView.getBoundingClientRect();this._textarea.style.left=v+"px",this._textarea.style.top=b+"px",this._textarea.style.width=Math.max(E.width,1)+"px",this._textarea.style.height=Math.max(E.height,1)+"px",this._textarea.style.lineHeight=E.height+"px"}C||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};c.CompositionHelper=w=f([p(2,x.IBufferService),p(3,x.IOptionsService),p(4,x.ICoreService),p(5,m.IRenderService)],w)},9806:(u,c)=>{function d(f,p,m){const x=m.getBoundingClientRect(),y=f.getComputedStyle(m),w=parseInt(y.getPropertyValue("padding-left")),C=parseInt(y.getPropertyValue("padding-top"));return[p.clientX-x.left-w,p.clientY-x.top-C]}Object.defineProperty(c,"__esModule",{value:!0}),c.getCoords=c.getCoordsRelativeToElement=void 0,c.getCoordsRelativeToElement=d,c.getCoords=function(f,p,m,x,y,w,C,_,S){if(!w)return;const b=d(f,p,m);return b?(b[0]=Math.ceil((b[0]+(S?C/2:0))/C),b[1]=Math.ceil(b[1]/_),b[0]=Math.min(Math.max(b[0],1),x+(S?1:0)),b[1]=Math.min(Math.max(b[1],1),y),b):void 0}},9504:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.moveToCellSequence=void 0;const f=d(2584);function p(_,S,b,v){const E=_-m(_,b),j=S-m(S,b),T=Math.abs(E-j)-(function(D,L,O){let M=0;const W=D-m(D,O),z=L-m(L,O);for(let R=0;R<Math.abs(W-z);R++){const P=x(D,L)==="A"?-1:1,V=O.buffer.lines.get(W+P*R);V!=null&&V.isWrapped&&M++}return M})(_,S,b);return C(T,w(x(_,S),v))}function m(_,S){let b=0,v=S.buffer.lines.get(_),E=v==null?void 0:v.isWrapped;for(;E&&_>=0&&_<S.rows;)b++,v=S.buffer.lines.get(--_),E=v==null?void 0:v.isWrapped;return b}function x(_,S){return _>S?"A":"B"}function y(_,S,b,v,E,j){let T=_,D=S,L="";for(;T!==b||D!==v;)T+=E?1:-1,E&&T>j.cols-1?(L+=j.buffer.translateBufferLineToString(D,!1,_,T),T=0,_=0,D++):!E&&T<0&&(L+=j.buffer.translateBufferLineToString(D,!1,0,_+1),T=j.cols-1,_=T,D--);return L+j.buffer.translateBufferLineToString(D,!1,_,T)}function w(_,S){const b=S?"O":"[";return f.C0.ESC+b+_}function C(_,S){_=Math.floor(_);let b="";for(let v=0;v<_;v++)b+=S;return b}c.moveToCellSequence=function(_,S,b,v){const E=b.buffer.x,j=b.buffer.y;if(!b.buffer.hasScrollback)return(function(L,O,M,W,z,R){return p(O,W,z,R).length===0?"":C(y(L,O,L,O-m(O,z),!1,z).length,w("D",R))})(E,j,0,S,b,v)+p(j,S,b,v)+(function(L,O,M,W,z,R){let P;P=p(O,W,z,R).length>0?W-m(W,z):O;const V=W,G=(function(Z,Q,U,I,$,q){let B;return B=p(U,I,$,q).length>0?I-m(I,$):Q,Z<U&&B<=I||Z>=U&&B<I?"C":"D"})(L,O,M,W,z,R);return C(y(L,P,M,V,G==="C",z).length,w(G,R))})(E,j,_,S,b,v);let T;if(j===S)return T=E>_?"D":"C",C(Math.abs(E-_),w(T,v));T=j>S?"D":"C";const D=Math.abs(j-S);return C((function(L,O){return O.cols-L})(j>S?_:E,b)+(D-1)*b.cols+1+((j>S?E:_)-1),w(T,v))}},1296:function(u,c,d){var f=this&&this.__decorate||function(R,P,V,G){var Z,Q=arguments.length,U=Q<3?P:G===null?G=Object.getOwnPropertyDescriptor(P,V):G;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(R,P,V,G);else for(var I=R.length-1;I>=0;I--)(Z=R[I])&&(U=(Q<3?Z(U):Q>3?Z(P,V,U):Z(P,V))||U);return Q>3&&U&&Object.defineProperty(P,V,U),U},p=this&&this.__param||function(R,P){return function(V,G){P(V,G,R)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRenderer=void 0;const m=d(3787),x=d(2550),y=d(2223),w=d(6171),C=d(6052),_=d(4725),S=d(8055),b=d(8460),v=d(844),E=d(2585),j="xterm-dom-renderer-owner-",T="xterm-rows",D="xterm-fg-",L="xterm-bg-",O="xterm-focus",M="xterm-selection";let W=1,z=c.DomRenderer=class extends v.Disposable{constructor(R,P,V,G,Z,Q,U,I,$,q,B,ee,X){super(),this._terminal=R,this._document=P,this._element=V,this._screenElement=G,this._viewportElement=Z,this._helperContainer=Q,this._linkifier2=U,this._charSizeService=$,this._optionsService=q,this._bufferService=B,this._coreBrowserService=ee,this._themeService=X,this._terminalClass=W++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new b.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(T),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(M),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((ne=>this._injectCss(ne)))),this._injectCss(this._themeService.colors),this._rowFactory=I.createInstance(m.DomRendererRowFactory,document),this._element.classList.add(j+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((ne=>this._handleLinkHover(ne)))),this.register(this._linkifier2.onHideLinkUnderline((ne=>this._handleLinkLeave(ne)))),this.register((0,v.toDisposable)((()=>{this._element.classList.remove(j+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new x.WidthCache(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(){const R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),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/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),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(const V of this._rowElements)V.style.width=`${this.dimensions.css.canvas.width}px`,V.style.height=`${this.dimensions.css.cell.height}px`,V.style.lineHeight=`${this.dimensions.css.cell.height}px`,V.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const P=`${this._terminalSelector} .${T} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=P,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(R){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let P=`${this._terminalSelector} .${T} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;P+=`${this._terminalSelector} .${T} .xterm-dim { color: ${S.color.multiplyOpacity(R.foreground,.5).css};}`,P+=`${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;}`;const V=`blink_underline_${this._terminalClass}`,G=`blink_bar_${this._terminalClass}`,Z=`blink_block_${this._terminalClass}`;P+=`@keyframes ${V} { 50% { border-bottom-style: hidden; }}`,P+=`@keyframes ${G} { 50% { box-shadow: none; }}`,P+=`@keyframes ${Z} { 0% { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,P+=`${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${G} 1s step-end infinite;}${this._terminalSelector} .${T}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Z} 1s step-end infinite;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${R.cursor.css} !important; color: ${R.cursorAccent.css} !important;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,P+=`${this._terminalSelector} .${M} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${M} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${M} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[Q,U]of R.ansi.entries())P+=`${this._terminalSelector} .${D}${Q} { color: ${U.css}; }${this._terminalSelector} .${D}${Q}.xterm-dim { color: ${S.color.multiplyOpacity(U,.5).css}; }${this._terminalSelector} .${L}${Q} { background-color: ${U.css}; }`;P+=`${this._terminalSelector} .${D}${y.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(R.background).css}; }${this._terminalSelector} .${D}${y.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${L}${y.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=P}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,P){for(let V=this._rowElements.length;V<=P;V++){const G=this._document.createElement("div");this._rowContainer.appendChild(G),this._rowElements.push(G)}for(;this._rowElements.length>P;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,P){this._refreshRowElements(R,P),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(O),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(O),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,P,V){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,P,V),this.renderRows(0,this._bufferService.rows-1),!R||!P)return;this._selectionRenderModel.update(this._terminal,R,P,V);const G=this._selectionRenderModel.viewportStartRow,Z=this._selectionRenderModel.viewportEndRow,Q=this._selectionRenderModel.viewportCappedStartRow,U=this._selectionRenderModel.viewportCappedEndRow;if(Q>=this._bufferService.rows||U<0)return;const I=this._document.createDocumentFragment();if(V){const $=R[0]>P[0];I.appendChild(this._createSelectionElement(Q,$?P[0]:R[0],$?R[0]:P[0],U-Q+1))}else{const $=G===Q?R[0]:0,q=Q===Z?P[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(Q,$,q));const B=U-Q-1;if(I.appendChild(this._createSelectionElement(Q+1,0,this._bufferService.cols,B)),Q!==U){const ee=Z===U?P[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(U,0,ee))}}this._selectionContainer.appendChild(I)}_createSelectionElement(R,P,V,G=1){const Z=this._document.createElement("div"),Q=P*this.dimensions.css.cell.width;let U=this.dimensions.css.cell.width*(V-P);return Q+U>this.dimensions.css.canvas.width&&(U=this.dimensions.css.canvas.width-Q),Z.style.height=G*this.dimensions.css.cell.height+"px",Z.style.top=R*this.dimensions.css.cell.height+"px",Z.style.left=`${Q}px`,Z.style.width=`${U}px`,Z}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(const R of this._rowElements)R.replaceChildren()}renderRows(R,P){const V=this._bufferService.buffer,G=V.ybase+V.y,Z=Math.min(V.x,this._bufferService.cols-1),Q=this._optionsService.rawOptions.cursorBlink,U=this._optionsService.rawOptions.cursorStyle,I=this._optionsService.rawOptions.cursorInactiveStyle;for(let $=R;$<=P;$++){const q=$+V.ydisp,B=this._rowElements[$],ee=V.lines.get(q);if(!B||!ee)break;B.replaceChildren(...this._rowFactory.createRow(ee,q,q===G,U,I,Z,Q,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${j}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,P,V,G,Z,Q){V<0&&(R=0),G<0&&(P=0);const U=this._bufferService.rows-1;V=Math.max(Math.min(V,U),0),G=Math.max(Math.min(G,U),0),Z=Math.min(Z,this._bufferService.cols);const I=this._bufferService.buffer,$=I.ybase+I.y,q=Math.min(I.x,Z-1),B=this._optionsService.rawOptions.cursorBlink,ee=this._optionsService.rawOptions.cursorStyle,X=this._optionsService.rawOptions.cursorInactiveStyle;for(let ne=V;ne<=G;++ne){const K=ne+I.ydisp,F=this._rowElements[ne],te=I.lines.get(K);if(!F||!te)break;F.replaceChildren(...this._rowFactory.createRow(te,K,K===$,ee,X,q,B,this.dimensions.css.cell.width,this._widthCache,Q?ne===V?R:0:-1,Q?(ne===G?P:Z)-1:-1))}}};c.DomRenderer=z=f([p(7,E.IInstantiationService),p(8,_.ICharSizeService),p(9,E.IOptionsService),p(10,E.IBufferService),p(11,_.ICoreBrowserService),p(12,_.IThemeService)],z)},3787:function(u,c,d){var f=this&&this.__decorate||function(T,D,L,O){var M,W=arguments.length,z=W<3?D:O===null?O=Object.getOwnPropertyDescriptor(D,L):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(T,D,L,O);else for(var R=T.length-1;R>=0;R--)(M=T[R])&&(z=(W<3?M(z):W>3?M(D,L,z):M(D,L))||z);return W>3&&z&&Object.defineProperty(D,L,z),z},p=this&&this.__param||function(T,D){return function(L,O){D(L,O,T)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRendererRowFactory=void 0;const m=d(2223),x=d(643),y=d(511),w=d(2585),C=d(8055),_=d(4725),S=d(4269),b=d(6171),v=d(3734);let E=c.DomRendererRowFactory=class{constructor(T,D,L,O,M,W,z){this._document=T,this._characterJoinerService=D,this._optionsService=L,this._coreBrowserService=O,this._coreService=M,this._decorationService=W,this._themeService=z,this._workCell=new y.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(T,D,L){this._selectionStart=T,this._selectionEnd=D,this._columnSelectMode=L}createRow(T,D,L,O,M,W,z,R,P,V,G){const Z=[],Q=this._characterJoinerService.getJoinedCharacters(D),U=this._themeService.colors;let I,$=T.getNoBgTrimmedLength();L&&$<W+1&&($=W+1);let q=0,B="",ee=0,X=0,ne=0,K=!1,F=0,te=!1,se=0;const xe=[],oe=V!==-1&&G!==-1;for(let ye=0;ye<$;ye++){T.loadCell(ye,this._workCell);let Le=this._workCell.getWidth();if(Le===0)continue;let Oe=!1,Me=ye,je=this._workCell;if(Q.length>0&&ye===Q[0][0]){Oe=!0;const tt=Q.shift();je=new S.JoinedCellData(this._workCell,T.translateToString(!0,tt[0],tt[1]),tt[1]-tt[0]),Me=tt[1]-1,Le=je.getWidth()}const nt=this._isCellInSelection(ye,D),Xe=L&&ye===W,he=oe&&ye>=V&&ye<=G;let ce=!1;this._decorationService.forEachDecorationAtCell(ye,D,void 0,(tt=>{ce=!0}));let de=je.getChars()||x.WHITESPACE_CELL_CHAR;if(de===" "&&(je.isUnderline()||je.isOverline())&&(de=" "),se=Le*R-P.get(de,je.isBold(),je.isItalic()),I){if(q&&(nt&&te||!nt&&!te&&je.bg===ee)&&(nt&&te&&U.selectionForeground||je.fg===X)&&je.extended.ext===ne&&he===K&&se===F&&!Xe&&!Oe&&!ce){je.isInvisible()?B+=x.WHITESPACE_CELL_CHAR:B+=de,q++;continue}q&&(I.textContent=B),I=this._document.createElement("span"),q=0,B=""}else I=this._document.createElement("span");if(ee=je.bg,X=je.fg,ne=je.extended.ext,K=he,F=se,te=nt,Oe&&W>=ye&&W<=Me&&(W=ye),!this._coreService.isCursorHidden&&Xe&&this._coreService.isCursorInitialized){if(xe.push("xterm-cursor"),this._coreBrowserService.isFocused)z&&xe.push("xterm-cursor-blink"),xe.push(O==="bar"?"xterm-cursor-bar":O==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(M)switch(M){case"outline":xe.push("xterm-cursor-outline");break;case"block":xe.push("xterm-cursor-block");break;case"bar":xe.push("xterm-cursor-bar");break;case"underline":xe.push("xterm-cursor-underline")}}if(je.isBold()&&xe.push("xterm-bold"),je.isItalic()&&xe.push("xterm-italic"),je.isDim()&&xe.push("xterm-dim"),B=je.isInvisible()?x.WHITESPACE_CELL_CHAR:je.getChars()||x.WHITESPACE_CELL_CHAR,je.isUnderline()&&(xe.push(`xterm-underline-${je.extended.underlineStyle}`),B===" "&&(B=" "),!je.isUnderlineColorDefault()))if(je.isUnderlineColorRGB())I.style.textDecorationColor=`rgb(${v.AttributeData.toColorRGB(je.getUnderlineColor()).join(",")})`;else{let tt=je.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&je.isBold()&&tt<8&&(tt+=8),I.style.textDecorationColor=U.ansi[tt].css}je.isOverline()&&(xe.push("xterm-overline"),B===" "&&(B=" ")),je.isStrikethrough()&&xe.push("xterm-strikethrough"),he&&(I.style.textDecoration="underline");let $e=je.getFgColor(),He=je.getFgColorMode(),ut=je.getBgColor(),re=je.getBgColorMode();const be=!!je.isInverse();if(be){const tt=$e;$e=ut,ut=tt;const _t=He;He=re,re=_t}let ke,ze,Ye,We=!1;switch(this._decorationService.forEachDecorationAtCell(ye,D,void 0,(tt=>{tt.options.layer!=="top"&&We||(tt.backgroundColorRGB&&(re=50331648,ut=tt.backgroundColorRGB.rgba>>8&16777215,ke=tt.backgroundColorRGB),tt.foregroundColorRGB&&(He=50331648,$e=tt.foregroundColorRGB.rgba>>8&16777215,ze=tt.foregroundColorRGB),We=tt.options.layer==="top")})),!We&&nt&&(ke=this._coreBrowserService.isFocused?U.selectionBackgroundOpaque:U.selectionInactiveBackgroundOpaque,ut=ke.rgba>>8&16777215,re=50331648,We=!0,U.selectionForeground&&(He=50331648,$e=U.selectionForeground.rgba>>8&16777215,ze=U.selectionForeground)),We&&xe.push("xterm-decoration-top"),re){case 16777216:case 33554432:Ye=U.ansi[ut],xe.push(`xterm-bg-${ut}`);break;case 50331648:Ye=C.channels.toColor(ut>>16,ut>>8&255,255&ut),this._addStyle(I,`background-color:#${j((ut>>>0).toString(16),"0",6)}`);break;default:be?(Ye=U.foreground,xe.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):Ye=U.background}switch(ke||je.isDim()&&(ke=C.color.multiplyOpacity(Ye,.5)),He){case 16777216:case 33554432:je.isBold()&&$e<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&($e+=8),this._applyMinimumContrast(I,Ye,U.ansi[$e],je,ke,void 0)||xe.push(`xterm-fg-${$e}`);break;case 50331648:const tt=C.channels.toColor($e>>16&255,$e>>8&255,255&$e);this._applyMinimumContrast(I,Ye,tt,je,ke,ze)||this._addStyle(I,`color:#${j($e.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(I,Ye,U.foreground,je,ke,ze)||be&&xe.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}xe.length&&(I.className=xe.join(" "),xe.length=0),Xe||Oe||ce?I.textContent=B:q++,se!==this.defaultSpacing&&(I.style.letterSpacing=`${se}px`),Z.push(I),ye=Me}return I&&q&&(I.textContent=B),Z}_applyMinimumContrast(T,D,L,O,M,W){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,b.treatGlyphAsBackgroundColor)(O.getCode()))return!1;const z=this._getContrastCache(O);let R;if(M||W||(R=z.getColor(D.rgba,L.rgba)),R===void 0){const P=this._optionsService.rawOptions.minimumContrastRatio/(O.isDim()?2:1);R=C.color.ensureContrastRatio(M||D,W||L,P),z.setColor((M||D).rgba,(W||L).rgba,R??null)}return!!R&&(this._addStyle(T,`color:${R.css}`),!0)}_getContrastCache(T){return T.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(T,D){T.setAttribute("style",`${T.getAttribute("style")||""}${D};`)}_isCellInSelection(T,D){const L=this._selectionStart,O=this._selectionEnd;return!(!L||!O)&&(this._columnSelectMode?L[0]<=O[0]?T>=L[0]&&D>=L[1]&&T<O[0]&&D<=O[1]:T<L[0]&&D>=L[1]&&T>=O[0]&&D<=O[1]:D>L[1]&&D<O[1]||L[1]===O[1]&&D===L[1]&&T>=L[0]&&T<O[0]||L[1]<O[1]&&D===O[1]&&T<O[0]||L[1]<O[1]&&D===L[1]&&T>=L[0])}};function j(T,D,L){for(;T.length<L;)T=D+T;return T}c.DomRendererRowFactory=E=f([p(1,_.ICharacterJoinerService),p(2,w.IOptionsService),p(3,_.ICoreBrowserService),p(4,w.ICoreService),p(5,w.IDecorationService),p(6,_.IThemeService)],E)},2550:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WidthCache=void 0,c.WidthCache=class{constructor(d,f){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=d.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";const p=d.createElement("span");p.classList.add("xterm-char-measure-element");const m=d.createElement("span");m.classList.add("xterm-char-measure-element"),m.style.fontWeight="bold";const x=d.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontStyle="italic";const y=d.createElement("span");y.classList.add("xterm-char-measure-element"),y.style.fontWeight="bold",y.style.fontStyle="italic",this._measureElements=[p,m,x,y],this._container.appendChild(p),this._container.appendChild(m),this._container.appendChild(x),this._container.appendChild(y),f.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(d,f,p,m){d===this._font&&f===this._fontSize&&p===this._weight&&m===this._weightBold||(this._font=d,this._fontSize=f,this._weight=p,this._weightBold=m,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${p}`,this._measureElements[1].style.fontWeight=`${m}`,this._measureElements[2].style.fontWeight=`${p}`,this._measureElements[3].style.fontWeight=`${m}`,this.clear())}get(d,f,p){let m=0;if(!f&&!p&&d.length===1&&(m=d.charCodeAt(0))<256){if(this._flat[m]!==-9999)return this._flat[m];const w=this._measure(d,0);return w>0&&(this._flat[m]=w),w}let x=d;f&&(x+="B"),p&&(x+="I");let y=this._holey.get(x);if(y===void 0){let w=0;f&&(w|=1),p&&(w|=2),y=this._measure(d,w),y>0&&this._holey.set(x,y)}return y}_measure(d,f){const p=this._measureElements[f];return p.textContent=d.repeat(32),p.offsetWidth/32}}},2223:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TEXT_BASELINE=c.DIM_OPACITY=c.INVERTED_DEFAULT_COLOR=void 0;const f=d(6114);c.INVERTED_DEFAULT_COLOR=257,c.DIM_OPACITY=.5,c.TEXT_BASELINE=f.isFirefox||f.isLegacyEdge?"bottom":"ideographic"},6171:(u,c)=>{function d(p){return 57508<=p&&p<=57558}function f(p){return p>=128512&&p<=128591||p>=127744&&p<=128511||p>=128640&&p<=128767||p>=9728&&p<=9983||p>=9984&&p<=10175||p>=65024&&p<=65039||p>=129280&&p<=129535||p>=127462&&p<=127487}Object.defineProperty(c,"__esModule",{value:!0}),c.computeNextVariantOffset=c.createRenderDimensions=c.treatGlyphAsBackgroundColor=c.allowRescaling=c.isEmoji=c.isRestrictedPowerlineGlyph=c.isPowerlineGlyph=c.throwIfFalsy=void 0,c.throwIfFalsy=function(p){if(!p)throw new Error("value must not be falsy");return p},c.isPowerlineGlyph=d,c.isRestrictedPowerlineGlyph=function(p){return 57520<=p&&p<=57527},c.isEmoji=f,c.allowRescaling=function(p,m,x,y){return m===1&&x>Math.ceil(1.5*y)&&p!==void 0&&p>255&&!f(p)&&!d(p)&&!(function(w){return 57344<=w&&w<=63743})(p)},c.treatGlyphAsBackgroundColor=function(p){return d(p)||(function(m){return 9472<=m&&m<=9631})(p)},c.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},c.computeNextVariantOffset=function(p,m,x=0){return(p-(2*Math.round(m)-x))%(2*Math.round(m))}},6052:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createSelectionRenderModel=void 0;class d{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(p,m,x,y=!1){if(this.selectionStart=m,this.selectionEnd=x,!m||!x||m[0]===x[0]&&m[1]===x[1])return void this.clear();const w=p.buffers.active.ydisp,C=m[1]-w,_=x[1]-w,S=Math.max(C,0),b=Math.min(_,p.rows-1);S>=p.rows||b<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=y,this.viewportStartRow=C,this.viewportEndRow=_,this.viewportCappedStartRow=S,this.viewportCappedEndRow=b,this.startCol=m[0],this.endCol=x[0])}isCellSelected(p,m,x){return!!this.hasSelection&&(x-=p.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?m>=this.startCol&&x>=this.viewportCappedStartRow&&m<this.endCol&&x<=this.viewportCappedEndRow:m<this.startCol&&x>=this.viewportCappedStartRow&&m>=this.endCol&&x<=this.viewportCappedEndRow:x>this.viewportStartRow&&x<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&x===this.viewportStartRow&&m>=this.startCol&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&x===this.viewportEndRow&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&x===this.viewportStartRow&&m>=this.startCol)}}c.createSelectionRenderModel=function(){return new d}},456:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionModel=void 0,c.SelectionModel=class{constructor(d){this._bufferService=d,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.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()){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?d%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)-1]:[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[d,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[Math.max(d,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const d=this.selectionStart,f=this.selectionEnd;return!(!d||!f)&&(d[1]>f[1]||d[1]===f[1]&&d[0]>f[0])}handleTrim(d){return this.selectionStart&&(this.selectionStart[1]-=d),this.selectionEnd&&(this.selectionEnd[1]-=d),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(u,c,d){var f=this&&this.__decorate||function(b,v,E,j){var T,D=arguments.length,L=D<3?v:j===null?j=Object.getOwnPropertyDescriptor(v,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,v,E,j);else for(var O=b.length-1;O>=0;O--)(T=b[O])&&(L=(D<3?T(L):D>3?T(v,E,L):T(v,E))||L);return D>3&&L&&Object.defineProperty(v,E,L),L},p=this&&this.__param||function(b,v){return function(E,j){v(E,j,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharSizeService=void 0;const m=d(2585),x=d(8460),y=d(844);let w=c.CharSizeService=class extends y.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(b,v,E){super(),this._optionsService=E,this.width=0,this.height=0,this._onCharSizeChange=this.register(new x.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new S(this._optionsService))}catch{this._measureStrategy=this.register(new _(b,v,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const b=this._measureStrategy.measure();b.width===this.width&&b.height===this.height||(this.width=b.width,this.height=b.height,this._onCharSizeChange.fire())}};c.CharSizeService=w=f([p(2,m.IOptionsService)],w);class C extends y.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(v,E){v!==void 0&&v>0&&E!==void 0&&E>0&&(this._result.width=v,this._result.height=E)}}class _ extends C{constructor(v,E,j){super(),this._document=v,this._parentElement=E,this._optionsService=j,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}}class S extends C{constructor(v){super(),this._optionsService=v,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const E=this._ctx.measureText("W");if(!("width"in E&&"fontBoundingBoxAscent"in E&&"fontBoundingBoxDescent"in E))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const v=this._ctx.measureText("W");return this._validateAndSet(v.width,v.fontBoundingBoxAscent+v.fontBoundingBoxDescent),this._result}}},4269:function(u,c,d){var f=this&&this.__decorate||function(S,b,v,E){var j,T=arguments.length,D=T<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,v):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(S,b,v,E);else for(var L=S.length-1;L>=0;L--)(j=S[L])&&(D=(T<3?j(D):T>3?j(b,v,D):j(b,v))||D);return T>3&&D&&Object.defineProperty(b,v,D),D},p=this&&this.__param||function(S,b){return function(v,E){b(v,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharacterJoinerService=c.JoinedCellData=void 0;const m=d(3734),x=d(643),y=d(511),w=d(2585);class C extends m.AttributeData{constructor(b,v,E){super(),this.content=0,this.combinedData="",this.fg=b.fg,this.bg=b.bg,this.combinedData=v,this._width=E}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(b){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.JoinedCellData=C;let _=c.CharacterJoinerService=class ck{constructor(b){this._bufferService=b,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new y.CellData}register(b){const v={id:this._nextCharacterJoinerId++,handler:b};return this._characterJoiners.push(v),v.id}deregister(b){for(let v=0;v<this._characterJoiners.length;v++)if(this._characterJoiners[v].id===b)return this._characterJoiners.splice(v,1),!0;return!1}getJoinedCharacters(b){if(this._characterJoiners.length===0)return[];const v=this._bufferService.buffer.lines.get(b);if(!v||v.length===0)return[];const E=[],j=v.translateToString(!0);let T=0,D=0,L=0,O=v.getFg(0),M=v.getBg(0);for(let W=0;W<v.getTrimmedLength();W++)if(v.loadCell(W,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==O||this._workCell.bg!==M){if(W-T>1){const z=this._getJoinedRanges(j,L,D,v,T);for(let R=0;R<z.length;R++)E.push(z[R])}T=W,L=D,O=this._workCell.fg,M=this._workCell.bg}D+=this._workCell.getChars().length||x.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-T>1){const W=this._getJoinedRanges(j,L,D,v,T);for(let z=0;z<W.length;z++)E.push(W[z])}return E}_getJoinedRanges(b,v,E,j,T){const D=b.substring(v,E);let L=[];try{L=this._characterJoiners[0].handler(D)}catch(O){console.error(O)}for(let O=1;O<this._characterJoiners.length;O++)try{const M=this._characterJoiners[O].handler(D);for(let W=0;W<M.length;W++)ck._mergeRanges(L,M[W])}catch(M){console.error(M)}return this._stringRangesToCellRanges(L,j,T),L}_stringRangesToCellRanges(b,v,E){let j=0,T=!1,D=0,L=b[j];if(L){for(let O=E;O<this._bufferService.cols;O++){const M=v.getWidth(O),W=v.getString(O).length||x.WHITESPACE_CELL_CHAR.length;if(M!==0){if(!T&&L[0]<=D&&(L[0]=O,T=!0),L[1]<=D){if(L[1]=O,L=b[++j],!L)break;L[0]<=D?(L[0]=O,T=!0):T=!1}D+=W}}L&&(L[1]=this._bufferService.cols)}}static _mergeRanges(b,v){let E=!1;for(let j=0;j<b.length;j++){const T=b[j];if(E){if(v[1]<=T[0])return b[j-1][1]=v[1],b;if(v[1]<=T[1])return b[j-1][1]=Math.max(v[1],T[1]),b.splice(j,1),b;b.splice(j,1),j--}else{if(v[1]<=T[0])return b.splice(j,0,v),b;if(v[1]<=T[1])return T[0]=Math.min(v[0],T[0]),b;v[0]<T[1]&&(T[0]=Math.min(v[0],T[0]),E=!0)}}return E?b[b.length-1][1]=v[1]:b.push(v),b}};c.CharacterJoinerService=_=f([p(0,w.IBufferService)],_)},5114:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreBrowserService=void 0;const f=d(844),p=d(8460),m=d(3656);class x extends f.Disposable{constructor(C,_,S){super(),this._textarea=C,this._window=_,this.mainDocument=S,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new y(this._window),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new p.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((b=>this._screenDprMonitor.setWindow(b)))),this.register((0,p.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(C){this._window!==C&&(this._window=C,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}}c.CoreBrowserService=x;class y extends f.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new f.MutableDisposable),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,f.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,m.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.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)}}},779:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.LinkProviderService=void 0;const f=d(844);class p extends f.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,f.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(x){return this.linkProviders.push(x),{dispose:()=>{const y=this.linkProviders.indexOf(x);y!==-1&&this.linkProviders.splice(y,1)}}}}c.LinkProviderService=p},8934:function(u,c,d){var f=this&&this.__decorate||function(w,C,_,S){var b,v=arguments.length,E=v<3?C:S===null?S=Object.getOwnPropertyDescriptor(C,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(w,C,_,S);else for(var j=w.length-1;j>=0;j--)(b=w[j])&&(E=(v<3?b(E):v>3?b(C,_,E):b(C,_))||E);return v>3&&E&&Object.defineProperty(C,_,E),E},p=this&&this.__param||function(w,C){return function(_,S){C(_,S,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.MouseService=void 0;const m=d(4725),x=d(9806);let y=c.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,_,S,b){return(0,x.getCoords)(window,w,C,_,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,b)}getMouseReportCoords(w,C){const _=(0,x.getCoordsRelativeToElement)(window,w,C);if(this._charSizeService.hasValidSize)return _[0]=Math.min(Math.max(_[0],0),this._renderService.dimensions.css.canvas.width-1),_[1]=Math.min(Math.max(_[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(_[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(_[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(_[0]),y:Math.floor(_[1])}}};c.MouseService=y=f([p(0,m.IRenderService),p(1,m.ICharSizeService)],y)},3230:function(u,c,d){var f=this&&this.__decorate||function(b,v,E,j){var T,D=arguments.length,L=D<3?v:j===null?j=Object.getOwnPropertyDescriptor(v,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,v,E,j);else for(var O=b.length-1;O>=0;O--)(T=b[O])&&(L=(D<3?T(L):D>3?T(v,E,L):T(v,E))||L);return D>3&&L&&Object.defineProperty(v,E,L),L},p=this&&this.__param||function(b,v){return function(E,j){v(E,j,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.RenderService=void 0;const m=d(6193),x=d(4725),y=d(8460),w=d(844),C=d(7226),_=d(2585);let S=c.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,v,E,j,T,D,L,O){super(),this._rowCount=b,this._charSizeService=j,this._renderer=this.register(new w.MutableDisposable),this._pausedResizeTask=new C.DebouncedIdleTask,this._observerDisposable=this.register(new w.MutableDisposable),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 y.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new y.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new y.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer(((M,W)=>this._renderRows(M,W)),L),this.register(this._renderDebouncer),this.register(L.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(D.onResize((()=>this._fullRefresh()))),this.register(D.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)==null?void 0:M.clear()}))),this.register(E.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(T.onDecorationRegistered((()=>this._fullRefresh()))),this.register(T.onDecorationRemoved((()=>this._fullRefresh()))),this.register(E.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(D.cols,D.rows),this._fullRefresh()}))),this.register(E.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(D.buffer.y,D.buffer.y,!0)))),this.register(O.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(L.window,v),this.register(L.onWindowChange((M=>this._registerIntersectionObserver(M,v))))}_registerIntersectionObserver(b,v){if("IntersectionObserver"in b){const E=new b.IntersectionObserver((j=>this._handleIntersectionChange(j[j.length-1])),{threshold:0});E.observe(v),this._observerDisposable.value=(0,w.toDisposable)((()=>E.disconnect()))}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.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(b,v,E=!1){this._isPaused?this._needsFullRefresh=!0:(E||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,v,this._rowCount))}_renderRows(b,v){this._renderer.value&&(b=Math.min(b,this._rowCount-1),v=Math.min(v,this._rowCount-1),this._renderer.value.renderRows(b,v),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:v}),this._onRender.fire({start:b,end:v}),this._isNextRenderRedrawOnly=!0)}resize(b,v){this._rowCount=v,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(b){this._renderer.value=b,this._renderer.value&&(this._renderer.value.onRequestRedraw((v=>this.refreshRows(v.start,v.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,v;this._renderer.value&&((v=(b=this._renderer.value).clearTextureAtlas)==null||v.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,v){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var E;return(E=this._renderer.value)==null?void 0:E.handleResize(b,v)})):this._renderer.value.handleResize(b,v),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)==null||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)==null||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)==null||b.handleFocus()}handleSelectionChanged(b,v,E){var j;this._selectionState.start=b,this._selectionState.end=v,this._selectionState.columnSelectMode=E,(j=this._renderer.value)==null||j.handleSelectionChanged(b,v,E)}handleCursorMove(){var b;(b=this._renderer.value)==null||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)==null||b.clear()}};c.RenderService=S=f([p(2,_.IOptionsService),p(3,x.ICharSizeService),p(4,_.IDecorationService),p(5,_.IBufferService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],S)},9312:function(u,c,d){var f=this&&this.__decorate||function(L,O,M,W){var z,R=arguments.length,P=R<3?O:W===null?W=Object.getOwnPropertyDescriptor(O,M):W;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(L,O,M,W);else for(var V=L.length-1;V>=0;V--)(z=L[V])&&(P=(R<3?z(P):R>3?z(O,M,P):z(O,M))||P);return R>3&&P&&Object.defineProperty(O,M,P),P},p=this&&this.__param||function(L,O){return function(M,W){O(M,W,L)}};Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionService=void 0;const m=d(9806),x=d(9504),y=d(456),w=d(4725),C=d(8460),_=d(844),S=d(6114),b=d(4841),v=d(511),E=d(2585),j=" ",T=new RegExp(j,"g");let D=c.SelectionService=class extends _.Disposable{constructor(L,O,M,W,z,R,P,V,G){super(),this._element=L,this._screenElement=O,this._linkifier=M,this._bufferService=W,this._coreService=z,this._mouseService=R,this._optionsService=P,this._renderService=V,this._coreBrowserService=G,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new v.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new C.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new C.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new C.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=Z=>this._handleMouseMove(Z),this._mouseUpListener=Z=>this._handleMouseUp(Z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((Z=>this._handleTrim(Z))),this.register(this._bufferService.buffers.onBufferActivate((Z=>this._handleBufferActivate(Z)))),this.enable(),this._model=new y.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,_.toDisposable)((()=>{this._removeMouseDownListeners()})))}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(){const L=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;return!(!L||!O||L[0]===O[0]&&L[1]===O[1])}get selectionText(){const L=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;if(!L||!O)return"";const M=this._bufferService.buffer,W=[];if(this._activeSelectionMode===3){if(L[0]===O[0])return"";const z=L[0]<O[0]?L[0]:O[0],R=L[0]<O[0]?O[0]:L[0];for(let P=L[1];P<=O[1];P++){const V=M.translateBufferLineToString(P,!0,z,R);W.push(V)}}else{const z=L[1]===O[1]?O[0]:void 0;W.push(M.translateBufferLineToString(L[1],!0,L[0],z));for(let R=L[1]+1;R<=O[1]-1;R++){const P=M.lines.get(R),V=M.translateBufferLineToString(R,!0);P!=null&&P.isWrapped?W[W.length-1]+=V:W.push(V)}if(L[1]!==O[1]){const R=M.lines.get(O[1]),P=M.translateBufferLineToString(O[1],!0,0,O[0]);R&&R.isWrapped?W[W.length-1]+=P:W.push(P)}}return W.map((z=>z.replace(T," "))).join(S.isWindows?`\r
|
|
250
|
+
`:`
|
|
251
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(L){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),S.isLinux&&L&&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(L){const O=this._getMouseBufferCoords(L),M=this._model.finalSelectionStart,W=this._model.finalSelectionEnd;return!!(M&&W&&O)&&this._areCoordsInSelection(O,M,W)}isCellInSelection(L,O){const M=this._model.finalSelectionStart,W=this._model.finalSelectionEnd;return!(!M||!W)&&this._areCoordsInSelection([L,O],M,W)}_areCoordsInSelection(L,O,M){return L[1]>O[1]&&L[1]<M[1]||O[1]===M[1]&&L[1]===O[1]&&L[0]>=O[0]&&L[0]<M[0]||O[1]<M[1]&&L[1]===M[1]&&L[0]<M[0]||O[1]<M[1]&&L[1]===O[1]&&L[0]>=O[0]}_selectWordAtCursor(L,O){var z,R;const M=(R=(z=this._linkifier.currentLink)==null?void 0:z.link)==null?void 0:R.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,b.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const W=this._getMouseBufferCoords(L);return!!W&&(this._selectWordAt(W,O),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(L,O){this._model.clearSelection(),L=Math.max(L,0),O=Math.min(O,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,L],this._model.selectionEnd=[this._bufferService.cols,O],this.refresh(),this._onSelectionChange.fire()}_handleTrim(L){this._model.handleTrim(L)&&this.refresh()}_getMouseBufferCoords(L){const O=this._mouseService.getCoords(L,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(O)return O[0]--,O[1]--,O[1]+=this._bufferService.buffer.ydisp,O}_getMouseEventScrollAmount(L){let O=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,L,this._screenElement)[1];const M=this._renderService.dimensions.css.canvas.height;return O>=0&&O<=M?0:(O>M&&(O-=M),O=Math.min(Math.max(O,-50),50),O/=50,O/Math.abs(O)+Math.round(14*O))}shouldForceSelection(L){return S.isMac?L.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:L.shiftKey}handleMouseDown(L){if(this._mouseDownTimeStamp=L.timeStamp,(L.button!==2||!this.hasSelection)&&L.button===0){if(!this._enabled){if(!this.shouldForceSelection(L))return;L.stopPropagation()}L.preventDefault(),this._dragScrollAmount=0,this._enabled&&L.shiftKey?this._handleIncrementalClick(L):L.detail===1?this._handleSingleClick(L):L.detail===2?this._handleDoubleClick(L):L.detail===3&&this._handleTripleClick(L),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()),50)}_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(L){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(L))}_handleSingleClick(L){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(L)?3:0,this._model.selectionStart=this._getMouseBufferCoords(L),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const O=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);O&&O.length!==this._model.selectionStart[0]&&O.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(L){this._selectWordAtCursor(L,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(L){const O=this._getMouseBufferCoords(L);O&&(this._activeSelectionMode=2,this._selectLineAt(O[1]))}shouldColumnSelect(L){return L.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(L){if(L.stopImmediatePropagation(),!this._model.selectionStart)return;const O=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(L),!this._model.selectionEnd)return void this.refresh(!0);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(L),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const M=this._bufferService.buffer;if(this._model.selectionEnd[1]<M.lines.length){const W=M.lines.get(this._model.selectionEnd[1]);W&&W.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}O&&O[0]===this._model.selectionEnd[0]&&O[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});const L=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(L.ydisp+this._bufferService.rows,L.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=L.ydisp),this.refresh()}}_handleMouseUp(L){const O=L.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&O<500&&L.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const M=this._mouseService.getCoords(L,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(M&&M[0]!==void 0&&M[1]!==void 0){const W=(0,x.moveToCellSequence)(M[0]-1,M[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(W,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const L=this._model.finalSelectionStart,O=this._model.finalSelectionEnd,M=!(!L||!O||L[0]===O[0]&&L[1]===O[1]);M?L&&O&&(this._oldSelectionStart&&this._oldSelectionEnd&&L[0]===this._oldSelectionStart[0]&&L[1]===this._oldSelectionStart[1]&&O[0]===this._oldSelectionEnd[0]&&O[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(L,O,M)):this._oldHasSelection&&this._fireOnSelectionChange(L,O,M)}_fireOnSelectionChange(L,O,M){this._oldSelectionStart=L,this._oldSelectionEnd=O,this._oldHasSelection=M,this._onSelectionChange.fire()}_handleBufferActivate(L){this.clearSelection(),this._trimListener.dispose(),this._trimListener=L.activeBuffer.lines.onTrim((O=>this._handleTrim(O)))}_convertViewportColToCharacterIndex(L,O){let M=O;for(let W=0;O>=W;W++){const z=L.loadCell(W,this._workCell).getChars().length;this._workCell.getWidth()===0?M--:z>1&&O!==W&&(M+=z-1)}return M}setSelection(L,O,M){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[L,O],this._model.selectionStartLength=M,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(L){this._isClickInSelection(L)||(this._selectWordAtCursor(L,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(L,O,M=!0,W=!0){if(L[0]>=this._bufferService.cols)return;const z=this._bufferService.buffer,R=z.lines.get(L[1]);if(!R)return;const P=z.translateBufferLineToString(L[1],!1);let V=this._convertViewportColToCharacterIndex(R,L[0]),G=V;const Z=L[0]-V;let Q=0,U=0,I=0,$=0;if(P.charAt(V)===" "){for(;V>0&&P.charAt(V-1)===" ";)V--;for(;G<P.length&&P.charAt(G+1)===" ";)G++}else{let ee=L[0],X=L[0];R.getWidth(ee)===0&&(Q++,ee--),R.getWidth(X)===2&&(U++,X++);const ne=R.getString(X).length;for(ne>1&&($+=ne-1,G+=ne-1);ee>0&&V>0&&!this._isCharWordSeparator(R.loadCell(ee-1,this._workCell));){R.loadCell(ee-1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===0?(Q++,ee--):K>1&&(I+=K-1,V-=K-1),V--,ee--}for(;X<R.length&&G+1<P.length&&!this._isCharWordSeparator(R.loadCell(X+1,this._workCell));){R.loadCell(X+1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===2?(U++,X++):K>1&&($+=K-1,G+=K-1),G++,X++}}G++;let q=V+Z-Q+I,B=Math.min(this._bufferService.cols,G-V+Q+U-I-$);if(O||P.slice(V,G).trim()!==""){if(M&&q===0&&R.getCodePoint(0)!==32){const ee=z.lines.get(L[1]-1);if(ee&&R.isWrapped&&ee.getCodePoint(this._bufferService.cols-1)!==32){const X=this._getWordAt([this._bufferService.cols-1,L[1]-1],!1,!0,!1);if(X){const ne=this._bufferService.cols-X.start;q-=ne,B+=ne}}}if(W&&q+B===this._bufferService.cols&&R.getCodePoint(this._bufferService.cols-1)!==32){const ee=z.lines.get(L[1]+1);if(ee!=null&&ee.isWrapped&&ee.getCodePoint(0)!==32){const X=this._getWordAt([0,L[1]+1],!1,!1,!0);X&&(B+=X.length)}}return{start:q,length:B}}}_selectWordAt(L,O){const M=this._getWordAt(L,O);if(M){for(;M.start<0;)M.start+=this._bufferService.cols,L[1]--;this._model.selectionStart=[M.start,L[1]],this._model.selectionStartLength=M.length}}_selectToWordAt(L){const O=this._getWordAt(L,!0);if(O){let M=L[1];for(;O.start<0;)O.start+=this._bufferService.cols,M--;if(!this._model.areSelectionValuesReversed())for(;O.start+O.length>this._bufferService.cols;)O.length-=this._bufferService.cols,M++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?O.start:O.start+O.length,M]}}_isCharWordSeparator(L){return L.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(L.getChars())>=0}_selectLineAt(L){const O=this._bufferService.buffer.getWrappedRangeForLine(L),M={start:{x:0,y:O.first},end:{x:this._bufferService.cols-1,y:O.last}};this._model.selectionStart=[0,O.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,b.getRangeLength)(M,this._bufferService.cols)}};c.SelectionService=D=f([p(3,E.IBufferService),p(4,E.ICoreService),p(5,w.IMouseService),p(6,E.IOptionsService),p(7,w.IRenderService),p(8,w.ICoreBrowserService)],D)},4725:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ILinkProviderService=c.IThemeService=c.ICharacterJoinerService=c.ISelectionService=c.IRenderService=c.IMouseService=c.ICoreBrowserService=c.ICharSizeService=void 0;const f=d(8343);c.ICharSizeService=(0,f.createDecorator)("CharSizeService"),c.ICoreBrowserService=(0,f.createDecorator)("CoreBrowserService"),c.IMouseService=(0,f.createDecorator)("MouseService"),c.IRenderService=(0,f.createDecorator)("RenderService"),c.ISelectionService=(0,f.createDecorator)("SelectionService"),c.ICharacterJoinerService=(0,f.createDecorator)("CharacterJoinerService"),c.IThemeService=(0,f.createDecorator)("ThemeService"),c.ILinkProviderService=(0,f.createDecorator)("LinkProviderService")},6731:function(u,c,d){var f=this&&this.__decorate||function(D,L,O,M){var W,z=arguments.length,R=z<3?L:M===null?M=Object.getOwnPropertyDescriptor(L,O):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(D,L,O,M);else for(var P=D.length-1;P>=0;P--)(W=D[P])&&(R=(z<3?W(R):z>3?W(L,O,R):W(L,O))||R);return z>3&&R&&Object.defineProperty(L,O,R),R},p=this&&this.__param||function(D,L){return function(O,M){L(O,M,D)}};Object.defineProperty(c,"__esModule",{value:!0}),c.ThemeService=c.DEFAULT_ANSI_COLORS=void 0;const m=d(7239),x=d(8055),y=d(8460),w=d(844),C=d(2585),_=x.css.toColor("#ffffff"),S=x.css.toColor("#000000"),b=x.css.toColor("#ffffff"),v=x.css.toColor("#000000"),E={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};c.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const D=[x.css.toColor("#2e3436"),x.css.toColor("#cc0000"),x.css.toColor("#4e9a06"),x.css.toColor("#c4a000"),x.css.toColor("#3465a4"),x.css.toColor("#75507b"),x.css.toColor("#06989a"),x.css.toColor("#d3d7cf"),x.css.toColor("#555753"),x.css.toColor("#ef2929"),x.css.toColor("#8ae234"),x.css.toColor("#fce94f"),x.css.toColor("#729fcf"),x.css.toColor("#ad7fa8"),x.css.toColor("#34e2e2"),x.css.toColor("#eeeeec")],L=[0,95,135,175,215,255];for(let O=0;O<216;O++){const M=L[O/36%6|0],W=L[O/6%6|0],z=L[O%6];D.push({css:x.channels.toCss(M,W,z),rgba:x.channels.toRgba(M,W,z)})}for(let O=0;O<24;O++){const M=8+10*O;D.push({css:x.channels.toCss(M,M,M),rgba:x.channels.toRgba(M,M,M)})}return D})());let j=c.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(D){super(),this._optionsService=D,this._contrastCache=new m.ColorContrastCache,this._halfContrastCache=new m.ColorContrastCache,this._onChangeColors=this.register(new y.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_,background:S,cursor:b,cursorAccent:v,selectionForeground:void 0,selectionBackgroundTransparent:E,selectionBackgroundOpaque:x.color.blend(S,E),selectionInactiveBackgroundTransparent:E,selectionInactiveBackgroundOpaque:x.color.blend(S,E),ansi:c.DEFAULT_ANSI_COLORS.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))))}_setTheme(D={}){const L=this._colors;if(L.foreground=T(D.foreground,_),L.background=T(D.background,S),L.cursor=T(D.cursor,b),L.cursorAccent=T(D.cursorAccent,v),L.selectionBackgroundTransparent=T(D.selectionBackground,E),L.selectionBackgroundOpaque=x.color.blend(L.background,L.selectionBackgroundTransparent),L.selectionInactiveBackgroundTransparent=T(D.selectionInactiveBackground,L.selectionBackgroundTransparent),L.selectionInactiveBackgroundOpaque=x.color.blend(L.background,L.selectionInactiveBackgroundTransparent),L.selectionForeground=D.selectionForeground?T(D.selectionForeground,x.NULL_COLOR):void 0,L.selectionForeground===x.NULL_COLOR&&(L.selectionForeground=void 0),x.color.isOpaque(L.selectionBackgroundTransparent)&&(L.selectionBackgroundTransparent=x.color.opacity(L.selectionBackgroundTransparent,.3)),x.color.isOpaque(L.selectionInactiveBackgroundTransparent)&&(L.selectionInactiveBackgroundTransparent=x.color.opacity(L.selectionInactiveBackgroundTransparent,.3)),L.ansi=c.DEFAULT_ANSI_COLORS.slice(),L.ansi[0]=T(D.black,c.DEFAULT_ANSI_COLORS[0]),L.ansi[1]=T(D.red,c.DEFAULT_ANSI_COLORS[1]),L.ansi[2]=T(D.green,c.DEFAULT_ANSI_COLORS[2]),L.ansi[3]=T(D.yellow,c.DEFAULT_ANSI_COLORS[3]),L.ansi[4]=T(D.blue,c.DEFAULT_ANSI_COLORS[4]),L.ansi[5]=T(D.magenta,c.DEFAULT_ANSI_COLORS[5]),L.ansi[6]=T(D.cyan,c.DEFAULT_ANSI_COLORS[6]),L.ansi[7]=T(D.white,c.DEFAULT_ANSI_COLORS[7]),L.ansi[8]=T(D.brightBlack,c.DEFAULT_ANSI_COLORS[8]),L.ansi[9]=T(D.brightRed,c.DEFAULT_ANSI_COLORS[9]),L.ansi[10]=T(D.brightGreen,c.DEFAULT_ANSI_COLORS[10]),L.ansi[11]=T(D.brightYellow,c.DEFAULT_ANSI_COLORS[11]),L.ansi[12]=T(D.brightBlue,c.DEFAULT_ANSI_COLORS[12]),L.ansi[13]=T(D.brightMagenta,c.DEFAULT_ANSI_COLORS[13]),L.ansi[14]=T(D.brightCyan,c.DEFAULT_ANSI_COLORS[14]),L.ansi[15]=T(D.brightWhite,c.DEFAULT_ANSI_COLORS[15]),D.extendedAnsi){const O=Math.min(L.ansi.length-16,D.extendedAnsi.length);for(let M=0;M<O;M++)L.ansi[M+16]=T(D.extendedAnsi[M],c.DEFAULT_ANSI_COLORS[M+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(D){this._restoreColor(D),this._onChangeColors.fire(this.colors)}_restoreColor(D){if(D!==void 0)switch(D){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[D]=this._restoreColors.ansi[D]}else for(let L=0;L<this._restoreColors.ansi.length;++L)this._colors.ansi[L]=this._restoreColors.ansi[L]}modifyColors(D){D(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()}}};function T(D,L){if(D!==void 0)try{return x.css.toColor(D)}catch{}return L}c.ThemeService=j=f([p(0,C.IOptionsService)],j)},6349:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CircularList=void 0;const f=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._maxLength=y,this.onDeleteEmitter=this.register(new f.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new f.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new f.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(y){if(this._maxLength===y)return;const w=new Array(y);for(let C=0;C<Math.min(y,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=y,this._startIndex=0}get length(){return this._length}set length(y){if(y>this._length)for(let w=this._length;w<y;w++)this._array[w]=void 0;this._length=y}get(y){return this._array[this._getCyclicIndex(y)]}set(y,w){this._array[this._getCyclicIndex(y)]=w}push(y){this._array[this._getCyclicIndex(this._length)]=y,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(y,w,...C){if(w){for(let _=y;_<this._length-w;_++)this._array[this._getCyclicIndex(_)]=this._array[this._getCyclicIndex(_+w)];this._length-=w,this.onDeleteEmitter.fire({index:y,amount:w})}for(let _=this._length-1;_>=y;_--)this._array[this._getCyclicIndex(_+C.length)]=this._array[this._getCyclicIndex(_)];for(let _=0;_<C.length;_++)this._array[this._getCyclicIndex(y+_)]=C[_];if(C.length&&this.onInsertEmitter.fire({index:y,amount:C.length}),this._length+C.length>this._maxLength){const _=this._length+C.length-this._maxLength;this._startIndex+=_,this._length=this._maxLength,this.onTrimEmitter.fire(_)}else this._length+=C.length}trimStart(y){y>this._length&&(y=this._length),this._startIndex+=y,this._length-=y,this.onTrimEmitter.fire(y)}shiftElements(y,w,C){if(!(w<=0)){if(y<0||y>=this._length)throw new Error("start argument out of range");if(y+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let S=w-1;S>=0;S--)this.set(y+S+C,this.get(y+S));const _=y+w+C-this._length;if(_>0)for(this._length+=_;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let _=0;_<w;_++)this.set(y+_+C,this.get(y+_))}}_getCyclicIndex(y){return(this._startIndex+y)%this._maxLength}}c.CircularList=m},1439:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.clone=void 0,c.clone=function d(f,p=5){if(typeof f!="object")return f;const m=Array.isArray(f)?[]:{};for(const x in f)m[x]=p<=1?f[x]:f[x]&&d(f[x],p-1);return m}},8055:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.contrastRatio=c.toPaddedHex=c.rgba=c.rgb=c.css=c.color=c.channels=c.NULL_COLOR=void 0;let d=0,f=0,p=0,m=0;var x,y,w,C,_;function S(v){const E=v.toString(16);return E.length<2?"0"+E:E}function b(v,E){return v<E?(E+.05)/(v+.05):(v+.05)/(E+.05)}c.NULL_COLOR={css:"#00000000",rgba:0},(function(v){v.toCss=function(E,j,T,D){return D!==void 0?`#${S(E)}${S(j)}${S(T)}${S(D)}`:`#${S(E)}${S(j)}${S(T)}`},v.toRgba=function(E,j,T,D=255){return(E<<24|j<<16|T<<8|D)>>>0},v.toColor=function(E,j,T,D){return{css:v.toCss(E,j,T,D),rgba:v.toRgba(E,j,T,D)}}})(x||(c.channels=x={})),(function(v){function E(j,T){return m=Math.round(255*T),[d,f,p]=_.toChannels(j.rgba),{css:x.toCss(d,f,p,m),rgba:x.toRgba(d,f,p,m)}}v.blend=function(j,T){if(m=(255&T.rgba)/255,m===1)return{css:T.css,rgba:T.rgba};const D=T.rgba>>24&255,L=T.rgba>>16&255,O=T.rgba>>8&255,M=j.rgba>>24&255,W=j.rgba>>16&255,z=j.rgba>>8&255;return d=M+Math.round((D-M)*m),f=W+Math.round((L-W)*m),p=z+Math.round((O-z)*m),{css:x.toCss(d,f,p),rgba:x.toRgba(d,f,p)}},v.isOpaque=function(j){return(255&j.rgba)==255},v.ensureContrastRatio=function(j,T,D){const L=_.ensureContrastRatio(j.rgba,T.rgba,D);if(L)return x.toColor(L>>24&255,L>>16&255,L>>8&255)},v.opaque=function(j){const T=(255|j.rgba)>>>0;return[d,f,p]=_.toChannels(T),{css:x.toCss(d,f,p),rgba:T}},v.opacity=E,v.multiplyOpacity=function(j,T){return m=255&j.rgba,E(j,m*T/255)},v.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(y||(c.color=y={})),(function(v){let E,j;try{const T=document.createElement("canvas");T.width=1,T.height=1;const D=T.getContext("2d",{willReadFrequently:!0});D&&(E=D,E.globalCompositeOperation="copy",j=E.createLinearGradient(0,0,1,1))}catch{}v.toColor=function(T){if(T.match(/#[\da-f]{3,8}/i))switch(T.length){case 4:return d=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),x.toColor(d,f,p);case 5:return d=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),m=parseInt(T.slice(4,5).repeat(2),16),x.toColor(d,f,p,m);case 7:return{css:T,rgba:(parseInt(T.slice(1),16)<<8|255)>>>0};case 9:return{css:T,rgba:parseInt(T.slice(1),16)>>>0}}const D=T.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(D)return d=parseInt(D[1]),f=parseInt(D[2]),p=parseInt(D[3]),m=Math.round(255*(D[5]===void 0?1:parseFloat(D[5]))),x.toColor(d,f,p,m);if(!E||!j)throw new Error("css.toColor: Unsupported css format");if(E.fillStyle=j,E.fillStyle=T,typeof E.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(E.fillRect(0,0,1,1),[d,f,p,m]=E.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:x.toRgba(d,f,p,m),css:T}}})(w||(c.css=w={})),(function(v){function E(j,T,D){const L=j/255,O=T/255,M=D/255;return .2126*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.7152*(O<=.03928?O/12.92:Math.pow((O+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}v.relativeLuminance=function(j){return E(j>>16&255,j>>8&255,255&j)},v.relativeLuminance2=E})(C||(c.rgb=C={})),(function(v){function E(T,D,L){const O=T>>24&255,M=T>>16&255,W=T>>8&255;let z=D>>24&255,R=D>>16&255,P=D>>8&255,V=b(C.relativeLuminance2(z,R,P),C.relativeLuminance2(O,M,W));for(;V<L&&(z>0||R>0||P>0);)z-=Math.max(0,Math.ceil(.1*z)),R-=Math.max(0,Math.ceil(.1*R)),P-=Math.max(0,Math.ceil(.1*P)),V=b(C.relativeLuminance2(z,R,P),C.relativeLuminance2(O,M,W));return(z<<24|R<<16|P<<8|255)>>>0}function j(T,D,L){const O=T>>24&255,M=T>>16&255,W=T>>8&255;let z=D>>24&255,R=D>>16&255,P=D>>8&255,V=b(C.relativeLuminance2(z,R,P),C.relativeLuminance2(O,M,W));for(;V<L&&(z<255||R<255||P<255);)z=Math.min(255,z+Math.ceil(.1*(255-z))),R=Math.min(255,R+Math.ceil(.1*(255-R))),P=Math.min(255,P+Math.ceil(.1*(255-P))),V=b(C.relativeLuminance2(z,R,P),C.relativeLuminance2(O,M,W));return(z<<24|R<<16|P<<8|255)>>>0}v.blend=function(T,D){if(m=(255&D)/255,m===1)return D;const L=D>>24&255,O=D>>16&255,M=D>>8&255,W=T>>24&255,z=T>>16&255,R=T>>8&255;return d=W+Math.round((L-W)*m),f=z+Math.round((O-z)*m),p=R+Math.round((M-R)*m),x.toRgba(d,f,p)},v.ensureContrastRatio=function(T,D,L){const O=C.relativeLuminance(T>>8),M=C.relativeLuminance(D>>8);if(b(O,M)<L){if(M<O){const R=E(T,D,L),P=b(O,C.relativeLuminance(R>>8));if(P<L){const V=j(T,D,L);return P>b(O,C.relativeLuminance(V>>8))?R:V}return R}const W=j(T,D,L),z=b(O,C.relativeLuminance(W>>8));if(z<L){const R=E(T,D,L);return z>b(O,C.relativeLuminance(R>>8))?W:R}return W}},v.reduceLuminance=E,v.increaseLuminance=j,v.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(_||(c.rgba=_={})),c.toPaddedHex=S,c.contrastRatio=b},8969:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreTerminal=void 0;const f=d(844),p=d(2585),m=d(4348),x=d(7866),y=d(744),w=d(7302),C=d(6975),_=d(8460),S=d(1753),b=d(1480),v=d(7994),E=d(9282),j=d(5435),T=d(5981),D=d(2660);let L=!1;class O extends f.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new _.EventEmitter),this._onScroll.event((W=>{var z;(z=this._onScrollApi)==null||z.fire(W.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(W){for(const z in W)this.optionsService.options[z]=W[z]}constructor(W){super(),this._windowsWrappingHeuristics=this.register(new f.MutableDisposable),this._onBinary=this.register(new _.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new _.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new _.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new _.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new _.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new _.EventEmitter),this._instantiationService=new m.InstantiationService,this.optionsService=this.register(new w.OptionsService(W)),this._instantiationService.setService(p.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(y.BufferService)),this._instantiationService.setService(p.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(x.LogService)),this._instantiationService.setService(p.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(p.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(S.CoreMouseService)),this._instantiationService.setService(p.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(b.UnicodeService)),this._instantiationService.setService(p.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(v.CharsetService),this._instantiationService.setService(p.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(D.OscLinkService),this._instantiationService.setService(p.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new j.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,_.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,_.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,_.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,_.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((z=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((z=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new T.WriteBuffer(((z,R)=>this._inputHandler.parse(z,R)))),this.register((0,_.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(W,z){this._writeBuffer.write(W,z)}writeSync(W,z){this._logService.logLevel<=p.LogLevelEnum.WARN&&!L&&(this._logService.warn("writeSync is unreliable and will be removed soon."),L=!0),this._writeBuffer.writeSync(W,z)}input(W,z=!0){this.coreService.triggerDataEvent(W,z)}resize(W,z){isNaN(W)||isNaN(z)||(W=Math.max(W,y.MINIMUM_COLS),z=Math.max(z,y.MINIMUM_ROWS),this._bufferService.resize(W,z))}scroll(W,z=!1){this._bufferService.scroll(W,z)}scrollLines(W,z,R){this._bufferService.scrollLines(W,z,R)}scrollPages(W){this.scrollLines(W*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(W){const z=W-this._bufferService.buffer.ydisp;z!==0&&this.scrollLines(z)}registerEscHandler(W,z){return this._inputHandler.registerEscHandler(W,z)}registerDcsHandler(W,z){return this._inputHandler.registerDcsHandler(W,z)}registerCsiHandler(W,z){return this._inputHandler.registerCsiHandler(W,z)}registerOscHandler(W,z){return this._inputHandler.registerOscHandler(W,z)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let W=!1;const z=this.optionsService.rawOptions.windowsPty;z&&z.buildNumber!==void 0&&z.buildNumber!==void 0?W=z.backend==="conpty"&&z.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(W=!0),W?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const W=[];W.push(this.onLineFeed(E.updateWindowsModeWrappedState.bind(null,this._bufferService))),W.push(this.registerCsiHandler({final:"H"},(()=>((0,E.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,f.toDisposable)((()=>{for(const z of W)z.dispose()}))}}}c.CoreTerminal=O},8460:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.runAndSubscribe=c.forwardEvent=c.EventEmitter=void 0,c.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=d=>(this._listeners.push(d),{dispose:()=>{if(!this._disposed){for(let f=0;f<this._listeners.length;f++)if(this._listeners[f]===d)return void this._listeners.splice(f,1)}}})),this._event}fire(d,f){const p=[];for(let m=0;m<this._listeners.length;m++)p.push(this._listeners[m]);for(let m=0;m<p.length;m++)p[m].call(void 0,d,f)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},c.forwardEvent=function(d,f){return d((p=>f.fire(p)))},c.runAndSubscribe=function(d,f){return f(void 0),d((p=>f(p)))}},5435:function(u,c,d){var f=this&&this.__decorate||function(Q,U,I,$){var q,B=arguments.length,ee=B<3?U:$===null?$=Object.getOwnPropertyDescriptor(U,I):$;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ee=Reflect.decorate(Q,U,I,$);else for(var X=Q.length-1;X>=0;X--)(q=Q[X])&&(ee=(B<3?q(ee):B>3?q(U,I,ee):q(U,I))||ee);return B>3&&ee&&Object.defineProperty(U,I,ee),ee},p=this&&this.__param||function(Q,U){return function(I,$){U(I,$,Q)}};Object.defineProperty(c,"__esModule",{value:!0}),c.InputHandler=c.WindowsOptionsReportType=void 0;const m=d(2584),x=d(7116),y=d(2015),w=d(844),C=d(482),_=d(8437),S=d(8460),b=d(643),v=d(511),E=d(3734),j=d(2585),T=d(1480),D=d(6242),L=d(6351),O=d(5941),M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},W=131072;function z(Q,U){if(Q>24)return U.setWinLines||!1;switch(Q){case 1:return!!U.restoreWin;case 2:return!!U.minimizeWin;case 3:return!!U.setWinPosition;case 4:return!!U.setWinSizePixels;case 5:return!!U.raiseWin;case 6:return!!U.lowerWin;case 7:return!!U.refreshWin;case 8:return!!U.setWinSizeChars;case 9:return!!U.maximizeWin;case 10:return!!U.fullscreenWin;case 11:return!!U.getWinState;case 13:return!!U.getWinPosition;case 14:return!!U.getWinSizePixels;case 15:return!!U.getScreenSizePixels;case 16:return!!U.getCellSizePixels;case 18:return!!U.getWinSizeChars;case 19:return!!U.getScreenSizeChars;case 20:return!!U.getIconTitle;case 21:return!!U.getWinTitle;case 22:return!!U.pushTitle;case 23:return!!U.popTitle;case 24:return!!U.setWinLines}return!1}var R;(function(Q){Q[Q.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",Q[Q.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(c.WindowsOptionsReportType=R={}));let P=0;class V extends w.Disposable{getAttrData(){return this._curAttrData}constructor(U,I,$,q,B,ee,X,ne,K=new y.EscapeSequenceParser){super(),this._bufferService=U,this._charsetService=I,this._coreService=$,this._logService=q,this._optionsService=B,this._oscLinkService=ee,this._coreMouseService=X,this._unicodeService=ne,this._parser=K,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new v.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=_.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=_.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new S.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new S.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new S.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new S.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new S.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new S.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new S.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new S.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new S.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new S.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new S.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new S.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new S.EventEmitter),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 G(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((F=>this._activeBuffer=F.activeBuffer))),this._parser.setCsiHandlerFallback(((F,te)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(F),params:te.toArray()})})),this._parser.setEscHandlerFallback((F=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(F)})})),this._parser.setExecuteHandlerFallback((F=>{this._logService.debug("Unknown EXECUTE code: ",{code:F})})),this._parser.setOscHandlerFallback(((F,te,se)=>{this._logService.debug("Unknown OSC code: ",{identifier:F,action:te,data:se})})),this._parser.setDcsHandlerFallback(((F,te,se)=>{te==="HOOK"&&(se=se.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(F),action:te,payload:se})})),this._parser.setPrintHandler(((F,te,se)=>this.print(F,te,se))),this._parser.registerCsiHandler({final:"@"},(F=>this.insertChars(F))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(F=>this.scrollLeft(F))),this._parser.registerCsiHandler({final:"A"},(F=>this.cursorUp(F))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(F=>this.scrollRight(F))),this._parser.registerCsiHandler({final:"B"},(F=>this.cursorDown(F))),this._parser.registerCsiHandler({final:"C"},(F=>this.cursorForward(F))),this._parser.registerCsiHandler({final:"D"},(F=>this.cursorBackward(F))),this._parser.registerCsiHandler({final:"E"},(F=>this.cursorNextLine(F))),this._parser.registerCsiHandler({final:"F"},(F=>this.cursorPrecedingLine(F))),this._parser.registerCsiHandler({final:"G"},(F=>this.cursorCharAbsolute(F))),this._parser.registerCsiHandler({final:"H"},(F=>this.cursorPosition(F))),this._parser.registerCsiHandler({final:"I"},(F=>this.cursorForwardTab(F))),this._parser.registerCsiHandler({final:"J"},(F=>this.eraseInDisplay(F,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(F=>this.eraseInDisplay(F,!0))),this._parser.registerCsiHandler({final:"K"},(F=>this.eraseInLine(F,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(F=>this.eraseInLine(F,!0))),this._parser.registerCsiHandler({final:"L"},(F=>this.insertLines(F))),this._parser.registerCsiHandler({final:"M"},(F=>this.deleteLines(F))),this._parser.registerCsiHandler({final:"P"},(F=>this.deleteChars(F))),this._parser.registerCsiHandler({final:"S"},(F=>this.scrollUp(F))),this._parser.registerCsiHandler({final:"T"},(F=>this.scrollDown(F))),this._parser.registerCsiHandler({final:"X"},(F=>this.eraseChars(F))),this._parser.registerCsiHandler({final:"Z"},(F=>this.cursorBackwardTab(F))),this._parser.registerCsiHandler({final:"`"},(F=>this.charPosAbsolute(F))),this._parser.registerCsiHandler({final:"a"},(F=>this.hPositionRelative(F))),this._parser.registerCsiHandler({final:"b"},(F=>this.repeatPrecedingCharacter(F))),this._parser.registerCsiHandler({final:"c"},(F=>this.sendDeviceAttributesPrimary(F))),this._parser.registerCsiHandler({prefix:">",final:"c"},(F=>this.sendDeviceAttributesSecondary(F))),this._parser.registerCsiHandler({final:"d"},(F=>this.linePosAbsolute(F))),this._parser.registerCsiHandler({final:"e"},(F=>this.vPositionRelative(F))),this._parser.registerCsiHandler({final:"f"},(F=>this.hVPosition(F))),this._parser.registerCsiHandler({final:"g"},(F=>this.tabClear(F))),this._parser.registerCsiHandler({final:"h"},(F=>this.setMode(F))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(F=>this.setModePrivate(F))),this._parser.registerCsiHandler({final:"l"},(F=>this.resetMode(F))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(F=>this.resetModePrivate(F))),this._parser.registerCsiHandler({final:"m"},(F=>this.charAttributes(F))),this._parser.registerCsiHandler({final:"n"},(F=>this.deviceStatus(F))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(F=>this.deviceStatusPrivate(F))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(F=>this.softReset(F))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(F=>this.setCursorStyle(F))),this._parser.registerCsiHandler({final:"r"},(F=>this.setScrollRegion(F))),this._parser.registerCsiHandler({final:"s"},(F=>this.saveCursor(F))),this._parser.registerCsiHandler({final:"t"},(F=>this.windowOptions(F))),this._parser.registerCsiHandler({final:"u"},(F=>this.restoreCursor(F))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(F=>this.insertColumns(F))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(F=>this.deleteColumns(F))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(F=>this.selectProtected(F))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(F=>this.requestMode(F,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(F=>this.requestMode(F,!1))),this._parser.setExecuteHandler(m.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(m.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(m.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(m.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(m.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(m.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(m.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(m.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(m.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new D.OscHandler((F=>(this.setTitle(F),this.setIconName(F),!0)))),this._parser.registerOscHandler(1,new D.OscHandler((F=>this.setIconName(F)))),this._parser.registerOscHandler(2,new D.OscHandler((F=>this.setTitle(F)))),this._parser.registerOscHandler(4,new D.OscHandler((F=>this.setOrReportIndexedColor(F)))),this._parser.registerOscHandler(8,new D.OscHandler((F=>this.setHyperlink(F)))),this._parser.registerOscHandler(10,new D.OscHandler((F=>this.setOrReportFgColor(F)))),this._parser.registerOscHandler(11,new D.OscHandler((F=>this.setOrReportBgColor(F)))),this._parser.registerOscHandler(12,new D.OscHandler((F=>this.setOrReportCursorColor(F)))),this._parser.registerOscHandler(104,new D.OscHandler((F=>this.restoreIndexedColor(F)))),this._parser.registerOscHandler(110,new D.OscHandler((F=>this.restoreFgColor(F)))),this._parser.registerOscHandler(111,new D.OscHandler((F=>this.restoreBgColor(F)))),this._parser.registerOscHandler(112,new D.OscHandler((F=>this.restoreCursorColor(F)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const F in x.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:F},(()=>this.selectCharset("("+F))),this._parser.registerEscHandler({intermediates:")",final:F},(()=>this.selectCharset(")"+F))),this._parser.registerEscHandler({intermediates:"*",final:F},(()=>this.selectCharset("*"+F))),this._parser.registerEscHandler({intermediates:"+",final:F},(()=>this.selectCharset("+"+F))),this._parser.registerEscHandler({intermediates:"-",final:F},(()=>this.selectCharset("-"+F))),this._parser.registerEscHandler({intermediates:".",final:F},(()=>this.selectCharset("."+F))),this._parser.registerEscHandler({intermediates:"/",final:F},(()=>this.selectCharset("/"+F)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((F=>(this._logService.error("Parsing error: ",F),F))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new L.DcsHandler(((F,te)=>this.requestStatusString(F,te))))}_preserveStack(U,I,$,q){this._parseStack.paused=!0,this._parseStack.cursorStartX=U,this._parseStack.cursorStartY=I,this._parseStack.decodedLength=$,this._parseStack.position=q}_logSlowResolvingAsync(U){this._logService.logLevel<=j.LogLevelEnum.WARN&&Promise.race([U,new Promise(((I,$)=>setTimeout((()=>$("#SLOW_TIMEOUT")),5e3)))]).catch((I=>{if(I!=="#SLOW_TIMEOUT")throw I;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(U,I){let $,q=this._activeBuffer.x,B=this._activeBuffer.y,ee=0;const X=this._parseStack.paused;if(X){if($=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,I))return this._logSlowResolvingAsync($),$;q=this._parseStack.cursorStartX,B=this._parseStack.cursorStartY,this._parseStack.paused=!1,U.length>W&&(ee=this._parseStack.position+W)}if(this._logService.logLevel<=j.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof U=="string"?` "${U}"`:` "${Array.prototype.map.call(U,(F=>String.fromCharCode(F))).join("")}"`),typeof U=="string"?U.split("").map((F=>F.charCodeAt(0))):U),this._parseBuffer.length<U.length&&this._parseBuffer.length<W&&(this._parseBuffer=new Uint32Array(Math.min(U.length,W))),X||this._dirtyRowTracker.clearRange(),U.length>W)for(let F=ee;F<U.length;F+=W){const te=F+W<U.length?F+W:U.length,se=typeof U=="string"?this._stringDecoder.decode(U.substring(F,te),this._parseBuffer):this._utf8Decoder.decode(U.subarray(F,te),this._parseBuffer);if($=this._parser.parse(this._parseBuffer,se))return this._preserveStack(q,B,se,F),this._logSlowResolvingAsync($),$}else if(!X){const F=typeof U=="string"?this._stringDecoder.decode(U,this._parseBuffer):this._utf8Decoder.decode(U,this._parseBuffer);if($=this._parser.parse(this._parseBuffer,F))return this._preserveStack(q,B,F,0),this._logSlowResolvingAsync($),$}this._activeBuffer.x===q&&this._activeBuffer.y===B||this._onCursorMove.fire();const ne=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),K=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);K<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(K,this._bufferService.rows-1),Math.min(ne,this._bufferService.rows-1))}print(U,I,$){let q,B;const ee=this._charsetService.charset,X=this._optionsService.rawOptions.screenReaderMode,ne=this._bufferService.cols,K=this._coreService.decPrivateModes.wraparound,F=this._coreService.modes.insertMode,te=this._curAttrData;let se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&$-I>0&&se.getWidth(this._activeBuffer.x-1)===2&&se.setCellFromCodepoint(this._activeBuffer.x-1,0,1,te);let xe=this._parser.precedingJoinState;for(let oe=I;oe<$;++oe){if(q=U[oe],q<127&&ee){const Me=ee[String.fromCharCode(q)];Me&&(q=Me.charCodeAt(0))}const ye=this._unicodeService.charProperties(q,xe);B=T.UnicodeService.extractWidth(ye);const Le=T.UnicodeService.extractShouldJoin(ye),Oe=Le?T.UnicodeService.extractWidth(xe):0;if(xe=ye,X&&this._onA11yChar.fire((0,C.stringFromCodePoint)(q)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+B-Oe>ne){if(K){const Me=se;let je=this._activeBuffer.x-Oe;for(this._activeBuffer.x=Oe,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),se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Oe>0&&se instanceof _.BufferLine&&se.copyCellsFrom(Me,je,0,Oe,!1);je<ne;)Me.setCellFromCodepoint(je++,0,1,te)}else if(this._activeBuffer.x=ne-1,B===2)continue}if(Le&&this._activeBuffer.x){const Me=se.getWidth(this._activeBuffer.x-1)?1:2;se.addCodepointToCell(this._activeBuffer.x-Me,q,B);for(let je=B-Oe;--je>=0;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}else if(F&&(se.insertCells(this._activeBuffer.x,B-Oe,this._activeBuffer.getNullCell(te)),se.getWidth(ne-1)===2&&se.setCellFromCodepoint(ne-1,b.NULL_CELL_CODE,b.NULL_CELL_WIDTH,te)),se.setCellFromCodepoint(this._activeBuffer.x++,q,B,te),B>0)for(;--B;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}this._parser.precedingJoinState=xe,this._activeBuffer.x<ne&&$-I>0&&se.getWidth(this._activeBuffer.x)===0&&!se.hasContent(this._activeBuffer.x)&&se.setCellFromCodepoint(this._activeBuffer.x,0,1,te),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(U,I){return U.final!=="t"||U.prefix||U.intermediates?this._parser.registerCsiHandler(U,I):this._parser.registerCsiHandler(U,($=>!z($.params[0],this._optionsService.rawOptions.windowOptions)||I($)))}registerDcsHandler(U,I){return this._parser.registerDcsHandler(U,new L.DcsHandler(I))}registerEscHandler(U,I){return this._parser.registerEscHandler(U,I)}registerOscHandler(U,I){return this._parser.registerOscHandler(U,new D.OscHandler(I))}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 U;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&&((U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&U.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);I.hasWidth(this._activeBuffer.x)&&!I.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const U=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-U),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(U=this._bufferService.cols-1){this._activeBuffer.x=Math.min(U,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(U,I){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=U,this._activeBuffer.y=this._activeBuffer.scrollTop+I):(this._activeBuffer.x=U,this._activeBuffer.y=I),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(U,I){this._restrictCursor(),this._setCursor(this._activeBuffer.x+U,this._activeBuffer.y+I)}cursorUp(U){const I=this._activeBuffer.y-this._activeBuffer.scrollTop;return I>=0?this._moveCursor(0,-Math.min(I,U.params[0]||1)):this._moveCursor(0,-(U.params[0]||1)),!0}cursorDown(U){const I=this._activeBuffer.scrollBottom-this._activeBuffer.y;return I>=0?this._moveCursor(0,Math.min(I,U.params[0]||1)):this._moveCursor(0,U.params[0]||1),!0}cursorForward(U){return this._moveCursor(U.params[0]||1,0),!0}cursorBackward(U){return this._moveCursor(-(U.params[0]||1),0),!0}cursorNextLine(U){return this.cursorDown(U),this._activeBuffer.x=0,!0}cursorPrecedingLine(U){return this.cursorUp(U),this._activeBuffer.x=0,!0}cursorCharAbsolute(U){return this._setCursor((U.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(U){return this._setCursor(U.length>=2?(U.params[1]||1)-1:0,(U.params[0]||1)-1),!0}charPosAbsolute(U){return this._setCursor((U.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(U){return this._moveCursor(U.params[0]||1,0),!0}linePosAbsolute(U){return this._setCursor(this._activeBuffer.x,(U.params[0]||1)-1),!0}vPositionRelative(U){return this._moveCursor(0,U.params[0]||1),!0}hVPosition(U){return this.cursorPosition(U),!0}tabClear(U){const I=U.params[0];return I===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:I===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(U){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=U.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(U){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=U.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(U){const I=U.params[0];return I===1&&(this._curAttrData.bg|=536870912),I!==2&&I!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(U,I,$,q=!1,B=!1){const ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+U);ee.replaceCells(I,$,this._activeBuffer.getNullCell(this._eraseAttrData()),B),q&&(ee.isWrapped=!1)}_resetBufferLine(U,I=!1){const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+U);$&&($.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),I),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+U),$.isWrapped=!1)}eraseInDisplay(U,I=!1){let $;switch(this._restrictCursor(this._bufferService.cols),U.params[0]){case 0:for($=this._activeBuffer.y,this._dirtyRowTracker.markDirty($),this._eraseInBufferLine($++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);$<this._bufferService.rows;$++)this._resetBufferLine($,I);this._dirtyRowTracker.markDirty($);break;case 1:for($=this._activeBuffer.y,this._dirtyRowTracker.markDirty($),this._eraseInBufferLine($,0,this._activeBuffer.x+1,!0,I),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get($+1).isWrapped=!1);$--;)this._resetBufferLine($,I);this._dirtyRowTracker.markDirty(0);break;case 2:for($=this._bufferService.rows,this._dirtyRowTracker.markDirty($-1);$--;)this._resetBufferLine($,I);this._dirtyRowTracker.markDirty(0);break;case 3:const q=this._activeBuffer.lines.length-this._bufferService.rows;q>0&&(this._activeBuffer.lines.trimStart(q),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-q,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-q,0),this._onScroll.fire(0))}return!0}eraseInLine(U,I=!1){switch(this._restrictCursor(this._bufferService.cols),U.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,I);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,I)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(U){this._restrictCursor();let I=U.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const $=this._activeBuffer.ybase+this._activeBuffer.y,q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-q+1;for(;I--;)this._activeBuffer.lines.splice(B-1,1),this._activeBuffer.lines.splice($,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(U){this._restrictCursor();let I=U.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const $=this._activeBuffer.ybase+this._activeBuffer.y;let q;for(q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-q;I--;)this._activeBuffer.lines.splice($,1),this._activeBuffer.lines.splice(q,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(U){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.insertCells(this._activeBuffer.x,U.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(U){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.deleteCells(this._activeBuffer.x,U.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(U){let I=U.params[0]||1;for(;I--;)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(U){let I=U.params[0]||1;for(;I--;)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(_.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=U.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);q.deleteCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=U.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);q.insertCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=U.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);q.insertCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=U.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);q.deleteCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(U){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(U.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(U){const I=this._parser.precedingJoinState;if(!I)return!0;const $=U.params[0]||1,q=T.UnicodeService.extractWidth(I),B=this._activeBuffer.x-q,ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(B),X=new Uint32Array(ee.length*$);let ne=0;for(let F=0;F<ee.length;){const te=ee.codePointAt(F)||0;X[ne++]=te,F+=te>65535?2:1}let K=ne;for(let F=1;F<$;++F)X.copyWithin(K,0,ne),K+=ne;return this.print(X,0,K),!0}sendDeviceAttributesPrimary(U){return U.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(m.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(m.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(U){return U.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(m.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(m.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(U.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(m.C0.ESC+"[>83;40003;0c")),!0}_is(U){return(this._optionsService.rawOptions.termName+"").indexOf(U)===0}setMode(U){for(let I=0;I<U.length;I++)switch(U.params[I]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(U){for(let I=0;I<U.length;I++)switch(U.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,x.DEFAULT_CHARSET),this._charsetService.setgCharset(1,x.DEFAULT_CHARSET),this._charsetService.setgCharset(2,x.DEFAULT_CHARSET),this._charsetService.setgCharset(3,x.DEFAULT_CHARSET);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(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(U){for(let I=0;I<U.length;I++)switch(U.params[I]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(U){for(let I=0;I<U.length;I++)switch(U.params[I]){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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),U.params[I]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(U,I){const $=this._coreService.decPrivateModes,{activeProtocol:q,activeEncoding:B}=this._coreMouseService,ee=this._coreService,{buffers:X,cols:ne}=this._bufferService,{active:K,alt:F}=X,te=this._optionsService.rawOptions,se=Le=>Le?1:2,xe=U.params[0];return oe=xe,ye=I?xe===2?4:xe===4?se(ee.modes.insertMode):xe===12?3:xe===20?se(te.convertEol):0:xe===1?se($.applicationCursorKeys):xe===3?te.windowOptions.setWinLines?ne===80?2:ne===132?1:0:0:xe===6?se($.origin):xe===7?se($.wraparound):xe===8?3:xe===9?se(q==="X10"):xe===12?se(te.cursorBlink):xe===25?se(!ee.isCursorHidden):xe===45?se($.reverseWraparound):xe===66?se($.applicationKeypad):xe===67?4:xe===1e3?se(q==="VT200"):xe===1002?se(q==="DRAG"):xe===1003?se(q==="ANY"):xe===1004?se($.sendFocus):xe===1005?4:xe===1006?se(B==="SGR"):xe===1015?4:xe===1016?se(B==="SGR_PIXELS"):xe===1048?1:xe===47||xe===1047||xe===1049?se(K===F):xe===2004?se($.bracketedPasteMode):0,ee.triggerDataEvent(`${m.C0.ESC}[${I?"":"?"}${oe};${ye}$y`),!0;var oe,ye}_updateAttrColor(U,I,$,q,B){return I===2?(U|=50331648,U&=-16777216,U|=E.AttributeData.fromColorRGB([$,q,B])):I===5&&(U&=-50331904,U|=33554432|255&$),U}_extractColor(U,I,$){const q=[0,0,-1,0,0,0];let B=0,ee=0;do{if(q[ee+B]=U.params[I+ee],U.hasSubParams(I+ee)){const X=U.getSubParams(I+ee);let ne=0;do q[1]===5&&(B=1),q[ee+ne+1+B]=X[ne];while(++ne<X.length&&ne+ee+1+B<q.length);break}if(q[1]===5&&ee+B>=2||q[1]===2&&ee+B>=5)break;q[1]&&(B=1)}while(++ee+I<U.length&&ee+B<q.length);for(let X=2;X<q.length;++X)q[X]===-1&&(q[X]=0);switch(q[0]){case 38:$.fg=this._updateAttrColor($.fg,q[1],q[3],q[4],q[5]);break;case 48:$.bg=this._updateAttrColor($.bg,q[1],q[3],q[4],q[5]);break;case 58:$.extended=$.extended.clone(),$.extended.underlineColor=this._updateAttrColor($.extended.underlineColor,q[1],q[3],q[4],q[5])}return ee}_processUnderline(U,I){I.extended=I.extended.clone(),(!~U||U>5)&&(U=1),I.extended.underlineStyle=U,I.fg|=268435456,U===0&&(I.fg&=-268435457),I.updateExtended()}_processSGR0(U){U.fg=_.DEFAULT_ATTR_DATA.fg,U.bg=_.DEFAULT_ATTR_DATA.bg,U.extended=U.extended.clone(),U.extended.underlineStyle=0,U.extended.underlineColor&=-67108864,U.updateExtended()}charAttributes(U){if(U.length===1&&U.params[0]===0)return this._processSGR0(this._curAttrData),!0;const I=U.length;let $;const q=this._curAttrData;for(let B=0;B<I;B++)$=U.params[B],$>=30&&$<=37?(q.fg&=-50331904,q.fg|=16777216|$-30):$>=40&&$<=47?(q.bg&=-50331904,q.bg|=16777216|$-40):$>=90&&$<=97?(q.fg&=-50331904,q.fg|=16777224|$-90):$>=100&&$<=107?(q.bg&=-50331904,q.bg|=16777224|$-100):$===0?this._processSGR0(q):$===1?q.fg|=134217728:$===3?q.bg|=67108864:$===4?(q.fg|=268435456,this._processUnderline(U.hasSubParams(B)?U.getSubParams(B)[0]:1,q)):$===5?q.fg|=536870912:$===7?q.fg|=67108864:$===8?q.fg|=1073741824:$===9?q.fg|=2147483648:$===2?q.bg|=134217728:$===21?this._processUnderline(2,q):$===22?(q.fg&=-134217729,q.bg&=-134217729):$===23?q.bg&=-67108865:$===24?(q.fg&=-268435457,this._processUnderline(0,q)):$===25?q.fg&=-536870913:$===27?q.fg&=-67108865:$===28?q.fg&=-1073741825:$===29?q.fg&=2147483647:$===39?(q.fg&=-67108864,q.fg|=16777215&_.DEFAULT_ATTR_DATA.fg):$===49?(q.bg&=-67108864,q.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):$===38||$===48||$===58?B+=this._extractColor(U,B,q):$===53?q.bg|=1073741824:$===55?q.bg&=-1073741825:$===59?(q.extended=q.extended.clone(),q.extended.underlineColor=-1,q.updateExtended()):$===100?(q.fg&=-67108864,q.fg|=16777215&_.DEFAULT_ATTR_DATA.fg,q.bg&=-67108864,q.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",$);return!0}deviceStatus(U){switch(U.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const I=this._activeBuffer.y+1,$=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${I};${$}R`)}return!0}deviceStatusPrivate(U){if(U.params[0]===6){const I=this._activeBuffer.y+1,$=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${I};${$}R`)}return!0}softReset(U){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=_.DEFAULT_ATTR_DATA.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(U){const I=U.params[0]||1;switch(I){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const $=I%2==1;return this._optionsService.options.cursorBlink=$,!0}setScrollRegion(U){const I=U.params[0]||1;let $;return(U.length<2||($=U.params[1])>this._bufferService.rows||$===0)&&($=this._bufferService.rows),$>I&&(this._activeBuffer.scrollTop=I-1,this._activeBuffer.scrollBottom=$-1,this._setCursor(0,0)),!0}windowOptions(U){if(!z(U.params[0],this._optionsService.rawOptions.windowOptions))return!0;const I=U.length>1?U.params[1]:0;switch(U.params[0]){case 14:I!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${m.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:I!==0&&I!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),I!==0&&I!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:I!==0&&I!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),I!==0&&I!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(U){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(U){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(U){return this._windowTitle=U,this._onTitleChange.fire(U),!0}setIconName(U){return this._iconName=U,!0}setOrReportIndexedColor(U){const I=[],$=U.split(";");for(;$.length>1;){const q=$.shift(),B=$.shift();if(/^\d+$/.exec(q)){const ee=parseInt(q);if(Z(ee))if(B==="?")I.push({type:0,index:ee});else{const X=(0,O.parseColor)(B);X&&I.push({type:1,index:ee,color:X})}}}return I.length&&this._onColor.fire(I),!0}setHyperlink(U){const I=U.split(";");return!(I.length<2)&&(I[1]?this._createHyperlink(I[0],I[1]):!I[0]&&this._finishHyperlink())}_createHyperlink(U,I){this._getCurrentLinkId()&&this._finishHyperlink();const $=U.split(":");let q;const B=$.findIndex((ee=>ee.startsWith("id=")));return B!==-1&&(q=$[B].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:q,uri:I}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(U,I){const $=U.split(";");for(let q=0;q<$.length&&!(I>=this._specialColors.length);++q,++I)if($[q]==="?")this._onColor.fire([{type:0,index:this._specialColors[I]}]);else{const B=(0,O.parseColor)($[q]);B&&this._onColor.fire([{type:1,index:this._specialColors[I],color:B}])}return!0}setOrReportFgColor(U){return this._setOrReportSpecialColor(U,0)}setOrReportBgColor(U){return this._setOrReportSpecialColor(U,1)}setOrReportCursorColor(U){return this._setOrReportSpecialColor(U,2)}restoreIndexedColor(U){if(!U)return this._onColor.fire([{type:2}]),!0;const I=[],$=U.split(";");for(let q=0;q<$.length;++q)if(/^\d+$/.exec($[q])){const B=parseInt($[q]);Z(B)&&I.push({type:2,index:B})}return I.length&&this._onColor.fire(I),!0}restoreFgColor(U){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(U){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(U){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,x.DEFAULT_CHARSET),!0}selectCharset(U){return U.length!==2?(this.selectDefaultCharset(),!0):(U[0]==="/"||this._charsetService.setgCharset(M[U[0]],x.CHARSETS[U[1]]||x.DEFAULT_CHARSET),!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){const U=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,U,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=_.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=_.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(U){return this._charsetService.setgLevel(U),!0}screenAlignmentPattern(){const U=new v.CellData;U.content=4194373,U.fg=this._curAttrData.fg,U.bg=this._curAttrData.bg,this._setCursor(0,0);for(let I=0;I<this._bufferService.rows;++I){const $=this._activeBuffer.ybase+this._activeBuffer.y+I,q=this._activeBuffer.lines.get($);q&&(q.fill(U),q.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(U,I){const $=this._bufferService.buffer,q=this._optionsService.rawOptions;return(B=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${B}${m.C0.ESC}\\`),!0))(U==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:U==='"p'?'P1$r61;1"p':U==="r"?`P1$r${$.scrollTop+1};${$.scrollBottom+1}r`:U==="m"?"P1$r0m":U===" q"?`P1$r${{block:2,underline:4,bar:6}[q.cursorStyle]-(q.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(U,I){this._dirtyRowTracker.markRangeDirty(U,I)}}c.InputHandler=V;let G=class{constructor(Q){this._bufferService=Q,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(Q){Q<this.start?this.start=Q:Q>this.end&&(this.end=Q)}markRangeDirty(Q,U){Q>U&&(P=Q,Q=U,U=P),Q<this.start&&(this.start=Q),U>this.end&&(this.end=U)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Z(Q){return 0<=Q&&Q<256}G=f([p(0,j.IBufferService)],G)},844:(u,c)=>{function d(f){for(const p of f)p.dispose();f.length=0}Object.defineProperty(c,"__esModule",{value:!0}),c.getDisposeArrayDisposable=c.disposeArray=c.toDisposable=c.MutableDisposable=c.Disposable=void 0,c.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const f of this._disposables)f.dispose();this._disposables.length=0}register(f){return this._disposables.push(f),f}unregister(f){const p=this._disposables.indexOf(f);p!==-1&&this._disposables.splice(p,1)}},c.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(f){var p;this._isDisposed||f===this._value||((p=this._value)==null||p.dispose(),this._value=f)}clear(){this.value=void 0}dispose(){var f;this._isDisposed=!0,(f=this._value)==null||f.dispose(),this._value=void 0}},c.toDisposable=function(f){return{dispose:f}},c.disposeArray=d,c.getDisposeArrayDisposable=function(f){return{dispose:()=>d(f)}}},1505:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.FourKeyMap=c.TwoKeyMap=void 0;class d{constructor(){this._data={}}set(p,m,x){this._data[p]||(this._data[p]={}),this._data[p][m]=x}get(p,m){return this._data[p]?this._data[p][m]:void 0}clear(){this._data={}}}c.TwoKeyMap=d,c.FourKeyMap=class{constructor(){this._data=new d}set(f,p,m,x,y){this._data.get(f,p)||this._data.set(f,p,new d),this._data.get(f,p).set(m,x,y)}get(f,p,m,x){var y;return(y=this._data.get(f,p))==null?void 0:y.get(m,x)}clear(){this._data.clear()}}},6114:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.isChromeOS=c.isLinux=c.isWindows=c.isIphone=c.isIpad=c.isMac=c.getSafariVersion=c.isSafari=c.isLegacyEdge=c.isFirefox=c.isNode=void 0,c.isNode=typeof process<"u"&&"title"in process;const d=c.isNode?"node":navigator.userAgent,f=c.isNode?"node":navigator.platform;c.isFirefox=d.includes("Firefox"),c.isLegacyEdge=d.includes("Edge"),c.isSafari=/^((?!chrome|android).)*safari/i.test(d),c.getSafariVersion=function(){if(!c.isSafari)return 0;const p=d.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[1])},c.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(f),c.isIpad=f==="iPad",c.isIphone=f==="iPhone",c.isWindows=["Windows","Win16","Win32","WinCE"].includes(f),c.isLinux=f.indexOf("Linux")>=0,c.isChromeOS=/\bCrOS\b/.test(d)},6106:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SortedList=void 0;let d=0;c.SortedList=class{constructor(f){this._getKey=f,this._array=[]}clear(){this._array.length=0}insert(f){this._array.length!==0?(d=this._search(this._getKey(f)),this._array.splice(d,0,f)):this._array.push(f)}delete(f){if(this._array.length===0)return!1;const p=this._getKey(f);if(p===void 0||(d=this._search(p),d===-1)||this._getKey(this._array[d])!==p)return!1;do if(this._array[d]===f)return this._array.splice(d,1),!0;while(++d<this._array.length&&this._getKey(this._array[d])===p);return!1}*getKeyIterator(f){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do yield this._array[d];while(++d<this._array.length&&this._getKey(this._array[d])===f)}forEachByKey(f,p){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do p(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===f)}values(){return[...this._array].values()}_search(f){let p=0,m=this._array.length-1;for(;m>=p;){let x=p+m>>1;const y=this._getKey(this._array[x]);if(y>f)m=x-1;else{if(!(y<f)){for(;x>0&&this._getKey(this._array[x-1])===f;)x--;return x}p=x+1}}return p}}},7226:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DebouncedIdleTask=c.IdleTaskQueue=c.PriorityTaskQueue=void 0;const f=d(6114);class p{constructor(){this._tasks=[],this._i=0}enqueue(y){this._tasks.push(y),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(y){this._idleCallback=void 0;let w=0,C=0,_=y.timeRemaining(),S=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),C=Math.max(w,C),S=y.timeRemaining(),1.5*C>S)return _-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(_-w))}ms`),void this._start();_=S}this.clear()}}class m extends p{_requestCallback(y){return setTimeout((()=>y(this._createDeadline(16))))}_cancelCallback(y){clearTimeout(y)}_createDeadline(y){const w=Date.now()+y;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}c.PriorityTaskQueue=m,c.IdleTaskQueue=!f.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(x){return requestIdleCallback(x)}_cancelCallback(x){cancelIdleCallback(x)}}:m,c.DebouncedIdleTask=class{constructor(){this._queue=new c.IdleTaskQueue}set(x){this._queue.clear(),this._queue.enqueue(x)}flush(){this._queue.flush()}}},9282:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.updateWindowsModeWrappedState=void 0;const f=d(643);c.updateWindowsModeWrappedState=function(p){const m=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),x=m==null?void 0:m.get(p.cols-1),y=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);y&&x&&(y.isWrapped=x[f.CHAR_DATA_CODE_INDEX]!==f.NULL_CELL_CODE&&x[f.CHAR_DATA_CODE_INDEX]!==f.WHITESPACE_CELL_CODE)}},3734:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ExtendedAttrs=c.AttributeData=void 0;class d{constructor(){this.fg=0,this.bg=0,this.extended=new f}static toColorRGB(m){return[m>>>16&255,m>>>8&255,255&m]}static fromColorRGB(m){return(255&m[0])<<16|(255&m[1])<<8|255&m[2]}clone(){const m=new d;return m.fg=this.fg,m.bg=this.bg,m.extended=this.extended.clone(),m}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}c.AttributeData=d;class f{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(m){this._ext=m}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(m){this._ext&=-469762049,this._ext|=m<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(m){this._ext&=-67108864,this._ext|=67108863&m}get urlId(){return this._urlId}set urlId(m){this._urlId=m}get underlineVariantOffset(){const m=(3758096384&this._ext)>>29;return m<0?4294967288^m:m}set underlineVariantOffset(m){this._ext&=536870911,this._ext|=m<<29&3758096384}constructor(m=0,x=0){this._ext=0,this._urlId=0,this._ext=m,this._urlId=x}clone(){return new f(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}c.ExtendedAttrs=f},9092:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Buffer=c.MAX_BUFFER_SIZE=void 0;const f=d(6349),p=d(7226),m=d(3734),x=d(8437),y=d(4634),w=d(511),C=d(643),_=d(4863),S=d(7116);c.MAX_BUFFER_SIZE=4294967295,c.Buffer=class{constructor(b,v,E){this._hasScrollback=b,this._optionsService=v,this._bufferService=E,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=x.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new p.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(b){return b?(this._nullCell.fg=b.fg,this._nullCell.bg=b.bg,this._nullCell.extended=b.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new m.ExtendedAttrs),this._nullCell}getWhitespaceCell(b){return b?(this._whitespaceCell.fg=b.fg,this._whitespaceCell.bg=b.bg,this._whitespaceCell.extended=b.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new m.ExtendedAttrs),this._whitespaceCell}getBlankLine(b,v){return new x.BufferLine(this._bufferService.cols,this.getNullCell(b),v)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const b=this.ybase+this.y-this.ydisp;return b>=0&&b<this._rows}_getCorrectBufferLength(b){if(!this._hasScrollback)return b;const v=b+this._optionsService.rawOptions.scrollback;return v>c.MAX_BUFFER_SIZE?c.MAX_BUFFER_SIZE:v}fillViewportRows(b){if(this.lines.length===0){b===void 0&&(b=x.DEFAULT_ATTR_DATA);let v=this._rows;for(;v--;)this.lines.push(this.getBlankLine(b))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(b,v){const E=this.getNullCell(x.DEFAULT_ATTR_DATA);let j=0;const T=this._getCorrectBufferLength(v);if(T>this.lines.maxLength&&(this.lines.maxLength=T),this.lines.length>0){if(this._cols<b)for(let L=0;L<this.lines.length;L++)j+=+this.lines.get(L).resize(b,E);let D=0;if(this._rows<v)for(let L=this._rows;L<v;L++)this.lines.length<v+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new x.BufferLine(b,E)):this.ybase>0&&this.lines.length<=this.ybase+this.y+D+1?(this.ybase--,D++,this.ydisp>0&&this.ydisp--):this.lines.push(new x.BufferLine(b,E)));else for(let L=this._rows;L>v;L--)this.lines.length>v+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(T<this.lines.maxLength){const L=this.lines.length-T;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=T}this.x=Math.min(this.x,b-1),this.y=Math.min(this.y,v-1),D&&(this.y+=D),this.savedX=Math.min(this.savedX,b-1),this.scrollTop=0}if(this.scrollBottom=v-1,this._isReflowEnabled&&(this._reflow(b,v),this._cols>b))for(let D=0;D<this.lines.length;D++)j+=+this.lines.get(D).resize(b,E);this._cols=b,this._rows=v,this._memoryCleanupQueue.clear(),j>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let b=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,b=!1);let v=0;for(;this._memoryCleanupPosition<this.lines.length;)if(v+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),v>100)return!0;return b}get _isReflowEnabled(){const b=this._optionsService.rawOptions.windowsPty;return b&&b.buildNumber?this._hasScrollback&&b.backend==="conpty"&&b.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(b,v){this._cols!==b&&(b>this._cols?this._reflowLarger(b,v):this._reflowSmaller(b,v))}_reflowLarger(b,v){const E=(0,y.reflowLargerGetLinesToRemove)(this.lines,this._cols,b,this.ybase+this.y,this.getNullCell(x.DEFAULT_ATTR_DATA));if(E.length>0){const j=(0,y.reflowLargerCreateNewLayout)(this.lines,E);(0,y.reflowLargerApplyNewLayout)(this.lines,j.layout),this._reflowLargerAdjustViewport(b,v,j.countRemoved)}}_reflowLargerAdjustViewport(b,v,E){const j=this.getNullCell(x.DEFAULT_ATTR_DATA);let T=E;for(;T-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<v&&this.lines.push(new x.BufferLine(b,j))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-E,0)}_reflowSmaller(b,v){const E=this.getNullCell(x.DEFAULT_ATTR_DATA),j=[];let T=0;for(let D=this.lines.length-1;D>=0;D--){let L=this.lines.get(D);if(!L||!L.isWrapped&&L.getTrimmedLength()<=b)continue;const O=[L];for(;L.isWrapped&&D>0;)L=this.lines.get(--D),O.unshift(L);const M=this.ybase+this.y;if(M>=D&&M<D+O.length)continue;const W=O[O.length-1].getTrimmedLength(),z=(0,y.reflowSmallerGetNewLineLengths)(O,this._cols,b),R=z.length-O.length;let P;P=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+R):Math.max(0,this.lines.length-this.lines.maxLength+R);const V=[];for(let $=0;$<R;$++){const q=this.getBlankLine(x.DEFAULT_ATTR_DATA,!0);V.push(q)}V.length>0&&(j.push({start:D+O.length+T,newLines:V}),T+=V.length),O.push(...V);let G=z.length-1,Z=z[G];Z===0&&(G--,Z=z[G]);let Q=O.length-R-1,U=W;for(;Q>=0;){const $=Math.min(U,Z);if(O[G]===void 0)break;if(O[G].copyCellsFrom(O[Q],U-$,Z-$,$,!0),Z-=$,Z===0&&(G--,Z=z[G]),U-=$,U===0){Q--;const q=Math.max(Q,0);U=(0,y.getWrappedLineTrimmedLength)(O,q,this._cols)}}for(let $=0;$<O.length;$++)z[$]<b&&O[$].setCell(z[$],E);let I=R-P;for(;I-- >0;)this.ybase===0?this.y<v-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-v&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+R,this.ybase+v-1)}if(j.length>0){const D=[],L=[];for(let G=0;G<this.lines.length;G++)L.push(this.lines.get(G));const O=this.lines.length;let M=O-1,W=0,z=j[W];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let R=0;for(let G=Math.min(this.lines.maxLength-1,O+T-1);G>=0;G--)if(z&&z.start>M+R){for(let Z=z.newLines.length-1;Z>=0;Z--)this.lines.set(G--,z.newLines[Z]);G++,D.push({index:M+1,amount:z.newLines.length}),R+=z.newLines.length,z=j[++W]}else this.lines.set(G,L[M--]);let P=0;for(let G=D.length-1;G>=0;G--)D[G].index+=P,this.lines.onInsertEmitter.fire(D[G]),P+=D[G].amount;const V=Math.max(0,O+T-this.lines.maxLength);V>0&&this.lines.onTrimEmitter.fire(V)}}translateBufferLineToString(b,v,E=0,j){const T=this.lines.get(b);return T?T.translateToString(v,E,j):""}getWrappedRangeForLine(b){let v=b,E=b;for(;v>0&&this.lines.get(v).isWrapped;)v--;for(;E+1<this.lines.length&&this.lines.get(E+1).isWrapped;)E++;return{first:v,last:E}}setupTabStops(b){for(b!=null?this.tabs[b]||(b=this.prevStop(b)):(this.tabs={},b=0);b<this._cols;b+=this._optionsService.rawOptions.tabStopWidth)this.tabs[b]=!0}prevStop(b){for(b==null&&(b=this.x);!this.tabs[--b]&&b>0;);return b>=this._cols?this._cols-1:b<0?0:b}nextStop(b){for(b==null&&(b=this.x);!this.tabs[++b]&&b<this._cols;);return b>=this._cols?this._cols-1:b<0?0:b}clearMarkers(b){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].line===b&&(this.markers[v].dispose(),this.markers.splice(v--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].dispose(),this.markers.splice(b--,1);this._isClearing=!1}addMarker(b){const v=new _.Marker(b);return this.markers.push(v),v.register(this.lines.onTrim((E=>{v.line-=E,v.line<0&&v.dispose()}))),v.register(this.lines.onInsert((E=>{v.line>=E.index&&(v.line+=E.amount)}))),v.register(this.lines.onDelete((E=>{v.line>=E.index&&v.line<E.index+E.amount&&v.dispose(),v.line>E.index&&(v.line-=E.amount)}))),v.register(v.onDispose((()=>this._removeMarker(v)))),v}_removeMarker(b){this._isClearing||this.markers.splice(this.markers.indexOf(b),1)}}},8437:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLine=c.DEFAULT_ATTR_DATA=void 0;const f=d(3734),p=d(511),m=d(643),x=d(482);c.DEFAULT_ATTR_DATA=Object.freeze(new f.AttributeData);let y=0;class w{constructor(_,S,b=!1){this.isWrapped=b,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*_);const v=S||p.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]);for(let E=0;E<_;++E)this.setCell(E,v);this.length=_}get(_){const S=this._data[3*_+0],b=2097151&S;return[this._data[3*_+1],2097152&S?this._combined[_]:b?(0,x.stringFromCodePoint)(b):"",S>>22,2097152&S?this._combined[_].charCodeAt(this._combined[_].length-1):b]}set(_,S){this._data[3*_+1]=S[m.CHAR_DATA_ATTR_INDEX],S[m.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[_]=S[1],this._data[3*_+0]=2097152|_|S[m.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*_+0]=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[m.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(_){return this._data[3*_+0]>>22}hasWidth(_){return 12582912&this._data[3*_+0]}getFg(_){return this._data[3*_+1]}getBg(_){return this._data[3*_+2]}hasContent(_){return 4194303&this._data[3*_+0]}getCodePoint(_){const S=this._data[3*_+0];return 2097152&S?this._combined[_].charCodeAt(this._combined[_].length-1):2097151&S}isCombined(_){return 2097152&this._data[3*_+0]}getString(_){const S=this._data[3*_+0];return 2097152&S?this._combined[_]:2097151&S?(0,x.stringFromCodePoint)(2097151&S):""}isProtected(_){return 536870912&this._data[3*_+2]}loadCell(_,S){return y=3*_,S.content=this._data[y+0],S.fg=this._data[y+1],S.bg=this._data[y+2],2097152&S.content&&(S.combinedData=this._combined[_]),268435456&S.bg&&(S.extended=this._extendedAttrs[_]),S}setCell(_,S){2097152&S.content&&(this._combined[_]=S.combinedData),268435456&S.bg&&(this._extendedAttrs[_]=S.extended),this._data[3*_+0]=S.content,this._data[3*_+1]=S.fg,this._data[3*_+2]=S.bg}setCellFromCodepoint(_,S,b,v){268435456&v.bg&&(this._extendedAttrs[_]=v.extended),this._data[3*_+0]=S|b<<22,this._data[3*_+1]=v.fg,this._data[3*_+2]=v.bg}addCodepointToCell(_,S,b){let v=this._data[3*_+0];2097152&v?this._combined[_]+=(0,x.stringFromCodePoint)(S):2097151&v?(this._combined[_]=(0,x.stringFromCodePoint)(2097151&v)+(0,x.stringFromCodePoint)(S),v&=-2097152,v|=2097152):v=S|4194304,b&&(v&=-12582913,v|=b<<22),this._data[3*_+0]=v}insertCells(_,S,b){if((_%=this.length)&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,b),S<this.length-_){const v=new p.CellData;for(let E=this.length-_-S-1;E>=0;--E)this.setCell(_+S+E,this.loadCell(_+E,v));for(let E=0;E<S;++E)this.setCell(_+E,b)}else for(let v=_;v<this.length;++v)this.setCell(v,b);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,b)}deleteCells(_,S,b){if(_%=this.length,S<this.length-_){const v=new p.CellData;for(let E=0;E<this.length-_-S;++E)this.setCell(_+E,this.loadCell(_+S+E,v));for(let E=this.length-S;E<this.length;++E)this.setCell(E,b)}else for(let v=_;v<this.length;++v)this.setCell(v,b);_&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,b),this.getWidth(_)!==0||this.hasContent(_)||this.setCellFromCodepoint(_,0,1,b)}replaceCells(_,S,b,v=!1){if(v)for(_&&this.getWidth(_-1)===2&&!this.isProtected(_-1)&&this.setCellFromCodepoint(_-1,0,1,b),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,b);_<S&&_<this.length;)this.isProtected(_)||this.setCell(_,b),_++;else for(_&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,b),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,b);_<S&&_<this.length;)this.setCell(_++,b)}resize(_,S){if(_===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const b=3*_;if(_>this.length){if(this._data.buffer.byteLength>=4*b)this._data=new Uint32Array(this._data.buffer,0,b);else{const v=new Uint32Array(b);v.set(this._data),this._data=v}for(let v=this.length;v<_;++v)this.setCell(v,S)}else{this._data=this._data.subarray(0,b);const v=Object.keys(this._combined);for(let j=0;j<v.length;j++){const T=parseInt(v[j],10);T>=_&&delete this._combined[T]}const E=Object.keys(this._extendedAttrs);for(let j=0;j<E.length;j++){const T=parseInt(E[j],10);T>=_&&delete this._extendedAttrs[T]}}return this.length=_,4*b*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const _=new Uint32Array(this._data.length);return _.set(this._data),this._data=_,1}return 0}fill(_,S=!1){if(S)for(let b=0;b<this.length;++b)this.isProtected(b)||this.setCell(b,_);else{this._combined={},this._extendedAttrs={};for(let b=0;b<this.length;++b)this.setCell(b,_)}}copyFrom(_){this.length!==_.length?this._data=new Uint32Array(_._data):this._data.set(_._data),this.length=_.length,this._combined={};for(const S in _._combined)this._combined[S]=_._combined[S];this._extendedAttrs={};for(const S in _._extendedAttrs)this._extendedAttrs[S]=_._extendedAttrs[S];this.isWrapped=_.isWrapped}clone(){const _=new w(0);_._data=new Uint32Array(this._data),_.length=this.length;for(const S in this._combined)_._combined[S]=this._combined[S];for(const S in this._extendedAttrs)_._extendedAttrs[S]=this._extendedAttrs[S];return _.isWrapped=this.isWrapped,_}getTrimmedLength(){for(let _=this.length-1;_>=0;--_)if(4194303&this._data[3*_+0])return _+(this._data[3*_+0]>>22);return 0}getNoBgTrimmedLength(){for(let _=this.length-1;_>=0;--_)if(4194303&this._data[3*_+0]||50331648&this._data[3*_+2])return _+(this._data[3*_+0]>>22);return 0}copyCellsFrom(_,S,b,v,E){const j=_._data;if(E)for(let D=v-1;D>=0;D--){for(let L=0;L<3;L++)this._data[3*(b+D)+L]=j[3*(S+D)+L];268435456&j[3*(S+D)+2]&&(this._extendedAttrs[b+D]=_._extendedAttrs[S+D])}else for(let D=0;D<v;D++){for(let L=0;L<3;L++)this._data[3*(b+D)+L]=j[3*(S+D)+L];268435456&j[3*(S+D)+2]&&(this._extendedAttrs[b+D]=_._extendedAttrs[S+D])}const T=Object.keys(_._combined);for(let D=0;D<T.length;D++){const L=parseInt(T[D],10);L>=S&&(this._combined[L-S+b]=_._combined[L])}}translateToString(_,S,b,v){S=S??0,b=b??this.length,_&&(b=Math.min(b,this.getTrimmedLength())),v&&(v.length=0);let E="";for(;S<b;){const j=this._data[3*S+0],T=2097151&j,D=2097152&j?this._combined[S]:T?(0,x.stringFromCodePoint)(T):m.WHITESPACE_CELL_CHAR;if(E+=D,v)for(let L=0;L<D.length;++L)v.push(S);S+=j>>22||1}return v&&v.push(S),E}}c.BufferLine=w},4841:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.getRangeLength=void 0,c.getRangeLength=function(d,f){if(d.start.y>d.end.y)throw new Error(`Buffer range end (${d.end.x}, ${d.end.y}) cannot be before start (${d.start.x}, ${d.start.y})`);return f*(d.end.y-d.start.y)+(d.end.x-d.start.x+1)}},4634:(u,c)=>{function d(f,p,m){if(p===f.length-1)return f[p].getTrimmedLength();const x=!f[p].hasContent(m-1)&&f[p].getWidth(m-1)===1,y=f[p+1].getWidth(0)===2;return x&&y?m-1:m}Object.defineProperty(c,"__esModule",{value:!0}),c.getWrappedLineTrimmedLength=c.reflowSmallerGetNewLineLengths=c.reflowLargerApplyNewLayout=c.reflowLargerCreateNewLayout=c.reflowLargerGetLinesToRemove=void 0,c.reflowLargerGetLinesToRemove=function(f,p,m,x,y){const w=[];for(let C=0;C<f.length-1;C++){let _=C,S=f.get(++_);if(!S.isWrapped)continue;const b=[f.get(C)];for(;_<f.length&&S.isWrapped;)b.push(S),S=f.get(++_);if(x>=C&&x<_){C+=b.length-1;continue}let v=0,E=d(b,v,p),j=1,T=0;for(;j<b.length;){const L=d(b,j,p),O=L-T,M=m-E,W=Math.min(O,M);b[v].copyCellsFrom(b[j],T,E,W,!1),E+=W,E===m&&(v++,E=0),T+=W,T===L&&(j++,T=0),E===0&&v!==0&&b[v-1].getWidth(m-1)===2&&(b[v].copyCellsFrom(b[v-1],m-1,E++,1,!1),b[v-1].setCell(m-1,y))}b[v].replaceCells(E,m,y);let D=0;for(let L=b.length-1;L>0&&(L>v||b[L].getTrimmedLength()===0);L--)D++;D>0&&(w.push(C+b.length-D),w.push(D)),C+=b.length-1}return w},c.reflowLargerCreateNewLayout=function(f,p){const m=[];let x=0,y=p[x],w=0;for(let C=0;C<f.length;C++)if(y===C){const _=p[++x];f.onDeleteEmitter.fire({index:C-w,amount:_}),C+=_-1,w+=_,y=p[++x]}else m.push(C);return{layout:m,countRemoved:w}},c.reflowLargerApplyNewLayout=function(f,p){const m=[];for(let x=0;x<p.length;x++)m.push(f.get(p[x]));for(let x=0;x<m.length;x++)f.set(x,m[x]);f.length=p.length},c.reflowSmallerGetNewLineLengths=function(f,p,m){const x=[],y=f.map(((S,b)=>d(f,b,p))).reduce(((S,b)=>S+b));let w=0,C=0,_=0;for(;_<y;){if(y-_<m){x.push(y-_);break}w+=m;const S=d(f,C,p);w>S&&(w-=S,C++);const b=f[C].getWidth(w-1)===2;b&&w--;const v=b?m-1:m;x.push(v),_+=v}return x},c.getWrappedLineTrimmedLength=d},5295:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferSet=void 0;const f=d(8460),p=d(844),m=d(9092);class x extends p.Disposable{constructor(w,C){super(),this._optionsService=w,this._bufferService=C,this._onBufferActivate=this.register(new f.EventEmitter),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 m.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new m.Buffer(!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(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),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(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}c.BufferSet=x},511:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CellData=void 0;const f=d(482),p=d(643),m=d(3734);class x extends m.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new m.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new x;return C.setFromCharData(w),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,f.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[p.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[p.CHAR_DATA_CHAR_INDEX].length===2){const _=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=_&&_<=56319){const S=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(_-55296)+S-56320+65536|w[p.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[p.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[p.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[p.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.CellData=x},643:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WHITESPACE_CELL_CODE=c.WHITESPACE_CELL_WIDTH=c.WHITESPACE_CELL_CHAR=c.NULL_CELL_CODE=c.NULL_CELL_WIDTH=c.NULL_CELL_CHAR=c.CHAR_DATA_CODE_INDEX=c.CHAR_DATA_WIDTH_INDEX=c.CHAR_DATA_CHAR_INDEX=c.CHAR_DATA_ATTR_INDEX=c.DEFAULT_EXT=c.DEFAULT_ATTR=c.DEFAULT_COLOR=void 0,c.DEFAULT_COLOR=0,c.DEFAULT_ATTR=256|c.DEFAULT_COLOR<<9,c.DEFAULT_EXT=0,c.CHAR_DATA_ATTR_INDEX=0,c.CHAR_DATA_CHAR_INDEX=1,c.CHAR_DATA_WIDTH_INDEX=2,c.CHAR_DATA_CODE_INDEX=3,c.NULL_CELL_CHAR="",c.NULL_CELL_WIDTH=1,c.NULL_CELL_CODE=0,c.WHITESPACE_CELL_CHAR=" ",c.WHITESPACE_CELL_WIDTH=1,c.WHITESPACE_CELL_CODE=32},4863:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Marker=void 0;const f=d(8460),p=d(844);class m{get id(){return this._id}constructor(y){this.line=y,this.isDisposed=!1,this._disposables=[],this._id=m._nextId++,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,p.disposeArray)(this._disposables),this._disposables.length=0)}register(y){return this._disposables.push(y),y}}c.Marker=m,m._nextId=1},7116:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DEFAULT_CHARSET=c.CHARSETS=void 0,c.CHARSETS={},c.DEFAULT_CHARSET=c.CHARSETS.B,c.CHARSETS[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:"≥","{":"π","|":"≠","}":"£","~":"·"},c.CHARSETS.A={"#":"£"},c.CHARSETS.B=void 0,c.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},c.CHARSETS.C=c.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},c.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},c.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},c.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},c.CHARSETS.E=c.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},c.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},c.CHARSETS.H=c.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(u,c)=>{var d,f,p;Object.defineProperty(c,"__esModule",{value:!0}),c.C1_ESCAPED=c.C1=c.C0=void 0,(function(m){m.NUL="\0",m.SOH="",m.STX="",m.ETX="",m.EOT="",m.ENQ="",m.ACK="",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
|
|
252
|
+
`,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="",m.SI="",m.DLE="",m.DC1="",m.DC2="",m.DC3="",m.DC4="",m.NAK="",m.SYN="",m.ETB="",m.CAN="",m.EM="",m.SUB="",m.ESC="\x1B",m.FS="",m.GS="",m.RS="",m.US="",m.SP=" ",m.DEL=""})(d||(c.C0=d={})),(function(m){m.PAD="",m.HOP="",m.BPH="",m.NBH="",m.IND="",m.NEL="
",m.SSA="",m.ESA="",m.HTS="",m.HTJ="",m.VTS="",m.PLD="",m.PLU="",m.RI="",m.SS2="",m.SS3="",m.DCS="",m.PU1="",m.PU2="",m.STS="",m.CCH="",m.MW="",m.SPA="",m.EPA="",m.SOS="",m.SGCI="",m.SCI="",m.CSI="",m.ST="",m.OSC="",m.PM="",m.APC=""})(f||(c.C1=f={})),(function(m){m.ST=`${d.ESC}\\`})(p||(c.C1_ESCAPED=p={}))},7399:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.evaluateKeyboardEvent=void 0;const f=d(2584),p={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:["'",'"']};c.evaluateKeyboardEvent=function(m,x,y,w){const C={type:0,cancel:!1,key:void 0},_=(m.shiftKey?1:0)|(m.altKey?2:0)|(m.ctrlKey?4:0)|(m.metaKey?8:0);switch(m.keyCode){case 0:m.key==="UIKeyInputUpArrow"?C.key=x?f.C0.ESC+"OA":f.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?C.key=x?f.C0.ESC+"OD":f.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?C.key=x?f.C0.ESC+"OC":f.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(C.key=x?f.C0.ESC+"OB":f.C0.ESC+"[B");break;case 8:C.key=m.ctrlKey?"\b":f.C0.DEL,m.altKey&&(C.key=f.C0.ESC+C.key);break;case 9:if(m.shiftKey){C.key=f.C0.ESC+"[Z";break}C.key=f.C0.HT,C.cancel=!0;break;case 13:C.key=m.altKey?f.C0.ESC+f.C0.CR:f.C0.CR,C.cancel=!0;break;case 27:C.key=f.C0.ESC,m.altKey&&(C.key=f.C0.ESC+f.C0.ESC),C.cancel=!0;break;case 37:if(m.metaKey)break;_?(C.key=f.C0.ESC+"[1;"+(_+1)+"D",C.key===f.C0.ESC+"[1;3D"&&(C.key=f.C0.ESC+(y?"b":"[1;5D"))):C.key=x?f.C0.ESC+"OD":f.C0.ESC+"[D";break;case 39:if(m.metaKey)break;_?(C.key=f.C0.ESC+"[1;"+(_+1)+"C",C.key===f.C0.ESC+"[1;3C"&&(C.key=f.C0.ESC+(y?"f":"[1;5C"))):C.key=x?f.C0.ESC+"OC":f.C0.ESC+"[C";break;case 38:if(m.metaKey)break;_?(C.key=f.C0.ESC+"[1;"+(_+1)+"A",y||C.key!==f.C0.ESC+"[1;3A"||(C.key=f.C0.ESC+"[1;5A")):C.key=x?f.C0.ESC+"OA":f.C0.ESC+"[A";break;case 40:if(m.metaKey)break;_?(C.key=f.C0.ESC+"[1;"+(_+1)+"B",y||C.key!==f.C0.ESC+"[1;3B"||(C.key=f.C0.ESC+"[1;5B")):C.key=x?f.C0.ESC+"OB":f.C0.ESC+"[B";break;case 45:m.shiftKey||m.ctrlKey||(C.key=f.C0.ESC+"[2~");break;case 46:C.key=_?f.C0.ESC+"[3;"+(_+1)+"~":f.C0.ESC+"[3~";break;case 36:C.key=_?f.C0.ESC+"[1;"+(_+1)+"H":x?f.C0.ESC+"OH":f.C0.ESC+"[H";break;case 35:C.key=_?f.C0.ESC+"[1;"+(_+1)+"F":x?f.C0.ESC+"OF":f.C0.ESC+"[F";break;case 33:m.shiftKey?C.type=2:m.ctrlKey?C.key=f.C0.ESC+"[5;"+(_+1)+"~":C.key=f.C0.ESC+"[5~";break;case 34:m.shiftKey?C.type=3:m.ctrlKey?C.key=f.C0.ESC+"[6;"+(_+1)+"~":C.key=f.C0.ESC+"[6~";break;case 112:C.key=_?f.C0.ESC+"[1;"+(_+1)+"P":f.C0.ESC+"OP";break;case 113:C.key=_?f.C0.ESC+"[1;"+(_+1)+"Q":f.C0.ESC+"OQ";break;case 114:C.key=_?f.C0.ESC+"[1;"+(_+1)+"R":f.C0.ESC+"OR";break;case 115:C.key=_?f.C0.ESC+"[1;"+(_+1)+"S":f.C0.ESC+"OS";break;case 116:C.key=_?f.C0.ESC+"[15;"+(_+1)+"~":f.C0.ESC+"[15~";break;case 117:C.key=_?f.C0.ESC+"[17;"+(_+1)+"~":f.C0.ESC+"[17~";break;case 118:C.key=_?f.C0.ESC+"[18;"+(_+1)+"~":f.C0.ESC+"[18~";break;case 119:C.key=_?f.C0.ESC+"[19;"+(_+1)+"~":f.C0.ESC+"[19~";break;case 120:C.key=_?f.C0.ESC+"[20;"+(_+1)+"~":f.C0.ESC+"[20~";break;case 121:C.key=_?f.C0.ESC+"[21;"+(_+1)+"~":f.C0.ESC+"[21~";break;case 122:C.key=_?f.C0.ESC+"[23;"+(_+1)+"~":f.C0.ESC+"[23~";break;case 123:C.key=_?f.C0.ESC+"[24;"+(_+1)+"~":f.C0.ESC+"[24~";break;default:if(!m.ctrlKey||m.shiftKey||m.altKey||m.metaKey)if(y&&!w||!m.altKey||m.metaKey)!y||m.altKey||m.ctrlKey||m.shiftKey||!m.metaKey?m.key&&!m.ctrlKey&&!m.altKey&&!m.metaKey&&m.keyCode>=48&&m.key.length===1?C.key=m.key:m.key&&m.ctrlKey&&(m.key==="_"&&(C.key=f.C0.US),m.key==="@"&&(C.key=f.C0.NUL)):m.keyCode===65&&(C.type=1);else{const S=p[m.keyCode],b=S==null?void 0:S[m.shiftKey?1:0];if(b)C.key=f.C0.ESC+b;else if(m.keyCode>=65&&m.keyCode<=90){const v=m.ctrlKey?m.keyCode-64:m.keyCode+32;let E=String.fromCharCode(v);m.shiftKey&&(E=E.toUpperCase()),C.key=f.C0.ESC+E}else if(m.keyCode===32)C.key=f.C0.ESC+(m.ctrlKey?f.C0.NUL:" ");else if(m.key==="Dead"&&m.code.startsWith("Key")){let v=m.code.slice(3,4);m.shiftKey||(v=v.toLowerCase()),C.key=f.C0.ESC+v,C.cancel=!0}}else m.keyCode>=65&&m.keyCode<=90?C.key=String.fromCharCode(m.keyCode-64):m.keyCode===32?C.key=f.C0.NUL:m.keyCode>=51&&m.keyCode<=55?C.key=String.fromCharCode(m.keyCode-51+27):m.keyCode===56?C.key=f.C0.DEL:m.keyCode===219?C.key=f.C0.ESC:m.keyCode===220?C.key=f.C0.FS:m.keyCode===221&&(C.key=f.C0.GS)}return C}},482:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Utf8ToUtf32=c.StringToUtf32=c.utf32ToString=c.stringFromCodePoint=void 0,c.stringFromCodePoint=function(d){return d>65535?(d-=65536,String.fromCharCode(55296+(d>>10))+String.fromCharCode(d%1024+56320)):String.fromCharCode(d)},c.utf32ToString=function(d,f=0,p=d.length){let m="";for(let x=f;x<p;++x){let y=d[x];y>65535?(y-=65536,m+=String.fromCharCode(55296+(y>>10))+String.fromCharCode(y%1024+56320)):m+=String.fromCharCode(y)}return m},c.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,f){const p=d.length;if(!p)return 0;let m=0,x=0;if(this._interim){const y=d.charCodeAt(x++);56320<=y&&y<=57343?f[m++]=1024*(this._interim-55296)+y-56320+65536:(f[m++]=this._interim,f[m++]=y),this._interim=0}for(let y=x;y<p;++y){const w=d.charCodeAt(y);if(55296<=w&&w<=56319){if(++y>=p)return this._interim=w,m;const C=d.charCodeAt(y);56320<=C&&C<=57343?f[m++]=1024*(w-55296)+C-56320+65536:(f[m++]=w,f[m++]=C)}else w!==65279&&(f[m++]=w)}return m}},c.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,f){const p=d.length;if(!p)return 0;let m,x,y,w,C=0,_=0,S=0;if(this.interim[0]){let E=!1,j=this.interim[0];j&=(224&j)==192?31:(240&j)==224?15:7;let T,D=0;for(;(T=63&this.interim[++D])&&D<4;)j<<=6,j|=T;const L=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,O=L-D;for(;S<O;){if(S>=p)return 0;if(T=d[S++],(192&T)!=128){S--,E=!0;break}this.interim[D++]=T,j<<=6,j|=63&T}E||(L===2?j<128?S--:f[C++]=j:L===3?j<2048||j>=55296&&j<=57343||j===65279||(f[C++]=j):j<65536||j>1114111||(f[C++]=j)),this.interim.fill(0)}const b=p-4;let v=S;for(;v<p;){for(;!(!(v<b)||128&(m=d[v])||128&(x=d[v+1])||128&(y=d[v+2])||128&(w=d[v+3]));)f[C++]=m,f[C++]=x,f[C++]=y,f[C++]=w,v+=4;if(m=d[v++],m<128)f[C++]=m;else if((224&m)==192){if(v>=p)return this.interim[0]=m,C;if(x=d[v++],(192&x)!=128){v--;continue}if(_=(31&m)<<6|63&x,_<128){v--;continue}f[C++]=_}else if((240&m)==224){if(v>=p)return this.interim[0]=m,C;if(x=d[v++],(192&x)!=128){v--;continue}if(v>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[v++],(192&y)!=128){v--;continue}if(_=(15&m)<<12|(63&x)<<6|63&y,_<2048||_>=55296&&_<=57343||_===65279)continue;f[C++]=_}else if((248&m)==240){if(v>=p)return this.interim[0]=m,C;if(x=d[v++],(192&x)!=128){v--;continue}if(v>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[v++],(192&y)!=128){v--;continue}if(v>=p)return this.interim[0]=m,this.interim[1]=x,this.interim[2]=y,C;if(w=d[v++],(192&w)!=128){v--;continue}if(_=(7&m)<<18|(63&x)<<12|(63&y)<<6|63&w,_<65536||_>1114111)continue;f[C++]=_}}return C}}},225:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeV6=void 0;const f=d(1480),p=[[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]],m=[[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]];let x;c.UnicodeV6=class{constructor(){if(this.version="6",!x){x=new Uint8Array(65536),x.fill(1),x[0]=0,x.fill(0,1,32),x.fill(0,127,160),x.fill(2,4352,4448),x[9001]=2,x[9002]=2,x.fill(2,11904,42192),x[12351]=1,x.fill(2,44032,55204),x.fill(2,63744,64256),x.fill(2,65040,65050),x.fill(2,65072,65136),x.fill(2,65280,65377),x.fill(2,65504,65511);for(let y=0;y<p.length;++y)x.fill(0,p[y][0],p[y][1]+1)}}wcwidth(y){return y<32?0:y<127?1:y<65536?x[y]:(function(w,C){let _,S=0,b=C.length-1;if(w<C[0][0]||w>C[b][1])return!1;for(;b>=S;)if(_=S+b>>1,w>C[_][1])S=_+1;else{if(!(w<C[_][0]))return!0;b=_-1}return!1})(y,m)?0:y>=131072&&y<=196605||y>=196608&&y<=262141?2:1}charProperties(y,w){let C=this.wcwidth(y),_=C===0&&w!==0;if(_){const S=f.UnicodeService.extractWidth(w);S===0?_=!1:S>C&&(C=S)}return f.UnicodeService.createPropertyValue(0,C,_)}}},5981:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WriteBuffer=void 0;const f=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._action=y,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new f.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(y,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const _=this._callbacks.shift();_&&_()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(y,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(w)}_innerWrite(y=0,w=!0){const C=y||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const _=this._writeBuffer[this._bufferOffset],S=this._action(_,w);if(S){const v=E=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,E))):this._innerWrite(C,E);return void S.catch((E=>(queueMicrotask((()=>{throw E})),Promise.resolve(!1)))).then(v)}const b=this._callbacks[this._bufferOffset];if(b&&b(),this._bufferOffset++,this._pendingData-=_.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}}c.WriteBuffer=m},5941:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.toRgbString=c.parseColor=void 0;const d=/^([\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})$/,f=/^[\da-f]+$/;function p(m,x){const y=m.toString(16),w=y.length<2?"0"+y:y;switch(x){case 4:return y[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}c.parseColor=function(m){if(!m)return;let x=m.toLowerCase();if(x.indexOf("rgb:")===0){x=x.slice(4);const y=d.exec(x);if(y){const w=y[1]?15:y[4]?255:y[7]?4095:65535;return[Math.round(parseInt(y[1]||y[4]||y[7]||y[10],16)/w*255),Math.round(parseInt(y[2]||y[5]||y[8]||y[11],16)/w*255),Math.round(parseInt(y[3]||y[6]||y[9]||y[12],16)/w*255)]}}else if(x.indexOf("#")===0&&(x=x.slice(1),f.exec(x)&&[3,6,9,12].includes(x.length))){const y=x.length/3,w=[0,0,0];for(let C=0;C<3;++C){const _=parseInt(x.slice(y*C,y*C+y),16);w[C]=y===1?_<<4:y===2?_:y===3?_>>4:_>>8}return w}},c.toRgbString=function(m,x=16){const[y,w,C]=m;return`rgb:${p(y,x)}/${p(w,x)}/${p(C,x)}`}},5770:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.PAYLOAD_LIMIT=void 0,c.PAYLOAD_LIMIT=1e7},6351:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DcsHandler=c.DcsParser=void 0;const f=d(482),p=d(8742),m=d(5770),x=[];c.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=x,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=x}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const _=this._handlers[w];return _.push(C),{dispose:()=>{const S=_.indexOf(C);S!==-1&&_.splice(S,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=x,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||x,this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(w,C,_){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(w,C,_);else this._handlerFb(this._ident,"PUT",(0,f.utf32ToString)(w,C,_))}unhook(w,C=!0){if(this._active.length){let _=!1,S=this._active.length-1,b=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,_=C,b=this._stack.fallThrough,this._stack.paused=!1),!b&&_===!1){for(;S>=0&&(_=this._active[S].unhook(w),_!==!0);S--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,_;S--}for(;S>=0;S--)if(_=this._active[S].unhook(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,_}else this._handlerFb(this._ident,"UNHOOK",w);this._active=x,this._ident=0}};const y=new p.Params;y.addParam(0),c.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=y,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():y,this._data="",this._hitLimit=!1}put(w,C,_){this._hitLimit||(this._data+=(0,f.utf32ToString)(w,C,_),this._data.length>m.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((_=>(this._params=y,this._data="",this._hitLimit=!1,_)));return this._params=y,this._data="",this._hitLimit=!1,C}}},2015:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.EscapeSequenceParser=c.VT500_TRANSITION_TABLE=c.TransitionTable=void 0;const f=d(844),p=d(8742),m=d(6242),x=d(6351);class y{constructor(S){this.table=new Uint8Array(S)}setDefault(S,b){this.table.fill(S<<4|b)}add(S,b,v,E){this.table[b<<8|S]=v<<4|E}addMany(S,b,v,E){for(let j=0;j<S.length;j++)this.table[b<<8|S[j]]=v<<4|E}}c.TransitionTable=y;const w=160;c.VT500_TRANSITION_TABLE=(function(){const _=new y(4095),S=Array.apply(null,Array(256)).map(((D,L)=>L)),b=(D,L)=>S.slice(D,L),v=b(32,127),E=b(0,24);E.push(25),E.push.apply(E,b(28,32));const j=b(0,14);let T;for(T in _.setDefault(1,0),_.addMany(v,0,2,0),j)_.addMany([24,26,153,154],T,3,0),_.addMany(b(128,144),T,3,0),_.addMany(b(144,152),T,3,0),_.add(156,T,0,0),_.add(27,T,11,1),_.add(157,T,4,8),_.addMany([152,158,159],T,0,7),_.add(155,T,11,3),_.add(144,T,11,9);return _.addMany(E,0,3,0),_.addMany(E,1,3,1),_.add(127,1,0,1),_.addMany(E,8,0,8),_.addMany(E,3,3,3),_.add(127,3,0,3),_.addMany(E,4,3,4),_.add(127,4,0,4),_.addMany(E,6,3,6),_.addMany(E,5,3,5),_.add(127,5,0,5),_.addMany(E,2,3,2),_.add(127,2,0,2),_.add(93,1,4,8),_.addMany(v,8,5,8),_.add(127,8,5,8),_.addMany([156,27,24,26,7],8,6,0),_.addMany(b(28,32),8,0,8),_.addMany([88,94,95],1,0,7),_.addMany(v,7,0,7),_.addMany(E,7,0,7),_.add(156,7,0,0),_.add(127,7,0,7),_.add(91,1,11,3),_.addMany(b(64,127),3,7,0),_.addMany(b(48,60),3,8,4),_.addMany([60,61,62,63],3,9,4),_.addMany(b(48,60),4,8,4),_.addMany(b(64,127),4,7,0),_.addMany([60,61,62,63],4,0,6),_.addMany(b(32,64),6,0,6),_.add(127,6,0,6),_.addMany(b(64,127),6,0,0),_.addMany(b(32,48),3,9,5),_.addMany(b(32,48),5,9,5),_.addMany(b(48,64),5,0,6),_.addMany(b(64,127),5,7,0),_.addMany(b(32,48),4,9,5),_.addMany(b(32,48),1,9,2),_.addMany(b(32,48),2,9,2),_.addMany(b(48,127),2,10,0),_.addMany(b(48,80),1,10,0),_.addMany(b(81,88),1,10,0),_.addMany([89,90,92],1,10,0),_.addMany(b(96,127),1,10,0),_.add(80,1,11,9),_.addMany(E,9,0,9),_.add(127,9,0,9),_.addMany(b(28,32),9,0,9),_.addMany(b(32,48),9,9,12),_.addMany(b(48,60),9,8,10),_.addMany([60,61,62,63],9,9,10),_.addMany(E,11,0,11),_.addMany(b(32,128),11,0,11),_.addMany(b(28,32),11,0,11),_.addMany(E,10,0,10),_.add(127,10,0,10),_.addMany(b(28,32),10,0,10),_.addMany(b(48,60),10,8,10),_.addMany([60,61,62,63],10,0,11),_.addMany(b(32,48),10,9,12),_.addMany(E,12,0,12),_.add(127,12,0,12),_.addMany(b(28,32),12,0,12),_.addMany(b(32,48),12,9,12),_.addMany(b(48,64),12,0,11),_.addMany(b(64,127),12,12,13),_.addMany(b(64,127),10,12,13),_.addMany(b(64,127),9,12,13),_.addMany(E,13,13,13),_.addMany(v,13,13,13),_.add(127,13,0,13),_.addMany([27,156,24,26],13,14,0),_.add(w,0,2,0),_.add(w,8,5,8),_.add(w,6,0,6),_.add(w,11,0,11),_.add(w,13,13,13),_})();class C extends f.Disposable{constructor(S=c.VT500_TRANSITION_TABLE){super(),this._transitions=S,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(b,v,E)=>{},this._executeHandlerFb=b=>{},this._csiHandlerFb=(b,v)=>{},this._escHandlerFb=b=>{},this._errorHandlerFb=b=>b,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,f.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new m.OscParser),this._dcsParser=this.register(new x.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,b=[64,126]){let v=0;if(S.prefix){if(S.prefix.length>1)throw new Error("only one byte as prefix supported");if(v=S.prefix.charCodeAt(0),v&&60>v||v>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(S.intermediates){if(S.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let j=0;j<S.intermediates.length;++j){const T=S.intermediates.charCodeAt(j);if(32>T||T>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");v<<=8,v|=T}}if(S.final.length!==1)throw new Error("final must be a single byte");const E=S.final.charCodeAt(0);if(b[0]>E||E>b[1])throw new Error(`final must be in range ${b[0]} .. ${b[1]}`);return v<<=8,v|=E,v}identToString(S){const b=[];for(;S;)b.push(String.fromCharCode(255&S)),S>>=8;return b.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,b){const v=this._identifier(S,[48,126]);this._escHandlers[v]===void 0&&(this._escHandlers[v]=[]);const E=this._escHandlers[v];return E.push(b),{dispose:()=>{const j=E.indexOf(b);j!==-1&&E.splice(j,1)}}}clearEscHandler(S){this._escHandlers[this._identifier(S,[48,126])]&&delete this._escHandlers[this._identifier(S,[48,126])]}setEscHandlerFallback(S){this._escHandlerFb=S}setExecuteHandler(S,b){this._executeHandlers[S.charCodeAt(0)]=b}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,b){const v=this._identifier(S);this._csiHandlers[v]===void 0&&(this._csiHandlers[v]=[]);const E=this._csiHandlers[v];return E.push(b),{dispose:()=>{const j=E.indexOf(b);j!==-1&&E.splice(j,1)}}}clearCsiHandler(S){this._csiHandlers[this._identifier(S)]&&delete this._csiHandlers[this._identifier(S)]}setCsiHandlerFallback(S){this._csiHandlerFb=S}registerDcsHandler(S,b){return this._dcsParser.registerHandler(this._identifier(S),b)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,b){return this._oscParser.registerHandler(S,b)}clearOscHandler(S){this._oscParser.clearHandler(S)}setOscHandlerFallback(S){this._oscParser.setHandlerFallback(S)}setErrorHandler(S){this._errorHandler=S}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(S,b,v,E,j){this._parseStack.state=S,this._parseStack.handlers=b,this._parseStack.handlerPos=v,this._parseStack.transition=E,this._parseStack.chunkPos=j}parse(S,b,v){let E,j=0,T=0,D=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,D=this._parseStack.chunkPos+1;else{if(v===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const L=this._parseStack.handlers;let O=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(v===!1&&O>-1){for(;O>=0&&(E=L[O](this._params),E!==!0);O--)if(E instanceof Promise)return this._parseStack.handlerPos=O,E}this._parseStack.handlers=[];break;case 4:if(v===!1&&O>-1){for(;O>=0&&(E=L[O](),E!==!0);O--)if(E instanceof Promise)return this._parseStack.handlerPos=O,E}this._parseStack.handlers=[];break;case 6:if(j=S[this._parseStack.chunkPos],E=this._dcsParser.unhook(j!==24&&j!==26,v),E)return E;j===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(j=S[this._parseStack.chunkPos],E=this._oscParser.end(j!==24&&j!==26,v),E)return E;j===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,D=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let L=D;L<b;++L){switch(j=S[L],T=this._transitions.table[this.currentState<<8|(j<160?j:w)],T>>4){case 2:for(let R=L+1;;++R){if(R>=b||(j=S[R])<32||j>126&&j<w){this._printHandler(S,L,R),L=R-1;break}if(++R>=b||(j=S[R])<32||j>126&&j<w){this._printHandler(S,L,R),L=R-1;break}if(++R>=b||(j=S[R])<32||j>126&&j<w){this._printHandler(S,L,R),L=R-1;break}if(++R>=b||(j=S[R])<32||j>126&&j<w){this._printHandler(S,L,R),L=R-1;break}}break;case 3:this._executeHandlers[j]?this._executeHandlers[j]():this._executeHandlerFb(j),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:L,code:j,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const O=this._csiHandlers[this._collect<<8|j];let M=O?O.length-1:-1;for(;M>=0&&(E=O[M](this._params),E!==!0);M--)if(E instanceof Promise)return this._preserveStack(3,O,M,T,L),E;M<0&&this._csiHandlerFb(this._collect<<8|j,this._params),this.precedingJoinState=0;break;case 8:do switch(j){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(j-48)}while(++L<b&&(j=S[L])>47&&j<60);L--;break;case 9:this._collect<<=8,this._collect|=j;break;case 10:const W=this._escHandlers[this._collect<<8|j];let z=W?W.length-1:-1;for(;z>=0&&(E=W[z](),E!==!0);z--)if(E instanceof Promise)return this._preserveStack(4,W,z,T,L),E;z<0&&this._escHandlerFb(this._collect<<8|j),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|j,this._params);break;case 13:for(let R=L+1;;++R)if(R>=b||(j=S[R])===24||j===26||j===27||j>127&&j<w){this._dcsParser.put(S,L,R),L=R-1;break}break;case 14:if(E=this._dcsParser.unhook(j!==24&&j!==26),E)return this._preserveStack(6,[],0,T,L),E;j===27&&(T|=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 R=L+1;;R++)if(R>=b||(j=S[R])<32||j>127&&j<w){this._oscParser.put(S,L,R),L=R-1;break}break;case 6:if(E=this._oscParser.end(j!==24&&j!==26),E)return this._preserveStack(5,[],0,T,L),E;j===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&T}}}c.EscapeSequenceParser=C},6242:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OscHandler=c.OscParser=void 0;const f=d(5770),p=d(482),m=[];c.OscParser=class{constructor(){this._state=0,this._active=m,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(x,y){this._handlers[x]===void 0&&(this._handlers[x]=[]);const w=this._handlers[x];return w.push(y),{dispose:()=>{const C=w.indexOf(y);C!==-1&&w.splice(C,1)}}}clearHandler(x){this._handlers[x]&&delete this._handlers[x]}setHandlerFallback(x){this._handlerFb=x}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}reset(){if(this._state===2)for(let x=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;x>=0;--x)this._active[x].end(!1);this._stack.paused=!1,this._active=m,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||m,this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].start();else this._handlerFb(this._id,"START")}_put(x,y,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(x,y,w);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(x,y,w))}start(){this.reset(),this._state=1}put(x,y,w){if(this._state!==3){if(this._state===1)for(;y<w;){const C=x[y++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-y>0&&this._put(x,y,w)}}end(x,y=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let w=!1,C=this._active.length-1,_=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=y,_=this._stack.fallThrough,this._stack.paused=!1),!_&&w===!1){for(;C>=0&&(w=this._active[C].end(x),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",x);this._active=m,this._id=-1,this._state=0}}},c.OscHandler=class{constructor(x){this._handler=x,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(x,y,w){this._hitLimit||(this._data+=(0,p.utf32ToString)(x,y,w),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(x){let y=!1;if(this._hitLimit)y=!1;else if(x&&(y=this._handler(this._data),y instanceof Promise))return y.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,y}}},8742:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Params=void 0;const d=2147483647;class f{static fromArray(m){const x=new f;if(!m.length)return x;for(let y=Array.isArray(m[0])?1:0;y<m.length;++y){const w=m[y];if(Array.isArray(w))for(let C=0;C<w.length;++C)x.addSubParam(w[C]);else x.addParam(w)}return x}constructor(m=32,x=32){if(this.maxLength=m,this.maxSubParamsLength=x,x>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(m),this.length=0,this._subParams=new Int32Array(x),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(m),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const m=new f(this.maxLength,this.maxSubParamsLength);return m.params.set(this.params),m.length=this.length,m._subParams.set(this._subParams),m._subParamsLength=this._subParamsLength,m._subParamsIdx.set(this._subParamsIdx),m._rejectDigits=this._rejectDigits,m._rejectSubDigits=this._rejectSubDigits,m._digitIsSub=this._digitIsSub,m}toArray(){const m=[];for(let x=0;x<this.length;++x){m.push(this.params[x]);const y=this._subParamsIdx[x]>>8,w=255&this._subParamsIdx[x];w-y>0&&m.push(Array.prototype.slice.call(this._subParams,y,w))}return m}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(m){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=m>d?d:m}}addSubParam(m){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=m>d?d:m,this._subParamsIdx[this.length-1]++}}hasSubParams(m){return(255&this._subParamsIdx[m])-(this._subParamsIdx[m]>>8)>0}getSubParams(m){const x=this._subParamsIdx[m]>>8,y=255&this._subParamsIdx[m];return y-x>0?this._subParams.subarray(x,y):null}getSubParamsAll(){const m={};for(let x=0;x<this.length;++x){const y=this._subParamsIdx[x]>>8,w=255&this._subParamsIdx[x];w-y>0&&(m[x]=this._subParams.slice(y,w))}return m}addDigit(m){let x;if(this._rejectDigits||!(x=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const y=this._digitIsSub?this._subParams:this.params,w=y[x-1];y[x-1]=~w?Math.min(10*w+m,d):m}}c.Params=f},5741:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.AddonManager=void 0,c.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let d=this._addons.length-1;d>=0;d--)this._addons[d].instance.dispose()}loadAddon(d,f){const p={instance:f,dispose:f.dispose,isDisposed:!1};this._addons.push(p),f.dispose=()=>this._wrappedAddonDispose(p),f.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let f=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===d){f=p;break}if(f===-1)throw new Error("Could not dispose an addon that has not been loaded");d.isDisposed=!0,d.dispose.apply(d.instance),this._addons.splice(f,1)}}},8771:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferApiView=void 0;const f=d(3785),p=d(511);c.BufferApiView=class{constructor(m,x){this._buffer=m,this.type=x}init(m){return this._buffer=m,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(m){const x=this._buffer.lines.get(m);if(x)return new f.BufferLineApiView(x)}getNullCell(){return new p.CellData}}},3785:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLineApiView=void 0;const f=d(511);c.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,m){if(!(p<0||p>=this._line.length))return m?(this._line.loadCell(p,m),m):this._line.loadCell(p,new f.CellData)}translateToString(p,m,x){return this._line.translateToString(p,m,x)}}},8285:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferNamespaceApi=void 0;const f=d(8771),p=d(8460),m=d(844);class x extends m.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new p.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new f.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new f.BufferApiView(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)}}c.BufferNamespaceApi=x},7975:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ParserApi=void 0,c.ParserApi=class{constructor(d){this._core=d}registerCsiHandler(d,f){return this._core.registerCsiHandler(d,(p=>f(p.toArray())))}addCsiHandler(d,f){return this.registerCsiHandler(d,f)}registerDcsHandler(d,f){return this._core.registerDcsHandler(d,((p,m)=>f(p,m.toArray())))}addDcsHandler(d,f){return this.registerDcsHandler(d,f)}registerEscHandler(d,f){return this._core.registerEscHandler(d,f)}addEscHandler(d,f){return this.registerEscHandler(d,f)}registerOscHandler(d,f){return this._core.registerOscHandler(d,f)}addOscHandler(d,f){return this.registerOscHandler(d,f)}}},7090:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeApi=void 0,c.UnicodeApi=class{constructor(d){this._core=d}register(d){this._core.unicodeService.register(d)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(d){this._core.unicodeService.activeVersion=d}}},744:function(u,c,d){var f=this&&this.__decorate||function(_,S,b,v){var E,j=arguments.length,T=j<3?S:v===null?v=Object.getOwnPropertyDescriptor(S,b):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,S,b,v);else for(var D=_.length-1;D>=0;D--)(E=_[D])&&(T=(j<3?E(T):j>3?E(S,b,T):E(S,b))||T);return j>3&&T&&Object.defineProperty(S,b,T),T},p=this&&this.__param||function(_,S){return function(b,v){S(b,v,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferService=c.MINIMUM_ROWS=c.MINIMUM_COLS=void 0;const m=d(8460),x=d(844),y=d(5295),w=d(2585);c.MINIMUM_COLS=2,c.MINIMUM_ROWS=1;let C=c.BufferService=class extends x.Disposable{get buffer(){return this.buffers.active}constructor(_){super(),this.isUserScrolling=!1,this._onResize=this.register(new m.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new m.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(_.rawOptions.cols||0,c.MINIMUM_COLS),this.rows=Math.max(_.rawOptions.rows||0,c.MINIMUM_ROWS),this.buffers=this.register(new y.BufferSet(_,this))}resize(_,S){this.cols=_,this.rows=S,this.buffers.resize(_,S),this._onResize.fire({cols:_,rows:S})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(_,S=!1){const b=this.buffer;let v;v=this._cachedBlankLine,v&&v.length===this.cols&&v.getFg(0)===_.fg&&v.getBg(0)===_.bg||(v=b.getBlankLine(_,S),this._cachedBlankLine=v),v.isWrapped=S;const E=b.ybase+b.scrollTop,j=b.ybase+b.scrollBottom;if(b.scrollTop===0){const T=b.lines.isFull;j===b.lines.length-1?T?b.lines.recycle().copyFrom(v):b.lines.push(v.clone()):b.lines.splice(j+1,0,v.clone()),T?this.isUserScrolling&&(b.ydisp=Math.max(b.ydisp-1,0)):(b.ybase++,this.isUserScrolling||b.ydisp++)}else{const T=j-E+1;b.lines.shiftElements(E+1,T-1,-1),b.lines.set(j,v.clone())}this.isUserScrolling||(b.ydisp=b.ybase),this._onScroll.fire(b.ydisp)}scrollLines(_,S,b){const v=this.buffer;if(_<0){if(v.ydisp===0)return;this.isUserScrolling=!0}else _+v.ydisp>=v.ybase&&(this.isUserScrolling=!1);const E=v.ydisp;v.ydisp=Math.max(Math.min(v.ydisp+_,v.ybase),0),E!==v.ydisp&&(S||this._onScroll.fire(v.ydisp))}};c.BufferService=C=f([p(0,w.IOptionsService)],C)},7994:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CharsetService=void 0,c.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(d){this.glevel=d,this.charset=this._charsets[d]}setgCharset(d,f){this._charsets[d]=f,this.glevel===d&&(this.charset=f)}}},1753:function(u,c,d){var f=this&&this.__decorate||function(v,E,j,T){var D,L=arguments.length,O=L<3?E:T===null?T=Object.getOwnPropertyDescriptor(E,j):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,E,j,T);else for(var M=v.length-1;M>=0;M--)(D=v[M])&&(O=(L<3?D(O):L>3?D(E,j,O):D(E,j))||O);return L>3&&O&&Object.defineProperty(E,j,O),O},p=this&&this.__param||function(v,E){return function(j,T){E(j,T,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreMouseService=void 0;const m=d(2585),x=d(8460),y=d(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:v=>v.button!==4&&v.action===1&&(v.ctrl=!1,v.alt=!1,v.shift=!1,!0)},VT200:{events:19,restrict:v=>v.action!==32},DRAG:{events:23,restrict:v=>v.action!==32||v.button!==3},ANY:{events:31,restrict:v=>!0}};function C(v,E){let j=(v.ctrl?16:0)|(v.shift?4:0)|(v.alt?8:0);return v.button===4?(j|=64,j|=v.action):(j|=3&v.button,4&v.button&&(j|=64),8&v.button&&(j|=128),v.action===32?j|=32:v.action!==0||E||(j|=3)),j}const _=String.fromCharCode,S={DEFAULT:v=>{const E=[C(v,!1)+32,v.col+32,v.row+32];return E[0]>255||E[1]>255||E[2]>255?"":`\x1B[M${_(E[0])}${_(E[1])}${_(E[2])}`},SGR:v=>{const E=v.action===0&&v.button!==4?"m":"M";return`\x1B[<${C(v,!0)};${v.col};${v.row}${E}`},SGR_PIXELS:v=>{const E=v.action===0&&v.button!==4?"m":"M";return`\x1B[<${C(v,!0)};${v.x};${v.y}${E}`}};let b=c.CoreMouseService=class extends y.Disposable{constructor(v,E){super(),this._bufferService=v,this._coreService=E,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new x.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const j of Object.keys(w))this.addProtocol(j,w[j]);for(const j of Object.keys(S))this.addEncoding(j,S[j]);this.reset()}addProtocol(v,E){this._protocols[v]=E}addEncoding(v,E){this._encodings[v]=E}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(v){if(!this._protocols[v])throw new Error(`unknown protocol "${v}"`);this._activeProtocol=v,this._onProtocolChange.fire(this._protocols[v].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(v){if(!this._encodings[v])throw new Error(`unknown encoding "${v}"`);this._activeEncoding=v}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(v){if(v.col<0||v.col>=this._bufferService.cols||v.row<0||v.row>=this._bufferService.rows||v.button===4&&v.action===32||v.button===3&&v.action!==32||v.button!==4&&(v.action===2||v.action===3)||(v.col++,v.row++,v.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,v,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(v))return!1;const E=this._encodings[this._activeEncoding](v);return E&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(E):this._coreService.triggerDataEvent(E,!0)),this._lastEvent=v,!0}explainEvents(v){return{down:!!(1&v),up:!!(2&v),drag:!!(4&v),move:!!(8&v),wheel:!!(16&v)}}_equalEvents(v,E,j){if(j){if(v.x!==E.x||v.y!==E.y)return!1}else if(v.col!==E.col||v.row!==E.row)return!1;return v.button===E.button&&v.action===E.action&&v.ctrl===E.ctrl&&v.alt===E.alt&&v.shift===E.shift}};c.CoreMouseService=b=f([p(0,m.IBufferService),p(1,m.ICoreService)],b)},6975:function(u,c,d){var f=this&&this.__decorate||function(b,v,E,j){var T,D=arguments.length,L=D<3?v:j===null?j=Object.getOwnPropertyDescriptor(v,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,v,E,j);else for(var O=b.length-1;O>=0;O--)(T=b[O])&&(L=(D<3?T(L):D>3?T(v,E,L):T(v,E))||L);return D>3&&L&&Object.defineProperty(v,E,L),L},p=this&&this.__param||function(b,v){return function(E,j){v(E,j,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreService=void 0;const m=d(1439),x=d(8460),y=d(844),w=d(2585),C=Object.freeze({insertMode:!1}),_=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let S=c.CoreService=class extends y.Disposable{constructor(b,v,E){super(),this._bufferService=b,this._logService=v,this._optionsService=E,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new x.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new x.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new x.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new x.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(_)}reset(){this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(_)}triggerDataEvent(b,v=!1){if(this._optionsService.rawOptions.disableStdin)return;const E=this._bufferService.buffer;v&&this._optionsService.rawOptions.scrollOnUserInput&&E.ybase!==E.ydisp&&this._onRequestScrollToBottom.fire(),v&&this._onUserInput.fire(),this._logService.debug(`sending data "${b}"`,(()=>b.split("").map((j=>j.charCodeAt(0))))),this._onData.fire(b)}triggerBinaryEvent(b){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${b}"`,(()=>b.split("").map((v=>v.charCodeAt(0))))),this._onBinary.fire(b))}};c.CoreService=S=f([p(0,w.IBufferService),p(1,w.ILogService),p(2,w.IOptionsService)],S)},9074:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DecorationService=void 0;const f=d(8055),p=d(8460),m=d(844),x=d(6106);let y=0,w=0;class C extends m.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new x.SortedList((b=>b==null?void 0:b.marker.line)),this._onDecorationRegistered=this.register(new p.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new p.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,m.toDisposable)((()=>this.reset())))}registerDecoration(b){if(b.marker.isDisposed)return;const v=new _(b);if(v){const E=v.marker.onDispose((()=>v.dispose()));v.onDispose((()=>{v&&(this._decorations.delete(v)&&this._onDecorationRemoved.fire(v),E.dispose())})),this._decorations.insert(v),this._onDecorationRegistered.fire(v)}return v}reset(){for(const b of this._decorations.values())b.dispose();this._decorations.clear()}*getDecorationsAtCell(b,v,E){let j=0,T=0;for(const D of this._decorations.getKeyIterator(v))j=D.options.x??0,T=j+(D.options.width??1),b>=j&&b<T&&(!E||(D.options.layer??"bottom")===E)&&(yield D)}forEachDecorationAtCell(b,v,E,j){this._decorations.forEachByKey(v,(T=>{y=T.options.x??0,w=y+(T.options.width??1),b>=y&&b<w&&(!E||(T.options.layer??"bottom")===E)&&j(T)}))}}c.DecorationService=C;class _ extends m.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=f.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=f.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(b){super(),this.options=b,this.onRenderEmitter=this.register(new p.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new p.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=b.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.InstantiationService=c.ServiceCollection=void 0;const f=d(2585),p=d(8343);class m{constructor(...y){this._entries=new Map;for(const[w,C]of y)this.set(w,C)}set(y,w){const C=this._entries.get(y);return this._entries.set(y,w),C}forEach(y){for(const[w,C]of this._entries.entries())y(w,C)}has(y){return this._entries.has(y)}get(y){return this._entries.get(y)}}c.ServiceCollection=m,c.InstantiationService=class{constructor(){this._services=new m,this._services.set(f.IInstantiationService,this)}setService(x,y){this._services.set(x,y)}getService(x){return this._services.get(x)}createInstance(x,...y){const w=(0,p.getServiceDependencies)(x).sort(((S,b)=>S.index-b.index)),C=[];for(const S of w){const b=this._services.get(S.id);if(!b)throw new Error(`[createInstance] ${x.name} depends on UNKNOWN service ${S.id}.`);C.push(b)}const _=w.length>0?w[0].index:y.length;if(y.length!==_)throw new Error(`[createInstance] First service dependency of ${x.name} at position ${_+1} conflicts with ${y.length} static arguments`);return new x(...y,...C)}}},7866:function(u,c,d){var f=this&&this.__decorate||function(_,S,b,v){var E,j=arguments.length,T=j<3?S:v===null?v=Object.getOwnPropertyDescriptor(S,b):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(_,S,b,v);else for(var D=_.length-1;D>=0;D--)(E=_[D])&&(T=(j<3?E(T):j>3?E(S,b,T):E(S,b))||T);return j>3&&T&&Object.defineProperty(S,b,T),T},p=this&&this.__param||function(_,S){return function(b,v){S(b,v,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.traceCall=c.setTraceLogger=c.LogService=void 0;const m=d(844),x=d(2585),y={trace:x.LogLevelEnum.TRACE,debug:x.LogLevelEnum.DEBUG,info:x.LogLevelEnum.INFO,warn:x.LogLevelEnum.WARN,error:x.LogLevelEnum.ERROR,off:x.LogLevelEnum.OFF};let w,C=c.LogService=class extends m.Disposable{get logLevel(){return this._logLevel}constructor(_){super(),this._optionsService=_,this._logLevel=x.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=y[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(_){for(let S=0;S<_.length;S++)typeof _[S]=="function"&&(_[S]=_[S]())}_log(_,S,b){this._evalLazyOptionalParams(b),_.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,...b)}trace(_,...S){var b;this._logLevel<=x.LogLevelEnum.TRACE&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.trace.bind(this._optionsService.options.logger))??console.log,_,S)}debug(_,...S){var b;this._logLevel<=x.LogLevelEnum.DEBUG&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.debug.bind(this._optionsService.options.logger))??console.log,_,S)}info(_,...S){var b;this._logLevel<=x.LogLevelEnum.INFO&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.info.bind(this._optionsService.options.logger))??console.info,_,S)}warn(_,...S){var b;this._logLevel<=x.LogLevelEnum.WARN&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.warn.bind(this._optionsService.options.logger))??console.warn,_,S)}error(_,...S){var b;this._logLevel<=x.LogLevelEnum.ERROR&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.error.bind(this._optionsService.options.logger))??console.error,_,S)}};c.LogService=C=f([p(0,x.IOptionsService)],C),c.setTraceLogger=function(_){w=_},c.traceCall=function(_,S,b){if(typeof b.value!="function")throw new Error("not supported");const v=b.value;b.value=function(...E){if(w.logLevel!==x.LogLevelEnum.TRACE)return v.apply(this,E);w.trace(`GlyphRenderer#${v.name}(${E.map((T=>JSON.stringify(T))).join(", ")})`);const j=v.apply(this,E);return w.trace(`GlyphRenderer#${v.name} return`,j),j}}},7302:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OptionsService=c.DEFAULT_OPTIONS=void 0;const f=d(8460),p=d(844),m=d(6114);c.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:m.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const x=["normal","bold","100","200","300","400","500","600","700","800","900"];class y extends p.Disposable{constructor(C){super(),this._onOptionChange=this.register(new f.EventEmitter),this.onOptionChange=this._onOptionChange.event;const _={...c.DEFAULT_OPTIONS};for(const S in C)if(S in _)try{const b=C[S];_[S]=this._sanitizeAndValidateOption(S,b)}catch(b){console.error(b)}this.rawOptions=_,this.options={..._},this._setupOptions(),this.register((0,p.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,_){return this.onOptionChange((S=>{S===C&&_(this.rawOptions[C])}))}onMultipleOptionChange(C,_){return this.onOptionChange((S=>{C.indexOf(S)!==-1&&_()}))}_setupOptions(){const C=S=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},_=(S,b)=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);b=this._sanitizeAndValidateOption(S,b),this.rawOptions[S]!==b&&(this.rawOptions[S]=b,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const b={get:C.bind(this,S),set:_.bind(this,S)};Object.defineProperty(this.options,S,b)}}_sanitizeAndValidateOption(C,_){switch(C){case"cursorStyle":if(_||(_=c.DEFAULT_OPTIONS[C]),!(function(S){return S==="block"||S==="underline"||S==="bar"})(_))throw new Error(`"${_}" is not a valid value for ${C}`);break;case"wordSeparator":_||(_=c.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof _=="number"&&1<=_&&_<=1e3)break;_=x.includes(_)?_:c.DEFAULT_OPTIONS[C];break;case"cursorWidth":_=Math.floor(_);case"lineHeight":case"tabStopWidth":if(_<1)throw new Error(`${C} cannot be less than 1, value: ${_}`);break;case"minimumContrastRatio":_=Math.max(1,Math.min(21,Math.round(10*_)/10));break;case"scrollback":if((_=Math.min(_,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${_}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(_<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${_}`);break;case"rows":case"cols":if(!_&&_!==0)throw new Error(`${C} must be numeric, value: ${_}`);break;case"windowsPty":_=_??{}}return _}}c.OptionsService=y},2660:function(u,c,d){var f=this&&this.__decorate||function(y,w,C,_){var S,b=arguments.length,v=b<3?w:_===null?_=Object.getOwnPropertyDescriptor(w,C):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(y,w,C,_);else for(var E=y.length-1;E>=0;E--)(S=y[E])&&(v=(b<3?S(v):b>3?S(w,C,v):S(w,C))||v);return b>3&&v&&Object.defineProperty(w,C,v),v},p=this&&this.__param||function(y,w){return function(C,_){w(C,_,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkService=void 0;const m=d(2585);let x=c.OscLinkService=class{constructor(y){this._bufferService=y,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(y){const w=this._bufferService.buffer;if(y.id===void 0){const E=w.addMarker(w.ybase+w.y),j={data:y,id:this._nextId++,lines:[E]};return E.onDispose((()=>this._removeMarkerFromLink(j,E))),this._dataByLinkId.set(j.id,j),j.id}const C=y,_=this._getEntryIdKey(C),S=this._entriesWithId.get(_);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const b=w.addMarker(w.ybase+w.y),v={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(v,b))),this._entriesWithId.set(v.key,v),this._dataByLinkId.set(v.id,v),v.id}addLineToLink(y,w){const C=this._dataByLinkId.get(y);if(C&&C.lines.every((_=>_.line!==w))){const _=this._bufferService.buffer.addMarker(w);C.lines.push(_),_.onDispose((()=>this._removeMarkerFromLink(C,_)))}}getLinkData(y){var w;return(w=this._dataByLinkId.get(y))==null?void 0:w.data}_getEntryIdKey(y){return`${y.id};;${y.uri}`}_removeMarkerFromLink(y,w){const C=y.lines.indexOf(w);C!==-1&&(y.lines.splice(C,1),y.lines.length===0&&(y.data.id!==void 0&&this._entriesWithId.delete(y.key),this._dataByLinkId.delete(y.id)))}};c.OscLinkService=x=f([p(0,m.IBufferService)],x)},8343:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createDecorator=c.getServiceDependencies=c.serviceRegistry=void 0;const d="di$target",f="di$dependencies";c.serviceRegistry=new Map,c.getServiceDependencies=function(p){return p[f]||[]},c.createDecorator=function(p){if(c.serviceRegistry.has(p))return c.serviceRegistry.get(p);const m=function(x,y,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,_,S){_[d]===_?_[f].push({id:C,index:S}):(_[f]=[{id:C,index:S}],_[d]=_)})(m,x,w)};return m.toString=()=>p,c.serviceRegistry.set(p,m),m}},2585:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.IDecorationService=c.IUnicodeService=c.IOscLinkService=c.IOptionsService=c.ILogService=c.LogLevelEnum=c.IInstantiationService=c.ICharsetService=c.ICoreService=c.ICoreMouseService=c.IBufferService=void 0;const f=d(8343);var p;c.IBufferService=(0,f.createDecorator)("BufferService"),c.ICoreMouseService=(0,f.createDecorator)("CoreMouseService"),c.ICoreService=(0,f.createDecorator)("CoreService"),c.ICharsetService=(0,f.createDecorator)("CharsetService"),c.IInstantiationService=(0,f.createDecorator)("InstantiationService"),(function(m){m[m.TRACE=0]="TRACE",m[m.DEBUG=1]="DEBUG",m[m.INFO=2]="INFO",m[m.WARN=3]="WARN",m[m.ERROR=4]="ERROR",m[m.OFF=5]="OFF"})(p||(c.LogLevelEnum=p={})),c.ILogService=(0,f.createDecorator)("LogService"),c.IOptionsService=(0,f.createDecorator)("OptionsService"),c.IOscLinkService=(0,f.createDecorator)("OscLinkService"),c.IUnicodeService=(0,f.createDecorator)("UnicodeService"),c.IDecorationService=(0,f.createDecorator)("DecorationService")},1480:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeService=void 0;const f=d(8460),p=d(225);class m{static extractShouldJoin(y){return(1&y)!=0}static extractWidth(y){return y>>1&3}static extractCharKind(y){return y>>3}static createPropertyValue(y,w,C=!1){return(16777215&y)<<3|(3&w)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new f.EventEmitter,this.onChange=this._onChange.event;const y=new p.UnicodeV6;this.register(y),this._active=y.version,this._activeProvider=y}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(y){if(!this._providers[y])throw new Error(`unknown Unicode version "${y}"`);this._active=y,this._activeProvider=this._providers[y],this._onChange.fire(y)}register(y){this._providers[y.version]=y}wcwidth(y){return this._activeProvider.wcwidth(y)}getStringCellWidth(y){let w=0,C=0;const _=y.length;for(let S=0;S<_;++S){let b=y.charCodeAt(S);if(55296<=b&&b<=56319){if(++S>=_)return w+this.wcwidth(b);const j=y.charCodeAt(S);56320<=j&&j<=57343?b=1024*(b-55296)+j-56320+65536:w+=this.wcwidth(j)}const v=this.charProperties(b,C);let E=m.extractWidth(v);m.extractShouldJoin(v)&&(E-=m.extractWidth(C)),w+=E,C=v}return w}charProperties(y,w){return this._activeProvider.charProperties(y,w)}}c.UnicodeService=m}},r={};function a(u){var c=r[u];if(c!==void 0)return c.exports;var d=r[u]={exports:{}};return n[u].call(d.exports,d,d.exports,a),d.exports}var l={};return(()=>{var u=l;Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const c=a(9042),d=a(3236),f=a(844),p=a(5741),m=a(8285),x=a(7975),y=a(7090),w=["cols","rows"];class C extends f.Disposable{constructor(S){super(),this._core=this.register(new d.Terminal(S)),this._addonManager=this.register(new p.AddonManager),this._publicOptions={...this._core.options};const b=E=>this._core.options[E],v=(E,j)=>{this._checkReadonlyOptions(E),this._core.options[E]=j};for(const E in this._core.options){const j={get:b.bind(this,E),set:v.bind(this,E)};Object.defineProperty(this._publicOptions,E,j)}}_checkReadonlyOptions(S){if(w.includes(S))throw new Error(`Option "${S}" 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 x.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new y.UnicodeApi(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 m.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const S=this._core.coreService.decPrivateModes;let b="none";switch(this._core.coreMouseService.activeProtocol){case"X10":b="x10";break;case"VT200":b="vt200";break;case"DRAG":b="drag";break;case"ANY":b="any"}return{applicationCursorKeysMode:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:b,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const b in S)this._publicOptions[b]=S[b]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,b=!0){this._core.input(S,b)}resize(S,b){this._verifyIntegers(S,b),this._core.resize(S,b)}open(S){this._core.open(S)}attachCustomKeyEventHandler(S){this._core.attachCustomKeyEventHandler(S)}attachCustomWheelEventHandler(S){this._core.attachCustomWheelEventHandler(S)}registerLinkProvider(S){return this._core.registerLinkProvider(S)}registerCharacterJoiner(S){return this._checkProposedApi(),this._core.registerCharacterJoiner(S)}deregisterCharacterJoiner(S){this._checkProposedApi(),this._core.deregisterCharacterJoiner(S)}registerMarker(S=0){return this._verifyIntegers(S),this._core.registerMarker(S)}registerDecoration(S){return this._checkProposedApi(),this._verifyPositiveIntegers(S.x??0,S.width??0,S.height??0),this._core.registerDecoration(S)}hasSelection(){return this._core.hasSelection()}select(S,b,v){this._verifyIntegers(S,b,v),this._core.select(S,b,v)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(S,b){this._verifyIntegers(S,b),this._core.selectLines(S,b)}dispose(){super.dispose()}scrollLines(S){this._verifyIntegers(S),this._core.scrollLines(S)}scrollPages(S){this._verifyIntegers(S),this._core.scrollPages(S)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(S){this._verifyIntegers(S),this._core.scrollToLine(S)}clear(){this._core.clear()}write(S,b){this._core.write(S,b)}writeln(S,b){this._core.write(S),this._core.write(`\r
|
|
253
|
+
`,b)}paste(S){this._core.paste(S)}refresh(S,b){this._verifyIntegers(S,b),this._core.refresh(S,b)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return c}_verifyIntegers(...S){for(const b of S)if(b===1/0||isNaN(b)||b%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const b of S)if(b&&(b===1/0||isNaN(b)||b%1!=0||b<0))throw new Error("This API only accepts positive integers")}}u.Terminal=C})(),l})()))})(Ym)),Ym.exports}var S6=_6();/**
|
|
254
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
255
|
+
* @license MIT
|
|
256
|
+
*
|
|
257
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
258
|
+
* @license MIT
|
|
259
|
+
*
|
|
260
|
+
* Originally forked from (with the author's permission):
|
|
261
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
262
|
+
* http://bellard.org/jslinux/
|
|
263
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
264
|
+
*/var w6=2,C6=1,k6=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),u={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},c=u.top+u.bottom,d=u.right+u.left,f=r-c,p=a-d-t;return{cols:Math.max(w6,Math.floor(p/e.css.cell.width)),rows:Math.max(C6,Math.floor(f/e.css.cell.height))}}};function E6({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=A.useRef(null),l=A.useRef(e),u=A.useRef(null),c=A.useRef(null),d=Lr(p=>p.writeSession),f=Lr(p=>p.resizeSession);return A.useEffect(()=>{l.current=e},[e]),A.useEffect(()=>{if(!n)return;const p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),n())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]),A.useEffect(()=>{if(!a.current)return;const p=new S6.Terminal({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),m=new k6;p.loadAddon(m),u.current={term:p,fitAddon:m},a.current.addEventListener("keydown",C=>{C.key==="Escape"&&n&&(C.preventDefault(),C.stopPropagation(),n())}),p.open(a.current);const x=a.current.querySelector(".xterm");x&&(x.style.padding="8px"),m.fit(),r&&setTimeout(()=>{p.focus()},150);const y=new ResizeObserver(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{requestAnimationFrame(()=>{var _;m.fit&&m.fit();const C=(_=u.current)==null?void 0:_.term;C&&C.cols>0&&C.rows>0&&f(l.current,C.cols,C.rows)})},100)});y.observe(a.current),p.onData(C=>{if(C==="\x1B"&&n){n();return}d(l.current,C)}),p.onKey(C=>{C.key==="\x1B"&&n&&(C.domEvent.stopPropagation(),n())});const w=Xt.subscribe(C=>{const _=C.payload;if(C.type==="terminal.output"&&(_==null?void 0:_.sessionId)===l.current){const S=_==null?void 0:_.data;S&&p.write(S)}});return()=>{w(),y.disconnect(),c.current&&clearTimeout(c.current),p.dispose(),u.current=null}},[e,d,f]),i.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[i.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[i.jsx("div",{}),i.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:i.jsx(Qp,{})})]}),i.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),n())}})]})}const uk="openfox-chat-textarea";function Pl(e){const t=document.getElementById(uk);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function j6(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 N6({isOpen:e,onClose:t}){const n=Lr(C=>C.createSession),r=Lr(C=>C.killSession),a=Lr(C=>C.sessions),l=Lr(C=>C.setWorkdir),u=Lr(C=>C.fetchSessions),c=Ht(C=>C.currentProject),d=Re(C=>C.currentSession),[f,p]=A.useState(!0),m=A.useRef(null),x=A.useRef(!1),y=A.useRef(!1),w=A.useCallback(()=>{t()},[t]);return A.useEffect(()=>{const C=(d==null?void 0:d.workspace)??(c==null?void 0:c.workdir);C&&l(C)},[d==null?void 0:d.workspace,c==null?void 0:c.workdir,l]),A.useEffect(()=>{e?(p(!0),u(c==null?void 0:c.id).finally(()=>p(!1))):Pl()},[e,u,c==null?void 0:c.id]),A.useEffect(()=>{e&&a.length===0&&!f&&!y.current&&(y.current=!0,n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)))},[e,a.length,f,n,d==null?void 0:d.projectId,c==null?void 0:c.id]),A.useEffect(()=>{e?(x.current=!0,setTimeout(()=>{var C;(C=m.current)==null||C.focus(),setTimeout(()=>{x.current=!1},200)},100)):y.current=!1},[e]),A.useEffect(()=>{if(!e)return;const C=_=>{x.current||_.key==="Escape"&&(_.preventDefault(),t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,t]),e?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:w}),i.jsxs("div",{ref:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),w())},children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)),className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"New terminal",children:i.jsx(BN,{})}),i.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:i.jsx(Es,{})})]})]}),i.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:f?i.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?i.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"mb-4",children:"No terminal sessions"}),i.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)),className:"px-4 py-2 bg-accent-primary/25 text-text-primary rounded hover:bg-accent-primary/40 transition-colors",children:"Create Terminal"})]})}):i.jsx("div",{className:`grid ${j6(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>i.jsx(E6,{sessionId:C.id,onClose:()=>r(C.id),onEscape:w,autoFocus:a.length===1},C.id))})})]})]}):null}function Kl({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",isOpen:a,onOpenChange:l}){const[u,c]=A.useState(!1),d=a!==void 0,f=d?a:u,p=R=>{if(d){const P=typeof R=="function"?R(u):R;l==null||l(P)}else c(R)},[m,x]=A.useState(null),y=A.useRef(null),w=A.useRef(null),[C,_]=A.useState(0),S=A.useRef(0),b=A.useMemo(()=>[...e,...t],[e,t]),v=A.useRef(b),E=A.useCallback(()=>{if(!y.current)return;const R=y.current.getBoundingClientRect(),P=200,G=window.innerHeight-R.bottom<P;x({top:G?R.top-P-4:R.bottom+4,left:R.left,alignToTop:G})},[]);A.useEffect(()=>{v.current=b},[b]),A.useEffect(()=>{function R(P){if(w.current){const V=P.target;w.current.contains(V)||p(!1)}}return f&&document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[f]),A.useEffect(()=>{f&&E()},[f,E]),A.useEffect(()=>{if(!f)return;setTimeout(()=>{var P;(P=w.current)==null||P.focus()},0);function R(P){const V=v.current,G=V.filter(Q=>!j(Q)),Z=T(S.current,V);switch(P.key){case"ArrowDown":if(P.preventDefault(),P.stopPropagation(),Z<G.length-1){const Q=D(S.current+1,V);S.current=Q,_(Q)}break;case"ArrowUp":if(P.preventDefault(),P.stopPropagation(),Z>0){const Q=L(S.current-1,V);S.current=Q,_(Q)}break;case"Enter":P.preventDefault(),P.stopPropagation(),O(S.current,V);break;case"Escape":P.preventDefault(),P.stopPropagation(),p(!1);break}}return window.addEventListener("keydown",R,!0),()=>window.removeEventListener("keydown",R,!0)},[f,b]);function j(R){var G;const P=R.label;return P?String(((G=P.props)==null?void 0:G.className)??"").includes("cursor-default"):!1}function T(R,P){let V=0;for(let G=0;G<R;G++){const Z=P[G];Z&&!j(Z)&&V++}return V}function D(R,P){for(let V=R;V<P.length;V++){const G=P[V];if(G&&!j(G))return V}return R}function L(R,P){for(let V=R;V>=0;V--){const G=P[V];if(G&&!j(G))return V}return R}function O(R,P){var G;const V=P[R];!V||j(V)||((G=V.onClick)==null||G.call(V),V.href&&(window.history.pushState(null,"",V.href),window.dispatchEvent(new PopStateEvent("popstate"))),p(!1))}A.useEffect(()=>{f&&(_(b.findIndex(R=>!j(R))),S.current=b.findIndex(R=>!j(R)))},[f,b]);const M=R=>{R.stopPropagation(),f||E(),p(!f)};function W(R,P,V,G){const Q=!j(R)&&G===C,U=i.jsxs(i.Fragment,{children:[R.icon&&i.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:R.icon}),R.label]}),I=P!==V-1;return R.href?i.jsx(Xn,{href:R.href,onClick:$=>{var q;(q=R.onClick)==null||q.call(R,$),p(!1)},onAuxClick:()=>p(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${R.danger?"text-accent-error hover:bg-accent-error/10":Q?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${I?"border-b border-border":""}`,children:U},G):i.jsx("button",{onClick:$=>{var q;(q=R.onClick)==null||q.call(R,$),R.closeOnClick!==!1&&p(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${R.danger?"text-accent-error hover:bg-accent-error/10":Q?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${I?"border-b border-border":""}`,children:U},G)}const z=m&&i.jsxs("div",{ref:w,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${m.alignToTop?"mb-1":"mt-1"}`,style:{top:m.top,left:m.left,minWidth:r},tabIndex:-1,children:[i.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.map((R,P)=>W(R,P,e.length,P))}),t.length>0&&i.jsx("div",{className:"border-t border-border",children:t.map((R,P)=>W(R,P,t.length,e.length+P))})]});return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"relative",children:i.jsx("div",{ref:y,onClick:M,children:n})}),f&&io.createPortal(z,document.body)]})}function T6(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 dk({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,l]=A.useState(!1),[u,c]=A.useState(null),[d,f]=A.useState(null);A.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const E=await(await we("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();f({sudoAvailable:E.sudoAvailable,userInGroup:E.userInGroup,groupHasWrite:E.groupHasWrite,groupName:E.groupName||null})}catch{f({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=A.useCallback(async v=>{l(!0),c(null);try{const j=await(await we("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:v})})).json();j.success?(r(),t()):j.sudoAvailable?c("Failed to fix permissions: "+(j.error||"Unknown error")):c(`Passwordless sudo is not available. Please fix permissions manually:
|
|
265
|
+
|
|
266
|
+
`+(v==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(E){c("Failed to fix permissions: "+(E instanceof Error?E.message:"Unknown error"))}finally{l(!1)}},[n,r,t]),x=(d==null?void 0:d.userInGroup)??!1,y=(d==null?void 0:d.groupHasWrite)??!1,w=(d==null?void 0:d.sudoAvailable)??!1,C=(d==null?void 0:d.groupName)??"",_=x&&!y,S=!x&&y,b=!x&&!y;return i.jsx(wt,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"text-sm text-text-secondary",children:[i.jsx("p",{children:_?i.jsxs(i.Fragment,{children:["The group ",i.jsx("strong",{children:C})," doesn't have write access:"]}):S?i.jsxs(i.Fragment,{children:["You're not a member of group ",i.jsx("strong",{children:C}),":"]}):i.jsxs(i.Fragment,{children:["You're not a member of group ",i.jsx("strong",{children:C})," and it doesn't have write access:"]})}),i.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),u?i.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:u}):d?i.jsxs("div",{className:"flex flex-col gap-2",children:[_&&i.jsxs(i.Fragment,{children:[i.jsx(Je,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&i.jsxs(i.Fragment,{children:[i.jsx(Je,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),b&&i.jsxs(i.Fragment,{children:[i.jsx(Je,{type:"button",variant:"primary",onClick:()=>m("join_group_and_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),i.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),i.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",i.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!u&&i.jsxs("div",{className:"text-xs text-text-secondary",children:[i.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),i.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx(Je,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function hk({isOpen:e,onClose:t}){const[,n]=zn(),r=Ht(j=>j.listProjects),[a,l]=A.useState(""),[u,c]=A.useState(null),[d,f]=A.useState(!1),[p,m]=A.useState(""),[x,y]=A.useState(null),w=A.useRef(null);A.useEffect(()=>{e&&(we("/api/config").then(j=>j.json()).then(j=>{j.workdir&&m(j.workdir)}),l(""),c(null),f(!1),y(null),setTimeout(()=>{var j;(j=w.current)==null||j.focus()},100))},[e]);const C=A.useCallback(async j=>{j.preventDefault();const T=T6(a);if(!T.valid){c(T.error);return}const D=`${p}/${a}`;await b(D)},[a,n,t,p]),_=A.useCallback(()=>{y(null)},[]),S=A.useCallback(async()=>{const j=`${p}/${a}`;await b(j)},[p,a,n,t,y,c,f]);async function b(j){f(!0),c(null),y(null);try{const T=await we("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:j})});if(!T.ok){const O=await T.json().catch(()=>({}));if(O.code==="EACCES"){y(j),f(!1);return}throw new Error(O.error||"Failed to create project")}const L=(await T.json()).project;t(),await r(),n(`/p/${L.id}`)}catch(T){c(T instanceof Error?T.message:"Failed to create project"),f(!1)}}const v=A.useCallback(()=>{l(""),c(null),t()},[t]),E=a?`${p}/${a}`:"";return i.jsxs(i.Fragment,{children:[i.jsx(wt,{isOpen:e,onClose:v,title:"Create New Project",size:"sm",children:i.jsxs("form",{onSubmit:C,className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),i.jsx(ai,{ref:w,id:"project-name",value:a,onChange:j=>{l(j.target.value),c(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),a&&i.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",i.jsx("span",{className:"font-mono",children:E})]}),u&&i.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:u})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Je,{type:"button",variant:"secondary",onClick:v,disabled:d,children:"Cancel"}),i.jsx(Je,{type:"submit",variant:"primary",disabled:d||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(ks,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),x&&i.jsx(dk,{isOpen:!!x,onClose:_,path:x,onRetry:S})]})}function fk(){const[e,t]=A.useState(null);return A.useEffect(()=>{we("/api/config").then(n=>n.json()).then(n=>{n.workdir&&t(n.workdir)})},[]),e}function cS({projects:e,currentProject:t}){const[,n]=zn(),r=Ht(_=>_.loadProject),a=Ht(_=>_.toggleStar),l=Ht(_=>_.createProject),u=Ht(_=>_.listProjects),[c,d]=A.useState(!1),[f,p]=A.useState(!1),m=fk(),x=A.useCallback(async _=>{const S=S1(_),b=await l(S,_);return b&&"id"in b?(await u(),p(!1),n(`/p/${b.id}`),!0):!1},[l,u,n]),w=A.useMemo(()=>{const _=e.filter(b=>b.isStarred).sort((b,v)=>b.name.localeCompare(v.name)),S=e.filter(b=>!b.isStarred).sort((b,v)=>b.name.localeCompare(v.name));return[..._,...S]},[e]).map(_=>({label:i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i.jsx("span",{className:"truncate flex-1",children:_.name}),i.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.nativeEvent.stopImmediatePropagation(),a(_.id,!_.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:_.isStarred?"Unstar project":"Star project",children:_.isStarred?i.jsx(f1,{className:"w-3.5 h-3.5 text-yellow-500"}):i.jsx(m1,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:_.id===(t==null?void 0:t.id)?i.jsx(Ir,{}):void 0,href:`/p/${_.id}`,closeOnClick:!0,onClick:()=>{r(_.id)}})),C=[{label:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Kr,{className:"w-4 h-4"}),i.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:i.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[i.jsx(ks,{className:"w-4 h-4"}),i.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return i.jsxs(i.Fragment,{children:[i.jsx(Kl,{items:w,footerItems:C,trigger:i.jsxs("button",{className:`text-text-secondary hover:text-text-primary text-sm truncate flex items-center gap-1 ${t?"hover:underline":""}`,title:(t==null?void 0:t.name)??"Select project",children:[(t==null?void 0:t.name)??i.jsx("span",{className:"text-text-muted",children:"Select project..."}),i.jsx(Qn,{})]}),minWidth:"250px"}),c&&i.jsx(hk,{isOpen:c,onClose:()=>d(!1)}),f&&i.jsx(xd,{initialPath:m??void 0,onSelect:x,onClose:()=>p(!1)})]})}function mk(e){const t=new Date(e),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()],a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0");return`${r} ${a}/${l}/${u}`}function Bd(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function A6(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=Math.floor((r.getTime()-a.getTime())/(1e3*60*60*24)),u=Bd(e);if(l===0)return`today ${u}`;if(l===1)return`yesterday ${u}`;if(l<7)return`${l} days ago ${u}`;{const c=t.getFullYear(),d=String(t.getMonth()+1).padStart(2,"0"),f=String(t.getDate()).padStart(2,"0");return`${c}/${d}/${f} ${u}`}}function pk(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 L6(e){const{year:t,month:n,day:r}=pk(e);return`${t}-${n}-${r}`}function gk(e){const t=new Map;for(const a of e){const l=L6(a.updatedAt);t.has(l)||t.set(l,[]),t.get(l).push(a)}for(const[a,l]of t)l.sort((u,c)=>{const d=new Date(u.updatedAt).getTime();return new Date(c.updatedAt).getTime()-d});const n=Array.from(t.keys()).sort((a,l)=>l.localeCompare(a)),r=new Map;for(const a of n)r.set(a,t.get(a));return r}function D6({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var p;const l=Re(m=>m.loadSession),u=e.filter(m=>m.projectId===t.id).slice(0,15),c=gk(u),d=A.useMemo(()=>{const m=[];m.push({label:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ks,{className:"w-4 h-4 text-accent-primary"}),i.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[x,y]of c){const w=y[0];if(w){m.push({label:i.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:mk(w.updatedAt)}),onClick:()=>{}});for(const C of y)m.push({label:i.jsxs("div",{className:"min-w-[160px]",children:[i.jsx("div",{className:"truncate text-sm",children:C.title??C.id.slice(0,8)}),i.jsx("div",{className:"text-text-muted text-xs",children:Bd(C.updatedAt)})]}),icon:C.id===(n==null?void 0:n.id)?i.jsx(Ir,{}):void 0,href:`/p/${t.id}/s/${C.id}`,onClick:()=>{l(C.id)}})}}return m},[t.id,c,n==null?void 0:n.id]),f=n?((p=n.metadata)==null?void 0:p.title)??n.id.slice(0,8):"No session selected";return i.jsx(Kl,{items:d,isOpen:r,onOpenChange:a,trigger:i.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:f,"data-testid":"header-session-dropdown",children:[f,i.jsx(Qn,{})]}),minWidth:"280px"})}function R6({items:e,trigger:t,isActive:n=!1}){const[r,a]=A.useState(!1),l=A.useRef(null);return A.useEffect(()=>{function u(c){l.current&&!l.current.contains(c.target)&&a(!1)}if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),i.jsxs("div",{className:"relative",ref:l,children:[i.jsxs("button",{type:"button",onClick:()=>a(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?i.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,i.jsx(Qn,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&i.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((u,c)=>{const d=u.label&&typeof u.label=="object"&&u.label.type===Xn?u.label:null;if(d){const f=d.props.href||"";return i.jsxs(Xn,{href:f,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,d.props.children]},c)}return u.href?i.jsxs("a",{href:u.href,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c):i.jsxs("button",{type:"button",onClick:()=>{var f;(f=u.onClick)==null||f.call(u),a(!1)},className:"flex items-center gap-2 px-3 py-2 text-sm w-full text-left border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,u.label]},c)})})]})}function O6({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)return null;const a=t.filter(u=>u.projectId===e.id).sort((u,c)=>new Date(c.updatedAt).getTime()-new Date(u.updatedAt).getTime()).slice(0,5),l=[{label:i.jsxs(Xn,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[i.jsx(ks,{className:"w-3 h-3 text-accent-primary"}),i.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(u=>({label:i.jsx(Xn,{href:`/p/${e.id}/s/${u.id}`,className:"flex items-center gap-2 truncate text-sm",children:i.jsx("span",{children:u.title??u.id.slice(0,8)})}),icon:u.id===(n==null?void 0:n.id)?i.jsx(Ir,{className:"w-3 h-3"}):void 0})),{label:i.jsxs(Xn,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[i.jsx(AN,{className:"w-3 h-3"}),i.jsx("span",{className:"text-sm",children:"Projects"})]})}];return i.jsx(R6,{items:l,trigger:i.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function I6({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=A.useState(!1),[a,l]=A.useState(!1),[u,c]=A.useState(!!document.fullscreenElement),[d,f]=zn();A.useEffect(()=>{const D=()=>c(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",D),()=>document.removeEventListener("fullscreenchange",D)},[]);const p=d.startsWith("/p/"),m=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),x=Re(D=>D.currentSession),y=Re(D=>D.sessions),w=Ht(D=>D.currentProject),C=Ht(D=>D.projects),_=Qt(D=>D.startAutoRefresh),S=Qt(D=>D.stopAutoRefresh),b=Lr(D=>D.setOpen),v=Lr(D=>D.isOpen),E=ws(D=>D.status==="available"),j=ws(D=>D.check);A.useEffect(()=>{ws.getState().status==="idle"&&j()},[j]),A.useEffect(()=>{const D=()=>l(!0);return window.addEventListener("open-session-dropdown",D),()=>window.removeEventListener("open-session-dropdown",D)},[]);const T=zl();return jl(T.terminalToggle,()=>{Lr.getState().toggleOpen()},{capture:!0}),A.useEffect(()=>(_(),()=>S()),[_,S]),i.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&m&&i.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:T.sessionSearch?`Toggle session list (${Fu(T.sessionSearch)})`:"Toggle session list",children:i.jsx(p_,{})}),i.jsx(Xn,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),w&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),i.jsx("span",{className:"hidden md:inline",children:i.jsx(cS,{projects:C,currentProject:w})}),i.jsx("span",{className:"md:hidden",children:i.jsx(O6,{currentProject:w,sessions:y,currentSession:x,projectIdFromUrl:p&&d.split("/")[2]||null},w==null?void 0:w.id)}),i.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),i.jsx("span",{className:"hidden md:inline",children:i.jsx(D6,{sessions:y,currentProject:w,currentSession:x,isOpen:a,onOpenChange:l})})]}),!w&&i.jsx("span",{className:"hidden md:inline",children:i.jsx(cS,{projects:C})})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&i.jsx("button",{onClick:()=>{var D,L,O;document.fullscreenElement?(D=document.exitFullscreen)==null||D.call(document):(O=(L=document.documentElement).requestFullscreen)==null||O.call(L)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:u?"Exit fullscreen":"Enter fullscreen",children:u?i.jsx(DN,{}):i.jsx(RN,{})}),p&&i.jsx("button",{onClick:()=>b(!v),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${v?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:i.jsx(UN,{})}),i.jsxs("button",{onClick:()=>r(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:E?"Settings — update available":"Settings",children:[i.jsx($N,{}),E&&i.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),i.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),f("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:i.jsx(IN,{})}),t&&m&&i.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:T.criteriaSidebar?`Toggle criteria sidebar (${Fu(T.criteriaSidebar)})`:"Toggle criteria sidebar",children:i.jsx(p_,{})})]}),i.jsx(v6,{isOpen:n,onClose:()=>r(!1)}),i.jsx(N6,{isOpen:v,onClose:()=>b(!1)})]})}function xk({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:l=n?"Saving...":"Save"}){return i.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[i.jsx(Je,{variant:"secondary",onClick:e,children:a}),i.jsx(Je,{variant:"primary",onClick:t,disabled:r??n,children:l})]})}const Eu=Hn()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await we(`/api/workspace/config?workdir=${encodeURIComponent(t)}`)).json();e({config:r.config??null,loading:!1})}catch{e({loading:!1})}},saveConfig:async(t,n)=>{const r=await we(`/api/workspace/config?workdir=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error("Failed to save workspace config");const a=await r.json();e({config:a.config??n})}})),M6=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],P6=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"];function B6(e,t=M6,n=P6){if(!e)return null;const r=e.replace(/\/+$/,"")||"/";if(t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function $6({isOpen:e,onClose:t,project:n}){const r=Ht(ye=>ye.updateProject),a=Eu(ye=>ye.config),l=Eu(ye=>ye.loading),u=Eu(ye=>ye.fetchConfig),c=Eu(ye=>ye.saveConfig),d=()=>{try{Xt.send("context.checkDynamic",{})}catch{}t()},[f,p]=A.useState(n.customInstructions??""),[m,x]=A.useState(n.dangerLevel??""),[y,w]=A.useState(!1),[C,_]=A.useState(!1),[S,b]=A.useState(!1),[v,E]=A.useState(null),[j,T]=A.useState(""),[D,L]=A.useState(!1),[O,M]=A.useState(""),[W,z]=A.useState(!1),[R,P]=A.useState(""),[V,G]=A.useState(!1),[Z,Q]=A.useState(!1),[U,I]=A.useState([]),[$,q]=A.useState(""),B=y||C||D||W;A.useEffect(()=>{e&&(p(n.customInstructions??""),x(n.dangerLevel??""),w(!1),_(!1),L(!1),z(!1),u(n.workdir))},[e,n,u]),A.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?T(a.setup.join(" && ")):T(""),M((a==null?void 0:a.rootDir)??"")},[a]);const ee=ye=>{p(ye.target.value),w(!0)},X=ye=>{x(ye),_(!0)},ne=ye=>{T(ye.target.value),L(!0)},K=ye=>{M(ye.target.value),z(!0)},F=A.useCallback(async()=>{const ye=m===""?null:m;await r(n.id,{customInstructions:f||null,dangerLevel:ye});const Le=j.trim()?j.split("&&").map(Oe=>Oe.trim()).filter(Boolean):[];await c(n.workdir,{...Le.length>0?{setup:Le}:{},...O.trim()?{rootDir:O.trim()}:{}}),w(!1),_(!1),L(!1),z(!1),d()},[n.id,m,f,j,O,r,c,n.workdir,d]),te=async()=>{const ye=O.trim(),Le=(a==null?void 0:a.rootDir)??"";if(ye){const Oe=B6(ye);if(Oe==="exact"){const Me=ye.replace(/\/+$/,"")||"/";E(`Cannot use "${Me}" directly as workspace root. Use a subdirectory like "${Me}/${n.name}" instead.`);return}if(Oe==="virtual_fs"){E(`Cannot use paths under "${ye}" for workspaces.`);return}}if(!W||!ye||ye===Le){b(!0),E(null);try{await F()}catch(Oe){E(Oe instanceof Error?Oe.message:"Failed to save settings")}finally{b(!1)}return}P(ye),b(!0),E(null);try{const Oe=await we(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:ye,workdir:n.workdir,projectName:n.name})});if(!Oe.ok){const je=await Oe.json().catch(()=>({}));E((je==null?void 0:je.error)??"Failed to validate workspace root directory"),b(!1);return}const Me=await Oe.json();if(!Me.exists){q(Me.resolvedPath),b(!1),G(!0);return}if(Me.workspaces&&Me.workspaces.length>0){I(Me.workspaces),b(!1),Q(!0);return}E(null),await F()}catch(Oe){E(Oe instanceof Error?Oe.message:"Failed to validate settings"),b(!1)}},se=async()=>{G(!1),b(!0);try{const ye=await we(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:R,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!ye.ok){const Oe=await ye.json().catch(()=>({}));E((Oe==null?void 0:Oe.error)??"Failed to create directory"),b(!1);return}const Le=await ye.json();if(Le.workspaces&&Le.workspaces.length>0){I(Le.workspaces),Q(!0),b(!1);return}await F()}catch(ye){E(ye instanceof Error?ye.message:"Failed to create directory")}finally{b(!1)}},xe=async()=>{Q(!1),b(!0),E(null);try{await F()}catch(ye){E(ye instanceof Error?ye.message:"Failed to save settings")}finally{b(!1)}},oe=()=>{G(!1),Q(!1),p(n.customInstructions??""),x(n.dangerLevel??""),w(!1),_(!1),L(!1),z(!1),d()};return i.jsxs(wt,{isOpen:e,onClose:oe,title:`${n.name} Settings`,size:"lg",footer:i.jsx(xk,{onCancel:oe,onSave:te,saving:S,saveDisabled:!B||S}),children:[i.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),i.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."}),i.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[i.jsx("button",{type:"button",onClick:()=>X(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m===""?"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"}),i.jsx("button",{type:"button",onClick:()=>X("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="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"}),i.jsx("button",{type:"button",onClick:()=>X("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="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"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),i.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),i.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."}),i.jsx("textarea",{value:f,onChange:ee,placeholder:"Enter project-specific instructions...",className:"w-full h-32 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:S})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Setup Command"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Command(s) to run after creating a workspace (shared clone). Use"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"&&"})," to chain multiple commands. Example:"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"npm install --prefer-offline"})]}),l&&i.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),i.jsx("input",{type:"text",value:j,onChange:ne,placeholder:"npm install --prefer-offline",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:l||S})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Root Directory"}),i.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Override the default workspace location. Leave empty to use the global directory"," ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"~/.local/share/openfox/workspaces/"}),". Supports absolute paths or paths relative to the project."]}),i.jsx("input",{type:"text",value:O,onChange:K,placeholder:"/absolute/or/relative/path",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:l||S})]}),v&&i.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:v})]}),V&&i.jsxs(wt,{isOpen:V,onClose:()=>G(!1),title:"Directory not found",size:"md",footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:()=>G(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:se,className:"px-4 py-2 text-sm font-medium rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:"Create"})]}),children:[i.jsxs("p",{className:"text-sm text-text-primary",children:["The directory ",i.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:$})," does not exist."]}),i.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),Z&&i.jsxs(wt,{isOpen:Z,onClose:()=>Q(!1),title:"Orphaned workspaces",size:"md",footer:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:()=>Q(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{type:"button",onClick:xe,className:"px-4 py-2 text-sm font-medium rounded bg-red-500 text-white hover:opacity-90 transition-colors",children:"Confirm change"})]}),children:[i.jsxs("p",{className:"text-sm text-text-primary",children:[U.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),i.jsx("ul",{className:"mt-2 space-y-1",children:U.map(ye=>i.jsx("li",{className:"text-sm font-mono text-text-muted",children:ye.name},ye.name))}),i.jsx("p",{className:"text-sm text-text-muted mt-3",children:"Existing workspaces will remain in the old location but will no longer be accessible from this project."})]})]})}const z6={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},H6="M6 18L18 6M6 6l12 12";function Yl({onClick:e,className:t="",size:n="md",variant:r="default"}){const a=r==="overlay"?"bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors":r==="sidebar"?"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors":r==="modal"?"text-text-muted hover:text-text-primary transition-colors":"hover:text-white transition-colors";return i.jsx(gd,{onClick:e,icon:H6,iconSize:z6[n],className:`${a} ${t}`,title:"Close"})}function qr(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function $p(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),a=new Array(e.length).fill(!1),l=n.indexOf(r);if(l>=0)for(let p=l;p<l+r.length;p++)a[p]=!0;else{let p=0;for(let m=0;m<e.length&&p<r.length;m++)n[m]===r[p]&&(a[m]=!0,p++)}const u=Array.from(e),c=[];let d="",f=a[0]??!1;for(let p=0;p<u.length;p++){const m=u[p]??"";a[p]===f?d+=m:(c.push(f?i.jsx("span",{className:"font-semibold text-accent-primary",children:d},c.length):d),d=m,f=a[p]??!1)}return c.push(f?i.jsx("span",{className:"font-semibold text-accent-primary",children:d},c.length):d),i.jsx(i.Fragment,{children:c})}function ii(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const l of r){let u=0;for(let c=0;c<l.length&&u<a.length;c++)l[c]===a[u]&&u++;if(u===a.length)return!0}return!1})}function yk(e,t,n,r,a){switch(e.key){case"ArrowDown":e.preventDefault(),n(l=>Math.min(l+1,t));break;case"ArrowUp":e.preventDefault(),n(l=>Math.max(l-1,0));break;case"Enter":e.preventDefault(),r();break;case"Escape":e.preventDefault(),a();break}}function bk({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=zn(),[a,l]=A.useState(!1),[u,c]=A.useState(null),[d,f]=A.useState(null),[p,m]=A.useState(""),[x,y]=A.useState(!1),w=Re(oe=>oe.sessions),C=Re(oe=>oe.currentSession),_=Re(oe=>oe.unreadSessionIds),S=Re(oe=>oe.deleteSession),b=Re(oe=>oe.deleteAllSessions),v=Re(oe=>oe.loadMoreSessions),E=Re(oe=>oe.sessionsHasMore),j=Re(oe=>oe.sessionsPaginationLoading),T=Re(oe=>oe.sessionsWithPendingConfirmations),D=Re(oe=>oe.pendingPathConfirmations),L=Ht(oe=>oe.currentProject),[O,M]=A.useState(""),[W,z]=A.useState(-1),R=A.useRef(null),P=A.useRef(null),V=A.useRef(!1),G=zl();jl(G.sessionSearch,()=>{var oe;if(t&&document.activeElement===R.current){n==null||n();return}t||(V.current=!0,n==null||n()),(oe=R.current)==null||oe.focus()});const Z=A.useRef(null),Q=A.useCallback(()=>{E&&!j&&L&&v(L.id)},[E,j,L,v]);A.useEffect(()=>{if(!Z.current||!E)return;const oe=new IntersectionObserver(ye=>{const Le=ye[0];Le&&Le.isIntersecting&&Q()},{threshold:.1});return oe.observe(Z.current),()=>oe.disconnect()},[E,Q]);const U=w.filter(oe=>oe.projectId===(L==null?void 0:L.id)),I=A.useMemo(()=>O?U.filter(oe=>{var Oe;const ye=oe.title??"",Le=(((Oe=oe.recentUserPrompts)==null?void 0:Oe.map(Me=>Me.content))??[]).join(" ");return ii(ye,O)||ii(Le,O)}):U,[U,O]),$=O.length>0,q=$&&I.length===0;A.useEffect(()=>{z(I.length>0?0:-1)},[I.length]),A.useEffect(()=>{var ye;if(W<0)return;const oe=(ye=P.current)==null?void 0:ye.querySelector(`[data-sidx="${W}"]`);oe==null||oe.scrollIntoView({block:"nearest"})},[W]);const B=(oe,ye)=>{ye==null||ye.stopPropagation(),c(oe)},ee=()=>{u&&(S(u),(C==null?void 0:C.id)===u&&r(`/p/${e}`),c(null))},X=(oe,ye)=>{ye==null||ye.stopPropagation();const Le=w.find(Me=>Me.id===oe),Oe=(Le==null?void 0:Le.title)??oe.slice(0,6);m(Oe),f(oe)},ne=()=>{if(!d||p.trim()==="")return;const oe=Re.getState().renameSession;oe(d,p.trim()),f(null),m("")},K=()=>{y(!0)},F=()=>{b(e),r(`/p/${e}`),y(!1)},te=oe=>{if(!V.current)return;oe.target.closest('a[href*="/s/"]')&&(V.current=!1,n==null||n())},se=()=>{var oe;M(""),(oe=R.current)==null||oe.focus()},xe=oe=>{var ye;switch(oe.key){case"Escape":M(""),(ye=R.current)==null||ye.blur();break;case"ArrowDown":oe.preventDefault(),z(Le=>Le<I.length-1?Le+1:Le);break;case"ArrowUp":oe.preventDefault(),z(Le=>Le>0?Le-1:0);break;case"Enter":{oe.preventDefault();const Le=I[W];Le&&(r(`/p/${e}/s/${Le.id}`),V.current&&(V.current=!1,n==null||n()));break}}};return i.jsxs(i.Fragment,{children:[t&&n&&i.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),i.jsxs("aside",{className:`
|
|
267
|
+
${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden"}
|
|
268
|
+
md:relative md:h-auto md:translate-x-0
|
|
269
|
+
|
|
270
|
+
fixed z-50 h-[calc(100vh-32px)]
|
|
271
|
+
w-[300px] bg-secondary border-r border-border flex flex-col
|
|
272
|
+
${t?"translate-x-0":"-translate-x-full"}
|
|
273
|
+
`,children:[i.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[i.jsx(Xn,{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"}),i.jsx(Kl,{items:[{label:"Edit project settings",onClick:()=>l(!0)},{label:"Delete all sessions",onClick:K,danger:!0}],trigger:i.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:i.jsx(d1,{})})}),n&&i.jsx(Yl,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),i.jsxs("div",{className:"px-4 py-2 border-b border-border",children:[i.jsxs("div",{className:"relative flex items-center",children:[i.jsx(Vi,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),i.jsx("input",{ref:R,type:"text",value:O,onChange:oe=>M(oe.target.value),onKeyDown:xe,placeholder:"Search sessions...",className:"w-full bg-bg-tertiary border border-border rounded pl-8 pr-8 py-1.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),O&&i.jsx("button",{type:"button",onClick:se,className:"absolute right-1.5 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:i.jsx(Es,{className:"w-3.5 h-3.5"})})]}),$&&!q&&i.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[I.length," ",I.length===1?"match":"matches"]})]}),L&&i.jsx($6,{isOpen:a,onClose:()=>l(!1),project:L}),i.jsx(Nl,{isOpen:u!==null,onClose:()=>c(null),onConfirm:ee,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),i.jsx(Nl,{isOpen:x,onClose:()=>y(!1),onConfirm:F,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),i.jsx(wt,{isOpen:d!==null,onClose:()=>{f(null),m("")},title:"Rename session",size:"sm",footer:i.jsx(xk,{onCancel:()=>{f(null),m("")},onSave:ne,saving:!1,saveDisabled:p.trim()==="",saveLabel:"Rename"}),children:i.jsx("input",{type:"text",value:p,onChange:oe=>m(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&ne()},onFocus:oe=>oe.target.select(),className:"w-full px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:!0})}),i.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-stable",children:I.length===0?i.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:$?"No matching sessions":"No sessions"}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"divide-y divide-border",ref:P,onClick:te,children:U6(I,C,_,B,X,e,T,D,O,W)}),j&&i.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),i.jsx("div",{ref:Z,className:"h-px"})]})})]})]})}function U6(e,t,n,r,a,l,u,c,d,f){const p=gk(e);let m=0;return Array.from(p).map(([x,y])=>{const w=y[0];return w?i.jsxs("div",{children:[i.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:mk(w.updatedAt)}),y.map(C=>{const _=m++,S=(t==null?void 0:t.id)===C.id,b=_===f,v=n.includes(C.id),E=C.isRunning,j=u.includes(C.id)||S&&c.length>0;return i.jsx("div",{"data-sidx":_,className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${S?"bg-bg-tertiary":""} ${b?"bg-accent-primary/10":""}`,children:i.jsxs(Xn,{href:`/p/${l}/s/${C.id}`,className:`block ${S?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[i.jsxs("div",{className:"flex justify-between items-center mb-1",children:[i.jsx("span",{className:`font-medium truncate text-sm ${S?"text-accent-primary":"text-text-primary"}`,children:d?$p(C.title??C.id.slice(0,6),d):C.title??C.id.slice(0,6)}),i.jsx(Kl,{items:[{label:"Rename session",onClick:T=>a(C.id,T)},{label:"Delete session",onClick:T=>r(C.id,T),danger:!0}],trigger:i.jsx("button",{onClick:T=>T.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:i.jsx(d1,{})})})]}),i.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[j?i.jsx("span",{title:"Awaiting confirmation",children:i.jsx(Xp,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):E?i.jsx(zN,{}):v&&!S?i.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,i.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:Bd(C.updatedAt)}),i.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)})]},x):null})}const uS=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function F6(){var u;const e=Ht(c=>c.currentProject),t=Re(c=>c.currentSession),n=md(),r=A.useRef(0),a=A.useRef(null);A.useEffect(()=>(n?(a.current||(r.current=0),a.current=window.setInterval(()=>{r.current=(r.current+1)%uS.length,l()},150),l()):(a.current&&(clearInterval(a.current),a.current=null),l()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t]);const l=()=>{var p;const d=(p=t==null?void 0:t.metadata)==null?void 0:p.title,f=n?`${uS[r.current]} `:"";e&&d?document.title=`${f}${e.name} - ${d} | OpenFox`:e?document.title=`${f}${e.name} | OpenFox`:document.title=`${f}OpenFox`};return typeof window<"u"&&((u=t==null?void 0:t.metadata)!=null&&u.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function vk({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return i.jsx(Nl,{isOpen:e,onClose:t,onConfirm:a,title:"Delete Project",confirmLabel:"Delete",confirmVariant:"danger",message:i.jsxs(i.Fragment,{children:["This will permanently delete the project"," ",i.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]})})}function V6({isOpen:e,onClose:t}){const[,n]=zn(),[r,a]=A.useState(!1),l=fk(),[u,c]=A.useState(!1),d=Ht(L=>L.projects),f=Ht(L=>L.createProject),p=Ht(L=>L.listProjects),m=Ht(L=>L.deleteProject),[x,y]=A.useState(null),[w,C]=A.useState(null);A.useEffect(()=>{e&&p()},[e,p]);const _=L=>{n(`/p/${L}`),t()},S=(L,O)=>{O.stopPropagation(),y(L)},b=()=>{x&&(m(x.id),y(null))},v=async L=>j(L);function E(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"}async function j(L){const O=S1(L),M=await f(O,L);return p(),E(M)?(C(M.error.path||L),!1):M&&"id"in M?(n(`/p/${M.id}`),t(),!0):!1}const T=A.useCallback(()=>{C(null)},[]),D=A.useCallback(async()=>{const L=w;C(null),L&&await j(L)},[w]);return e?i.jsxs(wt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(Je,{variant:"secondary",onClick:t,children:"Close"})}),children:[i.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[i.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:[i.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:i.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:d.length===0?i.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[i.jsx("p",{className:"mb-2",children:"No recent projects"}),i.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):i.jsx("div",{className:"divide-y divide-border",children:d.map(L=>i.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[i.jsxs("button",{onClick:()=>_(L.id),className:"flex-1 flex items-center gap-3 text-left",children:[i.jsx(Kr,{className:"w-5 h-5 text-accent-primary"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"font-medium truncate",children:L.name}),i.jsx("div",{className:"text-xs text-text-muted truncate",children:w1(L.workdir,32)})]})]}),i.jsx("button",{onClick:O=>S(L,O),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:i.jsx(so,{className:"w-4 h-4"})})]},L.id))})})]}),i.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:i.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[i.jsx(Je,{variant:"primary",onClick:()=>c(!0),children:"Select existing project"}),i.jsx(Je,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&i.jsx(hk,{isOpen:r,onClose:()=>a(!1)}),x&&i.jsx(vk,{isOpen:!0,onClose:()=>y(null),projectName:x.name,onConfirm:b}),u&&i.jsx(xd,{initialPath:l??void 0,onSelect:L=>{v(L)},onClose:()=>c(!1)}),w&&i.jsx(dk,{isOpen:!0,onClose:T,path:w,onRetry:D})]}):null}function G6(){const[e,t]=A.useState(!1),[n,r]=A.useState(null),[a,l]=A.useState(""),[u,c]=A.useState(""),d=A.useRef(null),f=Re(P=>P.sessions),p=Ht(P=>P.projects),m=Ht(P=>P.loading),x=Ht(P=>P.listProjects),y=Re(P=>P.listSessions),w=Ht(P=>P.deleteProject),C=Re(P=>P.connectionStatus);A.useEffect(()=>{C==="connected"&&(x(),y())},[C,x,y]),A.useEffect(()=>{const P=setTimeout(()=>c(a),150);return()=>clearTimeout(P)},[a]);const{matchCount:_,filteredSessionIds:S,relevanceScores:b,matchTypes:v,promptSnippets:E}=A.useMemo(()=>{if(!u)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const P=new Map(p.map(U=>[U.id,U])),V=new Map,G=new Map,Z=new Map,Q=f.filter(U=>{var K;const I=P.get(U.projectId),$=(I==null?void 0:I.name)??"",q=U.title??"",B=((K=U.recentUserPrompts)==null?void 0:K.map(F=>F.content))??[],ee=B.join(" ");let X=0,ne="";if(ii(q,u)&&(X+=10,ne="title"),ii(ee,u)){X+=3,ne=ne==="title"?"title":"prompts";const F=B.find(te=>ii(te,u));if(F){const te=F.toLowerCase().indexOf(u.toLowerCase());if(te>=0){const se=Math.max(0,te-30),xe=Math.min(F.length,te+u.length+30);Z.set(U.id,(se>0?"…":"")+F.slice(se,xe)+(xe<F.length?"…":""))}else Z.set(U.id,F.slice(0,80)+(F.length>80?"…":""))}}return ii($,u)&&(X+=1,ne=ne||"project"),V.set(U.id,X),G.set(U.id,ne),X>0});return{matchCount:Q.length,filteredSessionIds:new Set(Q.map(U=>U.id)),relevanceScores:V,matchTypes:G,promptSnippets:Z}},[f,u,p]),j=A.useMemo(()=>{const P=new Map;for(const V of f){const G=new Date(V.updatedAt).getTime(),Z=P.get(V.projectId)??0;G>Z&&P.set(V.projectId,G)}return P},[f]),T=A.useMemo(()=>{const P=new Map;for(const V of f){const G=P.get(V.projectId);G?G.push(V):P.set(V.projectId,[V])}for(const[,V]of P)V.sort((G,Z)=>new Date(Z.updatedAt).getTime()-new Date(G.updatedAt).getTime());return P},[f]),D=A.useMemo(()=>{let P=p;return u&&S&&(P=p.filter(V=>{const G=T.get(V.id);return G==null?void 0:G.some(Z=>S.has(Z.id))})),[...P].sort((V,G)=>{const Z=j.get(V.id)??new Date(V.updatedAt).getTime();return(j.get(G.id)??new Date(G.updatedAt).getTime())-Z})},[p,T,u,S,j]),L=A.useCallback(P=>{const V=T.get(P);return V?u&&S&&b?V.filter(G=>S.has(G.id)).sort((G,Z)=>{const Q=(b.get(Z.id)??0)-(b.get(G.id)??0);return Q!==0?Q:new Date(Z.updatedAt).getTime()-new Date(G.updatedAt).getTime()}):V.slice(0,5):[]},[T,u,S,b]),O=()=>{t(!0)},M=()=>{var P;l(""),c(""),(P=d.current)==null||P.focus()},W=P=>{var V;P.key==="Escape"&&(M(),(V=d.current)==null||V.blur())},z=u.length>0,R=z&&_===0;return i.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto bg-primary",children:[i.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[i.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),i.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),i.jsx(Je,{variant:"primary",onClick:O,children:"Open Project"})]}),f.length>0&&i.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[i.jsxs("div",{className:"relative flex items-center",children:[i.jsx(Vi,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),i.jsx("input",{ref:d,type:"text",value:a,onChange:P=>l(P.target.value),onKeyDown:W,placeholder:"Search sessions by title or keyword...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-10 pr-10 py-2.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),a&&i.jsx("button",{type:"button",onClick:M,className:"absolute right-3 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:i.jsx(Es,{className:"w-4 h-4"})})]}),z&&!R&&i.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[_," ",_===1?"match":"matches"]})]}),R?i.jsxs("div",{className:"text-center py-16 text-text-muted",children:[i.jsx(Vi,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),i.jsxs("p",{className:"text-lg",children:["No sessions matching ",i.jsxs("span",{className:"text-text-primary font-medium",children:["“",u,"”"]})]}),i.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):D.map(P=>{const V=L(P.id);return i.jsx("div",{className:"mb-6 md:mb-8",children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[i.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[i.jsxs(Xn,{href:`/p/${P.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[i.jsx(Kr,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),i.jsx("span",{className:"text-text-primary font-semibold",children:P.name})]}),i.jsx(Xn,{href:`/p/${P.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"}),i.jsx("button",{type:"button",onClick:()=>r({id:P.id,name:P.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:i.jsx(so,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"divide-y divide-border",children:V.length>0?V.map(G=>{const Z=p.find($=>G.projectId===$.id),Q=Z?`/p/${Z.id}/s/${G.id}`:"#",U=G.title??G.id.slice(0,8),I=v==null?void 0:v.get(G.id);return i.jsx(Xn,{href:Q,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-text-muted truncate",children:z&&I==="title"?$p(U,u):U}),z&&I&&I!=="title"&&i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[i.jsx("span",{className:"text-[10px] font-medium text-accent-primary border border-accent-primary/30 bg-accent-primary/8 rounded px-1 py-0.5 leading-none",children:I==="prompts"?"prompts":"project"}),I==="prompts"&&(E==null?void 0:E.get(G.id))&&i.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:$p(E.get(G.id),u)})]})]})}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[i.jsx("span",{className:"text-text-muted text-xs",children:A6(G.updatedAt)}),i.jsxs("span",{className:"text-text-muted text-xs",children:[G.messageCount," msgs"]})]})]})},G.id)}):i.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},P.id)}),!z&&D.length===0&&!m&&i.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),m&&i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(ui,{})})]}),e&&i.jsx(V6,{isOpen:e,onClose:()=>t(!1)}),n&&i.jsx(vk,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>w(n.id)})]})}function W6(){const[,e]=ro("/p/:projectId/new"),[,t]=zn(),n=e==null?void 0:e.projectId,r=Re(u=>u.createSession),a=Re(u=>u.resetPendingSessionCreate),l=A.useCallback(async()=>{if(!n)return;const u=await r(n);u?(t(`/p/${n}/s/${u.id}`),a()):(t(`/p/${n}`),a())},[n,r,t,a]);return A.useEffect(()=>{l()},[l]),i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsx(ui,{})})}function q6(){const e=Ht(t=>t.currentProject);return i.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:i.jsxs("div",{className:"max-w-md",children:[i.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),i.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),i.jsxs("div",{className:"flex flex-col gap-3",children:[e&&i.jsx(Xn,{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"}),i.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const fl=e=>Math.round(e*10)/10;function K6(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function zp(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function Y6(e){return`${e.providerId}::${e.model}`}function X6(e){return`${e.providerName} > ${e.model}`}function dS(e){let t=0,n=0,r=0,a=0,l=0,u=0;const c=[],d=[];let f=0;for(const[x,y]of e.entries()){const w=y.stats,C=zp(w);t+=w.totalTime,n+=w.toolTime,r+=w.prefillTokens,a+=w.generationTokens;const _=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;l+=_,u+=S,c.push({messageId:y.id,timestamp:y.timestamp,...C,mode:w.mode,responseIndex:x+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const b=w.llmCalls??[];for(const v of b)f+=1,d.push({messageId:y.id,timestamp:v.timestamp??y.timestamp,providerId:v.providerId,providerName:v.providerName,backend:v.backend,model:v.model,mode:w.mode,responseIndex:x+1,sessionCallIndex:f,callIndex:v.callIndex,promptTokens:v.promptTokens,completionTokens:v.completionTokens,ttft:v.ttft,completionTime:v.completionTime,prefillSpeed:v.prefillSpeed,generationSpeed:v.generationSpeed,totalTime:v.totalTime,...v.temperature!==void 0&&{temperature:v.temperature},...v.topP!==void 0&&{topP:v.topP},...v.topK!==void 0&&{topK:v.topK},...v.maxTokens!==void 0&&{maxTokens:v.maxTokens}})}const p=l>0?fl(r/l):0,m=u>0?fl(a/u):0;return{totalTime:fl(t),aiTime:fl(t-n),toolTime:fl(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:d.length,dataPoints:c,callDataPoints:d}}function Q6(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&K6(a.stats)).sort((a,l)=>new Date(a.timestamp).getTime()-new Date(l.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const l=Y6(zp(a.stats)),u=n.get(l)??[];n.set(l,[...u,a])}const r=Array.from(n.entries()).map(([a,l])=>{const u=zp(l[0].stats),c=dS(l);return{...u,key:a,label:X6(u),...c}});return{...dS(t),modelGroups:r}}function J6(e){return A.useMemo(()=>Q6(e),[e])}function _k(){var a;const e=Re(l=>l.gitStatus),t=Re(l=>l.currentSession),[n,r]=A.useState(!0);return A.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((a=e==null?void 0:e.diff)==null?void 0:a.files)??[],loading:n,error:null}}}function Sk(){return Qt.getState().platform??null}function wk(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function Ck(e,t,n){const r=Sk(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,l=wk(a);if(r!=null&&r.isWSL&&r.wslDistro)return`${`vscode://vscode-remote/wsl+${r.wslDistro}${l}`}:${t??1}`;const u=`vscode://file/${l}`;return t?`${u}:${t}`:u}function Z6(e){const t=Sk(),n=wk(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function eo(e){return e.toLocaleString("en-US").replace(/,/g," ")}function hS(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function Yr(e){if(!Number.isFinite(e))return"0s";if(e<10)return`${e.toFixed(1)}s`;const t=Math.round(e);if(t<60)return`${t}s`;if(t<3600){const u=Math.floor(t/60),c=t%60;return`${u}m ${c}s`}const n=Math.floor(t/3600),r=t%3600,a=Math.floor(r/60),l=r%60;return`${n}h ${a}m ${l}s`}const fS=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),mS=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function Hp(e){return Object.hasOwn(fS,e)?fS[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function eB(e){return Object.hasOwn(mS,e)?mS[e]:e.replace(/_/g," ")}const pS=["▁","▂","▃","▄","▅","▆","▇","█"];function tB(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 nB(e,t){if(e===t){const a=Math.max(Math.abs(e)*.05,1);return{minY:e-a,maxY:t+a}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function rB(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((x,y)=>x.x-y.x),r=n[0].x,a=n[n.length-1].x,l=Math.min(...n.map(x=>x.y)),u=Math.max(...n.map(x=>x.y)),{minY:c,maxY:d}=nB(l,u),f=Math.max(0,c),p=Array.from({length:t},()=>" "),m=new Map;for(const x of n){const y=a===r?0:Math.round((x.x-r)/(a-r)*(t-1)),w=m.get(y)??[];m.set(y,[...w,x.y])}for(const[x,y]of m){const w=Math.max(...y);p[x]=pS[tB(w,c,d)]??pS[0]}return{blocks:p.join(""),minX:r,maxX:a,minY:f,maxY:d}}function gS(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function xS({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:l,showAxes:u=!0,formatY:c=gS,formatX:d=gS}){const f=A.useMemo(()=>{const p=rB(e,t),m=Math.max(t*6,240),x=10,y=8,C=[...e].sort((v,E)=>v.x-E.x).map(v=>{const E=p.maxX===p.minX?m/2:x+(v.x-p.minX)/(p.maxX-p.minX)*(m-x*2),j=p.maxY===p.minY?n/2:y+(p.maxY-v.y)/(p.maxY-p.minY)*(n-y*2);return{...v,cx:E,cy:j,leftPercent:E/m*100,topPercent:j/n*100}}),_=C.map((v,E)=>`${E===0?"M":"L"} ${v.cx.toFixed(1)} ${v.cy.toFixed(1)}`).join(" "),b=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(v=>({value:v,y:p.maxY===p.minY?n/2:y+(p.maxY-v)/(p.maxY-p.minY)*(n-y*2)}));return{...p,chartWidth:m,points:C,path:_,gridLines:b}},[e,n,t]);return e.length===0?i.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&i.jsx("div",{className:"mb-1",children:r}),i.jsx("div",{children:"No data"})]}):i.jsxs("div",{className:"font-mono text-xs",children:[r&&i.jsx("div",{className:"text-text-secondary mb-2",children:r}),i.jsxs("div",{className:"flex gap-3",children:[u&&i.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:f.gridLines.map(p=>i.jsx("span",{children:c(p.value)},`${p.value}-${p.y}`))}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsxs("div",{className:"relative h-[78px]",children:[i.jsxs("svg",{viewBox:`0 0 ${f.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[f.gridLines.map(p=>i.jsx("line",{x1:"0",x2:f.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),f.points.map(p=>i.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}`)),f.points.length>1&&i.jsx("path",{d:f.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),f.points.map(p=>i.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${d(p.x)} -> ${c(p.y)}`,children:i.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:i.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),u&&i.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[i.jsx("span",{className:"w-12"}),i.jsxs("span",{className:"flex-1 flex justify-between",children:[i.jsx("span",{children:d(f.minX)}),i.jsx("span",{children:a}),i.jsx("span",{children:d(f.maxX)})]})]}),l&&u&&i.jsx("div",{className:"text-text-muted mt-1 text-center",children:l})]})}function sB({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:a=60}){const l=e.map(c=>({x:c.x,y:c.ppSpeed})),u=e.map(c=>({x:c.x,y:c.tgSpeed}));return i.jsxs("div",{className:"space-y-5",children:[i.jsx(xS,{data:l,width:a,label:t,xLabel:r}),i.jsx(xS,{data:u,width:a,label:n,xLabel:r})]})}function iB(e){const t=new Map;for(const n of e.callDataPoints){const r=t.get(n.messageId)??[];t.set(n.messageId,[...r,n])}return e.dataPoints.map(n=>{const r=[...t.get(n.messageId)??[]].sort((a,l)=>a.callIndex-l.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function aB(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 oB(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 lB(e){return e.callDataPoints.length>0?oB(e):aB(e)}function Fi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function bl(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function cB(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Fi(t)} ctx`:`${Fi(t)}-${Fi(n)} ctx`}function ad(e){return`${bl(e)} t/s`}function kk(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function uB(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 dB({isOpen:e,onClose:t,stats:n}){const r=A.useRef(null),[a,l]=A.useState({}),[u,c]=A.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});A.useEffect(()=>{var w;n.modelGroups.some(C=>C.key===u)||c(((w=n.modelGroups[0])==null?void 0:w.key)??"")},[u,n.modelGroups]);const d=A.useMemo(()=>n.modelGroups.find(w=>w.key===u)??n.modelGroups[0],[u,n.modelGroups]),f=A.useMemo(()=>d?iB(d):[],[d]),p=A.useMemo(()=>d?lB(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),m=A.useCallback(w=>{l(C=>({...C,[w]:!C[w]}))},[]),x=A.useCallback(()=>{if(!d)return;const w=uB(d);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),y=A.useCallback(async()=>{if(r.current)try{const w=(await J(async()=>{const{default:S}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:S}},[])).default,C=await w(r.current,{backgroundColor:"#1a1a1a",scale:2}),_=document.createElement("a");_.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,_.href=C.toDataURL("image/png"),_.click()}catch(w){console.error("Failed to export PNG:",w),x()}},[x]);return i.jsx(wt,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:i.jsxs("div",{ref:r,className:"space-y-6",children:[i.jsx("section",{children:i.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>i.jsx("button",{onClick:()=>c(w.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${w.key===(d==null?void 0:d.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:w.label,children:w.label},w.key))})}),d&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[i.jsx(xs,{label:"AI Time",value:Yr(d.aiTime)}),i.jsx(xs,{label:"Total Time",value:Yr(d.totalTime)}),i.jsx(xs,{label:"Tool Time",value:Yr(d.toolTime)}),i.jsx(xs,{label:"Responses",value:d.responseCount.toString()}),i.jsx(xs,{label:"LLM Calls",value:d.llmCallCount.toString()})]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[i.jsx(xs,{label:"Prefill Tokens",value:Fi(d.prefillTokens),subValue:`@ ${bl(d.avgPrefillSpeed)} tok/s`}),i.jsx(xs,{label:"Gen Tokens",value:Fi(d.generationTokens),subValue:`@ ${bl(d.avgGenerationSpeed)} tok/s`}),i.jsx(xs,{label:"Avg PP Speed",value:`${bl(d.avgPrefillSpeed)}`,subValue:"tok/s"}),i.jsx(xs,{label:"Avg TG Speed",value:`${bl(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&p.points.length>1&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.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"}),i.jsx("button",{onClick:y,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),i.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:i.jsx(sB,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),d&&i.jsxs("section",{children:[i.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",d.responseCount," responses)"]}),i.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:i.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[i.jsxs("colgroup",{children:[i.jsx("col",{className:"w-[7%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[10%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[14%]"}),i.jsx("col",{className:"w-[11%]"}),i.jsx("col",{className:"w-[2%]"})]}),i.jsx("thead",{children:i.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[i.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),i.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),i.jsx("th",{className:"px-2 py-2"})]})}),i.jsx("tbody",{children:f.map((w,C)=>i.jsxs(A.Fragment,{children:[i.jsx(hB,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>m(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((_,S)=>i.jsx(fB,{dataPoint:_,index:S},`${_.messageId}-${_.callIndex}`))]},w.messageId))})]})})]})]})})}function xs({label:e,value:t,subValue:n}){return i.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[i.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),i.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&i.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function hB({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?cB(e.calls.map(l=>l.promptTokens)):`${Fi(e.prefillTokens)} ctx`;return i.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[i.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:kk(e.timestamp)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Yr(e.totalTime)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ad(e.prefillSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ad(e.generationSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function fB({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[i.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]}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:kk(e.timestamp)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Yr(e.totalTime)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Fi(e.promptTokens)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ad(e.prefillSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:ad(e.generationSpeed)}),i.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),i.jsx("td",{className:"px-2 py-2"})]}),n&&i.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:i.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:i.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&i.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&i.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&i.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&i.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const mB={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"}},pB=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function gB(e){return mB[e]??{icon:"○",color:"text-text-muted"}}function Bg(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Xl=A.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=gB(t);return i.jsx("span",{className:`${a} ${n}`,children:r})});function yS({entries:e,title:t}){const n=A.useMemo(()=>e.reduce((r,a)=>(r[a.status]=(r[a.status]??0)+1,r),{}),[e]);return i.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[i.jsx("span",{children:t}),Object.keys(n).length>0&&i.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:pB.map(r=>{const a=n[r];return a?i.jsxs("span",{className:"flex items-center gap-0.5",children:[i.jsx(Xl,{status:r}),i.jsx("span",{children:a})]},r):null})})]})}const xB=A.memo(function({entries:t,title:n,onClearAll:r}){const[a,l]=A.useState(!1),u=A.useCallback(()=>{l(!1),r==null||r()},[r]);return t.length===0?null:i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&i.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),i.jsx("div",{className:"bg-primary",children:t.map((c,d)=>i.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[i.jsx(Xl,{status:c.status}),i.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[i.jsxs("span",{className:"text-text-muted",children:["[",c.id,"]"]})," ",Bg(c.description)]})]},c.id??d))}),r&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:i.jsxs("button",{onClick:()=>l(!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",children:[i.jsx(so,{className:"w-3 h-3"}),"Clear all"]})}),a&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[i.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:u,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),i.jsx("button",{onClick:()=>l(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})}),yB={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},bB=["pending","completed","failed","dismissed"];function vB(e){return yB[e]??bB}function _B(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function SB({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:l}){const[u,c]=A.useState(e),[d,f]=A.useState(null),[p,m]=A.useState(""),[x,y]=A.useState(!1),[w,C]=A.useState(""),_=A.useRef(null),S=A.useRef(null),b=A.useCallback(()=>{const z=S.current;z&&(z.style.height="auto",z.style.height=z.scrollHeight+"px")},[]);A.useEffect(()=>{c(e)},[e]),A.useEffect(()=>{var z;d&&(b(),(z=S.current)==null||z.focus())},[d,b]),A.useEffect(()=>{var z;x&&((z=_.current)==null||z.focus())},[x]);const v=A.useCallback(z=>{c(z),we(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:z})}).catch(R=>console.error(`Failed to sync ${n}:`,R))},[t,n]),E=A.useCallback(z=>{const R=vB(n),P=u.map(V=>V.id===z?{...V,status:_B(V.status,R)}:V);v(P)},[u,n,v]),j=A.useCallback((z,R)=>{f(z),m(R)},[]),T=A.useCallback((z,R,P)=>{var Z;const V=(R.trim()||((Z=P.find(Q=>Q.id===z))==null?void 0:Z.description))??"",G=P.map(Q=>Q.id===z?{...Q,description:V}:Q);v(G)},[v]),D=A.useCallback(()=>{d&&(T(d,p,u),f(null))},[d,p,u,T]),L=A.useCallback(z=>{z.key==="Enter"&&D(),z.key==="Escape"&&(z.stopPropagation(),f(null))},[D]),O=A.useCallback(z=>{v(u.filter(R=>R.id!==z))},[u,v]),M=A.useCallback(()=>{const z=w.trim();if(!z)return;const R=u.map(V=>Number(V.id)).filter(V=>Number.isInteger(V)&&V>=0),P=String(Math.max(-1,...R)+1);v([...u,{id:P,description:z,status:"pending"}]),C("")},[w,u,v]),W=A.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),M()),z.key==="Escape"&&(y(!1),C(""))},[M]);return i.jsxs(wt,{isOpen:a,onClose:l,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[i.jsxs("ul",{className:"space-y-1",children:[u.map((z,R)=>{const P=d===z.id,V=i.jsxs("button",{onClick:()=>j(z.id,z.description),className:"text-sm text-text-primary text-left hover:text-accent-primary transition-colors w-full cursor-pointer",title:"Click to edit",children:[i.jsxs("span",{className:"text-text-muted",children:["[",z.id,"]"]})," ",i.jsx("span",{children:Bg(z.description)})]}),G=P?i.jsx("textarea",{ref:S,value:p,onChange:Z=>{m(Z.target.value),b()},onBlur:D,onKeyDown:L,className:"w-full bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary resize-none",rows:1}):V;return i.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${R>0?"border-t border-border":""}`,children:[i.jsx("button",{onClick:()=>E(z.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:i.jsx(Xl,{status:z.status})}),i.jsx("div",{className:"flex-1 min-w-0",children:G}),i.jsx("button",{onClick:()=>O(z.id),className:"flex-shrink-0 text-text-muted hover:text-accent-error transition-colors cursor-pointer mt-0.5 ml-auto",title:"Delete entry",children:i.jsx("span",{className:"flex",children:i.jsx(Es,{className:"w-4 h-4"})})})]},z.id)}),u.length===0&&i.jsx("p",{className:"text-sm text-text-muted italic text-center py-4",children:"No entries yet."})]}),i.jsx("div",{className:"mt-4 pt-3 border-t border-border",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight",children:"○"}),i.jsx("input",{ref:_,value:w,onChange:z=>C(z.target.value),onKeyDown:W,placeholder:"New entry...",className:"flex-1 bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"}),i.jsxs("button",{onClick:M,className:"flex items-center gap-1 text-sm text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add entry",children:[i.jsx(ks,{className:"w-4 h-4"}),"Add"]})]})})]})}const Ot=Hn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const r=await(await we("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const r=await(await we("/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 we(`/api/workflows/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await we(`/api/workflows/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createWorkflow:async(n,r)=>{const a=await ci("POST","/api/workflows",{...n,destination:r});return a.success&&await t().fetchWorkflows(),a},updateWorkflow:async(n,r)=>{const a=await ci("PUT",`/api/workflows/${n}`,r);return a.success&&await t().fetchWorkflows(),a},deleteWorkflow:async n=>{try{const r=await we(`/api/workflows/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r)=>fd(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),r)})),wB={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function CB(e,t){await we(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function ju({id:e,agents:t}){const n=Ml(t,e),r=t.find(a=>a.id===e);return i.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function kB({id:e}){const t=Ot(u=>u.defaults),n=Ot(u=>u.userItems),a=A.useMemo(()=>[...t,...n],[t,n]).find(u=>u.id===e),l=(a==null?void 0:a.color)??"#3b82f6";return i.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${l}20`,color:l},children:(a==null?void 0:a.name)??e})}function EB({entries:e,sessionId:t}){const[n,r]=A.useState(e),[a,l]=A.useState(!1),[u,c]=A.useState(null),[d,f]=A.useState(""),[p,m]=A.useState(""),[x,y]=A.useState(!1),[w,C]=A.useState(!1),_=mt(Q=>Q.defaults),S=mt(Q=>Q.userItems),b=mt(Q=>Q.projectItems),v=A.useMemo(()=>[..._,...S,...b],[_,S,b]),E=A.useRef(null),j=A.useRef(null);A.useEffect(()=>{r(e)},[e]),A.useEffect(()=>{var Q;a&&((Q=E.current)==null||Q.focus())},[a]),A.useEffect(()=>{var Q;u&&((Q=j.current)==null||Q.focus())},[u]);const T=A.useCallback(Q=>{r(Q),CB(t,Q)},[t]),D=A.useCallback(Q=>{var B;const U=Q.map(ee=>ee.trim()).filter(Boolean);if(U.length===0)return;const I=n.map(ee=>Number(ee.id)).filter(ee=>Number.isInteger(ee)&&ee>=0),$=Math.max(-1,...I)+1,q=U.map((ee,X)=>({id:String($+X),description:ee,status:"pending"}));T([...n,...q]),f(""),(B=E.current)==null||B.focus()},[n,T]),L=A.useCallback(()=>{D([d])},[D,d]),O=A.useCallback(Q=>{const U=Q.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);U.length<2||(Q.preventDefault(),D(U))},[D]),M=A.useCallback(()=>{l(!1),f("")},[]),W=A.useCallback((Q,U)=>{c(Q),m(U)},[]),z=A.useCallback(()=>{if(!u)return;const Q=p.trim(),U=n.map(I=>I.id===u?{...I,description:Q||I.description}:I);T(U),c(null)},[u,p,n,T]),R=A.useCallback(Q=>{const U=n.map(I=>I.id===Q?{...I,status:wB[I.status]??"pending"}:I);T(U)},[n,T]),P=A.useCallback(Q=>{T(n.filter(U=>U.id!==Q))},[n,T]),V=A.useCallback(()=>{T([]),y(!1)},[T]),G=A.useCallback(Q=>{Q.key==="Enter"&&(Q.preventDefault(),L()),Q.key==="Escape"&&M()},[L,M]),Z=A.useCallback(Q=>{Q.key==="Enter"&&z(),Q.key==="Escape"&&c(null)},[z]);return i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[i.jsxs("div",{className:"bg-primary",children:[n.length===0&&!a&&i.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",i.jsx("button",{onClick:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((Q,U)=>{const I=Q.status,$=u===Q.id;return i.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${U>0?"border-t border-border":""}`,children:[i.jsx("button",{onClick:()=>R(Q.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${Q.status} (click to cycle)`,children:i.jsx(Xl,{status:I})}),i.jsx("div",{className:"flex-1 min-w-0",children:$?i.jsx("input",{ref:j,value:p,onChange:q=>m(q.target.value),onBlur:z,onKeyDown:Z,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"}):i.jsxs("button",{onClick:()=>W(Q.id,Q.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:["[",Q.id,"] ",Bg(Q.description)]})}),i.jsx("button",{onClick:()=>P(Q.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:i.jsx(Es,{className:"w-4 h-4"})})]},Q.id)})]}),a&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),i.jsx("input",{ref:E,value:d,onChange:Q=>f(Q.target.value),onKeyDown:G,onPaste:O,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"})]})}),i.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[a?i.jsxs(i.Fragment,{children:[i.jsxs("button",{onClick:L,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[i.jsx(ks,{className:"w-3 h-3"}),"Add"]}),i.jsx("button",{onClick:M,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):i.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[i.jsx(ks,{className:"w-3 h-3"}),"Add"]}),n.length>0&&i.jsxs("button",{onClick:()=>y(!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:[i.jsx(so,{className:"w-3 h-3"}),"Clear all"]}),i.jsx("button",{onClick:()=>C(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:i.jsx(Yp,{className:"w-3 h-3"})})]}),x&&i.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[i.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:V,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),i.jsx("button",{onClick:()=>y(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})}),i.jsx(wt,{isOpen:w,onClose:()=>C(!1),title:"About Acceptance Criteria",size:"md",children:i.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[i.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),i.jsxs("p",{children:["To use this feature, start in ",i.jsx(ju,{id:"planner",agents:v})," mode and",i.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",i.jsx(kB,{id:"default"})," builtin workflow to launch the automation part."]}),i.jsx("p",{children:"This workflow will automatically:"}),i.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[i.jsxs("li",{children:["Launch the ",i.jsx(ju,{id:"builder",agents:v}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),i.jsxs("li",{children:["Then launch the ",i.jsx(ju,{id:"verifier",agents:v})," 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."]}),i.jsxs("li",{children:["Launch a ",i.jsx(ju,{id:"code_reviewer",agents:v})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),i.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:i.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function jB({isOpen:e,onClose:t}){const n=Gr(C=>C.config),r=Gr(C=>C.saveConfig),[a,l]=A.useState(""),[u,c]=A.useState(""),[d,f]=A.useState(!1),[p,m]=A.useState(!1),[x,y]=A.useState(!1);A.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),c((n==null?void 0:n.url)??""),f((n==null?void 0:n.hotReload)??!1),m((n==null?void 0:n.disableInspect)??!1))},[e,n]);const w=async()=>{!a.trim()||!u.trim()||(y(!0),await r({command:a.trim(),url:u.trim(),hotReload:d,disableInspect:p}),y(!1),t())};return i.jsx(wt,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),i.jsx("input",{className:"input w-full",type:"text",value:a,onChange:C=>l(C.target.value),placeholder:"npm run dev"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),i.jsx("input",{className:"input w-full",type:"text",value:u,onChange:C=>c(C.target.value),placeholder:"http://localhost:3000"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"hotReload",checked:d,onChange:C=>f(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),i.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:C=>m(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),i.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),i.jsx("button",{className:"btn btn-primary",onClick:w,disabled:x||!a.trim()||!u.trim(),children:x?"Saving...":"Save"})]})]})})}const bS={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"},NB={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"},vS={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},TB="text-text-primary";function AB(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,a="text-text-primary",l;try{for(;(l=n.exec(e))!==null;){if(l.index>r){const f=e.slice(r,l.index);f&&t.push({text:f,className:a})}const u=l[1];if(!u)continue;const c=u.split(";").map(Number);if(c.length===0||c[0]===0){a="text-text-primary";continue}const d=[];for(const f of c)if(f>=30&&f<=37){const p=bS[f];p&&d.push(p)}else if(f>=40&&f<=47){const p=NB[f];p&&d.push(p)}else if(f>=90&&f<=97){const p=bS[f];p&&d.push(p)}else if(f in vS){const p=vS[f];p&&d.push(p)}else f===39?d.push(TB):f===49&&(a=a.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));d.length>0&&(a=d.join(" ")),r=n.lastIndex}if(r<e.length){const u=e.slice(r);u&&t.push({text:u,className:a})}return t}catch(u){return console.warn("ANSI parsing failed, stripping codes:",u),[{text:LB(e),className:"text-text-primary"}]}}function LB(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function od(e){const t=AB(e),n=[];return t.forEach((r,a)=>{const l=r.text.split(`
|
|
274
|
+
`);l.forEach((u,c)=>{n.push(ri.createElement("span",{key:`${a}-${c}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),c<l.length-1&&n.push(ri.createElement("br",{key:`${a}-${c}-br`}))})}),n.length===1?n[0]:n}function Ek({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return i.jsx("pre",{ref:t,className:n,children:e.length===0?i.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((r,a)=>i.jsx("span",{className:r.stream==="stderr"?"text-accent-warning":"",children:od(r.content)},a))})}function $g({isActive:e,onToggle:t,className:n,style:r}){return i.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:r,children:[e?i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):i.jsx(Qn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const $d=(e,t)=>{const n=A.useRef(!0),r=A.useRef(null),[a,l]=A.useState(!0),u=()=>{const c=e.current;c&&(c.scrollTop=c.scrollHeight)};return A.useEffect(()=>{const c=e.current;if(!c)return;const d=y=>{if(y.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(()=>{c.scrollHeight-c.scrollTop-c.offsetHeight<100&&(n.current=!0,l(!0))}));return}n.current=!1,l(!1)},f=y=>{y.touches[0]&&(r.current=y.touches[0].clientY)},p=y=>{if(r.current===null)return;const w=y.touches[0];if(!w)return;if(w.clientY-r.current>0){n.current=!1,l(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>{c.scrollHeight-c.scrollTop-c.offsetHeight<100&&(n.current=!0,l(!0))}))},m=new MutationObserver(()=>{n.current&&requestAnimationFrame(u)}),x=setInterval(()=>{n.current&&u()},1e3);return c.addEventListener("wheel",d,{passive:!0}),c.addEventListener("touchstart",f,{passive:!0}),c.addEventListener("touchmove",p,{passive:!0}),m.observe(c,{childList:!0,subtree:!0,characterData:!0}),()=>{c.removeEventListener("wheel",d),c.removeEventListener("touchstart",f),c.removeEventListener("touchmove",p),m.disconnect(),clearInterval(x)}},[t==null?void 0:t.id]),{force_scroll_to_bottom:()=>{n.current=!0,l(!0),u()},isAutoScrollActive:a,setAutoScroll:c=>{n.current=c,l(c),c&&u()}}},jk=A.memo(function({title:t,logs:n,onClose:r,preClassName:a}){const l=A.useRef(null),{isAutoScrollActive:u,setAutoScroll:c}=$d(l,null);return i.jsx(wt,{isOpen:!0,onClose:r,title:t,size:"full",headerRight:i.jsx($g,{isActive:u,onToggle:c,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),children:i.jsx("div",{ref:l,className:"h-full overflow-y-auto scrollbar-stable",children:i.jsx(Ek,{logs:n,preClassName:a})})})}),DB=A.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:a,onSetAutoScroll:l}){const[u,c]=A.useState(null),d=A.useRef(null),f=A.useRef(l);return f.current=l,A.useEffect(()=>{var m;const p=(m=n.current)==null?void 0:m.getBoundingClientRect();p&&c({bottom:window.innerHeight-p.bottom,right:window.innerWidth-p.right,width:p.width,height:p.height})},[n]),A.useEffect(()=>{const p=d.current;if(!p)return;const m=x=>{if(x.deltaY<0){f.current(!1);return}x.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{p.scrollHeight-p.scrollTop-p.offsetHeight<100&&f.current(!0)}))};return p.addEventListener("wheel",m,{passive:!0}),()=>p.removeEventListener("wheel",m)},[]),A.useEffect(()=>{d.current&&a&&(d.current.scrollTop=d.current.scrollHeight)},[t,a,u]),i.jsx("div",{className:`relative ${u?"":"hidden"}`,children:i.jsx("pre",{ref:d,className:"fixed z-40 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:u?{bottom:u.bottom,right:u.right,width:u.width*2,maxHeight:u.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1}:void 0,children:t.map((p,m)=>i.jsx("span",{className:p.stream==="stderr"?"text-accent-warning":"",children:od(p.content)},m))})})}),RB=A.memo(function({workdir:t}){const n=Gr(z=>z.setWorkdir),r=Gr(z=>z.status),a=Gr(z=>z.config),l=Gr(z=>z.logs),u=Gr(z=>z.start),c=Gr(z=>z.stop),d=Gr(z=>z.fetchLogs),[f,p]=A.useState(!1),[m,x]=A.useState(!1),[y,w]=A.useState(!1),[C,_]=A.useState(!1),S=A.useRef(null),{isAutoScrollActive:b,setAutoScroll:v}=$d(S,null),E=A.useRef(null),j=A.useRef(null),T=A.useRef(null),D=()=>{const z=r==null?void 0:r.inspectProxyPort;if(!z){r!=null&&r.url&&window.open(r.url,"_blank");return}const R=`${window.location.protocol}//${window.location.hostname}:${z}`;window.open(R,"_blank")},L=(r==null?void 0:r.state)??"off",O=a!==null,M=L==="running"||L==="warning";A.useEffect(()=>{n(t??null)},[t,n]),A.useEffect(()=>{M&&d()},[M,d]);const W=()=>{M?c():u()};return i.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${L==="running"?"bg-accent-success":L==="warning"?"bg-accent-warning":L==="error"?"bg-accent-error":"bg-text-muted"}`}),i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),i.jsx("button",{onClick:()=>p(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:i.jsx(ON,{})})]}),O?i.jsx(i.Fragment,{children:L==="running"||L==="warning"?i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("button",{onClick:W,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:[i.jsx(Xp,{}),"Stop"]}),(r==null?void 0:r.url)&&i.jsxs("button",{onClick:()=>D(),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:[i.jsx(MN,{}),"Open"]})]}):i.jsx("button",{onClick:W,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"})}):i.jsx("button",{onClick:()=>p(!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"}),i.jsxs("div",{ref:T,className:`relative ${O&&M?"":"hidden"}`,onMouseEnter:()=>{!O||!M||(j.current&&clearTimeout(j.current),E.current=setTimeout(()=>{w(!0),_(!1)},500))},onMouseLeave:()=>{E.current&&clearTimeout(E.current),_(!0),j.current=setTimeout(()=>w(!1),150)},children:[i.jsx(Ek,{logs:l,preRef:S,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),O&&M&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[(y||C)&&i.jsx($g,{isActive:b,onToggle:v,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),i.jsx("button",{onClick:()=>x(!0),className:"px-2 py-0.5 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors",children:"Expand"})]}),(y||C)&&T.current&&io.createPortal(i.jsx(DB,{logs:l,anchorRef:T,isHiding:C,isAutoScrollActive:b,onSetAutoScroll:v}),document.body)]})]}),i.jsx(jB,{isOpen:f,onClose:()=>p(!1)}),m&&i.jsx(jk,{title:"Dev Server Logs",logs:l,onClose:()=>x(!1)})]})}),OB=A.memo(function({sessionId:t}){var y;const n=vl(w=>w.processes),r=vl(w=>w.stopProcess),[a,l]=A.useState(null),[u,c]=A.useState([]),d=n.filter(w=>w.status!=="exited"),f=d.filter(w=>w.status==="running").length;if(n.length===0)return null;const p=w=>{switch(w){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"}},m=w=>{const C=vl.getState().logs[w]??[];c(C.map(_=>({content:_.content,stream:_.stream}))),l(w)},x=w=>{t&&r(w,t)};return i.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),i.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",f," running)"]})]})}),i.jsx("div",{className:"space-y-2",children:d.map(w=>i.jsx("div",{className:"border border-border rounded p-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(w.status)}`}),i.jsx("span",{className:"text-sm text-text-primary truncate",title:w.name,children:w.name}),i.jsxs("span",{className:"text-xs text-text-muted",children:["[",w.status,"]"]})]}),i.jsxs("div",{className:"flex gap-1 ml-2",children:[i.jsx("button",{onClick:()=>m(w.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"}),i.jsx("button",{onClick:()=>x(w.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"})]})]})},w.id))}),a&&i.jsx(jk,{title:((y=d.find(w=>w.id===a))==null?void 0:y.name)??"",logs:u,onClose:()=>{l(null),c([])}})]})});function IB({file:e,showEditorLink:t,workdir:n}){const r=w1(e.path,28),a=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",l=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"",u=t&&n?Ck(e.path,void 0,n):void 0,c=i.jsxs(i.Fragment,{children:[i.jsx("span",{className:`truncate ${a}`,title:e.path,children:r}),l&&i.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:l})]});return u?i.jsx("a",{href:u,className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0 hover:bg-bg-tertiary rounded px-1 -mx-1 transition-colors no-underline",title:`Open ${e.path} in VSCode`,children:c}):i.jsx("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:c})}function MB(){const{diff:e}=_k(),t=Gt(a=>a.settings[De.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",n=Re(a=>a.currentSession),r=(n==null?void 0:n.workspace)??(n==null?void 0:n.workdir);return e.loading?i.jsx("div",{className:"mt-3",children:i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[i.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),i.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?i.jsx("div",{className:"mt-3",children:i.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):i.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:i.jsx("div",{className:"pr-1",children:e.files.map((a,l)=>i.jsx(IB,{file:a,showEditorLink:t,workdir:r},l))})})}function Nk(e){const[t,n]=A.useState(!1),[r,a]=A.useState(null),[l,u]=A.useState(!1),[c,d]=A.useState(""),f=A.useCallback(()=>{t||e()},[t,e]),p=c.trim().length>0&&!t,m=A.useCallback(()=>{a(null),n(!1),d(""),u(!0)},[]);return{busy:t,setBusy:n,error:r,setError:a,loading:l,setLoading:u,newName:c,setNewName:d,handleClose:f,canCreate:p,resetState:m}}function Tk({isOpen:e,onClose:t,title:n,busy:r,loading:a,children:l}){const u=i.jsx("div",{className:"flex gap-2 justify-end",children:i.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Cancel"})});return i.jsx(wt,{isOpen:e,onClose:t,title:n,size:"md",footer:u,children:a||r?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(ui,{})}):l})}function Ak({icon:e,title:t,placeholder:n,buttonLabel:r,value:a,onChange:l,onCreate:u,canCreate:c,busy:d}){return i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:t}),i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded border border-border bg-bg-primary focus-within:border-accent-primary mb-3",children:[i.jsx("span",{className:"w-4 h-4 shrink-0 text-text-muted flex items-center",children:e}),i.jsx("input",{type:"text",value:a,onChange:f=>l(f.target.value),onKeyDown:f=>{f.key==="Enter"&&c&&u()},placeholder:n,className:"flex-1 bg-transparent text-sm text-text-primary outline-none font-mono placeholder-text-muted"})]}),i.jsx("button",{onClick:u,disabled:!c||d,className:"w-full px-4 py-2 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-50",children:r})]})}function PB({isOpen:e,onClose:t,sessionId:n}){const r=Re(D=>D.loadSession),{busy:a,setBusy:l,error:u,setError:c,loading:d,setLoading:f,newName:p,setNewName:m,handleClose:x,canCreate:y,resetState:w}=Nk(t),[C,_]=A.useState([]),[S,b]=A.useState(""),[v,E]=A.useState("");A.useEffect(()=>{e&&(w(),b(""),_([]),E(""),we(`/api/sessions/${n}/branches`).then(D=>D.json()).then(D=>{_(D.branches),E(D.defaultBranch??""),f(!1)}).catch(()=>{_([]),f(!1)}))},[e,n,w,f]);const j=A.useCallback(async D=>{c(null),l(!0);try{const L=await we(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:D})});if(!L.ok){const O=await L.json().catch(()=>({error:"Failed to switch branch"}));c(O.error),l(!1);return}await r(n),t()}catch(L){c(L instanceof Error?L.message:"Failed to switch branch"),l(!1)}},[n,r,t,c,l]),T=A.useCallback(async()=>{c(null),l(!0);try{const D={name:p.trim()};S&&(D.sourceBranch=S);const L=await we(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(!L.ok){const O=await L.json().catch(()=>({error:"Failed to create branch"}));c(O.error),l(!1);return}await r(n),t()}catch(D){c(D instanceof Error?D.message:"Failed to create branch"),l(!1)}},[p,S,n,r,t,c,l]);return i.jsx(Tk,{isOpen:e,onClose:x,title:"Switch Branch",busy:a,loading:d,children:i.jsxs("div",{children:[C.length>0&&i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Branches"}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(D=>i.jsxs("button",{onClick:()=>{D.current||j(D.name)},disabled:a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${D.current?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,children:[i.jsx(Mu,{className:"w-3.5 h-3.5 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:D.name}),D.current&&i.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!D.current&&i.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},D.name))})]}),i.jsx(Ak,{icon:i.jsx(Mu,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:p,onChange:m,onCreate:T,canCreate:y,busy:a}),p.trim()&&i.jsxs("div",{className:"mt-2",children:[i.jsxs("label",{className:"text-xs text-text-muted mb-1 block",children:["From branch (optional — defaults to ",v||"project default",")"]}),i.jsxs("div",{className:"relative",children:[i.jsx(Mu,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted pointer-events-none"}),i.jsx("input",{type:"text",value:S,onChange:D=>b(D.target.value),placeholder:v||"main",className:"w-full text-sm bg-bg-primary border border-border-default rounded pl-8 pr-2 py-1.5 text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),u&&i.jsx("p",{className:"mt-3 text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})})}function BB({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:l}){const u=Re(R=>R.loadSession),{busy:c,setBusy:d,error:f,setError:p,loading:m,setLoading:x,newName:y,setNewName:w,handleClose:C,canCreate:_,resetState:S}=Nk(t),[b,v]=A.useState([]),[E,j]=A.useState(null),[T,D]=A.useState(null),[L,O]=A.useState(!1);A.useEffect(()=>{e&&(S(),j(null),D(null),O(!1),we(`/api/projects/${n}/workspaces`).then(R=>R.json()).then(R=>{v(R.workspaces),x(!1)}).catch(()=>{v([]),x(!1)}))},[e,n,S,x]);const M=A.useCallback(async R=>{p(null),d(!0);try{const P=await we(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:R})});if(!P.ok){const V=await P.json().catch(()=>({error:"Failed to switch workspace"}));p(V.error),d(!1);return}await u(r),t()}catch(P){p(P instanceof Error?P.message:"Failed to switch workspace"),d(!1)}},[r,u,t,p,d]),W=A.useCallback(async(R,P)=>{p(null),D(null),O((P==null?void 0:P.force)===!0),d(!0);try{const V=await we(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:R,force:(P==null?void 0:P.force)===!0})});if(!V.ok){const Q=await V.json().catch(()=>({error:"Failed to delete workspace"}));p(Q.error),Q.conflictingSessionIds&&D(Q.conflictingSessionIds),O(!1),d(!1);return}j(null),O(!1),await u(r);const Z=await(await we(`/api/projects/${n}/workspaces`)).json();v(Z.workspaces),d(!1),x(!1)}catch(V){p(V instanceof Error?V.message:"Failed to delete workspace"),O(!1),d(!1)}},[r,n,u,p,d]),z=A.useCallback(async()=>{p(null),d(!0);try{const R=await we(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:y.trim()})});if(!R.ok){const P=await R.json().catch(()=>({error:"Failed to create workspace"}));p(P.error),d(!1);return}await u(r),t()}catch(R){p(R instanceof Error?R.message:"Failed to create workspace"),d(!1)}},[y,r,u,t,p,d]);return i.jsx(Tk,{isOpen:e,onClose:C,title:"Switch Workspace",busy:c,loading:m,children:i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),i.jsxs("div",{className:"max-h-48 overflow-y-auto space-y-0.5 bg-bg-tertiary/30 rounded p-2 mb-4",children:[i.jsxs("button",{onClick:()=>M("original"),disabled:c,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${a?"hover:bg-bg-tertiary text-text-secondary":"bg-accent-primary/10 text-accent-primary cursor-default"}`,children:[i.jsx(Kr,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:"original"}),i.jsx("span",{className:"text-xs text-text-muted ml-auto",children:l??"unknown"}),!a&&i.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),b.slice().sort((R,P)=>R.name===a?-1:P.name===a?1:R.name.localeCompare(P.name)).map(R=>i.jsx("div",{className:"group relative",children:E===R.name?i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded bg-accent-error/10",children:[i.jsxs("span",{className:"text-xs text-accent-error",children:["Delete ",R.name,"?"]}),i.jsx("button",{onClick:()=>W(R.name),disabled:c,className:"ml-auto text-xs px-2 py-0.5 rounded bg-accent-error text-white hover:opacity-90",children:"Confirm"}),i.jsx("button",{onClick:()=>j(null),disabled:c,className:"text-xs px-2 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary",children:"Cancel"})]}):i.jsxs("div",{className:"relative",children:[i.jsxs("button",{onClick:()=>{!c&&R.name!==a&&M(R.name)},disabled:c||R.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${R.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${c?"opacity-70":""}`,children:[i.jsx(Kr,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"font-mono truncate",children:R.name}),i.jsx("span",{className:"text-xs text-text-muted ml-auto",children:R.branch??"unknown"}),R.name===a&&i.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),R.name!==a&&!c&&i.jsx("button",{onClick:P=>{P.stopPropagation(),p(null),D(null),j(R.name)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 text-xs text-text-muted hover:text-accent-error transition-opacity px-1 py-0.5 rounded",title:"Delete workspace",children:"✕"})]})},R.path))]}),i.jsx(Ak,{icon:i.jsx(Kr,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:y,onChange:w,onCreate:z,canCreate:_,busy:c}),f&&i.jsxs("div",{className:"mt-3 text-sm bg-accent-error/10 p-2 rounded",role:"alert",children:[i.jsx("p",{className:"text-accent-error",children:f}),T&&T.length>0&&i.jsxs("div",{className:"mt-2 space-y-1",children:[i.jsx("p",{className:"text-xs text-text-muted",children:"Conflicting sessions:"}),i.jsx("ul",{className:"space-y-0.5",children:T.map(R=>i.jsx("li",{children:i.jsx(Xn,{href:`/p/${n}/s/${R}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:R})},R))}),i.jsx("button",{onClick:()=>W(E??"",{force:!0}),disabled:c||!E,className:"mt-2 text-xs px-2 py-1 rounded bg-accent-warning text-black hover:opacity-90 disabled:opacity-50","aria-label":"Force delete workspace, switching other sessions to original",children:L?"Processing...":"Force Delete (switch other sessions to original)"})]})]})]})})}function _S({messages:e,workdir:t}){var T,D,L;const[n,r]=A.useState(!1),[a,l]=A.useState(!1),[u,c]=A.useState(!1),[d,f]=A.useState(!1),[p,m]=A.useState(null),x=J6(e),{branch:y}=_k(),w=Qt(O=>O.version),C=Re(O=>O.currentSession),_=C!=null&&C.workspace?C.workspace.split("/").pop()??null:null,S=Gt(O=>O.settings[De.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",b=ws(O=>O.status),v=ws(O=>O.check),[E,j]=A.useState(!1);return i.jsxs("div",{className:"flex flex-col h-full",children:[x&&i.jsxs("div",{className:"mb-4",children:[i.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:i.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[i.jsx("span",{className:"text-text-secondary",children:Yr(x.aiTime)}),i.jsx("span",{className:"w-px h-3 bg-border"}),i.jsx("span",{className:"text-text-secondary",children:hS(x.avgPrefillSpeed)}),i.jsx("span",{children:"pp"}),i.jsx("span",{className:"w-px h-3 bg-border"}),i.jsx("span",{className:"text-text-secondary",children:hS(x.avgGenerationSpeed)}),i.jsx("span",{children:"tg"})]})}),i.jsx(dB,{isOpen:n,onClose:()=>r(!1),stats:x})]}),i.jsx("div",{className:"flex flex-col flex-1 overflow-y-auto scrollbar-stable",children:i.jsxs("div",{className:"mt-4",children:[i.jsx("button",{onClick:()=>m("criteria"),className:"w-full text-left cursor-pointer hover:bg-bg-tertiary rounded px-1 -mx-1 transition-colors",children:i.jsx(yS,{entries:((T=C==null?void 0:C.metadataEntries)==null?void 0:T.criteria)??[],title:"Acceptance Criteria"})}),C&&i.jsx(EB,{entries:((D=C==null?void 0:C.metadataEntries)==null?void 0:D.criteria)??[],sessionId:C.id}),C&&(()=>{const O=["review_findings","todos"],M=C.metadataEntries??{},W=O.filter(R=>R in M),z=Object.keys(M).filter(R=>R!=="criteria"&&!O.includes(R)).sort();return[...W,...z].filter(R=>{var P;return(((P=M[R])==null?void 0:P.length)??0)>0}).map(R=>i.jsxs("div",{className:"mt-6",children:[i.jsx("button",{onClick:()=>m(R),className:"w-full text-left cursor-pointer hover:bg-bg-tertiary rounded px-1 -mx-1 transition-colors",children:i.jsx(yS,{entries:M[R],title:Hp(R)})}),i.jsx(xB,{entries:M[R],onClearAll:async()=>{try{await we(`/api/sessions/${C.id}/metadata/${R}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(P){console.error(`Failed to clear ${R}:`,P)}}})]},R))})()]})}),y!==null&&i.jsxs("div",{className:"mt-4 space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[S&&t?i.jsxs("a",{href:Z6(t),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[i.jsx(Kr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary group-hover:text-accent-primary transition-colors",children:_??"original"})]}):i.jsxs(i.Fragment,{children:[i.jsx(Kr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),i.jsx("span",{className:"truncate text-text-secondary",children:_??"original"})]}),i.jsx("button",{onClick:()=>f(!0),className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]}),i.jsx("div",{className:"h-px bg-border"}),i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(Mu,{}),i.jsx("span",{className:"truncate text-text-secondary",children:y}),i.jsx("button",{onClick:()=>c(!0),className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]})]}),i.jsx(MB,{}),i.jsx(RB,{workdir:t}),i.jsx(OB,{sessionId:C==null?void 0:C.id}),w&&i.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[i.jsxs("div",{className:"flex items-center justify-center gap-1",children:[i.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",i.jsxs("span",{className:"font-mono",children:["v",w]}),i.jsx("button",{onClick:()=>{j(!0),v(!0)},disabled:b==="checking",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:i.jsx(pd,{className:`w-3 h-3 ${b==="checking"?"animate-spin":""}`})})]}),b==="available"&&i.jsx("button",{onClick:()=>l(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"}),E&&b==="upToDate"&&i.jsx("div",{className:"mt-1",children:"Up to date"}),b==="error"&&i.jsx("div",{className:"mt-1",children:"Update check failed"})]}),i.jsx(j1,{isOpen:a,onClose:()=>l(!1),versionInfo:null}),i.jsx(SB,{isOpen:p!==null,onClose:()=>m(null),entries:((L=C==null?void 0:C.metadataEntries)==null?void 0:L[p??""])??[],sessionId:(C==null?void 0:C.id)??"",metadataKey:p??"",title:Hp(p??"")}),C&&i.jsxs(i.Fragment,{children:[i.jsx(BB,{isOpen:d,onClose:()=>f(!1),projectId:C.projectId,sessionId:C.id,currentWorkspace:_,currentBranch:y??null}),i.jsx(PB,{isOpen:u,onClose:()=>c(!1),sessionId:C.id})]})]})}function $B({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const a=Re(l=>l.currentSession);return i.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&i.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),i.jsxs("div",{className:"flex h-full",children:[i.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?i.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary scrollbar-stable",children:i.jsx(_S,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})}):i.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),i.jsx("aside",{className:`
|
|
275
|
+
md:hidden
|
|
276
|
+
p-4 overflow-y-auto bg-secondary
|
|
277
|
+
transition-all duration-300 ease-in-out
|
|
278
|
+
fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
|
|
279
|
+
${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
|
|
280
|
+
`,children:i.jsx(_S,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})]})]})}function zB(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function Lk({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const a=n==="sm"?"w-12":"w-20",l=n==="sm"?"h-1":"h-1.5";return i.jsx("div",{className:`${l} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:i.jsx("div",{className:`h-full transition-all duration-300 ${zB(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function HB({dangerZone:e,size:t="md"}){return e?i.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function SS(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function UB(){const e=Re(b=>b.contextState),t=Re(b=>b.currentSession),n=Re(b=>b.compactContext),[r,a]=A.useState(!1),[l,u]=A.useState(!1),[c,d]=A.useState(!1),f=A.useRef(!1);if(A.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!f.current&&u(!1),f.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),!e||!t)return null;const{currentTokens:p,maxTokens:m,compactionCount:x,dangerZone:y,dynamicContextChanged:w}=e,C=Math.round(p/m*100),_=t.isRunning,S=()=>{Xt.send("context.applyDynamic",{}),u(!0)};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:SS(C,y),children:[eo(p)," / ",eo(m)]}),i.jsxs("span",{className:SS(C,y),children:["(",C,"%)"]}),i.jsx(Lk,{percent:C,dangerZone:y}),i.jsx(HB,{dangerZone:y}),x>0&&i.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"x"]})]}),i.jsx("div",{className:"flex-1 flex justify-end",children:i.jsxs("div",{className:"relative",children:[i.jsx("button",{onClick:()=>a(!r),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:i.jsx(h1,{})}),r&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>a(!1)}),i.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:[i.jsx("button",{onClick:()=>{_||n(),a(!1)},disabled:_,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:_?"Cannot compact while running":"Compact context",children:i.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),w&&i.jsx("button",{onClick:()=>{a(!1),d(!0)},disabled:_,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:_?"Cannot apply while running":"Apply dynamic context",children:i.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]})})]})}),w&&!l&&i.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[i.jsx("span",{children:"System prompt has changed —"}),i.jsx("button",{onClick:()=>d(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),i.jsx("button",{onClick:()=>u(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:i.jsx(Es,{})})]})}),i.jsxs(wt,{isOpen:c,onClose:()=>d(!1),title:"Update system prompt",size:"sm",children:[i.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."}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{onClick:()=>d(!1),className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),i.jsx("button",{onClick:()=>{S(),d(!1)},disabled:_,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 FB({stats:e,onClose:t}){var c;const n=mt(d=>d.defaults),r=mt(d=>d.userItems),l=[...n,...r].find(d=>d.id===e.mode),u=(l==null?void 0:l.name)??e.mode;return i.jsx(wt,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex items-center gap-3",children:i.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",u]})}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[i.jsx(Nu,{label:"Total Time",value:Yr(e.totalTime)}),i.jsx(Nu,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),i.jsx(Nu,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),i.jsx(Nu,{label:"LLM Calls",value:String(((c=e.llmCalls)==null?void 0:c.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((d,f)=>i.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",f+1]}),i.jsxs("span",{className:"text-xs text-text-muted",children:[d.ttft.toFixed(2),"s TTFT · ",d.completionTime.toFixed(2),"s gen"]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",i.jsxs("span",{className:"text-text-primary",children:[d.promptTokens," → ",d.completionTokens]})]}),i.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[d.temperature!==void 0&&i.jsx(Tu,{label:"temp",value:d.temperature.toFixed(2)}),d.topP!==void 0&&i.jsx(Tu,{label:"topP",value:d.topP.toFixed(2)}),d.topK!==void 0&&i.jsx(Tu,{label:"topK",value:String(d.topK)}),d.maxTokens!==void 0&&i.jsx(Tu,{label:"maxTok",value:String(d.maxTokens)})]})]})]},f))]})]})})}function Nu({label:e,value:t}){return i.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[i.jsx("div",{className:"text-xs text-text-muted",children:e}),i.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function Tu({label:e,value:t}){return i.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[i.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}const VB=A.memo(function({content:t,variant:n="default"}){return n==="labeled"?i.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[i.jsx("span",{className:"text-text-thinking",children:"thinking:"}),i.jsx("div",{className:"ml-1.5 mt-0.5 overflow-x-auto",children:i.jsx(Bn,{content:t})})]}):i.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item overflow-x-auto",children:i.jsx(Bn,{content:t,muted:!0})})});function Dk({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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"})}):e==="workspace"?i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}):i.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.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"})})}function GB({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return i.jsx(n,{className:"language-",children:i.jsx("code",{className:"language-",children:e})})}const to=A.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:l=1}){const{showSyntaxHighlighting:u}=Ki(),[c,d]=A.useState(null),f=sk(),p=A.useRef(t);if(A.useEffect(()=>{u&&(p.current=t,rk(t,n,f).then(x=>{p.current===t&&d(x)}))},[t,n,f,u]),!u||!c)return i.jsx(GB,{code:t,variant:r});if(r==="inline")return i.jsx("span",{dangerouslySetInnerHTML:{__html:c}});const m=a?"":"shiki-plain";return i.jsx("div",{className:m,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:c}})});function Rk({src:e,alt:t,isOpen:n,onClose:r}){return n?i.jsx(wt,{isOpen:n,onClose:r,title:"",size:"full",children:i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const ld=A.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",a=t==="removed"?"line-through decoration-red-400/30":"";return i.jsx("div",{className:`border-l-[3px] ${r}`,children:i.jsx("div",{className:`min-w-0 py-3 ${a}`,children:i.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),WB=A.memo(function({oldString:t,newString:n,filePath:r}){const a=A.useMemo(()=>Pd(r),[r]),l=t.length>0,u=n.length>0;return!l&&!u?i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):i.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[l&&i.jsx(ld,{type:"removed",children:i.jsx(to,{code:t,language:a,variant:"block",showLineNumbers:!0})}),u&&i.jsx(ld,{type:"added",children:i.jsx(to,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),qB=A.memo(function({content:t,filePath:n}){const r=A.useMemo(()=>Pd(n),[n]);return i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:i.jsx(ld,{type:"added",children:i.jsx(to,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),KB=A.memo(function({regions:t,filePath:n}){const r=A.useMemo(()=>Pd(n),[n]);return t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):i.jsx("div",{className:"space-y-2",children:t.map((a,l)=>i.jsx(XB,{region:a,language:r},l))})});function YB(e){const t=[];function n(r,a,l){const u=t[t.length-1];u&&u.type===r&&u.startLine+u.lines.length===a?u.lines.push(l):t.push({type:r,startLine:a,lines:[l]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const a=r.oldContent.split(`
|
|
281
|
+
`);for(let u=0;u<a.length;u++)n("removed",r.startLine+u,a[u]);const l=r.newContent.split(`
|
|
282
|
+
`);for(let u=0;u<l.length;u++)n("added",r.startLine+u,l[u])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const XB=A.memo(function({region:t,language:n}){const r=YB(t);return i.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,l)=>i.jsx(QB,{section:a,language:n},l))})}),QB=A.memo(function({section:t,language:n}){const r=t.lines.join(`
|
|
283
|
+
`);return t.type==="context"?i.jsx("div",{children:i.jsx("div",{className:"min-w-0 py-3",children:i.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:i.jsx(to,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):i.jsx(ld,{type:t.type,children:i.jsx(to,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function wS(e){return e.split(`
|
|
284
|
+
`).filter(t=>!t.startsWith(`
|
|
285
|
+
[`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
|
|
286
|
+
`)}const JB=A.memo(function({result:t,metadata:n,filePath:r}){const[a,l]=A.useState(!1),u=A.useMemo(()=>Pd(r),[r]),c=n==null?void 0:n.mimeType,d=n==null?void 0:n.base64Data;if(c!=null&&c.startsWith("image/")&&d){const w=`data:${c};base64,${d}`;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors",onClick:()=>l(!0),children:i.jsx("img",{src:w,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),i.jsx(Rk,{src:w,alt:r,isOpen:a,onClose:()=>l(!1)})]})}if(!t)return i.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const f=t;if(u==="markdown"){const w=wS(f);return i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto p-2",children:i.jsx(Bn,{content:w})})}const p=wS(f),m=f.split(`
|
|
287
|
+
`)[0],x=m==null?void 0:m.match(/^(\d+)\|/),y=x?parseInt(x[1],10):1;return i.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:i.jsx(to,{code:p,language:u,variant:"block",showLineNumbers:!0,startLine:y})})}),ZB={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"}},CS=A.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(l=>l.severity==="error"),r=t.filter(l=>l.severity==="warning"),a=t.filter(l=>l.severity==="info"||l.severity==="hint");return i.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[i.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[i.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&i.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&i.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&i.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),i.jsx("div",{className:"max-h-48 overflow-y-auto",children:t.map((l,u)=>{const c=ZB[l.severity];return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${c.bg} border-b border-border last:border-b-0`,children:[i.jsx("span",{className:`${c.color} text-xs flex-shrink-0 w-4 text-center`,children:c.icon}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",l.range.start.line+1,":",l.range.start.character+1]}),l.code&&i.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",l.code,"]"]})]}),i.jsx("div",{className:"text-xs text-text-primary break-words",children:l.message})]})]},u)})})]})}),e8=A.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:l,result:u,error:c,durationMs:d}){const f=A.useRef(null),[p,m]=A.useState(0);A.useEffect(()=>{f.current&&l==="pending"&&(f.current.scrollTop=f.current.scrollHeight)},[a,l]),A.useEffect(()=>{if(l!=="pending"||!r)return;const C=setInterval(()=>{m(Date.now()-r)},100);return()=>clearInterval(C)},[l,r]);const x=n/1e3,y=l==="pending"?p/1e3:(d??0)/1e3,w=l==="pending"?(a==null?void 0:a.map(C=>C.content).join(""))??"":u??"";return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[i.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),i.jsx("code",{className:"text-text-primary break-all",children:t})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[l==="pending"&&i.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),l==="interrupted"&&i.jsx("span",{className:"text-red-400",children:"interrupted"}),i.jsxs("span",{className:l==="pending"?"text-text-secondary":"text-text-muted",children:[y.toFixed(1),"s / ",x,"s"]})]})]}),l==="pending"&&i.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(w||l==="pending")&&i.jsx("pre",{ref:f,className:`text-xs bg-bg-primary p-2 rounded max-h-64 overflow-y-auto ${l==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:l==="pending"&&a?a.map((C,_)=>i.jsx("span",{className:C.stream==="stderr"?"text-accent-warning":"",children:od(C.content)},_)):od(w)}),l==="error"&&c&&i.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:c}),l!=="pending"&&d!==void 0&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Completed in ",(d/1e3).toFixed(2),"s"]})]})}),ml=A.memo(function({className:t=""}){return i.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})}),t8=A.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return console.warn("DevServerView: failed to parse result JSON",t.slice(0,200)),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}return n==="logs"?n8(r):r8(r)});function n8(e){if(!e.logs)return i.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"});const t=e.logs.split(`
|
|
288
|
+
`);return i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] overflow-y-auto break-words",children:t.map((n,r)=>{const a=n.startsWith("[stderr] ");return i.jsx("div",{className:a?"text-accent-warning":"",children:a?n.slice(9):n},r)})}),e.hasMore&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",e.limit," of ",e.total," lines"]})]})}function r8(e){const t=String(e.state??""),n=String(e.url??""),r=e.error?String(e.error):void 0,a=t==="running"?"text-accent-success":t==="stopped"?"text-text-muted":t==="error"?"text-accent-error":"text-text-muted";return i.jsxs("div",{className:"space-y-2 text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"State:"}),i.jsx("span",{className:`font-medium ${a}`,children:t})]}),n&&n!=="undefined"&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"URL:"}),i.jsx("a",{href:n,className:"text-accent-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:n})]}),r&&i.jsx("div",{className:"text-accent-error bg-accent-error/10 p-2 rounded",children:r})]})}const s8=A.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return console.warn("BackgroundProcessView: failed to parse result JSON",t.slice(0,200)),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}return n==="logs"?i8(r):n==="list"?a8(r):n==="status"?o8(r):n==="start"||n==="stop"?l8(r):i.jsxs("div",{className:"space-y-2 text-xs",children:[i.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})]})});function i8(e){const t=e.lines,n=e.hasMore,r=e.totalLines;return!t||t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"}):i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] overflow-y-auto break-words",children:t.map((a,l)=>i.jsx("div",{className:a.stream==="stderr"?"text-accent-warning":"",children:a.content},l))}),n&&r!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function a8(e){const t=e.processes,n=e.currentCount,r=e.maxPerSession;return!t||t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No background processes"}):i.jsxs("div",{className:"space-y-2",children:[t.map(a=>i.jsx(Ok,{process:a},a.id)),n!=null&&r!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function o8(e){const t=e.process,n=e.uptime;return t?i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ok,{process:t}),n!=null&&i.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",c8(n)]})]}):i.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function l8(e){const t=e.processId,n=e.name,r=e.pid,a=e.status,l=a==="running"?"text-accent-success":"text-text-muted";return i.jsxs("div",{className:"space-y-2 text-xs",children:[n&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"Name:"}),i.jsx("span",{className:"font-medium",children:n})]}),t&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"ID:"}),i.jsx("span",{className:"font-mono",children:t})]}),r!=null&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"PID:"}),i.jsx("span",{className:"font-mono",children:r})]}),a&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-text-muted",children:"Status:"}),i.jsx("span",{className:`font-medium ${l}`,children:a})]})]})}function Ok({process:e}){const t=e.status==="running"?"text-accent-success":(e.status==="exited","text-text-muted");return i.jsxs("div",{className:"border border-border rounded p-2 space-y-1 text-xs",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-medium",children:e.name}),i.jsx("span",{className:`${t}`,children:e.status})]}),e.pid!=null&&i.jsxs("div",{className:"text-text-muted",children:["PID: ",i.jsx("span",{className:"font-mono",children:e.pid})]}),e.command&&i.jsx("div",{className:"text-text-muted font-mono truncate",children:e.command})]})}function c8(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h ${n%60}m`:n>0?`${n}m ${t%60}s`:`${t}s`}const u8=A.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}switch(n){case"list":return d8(r);case"switch":case"delete":return h8(r);default:return i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:t})}});function d8(e){const t=e.workspaces??[];return t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic",children:"No workspaces found"}):i.jsxs("div",{className:"space-y-1 text-xs",children:[i.jsx("div",{className:"text-text-muted mb-1",children:"Workspaces:"}),t.map(n=>i.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[i.jsx("span",{className:n.active?"text-accent-success":"text-text-muted",children:n.active?"●":"○"}),i.jsx("span",{className:n.active?"text-text-primary font-medium":"text-text-secondary",children:n.name}),n.branch&&i.jsxs("span",{className:"text-text-muted",children:["· ",n.branch]}),n.active&&i.jsx("span",{className:"text-[10px] text-accent-primary",children:"(current)"})]},n.name))]})}function Xm({label:e,value:t,mono:n}){return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-text-muted",children:[e,":"]}),i.jsx("span",{className:n?"font-mono text-accent-primary":"text-text-primary",children:t})]})}function h8(e){return i.jsxs("div",{className:"space-y-2 text-xs",children:[e.message&&i.jsx("div",{className:"text-text-primary",children:e.message}),e.workspace&&i.jsx(Xm,{label:"Name",value:e.workspace,mono:!0}),e.path&&i.jsx(Xm,{label:"Path",value:e.path,mono:!0}),e.branch&&i.jsx(Xm,{label:"Branch",value:e.branch,mono:!0})]})}function f8(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 m8({confirmation:e}){const t=Re(m=>m.confirmPath),n=Re(m=>m.currentSession),r=Re(m=>m.switchDangerLevel),{title:a,description:l}=f8(e.reason),u=e.reason==="sensitive_file"||e.reason==="both",c=u?"border-red-500/50":"border-amber-500/50",d=u?"bg-red-500/10":"bg-amber-500/10",f=e.reason==="git_no_verify",p=()=>{n!=null&&n.id&&r("dangerous"),t(e.callId,!0,!1)};return i.jsxs("div",{className:`border ${c} ${d} rounded p-3 my-2`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(ip,{}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:`text-sm font-medium ${u?"text-red-400":"text-amber-400"}`,children:a}),i.jsx("div",{className:"text-xs text-text-muted",children:l})]})]}),i.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[i.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),i.jsx("div",{className:"bg-bg-primary rounded p-2 mb-3 max-h-24 overflow-y-auto",children:i.jsx("ul",{className:"space-y-0.5",children:e.paths.map((m,x)=>i.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:m},x))})}),i.jsxs("div",{className:"flex gap-2",children:[i.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"}),i.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"}),i.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${f?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function p8(e,t){if(e==="read_file"){const r=String(t.path??""),a=t.offset,l=t.limit,u=[];return a!==void 0&&a!==1&&u.push(`offset=${a}`),l!==void 0&&u.push(`limit=${l}`),u.length>0?`${r} [${u.join(", ")}]`:r}if(e==="write_file"||e==="edit_file")return String(t.path??"");if(e==="run_command"||e==="bash")return String(t.command??"");if(e==="return_value"){const r=String(t.content??"");return r.length>60?r.slice(0,60)+"...":r}if(e==="call_sub_agent")return String(t.subAgentType??"");if(e==="load_skill")return String(t.skillId??"");if(e==="web_fetch")return String(t.url??"");if(e==="web_search"){const r=String(t.query??"");return r.length>60?r.slice(0,57)+"...":r}if(e==="dev_server")return String(t.action??"");if(e==="background_process"){const r=String(t.action??""),a=t.name?String(t.name):"";return a?`${r}: ${a}`:r}if(e==="mcp_config")return String(t.action??"");const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function kS(e,t,n){var a;const r=p8(e,t);if(e==="read_file"&&n){const l=n.format,u=n.pageCount;if(l==="pdf"&&u!=null)return`${r} (PDF, ${u}p)`;if(l==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const l=n.contentType;if(l){const u=((a=l.split(";")[0])==null?void 0:a.trim())??"";if(u&&u!=="text/html")return`${r} (${u})`}}return r}function g8(e){return JSON.stringify(e,null,2)}const x8={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-text-tool-error",animate:!1}},y8=A.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:l,result:u,error:c,durationMs:d,diagnostics:f,editContext:p,startedAt:m,streamingOutput:x,metadata:y,truncated:w,callId:C}){var L;const _=!l,[S,b]=A.useState(_),v=x8[r],E=Gt(O=>O.settings[De.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",j=t==="edit_file"?(L=p==null?void 0:p.regions[0])==null?void 0:L.startLine:t==="read_file"?(()=>{const O=u==null?void 0:u.split(`
|
|
289
|
+
`)[0],M=O==null?void 0:O.match(/^(\d+): /);return M?parseInt(M[1],10):void 0})():void 0,T=Re(O=>O.pendingPathConfirmations),D=C?T.find(O=>O.callId===C||O.callId.startsWith(C+"-"))??null:null;return t==="step_done"?i.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary border border-border rounded px-2 py-1.5 my-1",children:[i.jsx("span",{className:`${v.color} ${v.animate?"animate-pulse":""}`,children:v.icon}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t})]}):a==="compact"?i.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary rounded px-2 py-1.5",children:[i.jsx(Dk,{tool:t}),i.jsx("span",{className:"text-accent-primary font-medium",children:t}),i.jsx("span",{className:"text-text-muted truncate flex-1",children:kS(t,n,y)}),i.jsx("span",{className:`${v.color} ${v.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):i.jsxs("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0",children:[i.jsxs("button",{className:"w-full flex items-center gap-1.5 p-2 bg-secondary hover:bg-secondary/80 text-left",onClick:()=>b(!S),children:[i.jsx("span",{className:`${v.color} ${v.animate?"animate-pulse":""}`,children:v.icon}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),i.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:kS(t,n,y)}),i.jsx("span",{className:"text-text-muted text-xs",children:S?"▼":"▶"})]}),S&&i.jsxs("div",{className:"p-2 bg-primary border-t border-border space-y-2 min-w-0",children:[t==="run_command"&&i.jsx(e8,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:x,status:r,result:u,error:c,durationMs:d}),t==="edit_file"&&r==="success"&&i.jsxs(i.Fragment,{children:[p&&p.regions.length>0?i.jsx(KB,{regions:p.regions,filePath:String(n.path??"")}):i.jsx(WB,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),f&&f.length>0&&i.jsx(CS,{diagnostics:f})]}),t==="write_file"&&r==="success"&&i.jsxs(i.Fragment,{children:[i.jsx(qB,{content:String(n.content??""),filePath:String(n.path??"")}),f&&f.length>0&&i.jsx(CS,{diagnostics:f})]}),t==="read_file"&&r==="success"&&i.jsx(JB,{result:u,metadata:y,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const O=(x==null?void 0:x.map(W=>W.content).join(""))??"",M=r==="pending"&&O?O:String(n.content??"");return i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:i.jsx(Bn,{content:M})})]})})(),t==="call_sub_agent"&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:[String(n.subAgentType??"Sub-Agent")," Prompt"]}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Bn,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&i.jsxs("div",{children:[i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Bn,{content:u??""})}),w&&i.jsx(ml,{className:"mt-1"})]}),t==="load_skill"&&r==="success"&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:["Skill: ",String(n.skillId??"")]}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Bn,{content:u??""})}),w&&i.jsx(ml,{className:"mt-1"})]}),t==="web_fetch"&&r==="success"&&i.jsxs("div",{className:"space-y-2",children:[!!(y!=null&&y.url)&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[i.jsx("span",{children:"Source:"}),i.jsx("a",{href:String(y.url),className:"text-accent-primary hover:underline truncate",target:"_blank",rel:"noopener noreferrer",children:String(y.url)}),!!(y!=null&&y.contentType)&&i.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["(",String(y.contentType),")"]}),(y==null?void 0:y.pageCount)!=null&&i.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["· ",String(y.pageCount)," pages"]})]}),i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Bn,{content:u??""})}),w&&i.jsx(ml,{})]}),t==="dev_server"&&r==="success"&&u&&i.jsx(t8,{result:u,action:String(n.action??"")}),t==="workspace"&&r==="success"&&u&&i.jsx(u8,{result:u,action:String(n.action??"")}),t==="background_process"&&r==="success"&&u&&i.jsx(s8,{result:u,action:String(n.action??"")}),t==="mcp_config"&&r==="success"&&i.jsxs("div",{children:[i.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh] overflow-y-auto",children:i.jsx(Bn,{content:u??""})}),w&&i.jsx(ml,{className:"mt-1"})]}),t==="step_done"&&null,t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&t!=="call_sub_agent"&&t!=="web_search"&&t!=="load_skill"&&t!=="web_fetch"&&t!=="dev_server"&&t!=="workspace"&&t!=="background_process"&&t!=="mcp_config"&&t!=="step_done"&&i.jsxs(i.Fragment,{children:[Object.keys(n).length>0&&i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto break-words",children:g8(n)})]}),r==="success"&&u!==void 0&&i.jsxs("div",{children:[i.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",d!==void 0&&` (${d}ms)`,":"]}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded overflow-x-auto max-h-[60vh] break-words",children:u||"No output"}),w&&i.jsx(ml,{className:"mt-1"})]})]}),r==="success"&&(t==="edit_file"||t==="write_file"||t==="read_file")&&d!==void 0&&i.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[i.jsxs("span",{children:["Completed in ",d,"ms"]}),E&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((y==null?void 0:y.path)??n.path??"")&&i.jsx("a",{href:Ck(String((y==null?void 0:y.path)??n.path),j),className:"text-accent-primary hover:underline ml-auto",children:"Open in VSCode"})]}),r==="error"&&c&&t!=="run_command"&&i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),i.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:c})]}),D&&i.jsx(m8,{confirmation:D})]})]})}),b8={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"};function v8(e,t){const n=b8[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const l=eB(a);return`${n} ${l}`}}catch{}return n}function _8(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 S8=A.memo(function({name:t,arguments:n}){let a=v8(t,n)+"...";if(t==="run_command"&&n){const l=_8(n);l&&(a=l)}return i.jsx("div",{className:"border border-border rounded overflow-hidden my-1 min-w-0 animate-pulse",children:i.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-bg-tertiary",children:[i.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),i.jsx(Dk,{tool:t}),i.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?i.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):i.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),w8={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},C8=A.memo(function({todos:t}){return Array.isArray(t)?t.length===0?i.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):i.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[i.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),i.jsx("div",{children:t.map((n,r)=>{const a=w8[n.status];return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[i.jsx("span",{className:`${(a==null?void 0:a.color)??"text-text-muted"} ${a!=null&&a.animate?"animate-pulse":""} text-sm leading-tight`,children:(a==null?void 0:a.icon)??"○"}),i.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):i.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})});function k8({toolCall:e}){var E;const t=Re(j=>j.pendingQuestions),n=Re(j=>j.answerQuestion),[r,a]=A.useState(""),l=A.useRef(null),u=A.useRef(null),c=t.find(j=>j.callId===e.id),d=e.arguments.question??(c==null?void 0:c.question)??"",f=e.arguments.type??(c==null?void 0:c.type)??"text",p=e.arguments.options??(c==null?void 0:c.options)??void 0,m=e.result!==void 0,x=c!==void 0&&!m,y=((E=e.result)==null?void 0:E.output)??"",w=y==="[user skipped]";A.useEffect(()=>{x&&l.current&&l.current.focus()},[x]),A.useEffect(()=>{x&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const C=A.useCallback(()=>{c&&n(c.callId,r)},[c,r,n]),_=A.useCallback(()=>{c&&n(c.callId,"",!0)},[c,n]),S=A.useCallback(j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),C()),j.key==="Escape"&&!j.shiftKey&&(j.preventDefault(),_())},[C,_]),b=A.useCallback(j=>{c&&n(c.callId,j)},[c,n]),v="px-3 py-1.5 text-xs font-medium rounded transition-colors";return i.jsxs("div",{ref:u,className:"my-1",children:[i.jsx("div",{className:"text-sm text-text-primary",children:d}),x&&i.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:i.jsx("div",{className:"p-3 bg-primary space-y-2",children:f==="confirm"?i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:()=>b("yes"),className:`${v} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),i.jsx("button",{onClick:()=>b("no"),className:`${v} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),i.jsx("button",{onClick:_,className:`${v} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):f==="choice"&&Array.isArray(p)&&p.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-col gap-1.5",children:p.map(j=>i.jsx("button",{onClick:()=>b(j),className:`${v} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:j},j))}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("textarea",{ref:l,value:r,onChange:j=>a(j.target.value),onKeyDown:S,placeholder:"Or type your own answer... (Enter to submit)",className:"flex-1 min-h-[36px] max-h-[80px] px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",rows:1}),i.jsx("button",{onClick:C,disabled:!r.trim(),className:`${v} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),i.jsx("button",{onClick:_,className:`${v} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("textarea",{ref:l,value:r,onChange:j=>a(j.target.value),onKeyDown:S,placeholder:"Type your answer here... (Enter to submit, Shift+Enter for new line)",className:"w-full min-h-[80px] 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}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{onClick:_,className:`${v} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),i.jsx("button",{onClick:C,disabled:!r.trim(),className:`${v} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),m&&i.jsx("div",{className:"mt-1 flex items-center gap-2",children:i.jsx("span",{className:`text-xs ${w?"text-amber-400":"text-accent-success"}`,children:w?"Skipped":`Answered: ${y}`})})]})}const ES={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"}},E8=A.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(c=>[c.id,c]))??[]),a=t.find(c=>{var d,f;return c.arguments.action==="get"&&((d=c.result)==null?void 0:d.success)&&((f=c.result)==null?void 0:f.output)}),l=t.some(c=>c.name==="session_metadata"),u=(()=>{if(!l)return"Acceptance Criteria";const c=new Set(t.map(d=>d.arguments.key).filter(Boolean));if(c.size===1){const d=c.values().next().value;return d?Hp(d):"Session Data"}return"Session Data"})();return i.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[i.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:i.jsx("span",{className:"text-xs font-medium text-text-muted",children:u})}),i.jsx("div",{className:"bg-primary",children:a?(()=>{const c=a.result.output;if(c==="No criteria defined yet.")return i.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),i.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(c).map((f,p)=>i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${p>0?"border-t border-border":""}`,children:[i.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx(Bn,{content:`[${f.id}] ${f.description}`})})]},f.id??p))}catch{return t.map((d,f)=>i.jsx(jS,{tc:d,index:f,criteriaMap:r},d.id??f))}})():t.map((c,d)=>i.jsx(jS,{tc:c,index:d,criteriaMap:r},c.id??d))})]})});function jS({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,a=e.arguments,l=e.name==="session_metadata",u=r==="remove",c=a.id,d=a.description,f=c?n.get(c):void 0,p=d??(f==null?void 0:f.description)??(u&&c?`[${c}]`:"Criterion updated"),m=a.reason,x=r==="fail";return i.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[l?i.jsx(Xl,{status:a.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const y=r&&ES[r]?ES[r]:{icon:"○",color:"text-text-muted"};return i.jsx("span",{className:`${y.color} text-sm leading-tight flex-shrink-0`,children:y.icon})})(),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:u?"line-through text-text-muted":"",children:i.jsx(Bn,{content:p})}),m&&i.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[i.jsx("span",{className:"text-text-muted",children:"└ "}),'"',m,'"']})]})]})}function j8(e){return e==="criterion"||e==="session_metadata"}function N8(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const a of e)a.type==="tool_call"&&j8(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function T8(e,t){if(e.segments&&e.segments.length>0)return A8(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 A8(e,t,n,r,a){const l=[],u=new Map(t.map(c=>[c.id,c]));for(const c of e)switch(c.type){case"text":l.push({type:"text",content:c.content});break;case"thinking":c.content&&c.content.trim().length>0&&l.push({type:"thinking",content:c.content});break;case"tool_call":{const d=u.get(c.toolCallId);d&&l.push({type:"tool_call",toolCall:d});break}}for(const c of n)l.push({type:"preparing_tool_call",preparing:c});return a&&r&&l.push({type:"stats",stats:r}),l}const zg=A.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0}){const l=Re(x=>{var y,w;return(w=(y=x.currentSession)==null?void 0:y.metadataEntries)==null?void 0:w.criteria}),u=mt(x=>x.defaults),c=mt(x=>x.userItems),d=[...u,...c],f=T8(t,n),p=r?f:f.filter(x=>x.type!=="thinking"),m=N8(p);return m.length===0?null:i.jsx("div",{className:"feed-item",children:i.jsxs("div",{className:"min-w-0",children:[m.map((x,y)=>{var w;switch(x.type){case"thinking":return i.jsx(VB,{content:x.content},y);case"text":return i.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:i.jsx(Bn,{content:x.content})},y);case"preparing_tool_call":return i.jsx(S8,{name:x.preparing.name,arguments:x.preparing.arguments},`preparing-${x.preparing.index}`);case"tool_call":{const C=x.toolCall,_=C.result;if(C.name==="ask_user")return i.jsx(k8,{toolCall:C},y);if(C.name==="todo_write"){const v=C.arguments.todos,E=Array.isArray(v)?v:[];return i.jsx(C8,{todos:E},y)}const S=(w=_==null?void 0:_.output)==null?void 0:w.includes("[interrupted by user]"),b=_?S?"interrupted":_.success?"success":"error":"pending";return i.jsx(y8,{tool:C.name,args:C.arguments,status:b,variant:"expandable",forceCompact:!a,result:_==null?void 0:_.output,error:_==null?void 0:_.error,durationMs:_==null?void 0:_.durationMs,diagnostics:_==null?void 0:_.diagnostics,editContext:_==null?void 0:_.editContext,startedAt:C.startedAt,streamingOutput:C.streamingOutput,metadata:_==null?void 0:_.metadata,truncated:(_==null?void 0:_.truncated)??!1,callId:C.id},y)}case"criteria_group":return i.jsx(E8,{toolCalls:x.toolCalls,criteria:l},y);case"stats":{const C=x.stats;if(!C||"error"in C)return null;const _=C.model.split("/").pop()??C.model,S=Ml(d,C.mode),b=d.find(T=>T.id===C.mode),v=(b==null?void 0:b.name)??C.mode,E=T=>T>=1e3?`${(T/1e3).toFixed(1)}k`:T.toString(),j=T=>T>=1e3?`${(T/1e3).toFixed(1)}k`:T.toFixed(1);return i.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted mt-3",children:[i.jsx("span",{className:"flex-1 h-px bg-border"}),i.jsx("span",{className:"text-text-secondary",children:_}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("span",{style:{color:S},children:v}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("span",{children:Yr(C.totalTime)}),C.toolTime>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[Yr(C.toolTime)," tools"]})]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[E(C.prefillTokens)," @ ",j(C.prefillSpeed)," pp"]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsxs("span",{children:[E(C.generationTokens)," @ ",j(C.generationSpeed)," tg"]}),i.jsx("span",{className:"text-text-muted",children:"·"}),i.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const T=new CustomEvent("open-turn-stats",{detail:{stats:C}});window.dispatchEvent(T)},children:i.jsx(Yp,{className:"w-3 h-3"})}),i.jsx("span",{className:"flex-1 h-px bg-border"})]},y)}}}),t.partial&&i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[i.jsx(ip,{}),i.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-text-truncated mt-1",children:[i.jsx(ip,{}),i.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]})})});function cd(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${a},${t})`}function L8(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const D8=A.memo(function({data:t}){var u;const n=Ot(c=>c.defaults),r=Ot(c=>c.userItems),l=((u=[...n,...r].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#8b949e";return i.jsxs("div",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:cd(l,.3),backgroundColor:cd(l,.08)},children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(HN,{color:l}),i.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName??"Task Completed"})]}),i.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[i.jsx(pl,{label:"Iterations",value:String(t.iterations)}),i.jsx(pl,{label:"Total time",value:Yr(t.totalTimeSeconds)}),i.jsx(pl,{label:"Tool calls",value:String(t.totalToolCalls)}),i.jsx(pl,{label:"Tokens",value:L8(t.totalTokensGenerated)}),i.jsx(pl,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function pl({label:e,value:t}){return i.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[i.jsx("div",{className:"text-sm text-text-muted",children:e}),i.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const R8=A.memo(function({data:t}){var u;const n=Ot(c=>c.defaults),r=Ot(c=>c.userItems),l=((u=[...n,...r].find(c=>c.id===t.workflowId))==null?void 0:u.color)??t.workflowColor??"#6b7280";return i.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:cd(l,.3),backgroundColor:cd(l,.08)},children:[i.jsx(PN,{className:"w-3 h-3 shrink-0",color:l}),i.jsx("span",{className:"text-sm font-medium",style:{color:l},children:t.workflowName}),i.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})}),O8=["text/"],I8=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function Uu(e){return e.startsWith("image/")}function Ik(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function Hg(e){return I8.includes(e)||O8.some(t=>e.startsWith(t))}function qa(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Mk(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const M8={"text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/javascript":"js","text/xml":"xml","text/x-yaml":"yaml","text/x-sh":"sh","text/tab-separated-values":"tsv","text/x-python":"py","text/x-java-source":"java","text/x-json":"json","text/x-typescript":"ts","text/css":"css","application/json":"json","application/xml":"xml","application/yaml":"yaml","application/x-yaml":"yaml","application/javascript":"js","application/xhtml+xml":"xhtml","application/x-sh":"sh","application/pdf":"pdf","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/svg+xml":"svg"};function P8(e){var t;return M8[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function B8(e){return Uu(e)||Hg(e)||e==="application/pdf"}function $8({attachments:e,messageId:t}){const[n,r]=A.useState(null),a=Re(p=>p.visionFallbackByMessage),l=Re(p=>p.messages),u=A.useMemo(()=>{const p=l.findIndex(m=>m.id===t);if(p===-1)return null;for(let m=p+1;m<l.length;m++){const x=l[m];if(x&&x.role==="assistant")return x.id}return null},[l,t]),c=p=>{r(p)},d=()=>{r(null)},f=p=>{const m=`${t}-${p}`;if(a[m])return a[m];if(u){const x=`${u}-${p}`;return a[x]}return null};return e.length===0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const m=f(p.id);return Ik(p.mimeType)?i.jsxs("div",{className:"relative inline-block",children:[i.jsxs("button",{onClick:()=>c(p.data),className:"group relative inline-block",title:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,disabled:(m==null?void 0:m.type)==="start",children:[i.jsx("img",{src:p.data,alt:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(m==null?void 0:m.type)==="start"&&i.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:i.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&i.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[m.description.slice(0,200),m.description.length>200?"...":""]})]},p.id):i.jsxs("div",{className:"inline-flex items-start gap-3 p-3 bg-bg-tertiary rounded-lg border border-border max-w-[300px]",children:[i.jsx("div",{className:"w-10 h-10 flex items-center justify-center rounded-md bg-bg-secondary text-sm font-bold text-text-muted shrink-0",children:Mk(p.filename)}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:p.filename,children:p.filename}),i.jsx("div",{className:"text-[10px] text-text-muted",children:qa(p.size)}),Hg(p.mimeType)&&p.data&&i.jsxs("div",{className:"mt-1.5 text-[10px] text-text-muted leading-relaxed line-clamp-3 font-mono break-all",children:[p.data.slice(0,200),p.data.length>200?"...":""]})]})]},p.id)})}),n&&i.jsx(Rk,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function z8({message:e}){const[t,n]=A.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,a=(r==null?void 0:r.color)??"#6b7280",l=(r==null?void 0:r.type)??"agent",u=l==="workspace"?"Workspace":(r==null?void 0:r.name)??"Agent",d={agent:(r==null?void 0:r.kind)==="reminder"?"reminder":"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions",workspace:`${(r==null?void 0:r.workspaceName)??""} · ${(r==null?void 0:r.branchName)??""}`,branch:`🌿 ${(r==null?void 0:r.branchName)??""}`}[l]??"injected",f=l==="workflow"||l==="subagent";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[i.jsx("span",{className:"flex-1 h-px bg-border"}),i.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${f?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!f&&n(!0)}),i.jsx("span",{className:f?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!f&&n(!0),children:u}),i.jsx("span",{children:"·"}),i.jsx("span",{className:f?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!f&&n(!0),children:d}),i.jsx("span",{className:"flex-1 h-px bg-border"})]}),f&&i.jsx("div",{className:"flex justify-center feed-item mb-4",children:i.jsx("div",{className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm overflow-x-auto",style:{borderLeft:`3px solid ${a}`},children:i.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),i.jsx(wt,{isOpen:t,onClose:()=>n(!1),title:`${u} Prompt`,size:"lg",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),i.jsx("span",{className:"text-sm text-text-primary font-medium",children:u}),i.jsxs("span",{className:"text-xs text-text-muted",children:["(",l,")"]})]}),i.jsx("div",{className:"h-full min-h-96",children:i.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap break-words bg-bg-tertiary rounded p-4 h-full min-h-96 overflow-auto font-mono",children:e.content})})]})})]})}async function H8(e){if(navigator.clipboard){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function U8({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",l=e.isSystemGenerated,u=Re(W=>W.loadSession),[c,d]=A.useState(!1),[f,p]=A.useState(!1),[m,x]=A.useState(!1),[y,w]=A.useState(e.content),[C,_]=A.useState(!1),[S,b]=A.useState(null),v=A.useRef(null),E=A.useCallback(()=>{const W=v.current;W&&(W.style.height="auto",W.style.height=`${W.scrollHeight}px`)},[]),j=async()=>{try{await H8(e.content),p(!0),window.setTimeout(()=>p(!1),1500)}catch{}},T=async()=>{if(!n||!t||C)return;_(!0),b(null);const W=await r_(n,t);_(!1),W?u(n):b("Failed to replay")},D=async()=>{if(!n||!t||!y.trim()||C)return;_(!0),b(null);const W=await r_(n,t,y);_(!1),W?(u(n),x(!1)):b("Failed to send")},L=()=>{w(e.content),x(!1),b(null)},M=`flex items-center gap-0.5 self-end transition-opacity focus-within:opacity-100 focus-within:pointer-events-auto ${c&&!m&&!C?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`;return i.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[!l&&i.jsxs("div",{className:M,children:[i.jsx("button",{onClick:()=>{j()},title:"Copy",disabled:C,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:f?i.jsx(Ir,{className:"w-3.5 h-3.5 text-accent-success"}):i.jsx(qp,{className:"w-3.5 h-3.5"})}),n&&t&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>{b(null),w(e.content),x(!0)},title:"Edit & resend",disabled:C,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:i.jsx(u1,{className:"w-3.5 h-3.5"})}),i.jsx("button",{onClick:()=>{T()},title:"Replay",disabled:C,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:i.jsx(pd,{className:"w-3.5 h-3.5"})})]})]}),i.jsxs("div",{className:`max-w-[75%] ${m?"w-full":""} rounded p-2 ${l?"bg-bg-system border border-border-system":"bg-accent-primary/15 text-text-primary"}`,children:[l&&i.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:a?"Command":r?"Auto":"System"}),m?i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("textarea",{ref:W=>{v.current=W,W&&(W.style.height="auto",W.style.height=`${W.scrollHeight}px`)},className:"w-full bg-bg-primary border border-border rounded p-1.5 text-sm text-text-primary resize-none focus:outline-none focus:border-accent-primary min-h-[60px] overflow-hidden disabled:opacity-50",value:y,onChange:W=>{w(W.target.value),E()},onKeyDown:W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),D()),W.key==="Escape"&&L()},disabled:C,autoFocus:!0}),S&&i.jsx("p",{className:"text-xs text-accent-error",children:S}),i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx("button",{onClick:L,disabled:C,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",title:"Cancel",children:i.jsx(Es,{className:"w-3.5 h-3.5"})}),i.jsx("button",{onClick:()=>{D()},disabled:C||!y.trim(),className:"p-1 rounded hover:bg-bg-tertiary text-accent-primary hover:text-accent-primary disabled:opacity-50",title:"Confirm (Ctrl+Enter)",children:i.jsx(Ir,{className:"w-3.5 h-3.5"})})]})]}):i.jsxs(i.Fragment,{children:[S&&i.jsx("p",{className:"text-xs text-accent-error mb-1",children:S}),i.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${l?"text-text-system":""}`,children:e.content}),e.attachments&&e.attachments.length>0&&i.jsx($8,{attachments:e.attachments,messageId:e.id})]})]})]})}const Pk=A.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:a}){const l=t.role==="user",u=t.role==="assistant",c=t.role==="system",d=t.role==="tool";if(u)return i.jsx(zg,{message:t,showStats:n});if(c&&t.isCompacted)return i.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[i.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),i.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
|
|
290
|
+
`,"")})]});if(d)return i.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[i.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),i.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap break-words overflow-x-auto max-h-32",children:[t.content.slice(0,500),t.content.length>500&&"..."]})]});if(t.messageKind==="workflow-started")try{const f=JSON.parse(t.content);return i.jsx(R8,{data:f})}catch{}if(t.messageKind==="task-completed")try{const f=JSON.parse(t.content);return i.jsx(D8,{data:f})}catch{}return t.messageKind==="context-reset"?i.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[i.jsx("div",{className:"flex-1 border-t border-border"}),i.jsx("span",{children:t.content}),i.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?i.jsx(z8,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?i.jsx("div",{className:"flex justify-end feed-item",children:i.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-bg-system border border-border-system",children:[i.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:"System"}),i.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-text-system italic",children:t.content})]})}):l?i.jsx(U8,{message:t,messageId:r,sessionId:a}):i.jsx("div",{className:"flex justify-start feed-item",children:i.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:i.jsx(Bn,{content:t.content})})})}),F8={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function V8(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function NS(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function G8({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,l=Math.round(t/n*100);return i.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[i.jsxs("span",{className:NS(l,a),children:[eo(t),"/",eo(n)]}),i.jsxs("span",{className:NS(l,a),children:["(",l,"%)"]}),i.jsx(Lk,{percent:l,dangerZone:a,size:"sm"}),a&&i.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&i.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const W8=A.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const l=A.useRef(null),u=A.useRef(null),[c,d]=A.useState(!1),f=mt(D=>D.defaults),p=mt(D=>D.userItems),m=[...f,...p],x=Re(D=>D.subAgentContextStates[r]),{showThinking:y,showVerboseToolOutput:w}=Ki(),{isAutoScrollActive:C,setAutoScroll:_}=$d(u,null),S=A.useCallback(()=>{const D=!c;d(D),D&&setTimeout(()=>{var L;(L=l.current)==null||L.scrollIntoView({block:"start",behavior:"smooth"})},220)},[c]),b=m.find(D=>D.id===n),v=(b==null?void 0:b.name)??F8[n]??n,E=Ml(m,n),j=V8(E),T=t.filter(D=>D.role!=="tool");return i.jsxs("div",{ref:l,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[i.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:j,children:[i.jsx("span",{className:"text-xs font-medium",children:v}),i.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:x&&i.jsx(G8,{contextState:x})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>_(!C),children:[i.jsx("span",{className:`w-1 h-1 rounded-full ${C?"bg-accent-success":"border border-text-muted"}`}),"live"]}),i.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:S,children:[c?"▼":"▶"," Expand"]})]})]}),i.jsx("div",{ref:u,className:`${c?"max-h-[calc(100vh-10rem)]":"max-h-80"} overflow-y-auto p-2 transition-[max-height] duration-200`,children:T.map(D=>D.role==="assistant"?i.jsx(zg,{message:D,showStats:!0,showThinking:y,showVerboseToolOutput:w},D.id):i.jsx(Pk,{message:D,isLastAssistantMessage:!1},D.id))})]})}),Qm={contentVisibility:"auto",containIntrinsicSize:"auto 200px"};function Au(e){var t;return e.type==="context-divider"?`ctx-${e.windowSequence}`:e.type==="subagent"?((t=e.messages[0])==null?void 0:t.id)??e.subAgentId:e.message.id}const Bk=A.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,showThinking:a=!0,showVerboseToolOutput:l=!0,showStats:u=!0,showAgentDefinitions:c=!0,showWorkflowBars:d=!0}){return i.jsx(i.Fragment,{children:t.map((f,p)=>{if(f.type==="context-divider")return i.jsxs("div",{"data-item-index":p,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[i.jsx("div",{className:"flex-1 border-t border-border"}),i.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),i.jsx("div",{className:"flex-1 border-t border-border"})]},Au(f));if(f.type==="subagent"){const w=f.messages.some(C=>C.isStreaming);return i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:Qm,children:i.jsx(W8,{messages:f.messages,subAgentType:f.subAgentType,subAgentId:f.subAgentId,isStreaming:w})},Au(f))}const m=f.message;if(m.role==="assistant")return i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:Qm,children:i.jsx(zg,{message:m,showStats:u,showThinking:a,showVerboseToolOutput:l})},Au(f));const x=!c&&m.messageKind==="auto-prompt",y=!d&&(m.messageKind==="workflow-started"||m.messageKind==="task-completed");return x||y?null:i.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",style:Qm,children:i.jsx("div",{"data-message-id":m.id,className:n===m.id?"rounded animate-highlight-fade":void 0,children:i.jsx(Pk,{message:m,messageId:m.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},Au(f))})})});function $k(e,t,n=!0){A.useEffect(()=>{if(!n)return;const r=a=>{var l;(l=e.current)!=null&&l.contains(a.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const q8=[],K8=A.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,hiddenCount:l=0}){const u=Re(P=>{var V,G;return((G=(V=P.currentSession)==null?void 0:V.metadataEntries)==null?void 0:G.criteria)??q8}),c=Re(P=>{var V;return(V=P.currentSession)==null?void 0:V.id}),d=Re(P=>{var V;return(V=P.currentSession)==null?void 0:V.mode}),f=Re(P=>{var V;return(V=P.currentSession)==null?void 0:V.phase}),p=Re(P=>P.error),m=Re(P=>P.clearError),x=md(),{showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S}=Ki(),b=Ot(P=>P.defaults),v=Ot(P=>P.userItems),E=[...b,...v],j=d==="planner",T=u.length>0,D=f==="done",L=t.some(P=>P.type==="message"&&P.message.role==="assistant"),O=j&&T&&!x&&L&&!D,M=Re(P=>{var V;return(V=P.currentSession)==null?void 0:V.projectId}),[W,z]=A.useState(!1),R=()=>{if(!M||!c)return;z(!1),window.open(`/p/${M}/s/${c}/readonly`,"_blank")||z(!0)};return i.jsxs("div",{ref:n,"data-testid":"chat-scroll-container",className:"flex-1 min-w-0 overflow-y-auto relative bg-primary scrollbar-stable",children:[i.jsxs("div",{className:"pt-4",children:[l>0&&i.jsxs("div",{className:"px-2 md:px-4 pb-2 space-y-1",children:[i.jsxs("button",{onClick:R,className:"w-full text-sm text-text-muted hover:text-text-primary bg-bg-tertiary/50 hover:bg-bg-tertiary border border-border rounded px-3 py-2 transition-colors text-center",children:[l," older item",l!==1?"s":""," hidden — View full history"]}),W&&i.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",i.jsx("a",{href:M&&c?`/p/${M}/s/${c}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),i.jsx(Bk,{displayItems:t,highlightedMessageId:r,sessionId:c,showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S})]}),i.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[p&&i.jsx("div",{className:"feed-item bg-text-tool-error/10 border border-text-tool-error/50 rounded p-2",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-text-tool-error text-sm font-medium",children:p.code}),i.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:p.message})]}),i.jsx(Yl,{onClick:m,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),O&&i.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:E.map(P=>{const V=P.color??"#3b82f6",G=parseInt(V.slice(1,3),16),Z=parseInt(V.slice(3,5),16),Q=parseInt(V.slice(5,7),16),U=`rgba(${G},${Z},${Q},0.12)`,I=`rgba(${G},${Z},${Q},0.22)`,$=`rgba(${G},${Z},${Q},0.25)`;return i.jsx(Y8,{workflowName:P.name,color:V,bg:U,bgHover:I,border:$,subGroups:P.subGroups,onLaunch:q=>a(P.id,q)},P.id)})})]})]})});function Y8({workflowName:e,color:t,bg:n,bgHover:r,border:a,subGroups:l,onLaunch:u}){const[c,d]=A.useState(!1),f=A.useRef(null);$k(f,()=>d(!1),c);const p=l&&l.length>0;return i.jsxs("div",{className:"relative flex",children:[i.jsxs("button",{onClick:()=>u(),"data-testid":"workflow-run-button",className:`px-4 py-1.5 text-sm font-medium transition-colors ${p?"rounded-l":"rounded"}`,style:{backgroundColor:n,color:t,border:`1px solid ${a}`,...p?{borderRight:"none"}:{}},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=r},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),p&&i.jsxs("div",{ref:f,className:"relative",children:[i.jsx("button",{onClick:()=>d(!c),className:"px-2.5 py-1.5 rounded-r text-sm font-medium transition-colors",style:{backgroundColor:n,color:t,border:`1px solid ${a}`},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=r},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n},children:"⋮"}),c&&i.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:[i.jsx("button",{onClick:()=>{u(),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),i.jsx("div",{className:"border-t border-border/50"}),l.map(m=>i.jsx("button",{onClick:()=>{u(m),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:m},m))]})]})]})}function X8(){const e=Re(r=>r.connectionStatus),t=Re(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return i.jsxs("div",{className:`
|
|
291
|
+
flex items-center justify-between px-4 py-2
|
|
292
|
+
text-sm font-medium
|
|
293
|
+
${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"}
|
|
294
|
+
`,children:[i.jsx("div",{className:"flex items-center gap-2",children:n?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"flex gap-1",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),i.jsx("span",{children:"Reconnecting to server..."})]}):i.jsxs(i.Fragment,{children:[i.jsx(FN,{}),i.jsx("span",{children:"Connection lost"})]})}),i.jsx("button",{onClick:()=>t(),disabled:n,className:`
|
|
295
|
+
px-3 py-1 rounded text-xs font-medium
|
|
296
|
+
transition-colors
|
|
297
|
+
${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"}
|
|
298
|
+
`,children:n?"Reconnecting...":"Reconnect"})]})}const mn=Hn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await ok("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await we(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await we(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const a=await ci("POST","/api/commands",{...n,destination:r});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,r)=>{const a=await ci("PUT",`/api/commands/${n}`,r);return a.success&&await t().fetchCommands(),a},deleteCommand:async n=>{try{const r=await we(`/api/commands/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateCommand:async(n,r)=>fd(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)}));function Q8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function J8({onClick:e}){return i.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:i.jsx(Kp,{})})}function zk({isOpen:e,onClose:t,initialEditId:n}){const r=mn(he=>he.defaults),a=mn(he=>he.userItems),l=mn(he=>he.projectItems),u=mn(he=>he.loading),c=mn(he=>he.fetchCommands),d=mn(he=>he.fetchCommand),f=mn(he=>he.fetchDefaultContent),p=mn(he=>he.createCommand),m=mn(he=>he.updateCommand),x=mn(he=>he.deleteCommand),[y,w]=A.useState(null),[C,_]=A.useState(null),{view:S,editingId:b,formError:v,saving:E,formData:j,setView:T,setEditingId:D,setFormError:L,setFormData:O,setSaving:M}=_1(),{requestDelete:W,clearConfirm:z,isConfirming:R}=Hl(),P=A.useRef(!1),V=mt(he=>he.defaults),G=mt(he=>he.userItems),Z=mt(he=>he.fetchAgents),U=[...V,...G].filter(he=>!he.subagent),I=A.useRef(c),$=A.useRef(Z),q=A.useRef(d),B=A.useRef(f),ee=A.useRef(n),X=A.useRef(T),ne=A.useRef(D),K=A.useRef(L),F=A.useRef(z);A.useEffect(()=>{I.current=c,$.current=Z,q.current=d,B.current=f,ee.current=n,X.current=T,ne.current=D,K.current=L,F.current=z}),A.useEffect(()=>{if(e)if(I.current(),$.current(),P.current||(F.current(),P.current=!0),ee.current){const he=r.some(ce=>ce.id===ee.current);X.current("edit"),ne.current(ee.current),K.current(""),he?B.current(ee.current).then(ce=>{ce&&O({name:ce.metadata.name+" (copy)",id:`${ee.current}-copy-${Date.now()}`,prompt:ce.prompt,agentMode:ce.metadata.agentMode??"",isDefault:!0,destination:"user"})}):q.current(ee.current).then(ce=>{ce&&O({name:ce.metadata.name,id:ce.metadata.id,prompt:ce.prompt,agentMode:ce.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else X.current("list"),ne.current(null);else P.current=!1},[e]);const te=async he=>{w(he);const ce=await f(he);_((ce==null?void 0:ce.prompt)??null)},se=async he=>{if(r.some(de=>de.id===he)){const de=await f(he);de&&(D(null),O({name:`${de.metadata.name} (copy)`,id:`${he}-copy-${Date.now()}`,prompt:de.prompt,agentMode:de.metadata.agentMode??"",isDefault:!0,destination:"user"}),L(""),T("edit"))}else{const de=await d(he);de&&(D(null),O({name:`${de.metadata.name} (copy)`,id:`${he}-copy-${Date.now()}`,prompt:de.prompt,agentMode:de.metadata.agentMode??"",isDefault:!1,destination:"user"}),L(""),T("edit"))}},xe=()=>{O({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),D(null),T("edit")},oe=async he=>{const ce=await d(he);ce&&(D(he),O({name:ce.metadata.name,id:ce.metadata.id,prompt:ce.prompt,agentMode:ce.metadata.agentMode??"",isDefault:!1,destination:"user"}),L(""),T("edit"))},ye=async he=>{await x(he),z()},Le=async()=>{const he=b??j.id;if(!he||!j.name||!j.prompt){L("Name and message are required.");return}M(!0),L("");const ce={metadata:{id:he,name:j.name,...j.agentMode?{agentMode:j.agentMode}:{}},prompt:j.prompt},de=b?await m(b,ce):await p(ce,j.destination);if(M(!1),!de.success){L(de.error??"Failed to save command.");return}n?t():T("list")},Oe=()=>{n?t():(T("list"),w(null),_(null))},Me=he=>{O(ce=>({...ce,name:he})),(!b||j.isDefault)&&O(ce=>({...ce,id:Q8(he)}))},je=()=>{w(null),_(null),T("list")},nt=()=>{y&&(w(null),T("edit"),D(y),f(y).then(he=>{he&&O({name:`${he.metadata.name} (copy)`,id:`${y}-copy-${Date.now()}`,prompt:he.prompt,agentMode:he.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(y){const he=r.find(ce=>ce.id===y);return i.jsx(wt,{isOpen:e,onClose:je,title:`Default: ${(he==null?void 0:he.name)??y}`,size:"xl",children:i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[i.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),i.jsx("span",{className:"font-mono",children:y})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),i.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:he==null?void 0:he.name})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),i.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(he==null?void 0:he.agentMode)||"None"})]})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),i.jsx("textarea",{value:C??"",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"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[i.jsx(Je,{variant:"secondary",onClick:je,children:"Close"}),i.jsx(Je,{variant:"primary",onClick:nt,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return i.jsx(wt,{isOpen:e,onClose:Oe,title:b?"Edit Command":"New Command",size:"xl",children:i.jsxs("div",{className:"flex flex-col h-full",children:[v&&i.jsx(Ka,{message:v}),i.jsxs("div",{className:"space-y-3 mb-3",children:[i.jsx(v1,{name:j.name,id:j.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!b&&!j.isDefault,onNameChange:Me,onIdChange:he=>O(ce=>({...ce,id:he}))}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsxs("select",{value:j.agentMode,onChange:he=>O(ce=>({...ce,agentMode:he.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:[i.jsx("option",{value:"",children:"None (keep current mode)"}),U.map(he=>i.jsx("option",{value:he.id,children:he.name},he.id))]})]}),!b&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),i.jsxs("select",{value:j.destination,onChange:he=>O(ce=>({...ce,destination:he.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:[i.jsx("option",{value:"user",children:"Global config"}),i.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})]}),i.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),i.jsx("textarea",{value:j.prompt,onChange:he=>O(ce=>({...ce,prompt:he.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"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[i.jsx(Je,{variant:"secondary",onClick:Oe,children:"Cancel"}),i.jsx(Je,{variant:"primary",onClick:Le,disabled:E||!j.name||!j.prompt,children:E?"Saving...":"Save"})]})]})});const Xe=he=>he.map(ce=>i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("span",{className:"text-text-primary text-sm font-medium",children:ce.name})})}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.jsx(Gi,{onClick:()=>oe(ce.id)}),i.jsx(Vu,{onClick:()=>se(ce.id)}),R(ce.id,"delete")?i.jsx(Zp,{onConfirm:()=>ye(ce.id),onCancel:z}):i.jsx(eg,{onClick:()=>W(ce.id)})]})]},ce.id));return i.jsxs(wt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[i.jsx(b1,{description:"Commands are pre-defined messages you can send with a single click.",onNew:xe}),i.jsxs(tg,{loading:u,hasItems:r.length>0||a.length>0||l.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),i.jsx("div",{className:"space-y-2",children:r.map(he=>i.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[i.jsx("div",{className:"min-w-0 flex-1 mr-3",children:i.jsx("span",{className:"text-text-primary text-sm font-medium",children:he.name})}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[i.jsx(J8,{onClick:()=>te(he.id)}),i.jsx(Vu,{onClick:()=>se(he.id)})]})]},he.id))})]}),a.length>0&&i.jsx(y1,{children:Xe(a)}),l.length>0&&i.jsxs("div",{className:"mt-4",children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),i.jsx("div",{className:"space-y-2",children:Xe(l)})]})]})]})}const Di=150,ys=54,Lu=80,Ar=30,$a=70,TS=100,Ri=50,Du=50,AS=4,Hk={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},Uk=[{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)"}],Z8=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}];function Ug(e,t){if(e.type==="agent"){const n=t.find(r=>r.id===e.agentId);return{name:(n==null?void 0:n.name)??(e.agentId||"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 e$(e,t,n,r){const a=Du+Ri+Di+TS+Di+Ri+Du,l=a/2,u=Du+Ri+Di/2,c=Du+Ri+Di+TS+Di/2,d=[],f=[],p=new Map,m=e.filter(V=>V.type==="agent"||V.type==="shell"),x=e.filter(V=>V.type==="sub_agent"),y=x.length>0,w=y?u:l,C=m.length>0?c:l,_=Ri+Ar/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:_,w:Lu,h:Ar}),p.set("$start",{cx:w,cy:_,w:Lu,h:Ar});const S=V=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:V,w:Lu,h:Ar}),p.set("$done",{cx:w,cy:V,w:Lu,h:Ar})};if(e.length===0){const V=_+Ar/2+$a*2+Ar/2;return S(V),{nodes:d,edges:f,width:a,height:V+Ar/2+Ri,posMap:p}}const b=_+Ar/2+$a,v=(V,G)=>{V.forEach((Z,Q)=>{const U=b+Q*(ys+$a)+ys/2,{name:I,color:$}=Ug(Z,r);d.push({id:Z.id,type:"step",label:I,color:$,cx:G,cy:U,w:Di,h:ys}),p.set(Z.id,{cx:G,cy:U,w:Di,h:ys})})};v(m,w),v(x,C);const E=m.length>0?b+(m.length-1)*(ys+$a)+ys/2:_,j=y?b+(x.length-1)*(ys+$a)+ys/2:_,T=Math.max(E,j)+ys/2+$a+Ar/2;S(T);const D=[];t&&p.has(t)&&D.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let L=0;for(const V of e)V.transitions.forEach((G,Z)=>{var B;if(!G.goto||!p.has(G.goto))return;const Q=p.get(V.id),U=p.get(G.goto),I=G.when.type==="step_result"?`${G.when.result}`:G.when.type==="metadata_all_match"?`${G.when.key??"?"}=${G.when.value??"?"}`:G.when.type==="metadata_all_in"?`${G.when.key??"?"} in [${((B=G.when.values)==null?void 0:B.join(","))??"?"}]`:Hk[G.when.type]??G.when.type,$=V.id===G.goto;let q;$?q="back":U.cy>Q.cy+1?q="down":U.cy<Q.cy-1?q="back":q="same",D.push({from:V.id,to:G.goto,label:I,edgeKey:`${V.id}:${Z}`,direction:q,backEdgeIndex:q==="back"?L++:0})});const O=new Map,M=new Map,W=new Map,z=new Map;for(const V of D)V.direction==="down"&&(O.set(V.from,(O.get(V.from)??0)+1),M.set(V.to,(M.get(V.to)??0)+1));const R=new Map,P=new Map;for(const V of D){if(V.direction!=="same")continue;const G=[V.from,V.to].sort().join("|");R.set(G,(R.get(G)??0)+1)}for(const V of D){if(V.direction==="back"||V.direction==="same"){let q=0;if(V.direction==="same"){const B=[V.from,V.to].sort().join("|");q=P.get(B)??0,P.set(B,q+1)}f.push({...V,fromPort:0,toPort:0,sameEdgeIndex:q});continue}const G=O.get(V.from)??1,Z=M.get(V.to)??1,Q=W.get(V.from)??0,U=z.get(V.to)??0;W.set(V.from,Q+1),z.set(V.to,U+1);const I=G===1?0:-.6+1.2*Q/(G-1),$=Z===1?0:-.6+1.2*U/(Z-1);f.push({...V,fromPort:I,toPort:$,sameEdgeIndex:0})}return{nodes:d,edges:f,width:a,height:T+Ar/2+Ri,posMap:p}}function t$({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:l,isReadOnly:u,onSelectNode:c,onSelectEdge:d,onRemoveStep:f,onCreateTransition:p,onReconnectTo:m,onReconnectFrom:x,onDeleteTransition:y}){const w=A.useRef(null),C=A.useRef(!1),[_,S]=A.useState(null),[b,v]=A.useState(null),[E,j]=A.useState(null),{nodes:T,edges:D,width:L,height:O,posMap:M}=A.useMemo(()=>e$(e,t,a,l),[e,t,a,l]),W=A.useCallback(X=>{var se;const ne=w.current;if(!ne)return{x:0,y:0};const K=ne.createSVGPoint();K.x=X.clientX,K.y=X.clientY;const F=(se=ne.getScreenCTM())==null?void 0:se.inverse();if(!F)return{x:0,y:0};const te=K.matrixTransform(F);return{x:te.x,y:te.y}},[]),z=A.useCallback(X=>!X||!b||X==="$start"?!1:b.type==="reconnect-from"?X!=="$done":!0,[b]),R=A.useCallback((X,ne)=>{if(u)return;X.stopPropagation(),X.preventDefault();const K=W(X);v({type:"new",fromNodeId:ne,mouseX:K.x,mouseY:K.y})},[W,u]),P=A.useCallback((X,ne)=>{if(u)return;X.stopPropagation(),X.preventDefault();const K=W(X);v({type:"reconnect-to",fromNodeId:ne.from,edgeKey:ne.edgeKey,mouseX:K.x,mouseY:K.y})},[W,u]),V=A.useCallback((X,ne)=>{if(u)return;X.stopPropagation(),X.preventDefault();const K=W(X);v({type:"reconnect-from",fromNodeId:ne.from,fixedTargetId:ne.to,edgeKey:ne.edgeKey,mouseX:K.x,mouseY:K.y})},[W,u]),G=A.useCallback(X=>{if(!b)return;const ne=W(X);v(K=>K?{...K,mouseX:ne.x,mouseY:ne.y}:null)},[b,W]),Z=A.useCallback(()=>{b&&(C.current=!0,E&&z(E)&&(b.type==="new"?p(b.fromNodeId,E):b.type==="reconnect-to"?m(b.edgeKey,E):b.type==="reconnect-from"&&x(b.edgeKey,E)),v(null),j(null))},[b,E,z,p,m,x]),Q=A.useCallback(()=>{if(C.current){C.current=!1;return}c(null),d(null)},[c,d]);A.useEffect(()=>{if(u)return;const X=ne=>{ne.target instanceof HTMLInputElement||ne.target instanceof HTMLTextAreaElement||ne.target instanceof HTMLSelectElement||(ne.key==="Delete"||ne.key==="Backspace")&&r&&r!=="start"&&(ne.preventDefault(),y(r),d(null))};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[u,r,y,d]);const U=X=>{const ne=M.get(X.from),K=M.get(X.to);if(!ne||!K)return null;let F,te,se,xe="middle",oe,ye;if(X.direction==="down"){const Le=ne.cx+X.fromPort*(ne.w/2-10),Oe=ne.cy+ne.h/2,Me=K.cx+X.toPort*(K.w/2-10),je=K.cy-K.h/2,nt=je-Oe,Xe=Me-Le;F=`M ${Le} ${Oe} C ${Le} ${Oe+nt*.4}, ${Me-Xe*.2} ${je-nt*.1}, ${Me} ${je}`,te=Le+(Me-Le)*.5,se=Oe+nt*.6,oe={x:Le,y:Oe},ye={x:Me,y:je}}else if(X.direction==="back"){const Le=X.from===X.to,Oe=ne.cx>=L/2,Me=X.backEdgeIndex*16,je=Oe?L-20-Me:20+Me;if(Le){const nt=ne.cx>=L/2,Xe=30+X.backEdgeIndex*14,he=ne.cy-ne.h/2,ce=nt?ne.cx+ne.w/2:ne.cx-ne.w/2,de=nt?ce+Xe:ce-Xe,$e=ne.cx+(nt?ne.w/4:-ne.w/4),He=he-20-X.backEdgeIndex*10;F=`M ${ce} ${ne.cy} C ${de} ${ne.cy}, ${de} ${He}, ${$e} ${he}`,te=de+10,se=He+4,xe="middle",oe={x:ce,y:ne.cy},ye={x:$e,y:he}}else{const nt=Oe?ne.cx+ne.w/2:ne.cx-ne.w/2,Xe=K.cx+(Oe?K.w/4:-K.w/4),he=Math.min(ne.cy,K.cy)-K.h/2-18-X.backEdgeIndex*14;F=`M ${nt} ${ne.cy} L ${je} ${ne.cy} L ${je} ${he} L ${Xe} ${he} L ${Xe} ${K.cy-K.h/2}`,te=je,se=(ne.cy+he)/2,xe=Oe?"start":"end",oe={x:nt,y:ne.cy},ye={x:Xe,y:K.cy-K.h/2}}}else{const Le=K.cx>ne.cx,Oe=X.sameEdgeIndex===0?-12:12,Me=Le?ne.cx+ne.w/2:ne.cx-ne.w/2,je=Le?K.cx-K.w/2:K.cx+K.w/2,nt=ne.cy+Oe,Xe=K.cy+Oe,he=(Me+je)/2;F=`M ${Me} ${nt} C ${he} ${nt}, ${he} ${Xe}, ${je} ${Xe}`,te=he,se=(nt+Xe)/2-6,oe={x:Me,y:nt},ye={x:je,y:Xe}}return{path:F,labelX:te,labelY:se,labelAnchor:xe,fromPt:oe,toPt:ye}},I=(X,ne)=>{const K=U(X);if(!K)return null;const{path:F,labelX:te,labelY:se,labelAnchor:xe}=K,oe=r===X.edgeKey,ye=X.label&&X.label!=="otherwise";return i.jsxs("g",{children:[i.jsx("path",{d:F,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Le=>{Le.stopPropagation(),u||d(oe?null:X.edgeKey)}}),i.jsx("path",{d:F,fill:"none",stroke:oe?"#58a6ff":"#484f58",strokeWidth:oe?2.2:1.2,markerEnd:oe?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),ye&&i.jsx("text",{x:te+(xe==="start"?5:xe==="end"?-5:0),y:se+3,textAnchor:xe,className:"text-[8px]",fill:oe?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:X.label})]},ne)},$=()=>{if(!r||b)return null;const X=D.find(se=>se.edgeKey===r);if(!X)return null;const ne=U(X);if(!ne)return null;const{fromPt:K,toPt:F}=ne,te=6;return i.jsxs(i.Fragment,{children:[X.edgeKey!=="start"&&i.jsx("circle",{cx:K.x,cy:K.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>V(se,X)}),i.jsx("circle",{cx:F.x,cy:F.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>P(se,X)})]})},q=()=>{if(!b)return null;let X,ne,K,F;if(b.type==="reconnect-from"){const xe=M.get(b.fixedTargetId);if(!xe)return null;X=b.mouseX,ne=b.mouseY,K=xe.cx,F=xe.cy-xe.h/2}else{const xe=M.get(b.fromNodeId);if(!xe)return null;X=xe.cx,ne=xe.cy+xe.h/2,K=b.mouseX,F=b.mouseY}const te=F-ne,se=Math.abs(te)>10?`M ${X} ${ne} C ${X} ${ne+te*.4}, ${K} ${F-te*.4}, ${K} ${F}`:`M ${X} ${ne} L ${K} ${F}`;return i.jsx("path",{d:se,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},B=X=>{const ne=X.cy+X.h/2,K=(b==null?void 0:b.fromNodeId)===X.id;return i.jsx("circle",{cx:X.cx,cy:ne,r:AS,fill:K?"#58a6ff":"#1c2128",stroke:K?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5,className:"cursor-crosshair",onMouseDown:F=>R(F,X.id)})},ee=X=>{const ne=X.cy-X.h/2,K=b&&E===X.id&&z(X.id);return i.jsx("circle",{cx:X.cx,cy:ne,r:AS,fill:K?"#3fb950":"#1c2128",stroke:K?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5})};return i.jsxs("svg",{ref:w,viewBox:`0 0 ${L} ${O}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:G,onMouseUp:Z,onClick:Q,children:[i.jsxs("defs",{children:[i.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),i.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),D.map((X,ne)=>I(X,ne)),T.map(X=>{const ne=n===X.id,K=X.cx-X.w/2,F=X.cy-X.h/2,te=_===X.id,se=b&&E===X.id&&z(X.id);if(X.type==="terminal"){const oe=X.id==="$start",ye=oe?"#58a6ff":"#3fb950",Le=oe,Oe=!oe;return i.jsxs("g",{onClick:Me=>{Me.stopPropagation(),oe&&!u&&d("start")},className:oe&&!u?"cursor-pointer":void 0,children:[se&&i.jsx("rect",{x:K-3,y:F-3,width:X.w+6,height:X.h+6,rx:X.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),oe&&r==="start"&&i.jsx("rect",{x:K-3,y:F-3,width:X.w+6,height:X.h+6,rx:X.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),i.jsx("rect",{x:K,y:F,width:X.w,height:X.h,rx:X.h/2,fill:ye,fillOpacity:.08,stroke:ye,strokeOpacity:.4,strokeWidth:1.5}),i.jsx("text",{x:X.cx,y:X.cy+4,textAnchor:"middle",fill:ye,className:"text-[10px] font-medium",pointerEvents:"none",children:X.label}),Le&&B(X),Oe&&ee(X)]},X.id)}const xe=X.color??"#6b7280";return i.jsxs("g",{onClick:oe=>{oe.stopPropagation(),u||c(ne?null:X.id)},onMouseEnter:()=>S(X.id),onMouseLeave:()=>S(null),className:u?void 0:"cursor-pointer",children:[se&&i.jsx("rect",{x:K-3,y:F-3,width:X.w+6,height:X.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ne&&i.jsx("rect",{x:K-3,y:F-3,width:X.w+6,height:X.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),i.jsx("rect",{x:K,y:F,width:X.w,height:X.h,rx:10,fill:xe,fillOpacity:.08,stroke:xe,strokeOpacity:.6,strokeWidth:ne?2:1.5}),i.jsx("text",{x:X.cx,y:X.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:X.label}),!u&&B(X),!u&&ee(X),te&&!b&&!u&&i.jsxs("g",{onClick:oe=>{oe.stopPropagation(),f(X.id)},className:"cursor-pointer",children:[i.jsx("circle",{cx:K+X.w-2,cy:F+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),i.jsx("line",{x1:K+X.w-5,y1:F-1,x2:K+X.w+1,y2:F+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),i.jsx("line",{x1:K+X.w+1,y1:F-1,x2:K+X.w-5,y2:F+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},X.id)}),b&&T.map(X=>z(X.id)?i.jsx("rect",{x:X.cx-X.w/2-8,y:X.cy-X.h/2-8,width:X.w+16,height:X.h+16,fill:"transparent",rx:12,onMouseEnter:()=>j(X.id),onMouseLeave:()=>j(null),onMouseUp:ne=>{ne.stopPropagation(),Z()}},`drop-${X.id}`):null),q(),$()]})}const Ru="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",gl="block text-[11px] text-text-secondary mb-0.5";function n$({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:a,isReadOnly:l,onNameChange:u,onDescriptionChange:c,onMaxIterationsChange:d,onColorChange:f}){return i.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[i.jsxs("div",{className:"min-w-[140px]",children:[i.jsx("label",{className:gl,children:"Name"}),i.jsx("input",{value:e,onChange:p=>u(p.target.value),placeholder:"Workflow name",className:`${Ru} ${l?"opacity-50":""}`,readOnly:l})]}),i.jsxs("div",{className:"min-w-[100px]",children:[i.jsx("label",{className:gl,children:"ID"}),i.jsx("input",{value:t,readOnly:!0,className:`${Ru} font-mono opacity-50`})]}),i.jsxs("div",{className:"flex-1 min-w-[140px]",children:[i.jsx("label",{className:gl,children:"Description"}),i.jsx("input",{value:n,onChange:p=>!l&&c(p.target.value),readOnly:l,placeholder:"What does this workflow do?",className:`${Ru} ${l?"opacity-50":""}`})]}),i.jsxs("div",{className:"w-20",children:[i.jsx("label",{className:gl,children:"Max Iter."}),i.jsx("input",{type:"number",value:r,onChange:p=>!l&&d(Number(p.target.value)),readOnly:l,className:`${Ru} font-mono ${l?"opacity-50":""}`})]}),i.jsxs("div",{children:[i.jsx("label",{className:gl,children:"Color"}),i.jsx("input",{type:"color",value:a,onChange:p=>!l&&f(p.target.value),disabled:l,className:`w-8 h-8 rounded border border-border bg-transparent ${l?"opacity-50":"cursor-pointer"}`})]})]})}function r$({name:e,id:t,color:n,description:r,isBuiltIn:a,actions:l}){return i.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),i.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&i.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),i.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:l})]})}function LS({title:e,items:t,renderActions:n}){return t.length===0?null:i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),i.jsx("div",{className:"space-y-2",children:t.map(r=>i.jsx(r$,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const za="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",Jm="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",bs="block text-[11px] text-text-secondary mb-0.5";function Zm({variables:e,onInsert:t}){return e.length===0?null:i.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>i.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 s$({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:l,onRemove:u,onSetEntry:c}){const{color:d,name:f}=Ug(e,n);return i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:d+"20",color:d},children:f}),t&&i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[!t&&i.jsx("button",{onClick:c,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),i.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Type"}),i.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,x=m==="sub_agent"?"verification":"build";if(m==="agent"){const y=n.find(w=>!w.subagent);l({...e,type:m,phase:x,agentId:(y==null?void 0:y.id)??"builder",name:(y==null?void 0:y.name)??"Agent"})}else if(m==="sub_agent"){const y=n.find(w=>w.subagent);l({...e,type:m,phase:x,subAgentType:(y==null?void 0:y.id)??"",name:(y==null?void 0:y.name)??"Sub-Agent"})}else l({...e,type:m,phase:x,name:"Shell"})},className:Jm,children:Z8.map(p=>i.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Agent Type"}),i.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Jm,children:n.filter(p=>!p.subagent).map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Sub-Agent Type"}),i.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Jm,children:[i.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Prompt"}),i.jsx("textarea",{value:e.prompt??"",onChange:p=>l({...e,prompt:p.target.value||void 0}),rows:6,className:`${za} resize-y text-xs`,placeholder:"Injected on first entry..."}),i.jsx(Zm,{variables:a,onInsert:p=>l({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Nudge Prompt"}),i.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>l({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${za} resize-y text-xs`,placeholder:"Injected on re-entry..."}),i.jsx(Zm,{variables:a,onInsert:p=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Command"}),i.jsx("textarea",{value:e.command??"",onChange:p=>l({...e,command:p.target.value}),rows:3,className:`${za} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),i.jsx(Zm,{variables:a,onInsert:p=>l({...e,command:(e.command??"")+`{{${p}}}`})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Timeout (ms)"}),i.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>l({...e,timeout:Number(p.target.value)}),className:`${za} font-mono text-xs`})]}),i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Success Codes"}),i.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>l({...e,successExitCodes:p.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${za} font-mono text-xs`})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:bs,children:"Sub-group"}),i.jsx("input",{value:e.subGroup??"",onChange:p=>l({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:za})]}),i.jsx("div",{className:"pt-1 border-t border-border/50",children:i.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Ha="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",DS="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",Oi="block text-[11px] text-text-secondary mb-0.5";function i$({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:l,transitionIndex:u,totalTransitions:c,onUpdateCondition:d,onUpdateSubGroup:f,onDelete:p,onMoveUp:m,onMoveDown:x}){var C;const y=a&&(a.type==="sub_agent"||a.type==="agent")?l.find(_=>_.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(y==null?void 0:y.results)&&y.results.length>0;return i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",u+1]}),c>1&&i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsx("button",{onClick:m,disabled:u===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:i.jsx(Qn,{className:"w-3 h-3",rotate:180})}),i.jsx("button",{onClick:x,disabled:u===c-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:i.jsx(Qn,{className:"w-3 h-3"})})]})]}),i.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[i.jsx("span",{className:"font-medium text-text-primary",children:e}),i.jsx(c1,{}),i.jsx("span",{className:"font-medium text-text-primary",children:t})]}),i.jsxs("div",{children:[i.jsx("label",{className:Oi,children:"Condition"}),i.jsx("select",{value:n.type,onChange:_=>{d(_.target.value==="step_result"?{type:"step_result",result:"success"}:{type:_.target.value})},className:DS,children:Uk.map(_=>i.jsx("option",{value:_.value,children:_.label},_.value))})]}),n.type==="step_result"&&i.jsxs("div",{children:[i.jsx("label",{className:Oi,children:"Result"}),w?i.jsx("select",{value:n.result??y.results[0],onChange:_=>{d({type:"step_result",result:_.target.value})},className:DS,children:y.results.map(_=>i.jsx("option",{value:_,children:_},_))}):i.jsx("input",{type:"text",value:n.result??"success",onChange:_=>d({type:"step_result",result:_.target.value}),placeholder:"e.g. success, passed, failed",className:Ha})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:Oi,children:"Metadata Key"}),i.jsx("input",{type:"text",value:n.key??"",onChange:_=>d({...n,key:_.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Ha})]}),i.jsxs("div",{children:[i.jsx("label",{className:Oi,children:"Field"}),i.jsx("input",{type:"text",value:n.field??"",onChange:_=>d({...n,field:_.target.value}),placeholder:"e.g. status",className:Ha})]}),n.type==="metadata_all_match"?i.jsxs("div",{children:[i.jsx("label",{className:Oi,children:"Value"}),i.jsx("input",{type:"text",value:n.value??"",onChange:_=>d({...n,value:_.target.value}),placeholder:"e.g. passed, resolved",className:Ha})]}):i.jsxs("div",{children:[i.jsx("label",{className:Oi,children:"Values (comma-separated)"}),i.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:_=>d({...n,values:_.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Ha})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:Oi,children:"Sub-group"}),i.jsx("input",{type:"text",value:r??"",onChange:_=>f(_.target.value||void 0),placeholder:"e.g. build, verify",className:Ha})]}),i.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function a$(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function o$(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const xl="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",RS="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",Ua="block text-[11px] text-text-secondary mb-0.5",OS=[];function Fk({isOpen:e,onClose:t,initialEditId:n}){var bn,rn;const r=Ot(Ce=>Ce.defaults),a=Ot(Ce=>Ce.userItems),l=Ot(Ce=>Ce.loading),u=Ot(Ce=>Ce.templateVariables),c=Ot(Ce=>Ce.fetchWorkflows),d=Ot(Ce=>Ce.fetchWorkflow),f=Ot(Ce=>Ce.fetchDefaultContent),p=Ot(Ce=>Ce.fetchTemplateVariables),m=Ot(Ce=>Ce.createWorkflow),x=Ot(Ce=>Ce.updateWorkflow),y=Ot(Ce=>Ce.deleteWorkflow),{requestDelete:w,clearConfirm:C,isConfirming:_}=Hl(),[S,b]=A.useState("list"),[v,E]=A.useState(null),[j,T]=A.useState(!1),[D,L]=A.useState(null),[O,M]=A.useState(null),[W,z]=A.useState(""),[R,P]=A.useState(""),[V,G]=A.useState(""),[Z,Q]=A.useState("1.0.0"),[U,I]=A.useState("#3b82f6"),[$,q]=A.useState(""),[B,ee]=A.useState(50),[X,ne]=A.useState(OS),[K,F]=A.useState({type:"always"}),[te,se]=A.useState(""),[xe,oe]=A.useState(!1),ye=mt(Ce=>Ce.defaults),Le=mt(Ce=>Ce.userItems),Oe=mt(Ce=>Ce.projectItems),Me=A.useMemo(()=>[...ye,...Le,...Oe],[ye,Le,Oe]),je=mt(Ce=>Ce.fetchAgents),[nt]=A.useState(null);A.useEffect(()=>{e&&(c(),p(),je(),L(null),M(null),n?r.some(Te=>Te.id===n)?f(n).then(Te=>{Te&&Xe({...Te,metadata:{...Te.metadata,name:Te.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):d(n).then(Te=>{Te&&Xe(Te,{editingId:n,isReadOnly:!1})}):(b("list"),E(null),T(!1)))},[e,c,d,f,p,n]);const Xe=(Ce,Te)=>{z(Ce.metadata.name),P(Ce.metadata.id),G(Ce.metadata.description),Q(Ce.metadata.version),I(Ce.metadata.color??"#3b82f6"),q(Ce.entryStep),ee(Ce.settings.maxIterations),ne(Ce.steps),F(Ce.startCondition??{type:"always"}),se(""),(Te==null?void 0:Te.editingId)!==void 0&&E(Te.editingId),(Te==null?void 0:Te.isReadOnly)!==void 0&&T(Te.isReadOnly),(Te==null?void 0:Te.selectedNodeKey)!==void 0&&L(null),(Te==null?void 0:Te.selectedEdgeKey)!==void 0&&M(null),b("edit")},he=async Ce=>{const Te=await d(Ce);Te&&Xe(Te,{editingId:Ce,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},ce=async()=>{var at;const Ce=v??R;if(!Ce||!W)return se("Name is required."),!1;if(X.length===0)return se("Add at least one step."),!1;let Te=$;if(!Te||!X.some(et=>et.id===Te)){if(Te=((at=X.find(et=>et.id))==null?void 0:at.id)??"",!Te)return se("All steps need an ID."),!1;q(Te)}oe(!0),se("");const Ue={metadata:{id:Ce,name:W,description:V,version:Z||"1.0.0",color:U},entryStep:Te,settings:{maxIterations:B},steps:X,startCondition:K},qe=v?await x(v,Ue):await m(Ue);return oe(!1),qe.success?(v||E(Ce),!0):(se(qe.error??"Failed to save."),!1)},de=async()=>{await ce()},$e=async()=>{await ce()&&(n?t():b("list"))},He=()=>{n?t():b("list")},ut=Ce=>{z(Ce),v||P(a$(Ce))},re=async Ce=>r.some(Ue=>Ue.id===Ce)?await f(Ce):await d(Ce),be=async Ce=>{const Te=await re(Ce);Te&&Xe({...Te,metadata:{...Te.metadata,name:Te.metadata.name+" (copy)",id:`${Ce}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},ke=()=>{E(null),z(""),P(""),G(""),Q("1.0.0"),I("#3b82f6"),q(""),ee(50),ne(structuredClone(OS)),F({type:"always"}),se(""),L(null),M(null),T(!1),b("edit")},ze=async Ce=>{await y(Ce),C()},Ye=A.useCallback(Ce=>{L(Ce),M(null)},[]),We=A.useCallback(Ce=>{M(Ce),L(null)},[]),tt=D!==null?Number(D):-1,_t=tt>=0?X[tt]??null:null,It=A.useCallback(Ce=>{ne(Te=>Te.map((Ue,qe)=>qe===tt?Ce:Ue))},[tt]),qt=K.type==="step_result"?`${K.result}`:K.type==="metadata_all_match"?`${K.key??"?"}=${K.value??"?"}`:K.type==="metadata_all_in"?`${K.key??"?"} in [${((bn=K.values)==null?void 0:bn.join(","))??"?"}]`:Hk[K.type]??K.type,dt=()=>{const Ce=X.length,Te=o$(X),Ue=Me.find(qe=>!qe.subagent);ne([...X,{id:Te,name:(Ue==null?void 0:Ue.name)??"Agent",type:"agent",phase:"build",agentId:(Ue==null?void 0:Ue.id)??"builder",transitions:[]}]),$||q(Te),Ye(String(Ce))},Cn=A.useCallback((Ce,Te)=>{Ce==="$start"?(q(Te),We("start")):ne(Ue=>{const qe=Ue.find(et=>et.id===Ce),at=qe?qe.transitions.length:0;return We(`${Ce}:${at}`),Ue.map(et=>et.id===Ce?{...et,transitions:[...et.transitions,{when:{type:"always"},goto:Te}]}:et)})},[We]),jt=Ce=>{if(Ce==="start")return null;const Te=Ce.lastIndexOf(":"),Ue=Ce.slice(0,Te),qe=parseInt(Ce.slice(Te+1));return{stepId:Ue,transIdx:qe}},Jt=A.useCallback((Ce,Te)=>{const Ue=jt(Ce);Ue&&ne(qe=>qe.map(at=>at.id===Ue.stepId?{...at,transitions:at.transitions.map((et,xt)=>xt===Ue.transIdx?Te(et):et)}:at))},[]),Mr=A.useCallback((Ce,Te)=>{if(Ce==="start"){q(Te);return}Jt(Ce,Ue=>({...Ue,goto:Te}))},[Jt]),_e=A.useCallback((Ce,Te)=>{const Ue=jt(Ce);Ue&&(ne(qe=>{const at=qe.find(xt=>xt.id===Ue.stepId);if(!at)return qe;const et=at.transitions[Ue.transIdx];return et?qe.map(xt=>xt.id===Ue.stepId?{...xt,transitions:xt.transitions.filter((sn,Zt)=>Zt!==Ue.transIdx)}:xt.id===Te?{...xt,transitions:[...xt.transitions,et]}:xt):qe}),M(null))},[]),Fe=A.useCallback(Ce=>{if(Ce==="start"){q(""),M(null);return}const Te=jt(Ce);Te&&(ne(Ue=>Ue.map(qe=>qe.id===Te.stepId?{...qe,transitions:qe.transitions.filter((at,et)=>et!==Te.transIdx)}:qe)),M(null))},[]),ae=A.useCallback((Ce,Te)=>{if(Ce==="start"){F(Te);return}Jt(Ce,Ue=>({...Ue,when:Te}))},[Jt]),fe=A.useCallback((Ce,Te)=>{Ce!=="start"&&Jt(Ce,Ue=>({...Ue,subGroup:Te||void 0}))},[Jt]),Ie=Ce=>Ug(Ce,Me).name,gt=()=>{if(!O)return null;if(O==="start"){const sn=X.find(Zt=>Zt.id===$);return{type:"start",fromLabel:"Start",toLabel:sn?Ie(sn):"(none)",condition:K}}const Ce=O.lastIndexOf(":"),Te=O.slice(0,Ce),Ue=parseInt(O.slice(Ce+1)),qe=X.find(sn=>sn.id===Te);if(!qe)return null;const at=qe.transitions[Ue];if(!at)return null;const et=X.find(sn=>sn.id===at.goto),xt=at.goto==="$done"?"Done":et?Ie(et):at.goto;return{type:"step",fromLabel:Ie(qe),toLabel:xt,condition:at.when,subGroup:at.subGroup}};if(S==="edit"){const Ce=gt();return i.jsxs(wt,{isOpen:e,onClose:He,title:j?W:v?"Edit Workflow":"New Workflow",size:"full",children:[te&&i.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:te}),i.jsx(n$,{formName:W,formId:R,formDescription:V,formMaxIterations:B,formColor:U,isReadOnly:j,onNameChange:ut,onDescriptionChange:G,onMaxIterationsChange:ee,onColorChange:I}),i.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[i.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[i.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!j&&i.jsx("button",{onClick:dt,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),i.jsxs("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:[i.jsx(t$,{steps:X,entryStep:$,selectedNodeId:(_t==null?void 0:_t.id)??null,selectedEdgeKey:O,startConditionLabel:qt,agentTypes:Me,isReadOnly:j,onSelectNode:Te=>{if(Te===null){Ye(null);return}const Ue=X.findIndex(qe=>qe.id===Te);Ye(Ue>=0?String(Ue):null)},onSelectEdge:We,onRemoveStep:Te=>{var qe;const Ue=X.findIndex(at=>at.id===Te);if(ne(at=>at.filter(et=>et.id!==Te)),tt===Ue&&Ye(null),$===Te){const at=X.filter(et=>et.id!==Te);q(((qe=at[0])==null?void 0:qe.id)??"")}},onCreateTransition:Cn,onReconnectTo:Mr,onReconnectFrom:_e,onDeleteTransition:Fe}),X.length===0&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[i.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),i.jsx("button",{onClick:dt,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"})]})]})]}),i.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[i.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:i.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),i.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:j&&(Ce||_t)?i.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):Ce?Ce.type==="start"?i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),$&&i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[i.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),i.jsx(c1,{}),i.jsx("span",{className:"text-text-primary font-medium",children:Ce.toLabel})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ua,children:"Activation Condition"}),i.jsx("select",{value:K.type,onChange:Te=>F(Te.target.value==="step_result"?{type:"step_result",result:"success"}:Te.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:Te.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:Te.target.value}),className:RS,children:Uk.map(Te=>i.jsx("option",{value:Te.value,children:Te.label},Te.value))})]}),K.type==="step_result"&&i.jsxs("div",{children:[i.jsx("label",{className:Ua,children:"Result"}),$&&(()=>{const Te=X.find(et=>et.id===$),Ue=Te&&(Te.type==="sub_agent"||Te.type==="agent")?Me.find(et=>et.id===(Te.type==="sub_agent"?Te.subAgentType:Te.agentId)):void 0,qe=(Ue==null?void 0:Ue.results)&&Ue.results.length>0,at=(Ue==null?void 0:Ue.results)??[];return qe?i.jsx("select",{value:K.result??at[0],onChange:et=>F({type:"step_result",result:et.target.value}),className:RS,children:at.map(et=>i.jsx("option",{value:et,children:et},et))}):i.jsx("input",{type:"text",value:K.result??"success",onChange:et=>F({type:"step_result",result:et.target.value}),placeholder:"e.g. success, passed, failed",className:xl})})()]}),(K.type==="metadata_all_match"||K.type==="metadata_all_in")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:Ua,children:"Metadata Key"}),i.jsx("input",{type:"text",value:K.key??"",onChange:Te=>F({...K,key:Te.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:xl})]}),i.jsxs("div",{children:[i.jsx("label",{className:Ua,children:"Field"}),i.jsx("input",{type:"text",value:K.field??"",onChange:Te=>F({...K,field:Te.target.value}),placeholder:"e.g. status",className:xl})]}),K.type==="metadata_all_match"?i.jsxs("div",{children:[i.jsx("label",{className:Ua,children:"Value"}),i.jsx("input",{type:"text",value:K.value??"",onChange:Te=>F({...K,value:Te.target.value}),placeholder:"e.g. passed, resolved",className:xl})]}):i.jsxs("div",{children:[i.jsx("label",{className:Ua,children:"Values (comma-separated)"}),i.jsx("input",{type:"text",value:((rn=K.values)==null?void 0:rn.join(", "))??"",onChange:Te=>F({...K,values:Te.target.value.split(",").map(Ue=>Ue.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:xl})]})]}),i.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 Te=jt(O),Ue=Te==null?void 0:Te.stepId,qe=(Te==null?void 0:Te.transIdx)??0,at=Ue?X.find(xt=>xt.id===Ue):void 0,et=(at==null?void 0:at.transitions.length)??0;return i.jsx(i$,{fromLabel:Ce.fromLabel,toLabel:Ce.toLabel,condition:Ce.condition,subGroup:"subGroup"in Ce?Ce.subGroup:void 0,fromStep:Ce.type==="step"?X.find(xt=>xt.id===Ce.fromLabel):void 0,agentTypes:Me,transitionIndex:qe,totalTransitions:et,onUpdateCondition:xt=>ae(O,xt),onUpdateSubGroup:xt=>fe(O,xt),onDelete:()=>Fe(O),onMoveUp:()=>{ne(xt=>{const sn=xt.find(Wt=>Wt.id===Ue);if(!sn||qe===0)return xt;const Zt=[...sn.transitions];return[Zt[qe-1],Zt[qe]]=[Zt[qe],Zt[qe-1]],xt.map(Wt=>Wt.id===Ue?{...Wt,transitions:Zt}:Wt)}),M(`${Ue}:${qe-1}`)},onMoveDown:()=>{ne(xt=>{const sn=xt.find(Wt=>Wt.id===Ue);if(!sn||qe===sn.transitions.length-1)return xt;const Zt=[...sn.transitions];return[Zt[qe],Zt[qe+1]]=[Zt[qe+1],Zt[qe]],xt.map(Wt=>Wt.id===Ue?{...Wt,transitions:Zt}:Wt)}),M(`${Ue}:${qe+1}`)}})})():_t?i.jsx(s$,{step:_t,isEntry:_t.id===$,agentTypes:Me,transitionCount:_t.transitions.length,templateVariables:u,onUpdate:It,onRemove:()=>{var Te;if(_t&&(ne(X.filter((Ue,qe)=>qe!==tt)),Ye(null),$===_t.id)){const Ue=X.filter((qe,at)=>at!==tt);q(((Te=Ue[0])==null?void 0:Te.id)??"")}},onSetEntry:()=>q(_t.id)}):i.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",i.jsx("br",{}),"Drag from a port to connect."]})})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[i.jsx(Je,{variant:"secondary",onClick:He,children:"Close"}),j?i.jsx(Je,{variant:"primary",onClick:()=>{z(W+" (copy)"),P(`${v}-copy-${Date.now()}`),E(null),T(!1)},children:"Duplicate & Customize"}):i.jsxs(i.Fragment,{children:[i.jsx(Je,{variant:"primary",onClick:de,children:"Save"}),i.jsx(Je,{variant:"primary",onClick:$e,children:"Save & Close"})]})]})]})}return i.jsx(wt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:i.jsx(x1,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:ke,loading:l,hasItems:r.length>0||a.length>0,children:i.jsxs("div",{className:"space-y-4",children:[i.jsx(LS,{title:"Built-in",items:r,renderActions:Ce=>i.jsx(i.Fragment,{children:i.jsx(Gi,{onClick:()=>be(Ce.id),children:i.jsx(Kp,{})})})}),i.jsx(LS,{title:"Custom",items:a,renderActions:Ce=>i.jsxs(i.Fragment,{children:[i.jsx(Gi,{onClick:()=>he(Ce.id),children:i.jsx("span",{className:"text-[10px]",children:"Edit"})}),i.jsx(Vu,{onClick:()=>be(Ce.id)}),_(Ce.id,"delete")?i.jsx(Zp,{onConfirm:()=>ze(Ce.id),onCancel:C}):i.jsx(eg,{onClick:()=>w(Ce.id)})]})})]})})})}function l$(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function c$({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:l,textareaContent:u,onSearchMessages:c,onToggleAutoScroll:d,isAutoScrollActive:f}){const[,p]=zn(),m=mn(B=>B.fetchCommands),x=Ot(B=>B.fetchWorkflows),y=mt(B=>B.fetchAgents),w=mn(B=>B.defaults),C=mn(B=>B.userItems),_=mn(B=>B.projectItems),S=Ot(B=>B.defaults),b=Ot(B=>B.userItems),v=Ot(B=>B.projectItems),E=mt(B=>B.defaults),j=mt(B=>B.userItems),T=mt(B=>B.projectItems),D=Re(B=>{var ee;return(ee=B.currentSession)==null?void 0:ee.mode}),L=Re(B=>{var ee;return((ee=B.currentSession)==null?void 0:ee.dangerLevel)??"normal"}),O=Re(B=>B.switchMode),M=Re(B=>B.switchDangerLevel),W=Re(B=>{var ee;return(ee=B.currentSession)==null?void 0:ee.projectId}),z=A.useRef(void 0),[R,P]=A.useState(""),[V,G]=A.useState(0),Z=A.useRef(null),Q=A.useRef(!1);A.useEffect(()=>{e&&(Q.current=!0)},[e]),A.useEffect(()=>{if(e){m(),x(),y(),P(""),G(0);const B=setTimeout(()=>{var ee;return(ee=Z.current)==null?void 0:ee.focus()},50);return()=>clearTimeout(B)}},[e,m,x,y]),A.useEffect(()=>{var B;!e&&Q.current&&(n==null||n(),(B=z.current)==null||B.call(z),z.current=void 0)},[e,n]);const I=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const B=W??l$(window.location.pathname);B&&p(`/p/${B}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{z.current=l,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),c==null||c()}},{id:"toggle-autoscroll",name:f?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),d==null||d(!f)}},...qr(qr(E,j),T).filter(B=>!B.subagent&&B.id!==D).map(B=>({id:B.id,name:B.name,prefix:"Agent > Switch to",action:()=>O(B.id)})),...qr(qr(w,C),_).map(B=>({id:B.id,name:B.name,prefix:"Command > Launch",action:()=>r(B.id,u)})),...qr(qr(S,b),v).map(B=>({id:B.id,name:B.name,prefix:"Workflow > Run",action:()=>a(B.id)})),...["normal","dangerous"].filter(B=>B!==L).map(B=>({id:B,name:B.charAt(0).toUpperCase()+B.slice(1),prefix:"Mode > Switch to",action:()=>M(B)}))].filter(B=>ii(`${B.prefix} ${B.name}`,R)),$=I.length-1,q=B=>{yk(B,$,G,()=>{var ee;(ee=I[V])==null||ee.action(),t()},t)};return e?io.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),i.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[i.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[i.jsx("input",{ref:Z,type:"text",value:R,onChange:B=>{P(B.target.value),G(0)},onKeyDown:q,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),i.jsx(Jp,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),i.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:I.length===0?i.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+S.length+b.length>0?"No matches":"No agents, commands, or workflows yet"}):I.map((B,ee)=>i.jsxs("button",{type:"button",onClick:()=>{B.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${ee===V?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[i.jsxs("span",{className:"text-text-muted font-normal",children:[B.prefix," "]}),i.jsx("span",{children:B.name})]},B.id))})]})]}),document.body):null}const Vk="openfox-message-search-filters",u$=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function d$(){try{const e=localStorage.getItem(Vk);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function h$(e){localStorage.setItem(Vk,JSON.stringify([...e]))}function f$(e){var n,r;if(e.type!=="message")return null;const t=e.message;if(t.role==="user")return"user";if(t.role==="assistant"){if((n=t.content)!=null&&n.trim())return"response";if((r=t.thinkingContent)!=null&&r.trim())return"thinking"}return null}function m$(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});const a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0"),c=String(t.getHours()).padStart(2,"0"),d=String(t.getMinutes()).padStart(2,"0");return`${a}/${l}/${u} ${c}:${d}`}function p$(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 g$(e){var t,n;if(e.type==="message"){const r=e.message;if(r.role==="assistant"){const a=(t=r.content)==null?void 0:t.trim();return((n=r.thinkingContent)==null?void 0:n.trim())&&!a?"italic text-text-muted":""}if(r.role==="user")return"font-bold"}return""}function x$(e){var n,r;if(e.type!=="message")return i.jsx(g_,{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())?i.jsx(GN,{className:"w-3.5 h-3.5"}):i.jsx(g_,{className:"w-3.5 h-3.5"}):i.jsx(VN,{className:"w-3.5 h-3.5"})}function IS(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",a=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 a?a.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const l=a.slice(0,200);return l.length<a.length?`${l}...`:l}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:""}function y$({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,l]=A.useState(""),[u,c]=A.useState(0),[d,f]=A.useState(d$),p=A.useRef(null),m=A.useRef(null),x=A.useRef(null),y=j=>{f(T=>{const D=new Set(T);return D.has(j)?D.delete(j):D.add(j),h$(D),D})},w=A.useMemo(()=>n.filter(j=>{var T,D;return!(j.type==="context-divider"||j.type==="message"&&(j.message.messageKind==="auto-prompt"||j.message.role==="assistant"&&!((T=j.message.content)!=null&&T.trim())&&!((D=j.message.thinkingContent)!=null&&D.trim())))}),[n]),C=A.useMemo(()=>w.filter(j=>{const T=f$(j);return!(T&&!d.has(T))}),[w,d]),_=A.useMemo(()=>a?w.filter(j=>{const T=IS(j);return ii(T,a)}):C,[C,a]),S=_.length-1;A.useEffect(()=>{if(e){l(""),c(0);const j=setTimeout(()=>{var T;return(T=p.current)==null?void 0:T.focus()},50);return()=>clearTimeout(j)}},[e]),A.useEffect(()=>{e&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[e]),A.useEffect(()=>{x.current&&x.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[u]);const b=j=>{yk(j,S,c,()=>{const T=_[u];if(T){const D=n.indexOf(T);D>=0&&r(D),t()}},t)},v=j=>{const T=n.indexOf(j);T>=0&&r(T),t()},E=j=>n.indexOf(j);return e?io.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[i.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),i.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[i.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[i.jsx(Vi,{}),i.jsx("input",{ref:p,type:"text",value:a,onChange:j=>{l(j.target.value),c(0)},onKeyDown:b,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),i.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:i.jsx(Es,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:u$.map(j=>{const T=d.has(j.key);return i.jsx("button",{type:"button",onClick:()=>y(j.key),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${T?"bg-accent-primary/20 text-accent-primary border border-accent-primary/40":"bg-bg-tertiary text-text-muted border border-border hover:text-text-secondary"}`,children:j.label},j.key)})}),i.jsx("div",{ref:m,className:"overflow-y-auto max-h-[60vh] p-2",children:_.length===0?i.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:C.length>0?"No matches":"No messages yet"}):_.map((j,T)=>{const D=E(j),L=x$(j),O=IS(j),M=g$(j),W=p$(j),z=j.type==="message"&&j.message.role==="user";return i.jsx("button",{ref:T===u?x:null,type:"button",onClick:()=>v(j),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${T===u?"bg-accent-primary/20 text-text-primary":z?"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:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[i.jsx("span",{className:"flex-shrink-0",children:L}),i.jsx("span",{className:`truncate flex-1 ${M}`,children:O})]}),W&&i.jsx("span",{className:"text-text-muted text-xs shrink-0",children:m$(W)})]})},`${D}-${j.type}`)})})]})]}),document.body):null}function b$({attachment:e,onRemove:t}){const n=Mk(e.filename);return i.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[i.jsx(Yl,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),Ik(e.mimeType)?i.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}):i.jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-md bg-bg-secondary text-xs font-bold text-text-muted",children:n}),i.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),i.jsx("div",{className:"text-[10px] text-text-muted",children:qa(e.size)})]})}function v$({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const l=A.useRef(null),u=A.useRef(null);A.useEffect(()=>{u.current&&l.current&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const c=f=>{switch(f.key){case"Enter":f.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":f.preventDefault(),r();break;case"ArrowUp":f.preventDefault(),a("up");break;case"ArrowDown":f.preventDefault(),a("down");break}},d=f=>{n(f)};return i.jsx("div",{ref:l,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg overflow-y-auto max-h-64",onKeyDown:c,children:e.map((f,p)=>i.jsxs("div",{ref:p===t?u:null,role:"listitem",onClick:()=>d(f.content),className:`
|
|
299
|
+
p-2 rounded cursor-pointer transition-colors
|
|
300
|
+
${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
|
|
301
|
+
`,children:[i.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[f.formattedTimestamp,f.sessionName&&i.jsxs(i.Fragment,{children:[" | ",i.jsx("span",{className:"text-accent-primary font-medium",children:f.sessionName})]})]}),i.jsx("div",{className:"text-sm text-text-primary mt-1",children:f.trimmedContent})]},f.id))})}function _$(){const e=bN(),t=e?"bg-amber-400":"bg-accent-primary";return i.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs("span",{className:"flex gap-0.5",children:[i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),i.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),i.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&i.jsx("span",{className:"text-text-muted",children:"esc to interrupt"})]})}const S$={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function w$(e,t={}){const n={...S$,...t};if(!e.type.startsWith("image/"))throw new Error("File is not an image");if(!["image/png","image/jpeg","image/gif"].includes(e.type))throw new Error(`Unsupported image format: ${e.type}. Only PNG, JPG, and GIF are supported.`);if(e.size<=n.maxSizeBytes){const a=await e.arrayBuffer(),l=A$(a),u=`data:${e.type};base64,${l}`,c=await Gk(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:c.width,height:c.height}}return await C$(e,n)}async function C$(e,t){const n=await E$(e),r=await Gk(n),{width:a,height:l}=k$(r.width,r.height,t.maxWidth,t.maxHeight),u=j$();u.width=a,u.height=l;const c=u.getContext("2d");if(!c)throw new Error("Failed to get canvas context");c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high",c.drawImage(r,0,0,a,l);let d=t.quality,f="";for(let m=0;m<10&&(f=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(MS(f)<=t.maxSizeBytes||d<=.3));m++)d-=.1;const p=MS(f);return{dataUrl:f,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:a,height:l}}function k$(e,t,n,r){const a=e/t;return e>t&&e>n?{width:n,height:Math.round(n/a)}:t>e&&t>r?{width:Math.round(r*a),height:r}:{width:e,height:t}}function E$(e){return new Promise((t,n)=>{const r=T$(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function Gk(e){return new Promise((t,n)=>{const r=N$(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function j$(){var t;const e=Fg();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function N$(){const e=Fg();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function T$(){const e=Fg();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Fg(){return globalThis}function A$(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const a=t[r];a!==void 0&&(n+=String.fromCharCode(a))}return btoa(n)}function MS(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const PS=50*1024*1024,BS=1024*1024,L$=["image/png","image/jpeg","image/gif"];function D$(e){return e==="application/pdf"}function R$(e){return L$.includes(e.type)}async function O$(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(e)})}async function $S(e,t,n){try{if(Hg(e.type)){if(e.size>BS){n(`Text file too large (${qa(e.size)}). Maximum is ${qa(BS)}.`);return}const r=await e.text(),a={id:Ou(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(Uu(e.type)||D$(e.type)){if(e.size>PS){const r=Uu(e.type)?"Image":"PDF";n(`${r} file too large (${qa(e.size)}). Maximum is ${qa(PS)}.`);return}if(Uu(e.type)&&R$(e)){const r=await w$(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:Ou(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await O$(e),a={id:Ou(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}}else n(`Unsupported file type: ${e.type}. Supported types: images (PNG, JPG, GIF, WebP, BMP, SVG), PDF, text files, JSON, XML, YAML, and other common text-based formats.`)}catch(r){const a=r instanceof Error?r.message??"Failed to process file":"Failed to process file";n(a)}}function Wk(e){const t=Re(l=>l.sendMessage),n=Re(l=>l.launchWorkflow),r=A.useCallback((l,u,c)=>{e(!0),t(l,u,c)},[e,t]),a=A.useCallback((l,u,c,d)=>{e(!0),n(l,u,c,d)},[e,n]);return{sendMessage:r,launchWorkflow:a}}function I$({children:e}){return io.createPortal(e,document.body)}function M$(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 P$({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:l,textareaContent:u,attachments:c}){const[d,f]=A.useState(!1),[p,m]=A.useState("commands"),[x,y]=A.useState(""),[w,C]=A.useState(0),[_,S]=A.useState(null),[b,v]=A.useState(null),E=A.useRef(null),j=A.useRef(null),T=mn(ee=>ee.defaults),D=mn(ee=>ee.userItems),L=mn(ee=>ee.projectItems),O=mn(ee=>ee.fetchCommands),M=Ot(ee=>ee.defaults),W=Ot(ee=>ee.userItems),z=Ot(ee=>ee.projectItems),R=Ot(ee=>ee.fetchWorkflows),P=qr(qr(T,D),L),V=qr(qr(M,W),z);A.useEffect(()=>{d&&(p==="commands"?O():p==="workflows"&&R())},[d,p,O,R]),A.useEffect(()=>{d&&(y(""),C(0),requestAnimationFrame(()=>{var ee;return(ee=E.current)==null?void 0:ee.focus()}))},[d,p]),A.useEffect(()=>{if(!d)return;const ee=X=>{var ne;(ne=j.current)!=null&&ne.contains(X.target)||f(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[d]);const G=ee=>{switch(ee.key){case"ArrowDown":ee.preventDefault(),C(X=>{const K=(p==="commands"?P:V).filter(F=>{const te=x.toLowerCase();return!te||F.name.toLowerCase().includes(te)});return Math.min(X+1,K.length-1)});break;case"ArrowUp":ee.preventDefault(),C(X=>Math.max(X-1,0));break;case"Enter":ee.preventDefault();break;case"Escape":ee.preventDefault(),f(!1);break}},Z=ee=>{y(ee),C(0)},Q=P.filter(ee=>!x||ee.name.toLowerCase().includes(x.toLowerCase())),U=V.filter(ee=>!x||ee.name.toLowerCase().includes(x.toLowerCase())),I=async ee=>{const X=await mn.getState().fetchCommand(ee);X&&e(X.prompt,X.metadata.agentMode,u,c),f(!1)},$=ee=>{t(ee),f(!1)},q=(ee,X)=>{X.stopPropagation(),f(!1),S(ee)},B=(ee,X)=>{X.stopPropagation(),f(!1),v(ee)};return i.jsxs("div",{ref:j,className:"relative",children:[i.jsx("button",{type:"button",onClick:()=>f(!d),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:i.jsx(h1,{className:"w-4 h-4"})}),d&&i.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 max-w-[calc(100vw-2rem)] bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[i.jsxs("div",{className:"flex border-b border-border",children:[i.jsx("button",{type:"button",onClick:()=>{m("commands"),y(""),C(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"}),i.jsx("button",{type:"button",onClick:()=>{m("workflows"),y(""),C(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"}),i.jsx("button",{type:"button",onClick:()=>m("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"&&i.jsx("div",{className:"p-2 border-b border-border",children:i.jsx("input",{ref:E,value:x,onChange:ee=>Z(ee.target.value),onKeyDown:G,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"})}),i.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:p==="commands"?Q.length===0?i.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:P.length===0?"No commands yet":"No matches"}):Q.map((ee,X)=>i.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${X===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[i.jsx("button",{type:"button",onClick:()=>I(ee.id),className:"flex-1 text-left",children:i.jsx("div",{className:"text-sm text-text-primary font-medium",children:ee.name})}),i.jsx(Gi,{className:"opacity-0 group-hover:opacity-100",onClick:ne=>q(ee.id,ne)})]},ee.id)):p==="workflows"?U.length===0?i.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:V.length===0?"No workflows yet":"No matches"}):U.map((ee,X)=>{const ne=M$(ee),K=ee.color??"#3b82f6";return i.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${X===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[i.jsxs("button",{type:"button",onClick:()=>$(ee.id),className:"flex-1 text-left flex items-center gap-2",children:[i.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:K}}),i.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:ee.name}),ne!==null&&i.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:ne?"#22c55e":"#6b7280"},title:ne?"Entry condition met":"Entry condition not met"})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[ee.subGroups&&ee.subGroups.length>0&&i.jsx(B$,{subGroups:ee.subGroups,onSelect:F=>{f(!1),n(ee.id,F)}}),i.jsx(Gi,{className:"opacity-0 group-hover:opacity-100",onClick:F=>B(ee.id,F)})]})]},ee.id)}):i.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[i.jsxs("button",{type:"button",onClick:()=>{l(),f(!1)},className:"flex items-center gap-2 px-4 py-2 rounded bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary transition-colors",children:[i.jsx(TN,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm font-medium",children:"Attach file"})]}),i.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&i.jsx("div",{className:"border-t border-border p-1",children:i.jsx("button",{type:"button",onClick:()=>{f(!1),p==="commands"?r():a()},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..."})})]}),i.jsx(zk,{isOpen:!!_,onClose:()=>S(null),initialEditId:_}),i.jsx(Fk,{isOpen:!!b,onClose:()=>v(null),initialEditId:b})]})}function B$({subGroups:e,onSelect:t}){const[n,r]=A.useState(!1),[a,l]=A.useState({top:0,right:0}),u=A.useRef(null),c=A.useRef(null);$k(c,()=>r(!1),n);const d=f=>{if(f.stopPropagation(),!n&&u.current){const p=u.current.getBoundingClientRect();l({top:p.bottom+4,right:window.innerWidth-p.right})}r(!n)};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:u,type:"button",onClick:d,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&i.jsx(I$,{children:i.jsx("div",{ref:c,onMouseDown:f=>f.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:a.top,right:a.right},children:e.map(f=>i.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(f)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:f},f))})})]})}function $$({messages:e,onCancel:t}){return e.length===0?null:i.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>i.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:[i.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),i.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),i.jsx(Yl,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function z$({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,onView:a,onEdit:l,onDuplicate:u,onDelete:c,onCancelDelete:d}){const f=e.allowedTools.filter(p=>!(r!=null&&r.has(p)));return i.jsxs(E1,{isBuiltIn:t,isConfirmingDelete:n,onView:a,onEdit:l,onDuplicate:u,onDelete:c,onCancelDelete:d,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),i.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),i.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&i.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&&i.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),i.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[f.slice(0,5).map(p=>i.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:p},p)),f.length>5&&i.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",f.length-5," more"]})]})]})}function zS({title:e,agents:t,subagents:n,isBuiltIn:r,alwaysAllowedNames:a,onView:l,onDuplicate:u,onEdit:c,onDelete:d,onCancelDelete:f,isConfirmingDelete:p}){if(t.length===0&&n.length===0)return null;const m=x=>i.jsx(z$,{agent:x,isBuiltIn:r,isConfirmingDelete:(p==null?void 0:p(x.id))??!1,alwaysAllowedNames:a,onView:()=>l(x.id),onEdit:r?void 0:()=>c==null?void 0:c(x.id),onDuplicate:()=>u(x.id),onDelete:r?void 0:()=>d==null?void 0:d(x.id),onCancelDelete:r?void 0:()=>f==null?void 0:f(x.id)},x.id);return i.jsxs("div",{children:[i.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),i.jsxs("div",{className:"space-y-2",children:[t.map(m),n.length>0&&i.jsxs("div",{className:"mt-3",children:[i.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:"Sub-agents"}),i.jsx("div",{className:"space-y-2",children:n.map(m)})]})]})]})}function H$(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const a=n.slice(0,r),u=n.slice(r+1).split(",").filter(Boolean);t.set(a,new Set(u))}}return t}function ep(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function U$({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:l,formPrompt:u,formError:c,saving:d,isReadOnly:f,availableTools:p,onNameChange:m,onIdChange:x,onDescriptionChange:y,onSubagentChange:w,onToolsChange:C,onColorChange:_,onPromptChange:S,onSave:b,onCancel:v,onDuplicate:E}){const j=H$(a),T=p.filter(O=>!(r&&O.topLevelOnly)),D=(O,M)=>{const W=new Map(j),z=W.get(O)||new Set,R=new Set(z);R.has(M)?R.delete(M):R.add(M),R.size===0?W.set(O,new Set):W.set(O,R),C(ep(W))},L=O=>{const M=new Map(j);M.has(O)?M.delete(O):M.set(O,new Set),C(ep(M))};return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"space-y-3",children:[c&&i.jsx(Ka,{message:c}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(Cr,{label:"Name",value:e,onChange:m,placeholder:"My Agent",readOnly:f}),i.jsx(Cr,{label:"ID",value:t,onChange:x,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(Cr,{label:"Description",value:n,onChange:y,placeholder:"What this agent does",readOnly:f}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),i.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[i.jsx("button",{onClick:()=>!f&&w(!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"} ${f?"pointer-events-none opacity-60":""}`,children:"Agent"}),i.jsx("button",{onClick:()=>!f&&w(!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"} ${f?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),i.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),i.jsx("input",{type:"color",value:l,onChange:O=>!f&&_(O.target.value),disabled:f,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),i.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:T.map(O=>{const M=j.has(O.name),W=O.actions.length>0,z=j.get(O.name)||new Set;return W?f?i.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:[i.jsx("span",{children:O.name}),i.jsx("span",{className:"text-[10px]",children:"*"})]},O.name):i.jsx(Kl,{trigger:i.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${M?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[i.jsx("span",{children:O.name}),W&&i.jsx("span",{className:`text-[10px] ${M&&z.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]}),minWidth:"160px",items:[...O.actions.map(R=>({label:i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${O.name}-${R}`,children:[i.jsx("input",{type:"checkbox",id:`${O.name}-${R}`,checked:z.has(R),onChange:()=>D(O.name,R),disabled:f,className:"w-3 h-3 rounded accent-accent-primary"}),i.jsx("span",{children:R})]}),closeOnClick:!1})),{label:M?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(M)L(O.name);else{const R=new Map(j);R.set(O.name,new Set(O.actions)),C(ep(R))}}}]},O.name):i.jsx("button",{onClick:()=>!f&&L(O.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${M?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${f?"pointer-events-none":"cursor-pointer"}`,children:i.jsx("span",{children:O.name})},O.name)})})]})]}),i.jsxs("div",{className:"flex-1 min-h-[150px] border-t border-border pt-3 flex flex-col",children:[i.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),i.jsx("textarea",{value:u,onChange:O=>!f&&S(O.target.value),readOnly:f,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 ${f?"opacity-60":""}`})]}),i.jsx(nT,{onCancel:v,onSave:b,saving:d,saveDisabled:!e||!u||f}),f&&i.jsx("div",{className:"flex justify-end mt-2",children:i.jsx("button",{onClick:E,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 F$(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function V$({isOpen:e,onClose:t,initialEditId:n}){const r=mt(de=>de.defaults),a=mt(de=>de.userItems),l=mt(de=>de.loading),u=mt(de=>de.fetchAgents),c=mt(de=>de.fetchAgent),d=mt(de=>de.fetchDefaultContent),f=mt(de=>de.createAgent),p=mt(de=>de.updateAgent),m=mt(de=>de.deleteAgent),[x,y]=A.useState("list"),[w,C]=A.useState(null),[_,S]=A.useState(!1),[b,v]=A.useState(""),[E,j]=A.useState(""),[T,D]=A.useState(""),[L,O]=A.useState(!0),[M,W]=A.useState([]),[z,R]=A.useState("#6b7280"),[P,V]=A.useState(""),[G,Z]=A.useState(""),[Q,U]=A.useState(!1),[I,$]=A.useState([]),[q,B]=A.useState(new Set),{requestDelete:ee,clearConfirm:X,isConfirming:ne}=Hl(),K=de=>{v(de.metadata.name),j(de.metadata.id),D(de.metadata.description),O(de.metadata.subagent),W(de.metadata.allowedTools),R(de.metadata.color??"#6b7280"),V(de.prompt),Z("")},F=(de,$e,He)=>{v(de.metadata.name+" (copy)"),j(`${$e}-copy-${Date.now()}`),D(de.metadata.description),O(de.metadata.subagent),W(de.metadata.allowedTools),R(de.metadata.color??"#6b7280"),V(de.prompt),Z(""),C(null),S(!1),y("edit")},te=(de,$e)=>{K(de),C($e),S(!0),y("edit")};A.useEffect(()=>{e&&(u(),we("/api/tools").then(de=>de.json()).then(de=>{const $e=de.tools||[];B(new Set($e.filter(He=>He.alwaysAllowed).map(He=>He.name))),$($e.filter(He=>!He.alwaysAllowed))}).catch(()=>{$([]),B(new Set)}),n?r.some($e=>$e.id===n)?d(n).then($e=>{$e&&F($e,n)}):c(n).then($e=>{$e&&(K($e),C(n),S(!1),y("edit"))}):(y("list"),C(null),S(!1)))},[e,u,c,d,n]);const se=async de=>{if(r.some(He=>He.id===de)){const He=await d(de);if(!He)return;te(He,de)}else{const He=await c(de);if(!He)return;te(He,de)}},xe=async de=>{const $e=await d(de);$e&&F($e,de)},oe=()=>{C(null),v(""),j(""),D(""),O(!0),W(["read_file"]),R("#6b7280"),V(""),Z(""),S(!1),y("edit")},ye=async de=>{const $e=await c(de);$e&&(K($e),C(de),S(!1),y("edit"))},Le=async de=>{await m(de)},Oe=async()=>{const de=w??E;if(!de||!b||!P){Z("Name and prompt are required.");return}U(!0),Z("");const $e={metadata:{id:de,name:b,description:T,subagent:L,allowedTools:M.filter(ut=>!q.has(ut)),color:z},prompt:P},He=w?await p(w,$e):await f($e);if(U(!1),!He.success){Z(He.error??"Failed to save agent.");return}n?t():y("list")},Me=()=>{n?t():(y("list"),S(!1))},je=de=>{v(de),w||j(F$(de))},nt=r.filter(de=>de.subagent),Xe=r.filter(de=>!de.subagent),he=a.filter(de=>de.subagent),ce=a.filter(de=>!de.subagent);return x==="edit"?i.jsx(wt,{isOpen:e,onClose:Me,title:_?`${b}`:w?"Edit Agent":"New Agent",size:"xl",children:i.jsx(U$,{formName:b,formId:E,formDescription:T,formSubagent:L,formTools:M,formColor:z,formPrompt:P,formError:G,saving:Q,isReadOnly:_,availableTools:I,onNameChange:je,onIdChange:j,onDescriptionChange:D,onSubagentChange:de=>{O(de),de&&W($e=>$e.filter(He=>{var ut;return!((ut=I.find(re=>re.name===He))!=null&&ut.topLevelOnly)}))},onToolsChange:W,onColorChange:R,onPromptChange:V,onSave:Oe,onCancel:Me,onDuplicate:()=>{v(b+" (copy)"),j(`${w}-copy-${Date.now()}`),C(null),S(!1)}})}):i.jsx(wt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:i.jsx(x1,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:oe,loading:l,hasItems:r.length>0||a.length>0,children:i.jsxs("div",{className:"space-y-4",children:[r.length>0&&i.jsx(zS,{title:"Built-in",agents:Xe,subagents:nt,isBuiltIn:!0,alwaysAllowedNames:q,onView:se,onDuplicate:xe}),a.length>0&&i.jsx(zS,{title:"Custom",agents:ce,subagents:he,isBuiltIn:!1,alwaysAllowedNames:q,isConfirmingDelete:de=>ne(de,"delete"),onView:se,onDuplicate:xe,onEdit:ye,onDelete:de=>{ne(de,"delete")?(Le(de),X()):ee(de)},onCancelDelete:X})]})})})}function G$(){const e=Re(b=>{var v;return(v=b.currentSession)==null?void 0:v.mode}),t=Re(b=>b.switchMode),n=mt(b=>b.defaults),r=mt(b=>b.userItems),a=mt(b=>b.fetchAgents),l=[...n,...r],[u,c]=A.useState(!1),[d,f]=A.useState(!1),[p,m]=A.useState(null),x=A.useRef(null);A.useEffect(()=>{a()},[a]),A.useEffect(()=>{function b(v){x.current&&!x.current.contains(v.target)&&c(!1)}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]);const y=zl();if(!e)return null;const w=l.filter(b=>!b.subagent),C=w.find(b=>b.id===e),_=(C==null?void 0:C.name)??e,S=Ml(l,e);return i.jsxs("div",{className:"relative",ref:x,children:[i.jsxs("button",{type:"button",onClick:()=>c(!u),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[i.jsx("span",{className:"text-sm font-medium",style:{color:S},children:_}),i.jsx(Qn,{className:`w-3 h-3 text-text-muted transition-transform ${u?"rotate-180":""}`})]}),u&&w.length>0&&i.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:[w.map((b,v)=>{const E=b.id===e,j=Ml(l,b.id),T=y.agentSwitching[v],D=T?Fu(T):null;return i.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${E?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[i.jsxs("button",{type:"button",onClick:()=>{E||t(b.id),c(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:"font-medium truncate",style:{color:j},children:b.name}),E&&i.jsx(Ir,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),D&&i.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:D})]},b.id)}),i.jsx("div",{className:"border-t border-border p-1",children:i.jsx("button",{type:"button",onClick:()=>{c(!1),f(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),i.jsx(V$,{isOpen:d,onClose:()=>{f(!1),m(null)},initialEditId:p})]})}function W$(){const e=Re(r=>r.currentSession),t=Re(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return i.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[i.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"}),i.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 HS({value:e,onChange:t}){return i.jsxs("div",{children:[i.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",i.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),i.jsx("input",{type:"text",value:e??"",onChange:n=>t(n.target.value),className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono"})]})}const q$=[8080,11434,8e3,1234];function Up(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function qk(e){return{name:e.name,url:e.url,backend:e.backend,apiKey:e.apiKey,isLocal:e.isLocal,thinkingField:e.thinkingField,authAdapter:e.authAdapter,transportAdapter:e.transportAdapter,models:e.models}}function K$({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:l,onTestParams:u,onShowRaw:c}){var d,f,p,m,x,y,w,C,_,S,b,v,E,j,T,D,L,O,M,W,z,R,P,V,G,Z,Q,U,I,$,q,B,ee,X,ne,K,F,te,se,xe,oe,ye,Le,Oe,Me;return i.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>l(e.id),disabled:n.progress[e.id]==="probing",className:"px-4 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:n.progress[e.id]==="probing"?"Probing...":"Auto-config"}),n.progress[e.id]==="done"&&i.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&i.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),i.jsxs("div",{className:"flex gap-3 items-end",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),i.jsx("input",{type:"number",value:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:je=>a(e.id,{contextWindow:parseInt(je.target.value)||e.contextWindow}),className:"w-32 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),i.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[i.jsx("input",{type:"checkbox",checked:((f=t[e.id])==null?void 0:f.supportsVision)??!1,onChange:je=>a(e.id,{supportsVision:je.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>u(e.id,"thinking"),disabled:(p=r[e.id+"-thinking"])==null?void 0:p.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(m=r[e.id+"-thinking"])!=null&&m.loading?"Testing...":"Test thinking"}),((x=r[e.id+"-thinking"])==null?void 0:x.result)&&i.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((y=r[e.id+"-thinking"])==null?void 0:y.error)&&i.jsx("span",{className:"text-xs text-red-500",title:(w=r[e.id+"-thinking"])==null?void 0:w.error,children:"Fail"}),((C=r[e.id+"-thinking"])==null?void 0:C.result)&&i.jsx("button",{onClick:()=>c(r[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>u(e.id,"non-thinking"),disabled:(_=r[e.id+"-non-thinking"])==null?void 0:_.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(S=r[e.id+"-non-thinking"])!=null&&S.loading?"Testing...":"Test non-thinking"}),((b=r[e.id+"-non-thinking"])==null?void 0:b.result)&&i.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((v=r[e.id+"-non-thinking"])==null?void 0:v.error)&&i.jsx("span",{className:"text-xs text-red-500",title:(E=r[e.id+"-non-thinking"])==null?void 0:E.error,children:"Fail"}),((j=r[e.id+"-non-thinking"])==null?void 0:j.result)&&i.jsx("button",{onClick:()=>c(r[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),i.jsxs("details",{className:"group",children:[i.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[i.jsx(Qn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),i.jsxs("div",{className:"mt-3 space-y-2",children:[i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:((T=t[e.id])==null?void 0:T.thinkingEnabled)??!1,onChange:je=>a(e.id,{thinkingEnabled:je.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),i.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((D=t[e.id])==null?void 0:D.thinkingEnabled)&&i.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),(L=e.reasoningEfforts)!=null&&L.length?i.jsx("select",{"aria-label":"Reasoning effort",value:((O=t[e.id])==null?void 0:O.thinkingLevel)??Up(e.reasoningEfforts),onChange:je=>a(e.id,{thinkingLevel:je.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary",children:e.reasoningEfforts.map(je=>i.jsx("option",{value:je,children:je},je))}):i.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((M=t[e.id])==null?void 0:M.thinkingLevel)??"",onChange:je=>a(e.id,{thinkingLevel:je.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),i.jsx(HS,{value:(W=t[e.id])==null?void 0:W.thinkingQueryParams,onChange:je=>a(e.id,{thinkingQueryParams:je})})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:((z=t[e.id])==null?void 0:z.nonThinkingEnabled)??!1,onChange:je=>a(e.id,{nonThinkingEnabled:je.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),i.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((R=t[e.id])==null?void 0:R.nonThinkingEnabled)&&i.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:i.jsx(HS,{value:(P=t[e.id])==null?void 0:P.nonThinkingQueryParams,onChange:je=>a(e.id,{nonThinkingQueryParams:je})})})]}),i.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Temperature"}),i.jsx("input",{type:"number",step:"0.1",value:((V=t[e.id])==null?void 0:V.temperature)??"",onChange:je=>a(e.id,{temperature:je.target.value?parseFloat(je.target.value):void 0}),placeholder:((Z=(G=t[e.id])==null?void 0:G.defaultTemperature)==null?void 0:Z.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((Q=t[e.id])==null?void 0:Q.defaultTemperature)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(U=t[e.id])==null?void 0:U.defaultTemperature]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top P"}),i.jsx("input",{type:"number",step:"0.05",value:((I=t[e.id])==null?void 0:I.topP)??"",onChange:je=>a(e.id,{topP:je.target.value?parseFloat(je.target.value):void 0}),placeholder:((q=($=t[e.id])==null?void 0:$.defaultTopP)==null?void 0:q.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((B=t[e.id])==null?void 0:B.defaultTopP)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(ee=t[e.id])==null?void 0:ee.defaultTopP]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top K"}),i.jsx("input",{type:"number",value:((X=t[e.id])==null?void 0:X.topK)??"",onChange:je=>a(e.id,{topK:je.target.value?parseInt(je.target.value):void 0}),placeholder:((K=(ne=t[e.id])==null?void 0:ne.defaultTopK)==null?void 0:K.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((F=t[e.id])==null?void 0:F.defaultTopK)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(te=t[e.id])==null?void 0:te.defaultTopK]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Max tokens"}),i.jsx("input",{type:"number",value:((se=t[e.id])==null?void 0:se.maxTokens)??"",onChange:je=>a(e.id,{maxTokens:je.target.value?parseInt(je.target.value):void 0}),placeholder:((oe=(xe=t[e.id])==null?void 0:xe.defaultMaxTokens)==null?void 0:oe.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((ye=t[e.id])==null?void 0:ye.defaultMaxTokens)!==void 0&&i.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Le=t[e.id])==null?void 0:Le.defaultMaxTokens]})]})]})]}),i.jsx("div",{className:"pt-3 border-t border-border",children:i.jsx(Y$,{value:(Oe=t[e.id])==null?void 0:Oe.compactionThreshold,maxTokens:((Me=t[e.id])==null?void 0:Me.contextWindow)??e.contextWindow,onChange:je=>a(e.id,{compactionThreshold:je})})})]})]})}function Y$({value:e,maxTokens:t,onChange:n}){const l=Math.min(95,Math.floor((t-5e3)/t*100)),u=Math.min(l,Math.ceil(15e3/t*100)),c=Math.min(e??.85,l/100),[d,f]=A.useState(Math.round(c*100));A.useEffect(()=>{const m=Math.min(e??.85,l/100);f(Math.round(m*100))},[e,l]);const p=Math.floor(t*(d/100));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[i.jsx("label",{className:"text-xs text-text-secondary",children:"Auto-compaction threshold"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"font-mono text-xs text-text-primary",children:[d,"% · ",eo(p)]}),i.jsx("button",{type:"button",onClick:()=>{n(void 0),f(Math.round(.85*100))},disabled:e===void 0,className:"text-xs text-accent-primary hover:underline disabled:text-text-muted disabled:no-underline",children:"Default"})]})]}),i.jsx("input",{"aria-label":"Auto-compaction threshold",type:"range",min:u,max:l,step:"1",value:d,onChange:m=>f(Number(m.target.value)),onMouseUp:()=>n(d/100),onTouchEnd:()=>n(d/100),onBlur:()=>n(d/100),onKeyUp:()=>n(d/100),className:"w-full"}),i.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Minimum ",eo(15e3)," tokens · maximum ",l,"% · default 85%"]})]})}function Kk({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:l}){const[u,c]=A.useState(r),[d,f]=A.useState(""),[p,m]=A.useState(""),[x,y]=A.useState("unknown"),[w,C]=A.useState(""),[_,S]=A.useState(!1),[b,v]=A.useState(),[E,j]=A.useState(),[T,D]=A.useState(!1),[L,O]=A.useState(null),[M,W]=A.useState([]),[z,R]=A.useState(null),[P,V]=A.useState(!1),[G,Z]=A.useState(""),[Q,U]=A.useState({}),[I,$]=A.useState({loading:!1,progress:{}}),[q,B]=A.useState({}),[ee,X]=A.useState(null),[ne,K]=A.useState(new Set),[F,te]=A.useState(""),[se,xe]=A.useState(null),[oe,ye]=A.useState("disconnected"),[Le,Oe]=A.useState(!1),[Me,je]=A.useState(null),[nt,Xe]=A.useState([]),[he,ce]=A.useState(!1),[de,$e]=A.useState(!1),He=A.useRef(null),ut=A.useRef(!1),re=A.useRef(null);A.useEffect(()=>{u===1&&e&&requestAnimationFrame(()=>{var _e;return(_e=re.current)==null?void 0:_e.focus()})},[u,e]),A.useEffect(()=>()=>{He.current!==null&&window.clearTimeout(He.current)},[]),A.useEffect(()=>{e&&we("/api/provider-presets").then(async _e=>_e.ok?await _e.json():{presets:[]}).then(_e=>Xe(_e.presets)).catch(()=>Xe([]))},[e]);function be(_e,Fe){U(ae=>({...ae,[_e]:{...ae[_e],...Fe}}))}function ke(_e){K(Fe=>new Set(Fe).add(_e.id)),U(Fe=>({...Fe,[_e.id]:{contextWindow:_e.contextWindow,...Fe[_e.id]}}))}function ze(_e){if(!_e.trim())return M;const Fe=_e.toLowerCase().split(/\s+/).filter(Boolean);return M.filter(ae=>Fe.every(fe=>ae.id.toLowerCase().includes(fe)))}A.useEffect(()=>{var _e,Fe;if(e)if(c(r),f((a==null?void 0:a.name)??""),m((a==null?void 0:a.url)??""),y((a==null?void 0:a.backend)??"unknown"),C((a==null?void 0:a.apiKey)??""),S((a==null?void 0:a.isLocal)??!1),v(a==null?void 0:a.authAdapter),j(a==null?void 0:a.transportAdapter),O(null),Z((a==null?void 0:a.thinkingField)??""),B({}),X(null),xe(null),ye("disconnected"),je(null),ce(!1),$e(!1),(_e=a==null?void 0:a.models)!=null&&_e.length){const ae={},fe=new Set;for(const Ie of a.models)ae[Ie.id]={contextWindow:Ie.contextWindow,supportsVision:Ie.supportsVision,thinkingEnabled:Ie.thinkingEnabled,thinkingLevel:Ie.thinkingLevel??Up(Ie.reasoningEfforts),nonThinkingEnabled:Ie.nonThinkingEnabled,thinkingQueryParams:Ie.thinkingQueryParams,nonThinkingQueryParams:Ie.nonThinkingQueryParams,defaultTemperature:Ie.defaultTemperature,defaultTopP:Ie.defaultTopP,defaultTopK:Ie.defaultTopK,defaultMaxTokens:Ie.defaultMaxTokens,temperature:Ie.temperature,topP:Ie.topP,topK:Ie.topK,maxTokens:Ie.maxTokens,compactionThreshold:Ie.compactionThreshold},Ie.selected&&fe.add(Ie.id);if(fe.size===0)for(const Ie of a.models)fe.add(Ie.id);K(fe),U(ae),W(a.models),R(l??((Fe=a.models[0])==null?void 0:Fe.id)??null)}else W([]),U({}),R(null),K(new Set)},[e,r,a==null?void 0:a.id,l]),A.useEffect(()=>{const _e=!!b;u===2&&p&&M.length===0&&!T&&!L&&(!_e||oe==="connected")&&qt(p)},[u,oe]),A.useEffect(()=>{!e||!b||!(a!=null&&a.id)||We(a.id)},[e,E,a==null?void 0:a.id]),A.useEffect(()=>{if(!Me)return;const _e=(a==null?void 0:a.id)??se;if(!_e)return;let Fe=!1;const ae=async()=>{const Ie=await We(_e);Fe||Ie!=="connected"||(je(null),ce(!1),$e(!1),await qt(p))};ae();const fe=window.setInterval(()=>void ae(),2e3);return()=>{Fe=!0,window.clearInterval(fe)}},[Me,se,a==null?void 0:a.id]);async function Ye(){if(a!=null&&a.id)return a.id;if(se)return se;const _e=await we("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:p,backend:x,authAdapter:b,transportAdapter:E,isLocal:!1,models:[]})});if(!_e.ok)throw new Error("Unable to create provider");const Fe=await _e.json();return xe(Fe.provider.id),Fe.provider.id}async function We(_e){const Fe=await we(`/api/provider-auth/${_e}/status`);if(!Fe.ok)return"error";const ae=await Fe.json(),fe=ae.state==="connected"?"connected":ae.state==="pending"?"pending":ae.state==="error"?"error":"disconnected";return ye(fe),fe}async function tt(){Oe(!0),ye("pending");try{const _e=await Ye(),Fe=await we(`/api/provider-auth/${_e}/login`,{method:"POST"});if(!Fe.ok)throw new Error("Unable to start provider sign-in");const ae=await Fe.json();je(ae)}catch{ye("error")}finally{Oe(!1)}}async function _t(){var _e;Me!=null&&Me.userCode&&(await((_e=navigator.clipboard)==null?void 0:_e.writeText(Me.userCode)),He.current!==null&&window.clearTimeout(He.current),$e(!1),requestAnimationFrame(()=>$e(!0)),He.current=window.setTimeout(()=>{$e(!1),He.current=null},1500))}function It(){Me&&(window.open(Me.directUrl??Me.verificationUrl,"_blank","noopener,noreferrer"),ce(!0))}async function qt(_e){var Fe,ae;D(!0),O(null),W([]);try{const fe=new URLSearchParams({url:_e});w&&fe.set("apiKey",w),x&&fe.set("backend",x);const Ie=E?await we(`/api/providers/${await Ye()}/models`):await we(`/api/providers/models?${fe.toString()}`);if(Ie.ok){const gt=await Ie.json();if((Fe=gt.models)!=null&&Fe.length){W(gt.models),R(((ae=gt.models[0])==null?void 0:ae.id)??null);const bn={};for(const rn of gt.models)bn[rn.id]={contextWindow:rn.contextWindow,thinkingEnabled:!0,thinkingLevel:Up(rn.reasoningEfforts),defaultTemperature:rn.defaultTemperature,defaultTopP:rn.defaultTopP,defaultTopK:rn.defaultTopK,defaultMaxTokens:rn.defaultMaxTokens};U(bn),gt.models.length===1&&(K(new Set([gt.models[0].id])),R(gt.models[0].id),dt(gt.models[0].id))}}else{const gt=await Ie.json();O(gt.error??`Failed to fetch models from ${_e}`)}}catch(fe){O(`Failed to fetch models from ${_e}: ${fe instanceof Error?fe.message:"Unknown error"}`)}D(!1)}async function dt(_e){$(Fe=>({loading:!0,progress:{...Fe.progress,[_e]:"probing"}}));try{const Fe=await we("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,apiKey:w||void 0,backend:x||"unknown",models:[{id:_e}]})});if(!Fe.ok){const fe=await Fe.json();throw new Error(fe.error??"Auto-config failed")}const ae=await Fe.json();for(const fe of ae.models){const Ie={};fe.contextSource!=="default"&&(Ie.contextWindow=fe.contextWindow,Ie.supportsVision=fe.supportsVision),fe.thinkingConfig&&(Ie.thinkingEnabled=!0,Ie.thinkingQueryParams=JSON.stringify(fe.thinkingConfig)),fe.nonThinkingConfig&&(Ie.nonThinkingEnabled=!0,Ie.nonThinkingQueryParams=JSON.stringify(fe.nonThinkingConfig)),be(fe.id,Ie),$(gt=>({...gt,progress:{...gt.progress,[fe.id]:"done"}}))}}catch(Fe){console.error("Auto-config error:",Fe),$(ae=>({...ae,progress:{...ae.progress,[_e]:"error"}}))}finally{$(Fe=>({...Fe,loading:!1}))}}async function Cn(_e,Fe){const ae=_e+"-"+Fe;B(fe=>({...fe,[ae]:{loading:!0}}));try{const fe=Q[_e],Ie=await we("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,providerId:(a==null?void 0:a.id)??se??void 0,transportAdapter:E,model:_e,apiKey:w||void 0,backend:x||"unknown",thinkingField:G||void 0,mode:Fe,modelConfig:{temperature:fe==null?void 0:fe.temperature,topP:fe==null?void 0:fe.topP,topK:fe==null?void 0:fe.topK,maxTokens:fe==null?void 0:fe.maxTokens,supportsVision:fe==null?void 0:fe.supportsVision,thinkingEnabled:fe==null?void 0:fe.thinkingEnabled,thinkingLevel:fe==null?void 0:fe.thinkingLevel,nonThinkingEnabled:fe==null?void 0:fe.nonThinkingEnabled,thinkingQueryParams:fe==null?void 0:fe.thinkingQueryParams,nonThinkingQueryParams:fe==null?void 0:fe.nonThinkingQueryParams}})}),gt=await Ie.json();Ie.ok?B(bn=>({...bn,[ae]:{loading:!1,result:JSON.stringify(gt,null,2),message:gt.message}})):B(bn=>({...bn,[ae]:{loading:!1,error:gt.error??"Test failed"}}))}catch(fe){B(Ie=>({...Ie,[ae]:{loading:!1,error:fe instanceof Error?fe.message:"Request failed"}}))}}function jt(){W([]),U({}),$({loading:!1,progress:{}}),B({}),X(null),K(new Set),te("")}function Jt(){se&&!ut.current&&we(`/api/providers/${se}`,{method:"DELETE"}).catch(_e=>{console.warn("Failed to clean up draft provider",_e)}),t()}function Mr(){const _e=d||"Provider",Fe=(a==null?void 0:a.id)??se??`temp-${Date.now()}`;n({id:Fe,name:_e,url:p,backend:x||"unknown",apiKey:w||void 0,isLocal:_,thinkingField:G||void 0,authAdapter:b,transportAdapter:E,models:M.map(ae=>{var fe,Ie,gt,bn,rn,Ce,Te,Ue,qe,at,et,xt,sn,Zt,Wt,an;return{id:ae.id,name:ae.name,apiModelId:ae.apiModelId,requestBody:ae.requestBody,reasoningEfforts:ae.reasoningEfforts,contextWindow:((fe=Q[ae.id])==null?void 0:fe.contextWindow)??ae.contextWindow,selected:ne.has(ae.id)||void 0,supportsVision:(Ie=Q[ae.id])==null?void 0:Ie.supportsVision,thinkingEnabled:(gt=Q[ae.id])==null?void 0:gt.thinkingEnabled,thinkingLevel:(bn=Q[ae.id])==null?void 0:bn.thinkingLevel,nonThinkingEnabled:(rn=Q[ae.id])==null?void 0:rn.nonThinkingEnabled,thinkingQueryParams:(Ce=Q[ae.id])==null?void 0:Ce.thinkingQueryParams,nonThinkingQueryParams:(Te=Q[ae.id])==null?void 0:Te.nonThinkingQueryParams,temperature:(Ue=Q[ae.id])==null?void 0:Ue.temperature,topP:(qe=Q[ae.id])==null?void 0:qe.topP,topK:(at=Q[ae.id])==null?void 0:at.topK,maxTokens:(et=Q[ae.id])==null?void 0:et.maxTokens,defaultMaxTokens:(xt=Q[ae.id])==null?void 0:xt.defaultMaxTokens,defaultTemperature:(sn=Q[ae.id])==null?void 0:sn.defaultTemperature,defaultTopP:(Zt=Q[ae.id])==null?void 0:Zt.defaultTopP,defaultTopK:(Wt=Q[ae.id])==null?void 0:Wt.defaultTopK,compactionThreshold:(an=Q[ae.id])==null?void 0:an.compactionThreshold}})}),ut.current=!0,t()}return e?i.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:[i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] overflow-y-auto shadow-2xl",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[i.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:a?"Edit Provider":"Add Provider"}),i.jsx("button",{onClick:Jt,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2].map(_e=>i.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${_e<u?"bg-accent-success":_e===u?"bg-accent-primary":"bg-border"}`},_e))}),u===1&&i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Inference engine"}),i.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[nt.map(_e=>i.jsx("button",{type:"button",onClick:()=>{f(_e.defaults.name??_e.name),m(_e.defaults.url),y(_e.defaults.backend),S(!1),C(""),v(_e.authAdapter),j(_e.transportAdapter),O(null),jt()},className:`p-2 rounded border text-center text-sm transition-colors ${E&&E===_e.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:_e.name},_e.id)),i.jsx("button",{type:"button",onClick:()=>{y("unknown"),S(!1),v(void 0),j(void 0),O(null),jt()},className:`p-2 rounded border text-center text-sm transition-colors ${x==="unknown"?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:"Other"},"other"),q$.map(_e=>{const Fe={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},ae={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return i.jsx("button",{type:"button",onClick:()=>{f(fe=>fe||(ae[_e]??"")),m(fe=>fe||`http://localhost:${_e}`),y(Fe[_e]??""),S(!0),v(void 0),j(void 0),O(null),jt()},className:`p-2 rounded border text-center text-sm transition-colors ${x===Fe[_e]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:ae[_e]??`localhost:${_e}`},_e)})]})]}),!b&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),i.jsx("input",{ref:re,type:"text",value:p,"data-testid":"provider-modal-url",onChange:_e=>{m(_e.target.value),O(null),W([]),U({})},placeholder:"http://localhost:8000",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),i.jsx("input",{type:"text",autoComplete:"off",value:d,onChange:_e=>f(_e.target.value),placeholder:"My LLM Server",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!b&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",i.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),i.jsx("input",{type:"text",autoComplete:"off",value:w,onChange:_e=>C(_e.target.value),placeholder:"sk-...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),!b&&i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:_,onChange:_e=>S(_e.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),i.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),u===2&&i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[!!b&&i.jsxs("div",{className:"rounded-lg border border-border bg-bg-primary p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Connect provider"}),i.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Connect this provider before choosing available models."})]}),oe==="connected"?i.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):i.jsx("button",{type:"button",onClick:()=>void tt(),disabled:Le||oe==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:Le||oe==="pending"?"Connecting...":oe==="error"?"Retry":"Connect"})]}),Me&&i.jsx("div",{className:"mt-4 border-t border-border pt-4",children:Me.mode!=="browser"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-xs text-text-muted",children:"Use this code to complete authorization:"}),i.jsx("button",{type:"button",onClick:()=>void _t(),className:"mt-3 w-full rounded-lg border border-accent-primary/40 px-4 py-4 font-mono text-2xl font-semibold tracking-[0.2em] text-accent-primary",children:Me.userCode??"Continue"}),i.jsxs("div",{className:"mt-3 flex gap-2",children:[i.jsx("button",{type:"button",onClick:()=>void _t(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:de?"Copied":"Copy code"}),i.jsx("button",{type:"button",onClick:It,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:he?"Reopen authorization":"Open authorization"})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-xs text-text-muted mb-3",children:Me.instructions}),i.jsx("button",{type:"button",onClick:It,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:he?"Reopen authorization":"Open authorization"})]})})]}),T&&i.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[i.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),L&&i.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[i.jsx("p",{children:L}),i.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",p]}),i.jsxs("div",{className:"flex gap-2 mt-2",children:[i.jsx("button",{onClick:()=>qt(p),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),i.jsx("button",{onClick:()=>{jt(),c(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"})]})]}),M.length>0&&x&&(!b||oe==="connected")&&i.jsxs(i.Fragment,{children:[ne.size>0&&i.jsxs("div",{className:"mb-4",children:[i.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",ne.size,")"]}),i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),i.jsx("div",{className:"space-y-2",children:M.filter(_e=>ne.has(_e.id)).map(_e=>{var Fe;return i.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[i.jsxs("div",{onClick:()=>R(z===_e.id?null:_e.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("span",{className:"text-sm font-medium text-text-primary",children:_e.name??_e.id.split("/").pop()}),i.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((Fe=Q[_e.id])==null?void 0:Fe.contextWindow)??_e.contextWindow).toLocaleString()," ctx"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[I.progress[_e.id]==="probing"?i.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):I.progress[_e.id]==="done"?i.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):I.progress[_e.id]==="error"?i.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):b?null:i.jsx("button",{onClick:ae=>{ae.stopPropagation(),dt(_e.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),M.length>1&&i.jsx("button",{onClick:ae=>{ae.stopPropagation();const fe=new Set(ne);fe.delete(_e.id),K(fe),z===_e.id&&R(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),i.jsx(Qn,{className:`w-4 h-4 text-text-muted transition-transform ${z===_e.id?"rotate-180":""}`})]})]}),z===_e.id&&i.jsx(K$,{model:_e,modelConfigs:Q,autoConfigState:I,testResults:q,onUpdateConfig:be,onRunAutoConfig:dt,onTestParams:Cn,onShowRaw:X})]},_e.id)})})]}),M.length>1&&i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),ne.size===0&&i.jsx("p",{className:"text-xs text-text-muted mb-2",children:"This provider has many models available. Select the ones you want to use below."}),i.jsxs("div",{className:"relative mb-2",children:[i.jsx("input",{type:"text",value:F,onChange:_e=>te(_e.target.value),placeholder:"Search models...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),F&&i.jsx("button",{onClick:()=>te(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",ze(F).length," of ",M.length," models"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:()=>{const _e=new Set(ne),Fe=ze(F);for(const ae of Fe)_e.add(ae.id);if(K(_e),U(ae=>{const fe={...ae};for(const Ie of Fe)fe[Ie.id]={contextWindow:Ie.contextWindow,...fe[Ie.id]};return fe}),!b)for(const ae of Fe)I.progress[ae.id]!=="probing"&&I.progress[ae.id]!=="done"&&dt(ae.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),i.jsx("button",{onClick:()=>{const _e=new Set(ne),Fe=ze(F);for(const ae of Fe)_e.delete(ae.id);K(_e)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),i.jsxs("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-border rounded-lg bg-bg-primary",children:[ze(F).map(_e=>{var ae;const Fe=ne.has(_e.id);return i.jsxs("div",{role:"checkbox","aria-checked":Fe,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${Fe?"bg-accent-primary/5":""}`,onClick:()=>{if(Fe){const fe=new Set(ne);fe.delete(_e.id),K(fe)}else ke(_e),b||dt(_e.id)},onKeyDown:fe=>{(fe.key==="Enter"||fe.key===" ")&&(fe.preventDefault(),fe.currentTarget.click())},children:[i.jsx("input",{type:"checkbox",checked:Fe,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),i.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:_e.name??_e.id.split("/").pop()}),i.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((ae=Q[_e.id])==null?void 0:ae.contextWindow)??_e.contextWindow).toLocaleString()," ctx"]}),I.progress[_e.id]==="probing"&&i.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),I.progress[_e.id]==="done"&&i.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),I.progress[_e.id]==="error"&&i.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},_e.id)}),ze(F).length===0&&i.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",F,"”"]})]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[i.jsx("div",{children:u>1&&i.jsx("button",{onClick:()=>{u===2&&jt(),c(u-1)},className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{onClick:Jt,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),u===1?i.jsx("button",{onClick:()=>c(2),disabled:!p,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:"Next — Test & Configure"}):i.jsx("button",{onClick:Mr,disabled:I.loading,"data-testid":"provider-modal-save",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:I.loading?"Configuring...":"Save Provider"})]})]})]}),P&&i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:_e=>{_e.target===_e.currentTarget&&V(!1)},children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[i.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),i.jsx("button",{onClick:()=>V(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsxs("div",{className:"px-6 py-4 space-y-4",children:[i.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),i.jsx("input",{type:"text",defaultValue:'{"chat_template_kwargs":{"enable_thinking":false}}',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),i.jsx("input",{type:"text",defaultValue:'reasoning_effort: "low"',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",i.jsx("span",{className:"text-text-muted",children:"(override)"})]}),i.jsx("input",{type:"text",value:G,onChange:_e=>Z(_e.target.value),placeholder:"Leave blank for auto-detect",className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-primary font-mono"}),i.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Field name the backend uses for reasoning/thinking content (e.g. reasoning, reasoning_content, thinking)."})]})]}),i.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:i.jsx("button",{onClick:()=>V(!1),className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Done"})})]})}),ee&&i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:_e=>{_e.target===_e.currentTarget&&X(null)},children:i.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[i.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),i.jsx("button",{onClick:()=>X(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),i.jsx("pre",{className:"px-6 py-4 overflow-y-auto text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:ee})]})})]}):null}function X$(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function Q$(e,t){const n=t.toLowerCase(),r=(e.name??"").toLowerCase(),a=e.id.toLowerCase(),l=a.replace(/-/g," ");return r.includes(n)||a.includes(n)||l.includes(n)}function US({activeProvider:e,shortModelName:t}){return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-accent-primary",children:e?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"hidden sm:inline",children:[e.name," • "]}),t]}):t}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${e!=null&&e.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:e!=null&&e.isLocal?"local":"api"})]})}function J$({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:l,settingDefault:u,highlighted:c,onModelClick:d,onSetDefault:f,onEditModel:p}){var m;return i.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm transition-colors group ${c?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${a?"opacity-50 cursor-wait":""} ${n?"text-accent-primary":"text-text-secondary"}`,children:[i.jsx("button",{type:"button",onClick:()=>d(e,t.id),disabled:a,className:"flex-1 truncate text-left",children:t.name??((m=t.id.split("/").pop())==null?void 0:m.replace(/-/g," "))??t.id}),i.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[i.jsx("span",{className:"text-xs text-text-muted",children:X$(t.contextWindow)}),l&&i.jsx("button",{type:"button",onClick:x=>f(x,e,t.id),disabled:u,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:r?"Default model":"Set as default model",children:r?i.jsx(f1,{className:"w-3.5 h-3.5 text-accent-warning"}):i.jsx(m1,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),i.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),p(e,t)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:i.jsx(u1,{className:"w-3 h-3 text-text-muted"})}),n&&i.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:i.jsx(Ir,{className:"w-3.5 h-3.5"})})]})]})}function Z$(){var Fe;const[,e]=zn(),t=Re(ae=>ae.currentSession),n=Re(ae=>ae.setSessionProvider),[r,a]=A.useState(!1),[l,u]=A.useState([]),[c,d]=A.useState(null),f=A.useRef(null),[p,m]=A.useState(null),[x,y]=A.useState(!1),[w,C]=A.useState({}),[_,S]=A.useState(null),[b,v]=A.useState(null),[E,j]=A.useState(!1),T=A.useRef(null),[D,L]=A.useState(!1),O=A.useRef(new Set),[M,W]=A.useState(-1),z=A.useRef(null),R=Qt(ae=>ae.providers),P=Qt(ae=>ae.activeProviderId),V=Qt(ae=>ae.defaultModelSelection),G=Qt(ae=>ae.activating),Z=Qt(ae=>ae.activateProvider),Q=Qt(ae=>ae.refreshModel),U=Qt(ae=>ae.refreshProviderModels),I=Qt(ae=>ae.setDefaultModel),$=Qt(ae=>ae.fetchConfig),q=zl();jl(q.modelSelector,()=>a(ae=>!ae));const B=(t==null?void 0:t.providerId)??null,ee=(t==null?void 0:t.providerModel)??null,X=(V==null?void 0:V.split("/")[0])??null,ne=(V==null?void 0:V.split("/").slice(1).join("/"))??null,K=B??X,F=ee??ne,te=F?((Fe=F.split("/").pop())==null?void 0:Fe.replace(/-/g," "))??F:"No model",[se,xe]=A.useState(!1),[oe,ye]=A.useState(""),Le=A.useRef(null);A.useEffect(()=>{function ae(fe){f.current&&!f.current.contains(fe.target)&&(a(!1),u([]),O.current=new Set)}return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[]),A.useEffect(()=>()=>{T.current!==null&&window.clearTimeout(T.current)},[]),A.useEffect(()=>{r||(ye(""),W(-1))},[r]),A.useEffect(()=>{var ae;r&&((ae=Le.current)==null||ae.focus())},[r]),A.useEffect(()=>{M>=0&&z.current&&z.current.scrollIntoView({block:"nearest"})},[M]),A.useEffect(()=>{if(r){const ae=R.map(fe=>fe.id);u(ae),R.filter(fe=>!!fe.authAdapter).forEach(fe=>void He(fe.id)),ae.forEach(fe=>{O.current.has(fe)||(O.current.add(fe),Xe(fe))})}},[r,R]),A.useEffect(()=>{if(!b)return;let ae=!1;const fe=async()=>{const gt=await He(b.providerId);ae||gt==="connected"&&(v(null),j(!1),L(!1),await $(),O.current.delete(b.providerId),await Xe(b.providerId))};fe();const Ie=window.setInterval(()=>void fe(),2e3);return()=>{ae=!0,window.clearInterval(Ie)}},[b]);const Oe=R.find(ae=>ae.id===K),Me=(Oe==null?void 0:Oe.status)==="disconnected",je=(ae,fe)=>t?t.providerId===ae&&t.providerModel===fe:!1,nt=(ae,fe)=>V?V===`${ae}/${fe}`:!1,Xe=async ae=>{d(ae);try{await U(ae)}catch{}finally{d(null)}},he=ae=>{l.includes(ae.id)?u(l.filter(fe=>fe!==ae.id)):(u([...l,ae.id]),Xe(ae.id))},ce=async ae=>{if(ae.id===P){he(ae);return}t?(n(ae.id,void 0),a(!1),u([])):await Z(ae.id)&&(a(!1),u([]))},de=ae=>{he(ae)},$e=async(ae,fe)=>{ae.stopPropagation(),O.current.delete(fe),await Xe(fe)},He=async ae=>{const fe=await we(`/api/provider-auth/${ae}/status`);if(!fe.ok)return"error";const Ie=await fe.json();return C(gt=>({...gt,[ae]:Ie.state})),Ie.state},ut=async(ae,fe)=>{ae.stopPropagation(),S(fe),C(Ie=>({...Ie,[fe]:"pending"})),j(!1),L(!1);try{const Ie=await we(`/api/provider-auth/${fe}/login`,{method:"POST"});if(!Ie.ok)throw new Error("Unable to start provider sign-in");const gt=await Ie.json();v({providerId:fe,...gt})}catch{C(Ie=>({...Ie,[fe]:"error"}))}finally{S(null)}},re=async()=>{var ae;b!=null&&b.userCode&&(await((ae=navigator.clipboard)==null?void 0:ae.writeText(b.userCode)),T.current!==null&&window.clearTimeout(T.current),j(!1),requestAnimationFrame(()=>j(!0)),T.current=window.setTimeout(()=>{j(!1),T.current=null},1500))},be=()=>{b&&(window.open(b.directUrl??b.verificationUrl,"_blank","noopener,noreferrer"),L(!0))},ke=()=>{v(null),j(!1),L(!1)},ze=async(ae,fe)=>{ae.stopPropagation(),S(fe);try{if(!(await we(`/api/provider-auth/${fe}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");C(gt=>({...gt,[fe]:"disconnected"})),await $()}finally{S(null)}},Ye=(ae,fe)=>{m({providerId:ae,model:fe}),y(!0)},We=p?R.find(ae=>ae.id===p.providerId):void 0,tt=()=>{m(null),y(!1)},_t=async ae=>{try{if(!(await we(`/api/providers/${ae.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(qk(ae))})).ok)throw new Error("Failed to update provider");await Qt.getState().fetchConfig()}catch{}m(null),y(!1)},It=async(ae,fe)=>{if(t){Re.setState(gt=>({currentSession:gt.currentSession?{...gt.currentSession,providerId:ae,providerModel:fe}:null})),n(ae,fe),u([]),a(!1),Pl();return}await Z(ae)&&(u([]),a(!1),Pl())},qt=async(ae,fe,Ie)=>{ae.stopPropagation(),xe(!0);try{await I(fe,Ie)}catch{}finally{xe(!1)}};function dt(ae){return ae.models.some(Ie=>Ie.selected)?ae.models.filter(Ie=>Ie.selected):ae.models}const Cn=A.useMemo(()=>oe.trim()?R.map(ae=>({provider:ae,models:dt(ae).filter(fe=>Q$(fe,oe))})).filter(ae=>ae.models.length>0):R.map(ae=>({provider:ae,models:dt(ae)})),[R,oe]),jt=A.useMemo(()=>Cn.flatMap(ae=>ae.models.map(fe=>({providerId:ae.provider.id,modelConfig:fe}))),[Cn]),Jt=jt.length+1,Mr=M===jt.length;A.useEffect(()=>{Jt===1?W(-1):M>=Jt?W(Jt-1):M<0&&oe.trim()&&W(0)},[Jt,M,oe]);const _e=ae=>{switch(ae.key){case"Escape":a(!1);break;case"ArrowDown":ae.preventDefault(),Jt>0&&W(fe=>fe<Jt-1?fe+1:0);break;case"ArrowUp":ae.preventDefault(),Jt>0&&W(fe=>fe>0?fe-1:Jt-1);break;case"Home":ae.preventDefault(),W(0);break;case"End":ae.preventDefault(),W(Jt-1);break;case"Enter":if(ae.preventDefault(),M===jt.length)e("/onboarding"),a(!1);else if(M>=0&&M<jt.length){const fe=jt[M];fe&&It(fe.providerId,fe.modelConfig.id)}break}};return R.length===0?i.jsxs("button",{type:"button",onClick:()=>Q(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:Me?"LLM server is offline. Click to retry.":te??"Click to refresh model",children:[Me?i.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):i.jsx(US,{activeProvider:Oe,shortModelName:te}),i.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):i.jsxs("div",{className:"relative",ref:f,children:[i.jsxs("button",{type:"button",onClick:()=>a(!r),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[Me?i.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):i.jsx(US,{activeProvider:Oe,shortModelName:te}),i.jsx(Qn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&i.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[i.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[i.jsx(Vi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),i.jsx("input",{ref:Le,type:"text",value:oe,onInput:ae=>{ye(ae.currentTarget.value),W(-1)},onKeyDown:_e,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),i.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:i.jsxs("div",{children:[Cn.map(ae=>{const fe=oe.trim().length>0||l.includes(ae.provider.id);return i.jsxs("div",{children:[i.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${ae.provider.id===K?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${G?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[i.jsxs("div",{onClick:()=>!G&&ce(ae.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[i.jsx("span",{className:`text-sm font-medium truncate ${ae.provider.id===K?"text-accent-primary":"text-text-primary"}`,children:ae.provider.name}),i.jsx("span",{className:"text-xs text-text-muted truncate",children:ae.provider.backend!=="unknown"&&t1(ae.provider.backend)})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!ae.provider.authAdapter&&(w[ae.provider.id]==="connected"||ae.provider.credentialRef?i.jsx("button",{type:"button",onClick:Ie=>ze(Ie,ae.provider.id),disabled:_===ae.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-success/40 text-accent-success hover:bg-accent-success/10 disabled:opacity-50",title:"Disconnect provider account",children:"Connected"}):i.jsx("button",{type:"button",onClick:Ie=>ut(Ie,ae.provider.id),disabled:_===ae.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-primary/40 text-accent-primary hover:bg-accent-primary/10 disabled:opacity-50",title:"Connect provider account",children:_===ae.provider.id?"Starting…":w[ae.provider.id]==="error"||w[ae.provider.id]==="expired"?"Retry":"Connect"})),ae.provider.id===K?i.jsx("span",{className:"text-accent-success",title:"Active provider",children:i.jsx(Ir,{className:"w-4 h-4"})}):i.jsx("span",{className:"w-4"}),i.jsx("button",{type:"button",onClick:Ie=>{Ie.stopPropagation(),$e(Ie,ae.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:i.jsx(pd,{className:`w-4 h-4 ${c===ae.provider.id?"animate-spin":""} ${ae.provider.id===P?"text-accent-primary":"text-text-muted"}`})}),i.jsx("button",{type:"button",onClick:Ie=>{Ie.stopPropagation(),de(ae.provider)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:i.jsx(Qn,{className:`w-4 h-4 transition-transform ${fe?"rotate-180":""} ${ae.provider.id===P?"text-accent-primary":"text-text-muted"}`})})]})]}),fe&&i.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:c===ae.provider.id?i.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):ae.models.length>0?ae.models.map(Ie=>{const bn=jt.findIndex(rn=>rn.providerId===ae.provider.id&&rn.modelConfig.id===Ie.id)===M;return i.jsx("div",{ref:bn?z:void 0,children:i.jsx(J$,{providerId:ae.provider.id,modelConfig:Ie,isActive:je(ae.provider.id,Ie.id),isDefault:nt(ae.provider.id,Ie.id),disabled:c==="activating",hasSession:!!t,settingDefault:se,highlighted:bn,onModelClick:It,onSetDefault:qt,onEditModel:Ye})},`${ae.provider.id}/${Ie.id}`)}):i.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},ae.provider.id)}),Cn.length===0&&oe.trim()&&i.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})}),i.jsx("div",{className:`border-t border-border px-3 py-2 ${Mr?"bg-bg-tertiary":""} flex-shrink-0`,children:i.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),b&&i.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 px-4",role:"dialog","aria-modal":"true","aria-labelledby":"provider-device-title",onMouseDown:ae=>{ae.target===ae.currentTarget&&ke()},children:i.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-bg-secondary p-6 shadow-2xl",children:[i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx("h2",{id:"provider-device-title",className:"text-lg font-semibold text-text-primary",children:"Connect provider"}),i.jsx("p",{className:"mt-1 text-sm text-text-muted",children:"Follow the provider instructions to complete authorization."})]}),i.jsx("button",{type:"button",onClick:ke,className:"rounded px-2 py-1 text-xl leading-none text-text-muted hover:bg-bg-tertiary hover:text-text-primary","aria-label":"Close",children:"×"})]}),b.mode!=="browser"?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:re,className:"mt-6 w-full select-all rounded-lg border border-accent-primary/40 bg-bg-primary px-4 py-5 font-mono text-3xl font-semibold tracking-[0.2em] text-accent-primary hover:bg-bg-tertiary",title:"Copy code",children:b.userCode??"Continue"}),i.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:E?"Copied to clipboard":"Click the code to copy it"}),i.jsxs("div",{className:"mt-6 flex gap-3",children:[i.jsx("button",{type:"button",onClick:re,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:E?"Copied":"Copy code"}),i.jsx("button",{type:"button",onClick:be,className:"flex-1 rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})]}),i.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:D?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]}):i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"mt-6 text-sm text-text-secondary leading-relaxed bg-bg-primary p-4 rounded-lg border border-border",children:b.instructions}),i.jsx("div",{className:"mt-6 flex gap-3",children:i.jsx("button",{type:"button",onClick:be,className:"w-full rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:D?"Reopen authorization":"Open authorization"})})]})]})}),p&&x&&i.jsx(Kk,{isOpen:!0,onClose:tt,onSave:_t,initialStep:2,editProvider:{id:p.providerId,name:(We==null?void 0:We.name)??"",url:(We==null?void 0:We.url)??"",backend:(We==null?void 0:We.backend)??"unknown",apiKey:We==null?void 0:We.apiKey,isLocal:We==null?void 0:We.isLocal,thinkingField:We==null?void 0:We.thinkingField,authAdapter:We==null?void 0:We.authAdapter,transportAdapter:We==null?void 0:We.transportAdapter,models:We==null?void 0:We.models},editModelId:p.model.id})]})}function e7(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r===-1)return null;const a=n.slice(r+1);return a.includes(" ")||a.includes(`
|
|
302
|
+
`)||a.includes(" ")?null:{query:a,startIndex:r}}const t7=A.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a},l){const u=e7(t,n),[c,d]=A.useState([]),[f,p]=A.useState(!1),[m,x]=A.useState(0),y=A.useRef(null),w=A.useRef([]),C=A.useRef(0),_=A.useRef([]);A.useEffect(()=>{C.current=m},[m]),A.useEffect(()=>{_.current=c},[c]),A.useEffect(()=>{if(!u){d([]);return}const v=setTimeout(()=>{S(u.query)},150);return()=>clearTimeout(v)},[u==null?void 0:u.query,r]);const S=async v=>{p(!0);try{const E=new URLSearchParams({q:v});r&&E.set("workdir",r);const T=await(await we(`/api/files?${E.toString()}`)).json();d(T),x(0),C.current=0}catch(E){console.error("File search failed:",E),d([])}finally{p(!1)}},b=A.useCallback(v=>{if(!u)return!1;switch(v.key){case"ArrowDown":return v.preventDefault(),x(E=>{var T;const j=Math.min(E+1,_.current.length-1);return w.current[j]&&((T=w.current[j])==null||T.scrollIntoView({block:"nearest"})),j}),C.current=Math.min(C.current+1,_.current.length-1),!0;case"ArrowUp":return v.preventDefault(),x(E=>{var T;const j=Math.max(E-1,0);return w.current[j]&&((T=w.current[j])==null||T.scrollIntoView({block:"nearest"})),j}),C.current=Math.max(C.current-1,0),!0;case"Enter":case"Tab":{const E=_.current;return E[C.current]?(v.preventDefault(),a(E[C.current],u.startIndex),!0):!1}case"Escape":return v.preventDefault(),d([]),!0}return!1},[u,a]);return A.useImperativeHandle(l,()=>({handleKeyDown:b}),[b]),A.useEffect(()=>{if(!u)return;const v=E=>{y.current&&!y.current.contains(E.target)&&d([])};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[u]),u?f?i.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:i.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:i.jsx("div",{className:"p-4 text-center",children:i.jsx(ui,{size:"sm"})})})}):c.length===0?null:i.jsx("div",{ref:y,className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:i.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64 overflow-y-auto",children:i.jsx("ul",{className:"py-1",children:c.map((v,E)=>i.jsxs("li",{ref:j=>{w.current[E]=j},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${E===m?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{u&&a(v,u.startIndex)},children:[v.type==="directory"?i.jsx(Kr,{className:"w-4 h-4 shrink-0"}):i.jsx("span",{className:"w-4 h-4 shrink-0"}),i.jsx("span",{className:"truncate",children:v.path})]},v.path))})})}):null});function n7({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:l,errorMessage:u,setErrorMessage:c,scrollContainerRef:d,sessionId:f,sessionMode:p,showHistory:m,history:x,selectedIndex:y,openHistory:w,closeHistory:C,navigateUp:_,navigateDown:S,selectCurrent:b,isAutoScrollActive:v,setAutoScroll:E,onOpenMessageSearch:j,onOpenCommandsModal:T,onOpenWorkflowsModal:D,onSelectWorkflow:L,onSelectWorkflowWithSubGroup:O,clearInput:M}){const W=A.useRef(null),z=A.useRef(null),R=A.useRef(0),P=A.useRef(0),V=A.useRef(null),G=md(),Z=Re(ce=>ce.stopGeneration),Q=Re(ce=>ce.cancelQueued),U=Re(ce=>ce.queuedMessages),I=Re(ce=>ce.restoredInput),$=Re(ce=>ce.clearRestoredInput),q=Re(ce=>{var de;return(de=ce.currentSession)==null?void 0:de.workdir}),B=Re(ce=>ce.currentSession),ee=A.useRef(!1),{sendMessage:X}=Wk(E);A.useEffect(()=>{var ce;I!==null&&(t(I),$(),(ce=W.current)==null||ce.focus())},[I,t,$]);const ne=A.useCallback(()=>{const ce=W.current;if(!ce)return;const de=e.length>=R.current;R.current=e.length,de||(ce.style.height="auto"),ce.style.height=`${Math.min(200,ce.scrollHeight)}px`},[e]);A.useEffect(()=>{if(!f)return;const ce=`openfox:draft:${f}`,de=localStorage.getItem(ce);de!==null&&t(de)},[f,t]),A.useEffect(()=>{var ce;(ce=W.current)==null||ce.focus(),ne()},[f,ne]),A.useEffect(()=>{if(!f)return;const ce=`openfox:draft:${f}`,de=setTimeout(()=>{e?localStorage.setItem(ce,e):localStorage.removeItem(ce)},500);return()=>clearTimeout(de)},[f,e]),A.useEffect(()=>{ne()},[e,ne]),A.useEffect(()=>{const ce=W.current;if(!ce)return;const de=async $e=>{var re;if(document.activeElement!==ce)return;const He=(re=$e.clipboardData)==null?void 0:re.items;if(!He)return;const ut=[];for(const be of Array.from(He)){let ke=be.getAsFile();if(ke&&B8(ke.type)){if($e.preventDefault(),!ke.name){const ze=P8(ke.type);ke=new File([ke],`pasted-file.${ze}`,{type:ke.type})}await $S(ke,ze=>ut.push(ze),c)}}ut.length>0&&r(be=>[...be,...ut])};return ce.addEventListener("paste",de),()=>ce.removeEventListener("paste",de)},[r,c]);const K=ce=>{ce.preventDefault(),!(!e.trim()&&n.length===0)&&(X(e,n.length>0?n:void 0),M())},F=ce=>{var de;if(!((de=V.current)!=null&&de.handleKeyDown(ce))){if(m)switch(ce.key){case"Enter":{ce.preventDefault();const $e=b();$e&&(t($e),C());return}case"Escape":ce.preventDefault(),C(),G&&Z();return;case"ArrowUp":ce.preventDefault(),_();return;case"ArrowDown":ce.preventDefault(),S();return}if(ce.key==="ArrowUp"&&e.trim()===""&&!m){ce.preventDefault(),w();return}ce.key==="Enter"&&!ce.shiftKey&&(ce.preventDefault(),K(ce))}};async function te(ce,de,$e){const He=[];for(const ut of Array.from(ce))await $S(ut,re=>He.push(re),$e);He.length>0&&de(ut=>[...ut,...He])}const se=A.useCallback(async ce=>{const de=ce.target.files;!de||de.length===0||(c(null),await te(de,r,c),z.current&&(z.current.value=""))},[r,c]),xe=A.useCallback(ce=>{var de;(de=ce.dataTransfer.types)!=null&&de.includes("Files")&&(ce.preventDefault(),ce.stopPropagation(),l(!0))},[l]),oe=A.useCallback(ce=>{ce.preventDefault(),ce.stopPropagation(),l(!1)},[l]),ye=A.useCallback(async ce=>{ce.preventDefault(),ce.stopPropagation(),l(!1),c(null);const de=ce.dataTransfer.files;!de||de.length===0||await te(de,r,c)},[r,l,c]),Le=A.useCallback(ce=>{r(n.filter(de=>de.id!==ce))},[n,r]),Oe=A.useCallback(()=>{var ce;(ce=z.current)==null||ce.click()},[]),Me=()=>{var ce;!e.trim()&&n.length===0||((ce=d.current)==null||ce.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),X(e,n),M())},je=A.useCallback((ce,de)=>{const He=ce.type==="directory"?"/":" ",ut=e.slice(0,de),re=e.slice(P.current),be=`${ut}@${ce.path}${He}${re}`;t(be);const ke=de+ce.path.length+2;P.current=ke,W.current&&(W.current.selectionStart=ke,W.current.selectionEnd=ke,W.current.focus())},[e,t]),nt=A.useCallback(ce=>{const de=ce.target.value;t(de),m&&C(),P.current=ce.target.selectionStart,!ee.current&&f&&de&&B&&B.messages.length===0&&(ee.current=!0,we(`/api/sessions/${f}/warmup`,{method:"POST"}).catch(()=>{}))},[t,m,C,f,B]),Xe=A.useCallback(ce=>{P.current=ce.target.selectionStart},[]),he=A.useCallback(ce=>{P.current=ce.currentTarget.selectionStart},[]);return i.jsxs("form",{onSubmit:K,className:"relative p-2 md:p-4 bg-secondary",children:[G&&i.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:i.jsx(_$,{})}),i.jsxs("div",{className:`absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2 border${v?" border-transparent":" rounded backdrop-blur-xl saturate-150 border-border"}`,children:[i.jsx($g,{isActive:v,onToggle:E,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"}),i.jsxs("button",{type:"button",onClick:j,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:[i.jsx(Vi,{}),"Browse history"]})]}),i.jsx("input",{ref:z,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:se,className:"hidden",multiple:!0}),u&&i.jsx("div",{className:"mb-2 p-2 bg-red-500/10 border border-red-500/50 rounded text-red-300 text-sm",children:u}),n.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(ce=>i.jsx(b$,{attachment:ce,onRemove:Le},ce.id))}),m&&i.jsx(v$,{history:x,selectedIndex:y,onSelect:ce=>{t(ce),C()},onEscape:C,onNavigate:ce=>{ce==="up"?_():S()}}),i.jsx($$,{messages:U,onCancel:Q}),i.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:xe,onDragLeave:oe,onDrop:ye,children:[i.jsxs("div",{className:"relative flex-1 min-w-0",children:[i.jsx("textarea",{id:uk,ref:W,value:e,onChange:nt,onKeyDown:F,onSelect:Xe,onKeyUp:he,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"w-full bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),i.jsx(t7,{ref:V,text:e,cursorPos:P.current,workdir:q,onSelect:je})]}),i.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[G&&i.jsxs("button",{type:"button",onClick:()=>Z(),"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:[i.jsx(Xp,{}),"Abort"]}),i.jsxs("div",{className:"flex items-center",children:[i.jsx("button",{type:"button",onClick:Me,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"}),i.jsx(P$,{onSendCommand:async(ce,de,$e,He)=>{var re;de&&p!==de&&await Re.getState().switchMode(de);const ut=$e&&$e.trim()?`${$e.trim()}
|
|
303
|
+
|
|
304
|
+
${ce}`:ce;(re=d.current)==null||re.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),X(ut,He!=null&&He.length?He:void 0,{messageKind:"command",isSystemGenerated:!0}),M()},onSelectWorkflow:L,onSelectWorkflowWithSubGroup:O,onOpenCommandsManager:T,onOpenWorkflowsManager:D,onAttach:Oe,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),i.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(G$,{}),i.jsx(W$,{})]}),i.jsx(Z$,{})]})]})}function r7(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function Yk(e,t=[]){const n=new Map,r=new Map;for(const f of t)f.type==="message"?n.set(f.message.id,f):f.type==="subagent"&&r.set(f.subAgentId,f);const a=[];let l,u=1,c=null;const d=()=>{if(!c||c.size===0)return;const f=new Map;let p=0;for(const x of e)x.role!=="tool"&&x.contextWindowId===l&&(x.subAgentId&&!f.has(x.subAgentId)&&f.set(x.subAgentId,p),p++);const m=[...c.entries()].sort((x,y)=>(f.get(x[0])??0)-(f.get(y[0])??0));for(const[x,y]of m){const w=r.get(x);(w==null?void 0:w.type)==="subagent"&&w.messages.length===y.messages.length&&w.messages.every((_,S)=>_===y.messages[S])?a.push(w):a.push({type:"subagent",subAgentId:x,subAgentType:y.subAgentType,messages:y.messages})}c=null};for(let f=0;f<e.length;f++){const p=e[f];if(p.role!=="tool")if(p.contextWindowId&&l&&p.contextWindowId!==l&&(d(),u++,a.push({type:"context-divider",windowSequence:u})),l=p.contextWindowId,p.subAgentId&&p.subAgentType){c||(c=new Map);let m=c.get(p.subAgentId);m||(m={subAgentType:p.subAgentType,messages:[]},c.set(p.subAgentId,m)),m.messages.push(p)}else{d();const m=n.get(p.id);(m==null?void 0:m.type)==="message"&&m.message===p?a.push(m):a.push({type:"message",message:p})}}return d(),a}function s7(e){const{year:t,month:n,day:r}=pk(e);return`${t}/${n}/${r} ${Bd(e)}`}function i7(e,t){return e.length<=t?e:e.substring(0,t)+"..."}const a7=10,o7=150;function l7(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 c7(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,a7).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:s7(r.timestamp),trimmedContent:i7(r.content,o7),sessionId:r.sessionId,sessionName:r.sessionName}))}function u7(e,t,n){const r=[],a=e.filter(l=>l.role==="user"&&!l.isSystemGenerated&&l.messageKind!=="auto-prompt");for(const l of a)r.push({id:l.id,content:l.content,timestamp:l.timestamp,sessionId:n??"",sessionName:"This session"});for(const l of t)n&&l.id===n||r.push(...l7(l));return c7(r)}function d7(e,t=[],n=null){const[r,a]=A.useState(0),[l,u]=A.useState(!1),c=A.useMemo(()=>u7(e,t,n),[e,t,n]),d=A.useCallback(()=>{c.length>0&&(a(c.length-1),u(!0))},[c.length]),f=A.useCallback(()=>{u(!1),a(0)},[]),p=A.useCallback(()=>{a(y=>c.length===0?y:y===0?c.length-1:y-1)},[c.length]),m=A.useCallback(()=>{a(y=>c.length===0?y:y===c.length-1?0:y+1)},[c.length]),x=A.useCallback(()=>{if(c.length===0||!l)return null;const y=c[r];return(y==null?void 0:y.content)??null},[c,r,l]);return{history:c,selectedIndex:r,showHistory:l,openHistory:d,closeHistory:f,navigateUp:p,navigateDown:m,selectCurrent:x}}A.memo(function({item:t}){const[n,r]=A.useState(!1);return t.type==="start"?i.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:[i.jsx("span",{className:"animate-pulse",children:"●"}),i.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&i.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):i.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[i.jsx("span",{className:"text-accent-success",children:"✓"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),i.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&&i.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:i.jsx(Bn,{content:t.description})})]})]})});function h7({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r}={}){const a=e??!0,[l,u]=A.useState(""),[c,d]=A.useState([]),[f,p]=A.useState(!1),[m,x]=A.useState(null),[y,w]=A.useState(!1),[C,_]=A.useState(!1),[S,b]=A.useState(!1),[v,E]=A.useState(!1),[j,T]=A.useState(null),D=A.useRef(null),L=Re(he=>he.currentSession),O=Re(he=>he.messages),M=Re(he=>he.sessions),W=md(),z=Re(he=>he.stopGeneration),R=n??O,{maxVisibleItems:P}=Ki(),V=mt(he=>he.defaults),G=mt(he=>he.userItems),Z=[...V,...G].filter(he=>!he.subagent),{history:Q,selectedIndex:U,showHistory:I,openHistory:$,closeHistory:q,navigateUp:B,navigateDown:ee,selectCurrent:X}=d7(R,M,L==null?void 0:L.id);A.useEffect(()=>{const he=ce=>{T(ce.detail.stats)};return window.addEventListener("open-turn-stats",he),()=>window.removeEventListener("open-turn-stats",he)},[]),A.useEffect(()=>{Ot.getState().fetchWorkflows()},[]),A.useEffect(()=>{const he=ce=>{r7(ce)&&(ce.preventDefault(),E(!0))};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[]);const ne=A.useRef([]),{displayItems:K,hiddenCount:F}=A.useMemo(()=>{const he=Yk(R,ne.current);return ne.current=he,P>0&&he.length>P?{displayItems:he.slice(-P),hiddenCount:he.length-P}:{displayItems:he,hiddenCount:0}},[R,P]),te=r??F,{isAutoScrollActive:se,setAutoScroll:xe}=$d(D,L),{sendMessage:oe,launchWorkflow:ye}=Wk(xe),Le=A.useCallback((he,ce)=>{ye(void 0,void 0,he,ce)},[ye]),Oe=A.useCallback(he=>{xe(!1);const ce=document.querySelector(`[data-item-index="${he}"]`);ce&&ce.scrollIntoView({behavior:"smooth",block:"center"})},[xe]);A.useEffect(()=>{const he=ce=>{const de=S||y||C||v||j;ce.key==="Escape"&&W&&!de&&z(),ce.key==="ScrollLock"&&xe(!se)};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[W,z,se,S,y,C,v,j]);const Me=zl();jl(Me.quickAction,()=>{b(!0)}),jl(Me.criteriaSidebar,()=>{t==null||t()}),XN(Me.agentSwitching,Z,he=>{Re.getState().switchMode(he)});const je=he=>{const ce=l.trim()?l:void 0,de=c.length>0?c:void 0;ye(ce,de,he),Xe()},nt=(he,ce)=>{const de=l.trim()?l:void 0,$e=c.length>0?c:void 0;ye(de,$e,he,ce),Xe()},Xe=()=>{u(""),d([]),L!=null&&L.id&&localStorage.removeItem(`openfox:draft:${L.id}`)};return i.jsxs(i.Fragment,{children:[i.jsxs($B,{criteriaSidebarOpen:a,onCriteriaSidebarToggle:t,messages:R,children:[i.jsx(UB,{}),j&&i.jsx(FB,{stats:j,onClose:()=>T(null)}),i.jsx(X8,{}),i.jsx(K8,{displayItems:K,scrollContainerRef:D,highlightedMessageId:null,onLaunchWorkflow:Le,hiddenCount:te}),i.jsx(n7,{input:l,setInput:u,attachments:c,setAttachments:d,dragOver:f,setDragOver:p,errorMessage:m,setErrorMessage:x,scrollContainerRef:D,sessionId:L==null?void 0:L.id,sessionMode:L==null?void 0:L.mode,showHistory:I,history:Q,selectedIndex:U,openHistory:$,closeHistory:q,navigateUp:B,navigateDown:ee,selectCurrent:X,isAutoScrollActive:se,setAutoScroll:xe,onOpenMessageSearch:()=>E(!0),onOpenCommandsModal:()=>w(!0),onOpenWorkflowsModal:()=>_(!0),onSelectWorkflow:je,onSelectWorkflowWithSubGroup:nt,clearInput:Xe}),i.jsx(zk,{isOpen:y,onClose:()=>w(!1)}),i.jsx(Fk,{isOpen:C,onClose:()=>_(!1)}),i.jsx(c$,{isOpen:S,onClose:()=>b(!1),onSearchMessages:()=>E(!0),isAutoScrollActive:se,onToggleAutoScroll:xe,textareaContent:l,onCloseComplete:Pl,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(he,ce)=>{const de=await mn.getState().fetchCommand(he);if(de){const $e=ce!=null&&ce.trim()?`${ce.trim()}
|
|
305
|
+
|
|
306
|
+
${de.prompt}`:de.prompt;de.metadata.agentMode&&await Re.getState().switchMode(de.metadata.agentMode),oe($e,c!=null&&c.length?c:void 0,{messageKind:"command",isSystemGenerated:!0}),Xe()}},onSelectWorkflow:he=>{const ce=l.trim()||void 0,de=c.length>0?c:void 0;ye(ce,de,he),Xe()}})]}),v&&i.jsx(y$,{isOpen:v,onClose:()=>{E(!1),Pl(!0)},displayItems:K,onNavigate:Oe})]})}function f7(){var v;const[,e]=ro("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=A.useState(null),[a,l]=A.useState([]),[u,c]=A.useState(0),[d,f]=A.useState(!0),[p,m]=A.useState(null),x=async()=>{if(t){f(!0),m(null);try{const E=await we(`/api/sessions/${t}?full=true`);if(!E.ok){m(`Failed to load session (${E.status})`),f(!1);return}const j=await E.json();r(j.session??null),l(j.messages??[]),c(j.hiddenCount??0)}catch(E){m(E instanceof Error?E.message:"Unknown error")}finally{f(!1)}}};A.useEffect(()=>{Gt.getState().getSettings([...Wp])},[]),A.useEffect(()=>{x()},[t]);const{showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S}=Ki(),b=A.useMemo(()=>Yk(a),[a]);return d?i.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:i.jsx(ui,{})}):p?i.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:i.jsxs("div",{className:"text-center space-y-4",children:[i.jsx("div",{className:"text-red-400 text-sm",children:p}),i.jsx("button",{onClick:x,className:"px-3 py-1.5 text-sm bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors",children:"Retry"})]})}):i.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((v=n==null?void 0:n.metadata)==null?void 0:v.title)??"Session"," — Read-only view"]}),i.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[a.length," messages",u>0?` (${u} older hidden)`:""]})]}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("button",{onClick:x,disabled:d,className:"px-3 py-1 text-xs bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors disabled:opacity-50",children:d?"Refreshing...":"Refresh"})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto print:overflow-visible scrollbar-stable",children:[i.jsx("div",{className:"pt-4",children:i.jsx(Bk,{displayItems:b,showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S})}),i.jsx("div",{className:"h-8"})]})]})}function FS({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,l]=A.useState(""),u=A.useRef(null);A.useEffect(()=>{e&&(l(""),setTimeout(()=>{var d;return(d=u.current)==null?void 0:d.focus()},100))},[e]);const c=d=>{d.preventDefault(),a.trim()&&n(a)};return i.jsx(wt,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.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."}),i.jsx(ai,{ref:u,type:"password",value:a,onChange:d=>l(d.target.value),placeholder:"Enter password",autoFocus:!0}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Je,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),i.jsx(Je,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function m7({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return i.jsx("div",{className:"flex justify-center py-6",children:i.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,l)=>{const u=l+1,c=u<e,d=u===e;return i.jsxs("div",{className:"flex items-center",children:[i.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`size-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors shrink-0 ${c?"bg-accent-primary text-text-primary hover:opacity-80":d?"bg-accent-primary text-text-primary":"bg-bg-tertiary text-text-muted"}`,children:c?"✓":u}),i.jsx("button",{onClick:()=>r==null?void 0:r(u),className:`ml-2 mr-4 text-sm whitespace-nowrap hidden sm:block ${d?"text-text-primary font-medium":"text-text-muted hover:text-text-secondary"}`,children:n[l]}),l<t-1&&i.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${c?"bg-accent-primary":"bg-border"}`})]},l)})})})}function p7({onNext:e}){const[t,n]=A.useState([]),[r,a]=A.useState([]),[l,u]=A.useState(!1),[c,d]=A.useState(null),[f,p]=A.useState(null),[m,x]=A.useState(null);A.useEffect(()=>{y()},[]);async function y(){try{const j=await we("/api/providers");if(j.ok){const D=(await j.json()).providers.map(L=>({id:L.id,name:L.name,url:L.url,backend:L.backend,model:null,apiKey:L.apiKey,isLocal:L.isLocal,thinkingField:L.thinkingField,models:L.models}));n(D),a(D)}}catch{}}async function w(j){const T=j.id.startsWith("temp-"),D=r.some(M=>M.id===j.id),L=r.length===0&&c===null,O=qk(j);try{let M;if(T){const z=await we("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!z.ok)throw new Error("Failed to create provider");const R=await z.json();M={...j,id:R.provider.id,model:null}}else{if(!(await we(`/api/providers/${j.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).ok)throw new Error("Failed to update provider");M={...j,model:null}}const W=z=>z.some(R=>R.id===M.id)?z.map(R=>R.id===M.id?M:R):[...z,M];a(W),n(W),L&&!D&&e({providers:[M]})}catch{if(T){const M={...j,model:null};a(W=>[...W,M])}}}function C(){d(null),u(!0)}function _(j){d(j),u(!0)}function S(){u(!1),d(null)}function b(j){p(j),t.some(D=>D.id===j)?we(`/api/providers/${j}`,{method:"DELETE"}).then(()=>{a(r.filter(D=>D.id!==j)),n(t.filter(D=>D.id!==j)),p(null)}).catch(()=>p(null)):(a(r.filter(D=>D.id!==j)),p(null))}function v(){const j=r.filter(T=>!T.id.startsWith("temp-"));e({providers:j})}const E=r.length>0;return i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),i.jsxs("div",{className:"space-y-4",children:[r.length>0?i.jsx("div",{className:"space-y-2",children:r.map(j=>i.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:t1(j.backend)}),i.jsx("span",{className:"text-text-primary font-medium",children:j.name}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${j.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:j.isLocal?"local":"api"})]}),i.jsx("p",{className:"text-text-muted text-sm mt-1 truncate",children:j.url}),j.model&&i.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",j.model]})]}),i.jsx("div",{className:"flex items-center gap-1",children:m===j.id?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>b(j.id),disabled:f===j.id,className:"px-2 py-1 text-xs text-red-500 hover:text-red-400 bg-red-500/10 rounded transition-colors disabled:opacity-50",children:f===j.id?"Deleting...":"Confirm"}),i.jsx("button",{onClick:()=>x(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>_(j),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary border border-border rounded transition-colors",children:"Edit"}),i.jsx("button",{onClick:()=>x(j.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:i.jsx(so,{})})]})})]},j.id))}):i.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:i.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),i.jsxs("button",{onClick:C,"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:[i.jsx(ks,{className:"w-4 h-4"}),"Add Provider"]}),i.jsx("button",{onClick:v,disabled:!E,"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"})]}),i.jsx(Kk,{isOpen:l,onClose:S,onSave:w,initialStep:1,editProvider:c??void 0})]})}function g7({onNext:e}){const[t,n]=A.useState(""),[r,a]=A.useState(!1);return A.useEffect(()=>{we("/api/config").then(l=>l.json()).then(l=>{l.workdir?n(l.workdir):fetch(Cs("/api/directories?path=")+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&n(u.current)}).catch(()=>{})}).catch(()=>{fetch(Cs("/api/directories?path=")+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})})},[]),i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",value:t,onChange:l=>n(l.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"}),i.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&i.jsx(xd,{initialPath:t||void 0,onSelect:l=>{n(l),a(!1)},onClose:()=>a(!1)}),i.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 x7({onNext:e}){const[t,n]=A.useState(!1),[r,a]=A.useState("http://localhost:11434"),[l,u]=A.useState("qwen3.5:0.8b"),[c,d]=A.useState("ollama"),{copied:f,copy:p}=ik();A.useEffect(()=>{we("/api/config").then(x=>x.json()).then(x=>{x.visionFallback&&(n(x.visionFallback.enabled),a(x.visionFallback.url),u(x.visionFallback.model),x.visionFallback.backend&&d(x.visionFallback.backend))}).catch(()=>{})},[]);function m(x){if(x){e({});return}e({visionFallback:{enabled:t,url:r,model:l,timeout:120,backend:c}})}return i.jsxs("div",{className:"max-w-xl mx-auto",children:[i.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),i.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[i.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"You need a server with a vision model. Choose your backend type below."}),i.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),i.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),i.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[i.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),i.jsx("button",{onClick:()=>p("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:f?i.jsx(Ir,{className:"w-4 h-4 text-accent-primary"}):i.jsx(LN,{className:"w-4 h-4"})})]}),i.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",i.jsx("strong",{children:"OpenAI"})," backend type."]})]}),i.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t,onChange:x=>n(x.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),i.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),t&&i.jsxs("div",{className:"space-y-4 pl-8",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),i.jsxs("select",{value:c,onChange:x=>d(x.target.value),className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[i.jsx("option",{value:"ollama",children:"Ollama"}),i.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),i.jsx("input",{type:"text",value:r,onChange:x=>a(x.target.value),placeholder:c==="ollama"?"http://localhost:11434":"http://localhost:8000/v1",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"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),i.jsx("input",{type:"text",value:l,onChange:x=>u(x.target.value),placeholder:c==="ollama"?"qwen3.5:0.8b":"qwen3.5-27b",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"})]})]}),i.jsxs("div",{className:"flex items-center justify-between pt-4",children:[i.jsx("button",{onClick:()=>m(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),i.jsx("button",{onClick:()=>m(!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 y7({onComplete:e}){const[t,n]=A.useState(1),[r,a]=A.useState(!1),[l,u]=A.useState({});async function c(m){u(x=>({...x,providers:m.providers})),n(2)}async function d(m){u(x=>({...x,...m})),n(3)}async function f(m){a(!0);try{if(!(await we("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:l.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(x){console.error("Failed to save onboarding data:",x),a(!1)}}const p=m=>{n(m)};return i.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[i.jsx(Yl,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),i.jsx(m7,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:p}),i.jsx("div",{className:"max-w-xl mx-auto",children:r?i.jsxs("div",{className:"text-center",children:[i.jsx(ks,{className:"w-6 h-6"}),i.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):i.jsxs(i.Fragment,{children:[t===1&&i.jsx(p7,{onNext:c}),t===2&&i.jsx(g7,{onNext:d}),t===3&&i.jsx(x7,{onNext:f})]})})]})}function b7({projectId:e}){var p;const[,t]=zn(),n=Re(m=>m.sessionsWithPendingConfirmations),r=Re(m=>{var x;return(x=m.currentSession)==null?void 0:x.id}),a=Re(m=>m.crossSessionConfirmations),l=Re(m=>m.sessions),u=n.find(m=>m!==r);if(!u)return null;const c=l.find(m=>m.id===u),d=(c==null?void 0:c.title)??u.slice(0,6),f=((p=a[u])==null?void 0:p.length)??0;return i.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 cursor-pointer hover:bg-amber-500/20 transition-colors",onClick:()=>t(e?`/p/${e}/s/${u}`:`/s/${u}`),role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&t(e?`/p/${e}/s/${u}`:`/s/${u}`)},children:[i.jsx(Yp,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),i.jsxs("span",{className:"text-sm text-amber-300 flex-1 truncate",children:[f," confirmation",f>1?"s":"",' pending in session "',d,'"']}),i.jsx("span",{className:"text-xs text-amber-400 font-medium flex-shrink-0",children:"View session →"})]})}const tp="openfox_updated_to",np="update_pending";function v7(){const[e,t]=A.useState(!1),n=localStorage.getItem(tp),r=localStorage.getItem(np);A.useEffect(()=>{if(!n||!r)return;const l=setTimeout(()=>{localStorage.removeItem(tp),localStorage.removeItem(np),t(!0)},8e3);return()=>clearTimeout(l)},[n,r]);const a=()=>{localStorage.removeItem(tp),localStorage.removeItem(np),t(!0)};return e||r!=="true"||!n?null:i.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:[i.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:i.jsx(Ir,{className:"w-3 h-3 text-accent-primary"})}),i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),i.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),i.jsx("button",{onClick:a,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:i.jsx(Qp,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Rt.getState().loadUserPresets(),Rt.getState().applySavedTheme());function Vg(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function Xk(){return i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsx(ui,{})})}function _7({sidebarOpen:e,onSidebarToggle:t}){const[,n]=ro("/p/:projectId"),r=n==null?void 0:n.projectId,a=Re(d=>d.connectionStatus),l=Ht(d=>d.currentProject),u=Vg();return EN({canLoad:a==="connected"||u,projectId:r,currentProjectId:l==null?void 0:l.id}),!l||l.id!==r?i.jsx(Xk,{}):i.jsxs(i.Fragment,{children:[i.jsx(bk,{projectId:r,isOpen:e,onClose:t}),i.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:i.jsx(q6,{})})]})}function S7({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=ro("/p/:projectId/s/:sessionId"),l=a==null?void 0:a.projectId,u=a==null?void 0:a.sessionId,[,c]=zn(),d=Re(C=>C.connectionStatus),f=Re(C=>C.currentSession),p=Re(C=>C.error),m=Re(C=>C.clearError),x=Ht(C=>C.currentProject),y=Vg();return jN({canLoad:d==="connected"||y,projectId:l,sessionId:u,currentProjectId:x==null?void 0:x.id,currentSessionId:f==null?void 0:f.id}),A.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&l&&(m(),c(`/p/${l}`))},[p,l,m,c]),!x||x.id!==l?i.jsx(Xk,{}):i.jsxs(i.Fragment,{children:[i.jsx(bk,{projectId:l,isOpen:e,onClose:t}),i.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[i.jsx(b7,{projectId:l}),i.jsx(h7,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function w7(){const e=Qt(r=>r.fetchConfig),[,t]=zn();async function n(){await e(),t("/")}return i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsx(y7,{onComplete:n})})}function C7(){const{connectionStatus:e}=vN(),t=Qt(I=>I.fetchConfig),n=Qt(I=>I.refreshProviderModels),r=Qt(I=>I.providers),a=Qt(I=>I.activeProviderId),[,l]=zn(),u=Vg(),[c,d]=A.useState(!1);A.useEffect(()=>{(e==="connected"||u)&&t().then(()=>{d(!0),Gt.getState().getSettings([...Wp,De.DISPLAY_THEME,De.DISPLAY_USER_PRESETS,De.KEYBINDINGS])})},[e,u,t]),A.useEffect(()=>{c&&a&&n(a).then(()=>{const I=Qt.getState().defaultModelSelection;(I?I.split("/")[0]:null)!==a&&t()})},[c,a,n,t]);const f=Gt(I=>I.settings);A.useEffect(()=>{c&&r.length===0&&l("/onboarding")},[c,r.length]),A.useEffect(()=>{const{applyPreset:I,applyTokens:$,setFollowSystemTheme:q,initSystemThemeListener:B}=Rt.getState(),ee=f[De.DISPLAY_THEME],X=f[De.DISPLAY_USER_PRESETS],ne=f[De.DISPLAY_FOLLOW_SYSTEM_THEME];if(X&&localStorage.setItem("openfox:userPresets",X),ee){localStorage.setItem("openfox:theme",ee);try{const F=JSON.parse(ee);F.preset&&F.tokens?(I(F.preset),Rt.setState({basePreset:F.preset}),$(F.tokens)):F.preset?I(F.preset):F.tokens&&$(F.tokens)}catch{I("dark")}}else I("system");ne!==void 0&&Rt.getState().followSystemTheme!==(ne==="true")&&q(ne==="true");const K=B();return()=>K()},[f[De.DISPLAY_THEME],f[De.DISPLAY_USER_PRESETS]]);const[p,m]=A.useState(!1);A.useEffect(()=>{if(localStorage.getItem("update_pending")!=="true")return;const $=Gt.getState().settings[De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];$!==void 0&&$!=="false"&&m(!0)},[f[De.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]]);const x=()=>{const I=localStorage.getItem("openfox:leftSidebar");return I!==null?I==="true":!0},y=()=>{const I=localStorage.getItem("openfox:rightSidebar");return I!==null?I==="true":!0},[w,C]=A.useState(x),[_,S]=A.useState(y),[b,v]=A.useState(!1),[E,j]=A.useState(!1),[T,D]=A.useState(!1),L=Yj();A.useEffect(()=>{const I=()=>{D(window.innerWidth<768)};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]);const[O]=zn(),M=/^\/p\/[^/]+$/.test(O),W=T?b:M?!0:w,z=T?E:_,R=()=>{T?v(!b):C(!w)},P=()=>{T?j(!E):S(!_)};A.useEffect(()=>{T||localStorage.setItem("openfox:leftSidebar",String(w))},[w,T]),A.useEffect(()=>{T||localStorage.setItem("openfox:rightSidebar",String(_))},[_,T]),A.useEffect(()=>{(e==="connected"||u)&&t()},[e,t,u]);const V=Re(I=>I.showPasswordModal),G=Re(I=>I.passwordModalRetry),Z=Re(I=>I.submitPassword),Q=Re(I=>I.cancelPassword),[U]=ro("/p/:projectId/s/:sessionId/readonly");return!U&&e!=="connected"&&!V&&!u?i.jsxs(i.Fragment,{children:[i.jsx(FS,{isOpen:!0,isRetry:G,onSubmit:Z,onCancel:Q}),i.jsx("div",{className:"h-screen flex items-center justify-center",children:i.jsx(sT,{text:"Connecting to server..."})})]}):U?i.jsx(f7,{}):i.jsxs(i.Fragment,{children:[i.jsx(FS,{isOpen:V,isRetry:G,onSubmit:Z,onCancel:Q}),i.jsxs("div",{className:"flex flex-col",style:{height:T?`calc(${L.offsetTop}px + ${L.height}px)`:"100vh"},children:[i.jsx(F6,{}),i.jsx(I6,{onMenuClick:R,onCriteriaToggle:P}),i.jsx("div",{className:"flex-1 flex overflow-hidden",children:i.jsxs(Vj,{children:[i.jsx(sl,{path:"/onboarding",children:i.jsx(w7,{})}),i.jsx(sl,{path:"/p/:projectId/s/:sessionId",children:i.jsx(S7,{sidebarOpen:W,onSidebarToggle:R,rightSidebarOpen:z,onRightSidebarToggle:P})}),i.jsx(sl,{path:"/p/:projectId/new",children:i.jsx(W6,{})}),i.jsx(sl,{path:"/p/:projectId",children:i.jsx(_7,{sidebarOpen:W,onSidebarToggle:R})}),i.jsx(sl,{path:"/",children:i.jsx(G6,{})})]})})]}),i.jsx(v7,{}),i.jsx(ak,{isOpen:p,onClose:()=>m(!1)})]})}wj.createRoot(document.getElementById("root")).render(i.jsx(ri.StrictMode,{children:i.jsx(JS,{base:e1,children:i.jsx(C7,{})})}));
|